@node9/proxy 1.19.2 → 1.19.3

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.js CHANGED
@@ -4739,19 +4739,16 @@ function isDaemonRunning() {
4739
4739
  }
4740
4740
  return false;
4741
4741
  }
4742
- const r = (0, import_child_process.spawnSync)("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
4743
- encoding: "utf8",
4744
- timeout: 300
4745
- });
4746
- if (r.status === 0 && (r.stdout ?? "").includes(`:${DAEMON_PORT}`)) return true;
4747
- return false;
4742
+ return true;
4748
4743
  }
4744
+ return false;
4745
+ }
4746
+ async function isDaemonReachable(timeoutMs = 500) {
4749
4747
  try {
4750
- const r = (0, import_child_process.spawnSync)("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
4751
- encoding: "utf8",
4752
- timeout: 300
4748
+ const res = await fetch(`http://${DAEMON_HOST}:${DAEMON_PORT}/settings`, {
4749
+ signal: AbortSignal.timeout(timeoutMs)
4753
4750
  });
4754
- return r.status === 0 && (r.stdout ?? "").includes(`:${DAEMON_PORT}`);
4751
+ return res.ok;
4755
4752
  } catch {
4756
4753
  return false;
4757
4754
  }
@@ -4890,7 +4887,7 @@ async function resolveViaDaemon(id, decision, internalToken, source) {
4890
4887
  signal: AbortSignal.timeout(3e3)
4891
4888
  });
4892
4889
  }
