@bastani/atomic 0.9.72 → 0.9.73

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.
@@ -73074,8 +73074,8 @@ function isLostBrokerSignature(error) {
73074
73074
  const code = error.code;
73075
73075
  return code === "ENOENT" || code === "ECONNRESET" || code === "EPIPE";
73076
73076
  }
73077
- async function classifyRegistrationFailure(error) {
73078
- if (!isLostBrokerSignature(error) || await isSocketAnswering(BROKER_SOCKET))
73077
+ async function classifyRegistrationFailure(error, socketPath) {
73078
+ if (!isLostBrokerSignature(error) || await isSocketAnswering(socketPath))
73079
73079
  return error;
73080
73080
  return new IntercomBrokerRetiringError(`Intercom broker went away before it registered this session: ${error.message}`, {
73081
73081
  cause: error
@@ -73100,7 +73100,7 @@ function isWorkflowFutureStageRosterEntries(value2) {
73100
73100
  function isWorkflowStageRosterEntries(value2) {
73101
73101
  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"));
73102
73102
  }
73103
- 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;
73103
+ 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;
73104
73104
  var init_client = __esm(() => {
73105
73105
  init_broker_status();
73106
73106
  init_paths();
@@ -73119,7 +73119,6 @@ var init_client = __esm(() => {
73119
73119
  init_workflow_prediction_fields();
73120
73120
  init_released_child_errors();
73121
73121
  init_released_reply_errors();
73122
- BROKER_SOCKET = getBrokerSocketPath();
73123
73122
  ConnectionClosedBeforeRegistrationError = class ConnectionClosedBeforeRegistrationError extends Error {
73124
73123
  constructor() {
73125
73124
  super("Connection closed before registration");
@@ -73146,6 +73145,7 @@ var init_client = __esm(() => {
73146
73145
  preferredSessionId;
73147
73146
  acknowledgesReceipt;
73148
73147
  connectTimeoutMs;
73148
+ brokerSocketPath;
73149
73149
  brokerAcknowledgesReceipt = false;
73150
73150
  brokerAcknowledgesPendingStageRoutes = false;
73151
73151
  multiplexesPendingStageRoutes;
@@ -73222,6 +73222,7 @@ var init_client = __esm(() => {
73222
73222
  this.acknowledgesReceipt = options.acknowledgesReceipt === true;
73223
73223
  this.connectTimeoutMs = options.connectTimeoutMs ?? BROKER_CONNECT_TIMEOUT_MS;
73224
73224
  this.multiplexesPendingStageRoutes = options.multiplexesPendingStageRoutes === true;
73225
+ this.brokerSocketPath = options.brokerSocketPath ?? getBrokerSocketPath();
73225
73226
  }
73226
73227
  failPending(error) {
73227
73228
  this.pendingSends.rejectAll(error);
@@ -73304,7 +73305,7 @@ var init_client = __esm(() => {
73304
73305
  if (!(error instanceof Error))
73305
73306
  throw error;
73306
73307
  if (!isBacklogRefusal(error) || retry >= BROKER_BACKLOG_RETRIES) {
73307
- const classified = await classifyRegistrationFailure(error);
73308
+ const classified = await classifyRegistrationFailure(error, this.brokerSocketPath);
73308
73309
  if (attempt.signal.aborted)
73309
73310
  throw connectAborted();
73310
73311
  if (expectedRouting?.verify === true && classified instanceof ConnectionClosedBeforeRegistrationError) {
@@ -73329,7 +73330,7 @@ var init_client = __esm(() => {
73329
73330
  this._groups = normalizeGroups(session.groups, session.group);
73330
73331
  this.registrationExpectedRouting = expectedRouting;
73331
73332
  return new Promise((resolve, reject) => {
73332
- const socket = net2.connect(BROKER_SOCKET);
73333
+ const socket = net2.connect(this.brokerSocketPath);
73333
73334
  this.socket = socket;
73334
73335
  this.disconnectError = null;
73335
73336
  let settled = false;
@@ -74616,7 +74617,7 @@ function getDefaultBrokerCommandParts(brokerPath, extensionDir, runtimePath, run
74616
74617
  function quoteWindowsArg(value2) {
74617
74618
  return `"${value2.replace(/"/g, '""')}"`;
74618
74619
  }
74619
- function getWindowsHiddenLauncherPath(intercomDir = INTERCOM_DIR) {
74620
+ function getWindowsHiddenLauncherPath(intercomDir = getIntercomDirPath()) {
74620
74621
  return join31(intercomDir, "broker-launch.vbs");
74621
74622
  }
74622
74623
  function usesDefaultBrokerCommand(brokerCommand, brokerArgs) {
@@ -74648,7 +74649,7 @@ function writeWindowsHiddenLauncher(commandLine, launcherPath = getWindowsHidden
74648
74649
  writeFileSync7(launcherPath, getWindowsHiddenLauncherScript(commandLine), "utf-8");
74649
74650
  return launcherPath;
74650
74651
  }
74651
- function getBrokerLaunchSpec(brokerPath, brokerCommand, brokerArgs, extensionDir = EXTENSION_DIR, platform = process.platform, intercomDir = INTERCOM_DIR, nodePath = process.execPath, runtime = getCurrentBrokerRuntime(), logPath = BROKER_LOG) {
74652
+ function getBrokerLaunchSpec(brokerPath, brokerCommand, brokerArgs, extensionDir = EXTENSION_DIR, platform = process.platform, intercomDir = getIntercomDirPath(), nodePath = process.execPath, runtime = getCurrentBrokerRuntime(), logPath = getBrokerLogPath()) {
74652
74653
  if (platform === "win32") {
74653
74654
  const launcherPath = getWindowsHiddenLauncherPath(intercomDir);
74654
74655
  return {
@@ -74687,7 +74688,7 @@ function getBrokerSpawnOptions(extensionDir = EXTENSION_DIR, stderr = "ignore",
74687
74688
  windowsHide: true
74688
74689
  };
74689
74690
  }
74690
- function resetBrokerLog(logPath = BROKER_LOG) {
74691
+ function resetBrokerLog(logPath = getBrokerLogPath()) {
74691
74692
  ensurePrivateDirectory(dirname15(logPath));
74692
74693
  try {
74693
74694
  const previous = readBrokerLogTail(logPath);
@@ -74717,7 +74718,7 @@ async function resetBrokerLogOnceReleased() {
74717
74718
  }
74718
74719
  return true;
74719
74720
  }
74720
- function readBrokerLogTail(logPath = BROKER_LOG, maxBytes = BROKER_LOG_TAIL_BYTES) {
74721
+ function readBrokerLogTail(logPath = getBrokerLogPath(), maxBytes = BROKER_LOG_TAIL_BYTES) {
74721
74722
  let fd;
74722
74723
  try {
74723
74724
  fd = openSync3(logPath, "r");
@@ -74738,7 +74739,7 @@ function readBrokerLogTail(logPath = BROKER_LOG, maxBytes = BROKER_LOG_TAIL_BYTE
74738
74739
  }
74739
74740
  }
74740
74741
  }
74741
- function describeBrokerLog(logPath = BROKER_LOG) {
74742
+ function describeBrokerLog(logPath = getBrokerLogPath()) {
74742
74743
  const tail = readBrokerLogTail(logPath);
74743
74744
  if (tail.length === 0)
74744
74745
  return `Broker log: ${logPath} (empty)`;
@@ -74750,7 +74751,7 @@ function toError2(error) {
74750
74751
  return error instanceof Error ? error : new Error(String(error));
74751
74752
  }
74752
74753
  async function spawnBrokerIfNeeded(brokerCommand, brokerArgs, readyTimeoutMs = BROKER_READY_TIMEOUT_MS, extensionDir = EXTENSION_DIR) {
74753
- ensurePrivateDirectory(INTERCOM_DIR);
74754
+ ensurePrivateDirectory(getIntercomDirPath());
74754
74755
  if (await isBrokerRunning()) {
74755
74756
  return;
74756
74757
  }
@@ -74769,7 +74770,7 @@ async function spawnBrokerHoldingLock(lockOwner, brokerCommand, brokerArgs, read
74769
74770
  }
74770
74771
  const brokerPath = resolveBrokerEntrypoint(extensionDir);
74771
74772
  const launch = getBrokerLaunchSpec(brokerPath, brokerCommand, brokerArgs, extensionDir);
74772
- const announcement = launch.kind === "windows-launcher" ? { path: BROKER_START_ANNOUNCEMENT, token: randomUUID16() } : undefined;
74773
+ const announcement = launch.kind === "windows-launcher" ? { path: getBrokerStartAnnouncementPath(), token: randomUUID16() } : undefined;
74773
74774
  if (announcement !== undefined) {
74774
74775
  try {
74775
74776
  unlinkSync4(announcement.path);
@@ -74782,7 +74783,7 @@ async function spawnBrokerHoldingLock(lockOwner, brokerCommand, brokerArgs, read
74782
74783
  await waitForBroker(readyTimeoutMs);
74783
74784
  return;
74784
74785
  }
74785
- const logFd = launch.kind === "direct" ? openSync3(BROKER_LOG, "a") : undefined;
74786
+ const logFd = launch.kind === "direct" ? openSync3(getBrokerLogPath(), "a") : undefined;
74786
74787
  let child;
74787
74788
  try {
74788
74789
  child = spawn(launch.command, launch.args, getBrokerSpawnOptions(extensionDir, logFd ?? "ignore", announcement));
@@ -74839,10 +74840,10 @@ async function isBrokerRunning() {
74839
74840
  if (await checkSocketConnectable()) {
74840
74841
  return true;
74841
74842
  }
74842
- if (!existsSync9(BROKER_PID))
74843
+ if (!existsSync9(getBrokerPidPath()))
74843
74844
  return false;
74844
74845
  try {
74845
- const pid = parseInt(readFileSync8(BROKER_PID, "utf-8").trim(), 10);
74846
+ const pid = parseInt(readFileSync8(getBrokerPidPath(), "utf-8").trim(), 10);
74846
74847
  if (!Number.isFinite(pid))
74847
74848
  return false;
74848
74849
  process.kill(pid, 0);
@@ -74852,20 +74853,20 @@ async function isBrokerRunning() {
74852
74853
  }
74853
74854
  }
74854
74855
  function checkSocketConnectable() {
74855
- return isSocketAnswering(BROKER_SOCKET2);
74856
+ return isSocketAnswering(getBrokerSocketPath());
74856
74857
  }
74857
74858
  function handSpawnLockToBroker(pid, owner) {
74858
74859
  if (pid === undefined || !ownsSpawnLock(owner))
74859
74860
  return false;
74860
74861
  try {
74861
- appendFileSync(BROKER_SPAWN_LOCK, `${pid}
74862
+ appendFileSync(getBrokerSpawnLockPath(), `${pid}
74862
74863
  `);
74863
74864
  return true;
74864
74865
  } catch {
74865
74866
  return false;
74866
74867
  }
74867
74868
  }
74868
- function ownsSpawnLock(owner, lockPath = BROKER_SPAWN_LOCK) {
74869
+ function ownsSpawnLock(owner, lockPath = getBrokerSpawnLockPath()) {
74869
74870
  try {
74870
74871
  return readFileSync8(lockPath, "utf-8").startsWith(owner);
74871
74872
  } catch {
@@ -74879,7 +74880,7 @@ function acquireSpawnLock() {
74879
74880
  ${Date.now()}
74880
74881
  `;
74881
74882
  try {
74882
- writeFileSync7(BROKER_SPAWN_LOCK, owner, { flag: "wx" });
74883
+ writeFileSync7(getBrokerSpawnLockPath(), owner, { flag: "wx" });
74883
74884
  return owner;
74884
74885
  } catch (error) {
74885
74886
  if (!(error instanceof Error) || error.code !== "EEXIST") {
@@ -74887,7 +74888,7 @@ ${Date.now()}
74887
74888
  }
74888
74889
  if (isSpawnLockStale()) {
74889
74890
  try {
74890
- unlinkSync4(BROKER_SPAWN_LOCK);
74891
+ unlinkSync4(getBrokerSpawnLockPath());
74891
74892
  } catch {}
74892
74893
  continue;
74893
74894
  }
@@ -74904,7 +74905,7 @@ function isProcessAlive(pid) {
74904
74905
  return error.code === "EPERM";
74905
74906
  }
74906
74907
  }
74907
- function isSpawnLockStale(lockPath = BROKER_SPAWN_LOCK, nowMs = Date.now()) {
74908
+ function isSpawnLockStale(lockPath = getBrokerSpawnLockPath(), nowMs = Date.now()) {
74908
74909
  if (!existsSync9(lockPath)) {
74909
74910
  return false;
74910
74911
  }
@@ -74923,7 +74924,7 @@ function isSpawnLockStale(lockPath = BROKER_SPAWN_LOCK, nowMs = Date.now()) {
74923
74924
  return true;
74924
74925
  }
74925
74926
  }
74926
- function releaseSpawnLock(owner, lockPath = BROKER_SPAWN_LOCK) {
74927
+ function releaseSpawnLock(owner, lockPath = getBrokerSpawnLockPath()) {
74927
74928
  if (!ownsSpawnLock(owner, lockPath))
74928
74929
  return;
74929
74930
  try {
@@ -74951,7 +74952,7 @@ ${describeBrokerLog()}`);
74951
74952
  ` + "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).
74952
74953
  ${describeBrokerLog()}`);
74953
74954
  }
74954
- 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;
74955
+ 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;
74955
74956
  var init_spawn = __esm(() => {
74956
74957
  init_socket_liveness();
74957
74958
  init_start_announcement();
@@ -74961,13 +74962,7 @@ var init_spawn = __esm(() => {
74961
74962
  init_protocol_version();
74962
74963
  init_shared_storage_setting();
74963
74964
  init_paths();
74964
- INTERCOM_DIR = getIntercomDirPath();
74965
74965
  EXTENSION_DIR = resolveIntercomPackageRoot(import.meta.url);
74966
- BROKER_SOCKET2 = getBrokerSocketPath();
74967
- BROKER_PID = getBrokerPidPath();
74968
- BROKER_SPAWN_LOCK = getBrokerSpawnLockPath();
74969
- BROKER_LOG = getBrokerLogPath();
74970
- BROKER_START_ANNOUNCEMENT = getBrokerStartAnnouncementPath();
74971
74966
  BROKER_LOG_TAIL_BYTES = 8 * 1024;
74972
74967
  });
74973
74968
 
@@ -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
 
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@bastani/atomic",
3
- "version": "0.9.72",
3
+ "version": "0.9.73",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@bastani/atomic",
9
- "version": "0.9.72",
9
+ "version": "0.9.73",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@bastani/atomic-natives": "0.9.72",
13
- "@bastani/pi-ai": "0.9.72",
12
+ "@bastani/atomic-natives": "0.9.73",
13
+ "@bastani/pi-ai": "0.9.73",
14
14
  "@earendil-works/pi-agent-core": "1.5.0",
15
15
  "@earendil-works/pi-codemode": "1.5.0",
16
16
  "@earendil-works/pi-tui": "1.5.0",
@@ -427,18 +427,18 @@
427
427
  }
428
428
  },
429
429
  "node_modules/@bastani/atomic-natives": {
430
- "version": "0.9.72",
431
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives/-/atomic-natives-0.9.72.tgz",
430
+ "version": "0.9.73",
431
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives/-/atomic-natives-0.9.73.tgz",
432
432
  "license": "MIT",
433
433
  "optionalDependencies": {
434
- "@bastani/atomic-natives-darwin-arm64": "0.9.72",
435
- "@bastani/atomic-natives-darwin-x64": "0.9.72",
436
- "@bastani/atomic-natives-linux-arm64-gnu": "0.9.72",
437
- "@bastani/atomic-natives-linux-arm64-musl": "0.9.72",
438
- "@bastani/atomic-natives-linux-x64-gnu": "0.9.72",
439
- "@bastani/atomic-natives-linux-x64-musl": "0.9.72",
440
- "@bastani/atomic-natives-win32-arm64-msvc": "0.9.72",
441
- "@bastani/atomic-natives-win32-x64-msvc": "0.9.72"
434
+ "@bastani/atomic-natives-darwin-arm64": "0.9.73",
435
+ "@bastani/atomic-natives-darwin-x64": "0.9.73",
436
+ "@bastani/atomic-natives-linux-arm64-gnu": "0.9.73",
437
+ "@bastani/atomic-natives-linux-arm64-musl": "0.9.73",
438
+ "@bastani/atomic-natives-linux-x64-gnu": "0.9.73",
439
+ "@bastani/atomic-natives-linux-x64-musl": "0.9.73",
440
+ "@bastani/atomic-natives-win32-arm64-msvc": "0.9.73",
441
+ "@bastani/atomic-natives-win32-x64-msvc": "0.9.73"
442
442
  },
443
443
  "engines": {
444
444
  "bun": ">=1.4.2",
@@ -446,8 +446,8 @@
446
446
  }
447
447
  },
448
448
  "node_modules/@bastani/atomic-natives-darwin-arm64": {
449
- "version": "0.9.72",
450
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-arm64/-/atomic-natives-darwin-arm64-0.9.72.tgz",
449
+ "version": "0.9.73",
450
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-arm64/-/atomic-natives-darwin-arm64-0.9.73.tgz",
451
451
  "license": "MIT",
452
452
  "os": [
453
453
  "darwin"
@@ -458,8 +458,8 @@
458
458
  "optional": true
459
459
  },
460
460
  "node_modules/@bastani/atomic-natives-darwin-x64": {
461
- "version": "0.9.72",
462
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-x64/-/atomic-natives-darwin-x64-0.9.72.tgz",
461
+ "version": "0.9.73",
462
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-x64/-/atomic-natives-darwin-x64-0.9.73.tgz",
463
463
  "license": "MIT",
464
464
  "os": [
465
465
  "darwin"
@@ -470,8 +470,8 @@
470
470
  "optional": true
471
471
  },
472
472
  "node_modules/@bastani/atomic-natives-linux-arm64-gnu": {
473
- "version": "0.9.72",
474
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-gnu/-/atomic-natives-linux-arm64-gnu-0.9.72.tgz",
473
+ "version": "0.9.73",
474
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-gnu/-/atomic-natives-linux-arm64-gnu-0.9.73.tgz",
475
475
  "license": "MIT",
476
476
  "os": [
477
477
  "linux"
@@ -485,8 +485,8 @@
485
485
  "optional": true
486
486
  },
487
487
  "node_modules/@bastani/atomic-natives-linux-arm64-musl": {
488
- "version": "0.9.72",
489
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-musl/-/atomic-natives-linux-arm64-musl-0.9.72.tgz",
488
+ "version": "0.9.73",
489
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-musl/-/atomic-natives-linux-arm64-musl-0.9.73.tgz",
490
490
  "license": "MIT",
491
491
  "os": [
492
492
  "linux"
@@ -500,8 +500,8 @@
500
500
  "optional": true
501
501
  },
502
502
  "node_modules/@bastani/atomic-natives-linux-x64-gnu": {
503
- "version": "0.9.72",
504
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-gnu/-/atomic-natives-linux-x64-gnu-0.9.72.tgz",
503
+ "version": "0.9.73",
504
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-gnu/-/atomic-natives-linux-x64-gnu-0.9.73.tgz",
505
505
  "license": "MIT",
506
506
  "os": [
507
507
  "linux"
@@ -515,8 +515,8 @@
515
515
  "optional": true
516
516
  },
517
517
  "node_modules/@bastani/atomic-natives-linux-x64-musl": {
518
- "version": "0.9.72",
519
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-musl/-/atomic-natives-linux-x64-musl-0.9.72.tgz",
518
+ "version": "0.9.73",
519
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-musl/-/atomic-natives-linux-x64-musl-0.9.73.tgz",
520
520
  "license": "MIT",
521
521
  "os": [
522
522
  "linux"
@@ -530,8 +530,8 @@
530
530
  "optional": true
531
531
  },
532
532
  "node_modules/@bastani/atomic-natives-win32-arm64-msvc": {
533
- "version": "0.9.72",
534
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-arm64-msvc/-/atomic-natives-win32-arm64-msvc-0.9.72.tgz",
533
+ "version": "0.9.73",
534
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-arm64-msvc/-/atomic-natives-win32-arm64-msvc-0.9.73.tgz",
535
535
  "license": "MIT",
536
536
  "os": [
537
537
  "win32"
@@ -542,8 +542,8 @@
542
542
  "optional": true
543
543
  },
544
544
  "node_modules/@bastani/atomic-natives-win32-x64-msvc": {
545
- "version": "0.9.72",
546
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-x64-msvc/-/atomic-natives-win32-x64-msvc-0.9.72.tgz",
545
+ "version": "0.9.73",
546
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-x64-msvc/-/atomic-natives-win32-x64-msvc-0.9.73.tgz",
547
547
  "license": "MIT",
548
548
  "os": [
549
549
  "win32"
@@ -554,8 +554,8 @@
554
554
  "optional": true
555
555
  },
556
556
  "node_modules/@bastani/pi-ai": {
557
- "version": "0.9.72",
558
- "resolved": "https://registry.npmjs.org/@bastani/pi-ai/-/pi-ai-0.9.72.tgz",
557
+ "version": "0.9.73",
558
+ "resolved": "https://registry.npmjs.org/@bastani/pi-ai/-/pi-ai-0.9.73.tgz",
559
559
  "license": "MIT",
560
560
  "dependencies": {
561
561
  "@anthropic-ai/sdk": "0.129.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/atomic",
3
- "version": "0.9.72",
3
+ "version": "0.9.73",
4
4
  "description": "Atomic coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "atomicConfig": {
@@ -89,8 +89,8 @@
89
89
  "prepublishOnly": "bun run clean && bun run build && bun run shrinkwrap"
90
90
  },
91
91
  "dependencies": {
92
- "@bastani/atomic-natives": "0.9.72",
93
- "@bastani/pi-ai": "0.9.72",
92
+ "@bastani/atomic-natives": "0.9.73",
93
+ "@bastani/pi-ai": "0.9.73",
94
94
  "@earendil-works/pi-agent-core": "1.5.0",
95
95
  "@earendil-works/pi-codemode": "1.5.0",
96
96
  "@earendil-works/pi-tui": "1.5.0",