@node9/proxy 2.2.0 → 2.2.2

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 (3) hide show
  1. package/dist/cli.js +56 -11
  2. package/dist/cli.mjs +56 -11
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -48029,6 +48029,20 @@ function buildReviewMessage(blockedByLabel, ruleDescription, reason) {
48029
48029
  return `Node9 flagged this for your review: ${why}. Approve to proceed, or deny to cancel.`;
48030
48030
  }
48031
48031
 
48032
+ // src/utils/platform-shell.ts
48033
+ function locatorCommand() {
48034
+ return process.platform === "win32" ? "where" : "which";
48035
+ }
48036
+ function shellInvocation(command) {
48037
+ if (process.platform === "win32") {
48038
+ return {
48039
+ file: process.env.ComSpec || "cmd.exe",
48040
+ args: ["/d", "/s", "/c", command]
48041
+ };
48042
+ }
48043
+ return { file: "/bin/bash", args: ["-c", command] };
48044
+ }
48045
+
48032
48046
  // src/proxy/index.ts
48033
48047
  function sanitize(value) {
48034
48048
  return value.replace(/[\x00-\x1F\x7F]/g, "");
@@ -48040,14 +48054,16 @@ async function runProxy(targetCommand) {
48040
48054
  let executable = cmd;
48041
48055
  let useShell = false;
48042
48056
  try {
48043
- const { stdout } = await (0, import_execa.execa)("which", [cmd]);
48044
- if (stdout) executable = stdout.trim();
48057
+ const { stdout } = await (0, import_execa.execa)(locatorCommand(), [cmd]);
48058
+ const first = stdout.split(/\r?\n/)[0]?.trim();
48059
+ if (first) executable = first;
48045
48060
  } catch {
48046
48061
  useShell = true;
48047
48062
  }
48048
48063
  console.error(import_chalk8.default.green(`\u{1F680} Node9 Proxy Active: Monitoring [${targetCommand}]`));
48049
48064
  const spawnEnv = { ...process.env, FORCE_COLOR: "1" };
48050
- const child = useShell ? (0, import_child_process4.spawn)("/bin/bash", ["-c", targetCommand], {
48065
+ const shell = shellInvocation(targetCommand);
48066
+ const child = useShell ? (0, import_child_process4.spawn)(shell.file, shell.args, {
48051
48067
  stdio: ["pipe", "pipe", "inherit"],
48052
48068
  shell: false,
48053
48069
  env: spawnEnv
@@ -48111,6 +48127,17 @@ async function runProxy(targetCommand) {
48111
48127
  child.stdin.write(line + "\n");
48112
48128
  });
48113
48129
  child.stdout.pipe(process.stdout);
48130
+ child.on("error", (err2) => {
48131
+ const what = useShell ? shell.file : executable;
48132
+ console.error(
48133
+ import_chalk8.default.red(
48134
+ err2.code === "ENOENT" ? `
48135
+ \u274C Node9 could not run "${targetCommand}": ${what} was not found on this machine.` : `
48136
+ \u274C Node9 could not run "${targetCommand}": ${err2.message}`
48137
+ )
48138
+ );
48139
+ process.exit(127);
48140
+ });
48114
48141
  child.on("exit", (code) => process.exit(code || 0));
48115
48142
  }
48116
48143
 
@@ -50210,6 +50237,7 @@ function registerDoctorCommand(program2, version2) {
50210
50237
  program2.command("doctor").description("Check that Node9 is installed and configured correctly").action(async () => {
50211
50238
  const homeDir2 = import_os47.default.homedir();
50212
50239
  let failures = 0;
50240
+ let warnings = 0;
50213
50241
  function pass(msg) {
50214
50242
  console.log(import_chalk13.default.green(" \u2705 ") + msg);
50215
50243
  }
@@ -50221,6 +50249,7 @@ function registerDoctorCommand(program2, version2) {
50221
50249
  function warn(msg, hint) {
50222
50250
  console.log(import_chalk13.default.yellow(" \u26A0\uFE0F ") + msg);
50223
50251
  if (hint) console.log(import_chalk13.default.gray(" " + hint));
50252
+ warnings++;
50224
50253
  }
50225
50254
  function section(title) {
50226
50255
  console.log("\n" + import_chalk13.default.bold(title));
@@ -50230,8 +50259,11 @@ function registerDoctorCommand(program2, version2) {
50230
50259
  `));
50231
50260
  section("Binary");
50232
50261
  try {
50233
- const which = (0, import_child_process8.execSync)("which node9", { encoding: "utf-8", timeout: 3e3 }).trim();
50234
- pass(`node9 found at ${which}`);
50262
+ const found = (0, import_child_process8.execSync)(`${locatorCommand()} node9`, {
50263
+ encoding: "utf-8",
50264
+ timeout: 3e3
50265
+ }).split(/\r?\n/)[0].trim();
50266
+ pass(`node9 found at ${found}`);
50235
50267
  } catch {
50236
50268
  warn("node9 not found in $PATH \u2014 hooks may not find it", "Run: npm install -g node9-ai");
50237
50269
  }
@@ -50311,7 +50343,8 @@ function registerDoctorCommand(program2, version2) {
50311
50343
  )
50312
50344
  );
50313
50345
  }
50314
- section("Daemon (optional)");
50346
+ const cloudOn = import_fs53.default.existsSync(import_path51.default.join(homeDir2, ".node9", "credentials.json")) && !!getConfig().settings.approvers?.cloud;
50347
+ section(cloudOn ? "Daemon" : "Daemon (optional)");
50315
50348
  if (isDaemonRunning()) {
50316
50349
  pass(
50317
50350
  `Daemon running on ${DAEMON_HOST}:${DAEMON_PORT} \u2014 terminal & native approvals enabled`
@@ -50329,7 +50362,7 @@ function registerDoctorCommand(program2, version2) {
50329
50362
  }
50330
50363
  } else {
50331
50364
  warn(
50332
- "Daemon not running \u2014 terminal & native approvals unavailable",
50365
+ cloudOn ? "Daemon not running \u2014 approvals unavailable AND nothing ships to the dashboard until it starts (it auto-starts on agent activity)" : "Daemon not running \u2014 terminal & native approvals unavailable",
50333
50366
  "Run: node9 daemon --background"
50334
50367
  );
50335
50368
  const cause = readStartupCause();
@@ -50379,8 +50412,13 @@ function registerDoctorCommand(program2, version2) {
50379
50412
  } else {
50380
50413
  const lag = shipLagBytes2();
50381
50414
  const wm = readWatermark2(AUDIT_SHIP_WATERMARK2);
50382
- if (lag === 0) {
50415
+ if (lag === 0 && isDaemonRunning()) {
50383
50416
  pass("Audit shipping caught up \u2014 dashboard matches the local log");
50417
+ } else if (lag === 0) {
50418
+ warn(
50419
+ "Nothing queued, but the daemon is not running \u2014 new activity will not reach the dashboard until it starts",
50420
+ "It auto-starts on agent activity, or run: node9 daemon --background"
50421
+ );
50384
50422
  } else if (wm && lag !== null) {
50385
50423
  const ageMin = Math.round((Date.now() - new Date(wm.updatedAt).getTime()) / 6e4);
50386
50424
  if (ageMin > 5 && !isDaemonRunning()) {
@@ -50404,12 +50442,19 @@ function registerDoctorCommand(program2, version2) {
50404
50442
  warn(`Shipping status unavailable: ${err2.message}`);
50405
50443
  }
50406
50444
  console.log("");
50407
- if (failures === 0) {
50408
- console.log(import_chalk13.default.green.bold(" All checks passed. Node9 is ready.\n"));
50409
- } else {
50445
+ if (failures > 0) {
50410
50446
  console.log(import_chalk13.default.red.bold(` ${failures} check(s) failed. See hints above.
50411
50447
  `));
50412
50448
  process.exit(1);
50449
+ } else if (warnings > 0) {
50450
+ console.log(
50451
+ import_chalk13.default.yellow.bold(
50452
+ ` ${warnings} warning(s) \u2014 Node9 is working, but see the hints above.
50453
+ `
50454
+ )
50455
+ );
50456
+ } else {
50457
+ console.log(import_chalk13.default.green.bold(" All checks passed. Node9 is ready.\n"));
50413
50458
  }
50414
50459
  });
50415
50460
  }
package/dist/cli.mjs CHANGED
@@ -48022,6 +48022,20 @@ function buildReviewMessage(blockedByLabel, ruleDescription, reason) {
48022
48022
  return `Node9 flagged this for your review: ${why}. Approve to proceed, or deny to cancel.`;
48023
48023
  }
48024
48024
 
48025
+ // src/utils/platform-shell.ts
48026
+ function locatorCommand() {
48027
+ return process.platform === "win32" ? "where" : "which";
48028
+ }
48029
+ function shellInvocation(command) {
48030
+ if (process.platform === "win32") {
48031
+ return {
48032
+ file: process.env.ComSpec || "cmd.exe",
48033
+ args: ["/d", "/s", "/c", command]
48034
+ };
48035
+ }
48036
+ return { file: "/bin/bash", args: ["-c", command] };
48037
+ }
48038
+
48025
48039
  // src/proxy/index.ts
48026
48040
  function sanitize(value) {
48027
48041
  return value.replace(/[\x00-\x1F\x7F]/g, "");
@@ -48033,14 +48047,16 @@ async function runProxy(targetCommand) {
48033
48047
  let executable = cmd;
48034
48048
  let useShell = false;
48035
48049
  try {
48036
- const { stdout } = await execa("which", [cmd]);
48037
- if (stdout) executable = stdout.trim();
48050
+ const { stdout } = await execa(locatorCommand(), [cmd]);
48051
+ const first = stdout.split(/\r?\n/)[0]?.trim();
48052
+ if (first) executable = first;
48038
48053
  } catch {
48039
48054
  useShell = true;
48040
48055
  }
48041
48056
  console.error(chalk8.green(`\u{1F680} Node9 Proxy Active: Monitoring [${targetCommand}]`));
48042
48057
  const spawnEnv = { ...process.env, FORCE_COLOR: "1" };
48043
- const child = useShell ? spawn2("/bin/bash", ["-c", targetCommand], {
48058
+ const shell = shellInvocation(targetCommand);
48059
+ const child = useShell ? spawn2(shell.file, shell.args, {
48044
48060
  stdio: ["pipe", "pipe", "inherit"],
48045
48061
  shell: false,
48046
48062
  env: spawnEnv
@@ -48104,6 +48120,17 @@ async function runProxy(targetCommand) {
48104
48120
  child.stdin.write(line + "\n");
48105
48121
  });
48106
48122
  child.stdout.pipe(process.stdout);
48123
+ child.on("error", (err2) => {
48124
+ const what = useShell ? shell.file : executable;
48125
+ console.error(
48126
+ chalk8.red(
48127
+ err2.code === "ENOENT" ? `
48128
+ \u274C Node9 could not run "${targetCommand}": ${what} was not found on this machine.` : `
48129
+ \u274C Node9 could not run "${targetCommand}": ${err2.message}`
48130
+ )
48131
+ );
48132
+ process.exit(127);
48133
+ });
48107
48134
  child.on("exit", (code) => process.exit(code || 0));
48108
48135
  }
48109
48136
 
@@ -50203,6 +50230,7 @@ function registerDoctorCommand(program2, version2) {
50203
50230
  program2.command("doctor").description("Check that Node9 is installed and configured correctly").action(async () => {
50204
50231
  const homeDir2 = os50.homedir();
50205
50232
  let failures = 0;
50233
+ let warnings = 0;
50206
50234
  function pass(msg) {
50207
50235
  console.log(chalk13.green(" \u2705 ") + msg);
50208
50236
  }
@@ -50214,6 +50242,7 @@ function registerDoctorCommand(program2, version2) {
50214
50242
  function warn(msg, hint) {
50215
50243
  console.log(chalk13.yellow(" \u26A0\uFE0F ") + msg);
50216
50244
  if (hint) console.log(chalk13.gray(" " + hint));
50245
+ warnings++;
50217
50246
  }
50218
50247
  function section(title) {
50219
50248
  console.log("\n" + chalk13.bold(title));
@@ -50223,8 +50252,11 @@ function registerDoctorCommand(program2, version2) {
50223
50252
  `));
50224
50253
  section("Binary");
50225
50254
  try {
50226
- const which = execSync("which node9", { encoding: "utf-8", timeout: 3e3 }).trim();
50227
- pass(`node9 found at ${which}`);
50255
+ const found = execSync(`${locatorCommand()} node9`, {
50256
+ encoding: "utf-8",
50257
+ timeout: 3e3
50258
+ }).split(/\r?\n/)[0].trim();
50259
+ pass(`node9 found at ${found}`);
50228
50260
  } catch {
50229
50261
  warn("node9 not found in $PATH \u2014 hooks may not find it", "Run: npm install -g node9-ai");
50230
50262
  }
@@ -50304,7 +50336,8 @@ function registerDoctorCommand(program2, version2) {
50304
50336
  )
50305
50337
  );
50306
50338
  }
50307
- section("Daemon (optional)");
50339
+ const cloudOn = fs55.existsSync(path53.join(homeDir2, ".node9", "credentials.json")) && !!getConfig().settings.approvers?.cloud;
50340
+ section(cloudOn ? "Daemon" : "Daemon (optional)");
50308
50341
  if (isDaemonRunning()) {
50309
50342
  pass(
50310
50343
  `Daemon running on ${DAEMON_HOST}:${DAEMON_PORT} \u2014 terminal & native approvals enabled`
@@ -50322,7 +50355,7 @@ function registerDoctorCommand(program2, version2) {
50322
50355
  }
50323
50356
  } else {
50324
50357
  warn(
50325
- "Daemon not running \u2014 terminal & native approvals unavailable",
50358
+ cloudOn ? "Daemon not running \u2014 approvals unavailable AND nothing ships to the dashboard until it starts (it auto-starts on agent activity)" : "Daemon not running \u2014 terminal & native approvals unavailable",
50326
50359
  "Run: node9 daemon --background"
50327
50360
  );
50328
50361
  const cause = readStartupCause();
@@ -50372,8 +50405,13 @@ function registerDoctorCommand(program2, version2) {
50372
50405
  } else {
50373
50406
  const lag = shipLagBytes2();
50374
50407
  const wm = readWatermark2(AUDIT_SHIP_WATERMARK2);
50375
- if (lag === 0) {
50408
+ if (lag === 0 && isDaemonRunning()) {
50376
50409
  pass("Audit shipping caught up \u2014 dashboard matches the local log");
50410
+ } else if (lag === 0) {
50411
+ warn(
50412
+ "Nothing queued, but the daemon is not running \u2014 new activity will not reach the dashboard until it starts",
50413
+ "It auto-starts on agent activity, or run: node9 daemon --background"
50414
+ );
50377
50415
  } else if (wm && lag !== null) {
50378
50416
  const ageMin = Math.round((Date.now() - new Date(wm.updatedAt).getTime()) / 6e4);
50379
50417
  if (ageMin > 5 && !isDaemonRunning()) {
@@ -50397,12 +50435,19 @@ function registerDoctorCommand(program2, version2) {
50397
50435
  warn(`Shipping status unavailable: ${err2.message}`);
50398
50436
  }
50399
50437
  console.log("");
50400
- if (failures === 0) {
50401
- console.log(chalk13.green.bold(" All checks passed. Node9 is ready.\n"));
50402
- } else {
50438
+ if (failures > 0) {
50403
50439
  console.log(chalk13.red.bold(` ${failures} check(s) failed. See hints above.
50404
50440
  `));
50405
50441
  process.exit(1);
50442
+ } else if (warnings > 0) {
50443
+ console.log(
50444
+ chalk13.yellow.bold(
50445
+ ` ${warnings} warning(s) \u2014 Node9 is working, but see the hints above.
50446
+ `
50447
+ )
50448
+ );
50449
+ } else {
50450
+ console.log(chalk13.green.bold(" All checks passed. Node9 is ready.\n"));
50406
50451
  }
50407
50452
  });
50408
50453
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node9/proxy",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "description": "The Sudo Command for AI Agents. Execution Security for Claude Code, Codex, Gemini, Cursor, Opencode, Pi, and any MCP server.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",