@moxt-ai/mobius 0.0.195 → 0.0.197
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 +532 -292
- 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 +504 -255
- 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 +504 -255
- 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 +76 -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.197",
|
|
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"
|
|
@@ -3404,11 +3406,23 @@ var package_default = {
|
|
|
3404
3406
|
exports: {
|
|
3405
3407
|
".": {
|
|
3406
3408
|
types: "./dist/index.d.ts",
|
|
3407
|
-
import: "./dist/index.js"
|
|
3409
|
+
import: "./dist/index.js",
|
|
3410
|
+
default: "./dist/index.js"
|
|
3408
3411
|
},
|
|
3409
3412
|
"./runtime": {
|
|
3410
3413
|
types: "./dist/runtime.d.ts",
|
|
3411
|
-
import: "./dist/runtime.js"
|
|
3414
|
+
import: "./dist/runtime.js",
|
|
3415
|
+
default: "./dist/runtime.js"
|
|
3416
|
+
},
|
|
3417
|
+
"./process": {
|
|
3418
|
+
types: "./dist/process/executable.d.ts",
|
|
3419
|
+
import: "./dist/process/executable.js",
|
|
3420
|
+
default: "./dist/process/executable.js"
|
|
3421
|
+
},
|
|
3422
|
+
"./filesystem": {
|
|
3423
|
+
types: "./dist/filesystem/private-path.d.ts",
|
|
3424
|
+
import: "./dist/filesystem/private-path.js",
|
|
3425
|
+
default: "./dist/filesystem/private-path.js"
|
|
3412
3426
|
}
|
|
3413
3427
|
}
|
|
3414
3428
|
},
|
|
@@ -3418,7 +3432,7 @@ var package_default = {
|
|
|
3418
3432
|
directory: "packages/cli"
|
|
3419
3433
|
},
|
|
3420
3434
|
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",
|
|
3435
|
+
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
3436
|
dev: "node --watch src/cli.ts",
|
|
3423
3437
|
prepack: "pnpm build",
|
|
3424
3438
|
start: "node dist/cli.js",
|
|
@@ -3506,17 +3520,31 @@ function normalizeAcpCapabilities(initialized) {
|
|
|
3506
3520
|
|
|
3507
3521
|
// src/process/executable.ts
|
|
3508
3522
|
import { spawn } from "node:child_process";
|
|
3509
|
-
import {
|
|
3510
|
-
import {
|
|
3511
|
-
import { join as join3, resolve } from "node:path";
|
|
3523
|
+
import { stat as stat2 } from "node:fs/promises";
|
|
3524
|
+
import { join as join5, resolve as resolve2 } from "node:path";
|
|
3512
3525
|
|
|
3513
3526
|
// 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";
|
|
3527
|
+
import { constants as constants2, readdirSync, readFileSync } from "node:fs";
|
|
3528
|
+
import { access as access2, readdir, readFile, realpath as realpath2, stat } from "node:fs/promises";
|
|
3529
|
+
import { join as join2 } from "node:path";
|
|
3517
3530
|
|
|
3518
3531
|
// src/platform/posix.ts
|
|
3519
3532
|
import { execFile } from "node:child_process";
|
|
3533
|
+
import { constants } from "node:fs";
|
|
3534
|
+
import { access, chmod, lstat, realpath, unlink } from "node:fs/promises";
|
|
3535
|
+
import { tmpdir } from "node:os";
|
|
3536
|
+
import { join } from "node:path";
|
|
3537
|
+
|
|
3538
|
+
// src/filesystem/path-error.ts
|
|
3539
|
+
var LocalPathError = class extends Error {
|
|
3540
|
+
code = "unsafe_local_path";
|
|
3541
|
+
constructor(message, options = {}) {
|
|
3542
|
+
super(message, options);
|
|
3543
|
+
this.name = "LocalPathError";
|
|
3544
|
+
}
|
|
3545
|
+
};
|
|
3546
|
+
|
|
3547
|
+
// src/platform/posix.ts
|
|
3520
3548
|
var PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
|
|
3521
3549
|
var PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
|
|
3522
3550
|
function parseProcessTable(output2) {
|
|
@@ -3561,6 +3589,81 @@ function processExists(processId) {
|
|
|
3561
3589
|
return false;
|
|
3562
3590
|
}
|
|
3563
3591
|
}
|
|
3592
|
+
function signalCapturedProcesses(processes, rootProcessId, signal) {
|
|
3593
|
+
const processIds = new Set(processes.map((identity2) => identity2.processId));
|
|
3594
|
+
const signalledGroups = /* @__PURE__ */ new Set();
|
|
3595
|
+
for (const identity2 of processes) {
|
|
3596
|
+
const isRootProcessGroup = identity2.processGroupId === rootProcessId;
|
|
3597
|
+
if (!isRootProcessGroup && !processIds.has(identity2.processGroupId) || signalledGroups.has(identity2.processGroupId)) {
|
|
3598
|
+
continue;
|
|
3599
|
+
}
|
|
3600
|
+
try {
|
|
3601
|
+
process.kill(-identity2.processGroupId, signal);
|
|
3602
|
+
signalledGroups.add(identity2.processGroupId);
|
|
3603
|
+
} catch {
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3606
|
+
for (const identity2 of processes) {
|
|
3607
|
+
if (identity2.processId === rootProcessId || identity2.processGroupId === rootProcessId || signalledGroups.has(identity2.processGroupId)) {
|
|
3608
|
+
continue;
|
|
3609
|
+
}
|
|
3610
|
+
try {
|
|
3611
|
+
process.kill(identity2.processId, signal);
|
|
3612
|
+
} catch {
|
|
3613
|
+
}
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
function terminateProcess(child2, signal) {
|
|
3617
|
+
if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
|
|
3618
|
+
return;
|
|
3619
|
+
}
|
|
3620
|
+
try {
|
|
3621
|
+
process.kill(-child2.pid, signal);
|
|
3622
|
+
return;
|
|
3623
|
+
} catch {
|
|
3624
|
+
}
|
|
3625
|
+
child2.kill(signal);
|
|
3626
|
+
}
|
|
3627
|
+
async function removeControlSocket(path3) {
|
|
3628
|
+
try {
|
|
3629
|
+
await unlink(path3);
|
|
3630
|
+
} catch (cause) {
|
|
3631
|
+
if (!(cause instanceof Error) || !("code" in cause) || cause.code !== "ENOENT") {
|
|
3632
|
+
throw cause;
|
|
3633
|
+
}
|
|
3634
|
+
}
|
|
3635
|
+
}
|
|
3636
|
+
var posixOperations = {
|
|
3637
|
+
controlSocketPath: (installationHash) => join(tmpdir(), `mobius-${installationHash}.sock`),
|
|
3638
|
+
prepareControlSocket: removeControlSocket,
|
|
3639
|
+
secureControlSocket: async (path3) => {
|
|
3640
|
+
await chmod(path3, 384);
|
|
3641
|
+
},
|
|
3642
|
+
removeControlSocket,
|
|
3643
|
+
pathDelimiter: ":",
|
|
3644
|
+
environmentValue: (environment, name2) => environment[name2],
|
|
3645
|
+
executableExtensions: () => [""],
|
|
3646
|
+
resolveExecutableTarget: async (path3) => {
|
|
3647
|
+
const target = await realpath(path3);
|
|
3648
|
+
await access(target, constants.X_OK);
|
|
3649
|
+
return target;
|
|
3650
|
+
},
|
|
3651
|
+
executableLaunch: (command, args) => ({ command, arguments: args }),
|
|
3652
|
+
spawnOptions: { detached: true, windowsHide: true },
|
|
3653
|
+
signalCapturedProcesses,
|
|
3654
|
+
terminateProcess,
|
|
3655
|
+
validatePathPermissions: async (path3, directory, privateAccess, signal) => {
|
|
3656
|
+
signal.throwIfAborted();
|
|
3657
|
+
const metadata = await lstat(path3);
|
|
3658
|
+
if (process.getuid === void 0 || metadata.uid !== process.getuid()) {
|
|
3659
|
+
throw new LocalPathError("Path is not user-owned");
|
|
3660
|
+
}
|
|
3661
|
+
if (privateAccess) {
|
|
3662
|
+
await chmod(path3, directory ? 448 : 384);
|
|
3663
|
+
}
|
|
3664
|
+
signal.throwIfAborted();
|
|
3665
|
+
}
|
|
3666
|
+
};
|
|
3564
3667
|
|
|
3565
3668
|
// src/platform/linux.ts
|
|
3566
3669
|
function appendLinuxProcessTableEntry(entries, processId, encoded) {
|
|
@@ -3592,7 +3695,7 @@ async function readLinuxProcessTable() {
|
|
|
3592
3695
|
appendLinuxProcessTableEntry(
|
|
3593
3696
|
entries,
|
|
3594
3697
|
processId,
|
|
3595
|
-
await readFile(
|
|
3698
|
+
await readFile(join2("/proc", directory.name, "stat"), "utf8")
|
|
3596
3699
|
);
|
|
3597
3700
|
} catch {
|
|
3598
3701
|
}
|
|
@@ -3617,7 +3720,7 @@ function readLinuxProcessTableSynchronously() {
|
|
|
3617
3720
|
appendLinuxProcessTableEntry(
|
|
3618
3721
|
entries,
|
|
3619
3722
|
processId,
|
|
3620
|
-
readFileSync(
|
|
3723
|
+
readFileSync(join2("/proc", directory.name, "stat"), "utf8")
|
|
3621
3724
|
);
|
|
3622
3725
|
} catch {
|
|
3623
3726
|
}
|
|
@@ -3633,11 +3736,11 @@ async function readLinuxProcessTableWithFallback() {
|
|
|
3633
3736
|
}
|
|
3634
3737
|
for (const candidate of ["/usr/bin/ps", "/bin/ps", "/run/current-system/sw/bin/ps"]) {
|
|
3635
3738
|
try {
|
|
3636
|
-
const resolvedPath = await
|
|
3739
|
+
const resolvedPath = await realpath2(candidate);
|
|
3637
3740
|
if (!(await stat(resolvedPath)).isFile()) {
|
|
3638
3741
|
continue;
|
|
3639
3742
|
}
|
|
3640
|
-
await
|
|
3743
|
+
await access2(resolvedPath, constants2.X_OK);
|
|
3641
3744
|
} catch {
|
|
3642
3745
|
continue;
|
|
3643
3746
|
}
|
|
@@ -3650,7 +3753,7 @@ async function readLinuxProcessTableWithFallback() {
|
|
|
3650
3753
|
}
|
|
3651
3754
|
function processExists2(processId) {
|
|
3652
3755
|
try {
|
|
3653
|
-
const encoded = readFileSync(
|
|
3756
|
+
const encoded = readFileSync(join2("/proc", processId.toString(), "stat"), "utf8");
|
|
3654
3757
|
const closingParenthesis = encoded.lastIndexOf(")");
|
|
3655
3758
|
if (closingParenthesis >= 0) {
|
|
3656
3759
|
const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
|
|
@@ -3663,6 +3766,7 @@ function processExists2(processId) {
|
|
|
3663
3766
|
return processExists(processId);
|
|
3664
3767
|
}
|
|
3665
3768
|
var linuxPlatform = {
|
|
3769
|
+
...posixOperations,
|
|
3666
3770
|
readProcessTable: readLinuxProcessTableWithFallback,
|
|
3667
3771
|
readProcessTableSynchronously: readLinuxProcessTableSynchronously,
|
|
3668
3772
|
processExists: processExists2,
|
|
@@ -3694,7 +3798,7 @@ var linuxPlatform = {
|
|
|
3694
3798
|
};
|
|
3695
3799
|
|
|
3696
3800
|
// src/platform/macos.ts
|
|
3697
|
-
import { isAbsolute, join as
|
|
3801
|
+
import { isAbsolute, join as join3 } from "node:path";
|
|
3698
3802
|
var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
|
|
3699
3803
|
"WorkBuddy.app",
|
|
3700
3804
|
"Contents",
|
|
@@ -3705,14 +3809,15 @@ var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
|
|
|
3705
3809
|
"codebuddy"
|
|
3706
3810
|
]);
|
|
3707
3811
|
var macosPlatform = {
|
|
3812
|
+
...posixOperations,
|
|
3708
3813
|
readProcessTable: () => readProcessTableWithPs("/bin/ps"),
|
|
3709
3814
|
readProcessTableSynchronously: () => [],
|
|
3710
3815
|
processExists,
|
|
3711
3816
|
workBuddyExecutablePaths: (environment) => {
|
|
3712
|
-
const paths = [
|
|
3817
|
+
const paths = [join3("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
|
|
3713
3818
|
const homeDirectory = environment["HOME"];
|
|
3714
3819
|
if (homeDirectory !== void 0 && isAbsolute(homeDirectory)) {
|
|
3715
|
-
paths.unshift(
|
|
3820
|
+
paths.unshift(join3(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
|
|
3716
3821
|
}
|
|
3717
3822
|
return paths;
|
|
3718
3823
|
},
|
|
@@ -3742,8 +3847,199 @@ var macosPlatform = {
|
|
|
3742
3847
|
}
|
|
3743
3848
|
};
|
|
3744
3849
|
|
|
3850
|
+
// src/platform/windows.ts
|
|
3851
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
3852
|
+
import { readFile as readFile2, realpath as realpath3 } from "node:fs/promises";
|
|
3853
|
+
import { dirname, extname, join as join4, resolve } from "node:path";
|
|
3854
|
+
import { promisify } from "node:util";
|
|
3855
|
+
|
|
3856
|
+
// src/process/process-error.ts
|
|
3857
|
+
var ProcessExecutionError = class extends Error {
|
|
3858
|
+
code;
|
|
3859
|
+
constructor(code, message, options = {}) {
|
|
3860
|
+
super(message, options);
|
|
3861
|
+
this.code = code;
|
|
3862
|
+
this.name = "ProcessExecutionError";
|
|
3863
|
+
}
|
|
3864
|
+
};
|
|
3865
|
+
|
|
3866
|
+
// src/platform/windows.ts
|
|
3867
|
+
var execute = promisify(execFile2);
|
|
3868
|
+
function environmentValue(environment, name2) {
|
|
3869
|
+
return Object.entries(environment).find(([key]) => key.toUpperCase() === name2.toUpperCase())?.[1];
|
|
3870
|
+
}
|
|
3871
|
+
function executableExtensions(executableName, environment) {
|
|
3872
|
+
if (/\.[a-zA-Z0-9]+$/.test(executableName)) {
|
|
3873
|
+
return [""];
|
|
3874
|
+
}
|
|
3875
|
+
const configured = environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD";
|
|
3876
|
+
const extensions = configured.split(";").map((extension) => extension.trim()).filter((extension) => extension.length > 0).map((extension) => extension.startsWith(".") ? extension : `.${extension}`);
|
|
3877
|
+
return extensions.length > 0 ? extensions : [".EXE"];
|
|
3878
|
+
}
|
|
3879
|
+
async function resolveExecutableTarget(path3) {
|
|
3880
|
+
let resolvedPath;
|
|
3881
|
+
try {
|
|
3882
|
+
resolvedPath = await realpath3(extname(path3) === "" ? `${path3}.cmd` : path3);
|
|
3883
|
+
} catch (cause) {
|
|
3884
|
+
if (extname(path3) !== "" || !(cause instanceof Error) || !("code" in cause) || cause.code !== "ENOENT") {
|
|
3885
|
+
throw cause;
|
|
3886
|
+
}
|
|
3887
|
+
resolvedPath = await realpath3(path3);
|
|
3888
|
+
}
|
|
3889
|
+
if (extname(resolvedPath).toLowerCase() === ".cmd") {
|
|
3890
|
+
const shim = await readFile2(resolvedPath, "utf8");
|
|
3891
|
+
const script = /"%_prog%"\s+"%dp0%[\\/]([^"\r\n]+\.(?:js|mjs|cjs))"\s+%\*/iu.exec(shim)?.[1];
|
|
3892
|
+
if (script !== void 0 && shim.includes("SET dp0=%~dp0")) {
|
|
3893
|
+
resolvedPath = await realpath3(resolve(dirname(resolvedPath), script));
|
|
3894
|
+
} else {
|
|
3895
|
+
const pnpmScript = /^\s*node\s+"%~dp0[\\/]([^"\r\n]+\.(?:js|mjs|cjs))"\s+%\*\s*$/imu.exec(shim)?.[1];
|
|
3896
|
+
if (pnpmScript === void 0 || !shim.includes("@SETLOCAL")) {
|
|
3897
|
+
throw new ProcessExecutionError(
|
|
3898
|
+
"process_unsupported_script",
|
|
3899
|
+
"Use a native executable or a verified Node entrypoint"
|
|
3900
|
+
);
|
|
3901
|
+
}
|
|
3902
|
+
resolvedPath = await realpath3(resolve(dirname(resolvedPath), pnpmScript));
|
|
3903
|
+
}
|
|
3904
|
+
}
|
|
3905
|
+
return resolvedPath;
|
|
3906
|
+
}
|
|
3907
|
+
function executableLaunch(command, args) {
|
|
3908
|
+
if (/\.(?:js|mjs|cjs)$/iu.test(command)) {
|
|
3909
|
+
return { command: process.execPath, arguments: [command, ...args] };
|
|
3910
|
+
}
|
|
3911
|
+
if (/\.(?:cmd|bat)$/iu.test(command)) {
|
|
3912
|
+
throw new ProcessExecutionError(
|
|
3913
|
+
"process_unsupported_script",
|
|
3914
|
+
"Use a native executable or a verified Node entrypoint"
|
|
3915
|
+
);
|
|
3916
|
+
}
|
|
3917
|
+
return { command, arguments: args };
|
|
3918
|
+
}
|
|
3919
|
+
function readProcessTable() {
|
|
3920
|
+
const systemRoot = environmentValue(process.env, "SystemRoot");
|
|
3921
|
+
if (systemRoot === void 0) {
|
|
3922
|
+
return Promise.resolve([]);
|
|
3923
|
+
}
|
|
3924
|
+
return new Promise((resolveTable) => {
|
|
3925
|
+
execFile2(
|
|
3926
|
+
join4(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
3927
|
+
[
|
|
3928
|
+
"-NoLogo",
|
|
3929
|
+
"-NoProfile",
|
|
3930
|
+
"-NonInteractive",
|
|
3931
|
+
"-Command",
|
|
3932
|
+
"Get-CimInstance Win32_Process | ForEach-Object { '{0} {1} {0}' -f $_.ProcessId, $_.ParentProcessId }"
|
|
3933
|
+
],
|
|
3934
|
+
{
|
|
3935
|
+
encoding: "utf8",
|
|
3936
|
+
windowsHide: true,
|
|
3937
|
+
timeout: 1e4,
|
|
3938
|
+
signal: AbortSignal.timeout(1e4),
|
|
3939
|
+
maxBuffer: 1024 * 1024
|
|
3940
|
+
},
|
|
3941
|
+
(error62, stdout) => resolveTable(error62 === null ? parseProcessTable(stdout) : [])
|
|
3942
|
+
);
|
|
3943
|
+
});
|
|
3944
|
+
}
|
|
3945
|
+
function signalCapturedProcesses2(processes, _rootProcessId, signal) {
|
|
3946
|
+
for (const identity2 of [...processes].reverse()) {
|
|
3947
|
+
try {
|
|
3948
|
+
process.kill(identity2.processId, signal);
|
|
3949
|
+
} catch {
|
|
3950
|
+
}
|
|
3951
|
+
}
|
|
3952
|
+
}
|
|
3953
|
+
function terminateProcess2(child2, signal) {
|
|
3954
|
+
if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
|
|
3955
|
+
return;
|
|
3956
|
+
}
|
|
3957
|
+
child2.kill(signal);
|
|
3958
|
+
}
|
|
3959
|
+
var windowsPermissions = `
|
|
3960
|
+
$ErrorActionPreference = 'Stop'
|
|
3961
|
+
Import-Module (Join-Path $PSHOME 'Modules/Microsoft.PowerShell.Security/Microsoft.PowerShell.Security.psd1')
|
|
3962
|
+
$item = Get-Item -LiteralPath $env:MOBIUS_PERMISSION_PATH -Force
|
|
3963
|
+
if (($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0) { throw 'Unsafe path' }
|
|
3964
|
+
$sid = [Security.Principal.WindowsIdentity]::GetCurrent().User
|
|
3965
|
+
$acl = Get-Acl -LiteralPath $item.FullName
|
|
3966
|
+
$owner = $acl.GetOwner([Security.Principal.SecurityIdentifier])
|
|
3967
|
+
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' }
|
|
3968
|
+
if ($env:MOBIUS_PERMISSION_PRIVATE -eq '1') {
|
|
3969
|
+
if ($item.PSIsContainer) {
|
|
3970
|
+
$private = New-Object Security.AccessControl.DirectorySecurity
|
|
3971
|
+
$rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'ContainerInherit,ObjectInherit', 'None', 'Allow')
|
|
3972
|
+
} else {
|
|
3973
|
+
$private = New-Object Security.AccessControl.FileSecurity
|
|
3974
|
+
$rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'Allow')
|
|
3975
|
+
}
|
|
3976
|
+
$private.SetOwner($sid)
|
|
3977
|
+
$private.SetAccessRuleProtection($true, $false)
|
|
3978
|
+
$private.AddAccessRule($rule)
|
|
3979
|
+
Set-Acl -LiteralPath $item.FullName -AclObject $private
|
|
3980
|
+
}
|
|
3981
|
+
`;
|
|
3982
|
+
async function validatePathPermissions(path3, _directory, privateAccess, signal) {
|
|
3983
|
+
signal.throwIfAborted();
|
|
3984
|
+
const systemRoot = environmentValue(process.env, "SystemRoot");
|
|
3985
|
+
if (systemRoot === void 0) {
|
|
3986
|
+
throw new LocalPathError("Windows system directory is unavailable");
|
|
3987
|
+
}
|
|
3988
|
+
try {
|
|
3989
|
+
await execute(
|
|
3990
|
+
join4(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
3991
|
+
[
|
|
3992
|
+
"-NoLogo",
|
|
3993
|
+
"-NoProfile",
|
|
3994
|
+
"-NonInteractive",
|
|
3995
|
+
"-EncodedCommand",
|
|
3996
|
+
Buffer.from(windowsPermissions, "utf16le").toString("base64")
|
|
3997
|
+
],
|
|
3998
|
+
{
|
|
3999
|
+
env: {
|
|
4000
|
+
...process.env,
|
|
4001
|
+
MOBIUS_PERMISSION_PATH: path3,
|
|
4002
|
+
MOBIUS_PERMISSION_PRIVATE: privateAccess ? "1" : "0"
|
|
4003
|
+
},
|
|
4004
|
+
windowsHide: true,
|
|
4005
|
+
signal: AbortSignal.any([signal, AbortSignal.timeout(1e4)]),
|
|
4006
|
+
timeout: 1e4,
|
|
4007
|
+
maxBuffer: 16384
|
|
4008
|
+
}
|
|
4009
|
+
);
|
|
4010
|
+
} catch (cause) {
|
|
4011
|
+
signal.throwIfAborted();
|
|
4012
|
+
throw new LocalPathError("The local path permissions could not be secured", { cause });
|
|
4013
|
+
}
|
|
4014
|
+
}
|
|
4015
|
+
var windowsPlatform = {
|
|
4016
|
+
controlSocketPath: (installationHash) => `\\\\.\\pipe\\mobius-${installationHash}`,
|
|
4017
|
+
prepareControlSocket: async () => {
|
|
4018
|
+
},
|
|
4019
|
+
secureControlSocket: async () => {
|
|
4020
|
+
},
|
|
4021
|
+
removeControlSocket: async () => {
|
|
4022
|
+
},
|
|
4023
|
+
pathDelimiter: ";",
|
|
4024
|
+
environmentValue,
|
|
4025
|
+
executableExtensions,
|
|
4026
|
+
resolveExecutableTarget,
|
|
4027
|
+
executableLaunch,
|
|
4028
|
+
spawnOptions: { detached: false, windowsHide: true },
|
|
4029
|
+
signalCapturedProcesses: signalCapturedProcesses2,
|
|
4030
|
+
terminateProcess: terminateProcess2,
|
|
4031
|
+
validatePathPermissions,
|
|
4032
|
+
readProcessTable,
|
|
4033
|
+
readProcessTableSynchronously: () => [],
|
|
4034
|
+
processExists,
|
|
4035
|
+
workBuddyExecutablePaths: () => [],
|
|
4036
|
+
openCodeArchives: {},
|
|
4037
|
+
grokDependencies: {}
|
|
4038
|
+
};
|
|
4039
|
+
|
|
3745
4040
|
// src/platform/index.ts
|
|
3746
4041
|
var fallbackPlatform = {
|
|
4042
|
+
...posixOperations,
|
|
3747
4043
|
readProcessTable: () => readProcessTableWithPs("/usr/bin/ps"),
|
|
3748
4044
|
readProcessTableSynchronously: () => [],
|
|
3749
4045
|
processExists,
|
|
@@ -3754,7 +4050,7 @@ var fallbackPlatform = {
|
|
|
3754
4050
|
var platforms = /* @__PURE__ */ new Map([
|
|
3755
4051
|
["linux", linuxPlatform],
|
|
3756
4052
|
["darwin", macosPlatform],
|
|
3757
|
-
["win32",
|
|
4053
|
+
["win32", windowsPlatform]
|
|
3758
4054
|
]);
|
|
3759
4055
|
function platformSupportFor(platform) {
|
|
3760
4056
|
return platforms.get(platform) ?? fallbackPlatform;
|
|
@@ -3793,14 +4089,6 @@ var ResolvedExecutable = class {
|
|
|
3793
4089
|
this.path = identity2.realPath;
|
|
3794
4090
|
}
|
|
3795
4091
|
};
|
|
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
4092
|
var ProcessResult = class {
|
|
3805
4093
|
stderr;
|
|
3806
4094
|
stdout;
|
|
@@ -3809,28 +4097,14 @@ var ProcessResult = class {
|
|
|
3809
4097
|
this.stdout = stdout;
|
|
3810
4098
|
}
|
|
3811
4099
|
};
|
|
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
4100
|
async function resolveExecutablePath(requestedPath2, platform = process.platform) {
|
|
3824
|
-
const absoluteRequestedPath =
|
|
4101
|
+
const absoluteRequestedPath = resolve2(requestedPath2);
|
|
3825
4102
|
try {
|
|
3826
|
-
const resolvedPath = await
|
|
4103
|
+
const resolvedPath = await platformSupportFor(platform).resolveExecutableTarget(absoluteRequestedPath);
|
|
3827
4104
|
const metadata = await stat2(resolvedPath);
|
|
3828
4105
|
if (!metadata.isFile()) {
|
|
3829
4106
|
return null;
|
|
3830
4107
|
}
|
|
3831
|
-
if (platform !== "win32") {
|
|
3832
|
-
await access2(resolvedPath, constants2.X_OK);
|
|
3833
|
-
}
|
|
3834
4108
|
return new ResolvedExecutable(
|
|
3835
4109
|
new ExecutableIdentity(
|
|
3836
4110
|
absoluteRequestedPath,
|
|
@@ -3846,15 +4120,16 @@ async function resolveExecutablePath(requestedPath2, platform = process.platform
|
|
|
3846
4120
|
}
|
|
3847
4121
|
}
|
|
3848
4122
|
async function findExecutableOnPath(executableName, environment, platform = process.platform) {
|
|
3849
|
-
const
|
|
3850
|
-
const
|
|
3851
|
-
const
|
|
4123
|
+
const support = platformSupportFor(platform);
|
|
4124
|
+
const encodedPath = support.environmentValue(environment, "PATH") ?? "";
|
|
4125
|
+
const separator = support.pathDelimiter;
|
|
4126
|
+
const extensions = support.executableExtensions(executableName, environment);
|
|
3852
4127
|
for (const entry of encodedPath.split(separator)) {
|
|
3853
4128
|
if (entry.length === 0) {
|
|
3854
4129
|
continue;
|
|
3855
4130
|
}
|
|
3856
4131
|
for (const extension of extensions) {
|
|
3857
|
-
const requestedPath2 =
|
|
4132
|
+
const requestedPath2 = resolve2(join5(entry, `${executableName}${extension}`));
|
|
3858
4133
|
const executable = await resolveExecutablePath(requestedPath2, platform);
|
|
3859
4134
|
if (executable !== null) {
|
|
3860
4135
|
return executable;
|
|
@@ -3875,7 +4150,7 @@ function appendBounded(chunks, chunk, currentBytes, limitBytes) {
|
|
|
3875
4150
|
chunks.push(chunk);
|
|
3876
4151
|
return nextBytes;
|
|
3877
4152
|
}
|
|
3878
|
-
function
|
|
4153
|
+
function readProcessTable2() {
|
|
3879
4154
|
return hostPlatform.readProcessTable();
|
|
3880
4155
|
}
|
|
3881
4156
|
function selectProcessTree(entries, rootProcessId) {
|
|
@@ -3910,38 +4185,14 @@ function mergeProcessTrees(captured, current) {
|
|
|
3910
4185
|
return [...processes.values()];
|
|
3911
4186
|
}
|
|
3912
4187
|
async function captureProcessTree(child2) {
|
|
3913
|
-
if (
|
|
4188
|
+
if (child2.pid === void 0) {
|
|
3914
4189
|
return [];
|
|
3915
4190
|
}
|
|
3916
4191
|
const entries = hostPlatform.readProcessTableSynchronously();
|
|
3917
4192
|
if (entries.length > 0) {
|
|
3918
4193
|
return selectProcessTree(entries, child2.pid);
|
|
3919
4194
|
}
|
|
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
|
-
}
|
|
4195
|
+
return selectProcessTree(await readProcessTable2(), child2.pid);
|
|
3945
4196
|
}
|
|
3946
4197
|
async function waitForCapturedProcessesExit(processes, rootProcessId) {
|
|
3947
4198
|
const processIds = processes.map((identity2) => identity2.processId).filter((processId) => processId !== rootProcessId);
|
|
@@ -3949,36 +4200,10 @@ async function waitForCapturedProcessesExit(processes, rootProcessId) {
|
|
|
3949
4200
|
if (processIds.every((processId) => !hostPlatform.processExists(processId))) {
|
|
3950
4201
|
return true;
|
|
3951
4202
|
}
|
|
3952
|
-
await
|
|
4203
|
+
await readProcessTable2();
|
|
3953
4204
|
}
|
|
3954
4205
|
return processIds.every((processId) => !hostPlatform.processExists(processId));
|
|
3955
4206
|
}
|
|
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
4207
|
async function stopProcessTree(child2, capturedProcesses = []) {
|
|
3983
4208
|
const childProcessId = child2.pid;
|
|
3984
4209
|
if (childProcessId === void 0) {
|
|
@@ -3989,8 +4214,8 @@ async function stopProcessTree(child2, capturedProcesses = []) {
|
|
|
3989
4214
|
if (childExited && processes.length === 0) {
|
|
3990
4215
|
return;
|
|
3991
4216
|
}
|
|
3992
|
-
|
|
3993
|
-
terminateProcess(child2);
|
|
4217
|
+
hostPlatform.signalCapturedProcesses(processes, childProcessId, GRACEFUL_STOP_SIGNAL);
|
|
4218
|
+
hostPlatform.terminateProcess(child2, "SIGTERM");
|
|
3994
4219
|
const [exitedAfterTermination, descendantsExitedAfterTermination] = await Promise.all([
|
|
3995
4220
|
waitForProcessExit(child2, PROCESS_GRACEFUL_STOP_TIMEOUT_MILLISECONDS),
|
|
3996
4221
|
waitForCapturedProcessesExit(processes, childProcessId)
|
|
@@ -3998,8 +4223,8 @@ async function stopProcessTree(child2, capturedProcesses = []) {
|
|
|
3998
4223
|
if (exitedAfterTermination && descendantsExitedAfterTermination) {
|
|
3999
4224
|
return;
|
|
4000
4225
|
}
|
|
4001
|
-
|
|
4002
|
-
|
|
4226
|
+
hostPlatform.signalCapturedProcesses(processes, childProcessId, FORCED_STOP_SIGNAL);
|
|
4227
|
+
hostPlatform.terminateProcess(child2, "SIGKILL");
|
|
4003
4228
|
const [exitedAfterForce, descendantsExitedAfterForce] = await Promise.all([
|
|
4004
4229
|
waitForProcessExit(child2, PROCESS_FORCED_STOP_TIMEOUT_MILLISECONDS),
|
|
4005
4230
|
waitForCapturedProcessesExit(processes, childProcessId)
|
|
@@ -4034,9 +4259,10 @@ function waitForProcessExit(child2, timeoutMilliseconds) {
|
|
|
4034
4259
|
async function runBoundedProcess(options) {
|
|
4035
4260
|
options.signal.throwIfAborted();
|
|
4036
4261
|
const outputLimitBytes = options.outputLimitBytes ?? DEFAULT_OUTPUT_LIMIT_BYTES;
|
|
4037
|
-
const
|
|
4262
|
+
const launch = executableLaunch2(options.command, options.arguments);
|
|
4263
|
+
const child2 = spawn(launch.command, [...launch.arguments], {
|
|
4038
4264
|
cwd: options.cwd,
|
|
4039
|
-
|
|
4265
|
+
...hostPlatform.spawnOptions,
|
|
4040
4266
|
env: { ...options.environment },
|
|
4041
4267
|
shell: false,
|
|
4042
4268
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -4145,6 +4371,10 @@ async function runBoundedProcess(options) {
|
|
|
4145
4371
|
}
|
|
4146
4372
|
}
|
|
4147
4373
|
}
|
|
4374
|
+
function executableLaunch2(command, args) {
|
|
4375
|
+
return hostPlatform.executableLaunch(command, args);
|
|
4376
|
+
}
|
|
4377
|
+
var platformSpawnOptions = hostPlatform.spawnOptions;
|
|
4148
4378
|
|
|
4149
4379
|
// src/agent-catalog/local-agent.ts
|
|
4150
4380
|
function readTrustedIdentity(path3) {
|
|
@@ -4537,8 +4767,8 @@ function formatAgentDiagnostics(inventory, json2, verbose = false) {
|
|
|
4537
4767
|
}
|
|
4538
4768
|
|
|
4539
4769
|
// src/agent-installation/managed-npm-package.ts
|
|
4540
|
-
import { mkdir, mkdtemp, open, realpath as
|
|
4541
|
-
import { delimiter, dirname, isAbsolute as isAbsolute2, join as
|
|
4770
|
+
import { mkdir, mkdtemp, open, realpath as realpath4, rename, rm, stat as stat3 } from "node:fs/promises";
|
|
4771
|
+
import { delimiter, dirname as dirname2, isAbsolute as isAbsolute2, join as join6, relative, sep } from "node:path";
|
|
4542
4772
|
var INSTALL_TIMEOUT_MILLISECONDS = 5 * 60 * 1e3;
|
|
4543
4773
|
var PACKAGE_METADATA_LIMIT_BYTES = 64 * 1024;
|
|
4544
4774
|
var PACKAGE_LOCK_LIMIT_BYTES = 8 * 1024 * 1024;
|
|
@@ -4589,7 +4819,7 @@ function isRecord2(value) {
|
|
|
4589
4819
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4590
4820
|
}
|
|
4591
4821
|
function packagePath(root, packageName) {
|
|
4592
|
-
return
|
|
4822
|
+
return join6(root, "node_modules", ...packageName.split("/"));
|
|
4593
4823
|
}
|
|
4594
4824
|
function isContainedPath(root, candidate) {
|
|
4595
4825
|
const difference = relative(root, candidate);
|
|
@@ -4694,14 +4924,14 @@ function verifyPackageLockEntry(lock, definition, verifyDependencyClosure) {
|
|
|
4694
4924
|
}
|
|
4695
4925
|
}
|
|
4696
4926
|
async function verifyRequiredDependency(rootPath, lock, definition) {
|
|
4697
|
-
const dependencyRoot = await
|
|
4927
|
+
const dependencyRoot = await realpath4(packagePath(rootPath, definition.packageName));
|
|
4698
4928
|
if (!isContainedPath(rootPath, dependencyRoot)) {
|
|
4699
4929
|
throw new ManagedNpmPackageError(
|
|
4700
4930
|
"managed_package_verification_failed",
|
|
4701
4931
|
"The required managed npm dependency escaped its private cache"
|
|
4702
4932
|
);
|
|
4703
4933
|
}
|
|
4704
|
-
const metadata = await readJsonRecord(
|
|
4934
|
+
const metadata = await readJsonRecord(join6(dependencyRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
|
|
4705
4935
|
if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
|
|
4706
4936
|
throw new ManagedNpmPackageError(
|
|
4707
4937
|
"managed_package_verification_failed",
|
|
@@ -4723,15 +4953,15 @@ async function validateManagedNpmPackage(root, definition) {
|
|
|
4723
4953
|
}
|
|
4724
4954
|
}
|
|
4725
4955
|
async function validateManagedNpmPackageContents(root, definition) {
|
|
4726
|
-
const rootPath = await
|
|
4727
|
-
const packageRoot = await
|
|
4956
|
+
const rootPath = await realpath4(root);
|
|
4957
|
+
const packageRoot = await realpath4(packagePath(rootPath, definition.packageName));
|
|
4728
4958
|
if (!isContainedPath(rootPath, packageRoot)) {
|
|
4729
4959
|
throw new ManagedNpmPackageError(
|
|
4730
4960
|
"managed_package_verification_failed",
|
|
4731
4961
|
"The managed npm package escaped its private cache"
|
|
4732
4962
|
);
|
|
4733
4963
|
}
|
|
4734
|
-
const metadata = await readJsonRecord(
|
|
4964
|
+
const metadata = await readJsonRecord(join6(packageRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
|
|
4735
4965
|
if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
|
|
4736
4966
|
throw new ManagedNpmPackageError(
|
|
4737
4967
|
"managed_package_verification_failed",
|
|
@@ -4739,14 +4969,14 @@ async function validateManagedNpmPackageContents(root, definition) {
|
|
|
4739
4969
|
);
|
|
4740
4970
|
}
|
|
4741
4971
|
if (definition instanceof SriManagedNpmPackageDefinition) {
|
|
4742
|
-
const lock = await readJsonRecord(
|
|
4972
|
+
const lock = await readJsonRecord(join6(rootPath, "package-lock.json"), PACKAGE_LOCK_LIMIT_BYTES);
|
|
4743
4973
|
verifyPackageLockEntry(lock, definition, definition.verifyDependencyClosure);
|
|
4744
4974
|
for (const dependency of definition.requiredDependencies) {
|
|
4745
4975
|
await verifyRequiredDependency(rootPath, lock, dependency);
|
|
4746
4976
|
}
|
|
4747
4977
|
}
|
|
4748
4978
|
const declaredBin = readBinPath(metadata, definition.executableName);
|
|
4749
|
-
const executable = await resolveExecutablePath(
|
|
4979
|
+
const executable = await resolveExecutablePath(join6(packageRoot, declaredBin));
|
|
4750
4980
|
if (executable === null || !isContainedPath(rootPath, executable.path)) {
|
|
4751
4981
|
throw new ManagedNpmPackageError(
|
|
4752
4982
|
"managed_package_verification_failed",
|
|
@@ -4768,9 +4998,9 @@ var ManagedNpmPackageInstaller = class {
|
|
|
4768
4998
|
throw error62;
|
|
4769
4999
|
}
|
|
4770
5000
|
}
|
|
4771
|
-
const parent =
|
|
5001
|
+
const parent = dirname2(root);
|
|
4772
5002
|
await mkdir(parent, { mode: 448, recursive: true });
|
|
4773
|
-
const staging = await mkdtemp(
|
|
5003
|
+
const staging = await mkdtemp(join6(parent, `.${definition.version}.staging-`));
|
|
4774
5004
|
try {
|
|
4775
5005
|
const npm = await findExecutableOnPath(process.platform === "win32" ? "npm.cmd" : "npm", environment);
|
|
4776
5006
|
if (npm === null) {
|
|
@@ -4796,14 +5026,14 @@ var ManagedNpmPackageInstaller = class {
|
|
|
4796
5026
|
`${definition.packageName}@${definition.version}`
|
|
4797
5027
|
);
|
|
4798
5028
|
const installEnvironment = {
|
|
4799
|
-
HOME:
|
|
5029
|
+
HOME: join6(staging, "home"),
|
|
4800
5030
|
NPM_CONFIG_AUDIT: "false",
|
|
4801
|
-
NPM_CONFIG_CACHE:
|
|
5031
|
+
NPM_CONFIG_CACHE: join6(staging, ".npm-cache"),
|
|
4802
5032
|
NPM_CONFIG_FUND: "false",
|
|
4803
5033
|
NPM_CONFIG_IGNORE_SCRIPTS: "true",
|
|
4804
5034
|
NPM_CONFIG_PACKAGE_LOCK: "true",
|
|
4805
5035
|
NPM_CONFIG_REGISTRY: "https://registry.npmjs.org/",
|
|
4806
|
-
PATH: `${
|
|
5036
|
+
PATH: `${dirname2(process.execPath)}${delimiter}/usr/bin${delimiter}/bin`
|
|
4807
5037
|
};
|
|
4808
5038
|
if (definition.includeOptionalDependencies) {
|
|
4809
5039
|
installEnvironment["NPM_CONFIG_INCLUDE"] = "optional";
|
|
@@ -4820,8 +5050,8 @@ var ManagedNpmPackageInstaller = class {
|
|
|
4820
5050
|
timeoutMilliseconds: INSTALL_TIMEOUT_MILLISECONDS
|
|
4821
5051
|
});
|
|
4822
5052
|
await Promise.all([
|
|
4823
|
-
rm(
|
|
4824
|
-
rm(
|
|
5053
|
+
rm(join6(staging, ".npm-cache"), { force: true, recursive: true }),
|
|
5054
|
+
rm(join6(staging, "home"), { force: true, recursive: true })
|
|
4825
5055
|
]);
|
|
4826
5056
|
await validateManagedNpmPackage(staging, definition);
|
|
4827
5057
|
try {
|
|
@@ -4857,7 +5087,7 @@ var ManagedNpmPackageInstaller = class {
|
|
|
4857
5087
|
};
|
|
4858
5088
|
|
|
4859
5089
|
// src/agent-catalog/agent-specification.ts
|
|
4860
|
-
import { join as
|
|
5090
|
+
import { join as join7 } from "node:path";
|
|
4861
5091
|
|
|
4862
5092
|
// src/agent-catalog/version-output.ts
|
|
4863
5093
|
function normalizeVersionOutput(output2) {
|
|
@@ -4880,7 +5110,7 @@ var LocalAgentSpecification = class {
|
|
|
4880
5110
|
resolveManagedAgent = async (stateDirectory, platform, signal) => {
|
|
4881
5111
|
signal.throwIfAborted();
|
|
4882
5112
|
const executable = await resolveExecutablePath(
|
|
4883
|
-
|
|
5113
|
+
join7(stateDirectory, ...this.managedAgentExecutablePath),
|
|
4884
5114
|
platform
|
|
4885
5115
|
);
|
|
4886
5116
|
signal.throwIfAborted();
|
|
@@ -10112,7 +10342,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
10112
10342
|
var NONE = 0;
|
|
10113
10343
|
var ASSUMED = 1;
|
|
10114
10344
|
var PROVEN = 2;
|
|
10115
|
-
function isRecursive(inst, stack,
|
|
10345
|
+
function isRecursive(inst, stack, resolve10) {
|
|
10116
10346
|
const cached2 = recursive.get(inst);
|
|
10117
10347
|
if (cached2 !== void 0)
|
|
10118
10348
|
return cached2 ? PROVEN : NONE;
|
|
@@ -10122,7 +10352,7 @@ function isRecursive(inst, stack, resolve9) {
|
|
|
10122
10352
|
let result = NONE;
|
|
10123
10353
|
const check2 = (child2) => {
|
|
10124
10354
|
if (result !== PROVEN && child2?._zod) {
|
|
10125
|
-
const answer = isRecursive(child2, stack,
|
|
10355
|
+
const answer = isRecursive(child2, stack, resolve10);
|
|
10126
10356
|
if (answer > result)
|
|
10127
10357
|
result = answer;
|
|
10128
10358
|
}
|
|
@@ -10133,7 +10363,7 @@ function isRecursive(inst, stack, resolve9) {
|
|
|
10133
10363
|
const desc2 = Object.getOwnPropertyDescriptor(sh, key);
|
|
10134
10364
|
if (spread && !desc2.enumerable)
|
|
10135
10365
|
continue;
|
|
10136
|
-
const child2 = desc2.get ? ASSUMED : desc2.value?._zod ? isRecursive(desc2.value, stack,
|
|
10366
|
+
const child2 = desc2.get ? ASSUMED : desc2.value?._zod ? isRecursive(desc2.value, stack, resolve10) : NONE;
|
|
10137
10367
|
if (child2 > answer)
|
|
10138
10368
|
answer = child2;
|
|
10139
10369
|
}
|
|
@@ -10197,7 +10427,7 @@ function isRecursive(inst, stack, resolve9) {
|
|
|
10197
10427
|
break;
|
|
10198
10428
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
10199
10429
|
case "lazy": {
|
|
10200
|
-
const inner = def._cachedInner ?? (
|
|
10430
|
+
const inner = def._cachedInner ?? (resolve10 ? inst._zod.innerType : void 0);
|
|
10201
10431
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
10202
10432
|
break;
|
|
10203
10433
|
}
|
|
@@ -25032,9 +25262,10 @@ var CodexAppServerClient = class {
|
|
|
25032
25262
|
#pendingFragments = [];
|
|
25033
25263
|
constructor(options) {
|
|
25034
25264
|
this.#handlers = options.handlers;
|
|
25035
|
-
|
|
25265
|
+
const launch = executableLaunch2(options.command, ["app-server"]);
|
|
25266
|
+
this.#child = spawn2(launch.command, [...launch.arguments], {
|
|
25036
25267
|
cwd: options.cwd,
|
|
25037
|
-
|
|
25268
|
+
...platformSpawnOptions,
|
|
25038
25269
|
env: { ...process.env, ...options.environment },
|
|
25039
25270
|
shell: false,
|
|
25040
25271
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -28767,7 +28998,7 @@ var AgentProbeError = class extends Error {
|
|
|
28767
28998
|
};
|
|
28768
28999
|
|
|
28769
29000
|
// src/agent-catalog/agents/resolve-user-local-executable.ts
|
|
28770
|
-
import { isAbsolute as isAbsolute4, join as
|
|
29001
|
+
import { isAbsolute as isAbsolute4, join as join8 } from "node:path";
|
|
28771
29002
|
async function resolveUserLocalExecutable(executableName, context) {
|
|
28772
29003
|
context.signal.throwIfAborted();
|
|
28773
29004
|
const platform = context.platform ?? process.platform;
|
|
@@ -28775,7 +29006,7 @@ async function resolveUserLocalExecutable(executableName, context) {
|
|
|
28775
29006
|
if (platform === "win32" || homeDirectory === void 0 || !isAbsolute4(homeDirectory)) {
|
|
28776
29007
|
return [];
|
|
28777
29008
|
}
|
|
28778
|
-
const executable = await resolveExecutablePath(
|
|
29009
|
+
const executable = await resolveExecutablePath(join8(homeDirectory, ".local", "bin", executableName), platform);
|
|
28779
29010
|
context.signal.throwIfAborted();
|
|
28780
29011
|
return executable === null ? [] : [executable];
|
|
28781
29012
|
}
|
|
@@ -28864,8 +29095,8 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
28864
29095
|
};
|
|
28865
29096
|
|
|
28866
29097
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
28867
|
-
import { mkdir as mkdir2, realpath as
|
|
28868
|
-
import { isAbsolute as isAbsolute5, join as
|
|
29098
|
+
import { mkdir as mkdir2, realpath as realpath5, stat as stat4, writeFile } from "node:fs/promises";
|
|
29099
|
+
import { isAbsolute as isAbsolute5, join as join10, normalize } from "node:path";
|
|
28869
29100
|
|
|
28870
29101
|
// src/agent-installation/deepseek-managed-package.ts
|
|
28871
29102
|
var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
|
|
@@ -28883,13 +29114,13 @@ var DEEPSEEK_HARNESS_PACKAGE = new DeepSeekHarnessManagedPackage(
|
|
|
28883
29114
|
|
|
28884
29115
|
// src/storage/state-directory.ts
|
|
28885
29116
|
import { homedir } from "node:os";
|
|
28886
|
-
import { join as
|
|
29117
|
+
import { join as join9, resolve as resolve3 } from "node:path";
|
|
28887
29118
|
function readStateDirectory(environment = process.env) {
|
|
28888
29119
|
const configured = environment["MOBIUS_STATE_DIRECTORY"]?.trim();
|
|
28889
29120
|
if (configured !== void 0 && configured.length > 0) {
|
|
28890
|
-
return
|
|
29121
|
+
return resolve3(configured);
|
|
28891
29122
|
}
|
|
28892
|
-
return
|
|
29123
|
+
return join9(homedir(), ".mobius");
|
|
28893
29124
|
}
|
|
28894
29125
|
|
|
28895
29126
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
@@ -28907,13 +29138,13 @@ async function prepareAgentHome(path3, imagePrompts) {
|
|
|
28907
29138
|
if (imagePrompts) {
|
|
28908
29139
|
await mkdir2(path3, { mode: 448, recursive: true });
|
|
28909
29140
|
}
|
|
28910
|
-
const resolved = await
|
|
29141
|
+
const resolved = await realpath5(path3);
|
|
28911
29142
|
const metadata = await stat4(resolved);
|
|
28912
29143
|
if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
|
|
28913
29144
|
throw new Error("Agent home is not a user-owned directory");
|
|
28914
29145
|
}
|
|
28915
29146
|
if (imagePrompts) {
|
|
28916
|
-
await writeFile(
|
|
29147
|
+
await writeFile(join10(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
|
|
28917
29148
|
mode: 384
|
|
28918
29149
|
});
|
|
28919
29150
|
}
|
|
@@ -28961,7 +29192,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
28961
29192
|
context.signal
|
|
28962
29193
|
);
|
|
28963
29194
|
if (managed.path === agent.path) {
|
|
28964
|
-
selectedHome =
|
|
29195
|
+
selectedHome = join10(readStateDirectory(context.environment), "agents", this.id, "home");
|
|
28965
29196
|
managedHome = true;
|
|
28966
29197
|
}
|
|
28967
29198
|
} catch {
|
|
@@ -28977,7 +29208,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
28977
29208
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
28978
29209
|
signal.throwIfAborted();
|
|
28979
29210
|
const executable = await validateManagedNpmPackage(
|
|
28980
|
-
|
|
29211
|
+
join10(stateDirectory, "agents", this.id, DEEPSEEK_HARNESS_PACKAGE.version),
|
|
28981
29212
|
DEEPSEEK_HARNESS_PACKAGE
|
|
28982
29213
|
);
|
|
28983
29214
|
signal.throwIfAborted();
|
|
@@ -29031,8 +29262,8 @@ var GeminiCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
29031
29262
|
};
|
|
29032
29263
|
|
|
29033
29264
|
// src/agent-catalog/agents/grok-build-agent.ts
|
|
29034
|
-
import { realpath as
|
|
29035
|
-
import { isAbsolute as isAbsolute6, join as
|
|
29265
|
+
import { realpath as realpath6 } from "node:fs/promises";
|
|
29266
|
+
import { isAbsolute as isAbsolute6, join as join11, relative as relative2, sep as sep2 } from "node:path";
|
|
29036
29267
|
import {
|
|
29037
29268
|
RequestError
|
|
29038
29269
|
} from "@agentclientprotocol/sdk";
|
|
@@ -29102,8 +29333,8 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
29102
29333
|
);
|
|
29103
29334
|
if (managed.path === agent.path) {
|
|
29104
29335
|
return Object.freeze({
|
|
29105
|
-
GROK_HOME: await
|
|
29106
|
-
|
|
29336
|
+
GROK_HOME: await realpath6(
|
|
29337
|
+
join11(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION, "home")
|
|
29107
29338
|
)
|
|
29108
29339
|
});
|
|
29109
29340
|
}
|
|
@@ -29114,9 +29345,9 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
29114
29345
|
};
|
|
29115
29346
|
resolveManagedAgent = async (stateDirectory, platform, signal) => {
|
|
29116
29347
|
signal.throwIfAborted();
|
|
29117
|
-
const versionRoot = await
|
|
29118
|
-
await validateManagedNpmPackage(
|
|
29119
|
-
const executable = await resolveExecutablePath(
|
|
29348
|
+
const versionRoot = await realpath6(join11(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION));
|
|
29349
|
+
await validateManagedNpmPackage(join11(versionRoot, "package"), grokBuildManagedPackage(platform, process.arch));
|
|
29350
|
+
const executable = await resolveExecutablePath(join11(versionRoot, "home", "bin", "grok"), platform);
|
|
29120
29351
|
signal.throwIfAborted();
|
|
29121
29352
|
if (executable === null || !isContainedPath2(versionRoot, executable.path)) {
|
|
29122
29353
|
throw new AgentProbeError("managed_agent_invalid", "The managed Grok Build executable is invalid");
|
|
@@ -29216,13 +29447,13 @@ var OhMyPiAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
29216
29447
|
};
|
|
29217
29448
|
|
|
29218
29449
|
// src/agent-catalog/agents/opencode-agent.ts
|
|
29219
|
-
import { join as
|
|
29450
|
+
import { join as join13 } from "node:path";
|
|
29220
29451
|
|
|
29221
29452
|
// src/agent-installation/managed-agent-archive.ts
|
|
29222
29453
|
import { createHash } from "node:crypto";
|
|
29223
29454
|
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
|
|
29455
|
+
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";
|
|
29456
|
+
import { delimiter as delimiter2, dirname as dirname3, isAbsolute as isAbsolute7, join as join12, relative as relative3, sep as sep3 } from "node:path";
|
|
29226
29457
|
|
|
29227
29458
|
// src/agent-installation/verified-download.ts
|
|
29228
29459
|
import { fetch } from "undici";
|
|
@@ -29402,16 +29633,16 @@ async function readManifest(path3) {
|
|
|
29402
29633
|
}
|
|
29403
29634
|
async function validateManagedAgentArchive(root, definition, signal) {
|
|
29404
29635
|
try {
|
|
29405
|
-
const rootPath = await
|
|
29636
|
+
const rootPath = await realpath7(root);
|
|
29406
29637
|
const rootMetadata = await stat5(rootPath);
|
|
29407
29638
|
if (!rootMetadata.isDirectory() || typeof process.getuid === "function" && rootMetadata.uid !== process.getuid()) {
|
|
29408
29639
|
throw new Error("Managed Agent root is not user-owned");
|
|
29409
29640
|
}
|
|
29410
|
-
const manifest = await readManifest(
|
|
29641
|
+
const manifest = await readManifest(join12(rootPath, "archive.json"));
|
|
29411
29642
|
if (manifest["archiveSha256"] !== definition.archiveSha256 || manifest["archiveUrl"] !== definition.archiveUrl.toString() || manifest["version"] !== definition.version || typeof manifest["executableSha256"] !== "string") {
|
|
29412
29643
|
throw new Error("Managed Agent archive identity is invalid");
|
|
29413
29644
|
}
|
|
29414
|
-
const executable = await resolveExecutablePath(
|
|
29645
|
+
const executable = await resolveExecutablePath(join12(rootPath, "bin", definition.executableName));
|
|
29415
29646
|
if (executable === null || !isContainedPath3(rootPath, executable.path) || await hashFile(executable.path, signal) !== manifest["executableSha256"]) {
|
|
29416
29647
|
throw new Error("Managed Agent executable is invalid");
|
|
29417
29648
|
}
|
|
@@ -29577,7 +29808,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
29577
29808
|
return Object.freeze(environment);
|
|
29578
29809
|
};
|
|
29579
29810
|
resolveManagedAgent = async (stateDirectory, platform, signal) => await validateManagedAgentArchive(
|
|
29580
|
-
|
|
29811
|
+
join13(stateDirectory, "agents", this.id, OPENCODE_MANAGED_VERSION),
|
|
29581
29812
|
openCodeManagedArchive(platform, process.arch),
|
|
29582
29813
|
signal
|
|
29583
29814
|
);
|
|
@@ -29595,7 +29826,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
29595
29826
|
};
|
|
29596
29827
|
|
|
29597
29828
|
// src/agent-catalog/agents/pi-agent.ts
|
|
29598
|
-
import { join as
|
|
29829
|
+
import { join as join14 } from "node:path";
|
|
29599
29830
|
import {
|
|
29600
29831
|
methods as methods4
|
|
29601
29832
|
} from "@agentclientprotocol/sdk";
|
|
@@ -29654,7 +29885,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
29654
29885
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
29655
29886
|
signal.throwIfAborted();
|
|
29656
29887
|
const executable = await validateManagedNpmPackage(
|
|
29657
|
-
|
|
29888
|
+
join14(stateDirectory, "agents", this.id, PI_AGENT_PACKAGE.version),
|
|
29658
29889
|
PI_AGENT_PACKAGE
|
|
29659
29890
|
);
|
|
29660
29891
|
signal.throwIfAborted();
|
|
@@ -29692,7 +29923,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
29692
29923
|
};
|
|
29693
29924
|
|
|
29694
29925
|
// src/agent-catalog/agents/workbuddy-agent.ts
|
|
29695
|
-
import { join as
|
|
29926
|
+
import { join as join15 } from "node:path";
|
|
29696
29927
|
|
|
29697
29928
|
// src/agent-installation/workbuddy-managed-package.ts
|
|
29698
29929
|
var WORKBUDDY_MANAGED_VERSION = "2.146.0";
|
|
@@ -29738,7 +29969,7 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
29738
29969
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
29739
29970
|
signal.throwIfAborted();
|
|
29740
29971
|
const executable = await validateManagedNpmPackage(
|
|
29741
|
-
|
|
29972
|
+
join15(stateDirectory, "agents", this.id, WORKBUDDY_MANAGED_VERSION),
|
|
29742
29973
|
WORKBUDDY_MANAGED_PACKAGE
|
|
29743
29974
|
);
|
|
29744
29975
|
signal.throwIfAborted();
|
|
@@ -29975,9 +30206,10 @@ async function probeAcpReadiness(specification, agent, environment, defaultWorks
|
|
|
29975
30206
|
signal.removeEventListener("abort", abort);
|
|
29976
30207
|
}
|
|
29977
30208
|
}
|
|
29978
|
-
const
|
|
30209
|
+
const launch = executableLaunch2(agent.adapterPath, agent.arguments);
|
|
30210
|
+
const child2 = spawn3(launch.command, [...launch.arguments], {
|
|
29979
30211
|
cwd: defaultWorkspace,
|
|
29980
|
-
|
|
30212
|
+
...platformSpawnOptions,
|
|
29981
30213
|
env: { ...environment, ...agent.environment },
|
|
29982
30214
|
shell: false,
|
|
29983
30215
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -30110,10 +30342,10 @@ function isAgentVersionSupported(reportedVersion, minimumSupportedVersion) {
|
|
|
30110
30342
|
}
|
|
30111
30343
|
|
|
30112
30344
|
// src/agent-catalog/executable-discovery.ts
|
|
30113
|
-
import { isAbsolute as isAbsolute8, join as
|
|
30345
|
+
import { isAbsolute as isAbsolute8, join as join17 } from "node:path";
|
|
30114
30346
|
|
|
30115
30347
|
// src/agent-installation/managed-adapter-installer.ts
|
|
30116
|
-
import { join as
|
|
30348
|
+
import { join as join16 } from "node:path";
|
|
30117
30349
|
var ManagedAdapterInstallError = class extends Error {
|
|
30118
30350
|
code;
|
|
30119
30351
|
constructor(code, message, options = {}) {
|
|
@@ -30170,7 +30402,7 @@ var ManagedAdapterInstaller = class {
|
|
|
30170
30402
|
this.#stateDirectory = options.stateDirectory;
|
|
30171
30403
|
}
|
|
30172
30404
|
install = async (specification, signal) => {
|
|
30173
|
-
const root =
|
|
30405
|
+
const root = join16(this.#stateDirectory, "adapters", specification.id, specification.adapterVersion);
|
|
30174
30406
|
try {
|
|
30175
30407
|
return await this.#npmInstaller.install(
|
|
30176
30408
|
root,
|
|
@@ -30204,7 +30436,7 @@ async function resolveManagedAdapterExecutable(specification, context) {
|
|
|
30204
30436
|
let managed;
|
|
30205
30437
|
try {
|
|
30206
30438
|
managed = await validateManagedAdapter(
|
|
30207
|
-
|
|
30439
|
+
join17(readStateDirectory(context.environment), "adapters", specification.id, specification.adapterVersion),
|
|
30208
30440
|
specification
|
|
30209
30441
|
);
|
|
30210
30442
|
} catch {
|
|
@@ -30518,16 +30750,16 @@ async function discoverLocalAgentInventory(options) {
|
|
|
30518
30750
|
}
|
|
30519
30751
|
|
|
30520
30752
|
// src/config.ts
|
|
30521
|
-
import { join as
|
|
30753
|
+
import { join as join18, resolve as resolve4 } from "node:path";
|
|
30522
30754
|
function loadDefaultWorkspace(environment = process.env) {
|
|
30523
30755
|
const { MOBIUS_DEFAULT_WORKSPACE: configuredWorkspace } = environment;
|
|
30524
|
-
return configuredWorkspace ??
|
|
30756
|
+
return configuredWorkspace ?? join18(readStateDirectory(environment), "workspace");
|
|
30525
30757
|
}
|
|
30526
30758
|
var DaemonLocalContext = class {
|
|
30527
30759
|
environment;
|
|
30528
30760
|
stateDirectory;
|
|
30529
30761
|
constructor(stateDirectory, environment = process.env) {
|
|
30530
|
-
this.stateDirectory =
|
|
30762
|
+
this.stateDirectory = resolve4(stateDirectory);
|
|
30531
30763
|
this.environment = Object.freeze({ ...environment, MOBIUS_STATE_DIRECTORY: this.stateDirectory });
|
|
30532
30764
|
}
|
|
30533
30765
|
};
|
|
@@ -30570,15 +30802,14 @@ function createDaemonConfig(connection, agents = [], installableAgents = [], loc
|
|
|
30570
30802
|
// src/daemon-manager.ts
|
|
30571
30803
|
import { spawn as spawn6 } from "node:child_process";
|
|
30572
30804
|
import { createHash as createHash9, randomBytes } from "node:crypto";
|
|
30573
|
-
import { readFile as
|
|
30805
|
+
import { readFile as readFile4, unlink as unlink3, writeFile as writeFile5 } from "node:fs/promises";
|
|
30574
30806
|
import { createConnection, createServer } from "node:net";
|
|
30575
|
-
import {
|
|
30576
|
-
import { join as join22 } from "node:path";
|
|
30807
|
+
import { join as join24 } from "node:path";
|
|
30577
30808
|
|
|
30578
30809
|
// src/pairing/pair-local-machine.ts
|
|
30579
|
-
import { mkdir as mkdir5, realpath as
|
|
30810
|
+
import { mkdir as mkdir5, realpath as realpath8, stat as stat6 } from "node:fs/promises";
|
|
30580
30811
|
import { hostname as hostname3 } from "node:os";
|
|
30581
|
-
import { basename, resolve as
|
|
30812
|
+
import { basename, resolve as resolve6 } from "node:path";
|
|
30582
30813
|
import { fetch as fetch3 } from "undici";
|
|
30583
30814
|
|
|
30584
30815
|
// src/agent-catalog/publish-agent-catalog.ts
|
|
@@ -30749,8 +30980,21 @@ async function unchangedIdentity(agent, signal) {
|
|
|
30749
30980
|
|
|
30750
30981
|
// src/storage/runtime-installation-store.ts
|
|
30751
30982
|
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
|
|
30983
|
+
import { mkdir as mkdir4, open as open4, readdir as readdir2, rename as rename3, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
|
|
30984
|
+
import { dirname as dirname4, join as join19, resolve as resolve5 } from "node:path";
|
|
30985
|
+
|
|
30986
|
+
// src/filesystem/private-path.ts
|
|
30987
|
+
import { lstat as lstat2 } from "node:fs/promises";
|
|
30988
|
+
async function validateLocalPath(path3, directory, privateAccess, signal) {
|
|
30989
|
+
signal.throwIfAborted();
|
|
30990
|
+
const metadata = await lstat2(path3);
|
|
30991
|
+
if (metadata.isSymbolicLink() || (directory ? !metadata.isDirectory() : !metadata.isFile())) {
|
|
30992
|
+
throw new LocalPathError("Unsafe local path");
|
|
30993
|
+
}
|
|
30994
|
+
await platformSupportFor(process.platform).validatePathPermissions(path3, directory, privateAccess, signal);
|
|
30995
|
+
}
|
|
30996
|
+
|
|
30997
|
+
// src/storage/runtime-installation-store.ts
|
|
30754
30998
|
var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
|
|
30755
30999
|
var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
|
|
30756
31000
|
var INSTALLATION_ID_PATTERN = /^min_[a-f0-9]{32}$/;
|
|
@@ -30992,8 +31236,8 @@ async function readJsonFile(path3, signal, missingCode) {
|
|
|
30992
31236
|
}
|
|
30993
31237
|
async function writeJsonAtomically(path3, value, signal) {
|
|
30994
31238
|
signal.throwIfAborted();
|
|
30995
|
-
const directory =
|
|
30996
|
-
const temporaryPath =
|
|
31239
|
+
const directory = dirname4(path3);
|
|
31240
|
+
const temporaryPath = join19(directory, `.${randomUUID()}.tmp`);
|
|
30997
31241
|
try {
|
|
30998
31242
|
await mkdir4(directory, { mode: 448, recursive: true });
|
|
30999
31243
|
signal.throwIfAborted();
|
|
@@ -31002,7 +31246,7 @@ async function writeJsonAtomically(path3, value, signal) {
|
|
|
31002
31246
|
signal.throwIfAborted();
|
|
31003
31247
|
await rename3(temporaryPath, path3);
|
|
31004
31248
|
} catch (cause) {
|
|
31005
|
-
await
|
|
31249
|
+
await unlink2(temporaryPath).catch(() => void 0);
|
|
31006
31250
|
signal.throwIfAborted();
|
|
31007
31251
|
throw new RuntimeInstallationStoreError("connection_unavailable", "The local Runtime state cannot be written", {
|
|
31008
31252
|
cause
|
|
@@ -31019,15 +31263,17 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
31019
31263
|
this.applicationId = applicationId;
|
|
31020
31264
|
this.installationId = installationId2;
|
|
31021
31265
|
this.stateDirectory = stateDirectory;
|
|
31022
|
-
this.#channelDirectory =
|
|
31023
|
-
this.#connectionDirectory =
|
|
31266
|
+
this.#channelDirectory = join19(stateDirectory, "channels");
|
|
31267
|
+
this.#connectionDirectory = join19(stateDirectory, "connections");
|
|
31024
31268
|
}
|
|
31025
31269
|
static open = async (options, signal) => {
|
|
31026
31270
|
signal.throwIfAborted();
|
|
31027
31271
|
const applicationId = validateApplicationId(options.applicationId);
|
|
31028
|
-
const rootDirectory =
|
|
31029
|
-
const applicationDirectory =
|
|
31272
|
+
const rootDirectory = resolve5(options.stateDirectory);
|
|
31273
|
+
const applicationDirectory = join19(rootDirectory, "installations", applicationId);
|
|
31030
31274
|
try {
|
|
31275
|
+
await mkdir4(rootDirectory, { mode: 448, recursive: true });
|
|
31276
|
+
await validateLocalPath(rootDirectory, true, true, signal);
|
|
31031
31277
|
await mkdir4(applicationDirectory, { mode: 448, recursive: true });
|
|
31032
31278
|
} catch (cause) {
|
|
31033
31279
|
throw new RuntimeInstallationStoreError(
|
|
@@ -31039,7 +31285,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
31039
31285
|
);
|
|
31040
31286
|
}
|
|
31041
31287
|
const storedInstallationId = await readOrCreateInstallationId(applicationDirectory, signal);
|
|
31042
|
-
const stateDirectory =
|
|
31288
|
+
const stateDirectory = join19(applicationDirectory, storedInstallationId);
|
|
31043
31289
|
try {
|
|
31044
31290
|
await mkdir4(stateDirectory, { mode: 448, recursive: true });
|
|
31045
31291
|
} catch (cause) {
|
|
@@ -31054,8 +31300,8 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
31054
31300
|
signal.throwIfAborted();
|
|
31055
31301
|
return new _RuntimeInstallationStore(applicationId, storedInstallationId, stateDirectory);
|
|
31056
31302
|
};
|
|
31057
|
-
connectionPath = (connectionId2) =>
|
|
31058
|
-
channelIndexPath = (channelId) =>
|
|
31303
|
+
connectionPath = (connectionId2) => join19(this.#connectionDirectory, `${validateConnectionId(connectionId2)}.json`);
|
|
31304
|
+
channelIndexPath = (channelId) => join19(this.#channelDirectory, channelIndexFileName(validateIdentifier(channelId, "invalid_channel_id")));
|
|
31059
31305
|
readConnection = async (connectionId2, signal) => {
|
|
31060
31306
|
const stored = decodeConnection(
|
|
31061
31307
|
await readJsonFile(this.connectionPath(connectionId2), signal, "connection_not_found")
|
|
@@ -31178,9 +31424,9 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
31178
31424
|
const connection = await this.readConnection(connectionId2, signal);
|
|
31179
31425
|
signal.throwIfAborted();
|
|
31180
31426
|
try {
|
|
31181
|
-
await
|
|
31427
|
+
await unlink2(this.connectionPath(connection.connectionId));
|
|
31182
31428
|
signal.throwIfAborted();
|
|
31183
|
-
await
|
|
31429
|
+
await unlink2(this.channelIndexPath(connection.channelId));
|
|
31184
31430
|
} catch (cause) {
|
|
31185
31431
|
signal.throwIfAborted();
|
|
31186
31432
|
if (isNodeError(cause, "ENOENT")) {
|
|
@@ -31217,7 +31463,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
31217
31463
|
};
|
|
31218
31464
|
};
|
|
31219
31465
|
async function readOrCreateInstallationId(applicationDirectory, signal) {
|
|
31220
|
-
const pointerPath =
|
|
31466
|
+
const pointerPath = join19(applicationDirectory, "current.json");
|
|
31221
31467
|
try {
|
|
31222
31468
|
return decodeInstallationPointer(await readJsonFile(pointerPath, signal, "installation_not_found")).installationId;
|
|
31223
31469
|
} catch (cause) {
|
|
@@ -31355,10 +31601,10 @@ function parseResumeConnectionId(arguments_) {
|
|
|
31355
31601
|
return value;
|
|
31356
31602
|
}
|
|
31357
31603
|
async function resolveDefaultWorkspace(path3) {
|
|
31358
|
-
const requestedWorkspace =
|
|
31604
|
+
const requestedWorkspace = resolve6(path3);
|
|
31359
31605
|
try {
|
|
31360
31606
|
await mkdir5(requestedWorkspace, { recursive: true, mode: 448 });
|
|
31361
|
-
const defaultWorkspace = await
|
|
31607
|
+
const defaultWorkspace = await realpath8(requestedWorkspace);
|
|
31362
31608
|
const metadata = await stat6(defaultWorkspace);
|
|
31363
31609
|
if (!metadata.isDirectory()) {
|
|
31364
31610
|
throw new PairingClientError("invalid_workspace", "The default workspace is not a directory");
|
|
@@ -31580,7 +31826,7 @@ var AuditStore = class {
|
|
|
31580
31826
|
|
|
31581
31827
|
// src/run-daemon.ts
|
|
31582
31828
|
import { createHash as createHash8, randomUUID as randomUUID9 } from "node:crypto";
|
|
31583
|
-
import { join as
|
|
31829
|
+
import { join as join23 } from "node:path";
|
|
31584
31830
|
import { styleText } from "node:util";
|
|
31585
31831
|
|
|
31586
31832
|
// src/acp/active-executions.ts
|
|
@@ -31671,7 +31917,7 @@ import {
|
|
|
31671
31917
|
} from "@agentclientprotocol/sdk";
|
|
31672
31918
|
|
|
31673
31919
|
// src/authorization/local-raster.ts
|
|
31674
|
-
import { open as open5, readFile as
|
|
31920
|
+
import { open as open5, readFile as readFile3, realpath as realpath9, stat as stat7 } from "node:fs/promises";
|
|
31675
31921
|
import { basename as basename2, isAbsolute as isAbsolute9, normalize as normalize2 } from "node:path";
|
|
31676
31922
|
import { fileURLToPath } from "node:url";
|
|
31677
31923
|
var MAX_LOCAL_RASTER_BYTES = 128 * 1024 * 1024;
|
|
@@ -31694,7 +31940,7 @@ var LocalRasterImage = class {
|
|
|
31694
31940
|
this.sourceUri = sourceUri;
|
|
31695
31941
|
}
|
|
31696
31942
|
base64 = async () => {
|
|
31697
|
-
const bytes = this.bytes ?? new Uint8Array(await
|
|
31943
|
+
const bytes = this.bytes ?? new Uint8Array(await readFile3(this.sourceUri));
|
|
31698
31944
|
return Buffer.from(bytes).toString("base64");
|
|
31699
31945
|
};
|
|
31700
31946
|
};
|
|
@@ -31742,7 +31988,7 @@ async function resolveCanonicalPath(requested, signal) {
|
|
|
31742
31988
|
return null;
|
|
31743
31989
|
}
|
|
31744
31990
|
try {
|
|
31745
|
-
const target = await
|
|
31991
|
+
const target = await realpath9(requested);
|
|
31746
31992
|
signal.throwIfAborted();
|
|
31747
31993
|
if (!isAbsolute9(target) || normalize2(target) !== target) {
|
|
31748
31994
|
return null;
|
|
@@ -32323,7 +32569,7 @@ function createWritableAcpStream(output2) {
|
|
|
32323
32569
|
if (outputFailure !== void 0) {
|
|
32324
32570
|
return Promise.reject(outputFailure);
|
|
32325
32571
|
}
|
|
32326
|
-
return new Promise((
|
|
32572
|
+
return new Promise((resolve10, reject) => {
|
|
32327
32573
|
pendingWriteFailures.add(reject);
|
|
32328
32574
|
output2.write(chunk, (error62) => {
|
|
32329
32575
|
pendingWriteFailures.delete(reject);
|
|
@@ -32336,7 +32582,7 @@ function createWritableAcpStream(output2) {
|
|
|
32336
32582
|
reject(outputFailure);
|
|
32337
32583
|
return;
|
|
32338
32584
|
}
|
|
32339
|
-
|
|
32585
|
+
resolve10();
|
|
32340
32586
|
});
|
|
32341
32587
|
});
|
|
32342
32588
|
}
|
|
@@ -32358,9 +32604,10 @@ var AgentConnection = class {
|
|
|
32358
32604
|
this.connection = createAcpClient(client2).connect(inProcess.app());
|
|
32359
32605
|
return;
|
|
32360
32606
|
}
|
|
32361
|
-
const
|
|
32607
|
+
const launch = executableLaunch2(agent.adapterPath, agent.arguments);
|
|
32608
|
+
const child2 = spawn4(launch.command, [...launch.arguments], {
|
|
32362
32609
|
cwd,
|
|
32363
|
-
|
|
32610
|
+
...platformSpawnOptions,
|
|
32364
32611
|
env: { ...process.env, ...agent.environment },
|
|
32365
32612
|
shell: false,
|
|
32366
32613
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -32377,12 +32624,12 @@ var AgentConnection = class {
|
|
|
32377
32624
|
stderr.on("data", (chunk) => {
|
|
32378
32625
|
process.stderr.write(`[${agent.id}-acp] ${chunk}`);
|
|
32379
32626
|
});
|
|
32380
|
-
this.termination = new Promise((
|
|
32627
|
+
this.termination = new Promise((resolve10) => {
|
|
32381
32628
|
child2.once("error", (cause) => {
|
|
32382
|
-
|
|
32629
|
+
resolve10({ kind: "failed", error: new AcpExecutionError("The ACP process could not run", { cause }) });
|
|
32383
32630
|
});
|
|
32384
32631
|
child2.once("exit", (code, signal) => {
|
|
32385
|
-
|
|
32632
|
+
resolve10({
|
|
32386
32633
|
kind: "failed",
|
|
32387
32634
|
error: new AcpExecutionError("The ACP process stopped", { cause: { code, signal } })
|
|
32388
32635
|
});
|
|
@@ -34538,7 +34785,7 @@ function sql(strings, ...params) {
|
|
|
34538
34785
|
return new SQL([new StringChunk(str)]);
|
|
34539
34786
|
}
|
|
34540
34787
|
_sql.raw = raw;
|
|
34541
|
-
function
|
|
34788
|
+
function join25(chunks, separator) {
|
|
34542
34789
|
const result = [];
|
|
34543
34790
|
for (const [i, chunk] of chunks.entries()) {
|
|
34544
34791
|
if (i > 0 && separator !== void 0) result.push(separator);
|
|
@@ -34546,7 +34793,7 @@ function sql(strings, ...params) {
|
|
|
34546
34793
|
}
|
|
34547
34794
|
return new SQL(result);
|
|
34548
34795
|
}
|
|
34549
|
-
_sql.join =
|
|
34796
|
+
_sql.join = join25;
|
|
34550
34797
|
function identifier2(value) {
|
|
34551
34798
|
return new Name(value);
|
|
34552
34799
|
}
|
|
@@ -36691,7 +36938,7 @@ var SQLiteSelectBase = class extends TypedQueryBuilder {
|
|
|
36691
36938
|
const baseTableName = this.tableName;
|
|
36692
36939
|
const tableName = getTableLikeName(table);
|
|
36693
36940
|
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
36694
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
36941
|
+
if (typeof tableName === "string" && this.config.joins?.some((join25) => join25.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
36695
36942
|
if (!this.isPartialSelect) {
|
|
36696
36943
|
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
|
|
36697
36944
|
if (typeof tableName === "string" && !is(table, SQL)) {
|
|
@@ -37530,7 +37777,7 @@ var SQLiteDialect = class {
|
|
|
37530
37777
|
if (!joins2) return;
|
|
37531
37778
|
const withEntries = Object.entries(joins2).filter(([_, v]) => v);
|
|
37532
37779
|
if (!withEntries.length) return;
|
|
37533
|
-
return sql.join(withEntries.map(([k,
|
|
37780
|
+
return sql.join(withEntries.map(([k, join25]) => {
|
|
37534
37781
|
const relation = tableConfig.relations[k];
|
|
37535
37782
|
const isSingle2 = is(relation, One);
|
|
37536
37783
|
const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
|
|
@@ -37541,7 +37788,7 @@ var SQLiteDialect = class {
|
|
|
37541
37788
|
table: targetTable,
|
|
37542
37789
|
mode: isSingle2 ? "first" : "many",
|
|
37543
37790
|
schema,
|
|
37544
|
-
queryConfig:
|
|
37791
|
+
queryConfig: join25,
|
|
37545
37792
|
tableConfig: schema[relation.targetTableName],
|
|
37546
37793
|
relationWhere: filter,
|
|
37547
37794
|
isNested: true,
|
|
@@ -37555,7 +37802,7 @@ var SQLiteDialect = class {
|
|
|
37555
37802
|
key: k,
|
|
37556
37803
|
selection: innerQuery.selection,
|
|
37557
37804
|
isArray: !isSingle2,
|
|
37558
|
-
isOptional: (relation.optional ?? false) ||
|
|
37805
|
+
isOptional: (relation.optional ?? false) || join25 !== true && !!join25.where
|
|
37559
37806
|
});
|
|
37560
37807
|
const jsonColumns = sql.join(innerQuery.selection.map((s) => {
|
|
37561
37808
|
return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
|
|
@@ -38171,7 +38418,7 @@ var SQLiteUpdateBase = class {
|
|
|
38171
38418
|
createJoin(joinType) {
|
|
38172
38419
|
return ((table, on) => {
|
|
38173
38420
|
const tableName = getTableLikeName(table);
|
|
38174
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
38421
|
+
if (typeof tableName === "string" && this.config.joins.some((join25) => join25.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
38175
38422
|
if (typeof on === "function") {
|
|
38176
38423
|
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
38424
|
on = on(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
|
|
@@ -40830,8 +41077,8 @@ var AcpContentExternalizer = class {
|
|
|
40830
41077
|
|
|
40831
41078
|
// src/external-content/local-external-content-store.ts
|
|
40832
41079
|
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
|
|
41080
|
+
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";
|
|
41081
|
+
import { dirname as dirname5, join as join20 } from "node:path";
|
|
40835
41082
|
var contentRequest = /^mobius-content:(image|audio|resource):([a-f0-9]{64})$/u;
|
|
40836
41083
|
var CONTENT_LIFETIME_MILLISECONDS = 24 * 60 * 60 * 1e3;
|
|
40837
41084
|
var metadataSchema2 = external_exports.strictObject({
|
|
@@ -40867,7 +41114,7 @@ var LocalExternalContentStore = class {
|
|
|
40867
41114
|
#expirationTimer;
|
|
40868
41115
|
#cleanup = Promise.resolve();
|
|
40869
41116
|
constructor(stateDirectory) {
|
|
40870
|
-
this.#root =
|
|
41117
|
+
this.#root = join20(stateDirectory, "tmp", "session-content", randomUUID3());
|
|
40871
41118
|
this.#expirationTimer = setInterval(() => {
|
|
40872
41119
|
void this.#expire().catch(() => void 0);
|
|
40873
41120
|
}, 6e4);
|
|
@@ -40878,11 +41125,11 @@ var LocalExternalContentStore = class {
|
|
|
40878
41125
|
await mkdir6(this.#root, { mode: 448, recursive: true });
|
|
40879
41126
|
const now = /* @__PURE__ */ new Date();
|
|
40880
41127
|
await utimes(this.#root, now, now);
|
|
40881
|
-
for (const directory of await readdir3(
|
|
41128
|
+
for (const directory of await readdir3(dirname5(this.#root), { withFileTypes: true })) {
|
|
40882
41129
|
if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
|
|
40883
41130
|
continue;
|
|
40884
41131
|
}
|
|
40885
|
-
const path3 =
|
|
41132
|
+
const path3 = join20(dirname5(this.#root), directory.name);
|
|
40886
41133
|
if (path3 === this.#root) {
|
|
40887
41134
|
continue;
|
|
40888
41135
|
}
|
|
@@ -40932,10 +41179,10 @@ var LocalExternalContentStore = class {
|
|
|
40932
41179
|
}
|
|
40933
41180
|
await this.#expire();
|
|
40934
41181
|
active.throwIfAborted();
|
|
40935
|
-
const directory =
|
|
41182
|
+
const directory = join20(this.#root, kind);
|
|
40936
41183
|
await mkdir6(directory, { mode: 448, recursive: true });
|
|
40937
41184
|
active.throwIfAborted();
|
|
40938
|
-
const path3 =
|
|
41185
|
+
const path3 = join20(directory, key);
|
|
40939
41186
|
const write = atomicWrite(path3, bytes, active);
|
|
40940
41187
|
await write;
|
|
40941
41188
|
active.throwIfAborted();
|
|
@@ -40968,12 +41215,12 @@ var LocalExternalContentStore = class {
|
|
|
40968
41215
|
}
|
|
40969
41216
|
try {
|
|
40970
41217
|
const [resolvedDirectory, resolvedPath, file2] = await Promise.all([
|
|
40971
|
-
|
|
40972
|
-
|
|
40973
|
-
|
|
41218
|
+
realpath10(dirname5(entry.path)),
|
|
41219
|
+
realpath10(entry.path),
|
|
41220
|
+
lstat3(entry.path)
|
|
40974
41221
|
]);
|
|
40975
41222
|
signal.throwIfAborted();
|
|
40976
|
-
if (!file2.isFile() || file2.isSymbolicLink() ||
|
|
41223
|
+
if (!file2.isFile() || file2.isSymbolicLink() || dirname5(resolvedPath) !== resolvedDirectory) {
|
|
40977
41224
|
return null;
|
|
40978
41225
|
}
|
|
40979
41226
|
return { mediaType: entry.mediaType, name: entry.name, path: resolvedPath };
|
|
@@ -42274,7 +42521,7 @@ var AgentInstallationManager = class {
|
|
|
42274
42521
|
|
|
42275
42522
|
// src/agent-installation/fixed-installation-executor.ts
|
|
42276
42523
|
import { realpathSync as realpathSync2, statSync as statSync2 } from "node:fs";
|
|
42277
|
-
import { resolve as
|
|
42524
|
+
import { resolve as resolve7 } from "node:path";
|
|
42278
42525
|
function findSpecification(specifications, agentId) {
|
|
42279
42526
|
for (const specification of specifications) {
|
|
42280
42527
|
if (specification.id === agentId) {
|
|
@@ -42285,7 +42532,7 @@ function findSpecification(specifications, agentId) {
|
|
|
42285
42532
|
}
|
|
42286
42533
|
function resolveDefaultWorkspace2(path3) {
|
|
42287
42534
|
try {
|
|
42288
|
-
const directory = realpathSync2(
|
|
42535
|
+
const directory = realpathSync2(resolve7(path3));
|
|
42289
42536
|
if (!statSync2(directory).isDirectory()) {
|
|
42290
42537
|
throw new Error("Default workspace is not a directory");
|
|
42291
42538
|
}
|
|
@@ -42300,7 +42547,7 @@ function resolveDefaultWorkspace2(path3) {
|
|
|
42300
42547
|
}
|
|
42301
42548
|
function resolveIntegrationStateDirectory(path3) {
|
|
42302
42549
|
try {
|
|
42303
|
-
const directory = realpathSync2(
|
|
42550
|
+
const directory = realpathSync2(resolve7(path3));
|
|
42304
42551
|
const metadata = statSync2(directory);
|
|
42305
42552
|
if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
|
|
42306
42553
|
throw new Error("Installation directory is not user-owned");
|
|
@@ -42472,9 +42719,9 @@ var FixedInstallationExecutor = class {
|
|
|
42472
42719
|
};
|
|
42473
42720
|
|
|
42474
42721
|
// src/authorization/workspace-directory.ts
|
|
42475
|
-
import { readdir as readdir4, realpath as
|
|
42722
|
+
import { readdir as readdir4, realpath as realpath11, stat as stat9 } from "node:fs/promises";
|
|
42476
42723
|
import { homedir as homedir2 } from "node:os";
|
|
42477
|
-
import { basename as basename4, dirname as
|
|
42724
|
+
import { basename as basename4, dirname as dirname6, isAbsolute as isAbsolute10, join as join21, normalize as normalize3, relative as relative4 } from "node:path";
|
|
42478
42725
|
|
|
42479
42726
|
// src/authorization/local-authorization-error.ts
|
|
42480
42727
|
var LocalAuthorizationError = class extends Error {
|
|
@@ -42553,7 +42800,7 @@ var WorkspaceDirectoryService = class {
|
|
|
42553
42800
|
throw new LocalAuthorizationError("The local directory path is invalid");
|
|
42554
42801
|
}
|
|
42555
42802
|
try {
|
|
42556
|
-
const target = await
|
|
42803
|
+
const target = await realpath11(requested);
|
|
42557
42804
|
signal.throwIfAborted();
|
|
42558
42805
|
const metadata = await stat9(target);
|
|
42559
42806
|
signal.throwIfAborted();
|
|
@@ -42603,7 +42850,7 @@ var WorkspaceDirectoryService = class {
|
|
|
42603
42850
|
continue;
|
|
42604
42851
|
}
|
|
42605
42852
|
try {
|
|
42606
|
-
const path3 = await this.resolvePath(
|
|
42853
|
+
const path3 = await this.resolvePath(join21(target, child2.name), signal);
|
|
42607
42854
|
entries.push({ directoryId: encodePath(path3), name: child2.name });
|
|
42608
42855
|
} catch (cause) {
|
|
42609
42856
|
signal.throwIfAborted();
|
|
@@ -42613,7 +42860,7 @@ var WorkspaceDirectoryService = class {
|
|
|
42613
42860
|
}
|
|
42614
42861
|
}
|
|
42615
42862
|
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
42616
|
-
const parent =
|
|
42863
|
+
const parent = dirname6(target);
|
|
42617
42864
|
return new WorkspaceDirectoryListing(
|
|
42618
42865
|
id,
|
|
42619
42866
|
this.label(target),
|
|
@@ -42639,15 +42886,15 @@ var WorkspaceDirectoryService = class {
|
|
|
42639
42886
|
|
|
42640
42887
|
// src/daemon-diagnostic-log.ts
|
|
42641
42888
|
import { appendFileSync, mkdirSync, readFileSync as readFileSync2, renameSync, statSync as statSync3, writeFileSync } from "node:fs";
|
|
42642
|
-
import { join as
|
|
42889
|
+
import { join as join22 } from "node:path";
|
|
42643
42890
|
var MAXIMUM_DAEMON_LOG_BYTES = 1 * 1024 * 1024;
|
|
42644
42891
|
var DaemonDiagnosticLog = class {
|
|
42645
42892
|
#directory;
|
|
42646
42893
|
#path;
|
|
42647
42894
|
#maximumBytes;
|
|
42648
42895
|
constructor(stateDirectory, maximumBytes = MAXIMUM_DAEMON_LOG_BYTES) {
|
|
42649
|
-
this.#directory =
|
|
42650
|
-
this.#path =
|
|
42896
|
+
this.#directory = join22(stateDirectory, "logs");
|
|
42897
|
+
this.#path = join22(this.#directory, "daemon.log");
|
|
42651
42898
|
this.#maximumBytes = maximumBytes;
|
|
42652
42899
|
}
|
|
42653
42900
|
// Export only correlation and failure metadata. Local messages and paths stay local.
|
|
@@ -43463,7 +43710,7 @@ var ActiveDaemonTurn = class {
|
|
|
43463
43710
|
var MAX_SESSIONS_WITH_COMPLETED_RECOVERY = 32;
|
|
43464
43711
|
var waitForTurnCompletion = (turn, waitSignal) => {
|
|
43465
43712
|
waitSignal.throwIfAborted();
|
|
43466
|
-
return new Promise((
|
|
43713
|
+
return new Promise((resolve10, reject) => {
|
|
43467
43714
|
let settled = false;
|
|
43468
43715
|
const finish = (result) => {
|
|
43469
43716
|
if (settled) {
|
|
@@ -43472,7 +43719,7 @@ var waitForTurnCompletion = (turn, waitSignal) => {
|
|
|
43472
43719
|
settled = true;
|
|
43473
43720
|
waitSignal.removeEventListener("abort", onAbort);
|
|
43474
43721
|
if (result.kind === "completed") {
|
|
43475
|
-
|
|
43722
|
+
resolve10();
|
|
43476
43723
|
} else {
|
|
43477
43724
|
reject(result.error);
|
|
43478
43725
|
}
|
|
@@ -43670,7 +43917,7 @@ var sessionEventCacheMigrations = [
|
|
|
43670
43917
|
|
|
43671
43918
|
// src/infra/local-sqlite-database.ts
|
|
43672
43919
|
import { chmodSync, mkdirSync as mkdirSync2 } from "node:fs";
|
|
43673
|
-
import { dirname as
|
|
43920
|
+
import { dirname as dirname7 } from "node:path";
|
|
43674
43921
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
43675
43922
|
|
|
43676
43923
|
// ../../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 +44028,7 @@ var LocalSqliteDatabase = class {
|
|
|
43781
44028
|
orm;
|
|
43782
44029
|
#sqlite;
|
|
43783
44030
|
constructor(path3, label, migrations, pragmas = []) {
|
|
43784
|
-
mkdirSync2(
|
|
44031
|
+
mkdirSync2(dirname7(path3), { mode: 448, recursive: true });
|
|
43785
44032
|
this.#sqlite = new DatabaseSync2(path3);
|
|
43786
44033
|
chmodSync(path3, 384);
|
|
43787
44034
|
try {
|
|
@@ -44340,10 +44587,11 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
44340
44587
|
);
|
|
44341
44588
|
}
|
|
44342
44589
|
signal.throwIfAborted();
|
|
44343
|
-
const
|
|
44590
|
+
const launch = executableLaunch2(agent.agentIdentity.realPath, ["app-server"]);
|
|
44591
|
+
const child2 = spawn5(launch.command, [...launch.arguments], {
|
|
44344
44592
|
cwd,
|
|
44345
44593
|
env: { ...process.env, ...agent.environment },
|
|
44346
|
-
|
|
44594
|
+
...platformSpawnOptions,
|
|
44347
44595
|
shell: false,
|
|
44348
44596
|
stdio: ["pipe", "pipe", "ignore"]
|
|
44349
44597
|
});
|
|
@@ -45769,8 +46017,8 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
45769
46017
|
|
|
45770
46018
|
// src/artifacts/local-file-streamer.ts
|
|
45771
46019
|
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
|
|
46020
|
+
import { realpath as realpath12, stat as stat10 } from "node:fs/promises";
|
|
46021
|
+
import { basename as basename5, extname as extname2, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve8 } from "node:path";
|
|
45774
46022
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
45775
46023
|
var CHUNK_BYTES = 192 * 1024;
|
|
45776
46024
|
function requestedPath(value) {
|
|
@@ -45792,12 +46040,12 @@ async function resolveFile(value, workingDirectory, signal) {
|
|
|
45792
46040
|
if (path3 === null || !isAbsolute11(path3) && workingDirectory === null) {
|
|
45793
46041
|
return null;
|
|
45794
46042
|
}
|
|
45795
|
-
const requested = workingDirectory === null ? path3 :
|
|
46043
|
+
const requested = workingDirectory === null ? path3 : resolve8(workingDirectory, path3);
|
|
45796
46044
|
if (!isAbsolute11(requested) || isAbsolute11(path3) && normalize4(path3) !== path3) {
|
|
45797
46045
|
return null;
|
|
45798
46046
|
}
|
|
45799
46047
|
try {
|
|
45800
|
-
const target = await
|
|
46048
|
+
const target = await realpath12(requested);
|
|
45801
46049
|
signal.throwIfAborted();
|
|
45802
46050
|
return isAbsolute11(target) && normalize4(target) === target ? target : null;
|
|
45803
46051
|
} catch {
|
|
@@ -45820,7 +46068,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
|
|
|
45820
46068
|
send2({
|
|
45821
46069
|
byteLength: before.size,
|
|
45822
46070
|
kind: FILE_BEGIN_KIND,
|
|
45823
|
-
mediaType: external?.mediaType ?? raster?.mimeType ?? (
|
|
46071
|
+
mediaType: external?.mediaType ?? raster?.mimeType ?? (extname2(target).toLowerCase() === ".svg" ? "image/svg+xml" : "application/octet-stream"),
|
|
45824
46072
|
modifiedAt: before.mtime.toISOString(),
|
|
45825
46073
|
name: external?.name ?? (basename5(target) || "file"),
|
|
45826
46074
|
requestId: command.requestId,
|
|
@@ -46722,13 +46970,13 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
46722
46970
|
operationSignal.throwIfAborted();
|
|
46723
46971
|
const skipPrevious = command.action === "active-turn";
|
|
46724
46972
|
if (previous.length > 0 && !skipPrevious) {
|
|
46725
|
-
await new Promise((
|
|
46973
|
+
await new Promise((resolve10, reject) => {
|
|
46726
46974
|
const onAbort = () => reject(operationSignal.reason);
|
|
46727
46975
|
operationSignal.addEventListener("abort", onAbort, { once: true });
|
|
46728
46976
|
void Promise.all(previous.map((request) => request.completion)).then(
|
|
46729
46977
|
() => {
|
|
46730
46978
|
operationSignal.removeEventListener("abort", onAbort);
|
|
46731
|
-
|
|
46979
|
+
resolve10();
|
|
46732
46980
|
},
|
|
46733
46981
|
(error62) => {
|
|
46734
46982
|
operationSignal.removeEventListener("abort", onAbort);
|
|
@@ -47162,7 +47410,7 @@ var RelayConnectionError = class extends Error {
|
|
|
47162
47410
|
};
|
|
47163
47411
|
function connectRelay(url2, signal) {
|
|
47164
47412
|
signal.throwIfAborted();
|
|
47165
|
-
return new Promise((
|
|
47413
|
+
return new Promise((resolve10, reject) => {
|
|
47166
47414
|
const endpoint = new URL(url2);
|
|
47167
47415
|
const headers = runtimeAuthorization(endpoint);
|
|
47168
47416
|
endpoint.searchParams.delete("token");
|
|
@@ -47229,7 +47477,7 @@ function connectRelay(url2, signal) {
|
|
|
47229
47477
|
}
|
|
47230
47478
|
finished = true;
|
|
47231
47479
|
cleanup();
|
|
47232
|
-
|
|
47480
|
+
resolve10(socket);
|
|
47233
47481
|
};
|
|
47234
47482
|
function onTimeout() {
|
|
47235
47483
|
fail(
|
|
@@ -47411,7 +47659,7 @@ async function runRelayConnection({
|
|
|
47411
47659
|
installationObserver.connect(socket);
|
|
47412
47660
|
onConnected();
|
|
47413
47661
|
try {
|
|
47414
|
-
await new Promise((
|
|
47662
|
+
await new Promise((resolve10, reject) => {
|
|
47415
47663
|
let finished = false;
|
|
47416
47664
|
const cleanup = () => {
|
|
47417
47665
|
connectionLiveness.close();
|
|
@@ -47429,7 +47677,7 @@ async function runRelayConnection({
|
|
|
47429
47677
|
}
|
|
47430
47678
|
finished = true;
|
|
47431
47679
|
cleanup();
|
|
47432
|
-
|
|
47680
|
+
resolve10();
|
|
47433
47681
|
};
|
|
47434
47682
|
const rejectConnection = (failure2) => {
|
|
47435
47683
|
if (finished) {
|
|
@@ -47815,12 +48063,12 @@ function waitForRelayRetry(signal, timer) {
|
|
|
47815
48063
|
if (signal.aborted) {
|
|
47816
48064
|
return Promise.resolve();
|
|
47817
48065
|
}
|
|
47818
|
-
return new Promise((
|
|
48066
|
+
return new Promise((resolve10) => {
|
|
47819
48067
|
const retry = timer.schedule(finish, RELAY_RECONNECT_DELAY_MILLISECONDS);
|
|
47820
48068
|
function finish() {
|
|
47821
48069
|
retry.cancel();
|
|
47822
48070
|
signal.removeEventListener("abort", finish);
|
|
47823
|
-
|
|
48071
|
+
resolve10();
|
|
47824
48072
|
}
|
|
47825
48073
|
signal.addEventListener("abort", finish, { once: true });
|
|
47826
48074
|
});
|
|
@@ -47876,11 +48124,11 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
47876
48124
|
stateDirectory
|
|
47877
48125
|
});
|
|
47878
48126
|
const channelHash = createHash8("sha256").update(config2.channelId).digest("hex");
|
|
47879
|
-
const sessionDatabase = openAcpSessionDatabase(
|
|
48127
|
+
const sessionDatabase = openAcpSessionDatabase(join23(stateDirectory, "sessions", `${channelHash}.sqlite`));
|
|
47880
48128
|
let eventsV2;
|
|
47881
48129
|
try {
|
|
47882
48130
|
eventsV2 = new CachedAcpSessionEventStoreV2(
|
|
47883
|
-
openSessionEventCacheV2Database(
|
|
48131
|
+
openSessionEventCacheV2Database(join23(stateDirectory, "sessions", `${channelHash}.events.sqlite`))
|
|
47884
48132
|
);
|
|
47885
48133
|
} catch (error62) {
|
|
47886
48134
|
sessionDatabase.close();
|
|
@@ -48147,17 +48395,17 @@ var START_TIMEOUT_MILLISECONDS = 12e4;
|
|
|
48147
48395
|
var MAXIMUM_MESSAGE_BYTES = 64 * 1024;
|
|
48148
48396
|
var CONNECTION_ID_PATTERN2 = /^mcn_[a-f0-9]{32}$/;
|
|
48149
48397
|
async function acquireManagerLock(stateDirectory) {
|
|
48150
|
-
const path3 =
|
|
48398
|
+
const path3 = join24(stateDirectory, "manager.lock");
|
|
48151
48399
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
48152
48400
|
try {
|
|
48153
48401
|
await writeFile5(path3, `${process.pid.toString()}
|
|
48154
48402
|
`, { flag: "wx", mode: 384 });
|
|
48155
|
-
return async () => await
|
|
48403
|
+
return async () => await unlink3(path3).catch(() => void 0);
|
|
48156
48404
|
} catch (cause) {
|
|
48157
48405
|
if (!isNodeError2(cause, "EEXIST")) {
|
|
48158
48406
|
throw cause;
|
|
48159
48407
|
}
|
|
48160
|
-
const encoded = await
|
|
48408
|
+
const encoded = await readFile4(path3, "utf8").catch(() => "");
|
|
48161
48409
|
const pid = Number(encoded.trim());
|
|
48162
48410
|
if (Number.isSafeInteger(pid) && pid > 1) {
|
|
48163
48411
|
try {
|
|
@@ -48169,7 +48417,7 @@ async function acquireManagerLock(stateDirectory) {
|
|
|
48169
48417
|
}
|
|
48170
48418
|
}
|
|
48171
48419
|
}
|
|
48172
|
-
await
|
|
48420
|
+
await unlink3(path3).catch(() => void 0);
|
|
48173
48421
|
}
|
|
48174
48422
|
}
|
|
48175
48423
|
return null;
|
|
@@ -48177,17 +48425,18 @@ async function acquireManagerLock(stateDirectory) {
|
|
|
48177
48425
|
function isRecord12(value) {
|
|
48178
48426
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
48179
48427
|
}
|
|
48428
|
+
var managerPlatform = platformSupportFor(process.platform);
|
|
48180
48429
|
function controlSocketPath(stateDirectory) {
|
|
48181
48430
|
const installationHash = createHash9("sha256").update(stateDirectory).digest("hex").slice(0, 32);
|
|
48182
|
-
return
|
|
48431
|
+
return managerPlatform.controlSocketPath(installationHash);
|
|
48183
48432
|
}
|
|
48184
48433
|
function controlTokenPath(stateDirectory) {
|
|
48185
|
-
return
|
|
48434
|
+
return join24(stateDirectory, "manager.token");
|
|
48186
48435
|
}
|
|
48187
48436
|
async function readOrCreateControlToken(stateDirectory) {
|
|
48188
48437
|
const path3 = controlTokenPath(stateDirectory);
|
|
48189
48438
|
try {
|
|
48190
|
-
return (await
|
|
48439
|
+
return (await readFile4(path3, "utf8")).trim();
|
|
48191
48440
|
} catch (cause) {
|
|
48192
48441
|
if (!isNodeError2(cause, "ENOENT")) {
|
|
48193
48442
|
throw cause;
|
|
@@ -48202,7 +48451,7 @@ async function readOrCreateControlToken(stateDirectory) {
|
|
|
48202
48451
|
if (!isNodeError2(cause, "EEXIST")) {
|
|
48203
48452
|
throw cause;
|
|
48204
48453
|
}
|
|
48205
|
-
return (await
|
|
48454
|
+
return (await readFile4(path3, "utf8")).trim();
|
|
48206
48455
|
}
|
|
48207
48456
|
}
|
|
48208
48457
|
function isNodeError2(error62, code) {
|
|
@@ -48421,9 +48670,9 @@ async function waitForReady(active, signal) {
|
|
|
48421
48670
|
return;
|
|
48422
48671
|
}
|
|
48423
48672
|
const deadline = AbortSignal.any([signal, AbortSignal.timeout(START_TIMEOUT_MILLISECONDS)]);
|
|
48424
|
-
await new Promise((
|
|
48673
|
+
await new Promise((resolve10, reject) => {
|
|
48425
48674
|
const abort = () => reject(deadline.reason);
|
|
48426
|
-
active.ready.then(
|
|
48675
|
+
active.ready.then(resolve10, reject).finally(() => deadline.removeEventListener("abort", abort));
|
|
48427
48676
|
deadline.addEventListener("abort", abort, { once: true });
|
|
48428
48677
|
});
|
|
48429
48678
|
if (active.status === "failed") {
|
|
@@ -48434,7 +48683,7 @@ function errorMessage2(error62) {
|
|
|
48434
48683
|
return error62 instanceof Error ? error62.message : "Unknown failure";
|
|
48435
48684
|
}
|
|
48436
48685
|
async function readSocketMessage(socket, signal) {
|
|
48437
|
-
return await new Promise((
|
|
48686
|
+
return await new Promise((resolve10, reject) => {
|
|
48438
48687
|
let encoded = "";
|
|
48439
48688
|
const finish = (error62, value) => {
|
|
48440
48689
|
signal.removeEventListener("abort", abort);
|
|
@@ -48442,7 +48691,7 @@ async function readSocketMessage(socket, signal) {
|
|
|
48442
48691
|
socket.removeAllListeners("error");
|
|
48443
48692
|
socket.removeAllListeners("end");
|
|
48444
48693
|
if (error62 === void 0) {
|
|
48445
|
-
|
|
48694
|
+
resolve10(value);
|
|
48446
48695
|
} else {
|
|
48447
48696
|
reject(error62);
|
|
48448
48697
|
}
|
|
@@ -48477,14 +48726,14 @@ async function sendControlRequest(stateDirectory, command, signal) {
|
|
|
48477
48726
|
const deadline = AbortSignal.any([signal, AbortSignal.timeout(CONTROL_TIMEOUT_MILLISECONDS)]);
|
|
48478
48727
|
const socket = createConnection(controlSocketPath(stateDirectory));
|
|
48479
48728
|
try {
|
|
48480
|
-
await new Promise((
|
|
48729
|
+
await new Promise((resolve10, reject) => {
|
|
48481
48730
|
const abort = () => {
|
|
48482
48731
|
socket.destroy();
|
|
48483
48732
|
reject(deadline.reason);
|
|
48484
48733
|
};
|
|
48485
48734
|
socket.once("connect", () => {
|
|
48486
48735
|
deadline.removeEventListener("abort", abort);
|
|
48487
|
-
|
|
48736
|
+
resolve10();
|
|
48488
48737
|
});
|
|
48489
48738
|
socket.once("error", reject);
|
|
48490
48739
|
deadline.addEventListener("abort", abort, { once: true });
|
|
@@ -48499,6 +48748,7 @@ async function sendControlRequest(stateDirectory, command, signal) {
|
|
|
48499
48748
|
async function spawnManager() {
|
|
48500
48749
|
const child2 = spawn6(process.execPath, [process.argv[1] ?? "", "__manager"], {
|
|
48501
48750
|
detached: true,
|
|
48751
|
+
windowsHide: true,
|
|
48502
48752
|
env: process.env,
|
|
48503
48753
|
stdio: "ignore"
|
|
48504
48754
|
});
|
|
@@ -48514,20 +48764,20 @@ async function waitForManagerExit(stateDirectory, signal) {
|
|
|
48514
48764
|
const deadline = AbortSignal.any([signal, AbortSignal.timeout(1e4)]);
|
|
48515
48765
|
while (!deadline.aborted) {
|
|
48516
48766
|
try {
|
|
48517
|
-
await
|
|
48767
|
+
await readFile4(join24(stateDirectory, "manager.lock"), "utf8");
|
|
48518
48768
|
} catch (cause) {
|
|
48519
48769
|
if (isNodeError2(cause, "ENOENT")) {
|
|
48520
48770
|
return;
|
|
48521
48771
|
}
|
|
48522
48772
|
throw cause;
|
|
48523
48773
|
}
|
|
48524
|
-
await new Promise((
|
|
48774
|
+
await new Promise((resolve10, reject) => {
|
|
48525
48775
|
const timeout = setTimeout(finish, 20);
|
|
48526
48776
|
const abort = () => finish(deadline.reason);
|
|
48527
48777
|
function finish(cause) {
|
|
48528
48778
|
clearTimeout(timeout);
|
|
48529
48779
|
deadline.removeEventListener("abort", abort);
|
|
48530
|
-
cause === void 0 ?
|
|
48780
|
+
cause === void 0 ? resolve10() : reject(cause);
|
|
48531
48781
|
}
|
|
48532
48782
|
deadline.addEventListener("abort", abort, { once: true });
|
|
48533
48783
|
});
|
|
@@ -48577,13 +48827,13 @@ async function ensureMatchingManager(stateDirectory, managerVersion, signal) {
|
|
|
48577
48827
|
await launchManager(managerVersion);
|
|
48578
48828
|
managerStarted = true;
|
|
48579
48829
|
}
|
|
48580
|
-
await new Promise((
|
|
48830
|
+
await new Promise((resolve10, reject) => {
|
|
48581
48831
|
const timeout = setTimeout(finish, 50);
|
|
48582
48832
|
const abort = () => finish(signal.reason);
|
|
48583
48833
|
function finish(cause2) {
|
|
48584
48834
|
clearTimeout(timeout);
|
|
48585
48835
|
signal.removeEventListener("abort", abort);
|
|
48586
|
-
cause2 === void 0 ?
|
|
48836
|
+
cause2 === void 0 ? resolve10() : reject(cause2);
|
|
48587
48837
|
}
|
|
48588
48838
|
signal.addEventListener("abort", abort, { once: true });
|
|
48589
48839
|
});
|
|
@@ -48670,33 +48920,23 @@ async function runManager(installation, managerVersion, signal) {
|
|
|
48670
48920
|
}
|
|
48671
48921
|
})();
|
|
48672
48922
|
});
|
|
48673
|
-
|
|
48674
|
-
await unlink2(socketPath).catch((cause) => {
|
|
48675
|
-
if (!isNodeError2(cause, "ENOENT")) {
|
|
48676
|
-
throw cause;
|
|
48677
|
-
}
|
|
48678
|
-
});
|
|
48679
|
-
}
|
|
48923
|
+
await managerPlatform.prepareControlSocket(socketPath);
|
|
48680
48924
|
server.listen(socketPath);
|
|
48681
|
-
await new Promise((
|
|
48682
|
-
server.once("listening",
|
|
48925
|
+
await new Promise((resolve10, reject) => {
|
|
48926
|
+
server.once("listening", resolve10);
|
|
48683
48927
|
server.once("error", reject);
|
|
48684
48928
|
});
|
|
48685
|
-
|
|
48686
|
-
await import("node:fs/promises").then(async ({ chmod: chmod2 }) => await chmod2(socketPath, 384));
|
|
48687
|
-
}
|
|
48929
|
+
await managerPlatform.secureControlSocket(socketPath);
|
|
48688
48930
|
try {
|
|
48689
|
-
await new Promise((
|
|
48690
|
-
const serverClosed = new Promise((
|
|
48931
|
+
await new Promise((resolve10) => combined.addEventListener("abort", () => resolve10(), { once: true }));
|
|
48932
|
+
const serverClosed = new Promise((resolve10) => server.close(() => resolve10()));
|
|
48691
48933
|
for (const socket of sockets) {
|
|
48692
48934
|
socket.destroy();
|
|
48693
48935
|
}
|
|
48694
48936
|
await serverClosed;
|
|
48695
48937
|
await supervisor.close();
|
|
48696
48938
|
} finally {
|
|
48697
|
-
|
|
48698
|
-
await unlink2(socketPath).catch(() => void 0);
|
|
48699
|
-
}
|
|
48939
|
+
await managerPlatform.removeControlSocket(socketPath).catch(() => void 0);
|
|
48700
48940
|
await releaseLock();
|
|
48701
48941
|
}
|
|
48702
48942
|
}
|
|
@@ -48839,7 +49079,7 @@ function createProgram() {
|
|
|
48839
49079
|
});
|
|
48840
49080
|
pair.command("list").description("list saved pairings").addOption(valueOption("--output-json <existing-file.json>", "write JSON to an existing file")).action(async (options) => {
|
|
48841
49081
|
const installation = await openMobiusCliInstallation(shutdown.signal, process.env);
|
|
48842
|
-
const outputPath = options.outputJson === void 0 ? null :
|
|
49082
|
+
const outputPath = options.outputJson === void 0 ? null : resolve9(options.outputJson);
|
|
48843
49083
|
const response = await requestManager(
|
|
48844
49084
|
installation,
|
|
48845
49085
|
package_default.version,
|