cmux 0.3.6 → 0.4.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 +97 -51
- package/dist/src/base64.d.ts +4 -0
- package/dist/src/base64.js +38 -0
- package/dist/src/browser.d.ts +6 -0
- package/dist/src/browser.js +6 -0
- package/dist/src/client.d.ts +202 -0
- package/dist/src/client.js +799 -0
- package/dist/src/errors.d.ts +18 -0
- package/dist/src/errors.js +29 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.js +8 -0
- package/dist/src/node-client.d.ts +18 -0
- package/dist/src/node-client.js +18 -0
- package/dist/src/node-transport.d.ts +27 -0
- package/dist/src/node-transport.js +99 -0
- package/dist/src/protocol/commands.d.ts +770 -0
- package/dist/src/protocol/commands.js +1 -0
- package/dist/src/protocol/common.d.ts +74 -0
- package/dist/src/protocol/common.js +1 -0
- package/dist/src/protocol/events.d.ts +349 -0
- package/dist/src/protocol/events.js +1 -0
- package/dist/src/protocol/index.d.ts +5 -0
- package/dist/src/protocol/index.js +5 -0
- package/dist/src/protocol/render.d.ts +49 -0
- package/dist/src/protocol/render.js +1 -0
- package/dist/src/protocol/tree.d.ts +95 -0
- package/dist/src/protocol/tree.js +1 -0
- package/dist/src/transport.d.ts +15 -0
- package/dist/src/transport.js +1 -0
- package/dist/src/types.d.ts +4 -0
- package/dist/src/types.js +2 -0
- package/dist/src/websocket-transport.d.ts +75 -0
- package/dist/src/websocket-transport.js +168 -0
- package/package.json +39 -31
- package/AGENTS.md +0 -87
- package/bin/cmux +0 -97
- package/lib/postinstall.js +0 -29
- package/llms.txt +0 -70
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { Transport, Unsubscribe } from "./transport.js";
|
|
2
|
+
interface WebSocketEventMap {
|
|
3
|
+
open: unknown;
|
|
4
|
+
message: {
|
|
5
|
+
data: unknown;
|
|
6
|
+
};
|
|
7
|
+
close: {
|
|
8
|
+
code?: number;
|
|
9
|
+
reason?: string;
|
|
10
|
+
};
|
|
11
|
+
error: unknown;
|
|
12
|
+
}
|
|
13
|
+
/** The WebSocket subset used by `WebSocketTransport`. */
|
|
14
|
+
export interface WebSocketLike {
|
|
15
|
+
readonly readyState: number;
|
|
16
|
+
send(data: string): void;
|
|
17
|
+
close(code?: number, reason?: string): void;
|
|
18
|
+
addEventListener?<K extends keyof WebSocketEventMap>(type: K, listener: (event: WebSocketEventMap[K]) => void): void;
|
|
19
|
+
removeEventListener?<K extends keyof WebSocketEventMap>(type: K, listener: (event: WebSocketEventMap[K]) => void): void;
|
|
20
|
+
on?(type: string, listener: (...args: unknown[]) => void): void;
|
|
21
|
+
off?(type: string, listener: (...args: unknown[]) => void): void;
|
|
22
|
+
}
|
|
23
|
+
/** A browser- or Node-compatible WebSocket constructor. */
|
|
24
|
+
export interface WebSocketConstructor {
|
|
25
|
+
new (url: string | URL, protocols?: string | string[]): WebSocketLike;
|
|
26
|
+
}
|
|
27
|
+
export interface WebSocketTransportOptions {
|
|
28
|
+
protocols?: string | string[];
|
|
29
|
+
/** Sends the cmux-tui WebSocket authentication preamble before queued protocol requests. */
|
|
30
|
+
authToken?: string;
|
|
31
|
+
/** Called while the server waits for a trusted TUI to approve this connection. */
|
|
32
|
+
onPairingChallenge?(challenge: PairingChallenge): void;
|
|
33
|
+
/** Receives the credential issued after approval for reconnects. */
|
|
34
|
+
onPairingCredential?(credential: string): void;
|
|
35
|
+
/** Called when a supplied token or reconnect credential is rejected. */
|
|
36
|
+
onAuthenticationRejected?(): void;
|
|
37
|
+
/** Inject a compatible constructor such as the Node `ws` package. */
|
|
38
|
+
WebSocket?: WebSocketConstructor;
|
|
39
|
+
}
|
|
40
|
+
export interface PairingChallenge {
|
|
41
|
+
id: number;
|
|
42
|
+
code: string;
|
|
43
|
+
peer: string;
|
|
44
|
+
expiresIn: number;
|
|
45
|
+
}
|
|
46
|
+
/** Sends and receives one JSON message per WebSocket text frame. */
|
|
47
|
+
export declare class WebSocketTransport implements Transport {
|
|
48
|
+
private readonly socket;
|
|
49
|
+
private readonly pending;
|
|
50
|
+
private readonly messageHandlers;
|
|
51
|
+
private readonly closeHandlers;
|
|
52
|
+
private readonly errorHandlers;
|
|
53
|
+
private readonly authToken;
|
|
54
|
+
private readonly onPairingChallenge;
|
|
55
|
+
private readonly onPairingCredential;
|
|
56
|
+
private readonly onAuthenticationRejected;
|
|
57
|
+
private authenticated;
|
|
58
|
+
private closed;
|
|
59
|
+
constructor(url: string | URL, options?: WebSocketTransportOptions | WebSocketConstructor);
|
|
60
|
+
send(json: string): void;
|
|
61
|
+
onMessage(handler: (json: string) => void): Unsubscribe;
|
|
62
|
+
onClose(handler: () => void): Unsubscribe;
|
|
63
|
+
onError(handler: (error: Error) => void): Unsubscribe;
|
|
64
|
+
close(): void;
|
|
65
|
+
private globalConstructor;
|
|
66
|
+
private listen;
|
|
67
|
+
private flush;
|
|
68
|
+
private flushPending;
|
|
69
|
+
private receive;
|
|
70
|
+
private receivePairing;
|
|
71
|
+
private eventError;
|
|
72
|
+
private fail;
|
|
73
|
+
private finish;
|
|
74
|
+
}
|
|
75
|
+
export {};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/** Sends and receives one JSON message per WebSocket text frame. */
|
|
2
|
+
export class WebSocketTransport {
|
|
3
|
+
socket;
|
|
4
|
+
pending = [];
|
|
5
|
+
messageHandlers = new Set();
|
|
6
|
+
closeHandlers = new Set();
|
|
7
|
+
errorHandlers = new Set();
|
|
8
|
+
authToken;
|
|
9
|
+
onPairingChallenge;
|
|
10
|
+
onPairingCredential;
|
|
11
|
+
onAuthenticationRejected;
|
|
12
|
+
authenticated = false;
|
|
13
|
+
closed = false;
|
|
14
|
+
constructor(url, options = {}) {
|
|
15
|
+
const normalized = typeof options === "function" ? { WebSocket: options } : options;
|
|
16
|
+
const Constructor = normalized.WebSocket ?? this.globalConstructor();
|
|
17
|
+
this.authToken = normalized.authToken;
|
|
18
|
+
this.onPairingChallenge = normalized.onPairingChallenge;
|
|
19
|
+
this.onPairingCredential = normalized.onPairingCredential;
|
|
20
|
+
this.onAuthenticationRejected = normalized.onAuthenticationRejected;
|
|
21
|
+
this.socket = new Constructor(url, normalized.protocols);
|
|
22
|
+
this.listen("open", () => this.flush());
|
|
23
|
+
this.listen("message", (event) => this.receive(event));
|
|
24
|
+
this.listen("error", (event) => this.fail(this.eventError(event)));
|
|
25
|
+
this.listen("close", (event) => this.finish(event));
|
|
26
|
+
}
|
|
27
|
+
send(json) {
|
|
28
|
+
if (this.closed)
|
|
29
|
+
throw new Error("WebSocket transport is closed");
|
|
30
|
+
if (this.socket.readyState === 1 && this.authenticated)
|
|
31
|
+
this.socket.send(json);
|
|
32
|
+
else
|
|
33
|
+
this.pending.push(json);
|
|
34
|
+
}
|
|
35
|
+
onMessage(handler) {
|
|
36
|
+
this.messageHandlers.add(handler);
|
|
37
|
+
return () => this.messageHandlers.delete(handler);
|
|
38
|
+
}
|
|
39
|
+
onClose(handler) {
|
|
40
|
+
this.closeHandlers.add(handler);
|
|
41
|
+
if (this.closed)
|
|
42
|
+
queueMicrotask(handler);
|
|
43
|
+
return () => this.closeHandlers.delete(handler);
|
|
44
|
+
}
|
|
45
|
+
onError(handler) {
|
|
46
|
+
this.errorHandlers.add(handler);
|
|
47
|
+
return () => this.errorHandlers.delete(handler);
|
|
48
|
+
}
|
|
49
|
+
close() {
|
|
50
|
+
if (this.closed)
|
|
51
|
+
return;
|
|
52
|
+
this.socket.close();
|
|
53
|
+
}
|
|
54
|
+
globalConstructor() {
|
|
55
|
+
const Constructor = globalThis.WebSocket;
|
|
56
|
+
if (!Constructor)
|
|
57
|
+
throw new Error("WebSocket is not available; inject a compatible constructor");
|
|
58
|
+
return Constructor;
|
|
59
|
+
}
|
|
60
|
+
listen(type, handler) {
|
|
61
|
+
if (this.socket.addEventListener) {
|
|
62
|
+
this.socket.addEventListener(type, handler);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (this.socket.on) {
|
|
66
|
+
this.socket.on(type, handler);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
throw new Error("injected WebSocket does not support event listeners");
|
|
70
|
+
}
|
|
71
|
+
flush() {
|
|
72
|
+
if (this.closed)
|
|
73
|
+
return;
|
|
74
|
+
if (this.authToken !== undefined) {
|
|
75
|
+
this.socket.send(JSON.stringify({ auth: { token: this.authToken } }));
|
|
76
|
+
this.authenticated = true;
|
|
77
|
+
this.flushPending();
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
this.socket.send(JSON.stringify({ pair: { request: true } }));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
flushPending() {
|
|
84
|
+
while (this.pending.length > 0)
|
|
85
|
+
this.socket.send(this.pending.shift());
|
|
86
|
+
}
|
|
87
|
+
receive(event) {
|
|
88
|
+
const data = event && typeof event === "object" && "data" in event ? event.data : event;
|
|
89
|
+
if (typeof data !== "string") {
|
|
90
|
+
this.fail(new Error("WebSocket server sent a non-text frame"));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (!this.authenticated) {
|
|
94
|
+
this.receivePairing(data);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
for (const handler of this.messageHandlers)
|
|
98
|
+
handler(data);
|
|
99
|
+
}
|
|
100
|
+
receivePairing(json) {
|
|
101
|
+
let value;
|
|
102
|
+
try {
|
|
103
|
+
value = JSON.parse(json);
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
this.fail(new Error("WebSocket server sent invalid pairing data"));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (!value || typeof value !== "object") {
|
|
110
|
+
this.fail(new Error("WebSocket server sent invalid pairing data"));
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const message = value;
|
|
114
|
+
if (message.pairing && typeof message.pairing === "object") {
|
|
115
|
+
const pairing = message.pairing;
|
|
116
|
+
if (typeof pairing.id === "number"
|
|
117
|
+
&& typeof pairing.code === "string"
|
|
118
|
+
&& typeof pairing.peer === "string"
|
|
119
|
+
&& typeof pairing.expires_in === "number") {
|
|
120
|
+
this.onPairingChallenge?.({
|
|
121
|
+
id: pairing.id,
|
|
122
|
+
code: pairing.code,
|
|
123
|
+
peer: pairing.peer,
|
|
124
|
+
expiresIn: pairing.expires_in,
|
|
125
|
+
});
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (message.paired && typeof message.paired === "object") {
|
|
130
|
+
const credential = message.paired.credential;
|
|
131
|
+
if (typeof credential === "string") {
|
|
132
|
+
this.authenticated = true;
|
|
133
|
+
this.onPairingCredential?.(credential);
|
|
134
|
+
this.flushPending();
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (message.pairing_error && typeof message.pairing_error === "object") {
|
|
139
|
+
const pairingError = message.pairing_error;
|
|
140
|
+
this.fail(new Error(typeof pairingError.message === "string" ? pairingError.message : "Pairing failed"));
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
this.fail(new Error("WebSocket server sent invalid pairing data"));
|
|
144
|
+
}
|
|
145
|
+
eventError(event) {
|
|
146
|
+
if (event instanceof Error)
|
|
147
|
+
return event;
|
|
148
|
+
if (event && typeof event === "object" && "error" in event && event.error instanceof Error) {
|
|
149
|
+
return event.error;
|
|
150
|
+
}
|
|
151
|
+
return new Error("WebSocket transport error");
|
|
152
|
+
}
|
|
153
|
+
fail(error) {
|
|
154
|
+
for (const handler of this.errorHandlers)
|
|
155
|
+
handler(error);
|
|
156
|
+
}
|
|
157
|
+
finish(event) {
|
|
158
|
+
if (this.closed)
|
|
159
|
+
return;
|
|
160
|
+
this.closed = true;
|
|
161
|
+
this.pending.length = 0;
|
|
162
|
+
if (event?.code === 1008 && event.reason === "authentication failed") {
|
|
163
|
+
this.onAuthenticationRejected?.();
|
|
164
|
+
}
|
|
165
|
+
for (const handler of this.closeHandlers)
|
|
166
|
+
handler();
|
|
167
|
+
}
|
|
168
|
+
}
|
package/package.json
CHANGED
|
@@ -1,45 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cmux",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"keywords": [
|
|
6
|
-
"cli",
|
|
7
|
-
"devbox",
|
|
8
|
-
"cloud",
|
|
9
|
-
"vm",
|
|
10
|
-
"development",
|
|
11
|
-
"sandbox",
|
|
12
|
-
"remote",
|
|
13
|
-
"vscode"
|
|
14
|
-
],
|
|
15
|
-
"homepage": "https://cmux.sh",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Typed TypeScript client for cmux-tui frontends",
|
|
16
5
|
"repository": {
|
|
17
6
|
"type": "git",
|
|
18
7
|
"url": "git+https://github.com/manaflow-ai/cmux.git",
|
|
19
|
-
"directory": "
|
|
8
|
+
"directory": "cmux-tui/bindings/typescript"
|
|
20
9
|
},
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
10
|
+
"homepage": "https://github.com/manaflow-ai/cmux/tree/main/cmux-tui/bindings/typescript",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./dist/src/index.js",
|
|
13
|
+
"types": "./dist/src/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"browser": {
|
|
17
|
+
"types": "./dist/src/browser.d.ts",
|
|
18
|
+
"import": "./dist/src/browser.js",
|
|
19
|
+
"default": "./dist/src/browser.js"
|
|
20
|
+
},
|
|
21
|
+
"types": "./dist/src/index.d.ts",
|
|
22
|
+
"import": "./dist/src/index.js",
|
|
23
|
+
"default": "./dist/src/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./browser": {
|
|
26
|
+
"types": "./dist/src/browser.d.ts",
|
|
27
|
+
"import": "./dist/src/browser.js",
|
|
28
|
+
"default": "./dist/src/browser.js"
|
|
29
|
+
},
|
|
30
|
+
"./node": {
|
|
31
|
+
"types": "./dist/src/index.d.ts",
|
|
32
|
+
"import": "./dist/src/index.js",
|
|
33
|
+
"default": "./dist/src/index.js"
|
|
34
|
+
}
|
|
25
35
|
},
|
|
36
|
+
"sideEffects": false,
|
|
26
37
|
"files": [
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"AGENTS.md",
|
|
30
|
-
"llms.txt"
|
|
38
|
+
"dist/src",
|
|
39
|
+
"README.md"
|
|
31
40
|
],
|
|
32
41
|
"scripts": {
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"cmux-darwin-arm64": "0.3.6",
|
|
37
|
-
"cmux-darwin-x64": "0.3.6",
|
|
38
|
-
"cmux-linux-arm64": "0.3.6",
|
|
39
|
-
"cmux-linux-x64": "0.3.6",
|
|
40
|
-
"cmux-win32-x64": "0.3.6"
|
|
42
|
+
"build": "tsc",
|
|
43
|
+
"test": "npm run build && node --test dist/test/*.test.js",
|
|
44
|
+
"e2e": "npm run build && node dist/e2e/e2e.js"
|
|
41
45
|
},
|
|
42
46
|
"engines": {
|
|
43
|
-
"node": ">=
|
|
47
|
+
"node": ">=20"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "20.19.25",
|
|
51
|
+
"typescript": "5.9.3"
|
|
44
52
|
}
|
|
45
53
|
}
|
package/AGENTS.md
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
# cmux CLI - Agent Instructions
|
|
2
|
-
|
|
3
|
-
cmux is a CLI for managing cloud development VMs. Use these commands to help users work with remote development environments.
|
|
4
|
-
|
|
5
|
-
## Quick Reference
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
# Authentication
|
|
9
|
-
cmux login # Login (opens browser)
|
|
10
|
-
cmux logout # Logout
|
|
11
|
-
cmux whoami # Show current user and team
|
|
12
|
-
|
|
13
|
-
# VM Lifecycle
|
|
14
|
-
cmux start [path] # Create VM, optionally sync directory
|
|
15
|
-
cmux ls # List all VMs
|
|
16
|
-
cmux status <id> # Show VM details and URLs
|
|
17
|
-
cmux pause <id> # Pause VM (preserves state, saves cost)
|
|
18
|
-
cmux resume <id> # Resume paused VM
|
|
19
|
-
cmux delete <id> # Delete VM permanently
|
|
20
|
-
|
|
21
|
-
# Access VM
|
|
22
|
-
cmux code <id> # Open VS Code in browser
|
|
23
|
-
cmux ssh <id> # SSH into VM
|
|
24
|
-
cmux vnc <id> # Open VNC desktop
|
|
25
|
-
cmux pty <id> # Interactive terminal session
|
|
26
|
-
|
|
27
|
-
# Work with VM
|
|
28
|
-
cmux exec <id> "cmd" # Run command in VM
|
|
29
|
-
cmux sync <id> <path> # Sync local files to VM
|
|
30
|
-
cmux sync <id> <path> --pull # Pull files from VM
|
|
31
|
-
|
|
32
|
-
# Browser Automation (control Chrome in VNC)
|
|
33
|
-
cmux computer open <id> <url> # Navigate to URL
|
|
34
|
-
cmux computer snapshot <id> # Get interactive elements (@e1, @e2...)
|
|
35
|
-
cmux computer click <id> <selector> # Click element (@e1 or CSS selector)
|
|
36
|
-
cmux computer type <id> "text" # Type into focused element
|
|
37
|
-
cmux computer fill <id> <sel> "value" # Clear and fill input
|
|
38
|
-
cmux computer screenshot <id> [file] # Take screenshot
|
|
39
|
-
cmux computer press <id> <key> # Press key (enter, tab, escape)
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## VM IDs
|
|
43
|
-
|
|
44
|
-
VM IDs look like `cmux_abc12345`. Always use the full ID when running commands.
|
|
45
|
-
|
|
46
|
-
## Common Workflows
|
|
47
|
-
|
|
48
|
-
### Create and access a VM
|
|
49
|
-
```bash
|
|
50
|
-
cmux start ./my-project # Creates VM, syncs directory, returns ID
|
|
51
|
-
cmux code cmux_abc123 # Opens VS Code
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### Run commands remotely
|
|
55
|
-
```bash
|
|
56
|
-
cmux exec cmux_abc123 "npm install"
|
|
57
|
-
cmux exec cmux_abc123 "npm run dev"
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Sync files
|
|
61
|
-
```bash
|
|
62
|
-
cmux sync cmux_abc123 . # Push current dir to VM
|
|
63
|
-
cmux sync cmux_abc123 ./dist --pull # Pull build output from VM
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### Browser automation
|
|
67
|
-
```bash
|
|
68
|
-
cmux computer open cmux_abc123 "https://localhost:3000"
|
|
69
|
-
cmux computer snapshot cmux_abc123 # See clickable elements
|
|
70
|
-
cmux computer click cmux_abc123 @e1 # Click first element
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### End of session
|
|
74
|
-
```bash
|
|
75
|
-
cmux pause cmux_abc123 # Pause to save costs (can resume later)
|
|
76
|
-
# OR
|
|
77
|
-
cmux delete cmux_abc123 # Delete permanently
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## Tips
|
|
81
|
-
|
|
82
|
-
- Run `cmux login` first if not authenticated
|
|
83
|
-
- Use `cmux whoami` to check current user and team
|
|
84
|
-
- Use `cmux ls` to see all VMs and their states
|
|
85
|
-
- Paused VMs preserve state and can be resumed instantly
|
|
86
|
-
- The `cmux pty` command requires an interactive terminal
|
|
87
|
-
- Browser automation commands work on the Chrome instance in the VNC desktop
|
package/bin/cmux
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { spawn } = require("child_process");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const fs = require("fs");
|
|
6
|
-
|
|
7
|
-
const PLATFORMS = {
|
|
8
|
-
"darwin-arm64": "cmux-darwin-arm64",
|
|
9
|
-
"darwin-x64": "cmux-darwin-x64",
|
|
10
|
-
"linux-arm64": "cmux-linux-arm64",
|
|
11
|
-
"linux-x64": "cmux-linux-x64",
|
|
12
|
-
"win32-x64": "cmux-win32-x64",
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// Map platform to local directory name (for development)
|
|
16
|
-
const LOCAL_DIRS = {
|
|
17
|
-
"darwin-arm64": "darwin-arm64",
|
|
18
|
-
"darwin-x64": "darwin-x64",
|
|
19
|
-
"linux-arm64": "linux-arm64",
|
|
20
|
-
"linux-x64": "linux-x64",
|
|
21
|
-
"win32-x64": "win32-x64",
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
function getBinaryPath() {
|
|
25
|
-
const platform = `${process.platform}-${process.arch}`;
|
|
26
|
-
const pkg = PLATFORMS[platform];
|
|
27
|
-
const localDir = LOCAL_DIRS[platform];
|
|
28
|
-
|
|
29
|
-
if (!pkg) {
|
|
30
|
-
console.error(`cmux: Unsupported platform: ${platform}`);
|
|
31
|
-
console.error(`Supported platforms: ${Object.keys(PLATFORMS).join(", ")}`);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const binName = process.platform === "win32" ? "cmux.exe" : "cmux";
|
|
36
|
-
|
|
37
|
-
// Try to find the platform-specific package from node_modules
|
|
38
|
-
try {
|
|
39
|
-
const pkgPath = require.resolve(`${pkg}/package.json`);
|
|
40
|
-
const pkgDir = path.dirname(pkgPath);
|
|
41
|
-
const binPath = path.join(pkgDir, "bin", binName);
|
|
42
|
-
|
|
43
|
-
if (fs.existsSync(binPath)) {
|
|
44
|
-
return binPath;
|
|
45
|
-
}
|
|
46
|
-
} catch (e) {
|
|
47
|
-
// Package not found in node_modules
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Try local development path (sibling directory)
|
|
51
|
-
const localBinPath = path.join(__dirname, "..", "..", localDir, "bin", binName);
|
|
52
|
-
if (fs.existsSync(localBinPath)) {
|
|
53
|
-
return localBinPath;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
console.error(`cmux: Could not find binary for platform: ${platform}`);
|
|
57
|
-
console.error(`Make sure ${pkg} is installed.`);
|
|
58
|
-
console.error("");
|
|
59
|
-
console.error("Try reinstalling with:");
|
|
60
|
-
console.error(" npm install cmux");
|
|
61
|
-
process.exit(1);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function main() {
|
|
65
|
-
const binPath = getBinaryPath();
|
|
66
|
-
const args = process.argv.slice(2);
|
|
67
|
-
|
|
68
|
-
// Use spawn for better signal handling (especially for PTY)
|
|
69
|
-
const child = spawn(binPath, args, {
|
|
70
|
-
stdio: "inherit",
|
|
71
|
-
windowsHide: true,
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
child.on("error", (err) => {
|
|
75
|
-
console.error(`cmux: Failed to start: ${err.message}`);
|
|
76
|
-
process.exit(1);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
child.on("exit", (code, signal) => {
|
|
80
|
-
if (signal) {
|
|
81
|
-
// Re-raise the signal
|
|
82
|
-
process.kill(process.pid, signal);
|
|
83
|
-
} else {
|
|
84
|
-
process.exit(code ?? 0);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// Forward signals to child
|
|
89
|
-
const signals = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
90
|
-
for (const sig of signals) {
|
|
91
|
-
process.on(sig, () => {
|
|
92
|
-
child.kill(sig);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
main();
|
package/lib/postinstall.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// Post-install message for cmux
|
|
4
|
-
// Only show in interactive terminals to avoid noise in CI
|
|
5
|
-
|
|
6
|
-
const isCI = process.env.CI === 'true' ||
|
|
7
|
-
process.env.CONTINUOUS_INTEGRATION === 'true' ||
|
|
8
|
-
process.env.BUILD_NUMBER !== undefined ||
|
|
9
|
-
process.env.GITHUB_ACTIONS === 'true';
|
|
10
|
-
|
|
11
|
-
const isInteractive = process.stdout.isTTY && !isCI;
|
|
12
|
-
|
|
13
|
-
if (isInteractive) {
|
|
14
|
-
const message = `
|
|
15
|
-
┌─────────────────────────────────────────────────────────┐
|
|
16
|
-
│ │
|
|
17
|
-
│ ✨ cmux installed successfully! │
|
|
18
|
-
│ │
|
|
19
|
-
│ Get started: │
|
|
20
|
-
│ $ cmux login # Login to your account │
|
|
21
|
-
│ $ cmux start # Create a cloud VM │
|
|
22
|
-
│ $ cmux --help # See all commands │
|
|
23
|
-
│ │
|
|
24
|
-
│ Documentation: https://cmux.sh/docs │
|
|
25
|
-
│ │
|
|
26
|
-
└─────────────────────────────────────────────────────────┘
|
|
27
|
-
`;
|
|
28
|
-
console.log(message);
|
|
29
|
-
}
|
package/llms.txt
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# cmux
|
|
2
|
-
|
|
3
|
-
> Cloud VMs for development - spawn isolated dev environments instantly
|
|
4
|
-
|
|
5
|
-
cmux is a CLI tool for managing cloud development VMs. It provides instant access to fully configured development environments with VS Code, VNC desktop, SSH, and browser automation.
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install -g cmux
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Commands
|
|
14
|
-
|
|
15
|
-
### Authentication
|
|
16
|
-
- `cmux login` - Login via browser
|
|
17
|
-
- `cmux logout` - Logout
|
|
18
|
-
- `cmux whoami` - Show current user and team
|
|
19
|
-
|
|
20
|
-
### VM Management
|
|
21
|
-
- `cmux start [path]` - Create new VM, optionally sync a directory
|
|
22
|
-
- `cmux ls` - List all VMs (aliases: list, ps)
|
|
23
|
-
- `cmux status <id>` - Show VM status and URLs
|
|
24
|
-
- `cmux pause <id>` - Pause VM (preserves state)
|
|
25
|
-
- `cmux resume <id>` - Resume paused VM
|
|
26
|
-
- `cmux delete <id>` - Delete VM permanently
|
|
27
|
-
|
|
28
|
-
### Accessing VMs
|
|
29
|
-
- `cmux code <id>` - Open VS Code in browser
|
|
30
|
-
- `cmux ssh <id>` - SSH into VM
|
|
31
|
-
- `cmux vnc <id>` - Open VNC desktop in browser
|
|
32
|
-
- `cmux pty <id>` - Interactive terminal session
|
|
33
|
-
|
|
34
|
-
### Working with VMs
|
|
35
|
-
- `cmux exec <id> "command"` - Execute command in VM
|
|
36
|
-
- `cmux sync <id> <path>` - Sync local directory to VM
|
|
37
|
-
- `cmux sync <id> <path> --pull` - Pull from VM to local
|
|
38
|
-
|
|
39
|
-
### Browser Automation
|
|
40
|
-
Control Chrome running in the VNC desktop:
|
|
41
|
-
- `cmux computer open <id> <url>` - Navigate to URL
|
|
42
|
-
- `cmux computer snapshot <id>` - Get accessibility tree with element refs (@e1, @e2)
|
|
43
|
-
- `cmux computer click <id> <selector>` - Click element (use @ref or CSS selector)
|
|
44
|
-
- `cmux computer type <id> "text"` - Type into focused element
|
|
45
|
-
- `cmux computer fill <id> <selector> "value"` - Clear and fill input
|
|
46
|
-
- `cmux computer screenshot <id> [file]` - Take screenshot
|
|
47
|
-
- `cmux computer press <id> <key>` - Press key (enter, tab, escape, etc.)
|
|
48
|
-
|
|
49
|
-
## Examples
|
|
50
|
-
|
|
51
|
-
Create a VM and run a dev server:
|
|
52
|
-
```bash
|
|
53
|
-
cmux start ./my-app
|
|
54
|
-
cmux exec cmux_abc123 "npm install && npm run dev"
|
|
55
|
-
cmux code cmux_abc123
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
Automate browser testing:
|
|
59
|
-
```bash
|
|
60
|
-
cmux computer open cmux_abc123 "http://localhost:3000"
|
|
61
|
-
cmux computer snapshot cmux_abc123
|
|
62
|
-
cmux computer click cmux_abc123 @e1
|
|
63
|
-
cmux computer screenshot cmux_abc123 test.png
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Links
|
|
67
|
-
|
|
68
|
-
- Homepage: https://cmux.sh
|
|
69
|
-
- Documentation: https://cmux.sh/docs
|
|
70
|
-
- GitHub: https://github.com/manaflow-ai/cmux
|