@anhlp/alp-daemon 0.0.0-stage → 0.0.1-beta.4
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/LICENSE +202 -0
- package/NOTICE +7 -0
- package/README.md +14 -2
- package/dist/THIRD-PARTY-NOTICES.txt +431 -0
- package/dist/alp-templates.d.ts +5 -0
- package/dist/alpd.js +49562 -0
- package/dist/attachments.d.ts +211 -0
- package/dist/attachments.js +819 -0
- package/dist/build-manifest.json +131 -0
- package/dist/conversation.d.ts +119 -0
- package/dist/conversation.js +672 -0
- package/dist/files.d.ts +123 -0
- package/dist/files.js +365 -0
- package/dist/git.d.ts +87 -0
- package/dist/git.js +1093 -0
- package/dist/gitignore.d.ts +62 -0
- package/dist/gitignore.js +254 -0
- package/dist/history.d.ts +24 -0
- package/dist/history.js +149 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +25 -0
- package/dist/lifecycle.d.ts +101 -0
- package/dist/lifecycle.js +239 -0
- package/dist/lock.d.ts +21 -0
- package/dist/lock.js +42 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +277 -0
- package/dist/operations.d.ts +23 -0
- package/dist/operations.js +275 -0
- package/dist/registry.d.ts +89 -0
- package/dist/registry.js +343 -0
- package/dist/rpc-error.d.ts +6 -0
- package/dist/rpc-error.js +11 -0
- package/dist/scheduler.d.ts +96 -0
- package/dist/scheduler.js +290 -0
- package/dist/schedules.d.ts +69 -0
- package/dist/schedules.js +244 -0
- package/dist/server.d.ts +58 -0
- package/dist/server.js +1780 -0
- package/dist/store.d.ts +176 -0
- package/dist/store.js +385 -0
- package/dist/terminals.d.ts +157 -0
- package/dist/terminals.js +487 -0
- package/dist/worktrees.d.ts +41 -0
- package/dist/worktrees.js +246 -0
- package/package.json +159 -4
- package/src/alp-templates.d.ts +5 -0
- package/src/attachments.ts +870 -0
- package/src/conversation.ts +837 -0
- package/src/files.ts +459 -0
- package/src/git.ts +1045 -0
- package/src/gitignore.ts +277 -0
- package/src/history.ts +118 -0
- package/src/index.ts +11 -0
- package/src/lifecycle.ts +283 -0
- package/src/lock.ts +53 -0
- package/src/main.ts +292 -0
- package/src/operations.ts +300 -0
- package/src/registry.ts +238 -0
- package/src/rpc-error.ts +4 -0
- package/src/scheduler.ts +422 -0
- package/src/schedules.ts +294 -0
- package/src/server.ts +2056 -0
- package/src/store.ts +448 -0
- package/src/terminals.ts +591 -0
- package/src/worktrees.ts +287 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { TerminalInfo, TerminalLimits } from '@anhlp/alp-protocol/rpc';
|
|
2
|
+
/**
|
|
3
|
+
* Terminals (capability `terminal`, docs/protocol/alp-json-rpc-v1.md §12.10, issue #121 H): a real
|
|
4
|
+
* PTY running a shell on this host **as the daemon's account**. A workspace chooses only where the
|
|
5
|
+
* shell starts and who sees the terminal; it is not a sandbox. alpd serves terminals only while the
|
|
6
|
+
* host owner opted in (`<ALP_HOME>/terminal.json` `allowRemoteTerminal`, an owner-private file no RPC
|
|
7
|
+
* writes), on macOS and Linux, when the optional `node-pty` module loads. Lifecycle is audited;
|
|
8
|
+
* input, output and the environment never are.
|
|
9
|
+
*/
|
|
10
|
+
/** Who a call acts for, as for attachments: a gateway's credential and grant epoch, or the owner. */
|
|
11
|
+
export type TerminalPrincipal = {
|
|
12
|
+
id: string;
|
|
13
|
+
epoch: string;
|
|
14
|
+
roots?: readonly string[];
|
|
15
|
+
};
|
|
16
|
+
/** The connection a terminal streams to: alpd's own IPC connection object. */
|
|
17
|
+
export type TerminalSink = {
|
|
18
|
+
send(message: unknown): void;
|
|
19
|
+
socket?: {
|
|
20
|
+
writableLength: number;
|
|
21
|
+
destroyed?: boolean;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
type Disposable = {
|
|
25
|
+
dispose(): void;
|
|
26
|
+
};
|
|
27
|
+
/** What alpd uses of a node-pty process. */
|
|
28
|
+
export type PtyProcess = {
|
|
29
|
+
pid: number;
|
|
30
|
+
/** The PTY's device (node-pty's UnixTerminal), such as /dev/ttys004 or /dev/pts/3. */
|
|
31
|
+
readonly ptsName?: string;
|
|
32
|
+
write(data: string): void;
|
|
33
|
+
resize(cols: number, rows: number): void;
|
|
34
|
+
kill(signal?: string): void;
|
|
35
|
+
onData(listener: (data: string) => void): Disposable;
|
|
36
|
+
onExit(listener: (event: {
|
|
37
|
+
exitCode: number;
|
|
38
|
+
signal?: number;
|
|
39
|
+
}) => void): Disposable;
|
|
40
|
+
};
|
|
41
|
+
export type PtySpawn = (file: string, args: string[], options: {
|
|
42
|
+
name: string;
|
|
43
|
+
cols: number;
|
|
44
|
+
rows: number;
|
|
45
|
+
cwd: string;
|
|
46
|
+
env: Record<string, string>;
|
|
47
|
+
}) => PtyProcess;
|
|
48
|
+
/** One process: ids, (Linux) session, controlling tty, age, and the terminal markers in its environment. */
|
|
49
|
+
export type ProcessRow = {
|
|
50
|
+
pid: number;
|
|
51
|
+
ppid: number;
|
|
52
|
+
pgid: number;
|
|
53
|
+
sid?: number;
|
|
54
|
+
tty?: string;
|
|
55
|
+
elapsedMs: number;
|
|
56
|
+
markers?: string[];
|
|
57
|
+
};
|
|
58
|
+
type Log = {
|
|
59
|
+
info(message: string, fields?: Record<string, unknown>): void;
|
|
60
|
+
warn(message: string, fields?: Record<string, unknown>): void;
|
|
61
|
+
};
|
|
62
|
+
export type TerminalServiceOptions = {
|
|
63
|
+
home: string;
|
|
64
|
+
/** The canonical directory of a registry workspace, or a RegistryError-like refusal. */
|
|
65
|
+
resolveWorkspace(workspaceId: string): Promise<string>;
|
|
66
|
+
log: Log;
|
|
67
|
+
/** Lower limits (tests, an embedding host); never higher than TERMINAL. */
|
|
68
|
+
limits?: Partial<TerminalLimits>;
|
|
69
|
+
now?: () => number;
|
|
70
|
+
platform?: NodeJS.Platform;
|
|
71
|
+
/** Test hook: the PTY spawner; default node-pty, loaded on first use. */
|
|
72
|
+
spawn?: PtySpawn;
|
|
73
|
+
/** Test hook: the process table; default `ps`. */
|
|
74
|
+
processes?: () => Promise<ProcessRow[]>;
|
|
75
|
+
sweepMs?: number;
|
|
76
|
+
killGraceMs?: number;
|
|
77
|
+
/** Bytes of terminal events waiting on a connection's socket before it counts as a slow consumer. */
|
|
78
|
+
maxBufferedBytes?: number;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* The host switch and the operator's lower limits. Anything but a regular, owner-private file of
|
|
82
|
+
* this user saying `"allowRemoteTerminal": true` is off.
|
|
83
|
+
*/
|
|
84
|
+
export declare function readTerminalConfig(home: string, log?: Log): Promise<{
|
|
85
|
+
enabled: boolean;
|
|
86
|
+
reason?: string;
|
|
87
|
+
limits: TerminalLimits;
|
|
88
|
+
paseo: boolean;
|
|
89
|
+
}>;
|
|
90
|
+
/**
|
|
91
|
+
* The process table: pid, parent, group, (Linux) session, controlling tty, age, and the terminal
|
|
92
|
+
* markers in each process's environment (macOS: `ps -E`, this user's processes only; Linux:
|
|
93
|
+
* /proc/<pid>/environ, readable for this user's processes).
|
|
94
|
+
*/
|
|
95
|
+
export declare function psProcesses(platform?: NodeJS.Platform): () => Promise<ProcessRow[]>;
|
|
96
|
+
/** Splits output into frames of at most `max` UTF-8 bytes, never inside a character. */
|
|
97
|
+
export declare function frames(data: string, max: number): string[];
|
|
98
|
+
export declare function createTerminalService(options: TerminalServiceOptions): {
|
|
99
|
+
/** `terminalLimits` for daemon.hello while terminals are served, else undefined. */
|
|
100
|
+
advertised(): Promise<TerminalLimits | undefined>;
|
|
101
|
+
create(principal: TerminalPrincipal, params: {
|
|
102
|
+
workspaceId: string;
|
|
103
|
+
cols: number;
|
|
104
|
+
rows: number;
|
|
105
|
+
requestId: string;
|
|
106
|
+
}): Promise<{
|
|
107
|
+
terminal: TerminalInfo;
|
|
108
|
+
}>;
|
|
109
|
+
list(principal: TerminalPrincipal, params: {
|
|
110
|
+
workspaceId?: string;
|
|
111
|
+
}): Promise<{
|
|
112
|
+
terminals: TerminalInfo[];
|
|
113
|
+
}>;
|
|
114
|
+
attach(principal: TerminalPrincipal, sink: TerminalSink, params: {
|
|
115
|
+
terminalId: string;
|
|
116
|
+
after?: number;
|
|
117
|
+
}): Promise<{
|
|
118
|
+
gap?: {
|
|
119
|
+
fromSeq: number;
|
|
120
|
+
toSeq: number;
|
|
121
|
+
} | undefined;
|
|
122
|
+
terminal: TerminalInfo;
|
|
123
|
+
nextSeq: number;
|
|
124
|
+
}>;
|
|
125
|
+
input(principal: TerminalPrincipal, sink: TerminalSink, params: {
|
|
126
|
+
terminalId: string;
|
|
127
|
+
data: string;
|
|
128
|
+
}): Promise<{
|
|
129
|
+
bytes: number;
|
|
130
|
+
}>;
|
|
131
|
+
resize(principal: TerminalPrincipal, sink: TerminalSink, params: {
|
|
132
|
+
terminalId: string;
|
|
133
|
+
cols: number;
|
|
134
|
+
rows: number;
|
|
135
|
+
}): Promise<{
|
|
136
|
+
cols: number;
|
|
137
|
+
rows: number;
|
|
138
|
+
}>;
|
|
139
|
+
close(principal: TerminalPrincipal, params: {
|
|
140
|
+
terminalId: string;
|
|
141
|
+
}): Promise<{
|
|
142
|
+
closed: true;
|
|
143
|
+
}>;
|
|
144
|
+
/** Every terminal of a principal, any epoch: a gateway's revocation. */
|
|
145
|
+
revoke(principalId: string): Promise<{
|
|
146
|
+
closed: number;
|
|
147
|
+
}>;
|
|
148
|
+
/** A connection closed: its terminals keep running for reconnectMs. */
|
|
149
|
+
disconnect(sink: TerminalSink): void;
|
|
150
|
+
sweep: () => Promise<void>;
|
|
151
|
+
/** alpd stops: every terminal ends (reason `shutdown`) and its tree is killed. */
|
|
152
|
+
shutdown(): Promise<void>;
|
|
153
|
+
/** Test hook: pids of every running terminal's shell. */
|
|
154
|
+
pids(): number[];
|
|
155
|
+
};
|
|
156
|
+
export type TerminalService = ReturnType<typeof createTerminalService>;
|
|
157
|
+
export {};
|
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
// packages/daemon/src/terminals.ts
|
|
2
|
+
import { randomBytes } from "node:crypto";
|
|
3
|
+
import { execFile } from "node:child_process";
|
|
4
|
+
import { constants } from "node:fs";
|
|
5
|
+
import { readFileSync } from "node:fs";
|
|
6
|
+
import { access, lstat, readFile } from "node:fs/promises";
|
|
7
|
+
import { createRequire } from "node:module";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import { ERROR, RPC_ERROR, TERMINAL, TERMINAL_LIMIT_KEYS, isTerminalId } from "@anhlp/alp-protocol";
|
|
10
|
+
import { RpcError } from "./rpc-error.js";
|
|
11
|
+
var SWEEP_MS = 5e3;
|
|
12
|
+
var KILL_GRACE_MS = 1e3;
|
|
13
|
+
var MAX_BUFFERED_BYTES = 2 * 1024 * 1024;
|
|
14
|
+
var CONFIG_FILE = "terminal.json";
|
|
15
|
+
var PRIVATE_ENV = /^(ALP_|npm_)/i;
|
|
16
|
+
var notFound = () => new RpcError(ERROR.notFound, "No such terminal", { reason: "not_found" });
|
|
17
|
+
var iso = (ms) => new Date(ms).toISOString();
|
|
18
|
+
async function readTerminalConfig(home, log) {
|
|
19
|
+
const defaults = Object.fromEntries(TERMINAL_LIMIT_KEYS.map((key) => [key, TERMINAL[key]]));
|
|
20
|
+
const file = path.join(home, CONFIG_FILE);
|
|
21
|
+
const info = await lstat(file).catch(() => void 0);
|
|
22
|
+
if (!info) return { enabled: false, reason: "missing", limits: defaults, paseo: false };
|
|
23
|
+
if (!info.isFile() || process.getuid && info.uid !== process.getuid() || info.mode & 63) {
|
|
24
|
+
log?.warn("terminal.json is not a private file of the daemon user; terminals stay off", { code: "ALPD_TERMINAL_CONFIG" });
|
|
25
|
+
return { enabled: false, reason: "not_private", limits: defaults, paseo: false };
|
|
26
|
+
}
|
|
27
|
+
let value;
|
|
28
|
+
try {
|
|
29
|
+
value = JSON.parse(await readFile(file, "utf8"));
|
|
30
|
+
} catch {
|
|
31
|
+
log?.warn("terminal.json is not valid JSON; terminals stay off", { code: "ALPD_TERMINAL_CONFIG" });
|
|
32
|
+
return { enabled: false, reason: "invalid", limits: defaults, paseo: false };
|
|
33
|
+
}
|
|
34
|
+
if (!value || typeof value !== "object" || value.version !== 1) return { enabled: false, reason: "invalid", limits: defaults, paseo: false };
|
|
35
|
+
const limits = { ...defaults };
|
|
36
|
+
if (value.limits && typeof value.limits === "object") {
|
|
37
|
+
for (const [key, raw] of Object.entries(value.limits)) {
|
|
38
|
+
if (!TERMINAL_LIMIT_KEYS.includes(key) || !Number.isSafeInteger(raw) || raw < 1) {
|
|
39
|
+
log?.warn(`terminal.json limit ${key} ignored`, { code: "ALPD_TERMINAL_CONFIG" });
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const k = key;
|
|
43
|
+
if (raw > defaults[k]) {
|
|
44
|
+
log?.warn(`terminal.json limit ${key} is above the maximum; ignored`, { code: "ALPD_TERMINAL_CONFIG" });
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
limits[k] = raw;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return value.allowRemoteTerminal === true ? { enabled: true, limits, paseo: value.allowPaseoTerminal === true } : { enabled: false, reason: "off", limits, paseo: false };
|
|
51
|
+
}
|
|
52
|
+
function elapsed(text) {
|
|
53
|
+
const [days, rest] = text.includes("-") ? text.split("-") : ["0", text];
|
|
54
|
+
const parts = rest.split(":").map(Number);
|
|
55
|
+
while (parts.length < 3) parts.unshift(0);
|
|
56
|
+
const [h, m, s] = parts;
|
|
57
|
+
return (((Number(days) * 24 + h) * 60 + m) * 60 + s) * 1e3;
|
|
58
|
+
}
|
|
59
|
+
var MARKER = /(?:^|\s)ALP_TERMINAL_ID=(atm_[0-9a-f]{32})(?=\s|$)/g;
|
|
60
|
+
var markersOf = (text) => [...text.matchAll(MARKER)].map((match) => match[1]);
|
|
61
|
+
var ENTRY = /^ALP_TERMINAL_ID=(atm_[0-9a-f]{32})$/;
|
|
62
|
+
function psProcesses(platform = process.platform) {
|
|
63
|
+
const linux = platform === "linux";
|
|
64
|
+
const run = (args) => new Promise((resolve) => {
|
|
65
|
+
const child = execFile("ps", args, { encoding: "utf8", maxBuffer: 256 * 1024 * 1024, killSignal: "SIGKILL", env: { ...process.env, LC_ALL: "C" } }, (error, stdout) => {
|
|
66
|
+
clearTimeout(timer);
|
|
67
|
+
resolve(error ? void 0 : stdout);
|
|
68
|
+
});
|
|
69
|
+
const timer = setTimeout(() => {
|
|
70
|
+
child.kill("SIGKILL");
|
|
71
|
+
resolve(void 0);
|
|
72
|
+
}, 1e4);
|
|
73
|
+
});
|
|
74
|
+
return async () => {
|
|
75
|
+
const columns = linux ? "pid=,ppid=,pgid=,sid=,tty=,etime=" : "pid=,ppid=,pgid=,tty=,etime=,command=";
|
|
76
|
+
const [stdout, plain] = await Promise.all([run(linux ? ["-A", "-o", columns] : ["-A", "-E", "-ww", "-o", columns]), linux ? void 0 : run(["-A", "-ww", "-o", "pid=,command="])]);
|
|
77
|
+
if (stdout === void 0) return [];
|
|
78
|
+
const commands = /* @__PURE__ */ new Map();
|
|
79
|
+
for (const line of plain?.split("\n") ?? []) {
|
|
80
|
+
const match = /^\s*(\d+) (.*)$/.exec(line);
|
|
81
|
+
if (match) commands.set(Number(match[1]), match[2]);
|
|
82
|
+
}
|
|
83
|
+
const rows = [];
|
|
84
|
+
for (const line of stdout.split("\n")) {
|
|
85
|
+
const cells = line.trim().split(/\s+/);
|
|
86
|
+
if (cells.length < 5) continue;
|
|
87
|
+
const [pid, ppid, pgid] = cells.slice(0, 3).map(Number);
|
|
88
|
+
if (!Number.isSafeInteger(pid) || !Number.isSafeInteger(ppid) || !Number.isSafeInteger(pgid)) continue;
|
|
89
|
+
const sid = linux ? Number(cells[3]) : void 0;
|
|
90
|
+
const tty = cells[linux ? 4 : 3];
|
|
91
|
+
let markers = [];
|
|
92
|
+
if (linux) {
|
|
93
|
+
try {
|
|
94
|
+
markers = readFileSync(`/proc/${pid}/environ`, "utf8").split("\0").flatMap((entry) => ENTRY.exec(entry)?.[1] ?? []);
|
|
95
|
+
} catch {
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
const full = /^\s*(?:\S+\s+){4}\S+ (.*)$/.exec(line)?.[1] ?? "";
|
|
99
|
+
const command = commands.get(pid);
|
|
100
|
+
if (command !== void 0 && full.startsWith(command)) markers = markersOf(full.slice(command.length));
|
|
101
|
+
}
|
|
102
|
+
rows.push({ pid, ppid, pgid, ...sid !== void 0 && Number.isSafeInteger(sid) ? { sid } : {}, .../^[?-]+$/.test(tty) ? {} : { tty }, elapsedMs: elapsed(cells[linux ? 5 : 4]), ...markers.length ? { markers } : {} });
|
|
103
|
+
}
|
|
104
|
+
return rows;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function frames(data, max) {
|
|
108
|
+
if (Buffer.byteLength(data) <= max) return [data];
|
|
109
|
+
const out = [];
|
|
110
|
+
let current = "";
|
|
111
|
+
let bytes = 0;
|
|
112
|
+
for (const char of data) {
|
|
113
|
+
const size = Buffer.byteLength(char);
|
|
114
|
+
if (bytes + size > max && current) {
|
|
115
|
+
out.push(current);
|
|
116
|
+
current = "";
|
|
117
|
+
bytes = 0;
|
|
118
|
+
}
|
|
119
|
+
current += char;
|
|
120
|
+
bytes += size;
|
|
121
|
+
}
|
|
122
|
+
if (current) out.push(current);
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
function createTerminalService(options) {
|
|
126
|
+
const { home, resolveWorkspace, log } = options;
|
|
127
|
+
const now = options.now ?? Date.now;
|
|
128
|
+
const platform = options.platform ?? process.platform;
|
|
129
|
+
const supported = platform === "darwin" || platform === "linux";
|
|
130
|
+
const listProcesses = options.processes ?? psProcesses(platform);
|
|
131
|
+
const killGraceMs = options.killGraceMs ?? KILL_GRACE_MS;
|
|
132
|
+
const maxBuffered = options.maxBufferedBytes ?? MAX_BUFFERED_BYTES;
|
|
133
|
+
const terminals = /* @__PURE__ */ new Map();
|
|
134
|
+
const requests = /* @__PURE__ */ new Map();
|
|
135
|
+
let spawner = options.spawn;
|
|
136
|
+
let loadError;
|
|
137
|
+
let closed = false;
|
|
138
|
+
let enabled = false;
|
|
139
|
+
function pty() {
|
|
140
|
+
if (spawner || loadError) return spawner;
|
|
141
|
+
try {
|
|
142
|
+
const name = "node-pty";
|
|
143
|
+
const module = createRequire(import.meta.url)(name);
|
|
144
|
+
spawner = module.spawn;
|
|
145
|
+
} catch (error) {
|
|
146
|
+
loadError = error;
|
|
147
|
+
log.warn("the optional node-pty module did not load; terminals are unavailable", { code: "ALPD_TERMINAL_UNAVAILABLE", error });
|
|
148
|
+
}
|
|
149
|
+
return spawner;
|
|
150
|
+
}
|
|
151
|
+
function effective(config) {
|
|
152
|
+
const limits = { ...config };
|
|
153
|
+
for (const key of TERMINAL_LIMIT_KEYS) {
|
|
154
|
+
const lower = options.limits?.[key];
|
|
155
|
+
if (Number.isSafeInteger(lower) && lower > 0 && lower < limits[key]) limits[key] = lower;
|
|
156
|
+
}
|
|
157
|
+
return limits;
|
|
158
|
+
}
|
|
159
|
+
async function state() {
|
|
160
|
+
const config = await readTerminalConfig(home, log);
|
|
161
|
+
const limits = effective(config.limits);
|
|
162
|
+
if (enabled && !config.enabled) {
|
|
163
|
+
log.info("terminals turned off on this host; ending every terminal", { code: "ALPD_TERMINAL_DISABLED" });
|
|
164
|
+
for (const terminal of terminals.values()) if (!terminal.exit) void end(terminal, "disabled");
|
|
165
|
+
}
|
|
166
|
+
enabled = config.enabled;
|
|
167
|
+
return { enabled: config.enabled, limits };
|
|
168
|
+
}
|
|
169
|
+
async function ready() {
|
|
170
|
+
if (closed) throw new RpcError(ERROR.unavailable, "alpd is shutting down", { reason: "terminal_unsupported" });
|
|
171
|
+
if (!supported) throw new RpcError(ERROR.unavailable, "Terminals are not supported on this host's platform", { reason: "terminal_unsupported" });
|
|
172
|
+
const current = await state();
|
|
173
|
+
if (!current.enabled) throw new RpcError(ERROR.unavailable, "The host has not allowed remote terminals (alp terminal allow)", { reason: "terminal_disabled" });
|
|
174
|
+
if (!pty()) throw new RpcError(ERROR.unavailable, "The terminal module is not installed on this host", { reason: "terminal_unsupported" });
|
|
175
|
+
return current.limits;
|
|
176
|
+
}
|
|
177
|
+
function info(terminal) {
|
|
178
|
+
return {
|
|
179
|
+
terminalId: terminal.id,
|
|
180
|
+
workspaceId: terminal.workspaceId,
|
|
181
|
+
title: terminal.title,
|
|
182
|
+
cols: terminal.cols,
|
|
183
|
+
rows: terminal.rows,
|
|
184
|
+
state: terminal.exit ? "exited" : "running",
|
|
185
|
+
attached: !!terminal.sink,
|
|
186
|
+
createdAt: iso(terminal.createdAt),
|
|
187
|
+
lastActivityAt: iso(terminal.lastActivityAt),
|
|
188
|
+
expiresAt: iso(terminal.expiresAt),
|
|
189
|
+
...terminal.exit ? { exitCode: terminal.exit.exitCode, signal: terminal.exit.signal, endReason: terminal.exit.reason } : {}
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
const audit = (message, terminal, fields = {}) => log.info(message, { terminalId: terminal.id, workspaceId: terminal.workspaceId, principal: terminal.principal.id, ...fields });
|
|
193
|
+
function own(principal, terminalId) {
|
|
194
|
+
const terminal = isTerminalId(terminalId) ? terminals.get(terminalId) : void 0;
|
|
195
|
+
if (!terminal || terminal.principal.id !== principal.id || terminal.principal.epoch !== principal.epoch || !within(principal, terminal.root)) throw notFound();
|
|
196
|
+
return terminal;
|
|
197
|
+
}
|
|
198
|
+
function within(principal, root) {
|
|
199
|
+
if (principal.roots === void 0) return true;
|
|
200
|
+
return principal.roots.some((granted) => root === granted || root.startsWith(granted.endsWith(path.sep) ? granted : granted + path.sep));
|
|
201
|
+
}
|
|
202
|
+
function send(terminal, event) {
|
|
203
|
+
const sink = terminal.sink;
|
|
204
|
+
if (!sink) return;
|
|
205
|
+
sink.send({ jsonrpc: "2.0", method: "terminal.event", params: event });
|
|
206
|
+
if (event.type === "output" && (sink.socket?.writableLength ?? 0) > maxBuffered) detach(terminal, "slow_consumer");
|
|
207
|
+
}
|
|
208
|
+
function detach(terminal, reason) {
|
|
209
|
+
const sink = terminal.sink;
|
|
210
|
+
if (!sink) return;
|
|
211
|
+
terminal.sink = void 0;
|
|
212
|
+
terminal.detachedAt = now();
|
|
213
|
+
if (reason !== "disconnected") sink.send({ jsonrpc: "2.0", method: "terminal.event", params: { terminalId: terminal.id, type: "detached", reason } });
|
|
214
|
+
audit("terminal detached", terminal, { code: "ALPD_TERMINAL_DETACHED", reason });
|
|
215
|
+
}
|
|
216
|
+
function output(terminal, data, limits) {
|
|
217
|
+
terminal.lastActivityAt = now();
|
|
218
|
+
for (const piece of frames(data, limits.maxOutputFrameBytes)) {
|
|
219
|
+
const frame = { seq: terminal.nextSeq++, data: piece, bytes: Buffer.byteLength(piece) };
|
|
220
|
+
terminal.ring.push(frame);
|
|
221
|
+
terminal.ringBytes += frame.bytes;
|
|
222
|
+
while (terminal.ringBytes > limits.replayBytes && terminal.ring.length > 1) terminal.ringBytes -= terminal.ring.shift().bytes;
|
|
223
|
+
send(terminal, { terminalId: terminal.id, type: "output", seq: frame.seq, data: frame.data });
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
async function tree(terminal) {
|
|
227
|
+
const running2 = !terminal.exit;
|
|
228
|
+
const lifetime = now() - terminal.createdAt;
|
|
229
|
+
const rows = await listProcesses();
|
|
230
|
+
const age = now() - terminal.createdAt + 2e3;
|
|
231
|
+
const own2 = rows.find((row) => row.pid === process.pid);
|
|
232
|
+
const children = /* @__PURE__ */ new Map();
|
|
233
|
+
for (const row of rows) children.set(row.ppid, [...children.get(row.ppid) ?? [], row]);
|
|
234
|
+
const found = /* @__PURE__ */ new Map();
|
|
235
|
+
for (const row of rows) if (row.markers?.includes(terminal.marker)) found.set(row.pid, row);
|
|
236
|
+
const holder = rows.find((row) => row.pid === terminal.pid);
|
|
237
|
+
const ours = !holder || holder.elapsedMs >= lifetime - 2e3;
|
|
238
|
+
const shell2 = running2 && ours ? holder : void 0;
|
|
239
|
+
if (shell2) found.set(shell2.pid, shell2);
|
|
240
|
+
const tty = shell2 && terminal.tty && shell2.tty === terminal.tty ? terminal.tty : void 0;
|
|
241
|
+
for (const row of rows) {
|
|
242
|
+
if (tty && row.tty === tty || row.sid !== void 0 && row.sid === terminal.pid && ours) found.set(row.pid, row);
|
|
243
|
+
}
|
|
244
|
+
const queue = [...found.values()];
|
|
245
|
+
while (queue.length) {
|
|
246
|
+
const row = queue.pop();
|
|
247
|
+
for (const child of children.get(row.pid) ?? []) if (!found.has(child.pid)) {
|
|
248
|
+
found.set(child.pid, child);
|
|
249
|
+
queue.push(child);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
const groups = new Set([...found.values()].map((row) => row.pgid));
|
|
253
|
+
for (const row of rows) if (groups.has(row.pgid)) found.set(row.pid, row);
|
|
254
|
+
return [...found.values()].filter((row) => row.pid > 1 && row.pid !== process.pid && (!own2 || row.pgid !== own2.pgid) && row.elapsedMs <= age);
|
|
255
|
+
}
|
|
256
|
+
function signal(rows, name) {
|
|
257
|
+
for (const row of rows) {
|
|
258
|
+
try {
|
|
259
|
+
process.kill(row.pid, name);
|
|
260
|
+
} catch {
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function reap(terminal) {
|
|
265
|
+
terminal.reaped ??= (async () => {
|
|
266
|
+
signal(await tree(terminal), "SIGHUP");
|
|
267
|
+
await new Promise((resolve) => setTimeout(resolve, killGraceMs));
|
|
268
|
+
const left = await tree(terminal);
|
|
269
|
+
signal(left, "SIGKILL");
|
|
270
|
+
if (left.length) {
|
|
271
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
272
|
+
signal(await tree(terminal), "SIGKILL");
|
|
273
|
+
}
|
|
274
|
+
})().catch((error) => log.warn("could not end every process of a terminal", { code: "ALPD_TERMINAL_REAP_FAILED", terminalId: terminal.id, error }));
|
|
275
|
+
return terminal.reaped;
|
|
276
|
+
}
|
|
277
|
+
function exited(terminal, exitCode, signalNumber) {
|
|
278
|
+
if (terminal.exit) return;
|
|
279
|
+
const reason = terminal.ending ?? "exited";
|
|
280
|
+
terminal.exit = { seq: terminal.nextSeq++, exitCode, signal: signalNumber, reason, at: now() };
|
|
281
|
+
for (const disposable of terminal.disposables) {
|
|
282
|
+
try {
|
|
283
|
+
disposable.dispose();
|
|
284
|
+
} catch {
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
requests.delete(terminal.requestKey);
|
|
288
|
+
send(terminal, { terminalId: terminal.id, type: "exit", seq: terminal.exit.seq, exitCode, signal: signalNumber, reason });
|
|
289
|
+
audit("terminal ended", terminal, { code: "ALPD_TERMINAL_ENDED", reason, exitCode, signal: signalNumber });
|
|
290
|
+
void reap(terminal);
|
|
291
|
+
}
|
|
292
|
+
async function end(terminal, reason) {
|
|
293
|
+
if (terminal.exit) return terminal.reaped;
|
|
294
|
+
terminal.ending ??= reason;
|
|
295
|
+
const reaping = reap(terminal);
|
|
296
|
+
try {
|
|
297
|
+
terminal.pty.kill("SIGHUP");
|
|
298
|
+
} catch {
|
|
299
|
+
}
|
|
300
|
+
await reaping;
|
|
301
|
+
if (!terminal.exit) exited(terminal, null, null);
|
|
302
|
+
}
|
|
303
|
+
let sweeping = false;
|
|
304
|
+
async function sweep() {
|
|
305
|
+
if (closed || sweeping) return;
|
|
306
|
+
sweeping = true;
|
|
307
|
+
try {
|
|
308
|
+
await sweepOnce();
|
|
309
|
+
} finally {
|
|
310
|
+
sweeping = false;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
async function sweepOnce() {
|
|
314
|
+
const current = await state().catch(() => void 0);
|
|
315
|
+
if (!current) return;
|
|
316
|
+
const { limits } = current;
|
|
317
|
+
const at = now();
|
|
318
|
+
for (const terminal of [...terminals.values()]) {
|
|
319
|
+
if (terminal.exit) {
|
|
320
|
+
if (at - terminal.exit.at >= limits.reconnectMs) terminals.delete(terminal.id);
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
if (at >= terminal.expiresAt) void end(terminal, "lifetime");
|
|
324
|
+
else if (at - terminal.lastActivityAt >= limits.idleMs) void end(terminal, "idle");
|
|
325
|
+
else if (!terminal.sink && terminal.detachedAt !== void 0 && at - terminal.detachedAt >= limits.reconnectMs) void end(terminal, "detached");
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
const timer = setInterval(() => void sweep().catch(() => {
|
|
329
|
+
}), options.sweepMs ?? SWEEP_MS);
|
|
330
|
+
timer.unref?.();
|
|
331
|
+
async function shell() {
|
|
332
|
+
const candidate = process.env.SHELL;
|
|
333
|
+
if (candidate && path.isAbsolute(candidate)) {
|
|
334
|
+
const listed = await readFile("/etc/shells", "utf8").then((text) => text.split("\n").map((line) => line.trim()).includes(candidate), () => false);
|
|
335
|
+
if (listed && await access(candidate, constants.X_OK).then(() => true, () => false)) return candidate;
|
|
336
|
+
}
|
|
337
|
+
return "/bin/sh";
|
|
338
|
+
}
|
|
339
|
+
function environment(marker) {
|
|
340
|
+
const env = {};
|
|
341
|
+
for (const [key, value] of Object.entries(process.env)) if (value !== void 0 && !PRIVATE_ENV.test(key)) env[key] = value;
|
|
342
|
+
return { ...env, TERM: "xterm-256color", COLORTERM: "truecolor", ALP_TERMINAL: "1", ALP_TERMINAL_ID: marker };
|
|
343
|
+
}
|
|
344
|
+
const running = (filter) => [...terminals.values()].filter((terminal) => !terminal.exit && filter(terminal)).length;
|
|
345
|
+
return {
|
|
346
|
+
/** `terminalLimits` for daemon.hello while terminals are served, else undefined. */
|
|
347
|
+
async advertised() {
|
|
348
|
+
if (closed || !supported) return void 0;
|
|
349
|
+
const current = await state().catch(() => void 0);
|
|
350
|
+
return current?.enabled && pty() ? current.limits : void 0;
|
|
351
|
+
},
|
|
352
|
+
async create(principal, params) {
|
|
353
|
+
const limits = await ready();
|
|
354
|
+
const requestKey = JSON.stringify([principal.id, principal.epoch, params.requestId]);
|
|
355
|
+
let root;
|
|
356
|
+
try {
|
|
357
|
+
root = await resolveWorkspace(params.workspaceId);
|
|
358
|
+
} catch (error) {
|
|
359
|
+
if (typeof error?.code === "number" && error.code !== ERROR.failed) throw new RpcError(error.code === ERROR.forbidden ? ERROR.forbidden : ERROR.notFound, error.code === ERROR.forbidden ? "The workspace directory changed" : "No workspace with this workspaceId", { reason: error.data?.reason ?? "not_found" });
|
|
360
|
+
throw error;
|
|
361
|
+
}
|
|
362
|
+
if (!within(principal, root)) throw new RpcError(ERROR.forbidden, "The workspace is outside this grant", { reason: "outside_workspace" });
|
|
363
|
+
const file = await shell();
|
|
364
|
+
if (closed) throw new RpcError(ERROR.unavailable, "alpd is shutting down", { reason: "terminal_unsupported" });
|
|
365
|
+
const repeated = terminals.get(requests.get(requestKey) ?? "");
|
|
366
|
+
if (repeated && !repeated.exit) {
|
|
367
|
+
if (repeated.workspaceId !== params.workspaceId) throw new RpcError(ERROR.conflict, "This requestId created another terminal", { reason: "request_conflict" });
|
|
368
|
+
return { terminal: info(repeated) };
|
|
369
|
+
}
|
|
370
|
+
if (running((terminal2) => terminal2.principal.id === principal.id) >= limits.maxPerPrincipal) throw new RpcError(ERROR.unavailable, `At most ${limits.maxPerPrincipal} terminals run per principal`, { reason: "terminal_limit", limit: "principal" });
|
|
371
|
+
if (running(() => true) >= limits.maxPerDaemon) throw new RpcError(ERROR.unavailable, `At most ${limits.maxPerDaemon} terminals run on this host`, { reason: "terminal_limit", limit: "daemon" });
|
|
372
|
+
const at = now();
|
|
373
|
+
const marker = `atm_${randomBytes(16).toString("hex")}`;
|
|
374
|
+
const process_ = pty()(file, [], { name: "xterm-256color", cols: params.cols, rows: params.rows, cwd: root, env: environment(marker) });
|
|
375
|
+
const terminal = {
|
|
376
|
+
id: `term_${randomBytes(16).toString("hex")}`,
|
|
377
|
+
principal: { id: principal.id, epoch: principal.epoch },
|
|
378
|
+
workspaceId: params.workspaceId,
|
|
379
|
+
root,
|
|
380
|
+
title: path.basename(file).slice(0, 64),
|
|
381
|
+
cols: params.cols,
|
|
382
|
+
rows: params.rows,
|
|
383
|
+
pty: process_,
|
|
384
|
+
pid: process_.pid,
|
|
385
|
+
...typeof process_.ptsName === "string" && process_.ptsName.startsWith("/dev/") ? { tty: process_.ptsName.slice("/dev/".length) } : {},
|
|
386
|
+
createdAt: at,
|
|
387
|
+
lastActivityAt: at,
|
|
388
|
+
expiresAt: at + limits.maxLifetimeMs,
|
|
389
|
+
requestKey,
|
|
390
|
+
ring: [],
|
|
391
|
+
ringBytes: 0,
|
|
392
|
+
nextSeq: 1,
|
|
393
|
+
detachedAt: at,
|
|
394
|
+
marker,
|
|
395
|
+
disposables: []
|
|
396
|
+
};
|
|
397
|
+
terminals.set(terminal.id, terminal);
|
|
398
|
+
requests.set(requestKey, terminal.id);
|
|
399
|
+
terminal.disposables.push(process_.onData((data) => output(terminal, data, limits)));
|
|
400
|
+
terminal.disposables.push(process_.onExit(({ exitCode, signal: number }) => exited(terminal, terminal.ending ? null : exitCode, number || null)));
|
|
401
|
+
audit("terminal created", terminal, { code: "ALPD_TERMINAL_CREATED" });
|
|
402
|
+
return { terminal: info(terminal) };
|
|
403
|
+
},
|
|
404
|
+
async list(principal, params) {
|
|
405
|
+
if (supported) await state().catch(() => void 0);
|
|
406
|
+
const terminals_ = [...terminals.values()].filter((terminal) => terminal.principal.id === principal.id && terminal.principal.epoch === principal.epoch && within(principal, terminal.root) && (params.workspaceId === void 0 || terminal.workspaceId === params.workspaceId)).sort((a, b) => b.createdAt - a.createdAt || (a.id < b.id ? -1 : 1));
|
|
407
|
+
return { terminals: terminals_.map(info) };
|
|
408
|
+
},
|
|
409
|
+
async attach(principal, sink, params) {
|
|
410
|
+
await ready();
|
|
411
|
+
const terminal = own(principal, params.terminalId);
|
|
412
|
+
if (terminal.sink && terminal.sink !== sink) detach(terminal, "replaced");
|
|
413
|
+
terminal.sink = sink;
|
|
414
|
+
terminal.detachedAt = void 0;
|
|
415
|
+
const after = Math.min(params.after ?? 0, terminal.nextSeq - 1);
|
|
416
|
+
const first = terminal.ring[0]?.seq ?? terminal.nextSeq;
|
|
417
|
+
const lastOutput = terminal.exit ? terminal.exit.seq - 1 : terminal.nextSeq - 1;
|
|
418
|
+
const gap = after + 1 < first && after < lastOutput ? { fromSeq: after + 1, toSeq: Math.min(first, lastOutput + 1) - 1 } : void 0;
|
|
419
|
+
for (const frame of terminal.ring) if (frame.seq > after) sink.send({ jsonrpc: "2.0", method: "terminal.event", params: { terminalId: terminal.id, type: "output", seq: frame.seq, data: frame.data } });
|
|
420
|
+
if (terminal.exit && terminal.exit.seq > after) sink.send({ jsonrpc: "2.0", method: "terminal.event", params: { terminalId: terminal.id, type: "exit", seq: terminal.exit.seq, exitCode: terminal.exit.exitCode, signal: terminal.exit.signal, reason: terminal.exit.reason } });
|
|
421
|
+
audit("terminal attached", terminal, { code: "ALPD_TERMINAL_ATTACHED", after, ...gap ? { gap: gap.toSeq - gap.fromSeq + 1 } : {} });
|
|
422
|
+
return { terminal: info(terminal), nextSeq: terminal.nextSeq, ...gap ? { gap } : {} };
|
|
423
|
+
},
|
|
424
|
+
async input(principal, sink, params) {
|
|
425
|
+
const limits = await ready();
|
|
426
|
+
const terminal = own(principal, params.terminalId);
|
|
427
|
+
if (terminal.sink !== sink) throw new RpcError(ERROR.conflict, "Attach the terminal on this connection first", { reason: "not_attached" });
|
|
428
|
+
if (terminal.exit || terminal.ending) throw new RpcError(ERROR.conflict, "The terminal has ended", { reason: "terminal_exited" });
|
|
429
|
+
const bytes = Buffer.byteLength(params.data);
|
|
430
|
+
if (bytes > limits.maxInputBytes) throw new RpcError(RPC_ERROR.invalidParams, `At most ${limits.maxInputBytes} bytes of input at once`, { reason: "input_too_large" });
|
|
431
|
+
terminal.pty.write(params.data);
|
|
432
|
+
terminal.lastActivityAt = now();
|
|
433
|
+
return { bytes };
|
|
434
|
+
},
|
|
435
|
+
async resize(principal, sink, params) {
|
|
436
|
+
await ready();
|
|
437
|
+
const terminal = own(principal, params.terminalId);
|
|
438
|
+
if (terminal.sink !== sink) throw new RpcError(ERROR.conflict, "Attach the terminal on this connection first", { reason: "not_attached" });
|
|
439
|
+
if (terminal.exit || terminal.ending) throw new RpcError(ERROR.conflict, "The terminal has ended", { reason: "terminal_exited" });
|
|
440
|
+
terminal.pty.resize(params.cols, params.rows);
|
|
441
|
+
terminal.cols = params.cols;
|
|
442
|
+
terminal.rows = params.rows;
|
|
443
|
+
return { cols: terminal.cols, rows: terminal.rows };
|
|
444
|
+
},
|
|
445
|
+
async close(principal, params) {
|
|
446
|
+
const terminal = own(principal, params.terminalId);
|
|
447
|
+
if (terminal.exit) {
|
|
448
|
+
terminals.delete(terminal.id);
|
|
449
|
+
return { closed: true };
|
|
450
|
+
}
|
|
451
|
+
await end(terminal, "closed");
|
|
452
|
+
terminals.delete(terminal.id);
|
|
453
|
+
return { closed: true };
|
|
454
|
+
},
|
|
455
|
+
/** Every terminal of a principal, any epoch: a gateway's revocation. */
|
|
456
|
+
async revoke(principalId) {
|
|
457
|
+
const mine = [...terminals.values()].filter((terminal) => terminal.principal.id === principalId);
|
|
458
|
+
const live = mine.filter((terminal) => !terminal.exit);
|
|
459
|
+
await Promise.all(live.map((terminal) => end(terminal, "revoked")));
|
|
460
|
+
for (const terminal of mine) terminals.delete(terminal.id);
|
|
461
|
+
if (mine.length) log.info("revoked the terminals of a principal", { code: "ALPD_TERMINAL_REVOKED", principal: principalId, closed: live.length });
|
|
462
|
+
return { closed: live.length };
|
|
463
|
+
},
|
|
464
|
+
/** A connection closed: its terminals keep running for reconnectMs. */
|
|
465
|
+
disconnect(sink) {
|
|
466
|
+
for (const terminal of terminals.values()) if (terminal.sink === sink) detach(terminal, "disconnected");
|
|
467
|
+
},
|
|
468
|
+
sweep,
|
|
469
|
+
/** alpd stops: every terminal ends (reason `shutdown`) and its tree is killed. */
|
|
470
|
+
async shutdown() {
|
|
471
|
+
closed = true;
|
|
472
|
+
clearInterval(timer);
|
|
473
|
+
await Promise.all([...terminals.values()].map((terminal) => terminal.exit ? terminal.reaped : end(terminal, "shutdown")));
|
|
474
|
+
terminals.clear();
|
|
475
|
+
},
|
|
476
|
+
/** Test hook: pids of every running terminal's shell. */
|
|
477
|
+
pids() {
|
|
478
|
+
return [...terminals.values()].filter((terminal) => !terminal.exit).map((terminal) => terminal.pid);
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
export {
|
|
483
|
+
createTerminalService,
|
|
484
|
+
frames,
|
|
485
|
+
psProcesses,
|
|
486
|
+
readTerminalConfig
|
|
487
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type RegistryService, type WorkspaceRecord } from './registry.js';
|
|
2
|
+
type Mapping = {
|
|
3
|
+
id: string;
|
|
4
|
+
source: string;
|
|
5
|
+
commonDir: string;
|
|
6
|
+
parent: string;
|
|
7
|
+
};
|
|
8
|
+
type Context = {
|
|
9
|
+
principalId?: string;
|
|
10
|
+
principalEpoch?: string;
|
|
11
|
+
mappingIds?: string[];
|
|
12
|
+
authorizedRoots?: string[];
|
|
13
|
+
};
|
|
14
|
+
/** Owner-only file; neither an RPC parameter nor repository configuration can approve a destination. */
|
|
15
|
+
export declare function worktreeMappings(home: string): Promise<Mapping[]>;
|
|
16
|
+
export declare function createWorkspaceWorktrees(home: string, registry: RegistryService, guard: <T>(directory: string, run: () => Promise<T>) => Promise<T>, register: (directory: string) => Promise<void>): {
|
|
17
|
+
describe(w: WorkspaceRecord): Promise<{
|
|
18
|
+
managedWorktree?: boolean | undefined;
|
|
19
|
+
branch: string | null;
|
|
20
|
+
id: string;
|
|
21
|
+
projectId: string;
|
|
22
|
+
directory: string;
|
|
23
|
+
canonical?: string;
|
|
24
|
+
title?: string | null;
|
|
25
|
+
pinnedAt?: string | null;
|
|
26
|
+
labels: string[];
|
|
27
|
+
createdAt: string;
|
|
28
|
+
archivedAt?: string | null;
|
|
29
|
+
idempotencyKey?: string;
|
|
30
|
+
}>;
|
|
31
|
+
assertAvailable(directory: string): Promise<void>;
|
|
32
|
+
grants(context?: Context): Promise<{
|
|
33
|
+
mappings: {
|
|
34
|
+
id: string;
|
|
35
|
+
source: string;
|
|
36
|
+
}[];
|
|
37
|
+
workspaces: WorkspaceRecord[];
|
|
38
|
+
}>;
|
|
39
|
+
mutate(method: "create" | "remove", p: any, context?: Context): Promise<any>;
|
|
40
|
+
};
|
|
41
|
+
export {};
|