@moxt-ai/mobius 0.0.194 → 0.0.196
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp/agent-connection.d.ts.map +1 -1
- package/dist/acp/agent-connection.js +4 -3
- package/dist/acp/agent-connection.js.map +1 -1
- package/dist/acp/codex/app-server-client.d.ts.map +1 -1
- package/dist/acp/codex/app-server-client.js +4 -2
- package/dist/acp/codex/app-server-client.js.map +1 -1
- package/dist/agent-catalog/acp-readiness-probe.d.ts.map +1 -1
- package/dist/agent-catalog/acp-readiness-probe.js +4 -3
- package/dist/agent-catalog/acp-readiness-probe.js.map +1 -1
- package/dist/cli.js +630 -343
- package/dist/cli.js.map +4 -4
- package/dist/daemon-history-commands.d.ts.map +1 -1
- package/dist/daemon-history-commands.js +70 -29
- package/dist/daemon-history-commands.js.map +1 -1
- package/dist/daemon-manager.d.ts.map +1 -1
- package/dist/daemon-manager.js +7 -17
- package/dist/daemon-manager.js.map +1 -1
- package/dist/filesystem/path-error.d.ts +5 -0
- package/dist/filesystem/path-error.d.ts.map +1 -0
- package/dist/filesystem/path-error.js +8 -0
- package/dist/filesystem/path-error.js.map +1 -0
- package/dist/filesystem/private-path.d.ts +3 -0
- package/dist/filesystem/private-path.d.ts.map +1 -0
- package/dist/filesystem/private-path.js +550 -0
- package/dist/filesystem/private-path.js.map +7 -0
- package/dist/index.js +602 -306
- package/dist/index.js.map +4 -4
- package/dist/native-sessions/codex-history.d.ts.map +1 -1
- package/dist/native-sessions/codex-history.js +4 -3
- package/dist/native-sessions/codex-history.js.map +1 -1
- package/dist/platform/contracts.d.ts +21 -0
- package/dist/platform/contracts.d.ts.map +1 -1
- package/dist/platform/index.d.ts.map +1 -1
- package/dist/platform/index.js +5 -3
- package/dist/platform/index.js.map +1 -1
- package/dist/platform/linux.d.ts.map +1 -1
- package/dist/platform/linux.js +2 -1
- package/dist/platform/linux.js.map +1 -1
- package/dist/platform/macos.d.ts.map +1 -1
- package/dist/platform/macos.js +2 -1
- package/dist/platform/macos.js.map +1 -1
- package/dist/platform/posix.d.ts +28 -1
- package/dist/platform/posix.d.ts.map +1 -1
- package/dist/platform/posix.js +91 -1
- package/dist/platform/posix.js.map +1 -1
- package/dist/platform/windows.d.ts +3 -0
- package/dist/platform/windows.d.ts.map +1 -0
- package/dist/platform/windows.js +174 -0
- package/dist/platform/windows.js.map +1 -0
- package/dist/process/executable.d.ts +7 -5
- package/dist/process/executable.d.ts.map +1 -1
- package/dist/process/executable.js +844 -386
- package/dist/process/executable.js.map +7 -1
- package/dist/process/process-error.d.ts +5 -0
- package/dist/process/process-error.d.ts.map +1 -0
- package/dist/process/process-error.js +9 -0
- package/dist/process/process-error.js.map +1 -0
- package/dist/runtime.js +602 -306
- package/dist/runtime.js.map +4 -4
- package/dist/storage/runtime-installation-store.d.ts.map +1 -1
- package/dist/storage/runtime-installation-store.js +3 -0
- package/dist/storage/runtime-installation-store.js.map +1 -1
- package/package.json +72 -70
package/dist/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
|
}
|
|
@@ -21353,6 +21353,7 @@ var provenanceSchema = external_exports.discriminatedUnion("kind", [
|
|
|
21353
21353
|
]);
|
|
21354
21354
|
var sessionEventFieldsV2 = {
|
|
21355
21355
|
eventId: identifierStringSchema,
|
|
21356
|
+
mobiusMetadata: external_exports.object({ omitted: external_exports.literal(true).optional() }).readonly().optional(),
|
|
21356
21357
|
position: positionSchema,
|
|
21357
21358
|
provenance: provenanceSchema,
|
|
21358
21359
|
recordedAt: external_exports.iso.datetime({ offset: true }),
|
|
@@ -21419,7 +21420,12 @@ var sessionEventLogPageV2Schema = external_exports.object({
|
|
|
21419
21420
|
truncated: external_exports.boolean(),
|
|
21420
21421
|
version: external_exports.literal(2)
|
|
21421
21422
|
}).readonly();
|
|
21422
|
-
var
|
|
21423
|
+
var sessionEventOmissionV2Schema = external_exports.literal("agent-reasoning");
|
|
21424
|
+
var nativeEventPageRequestV2Schema = external_exports.object({
|
|
21425
|
+
cursor: external_exports.string().min(1).max(512).nullable(),
|
|
21426
|
+
eventLimit: external_exports.number().int().min(1).max(1e4),
|
|
21427
|
+
omit: external_exports.array(sessionEventOmissionV2Schema).max(1).readonly().optional()
|
|
21428
|
+
}).readonly();
|
|
21423
21429
|
var queuedPromptRequestEventLogV2Schema = external_exports.object({
|
|
21424
21430
|
commandId: identifierStringSchema,
|
|
21425
21431
|
content: external_exports.array(contentBlockV2Schema).min(1).max(100).readonly(),
|
|
@@ -21466,6 +21472,7 @@ var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-
|
|
|
21466
21472
|
var pageRequestFields = {
|
|
21467
21473
|
cursor: external_exports.string().min(1).max(512).nullable(),
|
|
21468
21474
|
eventLimit: external_exports.number().int().min(1).max(1e4),
|
|
21475
|
+
omit: external_exports.array(sessionEventOmissionV2Schema).max(1).readonly().optional(),
|
|
21469
21476
|
requestId: identifierStringSchema,
|
|
21470
21477
|
sessionId: identifierStringSchema
|
|
21471
21478
|
};
|
|
@@ -21823,17 +21830,31 @@ function normalizeAcpCapabilities(initialized) {
|
|
|
21823
21830
|
|
|
21824
21831
|
// src/process/executable.ts
|
|
21825
21832
|
import { spawn } from "node:child_process";
|
|
21826
|
-
import {
|
|
21827
|
-
import {
|
|
21828
|
-
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";
|
|
21829
21835
|
|
|
21830
21836
|
// src/platform/linux.ts
|
|
21831
|
-
import { constants, readdirSync, readFileSync } from "node:fs";
|
|
21832
|
-
import { access, readdir, readFile, realpath, stat } from "node:fs/promises";
|
|
21833
|
-
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";
|
|
21834
21840
|
|
|
21835
21841
|
// src/platform/posix.ts
|
|
21836
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
|
|
21837
21858
|
var PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
|
|
21838
21859
|
var PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
|
|
21839
21860
|
function parseProcessTable(output2) {
|
|
@@ -21878,6 +21899,81 @@ function processExists(processId) {
|
|
|
21878
21899
|
return false;
|
|
21879
21900
|
}
|
|
21880
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
|
+
};
|
|
21881
21977
|
|
|
21882
21978
|
// src/platform/linux.ts
|
|
21883
21979
|
function appendLinuxProcessTableEntry(entries, processId, encoded) {
|
|
@@ -21909,7 +22005,7 @@ async function readLinuxProcessTable() {
|
|
|
21909
22005
|
appendLinuxProcessTableEntry(
|
|
21910
22006
|
entries,
|
|
21911
22007
|
processId,
|
|
21912
|
-
await readFile(
|
|
22008
|
+
await readFile(join2("/proc", directory.name, "stat"), "utf8")
|
|
21913
22009
|
);
|
|
21914
22010
|
} catch {
|
|
21915
22011
|
}
|
|
@@ -21934,7 +22030,7 @@ function readLinuxProcessTableSynchronously() {
|
|
|
21934
22030
|
appendLinuxProcessTableEntry(
|
|
21935
22031
|
entries,
|
|
21936
22032
|
processId,
|
|
21937
|
-
readFileSync(
|
|
22033
|
+
readFileSync(join2("/proc", directory.name, "stat"), "utf8")
|
|
21938
22034
|
);
|
|
21939
22035
|
} catch {
|
|
21940
22036
|
}
|
|
@@ -21950,11 +22046,11 @@ async function readLinuxProcessTableWithFallback() {
|
|
|
21950
22046
|
}
|
|
21951
22047
|
for (const candidate of ["/usr/bin/ps", "/bin/ps", "/run/current-system/sw/bin/ps"]) {
|
|
21952
22048
|
try {
|
|
21953
|
-
const resolvedPath = await
|
|
22049
|
+
const resolvedPath = await realpath2(candidate);
|
|
21954
22050
|
if (!(await stat(resolvedPath)).isFile()) {
|
|
21955
22051
|
continue;
|
|
21956
22052
|
}
|
|
21957
|
-
await
|
|
22053
|
+
await access2(resolvedPath, constants2.X_OK);
|
|
21958
22054
|
} catch {
|
|
21959
22055
|
continue;
|
|
21960
22056
|
}
|
|
@@ -21967,7 +22063,7 @@ async function readLinuxProcessTableWithFallback() {
|
|
|
21967
22063
|
}
|
|
21968
22064
|
function processExists2(processId) {
|
|
21969
22065
|
try {
|
|
21970
|
-
const encoded = readFileSync(
|
|
22066
|
+
const encoded = readFileSync(join2("/proc", processId.toString(), "stat"), "utf8");
|
|
21971
22067
|
const closingParenthesis = encoded.lastIndexOf(")");
|
|
21972
22068
|
if (closingParenthesis >= 0) {
|
|
21973
22069
|
const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
|
|
@@ -21980,6 +22076,7 @@ function processExists2(processId) {
|
|
|
21980
22076
|
return processExists(processId);
|
|
21981
22077
|
}
|
|
21982
22078
|
var linuxPlatform = {
|
|
22079
|
+
...posixOperations,
|
|
21983
22080
|
readProcessTable: readLinuxProcessTableWithFallback,
|
|
21984
22081
|
readProcessTableSynchronously: readLinuxProcessTableSynchronously,
|
|
21985
22082
|
processExists: processExists2,
|
|
@@ -22011,7 +22108,7 @@ var linuxPlatform = {
|
|
|
22011
22108
|
};
|
|
22012
22109
|
|
|
22013
22110
|
// src/platform/macos.ts
|
|
22014
|
-
import { isAbsolute, join as
|
|
22111
|
+
import { isAbsolute, join as join3 } from "node:path";
|
|
22015
22112
|
var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
|
|
22016
22113
|
"WorkBuddy.app",
|
|
22017
22114
|
"Contents",
|
|
@@ -22022,14 +22119,15 @@ var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
|
|
|
22022
22119
|
"codebuddy"
|
|
22023
22120
|
]);
|
|
22024
22121
|
var macosPlatform = {
|
|
22122
|
+
...posixOperations,
|
|
22025
22123
|
readProcessTable: () => readProcessTableWithPs("/bin/ps"),
|
|
22026
22124
|
readProcessTableSynchronously: () => [],
|
|
22027
22125
|
processExists,
|
|
22028
22126
|
workBuddyExecutablePaths: (environment) => {
|
|
22029
|
-
const paths = [
|
|
22127
|
+
const paths = [join3("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
|
|
22030
22128
|
const homeDirectory = environment["HOME"];
|
|
22031
22129
|
if (homeDirectory !== void 0 && isAbsolute(homeDirectory)) {
|
|
22032
|
-
paths.unshift(
|
|
22130
|
+
paths.unshift(join3(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
|
|
22033
22131
|
}
|
|
22034
22132
|
return paths;
|
|
22035
22133
|
},
|
|
@@ -22059,8 +22157,199 @@ var macosPlatform = {
|
|
|
22059
22157
|
}
|
|
22060
22158
|
};
|
|
22061
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
|
+
|
|
22062
22350
|
// src/platform/index.ts
|
|
22063
22351
|
var fallbackPlatform = {
|
|
22352
|
+
...posixOperations,
|
|
22064
22353
|
readProcessTable: () => readProcessTableWithPs("/usr/bin/ps"),
|
|
22065
22354
|
readProcessTableSynchronously: () => [],
|
|
22066
22355
|
processExists,
|
|
@@ -22071,7 +22360,7 @@ var fallbackPlatform = {
|
|
|
22071
22360
|
var platforms = /* @__PURE__ */ new Map([
|
|
22072
22361
|
["linux", linuxPlatform],
|
|
22073
22362
|
["darwin", macosPlatform],
|
|
22074
|
-
["win32",
|
|
22363
|
+
["win32", windowsPlatform]
|
|
22075
22364
|
]);
|
|
22076
22365
|
function platformSupportFor(platform) {
|
|
22077
22366
|
return platforms.get(platform) ?? fallbackPlatform;
|
|
@@ -22110,14 +22399,6 @@ var ResolvedExecutable = class {
|
|
|
22110
22399
|
this.path = identity2.realPath;
|
|
22111
22400
|
}
|
|
22112
22401
|
};
|
|
22113
|
-
var ProcessExecutionError = class extends Error {
|
|
22114
|
-
code;
|
|
22115
|
-
constructor(code, message, options = {}) {
|
|
22116
|
-
super(message, options);
|
|
22117
|
-
this.code = code;
|
|
22118
|
-
this.name = "ProcessExecutionError";
|
|
22119
|
-
}
|
|
22120
|
-
};
|
|
22121
22402
|
var ProcessResult = class {
|
|
22122
22403
|
stderr;
|
|
22123
22404
|
stdout;
|
|
@@ -22126,28 +22407,14 @@ var ProcessResult = class {
|
|
|
22126
22407
|
this.stdout = stdout;
|
|
22127
22408
|
}
|
|
22128
22409
|
};
|
|
22129
|
-
function executableExtensions(executableName, environment, platform) {
|
|
22130
|
-
if (platform !== "win32") {
|
|
22131
|
-
return [""];
|
|
22132
|
-
}
|
|
22133
|
-
if (/\.[a-zA-Z0-9]+$/.test(executableName)) {
|
|
22134
|
-
return [""];
|
|
22135
|
-
}
|
|
22136
|
-
const configured = environment["PATHEXT"] ?? ".COM;.EXE;.BAT;.CMD";
|
|
22137
|
-
const extensions = configured.split(";").map((extension) => extension.trim()).filter((extension) => extension.length > 0).map((extension) => extension.startsWith(".") ? extension : `.${extension}`);
|
|
22138
|
-
return extensions.length > 0 ? extensions : [".EXE"];
|
|
22139
|
-
}
|
|
22140
22410
|
async function resolveExecutablePath(requestedPath2, platform = process.platform) {
|
|
22141
|
-
const absoluteRequestedPath =
|
|
22411
|
+
const absoluteRequestedPath = resolve2(requestedPath2);
|
|
22142
22412
|
try {
|
|
22143
|
-
const resolvedPath = await
|
|
22413
|
+
const resolvedPath = await platformSupportFor(platform).resolveExecutableTarget(absoluteRequestedPath);
|
|
22144
22414
|
const metadata = await stat2(resolvedPath);
|
|
22145
22415
|
if (!metadata.isFile()) {
|
|
22146
22416
|
return null;
|
|
22147
22417
|
}
|
|
22148
|
-
if (platform !== "win32") {
|
|
22149
|
-
await access2(resolvedPath, constants2.X_OK);
|
|
22150
|
-
}
|
|
22151
22418
|
return new ResolvedExecutable(
|
|
22152
22419
|
new ExecutableIdentity(
|
|
22153
22420
|
absoluteRequestedPath,
|
|
@@ -22163,15 +22430,16 @@ async function resolveExecutablePath(requestedPath2, platform = process.platform
|
|
|
22163
22430
|
}
|
|
22164
22431
|
}
|
|
22165
22432
|
async function findExecutableOnPath(executableName, environment, platform = process.platform) {
|
|
22166
|
-
const
|
|
22167
|
-
const
|
|
22168
|
-
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);
|
|
22169
22437
|
for (const entry of encodedPath.split(separator)) {
|
|
22170
22438
|
if (entry.length === 0) {
|
|
22171
22439
|
continue;
|
|
22172
22440
|
}
|
|
22173
22441
|
for (const extension of extensions) {
|
|
22174
|
-
const requestedPath2 =
|
|
22442
|
+
const requestedPath2 = resolve2(join5(entry, `${executableName}${extension}`));
|
|
22175
22443
|
const executable = await resolveExecutablePath(requestedPath2, platform);
|
|
22176
22444
|
if (executable !== null) {
|
|
22177
22445
|
return executable;
|
|
@@ -22192,7 +22460,7 @@ function appendBounded(chunks, chunk, currentBytes, limitBytes) {
|
|
|
22192
22460
|
chunks.push(chunk);
|
|
22193
22461
|
return nextBytes;
|
|
22194
22462
|
}
|
|
22195
|
-
function
|
|
22463
|
+
function readProcessTable2() {
|
|
22196
22464
|
return hostPlatform.readProcessTable();
|
|
22197
22465
|
}
|
|
22198
22466
|
function selectProcessTree(entries, rootProcessId) {
|
|
@@ -22227,38 +22495,14 @@ function mergeProcessTrees(captured, current) {
|
|
|
22227
22495
|
return [...processes.values()];
|
|
22228
22496
|
}
|
|
22229
22497
|
async function captureProcessTree(child2) {
|
|
22230
|
-
if (
|
|
22498
|
+
if (child2.pid === void 0) {
|
|
22231
22499
|
return [];
|
|
22232
22500
|
}
|
|
22233
22501
|
const entries = hostPlatform.readProcessTableSynchronously();
|
|
22234
22502
|
if (entries.length > 0) {
|
|
22235
22503
|
return selectProcessTree(entries, child2.pid);
|
|
22236
22504
|
}
|
|
22237
|
-
return selectProcessTree(await
|
|
22238
|
-
}
|
|
22239
|
-
function signalCapturedProcessGroups(processes, rootProcessId, signal) {
|
|
22240
|
-
const processIds = new Set(processes.map((identity2) => identity2.processId));
|
|
22241
|
-
const signalledGroups = /* @__PURE__ */ new Set();
|
|
22242
|
-
for (const identity2 of processes) {
|
|
22243
|
-
const isRootProcessGroup = identity2.processGroupId === rootProcessId;
|
|
22244
|
-
if (!isRootProcessGroup && !processIds.has(identity2.processGroupId) || signalledGroups.has(identity2.processGroupId)) {
|
|
22245
|
-
continue;
|
|
22246
|
-
}
|
|
22247
|
-
try {
|
|
22248
|
-
process.kill(-identity2.processGroupId, signal);
|
|
22249
|
-
signalledGroups.add(identity2.processGroupId);
|
|
22250
|
-
} catch {
|
|
22251
|
-
}
|
|
22252
|
-
}
|
|
22253
|
-
for (const identity2 of processes) {
|
|
22254
|
-
if (identity2.processId === rootProcessId || identity2.processGroupId === rootProcessId || signalledGroups.has(identity2.processGroupId)) {
|
|
22255
|
-
continue;
|
|
22256
|
-
}
|
|
22257
|
-
try {
|
|
22258
|
-
process.kill(identity2.processId, signal);
|
|
22259
|
-
} catch {
|
|
22260
|
-
}
|
|
22261
|
-
}
|
|
22505
|
+
return selectProcessTree(await readProcessTable2(), child2.pid);
|
|
22262
22506
|
}
|
|
22263
22507
|
async function waitForCapturedProcessesExit(processes, rootProcessId) {
|
|
22264
22508
|
const processIds = processes.map((identity2) => identity2.processId).filter((processId) => processId !== rootProcessId);
|
|
@@ -22266,36 +22510,10 @@ async function waitForCapturedProcessesExit(processes, rootProcessId) {
|
|
|
22266
22510
|
if (processIds.every((processId) => !hostPlatform.processExists(processId))) {
|
|
22267
22511
|
return true;
|
|
22268
22512
|
}
|
|
22269
|
-
await
|
|
22513
|
+
await readProcessTable2();
|
|
22270
22514
|
}
|
|
22271
22515
|
return processIds.every((processId) => !hostPlatform.processExists(processId));
|
|
22272
22516
|
}
|
|
22273
|
-
function terminateProcess(child2) {
|
|
22274
|
-
if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
|
|
22275
|
-
return;
|
|
22276
|
-
}
|
|
22277
|
-
if (process.platform !== "win32") {
|
|
22278
|
-
try {
|
|
22279
|
-
process.kill(-child2.pid, "SIGTERM");
|
|
22280
|
-
return;
|
|
22281
|
-
} catch {
|
|
22282
|
-
}
|
|
22283
|
-
}
|
|
22284
|
-
child2.kill("SIGTERM");
|
|
22285
|
-
}
|
|
22286
|
-
function forceTerminateProcess(child2) {
|
|
22287
|
-
if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
|
|
22288
|
-
return;
|
|
22289
|
-
}
|
|
22290
|
-
if (process.platform !== "win32") {
|
|
22291
|
-
try {
|
|
22292
|
-
process.kill(-child2.pid, "SIGKILL");
|
|
22293
|
-
return;
|
|
22294
|
-
} catch {
|
|
22295
|
-
}
|
|
22296
|
-
}
|
|
22297
|
-
child2.kill("SIGKILL");
|
|
22298
|
-
}
|
|
22299
22517
|
async function stopProcessTree(child2, capturedProcesses = []) {
|
|
22300
22518
|
const childProcessId = child2.pid;
|
|
22301
22519
|
if (childProcessId === void 0) {
|
|
@@ -22306,8 +22524,8 @@ async function stopProcessTree(child2, capturedProcesses = []) {
|
|
|
22306
22524
|
if (childExited && processes.length === 0) {
|
|
22307
22525
|
return;
|
|
22308
22526
|
}
|
|
22309
|
-
|
|
22310
|
-
terminateProcess(child2);
|
|
22527
|
+
hostPlatform.signalCapturedProcesses(processes, childProcessId, GRACEFUL_STOP_SIGNAL);
|
|
22528
|
+
hostPlatform.terminateProcess(child2, "SIGTERM");
|
|
22311
22529
|
const [exitedAfterTermination, descendantsExitedAfterTermination] = await Promise.all([
|
|
22312
22530
|
waitForProcessExit(child2, PROCESS_GRACEFUL_STOP_TIMEOUT_MILLISECONDS),
|
|
22313
22531
|
waitForCapturedProcessesExit(processes, childProcessId)
|
|
@@ -22315,8 +22533,8 @@ async function stopProcessTree(child2, capturedProcesses = []) {
|
|
|
22315
22533
|
if (exitedAfterTermination && descendantsExitedAfterTermination) {
|
|
22316
22534
|
return;
|
|
22317
22535
|
}
|
|
22318
|
-
|
|
22319
|
-
|
|
22536
|
+
hostPlatform.signalCapturedProcesses(processes, childProcessId, FORCED_STOP_SIGNAL);
|
|
22537
|
+
hostPlatform.terminateProcess(child2, "SIGKILL");
|
|
22320
22538
|
const [exitedAfterForce, descendantsExitedAfterForce] = await Promise.all([
|
|
22321
22539
|
waitForProcessExit(child2, PROCESS_FORCED_STOP_TIMEOUT_MILLISECONDS),
|
|
22322
22540
|
waitForCapturedProcessesExit(processes, childProcessId)
|
|
@@ -22351,9 +22569,10 @@ function waitForProcessExit(child2, timeoutMilliseconds) {
|
|
|
22351
22569
|
async function runBoundedProcess(options) {
|
|
22352
22570
|
options.signal.throwIfAborted();
|
|
22353
22571
|
const outputLimitBytes = options.outputLimitBytes ?? DEFAULT_OUTPUT_LIMIT_BYTES;
|
|
22354
|
-
const
|
|
22572
|
+
const launch = executableLaunch2(options.command, options.arguments);
|
|
22573
|
+
const child2 = spawn(launch.command, [...launch.arguments], {
|
|
22355
22574
|
cwd: options.cwd,
|
|
22356
|
-
|
|
22575
|
+
...hostPlatform.spawnOptions,
|
|
22357
22576
|
env: { ...options.environment },
|
|
22358
22577
|
shell: false,
|
|
22359
22578
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -22462,6 +22681,10 @@ async function runBoundedProcess(options) {
|
|
|
22462
22681
|
}
|
|
22463
22682
|
}
|
|
22464
22683
|
}
|
|
22684
|
+
function executableLaunch2(command, args) {
|
|
22685
|
+
return hostPlatform.executableLaunch(command, args);
|
|
22686
|
+
}
|
|
22687
|
+
var platformSpawnOptions = hostPlatform.spawnOptions;
|
|
22465
22688
|
|
|
22466
22689
|
// src/agent-catalog/local-agent.ts
|
|
22467
22690
|
function readTrustedIdentity(path2) {
|
|
@@ -22616,25 +22839,25 @@ var LocalAgentCatalog = class {
|
|
|
22616
22839
|
|
|
22617
22840
|
// src/storage/state-directory.ts
|
|
22618
22841
|
import { homedir } from "node:os";
|
|
22619
|
-
import { join as
|
|
22842
|
+
import { join as join6, resolve as resolve3 } from "node:path";
|
|
22620
22843
|
function readStateDirectory(environment = process.env) {
|
|
22621
22844
|
const configured = environment["MOBIUS_STATE_DIRECTORY"]?.trim();
|
|
22622
22845
|
if (configured !== void 0 && configured.length > 0) {
|
|
22623
|
-
return
|
|
22846
|
+
return resolve3(configured);
|
|
22624
22847
|
}
|
|
22625
|
-
return
|
|
22848
|
+
return join6(homedir(), ".mobius");
|
|
22626
22849
|
}
|
|
22627
22850
|
|
|
22628
22851
|
// src/config.ts
|
|
22629
22852
|
function loadDefaultWorkspace(environment = process.env) {
|
|
22630
22853
|
const { MOBIUS_DEFAULT_WORKSPACE: configuredWorkspace } = environment;
|
|
22631
|
-
return configuredWorkspace ??
|
|
22854
|
+
return configuredWorkspace ?? join7(readStateDirectory(environment), "workspace");
|
|
22632
22855
|
}
|
|
22633
22856
|
var DaemonLocalContext = class {
|
|
22634
22857
|
environment;
|
|
22635
22858
|
stateDirectory;
|
|
22636
22859
|
constructor(stateDirectory, environment = process.env) {
|
|
22637
|
-
this.stateDirectory =
|
|
22860
|
+
this.stateDirectory = resolve4(stateDirectory);
|
|
22638
22861
|
this.environment = Object.freeze({ ...environment, MOBIUS_STATE_DIRECTORY: this.stateDirectory });
|
|
22639
22862
|
}
|
|
22640
22863
|
};
|
|
@@ -22804,7 +23027,7 @@ import {
|
|
|
22804
23027
|
} from "@agentclientprotocol/sdk";
|
|
22805
23028
|
|
|
22806
23029
|
// src/authorization/local-raster.ts
|
|
22807
|
-
import { open as open2, readFile as
|
|
23030
|
+
import { open as open2, readFile as readFile3, realpath as realpath4, stat as stat3 } from "node:fs/promises";
|
|
22808
23031
|
import { basename, isAbsolute as isAbsolute2, normalize } from "node:path";
|
|
22809
23032
|
import { fileURLToPath } from "node:url";
|
|
22810
23033
|
var MAX_LOCAL_RASTER_BYTES = 128 * 1024 * 1024;
|
|
@@ -22827,7 +23050,7 @@ var LocalRasterImage = class {
|
|
|
22827
23050
|
this.sourceUri = sourceUri;
|
|
22828
23051
|
}
|
|
22829
23052
|
base64 = async () => {
|
|
22830
|
-
const bytes = this.bytes ?? new Uint8Array(await
|
|
23053
|
+
const bytes = this.bytes ?? new Uint8Array(await readFile3(this.sourceUri));
|
|
22831
23054
|
return Buffer.from(bytes).toString("base64");
|
|
22832
23055
|
};
|
|
22833
23056
|
};
|
|
@@ -22875,7 +23098,7 @@ async function resolveCanonicalPath(requested, signal) {
|
|
|
22875
23098
|
return null;
|
|
22876
23099
|
}
|
|
22877
23100
|
try {
|
|
22878
|
-
const target = await
|
|
23101
|
+
const target = await realpath4(requested);
|
|
22879
23102
|
signal.throwIfAborted();
|
|
22880
23103
|
if (!isAbsolute2(target) || normalize(target) !== target) {
|
|
22881
23104
|
return null;
|
|
@@ -23483,7 +23706,7 @@ function createWritableAcpStream(output2) {
|
|
|
23483
23706
|
if (outputFailure !== void 0) {
|
|
23484
23707
|
return Promise.reject(outputFailure);
|
|
23485
23708
|
}
|
|
23486
|
-
return new Promise((
|
|
23709
|
+
return new Promise((resolve10, reject) => {
|
|
23487
23710
|
pendingWriteFailures.add(reject);
|
|
23488
23711
|
output2.write(chunk, (error62) => {
|
|
23489
23712
|
pendingWriteFailures.delete(reject);
|
|
@@ -23496,7 +23719,7 @@ function createWritableAcpStream(output2) {
|
|
|
23496
23719
|
reject(outputFailure);
|
|
23497
23720
|
return;
|
|
23498
23721
|
}
|
|
23499
|
-
|
|
23722
|
+
resolve10();
|
|
23500
23723
|
});
|
|
23501
23724
|
});
|
|
23502
23725
|
}
|
|
@@ -23518,9 +23741,10 @@ var AgentConnection = class {
|
|
|
23518
23741
|
this.connection = createAcpClient(client2).connect(inProcess.app());
|
|
23519
23742
|
return;
|
|
23520
23743
|
}
|
|
23521
|
-
const
|
|
23744
|
+
const launch = executableLaunch2(agent.adapterPath, agent.arguments);
|
|
23745
|
+
const child2 = spawn2(launch.command, [...launch.arguments], {
|
|
23522
23746
|
cwd,
|
|
23523
|
-
|
|
23747
|
+
...platformSpawnOptions,
|
|
23524
23748
|
env: { ...process.env, ...agent.environment },
|
|
23525
23749
|
shell: false,
|
|
23526
23750
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -23537,12 +23761,12 @@ var AgentConnection = class {
|
|
|
23537
23761
|
stderr.on("data", (chunk) => {
|
|
23538
23762
|
process.stderr.write(`[${agent.id}-acp] ${chunk}`);
|
|
23539
23763
|
});
|
|
23540
|
-
this.termination = new Promise((
|
|
23764
|
+
this.termination = new Promise((resolve10) => {
|
|
23541
23765
|
child2.once("error", (cause) => {
|
|
23542
|
-
|
|
23766
|
+
resolve10({ kind: "failed", error: new AcpExecutionError("The ACP process could not run", { cause }) });
|
|
23543
23767
|
});
|
|
23544
23768
|
child2.once("exit", (code, signal) => {
|
|
23545
|
-
|
|
23769
|
+
resolve10({
|
|
23546
23770
|
kind: "failed",
|
|
23547
23771
|
error: new AcpExecutionError("The ACP process stopped", { cause: { code, signal } })
|
|
23548
23772
|
});
|
|
@@ -25755,7 +25979,7 @@ function sql(strings, ...params) {
|
|
|
25755
25979
|
return new SQL([new StringChunk(str)]);
|
|
25756
25980
|
}
|
|
25757
25981
|
_sql.raw = raw;
|
|
25758
|
-
function
|
|
25982
|
+
function join24(chunks, separator) {
|
|
25759
25983
|
const result = [];
|
|
25760
25984
|
for (const [i, chunk] of chunks.entries()) {
|
|
25761
25985
|
if (i > 0 && separator !== void 0) result.push(separator);
|
|
@@ -25763,7 +25987,7 @@ function sql(strings, ...params) {
|
|
|
25763
25987
|
}
|
|
25764
25988
|
return new SQL(result);
|
|
25765
25989
|
}
|
|
25766
|
-
_sql.join =
|
|
25990
|
+
_sql.join = join24;
|
|
25767
25991
|
function identifier2(value) {
|
|
25768
25992
|
return new Name(value);
|
|
25769
25993
|
}
|
|
@@ -27908,7 +28132,7 @@ var SQLiteSelectBase = class extends TypedQueryBuilder {
|
|
|
27908
28132
|
const baseTableName = this.tableName;
|
|
27909
28133
|
const tableName = getTableLikeName(table);
|
|
27910
28134
|
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
27911
|
-
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`);
|
|
27912
28136
|
if (!this.isPartialSelect) {
|
|
27913
28137
|
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
|
|
27914
28138
|
if (typeof tableName === "string" && !is(table, SQL)) {
|
|
@@ -28747,7 +28971,7 @@ var SQLiteDialect = class {
|
|
|
28747
28971
|
if (!joins2) return;
|
|
28748
28972
|
const withEntries = Object.entries(joins2).filter(([_, v]) => v);
|
|
28749
28973
|
if (!withEntries.length) return;
|
|
28750
|
-
return sql.join(withEntries.map(([k,
|
|
28974
|
+
return sql.join(withEntries.map(([k, join24]) => {
|
|
28751
28975
|
const relation = tableConfig.relations[k];
|
|
28752
28976
|
const isSingle2 = is(relation, One);
|
|
28753
28977
|
const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
|
|
@@ -28758,7 +28982,7 @@ var SQLiteDialect = class {
|
|
|
28758
28982
|
table: targetTable,
|
|
28759
28983
|
mode: isSingle2 ? "first" : "many",
|
|
28760
28984
|
schema,
|
|
28761
|
-
queryConfig:
|
|
28985
|
+
queryConfig: join24,
|
|
28762
28986
|
tableConfig: schema[relation.targetTableName],
|
|
28763
28987
|
relationWhere: filter,
|
|
28764
28988
|
isNested: true,
|
|
@@ -28772,7 +28996,7 @@ var SQLiteDialect = class {
|
|
|
28772
28996
|
key: k,
|
|
28773
28997
|
selection: innerQuery.selection,
|
|
28774
28998
|
isArray: !isSingle2,
|
|
28775
|
-
isOptional: (relation.optional ?? false) ||
|
|
28999
|
+
isOptional: (relation.optional ?? false) || join24 !== true && !!join24.where
|
|
28776
29000
|
});
|
|
28777
29001
|
const jsonColumns = sql.join(innerQuery.selection.map((s) => {
|
|
28778
29002
|
return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
|
|
@@ -29388,7 +29612,7 @@ var SQLiteUpdateBase = class {
|
|
|
29388
29612
|
createJoin(joinType) {
|
|
29389
29613
|
return ((table, on) => {
|
|
29390
29614
|
const tableName = getTableLikeName(table);
|
|
29391
|
-
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`);
|
|
29392
29616
|
if (typeof on === "function") {
|
|
29393
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;
|
|
29394
29618
|
on = on(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
|
|
@@ -32047,8 +32271,8 @@ var AcpContentExternalizer = class {
|
|
|
32047
32271
|
|
|
32048
32272
|
// src/external-content/local-external-content-store.ts
|
|
32049
32273
|
import { createHash, randomUUID as randomUUID2 } from "node:crypto";
|
|
32050
|
-
import { lstat, mkdir, readdir as readdir2, realpath as
|
|
32051
|
-
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";
|
|
32052
32276
|
var contentRequest = /^mobius-content:(image|audio|resource):([a-f0-9]{64})$/u;
|
|
32053
32277
|
var CONTENT_LIFETIME_MILLISECONDS = 24 * 60 * 60 * 1e3;
|
|
32054
32278
|
var metadataSchema2 = external_exports.strictObject({
|
|
@@ -32084,7 +32308,7 @@ var LocalExternalContentStore = class {
|
|
|
32084
32308
|
#expirationTimer;
|
|
32085
32309
|
#cleanup = Promise.resolve();
|
|
32086
32310
|
constructor(stateDirectory) {
|
|
32087
|
-
this.#root =
|
|
32311
|
+
this.#root = join8(stateDirectory, "tmp", "session-content", randomUUID2());
|
|
32088
32312
|
this.#expirationTimer = setInterval(() => {
|
|
32089
32313
|
void this.#expire().catch(() => void 0);
|
|
32090
32314
|
}, 6e4);
|
|
@@ -32095,11 +32319,11 @@ var LocalExternalContentStore = class {
|
|
|
32095
32319
|
await mkdir(this.#root, { mode: 448, recursive: true });
|
|
32096
32320
|
const now = /* @__PURE__ */ new Date();
|
|
32097
32321
|
await utimes(this.#root, now, now);
|
|
32098
|
-
for (const directory of await readdir2(
|
|
32322
|
+
for (const directory of await readdir2(dirname2(this.#root), { withFileTypes: true })) {
|
|
32099
32323
|
if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
|
|
32100
32324
|
continue;
|
|
32101
32325
|
}
|
|
32102
|
-
const path2 =
|
|
32326
|
+
const path2 = join8(dirname2(this.#root), directory.name);
|
|
32103
32327
|
if (path2 === this.#root) {
|
|
32104
32328
|
continue;
|
|
32105
32329
|
}
|
|
@@ -32149,10 +32373,10 @@ var LocalExternalContentStore = class {
|
|
|
32149
32373
|
}
|
|
32150
32374
|
await this.#expire();
|
|
32151
32375
|
active.throwIfAborted();
|
|
32152
|
-
const directory =
|
|
32376
|
+
const directory = join8(this.#root, kind);
|
|
32153
32377
|
await mkdir(directory, { mode: 448, recursive: true });
|
|
32154
32378
|
active.throwIfAborted();
|
|
32155
|
-
const path2 =
|
|
32379
|
+
const path2 = join8(directory, key);
|
|
32156
32380
|
const write = atomicWrite(path2, bytes, active);
|
|
32157
32381
|
await write;
|
|
32158
32382
|
active.throwIfAborted();
|
|
@@ -32185,12 +32409,12 @@ var LocalExternalContentStore = class {
|
|
|
32185
32409
|
}
|
|
32186
32410
|
try {
|
|
32187
32411
|
const [resolvedDirectory, resolvedPath, file2] = await Promise.all([
|
|
32188
|
-
|
|
32189
|
-
|
|
32190
|
-
|
|
32412
|
+
realpath5(dirname2(entry.path)),
|
|
32413
|
+
realpath5(entry.path),
|
|
32414
|
+
lstat2(entry.path)
|
|
32191
32415
|
]);
|
|
32192
32416
|
signal.throwIfAborted();
|
|
32193
|
-
if (!file2.isFile() || file2.isSymbolicLink() ||
|
|
32417
|
+
if (!file2.isFile() || file2.isSymbolicLink() || dirname2(resolvedPath) !== resolvedDirectory) {
|
|
32194
32418
|
return null;
|
|
32195
32419
|
}
|
|
32196
32420
|
return { mediaType: entry.mediaType, name: entry.name, path: resolvedPath };
|
|
@@ -33283,9 +33507,9 @@ var LocalAuthorizationError = class extends Error {
|
|
|
33283
33507
|
};
|
|
33284
33508
|
|
|
33285
33509
|
// src/pairing/pair-local-machine.ts
|
|
33286
|
-
import { mkdir as mkdir6, realpath as
|
|
33510
|
+
import { mkdir as mkdir6, realpath as realpath10, stat as stat8 } from "node:fs/promises";
|
|
33287
33511
|
import { hostname as hostname3 } from "node:os";
|
|
33288
|
-
import { basename as basename3, resolve as
|
|
33512
|
+
import { basename as basename3, resolve as resolve6 } from "node:path";
|
|
33289
33513
|
import { fetch as fetch3 } from "undici";
|
|
33290
33514
|
|
|
33291
33515
|
// src/agent-catalog/agent-discovery.ts
|
|
@@ -33428,8 +33652,8 @@ var LocalAgentInventory = class {
|
|
|
33428
33652
|
};
|
|
33429
33653
|
|
|
33430
33654
|
// src/agent-installation/managed-npm-package.ts
|
|
33431
|
-
import { mkdir as mkdir2, mkdtemp, open as open3, realpath as
|
|
33432
|
-
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";
|
|
33433
33657
|
var INSTALL_TIMEOUT_MILLISECONDS = 5 * 60 * 1e3;
|
|
33434
33658
|
var PACKAGE_METADATA_LIMIT_BYTES = 64 * 1024;
|
|
33435
33659
|
var PACKAGE_LOCK_LIMIT_BYTES = 8 * 1024 * 1024;
|
|
@@ -33480,7 +33704,7 @@ function isRecord7(value) {
|
|
|
33480
33704
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
33481
33705
|
}
|
|
33482
33706
|
function packagePath(root, packageName) {
|
|
33483
|
-
return
|
|
33707
|
+
return join9(root, "node_modules", ...packageName.split("/"));
|
|
33484
33708
|
}
|
|
33485
33709
|
function isContainedPath(root, candidate) {
|
|
33486
33710
|
const difference = relative(root, candidate);
|
|
@@ -33585,14 +33809,14 @@ function verifyPackageLockEntry(lock, definition, verifyDependencyClosure) {
|
|
|
33585
33809
|
}
|
|
33586
33810
|
}
|
|
33587
33811
|
async function verifyRequiredDependency(rootPath, lock, definition) {
|
|
33588
|
-
const dependencyRoot = await
|
|
33812
|
+
const dependencyRoot = await realpath6(packagePath(rootPath, definition.packageName));
|
|
33589
33813
|
if (!isContainedPath(rootPath, dependencyRoot)) {
|
|
33590
33814
|
throw new ManagedNpmPackageError(
|
|
33591
33815
|
"managed_package_verification_failed",
|
|
33592
33816
|
"The required managed npm dependency escaped its private cache"
|
|
33593
33817
|
);
|
|
33594
33818
|
}
|
|
33595
|
-
const metadata = await readJsonRecord(
|
|
33819
|
+
const metadata = await readJsonRecord(join9(dependencyRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
|
|
33596
33820
|
if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
|
|
33597
33821
|
throw new ManagedNpmPackageError(
|
|
33598
33822
|
"managed_package_verification_failed",
|
|
@@ -33614,15 +33838,15 @@ async function validateManagedNpmPackage(root, definition) {
|
|
|
33614
33838
|
}
|
|
33615
33839
|
}
|
|
33616
33840
|
async function validateManagedNpmPackageContents(root, definition) {
|
|
33617
|
-
const rootPath = await
|
|
33618
|
-
const packageRoot = await
|
|
33841
|
+
const rootPath = await realpath6(root);
|
|
33842
|
+
const packageRoot = await realpath6(packagePath(rootPath, definition.packageName));
|
|
33619
33843
|
if (!isContainedPath(rootPath, packageRoot)) {
|
|
33620
33844
|
throw new ManagedNpmPackageError(
|
|
33621
33845
|
"managed_package_verification_failed",
|
|
33622
33846
|
"The managed npm package escaped its private cache"
|
|
33623
33847
|
);
|
|
33624
33848
|
}
|
|
33625
|
-
const metadata = await readJsonRecord(
|
|
33849
|
+
const metadata = await readJsonRecord(join9(packageRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
|
|
33626
33850
|
if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
|
|
33627
33851
|
throw new ManagedNpmPackageError(
|
|
33628
33852
|
"managed_package_verification_failed",
|
|
@@ -33630,14 +33854,14 @@ async function validateManagedNpmPackageContents(root, definition) {
|
|
|
33630
33854
|
);
|
|
33631
33855
|
}
|
|
33632
33856
|
if (definition instanceof SriManagedNpmPackageDefinition) {
|
|
33633
|
-
const lock = await readJsonRecord(
|
|
33857
|
+
const lock = await readJsonRecord(join9(rootPath, "package-lock.json"), PACKAGE_LOCK_LIMIT_BYTES);
|
|
33634
33858
|
verifyPackageLockEntry(lock, definition, definition.verifyDependencyClosure);
|
|
33635
33859
|
for (const dependency of definition.requiredDependencies) {
|
|
33636
33860
|
await verifyRequiredDependency(rootPath, lock, dependency);
|
|
33637
33861
|
}
|
|
33638
33862
|
}
|
|
33639
33863
|
const declaredBin = readBinPath(metadata, definition.executableName);
|
|
33640
|
-
const executable = await resolveExecutablePath(
|
|
33864
|
+
const executable = await resolveExecutablePath(join9(packageRoot, declaredBin));
|
|
33641
33865
|
if (executable === null || !isContainedPath(rootPath, executable.path)) {
|
|
33642
33866
|
throw new ManagedNpmPackageError(
|
|
33643
33867
|
"managed_package_verification_failed",
|
|
@@ -33659,9 +33883,9 @@ var ManagedNpmPackageInstaller = class {
|
|
|
33659
33883
|
throw error62;
|
|
33660
33884
|
}
|
|
33661
33885
|
}
|
|
33662
|
-
const parent =
|
|
33886
|
+
const parent = dirname3(root);
|
|
33663
33887
|
await mkdir2(parent, { mode: 448, recursive: true });
|
|
33664
|
-
const staging = await mkdtemp(
|
|
33888
|
+
const staging = await mkdtemp(join9(parent, `.${definition.version}.staging-`));
|
|
33665
33889
|
try {
|
|
33666
33890
|
const npm = await findExecutableOnPath(process.platform === "win32" ? "npm.cmd" : "npm", environment);
|
|
33667
33891
|
if (npm === null) {
|
|
@@ -33687,14 +33911,14 @@ var ManagedNpmPackageInstaller = class {
|
|
|
33687
33911
|
`${definition.packageName}@${definition.version}`
|
|
33688
33912
|
);
|
|
33689
33913
|
const installEnvironment = {
|
|
33690
|
-
HOME:
|
|
33914
|
+
HOME: join9(staging, "home"),
|
|
33691
33915
|
NPM_CONFIG_AUDIT: "false",
|
|
33692
|
-
NPM_CONFIG_CACHE:
|
|
33916
|
+
NPM_CONFIG_CACHE: join9(staging, ".npm-cache"),
|
|
33693
33917
|
NPM_CONFIG_FUND: "false",
|
|
33694
33918
|
NPM_CONFIG_IGNORE_SCRIPTS: "true",
|
|
33695
33919
|
NPM_CONFIG_PACKAGE_LOCK: "true",
|
|
33696
33920
|
NPM_CONFIG_REGISTRY: "https://registry.npmjs.org/",
|
|
33697
|
-
PATH: `${
|
|
33921
|
+
PATH: `${dirname3(process.execPath)}${delimiter}/usr/bin${delimiter}/bin`
|
|
33698
33922
|
};
|
|
33699
33923
|
if (definition.includeOptionalDependencies) {
|
|
33700
33924
|
installEnvironment["NPM_CONFIG_INCLUDE"] = "optional";
|
|
@@ -33711,8 +33935,8 @@ var ManagedNpmPackageInstaller = class {
|
|
|
33711
33935
|
timeoutMilliseconds: INSTALL_TIMEOUT_MILLISECONDS
|
|
33712
33936
|
});
|
|
33713
33937
|
await Promise.all([
|
|
33714
|
-
rm2(
|
|
33715
|
-
rm2(
|
|
33938
|
+
rm2(join9(staging, ".npm-cache"), { force: true, recursive: true }),
|
|
33939
|
+
rm2(join9(staging, "home"), { force: true, recursive: true })
|
|
33716
33940
|
]);
|
|
33717
33941
|
await validateManagedNpmPackage(staging, definition);
|
|
33718
33942
|
try {
|
|
@@ -33748,7 +33972,7 @@ var ManagedNpmPackageInstaller = class {
|
|
|
33748
33972
|
};
|
|
33749
33973
|
|
|
33750
33974
|
// src/agent-catalog/agent-specification.ts
|
|
33751
|
-
import { join as
|
|
33975
|
+
import { join as join10 } from "node:path";
|
|
33752
33976
|
|
|
33753
33977
|
// src/agent-catalog/version-output.ts
|
|
33754
33978
|
function normalizeVersionOutput(output2) {
|
|
@@ -33771,7 +33995,7 @@ var LocalAgentSpecification = class {
|
|
|
33771
33995
|
resolveManagedAgent = async (stateDirectory, platform, signal) => {
|
|
33772
33996
|
signal.throwIfAborted();
|
|
33773
33997
|
const executable = await resolveExecutablePath(
|
|
33774
|
-
|
|
33998
|
+
join10(stateDirectory, ...this.managedAgentExecutablePath),
|
|
33775
33999
|
platform
|
|
33776
34000
|
);
|
|
33777
34001
|
signal.throwIfAborted();
|
|
@@ -34147,9 +34371,10 @@ var CodexAppServerClient = class {
|
|
|
34147
34371
|
#pendingFragments = [];
|
|
34148
34372
|
constructor(options) {
|
|
34149
34373
|
this.#handlers = options.handlers;
|
|
34150
|
-
|
|
34374
|
+
const launch = executableLaunch2(options.command, ["app-server"]);
|
|
34375
|
+
this.#child = spawn3(launch.command, [...launch.arguments], {
|
|
34151
34376
|
cwd: options.cwd,
|
|
34152
|
-
|
|
34377
|
+
...platformSpawnOptions,
|
|
34153
34378
|
env: { ...process.env, ...options.environment },
|
|
34154
34379
|
shell: false,
|
|
34155
34380
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -35806,7 +36031,7 @@ var AgentProbeError = class extends Error {
|
|
|
35806
36031
|
};
|
|
35807
36032
|
|
|
35808
36033
|
// src/agent-catalog/agents/resolve-user-local-executable.ts
|
|
35809
|
-
import { isAbsolute as isAbsolute5, join as
|
|
36034
|
+
import { isAbsolute as isAbsolute5, join as join11 } from "node:path";
|
|
35810
36035
|
async function resolveUserLocalExecutable(executableName, context) {
|
|
35811
36036
|
context.signal.throwIfAborted();
|
|
35812
36037
|
const platform = context.platform ?? process.platform;
|
|
@@ -35814,7 +36039,7 @@ async function resolveUserLocalExecutable(executableName, context) {
|
|
|
35814
36039
|
if (platform === "win32" || homeDirectory === void 0 || !isAbsolute5(homeDirectory)) {
|
|
35815
36040
|
return [];
|
|
35816
36041
|
}
|
|
35817
|
-
const executable = await resolveExecutablePath(
|
|
36042
|
+
const executable = await resolveExecutablePath(join11(homeDirectory, ".local", "bin", executableName), platform);
|
|
35818
36043
|
context.signal.throwIfAborted();
|
|
35819
36044
|
return executable === null ? [] : [executable];
|
|
35820
36045
|
}
|
|
@@ -35903,8 +36128,8 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
35903
36128
|
};
|
|
35904
36129
|
|
|
35905
36130
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
35906
|
-
import { mkdir as mkdir3, realpath as
|
|
35907
|
-
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";
|
|
35908
36133
|
|
|
35909
36134
|
// src/agent-installation/deepseek-managed-package.ts
|
|
35910
36135
|
var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
|
|
@@ -35935,13 +36160,13 @@ async function prepareAgentHome(path2, imagePrompts) {
|
|
|
35935
36160
|
if (imagePrompts) {
|
|
35936
36161
|
await mkdir3(path2, { mode: 448, recursive: true });
|
|
35937
36162
|
}
|
|
35938
|
-
const resolved = await
|
|
36163
|
+
const resolved = await realpath7(path2);
|
|
35939
36164
|
const metadata = await stat6(resolved);
|
|
35940
36165
|
if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
|
|
35941
36166
|
throw new Error("Agent home is not a user-owned directory");
|
|
35942
36167
|
}
|
|
35943
36168
|
if (imagePrompts) {
|
|
35944
|
-
await writeFile2(
|
|
36169
|
+
await writeFile2(join12(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
|
|
35945
36170
|
mode: 384
|
|
35946
36171
|
});
|
|
35947
36172
|
}
|
|
@@ -35989,7 +36214,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
35989
36214
|
context.signal
|
|
35990
36215
|
);
|
|
35991
36216
|
if (managed.path === agent.path) {
|
|
35992
|
-
selectedHome =
|
|
36217
|
+
selectedHome = join12(readStateDirectory(context.environment), "agents", this.id, "home");
|
|
35993
36218
|
managedHome = true;
|
|
35994
36219
|
}
|
|
35995
36220
|
} catch {
|
|
@@ -36005,7 +36230,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
36005
36230
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
36006
36231
|
signal.throwIfAborted();
|
|
36007
36232
|
const executable = await validateManagedNpmPackage(
|
|
36008
|
-
|
|
36233
|
+
join12(stateDirectory, "agents", this.id, DEEPSEEK_HARNESS_PACKAGE.version),
|
|
36009
36234
|
DEEPSEEK_HARNESS_PACKAGE
|
|
36010
36235
|
);
|
|
36011
36236
|
signal.throwIfAborted();
|
|
@@ -36059,8 +36284,8 @@ var GeminiCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
36059
36284
|
};
|
|
36060
36285
|
|
|
36061
36286
|
// src/agent-catalog/agents/grok-build-agent.ts
|
|
36062
|
-
import { realpath as
|
|
36063
|
-
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";
|
|
36064
36289
|
import {
|
|
36065
36290
|
RequestError as RequestError2
|
|
36066
36291
|
} from "@agentclientprotocol/sdk";
|
|
@@ -36130,8 +36355,8 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
36130
36355
|
);
|
|
36131
36356
|
if (managed.path === agent.path) {
|
|
36132
36357
|
return Object.freeze({
|
|
36133
|
-
GROK_HOME: await
|
|
36134
|
-
|
|
36358
|
+
GROK_HOME: await realpath8(
|
|
36359
|
+
join13(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION, "home")
|
|
36135
36360
|
)
|
|
36136
36361
|
});
|
|
36137
36362
|
}
|
|
@@ -36142,9 +36367,9 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
36142
36367
|
};
|
|
36143
36368
|
resolveManagedAgent = async (stateDirectory, platform, signal) => {
|
|
36144
36369
|
signal.throwIfAborted();
|
|
36145
|
-
const versionRoot = await
|
|
36146
|
-
await validateManagedNpmPackage(
|
|
36147
|
-
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);
|
|
36148
36373
|
signal.throwIfAborted();
|
|
36149
36374
|
if (executable === null || !isContainedPath2(versionRoot, executable.path)) {
|
|
36150
36375
|
throw new AgentProbeError("managed_agent_invalid", "The managed Grok Build executable is invalid");
|
|
@@ -36244,13 +36469,13 @@ var OhMyPiAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
36244
36469
|
};
|
|
36245
36470
|
|
|
36246
36471
|
// src/agent-catalog/agents/opencode-agent.ts
|
|
36247
|
-
import { join as
|
|
36472
|
+
import { join as join15 } from "node:path";
|
|
36248
36473
|
|
|
36249
36474
|
// src/agent-installation/managed-agent-archive.ts
|
|
36250
36475
|
import { createHash as createHash3 } from "node:crypto";
|
|
36251
36476
|
import { createReadStream } from "node:fs";
|
|
36252
|
-
import { chmod, copyFile, mkdir as mkdir4, mkdtemp as mkdtemp2, open as open4, realpath as
|
|
36253
|
-
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";
|
|
36254
36479
|
|
|
36255
36480
|
// src/agent-installation/verified-download.ts
|
|
36256
36481
|
import { fetch } from "undici";
|
|
@@ -36430,16 +36655,16 @@ async function readManifest(path2) {
|
|
|
36430
36655
|
}
|
|
36431
36656
|
async function validateManagedAgentArchive(root, definition, signal) {
|
|
36432
36657
|
try {
|
|
36433
|
-
const rootPath = await
|
|
36658
|
+
const rootPath = await realpath9(root);
|
|
36434
36659
|
const rootMetadata = await stat7(rootPath);
|
|
36435
36660
|
if (!rootMetadata.isDirectory() || typeof process.getuid === "function" && rootMetadata.uid !== process.getuid()) {
|
|
36436
36661
|
throw new Error("Managed Agent root is not user-owned");
|
|
36437
36662
|
}
|
|
36438
|
-
const manifest = await readManifest(
|
|
36663
|
+
const manifest = await readManifest(join14(rootPath, "archive.json"));
|
|
36439
36664
|
if (manifest["archiveSha256"] !== definition.archiveSha256 || manifest["archiveUrl"] !== definition.archiveUrl.toString() || manifest["version"] !== definition.version || typeof manifest["executableSha256"] !== "string") {
|
|
36440
36665
|
throw new Error("Managed Agent archive identity is invalid");
|
|
36441
36666
|
}
|
|
36442
|
-
const executable = await resolveExecutablePath(
|
|
36667
|
+
const executable = await resolveExecutablePath(join14(rootPath, "bin", definition.executableName));
|
|
36443
36668
|
if (executable === null || !isContainedPath3(rootPath, executable.path) || await hashFile(executable.path, signal) !== manifest["executableSha256"]) {
|
|
36444
36669
|
throw new Error("Managed Agent executable is invalid");
|
|
36445
36670
|
}
|
|
@@ -36605,7 +36830,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
36605
36830
|
return Object.freeze(environment);
|
|
36606
36831
|
};
|
|
36607
36832
|
resolveManagedAgent = async (stateDirectory, platform, signal) => await validateManagedAgentArchive(
|
|
36608
|
-
|
|
36833
|
+
join15(stateDirectory, "agents", this.id, OPENCODE_MANAGED_VERSION),
|
|
36609
36834
|
openCodeManagedArchive(platform, process.arch),
|
|
36610
36835
|
signal
|
|
36611
36836
|
);
|
|
@@ -36623,7 +36848,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
36623
36848
|
};
|
|
36624
36849
|
|
|
36625
36850
|
// src/agent-catalog/agents/pi-agent.ts
|
|
36626
|
-
import { join as
|
|
36851
|
+
import { join as join16 } from "node:path";
|
|
36627
36852
|
import {
|
|
36628
36853
|
methods as methods7
|
|
36629
36854
|
} from "@agentclientprotocol/sdk";
|
|
@@ -36682,7 +36907,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
36682
36907
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
36683
36908
|
signal.throwIfAborted();
|
|
36684
36909
|
const executable = await validateManagedNpmPackage(
|
|
36685
|
-
|
|
36910
|
+
join16(stateDirectory, "agents", this.id, PI_AGENT_PACKAGE.version),
|
|
36686
36911
|
PI_AGENT_PACKAGE
|
|
36687
36912
|
);
|
|
36688
36913
|
signal.throwIfAborted();
|
|
@@ -36720,7 +36945,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
36720
36945
|
};
|
|
36721
36946
|
|
|
36722
36947
|
// src/agent-catalog/agents/workbuddy-agent.ts
|
|
36723
|
-
import { join as
|
|
36948
|
+
import { join as join17 } from "node:path";
|
|
36724
36949
|
|
|
36725
36950
|
// src/agent-installation/workbuddy-managed-package.ts
|
|
36726
36951
|
var WORKBUDDY_MANAGED_VERSION = "2.146.0";
|
|
@@ -36766,7 +36991,7 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
36766
36991
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
36767
36992
|
signal.throwIfAborted();
|
|
36768
36993
|
const executable = await validateManagedNpmPackage(
|
|
36769
|
-
|
|
36994
|
+
join17(stateDirectory, "agents", this.id, WORKBUDDY_MANAGED_VERSION),
|
|
36770
36995
|
WORKBUDDY_MANAGED_PACKAGE
|
|
36771
36996
|
);
|
|
36772
36997
|
signal.throwIfAborted();
|
|
@@ -36974,9 +37199,10 @@ async function probeAcpReadiness(specification, agent, environment, defaultWorks
|
|
|
36974
37199
|
signal.removeEventListener("abort", abort);
|
|
36975
37200
|
}
|
|
36976
37201
|
}
|
|
36977
|
-
const
|
|
37202
|
+
const launch = executableLaunch2(agent.adapterPath, agent.arguments);
|
|
37203
|
+
const child2 = spawn4(launch.command, [...launch.arguments], {
|
|
36978
37204
|
cwd: defaultWorkspace,
|
|
36979
|
-
|
|
37205
|
+
...platformSpawnOptions,
|
|
36980
37206
|
env: { ...environment, ...agent.environment },
|
|
36981
37207
|
shell: false,
|
|
36982
37208
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -37109,10 +37335,10 @@ function isAgentVersionSupported(reportedVersion, minimumSupportedVersion) {
|
|
|
37109
37335
|
}
|
|
37110
37336
|
|
|
37111
37337
|
// src/agent-catalog/executable-discovery.ts
|
|
37112
|
-
import { isAbsolute as isAbsolute9, join as
|
|
37338
|
+
import { isAbsolute as isAbsolute9, join as join19 } from "node:path";
|
|
37113
37339
|
|
|
37114
37340
|
// src/agent-installation/managed-adapter-installer.ts
|
|
37115
|
-
import { join as
|
|
37341
|
+
import { join as join18 } from "node:path";
|
|
37116
37342
|
var ManagedAdapterInstallError = class extends Error {
|
|
37117
37343
|
code;
|
|
37118
37344
|
constructor(code, message, options = {}) {
|
|
@@ -37169,7 +37395,7 @@ var ManagedAdapterInstaller = class {
|
|
|
37169
37395
|
this.#stateDirectory = options.stateDirectory;
|
|
37170
37396
|
}
|
|
37171
37397
|
install = async (specification, signal) => {
|
|
37172
|
-
const root =
|
|
37398
|
+
const root = join18(this.#stateDirectory, "adapters", specification.id, specification.adapterVersion);
|
|
37173
37399
|
try {
|
|
37174
37400
|
return await this.#npmInstaller.install(
|
|
37175
37401
|
root,
|
|
@@ -37203,7 +37429,7 @@ async function resolveManagedAdapterExecutable(specification, context) {
|
|
|
37203
37429
|
let managed;
|
|
37204
37430
|
try {
|
|
37205
37431
|
managed = await validateManagedAdapter(
|
|
37206
|
-
|
|
37432
|
+
join19(readStateDirectory(context.environment), "adapters", specification.id, specification.adapterVersion),
|
|
37207
37433
|
specification
|
|
37208
37434
|
);
|
|
37209
37435
|
} catch {
|
|
@@ -37684,8 +37910,21 @@ async function unchangedIdentity(agent, signal) {
|
|
|
37684
37910
|
|
|
37685
37911
|
// src/storage/runtime-installation-store.ts
|
|
37686
37912
|
import { createHash as createHash4, randomUUID as randomUUID3 } from "node:crypto";
|
|
37687
|
-
import { mkdir as mkdir5, open as open5, readdir as readdir3, rename as rename4, unlink, writeFile as writeFile4 } from "node:fs/promises";
|
|
37688
|
-
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
|
|
37689
37928
|
var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
|
|
37690
37929
|
var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
|
|
37691
37930
|
var INSTALLATION_ID_PATTERN = /^min_[a-f0-9]{32}$/;
|
|
@@ -37927,8 +38166,8 @@ async function readJsonFile(path2, signal, missingCode) {
|
|
|
37927
38166
|
}
|
|
37928
38167
|
async function writeJsonAtomically(path2, value, signal) {
|
|
37929
38168
|
signal.throwIfAborted();
|
|
37930
|
-
const directory =
|
|
37931
|
-
const temporaryPath =
|
|
38169
|
+
const directory = dirname5(path2);
|
|
38170
|
+
const temporaryPath = join20(directory, `.${randomUUID3()}.tmp`);
|
|
37932
38171
|
try {
|
|
37933
38172
|
await mkdir5(directory, { mode: 448, recursive: true });
|
|
37934
38173
|
signal.throwIfAborted();
|
|
@@ -37937,7 +38176,7 @@ async function writeJsonAtomically(path2, value, signal) {
|
|
|
37937
38176
|
signal.throwIfAborted();
|
|
37938
38177
|
await rename4(temporaryPath, path2);
|
|
37939
38178
|
} catch (cause) {
|
|
37940
|
-
await
|
|
38179
|
+
await unlink2(temporaryPath).catch(() => void 0);
|
|
37941
38180
|
signal.throwIfAborted();
|
|
37942
38181
|
throw new RuntimeInstallationStoreError("connection_unavailable", "The local Runtime state cannot be written", {
|
|
37943
38182
|
cause
|
|
@@ -37954,15 +38193,17 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
37954
38193
|
this.applicationId = applicationId;
|
|
37955
38194
|
this.installationId = installationId2;
|
|
37956
38195
|
this.stateDirectory = stateDirectory;
|
|
37957
|
-
this.#channelDirectory =
|
|
37958
|
-
this.#connectionDirectory =
|
|
38196
|
+
this.#channelDirectory = join20(stateDirectory, "channels");
|
|
38197
|
+
this.#connectionDirectory = join20(stateDirectory, "connections");
|
|
37959
38198
|
}
|
|
37960
38199
|
static open = async (options, signal) => {
|
|
37961
38200
|
signal.throwIfAborted();
|
|
37962
38201
|
const applicationId = validateApplicationId(options.applicationId);
|
|
37963
|
-
const rootDirectory =
|
|
37964
|
-
const applicationDirectory =
|
|
38202
|
+
const rootDirectory = resolve5(options.stateDirectory);
|
|
38203
|
+
const applicationDirectory = join20(rootDirectory, "installations", applicationId);
|
|
37965
38204
|
try {
|
|
38205
|
+
await mkdir5(rootDirectory, { mode: 448, recursive: true });
|
|
38206
|
+
await validateLocalPath(rootDirectory, true, true, signal);
|
|
37966
38207
|
await mkdir5(applicationDirectory, { mode: 448, recursive: true });
|
|
37967
38208
|
} catch (cause) {
|
|
37968
38209
|
throw new RuntimeInstallationStoreError(
|
|
@@ -37974,7 +38215,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
37974
38215
|
);
|
|
37975
38216
|
}
|
|
37976
38217
|
const storedInstallationId = await readOrCreateInstallationId(applicationDirectory, signal);
|
|
37977
|
-
const stateDirectory =
|
|
38218
|
+
const stateDirectory = join20(applicationDirectory, storedInstallationId);
|
|
37978
38219
|
try {
|
|
37979
38220
|
await mkdir5(stateDirectory, { mode: 448, recursive: true });
|
|
37980
38221
|
} catch (cause) {
|
|
@@ -37989,8 +38230,8 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
37989
38230
|
signal.throwIfAborted();
|
|
37990
38231
|
return new _RuntimeInstallationStore(applicationId, storedInstallationId, stateDirectory);
|
|
37991
38232
|
};
|
|
37992
|
-
connectionPath = (connectionId2) =>
|
|
37993
|
-
channelIndexPath = (channelId) =>
|
|
38233
|
+
connectionPath = (connectionId2) => join20(this.#connectionDirectory, `${validateConnectionId(connectionId2)}.json`);
|
|
38234
|
+
channelIndexPath = (channelId) => join20(this.#channelDirectory, channelIndexFileName(validateIdentifier(channelId, "invalid_channel_id")));
|
|
37994
38235
|
readConnection = async (connectionId2, signal) => {
|
|
37995
38236
|
const stored = decodeConnection(
|
|
37996
38237
|
await readJsonFile(this.connectionPath(connectionId2), signal, "connection_not_found")
|
|
@@ -38113,9 +38354,9 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
38113
38354
|
const connection = await this.readConnection(connectionId2, signal);
|
|
38114
38355
|
signal.throwIfAborted();
|
|
38115
38356
|
try {
|
|
38116
|
-
await
|
|
38357
|
+
await unlink2(this.connectionPath(connection.connectionId));
|
|
38117
38358
|
signal.throwIfAborted();
|
|
38118
|
-
await
|
|
38359
|
+
await unlink2(this.channelIndexPath(connection.channelId));
|
|
38119
38360
|
} catch (cause) {
|
|
38120
38361
|
signal.throwIfAborted();
|
|
38121
38362
|
if (isNodeError(cause, "ENOENT")) {
|
|
@@ -38152,7 +38393,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
38152
38393
|
};
|
|
38153
38394
|
};
|
|
38154
38395
|
async function readOrCreateInstallationId(applicationDirectory, signal) {
|
|
38155
|
-
const pointerPath =
|
|
38396
|
+
const pointerPath = join20(applicationDirectory, "current.json");
|
|
38156
38397
|
try {
|
|
38157
38398
|
return decodeInstallationPointer(await readJsonFile(pointerPath, signal, "installation_not_found")).installationId;
|
|
38158
38399
|
} catch (cause) {
|
|
@@ -38290,10 +38531,10 @@ function parseResumeConnectionId(arguments_) {
|
|
|
38290
38531
|
return value;
|
|
38291
38532
|
}
|
|
38292
38533
|
async function resolveDefaultWorkspace(path2) {
|
|
38293
|
-
const requestedWorkspace =
|
|
38534
|
+
const requestedWorkspace = resolve6(path2);
|
|
38294
38535
|
try {
|
|
38295
38536
|
await mkdir6(requestedWorkspace, { recursive: true, mode: 448 });
|
|
38296
|
-
const defaultWorkspace = await
|
|
38537
|
+
const defaultWorkspace = await realpath10(requestedWorkspace);
|
|
38297
38538
|
const metadata = await stat8(defaultWorkspace);
|
|
38298
38539
|
if (!metadata.isDirectory()) {
|
|
38299
38540
|
throw new PairingClientError("invalid_workspace", "The default workspace is not a directory");
|
|
@@ -38529,7 +38770,7 @@ function isRuntimeRelayRevocation(closeCode, closeReason) {
|
|
|
38529
38770
|
|
|
38530
38771
|
// src/run-daemon.ts
|
|
38531
38772
|
import { createHash as createHash8, randomUUID as randomUUID9 } from "node:crypto";
|
|
38532
|
-
import { join as
|
|
38773
|
+
import { join as join23 } from "node:path";
|
|
38533
38774
|
import { styleText } from "node:util";
|
|
38534
38775
|
|
|
38535
38776
|
// src/agent-installation/agent-installation-manager.ts
|
|
@@ -38796,7 +39037,7 @@ var AgentInstallationManager = class {
|
|
|
38796
39037
|
|
|
38797
39038
|
// src/agent-installation/fixed-installation-executor.ts
|
|
38798
39039
|
import { realpathSync as realpathSync2, statSync as statSync2 } from "node:fs";
|
|
38799
|
-
import { resolve as
|
|
39040
|
+
import { resolve as resolve7 } from "node:path";
|
|
38800
39041
|
function findSpecification(specifications, agentId) {
|
|
38801
39042
|
for (const specification of specifications) {
|
|
38802
39043
|
if (specification.id === agentId) {
|
|
@@ -38807,7 +39048,7 @@ function findSpecification(specifications, agentId) {
|
|
|
38807
39048
|
}
|
|
38808
39049
|
function resolveDefaultWorkspace2(path2) {
|
|
38809
39050
|
try {
|
|
38810
|
-
const directory = realpathSync2(
|
|
39051
|
+
const directory = realpathSync2(resolve7(path2));
|
|
38811
39052
|
if (!statSync2(directory).isDirectory()) {
|
|
38812
39053
|
throw new Error("Default workspace is not a directory");
|
|
38813
39054
|
}
|
|
@@ -38822,7 +39063,7 @@ function resolveDefaultWorkspace2(path2) {
|
|
|
38822
39063
|
}
|
|
38823
39064
|
function resolveIntegrationStateDirectory(path2) {
|
|
38824
39065
|
try {
|
|
38825
|
-
const directory = realpathSync2(
|
|
39066
|
+
const directory = realpathSync2(resolve7(path2));
|
|
38826
39067
|
const metadata = statSync2(directory);
|
|
38827
39068
|
if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
|
|
38828
39069
|
throw new Error("Installation directory is not user-owned");
|
|
@@ -38994,9 +39235,9 @@ var FixedInstallationExecutor = class {
|
|
|
38994
39235
|
};
|
|
38995
39236
|
|
|
38996
39237
|
// src/authorization/workspace-directory.ts
|
|
38997
|
-
import { readdir as readdir4, realpath as
|
|
39238
|
+
import { readdir as readdir4, realpath as realpath11, stat as stat9 } from "node:fs/promises";
|
|
38998
39239
|
import { homedir as homedir2 } from "node:os";
|
|
38999
|
-
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";
|
|
39000
39241
|
var WorkspaceDirectoryListing = class {
|
|
39001
39242
|
directoryId;
|
|
39002
39243
|
directoryLabel;
|
|
@@ -39064,7 +39305,7 @@ var WorkspaceDirectoryService = class {
|
|
|
39064
39305
|
throw new LocalAuthorizationError("The local directory path is invalid");
|
|
39065
39306
|
}
|
|
39066
39307
|
try {
|
|
39067
|
-
const target = await
|
|
39308
|
+
const target = await realpath11(requested);
|
|
39068
39309
|
signal.throwIfAborted();
|
|
39069
39310
|
const metadata = await stat9(target);
|
|
39070
39311
|
signal.throwIfAborted();
|
|
@@ -39114,7 +39355,7 @@ var WorkspaceDirectoryService = class {
|
|
|
39114
39355
|
continue;
|
|
39115
39356
|
}
|
|
39116
39357
|
try {
|
|
39117
|
-
const path2 = await this.resolvePath(
|
|
39358
|
+
const path2 = await this.resolvePath(join21(target, child2.name), signal);
|
|
39118
39359
|
entries.push({ directoryId: encodePath(path2), name: child2.name });
|
|
39119
39360
|
} catch (cause) {
|
|
39120
39361
|
signal.throwIfAborted();
|
|
@@ -39124,7 +39365,7 @@ var WorkspaceDirectoryService = class {
|
|
|
39124
39365
|
}
|
|
39125
39366
|
}
|
|
39126
39367
|
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
39127
|
-
const parent =
|
|
39368
|
+
const parent = dirname6(target);
|
|
39128
39369
|
return new WorkspaceDirectoryListing(
|
|
39129
39370
|
id,
|
|
39130
39371
|
this.label(target),
|
|
@@ -39150,15 +39391,15 @@ var WorkspaceDirectoryService = class {
|
|
|
39150
39391
|
|
|
39151
39392
|
// src/daemon-diagnostic-log.ts
|
|
39152
39393
|
import { appendFileSync, mkdirSync, readFileSync as readFileSync2, renameSync, statSync as statSync3, writeFileSync } from "node:fs";
|
|
39153
|
-
import { join as
|
|
39394
|
+
import { join as join22 } from "node:path";
|
|
39154
39395
|
var MAXIMUM_DAEMON_LOG_BYTES = 1 * 1024 * 1024;
|
|
39155
39396
|
var DaemonDiagnosticLog = class {
|
|
39156
39397
|
#directory;
|
|
39157
39398
|
#path;
|
|
39158
39399
|
#maximumBytes;
|
|
39159
39400
|
constructor(stateDirectory, maximumBytes = MAXIMUM_DAEMON_LOG_BYTES) {
|
|
39160
|
-
this.#directory =
|
|
39161
|
-
this.#path =
|
|
39401
|
+
this.#directory = join22(stateDirectory, "logs");
|
|
39402
|
+
this.#path = join22(this.#directory, "daemon.log");
|
|
39162
39403
|
this.#maximumBytes = maximumBytes;
|
|
39163
39404
|
}
|
|
39164
39405
|
// Export only correlation and failure metadata. Local messages and paths stay local.
|
|
@@ -39974,7 +40215,7 @@ var ActiveDaemonTurn = class {
|
|
|
39974
40215
|
var MAX_SESSIONS_WITH_COMPLETED_RECOVERY = 32;
|
|
39975
40216
|
var waitForTurnCompletion = (turn, waitSignal) => {
|
|
39976
40217
|
waitSignal.throwIfAborted();
|
|
39977
|
-
return new Promise((
|
|
40218
|
+
return new Promise((resolve10, reject) => {
|
|
39978
40219
|
let settled = false;
|
|
39979
40220
|
const finish = (result) => {
|
|
39980
40221
|
if (settled) {
|
|
@@ -39983,7 +40224,7 @@ var waitForTurnCompletion = (turn, waitSignal) => {
|
|
|
39983
40224
|
settled = true;
|
|
39984
40225
|
waitSignal.removeEventListener("abort", onAbort);
|
|
39985
40226
|
if (result.kind === "completed") {
|
|
39986
|
-
|
|
40227
|
+
resolve10();
|
|
39987
40228
|
} else {
|
|
39988
40229
|
reject(result.error);
|
|
39989
40230
|
}
|
|
@@ -40181,7 +40422,7 @@ var sessionEventCacheMigrations = [
|
|
|
40181
40422
|
|
|
40182
40423
|
// src/infra/local-sqlite-database.ts
|
|
40183
40424
|
import { chmodSync, mkdirSync as mkdirSync2 } from "node:fs";
|
|
40184
|
-
import { dirname as
|
|
40425
|
+
import { dirname as dirname7 } from "node:path";
|
|
40185
40426
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
40186
40427
|
|
|
40187
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
|
|
@@ -40292,7 +40533,7 @@ var LocalSqliteDatabase = class {
|
|
|
40292
40533
|
orm;
|
|
40293
40534
|
#sqlite;
|
|
40294
40535
|
constructor(path2, label, migrations, pragmas = []) {
|
|
40295
|
-
mkdirSync2(
|
|
40536
|
+
mkdirSync2(dirname7(path2), { mode: 448, recursive: true });
|
|
40296
40537
|
this.#sqlite = new DatabaseSync2(path2);
|
|
40297
40538
|
chmodSync(path2, 384);
|
|
40298
40539
|
try {
|
|
@@ -40851,10 +41092,11 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
40851
41092
|
);
|
|
40852
41093
|
}
|
|
40853
41094
|
signal.throwIfAborted();
|
|
40854
|
-
const
|
|
41095
|
+
const launch = executableLaunch2(agent.agentIdentity.realPath, ["app-server"]);
|
|
41096
|
+
const child2 = spawn5(launch.command, [...launch.arguments], {
|
|
40855
41097
|
cwd,
|
|
40856
41098
|
env: { ...process.env, ...agent.environment },
|
|
40857
|
-
|
|
41099
|
+
...platformSpawnOptions,
|
|
40858
41100
|
shell: false,
|
|
40859
41101
|
stdio: ["pipe", "pipe", "ignore"]
|
|
40860
41102
|
});
|
|
@@ -41658,7 +41900,7 @@ import { WebSocket as WebSocket5 } from "undici";
|
|
|
41658
41900
|
// package.json
|
|
41659
41901
|
var package_default = {
|
|
41660
41902
|
name: "@moxt-ai/mobius",
|
|
41661
|
-
version: "0.0.
|
|
41903
|
+
version: "0.0.196",
|
|
41662
41904
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
41663
41905
|
type: "module",
|
|
41664
41906
|
bin: {
|
|
@@ -41667,7 +41909,9 @@ var package_default = {
|
|
|
41667
41909
|
types: "./src/index.ts",
|
|
41668
41910
|
exports: {
|
|
41669
41911
|
".": "./src/index.ts",
|
|
41670
|
-
"./runtime": "./src/runtime.ts"
|
|
41912
|
+
"./runtime": "./src/runtime.ts",
|
|
41913
|
+
"./process": "./src/process/executable.ts",
|
|
41914
|
+
"./filesystem": "./src/filesystem/private-path.ts"
|
|
41671
41915
|
},
|
|
41672
41916
|
files: [
|
|
41673
41917
|
"dist"
|
|
@@ -41686,6 +41930,14 @@ var package_default = {
|
|
|
41686
41930
|
"./runtime": {
|
|
41687
41931
|
types: "./dist/runtime.d.ts",
|
|
41688
41932
|
import: "./dist/runtime.js"
|
|
41933
|
+
},
|
|
41934
|
+
"./process": {
|
|
41935
|
+
types: "./dist/process/executable.d.ts",
|
|
41936
|
+
import: "./dist/process/executable.js"
|
|
41937
|
+
},
|
|
41938
|
+
"./filesystem": {
|
|
41939
|
+
types: "./dist/filesystem/private-path.d.ts",
|
|
41940
|
+
import: "./dist/filesystem/private-path.js"
|
|
41689
41941
|
}
|
|
41690
41942
|
}
|
|
41691
41943
|
},
|
|
@@ -41695,7 +41947,7 @@ var package_default = {
|
|
|
41695
41947
|
directory: "packages/cli"
|
|
41696
41948
|
},
|
|
41697
41949
|
scripts: {
|
|
41698
|
-
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",
|
|
41950
|
+
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",
|
|
41699
41951
|
dev: "node --watch src/cli.ts",
|
|
41700
41952
|
prepack: "pnpm build",
|
|
41701
41953
|
start: "node dist/cli.js",
|
|
@@ -42356,8 +42608,8 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
42356
42608
|
|
|
42357
42609
|
// src/artifacts/local-file-streamer.ts
|
|
42358
42610
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
42359
|
-
import { realpath as
|
|
42360
|
-
import { basename as basename5, extname, isAbsolute as isAbsolute11, normalize as normalize4, resolve as
|
|
42611
|
+
import { realpath as realpath12, stat as stat10 } from "node:fs/promises";
|
|
42612
|
+
import { basename as basename5, extname as extname2, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve8 } from "node:path";
|
|
42361
42613
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
42362
42614
|
var CHUNK_BYTES = 192 * 1024;
|
|
42363
42615
|
function requestedPath(value) {
|
|
@@ -42379,12 +42631,12 @@ async function resolveFile(value, workingDirectory, signal) {
|
|
|
42379
42631
|
if (path2 === null || !isAbsolute11(path2) && workingDirectory === null) {
|
|
42380
42632
|
return null;
|
|
42381
42633
|
}
|
|
42382
|
-
const requested = workingDirectory === null ? path2 :
|
|
42634
|
+
const requested = workingDirectory === null ? path2 : resolve8(workingDirectory, path2);
|
|
42383
42635
|
if (!isAbsolute11(requested) || isAbsolute11(path2) && normalize4(path2) !== path2) {
|
|
42384
42636
|
return null;
|
|
42385
42637
|
}
|
|
42386
42638
|
try {
|
|
42387
|
-
const target = await
|
|
42639
|
+
const target = await realpath12(requested);
|
|
42388
42640
|
signal.throwIfAborted();
|
|
42389
42641
|
return isAbsolute11(target) && normalize4(target) === target ? target : null;
|
|
42390
42642
|
} catch {
|
|
@@ -42407,7 +42659,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
|
|
|
42407
42659
|
send2({
|
|
42408
42660
|
byteLength: before.size,
|
|
42409
42661
|
kind: FILE_BEGIN_KIND,
|
|
42410
|
-
mediaType: external?.mediaType ?? raster?.mimeType ?? (
|
|
42662
|
+
mediaType: external?.mediaType ?? raster?.mimeType ?? (extname2(target).toLowerCase() === ".svg" ? "image/svg+xml" : "application/octet-stream"),
|
|
42411
42663
|
modifiedAt: before.mtime.toISOString(),
|
|
42412
42664
|
name: external?.name ?? (basename5(target) || "file"),
|
|
42413
42665
|
requestId: command.requestId,
|
|
@@ -42697,6 +42949,78 @@ async function executeSessionConfigure(socket, command, config2, directories, au
|
|
|
42697
42949
|
}
|
|
42698
42950
|
|
|
42699
42951
|
// src/daemon-history-commands.ts
|
|
42952
|
+
function isAgentReasoning(event) {
|
|
42953
|
+
return event?.type === "acp" && event.payload.sessionUpdate === "agent_thought_chunk";
|
|
42954
|
+
}
|
|
42955
|
+
function omitAgentReasoning(events) {
|
|
42956
|
+
const retained = [];
|
|
42957
|
+
let previousReasoningMessageId;
|
|
42958
|
+
for (const event of events) {
|
|
42959
|
+
if (event.type !== "acp" || event.payload.sessionUpdate !== "agent_thought_chunk") {
|
|
42960
|
+
previousReasoningMessageId = void 0;
|
|
42961
|
+
retained.push(event);
|
|
42962
|
+
continue;
|
|
42963
|
+
}
|
|
42964
|
+
const messageId = event.payload.messageId ?? null;
|
|
42965
|
+
if (previousReasoningMessageId === void 0 || previousReasoningMessageId !== messageId) {
|
|
42966
|
+
retained.push({
|
|
42967
|
+
...event,
|
|
42968
|
+
mobiusMetadata: { omitted: true },
|
|
42969
|
+
payload: { ...event.payload, content: { text: "", type: "text" } }
|
|
42970
|
+
});
|
|
42971
|
+
}
|
|
42972
|
+
previousReasoningMessageId = messageId;
|
|
42973
|
+
}
|
|
42974
|
+
return retained;
|
|
42975
|
+
}
|
|
42976
|
+
async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoning, queuedPromptRequests, load, eventLogV2) {
|
|
42977
|
+
let cursor = initialCursor;
|
|
42978
|
+
let loaded = [];
|
|
42979
|
+
let sessionGenerationId = null;
|
|
42980
|
+
let sourceNextCursor = null;
|
|
42981
|
+
do {
|
|
42982
|
+
const replay = await load(eventLimit, cursor);
|
|
42983
|
+
if (sessionGenerationId !== null && replay.sessionGenerationId !== sessionGenerationId) {
|
|
42984
|
+
throw new AcpExecutionError("The Session reloaded while history was loading", {}, "session_reloaded");
|
|
42985
|
+
}
|
|
42986
|
+
sessionGenerationId = replay.sessionGenerationId;
|
|
42987
|
+
const events2 = replay.events.map(
|
|
42988
|
+
(event, index2) => eventLogV2.event(
|
|
42989
|
+
sessionId,
|
|
42990
|
+
replay.sessionGenerationId,
|
|
42991
|
+
replay.startPosition + index2,
|
|
42992
|
+
event,
|
|
42993
|
+
"1970-01-01T00:00:00.000Z"
|
|
42994
|
+
)
|
|
42995
|
+
);
|
|
42996
|
+
loaded = [...events2, ...loaded];
|
|
42997
|
+
sourceNextCursor = replay.nextCursor;
|
|
42998
|
+
const visible2 = omitReasoning ? omitAgentReasoning(loaded) : loaded;
|
|
42999
|
+
const reasoningContinuesBeforePage = sourceNextCursor !== null && isAgentReasoning(loaded[0]);
|
|
43000
|
+
if (visible2.length >= eventLimit && !reasoningContinuesBeforePage) {
|
|
43001
|
+
break;
|
|
43002
|
+
}
|
|
43003
|
+
cursor = sourceNextCursor;
|
|
43004
|
+
} while (cursor !== null);
|
|
43005
|
+
if (sessionGenerationId === null) {
|
|
43006
|
+
throw new AcpExecutionError("The Session history is unavailable", {}, "session_history_unavailable");
|
|
43007
|
+
}
|
|
43008
|
+
const visible = omitReasoning ? omitAgentReasoning(loaded) : loaded;
|
|
43009
|
+
const events = visible.slice(-eventLimit);
|
|
43010
|
+
const firstPosition = events[0] === void 0 ? 0 : Number(events[0].position);
|
|
43011
|
+
const nextCursor = firstPosition <= 1 ? null : (firstPosition - 1).toString();
|
|
43012
|
+
return {
|
|
43013
|
+
events: {
|
|
43014
|
+
events,
|
|
43015
|
+
nextCursor,
|
|
43016
|
+
sessionGenerationId,
|
|
43017
|
+
tailCursor: events.at(-1)?.eventId ?? "",
|
|
43018
|
+
truncated: nextCursor !== null,
|
|
43019
|
+
version: 2
|
|
43020
|
+
},
|
|
43021
|
+
queuedPromptRequests
|
|
43022
|
+
};
|
|
43023
|
+
}
|
|
42700
43024
|
async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, nativeSessions, eventLogV2, signal) {
|
|
42701
43025
|
let agentId;
|
|
42702
43026
|
try {
|
|
@@ -42720,35 +43044,23 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
42720
43044
|
signal
|
|
42721
43045
|
};
|
|
42722
43046
|
const recovery = eventLogV2.promptRequestRecovery(command.sessionId);
|
|
42723
|
-
const
|
|
42724
|
-
|
|
42725
|
-
|
|
42726
|
-
|
|
42727
|
-
|
|
42728
|
-
|
|
42729
|
-
|
|
42730
|
-
|
|
42731
|
-
"1970-01-01T00:00:00.000Z"
|
|
42732
|
-
)
|
|
43047
|
+
const events = await loadHistoryPage(
|
|
43048
|
+
command.sessionId,
|
|
43049
|
+
command.eventLimit,
|
|
43050
|
+
command.cursor,
|
|
43051
|
+
command.omit?.includes("agent-reasoning") === true,
|
|
43052
|
+
recovery.queuedPromptRequests,
|
|
43053
|
+
async (eventLimit, cursor) => await sessions.loadSessionEventsV2(loadOptions, eventLimit, cursor),
|
|
43054
|
+
eventLogV2
|
|
42733
43055
|
);
|
|
42734
|
-
|
|
43056
|
+
signal.throwIfAborted();
|
|
42735
43057
|
audit.record({
|
|
42736
43058
|
commandId: command.requestId,
|
|
42737
43059
|
event: "session_event_log_v2_loaded",
|
|
42738
43060
|
sessionId: command.sessionId
|
|
42739
43061
|
});
|
|
42740
43062
|
send(socket, {
|
|
42741
|
-
events
|
|
42742
|
-
events: {
|
|
42743
|
-
events,
|
|
42744
|
-
nextCursor: replay.nextCursor,
|
|
42745
|
-
sessionGenerationId: replay.sessionGenerationId,
|
|
42746
|
-
tailCursor,
|
|
42747
|
-
truncated: replay.truncated,
|
|
42748
|
-
version: 2
|
|
42749
|
-
},
|
|
42750
|
-
queuedPromptRequests: recovery.queuedPromptRequests
|
|
42751
|
-
},
|
|
43063
|
+
events,
|
|
42752
43064
|
kind: SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND,
|
|
42753
43065
|
requestId: command.requestId,
|
|
42754
43066
|
sessionId: command.sessionId
|
|
@@ -42787,46 +43099,30 @@ async function executeSessionPreviewHistoryPageLoad(socket, command, config2, di
|
|
|
42787
43099
|
command.additionalDirectoryIds,
|
|
42788
43100
|
signal
|
|
42789
43101
|
);
|
|
42790
|
-
const
|
|
42791
|
-
|
|
42792
|
-
|
|
42793
|
-
|
|
42794
|
-
|
|
42795
|
-
|
|
42796
|
-
|
|
42797
|
-
|
|
43102
|
+
const loadOptions = {
|
|
43103
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
43104
|
+
agent: await resolveCatalogAgent(config2, command.agentId, signal),
|
|
43105
|
+
cwd: resolved.cwd,
|
|
43106
|
+
sessionId: command.sessionId,
|
|
43107
|
+
signal
|
|
43108
|
+
};
|
|
43109
|
+
const events = await loadHistoryPage(
|
|
42798
43110
|
command.sessionId,
|
|
42799
43111
|
command.eventLimit,
|
|
42800
|
-
command.cursor
|
|
43112
|
+
command.cursor,
|
|
43113
|
+
command.omit?.includes("agent-reasoning") === true,
|
|
43114
|
+
[],
|
|
43115
|
+
async (eventLimit, cursor) => await sessions.previewNativeSessionEventsV2(loadOptions, command.sessionId, eventLimit, cursor),
|
|
43116
|
+
eventLogV2
|
|
42801
43117
|
);
|
|
42802
43118
|
signal.throwIfAborted();
|
|
42803
|
-
const events = replay.events.map(
|
|
42804
|
-
(event, index2) => eventLogV2.event(
|
|
42805
|
-
command.sessionId,
|
|
42806
|
-
replay.sessionGenerationId,
|
|
42807
|
-
replay.startPosition + index2,
|
|
42808
|
-
event,
|
|
42809
|
-
"1970-01-01T00:00:00.000Z"
|
|
42810
|
-
)
|
|
42811
|
-
);
|
|
42812
|
-
const tailCursor = events.at(-1)?.eventId ?? "";
|
|
42813
43119
|
audit.record({
|
|
42814
43120
|
commandId: command.requestId,
|
|
42815
43121
|
event: "session_event_log_v2_loaded",
|
|
42816
43122
|
sessionId: command.sessionId
|
|
42817
43123
|
});
|
|
42818
43124
|
send(socket, {
|
|
42819
|
-
events
|
|
42820
|
-
events: {
|
|
42821
|
-
events,
|
|
42822
|
-
nextCursor: replay.nextCursor,
|
|
42823
|
-
sessionGenerationId: replay.sessionGenerationId,
|
|
42824
|
-
tailCursor,
|
|
42825
|
-
truncated: replay.truncated,
|
|
42826
|
-
version: 2
|
|
42827
|
-
},
|
|
42828
|
-
queuedPromptRequests: []
|
|
42829
|
-
},
|
|
43125
|
+
events,
|
|
42830
43126
|
kind: SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND,
|
|
42831
43127
|
requestId: command.requestId,
|
|
42832
43128
|
sessionId: command.sessionId
|
|
@@ -43265,13 +43561,13 @@ function createNativeSessionRequestHandler(dependencies) {
|
|
|
43265
43561
|
operationSignal.throwIfAborted();
|
|
43266
43562
|
const skipPrevious = command.action === "active-turn";
|
|
43267
43563
|
if (previous.length > 0 && !skipPrevious) {
|
|
43268
|
-
await new Promise((
|
|
43564
|
+
await new Promise((resolve10, reject) => {
|
|
43269
43565
|
const onAbort = () => reject(operationSignal.reason);
|
|
43270
43566
|
operationSignal.addEventListener("abort", onAbort, { once: true });
|
|
43271
43567
|
void Promise.all(previous.map((request) => request.completion)).then(
|
|
43272
43568
|
() => {
|
|
43273
43569
|
operationSignal.removeEventListener("abort", onAbort);
|
|
43274
|
-
|
|
43570
|
+
resolve10();
|
|
43275
43571
|
},
|
|
43276
43572
|
(error62) => {
|
|
43277
43573
|
operationSignal.removeEventListener("abort", onAbort);
|
|
@@ -43685,7 +43981,7 @@ var RelayConnectionError = class extends Error {
|
|
|
43685
43981
|
};
|
|
43686
43982
|
function connectRelay(url2, signal) {
|
|
43687
43983
|
signal.throwIfAborted();
|
|
43688
|
-
return new Promise((
|
|
43984
|
+
return new Promise((resolve10, reject) => {
|
|
43689
43985
|
const endpoint = new URL(url2);
|
|
43690
43986
|
const headers = runtimeAuthorization(endpoint);
|
|
43691
43987
|
endpoint.searchParams.delete("token");
|
|
@@ -43752,7 +44048,7 @@ function connectRelay(url2, signal) {
|
|
|
43752
44048
|
}
|
|
43753
44049
|
finished = true;
|
|
43754
44050
|
cleanup();
|
|
43755
|
-
|
|
44051
|
+
resolve10(socket);
|
|
43756
44052
|
};
|
|
43757
44053
|
function onTimeout() {
|
|
43758
44054
|
fail(
|
|
@@ -43934,7 +44230,7 @@ async function runRelayConnection({
|
|
|
43934
44230
|
installationObserver.connect(socket);
|
|
43935
44231
|
onConnected();
|
|
43936
44232
|
try {
|
|
43937
|
-
await new Promise((
|
|
44233
|
+
await new Promise((resolve10, reject) => {
|
|
43938
44234
|
let finished = false;
|
|
43939
44235
|
const cleanup = () => {
|
|
43940
44236
|
connectionLiveness.close();
|
|
@@ -43952,7 +44248,7 @@ async function runRelayConnection({
|
|
|
43952
44248
|
}
|
|
43953
44249
|
finished = true;
|
|
43954
44250
|
cleanup();
|
|
43955
|
-
|
|
44251
|
+
resolve10();
|
|
43956
44252
|
};
|
|
43957
44253
|
const rejectConnection = (failure2) => {
|
|
43958
44254
|
if (finished) {
|
|
@@ -44338,12 +44634,12 @@ function waitForRelayRetry(signal, timer) {
|
|
|
44338
44634
|
if (signal.aborted) {
|
|
44339
44635
|
return Promise.resolve();
|
|
44340
44636
|
}
|
|
44341
|
-
return new Promise((
|
|
44637
|
+
return new Promise((resolve10) => {
|
|
44342
44638
|
const retry = timer.schedule(finish, RELAY_RECONNECT_DELAY_MILLISECONDS);
|
|
44343
44639
|
function finish() {
|
|
44344
44640
|
retry.cancel();
|
|
44345
44641
|
signal.removeEventListener("abort", finish);
|
|
44346
|
-
|
|
44642
|
+
resolve10();
|
|
44347
44643
|
}
|
|
44348
44644
|
signal.addEventListener("abort", finish, { once: true });
|
|
44349
44645
|
});
|
|
@@ -44399,11 +44695,11 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44399
44695
|
stateDirectory
|
|
44400
44696
|
});
|
|
44401
44697
|
const channelHash = createHash8("sha256").update(config2.channelId).digest("hex");
|
|
44402
|
-
const sessionDatabase = openAcpSessionDatabase(
|
|
44698
|
+
const sessionDatabase = openAcpSessionDatabase(join23(stateDirectory, "sessions", `${channelHash}.sqlite`));
|
|
44403
44699
|
let eventsV2;
|
|
44404
44700
|
try {
|
|
44405
44701
|
eventsV2 = new CachedAcpSessionEventStoreV2(
|
|
44406
|
-
openSessionEventCacheV2Database(
|
|
44702
|
+
openSessionEventCacheV2Database(join23(stateDirectory, "sessions", `${channelHash}.events.sqlite`))
|
|
44407
44703
|
);
|
|
44408
44704
|
} catch (error62) {
|
|
44409
44705
|
sessionDatabase.close();
|
|
@@ -44606,8 +44902,8 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44606
44902
|
}
|
|
44607
44903
|
|
|
44608
44904
|
// src/runtime.ts
|
|
44609
|
-
import { mkdir as mkdir7, realpath as
|
|
44610
|
-
import { resolve as
|
|
44905
|
+
import { mkdir as mkdir7, realpath as realpath13, stat as stat11 } from "node:fs/promises";
|
|
44906
|
+
import { resolve as resolve9 } from "node:path";
|
|
44611
44907
|
var RUNTIME_CREDENTIAL_PATTERN2 = /^[a-zA-Z0-9_-]{32,256}$/;
|
|
44612
44908
|
var MobiusRuntimeConfigurationError = class extends Error {
|
|
44613
44909
|
code = "runtime_configuration_invalid";
|
|
@@ -44670,10 +44966,10 @@ function loadMobiusRuntimeConnection(environment = process.env) {
|
|
|
44670
44966
|
});
|
|
44671
44967
|
}
|
|
44672
44968
|
async function resolveWorkspace(path2) {
|
|
44673
|
-
const requested =
|
|
44969
|
+
const requested = resolve9(path2);
|
|
44674
44970
|
try {
|
|
44675
44971
|
await mkdir7(requested, { recursive: true, mode: 448 });
|
|
44676
|
-
const resolved = await
|
|
44972
|
+
const resolved = await realpath13(requested);
|
|
44677
44973
|
const metadata = await stat11(resolved);
|
|
44678
44974
|
if (!metadata.isDirectory()) {
|
|
44679
44975
|
throw new MobiusRuntimeConfigurationError("The Runtime workspace is not a directory");
|