@bastani/atomic 0.9.72 → 0.9.73-alpha.1

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.
@@ -75206,8 +75206,8 @@ function isLostBrokerSignature(error) {
75206
75206
  const code = error.code;
75207
75207
  return code === "ENOENT" || code === "ECONNRESET" || code === "EPIPE";
75208
75208
  }
75209
- async function classifyRegistrationFailure(error) {
75210
- if (!isLostBrokerSignature(error) || await isSocketAnswering(BROKER_SOCKET))
75209
+ async function classifyRegistrationFailure(error, socketPath) {
75210
+ if (!isLostBrokerSignature(error) || await isSocketAnswering(socketPath))
75211
75211
  return error;
75212
75212
  return new IntercomBrokerRetiringError(`Intercom broker went away before it registered this session: ${error.message}`, {
75213
75213
  cause: error
@@ -75232,7 +75232,7 @@ function isWorkflowFutureStageRosterEntries(value2) {
75232
75232
  function isWorkflowStageRosterEntries(value2) {
75233
75233
  return Array.isArray(value2) && value2.every((entry) => typeof entry === "object" && entry !== null && entry.kind === "workflow-stage" && typeof entry.runId === "string" && typeof entry.stageId === "string" && typeof entry.stageName === "string" && typeof entry.target === "string" && (entry.lifecycle === "pending" || entry.lifecycle === "running") && typeof entry.group === "string" && (entry.sessionId === undefined || typeof entry.sessionId === "string"));
75234
75234
  }
75235
- var BROKER_SOCKET, BROKER_CONNECT_TIMEOUT_MS = 1e4, PENDING_STAGE_ROUTE_ACK_TIMEOUT_MS = 1e4, GROUP_REQUEST_TIMEOUT_MS = 5000, PRESENCE_ACK_TIMEOUT_MS = 5000, RESTORING_RECIPIENT_REQUEST_TIMEOUT_MS = 5000, BROKER_BACKLOG_RETRIES = 6, BROKER_BACKLOG_RETRY_BASE_MS = 25, ConnectionClosedBeforeRegistrationError, HELD_SEND_GRACE_MS = 5000, IntercomPendingStageRouteRefusedError, PENDING_STAGE_ROUTE_REFUSAL_CODES, IntercomClient;
75235
+ var BROKER_CONNECT_TIMEOUT_MS = 1e4, PENDING_STAGE_ROUTE_ACK_TIMEOUT_MS = 1e4, GROUP_REQUEST_TIMEOUT_MS = 5000, PRESENCE_ACK_TIMEOUT_MS = 5000, RESTORING_RECIPIENT_REQUEST_TIMEOUT_MS = 5000, BROKER_BACKLOG_RETRIES = 6, BROKER_BACKLOG_RETRY_BASE_MS = 25, ConnectionClosedBeforeRegistrationError, HELD_SEND_GRACE_MS = 5000, IntercomPendingStageRouteRefusedError, PENDING_STAGE_ROUTE_REFUSAL_CODES, IntercomClient;
75236
75236
  var init_client = __esm(() => {
75237
75237
  init_broker_status();
75238
75238
  init_paths();
@@ -75251,7 +75251,6 @@ var init_client = __esm(() => {
75251
75251
  init_workflow_prediction_fields();
75252
75252
  init_released_child_errors();
75253
75253
  init_released_reply_errors();
75254
- BROKER_SOCKET = getBrokerSocketPath();
75255
75254
  ConnectionClosedBeforeRegistrationError = class ConnectionClosedBeforeRegistrationError extends Error {
75256
75255
  constructor() {
75257
75256
  super("Connection closed before registration");
@@ -75278,6 +75277,7 @@ var init_client = __esm(() => {
75278
75277
  preferredSessionId;
75279
75278
  acknowledgesReceipt;
75280
75279
  connectTimeoutMs;
75280
+ brokerSocketPath;
75281
75281
  brokerAcknowledgesReceipt = false;
75282
75282
  brokerAcknowledgesPendingStageRoutes = false;
75283
75283
  multiplexesPendingStageRoutes;
@@ -75354,6 +75354,7 @@ var init_client = __esm(() => {
75354
75354
  this.acknowledgesReceipt = options.acknowledgesReceipt === true;
75355
75355
  this.connectTimeoutMs = options.connectTimeoutMs ?? BROKER_CONNECT_TIMEOUT_MS;
75356
75356
  this.multiplexesPendingStageRoutes = options.multiplexesPendingStageRoutes === true;
75357
+ this.brokerSocketPath = options.brokerSocketPath ?? getBrokerSocketPath();
75357
75358
  }
75358
75359
  failPending(error) {
75359
75360
  this.pendingSends.rejectAll(error);
@@ -75436,7 +75437,7 @@ var init_client = __esm(() => {
75436
75437
  if (!(error instanceof Error))
75437
75438
  throw error;
75438
75439
  if (!isBacklogRefusal(error) || retry >= BROKER_BACKLOG_RETRIES) {
75439
- const classified = await classifyRegistrationFailure(error);
75440
+ const classified = await classifyRegistrationFailure(error, this.brokerSocketPath);
75440
75441
  if (attempt.signal.aborted)
75441
75442
  throw connectAborted();
75442
75443
  if (expectedRouting?.verify === true && classified instanceof ConnectionClosedBeforeRegistrationError) {
@@ -75461,7 +75462,7 @@ var init_client = __esm(() => {
75461
75462
  this._groups = normalizeGroups(session.groups, session.group);
75462
75463
  this.registrationExpectedRouting = expectedRouting;
75463
75464
  return new Promise((resolve, reject) => {
75464
- const socket = net2.connect(BROKER_SOCKET);
75465
+ const socket = net2.connect(this.brokerSocketPath);
75465
75466
  this.socket = socket;
75466
75467
  this.disconnectError = null;
75467
75468
  let settled = false;
@@ -76748,7 +76749,7 @@ function getDefaultBrokerCommandParts(brokerPath, extensionDir, runtimePath, run
76748
76749
  function quoteWindowsArg(value2) {
76749
76750
  return `"${value2.replace(/"/g, '""')}"`;
76750
76751
  }
76751
- function getWindowsHiddenLauncherPath(intercomDir = INTERCOM_DIR) {
76752
+ function getWindowsHiddenLauncherPath(intercomDir = getIntercomDirPath()) {
76752
76753
  return join31(intercomDir, "broker-launch.vbs");
76753
76754
  }
76754
76755
  function usesDefaultBrokerCommand(brokerCommand, brokerArgs) {
@@ -76780,7 +76781,7 @@ function writeWindowsHiddenLauncher(commandLine, launcherPath = getWindowsHidden
76780
76781
  writeFileSync6(launcherPath, getWindowsHiddenLauncherScript(commandLine), "utf-8");
76781
76782
  return launcherPath;
76782
76783
  }
76783
- function getBrokerLaunchSpec(brokerPath, brokerCommand, brokerArgs, extensionDir = EXTENSION_DIR, platform = process.platform, intercomDir = INTERCOM_DIR, nodePath = process.execPath, runtime = getCurrentBrokerRuntime(), logPath = BROKER_LOG) {
76784
+ function getBrokerLaunchSpec(brokerPath, brokerCommand, brokerArgs, extensionDir = EXTENSION_DIR, platform = process.platform, intercomDir = getIntercomDirPath(), nodePath = process.execPath, runtime = getCurrentBrokerRuntime(), logPath = getBrokerLogPath()) {
76784
76785
  if (platform === "win32") {
76785
76786
  const launcherPath = getWindowsHiddenLauncherPath(intercomDir);
76786
76787
  return {
@@ -76819,7 +76820,7 @@ function getBrokerSpawnOptions(extensionDir = EXTENSION_DIR, stderr = "ignore",
76819
76820
  windowsHide: true
76820
76821
  };
76821
76822
  }
76822
- function resetBrokerLog(logPath = BROKER_LOG) {
76823
+ function resetBrokerLog(logPath = getBrokerLogPath()) {
76823
76824
  ensurePrivateDirectory(dirname14(logPath));
76824
76825
  try {
76825
76826
  const previous = readBrokerLogTail(logPath);
@@ -76849,7 +76850,7 @@ async function resetBrokerLogOnceReleased() {
76849
76850
  }
76850
76851
  return true;
76851
76852
  }
76852
- function readBrokerLogTail(logPath = BROKER_LOG, maxBytes = BROKER_LOG_TAIL_BYTES) {
76853
+ function readBrokerLogTail(logPath = getBrokerLogPath(), maxBytes = BROKER_LOG_TAIL_BYTES) {
76853
76854
  let fd;
76854
76855
  try {
76855
76856
  fd = openSync4(logPath, "r");
@@ -76870,7 +76871,7 @@ function readBrokerLogTail(logPath = BROKER_LOG, maxBytes = BROKER_LOG_TAIL_BYTE
76870
76871
  }
76871
76872
  }
76872
76873
  }
76873
- function describeBrokerLog(logPath = BROKER_LOG) {
76874
+ function describeBrokerLog(logPath = getBrokerLogPath()) {
76874
76875
  const tail = readBrokerLogTail(logPath);
76875
76876
  if (tail.length === 0)
76876
76877
  return `Broker log: ${logPath} (empty)`;
@@ -76882,7 +76883,7 @@ function toError2(error) {
76882
76883
  return error instanceof Error ? error : new Error(String(error));
76883
76884
  }
76884
76885
  async function spawnBrokerIfNeeded(brokerCommand, brokerArgs, readyTimeoutMs = BROKER_READY_TIMEOUT_MS, extensionDir = EXTENSION_DIR) {
76885
- ensurePrivateDirectory(INTERCOM_DIR);
76886
+ ensurePrivateDirectory(getIntercomDirPath());
76886
76887
  if (await isBrokerRunning()) {
76887
76888
  return;
76888
76889
  }
@@ -76901,7 +76902,7 @@ async function spawnBrokerHoldingLock(lockOwner, brokerCommand, brokerArgs, read
76901
76902
  }
76902
76903
  const brokerPath = resolveBrokerEntrypoint(extensionDir);
76903
76904
  const launch = getBrokerLaunchSpec(brokerPath, brokerCommand, brokerArgs, extensionDir);
76904
- const announcement = launch.kind === "windows-launcher" ? { path: BROKER_START_ANNOUNCEMENT, token: randomUUID16() } : undefined;
76905
+ const announcement = launch.kind === "windows-launcher" ? { path: getBrokerStartAnnouncementPath(), token: randomUUID16() } : undefined;
76905
76906
  if (announcement !== undefined) {
76906
76907
  try {
76907
76908
  unlinkSync4(announcement.path);
@@ -76914,7 +76915,7 @@ async function spawnBrokerHoldingLock(lockOwner, brokerCommand, brokerArgs, read
76914
76915
  await waitForBroker(readyTimeoutMs);
76915
76916
  return;
76916
76917
  }
76917
- const logFd = launch.kind === "direct" ? openSync4(BROKER_LOG, "a") : undefined;
76918
+ const logFd = launch.kind === "direct" ? openSync4(getBrokerLogPath(), "a") : undefined;
76918
76919
  let child;
76919
76920
  try {
76920
76921
  child = spawn(launch.command, launch.args, getBrokerSpawnOptions(extensionDir, logFd ?? "ignore", announcement));
@@ -76971,10 +76972,10 @@ async function isBrokerRunning() {
76971
76972
  if (await checkSocketConnectable()) {
76972
76973
  return true;
76973
76974
  }
76974
- if (!existsSync9(BROKER_PID))
76975
+ if (!existsSync9(getBrokerPidPath()))
76975
76976
  return false;
76976
76977
  try {
76977
- const pid = parseInt(readFileSync7(BROKER_PID, "utf-8").trim(), 10);
76978
+ const pid = parseInt(readFileSync7(getBrokerPidPath(), "utf-8").trim(), 10);
76978
76979
  if (!Number.isFinite(pid))
76979
76980
  return false;
76980
76981
  process.kill(pid, 0);
@@ -76984,20 +76985,20 @@ async function isBrokerRunning() {
76984
76985
  }
76985
76986
  }
76986
76987
  function checkSocketConnectable() {
76987
- return isSocketAnswering(BROKER_SOCKET2);
76988
+ return isSocketAnswering(getBrokerSocketPath());
76988
76989
  }
76989
76990
  function handSpawnLockToBroker(pid, owner) {
76990
76991
  if (pid === undefined || !ownsSpawnLock(owner))
76991
76992
  return false;
76992
76993
  try {
76993
- appendFileSync(BROKER_SPAWN_LOCK, `${pid}
76994
+ appendFileSync(getBrokerSpawnLockPath(), `${pid}
76994
76995
  `);
76995
76996
  return true;
76996
76997
  } catch {
76997
76998
  return false;
76998
76999
  }
76999
77000
  }
77000
- function ownsSpawnLock(owner, lockPath = BROKER_SPAWN_LOCK) {
77001
+ function ownsSpawnLock(owner, lockPath = getBrokerSpawnLockPath()) {
77001
77002
  try {
77002
77003
  return readFileSync7(lockPath, "utf-8").startsWith(owner);
77003
77004
  } catch {
@@ -77011,7 +77012,7 @@ function acquireSpawnLock() {
77011
77012
  ${Date.now()}
77012
77013
  `;
77013
77014
  try {
77014
- writeFileSync6(BROKER_SPAWN_LOCK, owner, { flag: "wx" });
77015
+ writeFileSync6(getBrokerSpawnLockPath(), owner, { flag: "wx" });
77015
77016
  return owner;
77016
77017
  } catch (error) {
77017
77018
  if (!(error instanceof Error) || error.code !== "EEXIST") {
@@ -77019,7 +77020,7 @@ ${Date.now()}
77019
77020
  }
77020
77021
  if (isSpawnLockStale()) {
77021
77022
  try {
77022
- unlinkSync4(BROKER_SPAWN_LOCK);
77023
+ unlinkSync4(getBrokerSpawnLockPath());
77023
77024
  } catch {}
77024
77025
  continue;
77025
77026
  }
@@ -77036,7 +77037,7 @@ function isProcessAlive(pid) {
77036
77037
  return error.code === "EPERM";
77037
77038
  }
77038
77039
  }
77039
- function isSpawnLockStale(lockPath = BROKER_SPAWN_LOCK, nowMs = Date.now()) {
77040
+ function isSpawnLockStale(lockPath = getBrokerSpawnLockPath(), nowMs = Date.now()) {
77040
77041
  if (!existsSync9(lockPath)) {
77041
77042
  return false;
77042
77043
  }
@@ -77055,7 +77056,7 @@ function isSpawnLockStale(lockPath = BROKER_SPAWN_LOCK, nowMs = Date.now()) {
77055
77056
  return true;
77056
77057
  }
77057
77058
  }
77058
- function releaseSpawnLock(owner, lockPath = BROKER_SPAWN_LOCK) {
77059
+ function releaseSpawnLock(owner, lockPath = getBrokerSpawnLockPath()) {
77059
77060
  if (!ownsSpawnLock(owner, lockPath))
77060
77061
  return;
77061
77062
  try {
@@ -77083,7 +77084,7 @@ ${describeBrokerLog()}`);
77083
77084
  ` + "The broker did not answer on its socket in time; it may still be starting, which a busy machine or an empty jiti " + "cache slows. Try again, or raise `brokerStartupTimeoutMs` in the Intercom config.json (default " + `${BROKER_READY_TIMEOUT_MS} ms).
77084
77085
  ${describeBrokerLog()}`);
77085
77086
  }
77086
- var INTERCOM_DIR, EXTENSION_DIR, BROKER_SOCKET2, BROKER_PID, BROKER_SPAWN_LOCK, BROKER_LOG, BROKER_START_ANNOUNCEMENT, BROKER_LOG_TAIL_BYTES, BROKER_POLL_INITIAL_INTERVAL_MS = 10, BROKER_POLL_MAX_INTERVAL_MS = 100, BROKER_SPAWN_LOCK_MAX_AGE_MS = 60000, INTERNAL_INTERCOM_BROKER_ARG = "--atomic-internal-intercom-broker", BROKER_LOG_RELEASE_WAIT_MS = 1000;
77087
+ var EXTENSION_DIR, BROKER_LOG_TAIL_BYTES, BROKER_POLL_INITIAL_INTERVAL_MS = 10, BROKER_POLL_MAX_INTERVAL_MS = 100, BROKER_SPAWN_LOCK_MAX_AGE_MS = 60000, INTERNAL_INTERCOM_BROKER_ARG = "--atomic-internal-intercom-broker", BROKER_LOG_RELEASE_WAIT_MS = 1000;
77087
77088
  var init_spawn = __esm(() => {
77088
77089
  init_socket_liveness();
77089
77090
  init_start_announcement();
@@ -77093,13 +77094,7 @@ var init_spawn = __esm(() => {
77093
77094
  init_protocol_version();
77094
77095
  init_shared_storage_setting();
77095
77096
  init_paths();
77096
- INTERCOM_DIR = getIntercomDirPath();
77097
77097
  EXTENSION_DIR = resolveIntercomPackageRoot(import.meta.url);
77098
- BROKER_SOCKET2 = getBrokerSocketPath();
77099
- BROKER_PID = getBrokerPidPath();
77100
- BROKER_SPAWN_LOCK = getBrokerSpawnLockPath();
77101
- BROKER_LOG = getBrokerLogPath();
77102
- BROKER_START_ANNOUNCEMENT = getBrokerStartAnnouncementPath();
77103
77098
  BROKER_LOG_TAIL_BYTES = 8 * 1024;
77104
77099
  });
77105
77100
 
@@ -72922,8 +72922,8 @@ function isLostBrokerSignature(error) {
72922
72922
  const code = error.code;
72923
72923
  return code === "ENOENT" || code === "ECONNRESET" || code === "EPIPE";
72924
72924
  }
72925
- async function classifyRegistrationFailure(error) {
72926
- if (!isLostBrokerSignature(error) || await isSocketAnswering(BROKER_SOCKET))
72925
+ async function classifyRegistrationFailure(error, socketPath) {
72926
+ if (!isLostBrokerSignature(error) || await isSocketAnswering(socketPath))
72927
72927
  return error;
72928
72928
  return new IntercomBrokerRetiringError(`Intercom broker went away before it registered this session: ${error.message}`, {
72929
72929
  cause: error
@@ -72948,7 +72948,7 @@ function isWorkflowFutureStageRosterEntries(value2) {
72948
72948
  function isWorkflowStageRosterEntries(value2) {
72949
72949
  return Array.isArray(value2) && value2.every((entry) => typeof entry === "object" && entry !== null && entry.kind === "workflow-stage" && typeof entry.runId === "string" && typeof entry.stageId === "string" && typeof entry.stageName === "string" && typeof entry.target === "string" && (entry.lifecycle === "pending" || entry.lifecycle === "running") && typeof entry.group === "string" && (entry.sessionId === undefined || typeof entry.sessionId === "string"));
72950
72950
  }
72951
- var BROKER_SOCKET, BROKER_CONNECT_TIMEOUT_MS = 1e4, PENDING_STAGE_ROUTE_ACK_TIMEOUT_MS = 1e4, GROUP_REQUEST_TIMEOUT_MS = 5000, PRESENCE_ACK_TIMEOUT_MS = 5000, RESTORING_RECIPIENT_REQUEST_TIMEOUT_MS = 5000, BROKER_BACKLOG_RETRIES = 6, BROKER_BACKLOG_RETRY_BASE_MS = 25, ConnectionClosedBeforeRegistrationError, HELD_SEND_GRACE_MS = 5000, IntercomPendingStageRouteRefusedError, PENDING_STAGE_ROUTE_REFUSAL_CODES, IntercomClient;
72951
+ var BROKER_CONNECT_TIMEOUT_MS = 1e4, PENDING_STAGE_ROUTE_ACK_TIMEOUT_MS = 1e4, GROUP_REQUEST_TIMEOUT_MS = 5000, PRESENCE_ACK_TIMEOUT_MS = 5000, RESTORING_RECIPIENT_REQUEST_TIMEOUT_MS = 5000, BROKER_BACKLOG_RETRIES = 6, BROKER_BACKLOG_RETRY_BASE_MS = 25, ConnectionClosedBeforeRegistrationError, HELD_SEND_GRACE_MS = 5000, IntercomPendingStageRouteRefusedError, PENDING_STAGE_ROUTE_REFUSAL_CODES, IntercomClient;
72952
72952
  var init_client = __esm(() => {
72953
72953
  init_broker_status();
72954
72954
  init_paths();
@@ -72967,7 +72967,6 @@ var init_client = __esm(() => {
72967
72967
  init_workflow_prediction_fields();
72968
72968
  init_released_child_errors();
72969
72969
  init_released_reply_errors();
72970
- BROKER_SOCKET = getBrokerSocketPath();
72971
72970
  ConnectionClosedBeforeRegistrationError = class ConnectionClosedBeforeRegistrationError extends Error {
72972
72971
  constructor() {
72973
72972
  super("Connection closed before registration");
@@ -72994,6 +72993,7 @@ var init_client = __esm(() => {
72994
72993
  preferredSessionId;
72995
72994
  acknowledgesReceipt;
72996
72995
  connectTimeoutMs;
72996
+ brokerSocketPath;
72997
72997
  brokerAcknowledgesReceipt = false;
72998
72998
  brokerAcknowledgesPendingStageRoutes = false;
72999
72999
  multiplexesPendingStageRoutes;
@@ -73070,6 +73070,7 @@ var init_client = __esm(() => {
73070
73070
  this.acknowledgesReceipt = options.acknowledgesReceipt === true;
73071
73071
  this.connectTimeoutMs = options.connectTimeoutMs ?? BROKER_CONNECT_TIMEOUT_MS;
73072
73072
  this.multiplexesPendingStageRoutes = options.multiplexesPendingStageRoutes === true;
73073
+ this.brokerSocketPath = options.brokerSocketPath ?? getBrokerSocketPath();
73073
73074
  }
73074
73075
  failPending(error) {
73075
73076
  this.pendingSends.rejectAll(error);
@@ -73152,7 +73153,7 @@ var init_client = __esm(() => {
73152
73153
  if (!(error instanceof Error))
73153
73154
  throw error;
73154
73155
  if (!isBacklogRefusal(error) || retry >= BROKER_BACKLOG_RETRIES) {
73155
- const classified = await classifyRegistrationFailure(error);
73156
+ const classified = await classifyRegistrationFailure(error, this.brokerSocketPath);
73156
73157
  if (attempt.signal.aborted)
73157
73158
  throw connectAborted();
73158
73159
  if (expectedRouting?.verify === true && classified instanceof ConnectionClosedBeforeRegistrationError) {
@@ -73177,7 +73178,7 @@ var init_client = __esm(() => {
73177
73178
  this._groups = normalizeGroups(session.groups, session.group);
73178
73179
  this.registrationExpectedRouting = expectedRouting;
73179
73180
  return new Promise((resolve, reject) => {
73180
- const socket = net2.connect(BROKER_SOCKET);
73181
+ const socket = net2.connect(this.brokerSocketPath);
73181
73182
  this.socket = socket;
73182
73183
  this.disconnectError = null;
73183
73184
  let settled = false;
@@ -74464,7 +74465,7 @@ function getDefaultBrokerCommandParts(brokerPath, extensionDir, runtimePath, run
74464
74465
  function quoteWindowsArg(value2) {
74465
74466
  return `"${value2.replace(/"/g, '""')}"`;
74466
74467
  }
74467
- function getWindowsHiddenLauncherPath(intercomDir = INTERCOM_DIR) {
74468
+ function getWindowsHiddenLauncherPath(intercomDir = getIntercomDirPath()) {
74468
74469
  return join30(intercomDir, "broker-launch.vbs");
74469
74470
  }
74470
74471
  function usesDefaultBrokerCommand(brokerCommand, brokerArgs) {
@@ -74496,7 +74497,7 @@ function writeWindowsHiddenLauncher(commandLine, launcherPath = getWindowsHidden
74496
74497
  writeFileSync6(launcherPath, getWindowsHiddenLauncherScript(commandLine), "utf-8");
74497
74498
  return launcherPath;
74498
74499
  }
74499
- function getBrokerLaunchSpec(brokerPath, brokerCommand, brokerArgs, extensionDir = EXTENSION_DIR, platform = process.platform, intercomDir = INTERCOM_DIR, nodePath = process.execPath, runtime = getCurrentBrokerRuntime(), logPath = BROKER_LOG) {
74500
+ function getBrokerLaunchSpec(brokerPath, brokerCommand, brokerArgs, extensionDir = EXTENSION_DIR, platform = process.platform, intercomDir = getIntercomDirPath(), nodePath = process.execPath, runtime = getCurrentBrokerRuntime(), logPath = getBrokerLogPath()) {
74500
74501
  if (platform === "win32") {
74501
74502
  const launcherPath = getWindowsHiddenLauncherPath(intercomDir);
74502
74503
  return {
@@ -74535,7 +74536,7 @@ function getBrokerSpawnOptions(extensionDir = EXTENSION_DIR, stderr = "ignore",
74535
74536
  windowsHide: true
74536
74537
  };
74537
74538
  }
74538
- function resetBrokerLog(logPath = BROKER_LOG) {
74539
+ function resetBrokerLog(logPath = getBrokerLogPath()) {
74539
74540
  ensurePrivateDirectory(dirname14(logPath));
74540
74541
  try {
74541
74542
  const previous = readBrokerLogTail(logPath);
@@ -74565,7 +74566,7 @@ async function resetBrokerLogOnceReleased() {
74565
74566
  }
74566
74567
  return true;
74567
74568
  }
74568
- function readBrokerLogTail(logPath = BROKER_LOG, maxBytes = BROKER_LOG_TAIL_BYTES) {
74569
+ function readBrokerLogTail(logPath = getBrokerLogPath(), maxBytes = BROKER_LOG_TAIL_BYTES) {
74569
74570
  let fd;
74570
74571
  try {
74571
74572
  fd = openSync3(logPath, "r");
@@ -74586,7 +74587,7 @@ function readBrokerLogTail(logPath = BROKER_LOG, maxBytes = BROKER_LOG_TAIL_BYTE
74586
74587
  }
74587
74588
  }
74588
74589
  }
74589
- function describeBrokerLog(logPath = BROKER_LOG) {
74590
+ function describeBrokerLog(logPath = getBrokerLogPath()) {
74590
74591
  const tail = readBrokerLogTail(logPath);
74591
74592
  if (tail.length === 0)
74592
74593
  return `Broker log: ${logPath} (empty)`;
@@ -74598,7 +74599,7 @@ function toError2(error) {
74598
74599
  return error instanceof Error ? error : new Error(String(error));
74599
74600
  }
74600
74601
  async function spawnBrokerIfNeeded(brokerCommand, brokerArgs, readyTimeoutMs = BROKER_READY_TIMEOUT_MS, extensionDir = EXTENSION_DIR) {
74601
- ensurePrivateDirectory(INTERCOM_DIR);
74602
+ ensurePrivateDirectory(getIntercomDirPath());
74602
74603
  if (await isBrokerRunning()) {
74603
74604
  return;
74604
74605
  }
@@ -74617,7 +74618,7 @@ async function spawnBrokerHoldingLock(lockOwner, brokerCommand, brokerArgs, read
74617
74618
  }
74618
74619
  const brokerPath = resolveBrokerEntrypoint(extensionDir);
74619
74620
  const launch = getBrokerLaunchSpec(brokerPath, brokerCommand, brokerArgs, extensionDir);
74620
- const announcement = launch.kind === "windows-launcher" ? { path: BROKER_START_ANNOUNCEMENT, token: randomUUID15() } : undefined;
74621
+ const announcement = launch.kind === "windows-launcher" ? { path: getBrokerStartAnnouncementPath(), token: randomUUID15() } : undefined;
74621
74622
  if (announcement !== undefined) {
74622
74623
  try {
74623
74624
  unlinkSync4(announcement.path);
@@ -74630,7 +74631,7 @@ async function spawnBrokerHoldingLock(lockOwner, brokerCommand, brokerArgs, read
74630
74631
  await waitForBroker(readyTimeoutMs);
74631
74632
  return;
74632
74633
  }
74633
- const logFd = launch.kind === "direct" ? openSync3(BROKER_LOG, "a") : undefined;
74634
+ const logFd = launch.kind === "direct" ? openSync3(getBrokerLogPath(), "a") : undefined;
74634
74635
  let child;
74635
74636
  try {
74636
74637
  child = spawn(launch.command, launch.args, getBrokerSpawnOptions(extensionDir, logFd ?? "ignore", announcement));
@@ -74687,10 +74688,10 @@ async function isBrokerRunning() {
74687
74688
  if (await checkSocketConnectable()) {
74688
74689
  return true;
74689
74690
  }
74690
- if (!existsSync8(BROKER_PID))
74691
+ if (!existsSync8(getBrokerPidPath()))
74691
74692
  return false;
74692
74693
  try {
74693
- const pid = parseInt(readFileSync7(BROKER_PID, "utf-8").trim(), 10);
74694
+ const pid = parseInt(readFileSync7(getBrokerPidPath(), "utf-8").trim(), 10);
74694
74695
  if (!Number.isFinite(pid))
74695
74696
  return false;
74696
74697
  process.kill(pid, 0);
@@ -74700,20 +74701,20 @@ async function isBrokerRunning() {
74700
74701
  }
74701
74702
  }
74702
74703
  function checkSocketConnectable() {
74703
- return isSocketAnswering(BROKER_SOCKET2);
74704
+ return isSocketAnswering(getBrokerSocketPath());
74704
74705
  }
74705
74706
  function handSpawnLockToBroker(pid, owner) {
74706
74707
  if (pid === undefined || !ownsSpawnLock(owner))
74707
74708
  return false;
74708
74709
  try {
74709
- appendFileSync(BROKER_SPAWN_LOCK, `${pid}
74710
+ appendFileSync(getBrokerSpawnLockPath(), `${pid}
74710
74711
  `);
74711
74712
  return true;
74712
74713
  } catch {
74713
74714
  return false;
74714
74715
  }
74715
74716
  }
74716
- function ownsSpawnLock(owner, lockPath = BROKER_SPAWN_LOCK) {
74717
+ function ownsSpawnLock(owner, lockPath = getBrokerSpawnLockPath()) {
74717
74718
  try {
74718
74719
  return readFileSync7(lockPath, "utf-8").startsWith(owner);
74719
74720
  } catch {
@@ -74727,7 +74728,7 @@ function acquireSpawnLock() {
74727
74728
  ${Date.now()}
74728
74729
  `;
74729
74730
  try {
74730
- writeFileSync6(BROKER_SPAWN_LOCK, owner, { flag: "wx" });
74731
+ writeFileSync6(getBrokerSpawnLockPath(), owner, { flag: "wx" });
74731
74732
  return owner;
74732
74733
  } catch (error) {
74733
74734
  if (!(error instanceof Error) || error.code !== "EEXIST") {
@@ -74735,7 +74736,7 @@ ${Date.now()}
74735
74736
  }
74736
74737
  if (isSpawnLockStale()) {
74737
74738
  try {
74738
- unlinkSync4(BROKER_SPAWN_LOCK);
74739
+ unlinkSync4(getBrokerSpawnLockPath());
74739
74740
  } catch {}
74740
74741
  continue;
74741
74742
  }
@@ -74752,7 +74753,7 @@ function isProcessAlive(pid) {
74752
74753
  return error.code === "EPERM";
74753
74754
  }
74754
74755
  }
74755
- function isSpawnLockStale(lockPath = BROKER_SPAWN_LOCK, nowMs = Date.now()) {
74756
+ function isSpawnLockStale(lockPath = getBrokerSpawnLockPath(), nowMs = Date.now()) {
74756
74757
  if (!existsSync8(lockPath)) {
74757
74758
  return false;
74758
74759
  }
@@ -74771,7 +74772,7 @@ function isSpawnLockStale(lockPath = BROKER_SPAWN_LOCK, nowMs = Date.now()) {
74771
74772
  return true;
74772
74773
  }
74773
74774
  }
74774
- function releaseSpawnLock(owner, lockPath = BROKER_SPAWN_LOCK) {
74775
+ function releaseSpawnLock(owner, lockPath = getBrokerSpawnLockPath()) {
74775
74776
  if (!ownsSpawnLock(owner, lockPath))
74776
74777
  return;
74777
74778
  try {
@@ -74799,7 +74800,7 @@ ${describeBrokerLog()}`);
74799
74800
  ` + "The broker did not answer on its socket in time; it may still be starting, which a busy machine or an empty jiti " + "cache slows. Try again, or raise `brokerStartupTimeoutMs` in the Intercom config.json (default " + `${BROKER_READY_TIMEOUT_MS} ms).
74800
74801
  ${describeBrokerLog()}`);
74801
74802
  }
74802
- var INTERCOM_DIR, EXTENSION_DIR, BROKER_SOCKET2, BROKER_PID, BROKER_SPAWN_LOCK, BROKER_LOG, BROKER_START_ANNOUNCEMENT, BROKER_LOG_TAIL_BYTES, BROKER_POLL_INITIAL_INTERVAL_MS = 10, BROKER_POLL_MAX_INTERVAL_MS = 100, BROKER_SPAWN_LOCK_MAX_AGE_MS = 60000, INTERNAL_INTERCOM_BROKER_ARG = "--atomic-internal-intercom-broker", BROKER_LOG_RELEASE_WAIT_MS = 1000;
74803
+ var EXTENSION_DIR, BROKER_LOG_TAIL_BYTES, BROKER_POLL_INITIAL_INTERVAL_MS = 10, BROKER_POLL_MAX_INTERVAL_MS = 100, BROKER_SPAWN_LOCK_MAX_AGE_MS = 60000, INTERNAL_INTERCOM_BROKER_ARG = "--atomic-internal-intercom-broker", BROKER_LOG_RELEASE_WAIT_MS = 1000;
74803
74804
  var init_spawn = __esm(() => {
74804
74805
  init_socket_liveness();
74805
74806
  init_start_announcement();
@@ -74809,13 +74810,7 @@ var init_spawn = __esm(() => {
74809
74810
  init_protocol_version();
74810
74811
  init_shared_storage_setting();
74811
74812
  init_paths();
74812
- INTERCOM_DIR = getIntercomDirPath();
74813
74813
  EXTENSION_DIR = resolveIntercomPackageRoot(import.meta.url);
74814
- BROKER_SOCKET2 = getBrokerSocketPath();
74815
- BROKER_PID = getBrokerPidPath();
74816
- BROKER_SPAWN_LOCK = getBrokerSpawnLockPath();
74817
- BROKER_LOG = getBrokerLogPath();
74818
- BROKER_START_ANNOUNCEMENT = getBrokerStartAnnouncementPath();
74819
74814
  BROKER_LOG_TAIL_BYTES = 8 * 1024;
74820
74815
  });
74821
74816