cmux 0.1.0 → 0.1.2

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
@@ -1,16 +1,32 @@
1
- # cmux
1
+ # cmux TypeScript Client
2
2
 
3
- A multiplexer tool.
3
+ Node.js client for the cmux-mux Unix-socket JSON-lines protocol.
4
4
 
5
- ## Installation
5
+ ## Build
6
6
 
7
7
  ```bash
8
- npm install cmux
8
+ npm i cmux
9
+ npm install
10
+ npm run build
9
11
  ```
10
12
 
13
+ The package has no runtime dependencies. Node 20 or newer is required.
14
+
11
15
  ## Usage
12
16
 
13
- ```javascript
14
- const cmux = require('cmux');
15
- console.log(cmux.hello());
16
- ```
17
+ ```ts
18
+ import { CmuxClient } from "cmux";
19
+
20
+ const client = new CmuxClient({ socketPath: process.env.CMUX_MUX_SOCKET });
21
+ const info = await client.identify();
22
+ const created = await client.newWorkspace({ name: "sdk-demo", cols: 80, rows: 24 });
23
+ await client.send(created.surface, { text: "echo hello\r" });
24
+ console.log((await client.readScreen(created.surface)).text);
25
+ await client.close();
26
+ ```
27
+
28
+ ## E2E
29
+
30
+ ```bash
31
+ CMUX_MUX_SOCKET=/path/to/session.sock npm run e2e
32
+ ```
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const index_js_1 = require("../src/index.js");
4
+ async function main() {
5
+ const socketPath = process.env.CMUX_MUX_SOCKET;
6
+ if (!socketPath)
7
+ throw new Error("CMUX_MUX_SOCKET is required");
8
+ const marker = `CMUX_TS_E2E_${process.pid}_${Date.now()}`;
9
+ const later = `${marker}_ATTACH`;
10
+ const client = new index_js_1.CmuxClient({ socketPath, timeoutMs: 5000 });
11
+ try {
12
+ const identify = await client.identify();
13
+ assert(identify.app === "cmux-mux", `unexpected app ${identify.app}`);
14
+ assert(identify.protocol >= 5 && identify.protocol <= 6, `unsupported protocol ${identify.protocol}`);
15
+ const created = await client.newWorkspace({ name: marker, cols: 80, rows: 24 });
16
+ await client.send(created.surface, { text: `printf '${marker}\\n'\r` });
17
+ await waitForMarker(client, created.surface, marker);
18
+ const screen = await client.readScreen(created.surface);
19
+ assert(screen.text.includes(marker), "marker missing from read-screen");
20
+ const tree = await client.listWorkspaces();
21
+ const workspaceId = findWorkspaceForSurface(tree, created.surface);
22
+ assert(workspaceId !== undefined, "new workspace not found");
23
+ await client.renameSurface(created.surface, `${marker}-renamed`);
24
+ const events = await client.subscribe();
25
+ await client.resizeSurface(created.surface, 100, 31);
26
+ const resized = await nextSurfaceResized(events, created.surface, 1000);
27
+ assert(resized.cols === 100 && resized.rows === 31, `bad resize event ${JSON.stringify(resized)}`);
28
+ await client.resizeSurface(created.surface, 100, 31);
29
+ const duplicate = await nextSurfaceResized(events, created.surface, 500).catch((err) => {
30
+ if (err instanceof index_js_1.CmuxTimeoutError)
31
+ return null;
32
+ throw err;
33
+ });
34
+ assert(duplicate === null, "same-size resize emitted surface-resized");
35
+ events.close();
36
+ const attach = await client.attachSurface(created.surface);
37
+ const first = await attach.next(1000);
38
+ assert(first.event === "vt-state", `first attach event was ${first.event}`);
39
+ await client.send(created.surface, { text: `printf '${later}\\n'\r` });
40
+ const output = await nextAttachOutput(attach, 3000);
41
+ assert(output.event === "output" || output.event === "resized", "attach did not produce output/resized after vt-state");
42
+ attach.close();
43
+ await client.closeWorkspace(workspaceId);
44
+ const afterClose = await client.listWorkspaces();
45
+ assert(findWorkspaceForSurface(afterClose, created.surface) === undefined, "closed workspace still present");
46
+ try {
47
+ await client.readScreen(created.surface);
48
+ throw new Error("read-screen on closed surface unexpectedly succeeded");
49
+ }
50
+ catch (err) {
51
+ assert(err instanceof index_js_1.CmuxCommandError, `closed surface error was not command error: ${err}`);
52
+ assert(String(err.message).length > 0, "command error did not preserve server message");
53
+ }
54
+ }
55
+ finally {
56
+ await client.close().catch(() => undefined);
57
+ }
58
+ }
59
+ async function waitForMarker(client, surface, marker) {
60
+ const deadline = Date.now() + 5000;
61
+ let last = "";
62
+ while (Date.now() < deadline) {
63
+ last = (await client.readScreen(surface)).text;
64
+ if (last.includes(marker))
65
+ return;
66
+ await new Promise((resolve) => setTimeout(resolve, 50));
67
+ }
68
+ throw new Error(`marker not found; last screen: ${JSON.stringify(last)}`);
69
+ }
70
+ async function nextSurfaceResized(events, surface, timeoutMs) {
71
+ const deadline = Date.now() + timeoutMs;
72
+ for (;;) {
73
+ const remaining = deadline - Date.now();
74
+ if (remaining <= 0)
75
+ throw new index_js_1.CmuxTimeoutError("surface-resized not observed");
76
+ const event = await events.next(remaining);
77
+ if (event.event === "surface-resized" && event.surface === surface)
78
+ return event;
79
+ }
80
+ }
81
+ async function nextAttachOutput(attach, timeoutMs) {
82
+ const deadline = Date.now() + timeoutMs;
83
+ for (;;) {
84
+ const remaining = deadline - Date.now();
85
+ if (remaining <= 0)
86
+ throw new index_js_1.CmuxTimeoutError("attach output not observed");
87
+ const event = await attach.next(remaining);
88
+ if (event.event === "output" || event.event === "resized")
89
+ return event;
90
+ }
91
+ }
92
+ function findWorkspaceForSurface(tree, surface) {
93
+ for (const workspace of tree.workspaces) {
94
+ for (const screen of workspace.screens) {
95
+ for (const pane of screen.panes) {
96
+ if ("tabs" in pane && pane.tabs?.some((tab) => tab.surface === surface))
97
+ return workspace.id;
98
+ }
99
+ }
100
+ }
101
+ return undefined;
102
+ }
103
+ function assert(condition, message) {
104
+ if (!condition)
105
+ throw new Error(message);
106
+ }
107
+ main().catch((err) => {
108
+ console.error(err);
109
+ process.exit(1);
110
+ });
@@ -0,0 +1,70 @@
1
+ import { AttachEvent, ClientOptions, EmptyResult, IdentifyResult, JsonObject, NewBrowserTabOptions, NewScreenOptions, NewTabOptions, NewWorkspaceOptions, ReadScreenResult, SelectOptions, SelectTabOptions, SendOptions, SplitOptions, SubscribeEvent, SurfaceResult, Tree, VtStateResult } from "./types.js";
2
+ type ResponseEnvelope = {
3
+ id?: unknown;
4
+ ok: true;
5
+ data: unknown;
6
+ } | {
7
+ id?: unknown;
8
+ ok: false;
9
+ error: string;
10
+ };
11
+ type EventObject = {
12
+ event: string;
13
+ [key: string]: unknown;
14
+ };
15
+ export declare function defaultSocketPath(session?: string): string;
16
+ export declare class CmuxStream<T extends EventObject> implements AsyncIterable<T> {
17
+ private readonly conn;
18
+ private readonly timeoutMs;
19
+ private readonly buffered;
20
+ private closed;
21
+ private constructor();
22
+ static open<T extends EventObject>(socketPath: string, timeoutMs: number, request: JsonObject): Promise<CmuxStream<T>>;
23
+ next(timeoutMs?: number): Promise<T>;
24
+ close(): void;
25
+ [Symbol.asyncIterator](): AsyncIterator<T>;
26
+ }
27
+ export declare class CmuxClient {
28
+ readonly socketPath: string;
29
+ readonly timeoutMs: number;
30
+ readonly allowProtocolV6Attach: boolean;
31
+ private connPromise;
32
+ private nextRequestId;
33
+ private protocol;
34
+ constructor(options?: ClientOptions);
35
+ close(): Promise<void>;
36
+ sendRaw(obj: JsonObject): Promise<ResponseEnvelope>;
37
+ request(cmd: string, params?: JsonObject): Promise<unknown>;
38
+ identify(): Promise<IdentifyResult>;
39
+ listWorkspaces(): Promise<Tree>;
40
+ send(surface: number, options?: SendOptions): Promise<EmptyResult>;
41
+ readScreen(surface: number): Promise<ReadScreenResult>;
42
+ vtState(surface: number): Promise<VtStateResult>;
43
+ newTab(options?: NewTabOptions): Promise<SurfaceResult>;
44
+ newBrowserTab(url: string, options?: NewBrowserTabOptions): Promise<SurfaceResult>;
45
+ newWorkspace(options?: NewWorkspaceOptions): Promise<SurfaceResult>;
46
+ newScreen(options?: NewScreenOptions): Promise<SurfaceResult>;
47
+ split(pane: number, dir: "right" | "down", options?: SplitOptions): Promise<SurfaceResult>;
48
+ setRatio(pane: number, dir: "right" | "down", ratio: number): Promise<EmptyResult>;
49
+ setDefaultColors(fg?: string, bg?: string): Promise<EmptyResult>;
50
+ closeSurface(surface: number): Promise<EmptyResult>;
51
+ closePane(pane: number): Promise<EmptyResult>;
52
+ closeScreen(screen: number): Promise<EmptyResult>;
53
+ closeWorkspace(workspace: number): Promise<EmptyResult>;
54
+ renamePane(pane: number, name: string): Promise<EmptyResult>;
55
+ renameSurface(surface: number, name: string): Promise<EmptyResult>;
56
+ renameScreen(screen: number, name: string): Promise<EmptyResult>;
57
+ renameWorkspace(workspace: number, name: string): Promise<EmptyResult>;
58
+ resizeSurface(surface: number, cols: number, rows: number): Promise<EmptyResult>;
59
+ focusPane(pane: number): Promise<EmptyResult>;
60
+ selectTab(options?: SelectTabOptions): Promise<EmptyResult>;
61
+ selectScreen(options?: SelectOptions): Promise<EmptyResult>;
62
+ selectWorkspace(options?: SelectOptions): Promise<EmptyResult>;
63
+ moveTab(surface: number, pane: number, index: number): Promise<EmptyResult>;
64
+ moveWorkspace(workspace: number, index: number): Promise<EmptyResult>;
65
+ scrollSurface(surface: number, delta: number): Promise<EmptyResult>;
66
+ subscribe(): Promise<CmuxStream<SubscribeEvent>>;
67
+ attachSurface(surface: number): Promise<CmuxStream<AttachEvent>>;
68
+ private nextId;
69
+ }
70
+ export {};
@@ -0,0 +1,281 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CmuxClient = exports.CmuxStream = void 0;
4
+ exports.defaultSocketPath = defaultSocketPath;
5
+ const node_buffer_1 = require("node:buffer");
6
+ const net = require("node:net");
7
+ const os = require("node:os");
8
+ const path = require("node:path");
9
+ const errors_js_1 = require("./errors.js");
10
+ function defaultSocketPath(session = "main") {
11
+ const base = process.env.TMPDIR || os.tmpdir();
12
+ return path.join(base, `cmux-mux-${process.getuid?.() ?? 0}`, `${session}.sock`);
13
+ }
14
+ class JsonLineConnection {
15
+ socket;
16
+ buffer = "";
17
+ lines = [];
18
+ waiters = [];
19
+ closedError = null;
20
+ constructor(socket) {
21
+ this.socket = socket;
22
+ socket.setEncoding("utf8");
23
+ socket.on("data", (chunk) => this.onData(chunk));
24
+ socket.on("error", (err) => this.closeWith(new errors_js_1.CmuxConnectionError(`socket error: ${err.message}`)));
25
+ socket.on("close", () => this.closeWith(new errors_js_1.CmuxConnectionError("session socket closed")));
26
+ }
27
+ static connect(socketPath) {
28
+ return new Promise((resolve, reject) => {
29
+ const socket = net.createConnection({ path: socketPath });
30
+ socket.once("connect", () => resolve(new JsonLineConnection(socket)));
31
+ socket.once("error", (err) => reject(new errors_js_1.CmuxConnectionError(`cannot connect to session socket ${socketPath}: ${err.message}`)));
32
+ });
33
+ }
34
+ send(value) {
35
+ const line = `${JSON.stringify(value)}\n`;
36
+ return new Promise((resolve, reject) => {
37
+ this.socket.write(line, "utf8", (err) => {
38
+ if (err)
39
+ reject(new errors_js_1.CmuxConnectionError(`socket write failed: ${err.message}`));
40
+ else
41
+ resolve();
42
+ });
43
+ });
44
+ }
45
+ async recv(timeoutMs) {
46
+ const pending = this.nextLine();
47
+ const line = await withTimeout(pending.promise, timeoutMs, "session did not respond", pending.cancel);
48
+ try {
49
+ const value = JSON.parse(line);
50
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
51
+ throw new errors_js_1.CmuxProtocolError("server sent non-object JSON line");
52
+ }
53
+ return value;
54
+ }
55
+ catch (err) {
56
+ if (err instanceof errors_js_1.CmuxProtocolError)
57
+ throw err;
58
+ throw new errors_js_1.CmuxProtocolError(`bad JSON from server: ${err.message}`);
59
+ }
60
+ }
61
+ close() {
62
+ this.socket.destroy();
63
+ }
64
+ nextLine() {
65
+ if (this.lines.length > 0) {
66
+ return { promise: Promise.resolve(this.lines.shift()), cancel: () => undefined };
67
+ }
68
+ if (this.closedError) {
69
+ return { promise: Promise.reject(this.closedError), cancel: () => undefined };
70
+ }
71
+ const waiter = {
72
+ active: true,
73
+ resolve: (_line) => { },
74
+ reject: (_error) => { },
75
+ };
76
+ const promise = new Promise((resolve, reject) => {
77
+ waiter.resolve = resolve;
78
+ waiter.reject = reject;
79
+ });
80
+ this.waiters.push(waiter);
81
+ return {
82
+ promise,
83
+ cancel: () => {
84
+ waiter.active = false;
85
+ },
86
+ };
87
+ }
88
+ onData(chunk) {
89
+ this.buffer += chunk;
90
+ for (;;) {
91
+ const index = this.buffer.indexOf("\n");
92
+ if (index < 0)
93
+ break;
94
+ const line = this.buffer.slice(0, index);
95
+ this.buffer = this.buffer.slice(index + 1);
96
+ if (line.trim() === "")
97
+ continue;
98
+ let delivered = false;
99
+ while (this.waiters.length > 0) {
100
+ const waiter = this.waiters.shift();
101
+ if (!waiter.active)
102
+ continue;
103
+ waiter.resolve(line);
104
+ delivered = true;
105
+ break;
106
+ }
107
+ if (!delivered)
108
+ this.lines.push(line);
109
+ }
110
+ }
111
+ closeWith(error) {
112
+ if (this.closedError)
113
+ return;
114
+ this.closedError = error;
115
+ while (this.waiters.length > 0) {
116
+ const waiter = this.waiters.shift();
117
+ if (waiter.active)
118
+ waiter.reject(error);
119
+ }
120
+ }
121
+ }
122
+ class CmuxStream {
123
+ conn;
124
+ timeoutMs;
125
+ buffered = [];
126
+ closed = false;
127
+ constructor(conn, timeoutMs, buffered) {
128
+ this.conn = conn;
129
+ this.timeoutMs = timeoutMs;
130
+ this.buffered = buffered;
131
+ }
132
+ static async open(socketPath, timeoutMs, request) {
133
+ const conn = await JsonLineConnection.connect(socketPath);
134
+ await conn.send(request);
135
+ const requestId = request.id;
136
+ const buffered = [];
137
+ for (;;) {
138
+ const value = await conn.recv(timeoutMs);
139
+ if (typeof value.event === "string") {
140
+ buffered.push(value);
141
+ continue;
142
+ }
143
+ if (value.id !== requestId)
144
+ continue;
145
+ const response = value;
146
+ if (response.ok === true)
147
+ return new CmuxStream(conn, timeoutMs, buffered);
148
+ throw new errors_js_1.CmuxCommandError(response.error || "unknown error", response.id, response);
149
+ }
150
+ }
151
+ async next(timeoutMs = this.timeoutMs) {
152
+ if (this.closed)
153
+ throw new errors_js_1.CmuxConnectionError("stream is closed");
154
+ if (this.buffered.length > 0)
155
+ return this.buffered.shift();
156
+ for (;;) {
157
+ const value = await this.conn.recv(timeoutMs);
158
+ if (typeof value.event !== "string")
159
+ continue;
160
+ const event = value;
161
+ if (event.event === "detached")
162
+ this.close();
163
+ return event;
164
+ }
165
+ }
166
+ close() {
167
+ if (!this.closed) {
168
+ this.closed = true;
169
+ this.conn.close();
170
+ }
171
+ }
172
+ async *[Symbol.asyncIterator]() {
173
+ while (!this.closed) {
174
+ yield await this.next();
175
+ }
176
+ }
177
+ }
178
+ exports.CmuxStream = CmuxStream;
179
+ class CmuxClient {
180
+ socketPath;
181
+ timeoutMs;
182
+ allowProtocolV6Attach;
183
+ connPromise;
184
+ nextRequestId = 1;
185
+ protocol = null;
186
+ constructor(options = {}) {
187
+ this.socketPath = options.socketPath ?? defaultSocketPath(options.session ?? "main");
188
+ this.timeoutMs = options.timeoutMs ?? 10_000;
189
+ this.allowProtocolV6Attach = options.allowProtocolV6Attach ?? true;
190
+ this.connPromise = JsonLineConnection.connect(this.socketPath);
191
+ }
192
+ async close() {
193
+ const conn = await this.connPromise;
194
+ conn.close();
195
+ }
196
+ async sendRaw(obj) {
197
+ const payload = { ...obj };
198
+ if (!("id" in payload))
199
+ payload.id = this.nextId();
200
+ const requestId = payload.id;
201
+ const conn = await this.connPromise;
202
+ await conn.send(payload);
203
+ for (;;) {
204
+ const response = await conn.recv(this.timeoutMs);
205
+ if (typeof response.event === "string")
206
+ continue;
207
+ if (response.id !== requestId && response.id !== undefined)
208
+ continue;
209
+ return response;
210
+ }
211
+ }
212
+ async request(cmd, params = {}) {
213
+ const response = await this.sendRaw({ id: this.nextId(), cmd, ...dropUndefined(params) });
214
+ if (response.ok === true)
215
+ return response.data;
216
+ throw new errors_js_1.CmuxCommandError(response.error || "unknown error", response.id, response);
217
+ }
218
+ async identify() {
219
+ const result = await this.request("identify");
220
+ this.protocol = result.protocol;
221
+ return result;
222
+ }
223
+ async listWorkspaces() { return this.request("list-workspaces"); }
224
+ async send(surface, options = {}) {
225
+ const bytes = options.bytes instanceof Uint8Array ? node_buffer_1.Buffer.from(options.bytes).toString("base64") : options.bytes;
226
+ await this.request("send", dropUndefined({ surface, text: options.text, bytes }));
227
+ return {};
228
+ }
229
+ async readScreen(surface) { return this.request("read-screen", { surface }); }
230
+ async vtState(surface) { return this.request("vt-state", { surface }); }
231
+ async newTab(options = {}) { return this.request("new-tab", options); }
232
+ async newBrowserTab(url, options = {}) { return this.request("new-browser-tab", dropUndefined({ url, ...options })); }
233
+ async newWorkspace(options = {}) { return this.request("new-workspace", options); }
234
+ async newScreen(options = {}) { return this.request("new-screen", options); }
235
+ async split(pane, dir, options = {}) { return this.request("split", dropUndefined({ pane, dir, ...options })); }
236
+ async setRatio(pane, dir, ratio) { await this.request("set-ratio", { pane, dir, ratio }); return {}; }
237
+ async setDefaultColors(fg, bg) { await this.request("set-default-colors", dropUndefined({ fg, bg })); return {}; }
238
+ async closeSurface(surface) { await this.request("close-surface", { surface }); return {}; }
239
+ async closePane(pane) { await this.request("close-pane", { pane }); return {}; }
240
+ async closeScreen(screen) { await this.request("close-screen", { screen }); return {}; }
241
+ async closeWorkspace(workspace) { await this.request("close-workspace", { workspace }); return {}; }
242
+ async renamePane(pane, name) { await this.request("rename-pane", { pane, name }); return {}; }
243
+ async renameSurface(surface, name) { await this.request("rename-surface", { surface, name }); return {}; }
244
+ async renameScreen(screen, name) { await this.request("rename-screen", { screen, name }); return {}; }
245
+ async renameWorkspace(workspace, name) { await this.request("rename-workspace", { workspace, name }); return {}; }
246
+ async resizeSurface(surface, cols, rows) { await this.request("resize-surface", { surface, cols, rows }); return {}; }
247
+ async focusPane(pane) { await this.request("focus-pane", { pane }); return {}; }
248
+ async selectTab(options = {}) { await this.request("select-tab", options); return {}; }
249
+ async selectScreen(options = {}) { await this.request("select-screen", options); return {}; }
250
+ async selectWorkspace(options = {}) { await this.request("select-workspace", options); return {}; }
251
+ async moveTab(surface, pane, index) { await this.request("move-tab", { surface, pane, index }); return {}; }
252
+ async moveWorkspace(workspace, index) { await this.request("move-workspace", { workspace, index }); return {}; }
253
+ async scrollSurface(surface, delta) { await this.request("scroll-surface", { surface, delta }); return {}; }
254
+ async subscribe() {
255
+ return CmuxStream.open(this.socketPath, this.timeoutMs, { id: this.nextId(), cmd: "subscribe" });
256
+ }
257
+ async attachSurface(surface) {
258
+ const protocol = this.protocol ?? (await this.identify()).protocol;
259
+ if (protocol > 6 || (protocol > 5 && !this.allowProtocolV6Attach)) {
260
+ throw new errors_js_1.CmuxProtocolError(`unsupported attach protocol ${protocol}`);
261
+ }
262
+ return CmuxStream.open(this.socketPath, this.timeoutMs, { id: this.nextId(), cmd: "attach-surface", surface });
263
+ }
264
+ nextId() {
265
+ return this.nextRequestId++;
266
+ }
267
+ }
268
+ exports.CmuxClient = CmuxClient;
269
+ function dropUndefined(value) {
270
+ return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined));
271
+ }
272
+ function withTimeout(promise, timeoutMs, message, onTimeout) {
273
+ let timer;
274
+ const timeout = new Promise((_, reject) => {
275
+ timer = setTimeout(() => {
276
+ onTimeout?.();
277
+ reject(new errors_js_1.CmuxTimeoutError(message));
278
+ }, timeoutMs);
279
+ });
280
+ return Promise.race([promise, timeout]).finally(() => clearTimeout(timer));
281
+ }
@@ -0,0 +1,14 @@
1
+ export declare class CmuxError extends Error {
2
+ constructor(message: string);
3
+ }
4
+ export declare class CmuxCommandError extends CmuxError {
5
+ readonly commandId: unknown;
6
+ readonly response: unknown;
7
+ constructor(message: string, commandId?: unknown, response?: unknown);
8
+ }
9
+ export declare class CmuxConnectionError extends CmuxError {
10
+ }
11
+ export declare class CmuxProtocolError extends CmuxError {
12
+ }
13
+ export declare class CmuxTimeoutError extends CmuxError {
14
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CmuxTimeoutError = exports.CmuxProtocolError = exports.CmuxConnectionError = exports.CmuxCommandError = exports.CmuxError = void 0;
4
+ class CmuxError extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ this.name = new.target.name;
8
+ }
9
+ }
10
+ exports.CmuxError = CmuxError;
11
+ class CmuxCommandError extends CmuxError {
12
+ commandId;
13
+ response;
14
+ constructor(message, commandId, response) {
15
+ super(message);
16
+ this.commandId = commandId;
17
+ this.response = response;
18
+ }
19
+ }
20
+ exports.CmuxCommandError = CmuxCommandError;
21
+ class CmuxConnectionError extends CmuxError {
22
+ }
23
+ exports.CmuxConnectionError = CmuxConnectionError;
24
+ class CmuxProtocolError extends CmuxError {
25
+ }
26
+ exports.CmuxProtocolError = CmuxProtocolError;
27
+ class CmuxTimeoutError extends CmuxError {
28
+ }
29
+ exports.CmuxTimeoutError = CmuxTimeoutError;
@@ -0,0 +1,3 @@
1
+ export * from "./client.js";
2
+ export * from "./errors.js";
3
+ export * from "./types.js";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./client.js"), exports);
18
+ __exportStar(require("./errors.js"), exports);
19
+ __exportStar(require("./types.js"), exports);