@node9/proxy 2.50.0 → 2.50.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.
Files changed (2) hide show
  1. package/dist/cli-main.js +54 -16
  2. package/package.json +1 -1
package/dist/cli-main.js CHANGED
@@ -24531,13 +24531,15 @@ function privateDir(dir2) {
24531
24531
  }
24532
24532
  return isPrivateDir(dir2);
24533
24533
  }
24534
+ function perHomeRuntimeDir(env, home) {
24535
+ const xdg = env.XDG_RUNTIME_DIR;
24536
+ if (!xdg || !import_path16.default.isAbsolute(xdg)) return null;
24537
+ return import_path16.default.join(xdg, `node9-${(0, import_crypto10.createHash)("sha256").update(home).digest("hex").slice(0, 12)}`);
24538
+ }
24534
24539
  function chooseActivitySocketPath(env, home, platform = process.platform) {
24535
24540
  const candidates2 = [];
24536
- const xdg = env.XDG_RUNTIME_DIR;
24537
- if (xdg && import_path16.default.isAbsolute(xdg) && isPrivateDir(xdg))
24538
- candidates2.push(
24539
- import_path16.default.join(xdg, `node9-${(0, import_crypto10.createHash)("sha256").update(home).digest("hex").slice(0, 12)}`)
24540
- );
24541
+ const xdgDir = perHomeRuntimeDir(env, home);
24542
+ if (xdgDir && isPrivateDir(import_path16.default.dirname(xdgDir))) candidates2.push(xdgDir);
24541
24543
  candidates2.push(import_path16.default.join(home, ".node9", "run"));
24542
24544
  for (const dir2 of candidates2) {
24543
24545
  const socketPath = import_path16.default.join(dir2, SOCKET_NAME);
@@ -24572,6 +24574,19 @@ function isOwnStaleSocket(socketPath) {
24572
24574
  return false;
24573
24575
  }
24574
24576
  }
24577
+ function removeOwnSocketDir(socketPath, env, home, platform = process.platform) {
24578
+ if (platform === "win32") return false;
24579
+ const dir2 = import_path16.default.dirname(socketPath);
24580
+ if (dir2 !== perHomeRuntimeDir(env, home)) return false;
24581
+ if (!isPrivateDir(dir2)) return false;
24582
+ try {
24583
+ if (import_fs16.default.readdirSync(dir2).length > 0) return false;
24584
+ import_fs16.default.rmdirSync(dir2);
24585
+ return true;
24586
+ } catch {
24587
+ return false;
24588
+ }
24589
+ }
24575
24590
  var import_fs16, import_path16, import_crypto10, SOCKET_NAME, currentUid, WINDOWS_PIPE;
24576
24591
  var init_activity_socket = __esm({
24577
24592
  "src/utils/activity-socket.ts"() {
@@ -44460,6 +44475,9 @@ function getDaemonServer() {
44460
44475
  function markRejectionHandlerRegistered() {
44461
44476
  daemonRejectionHandlerRegistered = true;
44462
44477
  }
44478
+ function markSignalHandlersRegistered() {
44479
+ daemonSignalHandlersRegistered = true;
44480
+ }
44463
44481
  function getActivitySocketPath() {
44464
44482
  return ACTIVITY_SOCKET_PATH;
44465
44483
  }
@@ -44683,14 +44701,23 @@ function startActivitySocket() {
44683
44701
  if (ACTIVITY_SOCKET_PATH && !import_fs65.default.existsSync(ACTIVITY_SOCKET_PATH)) attemptRebind("health-probe");
44684
44702
  }, ACTIVITY_HEALTH_PROBE_MS);
44685
44703
  activityHealthInterval.unref();
44686
- process.on("exit", () => {
44687
- if (activityHealthInterval) clearInterval(activityHealthInterval);
44688
- try {
44689
- if (ACTIVITY_SOCKET_PATH && isOwnStaleSocket(ACTIVITY_SOCKET_PATH))
44690
- import_fs65.default.unlinkSync(ACTIVITY_SOCKET_PATH);
44691
- } catch {
44692
- }
44693
- });
44704
+ process.on("exit", stopActivitySocket);
44705
+ }
44706
+ function stopActivitySocket() {
44707
+ if (activityHealthInterval) clearInterval(activityHealthInterval);
44708
+ activityHealthInterval = null;
44709
+ const socketPath = ACTIVITY_SOCKET_PATH;
44710
+ const bound = activitySocketIdentity;
44711
+ ACTIVITY_SOCKET_PATH = null;
44712
+ activitySocketIdentity = null;
44713
+ if (!socketPath || !bound || process.platform === "win32") return;
44714
+ try {
44715
+ const st = import_fs65.default.lstatSync(socketPath);
44716
+ if (isOwnStaleSocket(socketPath) && st.dev === bound.dev && st.ino === bound.ino)
44717
+ import_fs65.default.unlinkSync(socketPath);
44718
+ } catch {
44719
+ }
44720
+ removeOwnSocketDir(socketPath, process.env, import_os55.default.homedir());
44694
44721
  }
44695
44722
  function attemptRebind(reason) {
44696
44723
  if (!shouldRebind()) {
@@ -44824,6 +44851,8 @@ function bindActivitySocket() {
44824
44851
  if (process.platform !== "win32") {
44825
44852
  try {
44826
44853
  import_fs65.default.chmodSync(socketPath, 384);
44854
+ const st = import_fs65.default.lstatSync(socketPath);
44855
+ activitySocketIdentity = { dev: st.dev, ino: st.ino };
44827
44856
  } catch {
44828
44857
  }
44829
44858
  }
@@ -44831,7 +44860,7 @@ function bindActivitySocket() {
44831
44860
  });
44832
44861
  activitySocketServer = unixServer;
44833
44862
  }
44834
- var import_net5, import_fs65, import_path68, import_os55, import_crypto20, homeDir, DAEMON_PID_FILE, DECISIONS_FILE, AUDIT_LOG_FILE, TRUST_FILE2, GLOBAL_CONFIG_FILE, CREDENTIALS_FILE, INSIGHT_COUNTS_FILE, sseClients, cards, suggestionTracker, taintStore, sessionTaintStore, sessionExposureStore, sessionWriteStore, insightCounts, _abandonTimer, _hadBrowserClient, _daemonServer, daemonRejectionHandlerRegistered, AUTO_DENY_MS, TRUST_DURATIONS, autoStarted, ACTIVITY_SOCKET_PATH, activitySocketPathListeners, ACTIVITY_RING_SIZE, activityRing, LARGE_RESPONSE_RING_SIZE, largeResponseRing, cachedScanResult, cachedScanTs, SCAN_CACHE_TTL_MS, SECRET_KEY_RE, INPUT_PRICE_PER_1M, OUTPUT_PRICE_PER_1M, BYTES_PER_TOKEN, CRITICAL_FORENSIC_CATEGORIES, WRITE_TOOL_NAMES, ACTIVITY_REBIND_MAX_ATTEMPTS, ACTIVITY_REBIND_WINDOW_MS, ACTIVITY_HEALTH_PROBE_MS, activitySocketServer, activityHealthInterval, activityRebindAttempts, activityCircuitTripped;
44863
+ var import_net5, import_fs65, import_path68, import_os55, import_crypto20, homeDir, DAEMON_PID_FILE, DECISIONS_FILE, AUDIT_LOG_FILE, TRUST_FILE2, GLOBAL_CONFIG_FILE, CREDENTIALS_FILE, INSIGHT_COUNTS_FILE, sseClients, cards, suggestionTracker, taintStore, sessionTaintStore, sessionExposureStore, sessionWriteStore, insightCounts, _abandonTimer, _hadBrowserClient, _daemonServer, daemonRejectionHandlerRegistered, daemonSignalHandlersRegistered, AUTO_DENY_MS, TRUST_DURATIONS, autoStarted, ACTIVITY_SOCKET_PATH, activitySocketPathListeners, ACTIVITY_RING_SIZE, activityRing, LARGE_RESPONSE_RING_SIZE, largeResponseRing, cachedScanResult, cachedScanTs, SCAN_CACHE_TTL_MS, SECRET_KEY_RE, INPUT_PRICE_PER_1M, OUTPUT_PRICE_PER_1M, BYTES_PER_TOKEN, CRITICAL_FORENSIC_CATEGORIES, WRITE_TOOL_NAMES, ACTIVITY_REBIND_MAX_ATTEMPTS, ACTIVITY_REBIND_WINDOW_MS, ACTIVITY_HEALTH_PROBE_MS, activitySocketServer, activitySocketIdentity, activityHealthInterval, activityRebindAttempts, activityCircuitTripped;
44835
44864
  var init_state3 = __esm({
44836
44865
  "src/daemon/state.ts"() {
44837
44866
  "use strict";
@@ -44876,6 +44905,7 @@ var init_state3 = __esm({
44876
44905
  _hadBrowserClient = false;
44877
44906
  _daemonServer = null;
44878
44907
  daemonRejectionHandlerRegistered = false;
44908
+ daemonSignalHandlersRegistered = false;
44879
44909
  AUTO_DENY_MS = 12e4;
44880
44910
  TRUST_DURATIONS = {
44881
44911
  "30m": 30 * 6e4,
@@ -44916,6 +44946,7 @@ var init_state3 = __esm({
44916
44946
  ACTIVITY_REBIND_WINDOW_MS = 6e4;
44917
44947
  ACTIVITY_HEALTH_PROBE_MS = 2e3;
44918
44948
  activitySocketServer = null;
44949
+ activitySocketIdentity = null;
44919
44950
  activityHealthInterval = null;
44920
44951
  activityRebindAttempts = [];
44921
44952
  activityCircuitTripped = false;
@@ -48528,6 +48559,12 @@ data: ${JSON.stringify(item.data)}
48528
48559
  console.error(import_chalk8.default.red("[node9 daemon] unhandled rejection \u2014 keeping daemon alive:"), stack);
48529
48560
  });
48530
48561
  }
48562
+ if (!daemonSignalHandlersRegistered) {
48563
+ markSignalHandlersRegistered();
48564
+ process.once("SIGTERM", () => process.exit(0));
48565
+ process.once("SIGINT", () => process.exit(130));
48566
+ process.once("SIGHUP", () => process.exit(129));
48567
+ }
48531
48568
  const writeOwnPidFile = () => atomicWriteSync(
48532
48569
  DAEMON_PID_FILE,
48533
48570
  JSON.stringify({
@@ -48544,6 +48581,7 @@ data: ${JSON.stringify(item.data)}
48544
48581
  { mode: 384 }
48545
48582
  );
48546
48583
  server.listen(DAEMON_PORT, DAEMON_HOST, () => {
48584
+ startActivitySocket();
48547
48585
  writeOwnPidFile();
48548
48586
  onActivitySocketPathChange(() => {
48549
48587
  try {
@@ -48558,7 +48596,6 @@ data: ${JSON.stringify(item.data)}
48558
48596
  if (watchMode) {
48559
48597
  console.error(import_chalk8.default.cyan("\u{1F6F0}\uFE0F Flight Recorder active \u2014 daemon will not idle-timeout"));
48560
48598
  }
48561
- startActivitySocket();
48562
48599
  }
48563
48600
  var import_http4, import_fs72, import_path74, import_os60, import_crypto23, import_child_process5, import_chalk8;
48564
48601
  var init_server = __esm({
@@ -85738,7 +85775,8 @@ function summarize(results, config) {
85738
85775
  if (stopped) c.interrupted++;
85739
85776
  continue;
85740
85777
  }
85741
- if (!stopped && (r.unknown?.length ?? 0) > 0) {
85778
+ const notEnforcedStop = r.enforced === false && (r.decision === "review" || r.decision === "block");
85779
+ if (!stopped && !notEnforcedStop && (r.unknown?.length ?? 0) > 0) {
85742
85780
  c.undetermined++;
85743
85781
  continue;
85744
85782
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node9/proxy",
3
- "version": "2.50.0",
3
+ "version": "2.50.1",
4
4
  "description": "Access control for AI agents. Set what Claude Code, Codex, Gemini, Cursor and any MCP server are allowed to do, review risky actions before they run, and keep every action on the record.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",