@node9/proxy 1.1.3 → 1.1.4

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 +42 -20
  2. package/dist/cli.mjs +42 -20
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -4515,9 +4515,15 @@ data: ${JSON.stringify(item.data)}
4515
4515
  }
4516
4516
  }
4517
4517
  if (req.method === "GET" && pathname === "/settings") {
4518
- const s = getGlobalSettings();
4519
- res.writeHead(200, { "Content-Type": "application/json" });
4520
- return res.end(JSON.stringify({ ...s, autoStarted }));
4518
+ try {
4519
+ const s = getGlobalSettings();
4520
+ res.writeHead(200, { "Content-Type": "application/json" });
4521
+ return res.end(JSON.stringify({ ...s, autoStarted }));
4522
+ } catch (err) {
4523
+ console.error(import_chalk4.default.red("[node9 daemon] GET /settings failed:"), err);
4524
+ res.writeHead(500, { "Content-Type": "application/json" });
4525
+ return res.end(JSON.stringify({ error: "internal" }));
4526
+ }
4521
4527
  }
4522
4528
  if (req.method === "POST" && pathname === "/settings") {
4523
4529
  if (!validToken(req)) return res.writeHead(403).end();
@@ -4540,9 +4546,15 @@ data: ${JSON.stringify(item.data)}
4540
4546
  }
4541
4547
  }
4542
4548
  if (req.method === "GET" && pathname === "/slack-status") {
4543
- const s = getGlobalSettings();
4544
- res.writeHead(200, { "Content-Type": "application/json" });
4545
- return res.end(JSON.stringify({ hasKey: hasStoredSlackKey(), enabled: s.slackEnabled }));
4549
+ try {
4550
+ const s = getGlobalSettings();
4551
+ res.writeHead(200, { "Content-Type": "application/json" });
4552
+ return res.end(JSON.stringify({ hasKey: hasStoredSlackKey(), enabled: s.slackEnabled }));
4553
+ } catch (err) {
4554
+ console.error(import_chalk4.default.red("[node9 daemon] GET /slack-status failed:"), err);
4555
+ res.writeHead(500, { "Content-Type": "application/json" });
4556
+ return res.end(JSON.stringify({ error: "internal" }));
4557
+ }
4546
4558
  }
4547
4559
  if (req.method === "POST" && pathname === "/slack-key") {
4548
4560
  if (!validToken(req)) return res.writeHead(403).end();
@@ -4691,6 +4703,13 @@ data: ${JSON.stringify(item.data)}
4691
4703
  console.error(import_chalk4.default.red("\n\u{1F6D1} Node9 Daemon Error:"), e.message);
4692
4704
  process.exit(1);
4693
4705
  });
