@swmansion/argent 0.23.1-next.0 → 0.23.1-next.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.
package/dist/cli-cmds.mjs CHANGED
@@ -1805,14 +1805,10 @@ async function sweepDeadStateFiles() {
1805
1805
  continue;
1806
1806
  }
1807
1807
  if (fs.existsSync(fresh.bundlePath)) continue;
1808
- const guarded = process.platform !== "win32";
1809
- if (guarded && !processCommandMatches(fresh.pid, fresh.bundlePath)) continue;
1808
+ if (!couldBeOurToolServer(fresh.pid, fresh.bundlePath)) continue;
1810
1809
  await unlink(file).catch(() => {
1811
1810
  });
1812
- void terminatePid(
1813
- fresh.pid,
1814
- guarded ? () => processCommandMatches(fresh.pid, fresh.bundlePath) : void 0
1815
- );
1811
+ void terminatePid(fresh.pid, () => couldBeOurToolServer(fresh.pid, fresh.bundlePath));
1816
1812
  }
1817
1813
  }
1818
1814
  var readState = readToolsServerState;
@@ -1851,20 +1847,37 @@ async function killToolServer(bundlePath) {
1851
1847
  await terminatePid(state2.pid);
1852
1848
  await clearToolsServerState(bundlePath ?? state2.bundlePath);
1853
1849
  }
