@moxt-ai/mobius 0.0.195 → 0.0.197
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp/agent-connection.d.ts.map +1 -1
- package/dist/acp/agent-connection.js +4 -3
- package/dist/acp/agent-connection.js.map +1 -1
- package/dist/acp/codex/app-server-client.d.ts.map +1 -1
- package/dist/acp/codex/app-server-client.js +4 -2
- package/dist/acp/codex/app-server-client.js.map +1 -1
- package/dist/agent-catalog/acp-readiness-probe.d.ts.map +1 -1
- package/dist/agent-catalog/acp-readiness-probe.js +4 -3
- package/dist/agent-catalog/acp-readiness-probe.js.map +1 -1
- package/dist/cli.js +532 -292
- package/dist/cli.js.map +4 -4
- package/dist/daemon-manager.d.ts.map +1 -1
- package/dist/daemon-manager.js +7 -17
- package/dist/daemon-manager.js.map +1 -1
- package/dist/filesystem/path-error.d.ts +5 -0
- package/dist/filesystem/path-error.d.ts.map +1 -0
- package/dist/filesystem/path-error.js +8 -0
- package/dist/filesystem/path-error.js.map +1 -0
- package/dist/filesystem/private-path.d.ts +3 -0
- package/dist/filesystem/private-path.d.ts.map +1 -0
- package/dist/filesystem/private-path.js +550 -0
- package/dist/filesystem/private-path.js.map +7 -0
- package/dist/index.js +504 -255
- package/dist/index.js.map +4 -4
- package/dist/native-sessions/codex-history.d.ts.map +1 -1
- package/dist/native-sessions/codex-history.js +4 -3
- package/dist/native-sessions/codex-history.js.map +1 -1
- package/dist/platform/contracts.d.ts +21 -0
- package/dist/platform/contracts.d.ts.map +1 -1
- package/dist/platform/index.d.ts.map +1 -1
- package/dist/platform/index.js +5 -3
- package/dist/platform/index.js.map +1 -1
- package/dist/platform/linux.d.ts.map +1 -1
- package/dist/platform/linux.js +2 -1
- package/dist/platform/linux.js.map +1 -1
- package/dist/platform/macos.d.ts.map +1 -1
- package/dist/platform/macos.js +2 -1
- package/dist/platform/macos.js.map +1 -1
- package/dist/platform/posix.d.ts +28 -1
- package/dist/platform/posix.d.ts.map +1 -1
- package/dist/platform/posix.js +91 -1
- package/dist/platform/posix.js.map +1 -1
- package/dist/platform/windows.d.ts +3 -0
- package/dist/platform/windows.d.ts.map +1 -0
- package/dist/platform/windows.js +174 -0
- package/dist/platform/windows.js.map +1 -0
- package/dist/process/executable.d.ts +7 -5
- package/dist/process/executable.d.ts.map +1 -1
- package/dist/process/executable.js +844 -386
- package/dist/process/executable.js.map +7 -1
- package/dist/process/process-error.d.ts +5 -0
- package/dist/process/process-error.d.ts.map +1 -0
- package/dist/process/process-error.js +9 -0
- package/dist/process/process-error.js.map +1 -0
- package/dist/runtime.js +504 -255
- package/dist/runtime.js.map +4 -4
- package/dist/storage/runtime-installation-store.d.ts.map +1 -1
- package/dist/storage/runtime-installation-store.js +3 -0
- package/dist/storage/runtime-installation-store.js.map +1 -1
- package/package.json +76 -70
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ var createAcpClient = (handler) => client({ name: "mobius" }).onRequest(
|
|
|
32
32
|
})).onNotification("cursor/update_todos", discardExtensionParams, async () => Promise.resolve()).onNotification("cursor/task", discardExtensionParams, async () => Promise.resolve()).onNotification("cursor/generate_image", discardExtensionParams, async () => Promise.resolve());
|
|
33
33
|
|
|
34
34
|
// src/config.ts
|
|
35
|
-
import { join as
|
|
35
|
+
import { join as join7, resolve as resolve4 } from "node:path";
|
|
36
36
|
|
|
37
37
|
// ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/external.js
|
|
38
38
|
var external_exports = {};
|
|
@@ -5060,7 +5060,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
5060
5060
|
var NONE = 0;
|
|
5061
5061
|
var ASSUMED = 1;
|
|
5062
5062
|
var PROVEN = 2;
|
|
5063
|
-
function isRecursive(inst, stack,
|
|
5063
|
+
function isRecursive(inst, stack, resolve10) {
|
|
5064
5064
|
const cached2 = recursive.get(inst);
|
|
5065
5065
|
if (cached2 !== void 0)
|
|
5066
5066
|
return cached2 ? PROVEN : NONE;
|
|
@@ -5070,7 +5070,7 @@ function isRecursive(inst, stack, resolve9) {
|
|
|
5070
5070
|
let result = NONE;
|
|
5071
5071
|
const check2 = (child2) => {
|
|
5072
5072
|
if (result !== PROVEN && child2?._zod) {
|
|
5073
|
-
const answer = isRecursive(child2, stack,
|
|
5073
|
+
const answer = isRecursive(child2, stack, resolve10);
|
|
5074
5074
|
if (answer > result)
|
|
5075
5075
|
result = answer;
|
|
5076
5076
|
}
|
|
@@ -5081,7 +5081,7 @@ function isRecursive(inst, stack, resolve9) {
|
|
|
5081
5081
|
const desc2 = Object.getOwnPropertyDescriptor(sh, key);
|
|
5082
5082
|
if (spread && !desc2.enumerable)
|
|
5083
5083
|
continue;
|
|
5084
|
-
const child2 = desc2.get ? ASSUMED : desc2.value?._zod ? isRecursive(desc2.value, stack,
|
|
5084
|
+
const child2 = desc2.get ? ASSUMED : desc2.value?._zod ? isRecursive(desc2.value, stack, resolve10) : NONE;
|
|
5085
5085
|
if (child2 > answer)
|
|
5086
5086
|
answer = child2;
|
|
5087
5087
|
}
|
|
@@ -5145,7 +5145,7 @@ function isRecursive(inst, stack, resolve9) {
|
|
|
5145
5145
|
break;
|
|
5146
5146
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
5147
5147
|
case "lazy": {
|
|
5148
|
-
const inner = def._cachedInner ?? (
|
|
5148
|
+
const inner = def._cachedInner ?? (resolve10 ? inst._zod.innerType : void 0);
|
|
5149
5149
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
5150
5150
|
break;
|
|
5151
5151
|
}
|
|
@@ -21830,17 +21830,31 @@ function normalizeAcpCapabilities(initialized) {
|
|
|
21830
21830
|
|
|
21831
21831
|
// src/process/executable.ts
|
|
21832
21832
|
import { spawn } from "node:child_process";
|
|
21833
|
-
import {
|
|
21834
|
-
import {
|
|
21835
|
-
import { join as join3, resolve } from "node:path";
|
|
21833
|
+
import { stat as stat2 } from "node:fs/promises";
|
|
21834
|
+
import { join as join5, resolve as resolve2 } from "node:path";
|
|
21836
21835
|
|
|
21837
21836
|
// src/platform/linux.ts
|
|
21838
|
-
import { constants, readdirSync, readFileSync } from "node:fs";
|
|
21839
|
-
import { access, readdir, readFile, realpath, stat } from "node:fs/promises";
|
|
21840
|
-
import { join } from "node:path";
|
|
21837
|
+
import { constants as constants2, readdirSync, readFileSync } from "node:fs";
|
|
21838
|
+
import { access as access2, readdir, readFile, realpath as realpath2, stat } from "node:fs/promises";
|
|
21839
|
+
import { join as join2 } from "node:path";
|
|
21841
21840
|
|
|
21842
21841
|
// src/platform/posix.ts
|
|
21843
21842
|
import { execFile } from "node:child_process";
|
|
21843
|
+
import { constants } from "node:fs";
|
|
21844
|
+
import { access, chmod, lstat, realpath, unlink } from "node:fs/promises";
|
|
21845
|
+
import { tmpdir } from "node:os";
|
|
21846
|
+
import { join } from "node:path";
|
|
21847
|
+
|
|
21848
|
+
// src/filesystem/path-error.ts
|
|
21849
|
+
var LocalPathError = class extends Error {
|
|
21850
|
+
code = "unsafe_local_path";
|
|
21851
|
+
constructor(message, options = {}) {
|
|
21852
|
+
super(message, options);
|
|
21853
|
+
this.name = "LocalPathError";
|
|
21854
|
+
}
|
|
21855
|
+
};
|
|
21856
|
+
|
|
21857
|
+
// src/platform/posix.ts
|
|
21844
21858
|
var PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
|
|
21845
21859
|
var PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
|
|
21846
21860
|
function parseProcessTable(output2) {
|
|
@@ -21885,6 +21899,81 @@ function processExists(processId) {
|
|
|
21885
21899
|
return false;
|
|
21886
21900
|
}
|
|
21887
21901
|
}
|
|
21902
|
+
function signalCapturedProcesses(processes, rootProcessId, signal) {
|
|
21903
|
+
const processIds = new Set(processes.map((identity2) => identity2.processId));
|
|
21904
|
+
const signalledGroups = /* @__PURE__ */ new Set();
|
|
21905
|
+
for (const identity2 of processes) {
|
|
21906
|
+
const isRootProcessGroup = identity2.processGroupId === rootProcessId;
|
|
21907
|
+
if (!isRootProcessGroup && !processIds.has(identity2.processGroupId) || signalledGroups.has(identity2.processGroupId)) {
|
|
21908
|
+
continue;
|
|
21909
|
+
}
|
|
21910
|
+
try {
|
|
21911
|
+
process.kill(-identity2.processGroupId, signal);
|
|
21912
|
+
signalledGroups.add(identity2.processGroupId);
|
|
21913
|
+
} catch {
|
|
21914
|
+
}
|
|
21915
|
+
}
|
|
21916
|
+
for (const identity2 of processes) {
|
|
21917
|
+
if (identity2.processId === rootProcessId || identity2.processGroupId === rootProcessId || signalledGroups.has(identity2.processGroupId)) {
|
|
21918
|
+
continue;
|
|
21919
|
+
}
|
|
21920
|
+
try {
|
|
21921
|
+
process.kill(identity2.processId, signal);
|
|
21922
|
+
} catch {
|
|
21923
|
+
}
|
|
21924
|
+
}
|
|
21925
|
+
}
|
|
21926
|
+
function terminateProcess(child2, signal) {
|
|
21927
|
+
if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
|
|
21928
|
+
return;
|
|
21929
|
+
}
|
|
21930
|
+
try {
|
|
21931
|
+
process.kill(-child2.pid, signal);
|
|
21932
|
+
return;
|
|
21933
|
+
} catch {
|
|
21934
|
+
}
|
|
21935
|
+
child2.kill(signal);
|
|
21936
|
+
}
|
|
21937
|
+
async function removeControlSocket(path2) {
|
|
21938
|
+
try {
|
|
21939
|
+
await unlink(path2);
|
|
21940
|
+
} catch (cause) {
|
|
21941
|
+
if (!(cause instanceof Error) || !("code" in cause) || cause.code !== "ENOENT") {
|
|
21942
|
+
throw cause;
|
|
21943
|
+
}
|
|
21944
|
+
}
|
|
21945
|
+
}
|
|
21946
|
+
var posixOperations = {
|
|
21947
|
+
controlSocketPath: (installationHash) => join(tmpdir(), `mobius-${installationHash}.sock`),
|
|
21948
|
+
prepareControlSocket: removeControlSocket,
|
|
21949
|
+
secureControlSocket: async (path2) => {
|
|
21950
|
+
await chmod(path2, 384);
|
|
21951
|
+
},
|
|
21952
|
+
removeControlSocket,
|
|
21953
|
+
pathDelimiter: ":",
|
|
21954
|
+
environmentValue: (environment, name2) => environment[name2],
|
|
21955
|
+
executableExtensions: () => [""],
|
|
21956
|
+
resolveExecutableTarget: async (path2) => {
|
|
21957
|
+
const target = await realpath(path2);
|
|
21958
|
+
await access(target, constants.X_OK);
|
|
21959
|
+
return target;
|
|
21960
|
+
},
|
|
21961
|
+
executableLaunch: (command, args) => ({ command, arguments: args }),
|
|
21962
|
+
spawnOptions: { detached: true, windowsHide: true },
|
|
21963
|
+
signalCapturedProcesses,
|
|
21964
|
+
terminateProcess,
|
|
21965
|
+
validatePathPermissions: async (path2, directory, privateAccess, signal) => {
|
|
21966
|
+
signal.throwIfAborted();
|
|
21967
|
+
const metadata = await lstat(path2);
|
|
21968
|
+
if (process.getuid === void 0 || metadata.uid !== process.getuid()) {
|
|
21969
|
+
throw new LocalPathError("Path is not user-owned");
|
|
21970
|
+
}
|
|
21971
|
+
if (privateAccess) {
|
|
21972
|
+
await chmod(path2, directory ? 448 : 384);
|
|
21973
|
+
}
|
|
21974
|
+
signal.throwIfAborted();
|
|
21975
|
+
}
|
|
21976
|
+
};
|
|
21888
21977
|
|
|
21889
21978
|
// src/platform/linux.ts
|
|
21890
21979
|
function appendLinuxProcessTableEntry(entries, processId, encoded) {
|
|
@@ -21916,7 +22005,7 @@ async function readLinuxProcessTable() {
|
|
|
21916
22005
|
appendLinuxProcessTableEntry(
|
|
21917
22006
|
entries,
|
|
21918
22007
|
processId,
|
|
21919
|
-
await readFile(
|
|
22008
|
+
await readFile(join2("/proc", directory.name, "stat"), "utf8")
|
|
21920
22009
|
);
|
|
21921
22010
|
} catch {
|
|
21922
22011
|
}
|
|
@@ -21941,7 +22030,7 @@ function readLinuxProcessTableSynchronously() {
|
|
|
21941
22030
|
appendLinuxProcessTableEntry(
|
|
21942
22031
|
entries,
|
|
21943
22032
|
processId,
|
|
21944
|
-
readFileSync(
|
|
22033
|
+
readFileSync(join2("/proc", directory.name, "stat"), "utf8")
|
|
21945
22034
|
);
|
|
21946
22035
|
} catch {
|
|
21947
22036
|
}
|
|
@@ -21957,11 +22046,11 @@ async function readLinuxProcessTableWithFallback() {
|
|
|
21957
22046
|
}
|
|
21958
22047
|
for (const candidate of ["/usr/bin/ps", "/bin/ps", "/run/current-system/sw/bin/ps"]) {
|
|
21959
22048
|
try {
|
|
21960
|
-
const resolvedPath = await
|
|
22049
|
+
const resolvedPath = await realpath2(candidate);
|
|
21961
22050
|
if (!(await stat(resolvedPath)).isFile()) {
|
|
21962
22051
|
continue;
|
|
21963
22052
|
}
|
|
21964
|
-
await
|
|
22053
|
+
await access2(resolvedPath, constants2.X_OK);
|
|
21965
22054
|
} catch {
|
|
21966
22055
|
continue;
|
|
21967
22056
|
}
|
|
@@ -21974,7 +22063,7 @@ async function readLinuxProcessTableWithFallback() {
|
|
|
21974
22063
|
}
|
|
21975
22064
|
function processExists2(processId) {
|
|
21976
22065
|
try {
|
|
21977
|
-
const encoded = readFileSync(
|
|
22066
|
+
const encoded = readFileSync(join2("/proc", processId.toString(), "stat"), "utf8");
|
|
21978
22067
|
const closingParenthesis = encoded.lastIndexOf(")");
|
|
21979
22068
|
if (closingParenthesis >= 0) {
|
|
21980
22069
|
const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
|
|
@@ -21987,6 +22076,7 @@ function processExists2(processId) {
|
|
|
21987
22076
|
return processExists(processId);
|
|
21988
22077
|
}
|
|
21989
22078
|
var linuxPlatform = {
|
|
22079
|
+
...posixOperations,
|
|
21990
22080
|
readProcessTable: readLinuxProcessTableWithFallback,
|
|
21991
22081
|
readProcessTableSynchronously: readLinuxProcessTableSynchronously,
|
|
21992
22082
|
processExists: processExists2,
|
|
@@ -22018,7 +22108,7 @@ var linuxPlatform = {
|
|
|
22018
22108
|
};
|
|
22019
22109
|
|
|
22020
22110
|
// src/platform/macos.ts
|
|
22021
|
-
import { isAbsolute, join as
|
|
22111
|
+
import { isAbsolute, join as join3 } from "node:path";
|
|
22022
22112
|
var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
|
|
22023
22113
|
"WorkBuddy.app",
|
|
22024
22114
|
"Contents",
|
|
@@ -22029,14 +22119,15 @@ var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
|
|
|
22029
22119
|
"codebuddy"
|
|
22030
22120
|
]);
|
|
22031
22121
|
var macosPlatform = {
|
|
22122
|
+
...posixOperations,
|
|
22032
22123
|
readProcessTable: () => readProcessTableWithPs("/bin/ps"),
|
|
22033
22124
|
readProcessTableSynchronously: () => [],
|
|
22034
22125
|
processExists,
|
|
22035
22126
|
workBuddyExecutablePaths: (environment) => {
|
|
22036
|
-
const paths = [
|
|
22127
|
+
const paths = [join3("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
|
|
22037
22128
|
const homeDirectory = environment["HOME"];
|
|
22038
22129
|
if (homeDirectory !== void 0 && isAbsolute(homeDirectory)) {
|
|
22039
|
-
paths.unshift(
|
|
22130
|
+
paths.unshift(join3(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
|
|
22040
22131
|
}
|
|
22041
22132
|
return paths;
|
|
22042
22133
|
},
|
|
@@ -22066,8 +22157,199 @@ var macosPlatform = {
|
|
|
22066
22157
|
}
|
|
22067
22158
|
};
|
|
22068
22159
|
|
|
22160
|
+
// src/platform/windows.ts
|
|
22161
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
22162
|
+
import { readFile as readFile2, realpath as realpath3 } from "node:fs/promises";
|
|
22163
|
+
import { dirname, extname, join as join4, resolve } from "node:path";
|
|
22164
|
+
import { promisify } from "node:util";
|
|
22165
|
+
|
|
22166
|
+
// src/process/process-error.ts
|
|
22167
|
+
var ProcessExecutionError = class extends Error {
|
|
22168
|
+
code;
|
|
22169
|
+
constructor(code, message, options = {}) {
|
|
22170
|
+
super(message, options);
|
|
22171
|
+
this.code = code;
|
|
22172
|
+
this.name = "ProcessExecutionError";
|
|
22173
|
+
}
|
|
22174
|
+
};
|
|
22175
|
+
|
|
22176
|
+
// src/platform/windows.ts
|
|
22177
|
+
var execute = promisify(execFile2);
|
|
22178
|
+
function environmentValue(environment, name2) {
|
|
22179
|
+
return Object.entries(environment).find(([key]) => key.toUpperCase() === name2.toUpperCase())?.[1];
|
|
22180
|
+
}
|
|
22181
|
+
function executableExtensions(executableName, environment) {
|
|
22182
|
+
if (/\.[a-zA-Z0-9]+$/.test(executableName)) {
|
|
22183
|
+
return [""];
|
|
22184
|
+
}
|
|
22185
|
+
const configured = environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD";
|
|
22186
|
+
const extensions = configured.split(";").map((extension) => extension.trim()).filter((extension) => extension.length > 0).map((extension) => extension.startsWith(".") ? extension : `.${extension}`);
|
|
22187
|
+
return extensions.length > 0 ? extensions : [".EXE"];
|
|
22188
|
+
}
|
|
22189
|
+
async function resolveExecutableTarget(path2) {
|
|
22190
|
+
let resolvedPath;
|
|
22191
|
+
try {
|
|
22192
|
+
resolvedPath = await realpath3(extname(path2) === "" ? `${path2}.cmd` : path2);
|
|
22193
|
+
} catch (cause) {
|
|
22194
|
+
if (extname(path2) !== "" || !(cause instanceof Error) || !("code" in cause) || cause.code !== "ENOENT") {
|
|
22195
|
+
throw cause;
|
|
22196
|
+
}
|
|
22197
|
+
resolvedPath = await realpath3(path2);
|
|
22198
|
+
}
|
|
22199
|
+
if (extname(resolvedPath).toLowerCase() === ".cmd") {
|
|
22200
|
+
const shim = await readFile2(resolvedPath, "utf8");
|
|
22201
|
+
const script = /"%_prog%"\s+"%dp0%[\\/]([^"\r\n]+\.(?:js|mjs|cjs))"\s+%\*/iu.exec(shim)?.[1];
|
|
22202
|
+
if (script !== void 0 && shim.includes("SET dp0=%~dp0")) {
|
|
22203
|
+
resolvedPath = await realpath3(resolve(dirname(resolvedPath), script));
|
|
22204
|
+
} else {
|
|
22205
|
+
const pnpmScript = /^\s*node\s+"%~dp0[\\/]([^"\r\n]+\.(?:js|mjs|cjs))"\s+%\*\s*$/imu.exec(shim)?.[1];
|
|
22206
|
+
if (pnpmScript === void 0 || !shim.includes("@SETLOCAL")) {
|
|
22207
|
+
throw new ProcessExecutionError(
|
|
22208
|
+
"process_unsupported_script",
|
|
22209
|
+
"Use a native executable or a verified Node entrypoint"
|
|
22210
|
+
);
|
|
22211
|
+
}
|
|
22212
|
+
resolvedPath = await realpath3(resolve(dirname(resolvedPath), pnpmScript));
|
|
22213
|
+
}
|
|
22214
|
+
}
|
|
22215
|
+
return resolvedPath;
|
|
22216
|
+
}
|
|
22217
|
+
function executableLaunch(command, args) {
|
|
22218
|
+
if (/\.(?:js|mjs|cjs)$/iu.test(command)) {
|
|
22219
|
+
return { command: process.execPath, arguments: [command, ...args] };
|
|
22220
|
+
}
|
|
22221
|
+
if (/\.(?:cmd|bat)$/iu.test(command)) {
|
|
22222
|
+
throw new ProcessExecutionError(
|
|
22223
|
+
"process_unsupported_script",
|
|
22224
|
+
"Use a native executable or a verified Node entrypoint"
|
|
22225
|
+
);
|
|
22226
|
+
}
|
|
22227
|
+
return { command, arguments: args };
|
|
22228
|
+
}
|
|
22229
|
+
function readProcessTable() {
|
|
22230
|
+
const systemRoot = environmentValue(process.env, "SystemRoot");
|
|
22231
|
+
if (systemRoot === void 0) {
|
|
22232
|
+
return Promise.resolve([]);
|
|
22233
|
+
}
|
|
22234
|
+
return new Promise((resolveTable) => {
|
|
22235
|
+
execFile2(
|
|
22236
|
+
join4(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
22237
|
+
[
|
|
22238
|
+
"-NoLogo",
|
|
22239
|
+
"-NoProfile",
|
|
22240
|
+
"-NonInteractive",
|
|
22241
|
+
"-Command",
|
|
22242
|
+
"Get-CimInstance Win32_Process | ForEach-Object { '{0} {1} {0}' -f $_.ProcessId, $_.ParentProcessId }"
|
|
22243
|
+
],
|
|
22244
|
+
{
|
|
22245
|
+
encoding: "utf8",
|
|
22246
|
+
windowsHide: true,
|
|
22247
|
+
timeout: 1e4,
|
|
22248
|
+
signal: AbortSignal.timeout(1e4),
|
|
22249
|
+
maxBuffer: 1024 * 1024
|
|
22250
|
+
},
|
|
22251
|
+
(error62, stdout) => resolveTable(error62 === null ? parseProcessTable(stdout) : [])
|
|
22252
|
+
);
|
|
22253
|
+
});
|
|
22254
|
+
}
|
|
22255
|
+
function signalCapturedProcesses2(processes, _rootProcessId, signal) {
|
|
22256
|
+
for (const identity2 of [...processes].reverse()) {
|
|
22257
|
+
try {
|
|
22258
|
+
process.kill(identity2.processId, signal);
|
|
22259
|
+
} catch {
|
|
22260
|
+
}
|
|
22261
|
+
}
|
|
22262
|
+
}
|
|
22263
|
+
function terminateProcess2(child2, signal) {
|
|
22264
|
+
if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
|
|
22265
|
+
return;
|
|
22266
|
+
}
|
|
22267
|
+
child2.kill(signal);
|
|
22268
|
+
}
|
|
22269
|
+
var windowsPermissions = `
|
|
22270
|
+
$ErrorActionPreference = 'Stop'
|
|
22271
|
+
Import-Module (Join-Path $PSHOME 'Modules/Microsoft.PowerShell.Security/Microsoft.PowerShell.Security.psd1')
|
|
22272
|
+
$item = Get-Item -LiteralPath $env:MOBIUS_PERMISSION_PATH -Force
|
|
22273
|
+
if (($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0) { throw 'Unsafe path' }
|
|
22274
|
+
$sid = [Security.Principal.WindowsIdentity]::GetCurrent().User
|
|
22275
|
+
$acl = Get-Acl -LiteralPath $item.FullName
|
|
22276
|
+
$owner = $acl.GetOwner([Security.Principal.SecurityIdentifier])
|
|
22277
|
+
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' }
|
|
22278
|
+
if ($env:MOBIUS_PERMISSION_PRIVATE -eq '1') {
|
|
22279
|
+
if ($item.PSIsContainer) {
|
|
22280
|
+
$private = New-Object Security.AccessControl.DirectorySecurity
|
|
22281
|
+
$rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'ContainerInherit,ObjectInherit', 'None', 'Allow')
|
|
22282
|
+
} else {
|
|
22283
|
+
$private = New-Object Security.AccessControl.FileSecurity
|
|
22284
|
+
$rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'Allow')
|
|
22285
|
+
}
|
|
22286
|
+
$private.SetOwner($sid)
|
|
22287
|
+
$private.SetAccessRuleProtection($true, $false)
|
|
22288
|
+
$private.AddAccessRule($rule)
|
|
22289
|
+
Set-Acl -LiteralPath $item.FullName -AclObject $private
|
|
22290
|
+
}
|
|
22291
|
+
`;
|
|
22292
|
+
async function validatePathPermissions(path2, _directory, privateAccess, signal) {
|
|
22293
|
+
signal.throwIfAborted();
|
|
22294
|
+
const systemRoot = environmentValue(process.env, "SystemRoot");
|
|
22295
|
+
if (systemRoot === void 0) {
|
|
22296
|
+
throw new LocalPathError("Windows system directory is unavailable");
|
|
22297
|
+
}
|
|
22298
|
+
try {
|
|
22299
|
+
await execute(
|
|
22300
|
+
join4(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
22301
|
+
[
|
|
22302
|
+
"-NoLogo",
|
|
22303
|
+
"-NoProfile",
|
|
22304
|
+
"-NonInteractive",
|
|
22305
|
+
"-EncodedCommand",
|
|
22306
|
+
Buffer.from(windowsPermissions, "utf16le").toString("base64")
|
|
22307
|
+
],
|
|
22308
|
+
{
|
|
22309
|
+
env: {
|
|
22310
|
+
...process.env,
|
|
22311
|
+
MOBIUS_PERMISSION_PATH: path2,
|
|
22312
|
+
MOBIUS_PERMISSION_PRIVATE: privateAccess ? "1" : "0"
|
|
22313
|
+
},
|
|
22314
|
+
windowsHide: true,
|
|
22315
|
+
signal: AbortSignal.any([signal, AbortSignal.timeout(1e4)]),
|
|
22316
|
+
timeout: 1e4,
|
|
22317
|
+
maxBuffer: 16384
|
|
22318
|
+
}
|
|
22319
|
+
);
|
|
22320
|
+
} catch (cause) {
|
|
22321
|
+
signal.throwIfAborted();
|
|
22322
|
+
throw new LocalPathError("The local path permissions could not be secured", { cause });
|
|
22323
|
+
}
|
|
22324
|
+
}
|
|
22325
|
+
var windowsPlatform = {
|
|
22326
|
+
controlSocketPath: (installationHash) => `\\\\.\\pipe\\mobius-${installationHash}`,
|
|
22327
|
+
prepareControlSocket: async () => {
|
|
22328
|
+
},
|
|
22329
|
+
secureControlSocket: async () => {
|
|
22330
|
+
},
|
|
22331
|
+
removeControlSocket: async () => {
|
|
22332
|
+
},
|
|
22333
|
+
pathDelimiter: ";",
|
|
22334
|
+
environmentValue,
|
|
22335
|
+
executableExtensions,
|
|
22336
|
+
resolveExecutableTarget,
|
|
22337
|
+
executableLaunch,
|
|
22338
|
+
spawnOptions: { detached: false, windowsHide: true },
|
|
22339
|
+
signalCapturedProcesses: signalCapturedProcesses2,
|
|
22340
|
+
terminateProcess: terminateProcess2,
|
|
22341
|
+
validatePathPermissions,
|
|
22342
|
+
readProcessTable,
|
|
22343
|
+
readProcessTableSynchronously: () => [],
|
|
22344
|
+
processExists,
|
|
22345
|
+
workBuddyExecutablePaths: () => [],
|
|
22346
|
+
openCodeArchives: {},
|
|
22347
|
+
grokDependencies: {}
|
|
22348
|
+
};
|
|
22349
|
+
|
|
22069
22350
|
// src/platform/index.ts
|
|
22070
22351
|
var fallbackPlatform = {
|
|
22352
|
+
...posixOperations,
|
|
22071
22353
|
readProcessTable: () => readProcessTableWithPs("/usr/bin/ps"),
|
|
22072
22354
|
readProcessTableSynchronously: () => [],
|
|
22073
22355
|
processExists,
|
|
@@ -22078,7 +22360,7 @@ var fallbackPlatform = {
|
|
|
22078
22360
|
var platforms = /* @__PURE__ */ new Map([
|
|
22079
22361
|
["linux", linuxPlatform],
|
|
22080
22362
|
["darwin", macosPlatform],
|
|
22081
|
-
["win32",
|
|
22363
|
+
["win32", windowsPlatform]
|
|
22082
22364
|
]);
|
|
22083
22365
|
function platformSupportFor(platform) {
|
|
22084
22366
|
return platforms.get(platform) ?? fallbackPlatform;
|
|
@@ -22117,14 +22399,6 @@ var ResolvedExecutable = class {
|
|
|
22117
22399
|
this.path = identity2.realPath;
|
|
22118
22400
|
}
|
|
22119
22401
|
};
|
|
22120
|
-
var ProcessExecutionError = class extends Error {
|
|
22121
|
-
code;
|
|
22122
|
-
constructor(code, message, options = {}) {
|
|
22123
|
-
super(message, options);
|
|
22124
|
-
this.code = code;
|
|
22125
|
-
this.name = "ProcessExecutionError";
|
|
22126
|
-
}
|
|
22127
|
-
};
|
|
22128
22402
|
var ProcessResult = class {
|
|
22129
22403
|
stderr;
|
|
22130
22404
|
stdout;
|
|
@@ -22133,28 +22407,14 @@ var ProcessResult = class {
|
|
|
22133
22407
|
this.stdout = stdout;
|
|
22134
22408
|
}
|
|
22135
22409
|
};
|
|
22136
|
-
function executableExtensions(executableName, environment, platform) {
|
|
22137
|
-
if (platform !== "win32") {
|
|
22138
|
-
return [""];
|
|
22139
|
-
}
|
|
22140
|
-
if (/\.[a-zA-Z0-9]+$/.test(executableName)) {
|
|
22141
|
-
return [""];
|
|
22142
|
-
}
|
|
22143
|
-
const configured = environment["PATHEXT"] ?? ".COM;.EXE;.BAT;.CMD";
|
|
22144
|
-
const extensions = configured.split(";").map((extension) => extension.trim()).filter((extension) => extension.length > 0).map((extension) => extension.startsWith(".") ? extension : `.${extension}`);
|
|
22145
|
-
return extensions.length > 0 ? extensions : [".EXE"];
|
|
22146
|
-
}
|
|
22147
22410
|
async function resolveExecutablePath(requestedPath2, platform = process.platform) {
|
|
22148
|
-
const absoluteRequestedPath =
|
|
22411
|
+
const absoluteRequestedPath = resolve2(requestedPath2);
|
|
22149
22412
|
try {
|
|
22150
|
-
const resolvedPath = await
|
|
22413
|
+
const resolvedPath = await platformSupportFor(platform).resolveExecutableTarget(absoluteRequestedPath);
|
|
22151
22414
|
const metadata = await stat2(resolvedPath);
|
|
22152
22415
|
if (!metadata.isFile()) {
|
|
22153
22416
|
return null;
|
|
22154
22417
|
}
|
|
22155
|
-
if (platform !== "win32") {
|
|
22156
|
-
await access2(resolvedPath, constants2.X_OK);
|
|
22157
|
-
}
|
|
22158
22418
|
return new ResolvedExecutable(
|
|
22159
22419
|
new ExecutableIdentity(
|
|
22160
22420
|
absoluteRequestedPath,
|
|
@@ -22170,15 +22430,16 @@ async function resolveExecutablePath(requestedPath2, platform = process.platform
|
|
|
22170
22430
|
}
|
|
22171
22431
|
}
|
|
22172
22432
|
async function findExecutableOnPath(executableName, environment, platform = process.platform) {
|
|
22173
|
-
const
|
|
22174
|
-
const
|
|
22175
|
-
const
|
|
22433
|
+
const support = platformSupportFor(platform);
|
|
22434
|
+
const encodedPath = support.environmentValue(environment, "PATH") ?? "";
|
|
22435
|
+
const separator = support.pathDelimiter;
|
|
22436
|
+
const extensions = support.executableExtensions(executableName, environment);
|
|
22176
22437
|
for (const entry of encodedPath.split(separator)) {
|
|
22177
22438
|
if (entry.length === 0) {
|
|
22178
22439
|
continue;
|
|
22179
22440
|
}
|
|
22180
22441
|
for (const extension of extensions) {
|
|
22181
|
-
const requestedPath2 =
|
|
22442
|
+
const requestedPath2 = resolve2(join5(entry, `${executableName}${extension}`));
|
|
22182
22443
|
const executable = await resolveExecutablePath(requestedPath2, platform);
|
|
22183
22444
|
if (executable !== null) {
|
|
22184
22445
|
return executable;
|
|
@@ -22199,7 +22460,7 @@ function appendBounded(chunks, chunk, currentBytes, limitBytes) {
|
|
|
22199
22460
|
chunks.push(chunk);
|
|
22200
22461
|
return nextBytes;
|
|
22201
22462
|
}
|
|
22202
|
-
function
|
|
22463
|
+
function readProcessTable2() {
|
|
22203
22464
|
return hostPlatform.readProcessTable();
|
|
22204
22465
|
}
|
|
22205
22466
|
function selectProcessTree(entries, rootProcessId) {
|
|
@@ -22234,38 +22495,14 @@ function mergeProcessTrees(captured, current) {
|
|
|
22234
22495
|
return [...processes.values()];
|
|
22235
22496
|
}
|
|
22236
22497
|
async function captureProcessTree(child2) {
|
|
22237
|
-
if (
|
|
22498
|
+
if (child2.pid === void 0) {
|
|
22238
22499
|
return [];
|
|
22239
22500
|
}
|
|
22240
22501
|
const entries = hostPlatform.readProcessTableSynchronously();
|
|
22241
22502
|
if (entries.length > 0) {
|
|
22242
22503
|
return selectProcessTree(entries, child2.pid);
|
|
22243
22504
|
}
|
|
22244
|
-
return selectProcessTree(await
|
|
22245
|
-
}
|
|
22246
|
-
function signalCapturedProcessGroups(processes, rootProcessId, signal) {
|
|
22247
|
-
const processIds = new Set(processes.map((identity2) => identity2.processId));
|
|
22248
|
-
const signalledGroups = /* @__PURE__ */ new Set();
|
|
22249
|
-
for (const identity2 of processes) {
|
|
22250
|
-
const isRootProcessGroup = identity2.processGroupId === rootProcessId;
|
|
22251
|
-
if (!isRootProcessGroup && !processIds.has(identity2.processGroupId) || signalledGroups.has(identity2.processGroupId)) {
|
|
22252
|
-
continue;
|
|
22253
|
-
}
|
|
22254
|
-
try {
|
|
22255
|
-
process.kill(-identity2.processGroupId, signal);
|
|
22256
|
-
signalledGroups.add(identity2.processGroupId);
|
|
22257
|
-
} catch {
|
|
22258
|
-
}
|
|
22259
|
-
}
|
|
22260
|
-
for (const identity2 of processes) {
|
|
22261
|
-
if (identity2.processId === rootProcessId || identity2.processGroupId === rootProcessId || signalledGroups.has(identity2.processGroupId)) {
|
|
22262
|
-
continue;
|
|
22263
|
-
}
|
|
22264
|
-
try {
|
|
22265
|
-
process.kill(identity2.processId, signal);
|
|
22266
|
-
} catch {
|
|
22267
|
-
}
|
|
22268
|
-
}
|
|
22505
|
+
return selectProcessTree(await readProcessTable2(), child2.pid);
|
|
22269
22506
|
}
|
|
22270
22507
|
async function waitForCapturedProcessesExit(processes, rootProcessId) {
|
|
22271
22508
|
const processIds = processes.map((identity2) => identity2.processId).filter((processId) => processId !== rootProcessId);
|
|
@@ -22273,36 +22510,10 @@ async function waitForCapturedProcessesExit(processes, rootProcessId) {
|
|
|
22273
22510
|
if (processIds.every((processId) => !hostPlatform.processExists(processId))) {
|
|
22274
22511
|
return true;
|
|
22275
22512
|
}
|
|
22276
|
-
await
|
|
22513
|
+
await readProcessTable2();
|
|
22277
22514
|
}
|
|
22278
22515
|
return processIds.every((processId) => !hostPlatform.processExists(processId));
|
|
22279
22516
|
}
|
|
22280
|
-
function terminateProcess(child2) {
|
|
22281
|
-
if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
|
|
22282
|
-
return;
|
|
22283
|
-
}
|
|
22284
|
-
if (process.platform !== "win32") {
|
|
22285
|
-
try {
|
|
22286
|
-
process.kill(-child2.pid, "SIGTERM");
|
|
22287
|
-
return;
|
|
22288
|
-
} catch {
|
|
22289
|
-
}
|
|
22290
|
-
}
|
|
22291
|
-
child2.kill("SIGTERM");
|
|
22292
|
-
}
|
|
22293
|
-
function forceTerminateProcess(child2) {
|
|
22294
|
-
if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
|
|
22295
|
-
return;
|
|
22296
|
-
}
|
|
22297
|
-
if (process.platform !== "win32") {
|
|
22298
|
-
try {
|
|
22299
|
-
process.kill(-child2.pid, "SIGKILL");
|
|
22300
|
-
return;
|
|
22301
|
-
} catch {
|
|
22302
|
-
}
|
|
22303
|
-
}
|
|
22304
|
-
child2.kill("SIGKILL");
|
|
22305
|
-
}
|
|
22306
22517
|
async function stopProcessTree(child2, capturedProcesses = []) {
|
|
22307
22518
|
const childProcessId = child2.pid;
|
|
22308
22519
|
if (childProcessId === void 0) {
|
|
@@ -22313,8 +22524,8 @@ async function stopProcessTree(child2, capturedProcesses = []) {
|
|
|
22313
22524
|
if (childExited && processes.length === 0) {
|
|
22314
22525
|
return;
|
|
22315
22526
|
}
|
|
22316
|
-
|
|
22317
|
-
terminateProcess(child2);
|
|
22527
|
+
hostPlatform.signalCapturedProcesses(processes, childProcessId, GRACEFUL_STOP_SIGNAL);
|
|
22528
|
+
hostPlatform.terminateProcess(child2, "SIGTERM");
|
|
22318
22529
|
const [exitedAfterTermination, descendantsExitedAfterTermination] = await Promise.all([
|
|
22319
22530
|
waitForProcessExit(child2, PROCESS_GRACEFUL_STOP_TIMEOUT_MILLISECONDS),
|
|
22320
22531
|
waitForCapturedProcessesExit(processes, childProcessId)
|
|
@@ -22322,8 +22533,8 @@ async function stopProcessTree(child2, capturedProcesses = []) {
|
|
|
22322
22533
|
if (exitedAfterTermination && descendantsExitedAfterTermination) {
|
|
22323
22534
|
return;
|
|
22324
22535
|
}
|
|
22325
|
-
|
|
22326
|
-
|
|
22536
|
+
hostPlatform.signalCapturedProcesses(processes, childProcessId, FORCED_STOP_SIGNAL);
|
|
22537
|
+
hostPlatform.terminateProcess(child2, "SIGKILL");
|
|
22327
22538
|
const [exitedAfterForce, descendantsExitedAfterForce] = await Promise.all([
|
|
22328
22539
|
waitForProcessExit(child2, PROCESS_FORCED_STOP_TIMEOUT_MILLISECONDS),
|
|
22329
22540
|
waitForCapturedProcessesExit(processes, childProcessId)
|
|
@@ -22358,9 +22569,10 @@ function waitForProcessExit(child2, timeoutMilliseconds) {
|
|
|
22358
22569
|
async function runBoundedProcess(options) {
|
|
22359
22570
|
options.signal.throwIfAborted();
|
|
22360
22571
|
const outputLimitBytes = options.outputLimitBytes ?? DEFAULT_OUTPUT_LIMIT_BYTES;
|
|
22361
|
-
const
|
|
22572
|
+
const launch = executableLaunch2(options.command, options.arguments);
|
|
22573
|
+
const child2 = spawn(launch.command, [...launch.arguments], {
|
|
22362
22574
|
cwd: options.cwd,
|
|
22363
|
-
|
|
22575
|
+
...hostPlatform.spawnOptions,
|
|
22364
22576
|
env: { ...options.environment },
|
|
22365
22577
|
shell: false,
|
|
22366
22578
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -22469,6 +22681,10 @@ async function runBoundedProcess(options) {
|
|
|
22469
22681
|
}
|
|
22470
22682
|
}
|
|
22471
22683
|
}
|
|
22684
|
+
function executableLaunch2(command, args) {
|
|
22685
|
+
return hostPlatform.executableLaunch(command, args);
|
|
22686
|
+
}
|
|
22687
|
+
var platformSpawnOptions = hostPlatform.spawnOptions;
|
|
22472
22688
|
|
|
22473
22689
|
// src/agent-catalog/local-agent.ts
|
|
22474
22690
|
function readTrustedIdentity(path2) {
|
|
@@ -22623,25 +22839,25 @@ var LocalAgentCatalog = class {
|
|
|
22623
22839
|
|
|
22624
22840
|
// src/storage/state-directory.ts
|
|
22625
22841
|
import { homedir } from "node:os";
|
|
22626
|
-
import { join as
|
|
22842
|
+
import { join as join6, resolve as resolve3 } from "node:path";
|
|
22627
22843
|
function readStateDirectory(environment = process.env) {
|
|
22628
22844
|
const configured = environment["MOBIUS_STATE_DIRECTORY"]?.trim();
|
|
22629
22845
|
if (configured !== void 0 && configured.length > 0) {
|
|
22630
|
-
return
|
|
22846
|
+
return resolve3(configured);
|
|
22631
22847
|
}
|
|
22632
|
-
return
|
|
22848
|
+
return join6(homedir(), ".mobius");
|
|
22633
22849
|
}
|
|
22634
22850
|
|
|
22635
22851
|
// src/config.ts
|
|
22636
22852
|
function loadDefaultWorkspace(environment = process.env) {
|
|
22637
22853
|
const { MOBIUS_DEFAULT_WORKSPACE: configuredWorkspace } = environment;
|
|
22638
|
-
return configuredWorkspace ??
|
|
22854
|
+
return configuredWorkspace ?? join7(readStateDirectory(environment), "workspace");
|
|
22639
22855
|
}
|
|
22640
22856
|
var DaemonLocalContext = class {
|
|
22641
22857
|
environment;
|
|
22642
22858
|
stateDirectory;
|
|
22643
22859
|
constructor(stateDirectory, environment = process.env) {
|
|
22644
|
-
this.stateDirectory =
|
|
22860
|
+
this.stateDirectory = resolve4(stateDirectory);
|
|
22645
22861
|
this.environment = Object.freeze({ ...environment, MOBIUS_STATE_DIRECTORY: this.stateDirectory });
|
|
22646
22862
|
}
|
|
22647
22863
|
};
|
|
@@ -22811,7 +23027,7 @@ import {
|
|
|
22811
23027
|
} from "@agentclientprotocol/sdk";
|
|
22812
23028
|
|
|
22813
23029
|
// src/authorization/local-raster.ts
|
|
22814
|
-
import { open as open2, readFile as
|
|
23030
|
+
import { open as open2, readFile as readFile3, realpath as realpath4, stat as stat3 } from "node:fs/promises";
|
|
22815
23031
|
import { basename, isAbsolute as isAbsolute2, normalize } from "node:path";
|
|
22816
23032
|
import { fileURLToPath } from "node:url";
|
|
22817
23033
|
var MAX_LOCAL_RASTER_BYTES = 128 * 1024 * 1024;
|
|
@@ -22834,7 +23050,7 @@ var LocalRasterImage = class {
|
|
|
22834
23050
|
this.sourceUri = sourceUri;
|
|
22835
23051
|
}
|
|
22836
23052
|
base64 = async () => {
|
|
22837
|
-
const bytes = this.bytes ?? new Uint8Array(await
|
|
23053
|
+
const bytes = this.bytes ?? new Uint8Array(await readFile3(this.sourceUri));
|
|
22838
23054
|
return Buffer.from(bytes).toString("base64");
|
|
22839
23055
|
};
|
|
22840
23056
|
};
|
|
@@ -22882,7 +23098,7 @@ async function resolveCanonicalPath(requested, signal) {
|
|
|
22882
23098
|
return null;
|
|
22883
23099
|
}
|
|
22884
23100
|
try {
|
|
22885
|
-
const target = await
|
|
23101
|
+
const target = await realpath4(requested);
|
|
22886
23102
|
signal.throwIfAborted();
|
|
22887
23103
|
if (!isAbsolute2(target) || normalize(target) !== target) {
|
|
22888
23104
|
return null;
|
|
@@ -23490,7 +23706,7 @@ function createWritableAcpStream(output2) {
|
|
|
23490
23706
|
if (outputFailure !== void 0) {
|
|
23491
23707
|
return Promise.reject(outputFailure);
|
|
23492
23708
|
}
|
|
23493
|
-
return new Promise((
|
|
23709
|
+
return new Promise((resolve10, reject) => {
|
|
23494
23710
|
pendingWriteFailures.add(reject);
|
|
23495
23711
|
output2.write(chunk, (error62) => {
|
|
23496
23712
|
pendingWriteFailures.delete(reject);
|
|
@@ -23503,7 +23719,7 @@ function createWritableAcpStream(output2) {
|
|
|
23503
23719
|
reject(outputFailure);
|
|
23504
23720
|
return;
|
|
23505
23721
|
}
|
|
23506
|
-
|
|
23722
|
+
resolve10();
|
|
23507
23723
|
});
|
|
23508
23724
|
});
|
|
23509
23725
|
}
|
|
@@ -23525,9 +23741,10 @@ var AgentConnection = class {
|
|
|
23525
23741
|
this.connection = createAcpClient(client2).connect(inProcess.app());
|
|
23526
23742
|
return;
|
|
23527
23743
|
}
|
|
23528
|
-
const
|
|
23744
|
+
const launch = executableLaunch2(agent.adapterPath, agent.arguments);
|
|
23745
|
+
const child2 = spawn2(launch.command, [...launch.arguments], {
|
|
23529
23746
|
cwd,
|
|
23530
|
-
|
|
23747
|
+
...platformSpawnOptions,
|
|
23531
23748
|
env: { ...process.env, ...agent.environment },
|
|
23532
23749
|
shell: false,
|
|
23533
23750
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -23544,12 +23761,12 @@ var AgentConnection = class {
|
|
|
23544
23761
|
stderr.on("data", (chunk) => {
|
|
23545
23762
|
process.stderr.write(`[${agent.id}-acp] ${chunk}`);
|
|
23546
23763
|
});
|
|
23547
|
-
this.termination = new Promise((
|
|
23764
|
+
this.termination = new Promise((resolve10) => {
|
|
23548
23765
|
child2.once("error", (cause) => {
|
|
23549
|
-
|
|
23766
|
+
resolve10({ kind: "failed", error: new AcpExecutionError("The ACP process could not run", { cause }) });
|
|
23550
23767
|
});
|
|
23551
23768
|
child2.once("exit", (code, signal) => {
|
|
23552
|
-
|
|
23769
|
+
resolve10({
|
|
23553
23770
|
kind: "failed",
|
|
23554
23771
|
error: new AcpExecutionError("The ACP process stopped", { cause: { code, signal } })
|
|
23555
23772
|
});
|
|
@@ -25762,7 +25979,7 @@ function sql(strings, ...params) {
|
|
|
25762
25979
|
return new SQL([new StringChunk(str)]);
|
|
25763
25980
|
}
|
|
25764
25981
|
_sql.raw = raw;
|
|
25765
|
-
function
|
|
25982
|
+
function join24(chunks, separator) {
|
|
25766
25983
|
const result = [];
|
|
25767
25984
|
for (const [i, chunk] of chunks.entries()) {
|
|
25768
25985
|
if (i > 0 && separator !== void 0) result.push(separator);
|
|
@@ -25770,7 +25987,7 @@ function sql(strings, ...params) {
|
|
|
25770
25987
|
}
|
|
25771
25988
|
return new SQL(result);
|
|
25772
25989
|
}
|
|
25773
|
-
_sql.join =
|
|
25990
|
+
_sql.join = join24;
|
|
25774
25991
|
function identifier2(value) {
|
|
25775
25992
|
return new Name(value);
|
|
25776
25993
|
}
|
|
@@ -27915,7 +28132,7 @@ var SQLiteSelectBase = class extends TypedQueryBuilder {
|
|
|
27915
28132
|
const baseTableName = this.tableName;
|
|
27916
28133
|
const tableName = getTableLikeName(table);
|
|
27917
28134
|
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
27918
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
28135
|
+
if (typeof tableName === "string" && this.config.joins?.some((join24) => join24.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
27919
28136
|
if (!this.isPartialSelect) {
|
|
27920
28137
|
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
|
|
27921
28138
|
if (typeof tableName === "string" && !is(table, SQL)) {
|
|
@@ -28754,7 +28971,7 @@ var SQLiteDialect = class {
|
|
|
28754
28971
|
if (!joins2) return;
|
|
28755
28972
|
const withEntries = Object.entries(joins2).filter(([_, v]) => v);
|
|
28756
28973
|
if (!withEntries.length) return;
|
|
28757
|
-
return sql.join(withEntries.map(([k,
|
|
28974
|
+
return sql.join(withEntries.map(([k, join24]) => {
|
|
28758
28975
|
const relation = tableConfig.relations[k];
|
|
28759
28976
|
const isSingle2 = is(relation, One);
|
|
28760
28977
|
const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
|
|
@@ -28765,7 +28982,7 @@ var SQLiteDialect = class {
|
|
|
28765
28982
|
table: targetTable,
|
|
28766
28983
|
mode: isSingle2 ? "first" : "many",
|
|
28767
28984
|
schema,
|
|
28768
|
-
queryConfig:
|
|
28985
|
+
queryConfig: join24,
|
|
28769
28986
|
tableConfig: schema[relation.targetTableName],
|
|
28770
28987
|
relationWhere: filter,
|
|
28771
28988
|
isNested: true,
|
|
@@ -28779,7 +28996,7 @@ var SQLiteDialect = class {
|
|
|
28779
28996
|
key: k,
|
|
28780
28997
|
selection: innerQuery.selection,
|
|
28781
28998
|
isArray: !isSingle2,
|
|
28782
|
-
isOptional: (relation.optional ?? false) ||
|
|
28999
|
+
isOptional: (relation.optional ?? false) || join24 !== true && !!join24.where
|
|
28783
29000
|
});
|
|
28784
29001
|
const jsonColumns = sql.join(innerQuery.selection.map((s) => {
|
|
28785
29002
|
return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
|
|
@@ -29395,7 +29612,7 @@ var SQLiteUpdateBase = class {
|
|
|
29395
29612
|
createJoin(joinType) {
|
|
29396
29613
|
return ((table, on) => {
|
|
29397
29614
|
const tableName = getTableLikeName(table);
|
|
29398
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
29615
|
+
if (typeof tableName === "string" && this.config.joins.some((join24) => join24.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
29399
29616
|
if (typeof on === "function") {
|
|
29400
29617
|
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;
|
|
29401
29618
|
on = on(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
|
|
@@ -32054,8 +32271,8 @@ var AcpContentExternalizer = class {
|
|
|
32054
32271
|
|
|
32055
32272
|
// src/external-content/local-external-content-store.ts
|
|
32056
32273
|
import { createHash, randomUUID as randomUUID2 } from "node:crypto";
|
|
32057
|
-
import { lstat, mkdir, readdir as readdir2, realpath as
|
|
32058
|
-
import { dirname, join as
|
|
32274
|
+
import { lstat as lstat2, mkdir, readdir as readdir2, realpath as realpath5, rename, rm, stat as stat4, utimes, writeFile } from "node:fs/promises";
|
|
32275
|
+
import { dirname as dirname2, join as join8 } from "node:path";
|
|
32059
32276
|
var contentRequest = /^mobius-content:(image|audio|resource):([a-f0-9]{64})$/u;
|
|
32060
32277
|
var CONTENT_LIFETIME_MILLISECONDS = 24 * 60 * 60 * 1e3;
|
|
32061
32278
|
var metadataSchema2 = external_exports.strictObject({
|
|
@@ -32091,7 +32308,7 @@ var LocalExternalContentStore = class {
|
|
|
32091
32308
|
#expirationTimer;
|
|
32092
32309
|
#cleanup = Promise.resolve();
|
|
32093
32310
|
constructor(stateDirectory) {
|
|
32094
|
-
this.#root =
|
|
32311
|
+
this.#root = join8(stateDirectory, "tmp", "session-content", randomUUID2());
|
|
32095
32312
|
this.#expirationTimer = setInterval(() => {
|
|
32096
32313
|
void this.#expire().catch(() => void 0);
|
|
32097
32314
|
}, 6e4);
|
|
@@ -32102,11 +32319,11 @@ var LocalExternalContentStore = class {
|
|
|
32102
32319
|
await mkdir(this.#root, { mode: 448, recursive: true });
|
|
32103
32320
|
const now = /* @__PURE__ */ new Date();
|
|
32104
32321
|
await utimes(this.#root, now, now);
|
|
32105
|
-
for (const directory of await readdir2(
|
|
32322
|
+
for (const directory of await readdir2(dirname2(this.#root), { withFileTypes: true })) {
|
|
32106
32323
|
if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
|
|
32107
32324
|
continue;
|
|
32108
32325
|
}
|
|
32109
|
-
const path2 =
|
|
32326
|
+
const path2 = join8(dirname2(this.#root), directory.name);
|
|
32110
32327
|
if (path2 === this.#root) {
|
|
32111
32328
|
continue;
|
|
32112
32329
|
}
|
|
@@ -32156,10 +32373,10 @@ var LocalExternalContentStore = class {
|
|
|
32156
32373
|
}
|
|
32157
32374
|
await this.#expire();
|
|
32158
32375
|
active.throwIfAborted();
|
|
32159
|
-
const directory =
|
|
32376
|
+
const directory = join8(this.#root, kind);
|
|
32160
32377
|
await mkdir(directory, { mode: 448, recursive: true });
|
|
32161
32378
|
active.throwIfAborted();
|
|
32162
|
-
const path2 =
|
|
32379
|
+
const path2 = join8(directory, key);
|
|
32163
32380
|
const write = atomicWrite(path2, bytes, active);
|
|
32164
32381
|
await write;
|
|
32165
32382
|
active.throwIfAborted();
|
|
@@ -32192,12 +32409,12 @@ var LocalExternalContentStore = class {
|
|
|
32192
32409
|
}
|
|
32193
32410
|
try {
|
|
32194
32411
|
const [resolvedDirectory, resolvedPath, file2] = await Promise.all([
|
|
32195
|
-
|
|
32196
|
-
|
|
32197
|
-
|
|
32412
|
+
realpath5(dirname2(entry.path)),
|
|
32413
|
+
realpath5(entry.path),
|
|
32414
|
+
lstat2(entry.path)
|
|
32198
32415
|
]);
|
|
32199
32416
|
signal.throwIfAborted();
|
|
32200
|
-
if (!file2.isFile() || file2.isSymbolicLink() ||
|
|
32417
|
+
if (!file2.isFile() || file2.isSymbolicLink() || dirname2(resolvedPath) !== resolvedDirectory) {
|
|
32201
32418
|
return null;
|
|
32202
32419
|
}
|
|
32203
32420
|
return { mediaType: entry.mediaType, name: entry.name, path: resolvedPath };
|
|
@@ -33290,9 +33507,9 @@ var LocalAuthorizationError = class extends Error {
|
|
|
33290
33507
|
};
|
|
33291
33508
|
|
|
33292
33509
|
// src/pairing/pair-local-machine.ts
|
|
33293
|
-
import { mkdir as mkdir6, realpath as
|
|
33510
|
+
import { mkdir as mkdir6, realpath as realpath10, stat as stat8 } from "node:fs/promises";
|
|
33294
33511
|
import { hostname as hostname3 } from "node:os";
|
|
33295
|
-
import { basename as basename3, resolve as
|
|
33512
|
+
import { basename as basename3, resolve as resolve6 } from "node:path";
|
|
33296
33513
|
import { fetch as fetch3 } from "undici";
|
|
33297
33514
|
|
|
33298
33515
|
// src/agent-catalog/agent-discovery.ts
|
|
@@ -33435,8 +33652,8 @@ var LocalAgentInventory = class {
|
|
|
33435
33652
|
};
|
|
33436
33653
|
|
|
33437
33654
|
// src/agent-installation/managed-npm-package.ts
|
|
33438
|
-
import { mkdir as mkdir2, mkdtemp, open as open3, realpath as
|
|
33439
|
-
import { delimiter, dirname as
|
|
33655
|
+
import { mkdir as mkdir2, mkdtemp, open as open3, realpath as realpath6, rename as rename2, rm as rm2, stat as stat5 } from "node:fs/promises";
|
|
33656
|
+
import { delimiter, dirname as dirname3, isAbsolute as isAbsolute3, join as join9, relative, sep } from "node:path";
|
|
33440
33657
|
var INSTALL_TIMEOUT_MILLISECONDS = 5 * 60 * 1e3;
|
|
33441
33658
|
var PACKAGE_METADATA_LIMIT_BYTES = 64 * 1024;
|
|
33442
33659
|
var PACKAGE_LOCK_LIMIT_BYTES = 8 * 1024 * 1024;
|
|
@@ -33487,7 +33704,7 @@ function isRecord7(value) {
|
|
|
33487
33704
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
33488
33705
|
}
|
|
33489
33706
|
function packagePath(root, packageName) {
|
|
33490
|
-
return
|
|
33707
|
+
return join9(root, "node_modules", ...packageName.split("/"));
|
|
33491
33708
|
}
|
|
33492
33709
|
function isContainedPath(root, candidate) {
|
|
33493
33710
|
const difference = relative(root, candidate);
|
|
@@ -33592,14 +33809,14 @@ function verifyPackageLockEntry(lock, definition, verifyDependencyClosure) {
|
|
|
33592
33809
|
}
|
|
33593
33810
|
}
|
|
33594
33811
|
async function verifyRequiredDependency(rootPath, lock, definition) {
|
|
33595
|
-
const dependencyRoot = await
|
|
33812
|
+
const dependencyRoot = await realpath6(packagePath(rootPath, definition.packageName));
|
|
33596
33813
|
if (!isContainedPath(rootPath, dependencyRoot)) {
|
|
33597
33814
|
throw new ManagedNpmPackageError(
|
|
33598
33815
|
"managed_package_verification_failed",
|
|
33599
33816
|
"The required managed npm dependency escaped its private cache"
|
|
33600
33817
|
);
|
|
33601
33818
|
}
|
|
33602
|
-
const metadata = await readJsonRecord(
|
|
33819
|
+
const metadata = await readJsonRecord(join9(dependencyRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
|
|
33603
33820
|
if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
|
|
33604
33821
|
throw new ManagedNpmPackageError(
|
|
33605
33822
|
"managed_package_verification_failed",
|
|
@@ -33621,15 +33838,15 @@ async function validateManagedNpmPackage(root, definition) {
|
|
|
33621
33838
|
}
|
|
33622
33839
|
}
|
|
33623
33840
|
async function validateManagedNpmPackageContents(root, definition) {
|
|
33624
|
-
const rootPath = await
|
|
33625
|
-
const packageRoot = await
|
|
33841
|
+
const rootPath = await realpath6(root);
|
|
33842
|
+
const packageRoot = await realpath6(packagePath(rootPath, definition.packageName));
|
|
33626
33843
|
if (!isContainedPath(rootPath, packageRoot)) {
|
|
33627
33844
|
throw new ManagedNpmPackageError(
|
|
33628
33845
|
"managed_package_verification_failed",
|
|
33629
33846
|
"The managed npm package escaped its private cache"
|
|
33630
33847
|
);
|
|
33631
33848
|
}
|
|
33632
|
-
const metadata = await readJsonRecord(
|
|
33849
|
+
const metadata = await readJsonRecord(join9(packageRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
|
|
33633
33850
|
if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
|
|
33634
33851
|
throw new ManagedNpmPackageError(
|
|
33635
33852
|
"managed_package_verification_failed",
|
|
@@ -33637,14 +33854,14 @@ async function validateManagedNpmPackageContents(root, definition) {
|
|
|
33637
33854
|
);
|
|
33638
33855
|
}
|
|
33639
33856
|
if (definition instanceof SriManagedNpmPackageDefinition) {
|
|
33640
|
-
const lock = await readJsonRecord(
|
|
33857
|
+
const lock = await readJsonRecord(join9(rootPath, "package-lock.json"), PACKAGE_LOCK_LIMIT_BYTES);
|
|
33641
33858
|
verifyPackageLockEntry(lock, definition, definition.verifyDependencyClosure);
|
|
33642
33859
|
for (const dependency of definition.requiredDependencies) {
|
|
33643
33860
|
await verifyRequiredDependency(rootPath, lock, dependency);
|
|
33644
33861
|
}
|
|
33645
33862
|
}
|
|
33646
33863
|
const declaredBin = readBinPath(metadata, definition.executableName);
|
|
33647
|
-
const executable = await resolveExecutablePath(
|
|
33864
|
+
const executable = await resolveExecutablePath(join9(packageRoot, declaredBin));
|
|
33648
33865
|
if (executable === null || !isContainedPath(rootPath, executable.path)) {
|
|
33649
33866
|
throw new ManagedNpmPackageError(
|
|
33650
33867
|
"managed_package_verification_failed",
|
|
@@ -33666,9 +33883,9 @@ var ManagedNpmPackageInstaller = class {
|
|
|
33666
33883
|
throw error62;
|
|
33667
33884
|
}
|
|
33668
33885
|
}
|
|
33669
|
-
const parent =
|
|
33886
|
+
const parent = dirname3(root);
|
|
33670
33887
|
await mkdir2(parent, { mode: 448, recursive: true });
|
|
33671
|
-
const staging = await mkdtemp(
|
|
33888
|
+
const staging = await mkdtemp(join9(parent, `.${definition.version}.staging-`));
|
|
33672
33889
|
try {
|
|
33673
33890
|
const npm = await findExecutableOnPath(process.platform === "win32" ? "npm.cmd" : "npm", environment);
|
|
33674
33891
|
if (npm === null) {
|
|
@@ -33694,14 +33911,14 @@ var ManagedNpmPackageInstaller = class {
|
|
|
33694
33911
|
`${definition.packageName}@${definition.version}`
|
|
33695
33912
|
);
|
|
33696
33913
|
const installEnvironment = {
|
|
33697
|
-
HOME:
|
|
33914
|
+
HOME: join9(staging, "home"),
|
|
33698
33915
|
NPM_CONFIG_AUDIT: "false",
|
|
33699
|
-
NPM_CONFIG_CACHE:
|
|
33916
|
+
NPM_CONFIG_CACHE: join9(staging, ".npm-cache"),
|
|
33700
33917
|
NPM_CONFIG_FUND: "false",
|
|
33701
33918
|
NPM_CONFIG_IGNORE_SCRIPTS: "true",
|
|
33702
33919
|
NPM_CONFIG_PACKAGE_LOCK: "true",
|
|
33703
33920
|
NPM_CONFIG_REGISTRY: "https://registry.npmjs.org/",
|
|
33704
|
-
PATH: `${
|
|
33921
|
+
PATH: `${dirname3(process.execPath)}${delimiter}/usr/bin${delimiter}/bin`
|
|
33705
33922
|
};
|
|
33706
33923
|
if (definition.includeOptionalDependencies) {
|
|
33707
33924
|
installEnvironment["NPM_CONFIG_INCLUDE"] = "optional";
|
|
@@ -33718,8 +33935,8 @@ var ManagedNpmPackageInstaller = class {
|
|
|
33718
33935
|
timeoutMilliseconds: INSTALL_TIMEOUT_MILLISECONDS
|
|
33719
33936
|
});
|
|
33720
33937
|
await Promise.all([
|
|
33721
|
-
rm2(
|
|
33722
|
-
rm2(
|
|
33938
|
+
rm2(join9(staging, ".npm-cache"), { force: true, recursive: true }),
|
|
33939
|
+
rm2(join9(staging, "home"), { force: true, recursive: true })
|
|
33723
33940
|
]);
|
|
33724
33941
|
await validateManagedNpmPackage(staging, definition);
|
|
33725
33942
|
try {
|
|
@@ -33755,7 +33972,7 @@ var ManagedNpmPackageInstaller = class {
|
|
|
33755
33972
|
};
|
|
33756
33973
|
|
|
33757
33974
|
// src/agent-catalog/agent-specification.ts
|
|
33758
|
-
import { join as
|
|
33975
|
+
import { join as join10 } from "node:path";
|
|
33759
33976
|
|
|
33760
33977
|
// src/agent-catalog/version-output.ts
|
|
33761
33978
|
function normalizeVersionOutput(output2) {
|
|
@@ -33778,7 +33995,7 @@ var LocalAgentSpecification = class {
|
|
|
33778
33995
|
resolveManagedAgent = async (stateDirectory, platform, signal) => {
|
|
33779
33996
|
signal.throwIfAborted();
|
|
33780
33997
|
const executable = await resolveExecutablePath(
|
|
33781
|
-
|
|
33998
|
+
join10(stateDirectory, ...this.managedAgentExecutablePath),
|
|
33782
33999
|
platform
|
|
33783
34000
|
);
|
|
33784
34001
|
signal.throwIfAborted();
|
|
@@ -34154,9 +34371,10 @@ var CodexAppServerClient = class {
|
|
|
34154
34371
|
#pendingFragments = [];
|
|
34155
34372
|
constructor(options) {
|
|
34156
34373
|
this.#handlers = options.handlers;
|
|
34157
|
-
|
|
34374
|
+
const launch = executableLaunch2(options.command, ["app-server"]);
|
|
34375
|
+
this.#child = spawn3(launch.command, [...launch.arguments], {
|
|
34158
34376
|
cwd: options.cwd,
|
|
34159
|
-
|
|
34377
|
+
...platformSpawnOptions,
|
|
34160
34378
|
env: { ...process.env, ...options.environment },
|
|
34161
34379
|
shell: false,
|
|
34162
34380
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -35813,7 +36031,7 @@ var AgentProbeError = class extends Error {
|
|
|
35813
36031
|
};
|
|
35814
36032
|
|
|
35815
36033
|
// src/agent-catalog/agents/resolve-user-local-executable.ts
|
|
35816
|
-
import { isAbsolute as isAbsolute5, join as
|
|
36034
|
+
import { isAbsolute as isAbsolute5, join as join11 } from "node:path";
|
|
35817
36035
|
async function resolveUserLocalExecutable(executableName, context) {
|
|
35818
36036
|
context.signal.throwIfAborted();
|
|
35819
36037
|
const platform = context.platform ?? process.platform;
|
|
@@ -35821,7 +36039,7 @@ async function resolveUserLocalExecutable(executableName, context) {
|
|
|
35821
36039
|
if (platform === "win32" || homeDirectory === void 0 || !isAbsolute5(homeDirectory)) {
|
|
35822
36040
|
return [];
|
|
35823
36041
|
}
|
|
35824
|
-
const executable = await resolveExecutablePath(
|
|
36042
|
+
const executable = await resolveExecutablePath(join11(homeDirectory, ".local", "bin", executableName), platform);
|
|
35825
36043
|
context.signal.throwIfAborted();
|
|
35826
36044
|
return executable === null ? [] : [executable];
|
|
35827
36045
|
}
|
|
@@ -35910,8 +36128,8 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
35910
36128
|
};
|
|
35911
36129
|
|
|
35912
36130
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
35913
|
-
import { mkdir as mkdir3, realpath as
|
|
35914
|
-
import { isAbsolute as isAbsolute6, join as
|
|
36131
|
+
import { mkdir as mkdir3, realpath as realpath7, stat as stat6, writeFile as writeFile2 } from "node:fs/promises";
|
|
36132
|
+
import { isAbsolute as isAbsolute6, join as join12, normalize as normalize2 } from "node:path";
|
|
35915
36133
|
|
|
35916
36134
|
// src/agent-installation/deepseek-managed-package.ts
|
|
35917
36135
|
var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
|
|
@@ -35942,13 +36160,13 @@ async function prepareAgentHome(path2, imagePrompts) {
|
|
|
35942
36160
|
if (imagePrompts) {
|
|
35943
36161
|
await mkdir3(path2, { mode: 448, recursive: true });
|
|
35944
36162
|
}
|
|
35945
|
-
const resolved = await
|
|
36163
|
+
const resolved = await realpath7(path2);
|
|
35946
36164
|
const metadata = await stat6(resolved);
|
|
35947
36165
|
if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
|
|
35948
36166
|
throw new Error("Agent home is not a user-owned directory");
|
|
35949
36167
|
}
|
|
35950
36168
|
if (imagePrompts) {
|
|
35951
|
-
await writeFile2(
|
|
36169
|
+
await writeFile2(join12(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
|
|
35952
36170
|
mode: 384
|
|
35953
36171
|
});
|
|
35954
36172
|
}
|
|
@@ -35996,7 +36214,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
35996
36214
|
context.signal
|
|
35997
36215
|
);
|
|
35998
36216
|
if (managed.path === agent.path) {
|
|
35999
|
-
selectedHome =
|
|
36217
|
+
selectedHome = join12(readStateDirectory(context.environment), "agents", this.id, "home");
|
|
36000
36218
|
managedHome = true;
|
|
36001
36219
|
}
|
|
36002
36220
|
} catch {
|
|
@@ -36012,7 +36230,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
36012
36230
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
36013
36231
|
signal.throwIfAborted();
|
|
36014
36232
|
const executable = await validateManagedNpmPackage(
|
|
36015
|
-
|
|
36233
|
+
join12(stateDirectory, "agents", this.id, DEEPSEEK_HARNESS_PACKAGE.version),
|
|
36016
36234
|
DEEPSEEK_HARNESS_PACKAGE
|
|
36017
36235
|
);
|
|
36018
36236
|
signal.throwIfAborted();
|
|
@@ -36066,8 +36284,8 @@ var GeminiCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
36066
36284
|
};
|
|
36067
36285
|
|
|
36068
36286
|
// src/agent-catalog/agents/grok-build-agent.ts
|
|
36069
|
-
import { realpath as
|
|
36070
|
-
import { isAbsolute as isAbsolute7, join as
|
|
36287
|
+
import { realpath as realpath8 } from "node:fs/promises";
|
|
36288
|
+
import { isAbsolute as isAbsolute7, join as join13, relative as relative2, sep as sep2 } from "node:path";
|
|
36071
36289
|
import {
|
|
36072
36290
|
RequestError as RequestError2
|
|
36073
36291
|
} from "@agentclientprotocol/sdk";
|
|
@@ -36137,8 +36355,8 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
36137
36355
|
);
|
|
36138
36356
|
if (managed.path === agent.path) {
|
|
36139
36357
|
return Object.freeze({
|
|
36140
|
-
GROK_HOME: await
|
|
36141
|
-
|
|
36358
|
+
GROK_HOME: await realpath8(
|
|
36359
|
+
join13(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION, "home")
|
|
36142
36360
|
)
|
|
36143
36361
|
});
|
|
36144
36362
|
}
|
|
@@ -36149,9 +36367,9 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
36149
36367
|
};
|
|
36150
36368
|
resolveManagedAgent = async (stateDirectory, platform, signal) => {
|
|
36151
36369
|
signal.throwIfAborted();
|
|
36152
|
-
const versionRoot = await
|
|
36153
|
-
await validateManagedNpmPackage(
|
|
36154
|
-
const executable = await resolveExecutablePath(
|
|
36370
|
+
const versionRoot = await realpath8(join13(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION));
|
|
36371
|
+
await validateManagedNpmPackage(join13(versionRoot, "package"), grokBuildManagedPackage(platform, process.arch));
|
|
36372
|
+
const executable = await resolveExecutablePath(join13(versionRoot, "home", "bin", "grok"), platform);
|
|
36155
36373
|
signal.throwIfAborted();
|
|
36156
36374
|
if (executable === null || !isContainedPath2(versionRoot, executable.path)) {
|
|
36157
36375
|
throw new AgentProbeError("managed_agent_invalid", "The managed Grok Build executable is invalid");
|
|
@@ -36251,13 +36469,13 @@ var OhMyPiAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
36251
36469
|
};
|
|
36252
36470
|
|
|
36253
36471
|
// src/agent-catalog/agents/opencode-agent.ts
|
|
36254
|
-
import { join as
|
|
36472
|
+
import { join as join15 } from "node:path";
|
|
36255
36473
|
|
|
36256
36474
|
// src/agent-installation/managed-agent-archive.ts
|
|
36257
36475
|
import { createHash as createHash3 } from "node:crypto";
|
|
36258
36476
|
import { createReadStream } from "node:fs";
|
|
36259
|
-
import { chmod, copyFile, mkdir as mkdir4, mkdtemp as mkdtemp2, open as open4, realpath as
|
|
36260
|
-
import { delimiter as delimiter2, dirname as
|
|
36477
|
+
import { chmod as chmod2, copyFile, mkdir as mkdir4, mkdtemp as mkdtemp2, open as open4, realpath as realpath9, rename as rename3, rm as rm3, stat as stat7, writeFile as writeFile3 } from "node:fs/promises";
|
|
36478
|
+
import { delimiter as delimiter2, dirname as dirname4, isAbsolute as isAbsolute8, join as join14, relative as relative3, sep as sep3 } from "node:path";
|
|
36261
36479
|
|
|
36262
36480
|
// src/agent-installation/verified-download.ts
|
|
36263
36481
|
import { fetch } from "undici";
|
|
@@ -36437,16 +36655,16 @@ async function readManifest(path2) {
|
|
|
36437
36655
|
}
|
|
36438
36656
|
async function validateManagedAgentArchive(root, definition, signal) {
|
|
36439
36657
|
try {
|
|
36440
|
-
const rootPath = await
|
|
36658
|
+
const rootPath = await realpath9(root);
|
|
36441
36659
|
const rootMetadata = await stat7(rootPath);
|
|
36442
36660
|
if (!rootMetadata.isDirectory() || typeof process.getuid === "function" && rootMetadata.uid !== process.getuid()) {
|
|
36443
36661
|
throw new Error("Managed Agent root is not user-owned");
|
|
36444
36662
|
}
|
|
36445
|
-
const manifest = await readManifest(
|
|
36663
|
+
const manifest = await readManifest(join14(rootPath, "archive.json"));
|
|
36446
36664
|
if (manifest["archiveSha256"] !== definition.archiveSha256 || manifest["archiveUrl"] !== definition.archiveUrl.toString() || manifest["version"] !== definition.version || typeof manifest["executableSha256"] !== "string") {
|
|
36447
36665
|
throw new Error("Managed Agent archive identity is invalid");
|
|
36448
36666
|
}
|
|
36449
|
-
const executable = await resolveExecutablePath(
|
|
36667
|
+
const executable = await resolveExecutablePath(join14(rootPath, "bin", definition.executableName));
|
|
36450
36668
|
if (executable === null || !isContainedPath3(rootPath, executable.path) || await hashFile(executable.path, signal) !== manifest["executableSha256"]) {
|
|
36451
36669
|
throw new Error("Managed Agent executable is invalid");
|
|
36452
36670
|
}
|
|
@@ -36612,7 +36830,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
36612
36830
|
return Object.freeze(environment);
|
|
36613
36831
|
};
|
|
36614
36832
|
resolveManagedAgent = async (stateDirectory, platform, signal) => await validateManagedAgentArchive(
|
|
36615
|
-
|
|
36833
|
+
join15(stateDirectory, "agents", this.id, OPENCODE_MANAGED_VERSION),
|
|
36616
36834
|
openCodeManagedArchive(platform, process.arch),
|
|
36617
36835
|
signal
|
|
36618
36836
|
);
|
|
@@ -36630,7 +36848,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
36630
36848
|
};
|
|
36631
36849
|
|
|
36632
36850
|
// src/agent-catalog/agents/pi-agent.ts
|
|
36633
|
-
import { join as
|
|
36851
|
+
import { join as join16 } from "node:path";
|
|
36634
36852
|
import {
|
|
36635
36853
|
methods as methods7
|
|
36636
36854
|
} from "@agentclientprotocol/sdk";
|
|
@@ -36689,7 +36907,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
36689
36907
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
36690
36908
|
signal.throwIfAborted();
|
|
36691
36909
|
const executable = await validateManagedNpmPackage(
|
|
36692
|
-
|
|
36910
|
+
join16(stateDirectory, "agents", this.id, PI_AGENT_PACKAGE.version),
|
|
36693
36911
|
PI_AGENT_PACKAGE
|
|
36694
36912
|
);
|
|
36695
36913
|
signal.throwIfAborted();
|
|
@@ -36727,7 +36945,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
36727
36945
|
};
|
|
36728
36946
|
|
|
36729
36947
|
// src/agent-catalog/agents/workbuddy-agent.ts
|
|
36730
|
-
import { join as
|
|
36948
|
+
import { join as join17 } from "node:path";
|
|
36731
36949
|
|
|
36732
36950
|
// src/agent-installation/workbuddy-managed-package.ts
|
|
36733
36951
|
var WORKBUDDY_MANAGED_VERSION = "2.146.0";
|
|
@@ -36773,7 +36991,7 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
36773
36991
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
36774
36992
|
signal.throwIfAborted();
|
|
36775
36993
|
const executable = await validateManagedNpmPackage(
|
|
36776
|
-
|
|
36994
|
+
join17(stateDirectory, "agents", this.id, WORKBUDDY_MANAGED_VERSION),
|
|
36777
36995
|
WORKBUDDY_MANAGED_PACKAGE
|
|
36778
36996
|
);
|
|
36779
36997
|
signal.throwIfAborted();
|
|
@@ -36981,9 +37199,10 @@ async function probeAcpReadiness(specification, agent, environment, defaultWorks
|
|
|
36981
37199
|
signal.removeEventListener("abort", abort);
|
|
36982
37200
|
}
|
|
36983
37201
|
}
|
|
36984
|
-
const
|
|
37202
|
+
const launch = executableLaunch2(agent.adapterPath, agent.arguments);
|
|
37203
|
+
const child2 = spawn4(launch.command, [...launch.arguments], {
|
|
36985
37204
|
cwd: defaultWorkspace,
|
|
36986
|
-
|
|
37205
|
+
...platformSpawnOptions,
|
|
36987
37206
|
env: { ...environment, ...agent.environment },
|
|
36988
37207
|
shell: false,
|
|
36989
37208
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -37116,10 +37335,10 @@ function isAgentVersionSupported(reportedVersion, minimumSupportedVersion) {
|
|
|
37116
37335
|
}
|
|
37117
37336
|
|
|
37118
37337
|
// src/agent-catalog/executable-discovery.ts
|
|
37119
|
-
import { isAbsolute as isAbsolute9, join as
|
|
37338
|
+
import { isAbsolute as isAbsolute9, join as join19 } from "node:path";
|
|
37120
37339
|
|
|
37121
37340
|
// src/agent-installation/managed-adapter-installer.ts
|
|
37122
|
-
import { join as
|
|
37341
|
+
import { join as join18 } from "node:path";
|
|
37123
37342
|
var ManagedAdapterInstallError = class extends Error {
|
|
37124
37343
|
code;
|
|
37125
37344
|
constructor(code, message, options = {}) {
|
|
@@ -37176,7 +37395,7 @@ var ManagedAdapterInstaller = class {
|
|
|
37176
37395
|
this.#stateDirectory = options.stateDirectory;
|
|
37177
37396
|
}
|
|
37178
37397
|
install = async (specification, signal) => {
|
|
37179
|
-
const root =
|
|
37398
|
+
const root = join18(this.#stateDirectory, "adapters", specification.id, specification.adapterVersion);
|
|
37180
37399
|
try {
|
|
37181
37400
|
return await this.#npmInstaller.install(
|
|
37182
37401
|
root,
|
|
@@ -37210,7 +37429,7 @@ async function resolveManagedAdapterExecutable(specification, context) {
|
|
|
37210
37429
|
let managed;
|
|
37211
37430
|
try {
|
|
37212
37431
|
managed = await validateManagedAdapter(
|
|
37213
|
-
|
|
37432
|
+
join19(readStateDirectory(context.environment), "adapters", specification.id, specification.adapterVersion),
|
|
37214
37433
|
specification
|
|
37215
37434
|
);
|
|
37216
37435
|
} catch {
|
|
@@ -37691,8 +37910,21 @@ async function unchangedIdentity(agent, signal) {
|
|
|
37691
37910
|
|
|
37692
37911
|
// src/storage/runtime-installation-store.ts
|
|
37693
37912
|
import { createHash as createHash4, randomUUID as randomUUID3 } from "node:crypto";
|
|
37694
|
-
import { mkdir as mkdir5, open as open5, readdir as readdir3, rename as rename4, unlink, writeFile as writeFile4 } from "node:fs/promises";
|
|
37695
|
-
import { dirname as
|
|
37913
|
+
import { mkdir as mkdir5, open as open5, readdir as readdir3, rename as rename4, unlink as unlink2, writeFile as writeFile4 } from "node:fs/promises";
|
|
37914
|
+
import { dirname as dirname5, join as join20, resolve as resolve5 } from "node:path";
|
|
37915
|
+
|
|
37916
|
+
// src/filesystem/private-path.ts
|
|
37917
|
+
import { lstat as lstat3 } from "node:fs/promises";
|
|
37918
|
+
async function validateLocalPath(path2, directory, privateAccess, signal) {
|
|
37919
|
+
signal.throwIfAborted();
|
|
37920
|
+
const metadata = await lstat3(path2);
|
|
37921
|
+
if (metadata.isSymbolicLink() || (directory ? !metadata.isDirectory() : !metadata.isFile())) {
|
|
37922
|
+
throw new LocalPathError("Unsafe local path");
|
|
37923
|
+
}
|
|
37924
|
+
await platformSupportFor(process.platform).validatePathPermissions(path2, directory, privateAccess, signal);
|
|
37925
|
+
}
|
|
37926
|
+
|
|
37927
|
+
// src/storage/runtime-installation-store.ts
|
|
37696
37928
|
var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
|
|
37697
37929
|
var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
|
|
37698
37930
|
var INSTALLATION_ID_PATTERN = /^min_[a-f0-9]{32}$/;
|
|
@@ -37934,8 +38166,8 @@ async function readJsonFile(path2, signal, missingCode) {
|
|
|
37934
38166
|
}
|
|
37935
38167
|
async function writeJsonAtomically(path2, value, signal) {
|
|
37936
38168
|
signal.throwIfAborted();
|
|
37937
|
-
const directory =
|
|
37938
|
-
const temporaryPath =
|
|
38169
|
+
const directory = dirname5(path2);
|
|
38170
|
+
const temporaryPath = join20(directory, `.${randomUUID3()}.tmp`);
|
|
37939
38171
|
try {
|
|
37940
38172
|
await mkdir5(directory, { mode: 448, recursive: true });
|
|
37941
38173
|
signal.throwIfAborted();
|
|
@@ -37944,7 +38176,7 @@ async function writeJsonAtomically(path2, value, signal) {
|
|
|
37944
38176
|
signal.throwIfAborted();
|
|
37945
38177
|
await rename4(temporaryPath, path2);
|
|
37946
38178
|
} catch (cause) {
|
|
37947
|
-
await
|
|
38179
|
+
await unlink2(temporaryPath).catch(() => void 0);
|
|
37948
38180
|
signal.throwIfAborted();
|
|
37949
38181
|
throw new RuntimeInstallationStoreError("connection_unavailable", "The local Runtime state cannot be written", {
|
|
37950
38182
|
cause
|
|
@@ -37961,15 +38193,17 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
37961
38193
|
this.applicationId = applicationId;
|
|
37962
38194
|
this.installationId = installationId2;
|
|
37963
38195
|
this.stateDirectory = stateDirectory;
|
|
37964
|
-
this.#channelDirectory =
|
|
37965
|
-
this.#connectionDirectory =
|
|
38196
|
+
this.#channelDirectory = join20(stateDirectory, "channels");
|
|
38197
|
+
this.#connectionDirectory = join20(stateDirectory, "connections");
|
|
37966
38198
|
}
|
|
37967
38199
|
static open = async (options, signal) => {
|
|
37968
38200
|
signal.throwIfAborted();
|
|
37969
38201
|
const applicationId = validateApplicationId(options.applicationId);
|
|
37970
|
-
const rootDirectory =
|
|
37971
|
-
const applicationDirectory =
|
|
38202
|
+
const rootDirectory = resolve5(options.stateDirectory);
|
|
38203
|
+
const applicationDirectory = join20(rootDirectory, "installations", applicationId);
|
|
37972
38204
|
try {
|
|
38205
|
+
await mkdir5(rootDirectory, { mode: 448, recursive: true });
|
|
38206
|
+
await validateLocalPath(rootDirectory, true, true, signal);
|
|
37973
38207
|
await mkdir5(applicationDirectory, { mode: 448, recursive: true });
|
|
37974
38208
|
} catch (cause) {
|
|
37975
38209
|
throw new RuntimeInstallationStoreError(
|
|
@@ -37981,7 +38215,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
37981
38215
|
);
|
|
37982
38216
|
}
|
|
37983
38217
|
const storedInstallationId = await readOrCreateInstallationId(applicationDirectory, signal);
|
|
37984
|
-
const stateDirectory =
|
|
38218
|
+
const stateDirectory = join20(applicationDirectory, storedInstallationId);
|
|
37985
38219
|
try {
|
|
37986
38220
|
await mkdir5(stateDirectory, { mode: 448, recursive: true });
|
|
37987
38221
|
} catch (cause) {
|
|
@@ -37996,8 +38230,8 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
37996
38230
|
signal.throwIfAborted();
|
|
37997
38231
|
return new _RuntimeInstallationStore(applicationId, storedInstallationId, stateDirectory);
|
|
37998
38232
|
};
|
|
37999
|
-
connectionPath = (connectionId2) =>
|
|
38000
|
-
channelIndexPath = (channelId) =>
|
|
38233
|
+
connectionPath = (connectionId2) => join20(this.#connectionDirectory, `${validateConnectionId(connectionId2)}.json`);
|
|
38234
|
+
channelIndexPath = (channelId) => join20(this.#channelDirectory, channelIndexFileName(validateIdentifier(channelId, "invalid_channel_id")));
|
|
38001
38235
|
readConnection = async (connectionId2, signal) => {
|
|
38002
38236
|
const stored = decodeConnection(
|
|
38003
38237
|
await readJsonFile(this.connectionPath(connectionId2), signal, "connection_not_found")
|
|
@@ -38120,9 +38354,9 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
38120
38354
|
const connection = await this.readConnection(connectionId2, signal);
|
|
38121
38355
|
signal.throwIfAborted();
|
|
38122
38356
|
try {
|
|
38123
|
-
await
|
|
38357
|
+
await unlink2(this.connectionPath(connection.connectionId));
|
|
38124
38358
|
signal.throwIfAborted();
|
|
38125
|
-
await
|
|
38359
|
+
await unlink2(this.channelIndexPath(connection.channelId));
|
|
38126
38360
|
} catch (cause) {
|
|
38127
38361
|
signal.throwIfAborted();
|
|
38128
38362
|
if (isNodeError(cause, "ENOENT")) {
|
|
@@ -38159,7 +38393,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
38159
38393
|
};
|
|
38160
38394
|
};
|
|
38161
38395
|
async function readOrCreateInstallationId(applicationDirectory, signal) {
|
|
38162
|
-
const pointerPath =
|
|
38396
|
+
const pointerPath = join20(applicationDirectory, "current.json");
|
|
38163
38397
|
try {
|
|
38164
38398
|
return decodeInstallationPointer(await readJsonFile(pointerPath, signal, "installation_not_found")).installationId;
|
|
38165
38399
|
} catch (cause) {
|
|
@@ -38297,10 +38531,10 @@ function parseResumeConnectionId(arguments_) {
|
|
|
38297
38531
|
return value;
|
|
38298
38532
|
}
|
|
38299
38533
|
async function resolveDefaultWorkspace(path2) {
|
|
38300
|
-
const requestedWorkspace =
|
|
38534
|
+
const requestedWorkspace = resolve6(path2);
|
|
38301
38535
|
try {
|
|
38302
38536
|
await mkdir6(requestedWorkspace, { recursive: true, mode: 448 });
|
|
38303
|
-
const defaultWorkspace = await
|
|
38537
|
+
const defaultWorkspace = await realpath10(requestedWorkspace);
|
|
38304
38538
|
const metadata = await stat8(defaultWorkspace);
|
|
38305
38539
|
if (!metadata.isDirectory()) {
|
|
38306
38540
|
throw new PairingClientError("invalid_workspace", "The default workspace is not a directory");
|
|
@@ -38536,7 +38770,7 @@ function isRuntimeRelayRevocation(closeCode, closeReason) {
|
|
|
38536
38770
|
|
|
38537
38771
|
// src/run-daemon.ts
|
|
38538
38772
|
import { createHash as createHash8, randomUUID as randomUUID9 } from "node:crypto";
|
|
38539
|
-
import { join as
|
|
38773
|
+
import { join as join23 } from "node:path";
|
|
38540
38774
|
import { styleText } from "node:util";
|
|
38541
38775
|
|
|
38542
38776
|
// src/agent-installation/agent-installation-manager.ts
|
|
@@ -38803,7 +39037,7 @@ var AgentInstallationManager = class {
|
|
|
38803
39037
|
|
|
38804
39038
|
// src/agent-installation/fixed-installation-executor.ts
|
|
38805
39039
|
import { realpathSync as realpathSync2, statSync as statSync2 } from "node:fs";
|
|
38806
|
-
import { resolve as
|
|
39040
|
+
import { resolve as resolve7 } from "node:path";
|
|
38807
39041
|
function findSpecification(specifications, agentId) {
|
|
38808
39042
|
for (const specification of specifications) {
|
|
38809
39043
|
if (specification.id === agentId) {
|
|
@@ -38814,7 +39048,7 @@ function findSpecification(specifications, agentId) {
|
|
|
38814
39048
|
}
|
|
38815
39049
|
function resolveDefaultWorkspace2(path2) {
|
|
38816
39050
|
try {
|
|
38817
|
-
const directory = realpathSync2(
|
|
39051
|
+
const directory = realpathSync2(resolve7(path2));
|
|
38818
39052
|
if (!statSync2(directory).isDirectory()) {
|
|
38819
39053
|
throw new Error("Default workspace is not a directory");
|
|
38820
39054
|
}
|
|
@@ -38829,7 +39063,7 @@ function resolveDefaultWorkspace2(path2) {
|
|
|
38829
39063
|
}
|
|
38830
39064
|
function resolveIntegrationStateDirectory(path2) {
|
|
38831
39065
|
try {
|
|
38832
|
-
const directory = realpathSync2(
|
|
39066
|
+
const directory = realpathSync2(resolve7(path2));
|
|
38833
39067
|
const metadata = statSync2(directory);
|
|
38834
39068
|
if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
|
|
38835
39069
|
throw new Error("Installation directory is not user-owned");
|
|
@@ -39001,9 +39235,9 @@ var FixedInstallationExecutor = class {
|
|
|
39001
39235
|
};
|
|
39002
39236
|
|
|
39003
39237
|
// src/authorization/workspace-directory.ts
|
|
39004
|
-
import { readdir as readdir4, realpath as
|
|
39238
|
+
import { readdir as readdir4, realpath as realpath11, stat as stat9 } from "node:fs/promises";
|
|
39005
39239
|
import { homedir as homedir2 } from "node:os";
|
|
39006
|
-
import { basename as basename4, dirname as
|
|
39240
|
+
import { basename as basename4, dirname as dirname6, isAbsolute as isAbsolute10, join as join21, normalize as normalize3, relative as relative4 } from "node:path";
|
|
39007
39241
|
var WorkspaceDirectoryListing = class {
|
|
39008
39242
|
directoryId;
|
|
39009
39243
|
directoryLabel;
|
|
@@ -39071,7 +39305,7 @@ var WorkspaceDirectoryService = class {
|
|
|
39071
39305
|
throw new LocalAuthorizationError("The local directory path is invalid");
|
|
39072
39306
|
}
|
|
39073
39307
|
try {
|
|
39074
|
-
const target = await
|
|
39308
|
+
const target = await realpath11(requested);
|
|
39075
39309
|
signal.throwIfAborted();
|
|
39076
39310
|
const metadata = await stat9(target);
|
|
39077
39311
|
signal.throwIfAborted();
|
|
@@ -39121,7 +39355,7 @@ var WorkspaceDirectoryService = class {
|
|
|
39121
39355
|
continue;
|
|
39122
39356
|
}
|
|
39123
39357
|
try {
|
|
39124
|
-
const path2 = await this.resolvePath(
|
|
39358
|
+
const path2 = await this.resolvePath(join21(target, child2.name), signal);
|
|
39125
39359
|
entries.push({ directoryId: encodePath(path2), name: child2.name });
|
|
39126
39360
|
} catch (cause) {
|
|
39127
39361
|
signal.throwIfAborted();
|
|
@@ -39131,7 +39365,7 @@ var WorkspaceDirectoryService = class {
|
|
|
39131
39365
|
}
|
|
39132
39366
|
}
|
|
39133
39367
|
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
39134
|
-
const parent =
|
|
39368
|
+
const parent = dirname6(target);
|
|
39135
39369
|
return new WorkspaceDirectoryListing(
|
|
39136
39370
|
id,
|
|
39137
39371
|
this.label(target),
|
|
@@ -39157,15 +39391,15 @@ var WorkspaceDirectoryService = class {
|
|
|
39157
39391
|
|
|
39158
39392
|
// src/daemon-diagnostic-log.ts
|
|
39159
39393
|
import { appendFileSync, mkdirSync, readFileSync as readFileSync2, renameSync, statSync as statSync3, writeFileSync } from "node:fs";
|
|
39160
|
-
import { join as
|
|
39394
|
+
import { join as join22 } from "node:path";
|
|
39161
39395
|
var MAXIMUM_DAEMON_LOG_BYTES = 1 * 1024 * 1024;
|
|
39162
39396
|
var DaemonDiagnosticLog = class {
|
|
39163
39397
|
#directory;
|
|
39164
39398
|
#path;
|
|
39165
39399
|
#maximumBytes;
|
|
39166
39400
|
constructor(stateDirectory, maximumBytes = MAXIMUM_DAEMON_LOG_BYTES) {
|
|
39167
|
-
this.#directory =
|
|
39168
|
-
this.#path =
|
|
39401
|
+
this.#directory = join22(stateDirectory, "logs");
|
|
39402
|
+
this.#path = join22(this.#directory, "daemon.log");
|
|
39169
39403
|
this.#maximumBytes = maximumBytes;
|
|
39170
39404
|
}
|
|
39171
39405
|
// Export only correlation and failure metadata. Local messages and paths stay local.
|
|
@@ -39981,7 +40215,7 @@ var ActiveDaemonTurn = class {
|
|
|
39981
40215
|
var MAX_SESSIONS_WITH_COMPLETED_RECOVERY = 32;
|
|
39982
40216
|
var waitForTurnCompletion = (turn, waitSignal) => {
|
|
39983
40217
|
waitSignal.throwIfAborted();
|
|
39984
|
-
return new Promise((
|
|
40218
|
+
return new Promise((resolve10, reject) => {
|
|
39985
40219
|
let settled = false;
|
|
39986
40220
|
const finish = (result) => {
|
|
39987
40221
|
if (settled) {
|
|
@@ -39990,7 +40224,7 @@ var waitForTurnCompletion = (turn, waitSignal) => {
|
|
|
39990
40224
|
settled = true;
|
|
39991
40225
|
waitSignal.removeEventListener("abort", onAbort);
|
|
39992
40226
|
if (result.kind === "completed") {
|
|
39993
|
-
|
|
40227
|
+
resolve10();
|
|
39994
40228
|
} else {
|
|
39995
40229
|
reject(result.error);
|
|
39996
40230
|
}
|
|
@@ -40188,7 +40422,7 @@ var sessionEventCacheMigrations = [
|
|
|
40188
40422
|
|
|
40189
40423
|
// src/infra/local-sqlite-database.ts
|
|
40190
40424
|
import { chmodSync, mkdirSync as mkdirSync2 } from "node:fs";
|
|
40191
|
-
import { dirname as
|
|
40425
|
+
import { dirname as dirname7 } from "node:path";
|
|
40192
40426
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
40193
40427
|
|
|
40194
40428
|
// ../../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
|
|
@@ -40299,7 +40533,7 @@ var LocalSqliteDatabase = class {
|
|
|
40299
40533
|
orm;
|
|
40300
40534
|
#sqlite;
|
|
40301
40535
|
constructor(path2, label, migrations, pragmas = []) {
|
|
40302
|
-
mkdirSync2(
|
|
40536
|
+
mkdirSync2(dirname7(path2), { mode: 448, recursive: true });
|
|
40303
40537
|
this.#sqlite = new DatabaseSync2(path2);
|
|
40304
40538
|
chmodSync(path2, 384);
|
|
40305
40539
|
try {
|
|
@@ -40858,10 +41092,11 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
40858
41092
|
);
|
|
40859
41093
|
}
|
|
40860
41094
|
signal.throwIfAborted();
|
|
40861
|
-
const
|
|
41095
|
+
const launch = executableLaunch2(agent.agentIdentity.realPath, ["app-server"]);
|
|
41096
|
+
const child2 = spawn5(launch.command, [...launch.arguments], {
|
|
40862
41097
|
cwd,
|
|
40863
41098
|
env: { ...process.env, ...agent.environment },
|
|
40864
|
-
|
|
41099
|
+
...platformSpawnOptions,
|
|
40865
41100
|
shell: false,
|
|
40866
41101
|
stdio: ["pipe", "pipe", "ignore"]
|
|
40867
41102
|
});
|
|
@@ -41665,7 +41900,7 @@ import { WebSocket as WebSocket5 } from "undici";
|
|
|
41665
41900
|
// package.json
|
|
41666
41901
|
var package_default = {
|
|
41667
41902
|
name: "@moxt-ai/mobius",
|
|
41668
|
-
version: "0.0.
|
|
41903
|
+
version: "0.0.197",
|
|
41669
41904
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
41670
41905
|
type: "module",
|
|
41671
41906
|
bin: {
|
|
@@ -41674,7 +41909,9 @@ var package_default = {
|
|
|
41674
41909
|
types: "./src/index.ts",
|
|
41675
41910
|
exports: {
|
|
41676
41911
|
".": "./src/index.ts",
|
|
41677
|
-
"./runtime": "./src/runtime.ts"
|
|
41912
|
+
"./runtime": "./src/runtime.ts",
|
|
41913
|
+
"./process": "./src/process/executable.ts",
|
|
41914
|
+
"./filesystem": "./src/filesystem/private-path.ts"
|
|
41678
41915
|
},
|
|
41679
41916
|
files: [
|
|
41680
41917
|
"dist"
|
|
@@ -41688,11 +41925,23 @@ var package_default = {
|
|
|
41688
41925
|
exports: {
|
|
41689
41926
|
".": {
|
|
41690
41927
|
types: "./dist/index.d.ts",
|
|
41691
|
-
import: "./dist/index.js"
|
|
41928
|
+
import: "./dist/index.js",
|
|
41929
|
+
default: "./dist/index.js"
|
|
41692
41930
|
},
|
|
41693
41931
|
"./runtime": {
|
|
41694
41932
|
types: "./dist/runtime.d.ts",
|
|
41695
|
-
import: "./dist/runtime.js"
|
|
41933
|
+
import: "./dist/runtime.js",
|
|
41934
|
+
default: "./dist/runtime.js"
|
|
41935
|
+
},
|
|
41936
|
+
"./process": {
|
|
41937
|
+
types: "./dist/process/executable.d.ts",
|
|
41938
|
+
import: "./dist/process/executable.js",
|
|
41939
|
+
default: "./dist/process/executable.js"
|
|
41940
|
+
},
|
|
41941
|
+
"./filesystem": {
|
|
41942
|
+
types: "./dist/filesystem/private-path.d.ts",
|
|
41943
|
+
import: "./dist/filesystem/private-path.js",
|
|
41944
|
+
default: "./dist/filesystem/private-path.js"
|
|
41696
41945
|
}
|
|
41697
41946
|
}
|
|
41698
41947
|
},
|
|
@@ -41702,7 +41951,7 @@ var package_default = {
|
|
|
41702
41951
|
directory: "packages/cli"
|
|
41703
41952
|
},
|
|
41704
41953
|
scripts: {
|
|
41705
|
-
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",
|
|
41954
|
+
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",
|
|
41706
41955
|
dev: "node --watch src/cli.ts",
|
|
41707
41956
|
prepack: "pnpm build",
|
|
41708
41957
|
start: "node dist/cli.js",
|
|
@@ -42363,8 +42612,8 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
42363
42612
|
|
|
42364
42613
|
// src/artifacts/local-file-streamer.ts
|
|
42365
42614
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
42366
|
-
import { realpath as
|
|
42367
|
-
import { basename as basename5, extname, isAbsolute as isAbsolute11, normalize as normalize4, resolve as
|
|
42615
|
+
import { realpath as realpath12, stat as stat10 } from "node:fs/promises";
|
|
42616
|
+
import { basename as basename5, extname as extname2, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve8 } from "node:path";
|
|
42368
42617
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
42369
42618
|
var CHUNK_BYTES = 192 * 1024;
|
|
42370
42619
|
function requestedPath(value) {
|
|
@@ -42386,12 +42635,12 @@ async function resolveFile(value, workingDirectory, signal) {
|
|
|
42386
42635
|
if (path2 === null || !isAbsolute11(path2) && workingDirectory === null) {
|
|
42387
42636
|
return null;
|
|
42388
42637
|
}
|
|
42389
|
-
const requested = workingDirectory === null ? path2 :
|
|
42638
|
+
const requested = workingDirectory === null ? path2 : resolve8(workingDirectory, path2);
|
|
42390
42639
|
if (!isAbsolute11(requested) || isAbsolute11(path2) && normalize4(path2) !== path2) {
|
|
42391
42640
|
return null;
|
|
42392
42641
|
}
|
|
42393
42642
|
try {
|
|
42394
|
-
const target = await
|
|
42643
|
+
const target = await realpath12(requested);
|
|
42395
42644
|
signal.throwIfAborted();
|
|
42396
42645
|
return isAbsolute11(target) && normalize4(target) === target ? target : null;
|
|
42397
42646
|
} catch {
|
|
@@ -42414,7 +42663,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
|
|
|
42414
42663
|
send2({
|
|
42415
42664
|
byteLength: before.size,
|
|
42416
42665
|
kind: FILE_BEGIN_KIND,
|
|
42417
|
-
mediaType: external?.mediaType ?? raster?.mimeType ?? (
|
|
42666
|
+
mediaType: external?.mediaType ?? raster?.mimeType ?? (extname2(target).toLowerCase() === ".svg" ? "image/svg+xml" : "application/octet-stream"),
|
|
42418
42667
|
modifiedAt: before.mtime.toISOString(),
|
|
42419
42668
|
name: external?.name ?? (basename5(target) || "file"),
|
|
42420
42669
|
requestId: command.requestId,
|
|
@@ -43316,13 +43565,13 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
43316
43565
|
operationSignal.throwIfAborted();
|
|
43317
43566
|
const skipPrevious = command.action === "active-turn";
|
|
43318
43567
|
if (previous.length > 0 && !skipPrevious) {
|
|
43319
|
-
await new Promise((
|
|
43568
|
+
await new Promise((resolve10, reject) => {
|
|
43320
43569
|
const onAbort = () => reject(operationSignal.reason);
|
|
43321
43570
|
operationSignal.addEventListener("abort", onAbort, { once: true });
|
|
43322
43571
|
void Promise.all(previous.map((request) => request.completion)).then(
|
|
43323
43572
|
() => {
|
|
43324
43573
|
operationSignal.removeEventListener("abort", onAbort);
|
|
43325
|
-
|
|
43574
|
+
resolve10();
|
|
43326
43575
|
},
|
|
43327
43576
|
(error62) => {
|
|
43328
43577
|
operationSignal.removeEventListener("abort", onAbort);
|
|
@@ -43736,7 +43985,7 @@ var RelayConnectionError = class extends Error {
|
|
|
43736
43985
|
};
|
|
43737
43986
|
function connectRelay(url2, signal) {
|
|
43738
43987
|
signal.throwIfAborted();
|
|
43739
|
-
return new Promise((
|
|
43988
|
+
return new Promise((resolve10, reject) => {
|
|
43740
43989
|
const endpoint = new URL(url2);
|
|
43741
43990
|
const headers = runtimeAuthorization(endpoint);
|
|
43742
43991
|
endpoint.searchParams.delete("token");
|
|
@@ -43803,7 +44052,7 @@ function connectRelay(url2, signal) {
|
|
|
43803
44052
|
}
|
|
43804
44053
|
finished = true;
|
|
43805
44054
|
cleanup();
|
|
43806
|
-
|
|
44055
|
+
resolve10(socket);
|
|
43807
44056
|
};
|
|
43808
44057
|
function onTimeout() {
|
|
43809
44058
|
fail(
|
|
@@ -43985,7 +44234,7 @@ async function runRelayConnection({
|
|
|
43985
44234
|
installationObserver.connect(socket);
|
|
43986
44235
|
onConnected();
|
|
43987
44236
|
try {
|
|
43988
|
-
await new Promise((
|
|
44237
|
+
await new Promise((resolve10, reject) => {
|
|
43989
44238
|
let finished = false;
|
|
43990
44239
|
const cleanup = () => {
|
|
43991
44240
|
connectionLiveness.close();
|
|
@@ -44003,7 +44252,7 @@ async function runRelayConnection({
|
|
|
44003
44252
|
}
|
|
44004
44253
|
finished = true;
|
|
44005
44254
|
cleanup();
|
|
44006
|
-
|
|
44255
|
+
resolve10();
|
|
44007
44256
|
};
|
|
44008
44257
|
const rejectConnection = (failure2) => {
|
|
44009
44258
|
if (finished) {
|
|
@@ -44389,12 +44638,12 @@ function waitForRelayRetry(signal, timer) {
|
|
|
44389
44638
|
if (signal.aborted) {
|
|
44390
44639
|
return Promise.resolve();
|
|
44391
44640
|
}
|
|
44392
|
-
return new Promise((
|
|
44641
|
+
return new Promise((resolve10) => {
|
|
44393
44642
|
const retry = timer.schedule(finish, RELAY_RECONNECT_DELAY_MILLISECONDS);
|
|
44394
44643
|
function finish() {
|
|
44395
44644
|
retry.cancel();
|
|
44396
44645
|
signal.removeEventListener("abort", finish);
|
|
44397
|
-
|
|
44646
|
+
resolve10();
|
|
44398
44647
|
}
|
|
44399
44648
|
signal.addEventListener("abort", finish, { once: true });
|
|
44400
44649
|
});
|
|
@@ -44450,11 +44699,11 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44450
44699
|
stateDirectory
|
|
44451
44700
|
});
|
|
44452
44701
|
const channelHash = createHash8("sha256").update(config2.channelId).digest("hex");
|
|
44453
|
-
const sessionDatabase = openAcpSessionDatabase(
|
|
44702
|
+
const sessionDatabase = openAcpSessionDatabase(join23(stateDirectory, "sessions", `${channelHash}.sqlite`));
|
|
44454
44703
|
let eventsV2;
|
|
44455
44704
|
try {
|
|
44456
44705
|
eventsV2 = new CachedAcpSessionEventStoreV2(
|
|
44457
|
-
openSessionEventCacheV2Database(
|
|
44706
|
+
openSessionEventCacheV2Database(join23(stateDirectory, "sessions", `${channelHash}.events.sqlite`))
|
|
44458
44707
|
);
|
|
44459
44708
|
} catch (error62) {
|
|
44460
44709
|
sessionDatabase.close();
|
|
@@ -44657,8 +44906,8 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44657
44906
|
}
|
|
44658
44907
|
|
|
44659
44908
|
// src/runtime.ts
|
|
44660
|
-
import { mkdir as mkdir7, realpath as
|
|
44661
|
-
import { resolve as
|
|
44909
|
+
import { mkdir as mkdir7, realpath as realpath13, stat as stat11 } from "node:fs/promises";
|
|
44910
|
+
import { resolve as resolve9 } from "node:path";
|
|
44662
44911
|
var RUNTIME_CREDENTIAL_PATTERN2 = /^[a-zA-Z0-9_-]{32,256}$/;
|
|
44663
44912
|
var MobiusRuntimeConfigurationError = class extends Error {
|
|
44664
44913
|
code = "runtime_configuration_invalid";
|
|
@@ -44721,10 +44970,10 @@ function loadMobiusRuntimeConnection(environment = process.env) {
|
|
|
44721
44970
|
});
|
|
44722
44971
|
}
|
|
44723
44972
|
async function resolveWorkspace(path2) {
|
|
44724
|
-
const requested =
|
|
44973
|
+
const requested = resolve9(path2);
|
|
44725
44974
|
try {
|
|
44726
44975
|
await mkdir7(requested, { recursive: true, mode: 448 });
|
|
44727
|
-
const resolved = await
|
|
44976
|
+
const resolved = await realpath13(requested);
|
|
44728
44977
|
const metadata = await stat11(resolved);
|
|
44729
44978
|
if (!metadata.isDirectory()) {
|
|
44730
44979
|
throw new MobiusRuntimeConfigurationError("The Runtime workspace is not a directory");
|