@anhlp/alp-cli 0.0.1-beta.6 → 0.0.1-beta.7
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/acp/main.js +1 -1
- package/dist/acp.js +91 -147
- package/dist/alp-web/assets/{TerminalPanel-CqTsgY-W.js → TerminalPanel-BeMws9CP.js} +1 -1
- package/dist/alp-web/assets/index-Dl7motn1.js +59 -0
- package/dist/alp-web/assets/index-DwqDSiIi.css +1 -0
- package/dist/alp-web/index.html +2 -2
- package/dist/alp-web.js +102 -224
- package/dist/alpd.js +744 -867
- package/dist/backup.js +1 -1
- package/dist/build-manifest.json +1 -1
- package/dist/cli.js +4 -8
- package/dist/interfaces.js +2 -3
- package/dist/paths.d.ts +1 -1
- package/dist/roles.d.ts +3 -3
- package/dist/roles.js +1 -3
- package/dist/self-update.d.ts +35 -38
- package/dist/self-update.js +107 -98
- package/dist/usage.d.ts +1 -1
- package/dist/usage.js +2 -2
- package/dist/web-service.js +2 -2
- package/package.json +5 -5
- package/src/cli.js +6 -9
- package/src/interfaces.js +2 -3
- package/src/paths.js +1 -1
- package/src/roles.js +4 -6
- package/src/self-update.js +112 -112
- package/src/usage.js +2 -2
- package/src/web-service.js +3 -4
- package/dist/alp-web/assets/index-BMbDUCHW.css +0 -1
- package/dist/alp-web/assets/index-B_RFaj2C.js +0 -59
package/dist/acp/main.js
CHANGED
|
@@ -6,7 +6,7 @@ import { startDaemon } from "@anhlp/alp-client/supervise";
|
|
|
6
6
|
import { createLogger } from "@anhlp/alp-core/log";
|
|
7
7
|
import { createAcpAgent } from "./agent.js";
|
|
8
8
|
async function runAcp({ daemonEntry }) {
|
|
9
|
-
const version = true ? "0.0.1-beta.
|
|
9
|
+
const version = true ? "0.0.1-beta.7" : "0.0.0";
|
|
10
10
|
const logger = createLogger({ component: "acp" });
|
|
11
11
|
const log = (message, fields) => logger.warn(message, fields);
|
|
12
12
|
const app = createAcpAgent({
|
package/dist/acp.js
CHANGED
|
@@ -820,10 +820,10 @@ function mergeDefs(...defs) {
|
|
|
820
820
|
function cloneDef(schema) {
|
|
821
821
|
return mergeDefs(schema._zod.def);
|
|
822
822
|
}
|
|
823
|
-
function getElementAtPath(obj,
|
|
824
|
-
if (!
|
|
823
|
+
function getElementAtPath(obj, path5) {
|
|
824
|
+
if (!path5)
|
|
825
825
|
return obj;
|
|
826
|
-
return
|
|
826
|
+
return path5.reduce((acc, key) => acc?.[key], obj);
|
|
827
827
|
}
|
|
828
828
|
function promiseAllObject(promisesObj) {
|
|
829
829
|
const keys = Object.keys(promisesObj);
|
|
@@ -1232,11 +1232,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1232
1232
|
}
|
|
1233
1233
|
return false;
|
|
1234
1234
|
}
|
|
1235
|
-
function prefixIssues(
|
|
1235
|
+
function prefixIssues(path5, issues) {
|
|
1236
1236
|
return issues.map((iss) => {
|
|
1237
1237
|
var _a3;
|
|
1238
1238
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1239
|
-
iss.path.unshift(
|
|
1239
|
+
iss.path.unshift(path5);
|
|
1240
1240
|
return iss;
|
|
1241
1241
|
});
|
|
1242
1242
|
}
|
|
@@ -1383,16 +1383,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1383
1383
|
}
|
|
1384
1384
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
1385
1385
|
const fieldErrors = { _errors: [] };
|
|
1386
|
-
const processError = (error52,
|
|
1386
|
+
const processError = (error52, path5 = []) => {
|
|
1387
1387
|
for (const issue2 of error52.issues) {
|
|
1388
1388
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1389
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1389
|
+
issue2.errors.map((issues) => processError({ issues }, [...path5, ...issue2.path]));
|
|
1390
1390
|
} else if (issue2.code === "invalid_key") {
|
|
1391
|
-
processError({ issues: issue2.issues }, [...
|
|
1391
|
+
processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
|
|
1392
1392
|
} else if (issue2.code === "invalid_element") {
|
|
1393
|
-
processError({ issues: issue2.issues }, [...
|
|
1393
|
+
processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
|
|
1394
1394
|
} else {
|
|
1395
|
-
const fullpath = [...
|
|
1395
|
+
const fullpath = [...path5, ...issue2.path];
|
|
1396
1396
|
if (fullpath.length === 0) {
|
|
1397
1397
|
fieldErrors._errors.push(mapper(issue2));
|
|
1398
1398
|
} else {
|
|
@@ -1419,17 +1419,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1419
1419
|
}
|
|
1420
1420
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
1421
1421
|
const result = { errors: [] };
|
|
1422
|
-
const processError = (error52,
|
|
1422
|
+
const processError = (error52, path5 = []) => {
|
|
1423
1423
|
var _a3, _b;
|
|
1424
1424
|
for (const issue2 of error52.issues) {
|
|
1425
1425
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1426
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1426
|
+
issue2.errors.map((issues) => processError({ issues }, [...path5, ...issue2.path]));
|
|
1427
1427
|
} else if (issue2.code === "invalid_key") {
|
|
1428
|
-
processError({ issues: issue2.issues }, [...
|
|
1428
|
+
processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
|
|
1429
1429
|
} else if (issue2.code === "invalid_element") {
|
|
1430
|
-
processError({ issues: issue2.issues }, [...
|
|
1430
|
+
processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
|
|
1431
1431
|
} else {
|
|
1432
|
-
const fullpath = [...
|
|
1432
|
+
const fullpath = [...path5, ...issue2.path];
|
|
1433
1433
|
if (fullpath.length === 0) {
|
|
1434
1434
|
result.errors.push(mapper(issue2));
|
|
1435
1435
|
continue;
|
|
@@ -1461,8 +1461,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1461
1461
|
}
|
|
1462
1462
|
function toDotPath(_path) {
|
|
1463
1463
|
const segs = [];
|
|
1464
|
-
const
|
|
1465
|
-
for (const seg of
|
|
1464
|
+
const path5 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1465
|
+
for (const seg of path5) {
|
|
1466
1466
|
if (typeof seg === "number")
|
|
1467
1467
|
segs.push(`[${seg}]`);
|
|
1468
1468
|
else if (typeof seg === "symbol")
|
|
@@ -14154,13 +14154,13 @@ function resolveRef(ref, ctx) {
|
|
|
14154
14154
|
if (!ref.startsWith("#")) {
|
|
14155
14155
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14156
14156
|
}
|
|
14157
|
-
const
|
|
14158
|
-
if (
|
|
14157
|
+
const path5 = ref.slice(1).split("/").filter(Boolean);
|
|
14158
|
+
if (path5.length === 0) {
|
|
14159
14159
|
return ctx.rootSchema;
|
|
14160
14160
|
}
|
|
14161
14161
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14162
|
-
if (
|
|
14163
|
-
const key =
|
|
14162
|
+
if (path5[0] === defsKey) {
|
|
14163
|
+
const key = path5[1];
|
|
14164
14164
|
if (!key || !ctx.defs[key]) {
|
|
14165
14165
|
throw new Error(`Reference not found: ${ref}`);
|
|
14166
14166
|
}
|
|
@@ -18421,11 +18421,11 @@ import { Readable, Writable } from "node:stream";
|
|
|
18421
18421
|
import { setTimeout as delay } from "node:timers/promises";
|
|
18422
18422
|
import { execFileSync, spawn } from "node:child_process";
|
|
18423
18423
|
import { createHash, randomUUID } from "node:crypto";
|
|
18424
|
-
import { readFileSync
|
|
18424
|
+
import { readFileSync } from "node:fs";
|
|
18425
18425
|
import { open, readFile, writeFile, realpath, stat, lstat, mkdir, readlink, unlink, readdir, rename, rmdir, link } from "node:fs/promises";
|
|
18426
18426
|
import net from "node:net";
|
|
18427
18427
|
import os from "node:os";
|
|
18428
|
-
import
|
|
18428
|
+
import path from "node:path";
|
|
18429
18429
|
|
|
18430
18430
|
// packages/core/src/log.js
|
|
18431
18431
|
var LEVELS = Object.freeze({ debug: 10, info: 20, warn: 30, error: 40 });
|
|
@@ -18543,36 +18543,13 @@ function createLogger({ component, level, context = {}, write = stderrSink, now
|
|
|
18543
18543
|
var TAIL_BYTES = 256 * 1024;
|
|
18544
18544
|
|
|
18545
18545
|
// packages/core/src/packaged.js
|
|
18546
|
-
import { chmodSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
18547
|
-
import path from "node:path";
|
|
18548
|
-
var KEY = Symbol.for("alp.packaged");
|
|
18549
18546
|
var ROLE_ARGS = Object.freeze({
|
|
18550
18547
|
daemon: Object.freeze(["daemon", "run"]),
|
|
18551
18548
|
web: Object.freeze(["web", "serve"]),
|
|
18552
18549
|
"bridge-acp": Object.freeze(["bridge", "acp"]),
|
|
18553
18550
|
"bridge-antigravity": Object.freeze(["bridge", "antigravity"])
|
|
18554
18551
|
});
|
|
18555
|
-
|
|
18556
|
-
return (
|
|
18557
|
-
/** @type {any} */
|
|
18558
|
-
globalThis[KEY]
|
|
18559
|
-
);
|
|
18560
|
-
}
|
|
18561
|
-
function isPackaged() {
|
|
18562
|
-
return packagedInfo() !== void 0;
|
|
18563
|
-
}
|
|
18564
|
-
var EXECUTABLE_MARKER = "alp-standalone-executable:v1:2b6f0c1e";
|
|
18565
|
-
var isExecutableName = (file2) => /^alp(\.exe)?$/i.test(file2.split(/[\\/]/).pop() ?? "");
|
|
18566
|
-
var isSelf = (file2) => isPackaged() && typeof file2 === "string" && samePath(file2, process.execPath);
|
|
18567
|
-
var canonical = (file2) => {
|
|
18568
|
-
let resolved = path.resolve(file2);
|
|
18569
|
-
try {
|
|
18570
|
-
resolved = realpathSync.native(resolved);
|
|
18571
|
-
} catch {
|
|
18572
|
-
}
|
|
18573
|
-
return process.platform === "darwin" || process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
18574
|
-
};
|
|
18575
|
-
var samePath = (a, b) => canonical(a) === canonical(b);
|
|
18552
|
+
var isExecutableName = (file2) => /^alp(\.exe|\.cmd)?$/i.test(file2.split(/[\\/]/).pop() ?? "");
|
|
18576
18553
|
var isScript = (file2) => /\.[cm]?js$/i.test(file2);
|
|
18577
18554
|
function roleArgs(role) {
|
|
18578
18555
|
const args = ROLE_ARGS[role];
|
|
@@ -18580,21 +18557,12 @@ function roleArgs(role) {
|
|
|
18580
18557
|
return [...args];
|
|
18581
18558
|
}
|
|
18582
18559
|
function entryCommand(entry, role, args = [], execPath = process.execPath, { scriptOnly = false } = {}) {
|
|
18583
|
-
if (scriptOnly || isScript(entry) || !
|
|
18584
|
-
if (isPackaged() && execPath === process.execPath) return { command: "node", args: [entry, ...args] };
|
|
18585
|
-
return { command: execPath, args: [entry, ...args] };
|
|
18586
|
-
}
|
|
18560
|
+
if (scriptOnly || isScript(entry) || !isExecutableName(entry)) return { command: execPath, args: [entry, ...args] };
|
|
18587
18561
|
return { command: entry, args: [...roleArgs(role), ...args] };
|
|
18588
18562
|
}
|
|
18589
18563
|
function scriptCommand(script, args = []) {
|
|
18590
|
-
if (isPackaged()) return { command: process.execPath, args: [script, ...args], env: { BUN_BE_BUN: "1" } };
|
|
18591
18564
|
return { command: process.execPath, args: [script, ...args] };
|
|
18592
18565
|
}
|
|
18593
|
-
function executablePath() {
|
|
18594
|
-
return isPackaged() ? process.execPath : void 0;
|
|
18595
|
-
}
|
|
18596
|
-
var STALE_MS = 60 * 60 * 1e3;
|
|
18597
|
-
var SWEEP_MIN_MS = 10 * 60 * 1e3;
|
|
18598
18566
|
|
|
18599
18567
|
// packages/protocol/src/wire.js
|
|
18600
18568
|
var PROTOCOL_VERSION2 = 1;
|
|
@@ -18608,9 +18576,9 @@ var AlpRpcError = class extends Error {
|
|
|
18608
18576
|
};
|
|
18609
18577
|
var ERROR = Object.freeze({ failed: 1e3, notFound: 1001, forbidden: 1003, conflict: 1004, unavailable: 1005, protocol: 1006 });
|
|
18610
18578
|
var RPC_ERROR = Object.freeze({ parseError: -32700, invalidRequest: -32600, methodNotFound: -32601, invalidParams: -32602 });
|
|
18611
|
-
var CAPABILITY = Object.freeze({ sessionInterruptTurn: "session.interrupt.turn", catalogLive: "catalog.live", attachAfter: "attach.after", sessionHistory: "session.history", workspaceRegistry: "workspace.registry", workspaceWorktree: "workspace.worktree", workspaceGit: "workspace.git", workspaceGitFacts: "workspace.git.facts", promptReceipts: "prompt.receipts", extensionMethods: "extension.methods", team: "team", task: "task", library: "library", libraryProjectWrite: "library.project.write", settingsLanguage: "settings.language", sessionListPage: "session.list.page", questionWatch: "question.watch", questionWatchTurns: "question.watch.turns", sessionAttention: "session.attention", workspaceFiles: "workspace.files", workspaceFilesRead: "workspace.files.read", workspaceFilesBrowse: "workspace.files.browse", hostDirectories: "host.directories", promptImages: "prompt.images", schedule: "schedule", attachments: "attachments", sessionFork: "session.fork", sessionRewind: "session.rewind", sessionReload: "session.reload", sessionResumeCommand: "session.resumeCommand", sessionConfigureLive: "session.configure.live", terminal: "terminal", terminalCapture: "terminal.capture", terminalWatch: "terminal.watch" });
|
|
18579
|
+
var CAPABILITY = Object.freeze({ sessionInterruptTurn: "session.interrupt.turn", catalogLive: "catalog.live", attachAfter: "attach.after", sessionHistory: "session.history", workspaceRegistry: "workspace.registry", workspaceWorktree: "workspace.worktree", workspaceGit: "workspace.git", workspaceGitFacts: "workspace.git.facts", promptReceipts: "prompt.receipts", extensionMethods: "extension.methods", team: "team", task: "task", library: "library", libraryProjectWrite: "library.project.write", settingsLanguage: "settings.language", sessionListPage: "session.list.page", questionWatch: "question.watch", questionWatchTurns: "question.watch.turns", sessionAttention: "session.attention", workspaceFiles: "workspace.files", workspaceFilesRead: "workspace.files.read", workspaceFilesBrowse: "workspace.files.browse", hostDirectories: "host.directories", promptImages: "prompt.images", schedule: "schedule", attachments: "attachments", sessionFork: "session.fork", sessionRewind: "session.rewind", sessionReload: "session.reload", sessionResumeCommand: "session.resumeCommand", sessionCommands: "session.commands", sessionConfigureLive: "session.configure.live", terminal: "terminal", terminalCapture: "terminal.capture", terminalWatch: "terminal.watch" });
|
|
18612
18580
|
var PROMPT_IMAGES = Object.freeze({ mimeTypes: Object.freeze(["image/png", "image/jpeg", "image/gif", "image/webp"]), maxCount: 8, maxBytes: 5 * 1024 * 1024, maxTotalBytes: 11 * 1024 * 1024 });
|
|
18613
|
-
var RPC_METHODS = Object.freeze(["assignment.recall", "attachment.abort", "attachment.begin", "attachment.chunk", "attachment.commit", "attachment.delete", "attachment.get", "board.list", "catalog.get", "catalog.refresh", "daemon.hello", "daemon.pause", "daemon.pauses", "daemon.resume", "daemon.shutdown", "daemon.status", "daemon.usage", "extension.register", "extension.unregister", "host.directories.search", "library.delete", "library.duplicate", "library.get", "library.list", "library.models", "library.rename", "library.save", "library.skills.set", "project.list", "project.register", "project.remove", "question.answer", "question.list", "question.watch", "registry.owner", "registry.worktree", "schedule.cancel", "schedule.create", "schedule.get", "schedule.list", "session.archive", "session.attach", "session.attention.clear", "session.close", "session.compact", "session.configure", "session.configure.preview", "session.create", "session.fork", "session.get", "session.history", "session.interrupt", "session.list", "session.log", "session.message", "session.preview", "session.prompt", "session.release", "session.reload", "session.rename", "session.resumeCommand", "session.rewind", "session.status", "settings.language.get", "settings.language.set", "task.create", "task.gate.resolve", "task.list", "task.update", "team.list", "terminal.attach", "terminal.close", "terminal.capture", "terminal.create", "terminal.input", "terminal.list", "terminal.watch", "terminal.unwatch", "terminal.resize", "terminal.revoke", "workspace.files.find", "workspace.files.list", "workspace.files.preview", "workspace.files.read", "workspace.files.search", "workspace.get", "workspace.git.diff", "workspace.git.facts", "workspace.git.status", "workspace.list", "workspace.update", "workspace.worktree.create", "workspace.worktree.options", "workspace.worktree.remove"]);
|
|
18581
|
+
var RPC_METHODS = Object.freeze(["assignment.recall", "attachment.abort", "attachment.begin", "attachment.chunk", "attachment.commit", "attachment.delete", "attachment.get", "board.list", "catalog.get", "catalog.refresh", "daemon.hello", "daemon.pause", "daemon.pauses", "daemon.resume", "daemon.shutdown", "daemon.status", "daemon.usage", "extension.register", "extension.unregister", "host.directories.search", "library.delete", "library.duplicate", "library.get", "library.list", "library.models", "library.rename", "library.save", "library.skills.set", "project.list", "project.register", "project.remove", "question.answer", "question.list", "question.watch", "registry.owner", "registry.worktree", "schedule.cancel", "schedule.create", "schedule.get", "schedule.list", "session.archive", "session.attach", "session.attention.clear", "session.close", "session.commands", "session.compact", "session.configure", "session.configure.preview", "session.create", "session.fork", "session.get", "session.history", "session.interrupt", "session.list", "session.log", "session.message", "session.preview", "session.prompt", "session.release", "session.reload", "session.rename", "session.resumeCommand", "session.rewind", "session.status", "settings.language.get", "settings.language.set", "task.create", "task.gate.resolve", "task.list", "task.update", "team.list", "terminal.attach", "terminal.close", "terminal.capture", "terminal.create", "terminal.input", "terminal.list", "terminal.watch", "terminal.unwatch", "terminal.resize", "terminal.revoke", "workspace.files.find", "workspace.files.list", "workspace.files.preview", "workspace.files.read", "workspace.files.search", "workspace.get", "workspace.git.diff", "workspace.git.facts", "workspace.git.status", "workspace.list", "workspace.update", "workspace.worktree.create", "workspace.worktree.options", "workspace.worktree.remove"]);
|
|
18614
18582
|
var WORKSPACE_FILES = Object.freeze({ maxReadBytes: 1024 * 1024, maxListEntries: 1e3, maxPathLength: 4096, maxPreviewBytes: 50 * 1024 * 1024, maxPreviewChunkBytes: 8 * 1024 * 1024, maxFindEntries: 1e3 });
|
|
18615
18583
|
var WORKSPACE_GIT = Object.freeze({ maxFileBytes: 1024 * 1024, maxTotalBytes: 2 * 1024 * 1024, maxUntracked: 200, maxStatusFiles: 1e3, maxRefLength: 255 });
|
|
18616
18584
|
var ATTACHMENTS = Object.freeze({
|
|
@@ -19090,27 +19058,27 @@ var CLOSE_CODE = Object.freeze({ unsupportedData: 4003, tooLarge: 4009 });
|
|
|
19090
19058
|
|
|
19091
19059
|
// packages/client/src/index.js
|
|
19092
19060
|
function alpHome(env = process.env) {
|
|
19093
|
-
return
|
|
19061
|
+
return path.resolve(env.ALP_HOME || path.join(os.homedir(), ".alp"));
|
|
19094
19062
|
}
|
|
19095
19063
|
function daemonPaths(home) {
|
|
19096
|
-
const preferred =
|
|
19097
|
-
const socket = process.platform === "win32" ? `\\\\.\\pipe\\alpd-${createHash("sha256").update(home).digest("hex").slice(0, 24)}` : Buffer.byteLength(preferred) < 100 ? preferred :
|
|
19098
|
-
return { home, lock:
|
|
19064
|
+
const preferred = path.join(home, "alpd.sock");
|
|
19065
|
+
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");
|
|
19066
|
+
return { home, lock: path.join(home, "alpd.lock"), socket, log: path.join(home, "logs", "alpd.log"), install: path.join(home, "alpd.json") };
|
|
19099
19067
|
}
|
|
19100
19068
|
async function assertSafeAncestors(directory) {
|
|
19101
19069
|
if (process.platform === "win32") return;
|
|
19102
|
-
const absolute =
|
|
19103
|
-
let current =
|
|
19070
|
+
const absolute = path.isAbsolute(directory) ? directory : `${process.cwd()}/${directory}`;
|
|
19071
|
+
let current = path.parse(absolute).root;
|
|
19104
19072
|
const pending = absolute.slice(current.length).split("/");
|
|
19105
19073
|
let links = 0;
|
|
19106
19074
|
while (pending.length) {
|
|
19107
19075
|
const part = pending.shift();
|
|
19108
19076
|
if (!part || part === ".") continue;
|
|
19109
19077
|
if (part === "..") {
|
|
19110
|
-
current =
|
|
19078
|
+
current = path.dirname(current);
|
|
19111
19079
|
continue;
|
|
19112
19080
|
}
|
|
19113
|
-
const candidate =
|
|
19081
|
+
const candidate = path.join(current, part);
|
|
19114
19082
|
const info = await lstat(candidate).catch((error51) => {
|
|
19115
19083
|
if (error51.code !== "ENOENT") throw error51;
|
|
19116
19084
|
});
|
|
@@ -19123,8 +19091,8 @@ async function assertSafeAncestors(directory) {
|
|
|
19123
19091
|
if (info.isSymbolicLink()) {
|
|
19124
19092
|
if (++links > 40) throw new Error("IPC ancestor symlink loop");
|
|
19125
19093
|
const target = await readlink(candidate);
|
|
19126
|
-
if (
|
|
19127
|
-
pending.unshift(...target.slice(
|
|
19094
|
+
if (path.isAbsolute(target)) current = path.parse(target).root;
|
|
19095
|
+
pending.unshift(...target.slice(path.isAbsolute(target) ? path.parse(target).root.length : 0).split("/"));
|
|
19128
19096
|
continue;
|
|
19129
19097
|
}
|
|
19130
19098
|
if (!info.isDirectory() || info.mode & 18 && !(info.mode & 512)) {
|
|
@@ -19144,7 +19112,7 @@ async function assertPrivateDirectory(directory, { create = false } = {}) {
|
|
|
19144
19112
|
}
|
|
19145
19113
|
async function assertPrivateSocket(socketPath) {
|
|
19146
19114
|
if (process.platform === "win32") return;
|
|
19147
|
-
await assertPrivateDirectory(
|
|
19115
|
+
await assertPrivateDirectory(path.dirname(socketPath));
|
|
19148
19116
|
const info = await lstat(socketPath);
|
|
19149
19117
|
if (!info.isSocket() || info.uid !== process.getuid?.() || (info.mode & 63) !== 0) {
|
|
19150
19118
|
throw new Error("IPC socket must be owned by the current user with private permissions (0600)");
|
|
@@ -19152,43 +19120,25 @@ async function assertPrivateSocket(socketPath) {
|
|
|
19152
19120
|
return info;
|
|
19153
19121
|
}
|
|
19154
19122
|
var isFile = (file2) => stat(file2).then((info) => info.isFile(), () => false);
|
|
19155
|
-
|
|
19156
|
-
if (isScript(file2) || !isExecutableName(file2) || !await isFile(file2)) return false;
|
|
19157
|
-
const handle = await open(file2, "r").catch(() => void 0);
|
|
19158
|
-
if (!handle) return false;
|
|
19159
|
-
try {
|
|
19160
|
-
const { buffer, bytesRead } = await handle.read(Buffer.alloc(4), 0, 4, 0);
|
|
19161
|
-
if (bytesRead < 4) return false;
|
|
19162
|
-
const magic = buffer.readUInt32BE(0);
|
|
19163
|
-
const native = buffer.toString("latin1") === "\x7FELF" || buffer.subarray(0, 2).toString("latin1") === "MZ" || [4277009102, 4277009103, 3472551422, 3489328638, 3405691582].includes(magic);
|
|
19164
|
-
if (!native) return false;
|
|
19165
|
-
const marker = Buffer.from(EXECUTABLE_MARKER, "latin1");
|
|
19166
|
-
const chunk = Buffer.alloc(1 << 20);
|
|
19167
|
-
let tail2 = Buffer.alloc(0);
|
|
19168
|
-
for (let position = 0; ; ) {
|
|
19169
|
-
const { bytesRead: read } = await handle.read(chunk, 0, chunk.length, position);
|
|
19170
|
-
if (!read) return false;
|
|
19171
|
-
const window = Buffer.concat([tail2, chunk.subarray(0, read)]);
|
|
19172
|
-
if (window.includes(marker)) return true;
|
|
19173
|
-
tail2 = window.subarray(Math.max(0, window.length - marker.length + 1));
|
|
19174
|
-
position += read;
|
|
19175
|
-
}
|
|
19176
|
-
} finally {
|
|
19177
|
-
await handle.close();
|
|
19178
|
-
}
|
|
19179
|
-
}
|
|
19180
|
-
var BIN_DIRECTORIES = [path2.join(os.homedir(), ".alp", "bin"), path2.join(os.homedir(), ".npm-global", "bin"), path2.join(os.homedir(), ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"];
|
|
19123
|
+
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"];
|
|
19181
19124
|
var CLI_PACKAGES = ["@anhlp/alp", "@anhlp/alp-cli"];
|
|
19182
|
-
async function
|
|
19183
|
-
|
|
19184
|
-
const root =
|
|
19185
|
-
const
|
|
19186
|
-
|
|
19187
|
-
|
|
19188
|
-
|
|
19189
|
-
|
|
19190
|
-
|
|
19191
|
-
|
|
19125
|
+
async function cliDaemonEntry(cli) {
|
|
19126
|
+
const base = path.basename(cli).toLowerCase();
|
|
19127
|
+
const root = path.resolve(path.dirname(cli), "..");
|
|
19128
|
+
const alpd = (directory) => path.join(directory, "dist", "alpd.js");
|
|
19129
|
+
const named = async (directory) => readFile(path.join(directory, "package.json"), "utf8").then((text) => JSON.parse(text)?.name).catch(() => void 0);
|
|
19130
|
+
let candidates = [];
|
|
19131
|
+
if (base === "alp" || base === "alp.cmd") {
|
|
19132
|
+
if (!await isFile(path.join(root, "alp-bundle.json"))) return void 0;
|
|
19133
|
+
const current = path.join(path.dirname(root), "current");
|
|
19134
|
+
const viaCurrent = await realpath(current).then((real) => real === root, () => false);
|
|
19135
|
+
candidates = [alpd(path.join(viaCurrent ? current : root, "lib", "node_modules", "@anhlp", "alp-cli"))];
|
|
19136
|
+
} else if (base === "cli.js" && CLI_PACKAGES.includes(await named(root))) {
|
|
19137
|
+
candidates = [alpd(root)];
|
|
19138
|
+
} else if (base === "alp.js" && await named(root) === "@anhlp/alp") {
|
|
19139
|
+
candidates = [alpd(path.join(root, "node_modules", "@anhlp", "alp-cli")), alpd(path.join(root, "..", "alp-cli"))];
|
|
19140
|
+
}
|
|
19141
|
+
for (const candidate of candidates) if (await isFile(candidate)) return candidate;
|
|
19192
19142
|
return void 0;
|
|
19193
19143
|
}
|
|
19194
19144
|
async function findDaemonEntry({ home = alpHome(), env = process.env, candidates = (
|
|
@@ -19196,23 +19146,17 @@ async function findDaemonEntry({ home = alpHome(), env = process.env, candidates
|
|
|
19196
19146
|
[]
|
|
19197
19147
|
) } = {}) {
|
|
19198
19148
|
for (const candidate of candidates) if (candidate && await isFile(candidate)) return candidate;
|
|
19199
|
-
const own2 = executablePath();
|
|
19200
|
-
if (own2) return own2;
|
|
19201
19149
|
try {
|
|
19202
19150
|
const { entry } = JSON.parse(await readFile(daemonPaths(home).install, "utf8"));
|
|
19203
19151
|
if (typeof entry === "string" && await isFile(entry)) return entry;
|
|
19204
19152
|
} catch {
|
|
19205
19153
|
}
|
|
19206
|
-
for (const directory of [...(env.PATH ?? "").split(
|
|
19207
|
-
const
|
|
19208
|
-
|
|
19209
|
-
|
|
19210
|
-
|
|
19211
|
-
|
|
19212
|
-
const root = path2.resolve(path2.dirname(cli), "..");
|
|
19213
|
-
const name = await readFile(path2.join(root, "package.json"), "utf8").then((text) => JSON.parse(text)?.name).catch(() => void 0);
|
|
19214
|
-
const entry = path2.join(root, "dist", "alpd.js");
|
|
19215
|
-
if (CLI_PACKAGES.includes(name) && await isFile(entry)) return entry;
|
|
19154
|
+
for (const directory of [...(env.PATH ?? "").split(path.delimiter).filter(Boolean), ...BIN_DIRECTORIES]) {
|
|
19155
|
+
for (const name of process.platform === "win32" ? ["alp.cmd", "alp"] : ["alp"]) {
|
|
19156
|
+
const cli = await realpath(path.join(directory, name)).catch(() => void 0);
|
|
19157
|
+
const entry = cli && await cliDaemonEntry(cli);
|
|
19158
|
+
if (entry) return entry;
|
|
19159
|
+
}
|
|
19216
19160
|
}
|
|
19217
19161
|
return void 0;
|
|
19218
19162
|
}
|
|
@@ -19221,7 +19165,7 @@ function bootId() {
|
|
|
19221
19165
|
if (cachedBootId !== null) return cachedBootId;
|
|
19222
19166
|
try {
|
|
19223
19167
|
if (process.platform === "linux") {
|
|
19224
|
-
const id =
|
|
19168
|
+
const id = readFileSync("/proc/sys/kernel/random/boot_id", "utf8").trim();
|
|
19225
19169
|
if (id.length > 0) {
|
|
19226
19170
|
cachedBootId = id;
|
|
19227
19171
|
return cachedBootId;
|
|
@@ -19342,7 +19286,7 @@ async function tail(file2, lines = 30) {
|
|
|
19342
19286
|
}
|
|
19343
19287
|
}
|
|
19344
19288
|
async function lifecycleOwners(home) {
|
|
19345
|
-
const directory =
|
|
19289
|
+
const directory = path.join(home, "state", "alpd.starting");
|
|
19346
19290
|
const names = await readdir(directory).catch((error51) => {
|
|
19347
19291
|
if (error51.code === "ENOENT") return [];
|
|
19348
19292
|
throw error51;
|
|
@@ -19366,14 +19310,14 @@ async function withDaemonLifecycle(home, action, run, { joinStart = false, signa
|
|
|
19366
19310
|
} catch (cause) {
|
|
19367
19311
|
throw Object.assign(new Error(`ALP_HOME_UNUSABLE, alpd failed to start while preparing its home: ${cause.message}`, { cause }), { code: "ALP_HOME_UNUSABLE" });
|
|
19368
19312
|
}
|
|
19369
|
-
const state =
|
|
19313
|
+
const state = path.join(home, "state");
|
|
19370
19314
|
await assertPrivateDirectory(state, { create: true });
|
|
19371
|
-
const directory =
|
|
19315
|
+
const directory = path.join(state, "alpd.starting");
|
|
19372
19316
|
const currentBootId = bootId();
|
|
19373
19317
|
const token = `owner-${process.pid}-${bootTime()}-${action}-${randomUUID()}`;
|
|
19374
|
-
const candidate =
|
|
19318
|
+
const candidate = path.join(state, `alpd.starting-${token}`);
|
|
19375
19319
|
await mkdir(candidate, { mode: 448 });
|
|
19376
|
-
await writeFile(
|
|
19320
|
+
await writeFile(path.join(candidate, token), JSON.stringify({
|
|
19377
19321
|
pid: process.pid,
|
|
19378
19322
|
bootTime: bootTime(),
|
|
19379
19323
|
...currentBootId ? { bootId: currentBootId } : {},
|
|
@@ -19386,7 +19330,7 @@ async function withDaemonLifecycle(home, action, run, { joinStart = false, signa
|
|
|
19386
19330
|
const owner = await readDaemonLifecycle(home);
|
|
19387
19331
|
if (owner?.action === "start") {
|
|
19388
19332
|
try {
|
|
19389
|
-
await link(
|
|
19333
|
+
await link(path.join(directory, owner.token), path.join(directory, token));
|
|
19390
19334
|
joined = true;
|
|
19391
19335
|
} catch (error51) {
|
|
19392
19336
|
if (error51.code !== "ENOENT") throw error51;
|
|
@@ -19401,7 +19345,7 @@ async function withDaemonLifecycle(home, action, run, { joinStart = false, signa
|
|
|
19401
19345
|
} catch (error51) {
|
|
19402
19346
|
if (!["EEXIST", "ENOTEMPTY", "EPERM", "EACCES"].includes(error51.code)) throw error51;
|
|
19403
19347
|
for (const owner of await lifecycleOwners(home)) {
|
|
19404
|
-
if (!lockAlive(owner)) await unlink(
|
|
19348
|
+
if (!lockAlive(owner)) await unlink(path.join(directory, owner.token)).catch((error52) => {
|
|
19405
19349
|
if (error52.code !== "ENOENT") throw error52;
|
|
19406
19350
|
});
|
|
19407
19351
|
}
|
|
@@ -19415,13 +19359,13 @@ async function withDaemonLifecycle(home, action, run, { joinStart = false, signa
|
|
|
19415
19359
|
signal?.throwIfAborted();
|
|
19416
19360
|
return await run();
|
|
19417
19361
|
} finally {
|
|
19418
|
-
await unlink(
|
|
19362
|
+
await unlink(path.join(directory, token));
|
|
19419
19363
|
await rmdir(directory).catch((error51) => {
|
|
19420
19364
|
if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(error51.code)) throw error51;
|
|
19421
19365
|
});
|
|
19422
19366
|
}
|
|
19423
19367
|
} finally {
|
|
19424
|
-
await unlink(
|
|
19368
|
+
await unlink(path.join(candidate, token)).catch((error51) => {
|
|
19425
19369
|
if (error51.code !== "ENOENT") throw error51;
|
|
19426
19370
|
});
|
|
19427
19371
|
await rmdir(candidate).catch((error51) => {
|
|
@@ -19479,13 +19423,13 @@ ${log}` : ""}`);
|
|
|
19479
19423
|
|
|
19480
19424
|
// packages/client/src/supervise.js
|
|
19481
19425
|
import { mkdir as mkdir3, unlink as unlink3, writeFile as writeFile3, stat as stat2 } from "node:fs/promises";
|
|
19482
|
-
import
|
|
19426
|
+
import path3 from "node:path";
|
|
19483
19427
|
|
|
19484
19428
|
// packages/client/src/service.js
|
|
19485
19429
|
import { createHash as createHash2 } from "node:crypto";
|
|
19486
19430
|
import { mkdir as mkdir2, readFile as readFile2, unlink as unlink2, writeFile as writeFile2 } from "node:fs/promises";
|
|
19487
19431
|
import os2 from "node:os";
|
|
19488
|
-
import
|
|
19432
|
+
import path2 from "node:path";
|
|
19489
19433
|
|
|
19490
19434
|
// packages/client/src/command.js
|
|
19491
19435
|
import { spawn as spawn2 } from "node:child_process";
|
|
@@ -19521,14 +19465,14 @@ function runCommand(command, args, { cwd, env = process.env, timeoutMs = 15e3 }
|
|
|
19521
19465
|
|
|
19522
19466
|
// packages/client/src/service.js
|
|
19523
19467
|
function serviceFor({ home, env = process.env, platform = process.platform, uid = process.getuid?.() ?? 0 }) {
|
|
19524
|
-
const custom2 =
|
|
19525
|
-
const suffix = custom2 ? createHash2("sha256").update(
|
|
19468
|
+
const custom2 = path2.resolve(home) !== path2.join(os2.homedir(), ".alp");
|
|
19469
|
+
const suffix = custom2 ? createHash2("sha256").update(path2.resolve(home)).digest("hex").slice(0, 8) : "";
|
|
19526
19470
|
if (platform === "darwin") {
|
|
19527
19471
|
const label = `com.alp.alpd${suffix ? `.${suffix}` : ""}`;
|
|
19528
|
-
const directory = env.ALP_SERVICE_DIR ||
|
|
19472
|
+
const directory = env.ALP_SERVICE_DIR || path2.join(os2.homedir(), "Library", "LaunchAgents");
|
|
19529
19473
|
const launchctl = env.ALP_LAUNCHCTL || "launchctl";
|
|
19530
19474
|
const target = `gui/${uid}/${label}`;
|
|
19531
|
-
const file2 =
|
|
19475
|
+
const file2 = path2.join(directory, `${label}.plist`);
|
|
19532
19476
|
return {
|
|
19533
19477
|
kind: "launchd",
|
|
19534
19478
|
name: label,
|
|
@@ -19540,12 +19484,12 @@ function serviceFor({ home, env = process.env, platform = process.platform, uid
|
|
|
19540
19484
|
}
|
|
19541
19485
|
if (platform === "linux") {
|
|
19542
19486
|
const name = `alpd${suffix ? `-${suffix}` : ""}`;
|
|
19543
|
-
const directory = env.ALP_SERVICE_DIR ||
|
|
19487
|
+
const directory = env.ALP_SERVICE_DIR || path2.join(env.XDG_CONFIG_HOME || path2.join(os2.homedir(), ".config"), "systemd", "user");
|
|
19544
19488
|
const systemctl = env.ALP_SYSTEMCTL || "systemctl";
|
|
19545
19489
|
return {
|
|
19546
19490
|
kind: "systemd",
|
|
19547
19491
|
name,
|
|
19548
|
-
file:
|
|
19492
|
+
file: path2.join(directory, `${name}.service`),
|
|
19549
19493
|
install: [[systemctl, ["--user", "daemon-reload"]], [systemctl, ["--user", "enable", "--now", `${name}.service`]]],
|
|
19550
19494
|
start: [[systemctl, ["--user", "start", `${name}.service`]]],
|
|
19551
19495
|
uninstall: [[systemctl, ["--user", "disable", "--now", `${name}.service`], { ignore: true }]],
|
|
@@ -19576,7 +19520,7 @@ async function startService(service, run = runCommand) {
|
|
|
19576
19520
|
}
|
|
19577
19521
|
|
|
19578
19522
|
// packages/client/src/supervise.js
|
|
19579
|
-
var holdFile = (home) =>
|
|
19523
|
+
var holdFile = (home) => path3.join(home, "state", "alpd.held");
|
|
19580
19524
|
async function releaseHold(home) {
|
|
19581
19525
|
await unlink3(holdFile(home)).catch(() => {
|
|
19582
19526
|
});
|
|
@@ -19592,7 +19536,7 @@ async function whenReady(home, timeoutMs, signal) {
|
|
|
19592
19536
|
if (lockAlive(lock) && lock.ready) return lock.socket;
|
|
19593
19537
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
19594
19538
|
}
|
|
19595
|
-
throw new Error(`alpd did not become ready within ${timeoutMs / 1e3} s; see ${
|
|
19539
|
+
throw new Error(`alpd did not become ready within ${timeoutMs / 1e3} s; see ${path3.join(home, "logs")}`);
|
|
19596
19540
|
}
|
|
19597
19541
|
async function startDaemon({ home, entry, env = process.env, timeoutMs = 15e3, automatic = false, signal }) {
|
|
19598
19542
|
return withDaemonLifecycle(home, "start", async () => {
|
|
@@ -19615,7 +19559,7 @@ async function startDaemon({ home, entry, env = process.env, timeoutMs = 15e3, a
|
|
|
19615
19559
|
|
|
19616
19560
|
// packages/cli/src/acp/agent.ts
|
|
19617
19561
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
19618
|
-
import
|
|
19562
|
+
import path4 from "node:path";
|
|
19619
19563
|
var unlistedOf = ({ teams, team, teamLabel }) => teams.some((entry) => entry.id === team) ? void 0 : { id: team, label: teamLabel ?? (team === "custom" ? "Custom" : team) };
|
|
19620
19564
|
var MODES = [
|
|
19621
19565
|
{ id: "read-only", name: "Read only", description: "Agents read and search; nothing is changed" },
|
|
@@ -19659,9 +19603,9 @@ ${resource.text}
|
|
|
19659
19603
|
return text.trim();
|
|
19660
19604
|
}
|
|
19661
19605
|
function shown(file2, cwd) {
|
|
19662
|
-
if (!cwd || !
|
|
19663
|
-
const relative =
|
|
19664
|
-
return relative && !relative.startsWith("..") && !
|
|
19606
|
+
if (!cwd || !path4.isAbsolute(file2)) return file2;
|
|
19607
|
+
const relative = path4.relative(cwd, file2);
|
|
19608
|
+
return relative && !relative.startsWith("..") && !path4.isAbsolute(relative) ? relative : file2;
|
|
19665
19609
|
}
|
|
19666
19610
|
function toolKind(item) {
|
|
19667
19611
|
const detail = item.detail;
|
|
@@ -19998,8 +19942,8 @@ ${item2.text}`;
|
|
|
19998
19942
|
return preview2;
|
|
19999
19943
|
}
|
|
20000
19944
|
const absolute = (cwd) => {
|
|
20001
|
-
if (!
|
|
20002
|
-
return
|
|
19945
|
+
if (!path4.isAbsolute(cwd)) throw RequestError.invalidParams(void 0, "cwd must be an absolute path");
|
|
19946
|
+
return path4.resolve(cwd);
|
|
20003
19947
|
};
|
|
20004
19948
|
return agent({ name: "alp" }).onConnect((connection) => {
|
|
20005
19949
|
editor = connection.client;
|
|
@@ -20025,7 +19969,7 @@ ${item2.text}`;
|
|
|
20025
19969
|
const { session: record2 } = await request("session.get", { sessionId: params.sessionId }).catch(() => {
|
|
20026
19970
|
throw RequestError.resourceNotFound(params.sessionId);
|
|
20027
19971
|
});
|
|
20028
|
-
if (record2.parentId ||
|
|
19972
|
+
if (record2.parentId || path4.resolve(record2.projectRoot) !== cwd) throw RequestError.invalidParams(void 0, "That ALP session belongs to another project");
|
|
20029
19973
|
const session = track(params.sessionId, cwd, hostServers(params.mcpServers), {
|
|
20030
19974
|
teams: [{ id: record2.workflow?.mode ?? "pho", label: record2.teamLabel ?? record2.workflow?.mode ?? "pho" }],
|
|
20031
19975
|
team: record2.workflow?.mode ?? "pho",
|
|
@@ -20043,7 +19987,7 @@ ${item2.text}`;
|
|
|
20043
19987
|
send(session, { sessionUpdate: "available_commands_update", availableCommands: COMMANDS });
|
|
20044
19988
|
return { configOptions: configOptions(session), modes: modeState(session) };
|
|
20045
19989
|
}).onRequest("session/list", async ({ params }) => {
|
|
20046
|
-
const { sessions: rows } = await request("session.list", { ...params.cwd ? { projectRoot:
|
|
19990
|
+
const { sessions: rows } = await request("session.list", { ...params.cwd ? { projectRoot: path4.resolve(params.cwd) } : {}, rootsOnly: true, includeClosed: true });
|
|
20047
19991
|
return {
|
|
20048
19992
|
sessions: rows.filter((row) => row.persistent).slice(0, 100).map((row) => ({
|
|
20049
19993
|
sessionId: row.id,
|
|
@@ -20094,7 +20038,7 @@ ${item2.text}`;
|
|
|
20094
20038
|
|
|
20095
20039
|
// packages/cli/src/acp/main.ts
|
|
20096
20040
|
async function runAcp({ daemonEntry }) {
|
|
20097
|
-
const version2 = true ? "0.0.1-beta.
|
|
20041
|
+
const version2 = true ? "0.0.1-beta.7" : "0.0.0";
|
|
20098
20042
|
const logger = createLogger({ component: "acp" });
|
|
20099
20043
|
const log = (message, fields) => logger.warn(message, fields);
|
|
20100
20044
|
const app = createAcpAgent({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as On,a as In,r as _e,D as Nn,j as O,S as Wn,B as pt,t as Ts,b as gi,T as Hn,c as Ps,p as As,e as zn,R as Fn}from"./index-
|
|
1
|
+
import{u as On,a as In,r as _e,D as Nn,j as O,S as Wn,B as pt,t as Ts,b as gi,T as Hn,c as Ps,p as As,e as zn,R as Fn}from"./index-Dl7motn1.js";var Tr=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,Kn=(e,t)=>{for(var i in t)Tr(e,i,{get:t[i],enumerable:!0})},Y=(e,t,i,s)=>{for(var r=s>1?void 0:s?$n(t,i):t,n=e.length-1,o;n>=0;n--)(o=e[n])&&(r=(s?o(t,i,r):o(r))||r);return s&&r&&Tr(t,i,r),r},D=(e,t)=>(i,s)=>t(i,s,e),Os="Terminal input",Pi={get:()=>Os,set:e=>Os=e},Is="Too much output to announce, navigate to rows manually to read",Ai={get:()=>Is,set:e=>Is=e};function Un(e){return e.replace(/\r?\n/g,"\r")}function qn(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Vn(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function jn(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");Pr(r,t,i,s)}}function Pr(e,t,i,s){e=Un(e),e=qn(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function Ar(e,t,i){let s=i.getBoundingClientRect(),r=e.clientX-s.left-10,n=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function Ns(e,t,i,s,r){Ar(e,t,i),r&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function Ze(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function ci(e,t=0,i=e.length){let s="";for(let r=t;r<i;++r){let n=e[r];n>65535?(n-=65536,s+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):s+=String.fromCharCode(n)}return s}var Yn=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[s++]=(this._interim-55296)*1024+n-56320+65536:(t[s++]=this._interim,t[s++]=n),this._interim=0}for(let n=r;n<i;++n){let o=e.charCodeAt(n);if(55296<=o&&o<=56319){if(++n>=i)return this._interim=o,s;let a=e.charCodeAt(n);56320<=a&&a<=57343?t[s++]=(o-55296)*1024+a-56320+65536:(t[s++]=o,t[s++]=a);continue}o!==65279&&(t[s++]=o)}return s}},Xn=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,r,n,o,a,h=0,l=0;if(this.interim[0]){let f=!1,p=this.interim[0];p&=(p&224)===192?31:(p&240)===224?15:7;let u=0,v;for(;(v=this.interim[++u]&63)&&u<4;)p<<=6,p|=v;let E=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,R=E-u;for(;l<R;){if(l>=i)return 0;if(v=e[l++],(v&192)!==128){l--,f=!0;break}else this.interim[u++]=v,p<<=6,p|=v&63}f||(E===2?p<128?l--:t[s++]=p:E===3?p<2048||p>=55296&&p<=57343||p===65279||(t[s++]=p):p<65536||p>1114111||(t[s++]=p)),this.interim.fill(0)}let d=i-4,c=l;for(;c<i;){for(;c<d&&!((r=e[c])&128)&&!((n=e[c+1])&128)&&!((o=e[c+2])&128)&&!((a=e[c+3])&128);)t[s++]=r,t[s++]=n,t[s++]=o,t[s++]=a,c+=4;if(r=e[c++],r<128)t[s++]=r;else if((r&224)===192){if(c>=i)return this.interim[0]=r,s;if(n=e[c++],(n&192)!==128){c--;continue}if(h=(r&31)<<6|n&63,h<128){c--;continue}t[s++]=h}else if((r&240)===224){if(c>=i)return this.interim[0]=r,s;if(n=e[c++],(n&192)!==128){c--;continue}if(c>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[c++],(o&192)!==128){c--;continue}if(h=(r&15)<<12|(n&63)<<6|o&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[s++]=h}else if((r&248)===240){if(c>=i)return this.interim[0]=r,s;if(n=e[c++],(n&192)!==128){c--;continue}if(c>=i)return this.interim[0]=r,this.interim[1]=n,s;if(o=e[c++],(o&192)!==128){c--;continue}if(c>=i)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=o,s;if(a=e[c++],(a&192)!==128){c--;continue}if(h=(r&7)<<18|(n&63)<<12|(o&63)<<6|a&63,h<65536||h>1114111)continue;t[s++]=h}}return s}},Or="",Qe=" ",Nt=class Ir{constructor(){this.fg=0,this.bg=0,this.extended=new si}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new Ir;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},si=class Nr{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new Nr(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Re=class Wr extends Nt{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new si,this.combinedData=""}static fromCharData(t){let i=new Wr;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ze(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Ws="di$target",Oi="di$dependencies",vi=new Map;function Gn(e){return e[Oi]||[]}function oe(e){if(vi.has(e))return vi.get(e);let t=function(i,s,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Jn(t,i,r)};return t._id=e,vi.set(e,t),t}function Jn(e,t,i){t[Ws]===t?t[Oi].push({id:e,index:i}):(t[Oi]=[{id:e,index:i}],t[Ws]=t)}var ge=oe("BufferService"),Hr=oe("CoreMouseService"),ct=oe("CoreService"),Zn=oe("CharsetService"),ws=oe("InstantiationService"),zr=oe("LogService"),ve=oe("OptionsService"),Fr=oe("OscLinkService"),Qn=oe("UnicodeService"),Wt=oe("DecorationService"),Ii=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],r=this._optionsService.rawOptions.linkHandler,n=new Re,o=i.getTrimmedLength(),a=-1,h=-1,l=!1;for(let d=0;d<o;d++)if(!(h===-1&&!i.hasContent(d))){if(i.loadCell(d,n),n.hasExtendedAttrs()&&n.extended.urlId)if(h===-1){h=d,a=n.extended.urlId;continue}else l=n.extended.urlId!==a;else h!==-1&&(l=!0);if(l||h!==-1&&d===o-1){let c=this._oscLinkService.getLinkData(a)?.uri;if(c){let f={start:{x:h+1,y:e},end:{x:d+(!l&&d===o-1?1:0),y:e}},p=!1;if(!r?.allowNonHttpProtocols)try{let u=new URL(c);["http:","https:"].includes(u.protocol)||(p=!0)}catch{p=!0}p||s.push({text:c,range:f,activate:(u,v)=>r?r.activate(u,v,f):eo(u,v),hover:(u,v)=>r?.hover?.(u,v,f),leave:(u,v)=>r?.leave?.(u,v,f)})}l=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=d,a=n.extended.urlId):(h=-1,a=-1)}}t(s)}};Ii=Y([D(0,ge),D(1,ve),D(2,Fr)],Ii);function eo(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
2
2
|
|
|
3
3
|
WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var di=oe("CharSizeService"),Ue=oe("CoreBrowserService"),bs=oe("MouseService"),qe=oe("RenderService"),to=oe("SelectionService"),$r=oe("CharacterJoinerService"),vt=oe("ThemeService"),Kr=oe("LinkProviderService"),io=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Hs.isErrorNoTelemetry(e)?new Hs(e.message+`
|
|
4
4
|
|