adhdev 0.8.50 → 0.8.54
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/dist/cli/index.js +2115 -853
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +1391 -613
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/vendor/session-host-daemon/index.d.mts +3 -0
- package/vendor/session-host-daemon/index.d.ts +3 -0
- package/vendor/session-host-daemon/index.js +33 -2
- package/vendor/session-host-daemon/index.js.map +1 -1
- package/vendor/session-host-daemon/index.mjs +34 -2
- package/vendor/session-host-daemon/index.mjs.map +1 -1
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.d.mts +16 -1
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.d.ts +16 -1
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.js +59 -0
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.js.map +1 -1
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.mjs +54 -0
- package/vendor/session-host-daemon/node_modules/@adhdev/session-host-core/index.mjs.map +1 -1
- package/vendor/terminal-mux-cli/index.d.mts +1 -0
- package/vendor/terminal-mux-cli/index.d.ts +1 -0
- package/vendor/terminal-mux-cli/index.js +2070 -0
- package/vendor/terminal-mux-cli/index.mjs +2062 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.d.mts +442 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.d.ts +442 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.js +676 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.js.map +1 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.mjs +627 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/index.mjs.map +1 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/session-host-core/package.json +7 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/api.d.mts +16 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/api.d.ts +16 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/api.js +206 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/api.mjs +17 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/chunk-7RNMRPVZ.mjs +183 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/chunk-R4EFW6W3.mjs +46 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/chunk-XZWWVN5W.mjs +164 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/control-socket.d.mts +35 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/control-socket.d.ts +35 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/control-socket.js +219 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/control-socket.mjs +13 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/index.d.mts +5 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/index.d.ts +5 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/index.js +427 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/index.mjs +34 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/package.json +33 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/storage.d.mts +49 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/storage.d.ts +49 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/storage.js +222 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-control/storage.mjs +16 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/index.d.mts +164 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/index.d.ts +164 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/index.js +993 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/index.mjs +957 -0
- package/vendor/terminal-mux-cli/node_modules/@adhdev/terminal-mux-core/package.json +7 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/storage.ts
|
|
31
|
+
var storage_exports = {};
|
|
32
|
+
__export(storage_exports, {
|
|
33
|
+
TerminalMuxStorage: () => TerminalMuxStorage,
|
|
34
|
+
buildWorkspaceName: () => buildWorkspaceName,
|
|
35
|
+
getRootDir: () => getRootDir,
|
|
36
|
+
getWorkspaceControlEndpoint: () => getWorkspaceControlEndpoint,
|
|
37
|
+
sanitizeWorkspaceName: () => sanitizeWorkspaceName,
|
|
38
|
+
toWorkspaceRef: () => toWorkspaceRef
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(storage_exports);
|
|
41
|
+
var import_fs = __toESM(require("fs"));
|
|
42
|
+
var import_os = __toESM(require("os"));
|
|
43
|
+
var import_path = __toESM(require("path"));
|
|
44
|
+
function getRootDir() {
|
|
45
|
+
return import_path.default.join(import_os.default.homedir(), ".adhdev", "terminal-mux");
|
|
46
|
+
}
|
|
47
|
+
var WINDOW_MARKER = "--w--";
|
|
48
|
+
function getWorkspacesDir() {
|
|
49
|
+
return import_path.default.join(getRootDir(), "workspaces");
|
|
50
|
+
}
|
|
51
|
+
function getStatePath() {
|
|
52
|
+
return import_path.default.join(getRootDir(), "state.json");
|
|
53
|
+
}
|
|
54
|
+
function sanitizeWorkspaceName(name) {
|
|
55
|
+
return name.trim().replace(/[^a-zA-Z0-9._-]+/g, "-");
|
|
56
|
+
}
|
|
57
|
+
function toWorkspaceRef(name) {
|
|
58
|
+
const workspaceName = sanitizeWorkspaceName(name);
|
|
59
|
+
const markerIndex = workspaceName.indexOf(WINDOW_MARKER);
|
|
60
|
+
if (markerIndex < 0) {
|
|
61
|
+
return {
|
|
62
|
+
sessionName: workspaceName,
|
|
63
|
+
windowName: workspaceName,
|
|
64
|
+
workspaceName
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
sessionName: workspaceName.slice(0, markerIndex),
|
|
69
|
+
windowName: workspaceName.slice(markerIndex + WINDOW_MARKER.length),
|
|
70
|
+
workspaceName
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function buildWorkspaceName(sessionName, windowName) {
|
|
74
|
+
const session = sanitizeWorkspaceName(sessionName);
|
|
75
|
+
const window = sanitizeWorkspaceName(windowName);
|
|
76
|
+
if (!session || session === window) return window;
|
|
77
|
+
return `${session}${WINDOW_MARKER}${window}`;
|
|
78
|
+
}
|
|
79
|
+
function getWorkspaceControlEndpoint(name) {
|
|
80
|
+
const sanitized = sanitizeWorkspaceName(name);
|
|
81
|
+
if (process.platform === "win32") {
|
|
82
|
+
return {
|
|
83
|
+
kind: "pipe",
|
|
84
|
+
path: `\\\\.\\pipe\\adhmux-${sanitized}`
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
kind: "unix",
|
|
89
|
+
path: import_path.default.join(import_os.default.tmpdir(), `adhmux-${sanitized}.sock`)
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
var TerminalMuxStorage = class {
|
|
93
|
+
workspacesDir = getWorkspacesDir();
|
|
94
|
+
statePath = getStatePath();
|
|
95
|
+
listWorkspaceNames() {
|
|
96
|
+
return this.listWorkspaces().map((workspace) => workspace.name);
|
|
97
|
+
}
|
|
98
|
+
listWorkspaces() {
|
|
99
|
+
if (!import_fs.default.existsSync(this.workspacesDir)) return [];
|
|
100
|
+
return import_fs.default.readdirSync(this.workspacesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).flatMap((entry) => {
|
|
101
|
+
const name = entry.name.replace(/\.json$/, "");
|
|
102
|
+
const filePath = this.getWorkspacePath(name);
|
|
103
|
+
let title = name;
|
|
104
|
+
let paneCount = 0;
|
|
105
|
+
let updatedAt = 0;
|
|
106
|
+
try {
|
|
107
|
+
const parsed = JSON.parse(import_fs.default.readFileSync(filePath, "utf8"));
|
|
108
|
+
title = parsed.title || name;
|
|
109
|
+
paneCount = Object.keys(parsed.panes || {}).length;
|
|
110
|
+
updatedAt = import_fs.default.statSync(filePath).mtimeMs;
|
|
111
|
+
} catch {
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
return [{
|
|
115
|
+
name,
|
|
116
|
+
title,
|
|
117
|
+
paneCount,
|
|
118
|
+
updatedAt
|
|
119
|
+
}];
|
|
120
|
+
}).sort((a, b) => b.updatedAt - a.updatedAt || a.name.localeCompare(b.name));
|
|
121
|
+
}
|
|
122
|
+
listSessions() {
|
|
123
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
124
|
+
for (const workspace of this.listWorkspaces()) {
|
|
125
|
+
const ref = toWorkspaceRef(workspace.name);
|
|
126
|
+
const items = grouped.get(ref.sessionName) || [];
|
|
127
|
+
items.push(workspace);
|
|
128
|
+
grouped.set(ref.sessionName, items);
|
|
129
|
+
}
|
|
130
|
+
return Array.from(grouped.entries()).map(([sessionName, workspaces]) => {
|
|
131
|
+
const sorted = [...workspaces].sort((a, b) => b.updatedAt - a.updatedAt || a.name.localeCompare(b.name));
|
|
132
|
+
const active = sorted[0];
|
|
133
|
+
return {
|
|
134
|
+
name: sessionName,
|
|
135
|
+
title: toWorkspaceRef(active.name).sessionName,
|
|
136
|
+
windowCount: workspaces.length,
|
|
137
|
+
updatedAt: active.updatedAt,
|
|
138
|
+
activeWindowName: toWorkspaceRef(active.name).windowName
|
|
139
|
+
};
|
|
140
|
+
}).sort((a, b) => b.updatedAt - a.updatedAt || a.name.localeCompare(b.name));
|
|
141
|
+
}
|
|
142
|
+
listSessionWindows(sessionName) {
|
|
143
|
+
const normalizedSession = sanitizeWorkspaceName(sessionName);
|
|
144
|
+
return this.listWorkspaces().filter((workspace) => toWorkspaceRef(workspace.name).sessionName === normalizedSession);
|
|
145
|
+
}
|
|
146
|
+
resolveSessionWindowWorkspace(sessionName, windowName) {
|
|
147
|
+
const windows = this.listSessionWindows(sessionName);
|
|
148
|
+
if (windows.length === 0) return null;
|
|
149
|
+
if (!windowName) return windows[0].name;
|
|
150
|
+
const normalizedWindow = sanitizeWorkspaceName(windowName);
|
|
151
|
+
const exact = windows.find((workspace) => toWorkspaceRef(workspace.name).windowName === normalizedWindow);
|
|
152
|
+
return exact?.name || null;
|
|
153
|
+
}
|
|
154
|
+
loadWorkspace(name) {
|
|
155
|
+
const filePath = this.getWorkspacePath(name);
|
|
156
|
+
if (!import_fs.default.existsSync(filePath)) return null;
|
|
157
|
+
const parsed = JSON.parse(import_fs.default.readFileSync(filePath, "utf8"));
|
|
158
|
+
return parsed?.workspaceId ? parsed : null;
|
|
159
|
+
}
|
|
160
|
+
saveWorkspace(name, workspace) {
|
|
161
|
+
import_fs.default.mkdirSync(this.workspacesDir, { recursive: true });
|
|
162
|
+
import_fs.default.writeFileSync(this.getWorkspacePath(name), JSON.stringify(workspace, null, 2), "utf8");
|
|
163
|
+
}
|
|
164
|
+
renameWorkspace(fromName, toName) {
|
|
165
|
+
const fromPath = this.getWorkspacePath(fromName);
|
|
166
|
+
const toPath = this.getWorkspacePath(toName);
|
|
167
|
+
if (!import_fs.default.existsSync(fromPath)) {
|
|
168
|
+
throw new Error(`Workspace not found: ${fromName}`);
|
|
169
|
+
}
|
|
170
|
+
import_fs.default.mkdirSync(this.workspacesDir, { recursive: true });
|
|
171
|
+
import_fs.default.renameSync(fromPath, toPath);
|
|
172
|
+
}
|
|
173
|
+
deleteWorkspace(name) {
|
|
174
|
+
const filePath = this.getWorkspacePath(name);
|
|
175
|
+
if (!import_fs.default.existsSync(filePath)) {
|
|
176
|
+
throw new Error(`Workspace not found: ${name}`);
|
|
177
|
+
}
|
|
178
|
+
import_fs.default.unlinkSync(filePath);
|
|
179
|
+
const state = this.loadClientState();
|
|
180
|
+
if (state.lastWorkspace === sanitizeWorkspaceName(name)) {
|
|
181
|
+
this.saveClientState({ ...state, lastWorkspace: void 0, updatedAt: Date.now() });
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
getLastWorkspace() {
|
|
185
|
+
const state = this.loadClientState();
|
|
186
|
+
return state.lastWorkspace || null;
|
|
187
|
+
}
|
|
188
|
+
setLastWorkspace(name) {
|
|
189
|
+
this.saveClientState({
|
|
190
|
+
...this.loadClientState(),
|
|
191
|
+
lastWorkspace: sanitizeWorkspaceName(name),
|
|
192
|
+
updatedAt: Date.now()
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
getWorkspacePath(name) {
|
|
196
|
+
return import_path.default.join(this.workspacesDir, `${sanitizeWorkspaceName(name)}.json`);
|
|
197
|
+
}
|
|
198
|
+
loadClientState() {
|
|
199
|
+
if (!import_fs.default.existsSync(this.statePath)) {
|
|
200
|
+
return { updatedAt: 0 };
|
|
201
|
+
}
|
|
202
|
+
try {
|
|
203
|
+
const parsed = JSON.parse(import_fs.default.readFileSync(this.statePath, "utf8"));
|
|
204
|
+
return typeof parsed === "object" && parsed ? parsed : { updatedAt: 0 };
|
|
205
|
+
} catch {
|
|
206
|
+
return { updatedAt: 0 };
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
saveClientState(state) {
|
|
210
|
+
import_fs.default.mkdirSync(getRootDir(), { recursive: true });
|
|
211
|
+
import_fs.default.writeFileSync(this.statePath, JSON.stringify(state, null, 2), "utf8");
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
215
|
+
0 && (module.exports = {
|
|
216
|
+
TerminalMuxStorage,
|
|
217
|
+
buildWorkspaceName,
|
|
218
|
+
getRootDir,
|
|
219
|
+
getWorkspaceControlEndpoint,
|
|
220
|
+
sanitizeWorkspaceName,
|
|
221
|
+
toWorkspaceRef
|
|
222
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TerminalMuxStorage,
|
|
3
|
+
buildWorkspaceName,
|
|
4
|
+
getRootDir,
|
|
5
|
+
getWorkspaceControlEndpoint,
|
|
6
|
+
sanitizeWorkspaceName,
|
|
7
|
+
toWorkspaceRef
|
|
8
|
+
} from "./chunk-7RNMRPVZ.mjs";
|
|
9
|
+
export {
|
|
10
|
+
TerminalMuxStorage,
|
|
11
|
+
buildWorkspaceName,
|
|
12
|
+
getRootDir,
|
|
13
|
+
getWorkspaceControlEndpoint,
|
|
14
|
+
sanitizeWorkspaceName,
|
|
15
|
+
toWorkspaceRef
|
|
16
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { SessionHostRecord, SessionWriteOwner, SessionAttachedClient, SessionHostEvent, SessionHostClientOptions } from '@adhdev/session-host-core';
|
|
2
|
+
|
|
3
|
+
type MuxAxis = 'horizontal' | 'vertical';
|
|
4
|
+
type PaneAccessMode = 'interactive' | 'read-only';
|
|
5
|
+
type MuxPaneKind = 'runtime' | 'mirror';
|
|
6
|
+
type MuxLayoutPreset = 'even' | 'main-vertical' | 'main-horizontal' | 'tiled';
|
|
7
|
+
interface TerminalViewportState {
|
|
8
|
+
cols: number;
|
|
9
|
+
rows: number;
|
|
10
|
+
snapshotSeq: number;
|
|
11
|
+
text: string;
|
|
12
|
+
}
|
|
13
|
+
interface RuntimePaneState {
|
|
14
|
+
paneId: string;
|
|
15
|
+
paneKind: MuxPaneKind;
|
|
16
|
+
runtimeId: string;
|
|
17
|
+
runtimeKey: string;
|
|
18
|
+
displayName: string;
|
|
19
|
+
workspaceLabel: string;
|
|
20
|
+
accessMode: PaneAccessMode;
|
|
21
|
+
lifecycle: SessionHostRecord['lifecycle'];
|
|
22
|
+
writeOwner: SessionWriteOwner | null;
|
|
23
|
+
attachedClients: SessionAttachedClient[];
|
|
24
|
+
viewport: TerminalViewportState;
|
|
25
|
+
}
|
|
26
|
+
type MuxLayoutNode = {
|
|
27
|
+
type: 'pane';
|
|
28
|
+
paneId: string;
|
|
29
|
+
} | {
|
|
30
|
+
type: 'split';
|
|
31
|
+
axis: MuxAxis;
|
|
32
|
+
ratio: number;
|
|
33
|
+
first: MuxLayoutNode;
|
|
34
|
+
second: MuxLayoutNode;
|
|
35
|
+
};
|
|
36
|
+
interface MuxWorkspaceState {
|
|
37
|
+
workspaceId: string;
|
|
38
|
+
title: string;
|
|
39
|
+
root: MuxLayoutNode;
|
|
40
|
+
focusedPaneId: string;
|
|
41
|
+
zoomedPaneId?: string | null;
|
|
42
|
+
panes: Record<string, RuntimePaneState>;
|
|
43
|
+
}
|
|
44
|
+
interface OpenRuntimeOptions {
|
|
45
|
+
readOnly?: boolean;
|
|
46
|
+
takeover?: boolean;
|
|
47
|
+
cols?: number;
|
|
48
|
+
rows?: number;
|
|
49
|
+
paneId?: string;
|
|
50
|
+
}
|
|
51
|
+
interface CreateWorkspaceOptions extends OpenRuntimeOptions {
|
|
52
|
+
workspaceId?: string;
|
|
53
|
+
title?: string;
|
|
54
|
+
}
|
|
55
|
+
interface SplitPaneOptions extends OpenRuntimeOptions {
|
|
56
|
+
axis: MuxAxis;
|
|
57
|
+
}
|
|
58
|
+
interface RuntimePaneUpdate {
|
|
59
|
+
kind: 'runtime';
|
|
60
|
+
pane: RuntimePaneState;
|
|
61
|
+
event?: SessionHostEvent;
|
|
62
|
+
}
|
|
63
|
+
interface WorkspaceUpdate {
|
|
64
|
+
kind: 'workspace';
|
|
65
|
+
workspace: MuxWorkspaceState;
|
|
66
|
+
}
|
|
67
|
+
type MuxControllerEvent = RuntimePaneUpdate | WorkspaceUpdate;
|
|
68
|
+
interface PersistedMuxWorkspaceState {
|
|
69
|
+
workspaceId: string;
|
|
70
|
+
title: string;
|
|
71
|
+
focusedPaneId: string;
|
|
72
|
+
zoomedPaneId?: string | null;
|
|
73
|
+
root: MuxLayoutNode;
|
|
74
|
+
panes: Record<string, {
|
|
75
|
+
runtimeId?: string;
|
|
76
|
+
runtimeKey: string;
|
|
77
|
+
paneKind: MuxPaneKind;
|
|
78
|
+
accessMode: PaneAccessMode;
|
|
79
|
+
}>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
type ResizeDirection = 'left' | 'right' | 'up' | 'down';
|
|
83
|
+
declare function createMuxWorkspace(initialPane: RuntimePaneState, options?: {
|
|
84
|
+
workspaceId?: string;
|
|
85
|
+
title?: string;
|
|
86
|
+
}): MuxWorkspaceState;
|
|
87
|
+
declare function splitMuxPane(workspace: MuxWorkspaceState, targetPaneId: string, axis: MuxAxis, nextPane: RuntimePaneState): MuxWorkspaceState;
|
|
88
|
+
declare function removeMuxPane(workspace: MuxWorkspaceState, paneId: string): MuxWorkspaceState | null;
|
|
89
|
+
declare function focusMuxPane(workspace: MuxWorkspaceState, paneId: string): MuxWorkspaceState;
|
|
90
|
+
declare function updateMuxPane(workspace: MuxWorkspaceState, pane: RuntimePaneState): MuxWorkspaceState;
|
|
91
|
+
declare function toggleMuxPaneZoom(workspace: MuxWorkspaceState, paneId: string): MuxWorkspaceState;
|
|
92
|
+
declare function resizeMuxPane(workspace: MuxWorkspaceState, paneId: string, direction: ResizeDirection, amount?: number): MuxWorkspaceState;
|
|
93
|
+
declare function rebalanceMuxLayout(workspace: MuxWorkspaceState): MuxWorkspaceState;
|
|
94
|
+
declare function swapMuxPanePositions(workspace: MuxWorkspaceState, firstPaneId: string, secondPaneId: string): MuxWorkspaceState;
|
|
95
|
+
declare function applyMuxLayoutPreset(workspace: MuxWorkspaceState, preset: MuxLayoutPreset): MuxWorkspaceState;
|
|
96
|
+
|
|
97
|
+
interface GhosttyTerminalSurfaceOptions {
|
|
98
|
+
cols?: number;
|
|
99
|
+
rows?: number;
|
|
100
|
+
scrollback?: number;
|
|
101
|
+
}
|
|
102
|
+
declare class GhosttyTerminalSurface {
|
|
103
|
+
private terminal;
|
|
104
|
+
private cols;
|
|
105
|
+
private rows;
|
|
106
|
+
private snapshotSeq;
|
|
107
|
+
constructor(options?: GhosttyTerminalSurfaceOptions);
|
|
108
|
+
resetFromText(text: string, snapshotSeq?: number): void;
|
|
109
|
+
write(data: string, snapshotSeq?: number): void;
|
|
110
|
+
resize(cols: number, rows: number): void;
|
|
111
|
+
getViewportState(): TerminalViewportState;
|
|
112
|
+
dispose(): void;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
declare function resolveMuxOpenRuntimeRecord(records: SessionHostRecord[], identifier: string): SessionHostRecord;
|
|
116
|
+
|
|
117
|
+
declare class SessionHostMuxClient {
|
|
118
|
+
readonly clientId: string;
|
|
119
|
+
readonly clientType = "local-terminal";
|
|
120
|
+
private client;
|
|
121
|
+
private paneById;
|
|
122
|
+
private paneIdsByRuntime;
|
|
123
|
+
private workspaceById;
|
|
124
|
+
private listeners;
|
|
125
|
+
private unsubEvents;
|
|
126
|
+
constructor(options?: SessionHostClientOptions & {
|
|
127
|
+
clientId?: string;
|
|
128
|
+
});
|
|
129
|
+
connect(): Promise<void>;
|
|
130
|
+
onEvent(listener: (event: MuxControllerEvent) => void): () => void;
|
|
131
|
+
createWorkspace(target: string, options?: CreateWorkspaceOptions): Promise<MuxWorkspaceState>;
|
|
132
|
+
splitWorkspacePane(workspaceId: string, targetPaneId: string, runtimeTarget: string, options: SplitPaneOptions): Promise<MuxWorkspaceState>;
|
|
133
|
+
splitWorkspaceMirror(workspaceId: string, targetPaneId: string, sourcePaneId: string, axis: SplitPaneOptions['axis']): Promise<MuxWorkspaceState>;
|
|
134
|
+
replacePaneRuntime(workspaceId: string, paneId: string, runtimeTarget: string, options?: OpenRuntimeOptions): Promise<MuxWorkspaceState>;
|
|
135
|
+
restoreWorkspace(snapshot: PersistedMuxWorkspaceState): Promise<MuxWorkspaceState>;
|
|
136
|
+
closePane(workspaceId: string, paneId: string): Promise<MuxWorkspaceState | null>;
|
|
137
|
+
focusPane(workspaceId: string, paneId: string): Promise<MuxWorkspaceState>;
|
|
138
|
+
resizeLayoutPane(workspaceId: string, paneId: string, direction: 'left' | 'right' | 'up' | 'down', amount?: number): Promise<MuxWorkspaceState>;
|
|
139
|
+
rebalanceWorkspaceLayout(workspaceId: string): Promise<MuxWorkspaceState>;
|
|
140
|
+
applyLayoutPreset(workspaceId: string, preset: MuxLayoutPreset): Promise<MuxWorkspaceState>;
|
|
141
|
+
swapPanePositions(workspaceId: string, firstPaneId: string, secondPaneId: string): Promise<MuxWorkspaceState>;
|
|
142
|
+
togglePaneZoom(workspaceId: string, paneId: string): Promise<MuxWorkspaceState>;
|
|
143
|
+
sendInput(paneId: string, data: string): Promise<void>;
|
|
144
|
+
resizePane(paneId: string, cols: number, rows: number): Promise<void>;
|
|
145
|
+
takeoverPane(paneId: string): Promise<void>;
|
|
146
|
+
releasePane(paneId: string): Promise<void>;
|
|
147
|
+
listWorkspaces(): MuxWorkspaceState[];
|
|
148
|
+
listRuntimes(): Promise<SessionHostRecord[]>;
|
|
149
|
+
resumeRuntime(target: string): Promise<SessionHostRecord>;
|
|
150
|
+
serializeWorkspace(workspaceId: string): PersistedMuxWorkspaceState;
|
|
151
|
+
close(): Promise<void>;
|
|
152
|
+
private openRuntime;
|
|
153
|
+
private openMirrorRuntime;
|
|
154
|
+
private handleHostEvent;
|
|
155
|
+
private publishPaneUpdate;
|
|
156
|
+
private emit;
|
|
157
|
+
private requireWorkspace;
|
|
158
|
+
private requirePane;
|
|
159
|
+
private computeAccessMode;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
declare function serializeWorkspace(workspace: MuxWorkspaceState): PersistedMuxWorkspaceState;
|
|
163
|
+
|
|
164
|
+
export { type CreateWorkspaceOptions, GhosttyTerminalSurface, type GhosttyTerminalSurfaceOptions, type MuxAxis, type MuxControllerEvent, type MuxLayoutNode, type MuxLayoutPreset, type MuxWorkspaceState, type OpenRuntimeOptions, type PaneAccessMode, type PersistedMuxWorkspaceState, type RuntimePaneState, SessionHostMuxClient, type SplitPaneOptions, type TerminalViewportState, applyMuxLayoutPreset, createMuxWorkspace, focusMuxPane, rebalanceMuxLayout, removeMuxPane, resizeMuxPane, resolveMuxOpenRuntimeRecord, serializeWorkspace, splitMuxPane, swapMuxPanePositions, toggleMuxPaneZoom, updateMuxPane };
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { SessionHostRecord, SessionWriteOwner, SessionAttachedClient, SessionHostEvent, SessionHostClientOptions } from '@adhdev/session-host-core';
|
|
2
|
+
|
|
3
|
+
type MuxAxis = 'horizontal' | 'vertical';
|
|
4
|
+
type PaneAccessMode = 'interactive' | 'read-only';
|
|
5
|
+
type MuxPaneKind = 'runtime' | 'mirror';
|
|
6
|
+
type MuxLayoutPreset = 'even' | 'main-vertical' | 'main-horizontal' | 'tiled';
|
|
7
|
+
interface TerminalViewportState {
|
|
8
|
+
cols: number;
|
|
9
|
+
rows: number;
|
|
10
|
+
snapshotSeq: number;
|
|
11
|
+
text: string;
|
|
12
|
+
}
|
|
13
|
+
interface RuntimePaneState {
|
|
14
|
+
paneId: string;
|
|
15
|
+
paneKind: MuxPaneKind;
|
|
16
|
+
runtimeId: string;
|
|
17
|
+
runtimeKey: string;
|
|
18
|
+
displayName: string;
|
|
19
|
+
workspaceLabel: string;
|
|
20
|
+
accessMode: PaneAccessMode;
|
|
21
|
+
lifecycle: SessionHostRecord['lifecycle'];
|
|
22
|
+
writeOwner: SessionWriteOwner | null;
|
|
23
|
+
attachedClients: SessionAttachedClient[];
|
|
24
|
+
viewport: TerminalViewportState;
|
|
25
|
+
}
|
|
26
|
+
type MuxLayoutNode = {
|
|
27
|
+
type: 'pane';
|
|
28
|
+
paneId: string;
|
|
29
|
+
} | {
|
|
30
|
+
type: 'split';
|
|
31
|
+
axis: MuxAxis;
|
|
32
|
+
ratio: number;
|
|
33
|
+
first: MuxLayoutNode;
|
|
34
|
+
second: MuxLayoutNode;
|
|
35
|
+
};
|
|
36
|
+
interface MuxWorkspaceState {
|
|
37
|
+
workspaceId: string;
|
|
38
|
+
title: string;
|
|
39
|
+
root: MuxLayoutNode;
|
|
40
|
+
focusedPaneId: string;
|
|
41
|
+
zoomedPaneId?: string | null;
|
|
42
|
+
panes: Record<string, RuntimePaneState>;
|
|
43
|
+
}
|
|
44
|
+
interface OpenRuntimeOptions {
|
|
45
|
+
readOnly?: boolean;
|
|
46
|
+
takeover?: boolean;
|
|
47
|
+
cols?: number;
|
|
48
|
+
rows?: number;
|
|
49
|
+
paneId?: string;
|
|
50
|
+
}
|
|
51
|
+
interface CreateWorkspaceOptions extends OpenRuntimeOptions {
|
|
52
|
+
workspaceId?: string;
|
|
53
|
+
title?: string;
|
|
54
|
+
}
|
|
55
|
+
interface SplitPaneOptions extends OpenRuntimeOptions {
|
|
56
|
+
axis: MuxAxis;
|
|
57
|
+
}
|
|
58
|
+
interface RuntimePaneUpdate {
|
|
59
|
+
kind: 'runtime';
|
|
60
|
+
pane: RuntimePaneState;
|
|
61
|
+
event?: SessionHostEvent;
|
|
62
|
+
}
|
|
63
|
+
interface WorkspaceUpdate {
|
|
64
|
+
kind: 'workspace';
|
|
65
|
+
workspace: MuxWorkspaceState;
|
|
66
|
+
}
|
|
67
|
+
type MuxControllerEvent = RuntimePaneUpdate | WorkspaceUpdate;
|
|
68
|
+
interface PersistedMuxWorkspaceState {
|
|
69
|
+
workspaceId: string;
|
|
70
|
+
title: string;
|
|
71
|
+
focusedPaneId: string;
|
|
72
|
+
zoomedPaneId?: string | null;
|
|
73
|
+
root: MuxLayoutNode;
|
|
74
|
+
panes: Record<string, {
|
|
75
|
+
runtimeId?: string;
|
|
76
|
+
runtimeKey: string;
|
|
77
|
+
paneKind: MuxPaneKind;
|
|
78
|
+
accessMode: PaneAccessMode;
|
|
79
|
+
}>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
type ResizeDirection = 'left' | 'right' | 'up' | 'down';
|
|
83
|
+
declare function createMuxWorkspace(initialPane: RuntimePaneState, options?: {
|
|
84
|
+
workspaceId?: string;
|
|
85
|
+
title?: string;
|
|
86
|
+
}): MuxWorkspaceState;
|
|
87
|
+
declare function splitMuxPane(workspace: MuxWorkspaceState, targetPaneId: string, axis: MuxAxis, nextPane: RuntimePaneState): MuxWorkspaceState;
|
|
88
|
+
declare function removeMuxPane(workspace: MuxWorkspaceState, paneId: string): MuxWorkspaceState | null;
|
|
89
|
+
declare function focusMuxPane(workspace: MuxWorkspaceState, paneId: string): MuxWorkspaceState;
|
|
90
|
+
declare function updateMuxPane(workspace: MuxWorkspaceState, pane: RuntimePaneState): MuxWorkspaceState;
|
|
91
|
+
declare function toggleMuxPaneZoom(workspace: MuxWorkspaceState, paneId: string): MuxWorkspaceState;
|
|
92
|
+
declare function resizeMuxPane(workspace: MuxWorkspaceState, paneId: string, direction: ResizeDirection, amount?: number): MuxWorkspaceState;
|
|
93
|
+
declare function rebalanceMuxLayout(workspace: MuxWorkspaceState): MuxWorkspaceState;
|
|
94
|
+
declare function swapMuxPanePositions(workspace: MuxWorkspaceState, firstPaneId: string, secondPaneId: string): MuxWorkspaceState;
|
|
95
|
+
declare function applyMuxLayoutPreset(workspace: MuxWorkspaceState, preset: MuxLayoutPreset): MuxWorkspaceState;
|
|
96
|
+
|
|
97
|
+
interface GhosttyTerminalSurfaceOptions {
|
|
98
|
+
cols?: number;
|
|
99
|
+
rows?: number;
|
|
100
|
+
scrollback?: number;
|
|
101
|
+
}
|
|
102
|
+
declare class GhosttyTerminalSurface {
|
|
103
|
+
private terminal;
|
|
104
|
+
private cols;
|
|
105
|
+
private rows;
|
|
106
|
+
private snapshotSeq;
|
|
107
|
+
constructor(options?: GhosttyTerminalSurfaceOptions);
|
|
108
|
+
resetFromText(text: string, snapshotSeq?: number): void;
|
|
109
|
+
write(data: string, snapshotSeq?: number): void;
|
|
110
|
+
resize(cols: number, rows: number): void;
|
|
111
|
+
getViewportState(): TerminalViewportState;
|
|
112
|
+
dispose(): void;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
declare function resolveMuxOpenRuntimeRecord(records: SessionHostRecord[], identifier: string): SessionHostRecord;
|
|
116
|
+
|
|
117
|
+
declare class SessionHostMuxClient {
|
|
118
|
+
readonly clientId: string;
|
|
119
|
+
readonly clientType = "local-terminal";
|
|
120
|
+
private client;
|
|
121
|
+
private paneById;
|
|
122
|
+
private paneIdsByRuntime;
|
|
123
|
+
private workspaceById;
|
|
124
|
+
private listeners;
|
|
125
|
+
private unsubEvents;
|
|
126
|
+
constructor(options?: SessionHostClientOptions & {
|
|
127
|
+
clientId?: string;
|
|
128
|
+
});
|
|
129
|
+
connect(): Promise<void>;
|
|
130
|
+
onEvent(listener: (event: MuxControllerEvent) => void): () => void;
|
|
131
|
+
createWorkspace(target: string, options?: CreateWorkspaceOptions): Promise<MuxWorkspaceState>;
|
|
132
|
+
splitWorkspacePane(workspaceId: string, targetPaneId: string, runtimeTarget: string, options: SplitPaneOptions): Promise<MuxWorkspaceState>;
|
|
133
|
+
splitWorkspaceMirror(workspaceId: string, targetPaneId: string, sourcePaneId: string, axis: SplitPaneOptions['axis']): Promise<MuxWorkspaceState>;
|
|
134
|
+
replacePaneRuntime(workspaceId: string, paneId: string, runtimeTarget: string, options?: OpenRuntimeOptions): Promise<MuxWorkspaceState>;
|
|
135
|
+
restoreWorkspace(snapshot: PersistedMuxWorkspaceState): Promise<MuxWorkspaceState>;
|
|
136
|
+
closePane(workspaceId: string, paneId: string): Promise<MuxWorkspaceState | null>;
|
|
137
|
+
focusPane(workspaceId: string, paneId: string): Promise<MuxWorkspaceState>;
|
|
138
|
+
resizeLayoutPane(workspaceId: string, paneId: string, direction: 'left' | 'right' | 'up' | 'down', amount?: number): Promise<MuxWorkspaceState>;
|
|
139
|
+
rebalanceWorkspaceLayout(workspaceId: string): Promise<MuxWorkspaceState>;
|
|
140
|
+
applyLayoutPreset(workspaceId: string, preset: MuxLayoutPreset): Promise<MuxWorkspaceState>;
|
|
141
|
+
swapPanePositions(workspaceId: string, firstPaneId: string, secondPaneId: string): Promise<MuxWorkspaceState>;
|
|
142
|
+
togglePaneZoom(workspaceId: string, paneId: string): Promise<MuxWorkspaceState>;
|
|
143
|
+
sendInput(paneId: string, data: string): Promise<void>;
|
|
144
|
+
resizePane(paneId: string, cols: number, rows: number): Promise<void>;
|
|
145
|
+
takeoverPane(paneId: string): Promise<void>;
|
|
146
|
+
releasePane(paneId: string): Promise<void>;
|
|
147
|
+
listWorkspaces(): MuxWorkspaceState[];
|
|
148
|
+
listRuntimes(): Promise<SessionHostRecord[]>;
|
|
149
|
+
resumeRuntime(target: string): Promise<SessionHostRecord>;
|
|
150
|
+
serializeWorkspace(workspaceId: string): PersistedMuxWorkspaceState;
|
|
151
|
+
close(): Promise<void>;
|
|
152
|
+
private openRuntime;
|
|
153
|
+
private openMirrorRuntime;
|
|
154
|
+
private handleHostEvent;
|
|
155
|
+
private publishPaneUpdate;
|
|
156
|
+
private emit;
|
|
157
|
+
private requireWorkspace;
|
|
158
|
+
private requirePane;
|
|
159
|
+
private computeAccessMode;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
declare function serializeWorkspace(workspace: MuxWorkspaceState): PersistedMuxWorkspaceState;
|
|
163
|
+
|
|
164
|
+
export { type CreateWorkspaceOptions, GhosttyTerminalSurface, type GhosttyTerminalSurfaceOptions, type MuxAxis, type MuxControllerEvent, type MuxLayoutNode, type MuxLayoutPreset, type MuxWorkspaceState, type OpenRuntimeOptions, type PaneAccessMode, type PersistedMuxWorkspaceState, type RuntimePaneState, SessionHostMuxClient, type SplitPaneOptions, type TerminalViewportState, applyMuxLayoutPreset, createMuxWorkspace, focusMuxPane, rebalanceMuxLayout, removeMuxPane, resizeMuxPane, resolveMuxOpenRuntimeRecord, serializeWorkspace, splitMuxPane, swapMuxPanePositions, toggleMuxPaneZoom, updateMuxPane };
|