@mrrlin-dev/mcp 0.4.274 → 0.4.275

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/bin.cjs +41 -3
  2. package/package.json +1 -1
package/dist/bin.cjs CHANGED
@@ -107007,7 +107007,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
107007
107007
  }
107008
107008
 
107009
107009
  // src/_generated/version.ts
107010
- var PKG_VERSION = "0.4.274";
107010
+ var PKG_VERSION = "0.4.275";
107011
107011
 
107012
107012
  // src/bridge-allowed-origins.ts
107013
107013
  var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
@@ -132311,6 +132311,22 @@ Missing required flag(s): ${missing.join(
132311
132311
  }
132312
132312
 
132313
132313
  // src/restart-service.ts
132314
+ function parsePsLine(line) {
132315
+ const match2 = /^\s*(\d+)\s+(.*)$/.exec(line);
132316
+ if (!match2) return null;
132317
+ return { ppid: Number(match2[1]), isBridge: (match2[2] ?? "").trim().split(/\s+/).includes("director-bridge") };
132318
+ }
132319
+ function findBridgeAncestor(startPid, readPs, maxHops = 16) {
132320
+ let pid = startPid;
132321
+ for (let hop = 0; hop < maxHops && Number.isInteger(pid) && pid > 1; hop += 1) {
132322
+ const line = readPs(pid);
132323
+ const parsed = line === null ? null : parsePsLine(line);
132324
+ if (!parsed) return null;
132325
+ if (parsed.isBridge) return pid;
132326
+ pid = parsed.ppid;
132327
+ }
132328
+ return null;
132329
+ }
132314
132330
  var PREFIX2 = "[mrrlin-mcp restart-service]";
132315
132331
  function isOnlineBridge(entry) {
132316
132332
  if (!entry || typeof entry !== "object") return false;
@@ -132329,7 +132345,16 @@ function runRestartService(deps) {
132329
132345
  const done = (exitCode, outcome) => ({ exitCode, outcome });
132330
132346
  print(`${PREFIX2} installed version on disk: ${installedVersion}`);
132331
132347
  const jlist = deps.runPm2Jlist();
132348
+ const askAncestor = (why) => {
132349
+ if (deps.platform === "win32" || !deps.findAncestorBridge) return null;
132350
+ const pid = deps.findAncestorBridge();
132351
+ if (pid === null || !Number.isInteger(pid) || pid <= 1) return null;
132352
+ print(`${PREFIX2} ${why}, but this command runs inside the bridge (pid ${pid}), so that one is asked directly.`);
132353
+ return signalBridges(deps, [{ pid }], false, manual);
132354
+ };
132332
132355
  if (jlist.status !== 0) {
132356
+ const viaAncestor = askAncestor("pm2's process list could not be read from here");
132357
+ if (viaAncestor) return viaAncestor;
132333
132358
  if (jlist.errorCode === "ENOENT") {
132334
132359
  print(`${PREFIX2} pm2 is not installed here, so the bridge was NOT asked to reload. If you run the bridge some other way, restart it there.`);
132335
132360
  return done(1, "no_pm2");
@@ -132347,6 +132372,8 @@ function runRestartService(deps) {
132347
132372
  }
132348
132373
  const bridges = entries.filter(isOnlineBridge).filter((e) => typeof e.pid === "number" && Number.isInteger(e.pid) && e.pid > 0);
132349
132374
  if (bridges.length === 0) {
132375
+ const viaAncestor = askAncestor("pm2 listed no running mrrlin-bridge from here");
132376
+ if (viaAncestor) return viaAncestor;
132350
132377
  print(`${PREFIX2} no running mrrlin-bridge found under pm2. Start it with: mrrlin-mcp install-service`);
132351
132378
  return done(1, "no_bridge");
132352
132379
  }
@@ -132366,6 +132393,11 @@ function runRestartService(deps) {
132366
132393
  );
132367
132394
  if (sameCopy.length === 0) return done(1, "different_install");
132368
132395
  }
132396
+ return signalBridges(deps, sameCopy, elsewhere.length > 0, manual);
132397
+ }
132398
+ function signalBridges(deps, sameCopy, someElsewhere, manual) {
132399
+ const { print, installedVersion } = deps;
132400
+ const done = (exitCode, outcome) => ({ exitCode, outcome });
132369
132401
  if (deps.platform === "win32") {
132370
132402
  print(
132371
132403
  `${PREFIX2} Windows cannot send the reload signal, so the bridge was NOT asked to reload. The running bridge (pid ${sameCopy.map((b) => b.pid).join(", ")}) is still the old version and may not notice the new one by itself. To switch to the new version, ${manual}.`
@@ -132391,7 +132423,7 @@ function runRestartService(deps) {
132391
132423
  `${PREFIX2} asked the running bridge (pid ${signalled.join(", ")}) to reload onto ${installedVersion}. It has NOT restarted yet. If the copy on disk differs from the one it is running, it first lets any reply or task that is running finish, then restarts by itself; if it already runs this version, nothing changes. Anything said in the meantime is still handled by the running version.`
132392
132424
  );
132393
132425
  if (failed.length > 0) print(`${PREFIX2} could not signal: ${failed.join("; ")}`);
132394
- if (elsewhere.length > 0 || failed.length > 0) return done(0, "partial");
132426
+ if (someElsewhere || failed.length > 0) return done(0, "partial");
132395
132427
  return done(0, "signalled");
132396
132428
  }
132397
132429
 
@@ -133025,7 +133057,13 @@ async function main() {
133025
133057
  }
133026
133058
  },
133027
133059
  print: (line) => process.stdout.write(`${line}
133028
- `)
133060
+ `),
133061
+ // When pm2's list shows no bridge (an agent shell that cannot reach pm2), the bridge this command
133062
+ // runs inside is found by walking up its parents with `ps`.
133063
+ findAncestorBridge: () => findBridgeAncestor(process.ppid, (pid) => {
133064
+ const r = spawnSyncCommand("ps", ["-o", "ppid=,args=", "-p", String(pid)], { encoding: "utf8", timeout: 3e3 });
133065
+ return r.status === 0 && typeof r.stdout === "string" && r.stdout.trim() ? r.stdout.trim().split("\n")[0] ?? null : null;
133066
+ })
133029
133067
  }).exitCode;
133030
133068
  return;
133031
133069
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrrlin-dev/mcp",
3
- "version": "0.4.274",
3
+ "version": "0.4.275",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mrrlin-mcp": "dist/bin.cjs"