@camstack/server 1.2.788 → 1.2.789

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 (27) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +2 -53
  3. package/system/dist/addon-utils.mjs +1 -1
  4. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +3 -3
  5. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +4 -4
  6. package/system/dist/builtins/alerts/alerts.addon.mjs +2 -2
  7. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +4 -4
  8. package/system/dist/builtins/local-auth/local-auth.addon.mjs +3 -3
  9. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +9 -9
  10. package/system/dist/builtins/platform-probe/index.mjs +9 -9
  11. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +19 -19
  12. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  13. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  14. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +1 -1
  15. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +1 -1
  16. package/system/dist/builtins/system-config/system-config.addon.mjs +282 -282
  17. package/system/dist/{coral-accelerators-BW3OcrLD.mjs → coral-accelerators-DBlgWB8k.mjs} +6 -6
  18. package/system/dist/{custom-action-registry-N7flBDwT.mjs → custom-action-registry-B9zFBNVa.mjs} +37 -37
  19. package/system/dist/file-host-worker.js +1 -1
  20. package/system/dist/file-host-worker.mjs +1 -1
  21. package/system/dist/index.js +1 -1
  22. package/system/dist/index.mjs +213 -213
  23. package/system/dist/migrations/hub/2026-11-06-addon-settings-bare-rows.d.ts +3 -0
  24. package/system/dist/{restore-archive-Co2lk3OU.mjs → restore-archive-vn4co_kf.mjs} +149 -149
  25. package/system/dist/{wal-maintenance-DRnV6QYu.mjs → wal-maintenance-CadfiGWy.mjs} +0 -0
  26. package/system/dist/{wal-maintenance-C1Haue74.js → wal-maintenance-sSlXJm4k.js} +0 -0
  27. package/system/package.json +1 -1
@@ -25,7 +25,7 @@ import { LokiDestination, LokiLoggingAddon } from "./builtins/loki-logging/index
25
25
  import NativeMetricsAddon, { a as NativeMetricsProvider, i as parseProcStatusRss, n as nodeProcReader, r as parseProcStat } from "./builtins/native-metrics/native-metrics.addon.mjs";
26
26
  import { DeviceHistoryAddon } from "./builtins/device-history/device-history.addon.mjs";
27
27
  import { FilesystemStorageAddon, t as FilesystemStorageProvider } from "./builtins/sqlite-storage/filesystem-storage.addon.mjs";
28
- import { D as RecordsEngine, l as SqliteSettingsBackend } from "./wal-maintenance-DRnV6QYu.mjs";
28
+ import { D as RecordsEngine, l as SqliteSettingsBackend } from "./wal-maintenance-CadfiGWy.mjs";
29
29
  import { n as clearLegacyIntegrationRows, o as readLegacyIntegrationRows } from "./legacy-integration-rows-door-CjXTbmvH.mjs";
30
30
  import { SqliteSettingsAddon } from "./builtins/sqlite-storage/sqlite-settings.addon.mjs";
31
31
  import { ConfigStore, DeviceStore } from "./builtins/sqlite-storage/index.mjs";
@@ -36,18 +36,18 @@ import { a as MESH_CA_KEY_REF, i as MESH_CA_FIELD, n as DEFAULT_HUB_TLS_TCP_PORT
36
36
  import { $ as caFingerprintCompact, A as getProcessNodeMeshTransport, B as MESH_NODE_CERTIFICATES_COLLECTION, C as MESH_TLS_PORT_HELLO_FIELD, Ct as readOriginSetting, D as setProcessMeshTlsEnabler, Dt as readCidrSetting, E as ServiceBroker, Et as parseCidrList, F as renewMeshCertificate, G as getProcessMeshCertificateRegistry, H as MeshCertificateRegistry, I as revokeMeshCertificate, J as processMeshCrl, K as setProcessMeshCertificateRegistry, L as getProcessMeshTlsListenerState, M as isProcessVerifiedMeshPeer, N as onProcessNodeRegistered, O as dropProcessPeer, P as setProcessMeshPeerTransportLookup, Q as caFingerprint, R as openMeshTlsWhenRevocationsLoaded, S as verifyMembershipAnswer, St as parseOriginList, SystemConfigAddon, T as Errors, Tt as normalizeIp, U as RENEWAL_ABANDONED, V as MESH_NODE_CERTIFICATES_COLUMNS, W as describeMeshLeaf, X as getProcessMeshCaState, Y as MeshCaKeeper, Z as requireProcessMeshCa, _ as signPairingProof, _t as verifyAgentUiUnlockTicket, a as hubHostFromMeshAddress, at as issueMeshLeafForNode, b as MembershipResponder, bt as isInsecureOrigin, c as PAIRING_MAX_SESSIONS, ct as AGENT_DASHBOARD_ORIGINS_FIELD, d as PAIRING_PROTOCOL, dt as AGENT_UI_UNLOCK_USE, et as createMeshCsrPem, f as PAIRING_TTL_MS, ft as AGENT_UI_UNLOCK_VERSION, g as keyFingerprintShort, gt as parseAgentDashboardOrigins, h as describeCsr, ht as mintAgentUiUnlockTicket, i as AgentPairing, it as isValidAgentNodeId, j as getProcessPeerLeaf, k as emitProcessNodeRegistered, l as PAIRING_PATHS, lt as AGENT_UI_UNLOCK_TTL_MS, m as computePairingSas, mt as isAllowedAgentDashboardReturnTo, n as HubPairing, nt as generateMeshCa, o as PAIRING_CODE_DIGITS, ot as issueMeshLeafFromCsr, p as computePairingCommitment, pt as UnlockTicketJtiStore, q as MeshCrl, r as PairingHttpError, rt as generateMeshKeyPair, s as PAIRING_MAX_CODE_ATTEMPTS, st as loadMeshCa, tt as exportMeshPrivateKeyPem, u as PAIRING_PIN_DIGITS, ut as AGENT_UI_UNLOCK_TYP, v as verifyPairingProof, vt as InvalidCorsOriginError, w as TlsTcpTransporter, wt as createCidrMatcher, x as signMembershipProof, xt as normalizeOrigin, y as MEMBERSHIP_PATHS, yt as OPAQUE_ORIGIN, z as setProcessMeshTlsListenerState } from "./builtins/system-config/system-config.addon.mjs";
37
37
  import "./builtins/system-config/index.mjs";
38
38
  import { WinstonDestination, WinstonLoggingAddon } from "./builtins/winston-logging/index.mjs";
39
- 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";
39
+ 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";
40
40
  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-8dJTW2LI.mjs";
41
41
  import { n as getPlatformKeychainKey, r as setPlatformKeychainKey, t as clearPlatformKeychainKey } from "./platform-key-source-BWlq0jjn.mjs";
42
42
  import { n as getSinglePidStats, t as getPidStats } from "./resource-monitor-Di9daRwI.mjs";
43
- 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-Co2lk3OU.mjs";
44
- import { r as nodeCoralFs, t as classifyCoralAccelerator } from "./coral-accelerators-BW3OcrLD.mjs";
43
+ 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-vn4co_kf.mjs";
44
+ import { r as nodeCoralFs, t as classifyCoralAccelerator } from "./coral-accelerators-DBlgWB8k.mjs";
45
45
  import { z } from "zod";
46
46
  import * as crypto$1 from "node:crypto";
47
47
  import { createHash, randomBytes, randomUUID } from "node:crypto";
48
48
  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, installPythonPackages, installPythonPackages as installPythonPackages$1, installPythonRequirements, installPythonRequirements as installPythonRequirements$1 } from "@camstack/types/node";
49
49
  import { connect, createConnection, createServer } from "node:net";
50
- import * as fs from "node:fs";
50
+ import * as fs$1 from "node:fs";
51
51
  import { accessSync, constants, createReadStream, createWriteStream, existsSync, readFileSync, readdirSync } from "node:fs";
52
52
  import * as path$1 from "node:path";
53
53
  import { basename, dirname, isAbsolute, join, resolve } from "node:path";
