@moxt-ai/mobius 0.0.439 → 0.0.441
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-J2RRCJX6.js → chunk-H5UFPY6F.js} +2 -2
- package/dist/{chunk-J2RRCJX6.js.map → chunk-H5UFPY6F.js.map} +1 -1
- package/dist/{chunk-FDHUTFPW.js → chunk-WFQZ4ALO.js} +787 -390
- package/dist/{chunk-FDHUTFPW.js.map → chunk-WFQZ4ALO.js.map} +4 -4
- package/dist/{cli-2UKL4IVX.js → cli-A2WWY7SU.js} +3 -3
- package/dist/cli.js +2 -2
- package/dist/engine/runtime/catalog/handle-agent-catalog-discovery.d.ts +1 -0
- package/dist/engine/runtime/catalog/handle-agent-catalog-discovery.d.ts.map +1 -1
- package/dist/engine/runtime/catalog/handle-agent-catalog-discovery.js +2 -1
- package/dist/engine/runtime/catalog/handle-agent-catalog-discovery.js.map +1 -1
- package/dist/engine/runtime/command/agent-settings-discovery.d.ts +2 -0
- package/dist/engine/runtime/command/agent-settings-discovery.d.ts.map +1 -1
- package/dist/engine/runtime/command/agent-settings-discovery.js +6 -3
- package/dist/engine/runtime/command/agent-settings-discovery.js.map +1 -1
- package/dist/engine/runtime/command/context.d.ts +2 -0
- package/dist/engine/runtime/command/context.d.ts.map +1 -1
- package/dist/engine/runtime/command/registry/agent-catalog.d.ts.map +1 -1
- package/dist/engine/runtime/command/registry/agent-catalog.js +1 -0
- package/dist/engine/runtime/command/registry/agent-catalog.js.map +1 -1
- package/dist/engine/runtime/command/registry/agent-settings.d.ts.map +1 -1
- package/dist/engine/runtime/command/registry/agent-settings.js +1 -0
- package/dist/engine/runtime/command/registry/agent-settings.js.map +1 -1
- 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/runtime/relay/run-relay-connection.d.ts +3 -1
- package/dist/engine/runtime/relay/run-relay-connection.d.ts.map +1 -1
- package/dist/engine/runtime/relay/run-relay-connection.js +2 -1
- package/dist/engine/runtime/relay/run-relay-connection.js.map +1 -1
- package/dist/engine/runtime/run.d.ts.map +1 -1
- package/dist/engine/runtime/run.js +3 -0
- package/dist/engine/runtime/run.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/session/manager/session-manager.d.ts +2 -6
- package/dist/engine/session/manager/session-manager.d.ts.map +1 -1
- package/dist/engine/session/manager/session-manager.js +68 -28
- package/dist/engine/session/manager/session-manager.js.map +1 -1
- package/dist/engine/session/settings/agent-settings-cache.d.ts +19 -0
- package/dist/engine/session/settings/agent-settings-cache.d.ts.map +1 -0
- package/dist/engine/session/settings/agent-settings-cache.js +167 -0
- package/dist/engine/session/settings/agent-settings-cache.js.map +1 -0
- package/dist/engine/session/settings/discover-agent-settings.d.ts +2 -1
- package/dist/engine/session/settings/discover-agent-settings.d.ts.map +1 -1
- package/dist/engine/session/settings/discover-agent-settings.js +121 -95
- package/dist/engine/session/settings/discover-agent-settings.js.map +1 -1
- package/dist/engine/storage/files/local-files.d.ts +19 -0
- package/dist/engine/storage/files/local-files.d.ts.map +1 -1
- package/dist/engine/storage/files/local-files.js +94 -2
- package/dist/engine/storage/files/local-files.js.map +1 -1
- package/dist/engine/storage/installation/installation-files.d.ts +1 -1
- package/dist/engine/storage/installation/installation-files.d.ts.map +1 -1
- package/dist/engine/storage/installation/installation-files.js +2 -2
- package/dist/engine/storage/installation/installation-files.js.map +1 -1
- package/dist/engine.js +2 -2
- package/package.json +2 -2
- /package/dist/{cli-2UKL4IVX.js.map → cli-A2WWY7SU.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-H5UFPY6F.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)));
|
|
@@ -20291,6 +20296,7 @@ var sessionConfigUpdatedEventSchema = external_exports.object({
|
|
|
20291
20296
|
sessionId: identifierStringSchema
|
|
20292
20297
|
}).readonly();
|
|
20293
20298
|
var decodeSessionConfigurationSelections = (value) => decodeZodValue(value, sessionConfigurationSelectionsSchema);
|
|
20299
|
+
var decodeSessionConfigOptions = (value) => decodeZodValue(value, sessionConfigOptionsSchema);
|
|
20294
20300
|
var decodeSessionConfigureCommand = (encoded) => decodeZodMessage(encoded, sessionConfigureCommandSchema);
|
|
20295
20301
|
var encodeSessionConfigureCommand = (message) => encodeZodMessage(message, sessionConfigureCommandSchema);
|
|
20296
20302
|
var decodeSessionConfigUpdatedEvent = (encoded) => decodeZodMessage(encoded, sessionConfigUpdatedEventSchema);
|
|
@@ -20989,6 +20995,7 @@ var decodeKnownNativeSessionEvents = (value) => decode3(sanitizeConsumableNative
|
|
|
20989
20995
|
|
|
20990
20996
|
// ../mobius-sdk/src/protocol/session/files/index.ts
|
|
20991
20997
|
var FILE_READ_KIND = "file.read";
|
|
20998
|
+
var SCOPED_FILE_READ_KIND = "file.read.scoped";
|
|
20992
20999
|
var FILE_BEGIN_KIND = "file.begin";
|
|
20993
21000
|
var FILE_END_KIND = "file.end";
|
|
20994
21001
|
var FILE_FAILED_KIND = "file.failed";
|
|
@@ -21001,15 +21008,16 @@ var CONTENT_WRITE_MAX_BYTES = 32 * 1024 * 1024;
|
|
|
21001
21008
|
var PROMPT_IMAGE_MAX_BYTES = 5e6;
|
|
21002
21009
|
var CONTENT_CHUNK_MAGIC = new Uint8Array([77, 66, 67, 49]);
|
|
21003
21010
|
var CONTENT_CHUNK_HEADER_BYTES = CONTENT_CHUNK_MAGIC.byteLength + 1 + 4;
|
|
21004
|
-
var
|
|
21005
|
-
kind: external_exports.literal(FILE_READ_KIND),
|
|
21011
|
+
var fileReadFields = external_exports.object({
|
|
21006
21012
|
maxBytes: external_exports.number().int().positive().max(128 * 1024 * 1024),
|
|
21007
21013
|
requestId: identifierStringSchema,
|
|
21008
21014
|
sessionId: identifierStringSchema,
|
|
21009
21015
|
path: external_exports.string().min(1).max(4096)
|
|
21010
|
-
})
|
|
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();
|
|
21011
21019
|
var fileBeginEventSchema = external_exports.object({
|
|
21012
|
-
byteLength: external_exports.number().int().
|
|
21020
|
+
byteLength: external_exports.number().int().nonnegative().max(128 * 1024 * 1024),
|
|
21013
21021
|
kind: external_exports.literal(FILE_BEGIN_KIND),
|
|
21014
21022
|
mediaType: external_exports.string().min(1).max(255),
|
|
21015
21023
|
modifiedAt: external_exports.iso.datetime({ offset: true }),
|
|
@@ -21111,6 +21119,8 @@ var fileFailedEventSchema = external_exports.object({
|
|
|
21111
21119
|
}).readonly();
|
|
21112
21120
|
var decodeFileReadCommand = (encoded) => decodeZodMessage(encoded, fileReadCommandSchema);
|
|
21113
21121
|
var encodeFileReadCommand = (message) => encodeZodMessage(message, fileReadCommandSchema);
|
|
21122
|
+
var decodeScopedFileReadCommand = (encoded) => decodeZodMessage(encoded, scopedFileReadCommandSchema);
|
|
21123
|
+
var encodeScopedFileReadCommand = (message) => encodeZodMessage(message, scopedFileReadCommandSchema);
|
|
21114
21124
|
var decodeFileBeginEvent = (encoded) => decodeZodMessage(encoded, fileBeginEventSchema);
|
|
21115
21125
|
var encodeFileBeginEvent = (message) => encodeZodMessage(message, fileBeginEventSchema);
|
|
21116
21126
|
var decodeFileEndEvent = (encoded) => decodeZodMessage(encoded, fileEndEventSchema);
|
|
@@ -21808,6 +21818,11 @@ var serviceToDaemonSignatures = {
|
|
|
21808
21818
|
decodeAgentCatalogDiscoverCommand
|
|
21809
21819
|
),
|
|
21810
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
|
+
),
|
|
21811
21826
|
[CONTENT_WRITE_KIND]: defineMessageSignature(
|
|
21812
21827
|
CONTENT_WRITE_KIND,
|
|
21813
21828
|
encodeContentWriteCommand,
|
|
@@ -22072,8 +22087,12 @@ function encodeDaemonToServiceMessage(message) {
|
|
|
22072
22087
|
}
|
|
22073
22088
|
|
|
22074
22089
|
// src/engine/storage/files/local-files.ts
|
|
22075
|
-
import {
|
|
22076
|
-
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";
|
|
22093
|
+
import { tmpdir } from "node:os";
|
|
22094
|
+
import { basename, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
22095
|
+
import { promisify } from "node:util";
|
|
22077
22096
|
function entryKind(entry) {
|
|
22078
22097
|
if (entry.isDirectory()) {
|
|
22079
22098
|
return "directory";
|
|
@@ -22108,6 +22127,10 @@ async function listDirectory(path6) {
|
|
|
22108
22127
|
const entries = await readdir(path6, { withFileTypes: true });
|
|
22109
22128
|
return entries.map((entry) => ({ kind: entryKind(entry), name: entry.name }));
|
|
22110
22129
|
}
|
|
22130
|
+
async function createTemporaryDirectory(prefix) {
|
|
22131
|
+
const path6 = await mkdtemp(join(tmpdir(), prefix));
|
|
22132
|
+
return { path: path6, dispose: async () => await rm(path6, { recursive: true, force: true }) };
|
|
22133
|
+
}
|
|
22111
22134
|
async function ensurePrivateDirectory(path6) {
|
|
22112
22135
|
await mkdir(path6, { mode: 448, recursive: true });
|
|
22113
22136
|
}
|
|
@@ -22132,11 +22155,92 @@ async function readFileBytes(path6) {
|
|
|
22132
22155
|
function readFileChunks(path6, chunkBytes, signal) {
|
|
22133
22156
|
return createReadStream(path6, { highWaterMark: chunkBytes, signal });
|
|
22134
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
|
+
}
|
|
22135
22239
|
|
|
22136
22240
|
// src/engine/storage/installation/installation-files.ts
|
|
22137
22241
|
import { createHash, randomUUID } from "node:crypto";
|
|
22138
|
-
import { link, mkdir as mkdir2, open as open3, readdir as readdir2, rename, rm, unlink, writeFile } from "node:fs/promises";
|
|
22139
|
-
import { dirname, join } from "node:path";
|
|
22242
|
+
import { link, mkdir as mkdir2, open as open3, readdir as readdir2, rename, rm as rm2, unlink, writeFile } from "node:fs/promises";
|
|
22243
|
+
import { dirname, join as join2 } from "node:path";
|
|
22140
22244
|
|
|
22141
22245
|
// src/engine/util/node-error.ts
|
|
22142
22246
|
function isNodeError(error62, code) {
|
|
@@ -22146,22 +22250,22 @@ function isNodeError(error62, code) {
|
|
|
22146
22250
|
// src/engine/storage/installation/installation-files.ts
|
|
22147
22251
|
var MAXIMUM_FILE_BYTES = 16 * 1024;
|
|
22148
22252
|
function installationPointerPath(engineDataDir) {
|
|
22149
|
-
return
|
|
22253
|
+
return join2(engineDataDir, "current.json");
|
|
22150
22254
|
}
|
|
22151
22255
|
var installationDirectorySchema = external_exports.string().brand();
|
|
22152
22256
|
function installationDirectory(engineDataDir, installationId2) {
|
|
22153
|
-
return installationDirectorySchema.parse(
|
|
22257
|
+
return installationDirectorySchema.parse(join2(engineDataDir, installationId2));
|
|
22154
22258
|
}
|
|
22155
22259
|
function connectionDirectory(installationDirectory2) {
|
|
22156
|
-
return
|
|
22260
|
+
return join2(installationDirectory2, "connections");
|
|
22157
22261
|
}
|
|
22158
22262
|
function connectionFilePath(connectionDirectory2, connectionId2) {
|
|
22159
|
-
return
|
|
22263
|
+
return join2(connectionDirectory2, `${connectionId2}.json`);
|
|
22160
22264
|
}
|
|
22161
22265
|
function channelIndexFilePath(installationDirectory2, channelId) {
|
|
22162
|
-
return
|
|
22266
|
+
return join2(installationDirectory2, "channels", `mci_${createHash("sha256").update(channelId).digest("hex")}.json`);
|
|
22163
22267
|
}
|
|
22164
|
-
async function readInstallationFile(path6) {
|
|
22268
|
+
async function readInstallationFile(path6, maximumBytes = MAXIMUM_FILE_BYTES) {
|
|
22165
22269
|
let handle;
|
|
22166
22270
|
try {
|
|
22167
22271
|
handle = await open3(path6, "r");
|
|
@@ -22170,7 +22274,7 @@ async function readInstallationFile(path6) {
|
|
|
22170
22274
|
}
|
|
22171
22275
|
try {
|
|
22172
22276
|
const metadata = await handle.stat();
|
|
22173
|
-
if (!metadata.isFile() || metadata.size >
|
|
22277
|
+
if (!metadata.isFile() || metadata.size > maximumBytes) {
|
|
22174
22278
|
return { kind: "not-a-small-file" };
|
|
22175
22279
|
}
|
|
22176
22280
|
return { kind: "read", text: await handle.readFile({ encoding: "utf8" }) };
|
|
@@ -22181,7 +22285,7 @@ async function readInstallationFile(path6) {
|
|
|
22181
22285
|
async function writeInstallationFile(path6, text2, signal) {
|
|
22182
22286
|
signal.throwIfAborted();
|
|
22183
22287
|
const directory = dirname(path6);
|
|
22184
|
-
const temporaryPath =
|
|
22288
|
+
const temporaryPath = join2(directory, `.${randomUUID()}.tmp`);
|
|
22185
22289
|
try {
|
|
22186
22290
|
await mkdir2(directory, { mode: 448, recursive: true });
|
|
22187
22291
|
signal.throwIfAborted();
|
|
@@ -22194,12 +22298,12 @@ async function writeInstallationFile(path6, text2, signal) {
|
|
|
22194
22298
|
}
|
|
22195
22299
|
}
|
|
22196
22300
|
async function createInstallationFile(path6, text2) {
|
|
22197
|
-
const temporaryPath =
|
|
22301
|
+
const temporaryPath = join2(dirname(path6), `.${randomUUID()}.tmp`);
|
|
22198
22302
|
try {
|
|
22199
22303
|
await writeFile(temporaryPath, text2, { flag: "wx", mode: 384 });
|
|
22200
22304
|
await link(temporaryPath, path6);
|
|
22201
22305
|
} finally {
|
|
22202
|
-
await
|
|
22306
|
+
await rm2(temporaryPath, { force: true });
|
|
22203
22307
|
}
|
|
22204
22308
|
}
|
|
22205
22309
|
async function listInstallationFiles(directory) {
|
|
@@ -22213,12 +22317,12 @@ async function removeInstallationFile(path6) {
|
|
|
22213
22317
|
import { lstat as lstat2 } from "node:fs/promises";
|
|
22214
22318
|
|
|
22215
22319
|
// src/engine/util/platform/linux.ts
|
|
22216
|
-
import { isAbsolute, join as
|
|
22320
|
+
import { isAbsolute as isAbsolute2, join as join4 } from "node:path";
|
|
22217
22321
|
|
|
22218
22322
|
// src/engine/util/platform/posix.ts
|
|
22219
22323
|
import { chmod, lstat, unlink as unlink2 } from "node:fs/promises";
|
|
22220
|
-
import { tmpdir } from "node:os";
|
|
22221
|
-
import { join as
|
|
22324
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
22325
|
+
import { join as join3 } from "node:path";
|
|
22222
22326
|
|
|
22223
22327
|
// src/engine/util/filesystem/path-error.ts
|
|
22224
22328
|
var LocalPathError = class extends Error {
|
|
@@ -22240,7 +22344,7 @@ async function removeControlSocket(path6) {
|
|
|
22240
22344
|
}
|
|
22241
22345
|
}
|
|
22242
22346
|
var posixOperations = {
|
|
22243
|
-
controlSocketPath: (installationHash) =>
|
|
22347
|
+
controlSocketPath: (installationHash) => join3(tmpdir2(), `mobius-${installationHash}.sock`),
|
|
22244
22348
|
prepareControlSocket: removeControlSocket,
|
|
22245
22349
|
secureControlSocket: async (path6) => {
|
|
22246
22350
|
await chmod(path6, 384);
|
|
@@ -22264,16 +22368,16 @@ var linuxPlatform = {
|
|
|
22264
22368
|
...posixOperations,
|
|
22265
22369
|
claudeCodeExecutablePaths: (environment) => {
|
|
22266
22370
|
const homeDirectory = environment["HOME"];
|
|
22267
|
-
return homeDirectory !== void 0 &&
|
|
22371
|
+
return homeDirectory !== void 0 && isAbsolute2(homeDirectory) ? [join4(homeDirectory, ".local", "bin", "claude")] : [];
|
|
22268
22372
|
}
|
|
22269
22373
|
};
|
|
22270
22374
|
|
|
22271
22375
|
// src/engine/util/platform/macos.ts
|
|
22272
|
-
import { isAbsolute as
|
|
22376
|
+
import { isAbsolute as isAbsolute3, join as join6 } from "node:path";
|
|
22273
22377
|
|
|
22274
22378
|
// src/engine/util/platform/claude-desktop.ts
|
|
22275
22379
|
import { readdirSync } from "node:fs";
|
|
22276
|
-
import { join as
|
|
22380
|
+
import { join as join5 } from "node:path";
|
|
22277
22381
|
function installedDirectories(directory) {
|
|
22278
22382
|
try {
|
|
22279
22383
|
return readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
@@ -22289,14 +22393,14 @@ function claudeDesktopExecutablePaths(roots, executablePaths) {
|
|
|
22289
22393
|
for (const root of roots) {
|
|
22290
22394
|
const versions = installedDirectories(root).filter((version3) => /^\d+\.\d+\.\d+$/.test(version3)).toSorted((left, right) => right.localeCompare(left, "en", { numeric: true }));
|
|
22291
22395
|
for (const version3 of versions) {
|
|
22292
|
-
const directory =
|
|
22396
|
+
const directory = join5(root, version3);
|
|
22293
22397
|
const installations = [
|
|
22294
22398
|
directory,
|
|
22295
|
-
...installedDirectories(directory).map((build) =>
|
|
22399
|
+
...installedDirectories(directory).map((build) => join5(directory, build))
|
|
22296
22400
|
];
|
|
22297
22401
|
for (const installation of installations) {
|
|
22298
22402
|
for (const executablePath of executablePaths) {
|
|
22299
|
-
paths.push(
|
|
22403
|
+
paths.push(join5(installation, ...executablePath));
|
|
22300
22404
|
}
|
|
22301
22405
|
}
|
|
22302
22406
|
}
|
|
@@ -22310,11 +22414,11 @@ var macosPlatform = {
|
|
|
22310
22414
|
claudeCodeExecutablePaths: (environment) => {
|
|
22311
22415
|
const paths = ["/opt/homebrew/bin/claude", "/usr/local/bin/claude"];
|
|
22312
22416
|
const homeDirectory = environment["HOME"];
|
|
22313
|
-
if (homeDirectory !== void 0 &&
|
|
22314
|
-
paths.unshift(
|
|
22417
|
+
if (homeDirectory !== void 0 && isAbsolute3(homeDirectory)) {
|
|
22418
|
+
paths.unshift(join6(homeDirectory, ".local", "bin", "claude"));
|
|
22315
22419
|
paths.push(
|
|
22316
22420
|
...claudeDesktopExecutablePaths(
|
|
22317
|
-
[
|
|
22421
|
+
[join6(homeDirectory, "Library", "Application Support", "Claude", "claude-code")],
|
|
22318
22422
|
[["claude.app", "Contents", "MacOS", "claude"], ["claude"]]
|
|
22319
22423
|
)
|
|
22320
22424
|
);
|
|
@@ -22324,27 +22428,27 @@ var macosPlatform = {
|
|
|
22324
22428
|
};
|
|
22325
22429
|
|
|
22326
22430
|
// src/engine/util/platform/windows.ts
|
|
22327
|
-
import { execFile } from "node:child_process";
|
|
22328
|
-
import { isAbsolute as
|
|
22329
|
-
import { promisify } from "node:util";
|
|
22330
|
-
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);
|
|
22331
22435
|
function environmentValue(environment, name2) {
|
|
22332
22436
|
return Object.entries(environment).find(([key]) => key.toUpperCase() === name2.toUpperCase())?.[1];
|
|
22333
22437
|
}
|
|
22334
22438
|
function desktopClaudeExecutablePaths(environment) {
|
|
22335
22439
|
const roots = [];
|
|
22336
22440
|
const localAppData = environmentValue(environment, "LOCALAPPDATA");
|
|
22337
|
-
if (localAppData !== void 0 &&
|
|
22338
|
-
const dataDirectory =
|
|
22441
|
+
if (localAppData !== void 0 && isAbsolute4(localAppData)) {
|
|
22442
|
+
const dataDirectory = join7(localAppData, "Claude-Data");
|
|
22339
22443
|
for (const installation of installedDirectories(dataDirectory)) {
|
|
22340
22444
|
if (installation.startsWith("claude_")) {
|
|
22341
|
-
roots.push(
|
|
22445
|
+
roots.push(join7(dataDirectory, installation, "claude-code"));
|
|
22342
22446
|
}
|
|
22343
22447
|
}
|
|
22344
22448
|
}
|
|
22345
22449
|
const appData = environmentValue(environment, "APPDATA");
|
|
22346
|
-
if (appData !== void 0 &&
|
|
22347
|
-
roots.push(
|
|
22450
|
+
if (appData !== void 0 && isAbsolute4(appData)) {
|
|
22451
|
+
roots.push(join7(appData, "Claude", "claude-code"));
|
|
22348
22452
|
}
|
|
22349
22453
|
return claudeDesktopExecutablePaths(roots, [["claude.exe"]]);
|
|
22350
22454
|
}
|
|
@@ -22379,8 +22483,8 @@ async function validatePathPermissions(path6, _directory, privateAccess, signal)
|
|
|
22379
22483
|
throw new LocalPathError("Windows system directory is unavailable");
|
|
22380
22484
|
}
|
|
22381
22485
|
try {
|
|
22382
|
-
await
|
|
22383
|
-
|
|
22486
|
+
await execute2(
|
|
22487
|
+
join7(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
22384
22488
|
[
|
|
22385
22489
|
"-NoLogo",
|
|
22386
22490
|
"-NoProfile",
|
|
@@ -22417,12 +22521,12 @@ var windowsPlatform = {
|
|
|
22417
22521
|
claudeCodeExecutablePaths: (environment) => {
|
|
22418
22522
|
const paths = [];
|
|
22419
22523
|
const userProfile = environmentValue(environment, "USERPROFILE");
|
|
22420
|
-
if (userProfile !== void 0 &&
|
|
22421
|
-
paths.push(
|
|
22524
|
+
if (userProfile !== void 0 && isAbsolute4(userProfile)) {
|
|
22525
|
+
paths.push(join7(userProfile, ".local", "bin", "claude.exe"));
|
|
22422
22526
|
}
|
|
22423
22527
|
const localAppData = environmentValue(environment, "LOCALAPPDATA");
|
|
22424
|
-
if (localAppData !== void 0 &&
|
|
22425
|
-
paths.push(
|
|
22528
|
+
if (localAppData !== void 0 && isAbsolute4(localAppData)) {
|
|
22529
|
+
paths.push(join7(localAppData, "Microsoft", "WinGet", "Links", "claude.exe"));
|
|
22426
22530
|
}
|
|
22427
22531
|
paths.push(...desktopClaudeExecutablePaths(environment));
|
|
22428
22532
|
return paths;
|
|
@@ -22689,7 +22793,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
22689
22793
|
}
|
|
22690
22794
|
static open = async (engineDataDir, signal) => {
|
|
22691
22795
|
signal.throwIfAborted();
|
|
22692
|
-
const dataDirectory =
|
|
22796
|
+
const dataDirectory = resolve2(engineDataDir);
|
|
22693
22797
|
try {
|
|
22694
22798
|
await ensurePrivateDirectory(dataDirectory);
|
|
22695
22799
|
await validateLocalPath(dataDirectory, true, true, signal);
|
|
@@ -22910,7 +23014,7 @@ async function readOrCreateInstallationId(engineDataDir, signal) {
|
|
|
22910
23014
|
|
|
22911
23015
|
// src/engine/runtime/pairing.ts
|
|
22912
23016
|
import { hostname as hostname3 } from "node:os";
|
|
22913
|
-
import { basename as
|
|
23017
|
+
import { basename as basename7, resolve as resolve16 } from "node:path";
|
|
22914
23018
|
import { fetch as fetch3 } from "undici";
|
|
22915
23019
|
|
|
22916
23020
|
// ../../node_modules/.pnpm/@agentclientprotocol+sdk@1.4.0_zod@4.6.7/node_modules/@agentclientprotocol/sdk/dist/schema/index.js
|
|
@@ -25072,11 +25176,11 @@ var Connection = class {
|
|
|
25072
25176
|
const id = this.nextRequestId++;
|
|
25073
25177
|
let cancel = () => {
|
|
25074
25178
|
};
|
|
25075
|
-
const response = new Promise((
|
|
25179
|
+
const response = new Promise((resolve20, reject2) => {
|
|
25076
25180
|
const pendingResponse = {
|
|
25077
25181
|
resolve: (value) => {
|
|
25078
25182
|
try {
|
|
25079
|
-
|
|
25183
|
+
resolve20(mapResponse ? mapResponse(value) : value);
|
|
25080
25184
|
} catch (error62) {
|
|
25081
25185
|
reject2(error62);
|
|
25082
25186
|
}
|
|
@@ -25133,8 +25237,8 @@ var Connection = class {
|
|
|
25133
25237
|
this.stream = stream;
|
|
25134
25238
|
this.staticHandlers = handlers;
|
|
25135
25239
|
this.allowBatches = options?.allowBatches ?? true;
|
|
25136
|
-
this.closedPromise = new Promise((
|
|
25137
|
-
this.abortController.signal.addEventListener("abort", () =>
|
|
25240
|
+
this.closedPromise = new Promise((resolve20) => {
|
|
25241
|
+
this.abortController.signal.addEventListener("abort", () => resolve20());
|
|
25138
25242
|
});
|
|
25139
25243
|
void this.receive();
|
|
25140
25244
|
}
|
|
@@ -25900,8 +26004,8 @@ var AsyncQueue = class {
|
|
|
25900
26004
|
if (this.failed) {
|
|
25901
26005
|
return Promise.reject(this.failure);
|
|
25902
26006
|
}
|
|
25903
|
-
return new Promise((
|
|
25904
|
-
this.waiters.push({ resolve:
|
|
26007
|
+
return new Promise((resolve20, reject2) => {
|
|
26008
|
+
this.waiters.push({ resolve: resolve20, reject: reject2 });
|
|
25905
26009
|
});
|
|
25906
26010
|
}
|
|
25907
26011
|
};
|
|
@@ -26753,13 +26857,13 @@ function spawnClaudeWithParentLifeline(options) {
|
|
|
26753
26857
|
}
|
|
26754
26858
|
|
|
26755
26859
|
// src/engine/acp/harness/claude/upstream/dist/acp-agent.js
|
|
26756
|
-
import { execFile as
|
|
26860
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
26757
26861
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
26758
26862
|
import { existsSync as existsSync3 } from "node:fs";
|
|
26759
26863
|
import * as fs3 from "node:fs/promises";
|
|
26760
26864
|
import * as os3 from "node:os";
|
|
26761
26865
|
import * as path5 from "node:path";
|
|
26762
|
-
import { promisify as
|
|
26866
|
+
import { promisify as promisify3 } from "node:util";
|
|
26763
26867
|
|
|
26764
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
|
|
26765
26869
|
import { createRequire as $ne } from "node:module";
|
|
@@ -52719,7 +52823,7 @@ var JC = class {
|
|
|
52719
52823
|
function nm(e) {
|
|
52720
52824
|
return typeof e === "number" && Number.isInteger(e) && e > 0 ? e : void 0;
|
|
52721
52825
|
}
|
|
52722
|
-
var
|
|
52826
|
+
var rm4 = /* @__PURE__ */ Symbol("suppressControlResponse");
|
|
52723
52827
|
var Gy = class _Gy {
|
|
52724
52828
|
transport;
|
|
52725
52829
|
isSingleUserTurn;
|
|
@@ -52924,7 +53028,7 @@ var Gy = class _Gy {
|
|
|
52924
53028
|
try {
|
|
52925
53029
|
let n = await this.processControlRequest(e, t.signal);
|
|
52926
53030
|
if (this.cleanupPerformed) return;
|
|
52927
|
-
if (n ===
|
|
53031
|
+
if (n === rm4) return;
|
|
52928
53032
|
let r = { type: "control_response", response: { subtype: "success", request_id: e.request_id, response: n } };
|
|
52929
53033
|
await Promise.resolve(this.transport.write(me(r) + `
|
|
52930
53034
|
`));
|
|
@@ -52949,7 +53053,7 @@ var Gy = class _Gy {
|
|
|
52949
53053
|
if (e.request.subtype === "can_use_tool") {
|
|
52950
53054
|
if (!this.canUseTool) throw Error("canUseTool callback is not provided.");
|
|
52951
53055
|
let n = await this.canUseTool(e.request.tool_name, e.request.input, { signal: t, suggestions: e.request.permission_suggestions, blockedPath: e.request.blocked_path, decisionReason: e.request.decision_reason, title: e.request.title, displayName: e.request.display_name, description: e.request.description, toolUseID: e.request.tool_use_id, agentID: e.request.agent_id, requestId: e.request_id, ...e.request.matched_ask_rule && { matchedAskRule: { source: e.request.matched_ask_rule.source, toolName: e.request.matched_ask_rule.tool_name, ...e.request.matched_ask_rule.rule_content !== void 0 && { ruleContent: e.request.matched_ask_rule.rule_content } } } });
|
|
52952
|
-
if (n === null) return
|
|
53056
|
+
if (n === null) return rm4;
|
|
52953
53057
|
return { ...n, toolUseID: e.request.tool_use_id };
|
|
52954
53058
|
} else if (e.request.subtype === "hook_callback") return await this.handleHookCallbacks(e.request.callback_id, e.request.input, e.request.tool_use_id, t);
|
|
52955
53059
|
else if (e.request.subtype === "mcp_message") {
|
|
@@ -52964,17 +53068,17 @@ var Gy = class _Gy {
|
|
|
52964
53068
|
let n = e.request;
|
|
52965
53069
|
if (this.onElicitation) {
|
|
52966
53070
|
let r = await this.onElicitation({ serverName: n.mcp_server_name, message: n.message, mode: n.mode, url: n.url, elicitationId: n.elicitation_id, requestedSchema: n.requested_schema, title: n.title, displayName: n.display_name, description: n.description }, { signal: t, requestId: e.request_id });
|
|
52967
|
-
if (r === null) return
|
|
53071
|
+
if (r === null) return rm4;
|
|
52968
53072
|
return r;
|
|
52969
53073
|
}
|
|
52970
53074
|
return { action: "decline" };
|
|
52971
53075
|
} else if (e.request.subtype === "request_user_dialog") {
|
|
52972
53076
|
if (this.onUserDialog) {
|
|
52973
53077
|
let n = await this.onUserDialog({ dialogKind: e.request.dialog_kind, payload: e.request.payload, toolUseID: e.request.tool_use_id }, { signal: t, requestId: e.request_id });
|
|
52974
|
-
if (n === null) return
|
|
53078
|
+
if (n === null) return rm4;
|
|
52975
53079
|
return n;
|
|
52976
53080
|
}
|
|
52977
|
-
return ce(`[Query] No onUserDialog handler for request_user_dialog (kind=${e.request.dialog_kind}) \u2014 staying silent so a capable client (or the worker's park deadline) settles it`), Li("tengu_request_user_dialog_response_ignored", { shape: yi("auto_cancel") }),
|
|
53081
|
+
return ce(`[Query] No onUserDialog handler for request_user_dialog (kind=${e.request.dialog_kind}) \u2014 staying silent so a capable client (or the worker's park deadline) settles it`), Li("tengu_request_user_dialog_response_ignored", { shape: yi("auto_cancel") }), rm4;
|
|
52978
53082
|
} else if (e.request.subtype === "oauth_token_refresh") {
|
|
52979
53083
|
if (!this.getOAuthToken) throw Error("getOAuthToken callback is not provided.");
|
|
52980
53084
|
let n, r = await this.getOAuthToken({ signal: t, onDecline: (o) => {
|
|
@@ -63409,11 +63513,11 @@ var Pushable = class {
|
|
|
63409
63513
|
done = false;
|
|
63410
63514
|
push(item) {
|
|
63411
63515
|
if (this.resolvers.length > 0) {
|
|
63412
|
-
const
|
|
63413
|
-
if (
|
|
63516
|
+
const resolve20 = this.resolvers.shift();
|
|
63517
|
+
if (resolve20 === void 0) {
|
|
63414
63518
|
return;
|
|
63415
63519
|
}
|
|
63416
|
-
|
|
63520
|
+
resolve20({ value: item, done: false });
|
|
63417
63521
|
} else {
|
|
63418
63522
|
this.queue.push(item);
|
|
63419
63523
|
}
|
|
@@ -63421,8 +63525,8 @@ var Pushable = class {
|
|
|
63421
63525
|
end() {
|
|
63422
63526
|
this.done = true;
|
|
63423
63527
|
while (this.resolvers.length > 0) {
|
|
63424
|
-
const
|
|
63425
|
-
|
|
63528
|
+
const resolve20 = this.resolvers.shift();
|
|
63529
|
+
resolve20?.({ done: true, value: void 0 });
|
|
63426
63530
|
}
|
|
63427
63531
|
}
|
|
63428
63532
|
[Symbol.asyncIterator]() {
|
|
@@ -63438,8 +63542,8 @@ var Pushable = class {
|
|
|
63438
63542
|
if (this.done) {
|
|
63439
63543
|
return Promise.resolve({ done: true, value: void 0 });
|
|
63440
63544
|
}
|
|
63441
|
-
return new Promise((
|
|
63442
|
-
this.resolvers.push(
|
|
63545
|
+
return new Promise((resolve20) => {
|
|
63546
|
+
this.resolvers.push(resolve20);
|
|
63443
63547
|
});
|
|
63444
63548
|
}
|
|
63445
63549
|
};
|
|
@@ -63457,14 +63561,14 @@ function unreachable(value, logger = console) {
|
|
|
63457
63561
|
async function withDeadline(signal, timeoutMilliseconds, operation) {
|
|
63458
63562
|
const deadline = AbortSignal.any([signal, AbortSignal.timeout(timeoutMilliseconds)]);
|
|
63459
63563
|
deadline.throwIfAborted();
|
|
63460
|
-
return await new Promise((
|
|
63564
|
+
return await new Promise((resolve20, reject2) => {
|
|
63461
63565
|
const settle2 = (callback) => {
|
|
63462
63566
|
deadline.removeEventListener("abort", onAbort);
|
|
63463
63567
|
callback();
|
|
63464
63568
|
};
|
|
63465
63569
|
const onAbort = () => settle2(() => reject2(deadline.reason));
|
|
63466
63570
|
deadline.addEventListener("abort", onAbort, { once: true });
|
|
63467
|
-
operation().then((value) => settle2(() =>
|
|
63571
|
+
operation().then((value) => settle2(() => resolve20(value)), (error62) => settle2(() => reject2(error62)));
|
|
63468
63572
|
});
|
|
63469
63573
|
}
|
|
63470
63574
|
var environmentChain = Promise.resolve();
|
|
@@ -64163,8 +64267,8 @@ function inputPath(context, key) {
|
|
|
64163
64267
|
return plainString(context.input[key]);
|
|
64164
64268
|
}
|
|
64165
64269
|
function isInside(directory, candidate) {
|
|
64166
|
-
const
|
|
64167
|
-
return
|
|
64270
|
+
const relative4 = path.relative(path.resolve(directory), path.resolve(candidate));
|
|
64271
|
+
return relative4 === "" || !relative4.startsWith(`..${path.sep}`) && relative4 !== "..";
|
|
64168
64272
|
}
|
|
64169
64273
|
function hasSessionAllowRuleFor(changeSet, toolName) {
|
|
64170
64274
|
return !!changeSet?.updates.some((update) => update.type === "addRules" && update.destination === "session" && update.behavior === "allow" && update.rules.some((rule) => rule.toolName === toolName));
|
|
@@ -66314,7 +66418,7 @@ var SessionModeManager = class {
|
|
|
66314
66418
|
|
|
66315
66419
|
// src/engine/acp/harness/claude/upstream/dist/acp-agent.js
|
|
66316
66420
|
var CLAUDE_CONFIG_DIR = process.env.CLAUDE_CONFIG_DIR ?? path5.join(os3.homedir(), ".claude");
|
|
66317
|
-
var execFileAsync =
|
|
66421
|
+
var execFileAsync = promisify3(execFile3);
|
|
66318
66422
|
var ZERO_USAGE = Object.freeze({
|
|
66319
66423
|
input_tokens: 0,
|
|
66320
66424
|
output_tokens: 0,
|
|
@@ -66332,14 +66436,14 @@ function waitUnlessAborted(milliseconds, signal) {
|
|
|
66332
66436
|
if (signal.aborted) {
|
|
66333
66437
|
return Promise.resolve(false);
|
|
66334
66438
|
}
|
|
66335
|
-
return new Promise((
|
|
66439
|
+
return new Promise((resolve20) => {
|
|
66336
66440
|
const timer = setTimeout(() => {
|
|
66337
66441
|
signal.removeEventListener("abort", onAbort);
|
|
66338
|
-
|
|
66442
|
+
resolve20(true);
|
|
66339
66443
|
}, milliseconds);
|
|
66340
66444
|
const onAbort = () => {
|
|
66341
66445
|
clearTimeout(timer);
|
|
66342
|
-
|
|
66446
|
+
resolve20(false);
|
|
66343
66447
|
};
|
|
66344
66448
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
66345
66449
|
});
|
|
@@ -66577,7 +66681,7 @@ var ClientConnection = class {
|
|
|
66577
66681
|
}
|
|
66578
66682
|
};
|
|
66579
66683
|
function raceWithAbort(operation, signal) {
|
|
66580
|
-
return new Promise((
|
|
66684
|
+
return new Promise((resolve20, reject2) => {
|
|
66581
66685
|
const cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
66582
66686
|
const onAbort = () => {
|
|
66583
66687
|
cleanup();
|
|
@@ -66589,7 +66693,7 @@ function raceWithAbort(operation, signal) {
|
|
|
66589
66693
|
}
|
|
66590
66694
|
void operation.then((value) => {
|
|
66591
66695
|
cleanup();
|
|
66592
|
-
|
|
66696
|
+
resolve20(value);
|
|
66593
66697
|
}, (error62) => {
|
|
66594
66698
|
cleanup();
|
|
66595
66699
|
reject2(error62);
|
|
@@ -67192,12 +67296,12 @@ var ClaudeAcpAgent = class {
|
|
|
67192
67296
|
}
|
|
67193
67297
|
};
|
|
67194
67298
|
let completeTurn;
|
|
67195
|
-
turn.completion = new Promise((
|
|
67196
|
-
completeTurn =
|
|
67299
|
+
turn.completion = new Promise((resolve20) => {
|
|
67300
|
+
completeTurn = resolve20;
|
|
67197
67301
|
});
|
|
67198
|
-
const response = new Promise((
|
|
67302
|
+
const response = new Promise((resolve20, reject2) => {
|
|
67199
67303
|
turn.resolve = (result) => {
|
|
67200
|
-
|
|
67304
|
+
resolve20(result);
|
|
67201
67305
|
completeTurn();
|
|
67202
67306
|
};
|
|
67203
67307
|
turn.reject = (error62) => {
|
|
@@ -67661,8 +67765,8 @@ var ClaudeAcpAgent = class {
|
|
|
67661
67765
|
pendingNext ??= session.query.next().then((result) => ({ kind: "message", result }));
|
|
67662
67766
|
const nextMessage = pendingNext;
|
|
67663
67767
|
let onAbort;
|
|
67664
|
-
const abortRace = new Promise((
|
|
67665
|
-
onAbort = () =>
|
|
67768
|
+
const abortRace = new Promise((resolve20) => {
|
|
67769
|
+
onAbort = () => resolve20("abort");
|
|
67666
67770
|
cancelController.signal.addEventListener("abort", onAbort, { once: true });
|
|
67667
67771
|
});
|
|
67668
67772
|
const raced = await Promise.race([nextMessage, abortRace]);
|
|
@@ -71239,16 +71343,16 @@ var ClaudeAgentConnection = class extends EndpointAgentConnection {
|
|
|
71239
71343
|
// src/engine/util/process/executable.ts
|
|
71240
71344
|
import { spawn as spawn3 } from "node:child_process";
|
|
71241
71345
|
import { stat as stat5 } from "node:fs/promises";
|
|
71242
|
-
import { join as
|
|
71346
|
+
import { join as join16, resolve as resolve10 } from "node:path";
|
|
71243
71347
|
|
|
71244
71348
|
// src/engine/util/process/platform/linux.ts
|
|
71245
|
-
import { constants as
|
|
71349
|
+
import { constants as constants5, readdirSync as readdirSync3, readFileSync as readFileSync2 } from "node:fs";
|
|
71246
71350
|
import { access as access3, readdir as readdir5, readFile as readFile4, realpath as realpath5, stat as stat4 } from "node:fs/promises";
|
|
71247
|
-
import { join as
|
|
71351
|
+
import { join as join14 } from "node:path";
|
|
71248
71352
|
|
|
71249
71353
|
// src/engine/util/process/platform/posix.ts
|
|
71250
|
-
import { execFile as
|
|
71251
|
-
import { constants as
|
|
71354
|
+
import { execFile as execFile4 } from "node:child_process";
|
|
71355
|
+
import { constants as constants4 } from "node:fs";
|
|
71252
71356
|
import { access as access2, realpath as realpath4 } from "node:fs/promises";
|
|
71253
71357
|
var PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
|
|
71254
71358
|
var PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
|
|
@@ -71271,7 +71375,7 @@ function parseProcessTable(output2) {
|
|
|
71271
71375
|
}
|
|
71272
71376
|
function readProcessTableWithPs(executable) {
|
|
71273
71377
|
return new Promise((resolveTable) => {
|
|
71274
|
-
|
|
71378
|
+
execFile4(
|
|
71275
71379
|
executable,
|
|
71276
71380
|
["-axo", "pid=,ppid=,pgid="],
|
|
71277
71381
|
{
|
|
@@ -71335,7 +71439,7 @@ var posixOperations2 = {
|
|
|
71335
71439
|
executableExtensions: () => [""],
|
|
71336
71440
|
resolveExecutableTarget: async (path6) => {
|
|
71337
71441
|
const target = await realpath4(path6);
|
|
71338
|
-
await access2(target,
|
|
71442
|
+
await access2(target, constants4.X_OK);
|
|
71339
71443
|
return target;
|
|
71340
71444
|
},
|
|
71341
71445
|
executableLaunch: (command, args) => ({ command, arguments: args }),
|
|
@@ -71374,7 +71478,7 @@ async function readLinuxProcessTable() {
|
|
|
71374
71478
|
appendLinuxProcessTableEntry(
|
|
71375
71479
|
entries,
|
|
71376
71480
|
processId,
|
|
71377
|
-
await readFile4(
|
|
71481
|
+
await readFile4(join14("/proc", directory.name, "stat"), "utf8")
|
|
71378
71482
|
);
|
|
71379
71483
|
} catch {
|
|
71380
71484
|
}
|
|
@@ -71399,7 +71503,7 @@ function readLinuxProcessTableSynchronously() {
|
|
|
71399
71503
|
appendLinuxProcessTableEntry(
|
|
71400
71504
|
entries,
|
|
71401
71505
|
processId,
|
|
71402
|
-
readFileSync2(
|
|
71506
|
+
readFileSync2(join14("/proc", directory.name, "stat"), "utf8")
|
|
71403
71507
|
);
|
|
71404
71508
|
} catch {
|
|
71405
71509
|
}
|
|
@@ -71419,7 +71523,7 @@ async function readLinuxProcessTableWithFallback() {
|
|
|
71419
71523
|
if (!(await stat4(resolvedPath)).isFile()) {
|
|
71420
71524
|
continue;
|
|
71421
71525
|
}
|
|
71422
|
-
await access3(resolvedPath,
|
|
71526
|
+
await access3(resolvedPath, constants5.X_OK);
|
|
71423
71527
|
} catch {
|
|
71424
71528
|
continue;
|
|
71425
71529
|
}
|
|
@@ -71432,7 +71536,7 @@ async function readLinuxProcessTableWithFallback() {
|
|
|
71432
71536
|
}
|
|
71433
71537
|
function processExists2(processId) {
|
|
71434
71538
|
try {
|
|
71435
|
-
const encoded = readFileSync2(
|
|
71539
|
+
const encoded = readFileSync2(join14("/proc", processId.toString(), "stat"), "utf8");
|
|
71436
71540
|
const closingParenthesis = encoded.lastIndexOf(")");
|
|
71437
71541
|
if (closingParenthesis >= 0) {
|
|
71438
71542
|
const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
|
|
@@ -71460,9 +71564,9 @@ var macosProcessPlatform = {
|
|
|
71460
71564
|
};
|
|
71461
71565
|
|
|
71462
71566
|
// src/engine/util/process/platform/windows.ts
|
|
71463
|
-
import { execFile as
|
|
71567
|
+
import { execFile as execFile5 } from "node:child_process";
|
|
71464
71568
|
import { readFile as readFile5, realpath as realpath6 } from "node:fs/promises";
|
|
71465
|
-
import { dirname as dirname6, extname, join as
|
|
71569
|
+
import { dirname as dirname6, extname, join as join15, resolve as resolve9 } from "node:path";
|
|
71466
71570
|
|
|
71467
71571
|
// src/engine/util/process/process-error.ts
|
|
71468
71572
|
var ProcessExecutionError = class extends Error {
|
|
@@ -71503,12 +71607,12 @@ async function resolveExecutableTarget(path6) {
|
|
|
71503
71607
|
for (const tool of ["npm", "npx"]) {
|
|
71504
71608
|
const variable = `${tool.toUpperCase()}_CLI_JS`;
|
|
71505
71609
|
if (shim.includes(`SET "${variable}=%~dp0\\node_modules\\npm\\bin\\${tool}-cli.js"`) && shim.includes(`"%NODE_EXE%" "%${variable}%" %*`)) {
|
|
71506
|
-
return await realpath6(
|
|
71610
|
+
return await realpath6(resolve9(dirname6(resolvedPath), `node_modules/npm/bin/${tool}-cli.js`));
|
|
71507
71611
|
}
|
|
71508
71612
|
}
|
|
71509
71613
|
const script = /"%_prog%"\s+"%dp0%[\\/]([^"\r\n]+\.(?:js|mjs|cjs))"\s+%\*/iu.exec(shim)?.[1];
|
|
71510
71614
|
if (script !== void 0 && shim.includes("SET dp0=%~dp0")) {
|
|
71511
|
-
resolvedPath = await realpath6(
|
|
71615
|
+
resolvedPath = await realpath6(resolve9(dirname6(resolvedPath), script));
|
|
71512
71616
|
} else {
|
|
71513
71617
|
const pnpmScript = /^\s*node\s+"%~dp0[\\/]([^"\r\n]+\.(?:js|mjs|cjs))"\s+%\*\s*$/imu.exec(shim)?.[1];
|
|
71514
71618
|
if (pnpmScript === void 0 || !shim.includes("@SETLOCAL")) {
|
|
@@ -71517,7 +71621,7 @@ async function resolveExecutableTarget(path6) {
|
|
|
71517
71621
|
"Use a native executable or a verified Node entrypoint"
|
|
71518
71622
|
);
|
|
71519
71623
|
}
|
|
71520
|
-
resolvedPath = await realpath6(
|
|
71624
|
+
resolvedPath = await realpath6(resolve9(dirname6(resolvedPath), pnpmScript));
|
|
71521
71625
|
}
|
|
71522
71626
|
}
|
|
71523
71627
|
return resolvedPath;
|
|
@@ -71540,8 +71644,8 @@ function readProcessTable() {
|
|
|
71540
71644
|
return Promise.resolve([]);
|
|
71541
71645
|
}
|
|
71542
71646
|
return new Promise((resolveTable) => {
|
|
71543
|
-
|
|
71544
|
-
|
|
71647
|
+
execFile5(
|
|
71648
|
+
join15(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
71545
71649
|
[
|
|
71546
71650
|
"-NoLogo",
|
|
71547
71651
|
"-NoProfile",
|
|
@@ -71646,7 +71750,7 @@ var ProcessResult = class {
|
|
|
71646
71750
|
}
|
|
71647
71751
|
};
|
|
71648
71752
|
async function resolveExecutablePath(requestedPath2, platform2 = process.platform) {
|
|
71649
|
-
const absoluteRequestedPath =
|
|
71753
|
+
const absoluteRequestedPath = resolve10(requestedPath2);
|
|
71650
71754
|
try {
|
|
71651
71755
|
const resolvedPath = await processPlatformSupportFor(platform2).resolveExecutableTarget(absoluteRequestedPath);
|
|
71652
71756
|
const metadata = await stat5(resolvedPath);
|
|
@@ -71677,7 +71781,7 @@ async function findExecutableOnPath(executableName, environment, platform2 = pro
|
|
|
71677
71781
|
continue;
|
|
71678
71782
|
}
|
|
71679
71783
|
for (const extension of extensions) {
|
|
71680
|
-
const requestedPath2 =
|
|
71784
|
+
const requestedPath2 = resolve10(join16(entry, `${executableName}${extension}`));
|
|
71681
71785
|
const executable = await resolveExecutablePath(requestedPath2, platform2);
|
|
71682
71786
|
if (executable !== null) {
|
|
71683
71787
|
return executable;
|
|
@@ -72002,7 +72106,7 @@ var ClaudeCodeAgentSpecification = class extends InProcessAcpAgentSpecification
|
|
|
72002
72106
|
import { spawn as spawn4 } from "node:child_process";
|
|
72003
72107
|
|
|
72004
72108
|
// src/engine/acp/harness/codex/app-server-protocol.ts
|
|
72005
|
-
import { isAbsolute as
|
|
72109
|
+
import { isAbsolute as isAbsolute9 } from "node:path";
|
|
72006
72110
|
var boundedText = (maximum) => external_exports.string().max(maximum);
|
|
72007
72111
|
var jsonValue = external_exports.lazy(() => external_exports.unknown());
|
|
72008
72112
|
var requestIdSchema = external_exports.union([external_exports.number(), external_exports.string()]).refine((value) => typeof value === "number" || value.length <= 256);
|
|
@@ -72080,7 +72184,7 @@ var agentMessageQuestionsSchema = external_exports.array(
|
|
|
72080
72184
|
).max(100).nullish().catch(null);
|
|
72081
72185
|
var threadItemSchema = external_exports.discriminatedUnion("type", [
|
|
72082
72186
|
imageGenerationItemSchema,
|
|
72083
|
-
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) }),
|
|
72084
72188
|
external_exports.object({
|
|
72085
72189
|
id: boundedText(256),
|
|
72086
72190
|
text: boundedText(1e6),
|
|
@@ -73645,10 +73749,10 @@ function turnRunning(turn) {
|
|
|
73645
73749
|
}
|
|
73646
73750
|
function waitForNextPoll(timer, signal) {
|
|
73647
73751
|
signal.throwIfAborted();
|
|
73648
|
-
return new Promise((
|
|
73752
|
+
return new Promise((resolve20, reject2) => {
|
|
73649
73753
|
const poll = timer.schedule(() => {
|
|
73650
73754
|
signal.removeEventListener("abort", abort);
|
|
73651
|
-
|
|
73755
|
+
resolve20();
|
|
73652
73756
|
}, POLL_INTERVAL);
|
|
73653
73757
|
const abort = () => {
|
|
73654
73758
|
poll.cancel();
|
|
@@ -73990,7 +74094,7 @@ var CodexBorrowedAcpAgent = class {
|
|
|
73990
74094
|
import { createHash as createHash2 } from "node:crypto";
|
|
73991
74095
|
|
|
73992
74096
|
// src/engine/acp/content/raster.ts
|
|
73993
|
-
import { basename as
|
|
74097
|
+
import { basename as basename5, isAbsolute as isAbsolute10, normalize } from "node:path";
|
|
73994
74098
|
import { fileURLToPath } from "node:url";
|
|
73995
74099
|
var MAX_LOCAL_RASTER_BYTES = 128 * 1024 * 1024;
|
|
73996
74100
|
var PNG_SIGNATURE = Uint8Array.of(137, 80, 78, 71);
|
|
@@ -74033,13 +74137,13 @@ function sniffRasterMime(bytes) {
|
|
|
74033
74137
|
}
|
|
74034
74138
|
async function resolveCanonicalPath(requested, signal) {
|
|
74035
74139
|
signal.throwIfAborted();
|
|
74036
|
-
if (!
|
|
74140
|
+
if (!isAbsolute10(requested) || requested.includes("\0") || normalize(requested) !== requested) {
|
|
74037
74141
|
return null;
|
|
74038
74142
|
}
|
|
74039
74143
|
try {
|
|
74040
74144
|
const target = await canonicalPath(requested);
|
|
74041
74145
|
signal.throwIfAborted();
|
|
74042
|
-
if (!
|
|
74146
|
+
if (!isAbsolute10(target) || normalize(target) !== target) {
|
|
74043
74147
|
return null;
|
|
74044
74148
|
}
|
|
74045
74149
|
return target;
|
|
@@ -74070,7 +74174,7 @@ function parseLocalImageUri(uri) {
|
|
|
74070
74174
|
return null;
|
|
74071
74175
|
}
|
|
74072
74176
|
}
|
|
74073
|
-
if (!
|
|
74177
|
+
if (!isAbsolute10(trimmed) && /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(trimmed)) {
|
|
74074
74178
|
return null;
|
|
74075
74179
|
}
|
|
74076
74180
|
return trimmed;
|
|
@@ -74096,7 +74200,7 @@ async function readLocalRaster(uri, signal) {
|
|
|
74096
74200
|
if (mimeType === null) {
|
|
74097
74201
|
return null;
|
|
74098
74202
|
}
|
|
74099
|
-
return new LocalRasterImage(
|
|
74203
|
+
return new LocalRasterImage(basename5(target) || "Image", mimeType, target);
|
|
74100
74204
|
}
|
|
74101
74205
|
|
|
74102
74206
|
// src/engine/acp/native-history/codex/history-images.ts
|
|
@@ -75063,13 +75167,13 @@ var CodexAgentSpecification = class extends InProcessAcpAgentSpecification {
|
|
|
75063
75167
|
|
|
75064
75168
|
// src/engine/agent/specification/vendors/pi-agent.ts
|
|
75065
75169
|
import { createHash as createHash3 } from "node:crypto";
|
|
75066
|
-
import { join as
|
|
75170
|
+
import { join as join22 } from "node:path";
|
|
75067
75171
|
|
|
75068
75172
|
// src/engine/acp/harness/pi/upstream/dist/acp/agent.js
|
|
75069
75173
|
import { spawnSync } from "node:child_process";
|
|
75070
75174
|
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
75071
75175
|
import { existsSync as existsSync8, readdirSync as readdirSync6, readFileSync as readFileSync9, realpathSync as realpathSync3, statSync as statSync3, unlinkSync as unlinkSync2 } from "node:fs";
|
|
75072
|
-
import { basename as
|
|
75176
|
+
import { basename as basename6, dirname as dirname8, isAbsolute as isAbsolute13, join as join21 } from "node:path";
|
|
75073
75177
|
|
|
75074
75178
|
// src/engine/acp/harness/pi/upstream/dist/pi-rpc/process.js
|
|
75075
75179
|
import { spawn as spawn5 } from "node:child_process";
|
|
@@ -75196,10 +75300,10 @@ var PiRpcProcess = class _PiRpcProcess {
|
|
|
75196
75300
|
shell: shouldUseShellForPiCommand(cmd)
|
|
75197
75301
|
});
|
|
75198
75302
|
try {
|
|
75199
|
-
await new Promise((
|
|
75303
|
+
await new Promise((resolve20, reject2) => {
|
|
75200
75304
|
const onSpawn = () => {
|
|
75201
75305
|
cleanup();
|
|
75202
|
-
|
|
75306
|
+
resolve20();
|
|
75203
75307
|
};
|
|
75204
75308
|
const onError = (err) => {
|
|
75205
75309
|
cleanup();
|
|
@@ -75401,7 +75505,7 @@ var PiRpcProcess = class _PiRpcProcess {
|
|
|
75401
75505
|
const timeoutMs = opts?.timeoutMs;
|
|
75402
75506
|
const line = `${JSON.stringify(withId)}
|
|
75403
75507
|
`;
|
|
75404
|
-
return new Promise((
|
|
75508
|
+
return new Promise((resolve20, reject2) => {
|
|
75405
75509
|
const signal = opts?.signal;
|
|
75406
75510
|
if (signal?.aborted === true) {
|
|
75407
75511
|
reject2(signal.reason);
|
|
@@ -75423,7 +75527,7 @@ var PiRpcProcess = class _PiRpcProcess {
|
|
|
75423
75527
|
this.pending.set(id, {
|
|
75424
75528
|
resolve: (res) => {
|
|
75425
75529
|
drop();
|
|
75426
|
-
|
|
75530
|
+
resolve20(res);
|
|
75427
75531
|
},
|
|
75428
75532
|
reject: (error62) => {
|
|
75429
75533
|
drop();
|
|
@@ -75456,14 +75560,14 @@ var PiRpcProcess = class _PiRpcProcess {
|
|
|
75456
75560
|
});
|
|
75457
75561
|
}
|
|
75458
75562
|
writeLine(line) {
|
|
75459
|
-
return new Promise((
|
|
75563
|
+
return new Promise((resolve20, reject2) => {
|
|
75460
75564
|
try {
|
|
75461
75565
|
this.child.stdin.write(line, (error62) => {
|
|
75462
75566
|
if (error62) {
|
|
75463
75567
|
reject2(error62);
|
|
75464
75568
|
return;
|
|
75465
75569
|
}
|
|
75466
|
-
|
|
75570
|
+
resolve20();
|
|
75467
75571
|
});
|
|
75468
75572
|
} catch (error62) {
|
|
75469
75573
|
reject2(error62);
|
|
@@ -75525,7 +75629,7 @@ function maybeAuthRequiredError(err) {
|
|
|
75525
75629
|
}
|
|
75526
75630
|
|
|
75527
75631
|
// src/engine/acp/harness/pi/upstream/dist/acp/paths.js
|
|
75528
|
-
import { join as
|
|
75632
|
+
import { join as join17 } from "node:path";
|
|
75529
75633
|
|
|
75530
75634
|
// src/engine/acp/harness/pi/upstream/dist/acp/environment.js
|
|
75531
75635
|
import { homedir as homedir2 } from "node:os";
|
|
@@ -75535,10 +75639,10 @@ function environmentHome(environment) {
|
|
|
75535
75639
|
|
|
75536
75640
|
// src/engine/acp/harness/pi/upstream/dist/acp/paths.js
|
|
75537
75641
|
function getPiAcpDir(environment = process.env) {
|
|
75538
|
-
return
|
|
75642
|
+
return join17(environmentHome(environment), ".pi", "pi-acp");
|
|
75539
75643
|
}
|
|
75540
75644
|
function getPiAcpSessionMapPath(environment = process.env) {
|
|
75541
|
-
return
|
|
75645
|
+
return join17(getPiAcpDir(environment), "session-map.json");
|
|
75542
75646
|
}
|
|
75543
75647
|
|
|
75544
75648
|
// src/engine/acp/harness/pi/upstream/dist/acp/pi-commands.js
|
|
@@ -75660,15 +75764,15 @@ async function readPiLatestEntryId(sessionFile) {
|
|
|
75660
75764
|
|
|
75661
75765
|
// src/engine/acp/harness/pi/upstream/dist/acp/pi-sessions.js
|
|
75662
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";
|
|
75663
|
-
import { isAbsolute as
|
|
75767
|
+
import { isAbsolute as isAbsolute11, join as join18, resolve as resolve11 } from "node:path";
|
|
75664
75768
|
var DEFAULT_TAIL_BYTES = 256 * 1024;
|
|
75665
75769
|
var DEFAULT_HEAD_BYTES = 64 * 1024;
|
|
75666
75770
|
function getPiAgentDir(environment) {
|
|
75667
75771
|
const configured = environment["PI_CODING_AGENT_DIR"];
|
|
75668
|
-
return configured ?
|
|
75772
|
+
return configured ? resolve11(configured) : join18(environmentHome(environment), ".pi", "agent");
|
|
75669
75773
|
}
|
|
75670
75774
|
function readSessionDirFromSettings(agentDir) {
|
|
75671
|
-
const settingsPath =
|
|
75775
|
+
const settingsPath = join18(agentDir, "settings.json");
|
|
75672
75776
|
try {
|
|
75673
75777
|
if (!existsSync5(settingsPath)) {
|
|
75674
75778
|
return null;
|
|
@@ -75682,25 +75786,25 @@ function readSessionDirFromSettings(agentDir) {
|
|
|
75682
75786
|
if (typeof sessionDir !== "string" || !sessionDir.trim()) {
|
|
75683
75787
|
return null;
|
|
75684
75788
|
}
|
|
75685
|
-
return
|
|
75789
|
+
return isAbsolute11(sessionDir) ? sessionDir : resolve11(agentDir, sessionDir);
|
|
75686
75790
|
} catch {
|
|
75687
75791
|
return null;
|
|
75688
75792
|
}
|
|
75689
75793
|
}
|
|
75690
75794
|
function getPiSessionsDir(environment = process.env) {
|
|
75691
75795
|
const agentDir = getPiAgentDir(environment);
|
|
75692
|
-
return readSessionDirFromSettings(agentDir) ??
|
|
75796
|
+
return readSessionDirFromSettings(agentDir) ?? join18(agentDir, "sessions");
|
|
75693
75797
|
}
|
|
75694
75798
|
function getPiSessionDiscoveryDirs(environment) {
|
|
75695
75799
|
const discoveryDirectories = [getPiSessionsDir(environment)];
|
|
75696
75800
|
const mobiusSessionDirectory = environment["MOBIUS_PI_SESSION_DIR"];
|
|
75697
75801
|
if (mobiusSessionDirectory !== void 0 && mobiusSessionDirectory.trim().length > 0) {
|
|
75698
|
-
const mobiusSessionsRoot =
|
|
75802
|
+
const mobiusSessionsRoot = resolve11(mobiusSessionDirectory, "..");
|
|
75699
75803
|
for (const entry of readdirSync4(mobiusSessionsRoot, { withFileTypes: true, encoding: "utf-8" })) {
|
|
75700
75804
|
if (!entry.isDirectory()) {
|
|
75701
75805
|
continue;
|
|
75702
75806
|
}
|
|
75703
|
-
const directory =
|
|
75807
|
+
const directory = join18(mobiusSessionsRoot, entry.name);
|
|
75704
75808
|
if (!discoveryDirectories.includes(directory)) {
|
|
75705
75809
|
discoveryDirectories.push(directory);
|
|
75706
75810
|
}
|
|
@@ -75717,7 +75821,7 @@ function walkJsonlFiles(dir, out2) {
|
|
|
75717
75821
|
}
|
|
75718
75822
|
for (const e of entries) {
|
|
75719
75823
|
const name2 = typeof e.name === "string" ? e.name : String(e.name);
|
|
75720
|
-
const p =
|
|
75824
|
+
const p = join18(dir, name2);
|
|
75721
75825
|
if (e.isDirectory()) {
|
|
75722
75826
|
walkJsonlFiles(p, out2);
|
|
75723
75827
|
} else if (e.isFile() && name2.endsWith(".jsonl")) {
|
|
@@ -75986,7 +76090,7 @@ function findPiSession(sessionId, environment = process.env) {
|
|
|
75986
76090
|
|
|
75987
76091
|
// src/engine/acp/harness/pi/upstream/dist/acp/pi-settings.js
|
|
75988
76092
|
import { existsSync as existsSync6, readFileSync as readFileSync5 } from "node:fs";
|
|
75989
|
-
import { join as
|
|
76093
|
+
import { join as join19, resolve as resolve12 } from "node:path";
|
|
75990
76094
|
function isObject2(x) {
|
|
75991
76095
|
return Boolean(x) && typeof x === "object" && !Array.isArray(x);
|
|
75992
76096
|
}
|
|
@@ -76015,15 +76119,15 @@ function readJsonFile2(path6) {
|
|
|
76015
76119
|
}
|
|
76016
76120
|
}
|
|
76017
76121
|
function getMergedSettings(cwd, environment) {
|
|
76018
|
-
const globalSettingsPath =
|
|
76019
|
-
const projectSettingsPath =
|
|
76122
|
+
const globalSettingsPath = join19(getAgentDir(environment), "settings.json");
|
|
76123
|
+
const projectSettingsPath = resolve12(cwd, ".pi", "settings.json");
|
|
76020
76124
|
const global2 = readJsonFile2(globalSettingsPath);
|
|
76021
76125
|
const project = readJsonFile2(projectSettingsPath);
|
|
76022
76126
|
return deepMerge(global2, project);
|
|
76023
76127
|
}
|
|
76024
76128
|
function getAgentDir(environment = process.env) {
|
|
76025
76129
|
const configured = environment["PI_CODING_AGENT_DIR"];
|
|
76026
|
-
return configured ?
|
|
76130
|
+
return configured ? resolve12(configured) : join19(environmentHome(environment), ".pi", "agent");
|
|
76027
76131
|
}
|
|
76028
76132
|
function getEnableSkillCommands(cwd, environment = process.env) {
|
|
76029
76133
|
const merged = getMergedSettings(cwd, environment);
|
|
@@ -76053,7 +76157,7 @@ function getQuietStartup(cwd, environment = process.env) {
|
|
|
76053
76157
|
// src/engine/acp/harness/pi/upstream/dist/acp/session.js
|
|
76054
76158
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
76055
76159
|
import { readFileSync as readFileSync8 } from "node:fs";
|
|
76056
|
-
import { isAbsolute as
|
|
76160
|
+
import { isAbsolute as isAbsolute12, resolve as resolvePath } from "node:path";
|
|
76057
76161
|
|
|
76058
76162
|
// src/engine/acp/harness/pi/upstream/dist/acp/extension-questions.js
|
|
76059
76163
|
var questionBase = {
|
|
@@ -76277,7 +76381,7 @@ var SessionStore = class {
|
|
|
76277
76381
|
|
|
76278
76382
|
// src/engine/acp/harness/pi/upstream/dist/acp/slash-commands.js
|
|
76279
76383
|
import { existsSync as existsSync7, readdirSync as readdirSync5, readFileSync as readFileSync7 } from "node:fs";
|
|
76280
|
-
import { join as
|
|
76384
|
+
import { join as join20, resolve as resolve13 } from "node:path";
|
|
76281
76385
|
function parseFrontmatter(content) {
|
|
76282
76386
|
const frontmatter = {};
|
|
76283
76387
|
if (!content.startsWith("---")) {
|
|
@@ -76305,7 +76409,7 @@ function loadCommandsFromDir(dir, source, subdir = "") {
|
|
|
76305
76409
|
try {
|
|
76306
76410
|
const entries = readdirSync5(dir, { withFileTypes: true });
|
|
76307
76411
|
for (const entry of entries) {
|
|
76308
|
-
const fullPath =
|
|
76412
|
+
const fullPath = join20(dir, entry.name);
|
|
76309
76413
|
if (entry.isDirectory()) {
|
|
76310
76414
|
const newSubdir = subdir ? `${subdir}:${entry.name}` : entry.name;
|
|
76311
76415
|
commands.push(...loadCommandsFromDir(fullPath, source, newSubdir));
|
|
@@ -76345,8 +76449,8 @@ function loadCommandsFromDir(dir, source, subdir = "") {
|
|
|
76345
76449
|
}
|
|
76346
76450
|
function loadSlashCommands(cwd, environment = process.env) {
|
|
76347
76451
|
const commands = [];
|
|
76348
|
-
const userDir =
|
|
76349
|
-
const projectDir =
|
|
76452
|
+
const userDir = join20(environmentHome(environment), ".pi", "agent", "prompts");
|
|
76453
|
+
const projectDir = resolve13(cwd, ".pi", "prompts");
|
|
76350
76454
|
commands.push(...loadCommandsFromDir(userDir, "user"));
|
|
76351
76455
|
commands.push(...loadCommandsFromDir(projectDir, "project"));
|
|
76352
76456
|
return commands;
|
|
@@ -76594,7 +76698,7 @@ function toToolCallLocations(args, cwd, line) {
|
|
|
76594
76698
|
if (!path6) {
|
|
76595
76699
|
return void 0;
|
|
76596
76700
|
}
|
|
76597
|
-
const resolvedPath =
|
|
76701
|
+
const resolvedPath = isAbsolute12(path6) ? path6 : resolvePath(cwd, path6);
|
|
76598
76702
|
return [{ path: resolvedPath, ...typeof line === "number" ? { line } : {} }];
|
|
76599
76703
|
}
|
|
76600
76704
|
var SessionManager = class {
|
|
@@ -76818,8 +76922,8 @@ var PiAcpSession = class {
|
|
|
76818
76922
|
}
|
|
76819
76923
|
async prompt(message, images = []) {
|
|
76820
76924
|
const expandedMessage = expandSlashCommand(message, this.fileCommands);
|
|
76821
|
-
const turnPromise = new Promise((
|
|
76822
|
-
const queued = { message: expandedMessage, images, resolve:
|
|
76925
|
+
const turnPromise = new Promise((resolve20, reject2) => {
|
|
76926
|
+
const queued = { message: expandedMessage, images, resolve: resolve20, reject: reject2 };
|
|
76823
76927
|
if (this.pendingTurn) {
|
|
76824
76928
|
this.turnQueue.push(queued);
|
|
76825
76929
|
this.emit({
|
|
@@ -77148,7 +77252,7 @@ var PiAcpSession = class {
|
|
|
77148
77252
|
const p = getToolPath(args);
|
|
77149
77253
|
if (p) {
|
|
77150
77254
|
try {
|
|
77151
|
-
const abs =
|
|
77255
|
+
const abs = isAbsolute12(p) ? p : resolvePath(this.cwd, p);
|
|
77152
77256
|
snapshotOldText = readFileSync8(abs, "utf8");
|
|
77153
77257
|
this.fileSnapshots.set(toolCallId, { path: p, oldText: snapshotOldText });
|
|
77154
77258
|
if (toolName === "edit") {
|
|
@@ -77231,7 +77335,7 @@ var PiAcpSession = class {
|
|
|
77231
77335
|
let hasStructuredDiff = false;
|
|
77232
77336
|
if (!isError && snapshot) {
|
|
77233
77337
|
try {
|
|
77234
|
-
const abs =
|
|
77338
|
+
const abs = isAbsolute12(snapshot.path) ? snapshot.path : resolvePath(this.cwd, snapshot.path);
|
|
77235
77339
|
const newText = readFileSync8(abs, "utf8");
|
|
77236
77340
|
if (snapshot.oldText === null || newText !== snapshot.oldText) {
|
|
77237
77341
|
hasStructuredDiff = true;
|
|
@@ -77634,7 +77738,7 @@ var PiAcpAgent = class {
|
|
|
77634
77738
|
};
|
|
77635
77739
|
}
|
|
77636
77740
|
async newSession(params) {
|
|
77637
|
-
if (!
|
|
77741
|
+
if (!isAbsolute13(params.cwd)) {
|
|
77638
77742
|
throw RequestError.invalidParams(`cwd must be an absolute path: ${params.cwd}`);
|
|
77639
77743
|
}
|
|
77640
77744
|
this.lastSessionCwd = params.cwd;
|
|
@@ -78014,7 +78118,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
78014
78118
|
if (piPath) {
|
|
78015
78119
|
const resolved = realpathSync3(piPath);
|
|
78016
78120
|
const pkgRoot = dirname8(dirname8(resolved));
|
|
78017
|
-
const p =
|
|
78121
|
+
const p = join21(pkgRoot, "CHANGELOG.md");
|
|
78018
78122
|
if (existsSync8(p)) {
|
|
78019
78123
|
return p;
|
|
78020
78124
|
}
|
|
@@ -78025,7 +78129,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
78025
78129
|
const npmRoot = spawnSync("npm", ["root", "-g"], { encoding: "utf-8" });
|
|
78026
78130
|
const root = String(npmRoot.stdout ?? "").trim();
|
|
78027
78131
|
if (root) {
|
|
78028
|
-
const p =
|
|
78132
|
+
const p = join21(root, "@earendil-works", "pi-coding-agent", "CHANGELOG.md");
|
|
78029
78133
|
if (existsSync8(p)) {
|
|
78030
78134
|
return p;
|
|
78031
78135
|
}
|
|
@@ -78119,7 +78223,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
78119
78223
|
return { stopReason: "end_turn" };
|
|
78120
78224
|
}
|
|
78121
78225
|
const safeSessionId = session.sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
78122
|
-
const outputPath =
|
|
78226
|
+
const outputPath = join21(session.cwd, `pi-session-${safeSessionId}.html`);
|
|
78123
78227
|
let resultPath = "";
|
|
78124
78228
|
try {
|
|
78125
78229
|
const result2 = await session.proc.exportHtml(outputPath);
|
|
@@ -78269,7 +78373,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
78269
78373
|
return { sessions, nextCursor, _meta: {} };
|
|
78270
78374
|
}
|
|
78271
78375
|
async forkSession(params) {
|
|
78272
|
-
if (!
|
|
78376
|
+
if (!isAbsolute13(params.cwd)) {
|
|
78273
78377
|
throw RequestError.invalidParams(`cwd must be an absolute path: ${params.cwd}`);
|
|
78274
78378
|
}
|
|
78275
78379
|
const source = this.findStoredSession(params.sessionId);
|
|
@@ -78335,7 +78439,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
78335
78439
|
return { sessionId: session.sessionId, configOptions, modes };
|
|
78336
78440
|
}
|
|
78337
78441
|
async resumeSession(params) {
|
|
78338
|
-
if (!
|
|
78442
|
+
if (!isAbsolute13(params.cwd)) {
|
|
78339
78443
|
throw RequestError.invalidParams(`cwd must be an absolute path: ${params.cwd}`);
|
|
78340
78444
|
}
|
|
78341
78445
|
this.sessions.close(params.sessionId);
|
|
@@ -78406,7 +78510,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
78406
78510
|
return response;
|
|
78407
78511
|
}
|
|
78408
78512
|
async loadSession(params) {
|
|
78409
|
-
if (!
|
|
78513
|
+
if (!isAbsolute13(params.cwd)) {
|
|
78410
78514
|
throw RequestError.invalidParams(`cwd must be an absolute path: ${params.cwd}`);
|
|
78411
78515
|
}
|
|
78412
78516
|
this.sessions.close(params.sessionId);
|
|
@@ -78856,7 +78960,7 @@ function buildStartupInfo(opts) {
|
|
|
78856
78960
|
md.push("");
|
|
78857
78961
|
};
|
|
78858
78962
|
const contextItems = [];
|
|
78859
|
-
const contextPath =
|
|
78963
|
+
const contextPath = join21(opts.cwd, "AGENTS.md");
|
|
78860
78964
|
if (existsSync8(contextPath)) {
|
|
78861
78965
|
contextItems.push(contextPath);
|
|
78862
78966
|
}
|
|
@@ -78865,7 +78969,7 @@ function buildStartupInfo(opts) {
|
|
|
78865
78969
|
const pushSkillFromRoot = (root) => {
|
|
78866
78970
|
try {
|
|
78867
78971
|
for (const e of readdirSync6(root)) {
|
|
78868
|
-
const p =
|
|
78972
|
+
const p = join21(root, e);
|
|
78869
78973
|
try {
|
|
78870
78974
|
const st2 = statSync3(p);
|
|
78871
78975
|
if (st2.isFile() && e.toLowerCase().endsWith(".md")) {
|
|
@@ -78890,7 +78994,7 @@ function buildStartupInfo(opts) {
|
|
|
78890
78994
|
if (name2 === "node_modules" || name2 === ".git") {
|
|
78891
78995
|
continue;
|
|
78892
78996
|
}
|
|
78893
|
-
const p =
|
|
78997
|
+
const p = join21(dir, name2);
|
|
78894
78998
|
let st2;
|
|
78895
78999
|
try {
|
|
78896
79000
|
st2 = statSync3(p);
|
|
@@ -78907,36 +79011,36 @@ function buildStartupInfo(opts) {
|
|
|
78907
79011
|
} catch {
|
|
78908
79012
|
}
|
|
78909
79013
|
};
|
|
78910
|
-
const globalSkillsDir =
|
|
79014
|
+
const globalSkillsDir = join21(getAgentDir(opts.environment), "skills");
|
|
78911
79015
|
pushSkillFromRoot(globalSkillsDir);
|
|
78912
79016
|
const home = opts.environment["HOME"] ?? opts.environment["USERPROFILE"] ?? "";
|
|
78913
|
-
const legacyAgentsSkillsDir =
|
|
79017
|
+
const legacyAgentsSkillsDir = join21(home, ".agents", "skills");
|
|
78914
79018
|
pushSkillFromRoot(legacyAgentsSkillsDir);
|
|
78915
|
-
const projectSkillsDir =
|
|
79019
|
+
const projectSkillsDir = join21(opts.cwd, ".pi", "skills");
|
|
78916
79020
|
pushSkillFromRoot(projectSkillsDir);
|
|
78917
79021
|
addSection("Skills", skillsItems);
|
|
78918
79022
|
const promptsItems = [];
|
|
78919
|
-
const promptsDir =
|
|
79023
|
+
const promptsDir = join21(home, ".pi", "agent", "prompts");
|
|
78920
79024
|
try {
|
|
78921
79025
|
const prompts = readdirSync6(promptsDir).filter((f) => f.endsWith(".md"));
|
|
78922
79026
|
for (const f of prompts) {
|
|
78923
|
-
promptsItems.push(`/${
|
|
79027
|
+
promptsItems.push(`/${basename6(f, ".md")}`);
|
|
78924
79028
|
}
|
|
78925
79029
|
} catch {
|
|
78926
79030
|
}
|
|
78927
79031
|
addSection("Prompts", promptsItems);
|
|
78928
79032
|
const extItems = [];
|
|
78929
|
-
const extDir =
|
|
79033
|
+
const extDir = join21(home, ".pi", "agent", "extensions");
|
|
78930
79034
|
try {
|
|
78931
79035
|
const exts = readdirSync6(extDir).filter((f) => f.endsWith(".ts") || f.endsWith(".js"));
|
|
78932
79036
|
for (const f of exts) {
|
|
78933
|
-
extItems.push(
|
|
79037
|
+
extItems.push(join21(extDir, f));
|
|
78934
79038
|
}
|
|
78935
79039
|
} catch {
|
|
78936
79040
|
}
|
|
78937
79041
|
const settingsPaths = [
|
|
78938
|
-
|
|
78939
|
-
|
|
79042
|
+
join21(getAgentDir(opts.environment), "settings.json"),
|
|
79043
|
+
join21(opts.cwd, ".pi", "settings.json")
|
|
78940
79044
|
];
|
|
78941
79045
|
for (const settingsPath of settingsPaths) {
|
|
78942
79046
|
try {
|
|
@@ -79137,7 +79241,7 @@ var PiAgentSpecification = class extends InProcessAcpAgentSpecification {
|
|
|
79137
79241
|
// keeps the adapter's opt-in capability flag enabled for every launch it owns.
|
|
79138
79242
|
createLaunchEnvironment = async (_agent, context) => {
|
|
79139
79243
|
const workspaceHash = createHash3("sha256").update(context.defaultWorkspace).digest("hex").slice(0, 24);
|
|
79140
|
-
const sessionDirectory =
|
|
79244
|
+
const sessionDirectory = join22(context.dataDirectory, "agents", "pi", "sessions", workspaceHash);
|
|
79141
79245
|
return Object.freeze({
|
|
79142
79246
|
PI_ACP_ENABLE_EMBEDDED_CONTEXT: "true",
|
|
79143
79247
|
MOBIUS_PI_SESSION_DIR: sessionDirectory
|
|
@@ -79576,11 +79680,11 @@ function isAgentVersionSupported(reportedVersion, minimumSupportedVersion) {
|
|
|
79576
79680
|
}
|
|
79577
79681
|
|
|
79578
79682
|
// src/engine/agent/discovery/executable-discovery.ts
|
|
79579
|
-
import { isAbsolute as
|
|
79683
|
+
import { isAbsolute as isAbsolute14 } from "node:path";
|
|
79580
79684
|
async function resolveSpecificationExecutables(executableName, overrideVariable2, resolveInstalled, context) {
|
|
79581
79685
|
const override = context.environment[overrideVariable2];
|
|
79582
79686
|
if (override !== void 0) {
|
|
79583
|
-
if (override.length === 0 || !
|
|
79687
|
+
if (override.length === 0 || !isAbsolute14(override)) {
|
|
79584
79688
|
return [];
|
|
79585
79689
|
}
|
|
79586
79690
|
const executable = await resolveExecutablePath(override, context.platform);
|
|
@@ -79851,8 +79955,8 @@ var AdapterRegistry = class {
|
|
|
79851
79955
|
#resolve;
|
|
79852
79956
|
#dependencies;
|
|
79853
79957
|
#adapters = /* @__PURE__ */ new Map();
|
|
79854
|
-
constructor(
|
|
79855
|
-
this.#resolve =
|
|
79958
|
+
constructor(resolve20, dependencies) {
|
|
79959
|
+
this.#resolve = resolve20;
|
|
79856
79960
|
this.#dependencies = dependencies;
|
|
79857
79961
|
}
|
|
79858
79962
|
resolve = (agent2) => {
|
|
@@ -79888,7 +79992,7 @@ async function runCleanup(...actions) {
|
|
|
79888
79992
|
var nativeSessionIdSchema = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,255}$/);
|
|
79889
79993
|
|
|
79890
79994
|
// src/engine/acp/adapter/execution-connections.ts
|
|
79891
|
-
import { isAbsolute as
|
|
79995
|
+
import { isAbsolute as isAbsolute15, resolve as resolve14 } from "node:path";
|
|
79892
79996
|
|
|
79893
79997
|
// src/engine/acp/client/prompt-content.ts
|
|
79894
79998
|
function validatePromptContent(options, capabilities) {
|
|
@@ -80635,7 +80739,7 @@ var AcpSessionConnector = class {
|
|
|
80635
80739
|
};
|
|
80636
80740
|
|
|
80637
80741
|
// src/engine/acp/adapter/execution-connections.ts
|
|
80638
|
-
var absolutePathSchema = external_exports.string().min(1).refine(
|
|
80742
|
+
var absolutePathSchema = external_exports.string().min(1).refine(isAbsolute15);
|
|
80639
80743
|
var nativeHistoryRevisionSchema = external_exports.object({ latestEntryId: external_exports.string().max(256) });
|
|
80640
80744
|
var isMethodNotFound = (cause) => cause instanceof RequestError && cause.code === -32601;
|
|
80641
80745
|
var targetSchema = external_exports.object({
|
|
@@ -80729,9 +80833,9 @@ var AcpExecutionConnections = class {
|
|
|
80729
80833
|
);
|
|
80730
80834
|
}
|
|
80731
80835
|
const matches = [...this.#sessions].filter(
|
|
80732
|
-
({ 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(
|
|
80733
80837
|
scope.additionalDirectories,
|
|
80734
|
-
decoded.data.additionalDirectories.map((path6) =>
|
|
80838
|
+
decoded.data.additionalDirectories.map((path6) => resolve14(path6))
|
|
80735
80839
|
)
|
|
80736
80840
|
);
|
|
80737
80841
|
if (matches.length > 1) {
|
|
@@ -81965,11 +82069,11 @@ function describeEnvironmentProxyRoute(target) {
|
|
|
81965
82069
|
}
|
|
81966
82070
|
|
|
81967
82071
|
// src/engine/runtime/observability/diagnostic-log.ts
|
|
81968
|
-
import { join as
|
|
82072
|
+
import { join as join25 } from "node:path";
|
|
81969
82073
|
|
|
81970
82074
|
// src/engine/storage/logs/bounded-log.ts
|
|
81971
82075
|
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync10, renameSync as renameSync2, statSync as statSync5, writeFileSync as writeFileSync2 } from "node:fs";
|
|
81972
|
-
import { join as
|
|
82076
|
+
import { join as join23 } from "node:path";
|
|
81973
82077
|
var BoundedLineLog = class {
|
|
81974
82078
|
#path;
|
|
81975
82079
|
#maximumBytes;
|
|
@@ -81978,7 +82082,7 @@ var BoundedLineLog = class {
|
|
|
81978
82082
|
#onWriteFailure;
|
|
81979
82083
|
constructor(directory, filename, maximumBytes, onWriteFailure = () => void 0) {
|
|
81980
82084
|
this.#directory = directory;
|
|
81981
|
-
this.#path =
|
|
82085
|
+
this.#path = join23(directory, filename);
|
|
81982
82086
|
this.#maximumBytes = maximumBytes;
|
|
81983
82087
|
this.#onWriteFailure = onWriteFailure;
|
|
81984
82088
|
}
|
|
@@ -82029,21 +82133,21 @@ var BoundedLineLog = class {
|
|
|
82029
82133
|
|
|
82030
82134
|
// src/engine/storage/logs/log-files.ts
|
|
82031
82135
|
import { readFileSync as readFileSync11 } from "node:fs";
|
|
82032
|
-
import { join as
|
|
82136
|
+
import { join as join24 } from "node:path";
|
|
82033
82137
|
var DAEMON_LOG_FILENAME = "daemon.log";
|
|
82034
82138
|
var WORKER_LIFECYCLE_LOG_FILENAME = "worker-lifecycle.log";
|
|
82035
82139
|
function unhandledRejectionLogFilename(role) {
|
|
82036
82140
|
return `unhandled-rejections-${role}.log`;
|
|
82037
82141
|
}
|
|
82038
82142
|
function logDirectory(dataDirectory) {
|
|
82039
|
-
return
|
|
82143
|
+
return join24(dataDirectory, "logs");
|
|
82040
82144
|
}
|
|
82041
82145
|
function processLogPaths(dataDirectory) {
|
|
82042
82146
|
return [
|
|
82043
82147
|
WORKER_LIFECYCLE_LOG_FILENAME,
|
|
82044
82148
|
unhandledRejectionLogFilename("manager"),
|
|
82045
82149
|
unhandledRejectionLogFilename("worker")
|
|
82046
|
-
].map((filename) =>
|
|
82150
|
+
].map((filename) => join24(logDirectory(dataDirectory), filename));
|
|
82047
82151
|
}
|
|
82048
82152
|
function readLogText(path6) {
|
|
82049
82153
|
try {
|
|
@@ -82118,7 +82222,7 @@ var RuntimeDiagnosticLog = class {
|
|
|
82118
82222
|
this.#maximumBytes = maximumBytes;
|
|
82119
82223
|
const processLogsDirectory = options.processLogsDirectory;
|
|
82120
82224
|
this.#sources = [
|
|
82121
|
-
{ maximumBytes, path:
|
|
82225
|
+
{ maximumBytes, path: join25(directory, DAEMON_LOG_FILENAME) },
|
|
82122
82226
|
// The process logs a Runtime does not own, but must read to explain its own deaths.
|
|
82123
82227
|
...processLogsDirectory === void 0 ? [] : processLogPaths(processLogsDirectory).map((path6) => ({ maximumBytes: null, path: path6 }))
|
|
82124
82228
|
];
|
|
@@ -82347,7 +82451,7 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
82347
82451
|
}
|
|
82348
82452
|
|
|
82349
82453
|
// src/engine/runtime/config.ts
|
|
82350
|
-
import { resolve as
|
|
82454
|
+
import { resolve as resolve15 } from "node:path";
|
|
82351
82455
|
|
|
82352
82456
|
// src/engine/util/serial-task-queue.ts
|
|
82353
82457
|
var SerialTaskQueue = class {
|
|
@@ -82424,7 +82528,7 @@ var RuntimeLocalContext = class {
|
|
|
82424
82528
|
stateDirectory;
|
|
82425
82529
|
maxAcpProcesses;
|
|
82426
82530
|
constructor(stateDirectory, agentLaunchEnvironment, maxAcpProcesses = 1e3) {
|
|
82427
|
-
this.stateDirectory =
|
|
82531
|
+
this.stateDirectory = resolve15(stateDirectory);
|
|
82428
82532
|
this.agentLaunchEnvironment = Object.freeze({ ...agentLaunchEnvironment });
|
|
82429
82533
|
this.maxAcpProcesses = maxAcpProcesses;
|
|
82430
82534
|
}
|
|
@@ -82579,7 +82683,7 @@ function validatePairingId(value) {
|
|
|
82579
82683
|
return value;
|
|
82580
82684
|
}
|
|
82581
82685
|
async function resolveDefaultWorkspace(path6) {
|
|
82582
|
-
const requestedWorkspace =
|
|
82686
|
+
const requestedWorkspace = resolve16(path6);
|
|
82583
82687
|
let defaultWorkspace;
|
|
82584
82688
|
try {
|
|
82585
82689
|
defaultWorkspace = await ensureCanonicalDirectory(requestedWorkspace);
|
|
@@ -82649,7 +82753,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, signal) {
|
|
|
82649
82753
|
agents,
|
|
82650
82754
|
machineName: hostname3(),
|
|
82651
82755
|
pairingCode: options.code,
|
|
82652
|
-
workspaceName:
|
|
82756
|
+
workspaceName: basename7(defaultWorkspace) || "Local workspace"
|
|
82653
82757
|
}),
|
|
82654
82758
|
dispatcher: environmentProxyDispatcher,
|
|
82655
82759
|
headers: { "content-type": "application/json" },
|
|
@@ -82757,7 +82861,7 @@ async function prepareRuntimeConnection(installation, connection, signal, enviro
|
|
|
82757
82861
|
}
|
|
82758
82862
|
|
|
82759
82863
|
// src/engine/runtime/runtime-loop.ts
|
|
82760
|
-
import { resolve as
|
|
82864
|
+
import { resolve as resolve18 } from "node:path";
|
|
82761
82865
|
|
|
82762
82866
|
// src/engine/runtime/run.ts
|
|
82763
82867
|
import { styleText } from "node:util";
|
|
@@ -83267,7 +83371,7 @@ function sql(strings, ...params) {
|
|
|
83267
83371
|
return new SQL([new StringChunk(str)]);
|
|
83268
83372
|
}
|
|
83269
83373
|
_sql.raw = raw;
|
|
83270
|
-
function
|
|
83374
|
+
function join32(chunks, separator) {
|
|
83271
83375
|
const result = [];
|
|
83272
83376
|
for (const [i, chunk] of chunks.entries()) {
|
|
83273
83377
|
if (i > 0 && separator !== void 0) result.push(separator);
|
|
@@ -83275,7 +83379,7 @@ function sql(strings, ...params) {
|
|
|
83275
83379
|
}
|
|
83276
83380
|
return new SQL(result);
|
|
83277
83381
|
}
|
|
83278
|
-
_sql.join =
|
|
83382
|
+
_sql.join = join32;
|
|
83279
83383
|
function identifier2(value) {
|
|
83280
83384
|
return new Name(value);
|
|
83281
83385
|
}
|
|
@@ -85420,7 +85524,7 @@ var SQLiteSelectBase = class extends TypedQueryBuilder {
|
|
|
85420
85524
|
const baseTableName = this.tableName;
|
|
85421
85525
|
const tableName = getTableLikeName(table);
|
|
85422
85526
|
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
85423
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
85527
|
+
if (typeof tableName === "string" && this.config.joins?.some((join32) => join32.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
85424
85528
|
if (!this.isPartialSelect) {
|
|
85425
85529
|
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
|
|
85426
85530
|
if (typeof tableName === "string" && !is(table, SQL)) {
|
|
@@ -86259,7 +86363,7 @@ var SQLiteDialect = class {
|
|
|
86259
86363
|
if (!joins2) return;
|
|
86260
86364
|
const withEntries = Object.entries(joins2).filter(([_, v]) => v);
|
|
86261
86365
|
if (!withEntries.length) return;
|
|
86262
|
-
return sql.join(withEntries.map(([k2,
|
|
86366
|
+
return sql.join(withEntries.map(([k2, join32]) => {
|
|
86263
86367
|
const relation = tableConfig.relations[k2];
|
|
86264
86368
|
const isSingle2 = is(relation, One2);
|
|
86265
86369
|
const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
|
|
@@ -86270,7 +86374,7 @@ var SQLiteDialect = class {
|
|
|
86270
86374
|
table: targetTable,
|
|
86271
86375
|
mode: isSingle2 ? "first" : "many",
|
|
86272
86376
|
schema,
|
|
86273
|
-
queryConfig:
|
|
86377
|
+
queryConfig: join32,
|
|
86274
86378
|
tableConfig: schema[relation.targetTableName],
|
|
86275
86379
|
relationWhere: filter,
|
|
86276
86380
|
isNested: true,
|
|
@@ -86284,7 +86388,7 @@ var SQLiteDialect = class {
|
|
|
86284
86388
|
key: k2,
|
|
86285
86389
|
selection: innerQuery.selection,
|
|
86286
86390
|
isArray: !isSingle2,
|
|
86287
|
-
isOptional: (relation.optional ?? false) ||
|
|
86391
|
+
isOptional: (relation.optional ?? false) || join32 !== true && !!join32.where
|
|
86288
86392
|
});
|
|
86289
86393
|
const jsonColumns = sql.join(innerQuery.selection.map((s) => {
|
|
86290
86394
|
return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
|
|
@@ -86900,7 +87004,7 @@ var SQLiteUpdateBase = class {
|
|
|
86900
87004
|
createJoin(joinType) {
|
|
86901
87005
|
return ((table, on2) => {
|
|
86902
87006
|
const tableName = getTableLikeName(table);
|
|
86903
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
87007
|
+
if (typeof tableName === "string" && this.config.joins.some((join32) => join32.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
86904
87008
|
if (typeof on2 === "function") {
|
|
86905
87009
|
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;
|
|
86906
87010
|
on2 = on2(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
|
|
@@ -87852,7 +87956,7 @@ var SessionEventCacheTable = class {
|
|
|
87852
87956
|
// src/engine/storage/sqlite/local-databases.ts
|
|
87853
87957
|
import { createHash as createHash4 } from "node:crypto";
|
|
87854
87958
|
import { existsSync as existsSync9 } from "node:fs";
|
|
87855
|
-
import { join as
|
|
87959
|
+
import { join as join26 } from "node:path";
|
|
87856
87960
|
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
87857
87961
|
|
|
87858
87962
|
// src/engine/generated/acp-session-store-migrations.ts
|
|
@@ -88095,9 +88199,9 @@ var LocalSqliteDatabase = class {
|
|
|
88095
88199
|
function channelSessionDatabasePaths(stateDirectory, channelId) {
|
|
88096
88200
|
const channelHash = createHash4("sha256").update(channelId).digest("hex");
|
|
88097
88201
|
return {
|
|
88098
|
-
cancellations:
|
|
88099
|
-
events:
|
|
88100
|
-
sessions:
|
|
88202
|
+
cancellations: join26(stateDirectory, "sessions", `${channelHash}.cancellations.sqlite`),
|
|
88203
|
+
events: join26(stateDirectory, "sessions", `${channelHash}.events.sqlite`),
|
|
88204
|
+
sessions: join26(stateDirectory, "sessions", `${channelHash}.sqlite`)
|
|
88101
88205
|
};
|
|
88102
88206
|
}
|
|
88103
88207
|
function recordAppliedAdmissionOrder(path6) {
|
|
@@ -88253,14 +88357,14 @@ function mergeTextChunk(previous, incoming) {
|
|
|
88253
88357
|
var SessionEventHistoryProjection = class {
|
|
88254
88358
|
#toolCallEventIds = /* @__PURE__ */ new Map();
|
|
88255
88359
|
#latestEvent = null;
|
|
88256
|
-
apply = (liveEvent2,
|
|
88360
|
+
apply = (liveEvent2, resolve20) => {
|
|
88257
88361
|
if (liveEvent2.type === "lifecycle-metadata") {
|
|
88258
88362
|
this.#latestEvent = null;
|
|
88259
88363
|
return { kind: "skip" };
|
|
88260
88364
|
}
|
|
88261
88365
|
if (liveEvent2.type === "acp" && liveEvent2.payload.sessionUpdate === "tool_call_update") {
|
|
88262
88366
|
const targetEventId = this.#toolCallEventIds.get(liveEvent2.payload.toolCallId);
|
|
88263
|
-
const current = targetEventId === void 0 ? void 0 :
|
|
88367
|
+
const current = targetEventId === void 0 ? void 0 : resolve20([targetEventId]).get(targetEventId);
|
|
88264
88368
|
if (current?.type === "acp" && (current.payload.sessionUpdate === "tool_call" || current.payload.sessionUpdate === "tool_call_update")) {
|
|
88265
88369
|
return this.#replace(
|
|
88266
88370
|
current,
|
|
@@ -88284,12 +88388,12 @@ var SessionEventHistoryProjection = class {
|
|
|
88284
88388
|
* The projected tool call announced with this identifier, in its current
|
|
88285
88389
|
* merged form, or `undefined` when the projection has not recorded one.
|
|
88286
88390
|
*/
|
|
88287
|
-
getToolCall = (toolCallId,
|
|
88391
|
+
getToolCall = (toolCallId, resolve20) => {
|
|
88288
88392
|
const eventId = this.#toolCallEventIds.get(toolCallId);
|
|
88289
88393
|
if (eventId === void 0) {
|
|
88290
88394
|
return void 0;
|
|
88291
88395
|
}
|
|
88292
|
-
const event =
|
|
88396
|
+
const event = resolve20([eventId]).get(eventId);
|
|
88293
88397
|
if (event?.type === "acp" && (event.payload.sessionUpdate === "tool_call" || event.payload.sessionUpdate === "tool_call_update")) {
|
|
88294
88398
|
return event.payload;
|
|
88295
88399
|
}
|
|
@@ -88349,8 +88453,8 @@ var SessionEvents = class {
|
|
|
88349
88453
|
this.sessionGenerationId = sessionGenerationId;
|
|
88350
88454
|
this.#projection = new SessionEventHistoryProjection();
|
|
88351
88455
|
}
|
|
88352
|
-
apply = (event,
|
|
88353
|
-
const projected = this.#projection.apply(event,
|
|
88456
|
+
apply = (event, resolve20) => {
|
|
88457
|
+
const projected = this.#projection.apply(event, resolve20);
|
|
88354
88458
|
this.#throughPosition = event.position;
|
|
88355
88459
|
if (projected.kind === "skip") {
|
|
88356
88460
|
return;
|
|
@@ -88377,7 +88481,7 @@ var SessionEvents = class {
|
|
|
88377
88481
|
return this.#cachedItemsByEventId.size;
|
|
88378
88482
|
}
|
|
88379
88483
|
/** The projected tool call for this identifier, materializing it if needed. */
|
|
88380
|
-
toolCall = (toolCallId,
|
|
88484
|
+
toolCall = (toolCallId, resolve20) => this.#projection.getToolCall(toolCallId, resolve20);
|
|
88381
88485
|
item = (eventId) => this.#cachedItemsByEventId.get(eventId)?.event;
|
|
88382
88486
|
/**
|
|
88383
88487
|
* Materializes an event that was previously dropped to the cache database.
|
|
@@ -90808,19 +90912,30 @@ var SessionManager2 = class {
|
|
|
90808
90912
|
}
|
|
90809
90913
|
prepareSession = async (options, metrics = unmeasuredOperationMetrics, closed = "reopen") => await this.#prepareSession(options, { kind: "interactive-only" }, closed, metrics);
|
|
90810
90914
|
restoreSession = async (options, metrics = unmeasuredOperationMetrics, closed = "reopen") => await this.#prepareSession(options, { kind: "history-required" }, closed, metrics);
|
|
90915
|
+
inspectAgentSettings = async (options, models = /* @__PURE__ */ new Map()) => {
|
|
90916
|
+
options.signal.throwIfAborted();
|
|
90917
|
+
const inspections = await this.#probeAgentSettings(options);
|
|
90918
|
+
options.signal.throwIfAborted();
|
|
90919
|
+
for (const [model, result] of inspections.models) {
|
|
90920
|
+
models.set(model, result);
|
|
90921
|
+
}
|
|
90922
|
+
models.set(options.model, inspections.requested);
|
|
90923
|
+
if (inspections.requested instanceof AcpConfigurationValueUnavailableError) {
|
|
90924
|
+
throw inspections.requested;
|
|
90925
|
+
}
|
|
90926
|
+
return inspections.requested;
|
|
90927
|
+
};
|
|
90811
90928
|
/**
|
|
90812
90929
|
* Opens a short-lived native ACP session only to read the local Agent's
|
|
90813
90930
|
* authoritative settings. Its identity and store are private to this
|
|
90814
90931
|
* operation and never become a Mobius Session.
|
|
90815
90932
|
*/
|
|
90816
|
-
|
|
90933
|
+
#probeAgentSettings = async (options) => this.#operations.run(options, async (options2) => {
|
|
90934
|
+
const sessionId = `agent-settings-${crypto.randomUUID()}`;
|
|
90817
90935
|
return await this.#processes.runTransient(
|
|
90818
90936
|
options2.signal,
|
|
90819
90937
|
async () => await AgentSession.start(
|
|
90820
|
-
{
|
|
90821
|
-
...options2,
|
|
90822
|
-
sessionId: `agent-settings-${crypto.randomUUID()}`
|
|
90823
|
-
},
|
|
90938
|
+
{ ...options2, sessionId },
|
|
90824
90939
|
{ kind: "interactive-only" },
|
|
90825
90940
|
() => this.#agentSettingsObserver,
|
|
90826
90941
|
() => void 0,
|
|
@@ -90830,25 +90945,56 @@ var SessionManager2 = class {
|
|
|
90830
90945
|
),
|
|
90831
90946
|
async (runtime) => {
|
|
90832
90947
|
const prepared = runtime.prepared();
|
|
90833
|
-
const
|
|
90834
|
-
const
|
|
90948
|
+
const nativeEffort = runtime.agentSettingsModelEffort();
|
|
90949
|
+
const snapshot = (configOptions) => new AgentSettingsSnapshot(
|
|
90950
|
+
prepared.agentName,
|
|
90951
|
+
prepared.agentVersion,
|
|
90952
|
+
configOptions,
|
|
90953
|
+
nativeEffort === null ? { kind: "unavailable" } : { kind: "complete", value: nativeEffort }
|
|
90954
|
+
);
|
|
90835
90955
|
const modelOption2 = prepared.configOptions.find(isModelOption);
|
|
90836
|
-
const
|
|
90837
|
-
const configOptions = model === void 0 || modelIsFixed ? prepared.configOptions : (await runtime.applyConfiguration({
|
|
90956
|
+
const change = async (configId, value) => (await runtime.applyConfiguration({
|
|
90838
90957
|
...options2,
|
|
90839
90958
|
booleanValue: false,
|
|
90840
|
-
configId
|
|
90959
|
+
configId,
|
|
90841
90960
|
requestId: "agent-settings-model",
|
|
90842
|
-
sessionId
|
|
90843
|
-
value
|
|
90961
|
+
sessionId,
|
|
90962
|
+
value,
|
|
90844
90963
|
valueType: "select"
|
|
90845
90964
|
})).configOptions;
|
|
90846
|
-
|
|
90847
|
-
|
|
90848
|
-
|
|
90849
|
-
|
|
90850
|
-
|
|
90851
|
-
|
|
90965
|
+
const inspectModel = async (model) => {
|
|
90966
|
+
if (modelOption2?.type === "select" && modelOption2.values.length < 2 && modelOption2.currentValue === model) {
|
|
90967
|
+
return snapshot(prepared.configOptions);
|
|
90968
|
+
}
|
|
90969
|
+
try {
|
|
90970
|
+
return snapshot(await change(modelOption2?.id ?? "model", model));
|
|
90971
|
+
} catch (error62) {
|
|
90972
|
+
options2.signal.throwIfAborted();
|
|
90973
|
+
if (error62 instanceof AcpConfigurationValueUnavailableError && error62.configId === (modelOption2?.id ?? "model") && error62.requestedValue === model) {
|
|
90974
|
+
return error62;
|
|
90975
|
+
}
|
|
90976
|
+
throw error62;
|
|
90977
|
+
}
|
|
90978
|
+
};
|
|
90979
|
+
const models = /* @__PURE__ */ new Map();
|
|
90980
|
+
if (options2.model !== void 0) {
|
|
90981
|
+
return { requested: await inspectModel(options2.model), models };
|
|
90982
|
+
}
|
|
90983
|
+
if (nativeEffort?.resolution === AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE && modelOption2?.type === "select" && Object.hasOwn(nativeEffort.valuesByModel, modelOption2.currentValue)) {
|
|
90984
|
+
const effort = prepared.configOptions.find(
|
|
90985
|
+
(option) => option.id === nativeEffort.effortSettingId
|
|
90986
|
+
);
|
|
90987
|
+
for (const { value } of modelOption2.values) {
|
|
90988
|
+
models.set(value, await inspectModel(value));
|
|
90989
|
+
if (value !== modelOption2.currentValue && modelOption2.currentValue !== "") {
|
|
90990
|
+
await change(modelOption2.id, modelOption2.currentValue);
|
|
90991
|
+
if (effort?.type === "select" && effort.currentValue !== "") {
|
|
90992
|
+
await change(effort.id, effort.currentValue);
|
|
90993
|
+
}
|
|
90994
|
+
}
|
|
90995
|
+
}
|
|
90996
|
+
}
|
|
90997
|
+
return { requested: snapshot(prepared.configOptions), models };
|
|
90852
90998
|
},
|
|
90853
90999
|
async (runtime) => await runtime.close()
|
|
90854
91000
|
);
|
|
@@ -92033,8 +92179,8 @@ var RuntimeTurnActivity = class {
|
|
|
92033
92179
|
#changed() {
|
|
92034
92180
|
this.#changedAt = Date.now();
|
|
92035
92181
|
if (this.count() === 0) {
|
|
92036
|
-
for (const
|
|
92037
|
-
|
|
92182
|
+
for (const resolve20 of this.#idleWaiters) {
|
|
92183
|
+
resolve20();
|
|
92038
92184
|
}
|
|
92039
92185
|
this.#idleWaiters.clear();
|
|
92040
92186
|
}
|
|
@@ -92044,14 +92190,14 @@ var RuntimeTurnActivity = class {
|
|
|
92044
92190
|
if (this.count() === 0) {
|
|
92045
92191
|
return Promise.resolve();
|
|
92046
92192
|
}
|
|
92047
|
-
return new Promise((
|
|
92193
|
+
return new Promise((resolve20, reject2) => {
|
|
92048
92194
|
const abort = () => {
|
|
92049
92195
|
this.#idleWaiters.delete(idle);
|
|
92050
92196
|
reject2(signal.reason);
|
|
92051
92197
|
};
|
|
92052
92198
|
const idle = () => {
|
|
92053
92199
|
signal.removeEventListener("abort", abort);
|
|
92054
|
-
|
|
92200
|
+
resolve20();
|
|
92055
92201
|
};
|
|
92056
92202
|
this.#idleWaiters.add(idle);
|
|
92057
92203
|
signal.addEventListener("abort", abort, { once: true });
|
|
@@ -92215,7 +92361,7 @@ var ActiveRuntimeTurn = class {
|
|
|
92215
92361
|
// src/engine/session/turn/session-execution.ts
|
|
92216
92362
|
var waitForTurnCompletion = (turn, waitSignal) => {
|
|
92217
92363
|
waitSignal.throwIfAborted();
|
|
92218
|
-
return new Promise((
|
|
92364
|
+
return new Promise((resolve20, reject2) => {
|
|
92219
92365
|
let settled = false;
|
|
92220
92366
|
const finish = (result) => {
|
|
92221
92367
|
if (settled) {
|
|
@@ -92224,7 +92370,7 @@ var waitForTurnCompletion = (turn, waitSignal) => {
|
|
|
92224
92370
|
settled = true;
|
|
92225
92371
|
waitSignal.removeEventListener("abort", onAbort);
|
|
92226
92372
|
if (result.kind === "completed") {
|
|
92227
|
-
|
|
92373
|
+
resolve20();
|
|
92228
92374
|
} else {
|
|
92229
92375
|
reject2(result.error);
|
|
92230
92376
|
}
|
|
@@ -92407,7 +92553,7 @@ var SessionTurns = class {
|
|
|
92407
92553
|
|
|
92408
92554
|
// src/engine/session/workspace/workspace-directory.ts
|
|
92409
92555
|
import { homedir as homedir3 } from "node:os";
|
|
92410
|
-
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";
|
|
92411
92557
|
|
|
92412
92558
|
// src/engine/session/workspace/local-authorization-error.ts
|
|
92413
92559
|
var LocalAuthorizationError = class extends OperationError {
|
|
@@ -92473,7 +92619,7 @@ var WorkspaceDirectoryService = class {
|
|
|
92473
92619
|
}
|
|
92474
92620
|
if (id.startsWith("path-")) {
|
|
92475
92621
|
const path6 = expandCurrentUserHome(decodePath(id, "path-"));
|
|
92476
|
-
if (
|
|
92622
|
+
if (isAbsolute16(path6)) {
|
|
92477
92623
|
return path6;
|
|
92478
92624
|
}
|
|
92479
92625
|
}
|
|
@@ -92481,7 +92627,7 @@ var WorkspaceDirectoryService = class {
|
|
|
92481
92627
|
};
|
|
92482
92628
|
resolvePath = async (requested, signal) => {
|
|
92483
92629
|
signal.throwIfAborted();
|
|
92484
|
-
if (!
|
|
92630
|
+
if (!isAbsolute16(requested) || requested.includes("\0") || normalize2(requested) !== requested) {
|
|
92485
92631
|
throw new LocalAuthorizationError("The local directory path is invalid");
|
|
92486
92632
|
}
|
|
92487
92633
|
try {
|
|
@@ -92489,7 +92635,7 @@ var WorkspaceDirectoryService = class {
|
|
|
92489
92635
|
signal.throwIfAborted();
|
|
92490
92636
|
const metadata = await readPathMetadata(target);
|
|
92491
92637
|
signal.throwIfAborted();
|
|
92492
|
-
if (!
|
|
92638
|
+
if (!isAbsolute16(target) || normalize2(target) !== target || metadata.kind !== "directory") {
|
|
92493
92639
|
throw new LocalAuthorizationError("The selected location is not a directory");
|
|
92494
92640
|
}
|
|
92495
92641
|
return target;
|
|
@@ -92504,8 +92650,8 @@ var WorkspaceDirectoryService = class {
|
|
|
92504
92650
|
}
|
|
92505
92651
|
};
|
|
92506
92652
|
label = (path6) => {
|
|
92507
|
-
const suffix =
|
|
92508
|
-
return suffix === "" ? "~" : !
|
|
92653
|
+
const suffix = relative3(homedir3(), path6);
|
|
92654
|
+
return suffix === "" ? "~" : !isAbsolute16(suffix) && suffix !== ".." && !suffix.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) ? `~/${suffix.replaceAll("\\", "/")}` : path6;
|
|
92509
92655
|
};
|
|
92510
92656
|
identify = async (bindingId, requestedPath2, signal) => {
|
|
92511
92657
|
this.authorizeMachine(bindingId);
|
|
@@ -92513,7 +92659,7 @@ var WorkspaceDirectoryService = class {
|
|
|
92513
92659
|
return {
|
|
92514
92660
|
path: path6,
|
|
92515
92661
|
directoryId: encodePath(path6),
|
|
92516
|
-
name:
|
|
92662
|
+
name: basename8(path6) || path6,
|
|
92517
92663
|
label: this.label(path6)
|
|
92518
92664
|
};
|
|
92519
92665
|
};
|
|
@@ -92526,7 +92672,7 @@ var WorkspaceDirectoryService = class {
|
|
|
92526
92672
|
this.authorizeMachine(bindingId);
|
|
92527
92673
|
return {
|
|
92528
92674
|
directoryId: encodePath(recordedPath),
|
|
92529
|
-
name:
|
|
92675
|
+
name: basename8(recordedPath) || recordedPath,
|
|
92530
92676
|
label: this.label(recordedPath)
|
|
92531
92677
|
};
|
|
92532
92678
|
};
|
|
@@ -92553,7 +92699,7 @@ var WorkspaceDirectoryService = class {
|
|
|
92553
92699
|
continue;
|
|
92554
92700
|
}
|
|
92555
92701
|
try {
|
|
92556
|
-
const path6 = await this.resolvePath(
|
|
92702
|
+
const path6 = await this.resolvePath(join27(target, child.name), signal);
|
|
92557
92703
|
entries.push({ directoryId: encodePath(path6), name: child.name });
|
|
92558
92704
|
} catch (cause) {
|
|
92559
92705
|
signal.throwIfAborted();
|
|
@@ -92727,13 +92873,13 @@ function buildSessionLayer(options) {
|
|
|
92727
92873
|
|
|
92728
92874
|
// src/engine/session/content/external-content-store.ts
|
|
92729
92875
|
import { createHash as createHash8 } from "node:crypto";
|
|
92730
|
-
import { extname as extname2, join as
|
|
92876
|
+
import { extname as extname2, join as join29 } from "node:path";
|
|
92731
92877
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
92732
92878
|
|
|
92733
92879
|
// src/engine/storage/files/scratch-directory.ts
|
|
92734
92880
|
import { randomUUID as randomUUID16 } from "node:crypto";
|
|
92735
|
-
import { lstat as lstat4, mkdir as mkdir5, readdir as readdir6, readFile as readFile7, realpath as realpath7, rename as rename4, rm as
|
|
92736
|
-
import { dirname as dirname11, join as
|
|
92881
|
+
import { lstat as lstat4, mkdir as mkdir5, readdir as readdir6, readFile as readFile7, realpath as realpath7, rename as rename4, rm as rm5, stat as stat6, utimes, writeFile as writeFile2 } from "node:fs/promises";
|
|
92882
|
+
import { dirname as dirname11, join as join28 } from "node:path";
|
|
92737
92883
|
async function atomicWrite(path6, bytes, signal) {
|
|
92738
92884
|
const temporary = `${path6}.${randomUUID16()}.tmp`;
|
|
92739
92885
|
try {
|
|
@@ -92741,13 +92887,13 @@ async function atomicWrite(path6, bytes, signal) {
|
|
|
92741
92887
|
signal.throwIfAborted();
|
|
92742
92888
|
await rename4(temporary, path6);
|
|
92743
92889
|
} finally {
|
|
92744
|
-
await
|
|
92890
|
+
await rm5(temporary, { force: true });
|
|
92745
92891
|
}
|
|
92746
92892
|
}
|
|
92747
92893
|
var ScratchDirectory = class {
|
|
92748
92894
|
#root;
|
|
92749
92895
|
constructor(parent) {
|
|
92750
|
-
this.#root =
|
|
92896
|
+
this.#root = join28(parent, randomUUID16());
|
|
92751
92897
|
}
|
|
92752
92898
|
/** Refreshes this directory's lease and removes sibling directories whose lease is older than `leaseMilliseconds`. */
|
|
92753
92899
|
refreshLease = async (leaseMilliseconds) => {
|
|
@@ -92758,7 +92904,7 @@ var ScratchDirectory = class {
|
|
|
92758
92904
|
if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
|
|
92759
92905
|
continue;
|
|
92760
92906
|
}
|
|
92761
|
-
const path6 =
|
|
92907
|
+
const path6 = join28(dirname11(this.#root), directory.name);
|
|
92762
92908
|
if (path6 === this.#root) {
|
|
92763
92909
|
continue;
|
|
92764
92910
|
}
|
|
@@ -92767,21 +92913,21 @@ var ScratchDirectory = class {
|
|
|
92767
92913
|
() => Date.now()
|
|
92768
92914
|
);
|
|
92769
92915
|
if (modified + leaseMilliseconds <= Date.now()) {
|
|
92770
|
-
await
|
|
92916
|
+
await rm5(path6, { force: true, recursive: true });
|
|
92771
92917
|
}
|
|
92772
92918
|
}
|
|
92773
92919
|
};
|
|
92774
92920
|
/** Writes `bytes` atomically to `<group>/<name>` with owner-only permissions and returns the path. */
|
|
92775
92921
|
write = async (group, name2, bytes, signal) => {
|
|
92776
|
-
const directory =
|
|
92922
|
+
const directory = join28(this.#root, group);
|
|
92777
92923
|
await mkdir5(directory, { mode: 448, recursive: true });
|
|
92778
92924
|
signal.throwIfAborted();
|
|
92779
|
-
const path6 =
|
|
92925
|
+
const path6 = join28(directory, name2);
|
|
92780
92926
|
await atomicWrite(path6, bytes, signal);
|
|
92781
92927
|
return path6;
|
|
92782
92928
|
};
|
|
92783
92929
|
remove = async (path6) => {
|
|
92784
|
-
await
|
|
92930
|
+
await rm5(path6, { force: true });
|
|
92785
92931
|
};
|
|
92786
92932
|
/** The canonical path of a written file, or null when it is gone, is not a regular file, or escapes its directory. */
|
|
92787
92933
|
resolveFile = async (path6) => {
|
|
@@ -92803,7 +92949,7 @@ var ScratchDirectory = class {
|
|
|
92803
92949
|
return resolved === null ? null : new Uint8Array(await readFile7(resolved, { signal }));
|
|
92804
92950
|
};
|
|
92805
92951
|
removeAll = async () => {
|
|
92806
|
-
await
|
|
92952
|
+
await rm5(this.#root, { force: true, recursive: true });
|
|
92807
92953
|
};
|
|
92808
92954
|
};
|
|
92809
92955
|
|
|
@@ -92827,7 +92973,7 @@ var LocalExternalContentStore = class {
|
|
|
92827
92973
|
#expirationTimer;
|
|
92828
92974
|
#cleanup = Promise.resolve();
|
|
92829
92975
|
constructor(stateDirectory) {
|
|
92830
|
-
this.#scratch = new ScratchDirectory(
|
|
92976
|
+
this.#scratch = new ScratchDirectory(join29(stateDirectory, "tmp", "session-content"));
|
|
92831
92977
|
this.#expirationTimer = setInterval(() => {
|
|
92832
92978
|
void this.#expire().catch(() => void 0);
|
|
92833
92979
|
}, 6e4);
|
|
@@ -93233,6 +93379,176 @@ var AgentProcessPool = class {
|
|
|
93233
93379
|
};
|
|
93234
93380
|
};
|
|
93235
93381
|
|
|
93382
|
+
// src/engine/session/settings/agent-settings-cache.ts
|
|
93383
|
+
import { createHash as createHash9, randomUUID as randomUUID17 } from "node:crypto";
|
|
93384
|
+
import { join as join30 } from "node:path";
|
|
93385
|
+
var CACHE_FILE_LIMIT = 32 * 1024 * 1024;
|
|
93386
|
+
var CACHE_FORMAT = 1;
|
|
93387
|
+
var generationSchema = external_exports.union([external_exports.literal("initial"), external_exports.uuid()]);
|
|
93388
|
+
var modelEffortSchema = external_exports.discriminatedUnion("kind", [
|
|
93389
|
+
external_exports.object({ kind: external_exports.literal("unavailable") }),
|
|
93390
|
+
external_exports.object({
|
|
93391
|
+
kind: external_exports.literal("complete"),
|
|
93392
|
+
value: external_exports.object({
|
|
93393
|
+
effortSettingId: external_exports.string(),
|
|
93394
|
+
modelSettingId: external_exports.string(),
|
|
93395
|
+
resolution: external_exports.enum(["complete", "on_model_selection", "unavailable"]),
|
|
93396
|
+
unsupportedModelIds: external_exports.array(external_exports.string()),
|
|
93397
|
+
valuesByModel: external_exports.record(
|
|
93398
|
+
external_exports.string(),
|
|
93399
|
+
external_exports.array(
|
|
93400
|
+
external_exports.object({
|
|
93401
|
+
description: external_exports.string(),
|
|
93402
|
+
groupId: external_exports.string(),
|
|
93403
|
+
groupName: external_exports.string(),
|
|
93404
|
+
name: external_exports.string(),
|
|
93405
|
+
value: external_exports.string()
|
|
93406
|
+
})
|
|
93407
|
+
)
|
|
93408
|
+
)
|
|
93409
|
+
})
|
|
93410
|
+
})
|
|
93411
|
+
]);
|
|
93412
|
+
var cacheSchema = external_exports.object({
|
|
93413
|
+
format: external_exports.literal(CACHE_FORMAT),
|
|
93414
|
+
generation: generationSchema,
|
|
93415
|
+
fingerprint: external_exports.string(),
|
|
93416
|
+
inspections: external_exports.array(
|
|
93417
|
+
external_exports.object({
|
|
93418
|
+
model: external_exports.string().nullable(),
|
|
93419
|
+
result: external_exports.discriminatedUnion("kind", [
|
|
93420
|
+
external_exports.object({
|
|
93421
|
+
kind: external_exports.literal("snapshot"),
|
|
93422
|
+
agentName: external_exports.string(),
|
|
93423
|
+
agentVersion: external_exports.string(),
|
|
93424
|
+
configOptions: external_exports.unknown(),
|
|
93425
|
+
modelEffort: modelEffortSchema
|
|
93426
|
+
}),
|
|
93427
|
+
external_exports.object({
|
|
93428
|
+
kind: external_exports.literal("unavailable"),
|
|
93429
|
+
configId: external_exports.string(),
|
|
93430
|
+
requestedValue: external_exports.string(),
|
|
93431
|
+
offeredValues: external_exports.array(external_exports.string())
|
|
93432
|
+
})
|
|
93433
|
+
])
|
|
93434
|
+
})
|
|
93435
|
+
).max(1001)
|
|
93436
|
+
});
|
|
93437
|
+
function hash2(value) {
|
|
93438
|
+
return createHash9("sha256").update(JSON.stringify(value)).digest("hex");
|
|
93439
|
+
}
|
|
93440
|
+
async function readCache(path6) {
|
|
93441
|
+
const result = await readInstallationFile(path6, CACHE_FILE_LIMIT);
|
|
93442
|
+
return result.kind === "read" ? cacheSchema.parse(JSON.parse(result.text)) : void 0;
|
|
93443
|
+
}
|
|
93444
|
+
var AgentSettingsCache = class {
|
|
93445
|
+
#directory;
|
|
93446
|
+
#generationPath;
|
|
93447
|
+
#generation = 0;
|
|
93448
|
+
constructor(stateDirectory) {
|
|
93449
|
+
this.#directory = join30(stateDirectory, "agent-settings");
|
|
93450
|
+
this.#generationPath = join30(this.#directory, "generation");
|
|
93451
|
+
}
|
|
93452
|
+
get generation() {
|
|
93453
|
+
return this.#generation;
|
|
93454
|
+
}
|
|
93455
|
+
invalidate = async (signal) => {
|
|
93456
|
+
await writeInstallationFile(this.#generationPath, randomUUID17(), signal);
|
|
93457
|
+
this.#generation += 1;
|
|
93458
|
+
};
|
|
93459
|
+
open = async (agent2, signal) => {
|
|
93460
|
+
const inspections = /* @__PURE__ */ new Map();
|
|
93461
|
+
const path6 = join30(this.#directory, `${hash2(agent2.id)}.json`);
|
|
93462
|
+
const fingerprint = hash2([
|
|
93463
|
+
agent2.agentVersion,
|
|
93464
|
+
agent2.adapterVersion,
|
|
93465
|
+
agent2.runtimeExecutables,
|
|
93466
|
+
// An installation can serve different harness profiles, which may expose different providers.
|
|
93467
|
+
[
|
|
93468
|
+
"HOME",
|
|
93469
|
+
"USERPROFILE",
|
|
93470
|
+
"CODEX_HOME",
|
|
93471
|
+
"CLAUDE_CONFIG_DIR",
|
|
93472
|
+
"XDG_CONFIG_HOME",
|
|
93473
|
+
"OPENCODE_CONFIG_DIR",
|
|
93474
|
+
"OPENCODE_CONFIG",
|
|
93475
|
+
"PI_CODING_AGENT_DIR"
|
|
93476
|
+
].map((name2) => agent2.environment[name2])
|
|
93477
|
+
]);
|
|
93478
|
+
let generation;
|
|
93479
|
+
try {
|
|
93480
|
+
generation = await this.#readGeneration();
|
|
93481
|
+
} catch {
|
|
93482
|
+
signal.throwIfAborted();
|
|
93483
|
+
return { inspections, save: async () => void 0 };
|
|
93484
|
+
}
|
|
93485
|
+
try {
|
|
93486
|
+
const cached2 = await readCache(path6);
|
|
93487
|
+
if (cached2?.generation === generation && cached2.fingerprint === fingerprint) {
|
|
93488
|
+
for (const { model, result } of cached2.inspections) {
|
|
93489
|
+
inspections.set(
|
|
93490
|
+
model ?? void 0,
|
|
93491
|
+
result.kind === "snapshot" ? new AgentSettingsSnapshot(
|
|
93492
|
+
result.agentName,
|
|
93493
|
+
result.agentVersion,
|
|
93494
|
+
decodeSessionConfigOptions(result.configOptions),
|
|
93495
|
+
result.modelEffort
|
|
93496
|
+
) : new AcpConfigurationValueUnavailableError(
|
|
93497
|
+
result.configId,
|
|
93498
|
+
result.requestedValue,
|
|
93499
|
+
result.offeredValues
|
|
93500
|
+
)
|
|
93501
|
+
);
|
|
93502
|
+
}
|
|
93503
|
+
}
|
|
93504
|
+
} catch {
|
|
93505
|
+
inspections.clear();
|
|
93506
|
+
}
|
|
93507
|
+
signal.throwIfAborted();
|
|
93508
|
+
return {
|
|
93509
|
+
inspections,
|
|
93510
|
+
save: async (saveSignal) => {
|
|
93511
|
+
const data = JSON.stringify({
|
|
93512
|
+
format: CACHE_FORMAT,
|
|
93513
|
+
fingerprint,
|
|
93514
|
+
generation,
|
|
93515
|
+
inspections: [...inspections].map(([model, result]) => ({
|
|
93516
|
+
model: model ?? null,
|
|
93517
|
+
result: result instanceof AcpConfigurationValueUnavailableError ? {
|
|
93518
|
+
kind: "unavailable",
|
|
93519
|
+
configId: result.configId,
|
|
93520
|
+
requestedValue: result.requestedValue,
|
|
93521
|
+
offeredValues: result.offeredValues
|
|
93522
|
+
} : {
|
|
93523
|
+
kind: "snapshot",
|
|
93524
|
+
...result,
|
|
93525
|
+
// Only the base snapshot supplies the complete native model catalog.
|
|
93526
|
+
modelEffort: model === void 0 ? result.modelEffort : { kind: "unavailable" }
|
|
93527
|
+
}
|
|
93528
|
+
}))
|
|
93529
|
+
});
|
|
93530
|
+
try {
|
|
93531
|
+
if (Buffer.byteLength(data) <= CACHE_FILE_LIMIT && generation === await this.#readGeneration()) {
|
|
93532
|
+
await writeInstallationFile(path6, data, saveSignal);
|
|
93533
|
+
}
|
|
93534
|
+
} catch {
|
|
93535
|
+
saveSignal.throwIfAborted();
|
|
93536
|
+
}
|
|
93537
|
+
}
|
|
93538
|
+
};
|
|
93539
|
+
};
|
|
93540
|
+
#readGeneration = async () => {
|
|
93541
|
+
const result = await readInstallationFile(this.#generationPath);
|
|
93542
|
+
if (result.kind === "missing") {
|
|
93543
|
+
return "initial";
|
|
93544
|
+
}
|
|
93545
|
+
if (result.kind === "read") {
|
|
93546
|
+
return generationSchema.parse(result.text);
|
|
93547
|
+
}
|
|
93548
|
+
throw new Error("The Agent settings cache generation cannot be read");
|
|
93549
|
+
};
|
|
93550
|
+
};
|
|
93551
|
+
|
|
93236
93552
|
// src/engine/runtime/relay/diagnostics.ts
|
|
93237
93553
|
var MAX_DIAGNOSTIC_TEXT_LENGTH = 256;
|
|
93238
93554
|
function sanitizeDiagnosticText(value) {
|
|
@@ -93474,7 +93790,7 @@ function discoveredEvent(command, agents) {
|
|
|
93474
93790
|
};
|
|
93475
93791
|
}
|
|
93476
93792
|
function createAgentCatalogDiscoveryHandler(dependencies) {
|
|
93477
|
-
const { config: config2, discover, diagnostics, socket, signal, timer } = dependencies;
|
|
93793
|
+
const { config: config2, discover, invalidateAgentSettings, diagnostics, socket, signal, timer } = dependencies;
|
|
93478
93794
|
const requestIds = /* @__PURE__ */ new Set();
|
|
93479
93795
|
let controller = null;
|
|
93480
93796
|
let completion = null;
|
|
@@ -93500,6 +93816,7 @@ function createAgentCatalogDiscoveryHandler(dependencies) {
|
|
|
93500
93816
|
completion = (async () => {
|
|
93501
93817
|
try {
|
|
93502
93818
|
const published = await refreshAgentCatalog(config2, discover, operationSignal);
|
|
93819
|
+
await invalidateAgentSettings(operationSignal);
|
|
93503
93820
|
operationSignal.throwIfAborted();
|
|
93504
93821
|
if (socket.readyState === WebSocket3.OPEN) {
|
|
93505
93822
|
send(
|
|
@@ -93550,6 +93867,7 @@ function createAgentCatalogCommands(context) {
|
|
|
93550
93867
|
discover: context.config.rediscoverAgents === void 0 ? () => {
|
|
93551
93868
|
throw new Error("Agent catalog discovery is not available for this Runtime");
|
|
93552
93869
|
} : context.config.rediscoverAgents,
|
|
93870
|
+
invalidateAgentSettings: context.settingsCache.invalidate,
|
|
93553
93871
|
diagnostics: context.diagnostics,
|
|
93554
93872
|
socket: context.socket,
|
|
93555
93873
|
signal: context.signal,
|
|
@@ -93581,7 +93899,7 @@ var SessionError = class extends OperationError {
|
|
|
93581
93899
|
};
|
|
93582
93900
|
|
|
93583
93901
|
// src/engine/session/settings/discover-agent-settings.ts
|
|
93584
|
-
import { createHash as
|
|
93902
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
93585
93903
|
|
|
93586
93904
|
// src/engine/agent/settings/agent-settings-base.ts
|
|
93587
93905
|
var AgentSettingsLaunchSelectionResult = class {
|
|
@@ -93651,23 +93969,56 @@ function isUnavailableModel(cause, modelSettingId, requestedModel) {
|
|
|
93651
93969
|
function unsupportedModelIds(unsupportedModels) {
|
|
93652
93970
|
return [...new Set(unsupportedModels.map((item) => item.requestedValue))];
|
|
93653
93971
|
}
|
|
93654
|
-
async function discoverAgentSettings(command, resolveAgent, bindingId, directories, sessions, signal) {
|
|
93655
|
-
const { agent: agent2, adapter
|
|
93656
|
-
const directoryId = command.directoryId
|
|
93657
|
-
const
|
|
93658
|
-
const
|
|
93659
|
-
|
|
93660
|
-
|
|
93661
|
-
|
|
93662
|
-
|
|
93663
|
-
signal
|
|
93664
|
-
|
|
93665
|
-
|
|
93666
|
-
|
|
93667
|
-
|
|
93668
|
-
|
|
93669
|
-
|
|
93972
|
+
async function discoverAgentSettings(command, resolveAgent, bindingId, directories, sessions, settingsCache, signal) {
|
|
93973
|
+
const { agent: agent2, adapter } = await resolveAgent(command.agentId, signal);
|
|
93974
|
+
const directoryId = command.directoryId;
|
|
93975
|
+
const cache = directoryId === void 0 ? await settingsCache.open(agent2, signal) : void 0;
|
|
93976
|
+
const inspections = cache?.inspections ?? /* @__PURE__ */ new Map();
|
|
93977
|
+
const initialSize = inspections.size;
|
|
93978
|
+
let cwd;
|
|
93979
|
+
let probeDirectory;
|
|
93980
|
+
const inspect = async (model) => {
|
|
93981
|
+
signal.throwIfAborted();
|
|
93982
|
+
const cached2 = inspections.get(model);
|
|
93983
|
+
if (cached2 instanceof AcpConfigurationValueUnavailableError) {
|
|
93984
|
+
throw cached2;
|
|
93985
|
+
}
|
|
93986
|
+
if (cached2 !== void 0) {
|
|
93987
|
+
return cached2;
|
|
93988
|
+
}
|
|
93989
|
+
if (cwd === void 0) {
|
|
93990
|
+
if (directoryId === void 0) {
|
|
93991
|
+
probeDirectory = await createTemporaryDirectory("mobius-agent-settings-");
|
|
93992
|
+
cwd = probeDirectory.path;
|
|
93993
|
+
} else {
|
|
93994
|
+
cwd = await directories.resolve(bindingId, directoryId, signal);
|
|
93995
|
+
}
|
|
93996
|
+
}
|
|
93997
|
+
return await sessions.inspectAgentSettings(
|
|
93998
|
+
{
|
|
93999
|
+
adapter,
|
|
94000
|
+
additionalDirectories: [],
|
|
94001
|
+
agent: agent2,
|
|
94002
|
+
cwd,
|
|
94003
|
+
...model === void 0 ? {} : { model },
|
|
94004
|
+
signal
|
|
94005
|
+
},
|
|
94006
|
+
inspections
|
|
94007
|
+
);
|
|
93670
94008
|
};
|
|
94009
|
+
try {
|
|
94010
|
+
const result = await collectAgentSettings(command, agent2, inspect, signal);
|
|
94011
|
+
if (inspections.size !== initialSize) {
|
|
94012
|
+
await cache?.save(signal);
|
|
94013
|
+
}
|
|
94014
|
+
signal.throwIfAborted();
|
|
94015
|
+
return result;
|
|
94016
|
+
} finally {
|
|
94017
|
+
await probeDirectory?.dispose();
|
|
94018
|
+
}
|
|
94019
|
+
}
|
|
94020
|
+
async function collectAgentSettings(command, agent2, inspect, signal) {
|
|
94021
|
+
const baseSnapshot = await inspect();
|
|
93671
94022
|
const baseModel = modelOption(baseSnapshot.configOptions);
|
|
93672
94023
|
const unsupportedModels = [];
|
|
93673
94024
|
let selectedSnapshot = baseSnapshot;
|
|
@@ -93682,14 +94033,7 @@ async function discoverAgentSettings(command, resolveAgent, bindingId, directori
|
|
|
93682
94033
|
);
|
|
93683
94034
|
} else {
|
|
93684
94035
|
try {
|
|
93685
|
-
selectedSnapshot = await
|
|
93686
|
-
adapter: harnessAdapter,
|
|
93687
|
-
additionalDirectories: [],
|
|
93688
|
-
agent: agent2,
|
|
93689
|
-
cwd,
|
|
93690
|
-
model: command.model,
|
|
93691
|
-
signal
|
|
93692
|
-
});
|
|
94036
|
+
selectedSnapshot = await inspect(command.model);
|
|
93693
94037
|
} catch (cause) {
|
|
93694
94038
|
signal.throwIfAborted();
|
|
93695
94039
|
if (!isUnavailableModel(cause, baseModel.id, command.model)) {
|
|
@@ -93700,25 +94044,21 @@ async function discoverAgentSettings(command, resolveAgent, bindingId, directori
|
|
|
93700
94044
|
}
|
|
93701
94045
|
}
|
|
93702
94046
|
const adapter = agentSettingsAdapterForAgent(agent2.id);
|
|
93703
|
-
const modelEffort = await discoverModelEffort(
|
|
93704
|
-
command,
|
|
93705
|
-
agent2,
|
|
93706
|
-
harnessAdapter,
|
|
94047
|
+
const { modelEffort, effort } = await discoverModelEffort(
|
|
93707
94048
|
adapter.modelEffortResolution,
|
|
93708
94049
|
baseSnapshot.configOptions,
|
|
93709
|
-
selectedSnapshot.configOptions,
|
|
93710
94050
|
unsupportedModels,
|
|
93711
94051
|
baseSnapshot.modelEffort,
|
|
93712
|
-
|
|
93713
|
-
sessions,
|
|
94052
|
+
inspect,
|
|
93714
94053
|
signal
|
|
93715
94054
|
);
|
|
94055
|
+
const baseOptions = effort === void 0 || effortOption(baseSnapshot.configOptions) !== void 0 ? baseSnapshot.configOptions : [...baseSnapshot.configOptions, { ...effort, currentValue: "" }];
|
|
93716
94056
|
const baseSettings = withoutUnsupportedModels(
|
|
93717
|
-
settingsFromSnapshot(agent2,
|
|
94057
|
+
settingsFromSnapshot(agent2, baseOptions),
|
|
93718
94058
|
baseModel?.id ?? "",
|
|
93719
94059
|
modelEffort.unsupportedModelIds
|
|
93720
94060
|
);
|
|
93721
|
-
const settings = withoutUnsupportedModels(
|
|
94061
|
+
const settings = command.model === void 0 ? baseSettings : withoutUnsupportedModels(
|
|
93722
94062
|
settingsFromSnapshot(agent2, selectedSnapshot.configOptions),
|
|
93723
94063
|
baseModel?.id ?? "",
|
|
93724
94064
|
modelEffort.unsupportedModelIds
|
|
@@ -93728,7 +94068,7 @@ async function discoverAgentSettings(command, resolveAgent, bindingId, directori
|
|
|
93728
94068
|
agentId: command.agentId,
|
|
93729
94069
|
agentName: selectedSnapshot.agentName,
|
|
93730
94070
|
agentVersion: selectedSnapshot.agentVersion,
|
|
93731
|
-
directoryId,
|
|
94071
|
+
directoryId: command.directoryId ?? "default",
|
|
93732
94072
|
kind: AGENT_SETTINGS_DISCOVERED_KIND,
|
|
93733
94073
|
modelEffort,
|
|
93734
94074
|
requestId: command.requestId,
|
|
@@ -93802,33 +94142,45 @@ function unavailableModelEffort() {
|
|
|
93802
94142
|
valuesByModel: {}
|
|
93803
94143
|
};
|
|
93804
94144
|
}
|
|
93805
|
-
async function discoverModelEffort(
|
|
94145
|
+
async function discoverModelEffort(resolution, initialOptions, initiallyUnsupportedModels, discoveredModelEffort, inspect, signal) {
|
|
93806
94146
|
const model = modelOption(initialOptions);
|
|
93807
94147
|
const unsupportedModels = initiallyUnsupportedModels;
|
|
93808
94148
|
if (resolution !== AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE && resolution !== AGENT_MODEL_EFFORT_RESOLUTION_ON_MODEL_SELECTION) {
|
|
93809
|
-
return {
|
|
94149
|
+
return {
|
|
94150
|
+
modelEffort: { ...unavailableModelEffort(), unsupportedModelIds: unsupportedModelIds(unsupportedModels) }
|
|
94151
|
+
};
|
|
93810
94152
|
}
|
|
93811
94153
|
if (model === void 0 || model.type !== "select" || model.values.length === 0) {
|
|
93812
|
-
return {
|
|
94154
|
+
return {
|
|
94155
|
+
modelEffort: { ...unavailableModelEffort(), unsupportedModelIds: unsupportedModelIds(unsupportedModels) }
|
|
94156
|
+
};
|
|
93813
94157
|
}
|
|
94158
|
+
const inspectModel = async (model2) => (await inspect(model2)).configOptions;
|
|
93814
94159
|
if (resolution === AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE && discoveredModelEffort.kind === "complete" && discoveredModelEffort.value.resolution === AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE) {
|
|
93815
|
-
|
|
94160
|
+
for (const { value } of model.values) {
|
|
94161
|
+
if (value !== model.currentValue) {
|
|
94162
|
+
try {
|
|
94163
|
+
await inspectModel(value);
|
|
94164
|
+
} catch (cause) {
|
|
94165
|
+
signal.throwIfAborted();
|
|
94166
|
+
if (!isUnavailableModel(cause, model.id, value)) {
|
|
94167
|
+
throw cause;
|
|
94168
|
+
}
|
|
94169
|
+
unsupportedModels.push(cause);
|
|
94170
|
+
}
|
|
94171
|
+
}
|
|
94172
|
+
}
|
|
94173
|
+
return { modelEffort: discoveredModelEffort.value };
|
|
93816
94174
|
}
|
|
93817
|
-
const
|
|
93818
|
-
adapter: harnessAdapter,
|
|
93819
|
-
additionalDirectories: [],
|
|
93820
|
-
agent: agent2,
|
|
93821
|
-
cwd,
|
|
93822
|
-
model: modelValue,
|
|
93823
|
-
signal
|
|
93824
|
-
})).configOptions;
|
|
93825
|
-
const valuesByModel = {};
|
|
94175
|
+
const valuesByModel = /* @__PURE__ */ new Map();
|
|
93826
94176
|
if (resolution === "complete") {
|
|
93827
|
-
const
|
|
93828
|
-
if (
|
|
94177
|
+
const effort2 = effortOption(initialOptions);
|
|
94178
|
+
if (effort2 === void 0 || effort2.type !== "select" || effort2.values.length < 2) {
|
|
93829
94179
|
return {
|
|
93830
|
-
|
|
93831
|
-
|
|
94180
|
+
modelEffort: {
|
|
94181
|
+
...unavailableModelEffort(),
|
|
94182
|
+
unsupportedModelIds: unsupportedModelIds(unsupportedModels)
|
|
94183
|
+
}
|
|
93832
94184
|
};
|
|
93833
94185
|
}
|
|
93834
94186
|
for (const value of model.values) {
|
|
@@ -93836,8 +94188,8 @@ async function discoverModelEffort(command, agent2, harnessAdapter, resolution,
|
|
|
93836
94188
|
continue;
|
|
93837
94189
|
}
|
|
93838
94190
|
try {
|
|
93839
|
-
const
|
|
93840
|
-
valuesByModel
|
|
94191
|
+
const selectedEffort = effortOption(await inspectModel(value.value));
|
|
94192
|
+
valuesByModel.set(value.value, selectedEffort?.type === "select" ? selectedEffort.values : []);
|
|
93841
94193
|
} catch (cause) {
|
|
93842
94194
|
signal.throwIfAborted();
|
|
93843
94195
|
if (!isUnavailableModel(cause, model.id, value.value)) {
|
|
@@ -93847,80 +94199,77 @@ async function discoverModelEffort(command, agent2, harnessAdapter, resolution,
|
|
|
93847
94199
|
}
|
|
93848
94200
|
}
|
|
93849
94201
|
return {
|
|
93850
|
-
|
|
93851
|
-
|
|
93852
|
-
|
|
93853
|
-
|
|
93854
|
-
|
|
94202
|
+
modelEffort: {
|
|
94203
|
+
effortSettingId: effort2.id,
|
|
94204
|
+
modelSettingId: model.id,
|
|
94205
|
+
resolution: "complete",
|
|
94206
|
+
unsupportedModelIds: unsupportedModelIds(unsupportedModels),
|
|
94207
|
+
valuesByModel: Object.fromEntries(valuesByModel)
|
|
94208
|
+
}
|
|
93855
94209
|
};
|
|
93856
94210
|
}
|
|
93857
|
-
|
|
93858
|
-
|
|
93859
|
-
|
|
93860
|
-
if (
|
|
93861
|
-
|
|
94211
|
+
const defaultEffort = effortOption(initialOptions);
|
|
94212
|
+
let effort = defaultEffort;
|
|
94213
|
+
for (const value of model.values) {
|
|
94214
|
+
if (unsupportedModels.some((diagnostic) => diagnostic.requestedValue === value.value)) {
|
|
94215
|
+
continue;
|
|
93862
94216
|
}
|
|
93863
|
-
return {
|
|
93864
|
-
effortSettingId: selectedEffort2?.id ?? "",
|
|
93865
|
-
modelSettingId: model.id,
|
|
93866
|
-
resolution: "on_model_selection",
|
|
93867
|
-
unsupportedModelIds: unsupportedModelIds(unsupportedModels),
|
|
93868
|
-
valuesByModel
|
|
93869
|
-
};
|
|
93870
|
-
}
|
|
93871
|
-
const defaultModel = model.type === "select" ? model.currentValue : "";
|
|
93872
|
-
const reportedEffort = effortOption(selectedOptions);
|
|
93873
|
-
let selectedEffort = reportedEffort;
|
|
93874
|
-
if (defaultModel.length > 0 && reportedEffort === void 0) {
|
|
93875
94217
|
try {
|
|
93876
|
-
|
|
94218
|
+
const inspectedEffort = effortOption(await inspectModel(value.value));
|
|
94219
|
+
const selectedEffort = value.value === model.currentValue ? defaultEffort ?? inspectedEffort : inspectedEffort;
|
|
94220
|
+
effort ??= selectedEffort;
|
|
94221
|
+
valuesByModel.set(value.value, selectedEffort?.type === "select" ? selectedEffort.values : []);
|
|
93877
94222
|
} catch (cause) {
|
|
93878
94223
|
signal.throwIfAborted();
|
|
93879
|
-
if (!isUnavailableModel(cause, model.id,
|
|
94224
|
+
if (!isUnavailableModel(cause, model.id, value.value)) {
|
|
93880
94225
|
throw cause;
|
|
93881
94226
|
}
|
|
93882
94227
|
unsupportedModels.push(cause);
|
|
93883
94228
|
}
|
|
93884
94229
|
}
|
|
93885
|
-
if (defaultModel.length > 0 && !unsupportedModels.some((diagnostic) => diagnostic.requestedValue === defaultModel)) {
|
|
93886
|
-
valuesByModel[defaultModel] = selectedEffort?.type === "select" ? selectedEffort.values : [];
|
|
93887
|
-
}
|
|
93888
94230
|
return {
|
|
93889
|
-
|
|
93890
|
-
|
|
93891
|
-
|
|
93892
|
-
|
|
93893
|
-
|
|
94231
|
+
...effort === void 0 ? {} : { effort },
|
|
94232
|
+
modelEffort: {
|
|
94233
|
+
effortSettingId: effort?.id ?? "",
|
|
94234
|
+
modelSettingId: model.id,
|
|
94235
|
+
resolution: "on_model_selection",
|
|
94236
|
+
unsupportedModelIds: unsupportedModelIds(unsupportedModels),
|
|
94237
|
+
valuesByModel: Object.fromEntries(valuesByModel)
|
|
94238
|
+
}
|
|
93894
94239
|
};
|
|
93895
94240
|
}
|
|
93896
94241
|
function settingsRevision(agent2, reportedAgentVersion, settings, modelEffort) {
|
|
93897
|
-
|
|
93898
|
-
|
|
93899
|
-
|
|
93900
|
-
|
|
93901
|
-
|
|
93902
|
-
|
|
93903
|
-
|
|
93904
|
-
|
|
93905
|
-
|
|
93906
|
-
|
|
93907
|
-
|
|
93908
|
-
|
|
93909
|
-
|
|
93910
|
-
|
|
93911
|
-
|
|
93912
|
-
|
|
94242
|
+
return createHash10("sha256").update(
|
|
94243
|
+
JSON.stringify(
|
|
94244
|
+
{
|
|
94245
|
+
adapterVersion: agent2.adapterVersion,
|
|
94246
|
+
agentId: agent2.id,
|
|
94247
|
+
agentVersion: agent2.agentVersion,
|
|
94248
|
+
modelEffort,
|
|
94249
|
+
reportedAgentVersion,
|
|
94250
|
+
settings
|
|
94251
|
+
},
|
|
94252
|
+
(_key, value) => {
|
|
94253
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
94254
|
+
return value;
|
|
94255
|
+
}
|
|
94256
|
+
return Object.fromEntries(
|
|
94257
|
+
Object.entries(value).sort(([left], [right]) => left < right ? -1 : Number(left > right))
|
|
94258
|
+
);
|
|
94259
|
+
}
|
|
94260
|
+
)
|
|
93913
94261
|
).digest("hex");
|
|
93914
94262
|
}
|
|
93915
94263
|
|
|
93916
94264
|
// src/engine/runtime/command/agent-settings-discovery.ts
|
|
93917
94265
|
function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
93918
|
-
const { config: config2, directories, sessions, diagnostics, socket, signal, timer } = dependencies;
|
|
94266
|
+
const { config: config2, directories, sessions, settingsCache, diagnostics, socket, signal, timer } = dependencies;
|
|
93919
94267
|
const agentSettingsDiscoveries = /* @__PURE__ */ new Map();
|
|
93920
94268
|
const handle = (command) => {
|
|
93921
|
-
const directoryId = command.directoryId
|
|
94269
|
+
const directoryId = command.directoryId;
|
|
94270
|
+
const generation = settingsCache.generation;
|
|
93922
94271
|
const existing = [...agentSettingsDiscoveries.values()].find(
|
|
93923
|
-
(request) => request.agentId === command.agentId && request.directoryId === directoryId && !request.controller.signal.aborted
|
|
94272
|
+
(request) => request.agentId === command.agentId && request.directoryId === directoryId && request.generation === generation && !request.controller.signal.aborted
|
|
93924
94273
|
);
|
|
93925
94274
|
if ([...agentSettingsDiscoveries.values()].some((request) => request.requestIds.has(command.requestId))) {
|
|
93926
94275
|
if (socket.readyState === WebSocket4.OPEN) {
|
|
@@ -93976,6 +94325,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
93976
94325
|
config2.bindingId,
|
|
93977
94326
|
directories,
|
|
93978
94327
|
sessions,
|
|
94328
|
+
settingsCache,
|
|
93979
94329
|
operationSignal
|
|
93980
94330
|
);
|
|
93981
94331
|
for (const diagnostic of result.unsupportedModels) {
|
|
@@ -94019,6 +94369,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
94019
94369
|
agentSettingsDiscoveries.set(command.requestId, {
|
|
94020
94370
|
agentId: command.agentId,
|
|
94021
94371
|
directoryId,
|
|
94372
|
+
generation,
|
|
94022
94373
|
model: command.model,
|
|
94023
94374
|
requestIds,
|
|
94024
94375
|
completion,
|
|
@@ -94040,6 +94391,7 @@ function createAgentSettingsCommands(context) {
|
|
|
94040
94391
|
directories: context.directories,
|
|
94041
94392
|
diagnostics: context.diagnostics,
|
|
94042
94393
|
sessions: context.sessions,
|
|
94394
|
+
settingsCache: context.settingsCache,
|
|
94043
94395
|
signal: context.signal,
|
|
94044
94396
|
socket: context.socket,
|
|
94045
94397
|
timer: context.timer
|
|
@@ -94059,7 +94411,7 @@ function createAgentSettingsCommands(context) {
|
|
|
94059
94411
|
}
|
|
94060
94412
|
|
|
94061
94413
|
// src/engine/runtime/command/registry/content-write/index.ts
|
|
94062
|
-
import { createHash as
|
|
94414
|
+
import { createHash as createHash11 } from "node:crypto";
|
|
94063
94415
|
function createContentWriteCommands(context) {
|
|
94064
94416
|
const pending = /* @__PURE__ */ new Map();
|
|
94065
94417
|
const operations = /* @__PURE__ */ new Set();
|
|
@@ -94089,7 +94441,7 @@ function createContentWriteCommands(context) {
|
|
|
94089
94441
|
pending.set(message.requestId, {
|
|
94090
94442
|
bytes: new Uint8Array(message.byteLength),
|
|
94091
94443
|
command: message,
|
|
94092
|
-
hash:
|
|
94444
|
+
hash: createHash11("sha256"),
|
|
94093
94445
|
receivedBytes: 0,
|
|
94094
94446
|
sequence: 0
|
|
94095
94447
|
});
|
|
@@ -94183,7 +94535,7 @@ function createContentWriteCommands(context) {
|
|
|
94183
94535
|
import { WebSocket as WebSocket5 } from "undici";
|
|
94184
94536
|
|
|
94185
94537
|
// src/engine/session/content/session-files.ts
|
|
94186
|
-
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";
|
|
94187
94539
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
94188
94540
|
function requestedPath(value) {
|
|
94189
94541
|
if (value.includes("\0")) {
|
|
@@ -94201,21 +94553,21 @@ function requestedPath(value) {
|
|
|
94201
94553
|
}
|
|
94202
94554
|
async function resolveFile(value, workingDirectory, signal) {
|
|
94203
94555
|
const requested = requestedPath(value);
|
|
94204
|
-
if (requested === null || !
|
|
94556
|
+
if (requested === null || !isAbsolute17(requested.path) && workingDirectory === null) {
|
|
94205
94557
|
return null;
|
|
94206
94558
|
}
|
|
94207
|
-
if (
|
|
94559
|
+
if (isAbsolute17(requested.path) && normalize3(requested.path) !== requested.path) {
|
|
94208
94560
|
return null;
|
|
94209
94561
|
}
|
|
94210
|
-
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)];
|
|
94211
94563
|
for (const candidate of candidates) {
|
|
94212
|
-
if (!
|
|
94564
|
+
if (!isAbsolute17(candidate) || normalize3(candidate) !== candidate) {
|
|
94213
94565
|
continue;
|
|
94214
94566
|
}
|
|
94215
94567
|
try {
|
|
94216
94568
|
const target = await canonicalPath(candidate);
|
|
94217
94569
|
signal.throwIfAborted();
|
|
94218
|
-
if (
|
|
94570
|
+
if (isAbsolute17(target) && normalize3(target) === target) {
|
|
94219
94571
|
return target;
|
|
94220
94572
|
}
|
|
94221
94573
|
} catch {
|
|
@@ -94225,6 +94577,10 @@ async function resolveFile(value, workingDirectory, signal) {
|
|
|
94225
94577
|
return null;
|
|
94226
94578
|
}
|
|
94227
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
|
+
}
|
|
94228
94584
|
const external = await externalContent.resolve(command.sessionId, command.path, signal);
|
|
94229
94585
|
const target = external?.path ?? await resolveFile(command.path, workingDirectory, signal);
|
|
94230
94586
|
if (target === null) {
|
|
@@ -94241,7 +94597,7 @@ async function streamLocalFile(command, send2, sendChunk, signal, workingDirecto
|
|
|
94241
94597
|
kind: FILE_BEGIN_KIND,
|
|
94242
94598
|
mediaType: external?.mediaType ?? raster?.mimeType ?? (extname3(target).toLowerCase() === ".svg" ? "image/svg+xml" : "application/octet-stream"),
|
|
94243
94599
|
modifiedAt: before.modifiedAt.toISOString(),
|
|
94244
|
-
name: external?.name ?? (
|
|
94600
|
+
name: external?.name ?? (basename9(target) || "file"),
|
|
94245
94601
|
requestId: command.requestId,
|
|
94246
94602
|
sessionId: command.sessionId
|
|
94247
94603
|
});
|
|
@@ -94261,12 +94617,43 @@ async function streamLocalFile(command, send2, sendChunk, signal, workingDirecto
|
|
|
94261
94617
|
sessionId: command.sessionId
|
|
94262
94618
|
});
|
|
94263
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
|
+
}
|
|
94264
94651
|
|
|
94265
94652
|
// src/engine/runtime/command/registry/file-read/index.ts
|
|
94266
94653
|
var fileReadCommand = {
|
|
94267
94654
|
kind: FILE_READ_KIND,
|
|
94268
94655
|
handle: ({ externalContent, sessions, signal, socket }, message) => {
|
|
94269
|
-
if (message.kind !== FILE_READ_KIND) {
|
|
94656
|
+
if (message.kind !== FILE_READ_KIND && message.kind !== SCOPED_FILE_READ_KIND) {
|
|
94270
94657
|
throw new Error("Command kind mismatch");
|
|
94271
94658
|
}
|
|
94272
94659
|
void streamLocalFile(
|
|
@@ -94281,15 +94668,16 @@ var fileReadCommand = {
|
|
|
94281
94668
|
return;
|
|
94282
94669
|
}
|
|
94283
94670
|
send(socket, {
|
|
94284
|
-
code: "file_unavailable",
|
|
94671
|
+
code: error62 instanceof ScopedFileReadError ? error62.code : "file_unavailable",
|
|
94285
94672
|
kind: FILE_FAILED_KIND,
|
|
94286
|
-
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",
|
|
94287
94674
|
requestId: message.requestId,
|
|
94288
94675
|
sessionId: message.sessionId
|
|
94289
94676
|
});
|
|
94290
94677
|
});
|
|
94291
94678
|
}
|
|
94292
94679
|
};
|
|
94680
|
+
var scopedFileReadCommand = { ...fileReadCommand, kind: SCOPED_FILE_READ_KIND };
|
|
94293
94681
|
|
|
94294
94682
|
// src/engine/runtime/command/registry/history.ts
|
|
94295
94683
|
var sessionHistoryPageLoadCommand = {
|
|
@@ -94592,7 +94980,7 @@ function createNativeSessionCommands(context) {
|
|
|
94592
94980
|
}
|
|
94593
94981
|
|
|
94594
94982
|
// src/engine/session/workspace/resolve-session-directories.ts
|
|
94595
|
-
import { basename as
|
|
94983
|
+
import { basename as basename10 } from "node:path";
|
|
94596
94984
|
var ResolvedSessionDirectories = class {
|
|
94597
94985
|
additionalDirectories;
|
|
94598
94986
|
additionalDirectoryEntries;
|
|
@@ -94620,14 +95008,14 @@ async function resolveSessionDirectories(directories, bindingId, directoryId, ad
|
|
|
94620
95008
|
additionalDirectories.push(directory);
|
|
94621
95009
|
additionalDirectoryEntries.push({
|
|
94622
95010
|
directoryId: additionalDirectoryId,
|
|
94623
|
-
name:
|
|
95011
|
+
name: basename10(directory)
|
|
94624
95012
|
});
|
|
94625
95013
|
}
|
|
94626
95014
|
return new ResolvedSessionDirectories(cwd, selection.label, additionalDirectories, additionalDirectoryEntries);
|
|
94627
95015
|
}
|
|
94628
95016
|
|
|
94629
95017
|
// src/engine/session/prompt/apply-session-configuration.ts
|
|
94630
|
-
import { randomUUID as
|
|
95018
|
+
import { randomUUID as randomUUID18 } from "node:crypto";
|
|
94631
95019
|
function invalidSessionConfiguration(message) {
|
|
94632
95020
|
return new AcpExecutionError(message, {}, "invalid_session_configuration");
|
|
94633
95021
|
}
|
|
@@ -94752,7 +95140,7 @@ async function applySessionConfigurationSelection(sessions, options, selection,
|
|
|
94752
95140
|
booleanValue: selection.booleanValue,
|
|
94753
95141
|
configId: selection.configId,
|
|
94754
95142
|
cwd,
|
|
94755
|
-
requestId: `cfg_${
|
|
95143
|
+
requestId: `cfg_${randomUUID18()}`,
|
|
94756
95144
|
sessionId,
|
|
94757
95145
|
signal,
|
|
94758
95146
|
value: selection.value,
|
|
@@ -95135,7 +95523,11 @@ var runtimePingCommand = {
|
|
|
95135
95523
|
if (message.kind !== RUNTIME_PING_KIND) {
|
|
95136
95524
|
throw new Error("Command kind mismatch");
|
|
95137
95525
|
}
|
|
95138
|
-
send(socket, {
|
|
95526
|
+
send(socket, {
|
|
95527
|
+
kind: RUNTIME_PONG_KIND,
|
|
95528
|
+
requestId: message.requestId,
|
|
95529
|
+
scopedFileRead: supportsScopedLocalFileRead()
|
|
95530
|
+
});
|
|
95139
95531
|
}
|
|
95140
95532
|
};
|
|
95141
95533
|
|
|
@@ -95533,6 +95925,7 @@ function createCommandRegistry(context) {
|
|
|
95533
95925
|
...createAgentSettingsCommands(context),
|
|
95534
95926
|
...contentWrites.commands,
|
|
95535
95927
|
fileReadCommand,
|
|
95928
|
+
scopedFileReadCommand,
|
|
95536
95929
|
sessionCancelBeforeStartCommand,
|
|
95537
95930
|
sessionCancelCommand,
|
|
95538
95931
|
sessionCloseCommand,
|
|
@@ -95599,7 +95992,7 @@ var RelayConnectionError = class extends Error {
|
|
|
95599
95992
|
};
|
|
95600
95993
|
function connectRelay(url2, signal, transportFailed = () => void 0) {
|
|
95601
95994
|
signal.throwIfAborted();
|
|
95602
|
-
return new Promise((
|
|
95995
|
+
return new Promise((resolve20, reject2) => {
|
|
95603
95996
|
let releaseTransport = () => void 0;
|
|
95604
95997
|
let removeTransportObserver = () => void 0;
|
|
95605
95998
|
let released = false;
|
|
@@ -95723,7 +96116,7 @@ function connectRelay(url2, signal, transportFailed = () => void 0) {
|
|
|
95723
96116
|
}
|
|
95724
96117
|
finished = true;
|
|
95725
96118
|
cleanup();
|
|
95726
|
-
|
|
96119
|
+
resolve20({ release: release2, socket });
|
|
95727
96120
|
};
|
|
95728
96121
|
function onTimeout() {
|
|
95729
96122
|
fail(
|
|
@@ -95862,6 +96255,7 @@ async function runRelayConnection({
|
|
|
95862
96255
|
eventProjection,
|
|
95863
96256
|
externalContent,
|
|
95864
96257
|
sessions,
|
|
96258
|
+
settingsCache,
|
|
95865
96259
|
connectionEpoch,
|
|
95866
96260
|
diagnostics,
|
|
95867
96261
|
onConnected,
|
|
@@ -95880,6 +96274,7 @@ async function runRelayConnection({
|
|
|
95880
96274
|
config: config2,
|
|
95881
96275
|
directories,
|
|
95882
96276
|
sessions,
|
|
96277
|
+
settingsCache,
|
|
95883
96278
|
nativeSessions,
|
|
95884
96279
|
operations,
|
|
95885
96280
|
eventProjection,
|
|
@@ -95900,7 +96295,7 @@ async function runRelayConnection({
|
|
|
95900
96295
|
}
|
|
95901
96296
|
});
|
|
95902
96297
|
try {
|
|
95903
|
-
await new Promise((
|
|
96298
|
+
await new Promise((resolve20, reject2) => {
|
|
95904
96299
|
let finished = false;
|
|
95905
96300
|
let ready = false;
|
|
95906
96301
|
const cleanup = () => {
|
|
@@ -95918,7 +96313,7 @@ async function runRelayConnection({
|
|
|
95918
96313
|
}
|
|
95919
96314
|
finished = true;
|
|
95920
96315
|
cleanup();
|
|
95921
|
-
|
|
96316
|
+
resolve20();
|
|
95922
96317
|
};
|
|
95923
96318
|
const rejectConnection = (failure2) => {
|
|
95924
96319
|
if (finished) {
|
|
@@ -96254,12 +96649,12 @@ function waitForRelayRetry(signal, timer) {
|
|
|
96254
96649
|
if (signal.aborted) {
|
|
96255
96650
|
return Promise.resolve();
|
|
96256
96651
|
}
|
|
96257
|
-
return new Promise((
|
|
96652
|
+
return new Promise((resolve20) => {
|
|
96258
96653
|
const retry = timer.schedule(finish, RELAY_RECONNECT_DELAY_MILLISECONDS);
|
|
96259
96654
|
function finish() {
|
|
96260
96655
|
retry.cancel();
|
|
96261
96656
|
signal.removeEventListener("abort", finish);
|
|
96262
|
-
|
|
96657
|
+
resolve20();
|
|
96263
96658
|
}
|
|
96264
96659
|
signal.addEventListener("abort", finish, { once: true });
|
|
96265
96660
|
});
|
|
@@ -96293,6 +96688,7 @@ async function runRuntime(config2, parentSignal, timer = systemTimer, options =
|
|
|
96293
96688
|
const shutdown = new AbortController();
|
|
96294
96689
|
const signal = AbortSignal.any([parentSignal, shutdown.signal]);
|
|
96295
96690
|
const stateDirectory = config2.localContext.stateDirectory;
|
|
96691
|
+
const settingsCache = new AgentSettingsCache(stateDirectory);
|
|
96296
96692
|
const diagnostics = new RelayConnectionDiagnostics(
|
|
96297
96693
|
config2.channelId,
|
|
96298
96694
|
config2.relayUrl,
|
|
@@ -96390,6 +96786,7 @@ async function runRuntime(config2, parentSignal, timer = systemTimer, options =
|
|
|
96390
96786
|
resolveAgent,
|
|
96391
96787
|
directories,
|
|
96392
96788
|
sessions: agentRuntime,
|
|
96789
|
+
settingsCache,
|
|
96393
96790
|
nativeSessions,
|
|
96394
96791
|
operations,
|
|
96395
96792
|
publisher,
|
|
@@ -96479,7 +96876,7 @@ function relayUrlFromConnection(connection) {
|
|
|
96479
96876
|
return relayUrl;
|
|
96480
96877
|
}
|
|
96481
96878
|
async function resolveWorkspace(path6) {
|
|
96482
|
-
const requested =
|
|
96879
|
+
const requested = resolve18(path6);
|
|
96483
96880
|
let resolved;
|
|
96484
96881
|
try {
|
|
96485
96882
|
resolved = await ensureCanonicalDirectory(requested);
|
|
@@ -96578,7 +96975,7 @@ var MobiusRuntimeEngine = class {
|
|
|
96578
96975
|
#connections;
|
|
96579
96976
|
#installation = { kind: "uninitialized" };
|
|
96580
96977
|
constructor(params) {
|
|
96581
|
-
this.#engineDataDir =
|
|
96978
|
+
this.#engineDataDir = resolve19(params.engineDataDir);
|
|
96582
96979
|
this.#agentLaunchEnvironment = Object.freeze({ ...params.agentLaunchEnvironment });
|
|
96583
96980
|
this.#maxAcpProcesses = params.maxAcpProcesses ?? 1e3;
|
|
96584
96981
|
this.#connections = new ConnectionManager(this.#ensureInstallation);
|
|
@@ -96699,4 +97096,4 @@ export {
|
|
|
96699
97096
|
* MIT Licensed
|
|
96700
97097
|
*)
|
|
96701
97098
|
*/
|
|
96702
|
-
//# sourceMappingURL=chunk-
|
|
97099
|
+
//# sourceMappingURL=chunk-WFQZ4ALO.js.map
|