1854
- function processCommandMatches(pid, marker) {
1850
+ var PS_BIN = ["/bin/ps", "/usr/bin/ps"].find((p) => fs.existsSync(p)) ?? "ps";
1851
+ var PS_WIDTH_FLAGS = ["-ww"];
1852
+ function readProcessCommandLine(pid, flags2 = PS_WIDTH_FLAGS) {
1853
+ return execFileSync(PS_BIN, [...flags2, "-p", String(pid), "-o", "command="], {
1854
+ encoding: "utf8",
1855
+ timeout: 2e3,
1856
+ // A recycled pid can sit on a process with an argv past Node's 1 MiB exec
1857
+ // default, where the overrun surfaces as ENOBUFS instead of a command line.
1858
+ // Same ceiling as tool-server's vega-process ps probes.
1859
+ maxBuffer: 16 * 1024 * 1024,
1860
+ // Piping ps's stderr is what puts a rejected flag ("ps: invalid option --
1861
+ // 'w'") into the thrown error's message.
1862
+ stdio: ["ignore", "pipe", "pipe"]
1863
+ }).trim();
1864
+ }
1865
+ function couldBeOurToolServer(pid, marker) {
1855
1866
  if (!marker) return false;
1867
+ if (process.platform === "win32") return true;
1868
+ let cmd;
1856
1869
  try {
1857
- const cmd = execFileSync("ps", ["-p", String(pid), "-o", "command="], {
1858
- encoding: "utf8",
1859
- timeout: 2e3,
1860
- stdio: ["ignore", "pipe", "ignore"]
1861
- }).trim();
1862
- if (!cmd) return false;
1863
- const escaped = marker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1864
- return new RegExp(`(?:^|\\s)${escaped} start(?:\\s|$)`).test(cmd);
1865
- } catch {
1870
+ cmd = readProcessCommandLine(pid);
1871
+ } catch (err) {
1872
+ process.stderr.write(
1873
+ `[launcher] ps could not read pid ${pid}'s command line; leaving it alone: ${String(err)}
1874
+ `
1875
+ );
1866
1876
  return false;
1867
1877
  }
1878
+ if (!cmd) return false;
1879
+ const escaped = marker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1880
+ return new RegExp(`(?:^|\\s)${escaped} start(?:\\s|$)`).test(cmd);
1868
1881
  }
1869
1882
  var LOCK_WAIT_TIMEOUT_MS = 3e4;
1870
1883
  var LOCK_STALE_MS = 45e3;
@@ -1953,8 +1966,8 @@ async function ensureToolsServer(paths) {
1953
1966
  const state2 = await readState(paths.bundlePath);
1954
1967
  const reuse = await reusableHandle(state2, paths.bundlePath, paths.version);
1955
1968
  if (reuse) return reuse;
1956
- if (state2 && state2.managed === "autospawn" && state2.bundlePath === paths.bundlePath && isProcessAlive(state2.pid) && processCommandMatches(state2.pid, state2.bundlePath)) {
1957
- await terminatePid(state2.pid, () => processCommandMatches(state2.pid, state2.bundlePath));
1969
+ if (state2 && state2.managed === "autospawn" && state2.bundlePath === paths.bundlePath && isProcessAlive(state2.pid) && couldBeOurToolServer(state2.pid, state2.bundlePath)) {
1970
+ await terminatePid(state2.pid, () => couldBeOurToolServer(state2.pid, state2.bundlePath));
1958
1971
  }
1959
1972
  await clearToolsServerState(paths.bundlePath);
1960
1973
  await sweepDeadStateFiles();
@@ -7240,7 +7253,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
7240
7253
  var SESSION_ID2 = randomUUID5();
7241
7254
  function readCliVersion() {
7242
7255
  if (true) {
7243
- return "0.23.1-next.0";
7256
+ return "0.23.1-next.1";
7244
7257
  }
7245
7258
  return "0.0.0";
7246
7259
  }
@@ -16625,7 +16625,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
16625
16625
  var SESSION_ID = randomUUID4();
16626
16626
  function readCliVersion() {
16627
16627
  if (true) {
16628
- return "0.23.1-next.0";
16628
+ return "0.23.1-next.1";
16629
16629
  }
16630
16630
  return "0.0.0";
16631
16631
  }
@@ -23046,15 +23046,11 @@ async function killToolServerForInstallDir(packageDir) {
23046
23046
  const fresh = await readStateFile(file);
23047
23047
  if (!fresh || fresh.pid !== state2.pid || fresh.bundlePath !== state2.bundlePath) continue;
23048
23048
  const alive = isProcessAlive(fresh.pid);
23049
- const guarded = process.platform !== "win32";
23050
- if (alive && guarded && !processCommandMatches(fresh.pid, fresh.bundlePath)) {
23049
+ if (alive && !couldBeOurToolServer(fresh.pid, fresh.bundlePath)) {
23051
23050
  continue;
23052
23051
  }
23053
23052
  if (alive) {
23054
- await terminatePid(
23055
- fresh.pid,
23056
- guarded ? () => processCommandMatches(fresh.pid, fresh.bundlePath) : void 0
23057
- );
23053
+ await terminatePid(fresh.pid, () => couldBeOurToolServer(fresh.pid, fresh.bundlePath));
23058
23054
  }
23059
23055
  await unlink(file).catch(() => {
23060
23056
  });
@@ -23062,20 +23058,37 @@ async function killToolServerForInstallDir(packageDir) {
23062
23058
  }
23063
23059
  return killed;
23064
23060
  }
23065
- function processCommandMatches(pid, marker) {
23061
+ var PS_BIN = ["/bin/ps", "/usr/bin/ps"].find((p) => fs16.existsSync(p)) ?? "ps";
23062
+ var PS_WIDTH_FLAGS = ["-ww"];
23063
+ function readProcessCommandLine(pid, flags = PS_WIDTH_FLAGS) {
23064
+ return execFileSync5(PS_BIN, [...flags, "-p", String(pid), "-o", "command="], {
23065
+ encoding: "utf8",
23066
+ timeout: 2e3,
23067
+ // A recycled pid can sit on a process with an argv past Node's 1 MiB exec
23068
+ // default, where the overrun surfaces as ENOBUFS instead of a command line.
23069
+ // Same ceiling as tool-server's vega-process ps probes.
23070
+ maxBuffer: 16 * 1024 * 1024,
23071
+ // Piping ps's stderr is what puts a rejected flag ("ps: invalid option --
23072
+ // 'w'") into the thrown error's message.
23073
+ stdio: ["ignore", "pipe", "pipe"]
23074
+ }).trim();
23075
+ }
23076
+ function couldBeOurToolServer(pid, marker) {
23066
23077
  if (!marker) return false;
23078
+ if (process.platform === "win32") return true;
23079
+ let cmd;
23067
23080
  try {
23068
- const cmd = execFileSync5("ps", ["-p", String(pid), "-o", "command="], {
23069
- encoding: "utf8",
23070
- timeout: 2e3,
23071
- stdio: ["ignore", "pipe", "ignore"]
23072
- }).trim();
23073
- if (!cmd) return false;
23074
- const escaped = marker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
23075
- return new RegExp(`(?:^|\\s)${escaped} start(?:\\s|$)`).test(cmd);
23076
- } catch {
23081
+ cmd = readProcessCommandLine(pid);
23082
+ } catch (err) {
23083
+ process.stderr.write(
23084
+ `[launcher] ps could not read pid ${pid}'s command line; leaving it alone: ${String(err)}
23085
+ `
23086
+ );
23077
23087
  return false;
23078
23088
  }
23089
+ if (!cmd) return false;
23090
+ const escaped = marker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
23091
+ return new RegExp(`(?:^|\\s)${escaped} start(?:\\s|$)`).test(cmd);
23079
23092
  }
23080
23093
 
23081
23094
  // ../argent-tools-client/src/link-config.ts
@@ -16057,14 +16057,10 @@ async function sweepDeadStateFiles() {
16057
16057
  continue;
16058
16058
  }
16059
16059
  if (fs.existsSync(fresh.bundlePath)) continue;
16060
- const guarded = process.platform !== "win32";
16061
- if (guarded && !processCommandMatches(fresh.pid, fresh.bundlePath)) continue;
16060
+ if (!couldBeOurToolServer(fresh.pid, fresh.bundlePath)) continue;
16062
16061
  await unlink(file).catch(() => {
16063
16062
  });
16064
- void terminatePid(
16065
- fresh.pid,
16066
- guarded ? () => processCommandMatches(fresh.pid, fresh.bundlePath) : void 0
16067
- );
16063
+ void terminatePid(fresh.pid, () => couldBeOurToolServer(fresh.pid, fresh.bundlePath));
16068
16064
  }
16069
16065
  }
16070
16066
  var readState = readToolsServerState;
@@ -16097,20 +16093,37 @@ async function terminatePid(pid, stillOurs) {
16097
16093
  }
16098
16094
  await waitForExit(pid, SIGKILL_GRACE_MS);
16099
16095
  }
16100
- function processCommandMatches(pid, marker) {
16096
+ var PS_BIN = ["/bin/ps", "/usr/bin/ps"].find((p) => fs.existsSync(p)) ?? "ps";
16097
+ var PS_WIDTH_FLAGS = ["-ww"];
16098
+ function readProcessCommandLine(pid, flags = PS_WIDTH_FLAGS) {
16099
+ return execFileSync(PS_BIN, [...flags, "-p", String(pid), "-o", "command="], {
16100
+ encoding: "utf8",
16101
+ timeout: 2e3,
16102
+ // A recycled pid can sit on a process with an argv past Node's 1 MiB exec
16103
+ // default, where the overrun surfaces as ENOBUFS instead of a command line.
16104
+ // Same ceiling as tool-server's vega-process ps probes.
16105
+ maxBuffer: 16 * 1024 * 1024,
16106
+ // Piping ps's stderr is what puts a rejected flag ("ps: invalid option --
16107
+ // 'w'") into the thrown error's message.
16108
+ stdio: ["ignore", "pipe", "pipe"]
16109
+ }).trim();
16110
+ }
16111
+ function couldBeOurToolServer(pid, marker) {
16101
16112
  if (!marker) return false;
16113
+ if (process.platform === "win32") return true;
16114
+ let cmd;
16102
16115
  try {
16103
- const cmd = execFileSync("ps", ["-p", String(pid), "-o", "command="], {
16104
- encoding: "utf8",
16105
- timeout: 2e3,
16106
- stdio: ["ignore", "pipe", "ignore"]
16107
- }).trim();
16108
- if (!cmd) return false;
16109
- const escaped = marker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
16110
- return new RegExp(`(?:^|\\s)${escaped} start(?:\\s|$)`).test(cmd);
16111
- } catch {
16116
+ cmd = readProcessCommandLine(pid);
16117
+ } catch (err) {
16118
+ process.stderr.write(
16119
+ `[launcher] ps could not read pid ${pid}'s command line; leaving it alone: ${String(err)}
16120
+ `
16121
+ );
16112
16122
  return false;
16113
16123
  }
16124
+ if (!cmd) return false;
16125
+ const escaped = marker.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
16126
+ return new RegExp(`(?:^|\\s)${escaped} start(?:\\s|$)`).test(cmd);
16114
16127
  }
16115
16128
  var LOCK_WAIT_TIMEOUT_MS = 3e4;
16116
16129
  var LOCK_STALE_MS = 45e3;
@@ -16199,8 +16212,8 @@ async function ensureToolsServer(paths) {
16199
16212
  const state = await readState(paths.bundlePath);
16200
16213
  const reuse = await reusableHandle(state, paths.bundlePath, paths.version);
16201
16214
  if (reuse) return reuse;
16202
- if (state && state.managed === "autospawn" && state.bundlePath === paths.bundlePath && isProcessAlive(state.pid) && processCommandMatches(state.pid, state.bundlePath)) {
16203
- await terminatePid(state.pid, () => processCommandMatches(state.pid, state.bundlePath));
16215
+ if (state && state.managed === "autospawn" && state.bundlePath === paths.bundlePath && isProcessAlive(state.pid) && couldBeOurToolServer(state.pid, state.bundlePath)) {
16216
+ await terminatePid(state.pid, () => couldBeOurToolServer(state.pid, state.bundlePath));
16204
16217
  }
16205
16218
  await clearToolsServerState(paths.bundlePath);
16206
16219
  await sweepDeadStateFiles();
@@ -93916,7 +93916,7 @@ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
93916
93916
  var SESSION_ID = (0, import_node_crypto3.randomUUID)();
93917
93917
  function readCliVersion() {
93918
93918
  if (true) {
93919
- return "0.23.1-next.0";
93919
+ return "0.23.1-next.1";
93920
93920
  }
93921
93921
  return "0.0.0";
93922
93922
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.23.1-next.0",
3
+ "version": "0.23.1-next.1",
4
4
  "mcpName": "io.github.software-mansion/argent",
5
5
  "description": "MCP server for iOS Simulator and Android Emulator control",
6
6
  "license": "Apache-2.0",