@@ -5020,7 +5020,7 @@ var PythonEnvManager = class {
5020
5020
  async ensure(options) {
5021
5021
  const probe = await this.probe();
5022
5022
  if (!probe.available || !probe.path) throw userError("system.python-required", void 0, "Python 3.10+ is required but not found on this system");
5023
- if (!fs.existsSync(path$1.join(this.venvPath, "bin", "python"))) await execFileAsync$7(probe.path, [
5023
+ if (!fs$1.existsSync(path$1.join(this.venvPath, "bin", "python"))) await execFileAsync$7(probe.path, [
5024
5024
  "-m",
5025
5025
  "venv",
5026
5026
  this.venvPath
@@ -5043,7 +5043,7 @@ var PythonEnvManager = class {
5043
5043
  }
5044
5044
  spawn(script, args) {
5045
5045
  const venvPython = path$1.join(this.venvPath, "bin", "python");
5046
- if (!fs.existsSync(venvPython)) throw new Error("Python venv not initialized. Call ensure() first.");
5046
+ if (!fs$1.existsSync(venvPython)) throw new Error("Python venv not initialized. Call ensure() first.");
5047
5047
  return spawn(venvPython, [script, ...args]);
5048
5048
  }
5049
5049
  };
@@ -5395,20 +5395,20 @@ var StorageManager = class {
5395
5395
  const basePath = this.locationManager.getBackend(mappedName).basePath;
5396
5396
  location.files = {
5397
5397
  async readFile(p) {
5398
- return fs.promises.readFile(path$1.join(basePath, p));
5398
+ return fs$1.promises.readFile(path$1.join(basePath, p));
5399
5399
  },
5400
5400
  async writeFile(p, data) {
5401
5401
  const full = path$1.join(basePath, p);
5402
- await fs.promises.mkdir(path$1.dirname(full), { recursive: true });
5403
- await fs.promises.writeFile(full, data);
5402
+ await fs$1.promises.mkdir(path$1.dirname(full), { recursive: true });
5403
+ await fs$1.promises.writeFile(full, data);
5404
5404
  },
5405
5405
  async deleteFile(p) {
5406
- await fs.promises.rm(path$1.join(basePath, p), { force: true });
5406
+ await fs$1.promises.rm(path$1.join(basePath, p), { force: true });
5407
5407
  },
5408
5408
  async listFiles(prefix) {
5409
5409
  const dir = prefix ? path$1.join(basePath, prefix) : basePath;
5410
5410
  try {
5411
- return (await fs.promises.readdir(dir)).map((f) => prefix ? `${prefix}/${f}` : f);
5411
+ return (await fs$1.promises.readdir(dir)).map((f) => prefix ? `${prefix}/${f}` : f);
5412
5412
  } catch {
5413
5413
  return [];
5414
5414
  }
@@ -5418,7 +5418,7 @@ var StorageManager = class {
5418
5418
  },
5419
5419
  async exists(p) {
5420
5420
  try {
5421
- await fs.promises.access(path$1.join(basePath, p));
5421
+ await fs$1.promises.access(path$1.join(basePath, p));
5422
5422
  return true;
5423
5423
  } catch {
5424
5424
  return false;
@@ -5868,7 +5868,7 @@ var TRADITIONAL_NATIVE_PACKAGES = ["better-sqlite3"];
5868
5868
  function hasDotNode(dir, maxDepth) {
5869
5869
  let entries;
5870
5870
  try {
5871
- entries = fs.readdirSync(dir, { withFileTypes: true });
5871
+ entries = fs$1.readdirSync(dir, { withFileTypes: true });
5872
5872
  } catch {
5873
5873
  return false;
5874
5874
  }
@@ -5879,7 +5879,7 @@ function hasDotNode(dir, maxDepth) {
5879
5879
  }
5880
5880
  /** Locate the bundled `prebuild-install` bin.js inside the staged closure. */
5881
5881
  function resolvePrebuildInstallBin(closureDir, moduleDir) {
5882
- 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;
5882
+ 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;
5883
5883
  }
5884
5884
  /**
5885
5885
  * Default fetcher: run the closure's own `prebuild-install` under the CURRENT
@@ -5932,7 +5932,7 @@ async function ensureNativePrebuilds(closureDir, options) {
5932
5932
  const fetched = [];
5933
5933
  for (const pkg of packages) {
5934
5934
  const moduleDir = path$1.join(nm, pkg);
5935
- if (!fs.existsSync(moduleDir)) continue;
5935
+ if (!fs$1.existsSync(moduleDir)) continue;
5936
5936
  if (hasDotNode(moduleDir, 4)) continue;
5937
5937
  options.logger.warn("staged closure native prebuild missing — fetching for running ABI", { meta: {
5938
5938
  pkg,
@@ -5995,12 +5995,12 @@ async function ensureNativePrebuilds(closureDir, options) {
5995
5995
  function replantFromBundled(srcModuleDir, dstModuleDir, hasNative) {
5996
5996
  if (!hasNative(srcModuleDir)) return false;
5997
5997
  try {
5998
- fs.rmSync(dstModuleDir, {
5998
+ fs$1.rmSync(dstModuleDir, {
5999
5999
  recursive: true,
6000
6000
  force: true
6001
6001
  });
6002
- fs.mkdirSync(path$1.dirname(dstModuleDir), { recursive: true });
6003
- fs.cpSync(srcModuleDir, dstModuleDir, {
6002
+ fs$1.mkdirSync(path$1.dirname(dstModuleDir), { recursive: true });
6003
+ fs$1.cpSync(srcModuleDir, dstModuleDir, {
6004
6004
  recursive: true,
6005
6005
  dereference: true
6006
6006
  });
@@ -6029,7 +6029,7 @@ async function ensureAddonNativePrebuilds(addonDir, options) {
6029
6029
  const missing = [];
6030
6030
  for (const pkg of packages) {
6031
6031
  const moduleDir = path$1.join(nm, pkg);
6032
- if (!fs.existsSync(moduleDir)) continue;
6032
+ if (!fs$1.existsSync(moduleDir)) continue;
6033
6033
  if (hasNative(moduleDir)) {
6034
6034
  results.push({
6035
6035
  pkg,
@@ -6128,7 +6128,7 @@ async function defaultDownloadTarball(url, destTgz) {
6128
6128
  const res = await fetch(url);
6129
6129
  if (!res.ok || !res.body) throw new Error(`HTTP ${res.status} downloading ${url}`);
6130
6130
  const bytes = Buffer.from(await res.arrayBuffer());
6131
- await fs.promises.writeFile(destTgz, bytes);
6131
+ await fs$1.promises.writeFile(destTgz, bytes);
6132
6132
  }
6133
6133
  async function defaultExtractTarball(tgzPath, destDir) {
6134
6134
  await execFileAsync$5("tar", [
@@ -6214,7 +6214,7 @@ async function resolveUncached(options) {
6214
6214
  argsPrefix: []
6215
6215
  };
6216
6216
  const cliPath = bootstrappedCliPath(options.cacheDir);
6217
- if (fs.existsSync(cliPath)) {
6217
+ if (fs$1.existsSync(cliPath)) {
6218
6218
  options.logger.info("system npm unavailable — using bootstrapped npm", { meta: { cliPath } });
6219
6219
  return {
6220
6220
  command: process.execPath,
@@ -6226,12 +6226,12 @@ async function resolveUncached(options) {
6226
6226
  const registry = (options.registry ?? DEFAULT_REGISTRY$1).replace(/\/+$/, "");
6227
6227
  const tarballUrl = tarballUrlOf(await (options.fetchJson ?? defaultFetchJson)(`${registry}/npm/latest`));
6228
6228
  if (!tarballUrl) throw new Error(`registry metadata for 'npm' carries no dist.tarball (${registry})`);
6229
- await fs.promises.mkdir(options.cacheDir, { recursive: true });
6229
+ await fs$1.promises.mkdir(options.cacheDir, { recursive: true });
6230
6230
  const tgzPath = path$1.join(options.cacheDir, "npm-bootstrap.tgz");
6231
6231
  await (options.downloadTarball ?? defaultDownloadTarball)(tarballUrl, tgzPath);
6232
6232
  await (options.extractTarball ?? defaultExtractTarball)(tgzPath, options.cacheDir);
6233
- await fs.promises.rm(tgzPath, { force: true });
6234
- if (!fs.existsSync(cliPath)) throw new Error(`extracted npm tarball is missing ${cliPath}`);
6233
+ await fs$1.promises.rm(tgzPath, { force: true });
6234
+ if (!fs$1.existsSync(cliPath)) throw new Error(`extracted npm tarball is missing ${cliPath}`);
6235
6235
  options.logger.info("npm bootstrapped", { meta: { cliPath } });
6236
6236
  return {
6237
6237
  command: process.execPath,
@@ -6297,7 +6297,7 @@ function readOwningPackageVersion(entryPath) {
6297
6297
  let dir = path$1.dirname(entryPath);
6298
6298
  for (let hop = 0; hop < PACKAGE_JSON_LOOKUP_DEPTH; hop++) {
6299
6299
  try {
6300
- const version = asJsonObject$1(parseJsonUnknown(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8")))?.["version"];
6300
+ const version = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8")))?.["version"];
6301
6301
  if (typeof version === "string" && version.length > 0) return version;
6302
6302
  } catch {}
6303
6303
  const parent = path$1.dirname(dir);
@@ -6341,14 +6341,14 @@ function readOwningPackageVersion(entryPath) {
6341
6341
  function addonModuleCacheKey(entryPath) {
6342
6342
  let stat;
6343
6343
  try {
6344
- stat = fs.statSync(entryPath);
6344
+ stat = fs$1.statSync(entryPath);
6345
6345
  } catch {
6346
6346
  return null;
6347
6347
  }
6348
6348
  const version = readOwningPackageVersion(entryPath) ?? `m${stat.mtimeMs}`;
6349
6349
  let content;
6350
6350
  try {
6351
- content = createHash("sha1").update(fs.readFileSync(entryPath)).digest("hex").slice(0, 16);
6351
+ content = createHash("sha1").update(fs$1.readFileSync(entryPath)).digest("hex").slice(0, 16);
6352
6352
  } catch {
6353
6353
  content = `m${stat.mtimeMs}s${stat.size}`;
6354
6354
  }
@@ -6452,14 +6452,14 @@ var AddonLoader = class {
6452
6452
  * BUILTINS from the active closure, not the (now-inert) addons-dir copy, so
6453
6453
  * the addons-dir `@camstack/server/system` must NOT be double-loaded here. */
6454
6454
  async loadFromDirectory(addonsDir, skipPackages = []) {
6455
- if (!fs.existsSync(addonsDir)) return;
6455
+ if (!fs$1.existsSync(addonsDir)) return;
6456
6456
  const skip = new Set(skipPackages);
6457
- const entries = fs.readdirSync(addonsDir, { withFileTypes: true });
6457
+ const entries = fs$1.readdirSync(addonsDir, { withFileTypes: true });
6458
6458
  for (const entry of entries) {
6459
6459
  if (!isDirectoryEntry(entry, addonsDir)) continue;
6460
6460
  if (entry.name.startsWith("@")) {
6461
6461
  const scopeDir = path$1.join(addonsDir, entry.name);
6462
- const scopeEntries = fs.readdirSync(scopeDir, { withFileTypes: true });
6462
+ const scopeEntries = fs$1.readdirSync(scopeDir, { withFileTypes: true });
6463
6463
  for (const scopeEntry of scopeEntries) {
6464
6464
  if (!isDirectoryEntry(scopeEntry, scopeDir)) continue;
6465
6465
  if (skip.has(`${entry.name}/${scopeEntry.name}`)) continue;
@@ -6473,7 +6473,7 @@ var AddonLoader = class {
6473
6473
  }
6474
6474
  async tryLoadAddon(addonDir) {
6475
6475
  const pkgJsonPath = path$1.join(addonDir, "package.json");
6476
- if (!fs.existsSync(pkgJsonPath)) return;
6476
+ if (!fs$1.existsSync(pkgJsonPath)) return;
6477
6477
  try {
6478
6478
  await this.loadFromAddonDir(addonDir);
6479
6479
  } catch (err) {
@@ -6491,7 +6491,7 @@ var AddonLoader = class {
6491
6491
  /** Load addon from a specific directory (package.json + dist/) */
6492
6492
  async loadFromAddonDir(addonDir) {
6493
6493
  const pkgJsonPath = path$1.join(addonDir, "package.json");
6494
- const pkgJson = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8"))) ?? {};
6494
+ const pkgJson = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(pkgJsonPath, "utf-8"))) ?? {};
6495
6495
  const packageNameRaw = pkgJson["name"];
6496
6496
  const packageName = typeof packageNameRaw === "string" ? packageNameRaw : "";
6497
6497
  const packageVersionRaw = pkgJson["version"];
@@ -6539,7 +6539,7 @@ var AddonLoader = class {
6539
6539
  }
6540
6540
  const entryFile = declaration.entry.replace(/^\.\//, "").replace(/^src\//, "dist/").replace(/\.ts$/, ".js");
6541
6541
  let entryPath = path$1.resolve(addonDir, entryFile);
6542
- if (!fs.existsSync(entryPath)) {
6542
+ if (!fs$1.existsSync(entryPath)) {
6543
6543
  const base = entryPath.replace(/\.(js|cjs|mjs)$/, "");
6544
6544
  entryPath = [
6545
6545
  `${base}.cjs`,
@@ -6548,9 +6548,9 @@ var AddonLoader = class {
6548
6548
  path$1.resolve(addonDir, "dist", "index.cjs"),
6549
6549
  path$1.resolve(addonDir, "dist", "index.mjs"),
6550
6550
  path$1.resolve(addonDir, declaration.entry)
6551
- ].find((p) => fs.existsSync(p)) ?? entryPath;
6551
+ ].find((p) => fs$1.existsSync(p)) ?? entryPath;
6552
6552
  }
6553
- if (!fs.existsSync(entryPath)) throw new Error(`Entry not found: ${entryPath}`);
6553
+ if (!fs$1.existsSync(entryPath)) throw new Error(`Entry not found: ${entryPath}`);
6554
6554
  const modUnknown = await importAddonModuleFresh(entryPath);
6555
6555
  const mod = isRecord$4(modUnknown) ? modUnknown : {};
6556
6556
  const AddonClass = resolveAddonClass(mod);
@@ -6662,7 +6662,7 @@ function isDirectoryEntry(entry, parentDir) {
6662
6662
  if (entry.name.startsWith(".")) return false;
6663
6663
  if (entry.isDirectory()) return true;
6664
6664
  if (entry.isSymbolicLink()) try {
6665
- return fs.statSync(path$1.join(parentDir, entry.name)).isDirectory();
6665
+ return fs$1.statSync(path$1.join(parentDir, entry.name)).isDirectory();
6666
6666
  } catch {
6667
6667
  return false;
6668
6668
  }
@@ -6756,7 +6756,7 @@ var execFileAsync$4 = promisify(execFile);
6756
6756
  * Single source of truth — replaces scattered mkdirSync calls.
6757
6757
  */
6758
6758
  function ensureDir(dirPath) {
6759
- fs.mkdirSync(dirPath, { recursive: true });
6759
+ fs$1.mkdirSync(dirPath, { recursive: true });
6760
6760
  }
6761
6761
  /**
6762
6762
  * Copy a directory recursively — ASYNC so it never blocks the event loop.
@@ -6769,7 +6769,7 @@ function ensureDir(dirPath) {
6769
6769
  * `fs.promises.cp` keeps the I/O off the event loop. (Node ≥18 stable.)
6770
6770
  */
6771
6771
  async function copyDirRecursive(src, dest) {
6772
- await fs.promises.cp(src, dest, {
6772
+ await fs$1.promises.cp(src, dest, {
6773
6773
  recursive: true,
6774
6774
  force: true
6775
6775
  });
@@ -6874,13 +6874,13 @@ async function copyExtraFileDirs(pkgJson, sourceDir, destDir) {
6874
6874
  if (typeof fileEntry !== "string") continue;
6875
6875
  if (fileEntry === "dist" || fileEntry.includes("*")) continue;
6876
6876
  const srcPath = path$1.join(sourceDir, fileEntry);
6877
- if (!fs.existsSync(srcPath)) continue;
6877
+ if (!fs$1.existsSync(srcPath)) continue;
6878
6878
  const destPath = path$1.join(destDir, fileEntry);
6879
- const stat = await fs.promises.stat(srcPath);
6879
+ const stat = await fs$1.promises.stat(srcPath);
6880
6880
  if (stat.isDirectory()) await copyDirRecursive(srcPath, destPath);
6881
6881
  else if (stat.isFile()) {
6882
6882
  ensureDir(path$1.dirname(destPath));
6883
- await fs.promises.copyFile(srcPath, destPath);
6883
+ await fs$1.promises.copyFile(srcPath, destPath);
6884
6884
  }
6885
6885
  }
6886
6886
  }
@@ -6891,10 +6891,10 @@ async function copyExtraFileDirs(pkgJson, sourceDir, destDir) {
6891
6891
  function isSourceNewer(packageDir) {
6892
6892
  const srcDir = path$1.join(packageDir, "src");
6893
6893
  const distDir = path$1.join(packageDir, "dist");
6894
- if (!fs.existsSync(srcDir) || !fs.existsSync(distDir)) return true;
6894
+ if (!fs$1.existsSync(srcDir) || !fs$1.existsSync(distDir)) return true;
6895
6895
  try {
6896
- const distMtime = fs.statSync(distDir).mtimeMs;
6897
- const entries = fs.readdirSync(srcDir, {
6896
+ const distMtime = fs$1.statSync(distDir).mtimeMs;
6897
+ const entries = fs$1.readdirSync(srcDir, {
6898
6898
  withFileTypes: true,
6899
6899
  recursive: true
6900
6900
  });
@@ -6902,7 +6902,7 @@ function isSourceNewer(packageDir) {
6902
6902
  if (!entry.isFile()) continue;
6903
6903
  const parentDir = entry.parentPath ?? String(Reflect.get(entry, "path") ?? "");
6904
6904
  const filePath = path$1.join(parentDir, entry.name);
6905
- if (fs.statSync(filePath).mtimeMs > distMtime) return true;
6905
+ if (fs$1.statSync(filePath).mtimeMs > distMtime) return true;
6906
6906
  }
6907
6907
  return false;
6908
6908
  } catch {
@@ -6919,7 +6919,7 @@ function isSourceNewer(packageDir) {
6919
6919
  * `copyDirRecursive` for the wedge this prevents.
6920
6920
  */
6921
6921
  async function installPackageFromNpm(packageName, targetDir) {
6922
- const tmpDir = await fs.promises.mkdtemp(path$1.join(os$1.tmpdir(), "camstack-install-"));
6922
+ const tmpDir = await fs$1.promises.mkdtemp(path$1.join(os$1.tmpdir(), "camstack-install-"));
6923
6923
  try {
6924
6924
  const { stdout } = await execFileAsync$4("npm", [
6925
6925
  "pack",
@@ -6942,21 +6942,21 @@ async function installPackageFromNpm(packageName, targetDir) {
6942
6942
  extractDir
6943
6943
  ], { timeout: 3e4 });
6944
6944
  const packageSubDir = path$1.join(extractDir, "package");
6945
- const srcPkgJsonDir = fs.existsSync(path$1.join(packageSubDir, "package.json")) ? packageSubDir : extractDir;
6946
- await fs.promises.rm(targetDir, {
6945
+ const srcPkgJsonDir = fs$1.existsSync(path$1.join(packageSubDir, "package.json")) ? packageSubDir : extractDir;
6946
+ await fs$1.promises.rm(targetDir, {
6947
6947
  recursive: true,
6948
6948
  force: true
6949
6949
  });
6950
6950
  ensureDir(targetDir);
6951
- await fs.promises.copyFile(path$1.join(srcPkgJsonDir, "package.json"), path$1.join(targetDir, "package.json"));
6951
+ await fs$1.promises.copyFile(path$1.join(srcPkgJsonDir, "package.json"), path$1.join(targetDir, "package.json"));
6952
6952
  const distSrc = path$1.join(srcPkgJsonDir, "dist");
6953
- if (fs.existsSync(distSrc)) await copyDirRecursive(distSrc, path$1.join(targetDir, "dist"));
6953
+ if (fs$1.existsSync(distSrc)) await copyDirRecursive(distSrc, path$1.join(targetDir, "dist"));
6954
6954
  try {
6955
- const npmPkg = asJsonObject$1(parseJsonUnknown(await fs.promises.readFile(path$1.join(srcPkgJsonDir, "package.json"), "utf-8")));
6955
+ const npmPkg = asJsonObject$1(parseJsonUnknown(await fs$1.promises.readFile(path$1.join(srcPkgJsonDir, "package.json"), "utf-8")));
6956
6956
  if (npmPkg) await copyExtraFileDirs(npmPkg, srcPkgJsonDir, targetDir);
6957
6957
  } catch {}
6958
6958
  } finally {
6959
- await fs.promises.rm(tmpDir, {
6959
+ await fs$1.promises.rm(tmpDir, {
6960
6960
  recursive: true,
6961
6961
  force: true
6962
6962
  });
@@ -6981,7 +6981,7 @@ function packageDirName$1(declaredName) {
6981
6981
  }
6982
6982
  function isDirLike$1(p) {
6983
6983
  try {
6984
- return fs.statSync(p).isDirectory();
6984
+ return fs$1.statSync(p).isDirectory();
6985
6985
  } catch {
6986
6986
  return false;
6987
6987
  }
@@ -6999,12 +6999,12 @@ var AddonManifest = class {
6999
6999
  */
7000
7000
  read() {
7001
7001
  if (this.cache != null) return this.cache;
7002
- if (!fs.existsSync(this.manifestPath)) {
7002
+ if (!fs$1.existsSync(this.manifestPath)) {
7003
7003
  this.cache = this.empty();
7004
7004
  return this.cache;
7005
7005
  }
7006
7006
  try {
7007
- const raw = fs.readFileSync(this.manifestPath, "utf-8");
7007
+ const raw = fs$1.readFileSync(this.manifestPath, "utf-8");
7008
7008
  const parsed = JSON.parse(raw);
7009
7009
  if (parsed.version !== MANIFEST_VERSION) {
7010
7010
  process.stderr.write(`[AddonManifest] schema mismatch (file=${parsed.version} vs runtime=${MANIFEST_VERSION}); starting empty\n`);
@@ -7025,13 +7025,13 @@ var AddonManifest = class {
7025
7025
  * a half-written file.
7026
7026
  */
7027
7027
  write(manifest) {
7028
- fs.mkdirSync(path$1.dirname(this.manifestPath), { recursive: true });
7028
+ fs$1.mkdirSync(path$1.dirname(this.manifestPath), { recursive: true });
7029
7029
  const tmp = `${this.manifestPath}.tmp.${process.pid}.${Date.now()}`;
7030
- fs.writeFileSync(tmp, JSON.stringify(manifest, null, 2), {
7030
+ fs$1.writeFileSync(tmp, JSON.stringify(manifest, null, 2), {
7031
7031
  encoding: "utf-8",
7032
7032
  mode: 384
7033
7033
  });
7034
- fs.renameSync(tmp, this.manifestPath);
7034
+ fs$1.renameSync(tmp, this.manifestPath);
7035
7035
  this.cache = manifest;
7036
7036
  }
7037
7037
  /** Lookup a single addon's manifest entry, or `null` if not tracked. */
@@ -7106,22 +7106,22 @@ var AddonManifest = class {
7106
7106
  * exactly what moved. Returns the total number of changes.
7107
7107
  */
7108
7108
  reconcileFromDisk(addonsDir, onChange) {
7109
- if (!fs.existsSync(addonsDir)) return 0;
7109
+ if (!fs$1.existsSync(addonsDir)) return 0;
7110
7110
  const m = this.read();
7111
7111
  let changes = 0;
7112
7112
  const now = (/* @__PURE__ */ new Date()).toISOString();
7113
7113
  /** Package name → version, for every ADDON package actually installed. */
7114
7114
  const onDisk = /* @__PURE__ */ new Map();
7115
- for (const scope of fs.readdirSync(addonsDir, { withFileTypes: true })) {
7115
+ for (const scope of fs$1.readdirSync(addonsDir, { withFileTypes: true })) {
7116
7116
  if (!scope.name.startsWith("@") || !isDirLike$1(path$1.join(addonsDir, scope.name))) continue;
7117
7117
  const scopeDir = path$1.join(addonsDir, scope.name);
7118
- for (const pkg of fs.readdirSync(scopeDir, { withFileTypes: true })) {
7118
+ for (const pkg of fs$1.readdirSync(scopeDir, { withFileTypes: true })) {
7119
7119
  if (!isDirLike$1(path$1.join(scopeDir, pkg.name))) continue;
7120
7120
  const pkgJsonPath = path$1.join(scopeDir, pkg.name, "package.json");
7121
- if (!fs.existsSync(pkgJsonPath)) continue;
7121
+ if (!fs$1.existsSync(pkgJsonPath)) continue;
7122
7122
  let pkgJson;
7123
7123
  try {
7124
- const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
7124
+ const parsed = JSON.parse(fs$1.readFileSync(pkgJsonPath, "utf-8"));
7125
7125
  if (typeof parsed !== "object" || parsed == null) continue;
7126
7126
  pkgJson = parsed;
7127
7127
  } catch {
@@ -7192,28 +7192,28 @@ var AddonManifest = class {
7192
7192
  migrateFromInstallSourceMarkers(addonsDir) {
7193
7193
  const m = this.read();
7194
7194
  if (Object.keys(m.addons).length > 0) return 0;
7195
- if (!fs.existsSync(addonsDir)) return 0;
7195
+ if (!fs$1.existsSync(addonsDir)) return 0;
7196
7196
  let migrated = 0;
7197
7197
  const now = (/* @__PURE__ */ new Date()).toISOString();
7198
- for (const scope of fs.readdirSync(addonsDir, { withFileTypes: true })) {
7198
+ for (const scope of fs$1.readdirSync(addonsDir, { withFileTypes: true })) {
7199
7199
  if (!scope.isDirectory() || !scope.name.startsWith("@")) continue;
7200
7200
  const scopeDir = path$1.join(addonsDir, scope.name);
7201
- for (const pkg of fs.readdirSync(scopeDir, { withFileTypes: true })) {
7201
+ for (const pkg of fs$1.readdirSync(scopeDir, { withFileTypes: true })) {
7202
7202
  if (!pkg.isDirectory()) continue;
7203
7203
  const pkgDir = path$1.join(scopeDir, pkg.name);
7204
7204
  const markerPath = path$1.join(pkgDir, ".install-source");
7205
7205
  const pkgJsonPath = path$1.join(pkgDir, "package.json");
7206
- if (!fs.existsSync(pkgJsonPath)) continue;
7206
+ if (!fs$1.existsSync(pkgJsonPath)) continue;
7207
7207
  let pkgJson;
7208
7208
  try {
7209
- const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
7209
+ const parsed = JSON.parse(fs$1.readFileSync(pkgJsonPath, "utf-8"));
7210
7210
  if (typeof parsed !== "object" || parsed == null) continue;
7211
7211
  pkgJson = parsed;
7212
7212
  } catch {
7213
7213
  continue;
7214
7214
  }
7215
7215
  if (!pkgJson.name || !pkgJson.version) continue;
7216
- const source = fs.existsSync(markerPath) ? fs.readFileSync(markerPath, "utf-8").trim() : "bundled";
7216
+ const source = fs$1.existsSync(markerPath) ? fs$1.readFileSync(markerPath, "utf-8").trim() : "bundled";
7217
7217
  m.addons[pkgJson.name] = {
7218
7218
  name: pkgJson.name,
7219
7219
  version: pkgJson.version,
@@ -7417,7 +7417,7 @@ function planClosureDedupe(input) {
7417
7417
  function readTreeManifest(pkgJsonPath) {
7418
7418
  let raw;
7419
7419
  try {
7420
- raw = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8")));
7420
+ raw = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(pkgJsonPath, "utf-8")));
7421
7421
  } catch {
7422
7422
  return null;
7423
7423
  }
@@ -7442,7 +7442,7 @@ function readTreeManifest(pkgJsonPath) {
7442
7442
  function listTopLevelEntries(nodeModulesDir) {
7443
7443
  let entries;
7444
7444
  try {
7445
- entries = fs.readdirSync(nodeModulesDir, { withFileTypes: true });
7445
+ entries = fs$1.readdirSync(nodeModulesDir, { withFileTypes: true });
7446
7446
  } catch {
7447
7447
  return [];
7448
7448
  }
@@ -7452,7 +7452,7 @@ function listTopLevelEntries(nodeModulesDir) {
7452
7452
  if (entry.name.startsWith("@")) {
7453
7453
  let inner;
7454
7454
  try {
7455
- inner = fs.readdirSync(path$1.join(nodeModulesDir, entry.name), { withFileTypes: true });
7455
+ inner = fs$1.readdirSync(path$1.join(nodeModulesDir, entry.name), { withFileTypes: true });
7456
7456
  } catch {
7457
7457
  continue;
7458
7458
  }
@@ -7485,14 +7485,14 @@ function collectAddonTreeState(addonDir) {
7485
7485
  const entryDir = path$1.join(nodeModulesDir, name);
7486
7486
  let isLink = false;
7487
7487
  try {
7488
- isLink = fs.lstatSync(entryDir).isSymbolicLink();
7488
+ isLink = fs$1.lstatSync(entryDir).isSymbolicLink();
7489
7489
  } catch {
7490
7490
  continue;
7491
7491
  }
7492
7492
  if (isLink) {
7493
7493
  let target = "";
7494
7494
  try {
7495
- target = fs.readlinkSync(entryDir);
7495
+ target = fs$1.readlinkSync(entryDir);
7496
7496
  } catch {}
7497
7497
  existingLinks.push({
7498
7498
  name,
@@ -7506,7 +7506,7 @@ function collectAddonTreeState(addonDir) {
7506
7506
  version: manifest.version
7507
7507
  });
7508
7508
  for (const [depName, range] of manifest.ranges) {
7509
- if (fs.existsSync(path$1.join(entryDir, "node_modules", depName))) continue;
7509
+ if (fs$1.existsSync(path$1.join(entryDir, "node_modules", depName))) continue;
7510
7510
  addRange(depName, range);
7511
7511
  }
7512
7512
  }
@@ -7536,7 +7536,7 @@ function resolveClosureNodeModulesDir(explicitDir) {
7536
7536
  const frameworkDir = explicitDir ?? process.env["CAMSTACK_FRAMEWORK_DIR"];
7537
7537
  if (frameworkDir === void 0 || frameworkDir.length === 0) return null;
7538
7538
  const nodeModulesDir = explicitDir ?? path$1.join(frameworkDir, "node_modules");
7539
- return fs.existsSync(nodeModulesDir) ? nodeModulesDir : null;
7539
+ return fs$1.existsSync(nodeModulesDir) ? nodeModulesDir : null;
7540
7540
  }
7541
7541
  function symlinkType() {
7542
7542
  return process.platform === "win32" ? "junction" : "dir";
@@ -7555,10 +7555,10 @@ function executeClosureDedupe(addonDir, closureNodeModulesDir, plan, logger) {
7555
7555
  const nodeModulesDir = path$1.join(addonDir, "node_modules");
7556
7556
  const probePath = path$1.join(nodeModulesDir, ".closure-link-probe");
7557
7557
  try {
7558
- fs.mkdirSync(nodeModulesDir, { recursive: true });
7559
- fs.rmSync(probePath, { force: true });
7560
- fs.symlinkSync(closureNodeModulesDir, probePath, symlinkType());
7561
- fs.rmSync(probePath, { force: true });
7558
+ fs$1.mkdirSync(nodeModulesDir, { recursive: true });
7559
+ fs$1.rmSync(probePath, { force: true });
7560
+ fs$1.symlinkSync(closureNodeModulesDir, probePath, symlinkType());
7561
+ fs$1.rmSync(probePath, { force: true });
7562
7562
  } catch (err) {
7563
7563
  logger.warn("closure dedupe skipped — symlinks unavailable on this volume", { meta: {
7564
7564
  addonDir,
@@ -7580,12 +7580,12 @@ function executeClosureDedupe(addonDir, closureNodeModulesDir, plan, logger) {
7580
7580
  }
7581
7581
  const entryDir = path$1.join(nodeModulesDir, link.name);
7582
7582
  try {
7583
- fs.rmSync(entryDir, {
7583
+ fs$1.rmSync(entryDir, {
7584
7584
  recursive: true,
7585
7585
  force: true
7586
7586
  });
7587
- fs.mkdirSync(path$1.dirname(entryDir), { recursive: true });
7588
- fs.symlinkSync(target, entryDir, symlinkType());
7587
+ fs$1.mkdirSync(path$1.dirname(entryDir), { recursive: true });
7588
+ fs$1.symlinkSync(target, entryDir, symlinkType());
7589
7589
  linked.push(link.name);
7590
7590
  } catch (err) {
7591
7591
  logger.warn("closure dedupe — link failed; entry removed copy may need reinstall", { meta: {
@@ -7661,7 +7661,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry, npm
7661
7661
  count: Object.keys(native).length
7662
7662
  } });
7663
7663
  try {
7664
- fs.writeFileSync(markerFile, markerHash);
7664
+ fs$1.writeFileSync(markerFile, markerHash);
7665
7665
  } catch (err) {
7666
7666
  logger.warn("Failed to write native deps marker", { meta: {
7667
7667
  markerFile,
@@ -7699,7 +7699,7 @@ async function installManifestNativeDeps(addonDir, pkgRaw, logger, registry, npm
7699
7699
  }
7700
7700
  await rebuildNativeDeps(addonDir, pending.map(([name]) => name), logger, npmCacheDir ?? defaultNpmCacheDir(), registry);
7701
7701
  try {
7702
- fs.writeFileSync(markerFile, markerHash);
7702
+ fs$1.writeFileSync(markerFile, markerHash);
7703
7703
  } catch (err) {
7704
7704
  logger.warn("Failed to write native deps marker", { meta: {
7705
7705
  markerFile,
@@ -7721,12 +7721,12 @@ function copyPrebuiltNativeDep(name, addonDir, logger) {
7721
7721
  if (source === target) continue;
7722
7722
  if (!hasBuiltBinary(source)) continue;
7723
7723
  try {
7724
- fs.rmSync(target, {
7724
+ fs$1.rmSync(target, {
7725
7725
  recursive: true,
7726
7726
  force: true
7727
7727
  });
7728
- fs.mkdirSync(path$1.dirname(target), { recursive: true });
7729
- fs.cpSync(source, target, {
7728
+ fs$1.mkdirSync(path$1.dirname(target), { recursive: true });
7729
+ fs$1.cpSync(source, target, {
7730
7730
  recursive: true,
7731
7731
  dereference: true
7732
7732
  });
@@ -7762,7 +7762,7 @@ var BUNDLED_NATIVE_SIBLING_SCOPES = {
7762
7762
  function hasAnyDotNode(dir, maxDepth) {
7763
7763
  let entries;
7764
7764
  try {
7765
- entries = fs.readdirSync(dir, { withFileTypes: true });
7765
+ entries = fs$1.readdirSync(dir, { withFileTypes: true });
7766
7766
  } catch {
7767
7767
  return false;
7768
7768
  }
@@ -7776,12 +7776,12 @@ function copyPrebuiltModuleDir(src, dst, label, logger) {
7776
7776
  if (!hasAnyDotNode(src, 5)) return;
7777
7777
  if (hasAnyDotNode(dst, 5)) return;
7778
7778
  try {
7779
- fs.rmSync(dst, {
7779
+ fs$1.rmSync(dst, {
7780
7780
  recursive: true,
7781
7781
  force: true
7782
7782
  });
7783
- fs.mkdirSync(path$1.dirname(dst), { recursive: true });
7784
- fs.cpSync(src, dst, {
7783
+ fs$1.mkdirSync(path$1.dirname(dst), { recursive: true });
7784
+ fs$1.cpSync(src, dst, {
7785
7785
  recursive: true,
7786
7786
  dereference: true
7787
7787
  });
@@ -7816,7 +7816,7 @@ function copyPrebuiltModuleDir(src, dst, label, logger) {
7816
7816
  */
7817
7817
  function copyBundledNativeModules(sourceDir, targetDir, logger) {
7818
7818
  const srcNm = path$1.join(sourceDir, "node_modules");
7819
- if (!fs.existsSync(srcNm)) return;
7819
+ if (!fs$1.existsSync(srcNm)) return;
7820
7820
  const dstNm = path$1.join(targetDir, "node_modules");
7821
7821
  for (const [name, scopes] of Object.entries(BUNDLED_NATIVE_SIBLING_SCOPES)) {
7822
7822
  copyPrebuiltModuleDir(path$1.join(srcNm, name), path$1.join(dstNm, name), name, logger);
@@ -7824,7 +7824,7 @@ function copyBundledNativeModules(sourceDir, targetDir, logger) {
7824
7824
  const scopeSrc = path$1.join(srcNm, scope);
7825
7825
  let siblings;
7826
7826
  try {
7827
- siblings = fs.readdirSync(scopeSrc);
7827
+ siblings = fs$1.readdirSync(scopeSrc);
7828
7828
  } catch {
7829
7829
  continue;
7830
7830
  }
@@ -7834,12 +7834,12 @@ function copyBundledNativeModules(sourceDir, targetDir, logger) {
7834
7834
  }
7835
7835
  /** A package dir is "built" when it carries a compiled `.node` or a prebuilds tree. */
7836
7836
  function hasBuiltBinary(pkgDir) {
7837
- if (!fs.existsSync(path$1.join(pkgDir, "package.json"))) return false;
7837
+ if (!fs$1.existsSync(path$1.join(pkgDir, "package.json"))) return false;
7838
7838
  const releaseDir = path$1.join(pkgDir, "build", "Release");
7839
7839
  try {
7840
- if (fs.existsSync(releaseDir) && fs.readdirSync(releaseDir).some((f) => f.endsWith(".node"))) return true;
7840
+ if (fs$1.existsSync(releaseDir) && fs$1.readdirSync(releaseDir).some((f) => f.endsWith(".node"))) return true;
7841
7841
  } catch {}
7842
- return fs.existsSync(path$1.join(pkgDir, "prebuilds"));
7842
+ return fs$1.existsSync(path$1.join(pkgDir, "prebuilds"));
7843
7843
  }
7844
7844
  /** Candidate hoisted locations for `<name>`: NODE_PATH entries + ancestors of `addonDir`. */
7845
7845
  function candidateHoistedDirs(name, addonDir) {
@@ -7877,7 +7877,7 @@ function hashDeclaration(deps) {
7877
7877
  }
7878
7878
  function markerMatches(markerFile, expected) {
7879
7879
  try {
7880
- return fs.readFileSync(markerFile, "utf-8").trim() === expected;
7880
+ return fs$1.readFileSync(markerFile, "utf-8").trim() === expected;
7881
7881
  } catch {
7882
7882
  return false;
7883
7883
  }
@@ -8088,7 +8088,7 @@ function parseInstallSource(value) {
8088
8088
  function readPackageJson(pkgJsonPath) {
8089
8089
  let raw;
8090
8090
  try {
8091
- raw = asJsonObject$1(parseJsonUnknown(fs.readFileSync(pkgJsonPath, "utf-8")));
8091
+ raw = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(pkgJsonPath, "utf-8")));
8092
8092
  } catch {
8093
8093
  return null;
8094
8094
  }
@@ -8132,7 +8132,7 @@ var REGISTRY_LATEST_TIMEOUT_MS = 15e3;
8132
8132
  var FALLBACK_VERSION_PROBES = 25;
8133
8133
  function readInstalledPackageVersion(addonDir) {
8134
8134
  try {
8135
- const raw = JSON.parse(fs.readFileSync(path$1.join(addonDir, "package.json"), "utf-8"));
8135
+ const raw = JSON.parse(fs$1.readFileSync(path$1.join(addonDir, "package.json"), "utf-8"));
8136
8136
  if (raw === null || typeof raw !== "object") return null;
8137
8137
  const version = Reflect.get(raw, "version");
8138
8138
  return typeof version === "string" && version.length > 0 ? version : null;
@@ -8280,7 +8280,7 @@ var AddonInstaller = class AddonInstaller {
8280
8280
  } catch {
8281
8281
  return Object.freeze([]);
8282
8282
  }
8283
- const raw = fs.readFileSync(pkgPath, "utf-8");
8283
+ const raw = fs$1.readFileSync(pkgPath, "utf-8");
8284
8284
  const parsed = JSON.parse(raw);
8285
8285
  const deps = Object.keys(parsed.dependencies ?? {});
8286
8286
  const agentOnly = new Set(parsed.camstack?.agentOnlyBootstrapAddons ?? []);
@@ -8325,7 +8325,7 @@ var AddonInstaller = class AddonInstaller {
8325
8325
  } catch {
8326
8326
  return Object.freeze([]);
8327
8327
  }
8328
- const raw = fs.readFileSync(pkgPath, "utf-8");
8328
+ const raw = fs$1.readFileSync(pkgPath, "utf-8");
8329
8329
  const addons = JSON.parse(raw).camstack?.agentBootstrapAddons ?? [];
8330
8330
  return Object.freeze(["@camstack/server", ...addons]);
8331
8331
  }
@@ -8355,7 +8355,7 @@ var AddonInstaller = class AddonInstaller {
8355
8355
  this.logger.info(`Install source: ${isLocal ? `bundle (${this.bundledAddonsDir})` : "npm"}, ${pkgList.length} package(s)`);
8356
8356
  for (const packageName of pkgList) {
8357
8357
  const addonDir = path$1.join(this.addonsDir, packageName);
8358
- if (fs.existsSync(path$1.join(addonDir, "package.json"))) {
8358
+ if (fs$1.existsSync(path$1.join(addonDir, "package.json"))) {
8359
8359
  if (isLocal || shouldSkipClosureProvidedSeed(packageName, this.isResolvableFromClosure(packageName))) {
8360
8360
  this.logger.debug(`${packageName} — already installed, skipping`);
8361
8361
  continue;
@@ -8606,7 +8606,7 @@ var AddonInstaller = class AddonInstaller {
8606
8606
  const installedPackages = this.listInstalled();
8607
8607
  for (const pkg of installedPackages) {
8608
8608
  try {
8609
- if (fs.lstatSync(pkg.dir).isSymbolicLink()) continue;
8609
+ if (fs$1.lstatSync(pkg.dir).isSymbolicLink()) continue;
8610
8610
  } catch {
8611
8611
  continue;
8612
8612
  }
@@ -8646,7 +8646,7 @@ var AddonInstaller = class AddonInstaller {
8646
8646
  if (closureNodeModules !== null) for (const link of state.existingLinks) {
8647
8647
  if (!isClosureLinkTarget(link.target, closureNodeModules)) continue;
8648
8648
  const linkDir = path$1.join(nodeModulesDir, link.name);
8649
- const targetManifest = fs.existsSync(path$1.join(linkDir, "package.json"));
8649
+ const targetManifest = fs$1.existsSync(path$1.join(linkDir, "package.json"));
8650
8650
  const ranges = state.requirements.get(link.name) ?? [];
8651
8651
  let holds = targetManifest;
8652
8652
  if (holds && ranges.length > 0) {
@@ -8655,14 +8655,14 @@ var AddonInstaller = class AddonInstaller {
8655
8655
  }
8656
8656
  if (!holds) {
8657
8657
  this.logger.warn(`${packageName} — closure link for ${link.name} no longer holds; reinstalling this addon's deps`, { meta: { target: link.target } });
8658
- fs.rmSync(linkDir, { force: true });
8658
+ fs$1.rmSync(linkDir, { force: true });
8659
8659
  needsInstall = true;
8660
8660
  }
8661
8661
  }
8662
8662
  const linked = [];
8663
8663
  for (const [depName, range] of declaredEntries) {
8664
8664
  if (typeof range !== "string") continue;
8665
- if (fs.existsSync(path$1.join(nodeModulesDir, depName, "package.json"))) continue;
8665
+ if (fs$1.existsSync(path$1.join(nodeModulesDir, depName, "package.json"))) continue;
8666
8666
  const closureVersion = closureNodeModules === null ? void 0 : readClosureVersions(closureNodeModules, [depName]).get(depName);
8667
8667
  if (closureNodeModules !== null && closureVersion !== void 0 && closureSatisfiesRange(range, closureVersion)) {
8668
8668
  if (executeClosureDedupe(addonDir, closureNodeModules, {
@@ -8695,7 +8695,7 @@ var AddonInstaller = class AddonInstaller {
8695
8695
  const closureNodeModules = resolveClosureNodeModulesDir(this.closureNodeModulesDir);
8696
8696
  if (closureNodeModules !== null) {
8697
8697
  const state = collectAddonTreeState(addonDir);
8698
- for (const link of state.existingLinks) if (isClosureLinkTarget(link.target, closureNodeModules)) fs.rmSync(path$1.join(addonDir, "node_modules", link.name), { force: true });
8698
+ for (const link of state.existingLinks) if (isClosureLinkTarget(link.target, closureNodeModules)) fs$1.rmSync(path$1.join(addonDir, "node_modules", link.name), { force: true });
8699
8699
  }
8700
8700
  this.logger.info(`${packageName} — reinstalling runtime dependencies`, { meta: { addonDir } });
8701
8701
  await runNpm([
@@ -8740,7 +8740,7 @@ var AddonInstaller = class AddonInstaller {
8740
8740
  async realignFromClosure(packageName, closureDir) {
8741
8741
  const targetDir = path$1.join(this.addonsDir, packageName);
8742
8742
  const result = await this.installLocal(packageName, closureDir);
8743
- await fs.promises.writeFile(path$1.join(targetDir, ".install-source"), "closure");
8743
+ await fs$1.promises.writeFile(path$1.join(targetDir, ".install-source"), "closure");
8744
8744
  this.manifest.upsert(result.name, {
8745
8745
  version: result.version,
8746
8746
  source: "closure"
@@ -8756,17 +8756,17 @@ var AddonInstaller = class AddonInstaller {
8756
8756
  async installCopy(packageName, sourceDir, pkgData, targetDir) {
8757
8757
  await this.ensureBuilt(packageName, sourceDir, pkgData);
8758
8758
  const distDir = path$1.join(sourceDir, "dist");
8759
- if (!fs.existsSync(distDir)) throw new Error(`${packageName} has no dist/ after build`);
8760
- await fs.promises.rm(targetDir, {
8759
+ if (!fs$1.existsSync(distDir)) throw new Error(`${packageName} has no dist/ after build`);
8760
+ await fs$1.promises.rm(targetDir, {
8761
8761
  recursive: true,
8762
8762
  force: true
8763
8763
  });
8764
8764
  ensureDir(targetDir);
8765
- await fs.promises.writeFile(path$1.join(targetDir, "package.json"), JSON.stringify(stripBundledDeps(pkgData), null, 2));
8765
+ await fs$1.promises.writeFile(path$1.join(targetDir, "package.json"), JSON.stringify(stripBundledDeps(pkgData), null, 2));
8766
8766
  await copyDirRecursive(distDir, path$1.join(targetDir, "dist"));
8767
8767
  await copyExtraFileDirs(pkgData, sourceDir, targetDir);
8768
8768
  copyBundledNativeModules(sourceDir, targetDir, this.logger);
8769
- await fs.promises.writeFile(path$1.join(targetDir, ".install-source"), "local");
8769
+ await fs$1.promises.writeFile(path$1.join(targetDir, ".install-source"), "local");
8770
8770
  const localPkgVersion = asString$1(pkgData.version, "0.0.0");
8771
8771
  this.manifest.upsert(packageName, {
8772
8772
  version: localPkgVersion,
@@ -8807,7 +8807,7 @@ var AddonInstaller = class AddonInstaller {
8807
8807
  * unusual auth, offline mode, etc).
8808
8808
  */
8809
8809
  async installFromNpm(packageName, version) {
8810
- const tmpDir = fs.mkdtempSync(path$1.join(os$1.tmpdir(), "camstack-addon-npm-"));
8810
+ const tmpDir = fs$1.mkdtempSync(path$1.join(os$1.tmpdir(), "camstack-addon-npm-"));
8811
8811
  const packageSpec = version ? `${packageName}@${version}` : packageName;
8812
8812
  this.logger.info(`${packageName} — installing from npm`);
8813
8813
  try {
@@ -8821,19 +8821,19 @@ var AddonInstaller = class AddonInstaller {
8821
8821
  ];
8822
8822
  if (this.registry) args.push("--registry", this.registry);
8823
8823
  const { stdout } = await runNpm(args, this.npmRunOptions(tmpDir, 12e4));
8824
- const tgzFiles = fs.readdirSync(tmpDir).filter((f) => f.endsWith(".tgz"));
8824
+ const tgzFiles = fs$1.readdirSync(tmpDir).filter((f) => f.endsWith(".tgz"));
8825
8825
  if (tgzFiles.length === 0) throw new Error(`npm pack produced no tgz. stdout: ${stdout.trim()}`);
8826
8826
  return path$1.join(tmpDir, tgzFiles[0]);
8827
8827
  });
8828
8828
  const result = await this.installFromTgz(tgzPath);
8829
- fs.writeFileSync(path$1.join(this.addonsDir, result.name, ".install-source"), "npm");
8829
+ fs$1.writeFileSync(path$1.join(this.addonsDir, result.name, ".install-source"), "npm");
8830
8830
  this.manifest.upsert(result.name, {
8831
8831
  version: result.version,
8832
8832
  source: "npm"
8833
8833
  });
8834
8834
  return result;
8835
8835
  } finally {
8836
- fs.rmSync(tmpDir, {
8836
+ fs$1.rmSync(tmpDir, {
8837
8837
  recursive: true,
8838
8838
  force: true
8839
8839
  });
@@ -8871,7 +8871,7 @@ var AddonInstaller = class AddonInstaller {
8871
8871
  if (!tarRes.ok) throw new Error(`tarball GET ${tarballUrl} → ${tarRes.status}`);
8872
8872
  const tgzPath = path$1.join(tmpDir, `${packageName.replace(/[/@]/g, "-").replace(/^-+/, "")}-${resolvedVersion}.tgz`);
8873
8873
  const buf = Buffer.from(await tarRes.arrayBuffer());
8874
- fs.writeFileSync(tgzPath, buf);
8874
+ fs$1.writeFileSync(tgzPath, buf);
8875
8875
  return tgzPath;
8876
8876
  }
8877
8877
  /**
@@ -8892,7 +8892,7 @@ var AddonInstaller = class AddonInstaller {
8892
8892
  * on the next deploy.
8893
8893
  */
8894
8894
  async evictInstallDir(targetDir) {
8895
- if (!fs.existsSync(targetDir)) return;
8895
+ if (!fs$1.existsSync(targetDir)) return;
8896
8896
  const graveyard = path$1.join(this.addonsDir, ".evicting");
8897
8897
  ensureDir(graveyard);
8898
8898
  await this.sweepGraveyard(graveyard);
@@ -8900,10 +8900,10 @@ var AddonInstaller = class AddonInstaller {
8900
8900
  const flatName = path$1.relative(this.addonsDir, targetDir).replace(/[/\\]/g, "-");
8901
8901
  const asideDir = path$1.join(graveyard, `${flatName}-${ts}`);
8902
8902
  try {
8903
- fs.renameSync(targetDir, asideDir);
8903
+ fs$1.renameSync(targetDir, asideDir);
8904
8904
  } catch (renameErr) {
8905
8905
  if (renameErr.code === "EXDEV") {
8906
- await fs.promises.rm(targetDir, {
8906
+ await fs$1.promises.rm(targetDir, {
8907
8907
  recursive: true,
8908
8908
  force: true
8909
8909
  });
@@ -8911,7 +8911,7 @@ var AddonInstaller = class AddonInstaller {
8911
8911
  }
8912
8912
  throw renameErr;
8913
8913
  }
8914
- await fs.promises.rm(asideDir, {
8914
+ await fs$1.promises.rm(asideDir, {
8915
8915
  recursive: true,
8916
8916
  force: true
8917
8917
  }).catch((cleanupErr) => {
@@ -8932,14 +8932,14 @@ var AddonInstaller = class AddonInstaller {
8932
8932
  async sweepStagingResidue(stagingRoot) {
8933
8933
  let names;
8934
8934
  try {
8935
- names = fs.readdirSync(stagingRoot);
8935
+ names = fs$1.readdirSync(stagingRoot);
8936
8936
  } catch {
8937
8937
  return;
8938
8938
  }
8939
8939
  const now = Date.now();
8940
8940
  const ages = [];
8941
8941
  for (const name of names) try {
8942
- const stat = fs.statSync(path$1.join(stagingRoot, name));
8942
+ const stat = fs$1.statSync(path$1.join(stagingRoot, name));
8943
8943
  ages.push({
8944
8944
  name,
8945
8945
  ageMs: now - stat.mtimeMs
@@ -8950,7 +8950,7 @@ var AddonInstaller = class AddonInstaller {
8950
8950
  stagingRoot,
8951
8951
  entries: sweepable
8952
8952
  } });
8953
- await Promise.all(sweepable.map((name) => fs.promises.rm(path$1.join(stagingRoot, name), {
8953
+ await Promise.all(sweepable.map((name) => fs$1.promises.rm(path$1.join(stagingRoot, name), {
8954
8954
  recursive: true,
8955
8955
  force: true
8956
8956
  }).catch(() => void 0)));
@@ -8959,11 +8959,11 @@ var AddonInstaller = class AddonInstaller {
8959
8959
  async sweepGraveyard(graveyard) {
8960
8960
  let entries;
8961
8961
  try {
8962
- entries = fs.readdirSync(graveyard);
8962
+ entries = fs$1.readdirSync(graveyard);
8963
8963
  } catch {
8964
8964
  return;
8965
8965
  }
8966
- await Promise.all(entries.map((name) => fs.promises.rm(path$1.join(graveyard, name), {
8966
+ await Promise.all(entries.map((name) => fs$1.promises.rm(path$1.join(graveyard, name), {
8967
8967
  recursive: true,
8968
8968
  force: true
8969
8969
  }).catch(() => void 0)));
@@ -9014,7 +9014,7 @@ var AddonInstaller = class AddonInstaller {
9014
9014
  return;
9015
9015
  }
9016
9016
  const strippedManifest = stripBundledDeps(pkgView.raw);
9017
- await fs.promises.writeFile(pkgJsonPath, JSON.stringify(strippedManifest, null, 2));
9017
+ await fs$1.promises.writeFile(pkgJsonPath, JSON.stringify(strippedManifest, null, 2));
9018
9018
  const deps = asJsonObject$1(strippedManifest["dependencies"]);
9019
9019
  const depNames = deps ? Object.keys(deps) : [];
9020
9020
  if (depNames.length === 0) return;
@@ -9146,9 +9146,9 @@ var AddonInstaller = class AddonInstaller {
9146
9146
  "-C",
9147
9147
  stagingDir
9148
9148
  ], { timeout: 12e4 });
9149
- const pkgDir = fs.existsSync(path$1.join(stagingDir, "package", "package.json")) ? path$1.join(stagingDir, "package") : stagingDir;
9149
+ const pkgDir = fs$1.existsSync(path$1.join(stagingDir, "package", "package.json")) ? path$1.join(stagingDir, "package") : stagingDir;
9150
9150
  const pkgJsonPath = path$1.join(pkgDir, "package.json");
9151
- if (!fs.existsSync(pkgJsonPath)) throw new Error("No package.json found in tgz archive");
9151
+ if (!fs$1.existsSync(pkgJsonPath)) throw new Error("No package.json found in tgz archive");
9152
9152
  const pkgView = readPackageJson(pkgJsonPath);
9153
9153
  if (!pkgView) throw new Error(`Invalid package.json at ${pkgJsonPath}`);
9154
9154
  if (!pkgView.camstackAddons) throw new Error(`Package ${pkgView.name} has no camstack.addons manifest`);
@@ -9158,7 +9158,7 @@ var AddonInstaller = class AddonInstaller {
9158
9158
  this.dedupeTreeAgainstClosure(pkgDir, pkgView.name);
9159
9159
  await this.evictInstallDir(targetDir);
9160
9160
  ensureDir(path$1.dirname(targetDir));
9161
- await fs.promises.rename(pkgDir, targetDir);
9161
+ await fs$1.promises.rename(pkgDir, targetDir);
9162
9162
  this.manifest.upsert(pkgView.name, {
9163
9163
  version: pkgView.version,
9164
9164
  source: "bundled"
@@ -9169,7 +9169,7 @@ var AddonInstaller = class AddonInstaller {
9169
9169
  };
9170
9170
  } finally {
9171
9171
  this.inFlightStaging.delete(stagingName);
9172
- await fs.promises.rm(stagingDir, {
9172
+ await fs$1.promises.rm(stagingDir, {
9173
9173
  recursive: true,
9174
9174
  force: true
9175
9175
  }).catch(() => void 0);
@@ -9199,24 +9199,24 @@ var AddonInstaller = class AddonInstaller {
9199
9199
  const current = this.manifest.get(packageName);
9200
9200
  if (current == null) throw new Error(`Cannot update ${packageName}: not currently tracked in manifest`);
9201
9201
  const addonDir = path$1.join(this.addonsDir, packageName);
9202
- if (!fs.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
9202
+ if (!fs$1.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
9203
9203
  const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
9204
9204
  const backupRoot = path$1.join(this.addonsDir, ".backups", packageName);
9205
9205
  ensureDir(backupRoot);
9206
9206
  const backupDir = path$1.join(backupRoot, ts);
9207
9207
  this.logger.info(`${packageName} — backing up v${current.version} → ${backupDir}`);
9208
- fs.renameSync(addonDir, backupDir);
9208
+ fs$1.renameSync(addonDir, backupDir);
9209
9209
  let result;
9210
9210
  try {
9211
9211
  result = await this.installFromNpm(packageName, version);
9212
9212
  } catch (installErr) {
9213
9213
  this.logger.error(`${packageName} — install failed, restoring backup`, { meta: { error: errMsg$1(installErr) } });
9214
9214
  try {
9215
- if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
9215
+ if (fs$1.existsSync(addonDir)) fs$1.rmSync(addonDir, {
9216
9216
  recursive: true,
9217
9217
  force: true
9218
9218
  });
9219
- fs.renameSync(backupDir, addonDir);
9219
+ fs$1.renameSync(backupDir, addonDir);
9220
9220
  this.manifest.upsert(packageName, {
9221
9221
  version: current.version,
9222
9222
  source: current.source,
@@ -9277,7 +9277,7 @@ var AddonInstaller = class AddonInstaller {
9277
9277
  const current = this.manifest.get(packageName);
9278
9278
  if (current == null) throw new Error(`Cannot update ${packageName}: not currently tracked in manifest`);
9279
9279
  const addonDir = path$1.join(this.addonsDir, packageName);
9280
- if (!fs.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
9280
+ if (!fs$1.existsSync(addonDir)) throw new Error(`Cannot update ${packageName}: install dir ${addonDir} missing`);
9281
9281
  await this.installRuntimeDependencies(stagedPath, packageName);
9282
9282
  await this.installNativeDependencies(stagedPath, packageName);
9283
9283
  this.dedupeTreeAgainstClosure(stagedPath, packageName);
@@ -9286,14 +9286,14 @@ var AddonInstaller = class AddonInstaller {
9286
9286
  ensureDir(backupRoot);
9287
9287
  const backupDir = path$1.join(backupRoot, ts);
9288
9288
  this.logger.info(`${packageName} — backing up v${current.version} → ${backupDir}`);
9289
- fs.renameSync(addonDir, backupDir);
9289
+ fs$1.renameSync(addonDir, backupDir);
9290
9290
  try {
9291
9291
  try {
9292
- fs.renameSync(stagedPath, addonDir);
9292
+ fs$1.renameSync(stagedPath, addonDir);
9293
9293
  } catch (renameErr) {
9294
9294
  if (renameErr.code === "EXDEV") {
9295
- fs.cpSync(stagedPath, addonDir, { recursive: true });
9296
- fs.rmSync(stagedPath, {
9295
+ fs$1.cpSync(stagedPath, addonDir, { recursive: true });
9296
+ fs$1.rmSync(stagedPath, {
9297
9297
  recursive: true,
9298
9298
  force: true
9299
9299
  });
@@ -9302,11 +9302,11 @@ var AddonInstaller = class AddonInstaller {
9302
9302
  } catch (swapErr) {
9303
9303
  this.logger.error(`${packageName} — staged swap failed, restoring backup`, { meta: { error: errMsg$1(swapErr) } });
9304
9304
  try {
9305
- if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
9305
+ if (fs$1.existsSync(addonDir)) fs$1.rmSync(addonDir, {
9306
9306
  recursive: true,
9307
9307
  force: true
9308
9308
  });
9309
- fs.renameSync(backupDir, addonDir);
9309
+ fs$1.renameSync(backupDir, addonDir);
9310
9310
  this.manifest.upsert(packageName, {
9311
9311
  version: current.version,
9312
9312
  source: current.source,
@@ -9345,20 +9345,20 @@ var AddonInstaller = class AddonInstaller {
9345
9345
  this.logger.warn(`${packageName} — no backup to rollback to`);
9346
9346
  return null;
9347
9347
  }
9348
- if (!fs.existsSync(entry.lastBackupDir)) {
9348
+ if (!fs$1.existsSync(entry.lastBackupDir)) {
9349
9349
  this.logger.warn(`${packageName} — backup dir vanished: ${entry.lastBackupDir}`);
9350
9350
  return null;
9351
9351
  }
9352
9352
  const addonDir = path$1.join(this.addonsDir, packageName);
9353
- if (fs.existsSync(addonDir)) fs.rmSync(addonDir, {
9353
+ if (fs$1.existsSync(addonDir)) fs$1.rmSync(addonDir, {
9354
9354
  recursive: true,
9355
9355
  force: true
9356
9356
  });
9357
- fs.renameSync(entry.lastBackupDir, addonDir);
9357
+ fs$1.renameSync(entry.lastBackupDir, addonDir);
9358
9358
  const pkgJsonPath = path$1.join(addonDir, "package.json");
9359
9359
  let restoredVersion = entry.version;
9360
- if (fs.existsSync(pkgJsonPath)) try {
9361
- const parsed = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
9360
+ if (fs$1.existsSync(pkgJsonPath)) try {
9361
+ const parsed = JSON.parse(fs$1.readFileSync(pkgJsonPath, "utf-8"));
9362
9362
  if (typeof parsed === "object" && parsed != null) {
9363
9363
  const v = parsed.version;
9364
9364
  if (typeof v === "string" && v.length > 0) restoredVersion = v;
@@ -9406,7 +9406,7 @@ var AddonInstaller = class AddonInstaller {
9406
9406
  return false;
9407
9407
  }
9408
9408
  try {
9409
- await fs.promises.rm(target, {
9409
+ await fs$1.promises.rm(target, {
9410
9410
  recursive: true,
9411
9411
  force: true
9412
9412
  });
@@ -9424,7 +9424,7 @@ var AddonInstaller = class AddonInstaller {
9424
9424
  listBackupsFor(packageName) {
9425
9425
  const dir = path$1.join(this.backupsRoot, packageName);
9426
9426
  try {
9427
- return fs.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => path$1.join(dir, e.name)).sort();
9427
+ return fs$1.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => path$1.join(dir, e.name)).sort();
9428
9428
  } catch {
9429
9429
  return [];
9430
9430
  }
@@ -9456,7 +9456,7 @@ var AddonInstaller = class AddonInstaller {
9456
9456
  for (const dir of [pkgDir, path$1.dirname(pkgDir)]) {
9457
9457
  if (!this.isInsideBackups(dir)) continue;
9458
9458
  try {
9459
- await fs.promises.rmdir(dir);
9459
+ await fs$1.promises.rmdir(dir);
9460
9460
  } catch {
9461
9461
  return;
9462
9462
  }
@@ -9538,7 +9538,7 @@ var AddonInstaller = class AddonInstaller {
9538
9538
  */
9539
9539
  resolveBackupToKeep(packageName, backups) {
9540
9540
  const liveDir = path$1.join(this.addonsDir, packageName);
9541
- if (!fs.existsSync(liveDir)) {
9541
+ if (!fs$1.existsSync(liveDir)) {
9542
9542
  const newest = backups[backups.length - 1] ?? null;
9543
9543
  if (newest != null) this.logger.warn(`${packageName} — live install dir missing; retaining its newest backup as the only surviving copy`, { meta: {
9544
9544
  liveDir,
@@ -9555,7 +9555,7 @@ var AddonInstaller = class AddonInstaller {
9555
9555
  listBackedUpPackages() {
9556
9556
  let entries;
9557
9557
  try {
9558
- entries = fs.readdirSync(this.backupsRoot, { withFileTypes: true });
9558
+ entries = fs$1.readdirSync(this.backupsRoot, { withFileTypes: true });
9559
9559
  } catch {
9560
9560
  return [];
9561
9561
  }
@@ -9567,14 +9567,14 @@ var AddonInstaller = class AddonInstaller {
9567
9567
  continue;
9568
9568
  }
9569
9569
  const scopeDir = path$1.join(this.backupsRoot, entry.name);
9570
- for (const inner of fs.readdirSync(scopeDir, { withFileTypes: true })) if (inner.isDirectory()) names.push(`${entry.name}/${inner.name}`);
9570
+ for (const inner of fs$1.readdirSync(scopeDir, { withFileTypes: true })) if (inner.isDirectory()) names.push(`${entry.name}/${inner.name}`);
9571
9571
  }
9572
9572
  return names;
9573
9573
  }
9574
9574
  async uninstall(packageName) {
9575
9575
  const addonDir = path$1.join(this.addonsDir, packageName);
9576
- if (fs.existsSync(addonDir)) {
9577
- fs.rmSync(addonDir, {
9576
+ if (fs$1.existsSync(addonDir)) {
9577
+ fs$1.rmSync(addonDir, {
9578
9578
  recursive: true,
9579
9579
  force: true
9580
9580
  });
@@ -9582,8 +9582,8 @@ var AddonInstaller = class AddonInstaller {
9582
9582
  return;
9583
9583
  }
9584
9584
  const legacyDir = path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""));
9585
- if (fs.existsSync(legacyDir)) {
9586
- fs.rmSync(legacyDir, {
9585
+ if (fs$1.existsSync(legacyDir)) {
9586
+ fs$1.rmSync(legacyDir, {
9587
9587
  recursive: true,
9588
9588
  force: true
9589
9589
  });
@@ -9591,22 +9591,22 @@ var AddonInstaller = class AddonInstaller {
9591
9591
  }
9592
9592
  }
9593
9593
  listInstalled() {
9594
- if (!fs.existsSync(this.addonsDir)) return [];
9594
+ if (!fs$1.existsSync(this.addonsDir)) return [];
9595
9595
  const packageDirs = [];
9596
- for (const entry of fs.readdirSync(this.addonsDir, { withFileTypes: true })) {
9596
+ for (const entry of fs$1.readdirSync(this.addonsDir, { withFileTypes: true })) {
9597
9597
  if (!isDirEntry(entry, this.addonsDir)) continue;
9598
9598
  if (entry.name.startsWith("@")) {
9599
9599
  const scopeDir = path$1.join(this.addonsDir, entry.name);
9600
- for (const inner of fs.readdirSync(scopeDir, { withFileTypes: true })) if (isDirEntry(inner, scopeDir)) packageDirs.push(path$1.join(scopeDir, inner.name));
9600
+ for (const inner of fs$1.readdirSync(scopeDir, { withFileTypes: true })) if (isDirEntry(inner, scopeDir)) packageDirs.push(path$1.join(scopeDir, inner.name));
9601
9601
  } else packageDirs.push(path$1.join(this.addonsDir, entry.name));
9602
9602
  }
9603
9603
  return packageDirs.map((dir) => {
9604
9604
  const pkgPath = path$1.join(dir, "package.json");
9605
- if (!fs.existsSync(pkgPath)) return null;
9605
+ if (!fs$1.existsSync(pkgPath)) return null;
9606
9606
  const pkg = readPackageJson(pkgPath);
9607
9607
  if (!pkg || !pkg.camstackAddons) return null;
9608
9608
  const sourceFile = path$1.join(dir, ".install-source");
9609
- const installSource = fs.existsSync(sourceFile) ? parseInstallSource(fs.readFileSync(sourceFile, "utf-8").trim()) : void 0;
9609
+ const installSource = fs$1.existsSync(sourceFile) ? parseInstallSource(fs$1.readFileSync(sourceFile, "utf-8").trim()) : void 0;
9610
9610
  return {
9611
9611
  name: pkg.name,
9612
9612
  version: pkg.version,
@@ -9616,13 +9616,13 @@ var AddonInstaller = class AddonInstaller {
9616
9616
  }).filter((item) => item !== null);
9617
9617
  }
9618
9618
  isInstalled(packageName) {
9619
- if (fs.existsSync(path$1.join(this.addonsDir, packageName, "package.json"))) return true;
9620
- return fs.existsSync(path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json"));
9619
+ if (fs$1.existsSync(path$1.join(this.addonsDir, packageName, "package.json"))) return true;
9620
+ return fs$1.existsSync(path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json"));
9621
9621
  }
9622
9622
  getInstalledPackage(packageName) {
9623
9623
  let pkgPath = path$1.join(this.addonsDir, packageName, "package.json");
9624
- if (!fs.existsSync(pkgPath)) pkgPath = path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json");
9625
- if (!fs.existsSync(pkgPath)) return null;
9624
+ if (!fs$1.existsSync(pkgPath)) pkgPath = path$1.join(this.addonsDir, packageName.replace(/^@[^/]+\//, ""), "package.json");
9625
+ if (!fs$1.existsSync(pkgPath)) return null;
9626
9626
  const pkg = readPackageJson(pkgPath);
9627
9627
  if (!pkg) return null;
9628
9628
  return {
@@ -9641,7 +9641,7 @@ var AddonInstaller = class AddonInstaller {
9641
9641
  ]) {
9642
9642
  const candidate = path$1.join(this.bundledAddonsDir, dirName);
9643
9643
  try {
9644
- const pkg = asJsonObject$1(parseJsonUnknown(fs.readFileSync(path$1.join(candidate, "package.json"), "utf-8")));
9644
+ const pkg = asJsonObject$1(parseJsonUnknown(fs$1.readFileSync(path$1.join(candidate, "package.json"), "utf-8")));
9645
9645
  if (pkg && asString$1(pkg["name"]) === packageName) return candidate;
9646
9646
  } catch {}
9647
9647
  }
@@ -9650,7 +9650,7 @@ var AddonInstaller = class AddonInstaller {
9650
9650
  /** Ensure a package is built (dist/ exists and page bundles present) */
9651
9651
  async ensureBuilt(packageName, sourceDir, pkgData) {
9652
9652
  const distDir = path$1.join(sourceDir, "dist");
9653
- if (!(!fs.existsSync(distDir) || this.isDistIncomplete(pkgData, sourceDir))) return;
9653
+ if (!(!fs$1.existsSync(distDir) || this.isDistIncomplete(pkgData, sourceDir))) return;
9654
9654
  this.logger.info(`${packageName} — building (dist/ missing or incomplete)`);
9655
9655
  try {
9656
9656
  await runNpm(["run", "build"], this.npmRunOptions(sourceDir, 18e4));
@@ -9665,7 +9665,7 @@ var AddonInstaller = class AddonInstaller {
9665
9665
  if (!camstack?.addons) return false;
9666
9666
  for (const addon of camstack.addons) {
9667
9667
  if (!addon.pages) continue;
9668
- for (const page of addon.pages) if (page.bundle && !fs.existsSync(path$1.join(sourceDir, "dist", page.bundle))) return true;
9668
+ for (const page of addon.pages) if (page.bundle && !fs$1.existsSync(path$1.join(sourceDir, "dist", page.bundle))) return true;
9669
9669
  }
9670
9670
  return false;
9671
9671
  }
@@ -9674,7 +9674,7 @@ var AddonInstaller = class AddonInstaller {
9674
9674
  function isDirEntry(entry, parentDir) {
9675
9675
  if (entry.isDirectory()) return true;
9676
9676
  if (entry.isSymbolicLink()) try {
9677
- return fs.statSync(path$1.join(parentDir, entry.name)).isDirectory();
9677
+ return fs$1.statSync(path$1.join(parentDir, entry.name)).isDirectory();
9678
9678
  } catch {
9679
9679
  return false;
9680
9680
  }
@@ -9773,7 +9773,7 @@ function selectAddonResidue(candidates) {
9773
9773
  }
9774
9774
  function readDeclaredName(dir) {
9775
9775
  try {
9776
- const parsed = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
9776
+ const parsed = JSON.parse(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
9777
9777
  if (typeof parsed !== "object" || parsed === null) return null;
9778
9778
  const name = parsed.name;
9779
9779
  return typeof name === "string" ? name : null;
@@ -9783,7 +9783,7 @@ function readDeclaredName(dir) {
9783
9783
  }
9784
9784
  function readDeclaredVersion(dir) {
9785
9785
  try {
9786
- const parsed = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
9786
+ const parsed = JSON.parse(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
9787
9787
  if (typeof parsed !== "object" || parsed === null) return null;
9788
9788
  const version = parsed.version;
9789
9789
  return typeof version === "string" ? version : null;
@@ -9793,7 +9793,7 @@ function readDeclaredVersion(dir) {
9793
9793
  }
9794
9794
  function isDirLike(p) {
9795
9795
  try {
9796
- return fs.statSync(p).isDirectory();
9796
+ return fs$1.statSync(p).isDirectory();
9797
9797
  } catch {
9798
9798
  return false;
9799
9799
  }
@@ -9803,7 +9803,7 @@ function freeQuarantineTarget(store, scope, dirName) {
9803
9803
  const base = scope === null ? dirName : `${scope.replace("@", "")}__${dirName}`;
9804
9804
  let candidate = path$1.join(store, base);
9805
9805
  let n = 1;
9806
- while (fs.existsSync(candidate)) {
9806
+ while (fs$1.existsSync(candidate)) {
9807
9807
  candidate = path$1.join(store, `${base}-${n}`);
9808
9808
  n += 1;
9809
9809
  }
@@ -9820,7 +9820,7 @@ function freeQuarantineTarget(store, scope, dirName) {
9820
9820
  function quarantineAddonResidue(addonsDir, log) {
9821
9821
  const quarantined = [];
9822
9822
  const failed = [];
9823
- if (!fs.existsSync(addonsDir)) return {
9823
+ if (!fs$1.existsSync(addonsDir)) return {
9824
9824
  quarantined,
9825
9825
  failed
9826
9826
  };
@@ -9828,7 +9828,7 @@ function quarantineAddonResidue(addonsDir, log) {
9828
9828
  const scan = (parent, scope) => {
9829
9829
  let names;
9830
9830
  try {
9831
- names = fs.readdirSync(parent);
9831
+ names = fs$1.readdirSync(parent);
9832
9832
  } catch {
9833
9833
  return;
9834
9834
  }
@@ -9847,8 +9847,8 @@ function quarantineAddonResidue(addonsDir, log) {
9847
9847
  const version = readDeclaredVersion(full);
9848
9848
  const to = freeQuarantineTarget(store, scope, dirName);
9849
9849
  try {
9850
- fs.mkdirSync(store, { recursive: true });
9851
- fs.renameSync(full, to);
9850
+ fs$1.mkdirSync(store, { recursive: true });
9851
+ fs$1.renameSync(full, to);
9852
9852
  } catch (err) {
9853
9853
  const error = err instanceof Error ? err.message : String(err);
9854
9854
  failed.push({
@@ -9906,11 +9906,11 @@ function getRestartMarkerPath(dataDir) {
9906
9906
  * intact or no marker at all (never a half-written file).
9907
9907
  */
9908
9908
  function writePendingRestart(dataDir, marker) {
9909
- fs.mkdirSync(dataDir, { recursive: true });
9909
+ fs$1.mkdirSync(dataDir, { recursive: true });
9910
9910
  const markerPath = getRestartMarkerPath(dataDir);
9911
9911
  const tmpPath = `${markerPath}.tmp`;
9912
- fs.writeFileSync(tmpPath, JSON.stringify(marker, null, 2), "utf-8");
9913
- fs.renameSync(tmpPath, markerPath);
9912
+ fs$1.writeFileSync(tmpPath, JSON.stringify(marker, null, 2), "utf-8");
9913
+ fs$1.renameSync(tmpPath, markerPath);
9914
9914
  }
9915
9915
  /**
9916
9916
  * Read + consume the marker. Returns the parsed payload on success and
@@ -9935,10 +9935,10 @@ function writePendingRestart(dataDir, marker) {
9935
9935
  */
9936
9936
  function readPendingRestart(dataDir) {
9937
9937
  const markerPath = getRestartMarkerPath(dataDir);
9938
- if (!fs.existsSync(markerPath)) return null;
9938
+ if (!fs$1.existsSync(markerPath)) return null;
9939
9939
  let raw;
9940
9940
  try {
9941
- raw = fs.readFileSync(markerPath, "utf-8");
9941
+ raw = fs$1.readFileSync(markerPath, "utf-8");
9942
9942
  } catch (err) {
9943
9943
  console.error("[restart-coordinator] Marker unreadable — leaving in place:", err);
9944
9944
  return null;
@@ -9977,7 +9977,7 @@ function readPendingRestart(dataDir) {
9977
9977
  /** Remove the marker if present. No-op if missing. */
9978
9978
  function clearPendingRestart(dataDir) {
9979
9979
  const markerPath = getRestartMarkerPath(dataDir);
9980
- fs.rmSync(markerPath, { force: true });
9980
+ fs$1.rmSync(markerPath, { force: true });
9981
9981
  }
9982
9982
  function isRestartKind(value) {
9983
9983
  return value === "framework-update" || value === "manual" || value === "system";
@@ -9989,7 +9989,7 @@ function scheduleSelfRestart(options = {}) {
9989
9989
  const touchTarget = process.env["CAMSTACK_RESTART_TOUCH_FILE"];
9990
9990
  if (touchTarget !== void 0 && touchTarget.length > 0) try {
9991
9991
  const now = /* @__PURE__ */ new Date();
9992
- fs.utimesSync(touchTarget, now, now);
9992
+ fs$1.utimesSync(touchTarget, now, now);
9993
9993
  return;
9994
9994
  } catch (err) {
9995
9995
  console.error("[restart-coordinator] dev touch-reload failed; falling through to process exit:", err);
@@ -14359,11 +14359,11 @@ function applyEnvOverrides(raw) {
14359
14359
  return result;
14360
14360
  }
14361
14361
  function loadYaml(configPath) {
14362
- if (!fs.existsSync(configPath)) {
14362
+ if (!fs$1.existsSync(configPath)) {
14363
14363
  console.warn(`[ConfigManager] Config file not found at: ${configPath}\n → Using built-in defaults. Set CONFIG_PATH env var or create the file.\n → Example path from project root: ./server/backend/data/config.yaml`);
14364
14364
  return {};
14365
14365
  }
14366
- const parsed = load(fs.readFileSync(configPath, "utf-8")) ?? {};
14366
+ const parsed = load(fs$1.readFileSync(configPath, "utf-8")) ?? {};
14367
14367
  console.log(`[ConfigManager] Loaded config from: ${configPath}`);
14368
14368
  return parsed;
14369
14369
  }
@@ -22717,7 +22717,7 @@ async function probeVaapiInit(renderNode) {
22717
22717
  */
22718
22718
  function safeExistsSync(path) {
22719
22719
  try {
22720
- return fs.existsSync(path);
22720
+ return fs$1.existsSync(path);
22721
22721
  } catch {
22722
22722
  return false;
22723
22723
  }
@@ -22736,11 +22736,11 @@ function probeLinuxGpus() {
22736
22736
  if (safeExistsSync("/dev/nvidia0") || safeExistsSync("/proc/driver/nvidia/version")) signals.hasNvidiaGpu = true;
22737
22737
  try {
22738
22738
  const drmDir = "/sys/class/drm";
22739
- if (fs.existsSync(drmDir)) for (const entry of fs.readdirSync(drmDir)) {
22739
+ if (fs$1.existsSync(drmDir)) for (const entry of fs$1.readdirSync(drmDir)) {
22740
22740
  if (!entry.startsWith("card")) continue;
22741
22741
  const vendorPath = `${drmDir}/${entry}/device/vendor`;
22742
22742
  if (!safeExistsSync(vendorPath)) continue;
22743
- const vendor = fs.readFileSync(vendorPath, "utf8").trim().toLowerCase();
22743
+ const vendor = fs$1.readFileSync(vendorPath, "utf8").trim().toLowerCase();
22744
22744
  if (vendor === "0x10de") signals.hasNvidiaGpu = true;
22745
22745
  else if (vendor === "0x1002") signals.hasAmdGpu = true;
22746
22746
  else if (vendor === "0x8086") signals.hasIntelGpu = true;
@@ -22958,21 +22958,21 @@ function sleep$1(ms) {
22958
22958
  * crashed holder) is stolen.
22959
22959
  */
22960
22960
  async function withFileLock(lockPath, fn) {
22961
- fs.mkdirSync(join(lockPath, ".."), { recursive: true });
22961
+ fs$1.mkdirSync(join(lockPath, ".."), { recursive: true });
22962
22962
  for (;;) try {
22963
- const fd = fs.openSync(lockPath, "wx");
22964
- fs.closeSync(fd);
22963
+ const fd = fs$1.openSync(lockPath, "wx");
22964
+ fs$1.closeSync(fd);
22965
22965
  break;
22966
22966
  } catch {
22967
22967
  try {
22968
- if (Date.now() - fs.statSync(lockPath).mtimeMs > LOCK_STALE_MS) fs.rmSync(lockPath, { force: true });
22968
+ if (Date.now() - fs$1.statSync(lockPath).mtimeMs > LOCK_STALE_MS) fs$1.rmSync(lockPath, { force: true });
22969
22969
  else await sleep$1(LOCK_POLL_MS);
22970
22970
  } catch {}
22971
22971
  }
22972
22972
  try {
22973
22973
  return await fn();
22974
22974
  } finally {
22975
- fs.rmSync(lockPath, { force: true });
22975
+ fs$1.rmSync(lockPath, { force: true });
22976
22976
  }
22977
22977
  }
22978
22978
  /** Coalesce in-process + serialize cross-process for one binary id. */
@@ -23030,7 +23030,7 @@ var AddonDepsManager = class {
23030
23030
  * failed or tampered download throws, and provisioning reports it.
23031
23031
  */
23032
23032
  async stageNativeDepsDeclaredBy(requirementsFile) {
23033
- if (!declaresEdgetpuDelegate(fs.readFileSync(requirementsFile, "utf8"))) return;
23033
+ if (!declaresEdgetpuDelegate(fs$1.readFileSync(requirementsFile, "utf8"))) return;
23034
23034
  await singleFlight(this.depsDir, "edgetpu-delegate", () => ensureEdgetpuDelegate(this.nodeRoot, this.logger));
23035
23035
  }
23036
23036
  getDepsDir() {
@@ -24061,7 +24061,7 @@ async function buildAddonContext(runtime, declaration, dataDir, options) {
24061
24061
  const addonId = declaration.id;
24062
24062
  const nodeDataDir = process.env["CAMSTACK_DATA"] ?? dataDir;
24063
24063
  const addonDataDir = path$1.resolve(nodeDataDir, "addons-data", addonId);
24064
- fs.mkdirSync(addonDataDir, { recursive: true });
24064
+ fs$1.mkdirSync(addonDataDir, { recursive: true });
24065
24065
  if (runtime.mode === "broker") ensureBindingSubscription(runtime.broker);
24066
24066
  const regs = getRegistries(nodeId);
24067
24067
  const workerResolver = {
@@ -25921,7 +25921,7 @@ var FailedRunnerRetryLedger = class {
25921
25921
  function readRunnerPackageVersions(addonDirs) {
25922
25922
  const out = {};
25923
25923
  for (const dir of addonDirs) try {
25924
- const raw = JSON.parse(fs.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
25924
+ const raw = JSON.parse(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
25925
25925
  const version = typeof raw === "object" && raw !== null ? Reflect.get(raw, "version") : null;
25926
25926
  out[dir] = typeof version === "string" && version.length > 0 ? version : null;
25927
25927
  } catch {
@@ -25982,7 +25982,7 @@ function readAddonHeapDeclaration(spec) {
25982
25982
  if (cached !== void 0) return cached;
25983
25983
  let declaration = EMPTY_HEAP_DECLARATION;
25984
25984
  for (const manifestPath of [path$1.join(spec.addonDir, "package.json"), path$1.join(path$1.dirname(spec.addonDir), "package.json")]) try {
25985
- const raw = fs.readFileSync(manifestPath, "utf8");
25985
+ const raw = fs$1.readFileSync(manifestPath, "utf8");
25986
25986
  const parsed = JSON.parse(raw);
25987
25987
  const profile = extractHeapProfile(parsed, spec.addonId);
25988
25988
  const maxOldSpaceMb = extractMaxOldSpaceMb(parsed, spec.addonId);
@@ -27215,17 +27215,17 @@ var JobJournal = class {
27215
27215
  return path$1.join(this.jobsDir, `${id}.json`);
27216
27216
  }
27217
27217
  writeAtomic(filePath, data) {
27218
- fs.mkdirSync(path$1.dirname(filePath), { recursive: true });
27218
+ fs$1.mkdirSync(path$1.dirname(filePath), { recursive: true });
27219
27219
  const tmp = `${filePath}.tmp.${process.pid}.${Date.now()}`;
27220
- fs.writeFileSync(tmp, JSON.stringify(data, null, 2), {
27220
+ fs$1.writeFileSync(tmp, JSON.stringify(data, null, 2), {
27221
27221
  encoding: "utf-8",
27222
27222
  mode: 384
27223
27223
  });
27224
- fs.renameSync(tmp, filePath);
27224
+ fs$1.renameSync(tmp, filePath);
27225
27225
  }
27226
27226
  readIndex() {
27227
27227
  try {
27228
- const raw = JSON.parse(fs.readFileSync(this.indexPath, "utf-8"));
27228
+ const raw = JSON.parse(fs$1.readFileSync(this.indexPath, "utf-8"));
27229
27229
  if (raw && Array.isArray(raw.jobIds)) return {
27230
27230
  version: 1,
27231
27231
  jobIds: raw.jobIds
@@ -27250,7 +27250,7 @@ var JobJournal = class {
27250
27250
  }
27251
27251
  getJob(id) {
27252
27252
  try {
27253
- const parsed = lifecycleJobSchema.safeParse(JSON.parse(fs.readFileSync(this.jobPath(id), "utf-8")));
27253
+ const parsed = lifecycleJobSchema.safeParse(JSON.parse(fs$1.readFileSync(this.jobPath(id), "utf-8")));
27254
27254
  return parsed.success ? parsed.data : null;
27255
27255
  } catch {
27256
27256
  return null;
@@ -27315,14 +27315,14 @@ var StagingArea = class {
27315
27315
  }
27316
27316
  async fetchAndStage(input) {
27317
27317
  const destDir = path$1.join(this.stagingDir, input.jobId, safeSegment(input.name));
27318
- fs.rmSync(destDir, {
27318
+ fs$1.rmSync(destDir, {
27319
27319
  recursive: true,
27320
27320
  force: true
27321
27321
  });
27322
27322
  const tgz = await this.deps.fetchTarball(input.name, input.version, input.signal);
27323
27323
  if (input.signal.aborted) throw new Error("staging aborted after fetch");
27324
27324
  await this.deps.extract(tgz, destDir);
27325
- const raw = JSON.parse(fs.readFileSync(path$1.join(destDir, "package.json"), "utf-8"));
27325
+ const raw = JSON.parse(fs$1.readFileSync(path$1.join(destDir, "package.json"), "utf-8"));
27326
27326
  if (typeof raw.version !== "string" || raw.version.length === 0) throw new Error(`staging validation failed: ${input.name} staged a package.json with no version`);
27327
27327
  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}`);
27328
27328
  return {
@@ -27331,7 +27331,7 @@ var StagingArea = class {
27331
27331
  };
27332
27332
  }
27333
27333
  cleanup(jobId) {
27334
- fs.rmSync(path$1.join(this.stagingDir, jobId), {
27334
+ fs$1.rmSync(path$1.join(this.stagingDir, jobId), {
27335
27335
  recursive: true,
27336
27336
  force: true
27337
27337
  });
@@ -27346,13 +27346,13 @@ var StagingArea = class {
27346
27346
  sweepOrphans() {
27347
27347
  let entries;
27348
27348
  try {
27349
- entries = fs.readdirSync(this.stagingDir);
27349
+ entries = fs$1.readdirSync(this.stagingDir);
27350
27350
  } catch {
27351
27351
  return 0;
27352
27352
  }
27353
27353
  let removed = 0;
27354
27354
  for (const name of entries) try {
27355
- fs.rmSync(path$1.join(this.stagingDir, name), {
27355
+ fs$1.rmSync(path$1.join(this.stagingDir, name), {
27356
27356
  recursive: true,
27357
27357
  force: true
27358
27358
  });
@@ -27530,7 +27530,7 @@ var LifecycleJobEngine = class {
27530
27530
  * on failure → `failed`.
27531
27531
  */
27532
27532
  async reconcileJob(job) {
27533
- const exists = this.deps.stagedPathExists ?? ((p) => fs.existsSync(p));
27533
+ const exists = this.deps.stagedPathExists ?? ((p) => fs$1.existsSync(p));
27534
27534
  for (const task of job.tasks) {
27535
27535
  if (task.target === "framework") {
27536
27536
  if (!this.isTerminal(task.phase)) this.skipFrameworkTask(job, task);
@@ -28171,7 +28171,7 @@ var CatalogRegistry = class {
28171
28171
  const file = path$1.join(packageDir, "i18n", `${lang}.json`);
28172
28172
  let text;
28173
28173
  try {
28174
- text = fs.readFileSync(file, "utf8");
28174
+ text = fs$1.readFileSync(file, "utf8");
28175
28175
  } catch {
28176
28176
  continue;
28177
28177
  }