@moxt-ai/mobius 0.0.195 → 0.0.196
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/agent-connection.d.ts.map +1 -1
- package/dist/acp/agent-connection.js +4 -3
- package/dist/acp/agent-connection.js.map +1 -1
- package/dist/acp/codex/app-server-client.d.ts.map +1 -1
- package/dist/acp/codex/app-server-client.js +4 -2
- package/dist/acp/codex/app-server-client.js.map +1 -1
- package/dist/agent-catalog/acp-readiness-probe.d.ts.map +1 -1
- package/dist/agent-catalog/acp-readiness-probe.js +4 -3
- package/dist/agent-catalog/acp-readiness-probe.js.map +1 -1
- package/dist/cli.js +526 -290
- package/dist/cli.js.map +4 -4
- package/dist/daemon-manager.d.ts.map +1 -1
- package/dist/daemon-manager.js +7 -17
- package/dist/daemon-manager.js.map +1 -1
- package/dist/filesystem/path-error.d.ts +5 -0
- package/dist/filesystem/path-error.d.ts.map +1 -0
- package/dist/filesystem/path-error.js +8 -0
- package/dist/filesystem/path-error.js.map +1 -0
- package/dist/filesystem/private-path.d.ts +3 -0
- package/dist/filesystem/private-path.d.ts.map +1 -0
- package/dist/filesystem/private-path.js +550 -0
- package/dist/filesystem/private-path.js.map +7 -0
- package/dist/index.js +498 -253
- package/dist/index.js.map +4 -4
- package/dist/native-sessions/codex-history.d.ts.map +1 -1
- package/dist/native-sessions/codex-history.js +4 -3
- package/dist/native-sessions/codex-history.js.map +1 -1
- package/dist/platform/contracts.d.ts +21 -0
- package/dist/platform/contracts.d.ts.map +1 -1
- package/dist/platform/index.d.ts.map +1 -1
- package/dist/platform/index.js +5 -3
- package/dist/platform/index.js.map +1 -1
- package/dist/platform/linux.d.ts.map +1 -1
- package/dist/platform/linux.js +2 -1
- package/dist/platform/linux.js.map +1 -1
- package/dist/platform/macos.d.ts.map +1 -1
- package/dist/platform/macos.js +2 -1
- package/dist/platform/macos.js.map +1 -1
- package/dist/platform/posix.d.ts +28 -1
- package/dist/platform/posix.d.ts.map +1 -1
- package/dist/platform/posix.js +91 -1
- package/dist/platform/posix.js.map +1 -1
- package/dist/platform/windows.d.ts +3 -0
- package/dist/platform/windows.d.ts.map +1 -0
- package/dist/platform/windows.js +174 -0
- package/dist/platform/windows.js.map +1 -0
- package/dist/process/executable.d.ts +7 -5
- package/dist/process/executable.d.ts.map +1 -1
- package/dist/process/executable.js +844 -386
- package/dist/process/executable.js.map +7 -1
- package/dist/process/process-error.d.ts +5 -0
- package/dist/process/process-error.d.ts.map +1 -0
- package/dist/process/process-error.js +9 -0
- package/dist/process/process-error.js.map +1 -0
- package/dist/runtime.js +498 -253
- package/dist/runtime.js.map +4 -4
- package/dist/storage/runtime-installation-store.d.ts.map +1 -1
- package/dist/storage/runtime-installation-store.js +3 -0
- package/dist/storage/runtime-installation-store.js.map +1 -1
- package/package.json +72 -70
package/dist/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ var __export = (target, all) => {
|
|
|
8
8
|
// src/cli.ts
|
|
9
9
|
import { constants as constants3 } from "node:fs";
|
|
10
10
|
import { mkdir as mkdir7, open as open6 } from "node:fs/promises";
|
|
11
|
-
import { resolve as
|
|
11
|
+
import { resolve as resolve9 } from "node:path";
|
|
12
12
|
|
|
13
13
|
// ../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
|
|
14
14
|
var CommanderError = class extends Error {
|
|
@@ -3381,7 +3381,7 @@ var program = new Command();
|
|
|
3381
3381
|
// package.json
|
|
3382
3382
|
var package_default = {
|
|
3383
3383
|
name: "@moxt-ai/mobius",
|
|
3384
|
-
version: "0.0.
|
|
3384
|
+
version: "0.0.196",
|
|
3385
3385
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
3386
3386
|
type: "module",
|
|
3387
3387
|
bin: {
|
|
@@ -3390,7 +3390,9 @@ var package_default = {
|
|
|
3390
3390
|
types: "./src/index.ts",
|
|
3391
3391
|
exports: {
|
|
3392
3392
|
".": "./src/index.ts",
|
|
3393
|
-
"./runtime": "./src/runtime.ts"
|
|
3393
|
+
"./runtime": "./src/runtime.ts",
|
|
3394
|
+
"./process": "./src/process/executable.ts",
|
|
3395
|
+
"./filesystem": "./src/filesystem/private-path.ts"
|
|
3394
3396
|
},
|
|
3395
3397
|
files: [
|
|
3396
3398
|
"dist"
|
|
@@ -3409,6 +3411,14 @@ var package_default = {
|
|
|
3409
3411
|
"./runtime": {
|
|
3410
3412
|
types: "./dist/runtime.d.ts",
|
|
3411
3413
|
import: "./dist/runtime.js"
|
|
3414
|
+
},
|
|
3415
|
+
"./process": {
|
|
3416
|
+
types: "./dist/process/executable.d.ts",
|
|
3417
|
+
import: "./dist/process/executable.js"
|
|
3418
|
+
},
|
|
3419
|
+
"./filesystem": {
|
|
3420
|
+
types: "./dist/filesystem/private-path.d.ts",
|
|
3421
|
+
import: "./dist/filesystem/private-path.js"
|
|
3412
3422
|
}
|
|
3413
3423
|
}
|
|
3414
3424
|
},
|
|
@@ -3418,7 +3428,7 @@ var package_default = {
|
|
|
3418
3428
|
directory: "packages/cli"
|
|
3419
3429
|
},
|
|
3420
3430
|
scripts: {
|
|
3421
|
-
build: "tsc --project tsconfig.build.json && esbuild src/cli.ts src/index.ts src/runtime.ts --bundle --platform=node --format=esm --sourcemap --outdir=dist --external:@agentclientprotocol/* --external:undici",
|
|
3431
|
+
build: "tsc --project tsconfig.build.json && esbuild src/cli.ts src/index.ts src/runtime.ts src/process/executable.ts src/filesystem/private-path.ts --bundle --platform=node --format=esm --sourcemap --outdir=dist --external:@agentclientprotocol/* --external:undici",
|
|
3422
3432
|
dev: "node --watch src/cli.ts",
|
|
3423
3433
|
prepack: "pnpm build",
|
|
3424
3434
|
start: "node dist/cli.js",
|
|
@@ -3506,17 +3516,31 @@ function normalizeAcpCapabilities(initialized) {
|
|
|
3506
3516
|
|
|
3507
3517
|
// src/process/executable.ts
|
|
3508
3518
|
import { spawn } from "node:child_process";
|
|
3509
|
-
import {
|
|
3510
|
-
import {
|
|
3511
|
-
import { join as join3, resolve } from "node:path";
|
|
3519
|
+
import { stat as stat2 } from "node:fs/promises";
|
|
3520
|
+
import { join as join5, resolve as resolve2 } from "node:path";
|
|
3512
3521
|
|
|
3513
3522
|
// src/platform/linux.ts
|
|
3514
|
-
import { constants, readdirSync, readFileSync } from "node:fs";
|
|
3515
|
-
import { access, readdir, readFile, realpath, stat } from "node:fs/promises";
|
|
3516
|
-
import { join } from "node:path";
|
|
3523
|
+
import { constants as constants2, readdirSync, readFileSync } from "node:fs";
|
|
3524
|
+
import { access as access2, readdir, readFile, realpath as realpath2, stat } from "node:fs/promises";
|
|
3525
|
+
import { join as join2 } from "node:path";
|
|
3517
3526
|
|
|
3518
3527
|
// src/platform/posix.ts
|
|
3519
3528
|
import { execFile } from "node:child_process";
|
|
3529
|
+
import { constants } from "node:fs";
|
|
3530
|
+
import { access, chmod, lstat, realpath, unlink } from "node:fs/promises";
|
|
3531
|
+
import { tmpdir } from "node:os";
|
|
3532
|
+
import { join } from "node:path";
|
|
3533
|
+
|
|
3534
|
+
// src/filesystem/path-error.ts
|
|
3535
|
+
var LocalPathError = class extends Error {
|
|
3536
|
+
code = "unsafe_local_path";
|
|
3537
|
+
constructor(message, options = {}) {
|
|
3538
|
+
super(message, options);
|
|
3539
|
+
this.name = "LocalPathError";
|
|
3540
|
+
}
|
|
3541
|
+
};
|
|
3542
|
+
|
|
3543
|
+
// src/platform/posix.ts
|
|
3520
3544
|
var PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
|
|
3521
3545
|
var PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
|
|
3522
3546
|
function parseProcessTable(output2) {
|
|
@@ -3561,6 +3585,81 @@ function processExists(processId) {
|
|
|
3561
3585
|
return false;
|
|
3562
3586
|
}
|
|
3563
3587
|
}
|
|
3588
|
+
function signalCapturedProcesses(processes, rootProcessId, signal) {
|
|
3589
|
+
const processIds = new Set(processes.map((identity2) => identity2.processId));
|
|
3590
|
+
const signalledGroups = /* @__PURE__ */ new Set();
|
|
3591
|
+
for (const identity2 of processes) {
|
|
3592
|
+
const isRootProcessGroup = identity2.processGroupId === rootProcessId;
|
|
3593
|
+
if (!isRootProcessGroup && !processIds.has(identity2.processGroupId) || signalledGroups.has(identity2.processGroupId)) {
|
|
3594
|
+
continue;
|
|
3595
|
+
}
|
|
3596
|
+
try {
|
|
3597
|
+
process.kill(-identity2.processGroupId, signal);
|
|
3598
|
+
signalledGroups.add(identity2.processGroupId);
|
|
3599
|
+
} catch {
|
|
3600
|
+
}
|
|
3601
|
+
}
|
|
3602
|
+
for (const identity2 of processes) {
|
|
3603
|
+
if (identity2.processId === rootProcessId || identity2.processGroupId === rootProcessId || signalledGroups.has(identity2.processGroupId)) {
|
|
3604
|
+
continue;
|
|
3605
|
+
}
|
|
3606
|
+
try {
|
|
3607
|
+
process.kill(identity2.processId, signal);
|
|
3608
|
+
} catch {
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
}
|
|
3612
|
+
function terminateProcess(child2, signal) {
|
|
3613
|
+
if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
|
|
3614
|
+
return;
|
|
3615
|
+
}
|
|
3616
|
+
try {
|
|
3617
|
+
process.kill(-child2.pid, signal);
|
|
3618
|
+
return;
|
|
3619
|
+
} catch {
|
|
3620
|
+
}
|
|
3621
|
+
child2.kill(signal);
|
|
3622
|
+
}
|
|
3623
|
+
async function removeControlSocket(path3) {
|
|
3624
|
+
try {
|
|
3625
|
+
await unlink(path3);
|
|
3626
|
+
} catch (cause) {
|
|
3627
|
+
if (!(cause instanceof Error) || !("code" in cause) || cause.code !== "ENOENT") {
|
|
3628
|
+
throw cause;
|
|
3629
|
+
}
|
|
3630
|
+
}
|
|
3631
|
+
}
|
|
3632
|
+
var posixOperations = {
|
|
3633
|
+
controlSocketPath: (installationHash) => join(tmpdir(), `mobius-${installationHash}.sock`),
|
|
3634
|
+
prepareControlSocket: removeControlSocket,
|
|
3635
|
+
secureControlSocket: async (path3) => {
|
|
3636
|
+
await chmod(path3, 384);
|
|
3637
|
+
},
|
|
3638
|
+
removeControlSocket,
|
|
3639
|
+
pathDelimiter: ":",
|
|
3640
|
+
environmentValue: (environment, name2) => environment[name2],
|
|
3641
|
+
executableExtensions: () => [""],
|
|
3642
|
+
resolveExecutableTarget: async (path3) => {
|
|
3643
|
+
const target = await realpath(path3);
|
|
3644
|
+
await access(target, constants.X_OK);
|
|
3645
|
+
return target;
|
|
3646
|
+
},
|
|
3647
|
+
executableLaunch: (command, args) => ({ command, arguments: args }),
|
|
3648
|
+
spawnOptions: { detached: true, windowsHide: true },
|
|
3649
|
+
signalCapturedProcesses,
|
|
3650
|
+
terminateProcess,
|
|
3651
|
+
validatePathPermissions: async (path3, directory, privateAccess, signal) => {
|
|
3652
|
+
signal.throwIfAborted();
|
|
3653
|
+
const metadata = await lstat(path3);
|
|
3654
|
+
if (process.getuid === void 0 || metadata.uid !== process.getuid()) {
|
|
3655
|
+
throw new LocalPathError("Path is not user-owned");
|
|
3656
|
+
}
|
|
3657
|
+
if (privateAccess) {
|
|
3658
|
+
await chmod(path3, directory ? 448 : 384);
|
|
3659
|
+
}
|
|
3660
|
+
signal.throwIfAborted();
|
|
3661
|
+
}
|
|
3662
|
+
};
|
|
3564
3663
|
|
|
3565
3664
|
// src/platform/linux.ts
|
|
3566
3665
|
function appendLinuxProcessTableEntry(entries, processId, encoded) {
|
|
@@ -3592,7 +3691,7 @@ async function readLinuxProcessTable() {
|
|
|
3592
3691
|
appendLinuxProcessTableEntry(
|
|
3593
3692
|
entries,
|
|
3594
3693
|
processId,
|
|
3595
|
-
await readFile(
|
|
3694
|
+
await readFile(join2("/proc", directory.name, "stat"), "utf8")
|
|
3596
3695
|
);
|
|
3597
3696
|
} catch {
|
|
3598
3697
|
}
|
|
@@ -3617,7 +3716,7 @@ function readLinuxProcessTableSynchronously() {
|
|
|
3617
3716
|
appendLinuxProcessTableEntry(
|
|
3618
3717
|
entries,
|
|
3619
3718
|
processId,
|
|
3620
|
-
readFileSync(
|
|
3719
|
+
readFileSync(join2("/proc", directory.name, "stat"), "utf8")
|
|
3621
3720
|
);
|
|
3622
3721
|
} catch {
|
|
3623
3722
|
}
|
|
@@ -3633,11 +3732,11 @@ async function readLinuxProcessTableWithFallback() {
|
|
|
3633
3732
|
}
|
|
3634
3733
|
for (const candidate of ["/usr/bin/ps", "/bin/ps", "/run/current-system/sw/bin/ps"]) {
|
|
3635
3734
|
try {
|
|
3636
|
-
const resolvedPath = await
|
|
3735
|
+
const resolvedPath = await realpath2(candidate);
|
|
3637
3736
|
if (!(await stat(resolvedPath)).isFile()) {
|
|
3638
3737
|
continue;
|
|
3639
3738
|
}
|
|
3640
|
-
await
|
|
3739
|
+
await access2(resolvedPath, constants2.X_OK);
|
|
3641
3740
|
} catch {
|
|
3642
3741
|
continue;
|
|
3643
3742
|
}
|
|
@@ -3650,7 +3749,7 @@ async function readLinuxProcessTableWithFallback() {
|
|
|
3650
3749
|
}
|
|
3651
3750
|
function processExists2(processId) {
|
|
3652
3751
|
try {
|
|
3653
|
-
const encoded = readFileSync(
|
|
3752
|
+
const encoded = readFileSync(join2("/proc", processId.toString(), "stat"), "utf8");
|
|
3654
3753
|
const closingParenthesis = encoded.lastIndexOf(")");
|
|
3655
3754
|
if (closingParenthesis >= 0) {
|
|
3656
3755
|
const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
|
|
@@ -3663,6 +3762,7 @@ function processExists2(processId) {
|
|
|
3663
3762
|
return processExists(processId);
|
|
3664
3763
|
}
|
|
3665
3764
|
var linuxPlatform = {
|
|
3765
|
+
...posixOperations,
|
|
3666
3766
|
readProcessTable: readLinuxProcessTableWithFallback,
|
|
3667
3767
|
readProcessTableSynchronously: readLinuxProcessTableSynchronously,
|
|
3668
3768
|
processExists: processExists2,
|
|
@@ -3694,7 +3794,7 @@ var linuxPlatform = {
|
|
|
3694
3794
|
};
|
|
3695
3795
|
|
|
3696
3796
|
// src/platform/macos.ts
|
|
3697
|
-
import { isAbsolute, join as
|
|
3797
|
+
import { isAbsolute, join as join3 } from "node:path";
|
|
3698
3798
|
var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
|
|
3699
3799
|
"WorkBuddy.app",
|
|
3700
3800
|
"Contents",
|
|
@@ -3705,14 +3805,15 @@ var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
|
|
|
3705
3805
|
"codebuddy"
|
|
3706
3806
|
]);
|
|
3707
3807
|
var macosPlatform = {
|
|
3808
|
+
...posixOperations,
|
|
3708
3809
|
readProcessTable: () => readProcessTableWithPs("/bin/ps"),
|
|
3709
3810
|
readProcessTableSynchronously: () => [],
|
|
3710
3811
|
processExists,
|
|
3711
3812
|
workBuddyExecutablePaths: (environment) => {
|
|
3712
|
-
const paths = [
|
|
3813
|
+
const paths = [join3("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
|
|
3713
3814
|
const homeDirectory = environment["HOME"];
|
|
3714
3815
|
if (homeDirectory !== void 0 && isAbsolute(homeDirectory)) {
|
|
3715
|
-
paths.unshift(
|
|
3816
|
+
paths.unshift(join3(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
|
|
3716
3817
|
}
|
|
3717
3818
|
return paths;
|
|
3718
3819
|
},
|
|
@@ -3742,8 +3843,199 @@ var macosPlatform = {
|
|
|
3742
3843
|
}
|
|
3743
3844
|
};
|
|
3744
3845
|
|
|
3846
|
+
// src/platform/windows.ts
|
|
3847
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
3848
|
+
import { readFile as readFile2, realpath as realpath3 } from "node:fs/promises";
|
|
3849
|
+
import { dirname, extname, join as join4, resolve } from "node:path";
|
|
3850
|
+
import { promisify } from "node:util";
|
|
3851
|
+
|
|
3852
|
+
// src/process/process-error.ts
|
|
3853
|
+
var ProcessExecutionError = class extends Error {
|
|
3854
|
+
code;
|
|
3855
|
+
constructor(code, message, options = {}) {
|
|
3856
|
+
super(message, options);
|
|
3857
|
+
this.code = code;
|
|
3858
|
+
this.name = "ProcessExecutionError";
|
|
3859
|
+
}
|
|
3860
|
+
};
|
|
3861
|
+
|
|
3862
|
+
// src/platform/windows.ts
|
|
3863
|
+
var execute = promisify(execFile2);
|
|
3864
|
+
function environmentValue(environment, name2) {
|
|
3865
|
+
return Object.entries(environment).find(([key]) => key.toUpperCase() === name2.toUpperCase())?.[1];
|
|
3866
|
+
}
|
|
3867
|
+
function executableExtensions(executableName, environment) {
|
|
3868
|
+
if (/\.[a-zA-Z0-9]+$/.test(executableName)) {
|
|
3869
|
+
return [""];
|
|
3870
|
+
}
|
|
3871
|
+
const configured = environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD";
|
|
3872
|
+
const extensions = configured.split(";").map((extension) => extension.trim()).filter((extension) => extension.length > 0).map((extension) => extension.startsWith(".") ? extension : `.${extension}`);
|
|
3873
|
+
return extensions.length > 0 ? extensions : [".EXE"];
|
|
3874
|
+
}
|
|
3875
|
+
async function resolveExecutableTarget(path3) {
|
|
3876
|
+
let resolvedPath;
|
|
3877
|
+
try {
|
|
3878
|
+
resolvedPath = await realpath3(extname(path3) === "" ? `${path3}.cmd` : path3);
|
|
3879
|
+
} catch (cause) {
|
|
3880
|
+
if (extname(path3) !== "" || !(cause instanceof Error) || !("code" in cause) || cause.code !== "ENOENT") {
|
|
3881
|
+
throw cause;
|
|
3882
|
+
}
|
|
3883
|
+
resolvedPath = await realpath3(path3);
|
|
3884
|
+
}
|
|
3885
|
+
if (extname(resolvedPath).toLowerCase() === ".cmd") {
|
|
3886
|
+
const shim = await readFile2(resolvedPath, "utf8");
|
|
3887
|
+
const script = /"%_prog%"\s+"%dp0%[\\/]([^"\r\n]+\.(?:js|mjs|cjs))"\s+%\*/iu.exec(shim)?.[1];
|
|
3888
|
+
if (script !== void 0 && shim.includes("SET dp0=%~dp0")) {
|
|
3889
|
+
resolvedPath = await realpath3(resolve(dirname(resolvedPath), script));
|
|
3890
|
+
} else {
|
|
3891
|
+
const pnpmScript = /^\s*node\s+"%~dp0[\\/]([^"\r\n]+\.(?:js|mjs|cjs))"\s+%\*\s*$/imu.exec(shim)?.[1];
|
|
3892
|
+
if (pnpmScript === void 0 || !shim.includes("@SETLOCAL")) {
|
|
3893
|
+
throw new ProcessExecutionError(
|
|
3894
|
+
"process_unsupported_script",
|
|
3895
|
+
"Use a native executable or a verified Node entrypoint"
|
|
3896
|
+
);
|
|
3897
|
+
}
|
|
3898
|
+
resolvedPath = await realpath3(resolve(dirname(resolvedPath), pnpmScript));
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
return resolvedPath;
|
|
3902
|
+
}
|
|
3903
|
+
function executableLaunch(command, args) {
|
|
3904
|
+
if (/\.(?:js|mjs|cjs)$/iu.test(command)) {
|
|
3905
|
+
return { command: process.execPath, arguments: [command, ...args] };
|
|
3906
|
+
}
|
|
3907
|
+
if (/\.(?:cmd|bat)$/iu.test(command)) {
|
|
3908
|
+
throw new ProcessExecutionError(
|
|
3909
|
+
"process_unsupported_script",
|
|
3910
|
+
"Use a native executable or a verified Node entrypoint"
|
|
3911
|
+
);
|
|
3912
|
+
}
|
|
3913
|
+
return { command, arguments: args };
|
|
3914
|
+
}
|
|
3915
|
+
function readProcessTable() {
|
|
3916
|
+
const systemRoot = environmentValue(process.env, "SystemRoot");
|
|
3917
|
+
if (systemRoot === void 0) {
|
|
3918
|
+
return Promise.resolve([]);
|
|
3919
|
+
}
|
|
3920
|
+
return new Promise((resolveTable) => {
|
|
3921
|
+
execFile2(
|
|
3922
|
+
join4(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
3923
|
+
[
|
|
3924
|
+
"-NoLogo",
|
|
3925
|
+
"-NoProfile",
|
|
3926
|
+
"-NonInteractive",
|
|
3927
|
+
"-Command",
|
|
3928
|
+
"Get-CimInstance Win32_Process | ForEach-Object { '{0} {1} {0}' -f $_.ProcessId, $_.ParentProcessId }"
|
|
3929
|
+
],
|
|
3930
|
+
{
|
|
3931
|
+
encoding: "utf8",
|
|
3932
|
+
windowsHide: true,
|
|
3933
|
+
timeout: 1e4,
|
|
3934
|
+
signal: AbortSignal.timeout(1e4),
|
|
3935
|
+
maxBuffer: 1024 * 1024
|
|
3936
|
+
},
|
|
3937
|
+
(error62, stdout) => resolveTable(error62 === null ? parseProcessTable(stdout) : [])
|
|
3938
|
+
);
|
|
3939
|
+
});
|
|
3940
|
+
}
|
|
3941
|
+
function signalCapturedProcesses2(processes, _rootProcessId, signal) {
|
|
3942
|
+
for (const identity2 of [...processes].reverse()) {
|
|
3943
|
+
try {
|
|
3944
|
+
process.kill(identity2.processId, signal);
|
|
3945
|
+
} catch {
|
|
3946
|
+
}
|
|
3947
|
+
}
|
|
3948
|
+
}
|
|
3949
|
+
function terminateProcess2(child2, signal) {
|
|
3950
|
+
if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
|
|
3951
|
+
return;
|
|
3952
|
+
}
|
|
3953
|
+
child2.kill(signal);
|
|
3954
|
+
}
|
|
3955
|
+
var windowsPermissions = `
|
|
3956
|
+
$ErrorActionPreference = 'Stop'
|
|
3957
|
+
Import-Module (Join-Path $PSHOME 'Modules/Microsoft.PowerShell.Security/Microsoft.PowerShell.Security.psd1')
|
|
3958
|
+
$item = Get-Item -LiteralPath $env:MOBIUS_PERMISSION_PATH -Force
|
|
3959
|
+
if (($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0) { throw 'Unsafe path' }
|
|
3960
|
+
$sid = [Security.Principal.WindowsIdentity]::GetCurrent().User
|
|
3961
|
+
$acl = Get-Acl -LiteralPath $item.FullName
|
|
3962
|
+
$owner = $acl.GetOwner([Security.Principal.SecurityIdentifier])
|
|
3963
|
+
if ($owner -ne $sid -and -not ($owner.Value -eq 'S-1-5-32-544' -and ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))) { throw 'Path is not user-owned' }
|
|
3964
|
+
if ($env:MOBIUS_PERMISSION_PRIVATE -eq '1') {
|
|
3965
|
+
if ($item.PSIsContainer) {
|
|
3966
|
+
$private = New-Object Security.AccessControl.DirectorySecurity
|
|
3967
|
+
$rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'ContainerInherit,ObjectInherit', 'None', 'Allow')
|
|
3968
|
+
} else {
|
|
3969
|
+
$private = New-Object Security.AccessControl.FileSecurity
|
|
3970
|
+
$rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'Allow')
|
|
3971
|
+
}
|
|
3972
|
+
$private.SetOwner($sid)
|
|
3973
|
+
$private.SetAccessRuleProtection($true, $false)
|
|
3974
|
+
$private.AddAccessRule($rule)
|
|
3975
|
+
Set-Acl -LiteralPath $item.FullName -AclObject $private
|
|
3976
|
+
}
|
|
3977
|
+
`;
|
|
3978
|
+
async function validatePathPermissions(path3, _directory, privateAccess, signal) {
|
|
3979
|
+
signal.throwIfAborted();
|
|
3980
|
+
const systemRoot = environmentValue(process.env, "SystemRoot");
|
|
3981
|
+
if (systemRoot === void 0) {
|
|
3982
|
+
throw new LocalPathError("Windows system directory is unavailable");
|
|
3983
|
+
}
|
|
3984
|
+
try {
|
|
3985
|
+
await execute(
|
|
3986
|
+
join4(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
3987
|
+
[
|
|
3988
|
+
"-NoLogo",
|
|
3989
|
+
"-NoProfile",
|
|
3990
|
+
"-NonInteractive",
|
|
3991
|
+
"-EncodedCommand",
|
|
3992
|
+
Buffer.from(windowsPermissions, "utf16le").toString("base64")
|
|
3993
|
+
],
|
|
3994
|
+
{
|
|
3995
|
+
env: {
|
|
3996
|
+
...process.env,
|
|
3997
|
+
MOBIUS_PERMISSION_PATH: path3,
|
|
3998
|
+
MOBIUS_PERMISSION_PRIVATE: privateAccess ? "1" : "0"
|
|
3999
|
+
},
|
|
4000
|
+
windowsHide: true,
|
|
4001
|
+
signal: AbortSignal.any([signal, AbortSignal.timeout(1e4)]),
|
|
4002
|
+
timeout: 1e4,
|
|
4003
|
+
maxBuffer: 16384
|
|
4004
|
+
}
|
|
4005
|
+
);
|
|
4006
|
+
} catch (cause) {
|
|
4007
|
+
signal.throwIfAborted();
|
|
4008
|
+
throw new LocalPathError("The local path permissions could not be secured", { cause });
|
|
4009
|
+
}
|
|
4010
|
+
}
|
|
4011
|
+
var windowsPlatform = {
|
|
4012
|
+
controlSocketPath: (installationHash) => `\\\\.\\pipe\\mobius-${installationHash}`,
|
|
4013
|
+
prepareControlSocket: async () => {
|
|
4014
|
+
},
|
|
4015
|
+
secureControlSocket: async () => {
|
|
4016
|
+
},
|
|
4017
|
+
removeControlSocket: async () => {
|
|
4018
|
+
},
|
|
4019
|
+
pathDelimiter: ";",
|
|
4020
|
+
environmentValue,
|
|
4021
|
+
executableExtensions,
|
|
4022
|
+
resolveExecutableTarget,
|
|
4023
|
+
executableLaunch,
|
|
4024
|
+
spawnOptions: { detached: false, windowsHide: true },
|
|
4025
|
+
signalCapturedProcesses: signalCapturedProcesses2,
|
|
4026
|
+
terminateProcess: terminateProcess2,
|
|
4027
|
+
validatePathPermissions,
|
|
4028
|
+
readProcessTable,
|
|
4029
|
+
readProcessTableSynchronously: () => [],
|
|
4030
|
+
processExists,
|
|
4031
|
+
workBuddyExecutablePaths: () => [],
|
|
4032
|
+
openCodeArchives: {},
|
|
4033
|
+
grokDependencies: {}
|
|
4034
|
+
};
|
|
4035
|
+
|
|
3745
4036
|
// src/platform/index.ts
|
|
3746
4037
|
var fallbackPlatform = {
|
|
4038
|
+
...posixOperations,
|
|
3747
4039
|
readProcessTable: () => readProcessTableWithPs("/usr/bin/ps"),
|
|
3748
4040
|
readProcessTableSynchronously: () => [],
|
|
3749
4041
|
processExists,
|
|
@@ -3754,7 +4046,7 @@ var fallbackPlatform = {
|
|
|
3754
4046
|
var platforms = /* @__PURE__ */ new Map([
|
|
3755
4047
|
["linux", linuxPlatform],
|
|
3756
4048
|
["darwin", macosPlatform],
|
|
3757
|
-
["win32",
|
|
4049
|
+
["win32", windowsPlatform]
|
|
3758
4050
|
]);
|
|
3759
4051
|
function platformSupportFor(platform) {
|
|
3760
4052
|
return platforms.get(platform) ?? fallbackPlatform;
|
|
@@ -3793,14 +4085,6 @@ var ResolvedExecutable = class {
|
|
|
3793
4085
|
this.path = identity2.realPath;
|
|
3794
4086
|
}
|
|
3795
4087
|
};
|
|
3796
|
-
var ProcessExecutionError = class extends Error {
|
|
3797
|
-
code;
|
|
3798
|
-
constructor(code, message, options = {}) {
|
|
3799
|
-
super(message, options);
|
|
3800
|
-
this.code = code;
|
|
3801
|
-
this.name = "ProcessExecutionError";
|
|
3802
|
-
}
|
|
3803
|
-
};
|
|
3804
4088
|
var ProcessResult = class {
|
|
3805
4089
|
stderr;
|
|
3806
4090
|
stdout;
|
|
@@ -3809,28 +4093,14 @@ var ProcessResult = class {
|
|
|
3809
4093
|
this.stdout = stdout;
|
|
3810
4094
|
}
|
|
3811
4095
|
};
|
|
3812
|
-
function executableExtensions(executableName, environment, platform) {
|
|
3813
|
-
if (platform !== "win32") {
|
|
3814
|
-
return [""];
|
|
3815
|
-
}
|
|
3816
|
-
if (/\.[a-zA-Z0-9]+$/.test(executableName)) {
|
|
3817
|
-
return [""];
|
|
3818
|
-
}
|
|
3819
|
-
const configured = environment["PATHEXT"] ?? ".COM;.EXE;.BAT;.CMD";
|
|
3820
|
-
const extensions = configured.split(";").map((extension) => extension.trim()).filter((extension) => extension.length > 0).map((extension) => extension.startsWith(".") ? extension : `.${extension}`);
|
|
3821
|
-
return extensions.length > 0 ? extensions : [".EXE"];
|
|
3822
|
-
}
|
|
3823
4096
|
async function resolveExecutablePath(requestedPath2, platform = process.platform) {
|
|
3824
|
-
const absoluteRequestedPath =
|
|
4097
|
+
const absoluteRequestedPath = resolve2(requestedPath2);
|
|
3825
4098
|
try {
|
|
3826
|
-
const resolvedPath = await
|
|
4099
|
+
const resolvedPath = await platformSupportFor(platform).resolveExecutableTarget(absoluteRequestedPath);
|
|
3827
4100
|
const metadata = await stat2(resolvedPath);
|
|
3828
4101
|
if (!metadata.isFile()) {
|
|
3829
4102
|
return null;
|
|
3830
4103
|
}
|
|
3831
|
-
if (platform !== "win32") {
|
|
3832
|
-
await access2(resolvedPath, constants2.X_OK);
|
|
3833
|
-
}
|
|
3834
4104
|
return new ResolvedExecutable(
|
|
3835
4105
|
new ExecutableIdentity(
|
|
3836
4106
|
absoluteRequestedPath,
|
|
@@ -3846,15 +4116,16 @@ async function resolveExecutablePath(requestedPath2, platform = process.platform
|
|
|
3846
4116
|
}
|
|
3847
4117
|
}
|
|
3848
4118
|
async function findExecutableOnPath(executableName, environment, platform = process.platform) {
|
|
3849
|
-
const
|
|
3850
|
-
const
|
|
3851
|
-
const
|
|
4119
|
+
const support = platformSupportFor(platform);
|
|
4120
|
+
const encodedPath = support.environmentValue(environment, "PATH") ?? "";
|
|
4121
|
+
const separator = support.pathDelimiter;
|
|
4122
|
+
const extensions = support.executableExtensions(executableName, environment);
|
|
3852
4123
|
for (const entry of encodedPath.split(separator)) {
|
|
3853
4124
|
if (entry.length === 0) {
|
|
3854
4125
|
continue;
|
|
3855
4126
|
}
|
|
3856
4127
|
for (const extension of extensions) {
|
|
3857
|
-
const requestedPath2 =
|
|
4128
|
+
const requestedPath2 = resolve2(join5(entry, `${executableName}${extension}`));
|
|
3858
4129
|
const executable = await resolveExecutablePath(requestedPath2, platform);
|
|
3859
4130
|
if (executable !== null) {
|
|
3860
4131
|
return executable;
|
|
@@ -3875,7 +4146,7 @@ function appendBounded(chunks, chunk, currentBytes, limitBytes) {
|
|
|
3875
4146
|
chunks.push(chunk);
|
|
3876
4147
|
return nextBytes;
|
|
3877
4148
|
}
|
|
3878
|
-
function
|
|
4149
|
+
function readProcessTable2() {
|
|
3879
4150
|
return hostPlatform.readProcessTable();
|
|
3880
4151
|
}
|
|
3881
4152
|
function selectProcessTree(entries, rootProcessId) {
|
|
@@ -3910,38 +4181,14 @@ function mergeProcessTrees(captured, current) {
|
|
|
3910
4181
|
return [...processes.values()];
|
|
3911
4182
|
}
|
|
3912
4183
|
async function captureProcessTree(child2) {
|
|
3913
|
-
if (
|
|
4184
|
+
if (child2.pid === void 0) {
|
|
3914
4185
|
return [];
|
|
3915
4186
|
}
|
|
3916
4187
|
const entries = hostPlatform.readProcessTableSynchronously();
|
|
3917
4188
|
if (entries.length > 0) {
|
|
3918
4189
|
return selectProcessTree(entries, child2.pid);
|
|
3919
4190
|
}
|
|
3920
|
-
return selectProcessTree(await
|
|
3921
|
-
}
|
|
3922
|
-
function signalCapturedProcessGroups(processes, rootProcessId, signal) {
|
|
3923
|
-
const processIds = new Set(processes.map((identity2) => identity2.processId));
|
|
3924
|
-
const signalledGroups = /* @__PURE__ */ new Set();
|
|
3925
|
-
for (const identity2 of processes) {
|
|
3926
|
-
const isRootProcessGroup = identity2.processGroupId === rootProcessId;
|
|
3927
|
-
if (!isRootProcessGroup && !processIds.has(identity2.processGroupId) || signalledGroups.has(identity2.processGroupId)) {
|
|
3928
|
-
continue;
|
|
3929
|
-
}
|
|
3930
|
-
try {
|
|
3931
|
-
process.kill(-identity2.processGroupId, signal);
|
|
3932
|
-
signalledGroups.add(identity2.processGroupId);
|
|
3933
|
-
} catch {
|
|
3934
|
-
}
|
|
3935
|
-
}
|
|
3936
|
-
for (const identity2 of processes) {
|
|
3937
|
-
if (identity2.processId === rootProcessId || identity2.processGroupId === rootProcessId || signalledGroups.has(identity2.processGroupId)) {
|
|
3938
|
-
continue;
|
|
3939
|
-
}
|
|
3940
|
-
try {
|
|
3941
|
-
process.kill(identity2.processId, signal);
|
|
3942
|
-
} catch {
|
|
3943
|
-
}
|
|
3944
|
-
}
|
|
4191
|
+
return selectProcessTree(await readProcessTable2(), child2.pid);
|
|
3945
4192
|
}
|
|
3946
4193
|
async function waitForCapturedProcessesExit(processes, rootProcessId) {
|
|
3947
4194
|
const processIds = processes.map((identity2) => identity2.processId).filter((processId) => processId !== rootProcessId);
|
|
@@ -3949,36 +4196,10 @@ async function waitForCapturedProcessesExit(processes, rootProcessId) {
|
|
|
3949
4196
|
if (processIds.every((processId) => !hostPlatform.processExists(processId))) {
|
|
3950
4197
|
return true;
|
|
3951
4198
|
}
|
|
3952
|
-
await
|
|
4199
|
+
await readProcessTable2();
|
|
3953
4200
|
}
|
|
3954
4201
|
return processIds.every((processId) => !hostPlatform.processExists(processId));
|
|
3955
4202
|
}
|
|
3956
|
-
function terminateProcess(child2) {
|
|
3957
|
-
if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
|
|
3958
|
-
return;
|
|
3959
|
-
}
|
|
3960
|
-
if (process.platform !== "win32") {
|
|
3961
|
-
try {
|
|
3962
|
-
process.kill(-child2.pid, "SIGTERM");
|
|
3963
|
-
return;
|
|
3964
|
-
} catch {
|
|
3965
|
-
}
|
|
3966
|
-
}
|
|
3967
|
-
child2.kill("SIGTERM");
|
|
3968
|
-
}
|
|
3969
|
-
function forceTerminateProcess(child2) {
|
|
3970
|
-
if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
|
|
3971
|
-
return;
|
|
3972
|
-
}
|
|
3973
|
-
if (process.platform !== "win32") {
|
|
3974
|
-
try {
|
|
3975
|
-
process.kill(-child2.pid, "SIGKILL");
|
|
3976
|
-
return;
|
|
3977
|
-
} catch {
|
|
3978
|
-
}
|
|
3979
|
-
}
|
|
3980
|
-
child2.kill("SIGKILL");
|
|
3981
|
-
}
|
|
3982
4203
|
async function stopProcessTree(child2, capturedProcesses = []) {
|
|
3983
4204
|
const childProcessId = child2.pid;
|
|
3984
4205
|
if (childProcessId === void 0) {
|
|
@@ -3989,8 +4210,8 @@ async function stopProcessTree(child2, capturedProcesses = []) {
|
|
|
3989
4210
|
if (childExited && processes.length === 0) {
|
|
3990
4211
|
return;
|
|
3991
4212
|
}
|
|
3992
|
-
|
|
3993
|
-
terminateProcess(child2);
|
|
4213
|
+
hostPlatform.signalCapturedProcesses(processes, childProcessId, GRACEFUL_STOP_SIGNAL);
|
|
4214
|
+
hostPlatform.terminateProcess(child2, "SIGTERM");
|
|
3994
4215
|
const [exitedAfterTermination, descendantsExitedAfterTermination] = await Promise.all([
|
|
3995
4216
|
waitForProcessExit(child2, PROCESS_GRACEFUL_STOP_TIMEOUT_MILLISECONDS),
|
|
3996
4217
|
waitForCapturedProcessesExit(processes, childProcessId)
|
|
@@ -3998,8 +4219,8 @@ async function stopProcessTree(child2, capturedProcesses = []) {
|
|
|
3998
4219
|
if (exitedAfterTermination && descendantsExitedAfterTermination) {
|
|
3999
4220
|
return;
|
|
4000
4221
|
}
|
|
4001
|
-
|
|
4002
|
-
|
|
4222
|
+
hostPlatform.signalCapturedProcesses(processes, childProcessId, FORCED_STOP_SIGNAL);
|
|
4223
|
+
hostPlatform.terminateProcess(child2, "SIGKILL");
|
|
4003
4224
|
const [exitedAfterForce, descendantsExitedAfterForce] = await Promise.all([
|
|
4004
4225
|
waitForProcessExit(child2, PROCESS_FORCED_STOP_TIMEOUT_MILLISECONDS),
|
|
4005
4226
|
waitForCapturedProcessesExit(processes, childProcessId)
|
|
@@ -4034,9 +4255,10 @@ function waitForProcessExit(child2, timeoutMilliseconds) {
|
|
|
4034
4255
|
async function runBoundedProcess(options) {
|
|
4035
4256
|
options.signal.throwIfAborted();
|
|
4036
4257
|
const outputLimitBytes = options.outputLimitBytes ?? DEFAULT_OUTPUT_LIMIT_BYTES;
|
|
4037
|
-
const
|
|
4258
|
+
const launch = executableLaunch2(options.command, options.arguments);
|
|
4259
|
+
const child2 = spawn(launch.command, [...launch.arguments], {
|
|
4038
4260
|
cwd: options.cwd,
|
|
4039
|
-
|
|
4261
|
+
...hostPlatform.spawnOptions,
|
|
4040
4262
|
env: { ...options.environment },
|
|
4041
4263
|
shell: false,
|
|
4042
4264
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -4145,6 +4367,10 @@ async function runBoundedProcess(options) {
|
|
|
4145
4367
|
}
|
|
4146
4368
|
}
|
|
4147
4369
|
}
|
|
4370
|
+
function executableLaunch2(command, args) {
|
|
4371
|
+
return hostPlatform.executableLaunch(command, args);
|
|
4372
|
+
}
|
|
4373
|
+
var platformSpawnOptions = hostPlatform.spawnOptions;
|
|
4148
4374
|
|
|
4149
4375
|
// src/agent-catalog/local-agent.ts
|
|
4150
4376
|
function readTrustedIdentity(path3) {
|
|
@@ -4537,8 +4763,8 @@ function formatAgentDiagnostics(inventory, json2, verbose = false) {
|
|
|
4537
4763
|
}
|
|
4538
4764
|
|
|
4539
4765
|
// src/agent-installation/managed-npm-package.ts
|
|
4540
|
-
import { mkdir, mkdtemp, open, realpath as
|
|
4541
|
-
import { delimiter, dirname, isAbsolute as isAbsolute2, join as
|
|
4766
|
+
import { mkdir, mkdtemp, open, realpath as realpath4, rename, rm, stat as stat3 } from "node:fs/promises";
|
|
4767
|
+
import { delimiter, dirname as dirname2, isAbsolute as isAbsolute2, join as join6, relative, sep } from "node:path";
|
|
4542
4768
|
var INSTALL_TIMEOUT_MILLISECONDS = 5 * 60 * 1e3;
|
|
4543
4769
|
var PACKAGE_METADATA_LIMIT_BYTES = 64 * 1024;
|
|
4544
4770
|
var PACKAGE_LOCK_LIMIT_BYTES = 8 * 1024 * 1024;
|
|
@@ -4589,7 +4815,7 @@ function isRecord2(value) {
|
|
|
4589
4815
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4590
4816
|
}
|
|
4591
4817
|
function packagePath(root, packageName) {
|
|
4592
|
-
return
|
|
4818
|
+
return join6(root, "node_modules", ...packageName.split("/"));
|
|
4593
4819
|
}
|
|
4594
4820
|
function isContainedPath(root, candidate) {
|
|
4595
4821
|
const difference = relative(root, candidate);
|
|
@@ -4694,14 +4920,14 @@ function verifyPackageLockEntry(lock, definition, verifyDependencyClosure) {
|
|
|
4694
4920
|
}
|
|
4695
4921
|
}
|
|
4696
4922
|
async function verifyRequiredDependency(rootPath, lock, definition) {
|
|
4697
|
-
const dependencyRoot = await
|
|
4923
|
+
const dependencyRoot = await realpath4(packagePath(rootPath, definition.packageName));
|
|
4698
4924
|
if (!isContainedPath(rootPath, dependencyRoot)) {
|
|
4699
4925
|
throw new ManagedNpmPackageError(
|
|
4700
4926
|
"managed_package_verification_failed",
|
|
4701
4927
|
"The required managed npm dependency escaped its private cache"
|
|
4702
4928
|
);
|
|
4703
4929
|
}
|
|
4704
|
-
const metadata = await readJsonRecord(
|
|
4930
|
+
const metadata = await readJsonRecord(join6(dependencyRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
|
|
4705
4931
|
if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
|
|
4706
4932
|
throw new ManagedNpmPackageError(
|
|
4707
4933
|
"managed_package_verification_failed",
|
|
@@ -4723,15 +4949,15 @@ async function validateManagedNpmPackage(root, definition) {
|
|
|
4723
4949
|
}
|
|
4724
4950
|
}
|
|
4725
4951
|
async function validateManagedNpmPackageContents(root, definition) {
|
|
4726
|
-
const rootPath = await
|
|
4727
|
-
const packageRoot = await
|
|
4952
|
+
const rootPath = await realpath4(root);
|
|
4953
|
+
const packageRoot = await realpath4(packagePath(rootPath, definition.packageName));
|
|
4728
4954
|
if (!isContainedPath(rootPath, packageRoot)) {
|
|
4729
4955
|
throw new ManagedNpmPackageError(
|
|
4730
4956
|
"managed_package_verification_failed",
|
|
4731
4957
|
"The managed npm package escaped its private cache"
|
|
4732
4958
|
);
|
|
4733
4959
|
}
|
|
4734
|
-
const metadata = await readJsonRecord(
|
|
4960
|
+
const metadata = await readJsonRecord(join6(packageRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
|
|
4735
4961
|
if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
|
|
4736
4962
|
throw new ManagedNpmPackageError(
|
|
4737
4963
|
"managed_package_verification_failed",
|
|
@@ -4739,14 +4965,14 @@ async function validateManagedNpmPackageContents(root, definition) {
|
|
|
4739
4965
|
);
|
|
4740
4966
|
}
|
|
4741
4967
|
if (definition instanceof SriManagedNpmPackageDefinition) {
|
|
4742
|
-
const lock = await readJsonRecord(
|
|
4968
|
+
const lock = await readJsonRecord(join6(rootPath, "package-lock.json"), PACKAGE_LOCK_LIMIT_BYTES);
|
|
4743
4969
|
verifyPackageLockEntry(lock, definition, definition.verifyDependencyClosure);
|
|
4744
4970
|
for (const dependency of definition.requiredDependencies) {
|
|
4745
4971
|
await verifyRequiredDependency(rootPath, lock, dependency);
|
|
4746
4972
|
}
|
|
4747
4973
|
}
|
|
4748
4974
|
const declaredBin = readBinPath(metadata, definition.executableName);
|
|
4749
|
-
const executable = await resolveExecutablePath(
|
|
4975
|
+
const executable = await resolveExecutablePath(join6(packageRoot, declaredBin));
|
|
4750
4976
|
if (executable === null || !isContainedPath(rootPath, executable.path)) {
|
|
4751
4977
|
throw new ManagedNpmPackageError(
|
|
4752
4978
|
"managed_package_verification_failed",
|
|
@@ -4768,9 +4994,9 @@ var ManagedNpmPackageInstaller = class {
|
|
|
4768
4994
|
throw error62;
|
|
4769
4995
|
}
|
|
4770
4996
|
}
|
|
4771
|
-
const parent =
|
|
4997
|
+
const parent = dirname2(root);
|
|
4772
4998
|
await mkdir(parent, { mode: 448, recursive: true });
|
|
4773
|
-
const staging = await mkdtemp(
|
|
4999
|
+
const staging = await mkdtemp(join6(parent, `.${definition.version}.staging-`));
|
|
4774
5000
|
try {
|
|
4775
5001
|
const npm = await findExecutableOnPath(process.platform === "win32" ? "npm.cmd" : "npm", environment);
|
|
4776
5002
|
if (npm === null) {
|
|
@@ -4796,14 +5022,14 @@ var ManagedNpmPackageInstaller = class {
|
|
|
4796
5022
|
`${definition.packageName}@${definition.version}`
|
|
4797
5023
|
);
|
|
4798
5024
|
const installEnvironment = {
|
|
4799
|
-
HOME:
|
|
5025
|
+
HOME: join6(staging, "home"),
|
|
4800
5026
|
NPM_CONFIG_AUDIT: "false",
|
|
4801
|
-
NPM_CONFIG_CACHE:
|
|
5027
|
+
NPM_CONFIG_CACHE: join6(staging, ".npm-cache"),
|
|
4802
5028
|
NPM_CONFIG_FUND: "false",
|
|
4803
5029
|
NPM_CONFIG_IGNORE_SCRIPTS: "true",
|
|
4804
5030
|
NPM_CONFIG_PACKAGE_LOCK: "true",
|
|
4805
5031
|
NPM_CONFIG_REGISTRY: "https://registry.npmjs.org/",
|
|
4806
|
-
PATH: `${
|
|
5032
|
+
PATH: `${dirname2(process.execPath)}${delimiter}/usr/bin${delimiter}/bin`
|
|
4807
5033
|
};
|
|
4808
5034
|
if (definition.includeOptionalDependencies) {
|
|
4809
5035
|
installEnvironment["NPM_CONFIG_INCLUDE"] = "optional";
|
|
@@ -4820,8 +5046,8 @@ var ManagedNpmPackageInstaller = class {
|
|
|
4820
5046
|
timeoutMilliseconds: INSTALL_TIMEOUT_MILLISECONDS
|
|
4821
5047
|
});
|
|
4822
5048
|
await Promise.all([
|
|
4823
|
-
rm(
|
|
4824
|
-
rm(
|
|
5049
|
+
rm(join6(staging, ".npm-cache"), { force: true, recursive: true }),
|
|
5050
|
+
rm(join6(staging, "home"), { force: true, recursive: true })
|
|
4825
5051
|
]);
|
|
4826
5052
|
await validateManagedNpmPackage(staging, definition);
|
|
4827
5053
|
try {
|
|
@@ -4857,7 +5083,7 @@ var ManagedNpmPackageInstaller = class {
|
|
|
4857
5083
|
};
|
|
4858
5084
|
|
|
4859
5085
|
// src/agent-catalog/agent-specification.ts
|
|
4860
|
-
import { join as
|
|
5086
|
+
import { join as join7 } from "node:path";
|
|
4861
5087
|
|
|
4862
5088
|
// src/agent-catalog/version-output.ts
|
|
4863
5089
|
function normalizeVersionOutput(output2) {
|
|
@@ -4880,7 +5106,7 @@ var LocalAgentSpecification = class {
|
|
|
4880
5106
|
resolveManagedAgent = async (stateDirectory, platform, signal) => {
|
|
4881
5107
|
signal.throwIfAborted();
|
|
4882
5108
|
const executable = await resolveExecutablePath(
|
|
4883
|
-
|
|
5109
|
+
join7(stateDirectory, ...this.managedAgentExecutablePath),
|
|
4884
5110
|
platform
|
|
4885
5111
|
);
|
|
4886
5112
|
signal.throwIfAborted();
|
|
@@ -10112,7 +10338,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
10112
10338
|
var NONE = 0;
|
|
10113
10339
|
var ASSUMED = 1;
|
|
10114
10340
|
var PROVEN = 2;
|
|
10115
|
-
function isRecursive(inst, stack,
|
|
10341
|
+
function isRecursive(inst, stack, resolve10) {
|
|
10116
10342
|
const cached2 = recursive.get(inst);
|
|
10117
10343
|
if (cached2 !== void 0)
|
|
10118
10344
|
return cached2 ? PROVEN : NONE;
|
|
@@ -10122,7 +10348,7 @@ function isRecursive(inst, stack, resolve9) {
|
|
|
10122
10348
|
let result = NONE;
|
|
10123
10349
|
const check2 = (child2) => {
|
|
10124
10350
|
if (result !== PROVEN && child2?._zod) {
|
|
10125
|
-
const answer = isRecursive(child2, stack,
|
|
10351
|
+
const answer = isRecursive(child2, stack, resolve10);
|
|
10126
10352
|
if (answer > result)
|
|
10127
10353
|
result = answer;
|
|
10128
10354
|
}
|
|
@@ -10133,7 +10359,7 @@ function isRecursive(inst, stack, resolve9) {
|
|
|
10133
10359
|
const desc2 = Object.getOwnPropertyDescriptor(sh, key);
|
|
10134
10360
|
if (spread && !desc2.enumerable)
|
|
10135
10361
|
continue;
|
|
10136
|
-
const child2 = desc2.get ? ASSUMED : desc2.value?._zod ? isRecursive(desc2.value, stack,
|
|
10362
|
+
const child2 = desc2.get ? ASSUMED : desc2.value?._zod ? isRecursive(desc2.value, stack, resolve10) : NONE;
|
|
10137
10363
|
if (child2 > answer)
|
|
10138
10364
|
answer = child2;
|
|
10139
10365
|
}
|
|
@@ -10197,7 +10423,7 @@ function isRecursive(inst, stack, resolve9) {
|
|
|
10197
10423
|
break;
|
|
10198
10424
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
10199
10425
|
case "lazy": {
|
|
10200
|
-
const inner = def._cachedInner ?? (
|
|
10426
|
+
const inner = def._cachedInner ?? (resolve10 ? inst._zod.innerType : void 0);
|
|
10201
10427
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
10202
10428
|
break;
|
|
10203
10429
|
}
|
|
@@ -25032,9 +25258,10 @@ var CodexAppServerClient = class {
|
|
|
25032
25258
|
#pendingFragments = [];
|
|
25033
25259
|
constructor(options) {
|
|
25034
25260
|
this.#handlers = options.handlers;
|
|
25035
|
-
|
|
25261
|
+
const launch = executableLaunch2(options.command, ["app-server"]);
|
|
25262
|
+
this.#child = spawn2(launch.command, [...launch.arguments], {
|
|
25036
25263
|
cwd: options.cwd,
|
|
25037
|
-
|
|
25264
|
+
...platformSpawnOptions,
|
|
25038
25265
|
env: { ...process.env, ...options.environment },
|
|
25039
25266
|
shell: false,
|
|
25040
25267
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -28767,7 +28994,7 @@ var AgentProbeError = class extends Error {
|
|
|
28767
28994
|
};
|
|
28768
28995
|
|
|
28769
28996
|
// src/agent-catalog/agents/resolve-user-local-executable.ts
|
|
28770
|
-
import { isAbsolute as isAbsolute4, join as
|
|
28997
|
+
import { isAbsolute as isAbsolute4, join as join8 } from "node:path";
|
|
28771
28998
|
async function resolveUserLocalExecutable(executableName, context) {
|
|
28772
28999
|
context.signal.throwIfAborted();
|
|
28773
29000
|
const platform = context.platform ?? process.platform;
|
|
@@ -28775,7 +29002,7 @@ async function resolveUserLocalExecutable(executableName, context) {
|
|
|
28775
29002
|
if (platform === "win32" || homeDirectory === void 0 || !isAbsolute4(homeDirectory)) {
|
|
28776
29003
|
return [];
|
|
28777
29004
|
}
|
|
28778
|
-
const executable = await resolveExecutablePath(
|
|
29005
|
+
const executable = await resolveExecutablePath(join8(homeDirectory, ".local", "bin", executableName), platform);
|
|
28779
29006
|
context.signal.throwIfAborted();
|
|
28780
29007
|
return executable === null ? [] : [executable];
|
|
28781
29008
|
}
|
|
@@ -28864,8 +29091,8 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
28864
29091
|
};
|
|
28865
29092
|
|
|
28866
29093
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
28867
|
-
import { mkdir as mkdir2, realpath as
|
|
28868
|
-
import { isAbsolute as isAbsolute5, join as
|
|
29094
|
+
import { mkdir as mkdir2, realpath as realpath5, stat as stat4, writeFile } from "node:fs/promises";
|
|
29095
|
+
import { isAbsolute as isAbsolute5, join as join10, normalize } from "node:path";
|
|
28869
29096
|
|
|
28870
29097
|
// src/agent-installation/deepseek-managed-package.ts
|
|
28871
29098
|
var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
|
|
@@ -28883,13 +29110,13 @@ var DEEPSEEK_HARNESS_PACKAGE = new DeepSeekHarnessManagedPackage(
|
|
|
28883
29110
|
|
|
28884
29111
|
// src/storage/state-directory.ts
|
|
28885
29112
|
import { homedir } from "node:os";
|
|
28886
|
-
import { join as
|
|
29113
|
+
import { join as join9, resolve as resolve3 } from "node:path";
|
|
28887
29114
|
function readStateDirectory(environment = process.env) {
|
|
28888
29115
|
const configured = environment["MOBIUS_STATE_DIRECTORY"]?.trim();
|
|
28889
29116
|
if (configured !== void 0 && configured.length > 0) {
|
|
28890
|
-
return
|
|
29117
|
+
return resolve3(configured);
|
|
28891
29118
|
}
|
|
28892
|
-
return
|
|
29119
|
+
return join9(homedir(), ".mobius");
|
|
28893
29120
|
}
|
|
28894
29121
|
|
|
28895
29122
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
@@ -28907,13 +29134,13 @@ async function prepareAgentHome(path3, imagePrompts) {
|
|
|
28907
29134
|
if (imagePrompts) {
|
|
28908
29135
|
await mkdir2(path3, { mode: 448, recursive: true });
|
|
28909
29136
|
}
|
|
28910
|
-
const resolved = await
|
|
29137
|
+
const resolved = await realpath5(path3);
|
|
28911
29138
|
const metadata = await stat4(resolved);
|
|
28912
29139
|
if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
|
|
28913
29140
|
throw new Error("Agent home is not a user-owned directory");
|
|
28914
29141
|
}
|
|
28915
29142
|
if (imagePrompts) {
|
|
28916
|
-
await writeFile(
|
|
29143
|
+
await writeFile(join10(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
|
|
28917
29144
|
mode: 384
|
|
28918
29145
|
});
|
|
28919
29146
|
}
|
|
@@ -28961,7 +29188,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
28961
29188
|
context.signal
|
|
28962
29189
|
);
|
|
28963
29190
|
if (managed.path === agent.path) {
|
|
28964
|
-
selectedHome =
|
|
29191
|
+
selectedHome = join10(readStateDirectory(context.environment), "agents", this.id, "home");
|
|
28965
29192
|
managedHome = true;
|
|
28966
29193
|
}
|
|
28967
29194
|
} catch {
|
|
@@ -28977,7 +29204,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
28977
29204
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
28978
29205
|
signal.throwIfAborted();
|
|
28979
29206
|
const executable = await validateManagedNpmPackage(
|
|
28980
|
-
|
|
29207
|
+
join10(stateDirectory, "agents", this.id, DEEPSEEK_HARNESS_PACKAGE.version),
|
|
28981
29208
|
DEEPSEEK_HARNESS_PACKAGE
|
|
28982
29209
|
);
|
|
28983
29210
|
signal.throwIfAborted();
|
|
@@ -29031,8 +29258,8 @@ var GeminiCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
29031
29258
|
};
|
|
29032
29259
|
|
|
29033
29260
|
// src/agent-catalog/agents/grok-build-agent.ts
|
|
29034
|
-
import { realpath as
|
|
29035
|
-
import { isAbsolute as isAbsolute6, join as
|
|
29261
|
+
import { realpath as realpath6 } from "node:fs/promises";
|
|
29262
|
+
import { isAbsolute as isAbsolute6, join as join11, relative as relative2, sep as sep2 } from "node:path";
|
|
29036
29263
|
import {
|
|
29037
29264
|
RequestError
|
|
29038
29265
|
} from "@agentclientprotocol/sdk";
|
|
@@ -29102,8 +29329,8 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
29102
29329
|
);
|
|
29103
29330
|
if (managed.path === agent.path) {
|
|
29104
29331
|
return Object.freeze({
|
|
29105
|
-
GROK_HOME: await
|
|
29106
|
-
|
|
29332
|
+
GROK_HOME: await realpath6(
|
|
29333
|
+
join11(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION, "home")
|
|
29107
29334
|
)
|
|
29108
29335
|
});
|
|
29109
29336
|
}
|
|
@@ -29114,9 +29341,9 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
29114
29341
|
};
|
|
29115
29342
|
resolveManagedAgent = async (stateDirectory, platform, signal) => {
|
|
29116
29343
|
signal.throwIfAborted();
|
|
29117
|
-
const versionRoot = await
|
|
29118
|
-
await validateManagedNpmPackage(
|
|
29119
|
-
const executable = await resolveExecutablePath(
|
|
29344
|
+
const versionRoot = await realpath6(join11(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION));
|
|
29345
|
+
await validateManagedNpmPackage(join11(versionRoot, "package"), grokBuildManagedPackage(platform, process.arch));
|
|
29346
|
+
const executable = await resolveExecutablePath(join11(versionRoot, "home", "bin", "grok"), platform);
|
|
29120
29347
|
signal.throwIfAborted();
|
|
29121
29348
|
if (executable === null || !isContainedPath2(versionRoot, executable.path)) {
|
|
29122
29349
|
throw new AgentProbeError("managed_agent_invalid", "The managed Grok Build executable is invalid");
|
|
@@ -29216,13 +29443,13 @@ var OhMyPiAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
29216
29443
|
};
|
|
29217
29444
|
|
|
29218
29445
|
// src/agent-catalog/agents/opencode-agent.ts
|
|
29219
|
-
import { join as
|
|
29446
|
+
import { join as join13 } from "node:path";
|
|
29220
29447
|
|
|
29221
29448
|
// src/agent-installation/managed-agent-archive.ts
|
|
29222
29449
|
import { createHash } from "node:crypto";
|
|
29223
29450
|
import { createReadStream } from "node:fs";
|
|
29224
|
-
import { chmod, copyFile, mkdir as mkdir3, mkdtemp as mkdtemp2, open as open3, realpath as
|
|
29225
|
-
import { delimiter as delimiter2, dirname as
|
|
29451
|
+
import { chmod as chmod2, copyFile, mkdir as mkdir3, mkdtemp as mkdtemp2, open as open3, realpath as realpath7, rename as rename2, rm as rm2, stat as stat5, writeFile as writeFile2 } from "node:fs/promises";
|
|
29452
|
+
import { delimiter as delimiter2, dirname as dirname3, isAbsolute as isAbsolute7, join as join12, relative as relative3, sep as sep3 } from "node:path";
|
|
29226
29453
|
|
|
29227
29454
|
// src/agent-installation/verified-download.ts
|
|
29228
29455
|
import { fetch } from "undici";
|
|
@@ -29402,16 +29629,16 @@ async function readManifest(path3) {
|
|
|
29402
29629
|
}
|
|
29403
29630
|
async function validateManagedAgentArchive(root, definition, signal) {
|
|
29404
29631
|
try {
|
|
29405
|
-
const rootPath = await
|
|
29632
|
+
const rootPath = await realpath7(root);
|
|
29406
29633
|
const rootMetadata = await stat5(rootPath);
|
|
29407
29634
|
if (!rootMetadata.isDirectory() || typeof process.getuid === "function" && rootMetadata.uid !== process.getuid()) {
|
|
29408
29635
|
throw new Error("Managed Agent root is not user-owned");
|
|
29409
29636
|
}
|
|
29410
|
-
const manifest = await readManifest(
|
|
29637
|
+
const manifest = await readManifest(join12(rootPath, "archive.json"));
|
|
29411
29638
|
if (manifest["archiveSha256"] !== definition.archiveSha256 || manifest["archiveUrl"] !== definition.archiveUrl.toString() || manifest["version"] !== definition.version || typeof manifest["executableSha256"] !== "string") {
|
|
29412
29639
|
throw new Error("Managed Agent archive identity is invalid");
|
|
29413
29640
|
}
|
|
29414
|
-
const executable = await resolveExecutablePath(
|
|
29641
|
+
const executable = await resolveExecutablePath(join12(rootPath, "bin", definition.executableName));
|
|
29415
29642
|
if (executable === null || !isContainedPath3(rootPath, executable.path) || await hashFile(executable.path, signal) !== manifest["executableSha256"]) {
|
|
29416
29643
|
throw new Error("Managed Agent executable is invalid");
|
|
29417
29644
|
}
|
|
@@ -29577,7 +29804,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
29577
29804
|
return Object.freeze(environment);
|
|
29578
29805
|
};
|
|
29579
29806
|
resolveManagedAgent = async (stateDirectory, platform, signal) => await validateManagedAgentArchive(
|
|
29580
|
-
|
|
29807
|
+
join13(stateDirectory, "agents", this.id, OPENCODE_MANAGED_VERSION),
|
|
29581
29808
|
openCodeManagedArchive(platform, process.arch),
|
|
29582
29809
|
signal
|
|
29583
29810
|
);
|
|
@@ -29595,7 +29822,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
29595
29822
|
};
|
|
29596
29823
|
|
|
29597
29824
|
// src/agent-catalog/agents/pi-agent.ts
|
|
29598
|
-
import { join as
|
|
29825
|
+
import { join as join14 } from "node:path";
|
|
29599
29826
|
import {
|
|
29600
29827
|
methods as methods4
|
|
29601
29828
|
} from "@agentclientprotocol/sdk";
|
|
@@ -29654,7 +29881,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
29654
29881
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
29655
29882
|
signal.throwIfAborted();
|
|
29656
29883
|
const executable = await validateManagedNpmPackage(
|
|
29657
|
-
|
|
29884
|
+
join14(stateDirectory, "agents", this.id, PI_AGENT_PACKAGE.version),
|
|
29658
29885
|
PI_AGENT_PACKAGE
|
|
29659
29886
|
);
|
|
29660
29887
|
signal.throwIfAborted();
|
|
@@ -29692,7 +29919,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
29692
29919
|
};
|
|
29693
29920
|
|
|
29694
29921
|
// src/agent-catalog/agents/workbuddy-agent.ts
|
|
29695
|
-
import { join as
|
|
29922
|
+
import { join as join15 } from "node:path";
|
|
29696
29923
|
|
|
29697
29924
|
// src/agent-installation/workbuddy-managed-package.ts
|
|
29698
29925
|
var WORKBUDDY_MANAGED_VERSION = "2.146.0";
|
|
@@ -29738,7 +29965,7 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
29738
29965
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
29739
29966
|
signal.throwIfAborted();
|
|
29740
29967
|
const executable = await validateManagedNpmPackage(
|
|
29741
|
-
|
|
29968
|
+
join15(stateDirectory, "agents", this.id, WORKBUDDY_MANAGED_VERSION),
|
|
29742
29969
|
WORKBUDDY_MANAGED_PACKAGE
|
|
29743
29970
|
);
|
|
29744
29971
|
signal.throwIfAborted();
|
|
@@ -29975,9 +30202,10 @@ async function probeAcpReadiness(specification, agent, environment, defaultWorks
|
|
|
29975
30202
|
signal.removeEventListener("abort", abort);
|
|
29976
30203
|
}
|
|
29977
30204
|
}
|
|
29978
|
-
const
|
|
30205
|
+
const launch = executableLaunch2(agent.adapterPath, agent.arguments);
|
|
30206
|
+
const child2 = spawn3(launch.command, [...launch.arguments], {
|
|
29979
30207
|
cwd: defaultWorkspace,
|
|
29980
|
-
|
|
30208
|
+
...platformSpawnOptions,
|
|
29981
30209
|
env: { ...environment, ...agent.environment },
|
|
29982
30210
|
shell: false,
|
|
29983
30211
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -30110,10 +30338,10 @@ function isAgentVersionSupported(reportedVersion, minimumSupportedVersion) {
|
|
|
30110
30338
|
}
|
|
30111
30339
|
|
|
30112
30340
|
// src/agent-catalog/executable-discovery.ts
|
|
30113
|
-
import { isAbsolute as isAbsolute8, join as
|
|
30341
|
+
import { isAbsolute as isAbsolute8, join as join17 } from "node:path";
|
|
30114
30342
|
|
|
30115
30343
|
// src/agent-installation/managed-adapter-installer.ts
|
|
30116
|
-
import { join as
|
|
30344
|
+
import { join as join16 } from "node:path";
|
|
30117
30345
|
var ManagedAdapterInstallError = class extends Error {
|
|
30118
30346
|
code;
|
|
30119
30347
|
constructor(code, message, options = {}) {
|
|
@@ -30170,7 +30398,7 @@ var ManagedAdapterInstaller = class {
|
|
|
30170
30398
|
this.#stateDirectory = options.stateDirectory;
|
|
30171
30399
|
}
|
|
30172
30400
|
install = async (specification, signal) => {
|
|
30173
|
-
const root =
|
|
30401
|
+
const root = join16(this.#stateDirectory, "adapters", specification.id, specification.adapterVersion);
|
|
30174
30402
|
try {
|
|
30175
30403
|
return await this.#npmInstaller.install(
|
|
30176
30404
|
root,
|
|
@@ -30204,7 +30432,7 @@ async function resolveManagedAdapterExecutable(specification, context) {
|
|
|
30204
30432
|
let managed;
|
|
30205
30433
|
try {
|
|
30206
30434
|
managed = await validateManagedAdapter(
|
|
30207
|
-
|
|
30435
|
+
join17(readStateDirectory(context.environment), "adapters", specification.id, specification.adapterVersion),
|
|
30208
30436
|
specification
|
|
30209
30437
|
);
|
|
30210
30438
|
} catch {
|
|
@@ -30518,16 +30746,16 @@ async function discoverLocalAgentInventory(options) {
|
|
|
30518
30746
|
}
|
|
30519
30747
|
|
|
30520
30748
|
// src/config.ts
|
|
30521
|
-
import { join as
|
|
30749
|
+
import { join as join18, resolve as resolve4 } from "node:path";
|
|
30522
30750
|
function loadDefaultWorkspace(environment = process.env) {
|
|
30523
30751
|
const { MOBIUS_DEFAULT_WORKSPACE: configuredWorkspace } = environment;
|
|
30524
|
-
return configuredWorkspace ??
|
|
30752
|
+
return configuredWorkspace ?? join18(readStateDirectory(environment), "workspace");
|
|
30525
30753
|
}
|
|
30526
30754
|
var DaemonLocalContext = class {
|
|
30527
30755
|
environment;
|
|
30528
30756
|
stateDirectory;
|
|
30529
30757
|
constructor(stateDirectory, environment = process.env) {
|
|
30530
|
-
this.stateDirectory =
|
|
30758
|
+
this.stateDirectory = resolve4(stateDirectory);
|
|
30531
30759
|
this.environment = Object.freeze({ ...environment, MOBIUS_STATE_DIRECTORY: this.stateDirectory });
|
|
30532
30760
|
}
|
|
30533
30761
|
};
|
|
@@ -30570,15 +30798,14 @@ function createDaemonConfig(connection, agents = [], installableAgents = [], loc
|
|
|
30570
30798
|
// src/daemon-manager.ts
|
|
30571
30799
|
import { spawn as spawn6 } from "node:child_process";
|
|
30572
30800
|
import { createHash as createHash9, randomBytes } from "node:crypto";
|
|
30573
|
-
import { readFile as
|
|
30801
|
+
import { readFile as readFile4, unlink as unlink3, writeFile as writeFile5 } from "node:fs/promises";
|
|
30574
30802
|
import { createConnection, createServer } from "node:net";
|
|
30575
|
-
import {
|
|
30576
|
-
import { join as join22 } from "node:path";
|
|
30803
|
+
import { join as join24 } from "node:path";
|
|
30577
30804
|
|
|
30578
30805
|
// src/pairing/pair-local-machine.ts
|
|
30579
|
-
import { mkdir as mkdir5, realpath as
|
|
30806
|
+
import { mkdir as mkdir5, realpath as realpath8, stat as stat6 } from "node:fs/promises";
|
|
30580
30807
|
import { hostname as hostname3 } from "node:os";
|
|
30581
|
-
import { basename, resolve as
|
|
30808
|
+
import { basename, resolve as resolve6 } from "node:path";
|
|
30582
30809
|
import { fetch as fetch3 } from "undici";
|
|
30583
30810
|
|
|
30584
30811
|
// src/agent-catalog/publish-agent-catalog.ts
|
|
@@ -30749,8 +30976,21 @@ async function unchangedIdentity(agent, signal) {
|
|
|
30749
30976
|
|
|
30750
30977
|
// src/storage/runtime-installation-store.ts
|
|
30751
30978
|
import { createHash as createHash2, randomUUID } from "node:crypto";
|
|
30752
|
-
import { mkdir as mkdir4, open as open4, readdir as readdir2, rename as rename3, unlink, writeFile as writeFile3 } from "node:fs/promises";
|
|
30753
|
-
import { dirname as
|
|
30979
|
+
import { mkdir as mkdir4, open as open4, readdir as readdir2, rename as rename3, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
|
|
30980
|
+
import { dirname as dirname4, join as join19, resolve as resolve5 } from "node:path";
|
|
30981
|
+
|
|
30982
|
+
// src/filesystem/private-path.ts
|
|
30983
|
+
import { lstat as lstat2 } from "node:fs/promises";
|
|
30984
|
+
async function validateLocalPath(path3, directory, privateAccess, signal) {
|
|
30985
|
+
signal.throwIfAborted();
|
|
30986
|
+
const metadata = await lstat2(path3);
|
|
30987
|
+
if (metadata.isSymbolicLink() || (directory ? !metadata.isDirectory() : !metadata.isFile())) {
|
|
30988
|
+
throw new LocalPathError("Unsafe local path");
|
|
30989
|
+
}
|
|
30990
|
+
await platformSupportFor(process.platform).validatePathPermissions(path3, directory, privateAccess, signal);
|
|
30991
|
+
}
|
|
30992
|
+
|
|
30993
|
+
// src/storage/runtime-installation-store.ts
|
|
30754
30994
|
var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
|
|
30755
30995
|
var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
|
|
30756
30996
|
var INSTALLATION_ID_PATTERN = /^min_[a-f0-9]{32}$/;
|
|
@@ -30992,8 +31232,8 @@ async function readJsonFile(path3, signal, missingCode) {
|
|
|
30992
31232
|
}
|
|
30993
31233
|
async function writeJsonAtomically(path3, value, signal) {
|
|
30994
31234
|
signal.throwIfAborted();
|
|
30995
|
-
const directory =
|
|
30996
|
-
const temporaryPath =
|
|
31235
|
+
const directory = dirname4(path3);
|
|
31236
|
+
const temporaryPath = join19(directory, `.${randomUUID()}.tmp`);
|
|
30997
31237
|
try {
|
|
30998
31238
|
await mkdir4(directory, { mode: 448, recursive: true });
|
|
30999
31239
|
signal.throwIfAborted();
|
|
@@ -31002,7 +31242,7 @@ async function writeJsonAtomically(path3, value, signal) {
|
|
|
31002
31242
|
signal.throwIfAborted();
|
|
31003
31243
|
await rename3(temporaryPath, path3);
|
|
31004
31244
|
} catch (cause) {
|
|
31005
|
-
await
|
|
31245
|
+
await unlink2(temporaryPath).catch(() => void 0);
|
|
31006
31246
|
signal.throwIfAborted();
|
|
31007
31247
|
throw new RuntimeInstallationStoreError("connection_unavailable", "The local Runtime state cannot be written", {
|
|
31008
31248
|
cause
|
|
@@ -31019,15 +31259,17 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
31019
31259
|
this.applicationId = applicationId;
|
|
31020
31260
|
this.installationId = installationId2;
|
|
31021
31261
|
this.stateDirectory = stateDirectory;
|
|
31022
|
-
this.#channelDirectory =
|
|
31023
|
-
this.#connectionDirectory =
|
|
31262
|
+
this.#channelDirectory = join19(stateDirectory, "channels");
|
|
31263
|
+
this.#connectionDirectory = join19(stateDirectory, "connections");
|
|
31024
31264
|
}
|
|
31025
31265
|
static open = async (options, signal) => {
|
|
31026
31266
|
signal.throwIfAborted();
|
|
31027
31267
|
const applicationId = validateApplicationId(options.applicationId);
|
|
31028
|
-
const rootDirectory =
|
|
31029
|
-
const applicationDirectory =
|
|
31268
|
+
const rootDirectory = resolve5(options.stateDirectory);
|
|
31269
|
+
const applicationDirectory = join19(rootDirectory, "installations", applicationId);
|
|
31030
31270
|
try {
|
|
31271
|
+
await mkdir4(rootDirectory, { mode: 448, recursive: true });
|
|
31272
|
+
await validateLocalPath(rootDirectory, true, true, signal);
|
|
31031
31273
|
await mkdir4(applicationDirectory, { mode: 448, recursive: true });
|
|
31032
31274
|
} catch (cause) {
|
|
31033
31275
|
throw new RuntimeInstallationStoreError(
|
|
@@ -31039,7 +31281,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
31039
31281
|
);
|
|
31040
31282
|
}
|
|
31041
31283
|
const storedInstallationId = await readOrCreateInstallationId(applicationDirectory, signal);
|
|
31042
|
-
const stateDirectory =
|
|
31284
|
+
const stateDirectory = join19(applicationDirectory, storedInstallationId);
|
|
31043
31285
|
try {
|
|
31044
31286
|
await mkdir4(stateDirectory, { mode: 448, recursive: true });
|
|
31045
31287
|
} catch (cause) {
|
|
@@ -31054,8 +31296,8 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
31054
31296
|
signal.throwIfAborted();
|
|
31055
31297
|
return new _RuntimeInstallationStore(applicationId, storedInstallationId, stateDirectory);
|
|
31056
31298
|
};
|
|
31057
|
-
connectionPath = (connectionId2) =>
|
|
31058
|
-
channelIndexPath = (channelId) =>
|
|
31299
|
+
connectionPath = (connectionId2) => join19(this.#connectionDirectory, `${validateConnectionId(connectionId2)}.json`);
|
|
31300
|
+
channelIndexPath = (channelId) => join19(this.#channelDirectory, channelIndexFileName(validateIdentifier(channelId, "invalid_channel_id")));
|
|
31059
31301
|
readConnection = async (connectionId2, signal) => {
|
|
31060
31302
|
const stored = decodeConnection(
|
|
31061
31303
|
await readJsonFile(this.connectionPath(connectionId2), signal, "connection_not_found")
|
|
@@ -31178,9 +31420,9 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
31178
31420
|
const connection = await this.readConnection(connectionId2, signal);
|
|
31179
31421
|
signal.throwIfAborted();
|
|
31180
31422
|
try {
|
|
31181
|
-
await
|
|
31423
|
+
await unlink2(this.connectionPath(connection.connectionId));
|
|
31182
31424
|
signal.throwIfAborted();
|
|
31183
|
-
await
|
|
31425
|
+
await unlink2(this.channelIndexPath(connection.channelId));
|
|
31184
31426
|
} catch (cause) {
|
|
31185
31427
|
signal.throwIfAborted();
|
|
31186
31428
|
if (isNodeError(cause, "ENOENT")) {
|
|
@@ -31217,7 +31459,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
31217
31459
|
};
|
|
31218
31460
|
};
|
|
31219
31461
|
async function readOrCreateInstallationId(applicationDirectory, signal) {
|
|
31220
|
-
const pointerPath =
|
|
31462
|
+
const pointerPath = join19(applicationDirectory, "current.json");
|
|
31221
31463
|
try {
|
|
31222
31464
|
return decodeInstallationPointer(await readJsonFile(pointerPath, signal, "installation_not_found")).installationId;
|
|
31223
31465
|
} catch (cause) {
|
|
@@ -31355,10 +31597,10 @@ function parseResumeConnectionId(arguments_) {
|
|
|
31355
31597
|
return value;
|
|
31356
31598
|
}
|
|
31357
31599
|
async function resolveDefaultWorkspace(path3) {
|
|
31358
|
-
const requestedWorkspace =
|
|
31600
|
+
const requestedWorkspace = resolve6(path3);
|
|
31359
31601
|
try {
|
|
31360
31602
|
await mkdir5(requestedWorkspace, { recursive: true, mode: 448 });
|
|
31361
|
-
const defaultWorkspace = await
|
|
31603
|
+
const defaultWorkspace = await realpath8(requestedWorkspace);
|
|
31362
31604
|
const metadata = await stat6(defaultWorkspace);
|
|
31363
31605
|
if (!metadata.isDirectory()) {
|
|
31364
31606
|
throw new PairingClientError("invalid_workspace", "The default workspace is not a directory");
|
|
@@ -31580,7 +31822,7 @@ var AuditStore = class {
|
|
|
31580
31822
|
|
|
31581
31823
|
// src/run-daemon.ts
|
|
31582
31824
|
import { createHash as createHash8, randomUUID as randomUUID9 } from "node:crypto";
|
|
31583
|
-
import { join as
|
|
31825
|
+
import { join as join23 } from "node:path";
|
|
31584
31826
|
import { styleText } from "node:util";
|
|
31585
31827
|
|
|
31586
31828
|
// src/acp/active-executions.ts
|
|
@@ -31671,7 +31913,7 @@ import {
|
|
|
31671
31913
|
} from "@agentclientprotocol/sdk";
|
|
31672
31914
|
|
|
31673
31915
|
// src/authorization/local-raster.ts
|
|
31674
|
-
import { open as open5, readFile as
|
|
31916
|
+
import { open as open5, readFile as readFile3, realpath as realpath9, stat as stat7 } from "node:fs/promises";
|
|
31675
31917
|
import { basename as basename2, isAbsolute as isAbsolute9, normalize as normalize2 } from "node:path";
|
|
31676
31918
|
import { fileURLToPath } from "node:url";
|
|
31677
31919
|
var MAX_LOCAL_RASTER_BYTES = 128 * 1024 * 1024;
|
|
@@ -31694,7 +31936,7 @@ var LocalRasterImage = class {
|
|
|
31694
31936
|
this.sourceUri = sourceUri;
|
|
31695
31937
|
}
|
|
31696
31938
|
base64 = async () => {
|
|
31697
|
-
const bytes = this.bytes ?? new Uint8Array(await
|
|
31939
|
+
const bytes = this.bytes ?? new Uint8Array(await readFile3(this.sourceUri));
|
|
31698
31940
|
return Buffer.from(bytes).toString("base64");
|
|
31699
31941
|
};
|
|
31700
31942
|
};
|
|
@@ -31742,7 +31984,7 @@ async function resolveCanonicalPath(requested, signal) {
|
|
|
31742
31984
|
return null;
|
|
31743
31985
|
}
|
|
31744
31986
|
try {
|
|
31745
|
-
const target = await
|
|
31987
|
+
const target = await realpath9(requested);
|
|
31746
31988
|
signal.throwIfAborted();
|
|
31747
31989
|
if (!isAbsolute9(target) || normalize2(target) !== target) {
|
|
31748
31990
|
return null;
|
|
@@ -32323,7 +32565,7 @@ function createWritableAcpStream(output2) {
|
|
|
32323
32565
|
if (outputFailure !== void 0) {
|
|
32324
32566
|
return Promise.reject(outputFailure);
|
|
32325
32567
|
}
|
|
32326
|
-
return new Promise((
|
|
32568
|
+
return new Promise((resolve10, reject) => {
|
|
32327
32569
|
pendingWriteFailures.add(reject);
|
|
32328
32570
|
output2.write(chunk, (error62) => {
|
|
32329
32571
|
pendingWriteFailures.delete(reject);
|
|
@@ -32336,7 +32578,7 @@ function createWritableAcpStream(output2) {
|
|
|
32336
32578
|
reject(outputFailure);
|
|
32337
32579
|
return;
|
|
32338
32580
|
}
|
|
32339
|
-
|
|
32581
|
+
resolve10();
|
|
32340
32582
|
});
|
|
32341
32583
|
});
|
|
32342
32584
|
}
|
|
@@ -32358,9 +32600,10 @@ var AgentConnection = class {
|
|
|
32358
32600
|
this.connection = createAcpClient(client2).connect(inProcess.app());
|
|
32359
32601
|
return;
|
|
32360
32602
|
}
|
|
32361
|
-
const
|
|
32603
|
+
const launch = executableLaunch2(agent.adapterPath, agent.arguments);
|
|
32604
|
+
const child2 = spawn4(launch.command, [...launch.arguments], {
|
|
32362
32605
|
cwd,
|
|
32363
|
-
|
|
32606
|
+
...platformSpawnOptions,
|
|
32364
32607
|
env: { ...process.env, ...agent.environment },
|
|
32365
32608
|
shell: false,
|
|
32366
32609
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -32377,12 +32620,12 @@ var AgentConnection = class {
|
|
|
32377
32620
|
stderr.on("data", (chunk) => {
|
|
32378
32621
|
process.stderr.write(`[${agent.id}-acp] ${chunk}`);
|
|
32379
32622
|
});
|
|
32380
|
-
this.termination = new Promise((
|
|
32623
|
+
this.termination = new Promise((resolve10) => {
|
|
32381
32624
|
child2.once("error", (cause) => {
|
|
32382
|
-
|
|
32625
|
+
resolve10({ kind: "failed", error: new AcpExecutionError("The ACP process could not run", { cause }) });
|
|
32383
32626
|
});
|
|
32384
32627
|
child2.once("exit", (code, signal) => {
|
|
32385
|
-
|
|
32628
|
+
resolve10({
|
|
32386
32629
|
kind: "failed",
|
|
32387
32630
|
error: new AcpExecutionError("The ACP process stopped", { cause: { code, signal } })
|
|
32388
32631
|
});
|
|
@@ -34538,7 +34781,7 @@ function sql(strings, ...params) {
|
|
|
34538
34781
|
return new SQL([new StringChunk(str)]);
|
|
34539
34782
|
}
|
|
34540
34783
|
_sql.raw = raw;
|
|
34541
|
-
function
|
|
34784
|
+
function join25(chunks, separator) {
|
|
34542
34785
|
const result = [];
|
|
34543
34786
|
for (const [i, chunk] of chunks.entries()) {
|
|
34544
34787
|
if (i > 0 && separator !== void 0) result.push(separator);
|
|
@@ -34546,7 +34789,7 @@ function sql(strings, ...params) {
|
|
|
34546
34789
|
}
|
|
34547
34790
|
return new SQL(result);
|
|
34548
34791
|
}
|
|
34549
|
-
_sql.join =
|
|
34792
|
+
_sql.join = join25;
|
|
34550
34793
|
function identifier2(value) {
|
|
34551
34794
|
return new Name(value);
|
|
34552
34795
|
}
|
|
@@ -36691,7 +36934,7 @@ var SQLiteSelectBase = class extends TypedQueryBuilder {
|
|
|
36691
36934
|
const baseTableName = this.tableName;
|
|
36692
36935
|
const tableName = getTableLikeName(table);
|
|
36693
36936
|
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
36694
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
36937
|
+
if (typeof tableName === "string" && this.config.joins?.some((join25) => join25.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
36695
36938
|
if (!this.isPartialSelect) {
|
|
36696
36939
|
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
|
|
36697
36940
|
if (typeof tableName === "string" && !is(table, SQL)) {
|
|
@@ -37530,7 +37773,7 @@ var SQLiteDialect = class {
|
|
|
37530
37773
|
if (!joins2) return;
|
|
37531
37774
|
const withEntries = Object.entries(joins2).filter(([_, v]) => v);
|
|
37532
37775
|
if (!withEntries.length) return;
|
|
37533
|
-
return sql.join(withEntries.map(([k,
|
|
37776
|
+
return sql.join(withEntries.map(([k, join25]) => {
|
|
37534
37777
|
const relation = tableConfig.relations[k];
|
|
37535
37778
|
const isSingle2 = is(relation, One);
|
|
37536
37779
|
const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
|
|
@@ -37541,7 +37784,7 @@ var SQLiteDialect = class {
|
|
|
37541
37784
|
table: targetTable,
|
|
37542
37785
|
mode: isSingle2 ? "first" : "many",
|
|
37543
37786
|
schema,
|
|
37544
|
-
queryConfig:
|
|
37787
|
+
queryConfig: join25,
|
|
37545
37788
|
tableConfig: schema[relation.targetTableName],
|
|
37546
37789
|
relationWhere: filter,
|
|
37547
37790
|
isNested: true,
|
|
@@ -37555,7 +37798,7 @@ var SQLiteDialect = class {
|
|
|
37555
37798
|
key: k,
|
|
37556
37799
|
selection: innerQuery.selection,
|
|
37557
37800
|
isArray: !isSingle2,
|
|
37558
|
-
isOptional: (relation.optional ?? false) ||
|
|
37801
|
+
isOptional: (relation.optional ?? false) || join25 !== true && !!join25.where
|
|
37559
37802
|
});
|
|
37560
37803
|
const jsonColumns = sql.join(innerQuery.selection.map((s) => {
|
|
37561
37804
|
return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
|
|
@@ -38171,7 +38414,7 @@ var SQLiteUpdateBase = class {
|
|
|
38171
38414
|
createJoin(joinType) {
|
|
38172
38415
|
return ((table, on) => {
|
|
38173
38416
|
const tableName = getTableLikeName(table);
|
|
38174
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
38417
|
+
if (typeof tableName === "string" && this.config.joins.some((join25) => join25.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
38175
38418
|
if (typeof on === "function") {
|
|
38176
38419
|
const from = this.config.from ? is(table, SQLiteTable) ? table[Table.Symbol.Columns] : is(table, Subquery) ? table._.selectedFields : is(table, SQLiteViewBase) ? table[ViewBaseConfig].selectedFields : void 0 : void 0;
|
|
38177
38420
|
on = on(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
|
|
@@ -40830,8 +41073,8 @@ var AcpContentExternalizer = class {
|
|
|
40830
41073
|
|
|
40831
41074
|
// src/external-content/local-external-content-store.ts
|
|
40832
41075
|
import { createHash as createHash3, randomUUID as randomUUID3 } from "node:crypto";
|
|
40833
|
-
import { lstat, mkdir as mkdir6, readdir as readdir3, realpath as
|
|
40834
|
-
import { dirname as
|
|
41076
|
+
import { lstat as lstat3, mkdir as mkdir6, readdir as readdir3, realpath as realpath10, rename as rename4, rm as rm3, stat as stat8, utimes, writeFile as writeFile4 } from "node:fs/promises";
|
|
41077
|
+
import { dirname as dirname5, join as join20 } from "node:path";
|
|
40835
41078
|
var contentRequest = /^mobius-content:(image|audio|resource):([a-f0-9]{64})$/u;
|
|
40836
41079
|
var CONTENT_LIFETIME_MILLISECONDS = 24 * 60 * 60 * 1e3;
|
|
40837
41080
|
var metadataSchema2 = external_exports.strictObject({
|
|
@@ -40867,7 +41110,7 @@ var LocalExternalContentStore = class {
|
|
|
40867
41110
|
#expirationTimer;
|
|
40868
41111
|
#cleanup = Promise.resolve();
|
|
40869
41112
|
constructor(stateDirectory) {
|
|
40870
|
-
this.#root =
|
|
41113
|
+
this.#root = join20(stateDirectory, "tmp", "session-content", randomUUID3());
|
|
40871
41114
|
this.#expirationTimer = setInterval(() => {
|
|
40872
41115
|
void this.#expire().catch(() => void 0);
|
|
40873
41116
|
}, 6e4);
|
|
@@ -40878,11 +41121,11 @@ var LocalExternalContentStore = class {
|
|
|
40878
41121
|
await mkdir6(this.#root, { mode: 448, recursive: true });
|
|
40879
41122
|
const now = /* @__PURE__ */ new Date();
|
|
40880
41123
|
await utimes(this.#root, now, now);
|
|
40881
|
-
for (const directory of await readdir3(
|
|
41124
|
+
for (const directory of await readdir3(dirname5(this.#root), { withFileTypes: true })) {
|
|
40882
41125
|
if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
|
|
40883
41126
|
continue;
|
|
40884
41127
|
}
|
|
40885
|
-
const path3 =
|
|
41128
|
+
const path3 = join20(dirname5(this.#root), directory.name);
|
|
40886
41129
|
if (path3 === this.#root) {
|
|
40887
41130
|
continue;
|
|
40888
41131
|
}
|
|
@@ -40932,10 +41175,10 @@ var LocalExternalContentStore = class {
|
|
|
40932
41175
|
}
|
|
40933
41176
|
await this.#expire();
|
|
40934
41177
|
active.throwIfAborted();
|
|
40935
|
-
const directory =
|
|
41178
|
+
const directory = join20(this.#root, kind);
|
|
40936
41179
|
await mkdir6(directory, { mode: 448, recursive: true });
|
|
40937
41180
|
active.throwIfAborted();
|
|
40938
|
-
const path3 =
|
|
41181
|
+
const path3 = join20(directory, key);
|
|
40939
41182
|
const write = atomicWrite(path3, bytes, active);
|
|
40940
41183
|
await write;
|
|
40941
41184
|
active.throwIfAborted();
|
|
@@ -40968,12 +41211,12 @@ var LocalExternalContentStore = class {
|
|
|
40968
41211
|
}
|
|
40969
41212
|
try {
|
|
40970
41213
|
const [resolvedDirectory, resolvedPath, file2] = await Promise.all([
|
|
40971
|
-
|
|
40972
|
-
|
|
40973
|
-
|
|
41214
|
+
realpath10(dirname5(entry.path)),
|
|
41215
|
+
realpath10(entry.path),
|
|
41216
|
+
lstat3(entry.path)
|
|
40974
41217
|
]);
|
|
40975
41218
|
signal.throwIfAborted();
|
|
40976
|
-
if (!file2.isFile() || file2.isSymbolicLink() ||
|
|
41219
|
+
if (!file2.isFile() || file2.isSymbolicLink() || dirname5(resolvedPath) !== resolvedDirectory) {
|
|
40977
41220
|
return null;
|
|
40978
41221
|
}
|
|
40979
41222
|
return { mediaType: entry.mediaType, name: entry.name, path: resolvedPath };
|
|
@@ -42274,7 +42517,7 @@ var AgentInstallationManager = class {
|
|
|
42274
42517
|
|
|
42275
42518
|
// src/agent-installation/fixed-installation-executor.ts
|
|
42276
42519
|
import { realpathSync as realpathSync2, statSync as statSync2 } from "node:fs";
|
|
42277
|
-
import { resolve as
|
|
42520
|
+
import { resolve as resolve7 } from "node:path";
|
|
42278
42521
|
function findSpecification(specifications, agentId) {
|
|
42279
42522
|
for (const specification of specifications) {
|
|
42280
42523
|
if (specification.id === agentId) {
|
|
@@ -42285,7 +42528,7 @@ function findSpecification(specifications, agentId) {
|
|
|
42285
42528
|
}
|
|
42286
42529
|
function resolveDefaultWorkspace2(path3) {
|
|
42287
42530
|
try {
|
|
42288
|
-
const directory = realpathSync2(
|
|
42531
|
+
const directory = realpathSync2(resolve7(path3));
|
|
42289
42532
|
if (!statSync2(directory).isDirectory()) {
|
|
42290
42533
|
throw new Error("Default workspace is not a directory");
|
|
42291
42534
|
}
|
|
@@ -42300,7 +42543,7 @@ function resolveDefaultWorkspace2(path3) {
|
|
|
42300
42543
|
}
|
|
42301
42544
|
function resolveIntegrationStateDirectory(path3) {
|
|
42302
42545
|
try {
|
|
42303
|
-
const directory = realpathSync2(
|
|
42546
|
+
const directory = realpathSync2(resolve7(path3));
|
|
42304
42547
|
const metadata = statSync2(directory);
|
|
42305
42548
|
if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
|
|
42306
42549
|
throw new Error("Installation directory is not user-owned");
|
|
@@ -42472,9 +42715,9 @@ var FixedInstallationExecutor = class {
|
|
|
42472
42715
|
};
|
|
42473
42716
|
|
|
42474
42717
|
// src/authorization/workspace-directory.ts
|
|
42475
|
-
import { readdir as readdir4, realpath as
|
|
42718
|
+
import { readdir as readdir4, realpath as realpath11, stat as stat9 } from "node:fs/promises";
|
|
42476
42719
|
import { homedir as homedir2 } from "node:os";
|
|
42477
|
-
import { basename as basename4, dirname as
|
|
42720
|
+
import { basename as basename4, dirname as dirname6, isAbsolute as isAbsolute10, join as join21, normalize as normalize3, relative as relative4 } from "node:path";
|
|
42478
42721
|
|
|
42479
42722
|
// src/authorization/local-authorization-error.ts
|
|
42480
42723
|
var LocalAuthorizationError = class extends Error {
|
|
@@ -42553,7 +42796,7 @@ var WorkspaceDirectoryService = class {
|
|
|
42553
42796
|
throw new LocalAuthorizationError("The local directory path is invalid");
|
|
42554
42797
|
}
|
|
42555
42798
|
try {
|
|
42556
|
-
const target = await
|
|
42799
|
+
const target = await realpath11(requested);
|
|
42557
42800
|
signal.throwIfAborted();
|
|
42558
42801
|
const metadata = await stat9(target);
|
|
42559
42802
|
signal.throwIfAborted();
|
|
@@ -42603,7 +42846,7 @@ var WorkspaceDirectoryService = class {
|
|
|
42603
42846
|
continue;
|
|
42604
42847
|
}
|
|
42605
42848
|
try {
|
|
42606
|
-
const path3 = await this.resolvePath(
|
|
42849
|
+
const path3 = await this.resolvePath(join21(target, child2.name), signal);
|
|
42607
42850
|
entries.push({ directoryId: encodePath(path3), name: child2.name });
|
|
42608
42851
|
} catch (cause) {
|
|
42609
42852
|
signal.throwIfAborted();
|
|
@@ -42613,7 +42856,7 @@ var WorkspaceDirectoryService = class {
|
|
|
42613
42856
|
}
|
|
42614
42857
|
}
|
|
42615
42858
|
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
42616
|
-
const parent =
|
|
42859
|
+
const parent = dirname6(target);
|
|
42617
42860
|
return new WorkspaceDirectoryListing(
|
|
42618
42861
|
id,
|
|
42619
42862
|
this.label(target),
|
|
@@ -42639,15 +42882,15 @@ var WorkspaceDirectoryService = class {
|
|
|
42639
42882
|
|
|
42640
42883
|
// src/daemon-diagnostic-log.ts
|
|
42641
42884
|
import { appendFileSync, mkdirSync, readFileSync as readFileSync2, renameSync, statSync as statSync3, writeFileSync } from "node:fs";
|
|
42642
|
-
import { join as
|
|
42885
|
+
import { join as join22 } from "node:path";
|
|
42643
42886
|
var MAXIMUM_DAEMON_LOG_BYTES = 1 * 1024 * 1024;
|
|
42644
42887
|
var DaemonDiagnosticLog = class {
|
|
42645
42888
|
#directory;
|
|
42646
42889
|
#path;
|
|
42647
42890
|
#maximumBytes;
|
|
42648
42891
|
constructor(stateDirectory, maximumBytes = MAXIMUM_DAEMON_LOG_BYTES) {
|
|
42649
|
-
this.#directory =
|
|
42650
|
-
this.#path =
|
|
42892
|
+
this.#directory = join22(stateDirectory, "logs");
|
|
42893
|
+
this.#path = join22(this.#directory, "daemon.log");
|
|
42651
42894
|
this.#maximumBytes = maximumBytes;
|
|
42652
42895
|
}
|
|
42653
42896
|
// Export only correlation and failure metadata. Local messages and paths stay local.
|
|
@@ -43463,7 +43706,7 @@ var ActiveDaemonTurn = class {
|
|
|
43463
43706
|
var MAX_SESSIONS_WITH_COMPLETED_RECOVERY = 32;
|
|
43464
43707
|
var waitForTurnCompletion = (turn, waitSignal) => {
|
|
43465
43708
|
waitSignal.throwIfAborted();
|
|
43466
|
-
return new Promise((
|
|
43709
|
+
return new Promise((resolve10, reject) => {
|
|
43467
43710
|
let settled = false;
|
|
43468
43711
|
const finish = (result) => {
|
|
43469
43712
|
if (settled) {
|
|
@@ -43472,7 +43715,7 @@ var waitForTurnCompletion = (turn, waitSignal) => {
|
|
|
43472
43715
|
settled = true;
|
|
43473
43716
|
waitSignal.removeEventListener("abort", onAbort);
|
|
43474
43717
|
if (result.kind === "completed") {
|
|
43475
|
-
|
|
43718
|
+
resolve10();
|
|
43476
43719
|
} else {
|
|
43477
43720
|
reject(result.error);
|
|
43478
43721
|
}
|
|
@@ -43670,7 +43913,7 @@ var sessionEventCacheMigrations = [
|
|
|
43670
43913
|
|
|
43671
43914
|
// src/infra/local-sqlite-database.ts
|
|
43672
43915
|
import { chmodSync, mkdirSync as mkdirSync2 } from "node:fs";
|
|
43673
|
-
import { dirname as
|
|
43916
|
+
import { dirname as dirname7 } from "node:path";
|
|
43674
43917
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
43675
43918
|
|
|
43676
43919
|
// ../../node_modules/.pnpm/drizzle-orm@1.0.0-rc.4_@cloudflare+workers-types@5.20260918.1_@types+better-sqlite3@7.6_f872c171b7e1945bb1fa42180063dab2/node_modules/drizzle-orm/node-sqlite/session.js
|
|
@@ -43781,7 +44024,7 @@ var LocalSqliteDatabase = class {
|
|
|
43781
44024
|
orm;
|
|
43782
44025
|
#sqlite;
|
|
43783
44026
|
constructor(path3, label, migrations, pragmas = []) {
|
|
43784
|
-
mkdirSync2(
|
|
44027
|
+
mkdirSync2(dirname7(path3), { mode: 448, recursive: true });
|
|
43785
44028
|
this.#sqlite = new DatabaseSync2(path3);
|
|
43786
44029
|
chmodSync(path3, 384);
|
|
43787
44030
|
try {
|
|
@@ -44340,10 +44583,11 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
44340
44583
|
);
|
|
44341
44584
|
}
|
|
44342
44585
|
signal.throwIfAborted();
|
|
44343
|
-
const
|
|
44586
|
+
const launch = executableLaunch2(agent.agentIdentity.realPath, ["app-server"]);
|
|
44587
|
+
const child2 = spawn5(launch.command, [...launch.arguments], {
|
|
44344
44588
|
cwd,
|
|
44345
44589
|
env: { ...process.env, ...agent.environment },
|
|
44346
|
-
|
|
44590
|
+
...platformSpawnOptions,
|
|
44347
44591
|
shell: false,
|
|
44348
44592
|
stdio: ["pipe", "pipe", "ignore"]
|
|
44349
44593
|
});
|
|
@@ -45769,8 +46013,8 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45769
46013
|
|
|
45770
46014
|
// src/artifacts/local-file-streamer.ts
|
|
45771
46015
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
45772
|
-
import { realpath as
|
|
45773
|
-
import { basename as basename5, extname, isAbsolute as isAbsolute11, normalize as normalize4, resolve as
|
|
46016
|
+
import { realpath as realpath12, stat as stat10 } from "node:fs/promises";
|
|
46017
|
+
import { basename as basename5, extname as extname2, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve8 } from "node:path";
|
|
45774
46018
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
45775
46019
|
var CHUNK_BYTES = 192 * 1024;
|
|
45776
46020
|
function requestedPath(value) {
|
|
@@ -45792,12 +46036,12 @@ async function resolveFile(value, workingDirectory, signal) {
|
|
|
45792
46036
|
if (path3 === null || !isAbsolute11(path3) && workingDirectory === null) {
|
|
45793
46037
|
return null;
|
|
45794
46038
|
}
|
|
45795
|
-
const requested = workingDirectory === null ? path3 :
|
|
46039
|
+
const requested = workingDirectory === null ? path3 : resolve8(workingDirectory, path3);
|
|
45796
46040
|
if (!isAbsolute11(requested) || isAbsolute11(path3) && normalize4(path3) !== path3) {
|
|
45797
46041
|
return null;
|
|
45798
46042
|
}
|
|
45799
46043
|
try {
|
|
45800
|
-
const target = await
|
|
46044
|
+
const target = await realpath12(requested);
|
|
45801
46045
|
signal.throwIfAborted();
|
|
45802
46046
|
return isAbsolute11(target) && normalize4(target) === target ? target : null;
|
|
45803
46047
|
} catch {
|
|
@@ -45820,7 +46064,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
|
|
|
45820
46064
|
send2({
|
|
45821
46065
|
byteLength: before.size,
|
|
45822
46066
|
kind: FILE_BEGIN_KIND,
|
|
45823
|
-
mediaType: external?.mediaType ?? raster?.mimeType ?? (
|
|
46067
|
+
mediaType: external?.mediaType ?? raster?.mimeType ?? (extname2(target).toLowerCase() === ".svg" ? "image/svg+xml" : "application/octet-stream"),
|
|
45824
46068
|
modifiedAt: before.mtime.toISOString(),
|
|
45825
46069
|
name: external?.name ?? (basename5(target) || "file"),
|
|
45826
46070
|
requestId: command.requestId,
|
|
@@ -46722,13 +46966,13 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
46722
46966
|
operationSignal.throwIfAborted();
|
|
46723
46967
|
const skipPrevious = command.action === "active-turn";
|
|
46724
46968
|
if (previous.length > 0 && !skipPrevious) {
|
|
46725
|
-
await new Promise((
|
|
46969
|
+
await new Promise((resolve10, reject) => {
|
|
46726
46970
|
const onAbort = () => reject(operationSignal.reason);
|
|
46727
46971
|
operationSignal.addEventListener("abort", onAbort, { once: true });
|
|
46728
46972
|
void Promise.all(previous.map((request) => request.completion)).then(
|
|
46729
46973
|
() => {
|
|
46730
46974
|
operationSignal.removeEventListener("abort", onAbort);
|
|
46731
|
-
|
|
46975
|
+
resolve10();
|
|
46732
46976
|
},
|
|
46733
46977
|
(error62) => {
|
|
46734
46978
|
operationSignal.removeEventListener("abort", onAbort);
|
|
@@ -47162,7 +47406,7 @@ var RelayConnectionError = class extends Error {
|
|
|
47162
47406
|
};
|
|
47163
47407
|
function connectRelay(url2, signal) {
|
|
47164
47408
|
signal.throwIfAborted();
|
|
47165
|
-
return new Promise((
|
|
47409
|
+
return new Promise((resolve10, reject) => {
|
|
47166
47410
|
const endpoint = new URL(url2);
|
|
47167
47411
|
const headers = runtimeAuthorization(endpoint);
|
|
47168
47412
|
endpoint.searchParams.delete("token");
|
|
@@ -47229,7 +47473,7 @@ function connectRelay(url2, signal) {
|
|
|
47229
47473
|
}
|
|
47230
47474
|
finished = true;
|
|
47231
47475
|
cleanup();
|
|
47232
|
-
|
|
47476
|
+
resolve10(socket);
|
|
47233
47477
|
};
|
|
47234
47478
|
function onTimeout() {
|
|
47235
47479
|
fail(
|
|
@@ -47411,7 +47655,7 @@ async function runRelayConnection({
|
|
|
47411
47655
|
installationObserver.connect(socket);
|
|
47412
47656
|
onConnected();
|
|
47413
47657
|
try {
|
|
47414
|
-
await new Promise((
|
|
47658
|
+
await new Promise((resolve10, reject) => {
|
|
47415
47659
|
let finished = false;
|
|
47416
47660
|
const cleanup = () => {
|
|
47417
47661
|
connectionLiveness.close();
|
|
@@ -47429,7 +47673,7 @@ async function runRelayConnection({
|
|
|
47429
47673
|
}
|
|
47430
47674
|
finished = true;
|
|
47431
47675
|
cleanup();
|
|
47432
|
-
|
|
47676
|
+
resolve10();
|
|
47433
47677
|
};
|
|
47434
47678
|
const rejectConnection = (failure2) => {
|
|
47435
47679
|
if (finished) {
|
|
@@ -47815,12 +48059,12 @@ function waitForRelayRetry(signal, timer) {
|
|
|
47815
48059
|
if (signal.aborted) {
|
|
47816
48060
|
return Promise.resolve();
|
|
47817
48061
|
}
|
|
47818
|
-
return new Promise((
|
|
48062
|
+
return new Promise((resolve10) => {
|
|
47819
48063
|
const retry = timer.schedule(finish, RELAY_RECONNECT_DELAY_MILLISECONDS);
|
|
47820
48064
|
function finish() {
|
|
47821
48065
|
retry.cancel();
|
|
47822
48066
|
signal.removeEventListener("abort", finish);
|
|
47823
|
-
|
|
48067
|
+
resolve10();
|
|
47824
48068
|
}
|
|
47825
48069
|
signal.addEventListener("abort", finish, { once: true });
|
|
47826
48070
|
});
|
|
@@ -47876,11 +48120,11 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
47876
48120
|
stateDirectory
|
|
47877
48121
|
});
|
|
47878
48122
|
const channelHash = createHash8("sha256").update(config2.channelId).digest("hex");
|
|
47879
|
-
const sessionDatabase = openAcpSessionDatabase(
|
|
48123
|
+
const sessionDatabase = openAcpSessionDatabase(join23(stateDirectory, "sessions", `${channelHash}.sqlite`));
|
|
47880
48124
|
let eventsV2;
|
|
47881
48125
|
try {
|
|
47882
48126
|
eventsV2 = new CachedAcpSessionEventStoreV2(
|
|
47883
|
-
openSessionEventCacheV2Database(
|
|
48127
|
+
openSessionEventCacheV2Database(join23(stateDirectory, "sessions", `${channelHash}.events.sqlite`))
|
|
47884
48128
|
);
|
|
47885
48129
|
} catch (error62) {
|
|
47886
48130
|
sessionDatabase.close();
|
|
@@ -48147,17 +48391,17 @@ var START_TIMEOUT_MILLISECONDS = 12e4;
|
|
|
48147
48391
|
var MAXIMUM_MESSAGE_BYTES = 64 * 1024;
|
|
48148
48392
|
var CONNECTION_ID_PATTERN2 = /^mcn_[a-f0-9]{32}$/;
|
|
48149
48393
|
async function acquireManagerLock(stateDirectory) {
|
|
48150
|
-
const path3 =
|
|
48394
|
+
const path3 = join24(stateDirectory, "manager.lock");
|
|
48151
48395
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
48152
48396
|
try {
|
|
48153
48397
|
await writeFile5(path3, `${process.pid.toString()}
|
|
48154
48398
|
`, { flag: "wx", mode: 384 });
|
|
48155
|
-
return async () => await
|
|
48399
|
+
return async () => await unlink3(path3).catch(() => void 0);
|
|
48156
48400
|
} catch (cause) {
|
|
48157
48401
|
if (!isNodeError2(cause, "EEXIST")) {
|
|
48158
48402
|
throw cause;
|
|
48159
48403
|
}
|
|
48160
|
-
const encoded = await
|
|
48404
|
+
const encoded = await readFile4(path3, "utf8").catch(() => "");
|
|
48161
48405
|
const pid = Number(encoded.trim());
|
|
48162
48406
|
if (Number.isSafeInteger(pid) && pid > 1) {
|
|
48163
48407
|
try {
|
|
@@ -48169,7 +48413,7 @@ async function acquireManagerLock(stateDirectory) {
|
|
|
48169
48413
|
}
|
|
48170
48414
|
}
|
|
48171
48415
|
}
|
|
48172
|
-
await
|
|
48416
|
+
await unlink3(path3).catch(() => void 0);
|
|
48173
48417
|
}
|
|
48174
48418
|
}
|
|
48175
48419
|
return null;
|
|
@@ -48177,17 +48421,18 @@ async function acquireManagerLock(stateDirectory) {
|
|
|
48177
48421
|
function isRecord12(value) {
|
|
48178
48422
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
48179
48423
|
}
|
|
48424
|
+
var managerPlatform = platformSupportFor(process.platform);
|
|
48180
48425
|
function controlSocketPath(stateDirectory) {
|
|
48181
48426
|
const installationHash = createHash9("sha256").update(stateDirectory).digest("hex").slice(0, 32);
|
|
48182
|
-
return
|
|
48427
|
+
return managerPlatform.controlSocketPath(installationHash);
|
|
48183
48428
|
}
|
|
48184
48429
|
function controlTokenPath(stateDirectory) {
|
|
48185
|
-
return
|
|
48430
|
+
return join24(stateDirectory, "manager.token");
|
|
48186
48431
|
}
|
|
48187
48432
|
async function readOrCreateControlToken(stateDirectory) {
|
|
48188
48433
|
const path3 = controlTokenPath(stateDirectory);
|
|
48189
48434
|
try {
|
|
48190
|
-
return (await
|
|
48435
|
+
return (await readFile4(path3, "utf8")).trim();
|
|
48191
48436
|
} catch (cause) {
|
|
48192
48437
|
if (!isNodeError2(cause, "ENOENT")) {
|
|
48193
48438
|
throw cause;
|
|
@@ -48202,7 +48447,7 @@ async function readOrCreateControlToken(stateDirectory) {
|
|
|
48202
48447
|
if (!isNodeError2(cause, "EEXIST")) {
|
|
48203
48448
|
throw cause;
|
|
48204
48449
|
}
|
|
48205
|
-
return (await
|
|
48450
|
+
return (await readFile4(path3, "utf8")).trim();
|
|
48206
48451
|
}
|
|
48207
48452
|
}
|
|
48208
48453
|
function isNodeError2(error62, code) {
|
|
@@ -48421,9 +48666,9 @@ async function waitForReady(active, signal) {
|
|
|
48421
48666
|
return;
|
|
48422
48667
|
}
|
|
48423
48668
|
const deadline = AbortSignal.any([signal, AbortSignal.timeout(START_TIMEOUT_MILLISECONDS)]);
|
|
48424
|
-
await new Promise((
|
|
48669
|
+
await new Promise((resolve10, reject) => {
|
|
48425
48670
|
const abort = () => reject(deadline.reason);
|
|
48426
|
-
active.ready.then(
|
|
48671
|
+
active.ready.then(resolve10, reject).finally(() => deadline.removeEventListener("abort", abort));
|
|
48427
48672
|
deadline.addEventListener("abort", abort, { once: true });
|
|
48428
48673
|
});
|
|
48429
48674
|
if (active.status === "failed") {
|
|
@@ -48434,7 +48679,7 @@ function errorMessage2(error62) {
|
|
|
48434
48679
|
return error62 instanceof Error ? error62.message : "Unknown failure";
|
|
48435
48680
|
}
|
|
48436
48681
|
async function readSocketMessage(socket, signal) {
|
|
48437
|
-
return await new Promise((
|
|
48682
|
+
return await new Promise((resolve10, reject) => {
|
|
48438
48683
|
let encoded = "";
|
|
48439
48684
|
const finish = (error62, value) => {
|
|
48440
48685
|
signal.removeEventListener("abort", abort);
|
|
@@ -48442,7 +48687,7 @@ async function readSocketMessage(socket, signal) {
|
|
|
48442
48687
|
socket.removeAllListeners("error");
|
|
48443
48688
|
socket.removeAllListeners("end");
|
|
48444
48689
|
if (error62 === void 0) {
|
|
48445
|
-
|
|
48690
|
+
resolve10(value);
|
|
48446
48691
|
} else {
|
|
48447
48692
|
reject(error62);
|
|
48448
48693
|
}
|
|
@@ -48477,14 +48722,14 @@ async function sendControlRequest(stateDirectory, command, signal) {
|
|
|
48477
48722
|
const deadline = AbortSignal.any([signal, AbortSignal.timeout(CONTROL_TIMEOUT_MILLISECONDS)]);
|
|
48478
48723
|
const socket = createConnection(controlSocketPath(stateDirectory));
|
|
48479
48724
|
try {
|
|
48480
|
-
await new Promise((
|
|
48725
|
+
await new Promise((resolve10, reject) => {
|
|
48481
48726
|
const abort = () => {
|
|
48482
48727
|
socket.destroy();
|
|
48483
48728
|
reject(deadline.reason);
|
|
48484
48729
|
};
|
|
48485
48730
|
socket.once("connect", () => {
|
|
48486
48731
|
deadline.removeEventListener("abort", abort);
|
|
48487
|
-
|
|
48732
|
+
resolve10();
|
|
48488
48733
|
});
|
|
48489
48734
|
socket.once("error", reject);
|
|
48490
48735
|
deadline.addEventListener("abort", abort, { once: true });
|
|
@@ -48499,6 +48744,7 @@ async function sendControlRequest(stateDirectory, command, signal) {
|
|
|
48499
48744
|
async function spawnManager() {
|
|
48500
48745
|
const child2 = spawn6(process.execPath, [process.argv[1] ?? "", "__manager"], {
|
|
48501
48746
|
detached: true,
|
|
48747
|
+
windowsHide: true,
|
|
48502
48748
|
env: process.env,
|
|
48503
48749
|
stdio: "ignore"
|
|
48504
48750
|
});
|
|
@@ -48514,20 +48760,20 @@ async function waitForManagerExit(stateDirectory, signal) {
|
|
|
48514
48760
|
const deadline = AbortSignal.any([signal, AbortSignal.timeout(1e4)]);
|
|
48515
48761
|
while (!deadline.aborted) {
|
|
48516
48762
|
try {
|
|
48517
|
-
await
|
|
48763
|
+
await readFile4(join24(stateDirectory, "manager.lock"), "utf8");
|
|
48518
48764
|
} catch (cause) {
|
|
48519
48765
|
if (isNodeError2(cause, "ENOENT")) {
|
|
48520
48766
|
return;
|
|
48521
48767
|
}
|
|
48522
48768
|
throw cause;
|
|
48523
48769
|
}
|
|
48524
|
-
await new Promise((
|
|
48770
|
+
await new Promise((resolve10, reject) => {
|
|
48525
48771
|
const timeout = setTimeout(finish, 20);
|
|
48526
48772
|
const abort = () => finish(deadline.reason);
|
|
48527
48773
|
function finish(cause) {
|
|
48528
48774
|
clearTimeout(timeout);
|
|
48529
48775
|
deadline.removeEventListener("abort", abort);
|
|
48530
|
-
cause === void 0 ?
|
|
48776
|
+
cause === void 0 ? resolve10() : reject(cause);
|
|
48531
48777
|
}
|
|
48532
48778
|
deadline.addEventListener("abort", abort, { once: true });
|
|
48533
48779
|
});
|
|
@@ -48577,13 +48823,13 @@ async function ensureMatchingManager(stateDirectory, managerVersion, signal) {
|
|
|
48577
48823
|
await launchManager(managerVersion);
|
|
48578
48824
|
managerStarted = true;
|
|
48579
48825
|
}
|
|
48580
|
-
await new Promise((
|
|
48826
|
+
await new Promise((resolve10, reject) => {
|
|
48581
48827
|
const timeout = setTimeout(finish, 50);
|
|
48582
48828
|
const abort = () => finish(signal.reason);
|
|
48583
48829
|
function finish(cause2) {
|
|
48584
48830
|
clearTimeout(timeout);
|
|
48585
48831
|
signal.removeEventListener("abort", abort);
|
|
48586
|
-
cause2 === void 0 ?
|
|
48832
|
+
cause2 === void 0 ? resolve10() : reject(cause2);
|
|
48587
48833
|
}
|
|
48588
48834
|
signal.addEventListener("abort", abort, { once: true });
|
|
48589
48835
|
});
|
|
@@ -48670,33 +48916,23 @@ async function runManager(installation, managerVersion, signal) {
|
|
|
48670
48916
|
}
|
|
48671
48917
|
})();
|
|
48672
48918
|
});
|
|
48673
|
-
|
|
48674
|
-
await unlink2(socketPath).catch((cause) => {
|
|
48675
|
-
if (!isNodeError2(cause, "ENOENT")) {
|
|
48676
|
-
throw cause;
|
|
48677
|
-
}
|
|
48678
|
-
});
|
|
48679
|
-
}
|
|
48919
|
+
await managerPlatform.prepareControlSocket(socketPath);
|
|
48680
48920
|
server.listen(socketPath);
|
|
48681
|
-
await new Promise((
|
|
48682
|
-
server.once("listening",
|
|
48921
|
+
await new Promise((resolve10, reject) => {
|
|
48922
|
+
server.once("listening", resolve10);
|
|
48683
48923
|
server.once("error", reject);
|
|
48684
48924
|
});
|
|
48685
|
-
|
|
48686
|
-
await import("node:fs/promises").then(async ({ chmod: chmod2 }) => await chmod2(socketPath, 384));
|
|
48687
|
-
}
|
|
48925
|
+
await managerPlatform.secureControlSocket(socketPath);
|
|
48688
48926
|
try {
|
|
48689
|
-
await new Promise((
|
|
48690
|
-
const serverClosed = new Promise((
|
|
48927
|
+
await new Promise((resolve10) => combined.addEventListener("abort", () => resolve10(), { once: true }));
|
|
48928
|
+
const serverClosed = new Promise((resolve10) => server.close(() => resolve10()));
|
|
48691
48929
|
for (const socket of sockets) {
|
|
48692
48930
|
socket.destroy();
|
|
48693
48931
|
}
|
|
48694
48932
|
await serverClosed;
|
|
48695
48933
|
await supervisor.close();
|
|
48696
48934
|
} finally {
|
|
48697
|
-
|
|
48698
|
-
await unlink2(socketPath).catch(() => void 0);
|
|
48699
|
-
}
|
|
48935
|
+
await managerPlatform.removeControlSocket(socketPath).catch(() => void 0);
|
|
48700
48936
|
await releaseLock();
|
|
48701
48937
|
}
|
|
48702
48938
|
}
|
|
@@ -48839,7 +49075,7 @@ function createProgram() {
|
|
|
48839
49075
|
});
|
|
48840
49076
|
pair.command("list").description("list saved pairings").addOption(valueOption("--output-json <existing-file.json>", "write JSON to an existing file")).action(async (options) => {
|
|
48841
49077
|
const installation = await openMobiusCliInstallation(shutdown.signal, process.env);
|
|
48842
|
-
const outputPath = options.outputJson === void 0 ? null :
|
|
49078
|
+
const outputPath = options.outputJson === void 0 ? null : resolve9(options.outputJson);
|
|
48843
49079
|
const response = await requestManager(
|
|
48844
49080
|
installation,
|
|
48845
49081
|
package_default.version,
|