mobbdev 1.0.179 → 1.0.180

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/index.mjs +99 -5
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -13206,7 +13206,7 @@ var McpGQLClient = class {
13206
13206
  }
13207
13207
  };
13208
13208
  async function createAuthenticatedMcpGQLClient({
13209
- isBackgoundCall = false
13209
+ isBackgroundCall = false
13210
13210
  } = {}) {
13211
13211
  logDebug("[GraphQL] Getting config", {
13212
13212
  apiToken: configStore.get("apiToken")
@@ -13227,7 +13227,7 @@ async function createAuthenticatedMcpGQLClient({
13227
13227
  return initialClient;
13228
13228
  }
13229
13229
  const authService = new McpAuthService(initialClient);
13230
- const newApiToken = await authService.authenticate(isBackgoundCall);
13230
+ const newApiToken = await authService.authenticate(isBackgroundCall);
13231
13231
  configStore.set("apiToken", newApiToken);
13232
13232
  return new McpGQLClient({ apiKey: newApiToken, type: "apiKey" });
13233
13233
  }
@@ -13644,6 +13644,9 @@ var McpServer = class {
13644
13644
  __publicField(this, "toolRegistry");
13645
13645
  __publicField(this, "isEventHandlersSetup", false);
13646
13646
  __publicField(this, "eventHandlers", /* @__PURE__ */ new Map());
13647
+ __publicField(this, "parentProcessCheckInterval");
13648
+ __publicField(this, "parentPid");
13649
+ this.parentPid = process.ppid;
13647
13650
  this.server = new Server(
13648
13651
  {
13649
13652
  name: config4.name,
@@ -13658,8 +13661,12 @@ var McpServer = class {
13658
13661
  this.toolRegistry = new ToolRegistry();
13659
13662
  this.setupHandlers();
13660
13663
  this.setupProcessEventHandlers();
13664
+ this.setupParentProcessMonitoring();
13661
13665
  logInfo("MCP server instance created");
13662
- logDebug("MCP server instance config", { config: config4 });
13666
+ logDebug("MCP server instance config", {
13667
+ config: config4,
13668
+ parentPid: this.parentPid
13669
+ });
13663
13670
  }
13664
13671
  async trackServerUsage(action, signalOrError) {
13665
13672
  try {
@@ -13684,6 +13691,12 @@ var McpServer = class {
13684
13691
  const messages = {
13685
13692
  SIGINT: "MCP server interrupted",
13686
13693
  SIGTERM: "MCP server terminated",
13694
+ SIGHUP: "MCP server hangup signal received",
13695
+ SIGQUIT: "MCP server quit signal received",
13696
+ SIGABRT: "MCP server abort signal received",
13697
+ SIGPIPE: "MCP server broken pipe signal received",
13698
+ SIGCHLD: "MCP server child process signal received",
13699
+ SIGTSTP: "MCP server terminal stop signal received",
13687
13700
  exit: "MCP server exiting",
13688
13701
  uncaughtException: "Uncaught exception in MCP server",
13689
13702
  unhandledRejection: "Unhandled promise rejection in MCP server",
@@ -13714,7 +13727,10 @@ var McpServer = class {
13714
13727
  } else {
13715
13728
  logDebug(message, { signal });
13716
13729
  }
13717
- if (signal === "SIGINT" || signal === "SIGTERM") {
13730
+ if (signal === "SIGCHLD") {
13731
+ return;
13732
+ }
13733
+ if (signal === "SIGINT" || signal === "SIGTERM" || signal === "SIGHUP" || signal === "SIGQUIT" || signal === "SIGABRT" || signal === "SIGPIPE" || signal === "SIGTSTP") {
13718
13734
  await this.trackServerUsage("stop", signal);
13719
13735
  process.exit(0);
13720
13736
  }
@@ -13723,6 +13739,62 @@ var McpServer = class {
13723
13739
  process.exit(1);
13724
13740
  }
13725
13741
  }
13742
+ isParentProcessAlive() {
13743
+ try {
13744
+ process.kill(this.parentPid, 0);
13745
+ return true;
13746
+ } catch (error) {
13747
+ return false;
13748
+ }
13749
+ }
13750
+ async handleParentProcessDeath(source) {
13751
+ logInfo(`Parent process death detected via ${source}`, {
13752
+ parentPid: this.parentPid
13753
+ });
13754
+ await this.trackServerUsage("stop", `parent-death-${source}`);
13755
+ process.exit(0);
13756
+ }
13757
+ setupParentProcessMonitoring() {
13758
+ logInfo("Setting up parent process monitoring", {
13759
+ parentPid: this.parentPid
13760
+ });
13761
+ process.stdin.on("close", async () => {
13762
+ logDebug("stdin closed - parent likely terminated");
13763
+ await this.handleParentProcessDeath("stdin-close");
13764
+ });
13765
+ process.stdin.on("end", async () => {
13766
+ logDebug("stdin ended - parent likely terminated");
13767
+ await this.handleParentProcessDeath("stdin-end");
13768
+ });
13769
+ process.stdout.on("error", async (error) => {
13770
+ logWarn("stdout error - parent may have terminated", { error });
13771
+ if (error.message.includes("EPIPE") || error.message.includes("ECONNRESET")) {
13772
+ await this.handleParentProcessDeath("stdout-error");
13773
+ }
13774
+ });
13775
+ process.stderr.on("error", async (error) => {
13776
+ logWarn("stderr error - parent may have terminated", { error });
13777
+ if (error.message.includes("EPIPE") || error.message.includes("ECONNRESET")) {
13778
+ await this.handleParentProcessDeath("stderr-error");
13779
+ }
13780
+ });
13781
+ if (process.send) {
13782
+ process.on("disconnect", async () => {
13783
+ logDebug("IPC disconnected - parent terminated");
13784
+ await this.handleParentProcessDeath("ipc-disconnect");
13785
+ });
13786
+ logDebug("IPC monitoring enabled");
13787
+ } else {
13788
+ logDebug("IPC not available - skipping IPC monitoring");
13789
+ }
13790
+ this.parentProcessCheckInterval = setInterval(async () => {
13791
+ if (!this.isParentProcessAlive()) {
13792
+ logDebug("Parent process not alive during periodic check");
13793
+ await this.handleParentProcessDeath("periodic-check");
13794
+ }
13795
+ }, 1e4);
13796
+ logInfo("Parent process monitoring setup complete");
13797
+ }
13726
13798
  setupProcessEventHandlers() {
13727
13799
  if (this.isEventHandlersSetup) {
13728
13800
  logDebug("Process event handlers already setup, skipping");
@@ -13731,6 +13803,12 @@ var McpServer = class {
13731
13803
  const signals = [
13732
13804
  "SIGINT",
13733
13805
  "SIGTERM",
13806
+ "SIGHUP",
13807
+ "SIGQUIT",
13808
+ "SIGABRT",
13809
+ "SIGPIPE",
13810
+ "SIGCHLD",
13811
+ "SIGTSTP",
13734
13812
  "exit",
13735
13813
  "uncaughtException",
13736
13814
  "unhandledRejection",
@@ -13754,12 +13832,17 @@ var McpServer = class {
13754
13832
  };
13755
13833
  process.once("SIGINT", cleanup);
13756
13834
  process.once("SIGTERM", cleanup);
13835
+ process.once("SIGHUP", cleanup);
13836
+ process.once("SIGQUIT", cleanup);
13837
+ process.once("SIGABRT", cleanup);
13838
+ process.once("SIGPIPE", cleanup);
13839
+ process.once("SIGTSTP", cleanup);
13757
13840
  });
13758
13841
  }
13759
13842
  async triggerScanForNewAvailableFixes() {
13760
13843
  try {
13761
13844
  const gqlClient = await createAuthenticatedMcpGQLClient({
13762
- isBackgoundCall: true
13845
+ isBackgroundCall: true
13763
13846
  });
13764
13847
  const isConnected = await gqlClient.verifyApiConnection();
13765
13848
  if (!isConnected) {
@@ -13884,6 +13967,12 @@ var McpServer = class {
13884
13967
  this.toolRegistry.registerTool(tool);
13885
13968
  logInfo(`Tool registered: ${tool.name}`);
13886
13969
  }
13970
+ getParentProcessId() {
13971
+ return this.parentPid;
13972
+ }
13973
+ checkParentProcessAlive() {
13974
+ return this.isParentProcessAlive();
13975
+ }
13887
13976
  async start() {
13888
13977
  try {
13889
13978
  logInfo("Starting MCP server");
@@ -13902,6 +13991,11 @@ var McpServer = class {
13902
13991
  async stop() {
13903
13992
  logDebug("MCP server shutting down");
13904
13993
  await this.trackServerUsage("stop");
13994
+ if (this.parentProcessCheckInterval) {
13995
+ clearInterval(this.parentProcessCheckInterval);
13996
+ this.parentProcessCheckInterval = void 0;
13997
+ logDebug("Parent process check interval cleared");
13998
+ }
13905
13999
  this.eventHandlers.forEach((handler, signal) => {
13906
14000
  process.removeListener(signal, handler);
13907
14001
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "1.0.179",
3
+ "version": "1.0.180",
4
4
  "description": "Automated secure code remediation tool",
5
5
  "repository": "git+https://github.com/mobb-dev/bugsy.git",
6
6
  "main": "dist/index.mjs",