@moxt-ai/mobius 0.0.194 → 0.0.196
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp/agent-connection.d.ts.map +1 -1
- package/dist/acp/agent-connection.js +4 -3
- package/dist/acp/agent-connection.js.map +1 -1
- package/dist/acp/codex/app-server-client.d.ts.map +1 -1
- package/dist/acp/codex/app-server-client.js +4 -2
- package/dist/acp/codex/app-server-client.js.map +1 -1
- package/dist/agent-catalog/acp-readiness-probe.d.ts.map +1 -1
- package/dist/agent-catalog/acp-readiness-probe.js +4 -3
- package/dist/agent-catalog/acp-readiness-probe.js.map +1 -1
- package/dist/cli.js +630 -343
- package/dist/cli.js.map +4 -4
- package/dist/daemon-history-commands.d.ts.map +1 -1
- package/dist/daemon-history-commands.js +70 -29
- package/dist/daemon-history-commands.js.map +1 -1
- 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 +602 -306
- 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 +602 -306
- package/dist/runtime.js.map +4 -4
- package/dist/storage/runtime-installation-store.d.ts.map +1 -1
- package/dist/storage/runtime-installation-store.js +3 -0
- package/dist/storage/runtime-installation-store.js.map +1 -1
- package/package.json +72 -70
package/dist/runtime.js
CHANGED
|
@@ -5,8 +5,8 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/runtime.ts
|
|
8
|
-
import { mkdir as mkdir7, realpath as
|
|
9
|
-
import { resolve as
|
|
8
|
+
import { mkdir as mkdir7, realpath as realpath13, stat as stat11 } from "node:fs/promises";
|
|
9
|
+
import { resolve as resolve9 } from "node:path";
|
|
10
10
|
|
|
11
11
|
// ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/external.js
|
|
12
12
|
var external_exports = {};
|
|
@@ -5034,7 +5034,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
5034
5034
|
var NONE = 0;
|
|
5035
5035
|
var ASSUMED = 1;
|
|
5036
5036
|
var PROVEN = 2;
|
|
5037
|
-
function isRecursive(inst, stack,
|
|
5037
|
+
function isRecursive(inst, stack, resolve10) {
|
|
5038
5038
|
const cached2 = recursive.get(inst);
|
|
5039
5039
|
if (cached2 !== void 0)
|
|
5040
5040
|
return cached2 ? PROVEN : NONE;
|
|
@@ -5044,7 +5044,7 @@ function isRecursive(inst, stack, resolve9) {
|
|
|
5044
5044
|
let result = NONE;
|
|
5045
5045
|
const check2 = (child2) => {
|
|
5046
5046
|
if (result !== PROVEN && child2?._zod) {
|
|
5047
|
-
const answer = isRecursive(child2, stack,
|
|
5047
|
+
const answer = isRecursive(child2, stack, resolve10);
|
|
5048
5048
|
if (answer > result)
|
|
5049
5049
|
result = answer;
|
|
5050
5050
|
}
|
|
@@ -5055,7 +5055,7 @@ function isRecursive(inst, stack, resolve9) {
|
|
|
5055
5055
|
const desc2 = Object.getOwnPropertyDescriptor(sh, key);
|
|
5056
5056
|
if (spread && !desc2.enumerable)
|
|
5057
5057
|
continue;
|
|
5058
|
-
const child2 = desc2.get ? ASSUMED : desc2.value?._zod ? isRecursive(desc2.value, stack,
|
|
5058
|
+
const child2 = desc2.get ? ASSUMED : desc2.value?._zod ? isRecursive(desc2.value, stack, resolve10) : NONE;
|
|
5059
5059
|
if (child2 > answer)
|
|
5060
5060
|
answer = child2;
|
|
5061
5061
|
}
|
|
@@ -5119,7 +5119,7 @@ function isRecursive(inst, stack, resolve9) {
|
|
|
5119
5119
|
break;
|
|
5120
5120
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
5121
5121
|
case "lazy": {
|
|
5122
|
-
const inner = def._cachedInner ?? (
|
|
5122
|
+
const inner = def._cachedInner ?? (resolve10 ? inst._zod.innerType : void 0);
|
|
5123
5123
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
5124
5124
|
break;
|
|
5125
5125
|
}
|
|
@@ -21327,6 +21327,7 @@ var provenanceSchema = external_exports.discriminatedUnion("kind", [
|
|
|
21327
21327
|
]);
|
|
21328
21328
|
var sessionEventFieldsV2 = {
|
|
21329
21329
|
eventId: identifierStringSchema,
|
|
21330
|
+
mobiusMetadata: external_exports.object({ omitted: external_exports.literal(true).optional() }).readonly().optional(),
|
|
21330
21331
|
position: positionSchema,
|
|
21331
21332
|
provenance: provenanceSchema,
|
|
21332
21333
|
recordedAt: external_exports.iso.datetime({ offset: true }),
|
|
@@ -21393,7 +21394,12 @@ var sessionEventLogPageV2Schema = external_exports.object({
|
|
|
21393
21394
|
truncated: external_exports.boolean(),
|
|
21394
21395
|
version: external_exports.literal(2)
|
|
21395
21396
|
}).readonly();
|
|
21396
|
-
var
|
|
21397
|
+
var sessionEventOmissionV2Schema = external_exports.literal("agent-reasoning");
|
|
21398
|
+
var nativeEventPageRequestV2Schema = external_exports.object({
|
|
21399
|
+
cursor: external_exports.string().min(1).max(512).nullable(),
|
|
21400
|
+
eventLimit: external_exports.number().int().min(1).max(1e4),
|
|
21401
|
+
omit: external_exports.array(sessionEventOmissionV2Schema).max(1).readonly().optional()
|
|
21402
|
+
}).readonly();
|
|
21397
21403
|
var queuedPromptRequestEventLogV2Schema = external_exports.object({
|
|
21398
21404
|
commandId: identifierStringSchema,
|
|
21399
21405
|
content: external_exports.array(contentBlockV2Schema).min(1).max(100).readonly(),
|
|
@@ -21440,6 +21446,7 @@ var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-
|
|
|
21440
21446
|
var pageRequestFields = {
|
|
21441
21447
|
cursor: external_exports.string().min(1).max(512).nullable(),
|
|
21442
21448
|
eventLimit: external_exports.number().int().min(1).max(1e4),
|
|
21449
|
+
omit: external_exports.array(sessionEventOmissionV2Schema).max(1).readonly().optional(),
|
|
21443
21450
|
requestId: identifierStringSchema,
|
|
21444
21451
|
sessionId: identifierStringSchema
|
|
21445
21452
|
};
|
|
@@ -21797,17 +21804,31 @@ function normalizeAcpCapabilities(initialized) {
|
|
|
21797
21804
|
|
|
21798
21805
|
// src/process/executable.ts
|
|
21799
21806
|
import { spawn } from "node:child_process";
|
|
21800
|
-
import {
|
|
21801
|
-
import {
|
|
21802
|
-
import { join as join3, resolve } from "node:path";
|
|
21807
|
+
import { stat as stat2 } from "node:fs/promises";
|
|
21808
|
+
import { join as join5, resolve as resolve2 } from "node:path";
|
|
21803
21809
|
|
|
21804
21810
|
// src/platform/linux.ts
|
|
21805
|
-
import { constants, readdirSync, readFileSync } from "node:fs";
|
|
21806
|
-
import { access, readdir, readFile, realpath, stat } from "node:fs/promises";
|
|
21807
|
-
import { join } from "node:path";
|
|
21811
|
+
import { constants as constants2, readdirSync, readFileSync } from "node:fs";
|
|
21812
|
+
import { access as access2, readdir, readFile, realpath as realpath2, stat } from "node:fs/promises";
|
|
21813
|
+
import { join as join2 } from "node:path";
|
|
21808
21814
|
|
|
21809
21815
|
// src/platform/posix.ts
|
|
21810
21816
|
import { execFile } from "node:child_process";
|
|
21817
|
+
import { constants } from "node:fs";
|
|
21818
|
+
import { access, chmod, lstat, realpath, unlink } from "node:fs/promises";
|
|
21819
|
+
import { tmpdir } from "node:os";
|
|
21820
|
+
import { join } from "node:path";
|
|
21821
|
+
|
|
21822
|
+
// src/filesystem/path-error.ts
|
|
21823
|
+
var LocalPathError = class extends Error {
|
|
21824
|
+
code = "unsafe_local_path";
|
|
21825
|
+
constructor(message, options = {}) {
|
|
21826
|
+
super(message, options);
|
|
21827
|
+
this.name = "LocalPathError";
|
|
21828
|
+
}
|
|
21829
|
+
};
|
|
21830
|
+
|
|
21831
|
+
// src/platform/posix.ts
|
|
21811
21832
|
var PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
|
|
21812
21833
|
var PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
|
|
21813
21834
|
function parseProcessTable(output2) {
|
|
@@ -21852,6 +21873,81 @@ function processExists(processId) {
|
|
|
21852
21873
|
return false;
|
|
21853
21874
|
}
|
|
21854
21875
|
}
|
|
21876
|
+
function signalCapturedProcesses(processes, rootProcessId, signal) {
|
|
21877
|
+
const processIds = new Set(processes.map((identity2) => identity2.processId));
|
|
21878
|
+
const signalledGroups = /* @__PURE__ */ new Set();
|
|
21879
|
+
for (const identity2 of processes) {
|
|
21880
|
+
const isRootProcessGroup = identity2.processGroupId === rootProcessId;
|
|
21881
|
+
if (!isRootProcessGroup && !processIds.has(identity2.processGroupId) || signalledGroups.has(identity2.processGroupId)) {
|
|
21882
|
+
continue;
|
|
21883
|
+
}
|
|
21884
|
+
try {
|
|
21885
|
+
process.kill(-identity2.processGroupId, signal);
|
|
21886
|
+
signalledGroups.add(identity2.processGroupId);
|
|
21887
|
+
} catch {
|
|
21888
|
+
}
|
|
21889
|
+
}
|
|
21890
|
+
for (const identity2 of processes) {
|
|
21891
|
+
if (identity2.processId === rootProcessId || identity2.processGroupId === rootProcessId || signalledGroups.has(identity2.processGroupId)) {
|
|
21892
|
+
continue;
|
|
21893
|
+
}
|
|
21894
|
+
try {
|
|
21895
|
+
process.kill(identity2.processId, signal);
|
|
21896
|
+
} catch {
|
|
21897
|
+
}
|
|
21898
|
+
}
|
|
21899
|
+
}
|
|
21900
|
+
function terminateProcess(child2, signal) {
|
|
21901
|
+
if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
|
|
21902
|
+
return;
|
|
21903
|
+
}
|
|
21904
|
+
try {
|
|
21905
|
+
process.kill(-child2.pid, signal);
|
|
21906
|
+
return;
|
|
21907
|
+
} catch {
|
|
21908
|
+
}
|
|
21909
|
+
child2.kill(signal);
|
|
21910
|
+
}
|
|
21911
|
+
async function removeControlSocket(path2) {
|
|
21912
|
+
try {
|
|
21913
|
+
await unlink(path2);
|
|
21914
|
+
} catch (cause) {
|
|
21915
|
+
if (!(cause instanceof Error) || !("code" in cause) || cause.code !== "ENOENT") {
|
|
21916
|
+
throw cause;
|
|
21917
|
+
}
|
|
21918
|
+
}
|
|
21919
|
+
}
|
|
21920
|
+
var posixOperations = {
|
|
21921
|
+
controlSocketPath: (installationHash) => join(tmpdir(), `mobius-${installationHash}.sock`),
|
|
21922
|
+
prepareControlSocket: removeControlSocket,
|
|
21923
|
+
secureControlSocket: async (path2) => {
|
|
21924
|
+
await chmod(path2, 384);
|
|
21925
|
+
},
|
|
21926
|
+
removeControlSocket,
|
|
21927
|
+
pathDelimiter: ":",
|
|
21928
|
+
environmentValue: (environment, name2) => environment[name2],
|
|
21929
|
+
executableExtensions: () => [""],
|
|
21930
|
+
resolveExecutableTarget: async (path2) => {
|
|
21931
|
+
const target = await realpath(path2);
|
|
21932
|
+
await access(target, constants.X_OK);
|
|
21933
|
+
return target;
|
|
21934
|
+
},
|
|
21935
|
+
executableLaunch: (command, args) => ({ command, arguments: args }),
|
|
21936
|
+
spawnOptions: { detached: true, windowsHide: true },
|
|
21937
|
+
signalCapturedProcesses,
|
|
21938
|
+
terminateProcess,
|
|
21939
|
+
validatePathPermissions: async (path2, directory, privateAccess, signal) => {
|
|
21940
|
+
signal.throwIfAborted();
|
|
21941
|
+
const metadata = await lstat(path2);
|
|
21942
|
+
if (process.getuid === void 0 || metadata.uid !== process.getuid()) {
|
|
21943
|
+
throw new LocalPathError("Path is not user-owned");
|
|
21944
|
+
}
|
|
21945
|
+
if (privateAccess) {
|
|
21946
|
+
await chmod(path2, directory ? 448 : 384);
|
|
21947
|
+
}
|
|
21948
|
+
signal.throwIfAborted();
|
|
21949
|
+
}
|
|
21950
|
+
};
|
|
21855
21951
|
|
|
21856
21952
|
// src/platform/linux.ts
|
|
21857
21953
|
function appendLinuxProcessTableEntry(entries, processId, encoded) {
|
|
@@ -21883,7 +21979,7 @@ async function readLinuxProcessTable() {
|
|
|
21883
21979
|
appendLinuxProcessTableEntry(
|
|
21884
21980
|
entries,
|
|
21885
21981
|
processId,
|
|
21886
|
-
await readFile(
|
|
21982
|
+
await readFile(join2("/proc", directory.name, "stat"), "utf8")
|
|
21887
21983
|
);
|
|
21888
21984
|
} catch {
|
|
21889
21985
|
}
|
|
@@ -21908,7 +22004,7 @@ function readLinuxProcessTableSynchronously() {
|
|
|
21908
22004
|
appendLinuxProcessTableEntry(
|
|
21909
22005
|
entries,
|
|
21910
22006
|
processId,
|
|
21911
|
-
readFileSync(
|
|
22007
|
+
readFileSync(join2("/proc", directory.name, "stat"), "utf8")
|
|
21912
22008
|
);
|
|
21913
22009
|
} catch {
|
|
21914
22010
|
}
|
|
@@ -21924,11 +22020,11 @@ async function readLinuxProcessTableWithFallback() {
|
|
|
21924
22020
|
}
|
|
21925
22021
|
for (const candidate of ["/usr/bin/ps", "/bin/ps", "/run/current-system/sw/bin/ps"]) {
|
|
21926
22022
|
try {
|
|
21927
|
-
const resolvedPath = await
|
|
22023
|
+
const resolvedPath = await realpath2(candidate);
|
|
21928
22024
|
if (!(await stat(resolvedPath)).isFile()) {
|
|
21929
22025
|
continue;
|
|
21930
22026
|
}
|
|
21931
|
-
await
|
|
22027
|
+
await access2(resolvedPath, constants2.X_OK);
|
|
21932
22028
|
} catch {
|
|
21933
22029
|
continue;
|
|
21934
22030
|
}
|
|
@@ -21941,7 +22037,7 @@ async function readLinuxProcessTableWithFallback() {
|
|
|
21941
22037
|
}
|
|
21942
22038
|
function processExists2(processId) {
|
|
21943
22039
|
try {
|
|
21944
|
-
const encoded = readFileSync(
|
|
22040
|
+
const encoded = readFileSync(join2("/proc", processId.toString(), "stat"), "utf8");
|
|
21945
22041
|
const closingParenthesis = encoded.lastIndexOf(")");
|
|
21946
22042
|
if (closingParenthesis >= 0) {
|
|
21947
22043
|
const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
|
|
@@ -21954,6 +22050,7 @@ function processExists2(processId) {
|
|
|
21954
22050
|
return processExists(processId);
|
|
21955
22051
|
}
|
|
21956
22052
|
var linuxPlatform = {
|
|
22053
|
+
...posixOperations,
|
|
21957
22054
|
readProcessTable: readLinuxProcessTableWithFallback,
|
|
21958
22055
|
readProcessTableSynchronously: readLinuxProcessTableSynchronously,
|
|
21959
22056
|
processExists: processExists2,
|
|
@@ -21985,7 +22082,7 @@ var linuxPlatform = {
|
|
|
21985
22082
|
};
|
|
21986
22083
|
|
|
21987
22084
|
// src/platform/macos.ts
|
|
21988
|
-
import { isAbsolute, join as
|
|
22085
|
+
import { isAbsolute, join as join3 } from "node:path";
|
|
21989
22086
|
var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
|
|
21990
22087
|
"WorkBuddy.app",
|
|
21991
22088
|
"Contents",
|
|
@@ -21996,14 +22093,15 @@ var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
|
|
|
21996
22093
|
"codebuddy"
|
|
21997
22094
|
]);
|
|
21998
22095
|
var macosPlatform = {
|
|
22096
|
+
...posixOperations,
|
|
21999
22097
|
readProcessTable: () => readProcessTableWithPs("/bin/ps"),
|
|
22000
22098
|
readProcessTableSynchronously: () => [],
|
|
22001
22099
|
processExists,
|
|
22002
22100
|
workBuddyExecutablePaths: (environment) => {
|
|
22003
|
-
const paths = [
|
|
22101
|
+
const paths = [join3("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
|
|
22004
22102
|
const homeDirectory = environment["HOME"];
|
|
22005
22103
|
if (homeDirectory !== void 0 && isAbsolute(homeDirectory)) {
|
|
22006
|
-
paths.unshift(
|
|
22104
|
+
paths.unshift(join3(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
|
|
22007
22105
|
}
|
|
22008
22106
|
return paths;
|
|
22009
22107
|
},
|
|
@@ -22033,8 +22131,199 @@ var macosPlatform = {
|
|
|
22033
22131
|
}
|
|
22034
22132
|
};
|
|
22035
22133
|
|
|
22134
|
+
// src/platform/windows.ts
|
|
22135
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
22136
|
+
import { readFile as readFile2, realpath as realpath3 } from "node:fs/promises";
|
|
22137
|
+
import { dirname, extname, join as join4, resolve } from "node:path";
|
|
22138
|
+
import { promisify } from "node:util";
|
|
22139
|
+
|
|
22140
|
+
// src/process/process-error.ts
|
|
22141
|
+
var ProcessExecutionError = class extends Error {
|
|
22142
|
+
code;
|
|
22143
|
+
constructor(code, message, options = {}) {
|
|
22144
|
+
super(message, options);
|
|
22145
|
+
this.code = code;
|
|
22146
|
+
this.name = "ProcessExecutionError";
|
|
22147
|
+
}
|
|
22148
|
+
};
|
|
22149
|
+
|
|
22150
|
+
// src/platform/windows.ts
|
|
22151
|
+
var execute = promisify(execFile2);
|
|
22152
|
+
function environmentValue(environment, name2) {
|
|
22153
|
+
return Object.entries(environment).find(([key]) => key.toUpperCase() === name2.toUpperCase())?.[1];
|
|
22154
|
+
}
|
|
22155
|
+
function executableExtensions(executableName, environment) {
|
|
22156
|
+
if (/\.[a-zA-Z0-9]+$/.test(executableName)) {
|
|
22157
|
+
return [""];
|
|
22158
|
+
}
|
|
22159
|
+
const configured = environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD";
|
|
22160
|
+
const extensions = configured.split(";").map((extension) => extension.trim()).filter((extension) => extension.length > 0).map((extension) => extension.startsWith(".") ? extension : `.${extension}`);
|
|
22161
|
+
return extensions.length > 0 ? extensions : [".EXE"];
|
|
22162
|
+
}
|
|
22163
|
+
async function resolveExecutableTarget(path2) {
|
|
22164
|
+
let resolvedPath;
|
|
22165
|
+
try {
|
|
22166
|
+
resolvedPath = await realpath3(extname(path2) === "" ? `${path2}.cmd` : path2);
|
|
22167
|
+
} catch (cause) {
|
|
22168
|
+
if (extname(path2) !== "" || !(cause instanceof Error) || !("code" in cause) || cause.code !== "ENOENT") {
|
|
22169
|
+
throw cause;
|
|
22170
|
+
}
|
|
22171
|
+
resolvedPath = await realpath3(path2);
|
|
22172
|
+
}
|
|
22173
|
+
if (extname(resolvedPath).toLowerCase() === ".cmd") {
|
|
22174
|
+
const shim = await readFile2(resolvedPath, "utf8");
|
|
22175
|
+
const script = /"%_prog%"\s+"%dp0%[\\/]([^"\r\n]+\.(?:js|mjs|cjs))"\s+%\*/iu.exec(shim)?.[1];
|
|
22176
|
+
if (script !== void 0 && shim.includes("SET dp0=%~dp0")) {
|
|
22177
|
+
resolvedPath = await realpath3(resolve(dirname(resolvedPath), script));
|
|
22178
|
+
} else {
|
|
22179
|
+
const pnpmScript = /^\s*node\s+"%~dp0[\\/]([^"\r\n]+\.(?:js|mjs|cjs))"\s+%\*\s*$/imu.exec(shim)?.[1];
|
|
22180
|
+
if (pnpmScript === void 0 || !shim.includes("@SETLOCAL")) {
|
|
22181
|
+
throw new ProcessExecutionError(
|
|
22182
|
+
"process_unsupported_script",
|
|
22183
|
+
"Use a native executable or a verified Node entrypoint"
|
|
22184
|
+
);
|
|
22185
|
+
}
|
|
22186
|
+
resolvedPath = await realpath3(resolve(dirname(resolvedPath), pnpmScript));
|
|
22187
|
+
}
|
|
22188
|
+
}
|
|
22189
|
+
return resolvedPath;
|
|
22190
|
+
}
|
|
22191
|
+
function executableLaunch(command, args) {
|
|
22192
|
+
if (/\.(?:js|mjs|cjs)$/iu.test(command)) {
|
|
22193
|
+
return { command: process.execPath, arguments: [command, ...args] };
|
|
22194
|
+
}
|
|
22195
|
+
if (/\.(?:cmd|bat)$/iu.test(command)) {
|
|
22196
|
+
throw new ProcessExecutionError(
|
|
22197
|
+
"process_unsupported_script",
|
|
22198
|
+
"Use a native executable or a verified Node entrypoint"
|
|
22199
|
+
);
|
|
22200
|
+
}
|
|
22201
|
+
return { command, arguments: args };
|
|
22202
|
+
}
|
|
22203
|
+
function readProcessTable() {
|
|
22204
|
+
const systemRoot = environmentValue(process.env, "SystemRoot");
|
|
22205
|
+
if (systemRoot === void 0) {
|
|
22206
|
+
return Promise.resolve([]);
|
|
22207
|
+
}
|
|
22208
|
+
return new Promise((resolveTable) => {
|
|
22209
|
+
execFile2(
|
|
22210
|
+
join4(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
22211
|
+
[
|
|
22212
|
+
"-NoLogo",
|
|
22213
|
+
"-NoProfile",
|
|
22214
|
+
"-NonInteractive",
|
|
22215
|
+
"-Command",
|
|
22216
|
+
"Get-CimInstance Win32_Process | ForEach-Object { '{0} {1} {0}' -f $_.ProcessId, $_.ParentProcessId }"
|
|
22217
|
+
],
|
|
22218
|
+
{
|
|
22219
|
+
encoding: "utf8",
|
|
22220
|
+
windowsHide: true,
|
|
22221
|
+
timeout: 1e4,
|
|
22222
|
+
signal: AbortSignal.timeout(1e4),
|
|
22223
|
+
maxBuffer: 1024 * 1024
|
|
22224
|
+
},
|
|
22225
|
+
(error62, stdout) => resolveTable(error62 === null ? parseProcessTable(stdout) : [])
|
|
22226
|
+
);
|
|
22227
|
+
});
|
|
22228
|
+
}
|
|
22229
|
+
function signalCapturedProcesses2(processes, _rootProcessId, signal) {
|
|
22230
|
+
for (const identity2 of [...processes].reverse()) {
|
|
22231
|
+
try {
|
|
22232
|
+
process.kill(identity2.processId, signal);
|
|
22233
|
+
} catch {
|
|
22234
|
+
}
|
|
22235
|
+
}
|
|
22236
|
+
}
|
|
22237
|
+
function terminateProcess2(child2, signal) {
|
|
22238
|
+
if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
|
|
22239
|
+
return;
|
|
22240
|
+
}
|
|
22241
|
+
child2.kill(signal);
|
|
22242
|
+
}
|
|
22243
|
+
var windowsPermissions = `
|
|
22244
|
+
$ErrorActionPreference = 'Stop'
|
|
22245
|
+
Import-Module (Join-Path $PSHOME 'Modules/Microsoft.PowerShell.Security/Microsoft.PowerShell.Security.psd1')
|
|
22246
|
+
$item = Get-Item -LiteralPath $env:MOBIUS_PERMISSION_PATH -Force
|
|
22247
|
+
if (($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0) { throw 'Unsafe path' }
|
|
22248
|
+
$sid = [Security.Principal.WindowsIdentity]::GetCurrent().User
|
|
22249
|
+
$acl = Get-Acl -LiteralPath $item.FullName
|
|
22250
|
+
$owner = $acl.GetOwner([Security.Principal.SecurityIdentifier])
|
|
22251
|
+
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' }
|
|
22252
|
+
if ($env:MOBIUS_PERMISSION_PRIVATE -eq '1') {
|
|
22253
|
+
if ($item.PSIsContainer) {
|
|
22254
|
+
$private = New-Object Security.AccessControl.DirectorySecurity
|
|
22255
|
+
$rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'ContainerInherit,ObjectInherit', 'None', 'Allow')
|
|
22256
|
+
} else {
|
|
22257
|
+
$private = New-Object Security.AccessControl.FileSecurity
|
|
22258
|
+
$rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'Allow')
|
|
22259
|
+
}
|
|
22260
|
+
$private.SetOwner($sid)
|
|
22261
|
+
$private.SetAccessRuleProtection($true, $false)
|
|
22262
|
+
$private.AddAccessRule($rule)
|
|
22263
|
+
Set-Acl -LiteralPath $item.FullName -AclObject $private
|
|
22264
|
+
}
|
|
22265
|
+
`;
|
|
22266
|
+
async function validatePathPermissions(path2, _directory, privateAccess, signal) {
|
|
22267
|
+
signal.throwIfAborted();
|
|
22268
|
+
const systemRoot = environmentValue(process.env, "SystemRoot");
|
|
22269
|
+
if (systemRoot === void 0) {
|
|
22270
|
+
throw new LocalPathError("Windows system directory is unavailable");
|
|
22271
|
+
}
|
|
22272
|
+
try {
|
|
22273
|
+
await execute(
|
|
22274
|
+
join4(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
22275
|
+
[
|
|
22276
|
+
"-NoLogo",
|
|
22277
|
+
"-NoProfile",
|
|
22278
|
+
"-NonInteractive",
|
|
22279
|
+
"-EncodedCommand",
|
|
22280
|
+
Buffer.from(windowsPermissions, "utf16le").toString("base64")
|
|
22281
|
+
],
|
|
22282
|
+
{
|
|
22283
|
+
env: {
|
|
22284
|
+
...process.env,
|
|
22285
|
+
MOBIUS_PERMISSION_PATH: path2,
|
|
22286
|
+
MOBIUS_PERMISSION_PRIVATE: privateAccess ? "1" : "0"
|
|
22287
|
+
},
|
|
22288
|
+
windowsHide: true,
|
|
22289
|
+
signal: AbortSignal.any([signal, AbortSignal.timeout(1e4)]),
|
|
22290
|
+
timeout: 1e4,
|
|
22291
|
+
maxBuffer: 16384
|
|
22292
|
+
}
|
|
22293
|
+
);
|
|
22294
|
+
} catch (cause) {
|
|
22295
|
+
signal.throwIfAborted();
|
|
22296
|
+
throw new LocalPathError("The local path permissions could not be secured", { cause });
|
|
22297
|
+
}
|
|
22298
|
+
}
|
|
22299
|
+
var windowsPlatform = {
|
|
22300
|
+
controlSocketPath: (installationHash) => `\\\\.\\pipe\\mobius-${installationHash}`,
|
|
22301
|
+
prepareControlSocket: async () => {
|
|
22302
|
+
},
|
|
22303
|
+
secureControlSocket: async () => {
|
|
22304
|
+
},
|
|
22305
|
+
removeControlSocket: async () => {
|
|
22306
|
+
},
|
|
22307
|
+
pathDelimiter: ";",
|
|
22308
|
+
environmentValue,
|
|
22309
|
+
executableExtensions,
|
|
22310
|
+
resolveExecutableTarget,
|
|
22311
|
+
executableLaunch,
|
|
22312
|
+
spawnOptions: { detached: false, windowsHide: true },
|
|
22313
|
+
signalCapturedProcesses: signalCapturedProcesses2,
|
|
22314
|
+
terminateProcess: terminateProcess2,
|
|
22315
|
+
validatePathPermissions,
|
|
22316
|
+
readProcessTable,
|
|
22317
|
+
readProcessTableSynchronously: () => [],
|
|
22318
|
+
processExists,
|
|
22319
|
+
workBuddyExecutablePaths: () => [],
|
|
22320
|
+
openCodeArchives: {},
|
|
22321
|
+
grokDependencies: {}
|
|
22322
|
+
};
|
|
22323
|
+
|
|
22036
22324
|
// src/platform/index.ts
|
|
22037
22325
|
var fallbackPlatform = {
|
|
22326
|
+
...posixOperations,
|
|
22038
22327
|
readProcessTable: () => readProcessTableWithPs("/usr/bin/ps"),
|
|
22039
22328
|
readProcessTableSynchronously: () => [],
|
|
22040
22329
|
processExists,
|
|
@@ -22045,7 +22334,7 @@ var fallbackPlatform = {
|
|
|
22045
22334
|
var platforms = /* @__PURE__ */ new Map([
|
|
22046
22335
|
["linux", linuxPlatform],
|
|
22047
22336
|
["darwin", macosPlatform],
|
|
22048
|
-
["win32",
|
|
22337
|
+
["win32", windowsPlatform]
|
|
22049
22338
|
]);
|
|
22050
22339
|
function platformSupportFor(platform) {
|
|
22051
22340
|
return platforms.get(platform) ?? fallbackPlatform;
|
|
@@ -22084,14 +22373,6 @@ var ResolvedExecutable = class {
|
|
|
22084
22373
|
this.path = identity2.realPath;
|
|
22085
22374
|
}
|
|
22086
22375
|
};
|
|
22087
|
-
var ProcessExecutionError = class extends Error {
|
|
22088
|
-
code;
|
|
22089
|
-
constructor(code, message, options = {}) {
|
|
22090
|
-
super(message, options);
|
|
22091
|
-
this.code = code;
|
|
22092
|
-
this.name = "ProcessExecutionError";
|
|
22093
|
-
}
|
|
22094
|
-
};
|
|
22095
22376
|
var ProcessResult = class {
|
|
22096
22377
|
stderr;
|
|
22097
22378
|
stdout;
|
|
@@ -22100,28 +22381,14 @@ var ProcessResult = class {
|
|
|
22100
22381
|
this.stdout = stdout;
|
|
22101
22382
|
}
|
|
22102
22383
|
};
|
|
22103
|
-
function executableExtensions(executableName, environment, platform) {
|
|
22104
|
-
if (platform !== "win32") {
|
|
22105
|
-
return [""];
|
|
22106
|
-
}
|
|
22107
|
-
if (/\.[a-zA-Z0-9]+$/.test(executableName)) {
|
|
22108
|
-
return [""];
|
|
22109
|
-
}
|
|
22110
|
-
const configured = environment["PATHEXT"] ?? ".COM;.EXE;.BAT;.CMD";
|
|
22111
|
-
const extensions = configured.split(";").map((extension) => extension.trim()).filter((extension) => extension.length > 0).map((extension) => extension.startsWith(".") ? extension : `.${extension}`);
|
|
22112
|
-
return extensions.length > 0 ? extensions : [".EXE"];
|
|
22113
|
-
}
|
|
22114
22384
|
async function resolveExecutablePath(requestedPath2, platform = process.platform) {
|
|
22115
|
-
const absoluteRequestedPath =
|
|
22385
|
+
const absoluteRequestedPath = resolve2(requestedPath2);
|
|
22116
22386
|
try {
|
|
22117
|
-
const resolvedPath = await
|
|
22387
|
+
const resolvedPath = await platformSupportFor(platform).resolveExecutableTarget(absoluteRequestedPath);
|
|
22118
22388
|
const metadata = await stat2(resolvedPath);
|
|
22119
22389
|
if (!metadata.isFile()) {
|
|
22120
22390
|
return null;
|
|
22121
22391
|
}
|
|
22122
|
-
if (platform !== "win32") {
|
|
22123
|
-
await access2(resolvedPath, constants2.X_OK);
|
|
22124
|
-
}
|
|
22125
22392
|
return new ResolvedExecutable(
|
|
22126
22393
|
new ExecutableIdentity(
|
|
22127
22394
|
absoluteRequestedPath,
|
|
@@ -22137,15 +22404,16 @@ async function resolveExecutablePath(requestedPath2, platform = process.platform
|
|
|
22137
22404
|
}
|
|
22138
22405
|
}
|
|
22139
22406
|
async function findExecutableOnPath(executableName, environment, platform = process.platform) {
|
|
22140
|
-
const
|
|
22141
|
-
const
|
|
22142
|
-
const
|
|
22407
|
+
const support = platformSupportFor(platform);
|
|
22408
|
+
const encodedPath = support.environmentValue(environment, "PATH") ?? "";
|
|
22409
|
+
const separator = support.pathDelimiter;
|
|
22410
|
+
const extensions = support.executableExtensions(executableName, environment);
|
|
22143
22411
|
for (const entry of encodedPath.split(separator)) {
|
|
22144
22412
|
if (entry.length === 0) {
|
|
22145
22413
|
continue;
|
|
22146
22414
|
}
|
|
22147
22415
|
for (const extension of extensions) {
|
|
22148
|
-
const requestedPath2 =
|
|
22416
|
+
const requestedPath2 = resolve2(join5(entry, `${executableName}${extension}`));
|
|
22149
22417
|
const executable = await resolveExecutablePath(requestedPath2, platform);
|
|
22150
22418
|
if (executable !== null) {
|
|
22151
22419
|
return executable;
|
|
@@ -22166,7 +22434,7 @@ function appendBounded(chunks, chunk, currentBytes, limitBytes) {
|
|
|
22166
22434
|
chunks.push(chunk);
|
|
22167
22435
|
return nextBytes;
|
|
22168
22436
|
}
|
|
22169
|
-
function
|
|
22437
|
+
function readProcessTable2() {
|
|
22170
22438
|
return hostPlatform.readProcessTable();
|
|
22171
22439
|
}
|
|
22172
22440
|
function selectProcessTree(entries, rootProcessId) {
|
|
@@ -22201,38 +22469,14 @@ function mergeProcessTrees(captured, current) {
|
|
|
22201
22469
|
return [...processes.values()];
|
|
22202
22470
|
}
|
|
22203
22471
|
async function captureProcessTree(child2) {
|
|
22204
|
-
if (
|
|
22472
|
+
if (child2.pid === void 0) {
|
|
22205
22473
|
return [];
|
|
22206
22474
|
}
|
|
22207
22475
|
const entries = hostPlatform.readProcessTableSynchronously();
|
|
22208
22476
|
if (entries.length > 0) {
|
|
22209
22477
|
return selectProcessTree(entries, child2.pid);
|
|
22210
22478
|
}
|
|
22211
|
-
return selectProcessTree(await
|
|
22212
|
-
}
|
|
22213
|
-
function signalCapturedProcessGroups(processes, rootProcessId, signal) {
|
|
22214
|
-
const processIds = new Set(processes.map((identity2) => identity2.processId));
|
|
22215
|
-
const signalledGroups = /* @__PURE__ */ new Set();
|
|
22216
|
-
for (const identity2 of processes) {
|
|
22217
|
-
const isRootProcessGroup = identity2.processGroupId === rootProcessId;
|
|
22218
|
-
if (!isRootProcessGroup && !processIds.has(identity2.processGroupId) || signalledGroups.has(identity2.processGroupId)) {
|
|
22219
|
-
continue;
|
|
22220
|
-
}
|
|
22221
|
-
try {
|
|
22222
|
-
process.kill(-identity2.processGroupId, signal);
|
|
22223
|
-
signalledGroups.add(identity2.processGroupId);
|
|
22224
|
-
} catch {
|
|
22225
|
-
}
|
|
22226
|
-
}
|
|
22227
|
-
for (const identity2 of processes) {
|
|
22228
|
-
if (identity2.processId === rootProcessId || identity2.processGroupId === rootProcessId || signalledGroups.has(identity2.processGroupId)) {
|
|
22229
|
-
continue;
|
|
22230
|
-
}
|
|
22231
|
-
try {
|
|
22232
|
-
process.kill(identity2.processId, signal);
|
|
22233
|
-
} catch {
|
|
22234
|
-
}
|
|
22235
|
-
}
|
|
22479
|
+
return selectProcessTree(await readProcessTable2(), child2.pid);
|
|
22236
22480
|
}
|
|
22237
22481
|
async function waitForCapturedProcessesExit(processes, rootProcessId) {
|
|
22238
22482
|
const processIds = processes.map((identity2) => identity2.processId).filter((processId) => processId !== rootProcessId);
|
|
@@ -22240,36 +22484,10 @@ async function waitForCapturedProcessesExit(processes, rootProcessId) {
|
|
|
22240
22484
|
if (processIds.every((processId) => !hostPlatform.processExists(processId))) {
|
|
22241
22485
|
return true;
|
|
22242
22486
|
}
|
|
22243
|
-
await
|
|
22487
|
+
await readProcessTable2();
|
|
22244
22488
|
}
|
|
22245
22489
|
return processIds.every((processId) => !hostPlatform.processExists(processId));
|
|
22246
22490
|
}
|
|
22247
|
-
function terminateProcess(child2) {
|
|
22248
|
-
if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
|
|
22249
|
-
return;
|
|
22250
|
-
}
|
|
22251
|
-
if (process.platform !== "win32") {
|
|
22252
|
-
try {
|
|
22253
|
-
process.kill(-child2.pid, "SIGTERM");
|
|
22254
|
-
return;
|
|
22255
|
-
} catch {
|
|
22256
|
-
}
|
|
22257
|
-
}
|
|
22258
|
-
child2.kill("SIGTERM");
|
|
22259
|
-
}
|
|
22260
|
-
function forceTerminateProcess(child2) {
|
|
22261
|
-
if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
|
|
22262
|
-
return;
|
|
22263
|
-
}
|
|
22264
|
-
if (process.platform !== "win32") {
|
|
22265
|
-
try {
|
|
22266
|
-
process.kill(-child2.pid, "SIGKILL");
|
|
22267
|
-
return;
|
|
22268
|
-
} catch {
|
|
22269
|
-
}
|
|
22270
|
-
}
|
|
22271
|
-
child2.kill("SIGKILL");
|
|
22272
|
-
}
|
|
22273
22491
|
async function stopProcessTree(child2, capturedProcesses = []) {
|
|
22274
22492
|
const childProcessId = child2.pid;
|
|
22275
22493
|
if (childProcessId === void 0) {
|
|
@@ -22280,8 +22498,8 @@ async function stopProcessTree(child2, capturedProcesses = []) {
|
|
|
22280
22498
|
if (childExited && processes.length === 0) {
|
|
22281
22499
|
return;
|
|
22282
22500
|
}
|
|
22283
|
-
|
|
22284
|
-
terminateProcess(child2);
|
|
22501
|
+
hostPlatform.signalCapturedProcesses(processes, childProcessId, GRACEFUL_STOP_SIGNAL);
|
|
22502
|
+
hostPlatform.terminateProcess(child2, "SIGTERM");
|
|
22285
22503
|
const [exitedAfterTermination, descendantsExitedAfterTermination] = await Promise.all([
|
|
22286
22504
|
waitForProcessExit(child2, PROCESS_GRACEFUL_STOP_TIMEOUT_MILLISECONDS),
|
|
22287
22505
|
waitForCapturedProcessesExit(processes, childProcessId)
|
|
@@ -22289,8 +22507,8 @@ async function stopProcessTree(child2, capturedProcesses = []) {
|
|
|
22289
22507
|
if (exitedAfterTermination && descendantsExitedAfterTermination) {
|
|
22290
22508
|
return;
|
|
22291
22509
|
}
|
|
22292
|
-
|
|
22293
|
-
|
|
22510
|
+
hostPlatform.signalCapturedProcesses(processes, childProcessId, FORCED_STOP_SIGNAL);
|
|
22511
|
+
hostPlatform.terminateProcess(child2, "SIGKILL");
|
|
22294
22512
|
const [exitedAfterForce, descendantsExitedAfterForce] = await Promise.all([
|
|
22295
22513
|
waitForProcessExit(child2, PROCESS_FORCED_STOP_TIMEOUT_MILLISECONDS),
|
|
22296
22514
|
waitForCapturedProcessesExit(processes, childProcessId)
|
|
@@ -22325,9 +22543,10 @@ function waitForProcessExit(child2, timeoutMilliseconds) {
|
|
|
22325
22543
|
async function runBoundedProcess(options) {
|
|
22326
22544
|
options.signal.throwIfAborted();
|
|
22327
22545
|
const outputLimitBytes = options.outputLimitBytes ?? DEFAULT_OUTPUT_LIMIT_BYTES;
|
|
22328
|
-
const
|
|
22546
|
+
const launch = executableLaunch2(options.command, options.arguments);
|
|
22547
|
+
const child2 = spawn(launch.command, [...launch.arguments], {
|
|
22329
22548
|
cwd: options.cwd,
|
|
22330
|
-
|
|
22549
|
+
...hostPlatform.spawnOptions,
|
|
22331
22550
|
env: { ...options.environment },
|
|
22332
22551
|
shell: false,
|
|
22333
22552
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -22436,6 +22655,10 @@ async function runBoundedProcess(options) {
|
|
|
22436
22655
|
}
|
|
22437
22656
|
}
|
|
22438
22657
|
}
|
|
22658
|
+
function executableLaunch2(command, args) {
|
|
22659
|
+
return hostPlatform.executableLaunch(command, args);
|
|
22660
|
+
}
|
|
22661
|
+
var platformSpawnOptions = hostPlatform.spawnOptions;
|
|
22439
22662
|
|
|
22440
22663
|
// src/agent-catalog/local-agent.ts
|
|
22441
22664
|
function readTrustedIdentity(path2) {
|
|
@@ -22728,8 +22951,8 @@ var LocalAgentInventory = class {
|
|
|
22728
22951
|
};
|
|
22729
22952
|
|
|
22730
22953
|
// src/agent-installation/managed-npm-package.ts
|
|
22731
|
-
import { mkdir, mkdtemp, open as open2, realpath as
|
|
22732
|
-
import { delimiter, dirname, isAbsolute as isAbsolute2, join as
|
|
22954
|
+
import { mkdir, mkdtemp, open as open2, realpath as realpath4, rename, rm, stat as stat3 } from "node:fs/promises";
|
|
22955
|
+
import { delimiter, dirname as dirname2, isAbsolute as isAbsolute2, join as join6, relative, sep } from "node:path";
|
|
22733
22956
|
var INSTALL_TIMEOUT_MILLISECONDS = 5 * 60 * 1e3;
|
|
22734
22957
|
var PACKAGE_METADATA_LIMIT_BYTES = 64 * 1024;
|
|
22735
22958
|
var PACKAGE_LOCK_LIMIT_BYTES = 8 * 1024 * 1024;
|
|
@@ -22780,7 +23003,7 @@ function isRecord3(value) {
|
|
|
22780
23003
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22781
23004
|
}
|
|
22782
23005
|
function packagePath(root, packageName) {
|
|
22783
|
-
return
|
|
23006
|
+
return join6(root, "node_modules", ...packageName.split("/"));
|
|
22784
23007
|
}
|
|
22785
23008
|
function isContainedPath(root, candidate) {
|
|
22786
23009
|
const difference = relative(root, candidate);
|
|
@@ -22885,14 +23108,14 @@ function verifyPackageLockEntry(lock, definition, verifyDependencyClosure) {
|
|
|
22885
23108
|
}
|
|
22886
23109
|
}
|
|
22887
23110
|
async function verifyRequiredDependency(rootPath, lock, definition) {
|
|
22888
|
-
const dependencyRoot = await
|
|
23111
|
+
const dependencyRoot = await realpath4(packagePath(rootPath, definition.packageName));
|
|
22889
23112
|
if (!isContainedPath(rootPath, dependencyRoot)) {
|
|
22890
23113
|
throw new ManagedNpmPackageError(
|
|
22891
23114
|
"managed_package_verification_failed",
|
|
22892
23115
|
"The required managed npm dependency escaped its private cache"
|
|
22893
23116
|
);
|
|
22894
23117
|
}
|
|
22895
|
-
const metadata = await readJsonRecord(
|
|
23118
|
+
const metadata = await readJsonRecord(join6(dependencyRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
|
|
22896
23119
|
if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
|
|
22897
23120
|
throw new ManagedNpmPackageError(
|
|
22898
23121
|
"managed_package_verification_failed",
|
|
@@ -22914,15 +23137,15 @@ async function validateManagedNpmPackage(root, definition) {
|
|
|
22914
23137
|
}
|
|
22915
23138
|
}
|
|
22916
23139
|
async function validateManagedNpmPackageContents(root, definition) {
|
|
22917
|
-
const rootPath = await
|
|
22918
|
-
const packageRoot = await
|
|
23140
|
+
const rootPath = await realpath4(root);
|
|
23141
|
+
const packageRoot = await realpath4(packagePath(rootPath, definition.packageName));
|
|
22919
23142
|
if (!isContainedPath(rootPath, packageRoot)) {
|
|
22920
23143
|
throw new ManagedNpmPackageError(
|
|
22921
23144
|
"managed_package_verification_failed",
|
|
22922
23145
|
"The managed npm package escaped its private cache"
|
|
22923
23146
|
);
|
|
22924
23147
|
}
|
|
22925
|
-
const metadata = await readJsonRecord(
|
|
23148
|
+
const metadata = await readJsonRecord(join6(packageRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
|
|
22926
23149
|
if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
|
|
22927
23150
|
throw new ManagedNpmPackageError(
|
|
22928
23151
|
"managed_package_verification_failed",
|
|
@@ -22930,14 +23153,14 @@ async function validateManagedNpmPackageContents(root, definition) {
|
|
|
22930
23153
|
);
|
|
22931
23154
|
}
|
|
22932
23155
|
if (definition instanceof SriManagedNpmPackageDefinition) {
|
|
22933
|
-
const lock = await readJsonRecord(
|
|
23156
|
+
const lock = await readJsonRecord(join6(rootPath, "package-lock.json"), PACKAGE_LOCK_LIMIT_BYTES);
|
|
22934
23157
|
verifyPackageLockEntry(lock, definition, definition.verifyDependencyClosure);
|
|
22935
23158
|
for (const dependency of definition.requiredDependencies) {
|
|
22936
23159
|
await verifyRequiredDependency(rootPath, lock, dependency);
|
|
22937
23160
|
}
|
|
22938
23161
|
}
|
|
22939
23162
|
const declaredBin = readBinPath(metadata, definition.executableName);
|
|
22940
|
-
const executable = await resolveExecutablePath(
|
|
23163
|
+
const executable = await resolveExecutablePath(join6(packageRoot, declaredBin));
|
|
22941
23164
|
if (executable === null || !isContainedPath(rootPath, executable.path)) {
|
|
22942
23165
|
throw new ManagedNpmPackageError(
|
|
22943
23166
|
"managed_package_verification_failed",
|
|
@@ -22959,9 +23182,9 @@ var ManagedNpmPackageInstaller = class {
|
|
|
22959
23182
|
throw error62;
|
|
22960
23183
|
}
|
|
22961
23184
|
}
|
|
22962
|
-
const parent =
|
|
23185
|
+
const parent = dirname2(root);
|
|
22963
23186
|
await mkdir(parent, { mode: 448, recursive: true });
|
|
22964
|
-
const staging = await mkdtemp(
|
|
23187
|
+
const staging = await mkdtemp(join6(parent, `.${definition.version}.staging-`));
|
|
22965
23188
|
try {
|
|
22966
23189
|
const npm = await findExecutableOnPath(process.platform === "win32" ? "npm.cmd" : "npm", environment);
|
|
22967
23190
|
if (npm === null) {
|
|
@@ -22987,14 +23210,14 @@ var ManagedNpmPackageInstaller = class {
|
|
|
22987
23210
|
`${definition.packageName}@${definition.version}`
|
|
22988
23211
|
);
|
|
22989
23212
|
const installEnvironment = {
|
|
22990
|
-
HOME:
|
|
23213
|
+
HOME: join6(staging, "home"),
|
|
22991
23214
|
NPM_CONFIG_AUDIT: "false",
|
|
22992
|
-
NPM_CONFIG_CACHE:
|
|
23215
|
+
NPM_CONFIG_CACHE: join6(staging, ".npm-cache"),
|
|
22993
23216
|
NPM_CONFIG_FUND: "false",
|
|
22994
23217
|
NPM_CONFIG_IGNORE_SCRIPTS: "true",
|
|
22995
23218
|
NPM_CONFIG_PACKAGE_LOCK: "true",
|
|
22996
23219
|
NPM_CONFIG_REGISTRY: "https://registry.npmjs.org/",
|
|
22997
|
-
PATH: `${
|
|
23220
|
+
PATH: `${dirname2(process.execPath)}${delimiter}/usr/bin${delimiter}/bin`
|
|
22998
23221
|
};
|
|
22999
23222
|
if (definition.includeOptionalDependencies) {
|
|
23000
23223
|
installEnvironment["NPM_CONFIG_INCLUDE"] = "optional";
|
|
@@ -23011,8 +23234,8 @@ var ManagedNpmPackageInstaller = class {
|
|
|
23011
23234
|
timeoutMilliseconds: INSTALL_TIMEOUT_MILLISECONDS
|
|
23012
23235
|
});
|
|
23013
23236
|
await Promise.all([
|
|
23014
|
-
rm(
|
|
23015
|
-
rm(
|
|
23237
|
+
rm(join6(staging, ".npm-cache"), { force: true, recursive: true }),
|
|
23238
|
+
rm(join6(staging, "home"), { force: true, recursive: true })
|
|
23016
23239
|
]);
|
|
23017
23240
|
await validateManagedNpmPackage(staging, definition);
|
|
23018
23241
|
try {
|
|
@@ -23048,7 +23271,7 @@ var ManagedNpmPackageInstaller = class {
|
|
|
23048
23271
|
};
|
|
23049
23272
|
|
|
23050
23273
|
// src/agent-catalog/agent-specification.ts
|
|
23051
|
-
import { join as
|
|
23274
|
+
import { join as join7 } from "node:path";
|
|
23052
23275
|
|
|
23053
23276
|
// src/agent-catalog/version-output.ts
|
|
23054
23277
|
function normalizeVersionOutput(output2) {
|
|
@@ -23071,7 +23294,7 @@ var LocalAgentSpecification = class {
|
|
|
23071
23294
|
resolveManagedAgent = async (stateDirectory, platform, signal) => {
|
|
23072
23295
|
signal.throwIfAborted();
|
|
23073
23296
|
const executable = await resolveExecutablePath(
|
|
23074
|
-
|
|
23297
|
+
join7(stateDirectory, ...this.managedAgentExecutablePath),
|
|
23075
23298
|
platform
|
|
23076
23299
|
);
|
|
23077
23300
|
signal.throwIfAborted();
|
|
@@ -23553,9 +23776,10 @@ var CodexAppServerClient = class {
|
|
|
23553
23776
|
#pendingFragments = [];
|
|
23554
23777
|
constructor(options) {
|
|
23555
23778
|
this.#handlers = options.handlers;
|
|
23556
|
-
|
|
23779
|
+
const launch = executableLaunch2(options.command, ["app-server"]);
|
|
23780
|
+
this.#child = spawn2(launch.command, [...launch.arguments], {
|
|
23557
23781
|
cwd: options.cwd,
|
|
23558
|
-
|
|
23782
|
+
...platformSpawnOptions,
|
|
23559
23783
|
env: { ...process.env, ...options.environment },
|
|
23560
23784
|
shell: false,
|
|
23561
23785
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -25212,7 +25436,7 @@ var AgentProbeError = class extends Error {
|
|
|
25212
25436
|
};
|
|
25213
25437
|
|
|
25214
25438
|
// src/agent-catalog/agents/resolve-user-local-executable.ts
|
|
25215
|
-
import { isAbsolute as isAbsolute4, join as
|
|
25439
|
+
import { isAbsolute as isAbsolute4, join as join8 } from "node:path";
|
|
25216
25440
|
async function resolveUserLocalExecutable(executableName, context) {
|
|
25217
25441
|
context.signal.throwIfAborted();
|
|
25218
25442
|
const platform = context.platform ?? process.platform;
|
|
@@ -25220,7 +25444,7 @@ async function resolveUserLocalExecutable(executableName, context) {
|
|
|
25220
25444
|
if (platform === "win32" || homeDirectory === void 0 || !isAbsolute4(homeDirectory)) {
|
|
25221
25445
|
return [];
|
|
25222
25446
|
}
|
|
25223
|
-
const executable = await resolveExecutablePath(
|
|
25447
|
+
const executable = await resolveExecutablePath(join8(homeDirectory, ".local", "bin", executableName), platform);
|
|
25224
25448
|
context.signal.throwIfAborted();
|
|
25225
25449
|
return executable === null ? [] : [executable];
|
|
25226
25450
|
}
|
|
@@ -25309,8 +25533,8 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25309
25533
|
};
|
|
25310
25534
|
|
|
25311
25535
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
25312
|
-
import { mkdir as mkdir2, realpath as
|
|
25313
|
-
import { isAbsolute as isAbsolute5, join as
|
|
25536
|
+
import { mkdir as mkdir2, realpath as realpath5, stat as stat4, writeFile } from "node:fs/promises";
|
|
25537
|
+
import { isAbsolute as isAbsolute5, join as join10, normalize } from "node:path";
|
|
25314
25538
|
|
|
25315
25539
|
// src/agent-installation/deepseek-managed-package.ts
|
|
25316
25540
|
var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
|
|
@@ -25328,13 +25552,13 @@ var DEEPSEEK_HARNESS_PACKAGE = new DeepSeekHarnessManagedPackage(
|
|
|
25328
25552
|
|
|
25329
25553
|
// src/storage/state-directory.ts
|
|
25330
25554
|
import { homedir } from "node:os";
|
|
25331
|
-
import { join as
|
|
25555
|
+
import { join as join9, resolve as resolve3 } from "node:path";
|
|
25332
25556
|
function readStateDirectory(environment = process.env) {
|
|
25333
25557
|
const configured = environment["MOBIUS_STATE_DIRECTORY"]?.trim();
|
|
25334
25558
|
if (configured !== void 0 && configured.length > 0) {
|
|
25335
|
-
return
|
|
25559
|
+
return resolve3(configured);
|
|
25336
25560
|
}
|
|
25337
|
-
return
|
|
25561
|
+
return join9(homedir(), ".mobius");
|
|
25338
25562
|
}
|
|
25339
25563
|
|
|
25340
25564
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
@@ -25352,13 +25576,13 @@ async function prepareAgentHome(path2, imagePrompts) {
|
|
|
25352
25576
|
if (imagePrompts) {
|
|
25353
25577
|
await mkdir2(path2, { mode: 448, recursive: true });
|
|
25354
25578
|
}
|
|
25355
|
-
const resolved = await
|
|
25579
|
+
const resolved = await realpath5(path2);
|
|
25356
25580
|
const metadata = await stat4(resolved);
|
|
25357
25581
|
if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
|
|
25358
25582
|
throw new Error("Agent home is not a user-owned directory");
|
|
25359
25583
|
}
|
|
25360
25584
|
if (imagePrompts) {
|
|
25361
|
-
await writeFile(
|
|
25585
|
+
await writeFile(join10(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
|
|
25362
25586
|
mode: 384
|
|
25363
25587
|
});
|
|
25364
25588
|
}
|
|
@@ -25406,7 +25630,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25406
25630
|
context.signal
|
|
25407
25631
|
);
|
|
25408
25632
|
if (managed.path === agent.path) {
|
|
25409
|
-
selectedHome =
|
|
25633
|
+
selectedHome = join10(readStateDirectory(context.environment), "agents", this.id, "home");
|
|
25410
25634
|
managedHome = true;
|
|
25411
25635
|
}
|
|
25412
25636
|
} catch {
|
|
@@ -25422,7 +25646,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25422
25646
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
25423
25647
|
signal.throwIfAborted();
|
|
25424
25648
|
const executable = await validateManagedNpmPackage(
|
|
25425
|
-
|
|
25649
|
+
join10(stateDirectory, "agents", this.id, DEEPSEEK_HARNESS_PACKAGE.version),
|
|
25426
25650
|
DEEPSEEK_HARNESS_PACKAGE
|
|
25427
25651
|
);
|
|
25428
25652
|
signal.throwIfAborted();
|
|
@@ -25476,8 +25700,8 @@ var GeminiCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25476
25700
|
};
|
|
25477
25701
|
|
|
25478
25702
|
// src/agent-catalog/agents/grok-build-agent.ts
|
|
25479
|
-
import { realpath as
|
|
25480
|
-
import { isAbsolute as isAbsolute6, join as
|
|
25703
|
+
import { realpath as realpath6 } from "node:fs/promises";
|
|
25704
|
+
import { isAbsolute as isAbsolute6, join as join11, relative as relative2, sep as sep2 } from "node:path";
|
|
25481
25705
|
import {
|
|
25482
25706
|
RequestError
|
|
25483
25707
|
} from "@agentclientprotocol/sdk";
|
|
@@ -25547,8 +25771,8 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25547
25771
|
);
|
|
25548
25772
|
if (managed.path === agent.path) {
|
|
25549
25773
|
return Object.freeze({
|
|
25550
|
-
GROK_HOME: await
|
|
25551
|
-
|
|
25774
|
+
GROK_HOME: await realpath6(
|
|
25775
|
+
join11(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION, "home")
|
|
25552
25776
|
)
|
|
25553
25777
|
});
|
|
25554
25778
|
}
|
|
@@ -25559,9 +25783,9 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25559
25783
|
};
|
|
25560
25784
|
resolveManagedAgent = async (stateDirectory, platform, signal) => {
|
|
25561
25785
|
signal.throwIfAborted();
|
|
25562
|
-
const versionRoot = await
|
|
25563
|
-
await validateManagedNpmPackage(
|
|
25564
|
-
const executable = await resolveExecutablePath(
|
|
25786
|
+
const versionRoot = await realpath6(join11(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION));
|
|
25787
|
+
await validateManagedNpmPackage(join11(versionRoot, "package"), grokBuildManagedPackage(platform, process.arch));
|
|
25788
|
+
const executable = await resolveExecutablePath(join11(versionRoot, "home", "bin", "grok"), platform);
|
|
25565
25789
|
signal.throwIfAborted();
|
|
25566
25790
|
if (executable === null || !isContainedPath2(versionRoot, executable.path)) {
|
|
25567
25791
|
throw new AgentProbeError("managed_agent_invalid", "The managed Grok Build executable is invalid");
|
|
@@ -25661,13 +25885,13 @@ var OhMyPiAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25661
25885
|
};
|
|
25662
25886
|
|
|
25663
25887
|
// src/agent-catalog/agents/opencode-agent.ts
|
|
25664
|
-
import { join as
|
|
25888
|
+
import { join as join13 } from "node:path";
|
|
25665
25889
|
|
|
25666
25890
|
// src/agent-installation/managed-agent-archive.ts
|
|
25667
25891
|
import { createHash } from "node:crypto";
|
|
25668
25892
|
import { createReadStream } from "node:fs";
|
|
25669
|
-
import { chmod, copyFile, mkdir as mkdir3, mkdtemp as mkdtemp2, open as open3, realpath as
|
|
25670
|
-
import { delimiter as delimiter2, dirname as
|
|
25893
|
+
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";
|
|
25894
|
+
import { delimiter as delimiter2, dirname as dirname3, isAbsolute as isAbsolute7, join as join12, relative as relative3, sep as sep3 } from "node:path";
|
|
25671
25895
|
|
|
25672
25896
|
// src/agent-installation/verified-download.ts
|
|
25673
25897
|
import { fetch } from "undici";
|
|
@@ -25847,16 +26071,16 @@ async function readManifest(path2) {
|
|
|
25847
26071
|
}
|
|
25848
26072
|
async function validateManagedAgentArchive(root, definition, signal) {
|
|
25849
26073
|
try {
|
|
25850
|
-
const rootPath = await
|
|
26074
|
+
const rootPath = await realpath7(root);
|
|
25851
26075
|
const rootMetadata = await stat5(rootPath);
|
|
25852
26076
|
if (!rootMetadata.isDirectory() || typeof process.getuid === "function" && rootMetadata.uid !== process.getuid()) {
|
|
25853
26077
|
throw new Error("Managed Agent root is not user-owned");
|
|
25854
26078
|
}
|
|
25855
|
-
const manifest = await readManifest(
|
|
26079
|
+
const manifest = await readManifest(join12(rootPath, "archive.json"));
|
|
25856
26080
|
if (manifest["archiveSha256"] !== definition.archiveSha256 || manifest["archiveUrl"] !== definition.archiveUrl.toString() || manifest["version"] !== definition.version || typeof manifest["executableSha256"] !== "string") {
|
|
25857
26081
|
throw new Error("Managed Agent archive identity is invalid");
|
|
25858
26082
|
}
|
|
25859
|
-
const executable = await resolveExecutablePath(
|
|
26083
|
+
const executable = await resolveExecutablePath(join12(rootPath, "bin", definition.executableName));
|
|
25860
26084
|
if (executable === null || !isContainedPath3(rootPath, executable.path) || await hashFile(executable.path, signal) !== manifest["executableSha256"]) {
|
|
25861
26085
|
throw new Error("Managed Agent executable is invalid");
|
|
25862
26086
|
}
|
|
@@ -26022,7 +26246,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
26022
26246
|
return Object.freeze(environment);
|
|
26023
26247
|
};
|
|
26024
26248
|
resolveManagedAgent = async (stateDirectory, platform, signal) => await validateManagedAgentArchive(
|
|
26025
|
-
|
|
26249
|
+
join13(stateDirectory, "agents", this.id, OPENCODE_MANAGED_VERSION),
|
|
26026
26250
|
openCodeManagedArchive(platform, process.arch),
|
|
26027
26251
|
signal
|
|
26028
26252
|
);
|
|
@@ -26040,7 +26264,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
26040
26264
|
};
|
|
26041
26265
|
|
|
26042
26266
|
// src/agent-catalog/agents/pi-agent.ts
|
|
26043
|
-
import { join as
|
|
26267
|
+
import { join as join14 } from "node:path";
|
|
26044
26268
|
import {
|
|
26045
26269
|
methods as methods4
|
|
26046
26270
|
} from "@agentclientprotocol/sdk";
|
|
@@ -26099,7 +26323,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
26099
26323
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
26100
26324
|
signal.throwIfAborted();
|
|
26101
26325
|
const executable = await validateManagedNpmPackage(
|
|
26102
|
-
|
|
26326
|
+
join14(stateDirectory, "agents", this.id, PI_AGENT_PACKAGE.version),
|
|
26103
26327
|
PI_AGENT_PACKAGE
|
|
26104
26328
|
);
|
|
26105
26329
|
signal.throwIfAborted();
|
|
@@ -26137,7 +26361,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
26137
26361
|
};
|
|
26138
26362
|
|
|
26139
26363
|
// src/agent-catalog/agents/workbuddy-agent.ts
|
|
26140
|
-
import { join as
|
|
26364
|
+
import { join as join15 } from "node:path";
|
|
26141
26365
|
|
|
26142
26366
|
// src/agent-installation/workbuddy-managed-package.ts
|
|
26143
26367
|
var WORKBUDDY_MANAGED_VERSION = "2.146.0";
|
|
@@ -26183,7 +26407,7 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
26183
26407
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
26184
26408
|
signal.throwIfAborted();
|
|
26185
26409
|
const executable = await validateManagedNpmPackage(
|
|
26186
|
-
|
|
26410
|
+
join15(stateDirectory, "agents", this.id, WORKBUDDY_MANAGED_VERSION),
|
|
26187
26411
|
WORKBUDDY_MANAGED_PACKAGE
|
|
26188
26412
|
);
|
|
26189
26413
|
signal.throwIfAborted();
|
|
@@ -26420,9 +26644,10 @@ async function probeAcpReadiness(specification, agent, environment, defaultWorks
|
|
|
26420
26644
|
signal.removeEventListener("abort", abort);
|
|
26421
26645
|
}
|
|
26422
26646
|
}
|
|
26423
|
-
const
|
|
26647
|
+
const launch = executableLaunch2(agent.adapterPath, agent.arguments);
|
|
26648
|
+
const child2 = spawn3(launch.command, [...launch.arguments], {
|
|
26424
26649
|
cwd: defaultWorkspace,
|
|
26425
|
-
|
|
26650
|
+
...platformSpawnOptions,
|
|
26426
26651
|
env: { ...environment, ...agent.environment },
|
|
26427
26652
|
shell: false,
|
|
26428
26653
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -26555,10 +26780,10 @@ function isAgentVersionSupported(reportedVersion, minimumSupportedVersion) {
|
|
|
26555
26780
|
}
|
|
26556
26781
|
|
|
26557
26782
|
// src/agent-catalog/executable-discovery.ts
|
|
26558
|
-
import { isAbsolute as isAbsolute8, join as
|
|
26783
|
+
import { isAbsolute as isAbsolute8, join as join17 } from "node:path";
|
|
26559
26784
|
|
|
26560
26785
|
// src/agent-installation/managed-adapter-installer.ts
|
|
26561
|
-
import { join as
|
|
26786
|
+
import { join as join16 } from "node:path";
|
|
26562
26787
|
var ManagedAdapterInstallError = class extends Error {
|
|
26563
26788
|
code;
|
|
26564
26789
|
constructor(code, message, options = {}) {
|
|
@@ -26615,7 +26840,7 @@ var ManagedAdapterInstaller = class {
|
|
|
26615
26840
|
this.#stateDirectory = options.stateDirectory;
|
|
26616
26841
|
}
|
|
26617
26842
|
install = async (specification, signal) => {
|
|
26618
|
-
const root =
|
|
26843
|
+
const root = join16(this.#stateDirectory, "adapters", specification.id, specification.adapterVersion);
|
|
26619
26844
|
try {
|
|
26620
26845
|
return await this.#npmInstaller.install(
|
|
26621
26846
|
root,
|
|
@@ -26649,7 +26874,7 @@ async function resolveManagedAdapterExecutable(specification, context) {
|
|
|
26649
26874
|
let managed;
|
|
26650
26875
|
try {
|
|
26651
26876
|
managed = await validateManagedAdapter(
|
|
26652
|
-
|
|
26877
|
+
join17(readStateDirectory(context.environment), "adapters", specification.id, specification.adapterVersion),
|
|
26653
26878
|
specification
|
|
26654
26879
|
);
|
|
26655
26880
|
} catch {
|
|
@@ -27074,16 +27299,16 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
27074
27299
|
}
|
|
27075
27300
|
|
|
27076
27301
|
// src/config.ts
|
|
27077
|
-
import { join as
|
|
27302
|
+
import { join as join18, resolve as resolve4 } from "node:path";
|
|
27078
27303
|
function loadDefaultWorkspace(environment = process.env) {
|
|
27079
27304
|
const { MOBIUS_DEFAULT_WORKSPACE: configuredWorkspace } = environment;
|
|
27080
|
-
return configuredWorkspace ??
|
|
27305
|
+
return configuredWorkspace ?? join18(readStateDirectory(environment), "workspace");
|
|
27081
27306
|
}
|
|
27082
27307
|
var DaemonLocalContext = class {
|
|
27083
27308
|
environment;
|
|
27084
27309
|
stateDirectory;
|
|
27085
27310
|
constructor(stateDirectory, environment = process.env) {
|
|
27086
|
-
this.stateDirectory =
|
|
27311
|
+
this.stateDirectory = resolve4(stateDirectory);
|
|
27087
27312
|
this.environment = Object.freeze({ ...environment, MOBIUS_STATE_DIRECTORY: this.stateDirectory });
|
|
27088
27313
|
}
|
|
27089
27314
|
};
|
|
@@ -27197,7 +27422,7 @@ var AuditStore = class {
|
|
|
27197
27422
|
|
|
27198
27423
|
// src/run-daemon.ts
|
|
27199
27424
|
import { createHash as createHash7, randomUUID as randomUUID8 } from "node:crypto";
|
|
27200
|
-
import { join as
|
|
27425
|
+
import { join as join22 } from "node:path";
|
|
27201
27426
|
import { styleText } from "node:util";
|
|
27202
27427
|
|
|
27203
27428
|
// src/acp/active-executions.ts
|
|
@@ -27288,7 +27513,7 @@ import {
|
|
|
27288
27513
|
} from "@agentclientprotocol/sdk";
|
|
27289
27514
|
|
|
27290
27515
|
// src/authorization/local-raster.ts
|
|
27291
|
-
import { open as open4, readFile as
|
|
27516
|
+
import { open as open4, readFile as readFile3, realpath as realpath8, stat as stat6 } from "node:fs/promises";
|
|
27292
27517
|
import { basename, isAbsolute as isAbsolute9, normalize as normalize2 } from "node:path";
|
|
27293
27518
|
import { fileURLToPath } from "node:url";
|
|
27294
27519
|
var MAX_LOCAL_RASTER_BYTES = 128 * 1024 * 1024;
|
|
@@ -27311,7 +27536,7 @@ var LocalRasterImage = class {
|
|
|
27311
27536
|
this.sourceUri = sourceUri;
|
|
27312
27537
|
}
|
|
27313
27538
|
base64 = async () => {
|
|
27314
|
-
const bytes = this.bytes ?? new Uint8Array(await
|
|
27539
|
+
const bytes = this.bytes ?? new Uint8Array(await readFile3(this.sourceUri));
|
|
27315
27540
|
return Buffer.from(bytes).toString("base64");
|
|
27316
27541
|
};
|
|
27317
27542
|
};
|
|
@@ -27359,7 +27584,7 @@ async function resolveCanonicalPath(requested, signal) {
|
|
|
27359
27584
|
return null;
|
|
27360
27585
|
}
|
|
27361
27586
|
try {
|
|
27362
|
-
const target = await
|
|
27587
|
+
const target = await realpath8(requested);
|
|
27363
27588
|
signal.throwIfAborted();
|
|
27364
27589
|
if (!isAbsolute9(target) || normalize2(target) !== target) {
|
|
27365
27590
|
return null;
|
|
@@ -27940,7 +28165,7 @@ function createWritableAcpStream(output2) {
|
|
|
27940
28165
|
if (outputFailure !== void 0) {
|
|
27941
28166
|
return Promise.reject(outputFailure);
|
|
27942
28167
|
}
|
|
27943
|
-
return new Promise((
|
|
28168
|
+
return new Promise((resolve10, reject) => {
|
|
27944
28169
|
pendingWriteFailures.add(reject);
|
|
27945
28170
|
output2.write(chunk, (error62) => {
|
|
27946
28171
|
pendingWriteFailures.delete(reject);
|
|
@@ -27953,7 +28178,7 @@ function createWritableAcpStream(output2) {
|
|
|
27953
28178
|
reject(outputFailure);
|
|
27954
28179
|
return;
|
|
27955
28180
|
}
|
|
27956
|
-
|
|
28181
|
+
resolve10();
|
|
27957
28182
|
});
|
|
27958
28183
|
});
|
|
27959
28184
|
}
|
|
@@ -27975,9 +28200,10 @@ var AgentConnection = class {
|
|
|
27975
28200
|
this.connection = createAcpClient(client2).connect(inProcess.app());
|
|
27976
28201
|
return;
|
|
27977
28202
|
}
|
|
27978
|
-
const
|
|
28203
|
+
const launch = executableLaunch2(agent.adapterPath, agent.arguments);
|
|
28204
|
+
const child2 = spawn4(launch.command, [...launch.arguments], {
|
|
27979
28205
|
cwd,
|
|
27980
|
-
|
|
28206
|
+
...platformSpawnOptions,
|
|
27981
28207
|
env: { ...process.env, ...agent.environment },
|
|
27982
28208
|
shell: false,
|
|
27983
28209
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -27994,12 +28220,12 @@ var AgentConnection = class {
|
|
|
27994
28220
|
stderr.on("data", (chunk) => {
|
|
27995
28221
|
process.stderr.write(`[${agent.id}-acp] ${chunk}`);
|
|
27996
28222
|
});
|
|
27997
|
-
this.termination = new Promise((
|
|
28223
|
+
this.termination = new Promise((resolve10) => {
|
|
27998
28224
|
child2.once("error", (cause) => {
|
|
27999
|
-
|
|
28225
|
+
resolve10({ kind: "failed", error: new AcpExecutionError("The ACP process could not run", { cause }) });
|
|
28000
28226
|
});
|
|
28001
28227
|
child2.once("exit", (code, signal) => {
|
|
28002
|
-
|
|
28228
|
+
resolve10({
|
|
28003
28229
|
kind: "failed",
|
|
28004
28230
|
error: new AcpExecutionError("The ACP process stopped", { cause: { code, signal } })
|
|
28005
28231
|
});
|
|
@@ -30155,7 +30381,7 @@ function sql(strings, ...params) {
|
|
|
30155
30381
|
return new SQL([new StringChunk(str)]);
|
|
30156
30382
|
}
|
|
30157
30383
|
_sql.raw = raw;
|
|
30158
|
-
function
|
|
30384
|
+
function join24(chunks, separator) {
|
|
30159
30385
|
const result = [];
|
|
30160
30386
|
for (const [i, chunk] of chunks.entries()) {
|
|
30161
30387
|
if (i > 0 && separator !== void 0) result.push(separator);
|
|
@@ -30163,7 +30389,7 @@ function sql(strings, ...params) {
|
|
|
30163
30389
|
}
|
|
30164
30390
|
return new SQL(result);
|
|
30165
30391
|
}
|
|
30166
|
-
_sql.join =
|
|
30392
|
+
_sql.join = join24;
|
|
30167
30393
|
function identifier2(value) {
|
|
30168
30394
|
return new Name(value);
|
|
30169
30395
|
}
|
|
@@ -32308,7 +32534,7 @@ var SQLiteSelectBase = class extends TypedQueryBuilder {
|
|
|
32308
32534
|
const baseTableName = this.tableName;
|
|
32309
32535
|
const tableName = getTableLikeName(table);
|
|
32310
32536
|
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
32311
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
32537
|
+
if (typeof tableName === "string" && this.config.joins?.some((join24) => join24.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
32312
32538
|
if (!this.isPartialSelect) {
|
|
32313
32539
|
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
|
|
32314
32540
|
if (typeof tableName === "string" && !is(table, SQL)) {
|
|
@@ -33147,7 +33373,7 @@ var SQLiteDialect = class {
|
|
|
33147
33373
|
if (!joins2) return;
|
|
33148
33374
|
const withEntries = Object.entries(joins2).filter(([_, v]) => v);
|
|
33149
33375
|
if (!withEntries.length) return;
|
|
33150
|
-
return sql.join(withEntries.map(([k,
|
|
33376
|
+
return sql.join(withEntries.map(([k, join24]) => {
|
|
33151
33377
|
const relation = tableConfig.relations[k];
|
|
33152
33378
|
const isSingle2 = is(relation, One);
|
|
33153
33379
|
const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
|
|
@@ -33158,7 +33384,7 @@ var SQLiteDialect = class {
|
|
|
33158
33384
|
table: targetTable,
|
|
33159
33385
|
mode: isSingle2 ? "first" : "many",
|
|
33160
33386
|
schema,
|
|
33161
|
-
queryConfig:
|
|
33387
|
+
queryConfig: join24,
|
|
33162
33388
|
tableConfig: schema[relation.targetTableName],
|
|
33163
33389
|
relationWhere: filter,
|
|
33164
33390
|
isNested: true,
|
|
@@ -33172,7 +33398,7 @@ var SQLiteDialect = class {
|
|
|
33172
33398
|
key: k,
|
|
33173
33399
|
selection: innerQuery.selection,
|
|
33174
33400
|
isArray: !isSingle2,
|
|
33175
|
-
isOptional: (relation.optional ?? false) ||
|
|
33401
|
+
isOptional: (relation.optional ?? false) || join24 !== true && !!join24.where
|
|
33176
33402
|
});
|
|
33177
33403
|
const jsonColumns = sql.join(innerQuery.selection.map((s) => {
|
|
33178
33404
|
return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
|
|
@@ -33788,7 +34014,7 @@ var SQLiteUpdateBase = class {
|
|
|
33788
34014
|
createJoin(joinType) {
|
|
33789
34015
|
return ((table, on) => {
|
|
33790
34016
|
const tableName = getTableLikeName(table);
|
|
33791
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
34017
|
+
if (typeof tableName === "string" && this.config.joins.some((join24) => join24.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
33792
34018
|
if (typeof on === "function") {
|
|
33793
34019
|
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;
|
|
33794
34020
|
on = on(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
|
|
@@ -36447,8 +36673,8 @@ var AcpContentExternalizer = class {
|
|
|
36447
36673
|
|
|
36448
36674
|
// src/external-content/local-external-content-store.ts
|
|
36449
36675
|
import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
|
|
36450
|
-
import { lstat, mkdir as mkdir4, readdir as readdir2, realpath as
|
|
36451
|
-
import { dirname as
|
|
36676
|
+
import { lstat as lstat2, mkdir as mkdir4, readdir as readdir2, realpath as realpath9, rename as rename3, rm as rm3, stat as stat7, utimes, writeFile as writeFile3 } from "node:fs/promises";
|
|
36677
|
+
import { dirname as dirname4, join as join19 } from "node:path";
|
|
36452
36678
|
var contentRequest = /^mobius-content:(image|audio|resource):([a-f0-9]{64})$/u;
|
|
36453
36679
|
var CONTENT_LIFETIME_MILLISECONDS = 24 * 60 * 60 * 1e3;
|
|
36454
36680
|
var metadataSchema2 = external_exports.strictObject({
|
|
@@ -36484,7 +36710,7 @@ var LocalExternalContentStore = class {
|
|
|
36484
36710
|
#expirationTimer;
|
|
36485
36711
|
#cleanup = Promise.resolve();
|
|
36486
36712
|
constructor(stateDirectory) {
|
|
36487
|
-
this.#root =
|
|
36713
|
+
this.#root = join19(stateDirectory, "tmp", "session-content", randomUUID2());
|
|
36488
36714
|
this.#expirationTimer = setInterval(() => {
|
|
36489
36715
|
void this.#expire().catch(() => void 0);
|
|
36490
36716
|
}, 6e4);
|
|
@@ -36495,11 +36721,11 @@ var LocalExternalContentStore = class {
|
|
|
36495
36721
|
await mkdir4(this.#root, { mode: 448, recursive: true });
|
|
36496
36722
|
const now = /* @__PURE__ */ new Date();
|
|
36497
36723
|
await utimes(this.#root, now, now);
|
|
36498
|
-
for (const directory of await readdir2(
|
|
36724
|
+
for (const directory of await readdir2(dirname4(this.#root), { withFileTypes: true })) {
|
|
36499
36725
|
if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
|
|
36500
36726
|
continue;
|
|
36501
36727
|
}
|
|
36502
|
-
const path2 =
|
|
36728
|
+
const path2 = join19(dirname4(this.#root), directory.name);
|
|
36503
36729
|
if (path2 === this.#root) {
|
|
36504
36730
|
continue;
|
|
36505
36731
|
}
|
|
@@ -36549,10 +36775,10 @@ var LocalExternalContentStore = class {
|
|
|
36549
36775
|
}
|
|
36550
36776
|
await this.#expire();
|
|
36551
36777
|
active.throwIfAborted();
|
|
36552
|
-
const directory =
|
|
36778
|
+
const directory = join19(this.#root, kind);
|
|
36553
36779
|
await mkdir4(directory, { mode: 448, recursive: true });
|
|
36554
36780
|
active.throwIfAborted();
|
|
36555
|
-
const path2 =
|
|
36781
|
+
const path2 = join19(directory, key);
|
|
36556
36782
|
const write = atomicWrite(path2, bytes, active);
|
|
36557
36783
|
await write;
|
|
36558
36784
|
active.throwIfAborted();
|
|
@@ -36585,12 +36811,12 @@ var LocalExternalContentStore = class {
|
|
|
36585
36811
|
}
|
|
36586
36812
|
try {
|
|
36587
36813
|
const [resolvedDirectory, resolvedPath, file2] = await Promise.all([
|
|
36588
|
-
|
|
36589
|
-
|
|
36590
|
-
|
|
36814
|
+
realpath9(dirname4(entry.path)),
|
|
36815
|
+
realpath9(entry.path),
|
|
36816
|
+
lstat2(entry.path)
|
|
36591
36817
|
]);
|
|
36592
36818
|
signal.throwIfAborted();
|
|
36593
|
-
if (!file2.isFile() || file2.isSymbolicLink() ||
|
|
36819
|
+
if (!file2.isFile() || file2.isSymbolicLink() || dirname4(resolvedPath) !== resolvedDirectory) {
|
|
36594
36820
|
return null;
|
|
36595
36821
|
}
|
|
36596
36822
|
return { mediaType: entry.mediaType, name: entry.name, path: resolvedPath };
|
|
@@ -37891,7 +38117,7 @@ var AgentInstallationManager = class {
|
|
|
37891
38117
|
|
|
37892
38118
|
// src/agent-installation/fixed-installation-executor.ts
|
|
37893
38119
|
import { realpathSync as realpathSync2, statSync as statSync2 } from "node:fs";
|
|
37894
|
-
import { resolve as
|
|
38120
|
+
import { resolve as resolve5 } from "node:path";
|
|
37895
38121
|
function findSpecification(specifications, agentId) {
|
|
37896
38122
|
for (const specification of specifications) {
|
|
37897
38123
|
if (specification.id === agentId) {
|
|
@@ -37902,7 +38128,7 @@ function findSpecification(specifications, agentId) {
|
|
|
37902
38128
|
}
|
|
37903
38129
|
function resolveDefaultWorkspace(path2) {
|
|
37904
38130
|
try {
|
|
37905
|
-
const directory = realpathSync2(
|
|
38131
|
+
const directory = realpathSync2(resolve5(path2));
|
|
37906
38132
|
if (!statSync2(directory).isDirectory()) {
|
|
37907
38133
|
throw new Error("Default workspace is not a directory");
|
|
37908
38134
|
}
|
|
@@ -37917,7 +38143,7 @@ function resolveDefaultWorkspace(path2) {
|
|
|
37917
38143
|
}
|
|
37918
38144
|
function resolveIntegrationStateDirectory(path2) {
|
|
37919
38145
|
try {
|
|
37920
|
-
const directory = realpathSync2(
|
|
38146
|
+
const directory = realpathSync2(resolve5(path2));
|
|
37921
38147
|
const metadata = statSync2(directory);
|
|
37922
38148
|
if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
|
|
37923
38149
|
throw new Error("Installation directory is not user-owned");
|
|
@@ -38089,9 +38315,9 @@ var FixedInstallationExecutor = class {
|
|
|
38089
38315
|
};
|
|
38090
38316
|
|
|
38091
38317
|
// src/authorization/workspace-directory.ts
|
|
38092
|
-
import { readdir as readdir3, realpath as
|
|
38318
|
+
import { readdir as readdir3, realpath as realpath10, stat as stat8 } from "node:fs/promises";
|
|
38093
38319
|
import { homedir as homedir2 } from "node:os";
|
|
38094
|
-
import { basename as basename3, dirname as
|
|
38320
|
+
import { basename as basename3, dirname as dirname5, isAbsolute as isAbsolute10, join as join20, normalize as normalize3, relative as relative4 } from "node:path";
|
|
38095
38321
|
|
|
38096
38322
|
// src/authorization/local-authorization-error.ts
|
|
38097
38323
|
var LocalAuthorizationError = class extends Error {
|
|
@@ -38170,7 +38396,7 @@ var WorkspaceDirectoryService = class {
|
|
|
38170
38396
|
throw new LocalAuthorizationError("The local directory path is invalid");
|
|
38171
38397
|
}
|
|
38172
38398
|
try {
|
|
38173
|
-
const target = await
|
|
38399
|
+
const target = await realpath10(requested);
|
|
38174
38400
|
signal.throwIfAborted();
|
|
38175
38401
|
const metadata = await stat8(target);
|
|
38176
38402
|
signal.throwIfAborted();
|
|
@@ -38220,7 +38446,7 @@ var WorkspaceDirectoryService = class {
|
|
|
38220
38446
|
continue;
|
|
38221
38447
|
}
|
|
38222
38448
|
try {
|
|
38223
|
-
const path2 = await this.resolvePath(
|
|
38449
|
+
const path2 = await this.resolvePath(join20(target, child2.name), signal);
|
|
38224
38450
|
entries.push({ directoryId: encodePath(path2), name: child2.name });
|
|
38225
38451
|
} catch (cause) {
|
|
38226
38452
|
signal.throwIfAborted();
|
|
@@ -38230,7 +38456,7 @@ var WorkspaceDirectoryService = class {
|
|
|
38230
38456
|
}
|
|
38231
38457
|
}
|
|
38232
38458
|
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
38233
|
-
const parent =
|
|
38459
|
+
const parent = dirname5(target);
|
|
38234
38460
|
return new WorkspaceDirectoryListing(
|
|
38235
38461
|
id,
|
|
38236
38462
|
this.label(target),
|
|
@@ -38256,15 +38482,15 @@ var WorkspaceDirectoryService = class {
|
|
|
38256
38482
|
|
|
38257
38483
|
// src/daemon-diagnostic-log.ts
|
|
38258
38484
|
import { appendFileSync, mkdirSync, readFileSync as readFileSync2, renameSync, statSync as statSync3, writeFileSync } from "node:fs";
|
|
38259
|
-
import { join as
|
|
38485
|
+
import { join as join21 } from "node:path";
|
|
38260
38486
|
var MAXIMUM_DAEMON_LOG_BYTES = 1 * 1024 * 1024;
|
|
38261
38487
|
var DaemonDiagnosticLog = class {
|
|
38262
38488
|
#directory;
|
|
38263
38489
|
#path;
|
|
38264
38490
|
#maximumBytes;
|
|
38265
38491
|
constructor(stateDirectory, maximumBytes = MAXIMUM_DAEMON_LOG_BYTES) {
|
|
38266
|
-
this.#directory =
|
|
38267
|
-
this.#path =
|
|
38492
|
+
this.#directory = join21(stateDirectory, "logs");
|
|
38493
|
+
this.#path = join21(this.#directory, "daemon.log");
|
|
38268
38494
|
this.#maximumBytes = maximumBytes;
|
|
38269
38495
|
}
|
|
38270
38496
|
// Export only correlation and failure metadata. Local messages and paths stay local.
|
|
@@ -39080,7 +39306,7 @@ var ActiveDaemonTurn = class {
|
|
|
39080
39306
|
var MAX_SESSIONS_WITH_COMPLETED_RECOVERY = 32;
|
|
39081
39307
|
var waitForTurnCompletion = (turn, waitSignal) => {
|
|
39082
39308
|
waitSignal.throwIfAborted();
|
|
39083
|
-
return new Promise((
|
|
39309
|
+
return new Promise((resolve10, reject) => {
|
|
39084
39310
|
let settled = false;
|
|
39085
39311
|
const finish = (result) => {
|
|
39086
39312
|
if (settled) {
|
|
@@ -39089,7 +39315,7 @@ var waitForTurnCompletion = (turn, waitSignal) => {
|
|
|
39089
39315
|
settled = true;
|
|
39090
39316
|
waitSignal.removeEventListener("abort", onAbort);
|
|
39091
39317
|
if (result.kind === "completed") {
|
|
39092
|
-
|
|
39318
|
+
resolve10();
|
|
39093
39319
|
} else {
|
|
39094
39320
|
reject(result.error);
|
|
39095
39321
|
}
|
|
@@ -39287,7 +39513,7 @@ var sessionEventCacheMigrations = [
|
|
|
39287
39513
|
|
|
39288
39514
|
// src/infra/local-sqlite-database.ts
|
|
39289
39515
|
import { chmodSync, mkdirSync as mkdirSync2 } from "node:fs";
|
|
39290
|
-
import { dirname as
|
|
39516
|
+
import { dirname as dirname6 } from "node:path";
|
|
39291
39517
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
39292
39518
|
|
|
39293
39519
|
// ../../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
|
|
@@ -39398,7 +39624,7 @@ var LocalSqliteDatabase = class {
|
|
|
39398
39624
|
orm;
|
|
39399
39625
|
#sqlite;
|
|
39400
39626
|
constructor(path2, label, migrations, pragmas = []) {
|
|
39401
|
-
mkdirSync2(
|
|
39627
|
+
mkdirSync2(dirname6(path2), { mode: 448, recursive: true });
|
|
39402
39628
|
this.#sqlite = new DatabaseSync2(path2);
|
|
39403
39629
|
chmodSync(path2, 384);
|
|
39404
39630
|
try {
|
|
@@ -39957,10 +40183,11 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
39957
40183
|
);
|
|
39958
40184
|
}
|
|
39959
40185
|
signal.throwIfAborted();
|
|
39960
|
-
const
|
|
40186
|
+
const launch = executableLaunch2(agent.agentIdentity.realPath, ["app-server"]);
|
|
40187
|
+
const child2 = spawn5(launch.command, [...launch.arguments], {
|
|
39961
40188
|
cwd,
|
|
39962
40189
|
env: { ...process.env, ...agent.environment },
|
|
39963
|
-
|
|
40190
|
+
...platformSpawnOptions,
|
|
39964
40191
|
shell: false,
|
|
39965
40192
|
stdio: ["pipe", "pipe", "ignore"]
|
|
39966
40193
|
});
|
|
@@ -40764,7 +40991,7 @@ import { WebSocket as WebSocket5 } from "undici";
|
|
|
40764
40991
|
// package.json
|
|
40765
40992
|
var package_default = {
|
|
40766
40993
|
name: "@moxt-ai/mobius",
|
|
40767
|
-
version: "0.0.
|
|
40994
|
+
version: "0.0.196",
|
|
40768
40995
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
40769
40996
|
type: "module",
|
|
40770
40997
|
bin: {
|
|
@@ -40773,7 +41000,9 @@ var package_default = {
|
|
|
40773
41000
|
types: "./src/index.ts",
|
|
40774
41001
|
exports: {
|
|
40775
41002
|
".": "./src/index.ts",
|
|
40776
|
-
"./runtime": "./src/runtime.ts"
|
|
41003
|
+
"./runtime": "./src/runtime.ts",
|
|
41004
|
+
"./process": "./src/process/executable.ts",
|
|
41005
|
+
"./filesystem": "./src/filesystem/private-path.ts"
|
|
40777
41006
|
},
|
|
40778
41007
|
files: [
|
|
40779
41008
|
"dist"
|
|
@@ -40792,6 +41021,14 @@ var package_default = {
|
|
|
40792
41021
|
"./runtime": {
|
|
40793
41022
|
types: "./dist/runtime.d.ts",
|
|
40794
41023
|
import: "./dist/runtime.js"
|
|
41024
|
+
},
|
|
41025
|
+
"./process": {
|
|
41026
|
+
types: "./dist/process/executable.d.ts",
|
|
41027
|
+
import: "./dist/process/executable.js"
|
|
41028
|
+
},
|
|
41029
|
+
"./filesystem": {
|
|
41030
|
+
types: "./dist/filesystem/private-path.d.ts",
|
|
41031
|
+
import: "./dist/filesystem/private-path.js"
|
|
40795
41032
|
}
|
|
40796
41033
|
}
|
|
40797
41034
|
},
|
|
@@ -40801,7 +41038,7 @@ var package_default = {
|
|
|
40801
41038
|
directory: "packages/cli"
|
|
40802
41039
|
},
|
|
40803
41040
|
scripts: {
|
|
40804
|
-
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",
|
|
41041
|
+
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",
|
|
40805
41042
|
dev: "node --watch src/cli.ts",
|
|
40806
41043
|
prepack: "pnpm build",
|
|
40807
41044
|
start: "node dist/cli.js",
|
|
@@ -41462,8 +41699,8 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
41462
41699
|
|
|
41463
41700
|
// src/artifacts/local-file-streamer.ts
|
|
41464
41701
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
41465
|
-
import { realpath as
|
|
41466
|
-
import { basename as basename4, extname, isAbsolute as isAbsolute11, normalize as normalize4, resolve as
|
|
41702
|
+
import { realpath as realpath11, stat as stat9 } from "node:fs/promises";
|
|
41703
|
+
import { basename as basename4, extname as extname2, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve6 } from "node:path";
|
|
41467
41704
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
41468
41705
|
var CHUNK_BYTES = 192 * 1024;
|
|
41469
41706
|
function requestedPath(value) {
|
|
@@ -41485,12 +41722,12 @@ async function resolveFile(value, workingDirectory, signal) {
|
|
|
41485
41722
|
if (path2 === null || !isAbsolute11(path2) && workingDirectory === null) {
|
|
41486
41723
|
return null;
|
|
41487
41724
|
}
|
|
41488
|
-
const requested = workingDirectory === null ? path2 :
|
|
41725
|
+
const requested = workingDirectory === null ? path2 : resolve6(workingDirectory, path2);
|
|
41489
41726
|
if (!isAbsolute11(requested) || isAbsolute11(path2) && normalize4(path2) !== path2) {
|
|
41490
41727
|
return null;
|
|
41491
41728
|
}
|
|
41492
41729
|
try {
|
|
41493
|
-
const target = await
|
|
41730
|
+
const target = await realpath11(requested);
|
|
41494
41731
|
signal.throwIfAborted();
|
|
41495
41732
|
return isAbsolute11(target) && normalize4(target) === target ? target : null;
|
|
41496
41733
|
} catch {
|
|
@@ -41513,7 +41750,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
|
|
|
41513
41750
|
send2({
|
|
41514
41751
|
byteLength: before.size,
|
|
41515
41752
|
kind: FILE_BEGIN_KIND,
|
|
41516
|
-
mediaType: external?.mediaType ?? raster?.mimeType ?? (
|
|
41753
|
+
mediaType: external?.mediaType ?? raster?.mimeType ?? (extname2(target).toLowerCase() === ".svg" ? "image/svg+xml" : "application/octet-stream"),
|
|
41517
41754
|
modifiedAt: before.mtime.toISOString(),
|
|
41518
41755
|
name: external?.name ?? (basename4(target) || "file"),
|
|
41519
41756
|
requestId: command.requestId,
|
|
@@ -41803,6 +42040,78 @@ async function executeSessionConfigure(socket, command, config2, directories, au
|
|
|
41803
42040
|
}
|
|
41804
42041
|
|
|
41805
42042
|
// src/daemon-history-commands.ts
|
|
42043
|
+
function isAgentReasoning(event) {
|
|
42044
|
+
return event?.type === "acp" && event.payload.sessionUpdate === "agent_thought_chunk";
|
|
42045
|
+
}
|
|
42046
|
+
function omitAgentReasoning(events) {
|
|
42047
|
+
const retained = [];
|
|
42048
|
+
let previousReasoningMessageId;
|
|
42049
|
+
for (const event of events) {
|
|
42050
|
+
if (event.type !== "acp" || event.payload.sessionUpdate !== "agent_thought_chunk") {
|
|
42051
|
+
previousReasoningMessageId = void 0;
|
|
42052
|
+
retained.push(event);
|
|
42053
|
+
continue;
|
|
42054
|
+
}
|
|
42055
|
+
const messageId = event.payload.messageId ?? null;
|
|
42056
|
+
if (previousReasoningMessageId === void 0 || previousReasoningMessageId !== messageId) {
|
|
42057
|
+
retained.push({
|
|
42058
|
+
...event,
|
|
42059
|
+
mobiusMetadata: { omitted: true },
|
|
42060
|
+
payload: { ...event.payload, content: { text: "", type: "text" } }
|
|
42061
|
+
});
|
|
42062
|
+
}
|
|
42063
|
+
previousReasoningMessageId = messageId;
|
|
42064
|
+
}
|
|
42065
|
+
return retained;
|
|
42066
|
+
}
|
|
42067
|
+
async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoning, queuedPromptRequests, load, eventLogV2) {
|
|
42068
|
+
let cursor = initialCursor;
|
|
42069
|
+
let loaded = [];
|
|
42070
|
+
let sessionGenerationId = null;
|
|
42071
|
+
let sourceNextCursor = null;
|
|
42072
|
+
do {
|
|
42073
|
+
const replay = await load(eventLimit, cursor);
|
|
42074
|
+
if (sessionGenerationId !== null && replay.sessionGenerationId !== sessionGenerationId) {
|
|
42075
|
+
throw new AcpExecutionError("The Session reloaded while history was loading", {}, "session_reloaded");
|
|
42076
|
+
}
|
|
42077
|
+
sessionGenerationId = replay.sessionGenerationId;
|
|
42078
|
+
const events2 = replay.events.map(
|
|
42079
|
+
(event, index2) => eventLogV2.event(
|
|
42080
|
+
sessionId,
|
|
42081
|
+
replay.sessionGenerationId,
|
|
42082
|
+
replay.startPosition + index2,
|
|
42083
|
+
event,
|
|
42084
|
+
"1970-01-01T00:00:00.000Z"
|
|
42085
|
+
)
|
|
42086
|
+
);
|
|
42087
|
+
loaded = [...events2, ...loaded];
|
|
42088
|
+
sourceNextCursor = replay.nextCursor;
|
|
42089
|
+
const visible2 = omitReasoning ? omitAgentReasoning(loaded) : loaded;
|
|
42090
|
+
const reasoningContinuesBeforePage = sourceNextCursor !== null && isAgentReasoning(loaded[0]);
|
|
42091
|
+
if (visible2.length >= eventLimit && !reasoningContinuesBeforePage) {
|
|
42092
|
+
break;
|
|
42093
|
+
}
|
|
42094
|
+
cursor = sourceNextCursor;
|
|
42095
|
+
} while (cursor !== null);
|
|
42096
|
+
if (sessionGenerationId === null) {
|
|
42097
|
+
throw new AcpExecutionError("The Session history is unavailable", {}, "session_history_unavailable");
|
|
42098
|
+
}
|
|
42099
|
+
const visible = omitReasoning ? omitAgentReasoning(loaded) : loaded;
|
|
42100
|
+
const events = visible.slice(-eventLimit);
|
|
42101
|
+
const firstPosition = events[0] === void 0 ? 0 : Number(events[0].position);
|
|
42102
|
+
const nextCursor = firstPosition <= 1 ? null : (firstPosition - 1).toString();
|
|
42103
|
+
return {
|
|
42104
|
+
events: {
|
|
42105
|
+
events,
|
|
42106
|
+
nextCursor,
|
|
42107
|
+
sessionGenerationId,
|
|
42108
|
+
tailCursor: events.at(-1)?.eventId ?? "",
|
|
42109
|
+
truncated: nextCursor !== null,
|
|
42110
|
+
version: 2
|
|
42111
|
+
},
|
|
42112
|
+
queuedPromptRequests
|
|
42113
|
+
};
|
|
42114
|
+
}
|
|
41806
42115
|
async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, nativeSessions, eventLogV2, signal) {
|
|
41807
42116
|
let agentId;
|
|
41808
42117
|
try {
|
|
@@ -41826,35 +42135,23 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
41826
42135
|
signal
|
|
41827
42136
|
};
|
|
41828
42137
|
const recovery = eventLogV2.promptRequestRecovery(command.sessionId);
|
|
41829
|
-
const
|
|
41830
|
-
|
|
41831
|
-
|
|
41832
|
-
|
|
41833
|
-
|
|
41834
|
-
|
|
41835
|
-
|
|
41836
|
-
|
|
41837
|
-
"1970-01-01T00:00:00.000Z"
|
|
41838
|
-
)
|
|
42138
|
+
const events = await loadHistoryPage(
|
|
42139
|
+
command.sessionId,
|
|
42140
|
+
command.eventLimit,
|
|
42141
|
+
command.cursor,
|
|
42142
|
+
command.omit?.includes("agent-reasoning") === true,
|
|
42143
|
+
recovery.queuedPromptRequests,
|
|
42144
|
+
async (eventLimit, cursor) => await sessions.loadSessionEventsV2(loadOptions, eventLimit, cursor),
|
|
42145
|
+
eventLogV2
|
|
41839
42146
|
);
|
|
41840
|
-
|
|
42147
|
+
signal.throwIfAborted();
|
|
41841
42148
|
audit.record({
|
|
41842
42149
|
commandId: command.requestId,
|
|
41843
42150
|
event: "session_event_log_v2_loaded",
|
|
41844
42151
|
sessionId: command.sessionId
|
|
41845
42152
|
});
|
|
41846
42153
|
send(socket, {
|
|
41847
|
-
events
|
|
41848
|
-
events: {
|
|
41849
|
-
events,
|
|
41850
|
-
nextCursor: replay.nextCursor,
|
|
41851
|
-
sessionGenerationId: replay.sessionGenerationId,
|
|
41852
|
-
tailCursor,
|
|
41853
|
-
truncated: replay.truncated,
|
|
41854
|
-
version: 2
|
|
41855
|
-
},
|
|
41856
|
-
queuedPromptRequests: recovery.queuedPromptRequests
|
|
41857
|
-
},
|
|
42154
|
+
events,
|
|
41858
42155
|
kind: SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND,
|
|
41859
42156
|
requestId: command.requestId,
|
|
41860
42157
|
sessionId: command.sessionId
|
|
@@ -41893,46 +42190,30 @@ async function executeSessionPreviewHistoryPageLoad(socket, command, config2, di
|
|
|
41893
42190
|
command.additionalDirectoryIds,
|
|
41894
42191
|
signal
|
|
41895
42192
|
);
|
|
41896
|
-
const
|
|
41897
|
-
|
|
41898
|
-
|
|
41899
|
-
|
|
41900
|
-
|
|
41901
|
-
|
|
41902
|
-
|
|
41903
|
-
|
|
42193
|
+
const loadOptions = {
|
|
42194
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
42195
|
+
agent: await resolveCatalogAgent(config2, command.agentId, signal),
|
|
42196
|
+
cwd: resolved.cwd,
|
|
42197
|
+
sessionId: command.sessionId,
|
|
42198
|
+
signal
|
|
42199
|
+
};
|
|
42200
|
+
const events = await loadHistoryPage(
|
|
41904
42201
|
command.sessionId,
|
|
41905
42202
|
command.eventLimit,
|
|
41906
|
-
command.cursor
|
|
42203
|
+
command.cursor,
|
|
42204
|
+
command.omit?.includes("agent-reasoning") === true,
|
|
42205
|
+
[],
|
|
42206
|
+
async (eventLimit, cursor) => await sessions.previewNativeSessionEventsV2(loadOptions, command.sessionId, eventLimit, cursor),
|
|
42207
|
+
eventLogV2
|
|
41907
42208
|
);
|
|
41908
42209
|
signal.throwIfAborted();
|
|
41909
|
-
const events = replay.events.map(
|
|
41910
|
-
(event, index2) => eventLogV2.event(
|
|
41911
|
-
command.sessionId,
|
|
41912
|
-
replay.sessionGenerationId,
|
|
41913
|
-
replay.startPosition + index2,
|
|
41914
|
-
event,
|
|
41915
|
-
"1970-01-01T00:00:00.000Z"
|
|
41916
|
-
)
|
|
41917
|
-
);
|
|
41918
|
-
const tailCursor = events.at(-1)?.eventId ?? "";
|
|
41919
42210
|
audit.record({
|
|
41920
42211
|
commandId: command.requestId,
|
|
41921
42212
|
event: "session_event_log_v2_loaded",
|
|
41922
42213
|
sessionId: command.sessionId
|
|
41923
42214
|
});
|
|
41924
42215
|
send(socket, {
|
|
41925
|
-
events
|
|
41926
|
-
events: {
|
|
41927
|
-
events,
|
|
41928
|
-
nextCursor: replay.nextCursor,
|
|
41929
|
-
sessionGenerationId: replay.sessionGenerationId,
|
|
41930
|
-
tailCursor,
|
|
41931
|
-
truncated: replay.truncated,
|
|
41932
|
-
version: 2
|
|
41933
|
-
},
|
|
41934
|
-
queuedPromptRequests: []
|
|
41935
|
-
},
|
|
42216
|
+
events,
|
|
41936
42217
|
kind: SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND,
|
|
41937
42218
|
requestId: command.requestId,
|
|
41938
42219
|
sessionId: command.sessionId
|
|
@@ -42371,13 +42652,13 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
42371
42652
|
operationSignal.throwIfAborted();
|
|
42372
42653
|
const skipPrevious = command.action === "active-turn";
|
|
42373
42654
|
if (previous.length > 0 && !skipPrevious) {
|
|
42374
|
-
await new Promise((
|
|
42655
|
+
await new Promise((resolve10, reject) => {
|
|
42375
42656
|
const onAbort = () => reject(operationSignal.reason);
|
|
42376
42657
|
operationSignal.addEventListener("abort", onAbort, { once: true });
|
|
42377
42658
|
void Promise.all(previous.map((request) => request.completion)).then(
|
|
42378
42659
|
() => {
|
|
42379
42660
|
operationSignal.removeEventListener("abort", onAbort);
|
|
42380
|
-
|
|
42661
|
+
resolve10();
|
|
42381
42662
|
},
|
|
42382
42663
|
(error62) => {
|
|
42383
42664
|
operationSignal.removeEventListener("abort", onAbort);
|
|
@@ -42811,7 +43092,7 @@ var RelayConnectionError = class extends Error {
|
|
|
42811
43092
|
};
|
|
42812
43093
|
function connectRelay(url2, signal) {
|
|
42813
43094
|
signal.throwIfAborted();
|
|
42814
|
-
return new Promise((
|
|
43095
|
+
return new Promise((resolve10, reject) => {
|
|
42815
43096
|
const endpoint = new URL(url2);
|
|
42816
43097
|
const headers = runtimeAuthorization(endpoint);
|
|
42817
43098
|
endpoint.searchParams.delete("token");
|
|
@@ -42878,7 +43159,7 @@ function connectRelay(url2, signal) {
|
|
|
42878
43159
|
}
|
|
42879
43160
|
finished = true;
|
|
42880
43161
|
cleanup();
|
|
42881
|
-
|
|
43162
|
+
resolve10(socket);
|
|
42882
43163
|
};
|
|
42883
43164
|
function onTimeout() {
|
|
42884
43165
|
fail(
|
|
@@ -43060,7 +43341,7 @@ async function runRelayConnection({
|
|
|
43060
43341
|
installationObserver.connect(socket);
|
|
43061
43342
|
onConnected();
|
|
43062
43343
|
try {
|
|
43063
|
-
await new Promise((
|
|
43344
|
+
await new Promise((resolve10, reject) => {
|
|
43064
43345
|
let finished = false;
|
|
43065
43346
|
const cleanup = () => {
|
|
43066
43347
|
connectionLiveness.close();
|
|
@@ -43078,7 +43359,7 @@ async function runRelayConnection({
|
|
|
43078
43359
|
}
|
|
43079
43360
|
finished = true;
|
|
43080
43361
|
cleanup();
|
|
43081
|
-
|
|
43362
|
+
resolve10();
|
|
43082
43363
|
};
|
|
43083
43364
|
const rejectConnection = (failure2) => {
|
|
43084
43365
|
if (finished) {
|
|
@@ -43464,12 +43745,12 @@ function waitForRelayRetry(signal, timer) {
|
|
|
43464
43745
|
if (signal.aborted) {
|
|
43465
43746
|
return Promise.resolve();
|
|
43466
43747
|
}
|
|
43467
|
-
return new Promise((
|
|
43748
|
+
return new Promise((resolve10) => {
|
|
43468
43749
|
const retry = timer.schedule(finish, RELAY_RECONNECT_DELAY_MILLISECONDS);
|
|
43469
43750
|
function finish() {
|
|
43470
43751
|
retry.cancel();
|
|
43471
43752
|
signal.removeEventListener("abort", finish);
|
|
43472
|
-
|
|
43753
|
+
resolve10();
|
|
43473
43754
|
}
|
|
43474
43755
|
signal.addEventListener("abort", finish, { once: true });
|
|
43475
43756
|
});
|
|
@@ -43525,11 +43806,11 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
43525
43806
|
stateDirectory
|
|
43526
43807
|
});
|
|
43527
43808
|
const channelHash = createHash7("sha256").update(config2.channelId).digest("hex");
|
|
43528
|
-
const sessionDatabase = openAcpSessionDatabase(
|
|
43809
|
+
const sessionDatabase = openAcpSessionDatabase(join22(stateDirectory, "sessions", `${channelHash}.sqlite`));
|
|
43529
43810
|
let eventsV2;
|
|
43530
43811
|
try {
|
|
43531
43812
|
eventsV2 = new CachedAcpSessionEventStoreV2(
|
|
43532
|
-
openSessionEventCacheV2Database(
|
|
43813
|
+
openSessionEventCacheV2Database(join22(stateDirectory, "sessions", `${channelHash}.events.sqlite`))
|
|
43533
43814
|
);
|
|
43534
43815
|
} catch (error62) {
|
|
43535
43816
|
sessionDatabase.close();
|
|
@@ -43732,15 +44013,28 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
43732
44013
|
}
|
|
43733
44014
|
|
|
43734
44015
|
// src/pairing/pair-local-machine.ts
|
|
43735
|
-
import { mkdir as mkdir6, realpath as
|
|
44016
|
+
import { mkdir as mkdir6, realpath as realpath12, stat as stat10 } from "node:fs/promises";
|
|
43736
44017
|
import { hostname as hostname3 } from "node:os";
|
|
43737
|
-
import { basename as basename6, resolve as
|
|
44018
|
+
import { basename as basename6, resolve as resolve8 } from "node:path";
|
|
43738
44019
|
import { fetch as fetch4 } from "undici";
|
|
43739
44020
|
|
|
43740
44021
|
// src/storage/runtime-installation-store.ts
|
|
43741
44022
|
import { createHash as createHash8, randomUUID as randomUUID9 } from "node:crypto";
|
|
43742
|
-
import { mkdir as mkdir5, open as open5, readdir as readdir4, rename as rename4, unlink, writeFile as writeFile4 } from "node:fs/promises";
|
|
43743
|
-
import { dirname as
|
|
44023
|
+
import { mkdir as mkdir5, open as open5, readdir as readdir4, rename as rename4, unlink as unlink2, writeFile as writeFile4 } from "node:fs/promises";
|
|
44024
|
+
import { dirname as dirname7, join as join23, resolve as resolve7 } from "node:path";
|
|
44025
|
+
|
|
44026
|
+
// src/filesystem/private-path.ts
|
|
44027
|
+
import { lstat as lstat3 } from "node:fs/promises";
|
|
44028
|
+
async function validateLocalPath(path2, directory, privateAccess, signal) {
|
|
44029
|
+
signal.throwIfAborted();
|
|
44030
|
+
const metadata = await lstat3(path2);
|
|
44031
|
+
if (metadata.isSymbolicLink() || (directory ? !metadata.isDirectory() : !metadata.isFile())) {
|
|
44032
|
+
throw new LocalPathError("Unsafe local path");
|
|
44033
|
+
}
|
|
44034
|
+
await platformSupportFor(process.platform).validatePathPermissions(path2, directory, privateAccess, signal);
|
|
44035
|
+
}
|
|
44036
|
+
|
|
44037
|
+
// src/storage/runtime-installation-store.ts
|
|
43744
44038
|
var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
|
|
43745
44039
|
var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
|
|
43746
44040
|
var INSTALLATION_ID_PATTERN = /^min_[a-f0-9]{32}$/;
|
|
@@ -43982,8 +44276,8 @@ async function readJsonFile(path2, signal, missingCode) {
|
|
|
43982
44276
|
}
|
|
43983
44277
|
async function writeJsonAtomically(path2, value, signal) {
|
|
43984
44278
|
signal.throwIfAborted();
|
|
43985
|
-
const directory =
|
|
43986
|
-
const temporaryPath =
|
|
44279
|
+
const directory = dirname7(path2);
|
|
44280
|
+
const temporaryPath = join23(directory, `.${randomUUID9()}.tmp`);
|
|
43987
44281
|
try {
|
|
43988
44282
|
await mkdir5(directory, { mode: 448, recursive: true });
|
|
43989
44283
|
signal.throwIfAborted();
|
|
@@ -43992,7 +44286,7 @@ async function writeJsonAtomically(path2, value, signal) {
|
|
|
43992
44286
|
signal.throwIfAborted();
|
|
43993
44287
|
await rename4(temporaryPath, path2);
|
|
43994
44288
|
} catch (cause) {
|
|
43995
|
-
await
|
|
44289
|
+
await unlink2(temporaryPath).catch(() => void 0);
|
|
43996
44290
|
signal.throwIfAborted();
|
|
43997
44291
|
throw new RuntimeInstallationStoreError("connection_unavailable", "The local Runtime state cannot be written", {
|
|
43998
44292
|
cause
|
|
@@ -44009,15 +44303,17 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
44009
44303
|
this.applicationId = applicationId;
|
|
44010
44304
|
this.installationId = installationId2;
|
|
44011
44305
|
this.stateDirectory = stateDirectory;
|
|
44012
|
-
this.#channelDirectory =
|
|
44013
|
-
this.#connectionDirectory =
|
|
44306
|
+
this.#channelDirectory = join23(stateDirectory, "channels");
|
|
44307
|
+
this.#connectionDirectory = join23(stateDirectory, "connections");
|
|
44014
44308
|
}
|
|
44015
44309
|
static open = async (options, signal) => {
|
|
44016
44310
|
signal.throwIfAborted();
|
|
44017
44311
|
const applicationId = validateApplicationId(options.applicationId);
|
|
44018
|
-
const rootDirectory =
|
|
44019
|
-
const applicationDirectory =
|
|
44312
|
+
const rootDirectory = resolve7(options.stateDirectory);
|
|
44313
|
+
const applicationDirectory = join23(rootDirectory, "installations", applicationId);
|
|
44020
44314
|
try {
|
|
44315
|
+
await mkdir5(rootDirectory, { mode: 448, recursive: true });
|
|
44316
|
+
await validateLocalPath(rootDirectory, true, true, signal);
|
|
44021
44317
|
await mkdir5(applicationDirectory, { mode: 448, recursive: true });
|
|
44022
44318
|
} catch (cause) {
|
|
44023
44319
|
throw new RuntimeInstallationStoreError(
|
|
@@ -44029,7 +44325,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
44029
44325
|
);
|
|
44030
44326
|
}
|
|
44031
44327
|
const storedInstallationId = await readOrCreateInstallationId(applicationDirectory, signal);
|
|
44032
|
-
const stateDirectory =
|
|
44328
|
+
const stateDirectory = join23(applicationDirectory, storedInstallationId);
|
|
44033
44329
|
try {
|
|
44034
44330
|
await mkdir5(stateDirectory, { mode: 448, recursive: true });
|
|
44035
44331
|
} catch (cause) {
|
|
@@ -44044,8 +44340,8 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
44044
44340
|
signal.throwIfAborted();
|
|
44045
44341
|
return new _RuntimeInstallationStore(applicationId, storedInstallationId, stateDirectory);
|
|
44046
44342
|
};
|
|
44047
|
-
connectionPath = (connectionId2) =>
|
|
44048
|
-
channelIndexPath = (channelId) =>
|
|
44343
|
+
connectionPath = (connectionId2) => join23(this.#connectionDirectory, `${validateConnectionId(connectionId2)}.json`);
|
|
44344
|
+
channelIndexPath = (channelId) => join23(this.#channelDirectory, channelIndexFileName(validateIdentifier(channelId, "invalid_channel_id")));
|
|
44049
44345
|
readConnection = async (connectionId2, signal) => {
|
|
44050
44346
|
const stored = decodeConnection(
|
|
44051
44347
|
await readJsonFile(this.connectionPath(connectionId2), signal, "connection_not_found")
|
|
@@ -44168,9 +44464,9 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
44168
44464
|
const connection = await this.readConnection(connectionId2, signal);
|
|
44169
44465
|
signal.throwIfAborted();
|
|
44170
44466
|
try {
|
|
44171
|
-
await
|
|
44467
|
+
await unlink2(this.connectionPath(connection.connectionId));
|
|
44172
44468
|
signal.throwIfAborted();
|
|
44173
|
-
await
|
|
44469
|
+
await unlink2(this.channelIndexPath(connection.channelId));
|
|
44174
44470
|
} catch (cause) {
|
|
44175
44471
|
signal.throwIfAborted();
|
|
44176
44472
|
if (isNodeError(cause, "ENOENT")) {
|
|
@@ -44207,7 +44503,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
44207
44503
|
};
|
|
44208
44504
|
};
|
|
44209
44505
|
async function readOrCreateInstallationId(applicationDirectory, signal) {
|
|
44210
|
-
const pointerPath =
|
|
44506
|
+
const pointerPath = join23(applicationDirectory, "current.json");
|
|
44211
44507
|
try {
|
|
44212
44508
|
return decodeInstallationPointer(await readJsonFile(pointerPath, signal, "installation_not_found")).installationId;
|
|
44213
44509
|
} catch (cause) {
|
|
@@ -44299,10 +44595,10 @@ function validatePairingId(value) {
|
|
|
44299
44595
|
return value;
|
|
44300
44596
|
}
|
|
44301
44597
|
async function resolveDefaultWorkspace2(path2) {
|
|
44302
|
-
const requestedWorkspace =
|
|
44598
|
+
const requestedWorkspace = resolve8(path2);
|
|
44303
44599
|
try {
|
|
44304
44600
|
await mkdir6(requestedWorkspace, { recursive: true, mode: 448 });
|
|
44305
|
-
const defaultWorkspace = await
|
|
44601
|
+
const defaultWorkspace = await realpath12(requestedWorkspace);
|
|
44306
44602
|
const metadata = await stat10(defaultWorkspace);
|
|
44307
44603
|
if (!metadata.isDirectory()) {
|
|
44308
44604
|
throw new PairingClientError("invalid_workspace", "The default workspace is not a directory");
|
|
@@ -44545,10 +44841,10 @@ function loadMobiusRuntimeConnection(environment = process.env) {
|
|
|
44545
44841
|
});
|
|
44546
44842
|
}
|
|
44547
44843
|
async function resolveWorkspace(path2) {
|
|
44548
|
-
const requested =
|
|
44844
|
+
const requested = resolve9(path2);
|
|
44549
44845
|
try {
|
|
44550
44846
|
await mkdir7(requested, { recursive: true, mode: 448 });
|
|
44551
|
-
const resolved = await
|
|
44847
|
+
const resolved = await realpath13(requested);
|
|
44552
44848
|
const metadata = await stat11(resolved);
|
|
44553
44849
|
if (!metadata.isDirectory()) {
|
|
44554
44850
|
throw new MobiusRuntimeConfigurationError("The Runtime workspace is not a directory");
|