@wong2kim/wmux 1.0.6 → 1.1.1
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 +1 -1
- package/dist/cli/shared/constants.js +8 -3
- package/dist/mcp/mcp/wmux-client.js +37 -25
- package/dist/mcp/shared/constants.js +8 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Inspired by [cmux](https://github.com/manaflow-ai/cmux) (macOS), wmux brings the
|
|
|
14
14
|
|
|
15
15
|
## Install
|
|
16
16
|
|
|
17
|
-
**Download:** [wmux-1.
|
|
17
|
+
**Download:** [wmux-1.1.1 Setup.exe](https://github.com/openwong2kim/wmux/releases/latest)
|
|
18
18
|
|
|
19
19
|
Or build from source:
|
|
20
20
|
```powershell
|
|
@@ -49,9 +49,14 @@ exports.IPC = {
|
|
|
49
49
|
// Named Pipe / Unix socket path for wmux API
|
|
50
50
|
// Fixed name so MCP clients (e.g. Claude Code) can reconnect across wmux restarts
|
|
51
51
|
function getPipeName() {
|
|
52
|
-
if (process.platform === 'win32')
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
if (process.platform === 'win32') {
|
|
53
|
+
// Use os.userInfo() instead of process.env.USERNAME — env vars may not
|
|
54
|
+
// be inherited by MCP subprocesses spawned by Claude Code
|
|
55
|
+
const username = require('os').userInfo().username || 'default';
|
|
56
|
+
return `\\\\.\\pipe\\wmux-${username}`;
|
|
57
|
+
}
|
|
58
|
+
const home = require('os').homedir() || '/tmp';
|
|
59
|
+
return `${home}/.wmux.sock`;
|
|
55
60
|
}
|
|
56
61
|
// Environment variable names injected into PTY sessions
|
|
57
62
|
exports.ENV_KEYS = {
|
|
@@ -42,16 +42,18 @@ const TIMEOUT_MS = 10000;
|
|
|
42
42
|
const RETRY_COUNT = 3;
|
|
43
43
|
const RETRY_DELAY_MS = 1000;
|
|
44
44
|
function readAuthToken() {
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
return process.env.WMUX_AUTH_TOKEN;
|
|
48
|
-
// File fallback (when spawned by Claude Code as MCP server)
|
|
45
|
+
// File takes priority — always read the latest token from disk.
|
|
46
|
+
// Env vars may be stale (Claude Code caches them across MCP restarts).
|
|
49
47
|
try {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return undefined;
|
|
48
|
+
const fromFile = fs.readFileSync((0, constants_1.getAuthTokenPath)(), 'utf8').trim();
|
|
49
|
+
if (fromFile)
|
|
50
|
+
return fromFile;
|
|
54
51
|
}
|
|
52
|
+
catch { /* file doesn't exist */ }
|
|
53
|
+
// Env var fallback (when running inside wmux terminal)
|
|
54
|
+
if (process.env.WMUX_AUTH_TOKEN)
|
|
55
|
+
return process.env.WMUX_AUTH_TOKEN;
|
|
56
|
+
return undefined;
|
|
55
57
|
}
|
|
56
58
|
function attemptRpc(pipePath, token, method, params) {
|
|
57
59
|
return new Promise((resolve, reject) => {
|
|
@@ -122,24 +124,34 @@ function sleep(ms) {
|
|
|
122
124
|
return new Promise((r) => setTimeout(r, ms));
|
|
123
125
|
}
|
|
124
126
|
async function sendRpc(method, params = {}) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
127
|
+
// Try WMUX_SOCKET_PATH first (if set), then fall back to getPipeName().
|
|
128
|
+
// Claude Code may cache a stale WMUX_SOCKET_PATH from a previous session,
|
|
129
|
+
// so we must fall back to the derived name if the env path fails.
|
|
130
|
+
const envPath = process.env.WMUX_SOCKET_PATH;
|
|
131
|
+
const derivedPath = (0, constants_1.getPipeName)();
|
|
132
|
+
const pipePaths = envPath && envPath !== derivedPath ? [envPath, derivedPath] : [derivedPath];
|
|
133
|
+
for (const pipePath of pipePaths) {
|
|
134
|
+
for (let attempt = 0; attempt < RETRY_COUNT; attempt++) {
|
|
135
|
+
const token = readAuthToken();
|
|
136
|
+
if (!token) {
|
|
137
|
+
throw new Error('wmux auth token not found. Is wmux running?');
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
return await attemptRpc(pipePath, token, method, params);
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
const msg = err.message;
|
|
144
|
+
const isRetryable = msg.includes('not running') || msg.includes('unauthorized');
|
|
145
|
+
if (isRetryable && attempt < RETRY_COUNT - 1) {
|
|
146
|
+
await sleep(RETRY_DELAY_MS);
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
// If env path failed and we have a fallback, break to try derived path
|
|
150
|
+
if (isRetryable && pipePaths.length > 1 && pipePath === envPath) {
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
throw err;
|
|
141
154
|
}
|
|
142
|
-
throw err;
|
|
143
155
|
}
|
|
144
156
|
}
|
|
145
157
|
throw new Error('wmux is not running. Start the app first.');
|
|
@@ -49,9 +49,14 @@ exports.IPC = {
|
|
|
49
49
|
// Named Pipe / Unix socket path for wmux API
|
|
50
50
|
// Fixed name so MCP clients (e.g. Claude Code) can reconnect across wmux restarts
|
|
51
51
|
function getPipeName() {
|
|
52
|
-
if (process.platform === 'win32')
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
if (process.platform === 'win32') {
|
|
53
|
+
// Use os.userInfo() instead of process.env.USERNAME — env vars may not
|
|
54
|
+
// be inherited by MCP subprocesses spawned by Claude Code
|
|
55
|
+
const username = require('os').userInfo().username || 'default';
|
|
56
|
+
return `\\\\.\\pipe\\wmux-${username}`;
|
|
57
|
+
}
|
|
58
|
+
const home = require('os').homedir() || '/tmp';
|
|
59
|
+
return `${home}/.wmux.sock`;
|
|
55
60
|
}
|
|
56
61
|
// Environment variable names injected into PTY sessions
|
|
57
62
|
exports.ENV_KEYS = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wong2kim/wmux",
|
|
3
3
|
"productName": "wmux",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"description": "Windows terminal multiplexer with MCP server for AI agents - run multiple CLI sessions in parallel, control via Claude Code and other AI tools",
|
|
6
6
|
"main": ".vite/build/index.js",
|
|
7
7
|
"scripts": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"forge-publish": "electron-forge publish",
|
|
13
13
|
"lint": "eslint --ext .ts,.tsx .",
|
|
14
14
|
"build:cli": "tsc -p tsconfig.cli.json",
|
|
15
|
-
"build:mcp": "tsc -p tsconfig.mcp.json",
|
|
15
|
+
"build:mcp": "tsc -p tsconfig.mcp.json && esbuild dist/mcp/mcp/index.js --bundle --platform=node --outfile=dist/mcp-bundle/index.js --external:electron",
|
|
16
16
|
"cli": "node dist/cli/cli/index.js",
|
|
17
17
|
"mcp": "node dist/mcp/mcp/index.js",
|
|
18
18
|
"prepublishOnly": "npm run build:cli && npm run build:mcp"
|