4893
- var import_fs9, import_net, import_path9, import_os8, import_child_process, ACTIVITY_SOCKET_PATH, DAEMON_PORT, DAEMON_HOST;
4890
+ var import_fs9, import_net, import_path9, import_os8, ACTIVITY_SOCKET_PATH, DAEMON_PORT, DAEMON_HOST;
4894
4891
  var init_daemon = __esm({
4895
4892
  "src/auth/daemon.ts"() {
4896
4893
  "use strict";
@@ -4898,7 +4895,6 @@ var init_daemon = __esm({
4898
4895
  import_net = __toESM(require("net"));
4899
4896
  import_path9 = __toESM(require("path"));
4900
4897
  import_os8 = __toESM(require("os"));
4901
- import_child_process = require("child_process");
4902
4898
  ACTIVITY_SOCKET_PATH = process.platform === "win32" ? "\\\\.\\pipe\\node9-activity" : import_path9.default.join(import_os8.default.tmpdir(), "node9-activity.sock");
4903
4899
  DAEMON_PORT = 7391;
4904
4900
  DAEMON_HOST = "127.0.0.1";
@@ -5098,9 +5094,9 @@ function sendDesktopNotification(title, body) {
5098
5094
  if (process.platform === "darwin") {
5099
5095
  const esc = (s) => s.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
5100
5096
  const script = `display notification "${esc(body)}" with title "${esc(title)}"`;
5101
- (0, import_child_process2.spawn)("osascript", ["-e", script], { detached: true, stdio: "ignore" }).unref();
5097
+ (0, import_child_process.spawn)("osascript", ["-e", script], { detached: true, stdio: "ignore" }).unref();
5102
5098
  } else if (process.platform === "linux") {
5103
- (0, import_child_process2.spawn)("notify-send", [title, body, "--icon=dialog-warning"], {
5099
+ (0, import_child_process.spawn)("notify-send", [title, body, "--icon=dialog-warning"], {
5104
5100
  detached: true,
5105
5101
  stdio: "ignore"
5106
5102
  }).unref();
@@ -5195,7 +5191,7 @@ activate
5195
5191
  display dialog (item 1 of argv) with title (item 2 of argv) ${buttons}
5196
5192
  end tell
5197
5193
  end run`;
5198
- childProcess = (0, import_child_process2.spawn)("osascript", ["-e", script, "--", message, title]);
5194
+ childProcess = (0, import_child_process.spawn)("osascript", ["-e", script, "--", message, title]);
5199
5195
  } else if (process.platform === "linux") {
5200
5196
  const pangoMessage = buildPangoMessage(
5201
5197
  toolName,
@@ -5221,12 +5217,12 @@ end run`;
5221
5217
  argsList.push("--cancel-label", "Block \u238B");
5222
5218
  argsList.push("--extra-button", "Always Allow");
5223
5219
  }
5224
- childProcess = (0, import_child_process2.spawn)("zenity", argsList);
5220
+ childProcess = (0, import_child_process.spawn)("zenity", argsList);
5225
5221
  } else if (process.platform === "win32") {
5226
5222
  const b64Msg = Buffer.from(message).toString("base64");
5227
5223
  const b64Title = Buffer.from(title).toString("base64");
5228
5224
  const ps = `Add-Type -AssemblyName PresentationFramework; $msg = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("${b64Msg}")); $title = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("${b64Title}")); $res = [System.Windows.MessageBox]::Show($msg, $title, "${locked ? "OK" : "YesNo"}", "Warning", "Button2", "DefaultDesktopOnly"); if ($res -eq "Yes") { exit 0 } else { exit 1 }`;
5229
- childProcess = (0, import_child_process2.spawn)("powershell", ["-Command", ps]);
5225
+ childProcess = (0, import_child_process.spawn)("powershell", ["-Command", ps]);
5230
5226
  }
5231
5227
  let output = "";
5232
5228
  childProcess?.stdout?.on("data", (d) => output += d.toString());
@@ -5242,11 +5238,11 @@ end run`;
5242
5238
  }
5243
5239
  });
5244
5240
  }
5245
- var import_child_process2, import_path11, isTestEnv;
5241
+ var import_child_process, import_path11, isTestEnv;
5246
5242
  var init_native = __esm({
5247
5243
  "src/ui/native.ts"() {
5248
5244
  "use strict";
5249
- import_child_process2 = require("child_process");
5245
+ import_child_process = require("child_process");
5250
5246
  import_path11 = __toESM(require("path"));
5251
5247
  init_context_sniper();
5252
5248
  isTestEnv = () => {
@@ -12664,13 +12660,26 @@ data: ${JSON.stringify(item.data)}
12664
12660
  }).then((res) => {
12665
12661
  if (res.ok) {
12666
12662
  try {
12667
- const r = (0, import_child_process3.spawnSync)("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
12663
+ let orphanPid = null;
12664
+ const ss = (0, import_child_process2.spawnSync)("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
12668
12665
  encoding: "utf8",
12669
12666
  timeout: 1e3
12670
12667
  });
12671
- const match = r.stdout?.match(/pid=(\d+)/);
12672
- if (match) {
12673
- const orphanPid = parseInt(match[1], 10);
12668
+ if (!ss.error && ss.status === 0) {
12669
+ const m = ss.stdout?.match(/pid=(\d+)/);
12670
+ if (m) orphanPid = parseInt(m[1], 10);
12671
+ } else if (ss.error?.code === "ENOENT" || ss.status === null) {
12672
+ const lsof = (0, import_child_process2.spawnSync)(
12673
+ "lsof",
12674
+ ["-nP", `-iTCP:${DAEMON_PORT}`, "-sTCP:LISTEN", "-t"],
12675
+ { encoding: "utf8", timeout: 1e3 }
12676
+ );
12677
+ if (!lsof.error && lsof.status === 0) {
12678
+ const first = (lsof.stdout ?? "").split("\n")[0].trim();
12679
+ if (/^\d+$/.test(first)) orphanPid = parseInt(first, 10);
12680
+ }
12681
+ }
12682
+ if (orphanPid !== null) {
12674
12683
  process.kill(orphanPid, 0);
12675
12684
  atomicWriteSync2(
12676
12685
  DAEMON_PID_FILE,
@@ -12705,14 +12714,14 @@ data: ${JSON.stringify(item.data)}
12705
12714
  JSON.stringify({ pid: process.pid, port: DAEMON_PORT, internalToken, autoStarted }),
12706
12715
  { mode: 384 }
12707
12716
  );
12708
- console.error(import_chalk6.default.green(`\u{1F6E1}\uFE0F Node9 Guard LIVE: http://127.0.0.1:${DAEMON_PORT}`));
12717
+ console.error(import_chalk6.default.green(`\u{1F6E1}\uFE0F Node9 Guard LIVE on 127.0.0.1:${DAEMON_PORT}`));
12709
12718
  });
12710
12719
  if (watchMode) {
12711
12720
  console.error(import_chalk6.default.cyan("\u{1F6F0}\uFE0F Flight Recorder active \u2014 daemon will not idle-timeout"));
12712
12721
  }
12713
12722
  startActivitySocket();
12714
12723
  }
12715
- var import_http, import_fs25, import_path27, import_os23, import_crypto7, import_child_process3, import_chalk6;
12724
+ var import_http, import_fs25, import_path27, import_os23, import_crypto7, import_child_process2, import_chalk6;
12716
12725
  var init_server = __esm({
12717
12726
  "src/daemon/server.ts"() {
12718
12727
  "use strict";
@@ -12721,7 +12730,7 @@ var init_server = __esm({
12721
12730
  import_path27 = __toESM(require("path"));
12722
12731
  import_os23 = __toESM(require("os"));
12723
12732
  import_crypto7 = require("crypto");
12724
- import_child_process3 = require("child_process");
12733
+ import_child_process2 = require("child_process");
12725
12734
  import_chalk6 = __toESM(require("chalk"));
12726
12735
  init_core();
12727
12736
  init_scan();
@@ -12746,7 +12755,7 @@ function resolveNode9Binary() {
12746
12755
  }
12747
12756
  try {
12748
12757
  const cmd = process.platform === "win32" ? "where" : "which";
12749
- const r = (0, import_child_process4.spawnSync)(cmd, ["node9"], { encoding: "utf8", timeout: 3e3 });
12758
+ const r = (0, import_child_process3.spawnSync)(cmd, ["node9"], { encoding: "utf8", timeout: 3e3 });
12750
12759
  if (r.status === 0 && r.stdout.trim()) {
12751
12760
  return r.stdout.trim().split("\n")[0].trim();
12752
12761
  }
@@ -12798,8 +12807,8 @@ function installLaunchd(binaryPath) {
12798
12807
  const dir = import_path28.default.dirname(LAUNCHD_PLIST);
12799
12808
  if (!import_fs26.default.existsSync(dir)) import_fs26.default.mkdirSync(dir, { recursive: true });
12800
12809
  import_fs26.default.writeFileSync(LAUNCHD_PLIST, launchdPlist(binaryPath), "utf-8");
12801
- (0, import_child_process4.spawnSync)("launchctl", ["unload", LAUNCHD_PLIST], { encoding: "utf8" });
12802
- const r = (0, import_child_process4.spawnSync)("launchctl", ["load", "-w", LAUNCHD_PLIST], {
12810
+ (0, import_child_process3.spawnSync)("launchctl", ["unload", LAUNCHD_PLIST], { encoding: "utf8" });
12811
+ const r = (0, import_child_process3.spawnSync)("launchctl", ["load", "-w", LAUNCHD_PLIST], {
12803
12812
  encoding: "utf8",
12804
12813
  timeout: 5e3
12805
12814
  });
@@ -12809,7 +12818,7 @@ function installLaunchd(binaryPath) {
12809
12818
  }
12810
12819
  function uninstallLaunchd() {
12811
12820
  if (import_fs26.default.existsSync(LAUNCHD_PLIST)) {
12812
- (0, import_child_process4.spawnSync)("launchctl", ["unload", "-w", LAUNCHD_PLIST], { encoding: "utf8", timeout: 5e3 });
12821
+ (0, import_child_process3.spawnSync)("launchctl", ["unload", "-w", LAUNCHD_PLIST], { encoding: "utf8", timeout: 5e3 });
12813
12822
  import_fs26.default.unlinkSync(LAUNCHD_PLIST);
12814
12823
  }
12815
12824
  }
@@ -12838,18 +12847,18 @@ function installSystemd(binaryPath) {
12838
12847
  }
12839
12848
  import_fs26.default.writeFileSync(SYSTEMD_UNIT, systemdUnit(binaryPath), "utf-8");
12840
12849
  try {
12841
- (0, import_child_process4.execFileSync)("loginctl", ["enable-linger", import_os24.default.userInfo().username], { timeout: 3e3 });
12850
+ (0, import_child_process3.execFileSync)("loginctl", ["enable-linger", import_os24.default.userInfo().username], { timeout: 3e3 });
12842
12851
  } catch {
12843
12852
  }
12844
- const reload = (0, import_child_process4.spawnSync)("systemctl", ["--user", "daemon-reload"], {
12853
+ const reload = (0, import_child_process3.spawnSync)("systemctl", ["--user", "daemon-reload"], {
12845
12854
  encoding: "utf8",
12846
12855
  timeout: 5e3
12847
12856
  });
12848
12857
  if (reload.status !== 0) {
12849
12858
  throw new Error(`systemctl daemon-reload failed: ${reload.stderr}`);
12850
12859
  }
12851
- (0, import_child_process4.spawnSync)("systemctl", ["--user", "stop", "node9-daemon"], { encoding: "utf8", timeout: 3e3 });
12852
- const enable = (0, import_child_process4.spawnSync)("systemctl", ["--user", "enable", "--now", "node9-daemon"], {
12860
+ (0, import_child_process3.spawnSync)("systemctl", ["--user", "stop", "node9-daemon"], { encoding: "utf8", timeout: 3e3 });
12861
+ const enable = (0, import_child_process3.spawnSync)("systemctl", ["--user", "enable", "--now", "node9-daemon"], {
12853
12862
  encoding: "utf8",
12854
12863
  timeout: 5e3
12855
12864
  });
@@ -12859,11 +12868,11 @@ function installSystemd(binaryPath) {
12859
12868
  }
12860
12869
  function uninstallSystemd() {
12861
12870
  if (import_fs26.default.existsSync(SYSTEMD_UNIT)) {
12862
- (0, import_child_process4.spawnSync)("systemctl", ["--user", "disable", "--now", "node9-daemon"], {
12871
+ (0, import_child_process3.spawnSync)("systemctl", ["--user", "disable", "--now", "node9-daemon"], {
12863
12872
  encoding: "utf8",
12864
12873
  timeout: 5e3
12865
12874
  });
12866
- (0, import_child_process4.spawnSync)("systemctl", ["--user", "daemon-reload"], { encoding: "utf8", timeout: 5e3 });
12875
+ (0, import_child_process3.spawnSync)("systemctl", ["--user", "daemon-reload"], { encoding: "utf8", timeout: 5e3 });
12867
12876
  import_fs26.default.unlinkSync(SYSTEMD_UNIT);
12868
12877
  }
12869
12878
  }
@@ -12881,7 +12890,7 @@ function stopRunningDaemon() {
12881
12890
  try {
12882
12891
  process.kill(pid, "SIGTERM");
12883
12892
  const deadline = Date.now() + 3e3;
12884
- const pollStop = (0, import_child_process4.spawnSync)(
12893
+ const pollStop = (0, import_child_process3.spawnSync)(
12885
12894
  "sh",
12886
12895
  ["-c", `while kill -0 ${pid} 2>/dev/null; do sleep 0.1; done`],
12887
12896
  {
@@ -12913,7 +12922,7 @@ function installDaemonService() {
12913
12922
  return { ok: true, platform: "launchd", alreadyInstalled };
12914
12923
  }
12915
12924
  if (process.platform === "linux") {
12916
- const check = (0, import_child_process4.spawnSync)("systemctl", ["--user", "--version"], {
12925
+ const check = (0, import_child_process3.spawnSync)("systemctl", ["--user", "--version"], {
12917
12926
  encoding: "utf8",
12918
12927
  timeout: 2e3
12919
12928
  });
@@ -12964,14 +12973,14 @@ function isDaemonServiceInstalled() {
12964
12973
  if (process.platform === "linux") return isSystemdInstalled();
12965
12974
  return false;
12966
12975
  }
12967
- var import_fs26, import_path28, import_os24, import_child_process4, LAUNCHD_LABEL, LAUNCHD_PLIST, SYSTEMD_UNIT_DIR, SYSTEMD_UNIT;
12976
+ var import_fs26, import_path28, import_os24, import_child_process3, LAUNCHD_LABEL, LAUNCHD_PLIST, SYSTEMD_UNIT_DIR, SYSTEMD_UNIT;
12968
12977
  var init_service = __esm({
12969
12978
  "src/daemon/service.ts"() {
12970
12979
  "use strict";
12971
12980
  import_fs26 = __toESM(require("fs"));
12972
12981
  import_path28 = __toESM(require("path"));
12973
12982
  import_os24 = __toESM(require("os"));
12974
- import_child_process4 = require("child_process");
12983
+ import_child_process3 = require("child_process");
12975
12984
  LAUNCHD_LABEL = "ai.node9.daemon";
12976
12985
  LAUNCHD_PLIST = import_path28.default.join(import_os24.default.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
12977
12986
  SYSTEMD_UNIT_DIR = import_path28.default.join(import_os24.default.homedir(), ".config", "systemd", "user");
@@ -13021,28 +13030,19 @@ function daemonStatus() {
13021
13030
  processStatus = import_chalk7.default.yellow("not running (stale PID file)");
13022
13031
  }
13023
13032
  } else {
13024
- const r = (0, import_child_process5.spawnSync)("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
13025
- encoding: "utf8",
13026
- timeout: 500
13027
- });
13028
- if (r.status === 0 && (r.stdout ?? "").includes(`:${DAEMON_PORT}`)) {
13029
- processStatus = import_chalk7.default.yellow(`running (orphaned \u2014 no PID file)`);
13030
- } else {
13031
- processStatus = import_chalk7.default.yellow("not running");
13032
- }
13033
+ processStatus = import_chalk7.default.yellow("not running");
13033
13034
  }
13034
13035
  console.log(`
13035
13036
  Process : ${processStatus}`);
13036
13037
  console.log(` Service : ${serviceLabel}
13037
13038
  `);
13038
13039
  }
13039
- var import_fs27, import_chalk7, import_child_process5, MAX_PID;
13040
+ var import_fs27, import_chalk7, MAX_PID;
13040
13041
  var init_daemon2 = __esm({
13041
13042
  "src/daemon/index.ts"() {
13042
13043
  "use strict";
13043
13044
  import_fs27 = __toESM(require("fs"));
13044
13045
  import_chalk7 = __toESM(require("chalk"));
13045
- import_child_process5 = require("child_process");
13046
13046
  init_server();
13047
13047
  init_state2();
13048
13048
  init_service();
@@ -13219,7 +13219,7 @@ async function ensureDaemon() {
13219
13219
  } catch {
13220
13220
  }
13221
13221
  console.log(import_chalk30.default.dim("\u{1F6E1}\uFE0F Starting Node9 daemon..."));
13222
- const child = (0, import_child_process15.spawn)(process.execPath, [process.argv[1], "daemon"], {
13222
+ const child = (0, import_child_process13.spawn)(process.execPath, [process.argv[1], "daemon"], {
13223
13223
  detached: true,
13224
13224
  stdio: "ignore",
13225
13225
  env: { ...process.env, NODE9_AUTO_STARTED: "1" }
@@ -13849,7 +13849,7 @@ async function startTail(options = {}) {
13849
13849
  process.exit(1);
13850
13850
  });
13851
13851
  }
13852
- var import_http2, import_chalk30, import_fs45, import_os41, import_path47, import_readline6, import_child_process15, PID_FILE, ICONS, MODEL_CONTEXT_LIMITS, RESET2, BOLD2, RED, YELLOW, CYAN, GRAY, GREEN, HIDE_CURSOR, SHOW_CURSOR, ERASE_DOWN, pendingShownForId, pendingWrappedLines, DIVIDER;
13852
+ var import_http2, import_chalk30, import_fs45, import_os41, import_path47, import_readline6, import_child_process13, PID_FILE, ICONS, MODEL_CONTEXT_LIMITS, RESET2, BOLD2, RED, YELLOW, CYAN, GRAY, GREEN, HIDE_CURSOR, SHOW_CURSOR, ERASE_DOWN, pendingShownForId, pendingWrappedLines, DIVIDER;
13853
13853
  var init_tail = __esm({
13854
13854
  "src/tui/tail.ts"() {
13855
13855
  "use strict";
@@ -13859,7 +13859,7 @@ var init_tail = __esm({
13859
13859
  import_os41 = __toESM(require("os"));
13860
13860
  import_path47 = __toESM(require("path"));
13861
13861
  import_readline6 = __toESM(require("readline"));
13862
- import_child_process15 = require("child_process");
13862
+ import_child_process13 = require("child_process");
13863
13863
  init_daemon2();
13864
13864
  init_daemon();
13865
13865
  PID_FILE = import_path47.default.join(import_os41.default.homedir(), ".node9", "daemon.pid");
@@ -14315,7 +14315,7 @@ function parseDuration(str) {
14315
14315
  // src/proxy/index.ts
14316
14316
  var import_readline2 = __toESM(require("readline"));
14317
14317
  var import_chalk8 = __toESM(require("chalk"));
14318
- var import_child_process6 = require("child_process");
14318
+ var import_child_process4 = require("child_process");
14319
14319
  var import_execa = require("execa");
14320
14320
  var import_execa2 = require("execa");
14321
14321
  init_orchestrator();
@@ -14403,11 +14403,11 @@ async function runProxy(targetCommand) {
14403
14403
  }
14404
14404
  console.error(import_chalk8.default.green(`\u{1F680} Node9 Proxy Active: Monitoring [${targetCommand}]`));
14405
14405
  const spawnEnv = { ...process.env, FORCE_COLOR: "1" };
14406
- const child = useShell ? (0, import_child_process6.spawn)("/bin/bash", ["-c", targetCommand], {
14406
+ const child = useShell ? (0, import_child_process4.spawn)("/bin/bash", ["-c", targetCommand], {
14407
14407
  stdio: ["pipe", "pipe", "inherit"],
14408
14408
  shell: false,
14409
14409
  env: spawnEnv
14410
- }) : (0, import_child_process6.spawn)(executable, args, { stdio: ["pipe", "pipe", "inherit"], shell: false, env: spawnEnv });
14410
+ }) : (0, import_child_process4.spawn)(executable, args, { stdio: ["pipe", "pipe", "inherit"], shell: false, env: spawnEnv });
14411
14411
  const agentIn = import_readline2.default.createInterface({ input: process.stdin, terminal: false });
14412
14412
  agentIn.on("line", async (line) => {
14413
14413
  let message;
@@ -14471,7 +14471,7 @@ async function runProxy(targetCommand) {
14471
14471
  }
14472
14472
 
14473
14473
  // src/cli/daemon-starter.ts
14474
- var import_child_process7 = require("child_process");
14474
+ var import_child_process5 = require("child_process");
14475
14475
  var import_path29 = __toESM(require("path"));
14476
14476
  var import_fs28 = __toESM(require("fs"));
14477
14477
  init_daemon();
@@ -14489,7 +14489,7 @@ async function autoStartDaemonAndWait() {
14489
14489
  }
14490
14490
  if (!resolvedArgv1.endsWith(".js")) return false;
14491
14491
  try {
14492
- const child = (0, import_child_process7.spawn)(process.execPath, [resolvedArgv1, "daemon"], {
14492
+ const child = (0, import_child_process5.spawn)(process.execPath, [resolvedArgv1, "daemon"], {
14493
14493
  detached: true,
14494
14494
  stdio: "ignore",
14495
14495
  env: {
@@ -14501,13 +14501,7 @@ async function autoStartDaemonAndWait() {
14501
14501
  for (let i = 0; i < 20; i++) {
14502
14502
  await new Promise((r) => setTimeout(r, 250));
14503
14503
  if (!isDaemonRunning()) continue;
14504
- try {
14505
- const res = await fetch(`http://${DAEMON_HOST}:${DAEMON_PORT}/settings`, {
14506
- signal: AbortSignal.timeout(500)
14507
- });
14508
- if (res.ok) return true;
14509
- } catch {
14510
- }
14504
+ if (await isDaemonReachable()) return true;
14511
14505
  }
14512
14506
  } catch {
14513
14507
  }
@@ -14517,7 +14511,7 @@ async function autoStartDaemonAndWait() {
14517
14511
  // src/cli/commands/check.ts
14518
14512
  var import_chalk9 = __toESM(require("chalk"));
14519
14513
  var import_fs31 = __toESM(require("fs"));
14520
- var import_child_process9 = require("child_process");
14514
+ var import_child_process7 = require("child_process");
14521
14515
  var import_path32 = __toESM(require("path"));
14522
14516
  var import_os27 = __toESM(require("os"));
14523
14517
  init_orchestrator();
@@ -14526,7 +14520,7 @@ init_config();
14526
14520
  init_policy();
14527
14521
 
14528
14522
  // src/undo.ts
14529
- var import_child_process8 = require("child_process");
14523
+ var import_child_process6 = require("child_process");
14530
14524
  var import_crypto8 = __toESM(require("crypto"));
14531
14525
  var import_fs29 = __toESM(require("fs"));
14532
14526
  var import_net3 = __toESM(require("net"));
@@ -14639,7 +14633,7 @@ function ensureShadowRepo(shadowDir, cwd) {
14639
14633
  cleanOrphanedIndexFiles(shadowDir);
14640
14634
  const normalizedCwd = normalizeCwdForHash(cwd);
14641
14635
  const shadowEnvBase = { ...process.env, GIT_DIR: shadowDir, GIT_WORK_TREE: cwd };
14642
- const check = (0, import_child_process8.spawnSync)("git", ["rev-parse", "--git-dir"], {
14636
+ const check = (0, import_child_process6.spawnSync)("git", ["rev-parse", "--git-dir"], {
14643
14637
  env: shadowEnvBase,
14644
14638
  timeout: 3e3
14645
14639
  });
@@ -14665,17 +14659,17 @@ function ensureShadowRepo(shadowDir, cwd) {
14665
14659
  import_fs29.default.mkdirSync(shadowDir, { recursive: true });
14666
14660
  } catch {
14667
14661
  }
14668
- const init = (0, import_child_process8.spawnSync)("git", ["init", "--bare", shadowDir], { timeout: 5e3 });
14662
+ const init = (0, import_child_process6.spawnSync)("git", ["init", "--bare", shadowDir], { timeout: 5e3 });
14669
14663
  if (init.status !== 0 || init.error) {
14670
14664
  const reason = init.error ? init.error.message : init.stderr?.toString();
14671
14665
  if (process.env.NODE9_DEBUG === "1") console.error("[Node9] git init --bare failed:", reason);
14672
14666
  return false;
14673
14667
  }
14674
14668
  const configFile = import_path30.default.join(shadowDir, "config");
14675
- (0, import_child_process8.spawnSync)("git", ["config", "--file", configFile, "core.untrackedCache", "true"], {
14669
+ (0, import_child_process6.spawnSync)("git", ["config", "--file", configFile, "core.untrackedCache", "true"], {
14676
14670
  timeout: 3e3
14677
14671
  });
14678
- (0, import_child_process8.spawnSync)("git", ["config", "--file", configFile, "core.fsmonitor", "true"], {
14672
+ (0, import_child_process6.spawnSync)("git", ["config", "--file", configFile, "core.fsmonitor", "true"], {
14679
14673
  timeout: 3e3
14680
14674
  });
14681
14675
  try {
@@ -14686,14 +14680,17 @@ function ensureShadowRepo(shadowDir, cwd) {
14686
14680
  }
14687
14681
  function buildGitEnv(cwd) {
14688
14682
  const shadowDir = getShadowRepoDir(cwd);
14689
- const check = (0, import_child_process8.spawnSync)("git", ["rev-parse", "--git-dir"], {
14683
+ const check = (0, import_child_process6.spawnSync)("git", ["rev-parse", "--git-dir"], {
14690
14684
  env: { ...process.env, GIT_DIR: shadowDir, GIT_WORK_TREE: cwd },
14691
14685
  timeout: 2e3
14692
14686
  });
14693
14687
  if (check.status === 0) {
14694
14688
  return { ...process.env, GIT_DIR: shadowDir, GIT_WORK_TREE: cwd };
14695
14689
  }
14696
- return { ...process.env };
14690
+ const env = { ...process.env };
14691
+ delete env.GIT_DIR;
14692
+ delete env.GIT_WORK_TREE;
14693
+ return env;
14697
14694
  }
14698
14695
  async function createShadowSnapshot(tool = "unknown", args = {}, ignorePaths = []) {
14699
14696
  let indexFile = null;
@@ -14711,11 +14708,11 @@ async function createShadowSnapshot(tool = "unknown", args = {}, ignorePaths = [
14711
14708
  GIT_WORK_TREE: cwd,
14712
14709
  GIT_INDEX_FILE: indexFile
14713
14710
  };
14714
- (0, import_child_process8.spawnSync)("git", ["add", "-A"], { env: shadowEnv, timeout: GIT_TIMEOUT });
14715
- const treeRes = (0, import_child_process8.spawnSync)("git", ["write-tree"], { env: shadowEnv, timeout: GIT_TIMEOUT });
14711
+ (0, import_child_process6.spawnSync)("git", ["add", "-A"], { env: shadowEnv, timeout: GIT_TIMEOUT });
14712
+ const treeRes = (0, import_child_process6.spawnSync)("git", ["write-tree"], { env: shadowEnv, timeout: GIT_TIMEOUT });
14716
14713
  const treeHash = treeRes.stdout?.toString().trim();
14717
14714
  if (!treeHash || treeRes.status !== 0) return null;
14718
- const commitRes = (0, import_child_process8.spawnSync)(
14715
+ const commitRes = (0, import_child_process6.spawnSync)(
14719
14716
  "git",
14720
14717
  ["commit-tree", treeHash, "-m", `Node9 AI Snapshot: ${(/* @__PURE__ */ new Date()).toISOString()}`],
14721
14718
  { env: shadowEnv, timeout: GIT_TIMEOUT }
@@ -14727,7 +14724,7 @@ async function createShadowSnapshot(tool = "unknown", args = {}, ignorePaths = [
14727
14724
  let capturedFiles = [];
14728
14725
  let capturedDiff = null;
14729
14726
  if (prevEntry) {
14730
- const filesRes = (0, import_child_process8.spawnSync)("git", ["diff", "--name-only", prevEntry.hash, commitHash], {
14727
+ const filesRes = (0, import_child_process6.spawnSync)("git", ["diff", "--name-only", prevEntry.hash, commitHash], {
14731
14728
  env: shadowEnv,
14732
14729
  timeout: GIT_TIMEOUT
14733
14730
  });
@@ -14737,7 +14734,7 @@ async function createShadowSnapshot(tool = "unknown", args = {}, ignorePaths = [
14737
14734
  if (capturedFiles.length === 0) {
14738
14735
  return prevEntry.hash;
14739
14736
  }
14740
- const diffRes = (0, import_child_process8.spawnSync)("git", ["diff", prevEntry.hash, commitHash], {
14737
+ const diffRes = (0, import_child_process6.spawnSync)("git", ["diff", prevEntry.hash, commitHash], {
14741
14738
  env: shadowEnv,
14742
14739
  timeout: GIT_TIMEOUT
14743
14740
  });
@@ -14745,7 +14742,7 @@ async function createShadowSnapshot(tool = "unknown", args = {}, ignorePaths = [
14745
14742
  capturedDiff = diffRes.stdout?.toString() || null;
14746
14743
  }
14747
14744
  } else {
14748
- const filesRes = (0, import_child_process8.spawnSync)("git", ["ls-tree", "-r", "--name-only", commitHash], {
14745
+ const filesRes = (0, import_child_process6.spawnSync)("git", ["ls-tree", "-r", "--name-only", commitHash], {
14749
14746
  env: shadowEnv,
14750
14747
  timeout: GIT_TIMEOUT
14751
14748
  });
@@ -14778,7 +14775,7 @@ async function createShadowSnapshot(tool = "unknown", args = {}, ignorePaths = [
14778
14775
  notifySnapshotTaken(commitHash.slice(0, 7), tool, entry.argsSummary, capturedFiles.length);
14779
14776
  import_fs29.default.writeFileSync(UNDO_LATEST_PATH, commitHash);
14780
14777
  if (shouldGc) {
14781
- (0, import_child_process8.spawn)("git", ["gc", "--auto"], { env: shadowEnv, detached: true, stdio: "ignore" }).unref();
14778
+ (0, import_child_process6.spawn)("git", ["gc", "--auto"], { env: shadowEnv, detached: true, stdio: "ignore" }).unref();
14782
14779
  }
14783
14780
  return commitHash;
14784
14781
  } catch (err2) {
@@ -14799,14 +14796,14 @@ function getSnapshotHistory() {
14799
14796
  function computeUndoDiff(hash, cwd) {
14800
14797
  try {
14801
14798
  const env = buildGitEnv(cwd);
14802
- const statRes = (0, import_child_process8.spawnSync)("git", ["diff", hash, "--stat", "--", "."], {
14799
+ const statRes = (0, import_child_process6.spawnSync)("git", ["diff", hash, "--stat", "--", "."], {
14803
14800
  cwd,
14804
14801
  env,
14805
14802
  timeout: GIT_TIMEOUT
14806
14803
  });
14807
14804
  const stat = statRes.stdout?.toString().trim();
14808
14805
  if (!stat || statRes.status !== 0) return null;
14809
- const diffRes = (0, import_child_process8.spawnSync)("git", ["diff", hash, "--", "."], {
14806
+ const diffRes = (0, import_child_process6.spawnSync)("git", ["diff", hash, "--", "."], {
14810
14807
  cwd,
14811
14808
  env,
14812
14809
  timeout: GIT_TIMEOUT
@@ -14825,7 +14822,7 @@ function applyUndo(hash, cwd) {
14825
14822
  try {
14826
14823
  const dir = cwd ?? process.cwd();
14827
14824
  const env = buildGitEnv(dir);
14828
- const restore = (0, import_child_process8.spawnSync)("git", ["restore", "--source", hash, "--staged", "--worktree", "."], {
14825
+ const restore = (0, import_child_process6.spawnSync)("git", ["restore", "--source", hash, "--staged", "--worktree", "."], {
14829
14826
  cwd: dir,
14830
14827
  env,
14831
14828
  timeout: GIT_TIMEOUT
@@ -14837,7 +14834,7 @@ function applyUndo(hash, cwd) {
14837
14834
  }
14838
14835
  return false;
14839
14836
  }
14840
- const lsTree = (0, import_child_process8.spawnSync)("git", ["ls-tree", "-r", "--name-only", hash], {
14837
+ const lsTree = (0, import_child_process6.spawnSync)("git", ["ls-tree", "-r", "--name-only", hash], {
14841
14838
  cwd: dir,
14842
14839
  env,
14843
14840
  timeout: GIT_TIMEOUT
@@ -14856,8 +14853,8 @@ function applyUndo(hash, cwd) {
14856
14853
  `);
14857
14854
  return false;
14858
14855
  }
14859
- const tracked = (0, import_child_process8.spawnSync)("git", ["ls-files"], { cwd: dir, env, timeout: GIT_TIMEOUT }).stdout?.toString().trim().split("\n").filter(Boolean) ?? [];
14860
- const untracked = (0, import_child_process8.spawnSync)("git", ["ls-files", "--others", "--exclude-standard"], {
14856
+ const tracked = (0, import_child_process6.spawnSync)("git", ["ls-files"], { cwd: dir, env, timeout: GIT_TIMEOUT }).stdout?.toString().trim().split("\n").filter(Boolean) ?? [];
14857
+ const untracked = (0, import_child_process6.spawnSync)("git", ["ls-files", "--others", "--exclude-standard"], {
14861
14858
  cwd: dir,
14862
14859
  env,
14863
14860
  timeout: GIT_TIMEOUT
@@ -15128,7 +15125,7 @@ RAW: ${raw}
15128
15125
  ]) {
15129
15126
  delete safeEnv[key];
15130
15127
  }
15131
- const d = (0, import_child_process9.spawn)(process.execPath, [scriptPath, "daemon"], {
15128
+ const d = (0, import_child_process7.spawn)(process.execPath, [scriptPath, "daemon"], {
15132
15129
  detached: true,
15133
15130
  stdio: "ignore",
15134
15131
  env: { ...safeEnv, NODE9_AUTO_STARTED: "1" }
@@ -15961,7 +15958,7 @@ var import_chalk11 = __toESM(require("chalk"));
15961
15958
  var import_fs33 = __toESM(require("fs"));
15962
15959
  var import_path34 = __toESM(require("path"));
15963
15960
  var import_os29 = __toESM(require("os"));
15964
- var import_child_process10 = require("child_process");
15961
+ var import_child_process8 = require("child_process");
15965
15962
  init_daemon();
15966
15963
  function registerDoctorCommand(program2, version2) {
15967
15964
  program2.command("doctor").description("Check that Node9 is installed and configured correctly").action(() => {
@@ -15987,7 +15984,7 @@ function registerDoctorCommand(program2, version2) {
15987
15984
  `));
15988
15985
  section("Binary");
15989
15986
  try {
15990
- const which = (0, import_child_process10.execSync)("which node9", { encoding: "utf-8", timeout: 3e3 }).trim();
15987
+ const which = (0, import_child_process8.execSync)("which node9", { encoding: "utf-8", timeout: 3e3 }).trim();
15991
15988
  pass(`node9 found at ${which}`);
15992
15989
  } catch {
15993
15990
  warn(
@@ -16005,7 +16002,7 @@ function registerDoctorCommand(program2, version2) {
16005
16002
  );
16006
16003
  }
16007
16004
  try {
16008
- const gitVersion = (0, import_child_process10.execSync)("git --version", { encoding: "utf-8", timeout: 3e3 }).trim();
16005
+ const gitVersion = (0, import_child_process8.execSync)("git --version", { encoding: "utf-8", timeout: 3e3 }).trim();
16009
16006
  pass(gitVersion);
16010
16007
  } catch {
16011
16008
  warn(
@@ -16106,10 +16103,12 @@ function registerDoctorCommand(program2, version2) {
16106
16103
  }
16107
16104
  section("Daemon (optional)");
16108
16105
  if (isDaemonRunning()) {
16109
- pass(`Browser dashboard running \u2192 http://${DAEMON_HOST}:${DAEMON_PORT}/`);
16106
+ pass(
16107
+ `Daemon running on ${DAEMON_HOST}:${DAEMON_PORT} \u2014 terminal & native approvals enabled`
16108
+ );
16110
16109
  } else {
16111
16110
  warn(
16112
- "Daemon not running \u2014 browser approvals unavailable",
16111
+ "Daemon not running \u2014 terminal & native approvals unavailable",
16113
16112
  "Run: node9 daemon --background"
16114
16113
  );
16115
16114
  }
@@ -16981,7 +16980,7 @@ function registerReportCommand(program2) {
16981
16980
 
16982
16981
  // src/cli/commands/daemon-cmd.ts
16983
16982
  var import_chalk14 = __toESM(require("chalk"));
16984
- var import_child_process11 = require("child_process");
16983
+ var import_child_process9 = require("child_process");
16985
16984
  init_daemon2();
16986
16985
  var VALID_ACTIONS = "start | stop | restart | status | install | uninstall";
16987
16986
  function registerDaemonCommand(program2) {
@@ -17020,7 +17019,7 @@ function registerDaemonCommand(program2) {
17020
17019
  if (cmd === "restart") {
17021
17020
  stopDaemon();
17022
17021
  await new Promise((r) => setTimeout(r, 500));
17023
- const child = (0, import_child_process11.spawn)(process.execPath, [process.argv[1], "daemon"], {
17022
+ const child = (0, import_child_process9.spawn)(process.execPath, [process.argv[1], "daemon"], {
17024
17023
  detached: true,
17025
17024
  stdio: "ignore",
17026
17025
  env: { ...process.env, NODE9_AUTO_STARTED: "1" }
@@ -17050,7 +17049,7 @@ function registerDaemonCommand(program2) {
17050
17049
  return;
17051
17050
  }
17052
17051
  if (options.background) {
17053
- const child = (0, import_child_process11.spawn)(process.execPath, [process.argv[1], "daemon"], {
17052
+ const child = (0, import_child_process9.spawn)(process.execPath, [process.argv[1], "daemon"], {
17054
17053
  detached: true,
17055
17054
  stdio: "ignore"
17056
17055
  });
@@ -17708,7 +17707,7 @@ function registerUndoCommand(program2) {
17708
17707
 
17709
17708
  // src/cli/commands/watch.ts
17710
17709
  var import_chalk19 = __toESM(require("chalk"));
17711
- var import_child_process12 = require("child_process");
17710
+ var import_child_process10 = require("child_process");
17712
17711
  init_daemon();
17713
17712
  function registerWatchCommand(program2) {
17714
17713
  program2.command("watch").description("Run a command under Node9 watch mode (daemon stays alive for the session)").argument("<command>", "Command to run").argument("[args...]", "Arguments for the command").action(async (cmd, args) => {
@@ -17725,7 +17724,7 @@ function registerWatchCommand(program2) {
17725
17724
  }
17726
17725
  } catch {
17727
17726
  console.error(import_chalk19.default.dim("\u{1F6E1}\uFE0F Starting Node9 daemon (watch mode)..."));
17728
- const child = (0, import_child_process12.spawn)(process.execPath, [process.argv[1], "daemon"], {
17727
+ const child = (0, import_child_process10.spawn)(process.execPath, [process.argv[1], "daemon"], {
17729
17728
  detached: true,
17730
17729
  stdio: "ignore",
17731
17730
  env: { ...process.env, NODE9_AUTO_STARTED: "1", NODE9_WATCH_MODE: "1" }
@@ -17755,7 +17754,7 @@ function registerWatchCommand(program2) {
17755
17754
  "\n Tip: run `node9 tail` in another terminal to review and approve AI actions.\n"
17756
17755
  )
17757
17756
  );
17758
- const result = (0, import_child_process12.spawnSync)(cmd, args, {
17757
+ const result = (0, import_child_process10.spawnSync)(cmd, args, {
17759
17758
  stdio: "inherit",
17760
17759
  env: { ...process.env, NODE9_WATCH_MODE: "1" }
17761
17760
  });
@@ -17770,7 +17769,7 @@ function registerWatchCommand(program2) {
17770
17769
  // src/mcp-gateway/index.ts
17771
17770
  var import_readline4 = __toESM(require("readline"));
17772
17771
  var import_chalk20 = __toESM(require("chalk"));
17773
- var import_child_process13 = require("child_process");
17772
+ var import_child_process11 = require("child_process");
17774
17773
  var import_execa3 = require("execa");
17775
17774
  init_orchestrator();
17776
17775
  init_provenance();
@@ -17956,7 +17955,7 @@ async function runMcpGateway(upstreamCommand) {
17956
17955
  const safeEnv = Object.fromEntries(
17957
17956
  Object.entries(process.env).filter(([k]) => !UPSTREAM_INJECTOR_VARS.has(k))
17958
17957
  );
17959
- const child = (0, import_child_process13.spawn)(executable, cmdArgs, {
17958
+ const child = (0, import_child_process11.spawn)(executable, cmdArgs, {
17960
17959
  stdio: ["pipe", "pipe", "inherit"],
17961
17960
  // control stdin/stdout; inherit stderr
17962
17961
  shell: false,
@@ -18302,7 +18301,7 @@ var import_readline5 = __toESM(require("readline"));
18302
18301
  var import_fs39 = __toESM(require("fs"));
18303
18302
  var import_os35 = __toESM(require("os"));
18304
18303
  var import_path41 = __toESM(require("path"));
18305
- var import_child_process14 = require("child_process");
18304
+ var import_child_process12 = require("child_process");
18306
18305
  init_core();
18307
18306
  init_daemon();
18308
18307
  init_shields();
@@ -18776,7 +18775,7 @@ function handleRuleAdd(args) {
18776
18775
  return `Rule "${name}" added to ~/.node9/config.json \u2014 verdict: ${verdict} when ${field} matches "${pattern}"`;
18777
18776
  }
18778
18777
  function runCliCommand(subArgs) {
18779
- const result = (0, import_child_process14.spawnSync)(process.execPath, [process.argv[1], ...subArgs], {
18778
+ const result = (0, import_child_process12.spawnSync)(process.execPath, [process.argv[1], ...subArgs], {
18780
18779
  encoding: "utf-8",
18781
18780
  timeout: 6e4,
18782
18781
  // Disable colors — stdout is piped (not a TTY), chalk auto-detects, but be explicit
package/dist/cli.mjs CHANGED
@@ -4651,7 +4651,6 @@ import fs9 from "fs";
4651
4651
  import net from "net";
4652
4652
  import path9 from "path";
4653
4653
  import os8 from "os";
4654
- import { spawnSync } from "child_process";
4655
4654
  function notifyActivitySocket(data) {
4656
4655
  return new Promise((resolve) => {
4657
4656
  try {
@@ -4721,19 +4720,16 @@ function isDaemonRunning() {
4721
4720
  }
4722
4721
  return false;
4723
4722
  }
4724
- const r = spawnSync("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
4725
- encoding: "utf8",
4726
- timeout: 300
4727
- });
4728
- if (r.status === 0 && (r.stdout ?? "").includes(`:${DAEMON_PORT}`)) return true;
4729
- return false;
4723
+ return true;
4730
4724
  }
4725
+ return false;
4726
+ }
4727
+ async function isDaemonReachable(timeoutMs = 500) {
4731
4728
  try {
4732
- const r = spawnSync("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
4733
- encoding: "utf8",
4734
- timeout: 300
4729
+ const res = await fetch(`http://${DAEMON_HOST}:${DAEMON_PORT}/settings`, {
4730
+ signal: AbortSignal.timeout(timeoutMs)
4735
4731
  });
4736
- return r.status === 0 && (r.stdout ?? "").includes(`:${DAEMON_PORT}`);
4732
+ return res.ok;
4737
4733
  } catch {
4738
4734
  return false;
4739
4735
  }
@@ -11834,7 +11830,7 @@ import fs25 from "fs";
11834
11830
  import path27 from "path";
11835
11831
  import os23 from "os";
11836
11832
  import { randomUUID as randomUUID4 } from "crypto";
11837
- import { spawnSync as spawnSync2 } from "child_process";
11833
+ import { spawnSync } from "child_process";
11838
11834
  import chalk6 from "chalk";
11839
11835
  function startDaemon() {
11840
11836
  startCostSync();
@@ -12644,13 +12640,26 @@ data: ${JSON.stringify(item.data)}
12644
12640
  }).then((res) => {
12645
12641
  if (res.ok) {
12646
12642
  try {
12647
- const r = spawnSync2("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
12643
+ let orphanPid = null;
12644
+ const ss = spawnSync("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
12648
12645
  encoding: "utf8",
12649
12646
  timeout: 1e3
12650
12647
  });
12651
- const match = r.stdout?.match(/pid=(\d+)/);
12652
- if (match) {
12653
- const orphanPid = parseInt(match[1], 10);
12648
+ if (!ss.error && ss.status === 0) {
12649
+ const m = ss.stdout?.match(/pid=(\d+)/);
12650
+ if (m) orphanPid = parseInt(m[1], 10);
12651
+ } else if (ss.error?.code === "ENOENT" || ss.status === null) {
12652
+ const lsof = spawnSync(
12653
+ "lsof",
12654
+ ["-nP", `-iTCP:${DAEMON_PORT}`, "-sTCP:LISTEN", "-t"],
12655
+ { encoding: "utf8", timeout: 1e3 }
12656
+ );
12657
+ if (!lsof.error && lsof.status === 0) {
12658
+ const first = (lsof.stdout ?? "").split("\n")[0].trim();
12659
+ if (/^\d+$/.test(first)) orphanPid = parseInt(first, 10);
12660
+ }
12661
+ }
12662
+ if (orphanPid !== null) {
12654
12663
  process.kill(orphanPid, 0);
12655
12664
  atomicWriteSync2(
12656
12665
  DAEMON_PID_FILE,
@@ -12685,7 +12694,7 @@ data: ${JSON.stringify(item.data)}
12685
12694
  JSON.stringify({ pid: process.pid, port: DAEMON_PORT, internalToken, autoStarted }),
12686
12695
  { mode: 384 }
12687
12696
  );
12688
- console.error(chalk6.green(`\u{1F6E1}\uFE0F Node9 Guard LIVE: http://127.0.0.1:${DAEMON_PORT}`));
12697
+ console.error(chalk6.green(`\u{1F6E1}\uFE0F Node9 Guard LIVE on 127.0.0.1:${DAEMON_PORT}`));
12689
12698
  });
12690
12699
  if (watchMode) {
12691
12700
  console.error(chalk6.cyan("\u{1F6F0}\uFE0F Flight Recorder active \u2014 daemon will not idle-timeout"));
@@ -12711,7 +12720,7 @@ var init_server = __esm({
12711
12720
  import fs26 from "fs";
12712
12721
  import path28 from "path";
12713
12722
  import os24 from "os";
12714
- import { spawnSync as spawnSync3, execFileSync } from "child_process";
12723
+ import { spawnSync as spawnSync2, execFileSync } from "child_process";
12715
12724
  function resolveNode9Binary() {
12716
12725
  try {
12717
12726
  const script = process.argv[1];
@@ -12722,7 +12731,7 @@ function resolveNode9Binary() {
12722
12731
  }
12723
12732
  try {
12724
12733
  const cmd = process.platform === "win32" ? "where" : "which";
12725
- const r = spawnSync3(cmd, ["node9"], { encoding: "utf8", timeout: 3e3 });
12734
+ const r = spawnSync2(cmd, ["node9"], { encoding: "utf8", timeout: 3e3 });
12726
12735
  if (r.status === 0 && r.stdout.trim()) {
12727
12736
  return r.stdout.trim().split("\n")[0].trim();
12728
12737
  }
@@ -12774,8 +12783,8 @@ function installLaunchd(binaryPath) {
12774
12783
  const dir = path28.dirname(LAUNCHD_PLIST);
12775
12784
  if (!fs26.existsSync(dir)) fs26.mkdirSync(dir, { recursive: true });
12776
12785
  fs26.writeFileSync(LAUNCHD_PLIST, launchdPlist(binaryPath), "utf-8");
12777
- spawnSync3("launchctl", ["unload", LAUNCHD_PLIST], { encoding: "utf8" });
12778
- const r = spawnSync3("launchctl", ["load", "-w", LAUNCHD_PLIST], {
12786
+ spawnSync2("launchctl", ["unload", LAUNCHD_PLIST], { encoding: "utf8" });
12787
+ const r = spawnSync2("launchctl", ["load", "-w", LAUNCHD_PLIST], {
12779
12788
  encoding: "utf8",
12780
12789
  timeout: 5e3
12781
12790
  });
@@ -12785,7 +12794,7 @@ function installLaunchd(binaryPath) {
12785
12794
  }
12786
12795
  function uninstallLaunchd() {
12787
12796
  if (fs26.existsSync(LAUNCHD_PLIST)) {
12788
- spawnSync3("launchctl", ["unload", "-w", LAUNCHD_PLIST], { encoding: "utf8", timeout: 5e3 });
12797
+ spawnSync2("launchctl", ["unload", "-w", LAUNCHD_PLIST], { encoding: "utf8", timeout: 5e3 });
12789
12798
  fs26.unlinkSync(LAUNCHD_PLIST);
12790
12799
  }
12791
12800
  }
@@ -12817,15 +12826,15 @@ function installSystemd(binaryPath) {
12817
12826
  execFileSync("loginctl", ["enable-linger", os24.userInfo().username], { timeout: 3e3 });
12818
12827
  } catch {
12819
12828
  }
12820
- const reload = spawnSync3("systemctl", ["--user", "daemon-reload"], {
12829
+ const reload = spawnSync2("systemctl", ["--user", "daemon-reload"], {
12821
12830
  encoding: "utf8",
12822
12831
  timeout: 5e3
12823
12832
  });
12824
12833
  if (reload.status !== 0) {
12825
12834
  throw new Error(`systemctl daemon-reload failed: ${reload.stderr}`);
12826
12835
  }
12827
- spawnSync3("systemctl", ["--user", "stop", "node9-daemon"], { encoding: "utf8", timeout: 3e3 });
12828
- const enable = spawnSync3("systemctl", ["--user", "enable", "--now", "node9-daemon"], {
12836
+ spawnSync2("systemctl", ["--user", "stop", "node9-daemon"], { encoding: "utf8", timeout: 3e3 });
12837
+ const enable = spawnSync2("systemctl", ["--user", "enable", "--now", "node9-daemon"], {
12829
12838
  encoding: "utf8",
12830
12839
  timeout: 5e3
12831
12840
  });
@@ -12835,11 +12844,11 @@ function installSystemd(binaryPath) {
12835
12844
  }
12836
12845
  function uninstallSystemd() {
12837
12846
  if (fs26.existsSync(SYSTEMD_UNIT)) {
12838
- spawnSync3("systemctl", ["--user", "disable", "--now", "node9-daemon"], {
12847
+ spawnSync2("systemctl", ["--user", "disable", "--now", "node9-daemon"], {
12839
12848
  encoding: "utf8",
12840
12849
  timeout: 5e3
12841
12850
  });
12842
- spawnSync3("systemctl", ["--user", "daemon-reload"], { encoding: "utf8", timeout: 5e3 });
12851
+ spawnSync2("systemctl", ["--user", "daemon-reload"], { encoding: "utf8", timeout: 5e3 });
12843
12852
  fs26.unlinkSync(SYSTEMD_UNIT);
12844
12853
  }
12845
12854
  }
@@ -12857,7 +12866,7 @@ function stopRunningDaemon() {
12857
12866
  try {
12858
12867
  process.kill(pid, "SIGTERM");
12859
12868
  const deadline = Date.now() + 3e3;
12860
- const pollStop = spawnSync3(
12869
+ const pollStop = spawnSync2(
12861
12870
  "sh",
12862
12871
  ["-c", `while kill -0 ${pid} 2>/dev/null; do sleep 0.1; done`],
12863
12872
  {
@@ -12889,7 +12898,7 @@ function installDaemonService() {
12889
12898
  return { ok: true, platform: "launchd", alreadyInstalled };
12890
12899
  }
12891
12900
  if (process.platform === "linux") {
12892
- const check = spawnSync3("systemctl", ["--user", "--version"], {
12901
+ const check = spawnSync2("systemctl", ["--user", "--version"], {
12893
12902
  encoding: "utf8",
12894
12903
  timeout: 2e3
12895
12904
  });
@@ -12954,7 +12963,6 @@ var init_service = __esm({
12954
12963
  // src/daemon/index.ts
12955
12964
  import fs27 from "fs";
12956
12965
  import chalk7 from "chalk";
12957
- import { spawnSync as spawnSync4 } from "child_process";
12958
12966
  function stopDaemon() {
12959
12967
  if (!fs27.existsSync(DAEMON_PID_FILE)) return console.log(chalk7.yellow("Not running."));
12960
12968
  try {
@@ -12996,15 +13004,7 @@ function daemonStatus() {
12996
13004
  processStatus = chalk7.yellow("not running (stale PID file)");
12997
13005
  }
12998
13006
  } else {
12999
- const r = spawnSync4("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
13000
- encoding: "utf8",
13001
- timeout: 500
13002
- });
13003
- if (r.status === 0 && (r.stdout ?? "").includes(`:${DAEMON_PORT}`)) {
13004
- processStatus = chalk7.yellow(`running (orphaned \u2014 no PID file)`);
13005
- } else {
13006
- processStatus = chalk7.yellow("not running");
13007
- }
13007
+ processStatus = chalk7.yellow("not running");
13008
13008
  }
13009
13009
  console.log(`
13010
13010
  Process : ${processStatus}`);
@@ -14473,13 +14473,7 @@ async function autoStartDaemonAndWait() {
14473
14473
  for (let i = 0; i < 20; i++) {
14474
14474
  await new Promise((r) => setTimeout(r, 250));
14475
14475
  if (!isDaemonRunning()) continue;
14476
- try {
14477
- const res = await fetch(`http://${DAEMON_HOST}:${DAEMON_PORT}/settings`, {
14478
- signal: AbortSignal.timeout(500)
14479
- });
14480
- if (res.ok) return true;
14481
- } catch {
14482
- }
14476
+ if (await isDaemonReachable()) return true;
14483
14477
  }
14484
14478
  } catch {
14485
14479
  }
@@ -14498,7 +14492,7 @@ import path32 from "path";
14498
14492
  import os27 from "os";
14499
14493
 
14500
14494
  // src/undo.ts
14501
- import { spawnSync as spawnSync5, spawn as spawn4 } from "child_process";
14495
+ import { spawnSync as spawnSync3, spawn as spawn4 } from "child_process";
14502
14496
  import crypto3 from "crypto";
14503
14497
  import fs29 from "fs";
14504
14498
  import net3 from "net";
@@ -14611,7 +14605,7 @@ function ensureShadowRepo(shadowDir, cwd) {
14611
14605
  cleanOrphanedIndexFiles(shadowDir);
14612
14606
  const normalizedCwd = normalizeCwdForHash(cwd);
14613
14607
  const shadowEnvBase = { ...process.env, GIT_DIR: shadowDir, GIT_WORK_TREE: cwd };
14614
- const check = spawnSync5("git", ["rev-parse", "--git-dir"], {
14608
+ const check = spawnSync3("git", ["rev-parse", "--git-dir"], {
14615
14609
  env: shadowEnvBase,
14616
14610
  timeout: 3e3
14617
14611
  });
@@ -14637,17 +14631,17 @@ function ensureShadowRepo(shadowDir, cwd) {
14637
14631
  fs29.mkdirSync(shadowDir, { recursive: true });
14638
14632
  } catch {
14639
14633
  }
14640
- const init = spawnSync5("git", ["init", "--bare", shadowDir], { timeout: 5e3 });
14634
+ const init = spawnSync3("git", ["init", "--bare", shadowDir], { timeout: 5e3 });
14641
14635
  if (init.status !== 0 || init.error) {
14642
14636
  const reason = init.error ? init.error.message : init.stderr?.toString();
14643
14637
  if (process.env.NODE9_DEBUG === "1") console.error("[Node9] git init --bare failed:", reason);
14644
14638
  return false;
14645
14639
  }
14646
14640
  const configFile = path30.join(shadowDir, "config");
14647
- spawnSync5("git", ["config", "--file", configFile, "core.untrackedCache", "true"], {
14641
+ spawnSync3("git", ["config", "--file", configFile, "core.untrackedCache", "true"], {
14648
14642
  timeout: 3e3
14649
14643
  });
14650
- spawnSync5("git", ["config", "--file", configFile, "core.fsmonitor", "true"], {
14644
+ spawnSync3("git", ["config", "--file", configFile, "core.fsmonitor", "true"], {
14651
14645
  timeout: 3e3
14652
14646
  });
14653
14647
  try {
@@ -14658,14 +14652,17 @@ function ensureShadowRepo(shadowDir, cwd) {
14658
14652
  }
14659
14653
  function buildGitEnv(cwd) {
14660
14654
  const shadowDir = getShadowRepoDir(cwd);
14661
- const check = spawnSync5("git", ["rev-parse", "--git-dir"], {
14655
+ const check = spawnSync3("git", ["rev-parse", "--git-dir"], {
14662
14656
  env: { ...process.env, GIT_DIR: shadowDir, GIT_WORK_TREE: cwd },
14663
14657
  timeout: 2e3
14664
14658
  });
14665
14659
  if (check.status === 0) {
14666
14660
  return { ...process.env, GIT_DIR: shadowDir, GIT_WORK_TREE: cwd };
14667
14661
  }
14668
- return { ...process.env };
14662
+ const env = { ...process.env };
14663
+ delete env.GIT_DIR;
14664
+ delete env.GIT_WORK_TREE;
14665
+ return env;
14669
14666
  }
14670
14667
  async function createShadowSnapshot(tool = "unknown", args = {}, ignorePaths = []) {
14671
14668
  let indexFile = null;
@@ -14683,11 +14680,11 @@ async function createShadowSnapshot(tool = "unknown", args = {}, ignorePaths = [
14683
14680
  GIT_WORK_TREE: cwd,
14684
14681
  GIT_INDEX_FILE: indexFile
14685
14682
  };
14686
- spawnSync5("git", ["add", "-A"], { env: shadowEnv, timeout: GIT_TIMEOUT });
14687
- const treeRes = spawnSync5("git", ["write-tree"], { env: shadowEnv, timeout: GIT_TIMEOUT });
14683
+ spawnSync3("git", ["add", "-A"], { env: shadowEnv, timeout: GIT_TIMEOUT });
14684
+ const treeRes = spawnSync3("git", ["write-tree"], { env: shadowEnv, timeout: GIT_TIMEOUT });
14688
14685
  const treeHash = treeRes.stdout?.toString().trim();
14689
14686
  if (!treeHash || treeRes.status !== 0) return null;
14690
- const commitRes = spawnSync5(
14687
+ const commitRes = spawnSync3(
14691
14688
  "git",
14692
14689
  ["commit-tree", treeHash, "-m", `Node9 AI Snapshot: ${(/* @__PURE__ */ new Date()).toISOString()}`],
14693
14690
  { env: shadowEnv, timeout: GIT_TIMEOUT }
@@ -14699,7 +14696,7 @@ async function createShadowSnapshot(tool = "unknown", args = {}, ignorePaths = [
14699
14696
  let capturedFiles = [];
14700
14697
  let capturedDiff = null;
14701
14698
  if (prevEntry) {
14702
- const filesRes = spawnSync5("git", ["diff", "--name-only", prevEntry.hash, commitHash], {
14699
+ const filesRes = spawnSync3("git", ["diff", "--name-only", prevEntry.hash, commitHash], {
14703
14700
  env: shadowEnv,
14704
14701
  timeout: GIT_TIMEOUT
14705
14702
  });
@@ -14709,7 +14706,7 @@ async function createShadowSnapshot(tool = "unknown", args = {}, ignorePaths = [
14709
14706
  if (capturedFiles.length === 0) {
14710
14707
  return prevEntry.hash;
14711
14708
  }
14712
- const diffRes = spawnSync5("git", ["diff", prevEntry.hash, commitHash], {
14709
+ const diffRes = spawnSync3("git", ["diff", prevEntry.hash, commitHash], {
14713
14710
  env: shadowEnv,
14714
14711
  timeout: GIT_TIMEOUT
14715
14712
  });
@@ -14717,7 +14714,7 @@ async function createShadowSnapshot(tool = "unknown", args = {}, ignorePaths = [
14717
14714
  capturedDiff = diffRes.stdout?.toString() || null;
14718
14715
  }
14719
14716
  } else {
14720
- const filesRes = spawnSync5("git", ["ls-tree", "-r", "--name-only", commitHash], {
14717
+ const filesRes = spawnSync3("git", ["ls-tree", "-r", "--name-only", commitHash], {
14721
14718
  env: shadowEnv,
14722
14719
  timeout: GIT_TIMEOUT
14723
14720
  });
@@ -14771,14 +14768,14 @@ function getSnapshotHistory() {
14771
14768
  function computeUndoDiff(hash, cwd) {
14772
14769
  try {
14773
14770
  const env = buildGitEnv(cwd);
14774
- const statRes = spawnSync5("git", ["diff", hash, "--stat", "--", "."], {
14771
+ const statRes = spawnSync3("git", ["diff", hash, "--stat", "--", "."], {
14775
14772
  cwd,
14776
14773
  env,
14777
14774
  timeout: GIT_TIMEOUT
14778
14775
  });
14779
14776
  const stat = statRes.stdout?.toString().trim();
14780
14777
  if (!stat || statRes.status !== 0) return null;
14781
- const diffRes = spawnSync5("git", ["diff", hash, "--", "."], {
14778
+ const diffRes = spawnSync3("git", ["diff", hash, "--", "."], {
14782
14779
  cwd,
14783
14780
  env,
14784
14781
  timeout: GIT_TIMEOUT
@@ -14797,7 +14794,7 @@ function applyUndo(hash, cwd) {
14797
14794
  try {
14798
14795
  const dir = cwd ?? process.cwd();
14799
14796
  const env = buildGitEnv(dir);
14800
- const restore = spawnSync5("git", ["restore", "--source", hash, "--staged", "--worktree", "."], {
14797
+ const restore = spawnSync3("git", ["restore", "--source", hash, "--staged", "--worktree", "."], {
14801
14798
  cwd: dir,
14802
14799
  env,
14803
14800
  timeout: GIT_TIMEOUT
@@ -14809,7 +14806,7 @@ function applyUndo(hash, cwd) {
14809
14806
  }
14810
14807
  return false;
14811
14808
  }
14812
- const lsTree = spawnSync5("git", ["ls-tree", "-r", "--name-only", hash], {
14809
+ const lsTree = spawnSync3("git", ["ls-tree", "-r", "--name-only", hash], {
14813
14810
  cwd: dir,
14814
14811
  env,
14815
14812
  timeout: GIT_TIMEOUT
@@ -14828,8 +14825,8 @@ function applyUndo(hash, cwd) {
14828
14825
  `);
14829
14826
  return false;
14830
14827
  }
14831
- const tracked = spawnSync5("git", ["ls-files"], { cwd: dir, env, timeout: GIT_TIMEOUT }).stdout?.toString().trim().split("\n").filter(Boolean) ?? [];
14832
- const untracked = spawnSync5("git", ["ls-files", "--others", "--exclude-standard"], {
14828
+ const tracked = spawnSync3("git", ["ls-files"], { cwd: dir, env, timeout: GIT_TIMEOUT }).stdout?.toString().trim().split("\n").filter(Boolean) ?? [];
14829
+ const untracked = spawnSync3("git", ["ls-files", "--others", "--exclude-standard"], {
14833
14830
  cwd: dir,
14834
14831
  env,
14835
14832
  timeout: GIT_TIMEOUT
@@ -16078,10 +16075,12 @@ function registerDoctorCommand(program2, version2) {
16078
16075
  }
16079
16076
  section("Daemon (optional)");
16080
16077
  if (isDaemonRunning()) {
16081
- pass(`Browser dashboard running \u2192 http://${DAEMON_HOST}:${DAEMON_PORT}/`);
16078
+ pass(
16079
+ `Daemon running on ${DAEMON_HOST}:${DAEMON_PORT} \u2014 terminal & native approvals enabled`
16080
+ );
16082
16081
  } else {
16083
16082
  warn(
16084
- "Daemon not running \u2014 browser approvals unavailable",
16083
+ "Daemon not running \u2014 terminal & native approvals unavailable",
16085
16084
  "Run: node9 daemon --background"
16086
16085
  );
16087
16086
  }
@@ -17681,7 +17680,7 @@ function registerUndoCommand(program2) {
17681
17680
  // src/cli/commands/watch.ts
17682
17681
  init_daemon();
17683
17682
  import chalk19 from "chalk";
17684
- import { spawn as spawn7, spawnSync as spawnSync6 } from "child_process";
17683
+ import { spawn as spawn7, spawnSync as spawnSync4 } from "child_process";
17685
17684
  function registerWatchCommand(program2) {
17686
17685
  program2.command("watch").description("Run a command under Node9 watch mode (daemon stays alive for the session)").argument("<command>", "Command to run").argument("[args...]", "Arguments for the command").action(async (cmd, args) => {
17687
17686
  let port = DAEMON_PORT;
@@ -17727,7 +17726,7 @@ function registerWatchCommand(program2) {
17727
17726
  "\n Tip: run `node9 tail` in another terminal to review and approve AI actions.\n"
17728
17727
  )
17729
17728
  );
17730
- const result = spawnSync6(cmd, args, {
17729
+ const result = spawnSync4(cmd, args, {
17731
17730
  stdio: "inherit",
17732
17731
  env: { ...process.env, NODE9_WATCH_MODE: "1" }
17733
17732
  });
@@ -18274,7 +18273,7 @@ import readline5 from "readline";
18274
18273
  import fs39 from "fs";
18275
18274
  import os35 from "os";
18276
18275
  import path41 from "path";
18277
- import { spawnSync as spawnSync7 } from "child_process";
18276
+ import { spawnSync as spawnSync5 } from "child_process";
18278
18277
  init_core();
18279
18278
  init_daemon();
18280
18279
  init_shields();
@@ -18748,7 +18747,7 @@ function handleRuleAdd(args) {
18748
18747
  return `Rule "${name}" added to ~/.node9/config.json \u2014 verdict: ${verdict} when ${field} matches "${pattern}"`;
18749
18748
  }
18750
18749
  function runCliCommand(subArgs) {
18751
- const result = spawnSync7(process.execPath, [process.argv[1], ...subArgs], {
18750
+ const result = spawnSync5(process.execPath, [process.argv[1], ...subArgs], {
18752
18751
  encoding: "utf-8",
18753
18752
  timeout: 6e4,
18754
18753
  // Disable colors — stdout is piped (not a TTY), chalk auto-detects, but be explicit
package/dist/index.js CHANGED
@@ -3601,7 +3601,6 @@ var import_fs8 = __toESM(require("fs"));
3601
3601
  var import_net = __toESM(require("net"));
3602
3602
  var import_path8 = __toESM(require("path"));
3603
3603
  var import_os7 = __toESM(require("os"));
3604
- var import_child_process = require("child_process");
3605
3604
  var ACTIVITY_SOCKET_PATH = process.platform === "win32" ? "\\\\.\\pipe\\node9-activity" : import_path8.default.join(import_os7.default.tmpdir(), "node9-activity.sock");
3606
3605
  function notifyActivitySocket(data) {
3607
3606
  return new Promise((resolve) => {
@@ -3674,22 +3673,9 @@ function isDaemonRunning() {
3674
3673
  }
3675
3674
  return false;
3676
3675
  }
3677
- const r = (0, import_child_process.spawnSync)("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
3678
- encoding: "utf8",
3679
- timeout: 300
3680
- });
3681
- if (r.status === 0 && (r.stdout ?? "").includes(`:${DAEMON_PORT}`)) return true;
3682
- return false;
3683
- }
3684
- try {
3685
- const r = (0, import_child_process.spawnSync)("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
3686
- encoding: "utf8",
3687
- timeout: 300
3688
- });
3689
- return r.status === 0 && (r.stdout ?? "").includes(`:${DAEMON_PORT}`);
3690
- } catch {
3691
- return false;
3676
+ return true;
3692
3677
  }
3678
+ return false;
3693
3679
  }
3694
3680
  async function registerDaemonEntry(toolName, args, meta, riskMetadata, activityId, cwd, recoveryCommand, skipBackgroundAuth, viewOnly, localSmartRuleMatched, socketActivitySent) {
3695
3681
  const base = `http://${DAEMON_HOST}:${DAEMON_PORT}`;
@@ -3817,7 +3803,7 @@ async function resolveViaDaemon(id, decision, internalToken, source) {
3817
3803
  var import_crypto3 = require("crypto");
3818
3804
 
3819
3805
  // src/ui/native.ts
3820
- var import_child_process2 = require("child_process");
3806
+ var import_child_process = require("child_process");
3821
3807
  var import_path10 = __toESM(require("path"));
3822
3808
 
3823
3809
  // src/context-sniper.ts
@@ -4091,7 +4077,7 @@ activate
4091
4077
  display dialog (item 1 of argv) with title (item 2 of argv) ${buttons}
4092
4078
  end tell
4093
4079
  end run`;
4094
- childProcess = (0, import_child_process2.spawn)("osascript", ["-e", script, "--", message, title]);
4080
+ childProcess = (0, import_child_process.spawn)("osascript", ["-e", script, "--", message, title]);
4095
4081
  } else if (process.platform === "linux") {
4096
4082
  const pangoMessage = buildPangoMessage(
4097
4083
  toolName,
@@ -4117,12 +4103,12 @@ end run`;
4117
4103
  argsList.push("--cancel-label", "Block \u238B");
4118
4104
  argsList.push("--extra-button", "Always Allow");
4119
4105
  }
4120
- childProcess = (0, import_child_process2.spawn)("zenity", argsList);
4106
+ childProcess = (0, import_child_process.spawn)("zenity", argsList);
4121
4107
  } else if (process.platform === "win32") {
4122
4108
  const b64Msg = Buffer.from(message).toString("base64");
4123
4109
  const b64Title = Buffer.from(title).toString("base64");
4124
4110
  const ps = `Add-Type -AssemblyName PresentationFramework; $msg = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("${b64Msg}")); $title = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("${b64Title}")); $res = [System.Windows.MessageBox]::Show($msg, $title, "${locked ? "OK" : "YesNo"}", "Warning", "Button2", "DefaultDesktopOnly"); if ($res -eq "Yes") { exit 0 } else { exit 1 }`;
4125
- childProcess = (0, import_child_process2.spawn)("powershell", ["-Command", ps]);
4111
+ childProcess = (0, import_child_process.spawn)("powershell", ["-Command", ps]);
4126
4112
  }
4127
4113
  let output = "";
4128
4114
  childProcess?.stdout?.on("data", (d) => output += d.toString());
package/dist/index.mjs CHANGED
@@ -3571,7 +3571,6 @@ import fs8 from "fs";
3571
3571
  import net from "net";
3572
3572
  import path8 from "path";
3573
3573
  import os7 from "os";
3574
- import { spawnSync } from "child_process";
3575
3574
  var ACTIVITY_SOCKET_PATH = process.platform === "win32" ? "\\\\.\\pipe\\node9-activity" : path8.join(os7.tmpdir(), "node9-activity.sock");
3576
3575
  function notifyActivitySocket(data) {
3577
3576
  return new Promise((resolve) => {
@@ -3644,22 +3643,9 @@ function isDaemonRunning() {
3644
3643
  }
3645
3644
  return false;
3646
3645
  }
3647
- const r = spawnSync("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
3648
- encoding: "utf8",
3649
- timeout: 300
3650
- });
3651
- if (r.status === 0 && (r.stdout ?? "").includes(`:${DAEMON_PORT}`)) return true;
3652
- return false;
3653
- }
3654
- try {
3655
- const r = spawnSync("ss", ["-Htnp", `sport = :${DAEMON_PORT}`], {
3656
- encoding: "utf8",
3657
- timeout: 300
3658
- });
3659
- return r.status === 0 && (r.stdout ?? "").includes(`:${DAEMON_PORT}`);
3660
- } catch {
3661
- return false;
3646
+ return true;
3662
3647
  }
3648
+ return false;
3663
3649
  }
3664
3650
  async function registerDaemonEntry(toolName, args, meta, riskMetadata, activityId, cwd, recoveryCommand, skipBackgroundAuth, viewOnly, localSmartRuleMatched, socketActivitySent) {
3665
3651
  const base = `http://${DAEMON_HOST}:${DAEMON_PORT}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node9/proxy",
3
- "version": "1.19.2",
3
+ "version": "1.19.3",
4
4
  "description": "The Sudo Command for AI Agents. Execution Security for Claude Code & MCP.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",