@moxt-ai/mobius 0.0.440 → 0.0.442
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/{chunk-SABVCCTQ.js → chunk-F4KIJGAM.js} +2 -2
- package/dist/{chunk-SABVCCTQ.js.map → chunk-F4KIJGAM.js.map} +1 -1
- package/dist/{chunk-CDY4OZQN.js → chunk-VJM4WQG4.js} +306 -168
- package/dist/{chunk-CDY4OZQN.js.map → chunk-VJM4WQG4.js.map} +3 -3
- package/dist/{cli-R4RCIINT.js → cli-JEETGGG2.js} +3 -3
- package/dist/cli.js +2 -2
- package/dist/engine/runtime/command/registry/file-read/index.d.ts +1 -0
- package/dist/engine/runtime/command/registry/file-read/index.d.ts.map +1 -1
- package/dist/engine/runtime/command/registry/file-read/index.js +8 -4
- package/dist/engine/runtime/command/registry/file-read/index.js.map +1 -1
- package/dist/engine/runtime/command/registry/index.d.ts.map +1 -1
- package/dist/engine/runtime/command/registry/index.js +2 -1
- package/dist/engine/runtime/command/registry/index.js.map +1 -1
- package/dist/engine/runtime/command/registry/runtime.d.ts.map +1 -1
- package/dist/engine/runtime/command/registry/runtime.js +6 -1
- package/dist/engine/runtime/command/registry/runtime.js.map +1 -1
- package/dist/engine/session/content/session-files.d.ts +2 -2
- package/dist/engine/session/content/session-files.d.ts.map +1 -1
- package/dist/engine/session/content/session-files.js +38 -3
- package/dist/engine/session/content/session-files.js.map +1 -1
- package/dist/engine/storage/files/local-files.d.ts +15 -0
- package/dist/engine/storage/files/local-files.d.ts.map +1 -1
- package/dist/engine/storage/files/local-files.js +89 -3
- package/dist/engine/storage/files/local-files.js.map +1 -1
- package/dist/engine.js +2 -2
- package/package.json +2 -2
- /package/dist/{cli-R4RCIINT.js.map → cli-JEETGGG2.js.map} +0 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
__export,
|
|
4
4
|
__using,
|
|
5
5
|
package_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-F4KIJGAM.js";
|
|
7
7
|
|
|
8
8
|
// src/engine/runtime/relay/runtime-revocation.ts
|
|
9
9
|
var runtimeRevocationCloseCode = 1008;
|
|
@@ -24,7 +24,7 @@ function isRuntimeRelayRevocation(closeCode, closeReason) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
// src/engine/runtime/engine.ts
|
|
27
|
-
import { resolve as
|
|
27
|
+
import { resolve as resolve19 } from "node:path";
|
|
28
28
|
|
|
29
29
|
// src/engine/session/manager/operation-drain.ts
|
|
30
30
|
var RuntimeOperations = class {
|
|
@@ -83,7 +83,7 @@ var ConnectionManager = class {
|
|
|
83
83
|
|
|
84
84
|
// src/engine/runtime/connection/runtime-installation-store.ts
|
|
85
85
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
86
|
-
import { resolve } from "node:path";
|
|
86
|
+
import { resolve as resolve2 } from "node:path";
|
|
87
87
|
|
|
88
88
|
// ../mobius-sdk/src/protocol/platform/mobius-api.ts
|
|
89
89
|
var MOBIUS_API_PREFIX = "/mobius/api";
|
|
@@ -5175,7 +5175,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
5175
5175
|
var NONE = 0;
|
|
5176
5176
|
var ASSUMED = 1;
|
|
5177
5177
|
var PROVEN = 2;
|
|
5178
|
-
function isRecursive(inst, stack,
|
|
5178
|
+
function isRecursive(inst, stack, resolve20) {
|
|
5179
5179
|
const cached2 = recursive.get(inst);
|
|
5180
5180
|
if (cached2 !== void 0)
|
|
5181
5181
|
return cached2 ? PROVEN : NONE;
|
|
@@ -5185,7 +5185,7 @@ function isRecursive(inst, stack, resolve19) {
|
|
|
5185
5185
|
let result = NONE;
|
|
5186
5186
|
const check2 = (child) => {
|
|
5187
5187
|
if (result !== PROVEN && child?._zod) {
|
|
5188
|
-
const answer = isRecursive(child, stack,
|
|
5188
|
+
const answer = isRecursive(child, stack, resolve20);
|
|
5189
5189
|
if (answer > result)
|
|
5190
5190
|
result = answer;
|
|
5191
5191
|
}
|
|
@@ -5196,7 +5196,7 @@ function isRecursive(inst, stack, resolve19) {
|
|
|
5196
5196
|
const desc2 = Object.getOwnPropertyDescriptor(sh, key);
|
|
5197
5197
|
if (spread && !desc2.enumerable)
|
|
5198
5198
|
continue;
|
|
5199
|
-
const child = desc2.get ? ASSUMED : desc2.value?._zod ? isRecursive(desc2.value, stack,
|
|
5199
|
+
const child = desc2.get ? ASSUMED : desc2.value?._zod ? isRecursive(desc2.value, stack, resolve20) : NONE;
|
|
5200
5200
|
if (child > answer)
|
|
5201
5201
|
answer = child;
|
|
5202
5202
|
}
|
|
@@ -5260,7 +5260,7 @@ function isRecursive(inst, stack, resolve19) {
|
|
|
5260
5260
|
break;
|
|
5261
5261
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
5262
5262
|
case "lazy": {
|
|
5263
|
-
const inner = def._cachedInner ?? (
|
|
5263
|
+
const inner = def._cachedInner ?? (resolve20 ? inst._zod.innerType : void 0);
|
|
5264
5264
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
5265
5265
|
break;
|
|
5266
5266
|
}
|
|
@@ -19994,7 +19994,12 @@ function decodeRuntimePingCommand(encoded) {
|
|
|
19994
19994
|
function decodeRuntimePongEvent(encoded) {
|
|
19995
19995
|
const value = parseJson(encoded);
|
|
19996
19996
|
assertKind(value, RUNTIME_PONG_KIND);
|
|
19997
|
-
|
|
19997
|
+
const scopedFileRead = Reflect.get(value, "scopedFileRead");
|
|
19998
|
+
return {
|
|
19999
|
+
kind: RUNTIME_PONG_KIND,
|
|
20000
|
+
requestId: readIdentifier(value, "requestId"),
|
|
20001
|
+
...typeof scopedFileRead === "boolean" ? { scopedFileRead } : {}
|
|
20002
|
+
};
|
|
19998
20003
|
}
|
|
19999
20004
|
function encodeRuntimeLivenessReadyEvent(message) {
|
|
20000
20005
|
return JSON.stringify(decodeRuntimeLivenessReadyEvent(JSON.stringify(message)));
|
|
@@ -20990,6 +20995,7 @@ var decodeKnownNativeSessionEvents = (value) => decode3(sanitizeConsumableNative
|
|
|
20990
20995
|
|
|
20991
20996
|
// ../mobius-sdk/src/protocol/session/files/index.ts
|
|
20992
20997
|
var FILE_READ_KIND = "file.read";
|
|
20998
|
+
var SCOPED_FILE_READ_KIND = "file.read.scoped";
|
|
20993
20999
|
var FILE_BEGIN_KIND = "file.begin";
|
|
20994
21000
|
var FILE_END_KIND = "file.end";
|
|
20995
21001
|
var FILE_FAILED_KIND = "file.failed";
|
|
@@ -21002,15 +21008,16 @@ var CONTENT_WRITE_MAX_BYTES = 32 * 1024 * 1024;
|
|
|
21002
21008
|
var PROMPT_IMAGE_MAX_BYTES = 5e6;
|
|
21003
21009
|
var CONTENT_CHUNK_MAGIC = new Uint8Array([77, 66, 67, 49]);
|
|
21004
21010
|
var CONTENT_CHUNK_HEADER_BYTES = CONTENT_CHUNK_MAGIC.byteLength + 1 + 4;
|
|
21005
|
-
var
|
|
21006
|
-
kind: external_exports.literal(FILE_READ_KIND),
|
|
21011
|
+
var fileReadFields = external_exports.object({
|
|
21007
21012
|
maxBytes: external_exports.number().int().positive().max(128 * 1024 * 1024),
|
|
21008
21013
|
requestId: identifierStringSchema,
|
|
21009
21014
|
sessionId: identifierStringSchema,
|
|
21010
21015
|
path: external_exports.string().min(1).max(4096)
|
|
21011
|
-
})
|
|
21016
|
+
});
|
|
21017
|
+
var fileReadCommandSchema = fileReadFields.extend({ kind: external_exports.literal(FILE_READ_KIND) }).readonly();
|
|
21018
|
+
var scopedFileReadCommandSchema = fileReadFields.extend({ kind: external_exports.literal(SCOPED_FILE_READ_KIND) }).readonly();
|
|
21012
21019
|
var fileBeginEventSchema = external_exports.object({
|
|
21013
|
-
byteLength: external_exports.number().int().
|
|
21020
|
+
byteLength: external_exports.number().int().nonnegative().max(128 * 1024 * 1024),
|
|
21014
21021
|
kind: external_exports.literal(FILE_BEGIN_KIND),
|
|
21015
21022
|
mediaType: external_exports.string().min(1).max(255),
|
|
21016
21023
|
modifiedAt: external_exports.iso.datetime({ offset: true }),
|
|
@@ -21112,6 +21119,8 @@ var fileFailedEventSchema = external_exports.object({
|
|
|
21112
21119
|
}).readonly();
|
|
21113
21120
|
var decodeFileReadCommand = (encoded) => decodeZodMessage(encoded, fileReadCommandSchema);
|
|
21114
21121
|
var encodeFileReadCommand = (message) => encodeZodMessage(message, fileReadCommandSchema);
|
|
21122
|
+
var decodeScopedFileReadCommand = (encoded) => decodeZodMessage(encoded, scopedFileReadCommandSchema);
|
|
21123
|
+
var encodeScopedFileReadCommand = (message) => encodeZodMessage(message, scopedFileReadCommandSchema);
|
|
21115
21124
|
var decodeFileBeginEvent = (encoded) => decodeZodMessage(encoded, fileBeginEventSchema);
|
|
21116
21125
|
var encodeFileBeginEvent = (message) => encodeZodMessage(message, fileBeginEventSchema);
|
|
21117
21126
|
var decodeFileEndEvent = (encoded) => decodeZodMessage(encoded, fileEndEventSchema);
|
|
@@ -21809,6 +21818,11 @@ var serviceToDaemonSignatures = {
|
|
|
21809
21818
|
decodeAgentCatalogDiscoverCommand
|
|
21810
21819
|
),
|
|
21811
21820
|
[FILE_READ_KIND]: defineMessageSignature(FILE_READ_KIND, encodeFileReadCommand, decodeFileReadCommand),
|
|
21821
|
+
[SCOPED_FILE_READ_KIND]: defineMessageSignature(
|
|
21822
|
+
SCOPED_FILE_READ_KIND,
|
|
21823
|
+
encodeScopedFileReadCommand,
|
|
21824
|
+
decodeScopedFileReadCommand
|
|
21825
|
+
),
|
|
21812
21826
|
[CONTENT_WRITE_KIND]: defineMessageSignature(
|
|
21813
21827
|
CONTENT_WRITE_KIND,
|
|
21814
21828
|
encodeContentWriteCommand,
|
|
@@ -22073,10 +22087,12 @@ function encodeDaemonToServiceMessage(message) {
|
|
|
22073
22087
|
}
|
|
22074
22088
|
|
|
22075
22089
|
// src/engine/storage/files/local-files.ts
|
|
22076
|
-
import {
|
|
22077
|
-
import {
|
|
22090
|
+
import { execFile } from "node:child_process";
|
|
22091
|
+
import { constants, createReadStream } from "node:fs";
|
|
22092
|
+
import { mkdir, mkdtemp, open as open2, readdir, readFile, readlink, realpath, rm, stat } from "node:fs/promises";
|
|
22078
22093
|
import { tmpdir } from "node:os";
|
|
22079
|
-
import { join } from "node:path";
|
|
22094
|
+
import { basename, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
22095
|
+
import { promisify } from "node:util";
|
|
22080
22096
|
function entryKind(entry) {
|
|
22081
22097
|
if (entry.isDirectory()) {
|
|
22082
22098
|
return "directory";
|
|
@@ -22139,6 +22155,87 @@ async function readFileBytes(path6) {
|
|
|
22139
22155
|
function readFileChunks(path6, chunkBytes, signal) {
|
|
22140
22156
|
return createReadStream(path6, { highWaterMark: chunkBytes, signal });
|
|
22141
22157
|
}
|
|
22158
|
+
var execute = promisify(execFile);
|
|
22159
|
+
function supportsScopedLocalFileRead() {
|
|
22160
|
+
return process.platform === "linux" || process.platform === "darwin";
|
|
22161
|
+
}
|
|
22162
|
+
async function openedFilePath(fd, signal) {
|
|
22163
|
+
if (process.platform === "linux") {
|
|
22164
|
+
return await readlink(`/proc/self/fd/${fd}`);
|
|
22165
|
+
}
|
|
22166
|
+
if (process.platform === "darwin") {
|
|
22167
|
+
const { stdout } = await execute(
|
|
22168
|
+
"/usr/sbin/lsof",
|
|
22169
|
+
["-nP", "-w", "-a", "-p", String(process.pid), "-d", String(fd), "-Fn0"],
|
|
22170
|
+
{ signal, timeout: 2e3, maxBuffer: 16384 }
|
|
22171
|
+
);
|
|
22172
|
+
const field = stdout.split("\0").find((value) => value.startsWith("n/"));
|
|
22173
|
+
return field?.slice(1);
|
|
22174
|
+
}
|
|
22175
|
+
return void 0;
|
|
22176
|
+
}
|
|
22177
|
+
var ScopedFileReadError = class extends Error {
|
|
22178
|
+
code;
|
|
22179
|
+
constructor(code) {
|
|
22180
|
+
super("The local file is unavailable");
|
|
22181
|
+
this.code = code;
|
|
22182
|
+
}
|
|
22183
|
+
};
|
|
22184
|
+
function withinDirectory(directory, target) {
|
|
22185
|
+
const child = relative(directory, target);
|
|
22186
|
+
return child !== "" && child !== ".." && !child.startsWith(`..${sep}`) && !isAbsolute(child);
|
|
22187
|
+
}
|
|
22188
|
+
async function withScopedLocalFile(workingDirectory, requestedPath2, maximumBytes, signal, useFile) {
|
|
22189
|
+
const directory = await canonicalPath(workingDirectory);
|
|
22190
|
+
const candidate = resolve(directory, requestedPath2);
|
|
22191
|
+
if (directory !== workingDirectory || !withinDirectory(directory, candidate)) {
|
|
22192
|
+
throw new ScopedFileReadError("file_outside_scope");
|
|
22193
|
+
}
|
|
22194
|
+
const target = await canonicalPath(candidate);
|
|
22195
|
+
if (!withinDirectory(directory, target)) {
|
|
22196
|
+
throw new ScopedFileReadError("file_outside_scope");
|
|
22197
|
+
}
|
|
22198
|
+
signal.throwIfAborted();
|
|
22199
|
+
const handle = await open2(target, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
22200
|
+
try {
|
|
22201
|
+
const before = await handle.stat();
|
|
22202
|
+
if (!before.isFile()) {
|
|
22203
|
+
throw new ScopedFileReadError("file_unavailable");
|
|
22204
|
+
}
|
|
22205
|
+
if (before.size > maximumBytes) {
|
|
22206
|
+
throw new ScopedFileReadError("file_too_large");
|
|
22207
|
+
}
|
|
22208
|
+
if (await openedFilePath(handle.fd, signal) !== target || await canonicalPath(workingDirectory) !== directory) {
|
|
22209
|
+
throw new ScopedFileReadError("file_outside_scope");
|
|
22210
|
+
}
|
|
22211
|
+
await useFile({
|
|
22212
|
+
name: basename(target),
|
|
22213
|
+
size: before.size,
|
|
22214
|
+
modifiedAt: before.mtime,
|
|
22215
|
+
readPrefix: async (length) => {
|
|
22216
|
+
const header = Buffer.alloc(Math.min(before.size, length));
|
|
22217
|
+
const { bytesRead } = await handle.read(header, 0, header.length, 0);
|
|
22218
|
+
return header.subarray(0, bytesRead);
|
|
22219
|
+
},
|
|
22220
|
+
chunks: (chunkBytes) => before.size === 0 ? [] : handle.createReadStream({
|
|
22221
|
+
autoClose: false,
|
|
22222
|
+
start: 0,
|
|
22223
|
+
end: before.size - 1,
|
|
22224
|
+
highWaterMark: chunkBytes,
|
|
22225
|
+
signal
|
|
22226
|
+
}),
|
|
22227
|
+
verifyUnchanged: async () => {
|
|
22228
|
+
const after = await handle.stat();
|
|
22229
|
+
signal.throwIfAborted();
|
|
22230
|
+
if (after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.ctimeMs !== before.ctimeMs) {
|
|
22231
|
+
throw new ScopedFileReadError("file_unavailable");
|
|
22232
|
+
}
|
|
22233
|
+
}
|
|
22234
|
+
});
|
|
22235
|
+
} finally {
|
|
22236
|
+
await handle.close();
|
|
22237
|
+
}
|
|
22238
|
+
}
|
|
22142
22239
|
|
|
22143
22240
|
// src/engine/storage/installation/installation-files.ts
|
|
22144
22241
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -22220,7 +22317,7 @@ async function removeInstallationFile(path6) {
|
|
|
22220
22317
|
import { lstat as lstat2 } from "node:fs/promises";
|
|
22221
22318
|
|
|
22222
22319
|
// src/engine/util/platform/linux.ts
|
|
22223
|
-
import { isAbsolute, join as join4 } from "node:path";
|
|
22320
|
+
import { isAbsolute as isAbsolute2, join as join4 } from "node:path";
|
|
22224
22321
|
|
|
22225
22322
|
// src/engine/util/platform/posix.ts
|
|
22226
22323
|
import { chmod, lstat, unlink as unlink2 } from "node:fs/promises";
|
|
@@ -22271,12 +22368,12 @@ var linuxPlatform = {
|
|
|
22271
22368
|
...posixOperations,
|
|
22272
22369
|
claudeCodeExecutablePaths: (environment) => {
|
|
22273
22370
|
const homeDirectory = environment["HOME"];
|
|
22274
|
-
return homeDirectory !== void 0 &&
|
|
22371
|
+
return homeDirectory !== void 0 && isAbsolute2(homeDirectory) ? [join4(homeDirectory, ".local", "bin", "claude")] : [];
|
|
22275
22372
|
}
|
|
22276
22373
|
};
|
|
22277
22374
|
|
|
22278
22375
|
// src/engine/util/platform/macos.ts
|
|
22279
|
-
import { isAbsolute as
|
|
22376
|
+
import { isAbsolute as isAbsolute3, join as join6 } from "node:path";
|
|
22280
22377
|
|
|
22281
22378
|
// src/engine/util/platform/claude-desktop.ts
|
|
22282
22379
|
import { readdirSync } from "node:fs";
|
|
@@ -22317,7 +22414,7 @@ var macosPlatform = {
|
|
|
22317
22414
|
claudeCodeExecutablePaths: (environment) => {
|
|
22318
22415
|
const paths = ["/opt/homebrew/bin/claude", "/usr/local/bin/claude"];
|
|
22319
22416
|
const homeDirectory = environment["HOME"];
|
|
22320
|
-
if (homeDirectory !== void 0 &&
|
|
22417
|
+
if (homeDirectory !== void 0 && isAbsolute3(homeDirectory)) {
|
|
22321
22418
|
paths.unshift(join6(homeDirectory, ".local", "bin", "claude"));
|
|
22322
22419
|
paths.push(
|
|
22323
22420
|
...claudeDesktopExecutablePaths(
|
|
@@ -22331,17 +22428,17 @@ var macosPlatform = {
|
|
|
22331
22428
|
};
|
|
22332
22429
|
|
|
22333
22430
|
// src/engine/util/platform/windows.ts
|
|
22334
|
-
import { execFile } from "node:child_process";
|
|
22335
|
-
import { isAbsolute as
|
|
22336
|
-
import { promisify } from "node:util";
|
|
22337
|
-
var
|
|
22431
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
22432
|
+
import { isAbsolute as isAbsolute4, join as join7 } from "node:path";
|
|
22433
|
+
import { promisify as promisify2 } from "node:util";
|
|
22434
|
+
var execute2 = promisify2(execFile2);
|
|
22338
22435
|
function environmentValue(environment, name2) {
|
|
22339
22436
|
return Object.entries(environment).find(([key]) => key.toUpperCase() === name2.toUpperCase())?.[1];
|
|
22340
22437
|
}
|
|
22341
22438
|
function desktopClaudeExecutablePaths(environment) {
|
|
22342
22439
|
const roots = [];
|
|
22343
22440
|
const localAppData = environmentValue(environment, "LOCALAPPDATA");
|
|
22344
|
-
if (localAppData !== void 0 &&
|
|
22441
|
+
if (localAppData !== void 0 && isAbsolute4(localAppData)) {
|
|
22345
22442
|
const dataDirectory = join7(localAppData, "Claude-Data");
|
|
22346
22443
|
for (const installation of installedDirectories(dataDirectory)) {
|
|
22347
22444
|
if (installation.startsWith("claude_")) {
|
|
@@ -22350,7 +22447,7 @@ function desktopClaudeExecutablePaths(environment) {
|
|
|
22350
22447
|
}
|
|
22351
22448
|
}
|
|
22352
22449
|
const appData = environmentValue(environment, "APPDATA");
|
|
22353
|
-
if (appData !== void 0 &&
|
|
22450
|
+
if (appData !== void 0 && isAbsolute4(appData)) {
|
|
22354
22451
|
roots.push(join7(appData, "Claude", "claude-code"));
|
|
22355
22452
|
}
|
|
22356
22453
|
return claudeDesktopExecutablePaths(roots, [["claude.exe"]]);
|
|
@@ -22386,7 +22483,7 @@ async function validatePathPermissions(path6, _directory, privateAccess, signal)
|
|
|
22386
22483
|
throw new LocalPathError("Windows system directory is unavailable");
|
|
22387
22484
|
}
|
|
22388
22485
|
try {
|
|
22389
|
-
await
|
|
22486
|
+
await execute2(
|
|
22390
22487
|
join7(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
22391
22488
|
[
|
|
22392
22489
|
"-NoLogo",
|
|
@@ -22424,11 +22521,11 @@ var windowsPlatform = {
|
|
|
22424
22521
|
claudeCodeExecutablePaths: (environment) => {
|
|
22425
22522
|
const paths = [];
|
|
22426
22523
|
const userProfile = environmentValue(environment, "USERPROFILE");
|
|
22427
|
-
if (userProfile !== void 0 &&
|
|
22524
|
+
if (userProfile !== void 0 && isAbsolute4(userProfile)) {
|
|
22428
22525
|
paths.push(join7(userProfile, ".local", "bin", "claude.exe"));
|
|
22429
22526
|
}
|
|
22430
22527
|
const localAppData = environmentValue(environment, "LOCALAPPDATA");
|
|
22431
|
-
if (localAppData !== void 0 &&
|
|
22528
|
+
if (localAppData !== void 0 && isAbsolute4(localAppData)) {
|
|
22432
22529
|
paths.push(join7(localAppData, "Microsoft", "WinGet", "Links", "claude.exe"));
|
|
22433
22530
|
}
|
|
22434
22531
|
paths.push(...desktopClaudeExecutablePaths(environment));
|
|
@@ -22696,7 +22793,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
22696
22793
|
}
|
|
22697
22794
|
static open = async (engineDataDir, signal) => {
|
|
22698
22795
|
signal.throwIfAborted();
|
|
22699
|
-
const dataDirectory =
|
|
22796
|
+
const dataDirectory = resolve2(engineDataDir);
|
|
22700
22797
|
try {
|
|
22701
22798
|
await ensurePrivateDirectory(dataDirectory);
|
|
22702
22799
|
await validateLocalPath(dataDirectory, true, true, signal);
|
|
@@ -22917,7 +23014,7 @@ async function readOrCreateInstallationId(engineDataDir, signal) {
|
|
|
22917
23014
|
|
|
22918
23015
|
// src/engine/runtime/pairing.ts
|
|
22919
23016
|
import { hostname as hostname3 } from "node:os";
|
|
22920
|
-
import { basename as
|
|
23017
|
+
import { basename as basename7, resolve as resolve16 } from "node:path";
|
|
22921
23018
|
import { fetch as fetch3 } from "undici";
|
|
22922
23019
|
|
|
22923
23020
|
// ../../node_modules/.pnpm/@agentclientprotocol+sdk@1.4.0_zod@4.6.7/node_modules/@agentclientprotocol/sdk/dist/schema/index.js
|
|
@@ -25079,11 +25176,11 @@ var Connection = class {
|
|
|
25079
25176
|
const id = this.nextRequestId++;
|
|
25080
25177
|
let cancel = () => {
|
|
25081
25178
|
};
|
|
25082
|
-
const response = new Promise((
|
|
25179
|
+
const response = new Promise((resolve20, reject2) => {
|
|
25083
25180
|
const pendingResponse = {
|
|
25084
25181
|
resolve: (value) => {
|
|
25085
25182
|
try {
|
|
25086
|
-
|
|
25183
|
+
resolve20(mapResponse ? mapResponse(value) : value);
|
|
25087
25184
|
} catch (error62) {
|
|
25088
25185
|
reject2(error62);
|
|
25089
25186
|
}
|
|
@@ -25140,8 +25237,8 @@ var Connection = class {
|
|
|
25140
25237
|
this.stream = stream;
|
|
25141
25238
|
this.staticHandlers = handlers;
|
|
25142
25239
|
this.allowBatches = options?.allowBatches ?? true;
|
|
25143
|
-
this.closedPromise = new Promise((
|
|
25144
|
-
this.abortController.signal.addEventListener("abort", () =>
|
|
25240
|
+
this.closedPromise = new Promise((resolve20) => {
|
|
25241
|
+
this.abortController.signal.addEventListener("abort", () => resolve20());
|
|
25145
25242
|
});
|
|
25146
25243
|
void this.receive();
|
|
25147
25244
|
}
|
|
@@ -25907,8 +26004,8 @@ var AsyncQueue = class {
|
|
|
25907
26004
|
if (this.failed) {
|
|
25908
26005
|
return Promise.reject(this.failure);
|
|
25909
26006
|
}
|
|
25910
|
-
return new Promise((
|
|
25911
|
-
this.waiters.push({ resolve:
|
|
26007
|
+
return new Promise((resolve20, reject2) => {
|
|
26008
|
+
this.waiters.push({ resolve: resolve20, reject: reject2 });
|
|
25912
26009
|
});
|
|
25913
26010
|
}
|
|
25914
26011
|
};
|
|
@@ -26760,13 +26857,13 @@ function spawnClaudeWithParentLifeline(options) {
|
|
|
26760
26857
|
}
|
|
26761
26858
|
|
|
26762
26859
|
// src/engine/acp/harness/claude/upstream/dist/acp-agent.js
|
|
26763
|
-
import { execFile as
|
|
26860
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
26764
26861
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
26765
26862
|
import { existsSync as existsSync3 } from "node:fs";
|
|
26766
26863
|
import * as fs3 from "node:fs/promises";
|
|
26767
26864
|
import * as os3 from "node:os";
|
|
26768
26865
|
import * as path5 from "node:path";
|
|
26769
|
-
import { promisify as
|
|
26866
|
+
import { promisify as promisify3 } from "node:util";
|
|
26770
26867
|
|
|
26771
26868
|
// ../../node_modules/.pnpm/@anthropic-ai+claude-agent-sdk@0.3.257_@anthropic-ai+sdk@0.122.0_zod@4.6.7__@modelconte_d845268fdce2a8771f591438a8d88b04/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
|
|
26772
26869
|
import { createRequire as $ne } from "node:module";
|
|
@@ -63416,11 +63513,11 @@ var Pushable = class {
|
|
|
63416
63513
|
done = false;
|
|
63417
63514
|
push(item) {
|
|
63418
63515
|
if (this.resolvers.length > 0) {
|
|
63419
|
-
const
|
|
63420
|
-
if (
|
|
63516
|
+
const resolve20 = this.resolvers.shift();
|
|
63517
|
+
if (resolve20 === void 0) {
|
|
63421
63518
|
return;
|
|
63422
63519
|
}
|
|
63423
|
-
|
|
63520
|
+
resolve20({ value: item, done: false });
|
|
63424
63521
|
} else {
|
|
63425
63522
|
this.queue.push(item);
|
|
63426
63523
|
}
|
|
@@ -63428,8 +63525,8 @@ var Pushable = class {
|
|
|
63428
63525
|
end() {
|
|
63429
63526
|
this.done = true;
|
|
63430
63527
|
while (this.resolvers.length > 0) {
|
|
63431
|
-
const
|
|
63432
|
-
|
|
63528
|
+
const resolve20 = this.resolvers.shift();
|
|
63529
|
+
resolve20?.({ done: true, value: void 0 });
|
|
63433
63530
|
}
|
|
63434
63531
|
}
|
|
63435
63532
|
[Symbol.asyncIterator]() {
|
|
@@ -63445,8 +63542,8 @@ var Pushable = class {
|
|
|
63445
63542
|
if (this.done) {
|
|
63446
63543
|
return Promise.resolve({ done: true, value: void 0 });
|
|
63447
63544
|
}
|
|
63448
|
-
return new Promise((
|
|
63449
|
-
this.resolvers.push(
|
|
63545
|
+
return new Promise((resolve20) => {
|
|
63546
|
+
this.resolvers.push(resolve20);
|
|
63450
63547
|
});
|
|
63451
63548
|
}
|
|
63452
63549
|
};
|
|
@@ -63464,14 +63561,14 @@ function unreachable(value, logger = console) {
|
|
|
63464
63561
|
async function withDeadline(signal, timeoutMilliseconds, operation) {
|
|
63465
63562
|
const deadline = AbortSignal.any([signal, AbortSignal.timeout(timeoutMilliseconds)]);
|
|
63466
63563
|
deadline.throwIfAborted();
|
|
63467
|
-
return await new Promise((
|
|
63564
|
+
return await new Promise((resolve20, reject2) => {
|
|
63468
63565
|
const settle2 = (callback) => {
|
|
63469
63566
|
deadline.removeEventListener("abort", onAbort);
|
|
63470
63567
|
callback();
|
|
63471
63568
|
};
|
|
63472
63569
|
const onAbort = () => settle2(() => reject2(deadline.reason));
|
|
63473
63570
|
deadline.addEventListener("abort", onAbort, { once: true });
|
|
63474
|
-
operation().then((value) => settle2(() =>
|
|
63571
|
+
operation().then((value) => settle2(() => resolve20(value)), (error62) => settle2(() => reject2(error62)));
|
|
63475
63572
|
});
|
|
63476
63573
|
}
|
|
63477
63574
|
var environmentChain = Promise.resolve();
|
|
@@ -64170,8 +64267,8 @@ function inputPath(context, key) {
|
|
|
64170
64267
|
return plainString(context.input[key]);
|
|
64171
64268
|
}
|
|
64172
64269
|
function isInside(directory, candidate) {
|
|
64173
|
-
const
|
|
64174
|
-
return
|
|
64270
|
+
const relative4 = path.relative(path.resolve(directory), path.resolve(candidate));
|
|
64271
|
+
return relative4 === "" || !relative4.startsWith(`..${path.sep}`) && relative4 !== "..";
|
|
64175
64272
|
}
|
|
64176
64273
|
function hasSessionAllowRuleFor(changeSet, toolName) {
|
|
64177
64274
|
return !!changeSet?.updates.some((update) => update.type === "addRules" && update.destination === "session" && update.behavior === "allow" && update.rules.some((rule) => rule.toolName === toolName));
|
|
@@ -66321,7 +66418,7 @@ var SessionModeManager = class {
|
|
|
66321
66418
|
|
|
66322
66419
|
// src/engine/acp/harness/claude/upstream/dist/acp-agent.js
|
|
66323
66420
|
var CLAUDE_CONFIG_DIR = process.env.CLAUDE_CONFIG_DIR ?? path5.join(os3.homedir(), ".claude");
|
|
66324
|
-
var execFileAsync =
|
|
66421
|
+
var execFileAsync = promisify3(execFile3);
|
|
66325
66422
|
var ZERO_USAGE = Object.freeze({
|
|
66326
66423
|
input_tokens: 0,
|
|
66327
66424
|
output_tokens: 0,
|
|
@@ -66339,14 +66436,14 @@ function waitUnlessAborted(milliseconds, signal) {
|
|
|
66339
66436
|
if (signal.aborted) {
|
|
66340
66437
|
return Promise.resolve(false);
|
|
66341
66438
|
}
|
|
66342
|
-
return new Promise((
|
|
66439
|
+
return new Promise((resolve20) => {
|
|
66343
66440
|
const timer = setTimeout(() => {
|
|
66344
66441
|
signal.removeEventListener("abort", onAbort);
|
|
66345
|
-
|
|
66442
|
+
resolve20(true);
|
|
66346
66443
|
}, milliseconds);
|
|
66347
66444
|
const onAbort = () => {
|
|
66348
66445
|
clearTimeout(timer);
|
|
66349
|
-
|
|
66446
|
+
resolve20(false);
|
|
66350
66447
|
};
|
|
66351
66448
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
66352
66449
|
});
|
|
@@ -66584,7 +66681,7 @@ var ClientConnection = class {
|
|
|
66584
66681
|
}
|
|
66585
66682
|
};
|
|
66586
66683
|
function raceWithAbort(operation, signal) {
|
|
66587
|
-
return new Promise((
|
|
66684
|
+
return new Promise((resolve20, reject2) => {
|
|
66588
66685
|
const cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
66589
66686
|
const onAbort = () => {
|
|
66590
66687
|
cleanup();
|
|
@@ -66596,7 +66693,7 @@ function raceWithAbort(operation, signal) {
|
|
|
66596
66693
|
}
|
|
66597
66694
|
void operation.then((value) => {
|
|
66598
66695
|
cleanup();
|
|
66599
|
-
|
|
66696
|
+
resolve20(value);
|
|
66600
66697
|
}, (error62) => {
|
|
66601
66698
|
cleanup();
|
|
66602
66699
|
reject2(error62);
|
|
@@ -67199,12 +67296,12 @@ var ClaudeAcpAgent = class {
|
|
|
67199
67296
|
}
|
|
67200
67297
|
};
|
|
67201
67298
|
let completeTurn;
|
|
67202
|
-
turn.completion = new Promise((
|
|
67203
|
-
completeTurn =
|
|
67299
|
+
turn.completion = new Promise((resolve20) => {
|
|
67300
|
+
completeTurn = resolve20;
|
|
67204
67301
|
});
|
|
67205
|
-
const response = new Promise((
|
|
67302
|
+
const response = new Promise((resolve20, reject2) => {
|
|
67206
67303
|
turn.resolve = (result) => {
|
|
67207
|
-
|
|
67304
|
+
resolve20(result);
|
|
67208
67305
|
completeTurn();
|
|
67209
67306
|
};
|
|
67210
67307
|
turn.reject = (error62) => {
|
|
@@ -67668,8 +67765,8 @@ var ClaudeAcpAgent = class {
|
|
|
67668
67765
|
pendingNext ??= session.query.next().then((result) => ({ kind: "message", result }));
|
|
67669
67766
|
const nextMessage = pendingNext;
|
|
67670
67767
|
let onAbort;
|
|
67671
|
-
const abortRace = new Promise((
|
|
67672
|
-
onAbort = () =>
|
|
67768
|
+
const abortRace = new Promise((resolve20) => {
|
|
67769
|
+
onAbort = () => resolve20("abort");
|
|
67673
67770
|
cancelController.signal.addEventListener("abort", onAbort, { once: true });
|
|
67674
67771
|
});
|
|
67675
67772
|
const raced = await Promise.race([nextMessage, abortRace]);
|
|
@@ -71246,16 +71343,16 @@ var ClaudeAgentConnection = class extends EndpointAgentConnection {
|
|
|
71246
71343
|
// src/engine/util/process/executable.ts
|
|
71247
71344
|
import { spawn as spawn3 } from "node:child_process";
|
|
71248
71345
|
import { stat as stat5 } from "node:fs/promises";
|
|
71249
|
-
import { join as join16, resolve as
|
|
71346
|
+
import { join as join16, resolve as resolve10 } from "node:path";
|
|
71250
71347
|
|
|
71251
71348
|
// src/engine/util/process/platform/linux.ts
|
|
71252
|
-
import { constants as
|
|
71349
|
+
import { constants as constants5, readdirSync as readdirSync3, readFileSync as readFileSync2 } from "node:fs";
|
|
71253
71350
|
import { access as access3, readdir as readdir5, readFile as readFile4, realpath as realpath5, stat as stat4 } from "node:fs/promises";
|
|
71254
71351
|
import { join as join14 } from "node:path";
|
|
71255
71352
|
|
|
71256
71353
|
// src/engine/util/process/platform/posix.ts
|
|
71257
|
-
import { execFile as
|
|
71258
|
-
import { constants as
|
|
71354
|
+
import { execFile as execFile4 } from "node:child_process";
|
|
71355
|
+
import { constants as constants4 } from "node:fs";
|
|
71259
71356
|
import { access as access2, realpath as realpath4 } from "node:fs/promises";
|
|
71260
71357
|
var PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
|
|
71261
71358
|
var PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
|
|
@@ -71278,7 +71375,7 @@ function parseProcessTable(output2) {
|
|
|
71278
71375
|
}
|
|
71279
71376
|
function readProcessTableWithPs(executable) {
|
|
71280
71377
|
return new Promise((resolveTable) => {
|
|
71281
|
-
|
|
71378
|
+
execFile4(
|
|
71282
71379
|
executable,
|
|
71283
71380
|
["-axo", "pid=,ppid=,pgid="],
|
|
71284
71381
|
{
|
|
@@ -71342,7 +71439,7 @@ var posixOperations2 = {
|
|
|
71342
71439
|
executableExtensions: () => [""],
|
|
71343
71440
|
resolveExecutableTarget: async (path6) => {
|
|
71344
71441
|
const target = await realpath4(path6);
|
|
71345
|
-
await access2(target,
|
|
71442
|
+
await access2(target, constants4.X_OK);
|
|
71346
71443
|
return target;
|
|
71347
71444
|
},
|
|
71348
71445
|
executableLaunch: (command, args) => ({ command, arguments: args }),
|
|
@@ -71426,7 +71523,7 @@ async function readLinuxProcessTableWithFallback() {
|
|
|
71426
71523
|
if (!(await stat4(resolvedPath)).isFile()) {
|
|
71427
71524
|
continue;
|
|
71428
71525
|
}
|
|
71429
|
-
await access3(resolvedPath,
|
|
71526
|
+
await access3(resolvedPath, constants5.X_OK);
|
|
71430
71527
|
} catch {
|
|
71431
71528
|
continue;
|
|
71432
71529
|
}
|
|
@@ -71467,9 +71564,9 @@ var macosProcessPlatform = {
|
|
|
71467
71564
|
};
|
|
71468
71565
|
|
|
71469
71566
|
// src/engine/util/process/platform/windows.ts
|
|
71470
|
-
import { execFile as
|
|
71567
|
+
import { execFile as execFile5 } from "node:child_process";
|
|
71471
71568
|
import { readFile as readFile5, realpath as realpath6 } from "node:fs/promises";
|
|
71472
|
-
import { dirname as dirname6, extname, join as join15, resolve as
|
|
71569
|
+
import { dirname as dirname6, extname, join as join15, resolve as resolve9 } from "node:path";
|
|
71473
71570
|
|
|
71474
71571
|
// src/engine/util/process/process-error.ts
|
|
71475
71572
|
var ProcessExecutionError = class extends Error {
|
|
@@ -71510,12 +71607,12 @@ async function resolveExecutableTarget(path6) {
|
|
|
71510
71607
|
for (const tool of ["npm", "npx"]) {
|
|
71511
71608
|
const variable = `${tool.toUpperCase()}_CLI_JS`;
|
|
71512
71609
|
if (shim.includes(`SET "${variable}=%~dp0\\node_modules\\npm\\bin\\${tool}-cli.js"`) && shim.includes(`"%NODE_EXE%" "%${variable}%" %*`)) {
|
|
71513
|
-
return await realpath6(
|
|
71610
|
+
return await realpath6(resolve9(dirname6(resolvedPath), `node_modules/npm/bin/${tool}-cli.js`));
|
|
71514
71611
|
}
|
|
71515
71612
|
}
|
|
71516
71613
|
const script = /"%_prog%"\s+"%dp0%[\\/]([^"\r\n]+\.(?:js|mjs|cjs))"\s+%\*/iu.exec(shim)?.[1];
|
|
71517
71614
|
if (script !== void 0 && shim.includes("SET dp0=%~dp0")) {
|
|
71518
|
-
resolvedPath = await realpath6(
|
|
71615
|
+
resolvedPath = await realpath6(resolve9(dirname6(resolvedPath), script));
|
|
71519
71616
|
} else {
|
|
71520
71617
|
const pnpmScript = /^\s*node\s+"%~dp0[\\/]([^"\r\n]+\.(?:js|mjs|cjs))"\s+%\*\s*$/imu.exec(shim)?.[1];
|
|
71521
71618
|
if (pnpmScript === void 0 || !shim.includes("@SETLOCAL")) {
|
|
@@ -71524,7 +71621,7 @@ async function resolveExecutableTarget(path6) {
|
|
|
71524
71621
|
"Use a native executable or a verified Node entrypoint"
|
|
71525
71622
|
);
|
|
71526
71623
|
}
|
|
71527
|
-
resolvedPath = await realpath6(
|
|
71624
|
+
resolvedPath = await realpath6(resolve9(dirname6(resolvedPath), pnpmScript));
|
|
71528
71625
|
}
|
|
71529
71626
|
}
|
|
71530
71627
|
return resolvedPath;
|
|
@@ -71547,7 +71644,7 @@ function readProcessTable() {
|
|
|
71547
71644
|
return Promise.resolve([]);
|
|
71548
71645
|
}
|
|
71549
71646
|
return new Promise((resolveTable) => {
|
|
71550
|
-
|
|
71647
|
+
execFile5(
|
|
71551
71648
|
join15(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
71552
71649
|
[
|
|
71553
71650
|
"-NoLogo",
|
|
@@ -71653,7 +71750,7 @@ var ProcessResult = class {
|
|
|
71653
71750
|
}
|
|
71654
71751
|
};
|
|
71655
71752
|
async function resolveExecutablePath(requestedPath2, platform2 = process.platform) {
|
|
71656
|
-
const absoluteRequestedPath =
|
|
71753
|
+
const absoluteRequestedPath = resolve10(requestedPath2);
|
|
71657
71754
|
try {
|
|
71658
71755
|
const resolvedPath = await processPlatformSupportFor(platform2).resolveExecutableTarget(absoluteRequestedPath);
|
|
71659
71756
|
const metadata = await stat5(resolvedPath);
|
|
@@ -71684,7 +71781,7 @@ async function findExecutableOnPath(executableName, environment, platform2 = pro
|
|
|
71684
71781
|
continue;
|
|
71685
71782
|
}
|
|
71686
71783
|
for (const extension of extensions) {
|
|
71687
|
-
const requestedPath2 =
|
|
71784
|
+
const requestedPath2 = resolve10(join16(entry, `${executableName}${extension}`));
|
|
71688
71785
|
const executable = await resolveExecutablePath(requestedPath2, platform2);
|
|
71689
71786
|
if (executable !== null) {
|
|
71690
71787
|
return executable;
|
|
@@ -72009,7 +72106,7 @@ var ClaudeCodeAgentSpecification = class extends InProcessAcpAgentSpecification
|
|
|
72009
72106
|
import { spawn as spawn4 } from "node:child_process";
|
|
72010
72107
|
|
|
72011
72108
|
// src/engine/acp/harness/codex/app-server-protocol.ts
|
|
72012
|
-
import { isAbsolute as
|
|
72109
|
+
import { isAbsolute as isAbsolute9 } from "node:path";
|
|
72013
72110
|
var boundedText = (maximum) => external_exports.string().max(maximum);
|
|
72014
72111
|
var jsonValue = external_exports.lazy(() => external_exports.unknown());
|
|
72015
72112
|
var requestIdSchema = external_exports.union([external_exports.number(), external_exports.string()]).refine((value) => typeof value === "number" || value.length <= 256);
|
|
@@ -72087,7 +72184,7 @@ var agentMessageQuestionsSchema = external_exports.array(
|
|
|
72087
72184
|
).max(100).nullish().catch(null);
|
|
72088
72185
|
var threadItemSchema = external_exports.discriminatedUnion("type", [
|
|
72089
72186
|
imageGenerationItemSchema,
|
|
72090
|
-
external_exports.object({ type: external_exports.literal("imageView"), id: boundedText(256), path: boundedText(32768).refine(
|
|
72187
|
+
external_exports.object({ type: external_exports.literal("imageView"), id: boundedText(256), path: boundedText(32768).refine(isAbsolute9) }),
|
|
72091
72188
|
external_exports.object({
|
|
72092
72189
|
id: boundedText(256),
|
|
72093
72190
|
text: boundedText(1e6),
|
|
@@ -73652,10 +73749,10 @@ function turnRunning(turn) {
|
|
|
73652
73749
|
}
|
|
73653
73750
|
function waitForNextPoll(timer, signal) {
|
|
73654
73751
|
signal.throwIfAborted();
|
|
73655
|
-
return new Promise((
|
|
73752
|
+
return new Promise((resolve20, reject2) => {
|
|
73656
73753
|
const poll = timer.schedule(() => {
|
|
73657
73754
|
signal.removeEventListener("abort", abort);
|
|
73658
|
-
|
|
73755
|
+
resolve20();
|
|
73659
73756
|
}, POLL_INTERVAL);
|
|
73660
73757
|
const abort = () => {
|
|
73661
73758
|
poll.cancel();
|
|
@@ -73997,7 +74094,7 @@ var CodexBorrowedAcpAgent = class {
|
|
|
73997
74094
|
import { createHash as createHash2 } from "node:crypto";
|
|
73998
74095
|
|
|
73999
74096
|
// src/engine/acp/content/raster.ts
|
|
74000
|
-
import { basename as
|
|
74097
|
+
import { basename as basename5, isAbsolute as isAbsolute10, normalize } from "node:path";
|
|
74001
74098
|
import { fileURLToPath } from "node:url";
|
|
74002
74099
|
var MAX_LOCAL_RASTER_BYTES = 128 * 1024 * 1024;
|
|
74003
74100
|
var PNG_SIGNATURE = Uint8Array.of(137, 80, 78, 71);
|
|
@@ -74040,13 +74137,13 @@ function sniffRasterMime(bytes) {
|
|
|
74040
74137
|
}
|
|
74041
74138
|
async function resolveCanonicalPath(requested, signal) {
|
|
74042
74139
|
signal.throwIfAborted();
|
|
74043
|
-
if (!
|
|
74140
|
+
if (!isAbsolute10(requested) || requested.includes("\0") || normalize(requested) !== requested) {
|
|
74044
74141
|
return null;
|
|
74045
74142
|
}
|
|
74046
74143
|
try {
|
|
74047
74144
|
const target = await canonicalPath(requested);
|
|
74048
74145
|
signal.throwIfAborted();
|
|
74049
|
-
if (!
|
|
74146
|
+
if (!isAbsolute10(target) || normalize(target) !== target) {
|
|
74050
74147
|
return null;
|
|
74051
74148
|
}
|
|
74052
74149
|
return target;
|
|
@@ -74077,7 +74174,7 @@ function parseLocalImageUri(uri) {
|
|
|
74077
74174
|
return null;
|
|
74078
74175
|
}
|
|
74079
74176
|
}
|
|
74080
|
-
if (!
|
|
74177
|
+
if (!isAbsolute10(trimmed) && /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(trimmed)) {
|
|
74081
74178
|
return null;
|
|
74082
74179
|
}
|
|
74083
74180
|
return trimmed;
|
|
@@ -74103,7 +74200,7 @@ async function readLocalRaster(uri, signal) {
|
|
|
74103
74200
|
if (mimeType === null) {
|
|
74104
74201
|
return null;
|
|
74105
74202
|
}
|
|
74106
|
-
return new LocalRasterImage(
|
|
74203
|
+
return new LocalRasterImage(basename5(target) || "Image", mimeType, target);
|
|
74107
74204
|
}
|
|
74108
74205
|
|
|
74109
74206
|
// src/engine/acp/native-history/codex/history-images.ts
|
|
@@ -75076,7 +75173,7 @@ import { join as join22 } from "node:path";
|
|
|
75076
75173
|
import { spawnSync } from "node:child_process";
|
|
75077
75174
|
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
75078
75175
|
import { existsSync as existsSync8, readdirSync as readdirSync6, readFileSync as readFileSync9, realpathSync as realpathSync3, statSync as statSync3, unlinkSync as unlinkSync2 } from "node:fs";
|
|
75079
|
-
import { basename as
|
|
75176
|
+
import { basename as basename6, dirname as dirname8, isAbsolute as isAbsolute13, join as join21 } from "node:path";
|
|
75080
75177
|
|
|
75081
75178
|
// src/engine/acp/harness/pi/upstream/dist/pi-rpc/process.js
|
|
75082
75179
|
import { spawn as spawn5 } from "node:child_process";
|
|
@@ -75203,10 +75300,10 @@ var PiRpcProcess = class _PiRpcProcess {
|
|
|
75203
75300
|
shell: shouldUseShellForPiCommand(cmd)
|
|
75204
75301
|
});
|
|
75205
75302
|
try {
|
|
75206
|
-
await new Promise((
|
|
75303
|
+
await new Promise((resolve20, reject2) => {
|
|
75207
75304
|
const onSpawn = () => {
|
|
75208
75305
|
cleanup();
|
|
75209
|
-
|
|
75306
|
+
resolve20();
|
|
75210
75307
|
};
|
|
75211
75308
|
const onError = (err) => {
|
|
75212
75309
|
cleanup();
|
|
@@ -75408,7 +75505,7 @@ var PiRpcProcess = class _PiRpcProcess {
|
|
|
75408
75505
|
const timeoutMs = opts?.timeoutMs;
|
|
75409
75506
|
const line = `${JSON.stringify(withId)}
|
|
75410
75507
|
`;
|
|
75411
|
-
return new Promise((
|
|
75508
|
+
return new Promise((resolve20, reject2) => {
|
|
75412
75509
|
const signal = opts?.signal;
|
|
75413
75510
|
if (signal?.aborted === true) {
|
|
75414
75511
|
reject2(signal.reason);
|
|
@@ -75430,7 +75527,7 @@ var PiRpcProcess = class _PiRpcProcess {
|
|
|
75430
75527
|
this.pending.set(id, {
|
|
75431
75528
|
resolve: (res) => {
|
|
75432
75529
|
drop();
|
|
75433
|
-
|
|
75530
|
+
resolve20(res);
|
|
75434
75531
|
},
|
|
75435
75532
|
reject: (error62) => {
|
|
75436
75533
|
drop();
|
|
@@ -75463,14 +75560,14 @@ var PiRpcProcess = class _PiRpcProcess {
|
|
|
75463
75560
|
});
|
|
75464
75561
|
}
|
|
75465
75562
|
writeLine(line) {
|
|
75466
|
-
return new Promise((
|
|
75563
|
+
return new Promise((resolve20, reject2) => {
|
|
75467
75564
|
try {
|
|
75468
75565
|
this.child.stdin.write(line, (error62) => {
|
|
75469
75566
|
if (error62) {
|
|
75470
75567
|
reject2(error62);
|
|
75471
75568
|
return;
|
|
75472
75569
|
}
|
|
75473
|
-
|
|
75570
|
+
resolve20();
|
|
75474
75571
|
});
|
|
75475
75572
|
} catch (error62) {
|
|
75476
75573
|
reject2(error62);
|
|
@@ -75667,12 +75764,12 @@ async function readPiLatestEntryId(sessionFile) {
|
|
|
75667
75764
|
|
|
75668
75765
|
// src/engine/acp/harness/pi/upstream/dist/acp/pi-sessions.js
|
|
75669
75766
|
import { closeSync as closeSync2, existsSync as existsSync5, openSync as openSync2, readdirSync as readdirSync4, readFileSync as readFileSync4, readSync as readSync2, statSync as statSync2 } from "node:fs";
|
|
75670
|
-
import { isAbsolute as
|
|
75767
|
+
import { isAbsolute as isAbsolute11, join as join18, resolve as resolve11 } from "node:path";
|
|
75671
75768
|
var DEFAULT_TAIL_BYTES = 256 * 1024;
|
|
75672
75769
|
var DEFAULT_HEAD_BYTES = 64 * 1024;
|
|
75673
75770
|
function getPiAgentDir(environment) {
|
|
75674
75771
|
const configured = environment["PI_CODING_AGENT_DIR"];
|
|
75675
|
-
return configured ?
|
|
75772
|
+
return configured ? resolve11(configured) : join18(environmentHome(environment), ".pi", "agent");
|
|
75676
75773
|
}
|
|
75677
75774
|
function readSessionDirFromSettings(agentDir) {
|
|
75678
75775
|
const settingsPath = join18(agentDir, "settings.json");
|
|
@@ -75689,7 +75786,7 @@ function readSessionDirFromSettings(agentDir) {
|
|
|
75689
75786
|
if (typeof sessionDir !== "string" || !sessionDir.trim()) {
|
|
75690
75787
|
return null;
|
|
75691
75788
|
}
|
|
75692
|
-
return
|
|
75789
|
+
return isAbsolute11(sessionDir) ? sessionDir : resolve11(agentDir, sessionDir);
|
|
75693
75790
|
} catch {
|
|
75694
75791
|
return null;
|
|
75695
75792
|
}
|
|
@@ -75702,7 +75799,7 @@ function getPiSessionDiscoveryDirs(environment) {
|
|
|
75702
75799
|
const discoveryDirectories = [getPiSessionsDir(environment)];
|
|
75703
75800
|
const mobiusSessionDirectory = environment["MOBIUS_PI_SESSION_DIR"];
|
|
75704
75801
|
if (mobiusSessionDirectory !== void 0 && mobiusSessionDirectory.trim().length > 0) {
|
|
75705
|
-
const mobiusSessionsRoot =
|
|
75802
|
+
const mobiusSessionsRoot = resolve11(mobiusSessionDirectory, "..");
|
|
75706
75803
|
for (const entry of readdirSync4(mobiusSessionsRoot, { withFileTypes: true, encoding: "utf-8" })) {
|
|
75707
75804
|
if (!entry.isDirectory()) {
|
|
75708
75805
|
continue;
|
|
@@ -75993,7 +76090,7 @@ function findPiSession(sessionId, environment = process.env) {
|
|
|
75993
76090
|
|
|
75994
76091
|
// src/engine/acp/harness/pi/upstream/dist/acp/pi-settings.js
|
|
75995
76092
|
import { existsSync as existsSync6, readFileSync as readFileSync5 } from "node:fs";
|
|
75996
|
-
import { join as join19, resolve as
|
|
76093
|
+
import { join as join19, resolve as resolve12 } from "node:path";
|
|
75997
76094
|
function isObject2(x) {
|
|
75998
76095
|
return Boolean(x) && typeof x === "object" && !Array.isArray(x);
|
|
75999
76096
|
}
|
|
@@ -76023,14 +76120,14 @@ function readJsonFile2(path6) {
|
|
|
76023
76120
|
}
|
|
76024
76121
|
function getMergedSettings(cwd, environment) {
|
|
76025
76122
|
const globalSettingsPath = join19(getAgentDir(environment), "settings.json");
|
|
76026
|
-
const projectSettingsPath =
|
|
76123
|
+
const projectSettingsPath = resolve12(cwd, ".pi", "settings.json");
|
|
76027
76124
|
const global2 = readJsonFile2(globalSettingsPath);
|
|
76028
76125
|
const project = readJsonFile2(projectSettingsPath);
|
|
76029
76126
|
return deepMerge(global2, project);
|
|
76030
76127
|
}
|
|
76031
76128
|
function getAgentDir(environment = process.env) {
|
|
76032
76129
|
const configured = environment["PI_CODING_AGENT_DIR"];
|
|
76033
|
-
return configured ?
|
|
76130
|
+
return configured ? resolve12(configured) : join19(environmentHome(environment), ".pi", "agent");
|
|
76034
76131
|
}
|
|
76035
76132
|
function getEnableSkillCommands(cwd, environment = process.env) {
|
|
76036
76133
|
const merged = getMergedSettings(cwd, environment);
|
|
@@ -76060,7 +76157,7 @@ function getQuietStartup(cwd, environment = process.env) {
|
|
|
76060
76157
|
// src/engine/acp/harness/pi/upstream/dist/acp/session.js
|
|
76061
76158
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
76062
76159
|
import { readFileSync as readFileSync8 } from "node:fs";
|
|
76063
|
-
import { isAbsolute as
|
|
76160
|
+
import { isAbsolute as isAbsolute12, resolve as resolvePath } from "node:path";
|
|
76064
76161
|
|
|
76065
76162
|
// src/engine/acp/harness/pi/upstream/dist/acp/extension-questions.js
|
|
76066
76163
|
var questionBase = {
|
|
@@ -76284,7 +76381,7 @@ var SessionStore = class {
|
|
|
76284
76381
|
|
|
76285
76382
|
// src/engine/acp/harness/pi/upstream/dist/acp/slash-commands.js
|
|
76286
76383
|
import { existsSync as existsSync7, readdirSync as readdirSync5, readFileSync as readFileSync7 } from "node:fs";
|
|
76287
|
-
import { join as join20, resolve as
|
|
76384
|
+
import { join as join20, resolve as resolve13 } from "node:path";
|
|
76288
76385
|
function parseFrontmatter(content) {
|
|
76289
76386
|
const frontmatter = {};
|
|
76290
76387
|
if (!content.startsWith("---")) {
|
|
@@ -76353,7 +76450,7 @@ function loadCommandsFromDir(dir, source, subdir = "") {
|
|
|
76353
76450
|
function loadSlashCommands(cwd, environment = process.env) {
|
|
76354
76451
|
const commands = [];
|
|
76355
76452
|
const userDir = join20(environmentHome(environment), ".pi", "agent", "prompts");
|
|
76356
|
-
const projectDir =
|
|
76453
|
+
const projectDir = resolve13(cwd, ".pi", "prompts");
|
|
76357
76454
|
commands.push(...loadCommandsFromDir(userDir, "user"));
|
|
76358
76455
|
commands.push(...loadCommandsFromDir(projectDir, "project"));
|
|
76359
76456
|
return commands;
|
|
@@ -76601,7 +76698,7 @@ function toToolCallLocations(args, cwd, line) {
|
|
|
76601
76698
|
if (!path6) {
|
|
76602
76699
|
return void 0;
|
|
76603
76700
|
}
|
|
76604
|
-
const resolvedPath =
|
|
76701
|
+
const resolvedPath = isAbsolute12(path6) ? path6 : resolvePath(cwd, path6);
|
|
76605
76702
|
return [{ path: resolvedPath, ...typeof line === "number" ? { line } : {} }];
|
|
76606
76703
|
}
|
|
76607
76704
|
var SessionManager = class {
|
|
@@ -76825,8 +76922,8 @@ var PiAcpSession = class {
|
|
|
76825
76922
|
}
|
|
76826
76923
|
async prompt(message, images = []) {
|
|
76827
76924
|
const expandedMessage = expandSlashCommand(message, this.fileCommands);
|
|
76828
|
-
const turnPromise = new Promise((
|
|
76829
|
-
const queued = { message: expandedMessage, images, resolve:
|
|
76925
|
+
const turnPromise = new Promise((resolve20, reject2) => {
|
|
76926
|
+
const queued = { message: expandedMessage, images, resolve: resolve20, reject: reject2 };
|
|
76830
76927
|
if (this.pendingTurn) {
|
|
76831
76928
|
this.turnQueue.push(queued);
|
|
76832
76929
|
this.emit({
|
|
@@ -77155,7 +77252,7 @@ var PiAcpSession = class {
|
|
|
77155
77252
|
const p = getToolPath(args);
|
|
77156
77253
|
if (p) {
|
|
77157
77254
|
try {
|
|
77158
|
-
const abs =
|
|
77255
|
+
const abs = isAbsolute12(p) ? p : resolvePath(this.cwd, p);
|
|
77159
77256
|
snapshotOldText = readFileSync8(abs, "utf8");
|
|
77160
77257
|
this.fileSnapshots.set(toolCallId, { path: p, oldText: snapshotOldText });
|
|
77161
77258
|
if (toolName === "edit") {
|
|
@@ -77238,7 +77335,7 @@ var PiAcpSession = class {
|
|
|
77238
77335
|
let hasStructuredDiff = false;
|
|
77239
77336
|
if (!isError && snapshot) {
|
|
77240
77337
|
try {
|
|
77241
|
-
const abs =
|
|
77338
|
+
const abs = isAbsolute12(snapshot.path) ? snapshot.path : resolvePath(this.cwd, snapshot.path);
|
|
77242
77339
|
const newText = readFileSync8(abs, "utf8");
|
|
77243
77340
|
if (snapshot.oldText === null || newText !== snapshot.oldText) {
|
|
77244
77341
|
hasStructuredDiff = true;
|
|
@@ -77641,7 +77738,7 @@ var PiAcpAgent = class {
|
|
|
77641
77738
|
};
|
|
77642
77739
|
}
|
|
77643
77740
|
async newSession(params) {
|
|
77644
|
-
if (!
|
|
77741
|
+
if (!isAbsolute13(params.cwd)) {
|
|
77645
77742
|
throw RequestError.invalidParams(`cwd must be an absolute path: ${params.cwd}`);
|
|
77646
77743
|
}
|
|
77647
77744
|
this.lastSessionCwd = params.cwd;
|
|
@@ -78276,7 +78373,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
78276
78373
|
return { sessions, nextCursor, _meta: {} };
|
|
78277
78374
|
}
|
|
78278
78375
|
async forkSession(params) {
|
|
78279
|
-
if (!
|
|
78376
|
+
if (!isAbsolute13(params.cwd)) {
|
|
78280
78377
|
throw RequestError.invalidParams(`cwd must be an absolute path: ${params.cwd}`);
|
|
78281
78378
|
}
|
|
78282
78379
|
const source = this.findStoredSession(params.sessionId);
|
|
@@ -78342,7 +78439,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
78342
78439
|
return { sessionId: session.sessionId, configOptions, modes };
|
|
78343
78440
|
}
|
|
78344
78441
|
async resumeSession(params) {
|
|
78345
|
-
if (!
|
|
78442
|
+
if (!isAbsolute13(params.cwd)) {
|
|
78346
78443
|
throw RequestError.invalidParams(`cwd must be an absolute path: ${params.cwd}`);
|
|
78347
78444
|
}
|
|
78348
78445
|
this.sessions.close(params.sessionId);
|
|
@@ -78413,7 +78510,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
78413
78510
|
return response;
|
|
78414
78511
|
}
|
|
78415
78512
|
async loadSession(params) {
|
|
78416
|
-
if (!
|
|
78513
|
+
if (!isAbsolute13(params.cwd)) {
|
|
78417
78514
|
throw RequestError.invalidParams(`cwd must be an absolute path: ${params.cwd}`);
|
|
78418
78515
|
}
|
|
78419
78516
|
this.sessions.close(params.sessionId);
|
|
@@ -78927,7 +79024,7 @@ function buildStartupInfo(opts) {
|
|
|
78927
79024
|
try {
|
|
78928
79025
|
const prompts = readdirSync6(promptsDir).filter((f) => f.endsWith(".md"));
|
|
78929
79026
|
for (const f of prompts) {
|
|
78930
|
-
promptsItems.push(`/${
|
|
79027
|
+
promptsItems.push(`/${basename6(f, ".md")}`);
|
|
78931
79028
|
}
|
|
78932
79029
|
} catch {
|
|
78933
79030
|
}
|
|
@@ -79583,11 +79680,11 @@ function isAgentVersionSupported(reportedVersion, minimumSupportedVersion) {
|
|
|
79583
79680
|
}
|
|
79584
79681
|
|
|
79585
79682
|
// src/engine/agent/discovery/executable-discovery.ts
|
|
79586
|
-
import { isAbsolute as
|
|
79683
|
+
import { isAbsolute as isAbsolute14 } from "node:path";
|
|
79587
79684
|
async function resolveSpecificationExecutables(executableName, overrideVariable2, resolveInstalled, context) {
|
|
79588
79685
|
const override = context.environment[overrideVariable2];
|
|
79589
79686
|
if (override !== void 0) {
|
|
79590
|
-
if (override.length === 0 || !
|
|
79687
|
+
if (override.length === 0 || !isAbsolute14(override)) {
|
|
79591
79688
|
return [];
|
|
79592
79689
|
}
|
|
79593
79690
|
const executable = await resolveExecutablePath(override, context.platform);
|
|
@@ -79858,8 +79955,8 @@ var AdapterRegistry = class {
|
|
|
79858
79955
|
#resolve;
|
|
79859
79956
|
#dependencies;
|
|
79860
79957
|
#adapters = /* @__PURE__ */ new Map();
|
|
79861
|
-
constructor(
|
|
79862
|
-
this.#resolve =
|
|
79958
|
+
constructor(resolve20, dependencies) {
|
|
79959
|
+
this.#resolve = resolve20;
|
|
79863
79960
|
this.#dependencies = dependencies;
|
|
79864
79961
|
}
|
|
79865
79962
|
resolve = (agent2) => {
|
|
@@ -79895,7 +79992,7 @@ async function runCleanup(...actions) {
|
|
|
79895
79992
|
var nativeSessionIdSchema = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,255}$/);
|
|
79896
79993
|
|
|
79897
79994
|
// src/engine/acp/adapter/execution-connections.ts
|
|
79898
|
-
import { isAbsolute as
|
|
79995
|
+
import { isAbsolute as isAbsolute15, resolve as resolve14 } from "node:path";
|
|
79899
79996
|
|
|
79900
79997
|
// src/engine/acp/client/prompt-content.ts
|
|
79901
79998
|
function validatePromptContent(options, capabilities) {
|
|
@@ -80642,7 +80739,7 @@ var AcpSessionConnector = class {
|
|
|
80642
80739
|
};
|
|
80643
80740
|
|
|
80644
80741
|
// src/engine/acp/adapter/execution-connections.ts
|
|
80645
|
-
var absolutePathSchema = external_exports.string().min(1).refine(
|
|
80742
|
+
var absolutePathSchema = external_exports.string().min(1).refine(isAbsolute15);
|
|
80646
80743
|
var nativeHistoryRevisionSchema = external_exports.object({ latestEntryId: external_exports.string().max(256) });
|
|
80647
80744
|
var isMethodNotFound = (cause) => cause instanceof RequestError && cause.code === -32601;
|
|
80648
80745
|
var targetSchema = external_exports.object({
|
|
@@ -80736,9 +80833,9 @@ var AcpExecutionConnections = class {
|
|
|
80736
80833
|
);
|
|
80737
80834
|
}
|
|
80738
80835
|
const matches = [...this.#sessions].filter(
|
|
80739
|
-
({ connection, scope }) => connection.events.sessionId() === decoded.data.nativeSessionId && scope.cwd === decoded.data.cwd && scope.cwd ===
|
|
80836
|
+
({ connection, scope }) => connection.events.sessionId() === decoded.data.nativeSessionId && scope.cwd === decoded.data.cwd && scope.cwd === resolve14(decoded.data.cwd) && arraysEqual(scope.additionalDirectories, decoded.data.additionalDirectories) && arraysEqual(
|
|
80740
80837
|
scope.additionalDirectories,
|
|
80741
|
-
decoded.data.additionalDirectories.map((path6) =>
|
|
80838
|
+
decoded.data.additionalDirectories.map((path6) => resolve14(path6))
|
|
80742
80839
|
)
|
|
80743
80840
|
);
|
|
80744
80841
|
if (matches.length > 1) {
|
|
@@ -82354,7 +82451,7 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
82354
82451
|
}
|
|
82355
82452
|
|
|
82356
82453
|
// src/engine/runtime/config.ts
|
|
82357
|
-
import { resolve as
|
|
82454
|
+
import { resolve as resolve15 } from "node:path";
|
|
82358
82455
|
|
|
82359
82456
|
// src/engine/util/serial-task-queue.ts
|
|
82360
82457
|
var SerialTaskQueue = class {
|
|
@@ -82431,7 +82528,7 @@ var RuntimeLocalContext = class {
|
|
|
82431
82528
|
stateDirectory;
|
|
82432
82529
|
maxAcpProcesses;
|
|
82433
82530
|
constructor(stateDirectory, agentLaunchEnvironment, maxAcpProcesses = 1e3) {
|
|
82434
|
-
this.stateDirectory =
|
|
82531
|
+
this.stateDirectory = resolve15(stateDirectory);
|
|
82435
82532
|
this.agentLaunchEnvironment = Object.freeze({ ...agentLaunchEnvironment });
|
|
82436
82533
|
this.maxAcpProcesses = maxAcpProcesses;
|
|
82437
82534
|
}
|
|
@@ -82586,7 +82683,7 @@ function validatePairingId(value) {
|
|
|
82586
82683
|
return value;
|
|
82587
82684
|
}
|
|
82588
82685
|
async function resolveDefaultWorkspace(path6) {
|
|
82589
|
-
const requestedWorkspace =
|
|
82686
|
+
const requestedWorkspace = resolve16(path6);
|
|
82590
82687
|
let defaultWorkspace;
|
|
82591
82688
|
try {
|
|
82592
82689
|
defaultWorkspace = await ensureCanonicalDirectory(requestedWorkspace);
|
|
@@ -82656,7 +82753,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, signal) {
|
|
|
82656
82753
|
agents,
|
|
82657
82754
|
machineName: hostname3(),
|
|
82658
82755
|
pairingCode: options.code,
|
|
82659
|
-
workspaceName:
|
|
82756
|
+
workspaceName: basename7(defaultWorkspace) || "Local workspace"
|
|
82660
82757
|
}),
|
|
82661
82758
|
dispatcher: environmentProxyDispatcher,
|
|
82662
82759
|
headers: { "content-type": "application/json" },
|
|
@@ -82764,7 +82861,7 @@ async function prepareRuntimeConnection(installation, connection, signal, enviro
|
|
|
82764
82861
|
}
|
|
82765
82862
|
|
|
82766
82863
|
// src/engine/runtime/runtime-loop.ts
|
|
82767
|
-
import { resolve as
|
|
82864
|
+
import { resolve as resolve18 } from "node:path";
|
|
82768
82865
|
|
|
82769
82866
|
// src/engine/runtime/run.ts
|
|
82770
82867
|
import { styleText } from "node:util";
|
|
@@ -88260,14 +88357,14 @@ function mergeTextChunk(previous, incoming) {
|
|
|
88260
88357
|
var SessionEventHistoryProjection = class {
|
|
88261
88358
|
#toolCallEventIds = /* @__PURE__ */ new Map();
|
|
88262
88359
|
#latestEvent = null;
|
|
88263
|
-
apply = (liveEvent2,
|
|
88360
|
+
apply = (liveEvent2, resolve20) => {
|
|
88264
88361
|
if (liveEvent2.type === "lifecycle-metadata") {
|
|
88265
88362
|
this.#latestEvent = null;
|
|
88266
88363
|
return { kind: "skip" };
|
|
88267
88364
|
}
|
|
88268
88365
|
if (liveEvent2.type === "acp" && liveEvent2.payload.sessionUpdate === "tool_call_update") {
|
|
88269
88366
|
const targetEventId = this.#toolCallEventIds.get(liveEvent2.payload.toolCallId);
|
|
88270
|
-
const current = targetEventId === void 0 ? void 0 :
|
|
88367
|
+
const current = targetEventId === void 0 ? void 0 : resolve20([targetEventId]).get(targetEventId);
|
|
88271
88368
|
if (current?.type === "acp" && (current.payload.sessionUpdate === "tool_call" || current.payload.sessionUpdate === "tool_call_update")) {
|
|
88272
88369
|
return this.#replace(
|
|
88273
88370
|
current,
|
|
@@ -88291,12 +88388,12 @@ var SessionEventHistoryProjection = class {
|
|
|
88291
88388
|
* The projected tool call announced with this identifier, in its current
|
|
88292
88389
|
* merged form, or `undefined` when the projection has not recorded one.
|
|
88293
88390
|
*/
|
|
88294
|
-
getToolCall = (toolCallId,
|
|
88391
|
+
getToolCall = (toolCallId, resolve20) => {
|
|
88295
88392
|
const eventId = this.#toolCallEventIds.get(toolCallId);
|
|
88296
88393
|
if (eventId === void 0) {
|
|
88297
88394
|
return void 0;
|
|
88298
88395
|
}
|
|
88299
|
-
const event =
|
|
88396
|
+
const event = resolve20([eventId]).get(eventId);
|
|
88300
88397
|
if (event?.type === "acp" && (event.payload.sessionUpdate === "tool_call" || event.payload.sessionUpdate === "tool_call_update")) {
|
|
88301
88398
|
return event.payload;
|
|
88302
88399
|
}
|
|
@@ -88356,8 +88453,8 @@ var SessionEvents = class {
|
|
|
88356
88453
|
this.sessionGenerationId = sessionGenerationId;
|
|
88357
88454
|
this.#projection = new SessionEventHistoryProjection();
|
|
88358
88455
|
}
|
|
88359
|
-
apply = (event,
|
|
88360
|
-
const projected = this.#projection.apply(event,
|
|
88456
|
+
apply = (event, resolve20) => {
|
|
88457
|
+
const projected = this.#projection.apply(event, resolve20);
|
|
88361
88458
|
this.#throughPosition = event.position;
|
|
88362
88459
|
if (projected.kind === "skip") {
|
|
88363
88460
|
return;
|
|
@@ -88384,7 +88481,7 @@ var SessionEvents = class {
|
|
|
88384
88481
|
return this.#cachedItemsByEventId.size;
|
|
88385
88482
|
}
|
|
88386
88483
|
/** The projected tool call for this identifier, materializing it if needed. */
|
|
88387
|
-
toolCall = (toolCallId,
|
|
88484
|
+
toolCall = (toolCallId, resolve20) => this.#projection.getToolCall(toolCallId, resolve20);
|
|
88388
88485
|
item = (eventId) => this.#cachedItemsByEventId.get(eventId)?.event;
|
|
88389
88486
|
/**
|
|
88390
88487
|
* Materializes an event that was previously dropped to the cache database.
|
|
@@ -92082,8 +92179,8 @@ var RuntimeTurnActivity = class {
|
|
|
92082
92179
|
#changed() {
|
|
92083
92180
|
this.#changedAt = Date.now();
|
|
92084
92181
|
if (this.count() === 0) {
|
|
92085
|
-
for (const
|
|
92086
|
-
|
|
92182
|
+
for (const resolve20 of this.#idleWaiters) {
|
|
92183
|
+
resolve20();
|
|
92087
92184
|
}
|
|
92088
92185
|
this.#idleWaiters.clear();
|
|
92089
92186
|
}
|
|
@@ -92093,14 +92190,14 @@ var RuntimeTurnActivity = class {
|
|
|
92093
92190
|
if (this.count() === 0) {
|
|
92094
92191
|
return Promise.resolve();
|
|
92095
92192
|
}
|
|
92096
|
-
return new Promise((
|
|
92193
|
+
return new Promise((resolve20, reject2) => {
|
|
92097
92194
|
const abort = () => {
|
|
92098
92195
|
this.#idleWaiters.delete(idle);
|
|
92099
92196
|
reject2(signal.reason);
|
|
92100
92197
|
};
|
|
92101
92198
|
const idle = () => {
|
|
92102
92199
|
signal.removeEventListener("abort", abort);
|
|
92103
|
-
|
|
92200
|
+
resolve20();
|
|
92104
92201
|
};
|
|
92105
92202
|
this.#idleWaiters.add(idle);
|
|
92106
92203
|
signal.addEventListener("abort", abort, { once: true });
|
|
@@ -92264,7 +92361,7 @@ var ActiveRuntimeTurn = class {
|
|
|
92264
92361
|
// src/engine/session/turn/session-execution.ts
|
|
92265
92362
|
var waitForTurnCompletion = (turn, waitSignal) => {
|
|
92266
92363
|
waitSignal.throwIfAborted();
|
|
92267
|
-
return new Promise((
|
|
92364
|
+
return new Promise((resolve20, reject2) => {
|
|
92268
92365
|
let settled = false;
|
|
92269
92366
|
const finish = (result) => {
|
|
92270
92367
|
if (settled) {
|
|
@@ -92273,7 +92370,7 @@ var waitForTurnCompletion = (turn, waitSignal) => {
|
|
|
92273
92370
|
settled = true;
|
|
92274
92371
|
waitSignal.removeEventListener("abort", onAbort);
|
|
92275
92372
|
if (result.kind === "completed") {
|
|
92276
|
-
|
|
92373
|
+
resolve20();
|
|
92277
92374
|
} else {
|
|
92278
92375
|
reject2(result.error);
|
|
92279
92376
|
}
|
|
@@ -92456,7 +92553,7 @@ var SessionTurns = class {
|
|
|
92456
92553
|
|
|
92457
92554
|
// src/engine/session/workspace/workspace-directory.ts
|
|
92458
92555
|
import { homedir as homedir3 } from "node:os";
|
|
92459
|
-
import { basename as
|
|
92556
|
+
import { basename as basename8, dirname as dirname10, isAbsolute as isAbsolute16, join as join27, normalize as normalize2, relative as relative3 } from "node:path";
|
|
92460
92557
|
|
|
92461
92558
|
// src/engine/session/workspace/local-authorization-error.ts
|
|
92462
92559
|
var LocalAuthorizationError = class extends OperationError {
|
|
@@ -92522,7 +92619,7 @@ var WorkspaceDirectoryService = class {
|
|
|
92522
92619
|
}
|
|
92523
92620
|
if (id.startsWith("path-")) {
|
|
92524
92621
|
const path6 = expandCurrentUserHome(decodePath(id, "path-"));
|
|
92525
|
-
if (
|
|
92622
|
+
if (isAbsolute16(path6)) {
|
|
92526
92623
|
return path6;
|
|
92527
92624
|
}
|
|
92528
92625
|
}
|
|
@@ -92530,7 +92627,7 @@ var WorkspaceDirectoryService = class {
|
|
|
92530
92627
|
};
|
|
92531
92628
|
resolvePath = async (requested, signal) => {
|
|
92532
92629
|
signal.throwIfAborted();
|
|
92533
|
-
if (!
|
|
92630
|
+
if (!isAbsolute16(requested) || requested.includes("\0") || normalize2(requested) !== requested) {
|
|
92534
92631
|
throw new LocalAuthorizationError("The local directory path is invalid");
|
|
92535
92632
|
}
|
|
92536
92633
|
try {
|
|
@@ -92538,7 +92635,7 @@ var WorkspaceDirectoryService = class {
|
|
|
92538
92635
|
signal.throwIfAborted();
|
|
92539
92636
|
const metadata = await readPathMetadata(target);
|
|
92540
92637
|
signal.throwIfAborted();
|
|
92541
|
-
if (!
|
|
92638
|
+
if (!isAbsolute16(target) || normalize2(target) !== target || metadata.kind !== "directory") {
|
|
92542
92639
|
throw new LocalAuthorizationError("The selected location is not a directory");
|
|
92543
92640
|
}
|
|
92544
92641
|
return target;
|
|
@@ -92553,8 +92650,8 @@ var WorkspaceDirectoryService = class {
|
|
|
92553
92650
|
}
|
|
92554
92651
|
};
|
|
92555
92652
|
label = (path6) => {
|
|
92556
|
-
const suffix =
|
|
92557
|
-
return suffix === "" ? "~" : !
|
|
92653
|
+
const suffix = relative3(homedir3(), path6);
|
|
92654
|
+
return suffix === "" ? "~" : !isAbsolute16(suffix) && suffix !== ".." && !suffix.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) ? `~/${suffix.replaceAll("\\", "/")}` : path6;
|
|
92558
92655
|
};
|
|
92559
92656
|
identify = async (bindingId, requestedPath2, signal) => {
|
|
92560
92657
|
this.authorizeMachine(bindingId);
|
|
@@ -92562,7 +92659,7 @@ var WorkspaceDirectoryService = class {
|
|
|
92562
92659
|
return {
|
|
92563
92660
|
path: path6,
|
|
92564
92661
|
directoryId: encodePath(path6),
|
|
92565
|
-
name:
|
|
92662
|
+
name: basename8(path6) || path6,
|
|
92566
92663
|
label: this.label(path6)
|
|
92567
92664
|
};
|
|
92568
92665
|
};
|
|
@@ -92575,7 +92672,7 @@ var WorkspaceDirectoryService = class {
|
|
|
92575
92672
|
this.authorizeMachine(bindingId);
|
|
92576
92673
|
return {
|
|
92577
92674
|
directoryId: encodePath(recordedPath),
|
|
92578
|
-
name:
|
|
92675
|
+
name: basename8(recordedPath) || recordedPath,
|
|
92579
92676
|
label: this.label(recordedPath)
|
|
92580
92677
|
};
|
|
92581
92678
|
};
|
|
@@ -94438,7 +94535,7 @@ function createContentWriteCommands(context) {
|
|
|
94438
94535
|
import { WebSocket as WebSocket5 } from "undici";
|
|
94439
94536
|
|
|
94440
94537
|
// src/engine/session/content/session-files.ts
|
|
94441
|
-
import { basename as
|
|
94538
|
+
import { basename as basename9, extname as extname3, isAbsolute as isAbsolute17, join as join31, normalize as normalize3, resolve as resolve17 } from "node:path";
|
|
94442
94539
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
94443
94540
|
function requestedPath(value) {
|
|
94444
94541
|
if (value.includes("\0")) {
|
|
@@ -94456,21 +94553,21 @@ function requestedPath(value) {
|
|
|
94456
94553
|
}
|
|
94457
94554
|
async function resolveFile(value, workingDirectory, signal) {
|
|
94458
94555
|
const requested = requestedPath(value);
|
|
94459
|
-
if (requested === null || !
|
|
94556
|
+
if (requested === null || !isAbsolute17(requested.path) && workingDirectory === null) {
|
|
94460
94557
|
return null;
|
|
94461
94558
|
}
|
|
94462
|
-
if (
|
|
94559
|
+
if (isAbsolute17(requested.path) && normalize3(requested.path) !== requested.path) {
|
|
94463
94560
|
return null;
|
|
94464
94561
|
}
|
|
94465
|
-
const candidates = requested.explicitUrl || workingDirectory === null ? [requested.path] :
|
|
94562
|
+
const candidates = requested.explicitUrl || workingDirectory === null ? [requested.path] : isAbsolute17(requested.path) ? [join31(workingDirectory, requested.path), requested.path] : [resolve17(workingDirectory, requested.path)];
|
|
94466
94563
|
for (const candidate of candidates) {
|
|
94467
|
-
if (!
|
|
94564
|
+
if (!isAbsolute17(candidate) || normalize3(candidate) !== candidate) {
|
|
94468
94565
|
continue;
|
|
94469
94566
|
}
|
|
94470
94567
|
try {
|
|
94471
94568
|
const target = await canonicalPath(candidate);
|
|
94472
94569
|
signal.throwIfAborted();
|
|
94473
|
-
if (
|
|
94570
|
+
if (isAbsolute17(target) && normalize3(target) === target) {
|
|
94474
94571
|
return target;
|
|
94475
94572
|
}
|
|
94476
94573
|
} catch {
|
|
@@ -94480,6 +94577,10 @@ async function resolveFile(value, workingDirectory, signal) {
|
|
|
94480
94577
|
return null;
|
|
94481
94578
|
}
|
|
94482
94579
|
async function streamLocalFile(command, send2, sendChunk, signal, workingDirectory, externalContent) {
|
|
94580
|
+
if (command.kind === SCOPED_FILE_READ_KIND) {
|
|
94581
|
+
await streamScopedFile(command, send2, sendChunk, signal, workingDirectory);
|
|
94582
|
+
return;
|
|
94583
|
+
}
|
|
94483
94584
|
const external = await externalContent.resolve(command.sessionId, command.path, signal);
|
|
94484
94585
|
const target = external?.path ?? await resolveFile(command.path, workingDirectory, signal);
|
|
94485
94586
|
if (target === null) {
|
|
@@ -94496,7 +94597,7 @@ async function streamLocalFile(command, send2, sendChunk, signal, workingDirecto
|
|
|
94496
94597
|
kind: FILE_BEGIN_KIND,
|
|
94497
94598
|
mediaType: external?.mediaType ?? raster?.mimeType ?? (extname3(target).toLowerCase() === ".svg" ? "image/svg+xml" : "application/octet-stream"),
|
|
94498
94599
|
modifiedAt: before.modifiedAt.toISOString(),
|
|
94499
|
-
name: external?.name ?? (
|
|
94600
|
+
name: external?.name ?? (basename9(target) || "file"),
|
|
94500
94601
|
requestId: command.requestId,
|
|
94501
94602
|
sessionId: command.sessionId
|
|
94502
94603
|
});
|
|
@@ -94516,12 +94617,43 @@ async function streamLocalFile(command, send2, sendChunk, signal, workingDirecto
|
|
|
94516
94617
|
sessionId: command.sessionId
|
|
94517
94618
|
});
|
|
94518
94619
|
}
|
|
94620
|
+
async function streamScopedFile(command, send2, sendChunk, signal, workingDirectory) {
|
|
94621
|
+
const requested = requestedPath(command.path);
|
|
94622
|
+
if (workingDirectory === null || requested === null) {
|
|
94623
|
+
throw new ScopedFileReadError("file_outside_scope");
|
|
94624
|
+
}
|
|
94625
|
+
await withScopedLocalFile(workingDirectory, requested.path, command.maxBytes, signal, async (file2) => {
|
|
94626
|
+
const header = await file2.readPrefix(16);
|
|
94627
|
+
signal.throwIfAborted();
|
|
94628
|
+
send2({
|
|
94629
|
+
byteLength: file2.size,
|
|
94630
|
+
kind: FILE_BEGIN_KIND,
|
|
94631
|
+
mediaType: sniffRasterMime(header) ?? "application/octet-stream",
|
|
94632
|
+
modifiedAt: file2.modifiedAt.toISOString(),
|
|
94633
|
+
name: file2.name,
|
|
94634
|
+
requestId: command.requestId,
|
|
94635
|
+
sessionId: command.sessionId
|
|
94636
|
+
});
|
|
94637
|
+
let sequence = 0;
|
|
94638
|
+
let received = 0;
|
|
94639
|
+
for await (const bytes of file2.chunks(CONTENT_CHUNK_MAX_BYTES)) {
|
|
94640
|
+
received += bytes.byteLength;
|
|
94641
|
+
sendChunk(command.requestId, sequence, bytes);
|
|
94642
|
+
sequence += 1;
|
|
94643
|
+
}
|
|
94644
|
+
if (received !== file2.size) {
|
|
94645
|
+
throw new ScopedFileReadError("file_unavailable");
|
|
94646
|
+
}
|
|
94647
|
+
await file2.verifyUnchanged();
|
|
94648
|
+
send2({ kind: FILE_END_KIND, requestId: command.requestId, sessionId: command.sessionId });
|
|
94649
|
+
});
|
|
94650
|
+
}
|
|
94519
94651
|
|
|
94520
94652
|
// src/engine/runtime/command/registry/file-read/index.ts
|
|
94521
94653
|
var fileReadCommand = {
|
|
94522
94654
|
kind: FILE_READ_KIND,
|
|
94523
94655
|
handle: ({ externalContent, sessions, signal, socket }, message) => {
|
|
94524
|
-
if (message.kind !== FILE_READ_KIND) {
|
|
94656
|
+
if (message.kind !== FILE_READ_KIND && message.kind !== SCOPED_FILE_READ_KIND) {
|
|
94525
94657
|
throw new Error("Command kind mismatch");
|
|
94526
94658
|
}
|
|
94527
94659
|
void streamLocalFile(
|
|
@@ -94536,15 +94668,16 @@ var fileReadCommand = {
|
|
|
94536
94668
|
return;
|
|
94537
94669
|
}
|
|
94538
94670
|
send(socket, {
|
|
94539
|
-
code: "file_unavailable",
|
|
94671
|
+
code: error62 instanceof ScopedFileReadError ? error62.code : "file_unavailable",
|
|
94540
94672
|
kind: FILE_FAILED_KIND,
|
|
94541
|
-
message: error62 instanceof Error ? error62.message : "The local file is unavailable",
|
|
94673
|
+
message: message.kind === FILE_READ_KIND && error62 instanceof Error ? error62.message : "The local file is unavailable",
|
|
94542
94674
|
requestId: message.requestId,
|
|
94543
94675
|
sessionId: message.sessionId
|
|
94544
94676
|
});
|
|
94545
94677
|
});
|
|
94546
94678
|
}
|
|
94547
94679
|
};
|
|
94680
|
+
var scopedFileReadCommand = { ...fileReadCommand, kind: SCOPED_FILE_READ_KIND };
|
|
94548
94681
|
|
|
94549
94682
|
// src/engine/runtime/command/registry/history.ts
|
|
94550
94683
|
var sessionHistoryPageLoadCommand = {
|
|
@@ -94847,7 +94980,7 @@ function createNativeSessionCommands(context) {
|
|
|
94847
94980
|
}
|
|
94848
94981
|
|
|
94849
94982
|
// src/engine/session/workspace/resolve-session-directories.ts
|
|
94850
|
-
import { basename as
|
|
94983
|
+
import { basename as basename10 } from "node:path";
|
|
94851
94984
|
var ResolvedSessionDirectories = class {
|
|
94852
94985
|
additionalDirectories;
|
|
94853
94986
|
additionalDirectoryEntries;
|
|
@@ -94875,7 +95008,7 @@ async function resolveSessionDirectories(directories, bindingId, directoryId, ad
|
|
|
94875
95008
|
additionalDirectories.push(directory);
|
|
94876
95009
|
additionalDirectoryEntries.push({
|
|
94877
95010
|
directoryId: additionalDirectoryId,
|
|
94878
|
-
name:
|
|
95011
|
+
name: basename10(directory)
|
|
94879
95012
|
});
|
|
94880
95013
|
}
|
|
94881
95014
|
return new ResolvedSessionDirectories(cwd, selection.label, additionalDirectories, additionalDirectoryEntries);
|
|
@@ -95390,7 +95523,11 @@ var runtimePingCommand = {
|
|
|
95390
95523
|
if (message.kind !== RUNTIME_PING_KIND) {
|
|
95391
95524
|
throw new Error("Command kind mismatch");
|
|
95392
95525
|
}
|
|
95393
|
-
send(socket, {
|
|
95526
|
+
send(socket, {
|
|
95527
|
+
kind: RUNTIME_PONG_KIND,
|
|
95528
|
+
requestId: message.requestId,
|
|
95529
|
+
scopedFileRead: supportsScopedLocalFileRead()
|
|
95530
|
+
});
|
|
95394
95531
|
}
|
|
95395
95532
|
};
|
|
95396
95533
|
|
|
@@ -95788,6 +95925,7 @@ function createCommandRegistry(context) {
|
|
|
95788
95925
|
...createAgentSettingsCommands(context),
|
|
95789
95926
|
...contentWrites.commands,
|
|
95790
95927
|
fileReadCommand,
|
|
95928
|
+
scopedFileReadCommand,
|
|
95791
95929
|
sessionCancelBeforeStartCommand,
|
|
95792
95930
|
sessionCancelCommand,
|
|
95793
95931
|
sessionCloseCommand,
|
|
@@ -95854,7 +95992,7 @@ var RelayConnectionError = class extends Error {
|
|
|
95854
95992
|
};
|
|
95855
95993
|
function connectRelay(url2, signal, transportFailed = () => void 0) {
|
|
95856
95994
|
signal.throwIfAborted();
|
|
95857
|
-
return new Promise((
|
|
95995
|
+
return new Promise((resolve20, reject2) => {
|
|
95858
95996
|
let releaseTransport = () => void 0;
|
|
95859
95997
|
let removeTransportObserver = () => void 0;
|
|
95860
95998
|
let released = false;
|
|
@@ -95978,7 +96116,7 @@ function connectRelay(url2, signal, transportFailed = () => void 0) {
|
|
|
95978
96116
|
}
|
|
95979
96117
|
finished = true;
|
|
95980
96118
|
cleanup();
|
|
95981
|
-
|
|
96119
|
+
resolve20({ release: release2, socket });
|
|
95982
96120
|
};
|
|
95983
96121
|
function onTimeout() {
|
|
95984
96122
|
fail(
|
|
@@ -96157,7 +96295,7 @@ async function runRelayConnection({
|
|
|
96157
96295
|
}
|
|
96158
96296
|
});
|
|
96159
96297
|
try {
|
|
96160
|
-
await new Promise((
|
|
96298
|
+
await new Promise((resolve20, reject2) => {
|
|
96161
96299
|
let finished = false;
|
|
96162
96300
|
let ready = false;
|
|
96163
96301
|
const cleanup = () => {
|
|
@@ -96175,7 +96313,7 @@ async function runRelayConnection({
|
|
|
96175
96313
|
}
|
|
96176
96314
|
finished = true;
|
|
96177
96315
|
cleanup();
|
|
96178
|
-
|
|
96316
|
+
resolve20();
|
|
96179
96317
|
};
|
|
96180
96318
|
const rejectConnection = (failure2) => {
|
|
96181
96319
|
if (finished) {
|
|
@@ -96511,12 +96649,12 @@ function waitForRelayRetry(signal, timer) {
|
|
|
96511
96649
|
if (signal.aborted) {
|
|
96512
96650
|
return Promise.resolve();
|
|
96513
96651
|
}
|
|
96514
|
-
return new Promise((
|
|
96652
|
+
return new Promise((resolve20) => {
|
|
96515
96653
|
const retry = timer.schedule(finish, RELAY_RECONNECT_DELAY_MILLISECONDS);
|
|
96516
96654
|
function finish() {
|
|
96517
96655
|
retry.cancel();
|
|
96518
96656
|
signal.removeEventListener("abort", finish);
|
|
96519
|
-
|
|
96657
|
+
resolve20();
|
|
96520
96658
|
}
|
|
96521
96659
|
signal.addEventListener("abort", finish, { once: true });
|
|
96522
96660
|
});
|
|
@@ -96738,7 +96876,7 @@ function relayUrlFromConnection(connection) {
|
|
|
96738
96876
|
return relayUrl;
|
|
96739
96877
|
}
|
|
96740
96878
|
async function resolveWorkspace(path6) {
|
|
96741
|
-
const requested =
|
|
96879
|
+
const requested = resolve18(path6);
|
|
96742
96880
|
let resolved;
|
|
96743
96881
|
try {
|
|
96744
96882
|
resolved = await ensureCanonicalDirectory(requested);
|
|
@@ -96837,7 +96975,7 @@ var MobiusRuntimeEngine = class {
|
|
|
96837
96975
|
#connections;
|
|
96838
96976
|
#installation = { kind: "uninitialized" };
|
|
96839
96977
|
constructor(params) {
|
|
96840
|
-
this.#engineDataDir =
|
|
96978
|
+
this.#engineDataDir = resolve19(params.engineDataDir);
|
|
96841
96979
|
this.#agentLaunchEnvironment = Object.freeze({ ...params.agentLaunchEnvironment });
|
|
96842
96980
|
this.#maxAcpProcesses = params.maxAcpProcesses ?? 1e3;
|
|
96843
96981
|
this.#connections = new ConnectionManager(this.#ensureInstallation);
|
|
@@ -96958,4 +97096,4 @@ export {
|
|
|
96958
97096
|
* MIT Licensed
|
|
96959
97097
|
*)
|
|
96960
97098
|
*/
|
|
96961
|
-
//# sourceMappingURL=chunk-
|
|
97099
|
+
//# sourceMappingURL=chunk-VJM4WQG4.js.map
|