4706
+ if (!daemonRejectionHandlerRegistered) {
4707
+ daemonRejectionHandlerRegistered = true;
4708
+ process.on("unhandledRejection", (reason) => {
4709
+ const stack = reason instanceof Error ? reason.stack : String(reason);
4710
+ console.error(import_chalk4.default.red("[node9 daemon] unhandled rejection \u2014 keeping daemon alive:"), stack);
4711
+ });
4712
+ }
4694
4713
  server.listen(DAEMON_PORT2, DAEMON_HOST2, () => {
4695
4714
  atomicWriteSync2(
4696
4715
  DAEMON_PID_FILE,
@@ -4787,7 +4806,7 @@ function daemonStatus() {
4787
4806
  console.log(import_chalk4.default.yellow("Node9 daemon: not running"));
4788
4807
  }
4789
4808
  }
4790
- var import_http, import_net2, import_fs5, import_path7, import_os4, import_child_process3, import_crypto3, import_chalk4, ACTIVITY_SOCKET_PATH2, DAEMON_PORT2, DAEMON_HOST2, homeDir, DAEMON_PID_FILE, DECISIONS_FILE, GLOBAL_CONFIG_FILE, CREDENTIALS_FILE, AUDIT_LOG_FILE, TRUST_FILE2, TRUST_DURATIONS, SECRET_KEY_RE, AUTO_DENY_MS, autoStarted, pending, sseClients, abandonTimer, daemonServer, hadBrowserClient, ACTIVITY_RING_SIZE, activityRing;
4809
+ var import_http, import_net2, import_fs5, import_path7, import_os4, import_child_process3, import_crypto3, import_chalk4, daemonRejectionHandlerRegistered, ACTIVITY_SOCKET_PATH2, DAEMON_PORT2, DAEMON_HOST2, homeDir, DAEMON_PID_FILE, DECISIONS_FILE, GLOBAL_CONFIG_FILE, CREDENTIALS_FILE, AUDIT_LOG_FILE, TRUST_FILE2, TRUST_DURATIONS, SECRET_KEY_RE, AUTO_DENY_MS, autoStarted, pending, sseClients, abandonTimer, daemonServer, hadBrowserClient, ACTIVITY_RING_SIZE, activityRing;
4791
4810
  var init_daemon = __esm({
4792
4811
  "src/daemon/index.ts"() {
4793
4812
  "use strict";
@@ -4802,6 +4821,7 @@ var init_daemon = __esm({
4802
4821
  import_chalk4 = __toESM(require("chalk"));
4803
4822
  init_core();
4804
4823
  init_shields();
4824
+ daemonRejectionHandlerRegistered = false;
4805
4825
  ACTIVITY_SOCKET_PATH2 = process.platform === "win32" ? "\\\\.\\pipe\\node9-activity" : import_path7.default.join(import_os4.default.tmpdir(), "node9-activity.sock");
4806
4826
  DAEMON_PORT2 = 7391;
4807
4827
  DAEMON_HOST2 = "127.0.0.1";
@@ -6924,21 +6944,23 @@ shieldCmd.command("status").description("Show which shields are currently active
6924
6944
  }
6925
6945
  console.log("");
6926
6946
  });
6927
- process.on("unhandledRejection", (reason) => {
6928
- const isCheckHook = process.argv[2] === "check";
6929
- if (isCheckHook) {
6930
- if (process.env.NODE9_DEBUG === "1" || getConfig().settings.enableHookLogDebug) {
6931
- const logPath = import_path10.default.join(import_os7.default.homedir(), ".node9", "hook-debug.log");
6932
- const msg = reason instanceof Error ? reason.message : String(reason);
6933
- import_fs8.default.appendFileSync(logPath, `[${(/* @__PURE__ */ new Date()).toISOString()}] UNHANDLED: ${msg}
6947
+ if (process.argv[2] !== "daemon") {
6948
+ process.on("unhandledRejection", (reason) => {
6949
+ const isCheckHook = process.argv[2] === "check";
6950
+ if (isCheckHook) {
6951
+ if (process.env.NODE9_DEBUG === "1" || getConfig().settings.enableHookLogDebug) {
6952
+ const logPath = import_path10.default.join(import_os7.default.homedir(), ".node9", "hook-debug.log");
6953
+ const msg = reason instanceof Error ? reason.message : String(reason);
6954
+ import_fs8.default.appendFileSync(logPath, `[${(/* @__PURE__ */ new Date()).toISOString()}] UNHANDLED: ${msg}
6934
6955
  `);
6956
+ }
6957
+ process.exit(0);
6958
+ } else {
6959
+ console.error("[Node9] Unhandled error:", reason);
6960
+ process.exit(1);
6935
6961
  }
6936
- process.exit(0);
6937
- } else {
6938
- console.error("[Node9] Unhandled error:", reason);
6939
- process.exit(1);
6940
- }
6941
- });
6962
+ });
6963
+ }
6942
6964
  var knownSubcommands = new Set(program.commands.map((c) => c.name()));
6943
6965
  var firstArg = process.argv[2];
6944
6966
  if (firstArg && firstArg !== "--" && !firstArg.startsWith("-") && !knownSubcommands.has(firstArg)) {
package/dist/cli.mjs CHANGED
@@ -4502,9 +4502,15 @@ data: ${JSON.stringify(item.data)}
4502
4502
  }
4503
4503
  }
4504
4504
  if (req.method === "GET" && pathname === "/settings") {
4505
- const s = getGlobalSettings();
4506
- res.writeHead(200, { "Content-Type": "application/json" });
4507
- return res.end(JSON.stringify({ ...s, autoStarted }));
4505
+ try {
4506
+ const s = getGlobalSettings();
4507
+ res.writeHead(200, { "Content-Type": "application/json" });
4508
+ return res.end(JSON.stringify({ ...s, autoStarted }));
4509
+ } catch (err) {
4510
+ console.error(chalk4.red("[node9 daemon] GET /settings failed:"), err);
4511
+ res.writeHead(500, { "Content-Type": "application/json" });
4512
+ return res.end(JSON.stringify({ error: "internal" }));
4513
+ }
4508
4514
  }
4509
4515
  if (req.method === "POST" && pathname === "/settings") {
4510
4516
  if (!validToken(req)) return res.writeHead(403).end();
@@ -4527,9 +4533,15 @@ data: ${JSON.stringify(item.data)}
4527
4533
  }
4528
4534
  }
4529
4535
  if (req.method === "GET" && pathname === "/slack-status") {
4530
- const s = getGlobalSettings();
4531
- res.writeHead(200, { "Content-Type": "application/json" });
4532
- return res.end(JSON.stringify({ hasKey: hasStoredSlackKey(), enabled: s.slackEnabled }));
4536
+ try {
4537
+ const s = getGlobalSettings();
4538
+ res.writeHead(200, { "Content-Type": "application/json" });
4539
+ return res.end(JSON.stringify({ hasKey: hasStoredSlackKey(), enabled: s.slackEnabled }));
4540
+ } catch (err) {
4541
+ console.error(chalk4.red("[node9 daemon] GET /slack-status failed:"), err);
4542
+ res.writeHead(500, { "Content-Type": "application/json" });
4543
+ return res.end(JSON.stringify({ error: "internal" }));
4544
+ }
4533
4545
  }
4534
4546
  if (req.method === "POST" && pathname === "/slack-key") {
4535
4547
  if (!validToken(req)) return res.writeHead(403).end();
@@ -4678,6 +4690,13 @@ data: ${JSON.stringify(item.data)}
4678
4690
  console.error(chalk4.red("\n\u{1F6D1} Node9 Daemon Error:"), e.message);
4679
4691
  process.exit(1);
4680
4692
  });
4693
+ if (!daemonRejectionHandlerRegistered) {
4694
+ daemonRejectionHandlerRegistered = true;
4695
+ process.on("unhandledRejection", (reason) => {
4696
+ const stack = reason instanceof Error ? reason.stack : String(reason);
4697
+ console.error(chalk4.red("[node9 daemon] unhandled rejection \u2014 keeping daemon alive:"), stack);
4698
+ });
4699
+ }
4681
4700
  server.listen(DAEMON_PORT2, DAEMON_HOST2, () => {
4682
4701
  atomicWriteSync2(
4683
4702
  DAEMON_PID_FILE,
@@ -4774,13 +4793,14 @@ function daemonStatus() {
4774
4793
  console.log(chalk4.yellow("Node9 daemon: not running"));
4775
4794
  }
4776
4795
  }
4777
- var ACTIVITY_SOCKET_PATH2, DAEMON_PORT2, DAEMON_HOST2, homeDir, DAEMON_PID_FILE, DECISIONS_FILE, GLOBAL_CONFIG_FILE, CREDENTIALS_FILE, AUDIT_LOG_FILE, TRUST_FILE2, TRUST_DURATIONS, SECRET_KEY_RE, AUTO_DENY_MS, autoStarted, pending, sseClients, abandonTimer, daemonServer, hadBrowserClient, ACTIVITY_RING_SIZE, activityRing;
4796
+ var daemonRejectionHandlerRegistered, ACTIVITY_SOCKET_PATH2, DAEMON_PORT2, DAEMON_HOST2, homeDir, DAEMON_PID_FILE, DECISIONS_FILE, GLOBAL_CONFIG_FILE, CREDENTIALS_FILE, AUDIT_LOG_FILE, TRUST_FILE2, TRUST_DURATIONS, SECRET_KEY_RE, AUTO_DENY_MS, autoStarted, pending, sseClients, abandonTimer, daemonServer, hadBrowserClient, ACTIVITY_RING_SIZE, activityRing;
4778
4797
  var init_daemon = __esm({
4779
4798
  "src/daemon/index.ts"() {
4780
4799
  "use strict";
4781
4800
  init_ui2();
4782
4801
  init_core();
4783
4802
  init_shields();
4803
+ daemonRejectionHandlerRegistered = false;
4784
4804
  ACTIVITY_SOCKET_PATH2 = process.platform === "win32" ? "\\\\.\\pipe\\node9-activity" : path7.join(os4.tmpdir(), "node9-activity.sock");
4785
4805
  DAEMON_PORT2 = 7391;
4786
4806
  DAEMON_HOST2 = "127.0.0.1";
@@ -6903,21 +6923,23 @@ shieldCmd.command("status").description("Show which shields are currently active
6903
6923
  }
6904
6924
  console.log("");
6905
6925
  });
6906
- process.on("unhandledRejection", (reason) => {
6907
- const isCheckHook = process.argv[2] === "check";
6908
- if (isCheckHook) {
6909
- if (process.env.NODE9_DEBUG === "1" || getConfig().settings.enableHookLogDebug) {
6910
- const logPath = path10.join(os7.homedir(), ".node9", "hook-debug.log");
6911
- const msg = reason instanceof Error ? reason.message : String(reason);
6912
- fs8.appendFileSync(logPath, `[${(/* @__PURE__ */ new Date()).toISOString()}] UNHANDLED: ${msg}
6926
+ if (process.argv[2] !== "daemon") {
6927
+ process.on("unhandledRejection", (reason) => {
6928
+ const isCheckHook = process.argv[2] === "check";
6929
+ if (isCheckHook) {
6930
+ if (process.env.NODE9_DEBUG === "1" || getConfig().settings.enableHookLogDebug) {
6931
+ const logPath = path10.join(os7.homedir(), ".node9", "hook-debug.log");
6932
+ const msg = reason instanceof Error ? reason.message : String(reason);
6933
+ fs8.appendFileSync(logPath, `[${(/* @__PURE__ */ new Date()).toISOString()}] UNHANDLED: ${msg}
6913
6934
  `);
6935
+ }
6936
+ process.exit(0);
6937
+ } else {
6938
+ console.error("[Node9] Unhandled error:", reason);
6939
+ process.exit(1);
6914
6940
  }
6915
- process.exit(0);
6916
- } else {
6917
- console.error("[Node9] Unhandled error:", reason);
6918
- process.exit(1);
6919
- }
6920
- });
6941
+ });
6942
+ }
6921
6943
  var knownSubcommands = new Set(program.commands.map((c) => c.name()));
6922
6944
  var firstArg = process.argv[2];
6923
6945
  if (firstArg && firstArg !== "--" && !firstArg.startsWith("-") && !knownSubcommands.has(firstArg)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node9/proxy",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
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",