@xelexis/x-broker 0.15.0 → 0.17.0

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.
package/README.md CHANGED
@@ -7,7 +7,7 @@ Requires Node.js 18 or later and npm. Supports Windows x64, macOS ARM64/x64 and
7
7
  ## Prepare
8
8
 
9
9
  ```sh
10
- npx -y @xelexis/x-broker@0.15.0 --version
10
+ npx -y @xelexis/x-broker@0.17.0 --version
11
11
  ```
12
12
 
13
13
  Pin a published npm version. The server and client versions can differ.
@@ -23,7 +23,7 @@ Use `npx` on every supported OS, including Windows. Replace the broker URL, proj
23
23
  "mcpServers": {
24
24
  "x-broker": {
25
25
  "command": "npx",
26
- "args": ["-y", "@xelexis/x-broker@0.15.0", "--broker-url", "https://broker.example/mcp?project=brk", "--token", "<project token>"]
26
+ "args": ["-y", "@xelexis/x-broker@0.17.0", "--broker-url", "https://broker.example/mcp?project=brk", "--token", "<project token>"]
27
27
  }
28
28
  }
29
29
  }
@@ -34,7 +34,7 @@ Use `npx` on every supported OS, including Windows. Replace the broker URL, proj
34
34
  ```toml
35
35
  [mcp_servers.x-broker]
36
36
  command = "npx"
37
- args = ["-y", "@xelexis/x-broker@0.15.0", "--broker-url", "https://broker.example/mcp?project=brk", "--token", "<project token>"]
37
+ args = ["-y", "@xelexis/x-broker@0.17.0", "--broker-url", "https://broker.example/mcp?project=brk", "--token", "<project token>"]
38
38
  ```
39
39
 
40
40
  Codex reads project settings only in trusted projects. Keep the same OS user and authentication directory when you change an existing setup.
Binary file
Binary file
Binary file
Binary file
package/bin/x-broker.js CHANGED
@@ -2,9 +2,10 @@
2
2
  "use strict";
3
3
 
4
4
  // npm launcher for asb-client. It writes nothing to stdout (the MCP stdio
5
- // channel) and relays stdin/stdout through pipes rather than inheriting them:
6
- // if this process is killed, the client's stdin closes and it exits on EOF
7
- // instead of outliving its host. Diagnostics go to stderr only.
5
+ // channel). POSIX execve replaces this process and inherits the host's stdio
6
+ // pipes, so host EOF ends the client. The fallback relays through pipes: killing
7
+ // the launcher closes the client's stdin so it cannot outlive its host.
8
+ // Diagnostics go to stderr only.
8
9
  const { spawn } = require("node:child_process");
9
10
  const fs = require("node:fs");
10
11
  const path = require("node:path");
@@ -40,44 +41,52 @@ function checkBinary(file) {
40
41
  }
41
42
  }
42
43
 
43
- function main() {
44
+ function main({ proc = process, spawnProcess = spawn, resolveBinary = binaryPath, verifyBinary = checkBinary } = {}) {
44
45
  let file;
45
46
  try {
46
- file = binaryPath();
47
- checkBinary(file);
47
+ file = resolveBinary({ platform: proc.platform, arch: proc.arch });
48
+ verifyBinary(file);
48
49
  } catch (err) {
49
- process.stderr.write(`x-broker: ${err.message}\n`);
50
- process.exit(1);
50
+ proc.stderr.write(`x-broker: ${err.message}\n`);
51
+ proc.exit(1);
51
52
  }
52
- const child = spawn(file, process.argv.slice(2), { stdio: ["pipe", "pipe", "inherit"], windowsHide: true });
53
- const signals = process.platform === "win32" ? ["SIGINT", "SIGTERM", "SIGBREAK"] : ["SIGINT", "SIGTERM", "SIGHUP"];
53
+ if (proc.platform !== "win32" && typeof proc.execve === "function") {
54
+ try {
55
+ proc.execve(file, [file, ...proc.argv.slice(2)], proc.env);
56
+ return;
57
+ } catch {
58
+ proc.stderr.write("x-broker: execve failed; using spawn fallback.\n");
59
+ }
60
+ }
61
+ const child = spawnProcess(file, proc.argv.slice(2), { stdio: ["pipe", "pipe", "inherit"], windowsHide: true });
62
+ const signals = proc.platform === "win32" ? ["SIGINT", "SIGTERM", "SIGBREAK"] : ["SIGINT", "SIGTERM", "SIGHUP"];
54
63
  const forward = (signal) => {
55
64
  if (child.exitCode === null && child.signalCode === null) child.kill(signal);
56
65
  };
57
- for (const signal of signals) process.on(signal, forward);
66
+ for (const signal of signals) proc.on(signal, forward);
58
67
 
59
- process.stdin.pipe(child.stdin);
60
- child.stdout.pipe(process.stdout, { end: false });
68
+ proc.stdin.pipe(child.stdin);
69
+ child.stdout.pipe(proc.stdout, { end: false });
61
70
  // The client may exit before reading everything, and the host may close
62
71
  // our stdout; neither is a launcher error.
63
72
  child.stdin.on("error", () => {});
64
- process.stdout.on("error", () => forward("SIGTERM"));
73
+ proc.stdout.on("error", () => forward("SIGTERM"));
65
74
 
66
75
  child.on("error", (err) => {
67
- process.stderr.write(`x-broker: cannot start ${file}: ${err.message}\n`);
68
- process.exit(1);
76
+ proc.stderr.write(`x-broker: cannot start ${file}: ${err.message}\n`);
77
+ proc.exit(1);
69
78
  });
70
79
  child.on("close", (code, signal) => {
71
- process.stdin.unpipe(child.stdin);
72
- process.stdin.destroy();
73
- for (const s of signals) process.removeListener(s, forward);
80
+ proc.stdin.unpipe(child.stdin);
81
+ proc.stdin.destroy();
82
+ for (const s of signals) proc.removeListener(s, forward);
74
83
  // Flush relayed output before mirroring the client's exit.
75
- process.stdout.write("", () => {
76
- if (signal) process.kill(process.pid, signal);
77
- process.exit(code ?? 1);
84
+ proc.stdout.write("", () => {
85
+ if (signal) proc.kill(proc.pid, signal);
86
+ proc.exit(code ?? 1);
78
87
  });
79
88
  });
80
89
  }
81
90
 
82
91
  if (require.main === module) main();
83
- module.exports = { binaryPath };
92
+ module.exports = { binaryPath, main };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xelexis/x-broker",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "description": "npx launcher and bundled clients for the Agent Session Broker MCP client (asb-client)",
5
5
  "bin": {
6
6
  "x-broker": "bin/x-broker.js"
@@ -23,5 +23,5 @@
23
23
  "bugs": {
24
24
  "url": "https://github.com/xelexis-dev/agent-session-broker-deploy#readme"
25
25
  },
26
- "xBrokerClientInputs": "sha256:bc6d362b539915e555d7bf1672adbc674e99467e832f99cc4d388e524e942edd"
26
+ "xBrokerClientInputs": "sha256:1ef87e77d25e135b47673f0b79adfabb384a64e0b49d2f0b3dbb51092d1f0f3c"
27
27
  }