@anhlp/alp-client 0.0.0-stage → 0.0.1-beta.10
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 +45 -2
- package/dist/acp-probe.d.ts +45 -0
- package/dist/acp-probe.js +46 -0
- package/dist/antigravity-probe.d.ts +33 -0
- package/dist/antigravity-probe.js +101 -0
- package/dist/command.d.ts +5 -0
- package/dist/command.js +35 -0
- package/dist/doctor.d.ts +21 -0
- package/dist/doctor.js +850 -0
- package/dist/index.d.ts +216 -0
- package/dist/index.js +702 -0
- package/dist/integration-lock.d.ts +37 -0
- package/dist/integration-lock.js +199 -0
- package/dist/ipc.d.ts +42 -0
- package/dist/ipc.js +69 -0
- package/dist/library-test.d.ts +94 -0
- package/dist/library-test.js +37 -0
- package/dist/mcp-probe.d.ts +24 -0
- package/dist/mcp-probe.js +147 -0
- package/dist/portable.d.ts +20 -0
- package/dist/portable.js +36 -0
- package/dist/prompt.d.ts +32 -0
- package/dist/prompt.js +59 -0
- package/dist/render.d.ts +6 -0
- package/dist/render.js +123 -0
- package/dist/rpc/client.d.ts +82 -0
- package/dist/rpc/client.js +292 -0
- package/dist/rpc/errors.d.ts +42 -0
- package/dist/rpc/errors.js +34 -0
- package/dist/rpc/framing.d.ts +21 -0
- package/dist/rpc/framing.js +57 -0
- package/dist/rpc/handshake.d.ts +24 -0
- package/dist/rpc/handshake.js +10 -0
- package/dist/rpc/reconnect.d.ts +97 -0
- package/dist/rpc/reconnect.js +227 -0
- package/dist/rpc/registry.d.ts +227 -0
- package/dist/rpc/registry.js +223 -0
- package/dist/rpc/terminal-directory.d.ts +24 -0
- package/dist/rpc/terminal-directory.js +70 -0
- package/dist/rpc/timers.d.ts +11 -0
- package/dist/rpc/timers.js +11 -0
- package/dist/service.d.ts +50 -0
- package/dist/service.js +145 -0
- package/dist/setup.d.ts +8 -0
- package/dist/setup.js +273 -0
- package/dist/supervise.d.ts +14 -0
- package/dist/supervise.js +91 -0
- package/dist/websocket.d.ts +51 -0
- package/dist/websocket.js +190 -0
- package/package.json +174 -4
- package/src/acp-probe.js +53 -0
- package/src/antigravity-probe.js +113 -0
- package/src/command.js +20 -0
- package/src/doctor.d.ts +21 -0
- package/src/doctor.js +912 -0
- package/src/index.js +813 -0
- package/src/integration-lock.js +203 -0
- package/src/ipc.js +92 -0
- package/src/library-test.js +41 -0
- package/src/mcp-probe.js +118 -0
- package/src/portable.js +30 -0
- package/src/prompt.js +64 -0
- package/src/render.js +139 -0
- package/src/rpc/client.js +296 -0
- package/src/rpc/errors.js +54 -0
- package/src/rpc/framing.js +61 -0
- package/src/rpc/handshake.js +21 -0
- package/src/rpc/reconnect.js +226 -0
- package/src/rpc/registry.js +229 -0
- package/src/rpc/terminal-directory.js +61 -0
- package/src/rpc/timers.js +16 -0
- package/src/service.js +158 -0
- package/src/setup.js +316 -0
- package/src/supervise.d.ts +14 -0
- package/src/supervise.js +97 -0
- package/src/websocket.js +259 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,702 @@
|
|
|
1
|
+
// packages/client/src/index.js
|
|
2
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
3
|
+
import { execFileSync, spawn } from "node:child_process";
|
|
4
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
5
|
+
import { fstatSync, readFileSync } from "node:fs";
|
|
6
|
+
import { open, readFile, writeFile, realpath, stat, lstat, mkdir, readlink, unlink, readdir, chmod, rename, rmdir, link } from "node:fs/promises";
|
|
7
|
+
import net from "node:net";
|
|
8
|
+
import os from "node:os";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import { scrubText } from "@anhlp/alp-core/log";
|
|
11
|
+
import { entryCommand, isNativeDaemonName, NATIVE_DAEMON } from "@anhlp/alp-core/packaged";
|
|
12
|
+
import { dashboardSettings } from "@anhlp/alp-core/user-settings";
|
|
13
|
+
import { createSocketTransport } from "./ipc.js";
|
|
14
|
+
import { AlpRpcClient } from "./rpc/client.js";
|
|
15
|
+
import { hello } from "./rpc/handshake.js";
|
|
16
|
+
import { PROTOCOL_VERSION, MAX_FRAME, AlpRpcError, encodeFrame } from "@anhlp/alp-protocol";
|
|
17
|
+
export * from "./portable.js";
|
|
18
|
+
import { connectWebSocket, createWebSocketTransport, redactUrl, CLOSE_CODE } from "./websocket.js";
|
|
19
|
+
import { createSocketTransport as createSocketTransport2 } from "./ipc.js";
|
|
20
|
+
function alpHome(env = process.env) {
|
|
21
|
+
return path.resolve(env.ALP_HOME || path.join(os.homedir(), ".alp"));
|
|
22
|
+
}
|
|
23
|
+
function daemonPaths(home) {
|
|
24
|
+
const preferred = path.join(home, "alpd.sock");
|
|
25
|
+
const socket = process.platform === "win32" ? `\\\\.\\pipe\\alpd-${createHash("sha256").update(home).digest("hex").slice(0, 24)}` : Buffer.byteLength(preferred) < 100 ? preferred : path.join(os.tmpdir(), `alpd-${process.getuid?.() ?? "user"}-${createHash("sha256").update(home).digest("hex").slice(0, 12)}`, "rpc.sock");
|
|
26
|
+
return { home, lock: path.join(home, "alpd.lock"), socket, log: path.join(home, "logs", "alpd.log"), install: path.join(home, "alpd.json") };
|
|
27
|
+
}
|
|
28
|
+
async function assertSafeAncestors(directory) {
|
|
29
|
+
if (process.platform === "win32") return;
|
|
30
|
+
const absolute = path.isAbsolute(directory) ? directory : `${process.cwd()}/${directory}`;
|
|
31
|
+
let current = path.parse(absolute).root;
|
|
32
|
+
const pending = absolute.slice(current.length).split("/");
|
|
33
|
+
let links = 0;
|
|
34
|
+
while (pending.length) {
|
|
35
|
+
const part = pending.shift();
|
|
36
|
+
if (!part || part === ".") continue;
|
|
37
|
+
if (part === "..") {
|
|
38
|
+
current = path.dirname(current);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const candidate = path.join(current, part);
|
|
42
|
+
const info = await lstat(candidate).catch((error) => {
|
|
43
|
+
if (error.code !== "ENOENT") throw error;
|
|
44
|
+
});
|
|
45
|
+
if (!info) {
|
|
46
|
+
current = candidate;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const trustedOwner = info.uid === 0 || info.uid === process.getuid?.();
|
|
50
|
+
if (!trustedOwner) throw new Error("IPC requires ancestors owned by the current user or root");
|
|
51
|
+
if (info.isSymbolicLink()) {
|
|
52
|
+
if (++links > 40) throw new Error("IPC ancestor symlink loop");
|
|
53
|
+
const target = await readlink(candidate);
|
|
54
|
+
if (path.isAbsolute(target)) current = path.parse(target).root;
|
|
55
|
+
pending.unshift(...target.slice(path.isAbsolute(target) ? path.parse(target).root.length : 0).split("/"));
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (!info.isDirectory() || info.mode & 18 && !(info.mode & 512)) {
|
|
59
|
+
throw new Error("IPC requires trusted ancestors without shared write permissions");
|
|
60
|
+
}
|
|
61
|
+
current = candidate;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async function assertPrivateDirectory(directory, { create = false } = {}) {
|
|
65
|
+
await assertSafeAncestors(directory);
|
|
66
|
+
if (create) await mkdir(directory, { recursive: true, mode: 448 });
|
|
67
|
+
let info = await lstat(directory);
|
|
68
|
+
if (!info.isDirectory() || info.isSymbolicLink()) throw new Error("IPC requires a private directory, not a symlink");
|
|
69
|
+
if (process.platform === "win32") return;
|
|
70
|
+
const shown = JSON.stringify(directory);
|
|
71
|
+
const mine = (entry) => entry.isDirectory() && !entry.isSymbolicLink() && entry.uid === process.getuid?.();
|
|
72
|
+
if (info.uid !== process.getuid?.()) throw new Error(`IPC directory ${shown} must be owned by the current user (it belongs to uid ${info.uid}); use a directory of your own`);
|
|
73
|
+
if ((info.mode & 63) === 0) return;
|
|
74
|
+
if (create && (await readdir(directory)).length === 0) {
|
|
75
|
+
await chmod(directory, 448).catch(() => {
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
info = await lstat(directory);
|
|
79
|
+
if (mine(info) && (info.mode & 63) === 0) return;
|
|
80
|
+
const quoted = `'${directory.replaceAll("'", "'\\''")}'`;
|
|
81
|
+
throw new Error(`IPC directory ${shown} must have private permissions (0700), not ${(info.mode & 511).toString(8).padStart(4, "0")}; fix it with: chmod 700 ${quoted}`);
|
|
82
|
+
}
|
|
83
|
+
async function assertPrivateSocket(socketPath) {
|
|
84
|
+
if (process.platform === "win32") return;
|
|
85
|
+
await assertPrivateDirectory(path.dirname(socketPath));
|
|
86
|
+
const info = await lstat(socketPath);
|
|
87
|
+
if (!info.isSocket() || info.uid !== process.getuid?.() || (info.mode & 63) !== 0) {
|
|
88
|
+
throw new Error("IPC socket must be owned by the current user with private permissions (0600)");
|
|
89
|
+
}
|
|
90
|
+
return info;
|
|
91
|
+
}
|
|
92
|
+
var isFile = (file) => stat(file).then((info) => info.isFile(), () => false);
|
|
93
|
+
var BIN_DIRECTORIES = [path.join(os.homedir(), ".alp", "bin"), path.join(os.homedir(), ".npm-global", "bin"), path.join(os.homedir(), ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"];
|
|
94
|
+
var CLI_PACKAGES = ["@anhlp/alp", "@anhlp/alp-cli"];
|
|
95
|
+
async function cliDaemonEntry(cli, depth = 0, env = process.env) {
|
|
96
|
+
const base = path.basename(cli).toLowerCase();
|
|
97
|
+
const root = path.resolve(path.dirname(cli), "..");
|
|
98
|
+
const alpd = (directory) => path.join(directory, "dist", "alpd.js");
|
|
99
|
+
const named = async (directory) => readFile(path.join(directory, "package.json"), "utf8").then((text) => JSON.parse(text)?.name).catch(() => void 0);
|
|
100
|
+
let candidates = [];
|
|
101
|
+
if (base === "alp.cmd" && depth < 1 && !await isFile(path.join(root, "alp-bundle.json"))) {
|
|
102
|
+
const text = await stat(cli).then((info) => info.size <= 64 * 1024 ? readFile(cli, "utf8") : "", () => "");
|
|
103
|
+
for (const [, quoted] of text.matchAll(/"([^"\r\n]+\.js)"/gi)) {
|
|
104
|
+
const script = quoted.replace(/^%~?dp0%?[\\/]?/i, `${path.dirname(cli)}${path.sep}`);
|
|
105
|
+
const entry = path.isAbsolute(script) && await isFile(script) ? await cliDaemonEntry(script, depth + 1, env) : void 0;
|
|
106
|
+
if (entry) return entry;
|
|
107
|
+
}
|
|
108
|
+
return void 0;
|
|
109
|
+
}
|
|
110
|
+
if (base === "alp" || base === "alp.cmd") {
|
|
111
|
+
if (!await isFile(path.join(root, "alp-bundle.json"))) return void 0;
|
|
112
|
+
const current = path.join(path.dirname(root), "current");
|
|
113
|
+
const viaCurrent = await realpath(current).then((real) => real === root, () => false);
|
|
114
|
+
const bundle = viaCurrent ? current : root;
|
|
115
|
+
candidates = [...env.ALP_NATIVE_DAEMON === "0" ? [] : [path.join(bundle, "bin", NATIVE_DAEMON)], alpd(path.join(bundle, "lib", "node_modules", "@anhlp", "alp-cli"))];
|
|
116
|
+
} else if (base === "cli.js" && CLI_PACKAGES.includes(await named(root))) {
|
|
117
|
+
candidates = [alpd(root)];
|
|
118
|
+
} else if (base === "alp.js" && await named(root) === "@anhlp/alp") {
|
|
119
|
+
candidates = [alpd(path.join(root, "node_modules", "@anhlp", "alp-cli")), alpd(path.join(root, "..", "alp-cli"))];
|
|
120
|
+
}
|
|
121
|
+
for (const candidate of candidates) if (await isFile(candidate)) return candidate;
|
|
122
|
+
return void 0;
|
|
123
|
+
}
|
|
124
|
+
async function findDaemonEntry({ home = alpHome(), env = process.env, candidates = (
|
|
125
|
+
/** @type {Array<string | undefined>} */
|
|
126
|
+
[]
|
|
127
|
+
), binDirectories = BIN_DIRECTORIES } = {}) {
|
|
128
|
+
for (const candidate of candidates) if (candidate && await isFile(candidate)) return candidate;
|
|
129
|
+
try {
|
|
130
|
+
const { entry } = JSON.parse(await readFile(daemonPaths(home).install, "utf8"));
|
|
131
|
+
if (typeof entry === "string" && await isFile(entry)) return entry;
|
|
132
|
+
} catch {
|
|
133
|
+
}
|
|
134
|
+
for (const directory of [...(env.PATH ?? "").split(path.delimiter).filter(Boolean), ...binDirectories]) {
|
|
135
|
+
for (const name of process.platform === "win32" ? ["alp.cmd", "alp"] : ["alp"]) {
|
|
136
|
+
const cli = await realpath(path.join(directory, name)).catch(() => void 0);
|
|
137
|
+
const entry = cli && await cliDaemonEntry(cli, 0, env);
|
|
138
|
+
if (entry) return entry;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return void 0;
|
|
142
|
+
}
|
|
143
|
+
function assertIntegrationName(name) {
|
|
144
|
+
if (typeof name !== "string" || !/^[a-z0-9][a-z0-9-]*$/.test(name)) throw new TypeError(`Invalid integration name: ${JSON.stringify(name)}`);
|
|
145
|
+
return name;
|
|
146
|
+
}
|
|
147
|
+
var cachedBootId = null;
|
|
148
|
+
function bootId() {
|
|
149
|
+
if (cachedBootId !== null) return cachedBootId;
|
|
150
|
+
try {
|
|
151
|
+
if (process.platform === "linux") {
|
|
152
|
+
const id = readFileSync("/proc/sys/kernel/random/boot_id", "utf8").trim();
|
|
153
|
+
if (id.length > 0) {
|
|
154
|
+
cachedBootId = id;
|
|
155
|
+
return cachedBootId;
|
|
156
|
+
}
|
|
157
|
+
} else if (process.platform === "darwin") {
|
|
158
|
+
const id = execFileSync("sysctl", ["-n", "kern.bootsessionuuid"], {
|
|
159
|
+
encoding: "utf8",
|
|
160
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
161
|
+
timeout: 2e3
|
|
162
|
+
}).trim();
|
|
163
|
+
if (id.length > 0) {
|
|
164
|
+
cachedBootId = id;
|
|
165
|
+
return cachedBootId;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
} catch {
|
|
169
|
+
}
|
|
170
|
+
cachedBootId = void 0;
|
|
171
|
+
return cachedBootId;
|
|
172
|
+
}
|
|
173
|
+
function _setBootIdForTest(id = null) {
|
|
174
|
+
cachedBootId = id;
|
|
175
|
+
}
|
|
176
|
+
function bootTime() {
|
|
177
|
+
return Math.round((Date.now() - os.uptime() * 1e3) / 1e3);
|
|
178
|
+
}
|
|
179
|
+
function isSameBoot(lock, { bootId: curBootId = bootId(), bootTime: curBootTime = bootTime() } = {}) {
|
|
180
|
+
if (!lock) return false;
|
|
181
|
+
if (typeof lock.bootId === "string" && lock.bootId.length > 0 && typeof curBootId === "string" && curBootId.length > 0) {
|
|
182
|
+
return lock.bootId === curBootId;
|
|
183
|
+
}
|
|
184
|
+
if (typeof lock.bootTime === "number" && Number.isFinite(lock.bootTime) && Number.isFinite(curBootTime)) {
|
|
185
|
+
return Math.abs(lock.bootTime - curBootTime) <= 30;
|
|
186
|
+
}
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
async function readLock(home) {
|
|
190
|
+
try {
|
|
191
|
+
return JSON.parse(await readFile(daemonPaths(home).lock, "utf8"));
|
|
192
|
+
} catch (error) {
|
|
193
|
+
if (error?.code === "ENOENT" || error instanceof SyntaxError) return void 0;
|
|
194
|
+
throw error;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function lockAlive(lock) {
|
|
198
|
+
if (!lock || !Number.isSafeInteger(lock.pid) || !isSameBoot(lock)) return false;
|
|
199
|
+
try {
|
|
200
|
+
process.kill(lock.pid, 0);
|
|
201
|
+
return true;
|
|
202
|
+
} catch (error) {
|
|
203
|
+
return error?.code === "EPERM";
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async function acquireDaemonLock(home, contents) {
|
|
207
|
+
const file = daemonPaths(home).lock;
|
|
208
|
+
const currentBootId = bootId();
|
|
209
|
+
const lock = {
|
|
210
|
+
pid: process.pid,
|
|
211
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
212
|
+
startedUptime: Math.floor(os.uptime()),
|
|
213
|
+
bootTime: bootTime(),
|
|
214
|
+
...currentBootId ? { bootId: currentBootId } : {},
|
|
215
|
+
uid: process.getuid?.() ?? -1,
|
|
216
|
+
ready: false,
|
|
217
|
+
...contents
|
|
218
|
+
};
|
|
219
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
220
|
+
try {
|
|
221
|
+
const handle = await open(file, "wx", 384);
|
|
222
|
+
let ours;
|
|
223
|
+
try {
|
|
224
|
+
ours = await handle.stat();
|
|
225
|
+
await handle.writeFile(JSON.stringify(lock));
|
|
226
|
+
} catch (error) {
|
|
227
|
+
if (!ours) {
|
|
228
|
+
try {
|
|
229
|
+
ours = fstatSync(handle.fd);
|
|
230
|
+
} catch {
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
await handle.close().catch(() => {
|
|
234
|
+
});
|
|
235
|
+
const there = await lstat(file).catch(() => void 0);
|
|
236
|
+
if (ours && there && ours.ino === there.ino && ours.dev === there.dev) await unlink(file).catch(() => {
|
|
237
|
+
});
|
|
238
|
+
throw error;
|
|
239
|
+
}
|
|
240
|
+
await handle.close();
|
|
241
|
+
return lock;
|
|
242
|
+
} catch (error) {
|
|
243
|
+
if (error?.code !== "EEXIST") throw error;
|
|
244
|
+
const current = await readLock(home);
|
|
245
|
+
if (lockAlive(current)) throw new Error(current.maintenance ? `ALP is busy: alp ${current.maintenance} runs (pid ${current.pid}); try again when it finishes` : `ALP daemon already running (pid ${current.pid})`);
|
|
246
|
+
const again = await readFile(file, "utf8").catch(() => void 0);
|
|
247
|
+
let parsed;
|
|
248
|
+
try {
|
|
249
|
+
parsed = again === void 0 ? void 0 : JSON.parse(again);
|
|
250
|
+
} catch {
|
|
251
|
+
throw new Error(`ALP daemon lock ${file} cannot be read: another start may be writing it. If no alpd or alp command is starting, remove it and try again`);
|
|
252
|
+
}
|
|
253
|
+
if (again === void 0 || JSON.stringify(current) === again || !lockAlive(parsed)) await unlink(file).catch(() => {
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
throw new Error("Could not acquire the ALP daemon lock");
|
|
258
|
+
}
|
|
259
|
+
async function releaseDaemonLock(home) {
|
|
260
|
+
const current = await readLock(home);
|
|
261
|
+
if (current?.pid === process.pid) await unlink(daemonPaths(home).lock).catch(() => {
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
var AlpClient = class extends AlpRpcClient {
|
|
265
|
+
/** Host features captured by connect's handshake. @type {readonly string[]} */
|
|
266
|
+
capabilities = [];
|
|
267
|
+
/** Limits captured by connect's handshake. @type {import('@anhlp/alp-protocol').AttachmentLimits | undefined} */
|
|
268
|
+
attachmentLimits;
|
|
269
|
+
/** @type {{ readonly maxCount: number; readonly maxBytes: number; readonly maxTotalBytes: number } | undefined} */
|
|
270
|
+
promptImageLimits;
|
|
271
|
+
/** @type {import('@anhlp/alp-protocol').TerminalLimits | undefined} */
|
|
272
|
+
terminalLimits;
|
|
273
|
+
/**
|
|
274
|
+
* @param {import('node:net').Socket} socket a connected or connecting socket; the client owns it
|
|
275
|
+
* @param {import('./rpc/client.js').AlpRpcClientOptions & import('./ipc.js').SocketTransportOptions} [options]
|
|
276
|
+
*/
|
|
277
|
+
constructor(socket, { maxFrame, maxBufferedBytes, ...options } = {}) {
|
|
278
|
+
super(createSocketTransport(socket, { maxFrame, maxBufferedBytes }), { maxFrame, ...options });
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
async function openSocket(socketPath) {
|
|
282
|
+
await assertPrivateSocket(socketPath);
|
|
283
|
+
return (
|
|
284
|
+
/** @type {Promise<import('node:net').Socket>} */
|
|
285
|
+
new Promise((resolve, reject) => {
|
|
286
|
+
const candidate = net.createConnection(socketPath);
|
|
287
|
+
candidate.once("connect", () => {
|
|
288
|
+
candidate.off("error", reject);
|
|
289
|
+
resolve(candidate);
|
|
290
|
+
});
|
|
291
|
+
candidate.once("error", reject);
|
|
292
|
+
})
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
async function connectSocket(socketPath, options) {
|
|
296
|
+
return createSocketTransport(await openSocket(socketPath), options);
|
|
297
|
+
}
|
|
298
|
+
async function connect(socketPath, client = { name: "alp", version: "0" }, options = {}) {
|
|
299
|
+
const connection = new AlpClient(await openSocket(socketPath), options);
|
|
300
|
+
try {
|
|
301
|
+
const greeting = await hello(connection, client, void 0, { agent: typeof process.env.ALP_AGENT_SESSION === "string" && process.env.ALP_AGENT_SESSION !== "" });
|
|
302
|
+
connection.capabilities = Object.freeze(Array.isArray(greeting.capabilities) ? greeting.capabilities.filter((value) => typeof value === "string") : []);
|
|
303
|
+
if (greeting.attachmentLimits && typeof greeting.attachmentLimits === "object") {
|
|
304
|
+
connection.attachmentLimits = Object.freeze({ ...greeting.attachmentLimits });
|
|
305
|
+
}
|
|
306
|
+
if (greeting.promptImageLimits && typeof greeting.promptImageLimits === "object") {
|
|
307
|
+
connection.promptImageLimits = Object.freeze({ ...greeting.promptImageLimits });
|
|
308
|
+
}
|
|
309
|
+
if (greeting.terminalLimits && typeof greeting.terminalLimits === "object") {
|
|
310
|
+
connection.terminalLimits = Object.freeze({ ...greeting.terminalLimits });
|
|
311
|
+
}
|
|
312
|
+
} catch (error) {
|
|
313
|
+
connection.close();
|
|
314
|
+
throw error;
|
|
315
|
+
}
|
|
316
|
+
return connection;
|
|
317
|
+
}
|
|
318
|
+
function launcherReason(text) {
|
|
319
|
+
const line = text.trim().split("\n").filter(Boolean).at(-1);
|
|
320
|
+
if (!line) return "";
|
|
321
|
+
let reason = line;
|
|
322
|
+
try {
|
|
323
|
+
const record = JSON.parse(line);
|
|
324
|
+
reason = `${record.code ? `${record.code}, ` : ""}${record.msg}${record.error?.message ? `: ${record.error.message}` : ""}`;
|
|
325
|
+
} catch {
|
|
326
|
+
}
|
|
327
|
+
return `: ${scrubText(reason, { max: 600 })}`;
|
|
328
|
+
}
|
|
329
|
+
async function tail(file, lines = 30) {
|
|
330
|
+
try {
|
|
331
|
+
return scrubText((await readFile(file, "utf8")).split("\n").slice(-lines).join("\n"), { max: 8e3 });
|
|
332
|
+
} catch {
|
|
333
|
+
return "";
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
async function lifecycleOwners(home) {
|
|
337
|
+
const directory = path.join(home, "state", "alpd.starting");
|
|
338
|
+
const names = await readdir(directory).catch((error) => {
|
|
339
|
+
if (error.code === "ENOENT") return [];
|
|
340
|
+
throw error;
|
|
341
|
+
});
|
|
342
|
+
return names.map((token) => {
|
|
343
|
+
const match = /^owner-(\d+)-(\d+)-(start|stop)-[a-f0-9-]+$/.exec(token);
|
|
344
|
+
if (!match) throw new Error("Invalid alpd startup admission owner");
|
|
345
|
+
return { token, pid: Number(match[1]), bootTime: Number(match[2]), action: match[3] };
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
async function readDaemonLifecycle(home) {
|
|
349
|
+
return (await lifecycleOwners(home)).find((owner) => lockAlive(owner));
|
|
350
|
+
}
|
|
351
|
+
async function withDaemonLifecycle(home, action, run, { joinStart = false, signal = (
|
|
352
|
+
/** @type {AbortSignal | undefined} */
|
|
353
|
+
void 0
|
|
354
|
+
) } = {}) {
|
|
355
|
+
signal?.throwIfAborted();
|
|
356
|
+
try {
|
|
357
|
+
await assertPrivateDirectory(home, { create: true });
|
|
358
|
+
} catch (cause) {
|
|
359
|
+
throw Object.assign(new Error(`ALP_HOME_UNUSABLE, alpd failed to start while preparing its home: ${cause.message}`, { cause }), { code: "ALP_HOME_UNUSABLE" });
|
|
360
|
+
}
|
|
361
|
+
const state = path.join(home, "state");
|
|
362
|
+
await assertPrivateDirectory(state, { create: true });
|
|
363
|
+
const directory = path.join(state, "alpd.starting");
|
|
364
|
+
const currentBootId = bootId();
|
|
365
|
+
const token = `owner-${process.pid}-${bootTime()}-${action}-${randomUUID()}`;
|
|
366
|
+
const candidate = path.join(state, `alpd.starting-${token}`);
|
|
367
|
+
await mkdir(candidate, { mode: 448 });
|
|
368
|
+
await writeFile(path.join(candidate, token), JSON.stringify({
|
|
369
|
+
pid: process.pid,
|
|
370
|
+
bootTime: bootTime(),
|
|
371
|
+
...currentBootId ? { bootId: currentBootId } : {},
|
|
372
|
+
startedUptime: Math.floor(os.uptime()),
|
|
373
|
+
action
|
|
374
|
+
}), { mode: 384 });
|
|
375
|
+
try {
|
|
376
|
+
let joined = false;
|
|
377
|
+
if (joinStart) {
|
|
378
|
+
const owner = await readDaemonLifecycle(home);
|
|
379
|
+
if (owner?.action === "start") {
|
|
380
|
+
try {
|
|
381
|
+
await link(path.join(directory, owner.token), path.join(directory, token));
|
|
382
|
+
joined = true;
|
|
383
|
+
} catch (error) {
|
|
384
|
+
if (error.code !== "ENOENT") throw error;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
while (!joined) {
|
|
389
|
+
signal?.throwIfAborted();
|
|
390
|
+
try {
|
|
391
|
+
await rename(candidate, directory);
|
|
392
|
+
break;
|
|
393
|
+
} catch (error) {
|
|
394
|
+
if (!["EEXIST", "ENOTEMPTY", "EPERM", "EACCES"].includes(error.code)) throw error;
|
|
395
|
+
for (const owner of await lifecycleOwners(home)) {
|
|
396
|
+
if (!lockAlive(owner)) await unlink(path.join(directory, owner.token)).catch((error2) => {
|
|
397
|
+
if (error2.code !== "ENOENT") throw error2;
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
await rmdir(directory).catch((error2) => {
|
|
401
|
+
if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(error2.code)) throw error2;
|
|
402
|
+
});
|
|
403
|
+
await delay(25, void 0, { signal });
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
try {
|
|
407
|
+
signal?.throwIfAborted();
|
|
408
|
+
return await run();
|
|
409
|
+
} finally {
|
|
410
|
+
await unlink(path.join(directory, token));
|
|
411
|
+
await rmdir(directory).catch((error) => {
|
|
412
|
+
if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(error.code)) throw error;
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
} finally {
|
|
416
|
+
await unlink(path.join(candidate, token)).catch((error) => {
|
|
417
|
+
if (error.code !== "ENOENT") throw error;
|
|
418
|
+
});
|
|
419
|
+
await rmdir(candidate).catch((error) => {
|
|
420
|
+
if (error.code !== "ENOENT") throw error;
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
var DAEMON_START_TIMEOUT_MS = 6e4;
|
|
425
|
+
var DAEMON_START_TIMEOUT_MAX_MS = 36e5;
|
|
426
|
+
function daemonStartTimeoutMs(env = process.env) {
|
|
427
|
+
const raw = env.ALP_DAEMON_START_TIMEOUT_MS?.trim();
|
|
428
|
+
if (!raw || !/^[0-9]+$/.test(raw)) return DAEMON_START_TIMEOUT_MS;
|
|
429
|
+
const value = Number(raw);
|
|
430
|
+
return value > 0 && value <= DAEMON_START_TIMEOUT_MAX_MS ? value : DAEMON_START_TIMEOUT_MS;
|
|
431
|
+
}
|
|
432
|
+
async function ensureDaemon({ home = alpHome(), entry = (
|
|
433
|
+
/** @type {string | undefined} */
|
|
434
|
+
void 0
|
|
435
|
+
), env = process.env, execPath = process.execPath, timeoutMs = daemonStartTimeoutMs(env), lifecycleLocked = false, signal = (
|
|
436
|
+
/** @type {AbortSignal | undefined} */
|
|
437
|
+
void 0
|
|
438
|
+
) } = {}) {
|
|
439
|
+
signal?.throwIfAborted();
|
|
440
|
+
if (!lifecycleLocked) return withDaemonLifecycle(home, "start", () => ensureDaemon({ home, entry, env, execPath, timeoutMs, lifecycleLocked: true, signal }), { signal });
|
|
441
|
+
const ready = async () => {
|
|
442
|
+
const lock = await readLock(home);
|
|
443
|
+
return lockAlive(lock) && lock.ready ? lock.socket : void 0;
|
|
444
|
+
};
|
|
445
|
+
const live = await ready();
|
|
446
|
+
if (live) return live;
|
|
447
|
+
const held = await readLock(home);
|
|
448
|
+
if (lockAlive(held) && held.maintenance) throw new Error(`ALP is busy: alp ${held.maintenance} runs (pid ${held.pid}); alpd starts again when it finishes`);
|
|
449
|
+
if (!lockAlive(held)) {
|
|
450
|
+
entry ??= await findDaemonEntry({ home, env });
|
|
451
|
+
if (!entry) throw new Error("ALP daemon is not running and alpd.js was not found. Install the ALP CLI and run `alp daemon start`, or set ALP_DAEMON_ENTRY to alpd.js");
|
|
452
|
+
signal?.throwIfAborted();
|
|
453
|
+
await new Promise((resolve, reject) => {
|
|
454
|
+
const launch = entryCommand(entry, "daemon", ["--detach", `--startup-timeout=${timeoutMs}`], execPath);
|
|
455
|
+
const launchEnv = { ...env, ALP_HOME: home, ELECTRON_RUN_AS_NODE: "1" };
|
|
456
|
+
if (isNativeDaemonName(launch.command)) delete launchEnv.BUN_BE_BUN;
|
|
457
|
+
const launcher = spawn(launch.command, launch.args, {
|
|
458
|
+
env: launchEnv,
|
|
459
|
+
stdio: ["ignore", "ignore", "pipe"],
|
|
460
|
+
windowsHide: true
|
|
461
|
+
});
|
|
462
|
+
let failure = "";
|
|
463
|
+
launcher.stderr.on("data", (chunk) => {
|
|
464
|
+
if (failure.length < 8e3) failure += chunk;
|
|
465
|
+
});
|
|
466
|
+
launcher.once("error", reject);
|
|
467
|
+
launcher.once("close", (code) => code === 0 ? resolve() : reject(new Error(`ALP daemon launcher exited (${code})${launcherReason(failure)}`)));
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
const deadline = Date.now() + timeoutMs;
|
|
471
|
+
while (Date.now() < deadline) {
|
|
472
|
+
signal?.throwIfAborted();
|
|
473
|
+
const socket = await ready();
|
|
474
|
+
if (socket) return socket;
|
|
475
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
476
|
+
}
|
|
477
|
+
const log = await tail(daemonPaths(home).log);
|
|
478
|
+
throw new Error(`ALP daemon did not become ready within ${timeoutMs} ms${log ? `
|
|
479
|
+
${log}` : ""}`);
|
|
480
|
+
}
|
|
481
|
+
var INTEGRATION_DESCRIPTOR_FIELDS = ["main", "entry", "path", "command"];
|
|
482
|
+
async function readIntegrationDescriptor(file, baseDirs = []) {
|
|
483
|
+
try {
|
|
484
|
+
const raw = JSON.parse(await readFile(file, "utf8"));
|
|
485
|
+
for (const field of INTEGRATION_DESCRIPTOR_FIELDS) {
|
|
486
|
+
const value = raw?.[field];
|
|
487
|
+
if (typeof value !== "string" || !value.trim()) continue;
|
|
488
|
+
if (path.isAbsolute(value)) {
|
|
489
|
+
if (await isFile(value)) return value;
|
|
490
|
+
} else {
|
|
491
|
+
const bases = [path.dirname(file), ...baseDirs];
|
|
492
|
+
for (const base of bases) {
|
|
493
|
+
const resolved = path.resolve(base, value);
|
|
494
|
+
if (await isFile(resolved)) return resolved;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
} catch {
|
|
499
|
+
}
|
|
500
|
+
return void 0;
|
|
501
|
+
}
|
|
502
|
+
async function integrationCandidateFromHome(home, name) {
|
|
503
|
+
const descriptors = [
|
|
504
|
+
path.join(home, "integrations", `${name}.json`),
|
|
505
|
+
path.join(home, "integrations", name, "integration.json")
|
|
506
|
+
];
|
|
507
|
+
for (const descriptor of descriptors) {
|
|
508
|
+
const entry = await readIntegrationDescriptor(descriptor, [home]);
|
|
509
|
+
if (entry) return entry;
|
|
510
|
+
}
|
|
511
|
+
const legacy = path.join(home, "integrations", name, "main.js");
|
|
512
|
+
return await isFile(legacy) ? legacy : void 0;
|
|
513
|
+
}
|
|
514
|
+
function integrationBinaryName(name) {
|
|
515
|
+
return `alp-${name}-integration`;
|
|
516
|
+
}
|
|
517
|
+
async function distributionRoots() {
|
|
518
|
+
const roots = [];
|
|
519
|
+
const argv = process.argv[1] ? await realpath(process.argv[1]).catch(() => process.argv[1]) : void 0;
|
|
520
|
+
if (argv) {
|
|
521
|
+
let directory = path.dirname(argv);
|
|
522
|
+
for (let depth = 0; depth < 4; depth += 1) {
|
|
523
|
+
roots.push(path.resolve(directory, ".."));
|
|
524
|
+
directory = path.resolve(directory, "..");
|
|
525
|
+
}
|
|
526
|
+
for (let ancestor = path.dirname(argv); ; ancestor = path.dirname(ancestor)) {
|
|
527
|
+
if (await isFile(path.join(ancestor, "package.json"))) roots.push(ancestor);
|
|
528
|
+
if (path.dirname(ancestor) === ancestor) break;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
roots.push(process.cwd());
|
|
532
|
+
return [...new Set(roots)];
|
|
533
|
+
}
|
|
534
|
+
async function discoverIntegration(name = "dashboard", options = {}) {
|
|
535
|
+
assertIntegrationName(name);
|
|
536
|
+
if (name === "dashboard" || name === "web") return void 0;
|
|
537
|
+
const { env = process.env, binDirectories = BIN_DIRECTORIES, roots } = options;
|
|
538
|
+
const envCandidates = [
|
|
539
|
+
env[`ALP_${name.toUpperCase()}_INTEGRATION`],
|
|
540
|
+
name === "paseo" ? env.ALP_WEB_INTEGRATION : void 0,
|
|
541
|
+
env.ALP_INTEGRATION_ENTRY
|
|
542
|
+
].filter(Boolean);
|
|
543
|
+
for (const candidate of envCandidates) if (await isFile(candidate)) return candidate;
|
|
544
|
+
const home = options?.home ? path.resolve(options.home) : alpHome();
|
|
545
|
+
const fromHome = await integrationCandidateFromHome(home, name);
|
|
546
|
+
if (fromHome) return fromHome;
|
|
547
|
+
for (const root of roots ?? await distributionRoots()) {
|
|
548
|
+
for (const descriptorPath of [path.join(root, "integrations", `${name}.json`), path.join(root, "integrations", name, "integration.json")]) {
|
|
549
|
+
const entry = await readIntegrationDescriptor(descriptorPath, [root]);
|
|
550
|
+
if (entry) return entry;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
const binary = integrationBinaryName(name);
|
|
554
|
+
for (const directory of [...(env.PATH ?? "").split(path.delimiter).filter(Boolean), ...binDirectories]) {
|
|
555
|
+
const candidate = await realpath(path.join(directory, binary)).catch(() => void 0);
|
|
556
|
+
if (candidate && await isFile(candidate)) return candidate;
|
|
557
|
+
}
|
|
558
|
+
return void 0;
|
|
559
|
+
}
|
|
560
|
+
function integrationAlive(lock) {
|
|
561
|
+
if (!lock || !Number.isSafeInteger(lock.pid) || !isSameBoot(lock)) return false;
|
|
562
|
+
try {
|
|
563
|
+
process.kill(lock.pid, 0);
|
|
564
|
+
return true;
|
|
565
|
+
} catch (error) {
|
|
566
|
+
return error?.code === "EPERM";
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
function integrationText(name, home) {
|
|
570
|
+
const logs = path.join(home, "logs", "integrations");
|
|
571
|
+
if (name === "dashboard") return {
|
|
572
|
+
what: "alp dashboard",
|
|
573
|
+
log: path.join(logs, "alp-dashboard.log"),
|
|
574
|
+
missing: "alp dashboard runs the alp-dashboard service of the ALP CLI, which is started with its entry (packages/cli/dist/alp-dashboard.js); run `alp dashboard`"
|
|
575
|
+
};
|
|
576
|
+
if (name === "paseo") return {
|
|
577
|
+
what: "The Paseo integration",
|
|
578
|
+
log: path.join(logs, "paseo.log"),
|
|
579
|
+
missing: "The Paseo integration is an optional integration package. Install it (for example `npm install -g @anhlp/alp-paseo@beta`), then run the command again."
|
|
580
|
+
};
|
|
581
|
+
return {
|
|
582
|
+
what: `ALP integration ${name}`,
|
|
583
|
+
log: path.join(logs, `${name}.log`),
|
|
584
|
+
missing: `ALP integration ${name} is not installed: no ALP_${name.toUpperCase()}_INTEGRATION, descriptor <home>/integrations/${name}.json or alp-${name}-integration binary was found.`
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
async function startIntegration(nameOrOptions = "dashboard") {
|
|
588
|
+
const options = typeof nameOrOptions === "string" ? { name: nameOrOptions } : nameOrOptions ?? {};
|
|
589
|
+
const name = assertIntegrationName(options.name ?? "dashboard");
|
|
590
|
+
if (options.entry !== void 0 && (typeof options.entry !== "string" || !options.entry)) throw new TypeError("startIntegration entry must be a non-empty path");
|
|
591
|
+
const args = options.args ?? [];
|
|
592
|
+
if (!Array.isArray(args) || !args.every((arg) => typeof arg === "string")) throw new TypeError("startIntegration args must be a list of strings");
|
|
593
|
+
const fs = await import("node:fs/promises");
|
|
594
|
+
const pathMod = await import("node:path");
|
|
595
|
+
const home = options.home ? pathMod.resolve(options.home) : alpHome();
|
|
596
|
+
const text = integrationText(name, home);
|
|
597
|
+
const explicit = options.entry !== void 0 ? pathMod.resolve(options.entry) : void 0;
|
|
598
|
+
if (explicit !== void 0 && !await isFile(explicit)) throw new Error(`${text.what}: integration entry not found: ${explicit}`);
|
|
599
|
+
const lockPath = pathMod.join(home, "integrations", `${name}.lock`);
|
|
600
|
+
const webPath = pathMod.join(home, `${name}.json`);
|
|
601
|
+
const started = explicit ? ` (entry ${explicit})` : "";
|
|
602
|
+
if (name === "dashboard") {
|
|
603
|
+
let settings = {};
|
|
604
|
+
try {
|
|
605
|
+
settings = JSON.parse(await fs.readFile(pathMod.join(home, "settings.json"), "utf8"));
|
|
606
|
+
} catch {
|
|
607
|
+
}
|
|
608
|
+
if (dashboardSettings(settings).enabled === false) throw new Error('alp dashboard is disabled by settings ("dashboard.enabled": false).');
|
|
609
|
+
}
|
|
610
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
611
|
+
const readLock2 = async () => {
|
|
612
|
+
try {
|
|
613
|
+
return JSON.parse(await fs.readFile(lockPath, "utf8"));
|
|
614
|
+
} catch {
|
|
615
|
+
return void 0;
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
const readWeb = async () => {
|
|
619
|
+
try {
|
|
620
|
+
return JSON.parse(await fs.readFile(webPath, "utf8"));
|
|
621
|
+
} catch {
|
|
622
|
+
return void 0;
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
async function waitForReady() {
|
|
626
|
+
const deadline = Date.now() + 3e4;
|
|
627
|
+
while (Date.now() < deadline) {
|
|
628
|
+
const lock2 = await readLock2();
|
|
629
|
+
if (lock2 && integrationAlive(lock2) && lock2.ready) {
|
|
630
|
+
const info = await readWeb();
|
|
631
|
+
if (info && info.pid === lock2.pid) return lock2;
|
|
632
|
+
}
|
|
633
|
+
if (name === "dashboard" && webStartupFailed()) throw new Error(`${text.what}${started} failed to start; see ${text.log}`);
|
|
634
|
+
await sleep(100);
|
|
635
|
+
}
|
|
636
|
+
const lock = await readLock2();
|
|
637
|
+
if (lock && !lock.ready) throw new Error(`${text.what}${started} started but did not become ready; see ${text.log}`);
|
|
638
|
+
if (!lock) throw new Error(explicit ? `${text.what}${started} did not start; see ${text.log}` : text.missing);
|
|
639
|
+
throw new Error(`${text.what}${started} did not publish a ${name}.json matching its lock; see ${text.log}`);
|
|
640
|
+
}
|
|
641
|
+
let webStartupFailed = () => false;
|
|
642
|
+
const existing = await readLock2();
|
|
643
|
+
if (existing && integrationAlive(existing)) {
|
|
644
|
+
return waitForReady();
|
|
645
|
+
}
|
|
646
|
+
const entry = explicit ?? await discoverIntegration(name, { home });
|
|
647
|
+
if (!entry) throw new Error(text.missing);
|
|
648
|
+
const { spawn: spawn2 } = await import("node:child_process");
|
|
649
|
+
const launch = name === "dashboard" ? entryCommand(entry, "dashboard", ["--service", ...args]) : entryCommand(entry, "dashboard", ["--service", ...args], void 0, { scriptOnly: true });
|
|
650
|
+
const child = spawn2(launch.command, launch.args, { stdio: "ignore", detached: true, env: { ...process.env, ALP_HOME: home } });
|
|
651
|
+
let spawnError = null;
|
|
652
|
+
child.on("error", (error) => {
|
|
653
|
+
spawnError = error;
|
|
654
|
+
});
|
|
655
|
+
let exited = false;
|
|
656
|
+
child.on("exit", (code) => {
|
|
657
|
+
if (code !== 0 && code !== null) exited = true;
|
|
658
|
+
});
|
|
659
|
+
child.unref();
|
|
660
|
+
webStartupFailed = () => exited;
|
|
661
|
+
if (spawnError) throw spawnError;
|
|
662
|
+
await sleep(150);
|
|
663
|
+
if (spawnError) throw spawnError;
|
|
664
|
+
if (exited) throw new Error(`${text.what}${explicit ? started : ` (${entry})`} failed to start; see ${text.log}`);
|
|
665
|
+
return waitForReady();
|
|
666
|
+
}
|
|
667
|
+
export {
|
|
668
|
+
AlpClient,
|
|
669
|
+
AlpRpcError,
|
|
670
|
+
CLOSE_CODE,
|
|
671
|
+
DAEMON_START_TIMEOUT_MS,
|
|
672
|
+
MAX_FRAME,
|
|
673
|
+
PROTOCOL_VERSION,
|
|
674
|
+
_setBootIdForTest,
|
|
675
|
+
acquireDaemonLock,
|
|
676
|
+
alpHome,
|
|
677
|
+
assertIntegrationName,
|
|
678
|
+
assertPrivateDirectory,
|
|
679
|
+
assertPrivateSocket,
|
|
680
|
+
bootId,
|
|
681
|
+
bootTime,
|
|
682
|
+
connect,
|
|
683
|
+
connectSocket,
|
|
684
|
+
connectWebSocket,
|
|
685
|
+
createSocketTransport2 as createSocketTransport,
|
|
686
|
+
createWebSocketTransport,
|
|
687
|
+
daemonPaths,
|
|
688
|
+
daemonStartTimeoutMs,
|
|
689
|
+
discoverIntegration,
|
|
690
|
+
encodeFrame,
|
|
691
|
+
ensureDaemon,
|
|
692
|
+
findDaemonEntry,
|
|
693
|
+
integrationAlive,
|
|
694
|
+
isSameBoot,
|
|
695
|
+
lockAlive,
|
|
696
|
+
readDaemonLifecycle,
|
|
697
|
+
readLock,
|
|
698
|
+
redactUrl,
|
|
699
|
+
releaseDaemonLock,
|
|
700
|
+
startIntegration,
|
|
701
|
+
withDaemonLifecycle
|
|
702
|
+
};
|