@moxt-ai/mobius 0.0.335 → 0.0.337
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/cli.js +709 -475
- package/dist/cli.js.map +4 -4
- package/dist/daemon/control/protocol.d.ts +2 -0
- package/dist/daemon/control/protocol.d.ts.map +1 -1
- package/dist/daemon/control/protocol.js +25 -0
- package/dist/daemon/control/protocol.js.map +1 -1
- package/dist/daemon/control/switch-status.d.ts.map +1 -1
- package/dist/daemon/control/switch-status.js +3 -3
- package/dist/daemon/control/switch-status.js.map +1 -1
- package/dist/daemon/lifecycle/manager-client.d.ts.map +1 -1
- package/dist/daemon/lifecycle/manager-client.js +12 -12
- package/dist/daemon/lifecycle/manager-client.js.map +1 -1
- package/dist/daemon/lifecycle/manager.d.ts.map +1 -1
- package/dist/daemon/lifecycle/manager.js +4 -9
- package/dist/daemon/lifecycle/manager.js.map +1 -1
- package/dist/daemon/upgrades/upgrade.d.ts.map +1 -1
- package/dist/daemon/upgrades/upgrade.js +4 -4
- package/dist/daemon/upgrades/upgrade.js.map +1 -1
- package/dist/runtime/relay/run-relay-connection.d.ts.map +1 -1
- package/dist/runtime/relay/run-relay-connection.js +5 -57
- package/dist/runtime/relay/run-relay-connection.js.map +1 -1
- package/dist/runtime.js +585 -402
- package/dist/runtime.js.map +4 -4
- package/dist/session/live/session-configurations.d.ts.map +1 -1
- package/dist/session/live/session-configurations.js +8 -1
- package/dist/session/live/session-configurations.js.map +1 -1
- package/dist/session/turn/execution-receipts.d.ts.map +1 -1
- package/dist/session/turn/execution-receipts.js +6 -3
- package/dist/session/turn/execution-receipts.js.map +1 -1
- package/dist/storage/session/execution-receipt-table.d.ts.map +1 -1
- package/dist/storage/session/execution-receipt-table.js +5 -2
- package/dist/storage/session/execution-receipt-table.js.map +1 -1
- package/dist/util/filesystem/private-path.js +6 -324
- package/dist/util/filesystem/private-path.js.map +4 -4
- package/dist/util/platform/contracts.d.ts +0 -26
- package/dist/util/platform/contracts.d.ts.map +1 -1
- package/dist/util/platform/index.d.ts.map +1 -1
- package/dist/util/platform/index.js +1 -4
- package/dist/util/platform/index.js.map +1 -1
- package/dist/util/platform/linux.d.ts.map +1 -1
- package/dist/util/platform/linux.js +1 -117
- package/dist/util/platform/linux.js.map +1 -1
- package/dist/util/platform/macos.d.ts.map +1 -1
- package/dist/util/platform/macos.js +1 -4
- package/dist/util/platform/macos.js.map +1 -1
- package/dist/util/platform/posix.d.ts +0 -21
- package/dist/util/platform/posix.d.ts.map +1 -1
- package/dist/util/platform/posix.js +1 -104
- package/dist/util/platform/posix.js.map +1 -1
- package/dist/util/platform/windows.d.ts.map +1 -1
- package/dist/util/platform/windows.js +1 -107
- package/dist/util/platform/windows.js.map +1 -1
- package/dist/util/process/executable.d.ts +2 -2
- package/dist/util/process/executable.d.ts.map +1 -1
- package/dist/util/process/executable.js +31 -222
- package/dist/util/process/executable.js.map +4 -4
- package/dist/util/process/platform/contracts.d.ts +29 -0
- package/dist/util/process/platform/contracts.d.ts.map +1 -0
- package/dist/util/process/platform/contracts.js +2 -0
- package/dist/util/process/platform/contracts.js.map +1 -0
- package/dist/util/process/platform/index.d.ts +3 -0
- package/dist/util/process/platform/index.d.ts.map +1 -0
- package/dist/util/process/platform/index.js +20 -0
- package/dist/util/process/platform/index.js.map +1 -0
- package/dist/util/process/platform/linux.d.ts +3 -0
- package/dist/util/process/platform/linux.d.ts.map +1 -0
- package/dist/util/process/platform/linux.js +122 -0
- package/dist/util/process/platform/linux.js.map +1 -0
- package/dist/util/process/platform/macos.d.ts +3 -0
- package/dist/util/process/platform/macos.d.ts.map +1 -0
- package/dist/util/process/platform/macos.js +8 -0
- package/dist/util/process/platform/macos.js.map +1 -0
- package/dist/util/process/platform/posix.d.ts +25 -0
- package/dist/util/process/platform/posix.d.ts.map +1 -0
- package/dist/util/process/platform/posix.js +107 -0
- package/dist/util/process/platform/posix.js.map +1 -0
- package/dist/util/process/platform/windows.d.ts +3 -0
- package/dist/util/process/platform/windows.d.ts.map +1 -0
- package/dist/util/process/platform/windows.js +114 -0
- package/dist/util/process/platform/windows.js.map +1 -0
- package/package.json +2 -2
package/dist/runtime.js
CHANGED
|
@@ -55,30 +55,17 @@ import { realpathSync, statSync } from "node:fs";
|
|
|
55
55
|
// src/util/process/executable.ts
|
|
56
56
|
import { spawn } from "node:child_process";
|
|
57
57
|
import { stat as stat2 } from "node:fs/promises";
|
|
58
|
-
import { join as
|
|
58
|
+
import { join as join3, resolve as resolve2 } from "node:path";
|
|
59
59
|
|
|
60
|
-
// src/util/platform/linux.ts
|
|
60
|
+
// src/util/process/platform/linux.ts
|
|
61
61
|
import { constants as constants2, readdirSync, readFileSync } from "node:fs";
|
|
62
62
|
import { access as access2, readdir, readFile, realpath as realpath2, stat } from "node:fs/promises";
|
|
63
|
-
import {
|
|
63
|
+
import { join } from "node:path";
|
|
64
64
|
|
|
65
|
-
// src/util/platform/posix.ts
|
|
65
|
+
// src/util/process/platform/posix.ts
|
|
66
66
|
import { execFile } from "node:child_process";
|
|
67
67
|
import { constants } from "node:fs";
|
|
68
|
-
import { access,
|
|
69
|
-
import { tmpdir } from "node:os";
|
|
70
|
-
import { join } from "node:path";
|
|
71
|
-
|
|
72
|
-
// src/util/filesystem/path-error.ts
|
|
73
|
-
var LocalPathError = class extends Error {
|
|
74
|
-
code = "unsafe_local_path";
|
|
75
|
-
constructor(message, options = {}) {
|
|
76
|
-
super(message, options);
|
|
77
|
-
this.name = "LocalPathError";
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
// src/util/platform/posix.ts
|
|
68
|
+
import { access, realpath } from "node:fs/promises";
|
|
82
69
|
var PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
|
|
83
70
|
var PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
|
|
84
71
|
function parseProcessTable(output2) {
|
|
@@ -158,22 +145,7 @@ function terminateProcess(child, signal) {
|
|
|
158
145
|
}
|
|
159
146
|
child.kill(signal);
|
|
160
147
|
}
|
|
161
|
-
async function removeControlSocket(path7) {
|
|
162
|
-
try {
|
|
163
|
-
await unlink(path7);
|
|
164
|
-
} catch (cause) {
|
|
165
|
-
if (!(cause instanceof Error) || !("code" in cause) || cause.code !== "ENOENT") {
|
|
166
|
-
throw cause;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
148
|
var posixOperations = {
|
|
171
|
-
controlSocketPath: (installationHash) => join(tmpdir(), `mobius-${installationHash}.sock`),
|
|
172
|
-
prepareControlSocket: removeControlSocket,
|
|
173
|
-
secureControlSocket: async (path7) => {
|
|
174
|
-
await chmod(path7, 384);
|
|
175
|
-
},
|
|
176
|
-
removeControlSocket,
|
|
177
149
|
pathDelimiter: ":",
|
|
178
150
|
environmentValue: (environment, name2) => environment[name2],
|
|
179
151
|
executableExtensions: () => [""],
|
|
@@ -185,21 +157,10 @@ var posixOperations = {
|
|
|
185
157
|
executableLaunch: (command, args) => ({ command, arguments: args }),
|
|
186
158
|
spawnOptions: { detached: true, windowsHide: true },
|
|
187
159
|
signalCapturedProcesses,
|
|
188
|
-
terminateProcess
|
|
189
|
-
validatePathPermissions: async (path7, directory, privateAccess, signal) => {
|
|
190
|
-
signal.throwIfAborted();
|
|
191
|
-
const metadata = await lstat(path7);
|
|
192
|
-
if (process.getuid === void 0 || metadata.uid !== process.getuid()) {
|
|
193
|
-
throw new LocalPathError("Path is not user-owned");
|
|
194
|
-
}
|
|
195
|
-
if (privateAccess) {
|
|
196
|
-
await chmod(path7, directory ? 448 : 384);
|
|
197
|
-
}
|
|
198
|
-
signal.throwIfAborted();
|
|
199
|
-
}
|
|
160
|
+
terminateProcess
|
|
200
161
|
};
|
|
201
162
|
|
|
202
|
-
// src/util/platform/linux.ts
|
|
163
|
+
// src/util/process/platform/linux.ts
|
|
203
164
|
function appendLinuxProcessTableEntry(entries, processId, encoded) {
|
|
204
165
|
const closingParenthesis = encoded.lastIndexOf(")");
|
|
205
166
|
if (!encoded.startsWith(`${processId.toString()} (`) || closingParenthesis < 0) {
|
|
@@ -229,7 +190,7 @@ async function readLinuxProcessTable() {
|
|
|
229
190
|
appendLinuxProcessTableEntry(
|
|
230
191
|
entries,
|
|
231
192
|
processId,
|
|
232
|
-
await readFile(
|
|
193
|
+
await readFile(join("/proc", directory.name, "stat"), "utf8")
|
|
233
194
|
);
|
|
234
195
|
} catch {
|
|
235
196
|
}
|
|
@@ -254,7 +215,7 @@ function readLinuxProcessTableSynchronously() {
|
|
|
254
215
|
appendLinuxProcessTableEntry(
|
|
255
216
|
entries,
|
|
256
217
|
processId,
|
|
257
|
-
readFileSync(
|
|
218
|
+
readFileSync(join("/proc", directory.name, "stat"), "utf8")
|
|
258
219
|
);
|
|
259
220
|
} catch {
|
|
260
221
|
}
|
|
@@ -287,7 +248,7 @@ async function readLinuxProcessTableWithFallback() {
|
|
|
287
248
|
}
|
|
288
249
|
function processExists2(processId) {
|
|
289
250
|
try {
|
|
290
|
-
const encoded = readFileSync(
|
|
251
|
+
const encoded = readFileSync(join("/proc", processId.toString(), "stat"), "utf8");
|
|
291
252
|
const closingParenthesis = encoded.lastIndexOf(")");
|
|
292
253
|
if (closingParenthesis >= 0) {
|
|
293
254
|
const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
|
|
@@ -299,80 +260,25 @@ function processExists2(processId) {
|
|
|
299
260
|
}
|
|
300
261
|
return processExists(processId);
|
|
301
262
|
}
|
|
302
|
-
var
|
|
263
|
+
var linuxProcessPlatform = {
|
|
303
264
|
...posixOperations,
|
|
304
265
|
readProcessTable: readLinuxProcessTableWithFallback,
|
|
305
266
|
readProcessTableSynchronously: readLinuxProcessTableSynchronously,
|
|
306
|
-
processExists: processExists2
|
|
307
|
-
claudeCodeExecutablePaths: (environment) => {
|
|
308
|
-
const homeDirectory = environment["HOME"];
|
|
309
|
-
return homeDirectory !== void 0 && isAbsolute(homeDirectory) ? [join2(homeDirectory, ".local", "bin", "claude")] : [];
|
|
310
|
-
}
|
|
267
|
+
processExists: processExists2
|
|
311
268
|
};
|
|
312
269
|
|
|
313
|
-
// src/util/platform/macos.ts
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
// src/util/platform/claude-desktop.ts
|
|
317
|
-
import { readdirSync as readdirSync2 } from "node:fs";
|
|
318
|
-
import { join as join3 } from "node:path";
|
|
319
|
-
function installedDirectories(directory) {
|
|
320
|
-
try {
|
|
321
|
-
return readdirSync2(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
322
|
-
} catch (cause) {
|
|
323
|
-
if (cause instanceof Error && "code" in cause && (cause.code === "ENOENT" || cause.code === "ENOTDIR" || cause.code === "EACCES")) {
|
|
324
|
-
return [];
|
|
325
|
-
}
|
|
326
|
-
throw cause;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
function claudeDesktopExecutablePaths(roots, executablePaths) {
|
|
330
|
-
const paths = [];
|
|
331
|
-
for (const root of roots) {
|
|
332
|
-
const versions = installedDirectories(root).filter((version2) => /^\d+\.\d+\.\d+$/.test(version2)).toSorted((left, right) => right.localeCompare(left, "en", { numeric: true }));
|
|
333
|
-
for (const version2 of versions) {
|
|
334
|
-
const directory = join3(root, version2);
|
|
335
|
-
const installations = [
|
|
336
|
-
directory,
|
|
337
|
-
...installedDirectories(directory).map((build) => join3(directory, build))
|
|
338
|
-
];
|
|
339
|
-
for (const installation of installations) {
|
|
340
|
-
for (const executablePath of executablePaths) {
|
|
341
|
-
paths.push(join3(installation, ...executablePath));
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
return paths;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
// src/util/platform/macos.ts
|
|
350
|
-
var macosPlatform = {
|
|
270
|
+
// src/util/process/platform/macos.ts
|
|
271
|
+
var macosProcessPlatform = {
|
|
351
272
|
...posixOperations,
|
|
352
273
|
readProcessTable: () => readProcessTableWithPs("/bin/ps"),
|
|
353
274
|
readProcessTableSynchronously: () => [],
|
|
354
|
-
processExists
|
|
355
|
-
claudeCodeExecutablePaths: (environment) => {
|
|
356
|
-
const paths = ["/opt/homebrew/bin/claude", "/usr/local/bin/claude"];
|
|
357
|
-
const homeDirectory = environment["HOME"];
|
|
358
|
-
if (homeDirectory !== void 0 && isAbsolute2(homeDirectory)) {
|
|
359
|
-
paths.unshift(join4(homeDirectory, ".local", "bin", "claude"));
|
|
360
|
-
paths.push(
|
|
361
|
-
...claudeDesktopExecutablePaths(
|
|
362
|
-
[join4(homeDirectory, "Library", "Application Support", "Claude", "claude-code")],
|
|
363
|
-
[["claude.app", "Contents", "MacOS", "claude"], ["claude"]]
|
|
364
|
-
)
|
|
365
|
-
);
|
|
366
|
-
}
|
|
367
|
-
return paths;
|
|
368
|
-
}
|
|
275
|
+
processExists
|
|
369
276
|
};
|
|
370
277
|
|
|
371
|
-
// src/util/platform/windows.ts
|
|
278
|
+
// src/util/process/platform/windows.ts
|
|
372
279
|
import { execFile as execFile2 } from "node:child_process";
|
|
373
280
|
import { readFile as readFile2, realpath as realpath3 } from "node:fs/promises";
|
|
374
|
-
import { dirname, extname,
|
|
375
|
-
import { promisify } from "node:util";
|
|
281
|
+
import { dirname, extname, join as join2, resolve } from "node:path";
|
|
376
282
|
|
|
377
283
|
// src/util/process/process-error.ts
|
|
378
284
|
var ProcessExecutionError = class extends Error {
|
|
@@ -384,28 +290,10 @@ var ProcessExecutionError = class extends Error {
|
|
|
384
290
|
}
|
|
385
291
|
};
|
|
386
292
|
|
|
387
|
-
// src/util/platform/windows.ts
|
|
388
|
-
var execute = promisify(execFile2);
|
|
293
|
+
// src/util/process/platform/windows.ts
|
|
389
294
|
function environmentValue(environment, name2) {
|
|
390
295
|
return Object.entries(environment).find(([key]) => key.toUpperCase() === name2.toUpperCase())?.[1];
|
|
391
296
|
}
|
|
392
|
-
function desktopClaudeExecutablePaths(environment) {
|
|
393
|
-
const roots = [];
|
|
394
|
-
const localAppData = environmentValue(environment, "LOCALAPPDATA");
|
|
395
|
-
if (localAppData !== void 0 && isAbsolute3(localAppData)) {
|
|
396
|
-
const dataDirectory = join5(localAppData, "Claude-Data");
|
|
397
|
-
for (const installation of installedDirectories(dataDirectory)) {
|
|
398
|
-
if (installation.startsWith("claude_")) {
|
|
399
|
-
roots.push(join5(dataDirectory, installation, "claude-code"));
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
const appData = environmentValue(environment, "APPDATA");
|
|
404
|
-
if (appData !== void 0 && isAbsolute3(appData)) {
|
|
405
|
-
roots.push(join5(appData, "Claude", "claude-code"));
|
|
406
|
-
}
|
|
407
|
-
return claudeDesktopExecutablePaths(roots, [["claude.exe"]]);
|
|
408
|
-
}
|
|
409
297
|
function executableExtensions(executableName, environment) {
|
|
410
298
|
if (/\.[a-zA-Z0-9]+$/.test(executableName)) {
|
|
411
299
|
return [""];
|
|
@@ -464,7 +352,7 @@ function readProcessTable() {
|
|
|
464
352
|
}
|
|
465
353
|
return new Promise((resolveTable) => {
|
|
466
354
|
execFile2(
|
|
467
|
-
|
|
355
|
+
join2(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
468
356
|
[
|
|
469
357
|
"-NoLogo",
|
|
470
358
|
"-NoProfile",
|
|
@@ -497,71 +385,7 @@ function terminateProcess2(child, signal) {
|
|
|
497
385
|
}
|
|
498
386
|
child.kill(signal);
|
|
499
387
|
}
|
|
500
|
-
var
|
|
501
|
-
$ErrorActionPreference = 'Stop'
|
|
502
|
-
$ProgressPreference = 'SilentlyContinue'
|
|
503
|
-
$item = Get-Item -LiteralPath $env:MOBIUS_PERMISSION_PATH -Force
|
|
504
|
-
if (($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0) { throw 'Unsafe path' }
|
|
505
|
-
$sid = [Security.Principal.WindowsIdentity]::GetCurrent().User
|
|
506
|
-
$acl = $item.GetAccessControl()
|
|
507
|
-
$owner = $acl.GetOwner([Security.Principal.SecurityIdentifier])
|
|
508
|
-
if ($owner -ne $sid -and -not ($owner.Value -eq 'S-1-5-32-544' -and ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))) { throw 'Path is not user-owned' }
|
|
509
|
-
if ($env:MOBIUS_PERMISSION_PRIVATE -eq '1') {
|
|
510
|
-
if ($item.PSIsContainer) {
|
|
511
|
-
$private = New-Object Security.AccessControl.DirectorySecurity
|
|
512
|
-
$rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'ContainerInherit,ObjectInherit', 'None', 'Allow')
|
|
513
|
-
} else {
|
|
514
|
-
$private = New-Object Security.AccessControl.FileSecurity
|
|
515
|
-
$rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'Allow')
|
|
516
|
-
}
|
|
517
|
-
$private.SetOwner($sid)
|
|
518
|
-
$private.SetAccessRuleProtection($true, $false)
|
|
519
|
-
$private.AddAccessRule($rule)
|
|
520
|
-
$item.SetAccessControl($private)
|
|
521
|
-
}
|
|
522
|
-
`;
|
|
523
|
-
var windowsPermissionsTimeoutMs = 3e4;
|
|
524
|
-
async function validatePathPermissions(path7, _directory, privateAccess, signal) {
|
|
525
|
-
signal.throwIfAborted();
|
|
526
|
-
const systemRoot = environmentValue(process.env, "SystemRoot");
|
|
527
|
-
if (systemRoot === void 0) {
|
|
528
|
-
throw new LocalPathError("Windows system directory is unavailable");
|
|
529
|
-
}
|
|
530
|
-
try {
|
|
531
|
-
await execute(
|
|
532
|
-
join5(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
533
|
-
[
|
|
534
|
-
"-NoLogo",
|
|
535
|
-
"-NoProfile",
|
|
536
|
-
"-NonInteractive",
|
|
537
|
-
"-EncodedCommand",
|
|
538
|
-
Buffer.from(windowsPermissions, "utf16le").toString("base64")
|
|
539
|
-
],
|
|
540
|
-
{
|
|
541
|
-
env: {
|
|
542
|
-
...process.env,
|
|
543
|
-
MOBIUS_PERMISSION_PATH: path7,
|
|
544
|
-
MOBIUS_PERMISSION_PRIVATE: privateAccess ? "1" : "0"
|
|
545
|
-
},
|
|
546
|
-
windowsHide: true,
|
|
547
|
-
signal: AbortSignal.any([signal, AbortSignal.timeout(windowsPermissionsTimeoutMs)]),
|
|
548
|
-
timeout: windowsPermissionsTimeoutMs,
|
|
549
|
-
maxBuffer: 16384
|
|
550
|
-
}
|
|
551
|
-
);
|
|
552
|
-
} catch (cause) {
|
|
553
|
-
signal.throwIfAborted();
|
|
554
|
-
throw new LocalPathError("The local path permissions could not be secured", { cause });
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
var windowsPlatform = {
|
|
558
|
-
controlSocketPath: (installationHash) => `\\\\.\\pipe\\mobius-${installationHash}`,
|
|
559
|
-
prepareControlSocket: async () => {
|
|
560
|
-
},
|
|
561
|
-
secureControlSocket: async () => {
|
|
562
|
-
},
|
|
563
|
-
removeControlSocket: async () => {
|
|
564
|
-
},
|
|
388
|
+
var windowsProcessPlatform = {
|
|
565
389
|
pathDelimiter: ";",
|
|
566
390
|
environmentValue,
|
|
567
391
|
executableExtensions,
|
|
@@ -570,44 +394,29 @@ var windowsPlatform = {
|
|
|
570
394
|
spawnOptions: { detached: false, windowsHide: true },
|
|
571
395
|
signalCapturedProcesses: signalCapturedProcesses2,
|
|
572
396
|
terminateProcess: terminateProcess2,
|
|
573
|
-
validatePathPermissions,
|
|
574
397
|
readProcessTable,
|
|
575
398
|
readProcessTableSynchronously: () => [],
|
|
576
|
-
processExists
|
|
577
|
-
claudeCodeExecutablePaths: (environment) => {
|
|
578
|
-
const paths = [];
|
|
579
|
-
const userProfile = environmentValue(environment, "USERPROFILE");
|
|
580
|
-
if (userProfile !== void 0 && isAbsolute3(userProfile)) {
|
|
581
|
-
paths.push(join5(userProfile, ".local", "bin", "claude.exe"));
|
|
582
|
-
}
|
|
583
|
-
const localAppData = environmentValue(environment, "LOCALAPPDATA");
|
|
584
|
-
if (localAppData !== void 0 && isAbsolute3(localAppData)) {
|
|
585
|
-
paths.push(join5(localAppData, "Microsoft", "WinGet", "Links", "claude.exe"));
|
|
586
|
-
}
|
|
587
|
-
paths.push(...desktopClaudeExecutablePaths(environment));
|
|
588
|
-
return paths;
|
|
589
|
-
}
|
|
399
|
+
processExists
|
|
590
400
|
};
|
|
591
401
|
|
|
592
|
-
// src/util/platform/index.ts
|
|
402
|
+
// src/util/process/platform/index.ts
|
|
593
403
|
var fallbackPlatform = {
|
|
594
404
|
...posixOperations,
|
|
595
405
|
readProcessTable: () => readProcessTableWithPs("/usr/bin/ps"),
|
|
596
406
|
readProcessTableSynchronously: () => [],
|
|
597
|
-
processExists
|
|
598
|
-
claudeCodeExecutablePaths: () => []
|
|
407
|
+
processExists
|
|
599
408
|
};
|
|
600
409
|
var platforms = /* @__PURE__ */ new Map([
|
|
601
|
-
["linux",
|
|
602
|
-
["darwin",
|
|
603
|
-
["win32",
|
|
410
|
+
["linux", linuxProcessPlatform],
|
|
411
|
+
["darwin", macosProcessPlatform],
|
|
412
|
+
["win32", windowsProcessPlatform]
|
|
604
413
|
]);
|
|
605
|
-
function
|
|
414
|
+
function processPlatformSupportFor(platform2) {
|
|
606
415
|
return platforms.get(platform2) ?? fallbackPlatform;
|
|
607
416
|
}
|
|
608
417
|
|
|
609
418
|
// src/util/process/executable.ts
|
|
610
|
-
var hostPlatform =
|
|
419
|
+
var hostPlatform = processPlatformSupportFor(process.platform);
|
|
611
420
|
var DEFAULT_OUTPUT_LIMIT_BYTES = 16 * 1024;
|
|
612
421
|
var PROCESS_GRACEFUL_STOP_TIMEOUT_MILLISECONDS = 1e3;
|
|
613
422
|
var PROCESS_FORCED_STOP_TIMEOUT_MILLISECONDS = 5e3;
|
|
@@ -650,7 +459,7 @@ var ProcessResult = class {
|
|
|
650
459
|
async function resolveExecutablePath(requestedPath2, platform2 = process.platform) {
|
|
651
460
|
const absoluteRequestedPath = resolve2(requestedPath2);
|
|
652
461
|
try {
|
|
653
|
-
const resolvedPath = await
|
|
462
|
+
const resolvedPath = await processPlatformSupportFor(platform2).resolveExecutableTarget(absoluteRequestedPath);
|
|
654
463
|
const metadata = await stat2(resolvedPath);
|
|
655
464
|
if (!metadata.isFile()) {
|
|
656
465
|
return null;
|
|
@@ -670,7 +479,7 @@ async function resolveExecutablePath(requestedPath2, platform2 = process.platfor
|
|
|
670
479
|
}
|
|
671
480
|
}
|
|
672
481
|
async function findExecutableOnPath(executableName, environment, platform2 = process.platform) {
|
|
673
|
-
const support =
|
|
482
|
+
const support = processPlatformSupportFor(platform2);
|
|
674
483
|
const encodedPath = support.environmentValue(environment, "PATH") ?? "";
|
|
675
484
|
const separator = support.pathDelimiter;
|
|
676
485
|
const extensions = support.executableExtensions(executableName, environment);
|
|
@@ -679,7 +488,7 @@ async function findExecutableOnPath(executableName, environment, platform2 = pro
|
|
|
679
488
|
continue;
|
|
680
489
|
}
|
|
681
490
|
for (const extension of extensions) {
|
|
682
|
-
const requestedPath2 = resolve2(
|
|
491
|
+
const requestedPath2 = resolve2(join3(entry, `${executableName}${extension}`));
|
|
683
492
|
const executable = await resolveExecutablePath(requestedPath2, platform2);
|
|
684
493
|
if (executable !== null) {
|
|
685
494
|
return executable;
|
|
@@ -20920,7 +20729,7 @@ async function runCleanup(...actions) {
|
|
|
20920
20729
|
}
|
|
20921
20730
|
|
|
20922
20731
|
// src/acp/adapter/live-sessions.ts
|
|
20923
|
-
import { isAbsolute
|
|
20732
|
+
import { isAbsolute, resolve as resolve3 } from "node:path";
|
|
20924
20733
|
import { methods as methods3 } from "@agentclientprotocol/sdk";
|
|
20925
20734
|
|
|
20926
20735
|
// ../mobius-sdk/src/protocol/platform/mobius-api.ts
|
|
@@ -20993,17 +20802,6 @@ var ProtocolMessageError = class extends Error {
|
|
|
20993
20802
|
this.name = "ProtocolMessageError";
|
|
20994
20803
|
}
|
|
20995
20804
|
};
|
|
20996
|
-
var UnsupportedProtocolMessageKindError = class extends Error {
|
|
20997
|
-
code = "unsupported_protocol_message_kind";
|
|
20998
|
-
direction;
|
|
20999
|
-
messageKind;
|
|
21000
|
-
constructor(direction, messageKind) {
|
|
21001
|
-
super(`Unsupported ${direction} message kind: ${messageKind}`);
|
|
21002
|
-
this.name = "UnsupportedProtocolMessageKindError";
|
|
21003
|
-
this.direction = direction;
|
|
21004
|
-
this.messageKind = messageKind;
|
|
21005
|
-
}
|
|
21006
|
-
};
|
|
21007
20805
|
function isRecord2(value) {
|
|
21008
20806
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21009
20807
|
}
|
|
@@ -22507,7 +22305,129 @@ var sessionWireEventSchema = external_exports.union([
|
|
|
22507
22305
|
var sessionWireEnvelopeSchema = external_exports.object({
|
|
22508
22306
|
kind: external_exports.literal(SESSION_EVENT_KIND),
|
|
22509
22307
|
events: external_exports.array(sessionWireEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly()
|
|
22510
|
-
}).readonly();
|
|
22308
|
+
}).passthrough().readonly();
|
|
22309
|
+
var knownContentBlockTypes = /* @__PURE__ */ new Set([
|
|
22310
|
+
"text",
|
|
22311
|
+
"image",
|
|
22312
|
+
"audio",
|
|
22313
|
+
"resource_link",
|
|
22314
|
+
"resource",
|
|
22315
|
+
"external_image",
|
|
22316
|
+
"external_audio",
|
|
22317
|
+
"external_resource"
|
|
22318
|
+
]);
|
|
22319
|
+
var knownToolCallContentTypes = /* @__PURE__ */ new Set(["content", "diff", "terminal"]);
|
|
22320
|
+
var knownPlanTypes = /* @__PURE__ */ new Set(["items", "file", "markdown"]);
|
|
22321
|
+
var knownConfigOptionTypes = /* @__PURE__ */ new Set(["select", "boolean"]);
|
|
22322
|
+
var knownSessionUpdates = /* @__PURE__ */ new Set([
|
|
22323
|
+
"user_message_chunk",
|
|
22324
|
+
"agent_message_chunk",
|
|
22325
|
+
"agent_thought_chunk",
|
|
22326
|
+
"tool_call",
|
|
22327
|
+
"tool_call_update",
|
|
22328
|
+
"plan",
|
|
22329
|
+
"plan_update",
|
|
22330
|
+
"plan_removed",
|
|
22331
|
+
"available_commands_update",
|
|
22332
|
+
"current_mode_update",
|
|
22333
|
+
"config_option_update",
|
|
22334
|
+
"session_info_update",
|
|
22335
|
+
"usage_update",
|
|
22336
|
+
"compaction_update",
|
|
22337
|
+
"compaction_summary_chunk"
|
|
22338
|
+
]);
|
|
22339
|
+
var knownLifecycleKinds = /* @__PURE__ */ new Set([
|
|
22340
|
+
"session.queue.changed",
|
|
22341
|
+
"session.permission.requested",
|
|
22342
|
+
"session.permission.resolved",
|
|
22343
|
+
"session.elicitation.requested",
|
|
22344
|
+
"session.elicitation.resolved",
|
|
22345
|
+
"prompt.requested",
|
|
22346
|
+
"prompt.started",
|
|
22347
|
+
"prompt.completed",
|
|
22348
|
+
"prompt.failed-before-start",
|
|
22349
|
+
"prompt.failed"
|
|
22350
|
+
]);
|
|
22351
|
+
function isRecord3(value) {
|
|
22352
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22353
|
+
}
|
|
22354
|
+
function hasUnknownDiscriminator(value, key, known) {
|
|
22355
|
+
if (!isRecord3(value)) {
|
|
22356
|
+
return false;
|
|
22357
|
+
}
|
|
22358
|
+
const variant = value[key];
|
|
22359
|
+
return typeof variant === "string" && !known.has(variant);
|
|
22360
|
+
}
|
|
22361
|
+
function containsUnknownContentBlock(value) {
|
|
22362
|
+
return hasUnknownDiscriminator(value, "type", knownContentBlockTypes);
|
|
22363
|
+
}
|
|
22364
|
+
function containsUnknownToolCallContent(value) {
|
|
22365
|
+
if (hasUnknownDiscriminator(value, "type", knownToolCallContentTypes)) {
|
|
22366
|
+
return true;
|
|
22367
|
+
}
|
|
22368
|
+
return isRecord3(value) && value["type"] === "content" && containsUnknownContentBlock(value["content"]);
|
|
22369
|
+
}
|
|
22370
|
+
function arrayContainsUnknown(value, predicate) {
|
|
22371
|
+
return Array.isArray(value) && value.some(predicate);
|
|
22372
|
+
}
|
|
22373
|
+
function containsUnknownAcpVariant(payload) {
|
|
22374
|
+
const update = payload["sessionUpdate"];
|
|
22375
|
+
if (typeof update !== "string") {
|
|
22376
|
+
return false;
|
|
22377
|
+
}
|
|
22378
|
+
if (!knownSessionUpdates.has(update)) {
|
|
22379
|
+
return true;
|
|
22380
|
+
}
|
|
22381
|
+
if (["user_message_chunk", "agent_message_chunk", "agent_thought_chunk", "compaction_summary_chunk"].includes(
|
|
22382
|
+
update
|
|
22383
|
+
)) {
|
|
22384
|
+
return containsUnknownContentBlock(payload["content"]);
|
|
22385
|
+
}
|
|
22386
|
+
if (update === "tool_call" || update === "tool_call_update") {
|
|
22387
|
+
return arrayContainsUnknown(payload["content"], containsUnknownToolCallContent);
|
|
22388
|
+
}
|
|
22389
|
+
if (update === "plan_update") {
|
|
22390
|
+
return hasUnknownDiscriminator(payload["plan"], "type", knownPlanTypes);
|
|
22391
|
+
}
|
|
22392
|
+
if (update === "config_option_update") {
|
|
22393
|
+
return arrayContainsUnknown(
|
|
22394
|
+
payload["configOptions"],
|
|
22395
|
+
(option) => hasUnknownDiscriminator(option, "type", knownConfigOptionTypes)
|
|
22396
|
+
);
|
|
22397
|
+
}
|
|
22398
|
+
if (update === "compaction_update") {
|
|
22399
|
+
return arrayContainsUnknown(payload["summary"], containsUnknownContentBlock);
|
|
22400
|
+
}
|
|
22401
|
+
return false;
|
|
22402
|
+
}
|
|
22403
|
+
function isKnownSessionEventVariant(value) {
|
|
22404
|
+
if (!isRecord3(value)) {
|
|
22405
|
+
return true;
|
|
22406
|
+
}
|
|
22407
|
+
const type = value["type"];
|
|
22408
|
+
if (typeof type !== "string") {
|
|
22409
|
+
return true;
|
|
22410
|
+
}
|
|
22411
|
+
if (type === "acp") {
|
|
22412
|
+
const payload = value["payload"];
|
|
22413
|
+
return !isRecord3(payload) || !containsUnknownAcpVariant(payload);
|
|
22414
|
+
}
|
|
22415
|
+
if (type === "lifecycle-metadata") {
|
|
22416
|
+
const payload = value["payload"];
|
|
22417
|
+
if (!isRecord3(payload)) {
|
|
22418
|
+
return true;
|
|
22419
|
+
}
|
|
22420
|
+
const kind = payload["kind"];
|
|
22421
|
+
if (typeof kind === "string" && !knownLifecycleKinds.has(kind)) {
|
|
22422
|
+
return false;
|
|
22423
|
+
}
|
|
22424
|
+
return kind !== "prompt.requested" || !arrayContainsUnknown(payload["content"], containsUnknownContentBlock);
|
|
22425
|
+
}
|
|
22426
|
+
return false;
|
|
22427
|
+
}
|
|
22428
|
+
function filterKnownSessionEventVariants(events) {
|
|
22429
|
+
return Array.isArray(events) ? events.filter(isKnownSessionEventVariant) : events;
|
|
22430
|
+
}
|
|
22511
22431
|
var sessionEventBatchSchema = external_exports.array(sessionEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
22512
22432
|
var sessionLiveEventBatchSchema = external_exports.array(sessionLiveEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
22513
22433
|
var sessionExportSchema = external_exports.object({
|
|
@@ -22593,10 +22513,28 @@ function decode4(value, schema) {
|
|
|
22593
22513
|
function encode3(value, schema) {
|
|
22594
22514
|
return JSON.stringify(decode4(value, schema));
|
|
22595
22515
|
}
|
|
22516
|
+
function sanitizeKnownNativeSessionEvents(value) {
|
|
22517
|
+
const input2 = inputValue(value);
|
|
22518
|
+
if (!isRecord3(input2)) {
|
|
22519
|
+
return input2;
|
|
22520
|
+
}
|
|
22521
|
+
const page = input2["events"];
|
|
22522
|
+
const queuedPromptRequests = input2["queuedPromptRequests"];
|
|
22523
|
+
return {
|
|
22524
|
+
...input2,
|
|
22525
|
+
events: isRecord3(page) ? { ...page, events: filterKnownSessionEventVariants(page["events"]) } : page,
|
|
22526
|
+
queuedPromptRequests: Array.isArray(queuedPromptRequests) ? queuedPromptRequests.filter(
|
|
22527
|
+
(prompt) => !isRecord3(prompt) || !arrayContainsUnknown(prompt["content"], containsUnknownContentBlock)
|
|
22528
|
+
) : queuedPromptRequests
|
|
22529
|
+
};
|
|
22530
|
+
}
|
|
22531
|
+
var knownSessionLiveEventBatchSchema = external_exports.array(sessionLiveEventSchema).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
22596
22532
|
var decodeSessionEvent = (value) => decode4(value, sessionEventSchema);
|
|
22533
|
+
var decodeKnownSessionEventPayload = (value) => isKnownSessionEventVariant(value) ? decode4(value, sessionEventPayloadSchema) : null;
|
|
22597
22534
|
var decodeSessionEventEnvelope = (value) => decode4(value, sessionEventEnvelopeSchema);
|
|
22598
22535
|
var encodeSessionEventEnvelope = (value) => encode3(value, sessionEventEnvelopeSchema);
|
|
22599
22536
|
var decodeAcpSessionUpdate = (value) => decode4(value, acpSessionUpdateSchema);
|
|
22537
|
+
var decodeKnownNativeSessionEvents = (value) => decode4(sanitizeKnownNativeSessionEvents(value), nativeSessionEventsSchema);
|
|
22600
22538
|
|
|
22601
22539
|
// ../mobius-sdk/src/protocol/session/observability/history.ts
|
|
22602
22540
|
var SESSION_HISTORY_PAGE_LOAD_KIND = "session.live-history.v2.page.load";
|
|
@@ -22627,6 +22565,30 @@ var pageLoadedFields = {
|
|
|
22627
22565
|
};
|
|
22628
22566
|
var sessionHistoryPageLoadedSchema = external_exports.object({ ...pageLoadedFields, kind: external_exports.literal(SESSION_HISTORY_PAGE_LOADED_KIND) }).readonly();
|
|
22629
22567
|
var sessionPreviewHistoryPageLoadedSchema = external_exports.object({ ...pageLoadedFields, kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND) }).readonly();
|
|
22568
|
+
var wireNativeSessionEventsSchema = external_exports.object({
|
|
22569
|
+
events: external_exports.object({
|
|
22570
|
+
events: external_exports.array(external_exports.unknown()).max(1e4).readonly(),
|
|
22571
|
+
nextCursor: external_exports.string().min(1).max(512).nullable(),
|
|
22572
|
+
sessionGenerationId: identifierStringSchema,
|
|
22573
|
+
tailCursor: external_exports.string().max(512),
|
|
22574
|
+
throughPosition: external_exports.string().regex(/^(0|[1-9][0-9]*)$/u).optional(),
|
|
22575
|
+
truncated: external_exports.boolean(),
|
|
22576
|
+
version: external_exports.literal(2)
|
|
22577
|
+
}).passthrough().readonly(),
|
|
22578
|
+
queuedPromptRequests: external_exports.array(external_exports.unknown()).max(1e3).readonly()
|
|
22579
|
+
}).passthrough().readonly();
|
|
22580
|
+
var sessionHistoryWirePageLoadedSchema = external_exports.object({
|
|
22581
|
+
events: wireNativeSessionEventsSchema,
|
|
22582
|
+
kind: external_exports.literal(SESSION_HISTORY_PAGE_LOADED_KIND),
|
|
22583
|
+
requestId: identifierStringSchema,
|
|
22584
|
+
sessionId: identifierStringSchema
|
|
22585
|
+
}).passthrough().readonly();
|
|
22586
|
+
var sessionPreviewHistoryWirePageLoadedSchema = external_exports.object({
|
|
22587
|
+
events: wireNativeSessionEventsSchema,
|
|
22588
|
+
kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND),
|
|
22589
|
+
requestId: identifierStringSchema,
|
|
22590
|
+
sessionId: identifierStringSchema
|
|
22591
|
+
}).passthrough().readonly();
|
|
22630
22592
|
function decode5(schema, encoded) {
|
|
22631
22593
|
try {
|
|
22632
22594
|
const value = JSON.parse(encoded);
|
|
@@ -22635,10 +22597,21 @@ function decode5(schema, encoded) {
|
|
|
22635
22597
|
throw new ProtocolMessageError("Invalid live Session history message", { cause });
|
|
22636
22598
|
}
|
|
22637
22599
|
}
|
|
22600
|
+
function decodeLoaded(schema, encoded) {
|
|
22601
|
+
try {
|
|
22602
|
+
const value = JSON.parse(encoded);
|
|
22603
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
22604
|
+
return schema.parse(value);
|
|
22605
|
+
}
|
|
22606
|
+
return schema.parse({ ...value, events: decodeKnownNativeSessionEvents(Reflect.get(value, "events")) });
|
|
22607
|
+
} catch (cause) {
|
|
22608
|
+
throw new ProtocolMessageError("Invalid live Session history message", { cause });
|
|
22609
|
+
}
|
|
22610
|
+
}
|
|
22638
22611
|
var decodeSessionHistoryPageLoad = (encoded) => decode5(sessionHistoryPageLoadSchema, encoded);
|
|
22639
|
-
var decodeSessionHistoryPageLoaded = (encoded) =>
|
|
22612
|
+
var decodeSessionHistoryPageLoaded = (encoded) => decodeLoaded(sessionHistoryPageLoadedSchema, encoded);
|
|
22640
22613
|
var decodeSessionPreviewHistoryPageLoad = (encoded) => decode5(sessionPreviewHistoryPageLoadSchema, encoded);
|
|
22641
|
-
var decodeSessionPreviewHistoryPageLoaded = (encoded) =>
|
|
22614
|
+
var decodeSessionPreviewHistoryPageLoaded = (encoded) => decodeLoaded(sessionPreviewHistoryPageLoadedSchema, encoded);
|
|
22642
22615
|
var encodeSessionHistoryPageLoad = (value) => JSON.stringify(sessionHistoryPageLoadSchema.parse(value));
|
|
22643
22616
|
var encodeSessionHistoryPageLoaded = (value) => JSON.stringify(sessionHistoryPageLoadedSchema.parse(value));
|
|
22644
22617
|
var encodeSessionPreviewHistoryPageLoad = (value) => JSON.stringify(sessionPreviewHistoryPageLoadSchema.parse(value));
|
|
@@ -22879,13 +22852,28 @@ var serviceToDaemonSignatures = {
|
|
|
22879
22852
|
)
|
|
22880
22853
|
};
|
|
22881
22854
|
var serviceToDaemonRegistry = serviceToDaemonSignatures;
|
|
22882
|
-
|
|
22855
|
+
var knownNativeActions = /* @__PURE__ */ new Set(["active-turn", "find", "list", "import", "fork"]);
|
|
22856
|
+
function isRecord4(value) {
|
|
22857
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22858
|
+
}
|
|
22859
|
+
function hasUnknownDiscriminator2(value, key, known) {
|
|
22860
|
+
if (!isRecord4(value)) {
|
|
22861
|
+
return false;
|
|
22862
|
+
}
|
|
22863
|
+
const variant = value[key];
|
|
22864
|
+
return typeof variant === "string" && !known.has(variant);
|
|
22865
|
+
}
|
|
22866
|
+
function hasUnknownServiceVariant(kind, value) {
|
|
22867
|
+
return kind === NATIVE_SESSION_REQUEST_KIND && hasUnknownDiscriminator2(value, "action", knownNativeActions);
|
|
22868
|
+
}
|
|
22869
|
+
function decodeKnownServiceToDaemonMessage(encoded) {
|
|
22883
22870
|
const kind = decodeMessageKind(encoded);
|
|
22884
22871
|
const signature = serviceToDaemonRegistry[kind];
|
|
22885
22872
|
if (signature === void 0) {
|
|
22886
|
-
|
|
22873
|
+
return null;
|
|
22887
22874
|
}
|
|
22888
|
-
|
|
22875
|
+
const value = parseJson(encoded);
|
|
22876
|
+
return hasUnknownServiceVariant(kind, value) ? null : signature.decoder(encoded);
|
|
22889
22877
|
}
|
|
22890
22878
|
var daemonToServiceSignatures = {
|
|
22891
22879
|
[SESSION_CLOSED_KIND]: defineMessageSignature(
|
|
@@ -23101,7 +23089,7 @@ var SessionConfigProtocolError = class extends Error {
|
|
|
23101
23089
|
this.name = "SessionConfigProtocolError";
|
|
23102
23090
|
}
|
|
23103
23091
|
};
|
|
23104
|
-
function
|
|
23092
|
+
function isRecord5(value) {
|
|
23105
23093
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23106
23094
|
}
|
|
23107
23095
|
function readString3(value, fallback = "") {
|
|
@@ -23132,7 +23120,7 @@ function normalizeConfigValues(value) {
|
|
|
23132
23120
|
}
|
|
23133
23121
|
const normalized = [];
|
|
23134
23122
|
for (const entry of value) {
|
|
23135
|
-
if (!
|
|
23123
|
+
if (!isRecord5(entry)) {
|
|
23136
23124
|
continue;
|
|
23137
23125
|
}
|
|
23138
23126
|
const groupedOptions = entry["options"];
|
|
@@ -23140,7 +23128,7 @@ function normalizeConfigValues(value) {
|
|
|
23140
23128
|
const groupId = readString3(entry["group"]);
|
|
23141
23129
|
const groupName = readString3(entry["name"]);
|
|
23142
23130
|
for (const groupedOption of groupedOptions) {
|
|
23143
|
-
if (
|
|
23131
|
+
if (isRecord5(groupedOption)) {
|
|
23144
23132
|
const normalizedValue = normalizeConfigValue(groupedOption, groupId, groupName);
|
|
23145
23133
|
if (normalizedValue !== void 0) {
|
|
23146
23134
|
normalized.push(normalizedValue);
|
|
@@ -23165,7 +23153,7 @@ function normalizeConfigOptions(value, modes) {
|
|
|
23165
23153
|
const normalized = [];
|
|
23166
23154
|
if (Array.isArray(value)) {
|
|
23167
23155
|
for (const option of value) {
|
|
23168
|
-
if (!
|
|
23156
|
+
if (!isRecord5(option)) {
|
|
23169
23157
|
continue;
|
|
23170
23158
|
}
|
|
23171
23159
|
const id = truncate2(readString3(option["id"]), 128);
|
|
@@ -23205,12 +23193,12 @@ function normalizeConfigOptions(value, modes) {
|
|
|
23205
23193
|
}
|
|
23206
23194
|
}
|
|
23207
23195
|
}
|
|
23208
|
-
if (
|
|
23196
|
+
if (isRecord5(modes)) {
|
|
23209
23197
|
const values = [];
|
|
23210
23198
|
const availableModes = modes["availableModes"];
|
|
23211
23199
|
if (Array.isArray(availableModes)) {
|
|
23212
23200
|
for (const mode of availableModes) {
|
|
23213
|
-
if (!
|
|
23201
|
+
if (!isRecord5(mode)) {
|
|
23214
23202
|
continue;
|
|
23215
23203
|
}
|
|
23216
23204
|
const id = truncate2(readString3(mode["id"]), 500);
|
|
@@ -23243,7 +23231,7 @@ function normalizeConfigOptions(value, modes) {
|
|
|
23243
23231
|
return normalized.slice(0, MAXIMUM_CONFIG_OPTIONS);
|
|
23244
23232
|
}
|
|
23245
23233
|
function normalizeStandardLifecycle(response) {
|
|
23246
|
-
const lifecycle =
|
|
23234
|
+
const lifecycle = isRecord5(response) ? response : {};
|
|
23247
23235
|
return normalizeConfigOptions(lifecycle["configOptions"], lifecycle["modes"]);
|
|
23248
23236
|
}
|
|
23249
23237
|
function replaceStandardConfigOptions(current, value) {
|
|
@@ -23285,7 +23273,7 @@ var StandardSessionConfigProtocol = class {
|
|
|
23285
23273
|
"ACP agent exited while changing session configuration",
|
|
23286
23274
|
change.signal
|
|
23287
23275
|
);
|
|
23288
|
-
if (!
|
|
23276
|
+
if (!isRecord5(response) || !Array.isArray(response["configOptions"])) {
|
|
23289
23277
|
throw new SessionConfigProtocolError("The Agent returned an invalid session configuration response");
|
|
23290
23278
|
}
|
|
23291
23279
|
return replaceStandardConfigOptions(current, response["configOptions"]);
|
|
@@ -23594,7 +23582,7 @@ var AcpSessionConnector = class {
|
|
|
23594
23582
|
};
|
|
23595
23583
|
|
|
23596
23584
|
// src/acp/adapter/live-sessions.ts
|
|
23597
|
-
var absolutePathSchema = external_exports.string().min(1).refine(
|
|
23585
|
+
var absolutePathSchema = external_exports.string().min(1).refine(isAbsolute);
|
|
23598
23586
|
var targetSchema = external_exports.object({
|
|
23599
23587
|
nativeSessionId: nativeSessionIdSchema,
|
|
23600
23588
|
cwd: absolutePathSchema,
|
|
@@ -24924,7 +24912,7 @@ import { createHash as createHash3 } from "node:crypto";
|
|
|
24924
24912
|
import { spawn as spawn2 } from "node:child_process";
|
|
24925
24913
|
|
|
24926
24914
|
// src/acp/harness/codex/app-server-protocol.ts
|
|
24927
|
-
import { isAbsolute as
|
|
24915
|
+
import { isAbsolute as isAbsolute2 } from "node:path";
|
|
24928
24916
|
var boundedText = (maximum) => external_exports.string().max(maximum);
|
|
24929
24917
|
var jsonValue = external_exports.lazy(() => external_exports.unknown());
|
|
24930
24918
|
var requestIdSchema = external_exports.union([external_exports.number(), external_exports.string()]).refine((value) => typeof value === "number" || value.length <= 256);
|
|
@@ -24996,7 +24984,7 @@ var imageGenerationItemSchema = external_exports.object({
|
|
|
24996
24984
|
});
|
|
24997
24985
|
var threadItemSchema = external_exports.discriminatedUnion("type", [
|
|
24998
24986
|
imageGenerationItemSchema,
|
|
24999
|
-
external_exports.object({ type: external_exports.literal("imageView"), id: boundedText(256), path: boundedText(32768).refine(
|
|
24987
|
+
external_exports.object({ type: external_exports.literal("imageView"), id: boundedText(256), path: boundedText(32768).refine(isAbsolute2) }),
|
|
25000
24988
|
external_exports.object({
|
|
25001
24989
|
id: boundedText(256),
|
|
25002
24990
|
text: boundedText(1e6),
|
|
@@ -25474,7 +25462,7 @@ var CodexAppServerClient = class {
|
|
|
25474
25462
|
import { createHash } from "node:crypto";
|
|
25475
25463
|
|
|
25476
25464
|
// src/acp/content/raster.ts
|
|
25477
|
-
import { basename, isAbsolute as
|
|
25465
|
+
import { basename, isAbsolute as isAbsolute3, normalize } from "node:path";
|
|
25478
25466
|
import { fileURLToPath } from "node:url";
|
|
25479
25467
|
|
|
25480
25468
|
// src/storage/files/local-files.ts
|
|
@@ -25581,13 +25569,13 @@ function sniffRasterMime(bytes) {
|
|
|
25581
25569
|
}
|
|
25582
25570
|
async function resolveCanonicalPath(requested, signal) {
|
|
25583
25571
|
signal.throwIfAborted();
|
|
25584
|
-
if (!
|
|
25572
|
+
if (!isAbsolute3(requested) || requested.includes("\0") || normalize(requested) !== requested) {
|
|
25585
25573
|
return null;
|
|
25586
25574
|
}
|
|
25587
25575
|
try {
|
|
25588
25576
|
const target = await canonicalPath(requested);
|
|
25589
25577
|
signal.throwIfAborted();
|
|
25590
|
-
if (!
|
|
25578
|
+
if (!isAbsolute3(target) || normalize(target) !== target) {
|
|
25591
25579
|
return null;
|
|
25592
25580
|
}
|
|
25593
25581
|
return target;
|
|
@@ -25618,7 +25606,7 @@ function parseLocalImageUri(uri) {
|
|
|
25618
25606
|
return null;
|
|
25619
25607
|
}
|
|
25620
25608
|
}
|
|
25621
|
-
if (!
|
|
25609
|
+
if (!isAbsolute3(trimmed) && /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(trimmed)) {
|
|
25622
25610
|
return null;
|
|
25623
25611
|
}
|
|
25624
25612
|
return trimmed;
|
|
@@ -26884,12 +26872,12 @@ async function replayCodexHistory(client2, threadId, emit, signal) {
|
|
|
26884
26872
|
|
|
26885
26873
|
// src/storage/session/temporary-session-event-cache.ts
|
|
26886
26874
|
import { mkdtempSync, rmSync } from "node:fs";
|
|
26887
|
-
import { tmpdir
|
|
26888
|
-
import { join as
|
|
26875
|
+
import { tmpdir } from "node:os";
|
|
26876
|
+
import { join as join5 } from "node:path";
|
|
26889
26877
|
|
|
26890
26878
|
// src/storage/sqlite/local-databases.ts
|
|
26891
26879
|
import { createHash as createHash2 } from "node:crypto";
|
|
26892
|
-
import { join as
|
|
26880
|
+
import { join as join4 } from "node:path";
|
|
26893
26881
|
|
|
26894
26882
|
// src/generated/acp-session-store-migrations.ts
|
|
26895
26883
|
var acpSessionStoreMigrations = [
|
|
@@ -27432,7 +27420,7 @@ function sql(strings, ...params) {
|
|
|
27432
27420
|
return new SQL([new StringChunk(str)]);
|
|
27433
27421
|
}
|
|
27434
27422
|
_sql.raw = raw;
|
|
27435
|
-
function
|
|
27423
|
+
function join34(chunks, separator) {
|
|
27436
27424
|
const result = [];
|
|
27437
27425
|
for (const [i, chunk] of chunks.entries()) {
|
|
27438
27426
|
if (i > 0 && separator !== void 0) result.push(separator);
|
|
@@ -27440,7 +27428,7 @@ function sql(strings, ...params) {
|
|
|
27440
27428
|
}
|
|
27441
27429
|
return new SQL(result);
|
|
27442
27430
|
}
|
|
27443
|
-
_sql.join =
|
|
27431
|
+
_sql.join = join34;
|
|
27444
27432
|
function identifier2(value) {
|
|
27445
27433
|
return new Name(value);
|
|
27446
27434
|
}
|
|
@@ -29161,7 +29149,7 @@ var SQLiteSelectBase = class extends TypedQueryBuilder {
|
|
|
29161
29149
|
const baseTableName = this.tableName;
|
|
29162
29150
|
const tableName = getTableLikeName(table);
|
|
29163
29151
|
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
29164
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
29152
|
+
if (typeof tableName === "string" && this.config.joins?.some((join34) => join34.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
29165
29153
|
if (!this.isPartialSelect) {
|
|
29166
29154
|
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
|
|
29167
29155
|
if (typeof tableName === "string" && !is(table, SQL)) {
|
|
@@ -30707,7 +30695,7 @@ var SQLiteDialect = class {
|
|
|
30707
30695
|
if (!joins2) return;
|
|
30708
30696
|
const withEntries = Object.entries(joins2).filter(([_, v]) => v);
|
|
30709
30697
|
if (!withEntries.length) return;
|
|
30710
|
-
return sql.join(withEntries.map(([k2,
|
|
30698
|
+
return sql.join(withEntries.map(([k2, join34]) => {
|
|
30711
30699
|
const relation = tableConfig.relations[k2];
|
|
30712
30700
|
const isSingle2 = is(relation, One);
|
|
30713
30701
|
const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
|
|
@@ -30718,7 +30706,7 @@ var SQLiteDialect = class {
|
|
|
30718
30706
|
table: targetTable,
|
|
30719
30707
|
mode: isSingle2 ? "first" : "many",
|
|
30720
30708
|
schema,
|
|
30721
|
-
queryConfig:
|
|
30709
|
+
queryConfig: join34,
|
|
30722
30710
|
tableConfig: schema[relation.targetTableName],
|
|
30723
30711
|
relationWhere: filter,
|
|
30724
30712
|
isNested: true,
|
|
@@ -30732,7 +30720,7 @@ var SQLiteDialect = class {
|
|
|
30732
30720
|
key: k2,
|
|
30733
30721
|
selection: innerQuery.selection,
|
|
30734
30722
|
isArray: !isSingle2,
|
|
30735
|
-
isOptional: (relation.optional ?? false) ||
|
|
30723
|
+
isOptional: (relation.optional ?? false) || join34 !== true && !!join34.where
|
|
30736
30724
|
});
|
|
30737
30725
|
const jsonColumns = sql.join(innerQuery.selection.map((s) => {
|
|
30738
30726
|
return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
|
|
@@ -31086,7 +31074,7 @@ var SQLiteUpdateBase = class {
|
|
|
31086
31074
|
createJoin(joinType) {
|
|
31087
31075
|
return ((table, on2) => {
|
|
31088
31076
|
const tableName = getTableLikeName(table);
|
|
31089
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
31077
|
+
if (typeof tableName === "string" && this.config.joins.some((join34) => join34.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
31090
31078
|
if (typeof on2 === "function") {
|
|
31091
31079
|
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;
|
|
31092
31080
|
on2 = on2(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
|
|
@@ -31870,8 +31858,8 @@ var LocalSqliteDatabase = class {
|
|
|
31870
31858
|
function channelSessionDatabasePaths(stateDirectory, channelId) {
|
|
31871
31859
|
const channelHash = createHash2("sha256").update(channelId).digest("hex");
|
|
31872
31860
|
return {
|
|
31873
|
-
events:
|
|
31874
|
-
sessions:
|
|
31861
|
+
events: join4(stateDirectory, "sessions", `${channelHash}.events.sqlite`),
|
|
31862
|
+
sessions: join4(stateDirectory, "sessions", `${channelHash}.sqlite`)
|
|
31875
31863
|
};
|
|
31876
31864
|
}
|
|
31877
31865
|
var openAcpSessionDatabase = (path7) => new LocalSqliteDatabase(path7, "ACP Session database", acpSessionStoreMigrations);
|
|
@@ -32049,11 +32037,11 @@ var SessionEventCacheTable = class {
|
|
|
32049
32037
|
|
|
32050
32038
|
// src/storage/session/temporary-session-event-cache.ts
|
|
32051
32039
|
function openTemporarySessionEventCache() {
|
|
32052
|
-
const directory = mkdtempSync(
|
|
32040
|
+
const directory = mkdtempSync(join5(tmpdir(), "mobius-preview-events-"));
|
|
32053
32041
|
const removeFiles = () => rmSync(directory, { recursive: true, force: true });
|
|
32054
32042
|
try {
|
|
32055
32043
|
return {
|
|
32056
|
-
table: new SessionEventCacheTable(openSessionEventCacheDatabase(
|
|
32044
|
+
table: new SessionEventCacheTable(openSessionEventCacheDatabase(join5(directory, "events.sqlite"))),
|
|
32057
32045
|
removeFiles
|
|
32058
32046
|
};
|
|
32059
32047
|
} catch (error62) {
|
|
@@ -32345,7 +32333,7 @@ var toolImageSchema = external_exports.union([
|
|
|
32345
32333
|
file: external_exports.object({ base64: external_exports.string(), type: external_exports.string() })
|
|
32346
32334
|
}).transform(({ file: file2 }) => ({ type: "image", data: file2.base64, mimeType: file2.type }))
|
|
32347
32335
|
]);
|
|
32348
|
-
function
|
|
32336
|
+
function isRecord6(value) {
|
|
32349
32337
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
32350
32338
|
}
|
|
32351
32339
|
var AcpContentExternalizer = class {
|
|
@@ -32452,13 +32440,13 @@ var AcpContentExternalizer = class {
|
|
|
32452
32440
|
}
|
|
32453
32441
|
return result2;
|
|
32454
32442
|
}
|
|
32455
|
-
if (!
|
|
32443
|
+
if (!isRecord6(value)) {
|
|
32456
32444
|
return value;
|
|
32457
32445
|
}
|
|
32458
32446
|
const image = toolImageSchema.safeParse(value);
|
|
32459
32447
|
if (image.success && image.data.data.length > 0) {
|
|
32460
32448
|
const prepared = await this.#content(sessionId, image.data, signal);
|
|
32461
|
-
if (
|
|
32449
|
+
if (isRecord6(prepared.event) && typeof prepared.event["imageKey"] === "string") {
|
|
32462
32450
|
images.set(prepared.event["imageKey"], prepared);
|
|
32463
32451
|
} else {
|
|
32464
32452
|
images.set(`unavailable:${images.size}`, prepared);
|
|
@@ -32489,7 +32477,7 @@ var AcpContentExternalizer = class {
|
|
|
32489
32477
|
const prepared = await this.#content(sessionId, content, signal);
|
|
32490
32478
|
agentContent.push({ ...item, content: prepared.agent });
|
|
32491
32479
|
eventContent.push({ ...item, content: prepared.event });
|
|
32492
|
-
if (
|
|
32480
|
+
if (isRecord6(prepared.event) && typeof prepared.event["imageKey"] === "string") {
|
|
32493
32481
|
images.delete(prepared.event["imageKey"]);
|
|
32494
32482
|
}
|
|
32495
32483
|
}
|
|
@@ -32563,13 +32551,13 @@ var RuntimeAgentDependencies = class {
|
|
|
32563
32551
|
|
|
32564
32552
|
// src/daemon/pairing/pair-local-machine.ts
|
|
32565
32553
|
import { hostname as hostname3 } from "node:os";
|
|
32566
|
-
import { basename as basename6, join as
|
|
32554
|
+
import { basename as basename6, join as join26, resolve as resolve16 } from "node:path";
|
|
32567
32555
|
import { fetch as fetch3 } from "undici";
|
|
32568
32556
|
|
|
32569
32557
|
// package.json
|
|
32570
32558
|
var package_default = {
|
|
32571
32559
|
name: "@moxt-ai/mobius",
|
|
32572
|
-
version: "0.0.
|
|
32560
|
+
version: "0.0.337",
|
|
32573
32561
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
32574
32562
|
type: "module",
|
|
32575
32563
|
bin: {
|
|
@@ -32751,7 +32739,7 @@ import { existsSync as existsSync3 } from "node:fs";
|
|
|
32751
32739
|
import * as fs3 from "node:fs/promises";
|
|
32752
32740
|
import * as os3 from "node:os";
|
|
32753
32741
|
import * as path6 from "node:path";
|
|
32754
|
-
import { promisify
|
|
32742
|
+
import { promisify } from "node:util";
|
|
32755
32743
|
import { agent as acpAgent, CreateElicitationResponse as CreateElicitationResponse2, methods as methods7, ndJsonStream, RequestError as RequestError6 } from "@agentclientprotocol/sdk";
|
|
32756
32744
|
|
|
32757
32745
|
// ../../node_modules/.pnpm/@anthropic-ai+claude-agent-sdk@0.3.257_@anthropic-ai+sdk@0.122.0_zod@4.6.5__@modelconte_b0b90ed00d211c5955785f7de7f8dbf4/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
|
|
@@ -69847,7 +69835,7 @@ var DESTINATIONS = /* @__PURE__ */ new Set([
|
|
|
69847
69835
|
]);
|
|
69848
69836
|
var BEHAVIORS = /* @__PURE__ */ new Set(["allow", "deny", "ask"]);
|
|
69849
69837
|
var MODES = /* @__PURE__ */ new Set(["default", "acceptEdits", "bypassPermissions", "plan", "dontAsk", "auto"]);
|
|
69850
|
-
function
|
|
69838
|
+
function isRecord7(value) {
|
|
69851
69839
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
69852
69840
|
}
|
|
69853
69841
|
function isDestination(value) {
|
|
@@ -69864,13 +69852,13 @@ function safePlainString(value, maxLength) {
|
|
|
69864
69852
|
});
|
|
69865
69853
|
}
|
|
69866
69854
|
function isRule(value) {
|
|
69867
|
-
if (!
|
|
69855
|
+
if (!isRecord7(value) || !safePlainString(value.toolName, MAX_TOOL_NAME_LENGTH)) {
|
|
69868
69856
|
return false;
|
|
69869
69857
|
}
|
|
69870
69858
|
return value.ruleContent === void 0 || safePlainString(value.ruleContent, MAX_RULE_CONTENT_LENGTH);
|
|
69871
69859
|
}
|
|
69872
69860
|
function isKnownUpdate(value) {
|
|
69873
|
-
if (!
|
|
69861
|
+
if (!isRecord7(value) || !isDestination(value.destination) || typeof value.type !== "string") {
|
|
69874
69862
|
return false;
|
|
69875
69863
|
}
|
|
69876
69864
|
switch (value.type) {
|
|
@@ -72117,7 +72105,7 @@ var SessionModeManager = class {
|
|
|
72117
72105
|
|
|
72118
72106
|
// src/acp/harness/claude/upstream/dist/acp-agent.js
|
|
72119
72107
|
var CLAUDE_CONFIG_DIR = process.env.CLAUDE_CONFIG_DIR ?? path6.join(os3.homedir(), ".claude");
|
|
72120
|
-
var execFileAsync =
|
|
72108
|
+
var execFileAsync = promisify(execFile3);
|
|
72121
72109
|
var ZERO_USAGE = Object.freeze({
|
|
72122
72110
|
input_tokens: 0,
|
|
72123
72111
|
output_tokens: 0,
|
|
@@ -76884,6 +76872,237 @@ var ClaudeAgentConnection = class extends EndpointAgentConnection {
|
|
|
76884
76872
|
}
|
|
76885
76873
|
};
|
|
76886
76874
|
|
|
76875
|
+
// src/util/platform/linux.ts
|
|
76876
|
+
import { isAbsolute as isAbsolute8, join as join13 } from "node:path";
|
|
76877
|
+
|
|
76878
|
+
// src/util/platform/posix.ts
|
|
76879
|
+
import { chmod, lstat as lstat2, unlink as unlink2 } from "node:fs/promises";
|
|
76880
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
76881
|
+
import { join as join12 } from "node:path";
|
|
76882
|
+
|
|
76883
|
+
// src/util/filesystem/path-error.ts
|
|
76884
|
+
var LocalPathError = class extends Error {
|
|
76885
|
+
code = "unsafe_local_path";
|
|
76886
|
+
constructor(message, options = {}) {
|
|
76887
|
+
super(message, options);
|
|
76888
|
+
this.name = "LocalPathError";
|
|
76889
|
+
}
|
|
76890
|
+
};
|
|
76891
|
+
|
|
76892
|
+
// src/util/platform/posix.ts
|
|
76893
|
+
async function removeControlSocket(path7) {
|
|
76894
|
+
try {
|
|
76895
|
+
await unlink2(path7);
|
|
76896
|
+
} catch (cause) {
|
|
76897
|
+
if (!(cause instanceof Error) || !("code" in cause) || cause.code !== "ENOENT") {
|
|
76898
|
+
throw cause;
|
|
76899
|
+
}
|
|
76900
|
+
}
|
|
76901
|
+
}
|
|
76902
|
+
var posixOperations2 = {
|
|
76903
|
+
controlSocketPath: (installationHash) => join12(tmpdir2(), `mobius-${installationHash}.sock`),
|
|
76904
|
+
prepareControlSocket: removeControlSocket,
|
|
76905
|
+
secureControlSocket: async (path7) => {
|
|
76906
|
+
await chmod(path7, 384);
|
|
76907
|
+
},
|
|
76908
|
+
removeControlSocket,
|
|
76909
|
+
validatePathPermissions: async (path7, directory, privateAccess, signal) => {
|
|
76910
|
+
signal.throwIfAborted();
|
|
76911
|
+
const metadata = await lstat2(path7);
|
|
76912
|
+
if (process.getuid === void 0 || metadata.uid !== process.getuid()) {
|
|
76913
|
+
throw new LocalPathError("Path is not user-owned");
|
|
76914
|
+
}
|
|
76915
|
+
if (privateAccess) {
|
|
76916
|
+
await chmod(path7, directory ? 448 : 384);
|
|
76917
|
+
}
|
|
76918
|
+
signal.throwIfAborted();
|
|
76919
|
+
}
|
|
76920
|
+
};
|
|
76921
|
+
|
|
76922
|
+
// src/util/platform/linux.ts
|
|
76923
|
+
var linuxPlatform = {
|
|
76924
|
+
...posixOperations2,
|
|
76925
|
+
claudeCodeExecutablePaths: (environment) => {
|
|
76926
|
+
const homeDirectory = environment["HOME"];
|
|
76927
|
+
return homeDirectory !== void 0 && isAbsolute8(homeDirectory) ? [join13(homeDirectory, ".local", "bin", "claude")] : [];
|
|
76928
|
+
}
|
|
76929
|
+
};
|
|
76930
|
+
|
|
76931
|
+
// src/util/platform/macos.ts
|
|
76932
|
+
import { isAbsolute as isAbsolute9, join as join15 } from "node:path";
|
|
76933
|
+
|
|
76934
|
+
// src/util/platform/claude-desktop.ts
|
|
76935
|
+
import { readdirSync as readdirSync3 } from "node:fs";
|
|
76936
|
+
import { join as join14 } from "node:path";
|
|
76937
|
+
function installedDirectories(directory) {
|
|
76938
|
+
try {
|
|
76939
|
+
return readdirSync3(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
76940
|
+
} catch (cause) {
|
|
76941
|
+
if (cause instanceof Error && "code" in cause && (cause.code === "ENOENT" || cause.code === "ENOTDIR" || cause.code === "EACCES")) {
|
|
76942
|
+
return [];
|
|
76943
|
+
}
|
|
76944
|
+
throw cause;
|
|
76945
|
+
}
|
|
76946
|
+
}
|
|
76947
|
+
function claudeDesktopExecutablePaths(roots, executablePaths) {
|
|
76948
|
+
const paths = [];
|
|
76949
|
+
for (const root of roots) {
|
|
76950
|
+
const versions = installedDirectories(root).filter((version2) => /^\d+\.\d+\.\d+$/.test(version2)).toSorted((left, right) => right.localeCompare(left, "en", { numeric: true }));
|
|
76951
|
+
for (const version2 of versions) {
|
|
76952
|
+
const directory = join14(root, version2);
|
|
76953
|
+
const installations = [
|
|
76954
|
+
directory,
|
|
76955
|
+
...installedDirectories(directory).map((build) => join14(directory, build))
|
|
76956
|
+
];
|
|
76957
|
+
for (const installation of installations) {
|
|
76958
|
+
for (const executablePath of executablePaths) {
|
|
76959
|
+
paths.push(join14(installation, ...executablePath));
|
|
76960
|
+
}
|
|
76961
|
+
}
|
|
76962
|
+
}
|
|
76963
|
+
}
|
|
76964
|
+
return paths;
|
|
76965
|
+
}
|
|
76966
|
+
|
|
76967
|
+
// src/util/platform/macos.ts
|
|
76968
|
+
var macosPlatform = {
|
|
76969
|
+
...posixOperations2,
|
|
76970
|
+
claudeCodeExecutablePaths: (environment) => {
|
|
76971
|
+
const paths = ["/opt/homebrew/bin/claude", "/usr/local/bin/claude"];
|
|
76972
|
+
const homeDirectory = environment["HOME"];
|
|
76973
|
+
if (homeDirectory !== void 0 && isAbsolute9(homeDirectory)) {
|
|
76974
|
+
paths.unshift(join15(homeDirectory, ".local", "bin", "claude"));
|
|
76975
|
+
paths.push(
|
|
76976
|
+
...claudeDesktopExecutablePaths(
|
|
76977
|
+
[join15(homeDirectory, "Library", "Application Support", "Claude", "claude-code")],
|
|
76978
|
+
[["claude.app", "Contents", "MacOS", "claude"], ["claude"]]
|
|
76979
|
+
)
|
|
76980
|
+
);
|
|
76981
|
+
}
|
|
76982
|
+
return paths;
|
|
76983
|
+
}
|
|
76984
|
+
};
|
|
76985
|
+
|
|
76986
|
+
// src/util/platform/windows.ts
|
|
76987
|
+
import { execFile as execFile4 } from "node:child_process";
|
|
76988
|
+
import { isAbsolute as isAbsolute10, join as join16 } from "node:path";
|
|
76989
|
+
import { promisify as promisify2 } from "node:util";
|
|
76990
|
+
var execute = promisify2(execFile4);
|
|
76991
|
+
function environmentValue2(environment, name2) {
|
|
76992
|
+
return Object.entries(environment).find(([key]) => key.toUpperCase() === name2.toUpperCase())?.[1];
|
|
76993
|
+
}
|
|
76994
|
+
function desktopClaudeExecutablePaths(environment) {
|
|
76995
|
+
const roots = [];
|
|
76996
|
+
const localAppData = environmentValue2(environment, "LOCALAPPDATA");
|
|
76997
|
+
if (localAppData !== void 0 && isAbsolute10(localAppData)) {
|
|
76998
|
+
const dataDirectory = join16(localAppData, "Claude-Data");
|
|
76999
|
+
for (const installation of installedDirectories(dataDirectory)) {
|
|
77000
|
+
if (installation.startsWith("claude_")) {
|
|
77001
|
+
roots.push(join16(dataDirectory, installation, "claude-code"));
|
|
77002
|
+
}
|
|
77003
|
+
}
|
|
77004
|
+
}
|
|
77005
|
+
const appData = environmentValue2(environment, "APPDATA");
|
|
77006
|
+
if (appData !== void 0 && isAbsolute10(appData)) {
|
|
77007
|
+
roots.push(join16(appData, "Claude", "claude-code"));
|
|
77008
|
+
}
|
|
77009
|
+
return claudeDesktopExecutablePaths(roots, [["claude.exe"]]);
|
|
77010
|
+
}
|
|
77011
|
+
var windowsPermissions = `
|
|
77012
|
+
$ErrorActionPreference = 'Stop'
|
|
77013
|
+
$ProgressPreference = 'SilentlyContinue'
|
|
77014
|
+
$item = Get-Item -LiteralPath $env:MOBIUS_PERMISSION_PATH -Force
|
|
77015
|
+
if (($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0) { throw 'Unsafe path' }
|
|
77016
|
+
$sid = [Security.Principal.WindowsIdentity]::GetCurrent().User
|
|
77017
|
+
$acl = $item.GetAccessControl()
|
|
77018
|
+
$owner = $acl.GetOwner([Security.Principal.SecurityIdentifier])
|
|
77019
|
+
if ($owner -ne $sid -and -not ($owner.Value -eq 'S-1-5-32-544' -and ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))) { throw 'Path is not user-owned' }
|
|
77020
|
+
if ($env:MOBIUS_PERMISSION_PRIVATE -eq '1') {
|
|
77021
|
+
if ($item.PSIsContainer) {
|
|
77022
|
+
$private = New-Object Security.AccessControl.DirectorySecurity
|
|
77023
|
+
$rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'ContainerInherit,ObjectInherit', 'None', 'Allow')
|
|
77024
|
+
} else {
|
|
77025
|
+
$private = New-Object Security.AccessControl.FileSecurity
|
|
77026
|
+
$rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'Allow')
|
|
77027
|
+
}
|
|
77028
|
+
$private.SetOwner($sid)
|
|
77029
|
+
$private.SetAccessRuleProtection($true, $false)
|
|
77030
|
+
$private.AddAccessRule($rule)
|
|
77031
|
+
$item.SetAccessControl($private)
|
|
77032
|
+
}
|
|
77033
|
+
`;
|
|
77034
|
+
var windowsPermissionsTimeoutMs = 3e4;
|
|
77035
|
+
async function validatePathPermissions(path7, _directory, privateAccess, signal) {
|
|
77036
|
+
signal.throwIfAborted();
|
|
77037
|
+
const systemRoot = environmentValue2(process.env, "SystemRoot");
|
|
77038
|
+
if (systemRoot === void 0) {
|
|
77039
|
+
throw new LocalPathError("Windows system directory is unavailable");
|
|
77040
|
+
}
|
|
77041
|
+
try {
|
|
77042
|
+
await execute(
|
|
77043
|
+
join16(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
77044
|
+
[
|
|
77045
|
+
"-NoLogo",
|
|
77046
|
+
"-NoProfile",
|
|
77047
|
+
"-NonInteractive",
|
|
77048
|
+
"-EncodedCommand",
|
|
77049
|
+
Buffer.from(windowsPermissions, "utf16le").toString("base64")
|
|
77050
|
+
],
|
|
77051
|
+
{
|
|
77052
|
+
env: {
|
|
77053
|
+
...process.env,
|
|
77054
|
+
MOBIUS_PERMISSION_PATH: path7,
|
|
77055
|
+
MOBIUS_PERMISSION_PRIVATE: privateAccess ? "1" : "0"
|
|
77056
|
+
},
|
|
77057
|
+
windowsHide: true,
|
|
77058
|
+
signal: AbortSignal.any([signal, AbortSignal.timeout(windowsPermissionsTimeoutMs)]),
|
|
77059
|
+
timeout: windowsPermissionsTimeoutMs,
|
|
77060
|
+
maxBuffer: 16384
|
|
77061
|
+
}
|
|
77062
|
+
);
|
|
77063
|
+
} catch (cause) {
|
|
77064
|
+
signal.throwIfAborted();
|
|
77065
|
+
throw new LocalPathError("The local path permissions could not be secured", { cause });
|
|
77066
|
+
}
|
|
77067
|
+
}
|
|
77068
|
+
var windowsPlatform = {
|
|
77069
|
+
controlSocketPath: (installationHash) => `\\\\.\\pipe\\mobius-${installationHash}`,
|
|
77070
|
+
prepareControlSocket: async () => {
|
|
77071
|
+
},
|
|
77072
|
+
secureControlSocket: async () => {
|
|
77073
|
+
},
|
|
77074
|
+
removeControlSocket: async () => {
|
|
77075
|
+
},
|
|
77076
|
+
validatePathPermissions,
|
|
77077
|
+
claudeCodeExecutablePaths: (environment) => {
|
|
77078
|
+
const paths = [];
|
|
77079
|
+
const userProfile = environmentValue2(environment, "USERPROFILE");
|
|
77080
|
+
if (userProfile !== void 0 && isAbsolute10(userProfile)) {
|
|
77081
|
+
paths.push(join16(userProfile, ".local", "bin", "claude.exe"));
|
|
77082
|
+
}
|
|
77083
|
+
const localAppData = environmentValue2(environment, "LOCALAPPDATA");
|
|
77084
|
+
if (localAppData !== void 0 && isAbsolute10(localAppData)) {
|
|
77085
|
+
paths.push(join16(localAppData, "Microsoft", "WinGet", "Links", "claude.exe"));
|
|
77086
|
+
}
|
|
77087
|
+
paths.push(...desktopClaudeExecutablePaths(environment));
|
|
77088
|
+
return paths;
|
|
77089
|
+
}
|
|
77090
|
+
};
|
|
77091
|
+
|
|
77092
|
+
// src/util/platform/index.ts
|
|
77093
|
+
var fallbackPlatform2 = {
|
|
77094
|
+
...posixOperations2,
|
|
77095
|
+
claudeCodeExecutablePaths: () => []
|
|
77096
|
+
};
|
|
77097
|
+
var platforms2 = /* @__PURE__ */ new Map([
|
|
77098
|
+
["linux", linuxPlatform],
|
|
77099
|
+
["darwin", macosPlatform],
|
|
77100
|
+
["win32", windowsPlatform]
|
|
77101
|
+
]);
|
|
77102
|
+
function platformSupportFor(platform2) {
|
|
77103
|
+
return platforms2.get(platform2) ?? fallbackPlatform2;
|
|
77104
|
+
}
|
|
77105
|
+
|
|
76887
77106
|
// src/agent/discovery/version-output.ts
|
|
76888
77107
|
function normalizeVersionOutput(output2) {
|
|
76889
77108
|
return output2.trim().split(/\r?\n/, 1)[0]?.trim().slice(0, 128) ?? "";
|
|
@@ -77981,7 +78200,7 @@ var CodexAgentSpecification = class extends InProcessAcpAgentSpecification {
|
|
|
77981
78200
|
|
|
77982
78201
|
// src/agent/specification/vendors/pi-agent.ts
|
|
77983
78202
|
import { createHash as createHash4 } from "node:crypto";
|
|
77984
|
-
import { join as
|
|
78203
|
+
import { join as join22 } from "node:path";
|
|
77985
78204
|
import {
|
|
77986
78205
|
methods as methods11
|
|
77987
78206
|
} from "@agentclientprotocol/sdk";
|
|
@@ -77996,7 +78215,7 @@ import {
|
|
|
77996
78215
|
import { spawnSync } from "node:child_process";
|
|
77997
78216
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
77998
78217
|
import { existsSync as existsSync7, readdirSync as readdirSync6, readFileSync as readFileSync8, realpathSync as realpathSync4, statSync as statSync4, unlinkSync as unlinkSync2 } from "node:fs";
|
|
77999
|
-
import { basename as basename5, dirname as dirname8, isAbsolute as isAbsolute13, join as
|
|
78218
|
+
import { basename as basename5, dirname as dirname8, isAbsolute as isAbsolute13, join as join21 } from "node:path";
|
|
78000
78219
|
import { RequestError as RequestError10 } from "@agentclientprotocol/sdk";
|
|
78001
78220
|
|
|
78002
78221
|
// src/acp/harness/pi/upstream/dist/pi-rpc/process.js
|
|
@@ -78454,7 +78673,7 @@ function maybeAuthRequiredError(err) {
|
|
|
78454
78673
|
}
|
|
78455
78674
|
|
|
78456
78675
|
// src/acp/harness/pi/upstream/dist/acp/paths.js
|
|
78457
|
-
import { join as
|
|
78676
|
+
import { join as join17 } from "node:path";
|
|
78458
78677
|
|
|
78459
78678
|
// src/acp/harness/pi/upstream/dist/acp/environment.js
|
|
78460
78679
|
import { homedir as homedir2 } from "node:os";
|
|
@@ -78464,10 +78683,10 @@ function environmentHome(environment) {
|
|
|
78464
78683
|
|
|
78465
78684
|
// src/acp/harness/pi/upstream/dist/acp/paths.js
|
|
78466
78685
|
function getPiAcpDir(environment = process.env) {
|
|
78467
|
-
return
|
|
78686
|
+
return join17(environmentHome(environment), ".pi", "pi-acp");
|
|
78468
78687
|
}
|
|
78469
78688
|
function getPiAcpSessionMapPath(environment = process.env) {
|
|
78470
|
-
return
|
|
78689
|
+
return join17(getPiAcpDir(environment), "session-map.json");
|
|
78471
78690
|
}
|
|
78472
78691
|
|
|
78473
78692
|
// src/acp/harness/pi/upstream/dist/acp/pi-commands.js
|
|
@@ -78512,15 +78731,15 @@ function toAvailableCommandsFromPiGetCommands(data, opts) {
|
|
|
78512
78731
|
|
|
78513
78732
|
// src/acp/harness/pi/upstream/dist/acp/pi-sessions.js
|
|
78514
78733
|
import { closeSync as closeSync2, existsSync as existsSync4, openSync as openSync2, readdirSync as readdirSync4, readFileSync as readFileSync3, readSync as readSync2, statSync as statSync3 } from "node:fs";
|
|
78515
|
-
import { isAbsolute as isAbsolute11, join as
|
|
78734
|
+
import { isAbsolute as isAbsolute11, join as join18, resolve as resolve10 } from "node:path";
|
|
78516
78735
|
var DEFAULT_TAIL_BYTES = 256 * 1024;
|
|
78517
78736
|
var DEFAULT_HEAD_BYTES = 64 * 1024;
|
|
78518
78737
|
function getPiAgentDir(environment) {
|
|
78519
78738
|
const configured = environment["PI_CODING_AGENT_DIR"];
|
|
78520
|
-
return configured ? resolve10(configured) :
|
|
78739
|
+
return configured ? resolve10(configured) : join18(environmentHome(environment), ".pi", "agent");
|
|
78521
78740
|
}
|
|
78522
78741
|
function readSessionDirFromSettings(agentDir) {
|
|
78523
|
-
const settingsPath =
|
|
78742
|
+
const settingsPath = join18(agentDir, "settings.json");
|
|
78524
78743
|
try {
|
|
78525
78744
|
if (!existsSync4(settingsPath)) {
|
|
78526
78745
|
return null;
|
|
@@ -78541,7 +78760,7 @@ function readSessionDirFromSettings(agentDir) {
|
|
|
78541
78760
|
}
|
|
78542
78761
|
function getPiSessionsDir(environment = process.env) {
|
|
78543
78762
|
const agentDir = getPiAgentDir(environment);
|
|
78544
|
-
return readSessionDirFromSettings(agentDir) ??
|
|
78763
|
+
return readSessionDirFromSettings(agentDir) ?? join18(agentDir, "sessions");
|
|
78545
78764
|
}
|
|
78546
78765
|
function getPiSessionDiscoveryDirs(environment) {
|
|
78547
78766
|
const discoveryDirectories = [getPiSessionsDir(environment)];
|
|
@@ -78552,7 +78771,7 @@ function getPiSessionDiscoveryDirs(environment) {
|
|
|
78552
78771
|
if (!entry.isDirectory()) {
|
|
78553
78772
|
continue;
|
|
78554
78773
|
}
|
|
78555
|
-
const directory =
|
|
78774
|
+
const directory = join18(mobiusSessionsRoot, entry.name);
|
|
78556
78775
|
if (!discoveryDirectories.includes(directory)) {
|
|
78557
78776
|
discoveryDirectories.push(directory);
|
|
78558
78777
|
}
|
|
@@ -78569,7 +78788,7 @@ function walkJsonlFiles(dir, out2) {
|
|
|
78569
78788
|
}
|
|
78570
78789
|
for (const e of entries) {
|
|
78571
78790
|
const name2 = typeof e.name === "string" ? e.name : String(e.name);
|
|
78572
|
-
const p =
|
|
78791
|
+
const p = join18(dir, name2);
|
|
78573
78792
|
if (e.isDirectory()) {
|
|
78574
78793
|
walkJsonlFiles(p, out2);
|
|
78575
78794
|
} else if (e.isFile() && name2.endsWith(".jsonl")) {
|
|
@@ -78838,7 +79057,7 @@ function findPiSession(sessionId, environment = process.env) {
|
|
|
78838
79057
|
|
|
78839
79058
|
// src/acp/harness/pi/upstream/dist/acp/pi-settings.js
|
|
78840
79059
|
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:fs";
|
|
78841
|
-
import { join as
|
|
79060
|
+
import { join as join19, resolve as resolve11 } from "node:path";
|
|
78842
79061
|
function isObject2(x) {
|
|
78843
79062
|
return Boolean(x) && typeof x === "object" && !Array.isArray(x);
|
|
78844
79063
|
}
|
|
@@ -78867,7 +79086,7 @@ function readJsonFile(path7) {
|
|
|
78867
79086
|
}
|
|
78868
79087
|
}
|
|
78869
79088
|
function getMergedSettings(cwd, environment) {
|
|
78870
|
-
const globalSettingsPath =
|
|
79089
|
+
const globalSettingsPath = join19(getAgentDir(environment), "settings.json");
|
|
78871
79090
|
const projectSettingsPath = resolve11(cwd, ".pi", "settings.json");
|
|
78872
79091
|
const global2 = readJsonFile(globalSettingsPath);
|
|
78873
79092
|
const project = readJsonFile(projectSettingsPath);
|
|
@@ -78875,7 +79094,7 @@ function getMergedSettings(cwd, environment) {
|
|
|
78875
79094
|
}
|
|
78876
79095
|
function getAgentDir(environment = process.env) {
|
|
78877
79096
|
const configured = environment["PI_CODING_AGENT_DIR"];
|
|
78878
|
-
return configured ? resolve11(configured) :
|
|
79097
|
+
return configured ? resolve11(configured) : join19(environmentHome(environment), ".pi", "agent");
|
|
78879
79098
|
}
|
|
78880
79099
|
function getEnableSkillCommands(cwd, environment = process.env) {
|
|
78881
79100
|
const merged = getMergedSettings(cwd, environment);
|
|
@@ -79131,7 +79350,7 @@ var SessionStore = class {
|
|
|
79131
79350
|
|
|
79132
79351
|
// src/acp/harness/pi/upstream/dist/acp/slash-commands.js
|
|
79133
79352
|
import { existsSync as existsSync6, readdirSync as readdirSync5, readFileSync as readFileSync6 } from "node:fs";
|
|
79134
|
-
import { join as
|
|
79353
|
+
import { join as join20, resolve as resolve12 } from "node:path";
|
|
79135
79354
|
function parseFrontmatter(content) {
|
|
79136
79355
|
const frontmatter = {};
|
|
79137
79356
|
if (!content.startsWith("---")) {
|
|
@@ -79159,7 +79378,7 @@ function loadCommandsFromDir(dir, source, subdir = "") {
|
|
|
79159
79378
|
try {
|
|
79160
79379
|
const entries = readdirSync5(dir, { withFileTypes: true });
|
|
79161
79380
|
for (const entry of entries) {
|
|
79162
|
-
const fullPath =
|
|
79381
|
+
const fullPath = join20(dir, entry.name);
|
|
79163
79382
|
if (entry.isDirectory()) {
|
|
79164
79383
|
const newSubdir = subdir ? `${subdir}:${entry.name}` : entry.name;
|
|
79165
79384
|
commands.push(...loadCommandsFromDir(fullPath, source, newSubdir));
|
|
@@ -79199,7 +79418,7 @@ function loadCommandsFromDir(dir, source, subdir = "") {
|
|
|
79199
79418
|
}
|
|
79200
79419
|
function loadSlashCommands(cwd, environment = process.env) {
|
|
79201
79420
|
const commands = [];
|
|
79202
|
-
const userDir =
|
|
79421
|
+
const userDir = join20(environmentHome(environment), ".pi", "agent", "prompts");
|
|
79203
79422
|
const projectDir = resolve12(cwd, ".pi", "prompts");
|
|
79204
79423
|
commands.push(...loadCommandsFromDir(userDir, "user"));
|
|
79205
79424
|
commands.push(...loadCommandsFromDir(projectDir, "project"));
|
|
@@ -80846,7 +81065,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
80846
81065
|
if (piPath) {
|
|
80847
81066
|
const resolved = realpathSync4(piPath);
|
|
80848
81067
|
const pkgRoot = dirname8(dirname8(resolved));
|
|
80849
|
-
const p =
|
|
81068
|
+
const p = join21(pkgRoot, "CHANGELOG.md");
|
|
80850
81069
|
if (existsSync7(p)) {
|
|
80851
81070
|
return p;
|
|
80852
81071
|
}
|
|
@@ -80857,7 +81076,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
80857
81076
|
const npmRoot = spawnSync("npm", ["root", "-g"], { encoding: "utf-8" });
|
|
80858
81077
|
const root = String(npmRoot.stdout ?? "").trim();
|
|
80859
81078
|
if (root) {
|
|
80860
|
-
const p =
|
|
81079
|
+
const p = join21(root, "@earendil-works", "pi-coding-agent", "CHANGELOG.md");
|
|
80861
81080
|
if (existsSync7(p)) {
|
|
80862
81081
|
return p;
|
|
80863
81082
|
}
|
|
@@ -80951,7 +81170,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
80951
81170
|
return { stopReason: "end_turn" };
|
|
80952
81171
|
}
|
|
80953
81172
|
const safeSessionId = session.sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
80954
|
-
const outputPath =
|
|
81173
|
+
const outputPath = join21(session.cwd, `pi-session-${safeSessionId}.html`);
|
|
80955
81174
|
let resultPath = "";
|
|
80956
81175
|
try {
|
|
80957
81176
|
const result2 = await session.proc.exportHtml(outputPath);
|
|
@@ -81665,7 +81884,7 @@ function buildStartupInfo(opts) {
|
|
|
81665
81884
|
md.push("");
|
|
81666
81885
|
};
|
|
81667
81886
|
const contextItems = [];
|
|
81668
|
-
const contextPath =
|
|
81887
|
+
const contextPath = join21(opts.cwd, "AGENTS.md");
|
|
81669
81888
|
if (existsSync7(contextPath)) {
|
|
81670
81889
|
contextItems.push(contextPath);
|
|
81671
81890
|
}
|
|
@@ -81674,7 +81893,7 @@ function buildStartupInfo(opts) {
|
|
|
81674
81893
|
const pushSkillFromRoot = (root) => {
|
|
81675
81894
|
try {
|
|
81676
81895
|
for (const e of readdirSync6(root)) {
|
|
81677
|
-
const p =
|
|
81896
|
+
const p = join21(root, e);
|
|
81678
81897
|
try {
|
|
81679
81898
|
const st2 = statSync4(p);
|
|
81680
81899
|
if (st2.isFile() && e.toLowerCase().endsWith(".md")) {
|
|
@@ -81699,7 +81918,7 @@ function buildStartupInfo(opts) {
|
|
|
81699
81918
|
if (name2 === "node_modules" || name2 === ".git") {
|
|
81700
81919
|
continue;
|
|
81701
81920
|
}
|
|
81702
|
-
const p =
|
|
81921
|
+
const p = join21(dir, name2);
|
|
81703
81922
|
let st2;
|
|
81704
81923
|
try {
|
|
81705
81924
|
st2 = statSync4(p);
|
|
@@ -81716,16 +81935,16 @@ function buildStartupInfo(opts) {
|
|
|
81716
81935
|
} catch {
|
|
81717
81936
|
}
|
|
81718
81937
|
};
|
|
81719
|
-
const globalSkillsDir =
|
|
81938
|
+
const globalSkillsDir = join21(getAgentDir(opts.environment), "skills");
|
|
81720
81939
|
pushSkillFromRoot(globalSkillsDir);
|
|
81721
81940
|
const home = opts.environment["HOME"] ?? opts.environment["USERPROFILE"] ?? "";
|
|
81722
|
-
const legacyAgentsSkillsDir =
|
|
81941
|
+
const legacyAgentsSkillsDir = join21(home, ".agents", "skills");
|
|
81723
81942
|
pushSkillFromRoot(legacyAgentsSkillsDir);
|
|
81724
|
-
const projectSkillsDir =
|
|
81943
|
+
const projectSkillsDir = join21(opts.cwd, ".pi", "skills");
|
|
81725
81944
|
pushSkillFromRoot(projectSkillsDir);
|
|
81726
81945
|
addSection("Skills", skillsItems);
|
|
81727
81946
|
const promptsItems = [];
|
|
81728
|
-
const promptsDir =
|
|
81947
|
+
const promptsDir = join21(home, ".pi", "agent", "prompts");
|
|
81729
81948
|
try {
|
|
81730
81949
|
const prompts = readdirSync6(promptsDir).filter((f) => f.endsWith(".md"));
|
|
81731
81950
|
for (const f of prompts) {
|
|
@@ -81735,17 +81954,17 @@ function buildStartupInfo(opts) {
|
|
|
81735
81954
|
}
|
|
81736
81955
|
addSection("Prompts", promptsItems);
|
|
81737
81956
|
const extItems = [];
|
|
81738
|
-
const extDir =
|
|
81957
|
+
const extDir = join21(home, ".pi", "agent", "extensions");
|
|
81739
81958
|
try {
|
|
81740
81959
|
const exts = readdirSync6(extDir).filter((f) => f.endsWith(".ts") || f.endsWith(".js"));
|
|
81741
81960
|
for (const f of exts) {
|
|
81742
|
-
extItems.push(
|
|
81961
|
+
extItems.push(join21(extDir, f));
|
|
81743
81962
|
}
|
|
81744
81963
|
} catch {
|
|
81745
81964
|
}
|
|
81746
81965
|
const settingsPaths = [
|
|
81747
|
-
|
|
81748
|
-
|
|
81966
|
+
join21(getAgentDir(opts.environment), "settings.json"),
|
|
81967
|
+
join21(opts.cwd, ".pi", "settings.json")
|
|
81749
81968
|
];
|
|
81750
81969
|
for (const settingsPath of settingsPaths) {
|
|
81751
81970
|
try {
|
|
@@ -81943,7 +82162,7 @@ var PiAgentSpecification = class extends InProcessAcpAgentSpecification {
|
|
|
81943
82162
|
// keeps the adapter's opt-in capability flag enabled for every launch it owns.
|
|
81944
82163
|
createLaunchEnvironment = async (_agent, context) => {
|
|
81945
82164
|
const workspaceHash = createHash4("sha256").update(context.defaultWorkspace).digest("hex").slice(0, 24);
|
|
81946
|
-
const sessionDirectory =
|
|
82165
|
+
const sessionDirectory = join22(context.dataDirectory, "agents", "pi", "sessions", workspaceHash);
|
|
81947
82166
|
return Object.freeze({
|
|
81948
82167
|
PI_ACP_ENABLE_EMBEDDED_CONTEXT: "true",
|
|
81949
82168
|
MOBIUS_PI_SESSION_DIR: sessionDirectory
|
|
@@ -82594,7 +82813,7 @@ var AgentCatalogPublishError = class extends Error {
|
|
|
82594
82813
|
this.name = "AgentCatalogPublishError";
|
|
82595
82814
|
}
|
|
82596
82815
|
};
|
|
82597
|
-
function
|
|
82816
|
+
function isRecord8(value) {
|
|
82598
82817
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
82599
82818
|
}
|
|
82600
82819
|
function isSafeRelayErrorMessage(value) {
|
|
@@ -82607,7 +82826,7 @@ async function rejectedCatalogError(response) {
|
|
|
82607
82826
|
} catch {
|
|
82608
82827
|
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
82609
82828
|
}
|
|
82610
|
-
if (!
|
|
82829
|
+
if (!isRecord8(value) || !isRecord8(value["error"])) {
|
|
82611
82830
|
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
82612
82831
|
}
|
|
82613
82832
|
const code = value["error"]["code"];
|
|
@@ -82676,7 +82895,7 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
82676
82895
|
}
|
|
82677
82896
|
|
|
82678
82897
|
// src/runtime/config.ts
|
|
82679
|
-
import { join as
|
|
82898
|
+
import { join as join24, resolve as resolve14 } from "node:path";
|
|
82680
82899
|
|
|
82681
82900
|
// src/util/serial-task-queue.ts
|
|
82682
82901
|
var SerialTaskQueue = class {
|
|
@@ -82749,19 +82968,19 @@ var LocalAgentCatalog = class {
|
|
|
82749
82968
|
|
|
82750
82969
|
// src/storage/state-directory.ts
|
|
82751
82970
|
import { homedir as homedir3 } from "node:os";
|
|
82752
|
-
import { join as
|
|
82971
|
+
import { join as join23, resolve as resolve13 } from "node:path";
|
|
82753
82972
|
var stateRootSchema = external_exports.string().brand();
|
|
82754
82973
|
function readStateDirectory(environment = process.env) {
|
|
82755
82974
|
const configured = environment["MOBIUS_STATE_DIRECTORY"]?.trim();
|
|
82756
82975
|
return stateRootSchema.parse(
|
|
82757
|
-
configured !== void 0 && configured.length > 0 ? resolve13(configured) :
|
|
82976
|
+
configured !== void 0 && configured.length > 0 ? resolve13(configured) : join23(homedir3(), ".mobius")
|
|
82758
82977
|
);
|
|
82759
82978
|
}
|
|
82760
82979
|
|
|
82761
82980
|
// src/runtime/config.ts
|
|
82762
82981
|
function loadDefaultWorkspace(dataDirectory, environment = process.env) {
|
|
82763
82982
|
const { MOBIUS_DEFAULT_WORKSPACE: configuredWorkspace } = environment;
|
|
82764
|
-
return configuredWorkspace ??
|
|
82983
|
+
return configuredWorkspace ?? join24(dataDirectory, "workspace");
|
|
82765
82984
|
}
|
|
82766
82985
|
var RuntimeLocalContext = class {
|
|
82767
82986
|
environment;
|
|
@@ -82870,7 +83089,7 @@ import { resolve as resolve15 } from "node:path";
|
|
|
82870
83089
|
// src/storage/installation/installation-files.ts
|
|
82871
83090
|
import { createHash as createHash5, randomUUID as randomUUID12 } from "node:crypto";
|
|
82872
83091
|
import { mkdir as mkdir4, open as open5, readdir as readdir5, rename as rename3, unlink as unlink3, writeFile } from "node:fs/promises";
|
|
82873
|
-
import { dirname as dirname9, join as
|
|
83092
|
+
import { dirname as dirname9, join as join25 } from "node:path";
|
|
82874
83093
|
|
|
82875
83094
|
// src/util/node-error.ts
|
|
82876
83095
|
function isNodeError(error62, code) {
|
|
@@ -82893,23 +83112,23 @@ var STATE_ROOT_ENTRY_NAMES = new Set(Object.values(STATE_ROOT_LAYOUT));
|
|
|
82893
83112
|
// src/storage/installation/installation-files.ts
|
|
82894
83113
|
var MAXIMUM_FILE_BYTES = 16 * 1024;
|
|
82895
83114
|
function applicationDirectory(root, applicationId) {
|
|
82896
|
-
return
|
|
83115
|
+
return join25(root, STATE_ROOT_LAYOUT.installations, applicationId);
|
|
82897
83116
|
}
|
|
82898
83117
|
function installationPointerPath(applicationDirectory2) {
|
|
82899
|
-
return
|
|
83118
|
+
return join25(applicationDirectory2, "current.json");
|
|
82900
83119
|
}
|
|
82901
83120
|
var installationDirectorySchema = external_exports.string().brand();
|
|
82902
83121
|
function installationDirectory(applicationDirectory2, installationId2) {
|
|
82903
|
-
return installationDirectorySchema.parse(
|
|
83122
|
+
return installationDirectorySchema.parse(join25(applicationDirectory2, installationId2));
|
|
82904
83123
|
}
|
|
82905
83124
|
function connectionDirectory(installationDirectory2) {
|
|
82906
|
-
return
|
|
83125
|
+
return join25(installationDirectory2, "connections");
|
|
82907
83126
|
}
|
|
82908
83127
|
function connectionFilePath(connectionDirectory2, connectionId2) {
|
|
82909
|
-
return
|
|
83128
|
+
return join25(connectionDirectory2, `${connectionId2}.json`);
|
|
82910
83129
|
}
|
|
82911
83130
|
function channelIndexFilePath(installationDirectory2, channelId) {
|
|
82912
|
-
return
|
|
83131
|
+
return join25(installationDirectory2, "channels", `mci_${createHash5("sha256").update(channelId).digest("hex")}.json`);
|
|
82913
83132
|
}
|
|
82914
83133
|
async function readInstallationFile(path7) {
|
|
82915
83134
|
let handle;
|
|
@@ -82931,7 +83150,7 @@ async function readInstallationFile(path7) {
|
|
|
82931
83150
|
async function writeInstallationFile(path7, text2, signal) {
|
|
82932
83151
|
signal.throwIfAborted();
|
|
82933
83152
|
const directory = dirname9(path7);
|
|
82934
|
-
const temporaryPath =
|
|
83153
|
+
const temporaryPath = join25(directory, `.${randomUUID12()}.tmp`);
|
|
82935
83154
|
try {
|
|
82936
83155
|
await mkdir4(directory, { mode: 448, recursive: true });
|
|
82937
83156
|
signal.throwIfAborted();
|
|
@@ -83029,7 +83248,7 @@ var RuntimeInstallationStoreError = class extends Error {
|
|
|
83029
83248
|
this.name = "RuntimeInstallationStoreError";
|
|
83030
83249
|
}
|
|
83031
83250
|
};
|
|
83032
|
-
function
|
|
83251
|
+
function isRecord9(value) {
|
|
83033
83252
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
83034
83253
|
}
|
|
83035
83254
|
function hasExactKeys(value, expectedKeys) {
|
|
@@ -83096,7 +83315,7 @@ function installationId() {
|
|
|
83096
83315
|
return `min_${randomUUID13().replaceAll("-", "")}`;
|
|
83097
83316
|
}
|
|
83098
83317
|
function decodeInstallationPointer(value) {
|
|
83099
|
-
if (!
|
|
83318
|
+
if (!isRecord9(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {
|
|
83100
83319
|
throw new RuntimeInstallationStoreError("invalid_installation", "The local installation record is invalid");
|
|
83101
83320
|
}
|
|
83102
83321
|
const storedInstallationId = value["installationId"];
|
|
@@ -83106,7 +83325,7 @@ function decodeInstallationPointer(value) {
|
|
|
83106
83325
|
return { installationId: validateInstallationId(storedInstallationId) };
|
|
83107
83326
|
}
|
|
83108
83327
|
function decodeChannelIndex(value) {
|
|
83109
|
-
if (!
|
|
83328
|
+
if (!isRecord9(value) || !hasExactKeys(value, CHANNEL_INDEX_KEYS) || value["version"] !== 1) {
|
|
83110
83329
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
83111
83330
|
}
|
|
83112
83331
|
const applicationId = value["applicationId"];
|
|
@@ -83156,7 +83375,7 @@ function decodeVerifiedConnection(value) {
|
|
|
83156
83375
|
);
|
|
83157
83376
|
}
|
|
83158
83377
|
function decodeConnection(value) {
|
|
83159
|
-
if (!
|
|
83378
|
+
if (!isRecord9(value)) {
|
|
83160
83379
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
83161
83380
|
}
|
|
83162
83381
|
return decodeVerifiedConnection(value);
|
|
@@ -83769,7 +83988,10 @@ function legacyState(receipt) {
|
|
|
83769
83988
|
if (receipt.outcome === null) {
|
|
83770
83989
|
return receipt.started ? "running" : "dispatching";
|
|
83771
83990
|
}
|
|
83772
|
-
const event =
|
|
83991
|
+
const event = decodeKnownSessionEventPayload(JSON.parse(receipt.outcome));
|
|
83992
|
+
if (event === null) {
|
|
83993
|
+
return "failed";
|
|
83994
|
+
}
|
|
83773
83995
|
return event.type === "lifecycle-metadata" && event.payload.kind === "prompt.completed" ? event.payload.stopReason === "cancelled" ? "cancelled" : "succeeded" : "failed";
|
|
83774
83996
|
}
|
|
83775
83997
|
var ExecutionReceiptTable = class {
|
|
@@ -84578,7 +84800,11 @@ var storedSessionConfigurationsSchema = external_exports.array(
|
|
|
84578
84800
|
external_exports.object({ configId: external_exports.string().max(128), type: external_exports.literal("select"), value: external_exports.string().max(500) })
|
|
84579
84801
|
])
|
|
84580
84802
|
).max(100);
|
|
84581
|
-
var decodeStoredSessionConfigurations = (value) => storedSessionConfigurationsSchema.parse(
|
|
84803
|
+
var decodeStoredSessionConfigurations = (value) => storedSessionConfigurationsSchema.parse(
|
|
84804
|
+
Array.isArray(value) ? value.filter(
|
|
84805
|
+
(configuration) => typeof configuration !== "object" || configuration === null || !("type" in configuration) || typeof configuration.type !== "string" || configuration.type === "boolean" || configuration.type === "select"
|
|
84806
|
+
) : value
|
|
84807
|
+
);
|
|
84582
84808
|
var SessionConfigurations = class {
|
|
84583
84809
|
#selected = [];
|
|
84584
84810
|
stored = () => this.#selected;
|
|
@@ -87092,7 +87318,7 @@ var ExecutionReceipts = class {
|
|
|
87092
87318
|
};
|
|
87093
87319
|
outcome = (commandId) => {
|
|
87094
87320
|
const receipt = this.#executions.get(commandId);
|
|
87095
|
-
return receipt?.outcome === null || receipt === void 0 ? void 0 :
|
|
87321
|
+
return receipt?.outcome === null || receipt === void 0 ? void 0 : decodeKnownSessionEventPayload(JSON.parse(receipt.outcome)) ?? void 0;
|
|
87096
87322
|
};
|
|
87097
87323
|
/** Reserves an unseen command for cancellation before a delayed prompt can claim its identity. */
|
|
87098
87324
|
recordCancellationBeforeAdmission = (commandId, sessionId) => {
|
|
@@ -87155,7 +87381,10 @@ var ExecutionReceipts = class {
|
|
|
87155
87381
|
code: "runtime_restarted",
|
|
87156
87382
|
message: "The local runtime restarted before this request started"
|
|
87157
87383
|
}
|
|
87158
|
-
} :
|
|
87384
|
+
} : decodeKnownSessionEventPayload(JSON.parse(receipt.outcome));
|
|
87385
|
+
if (event === null) {
|
|
87386
|
+
continue;
|
|
87387
|
+
}
|
|
87159
87388
|
const recordedAt = receipt.outcome === null ? (/* @__PURE__ */ new Date()).toISOString() : external_exports.object({ recordedAt: external_exports.string() }).parse(JSON.parse(receipt.outcome)).recordedAt;
|
|
87160
87389
|
recovered.push({ sessionId: receipt.sessionId, event, recordedAt });
|
|
87161
87390
|
if (receipt.outcome === null) {
|
|
@@ -87577,7 +87806,7 @@ var SessionTurns = class {
|
|
|
87577
87806
|
|
|
87578
87807
|
// src/session/workspace/workspace-directory.ts
|
|
87579
87808
|
import { homedir as homedir4 } from "node:os";
|
|
87580
|
-
import { basename as basename7, dirname as dirname10, isAbsolute as isAbsolute15, join as
|
|
87809
|
+
import { basename as basename7, dirname as dirname10, isAbsolute as isAbsolute15, join as join27, normalize as normalize2, relative as relative2 } from "node:path";
|
|
87581
87810
|
var WorkspaceDirectoryListing = class {
|
|
87582
87811
|
directoryId;
|
|
87583
87812
|
directoryLabel;
|
|
@@ -87699,7 +87928,7 @@ var WorkspaceDirectoryService = class {
|
|
|
87699
87928
|
continue;
|
|
87700
87929
|
}
|
|
87701
87930
|
try {
|
|
87702
|
-
const path7 = await this.resolvePath(
|
|
87931
|
+
const path7 = await this.resolvePath(join27(target, child.name), signal);
|
|
87703
87932
|
entries.push({ directoryId: encodePath(path7), name: child.name });
|
|
87704
87933
|
} catch (cause) {
|
|
87705
87934
|
signal.throwIfAborted();
|
|
@@ -87847,12 +88076,12 @@ function buildSessionLayer(options) {
|
|
|
87847
88076
|
|
|
87848
88077
|
// src/session/content/external-content-store.ts
|
|
87849
88078
|
import { createHash as createHash7 } from "node:crypto";
|
|
87850
|
-
import { join as
|
|
88079
|
+
import { join as join29 } from "node:path";
|
|
87851
88080
|
|
|
87852
88081
|
// src/storage/files/scratch-directory.ts
|
|
87853
88082
|
import { randomUUID as randomUUID17 } from "node:crypto";
|
|
87854
88083
|
import { lstat as lstat4, mkdir as mkdir5, readdir as readdir6, readFile as readFile6, realpath as realpath7, rename as rename4, rm as rm3, stat as stat6, utimes, writeFile as writeFile2 } from "node:fs/promises";
|
|
87855
|
-
import { dirname as dirname11, join as
|
|
88084
|
+
import { dirname as dirname11, join as join28 } from "node:path";
|
|
87856
88085
|
async function atomicWrite(path7, bytes, signal) {
|
|
87857
88086
|
const temporary = `${path7}.${randomUUID17()}.tmp`;
|
|
87858
88087
|
try {
|
|
@@ -87866,7 +88095,7 @@ async function atomicWrite(path7, bytes, signal) {
|
|
|
87866
88095
|
var ScratchDirectory = class {
|
|
87867
88096
|
#root;
|
|
87868
88097
|
constructor(parent) {
|
|
87869
|
-
this.#root =
|
|
88098
|
+
this.#root = join28(parent, randomUUID17());
|
|
87870
88099
|
}
|
|
87871
88100
|
/** Refreshes this directory's lease and removes sibling directories whose lease is older than `leaseMilliseconds`. */
|
|
87872
88101
|
refreshLease = async (leaseMilliseconds) => {
|
|
@@ -87877,7 +88106,7 @@ var ScratchDirectory = class {
|
|
|
87877
88106
|
if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
|
|
87878
88107
|
continue;
|
|
87879
88108
|
}
|
|
87880
|
-
const path7 =
|
|
88109
|
+
const path7 = join28(dirname11(this.#root), directory.name);
|
|
87881
88110
|
if (path7 === this.#root) {
|
|
87882
88111
|
continue;
|
|
87883
88112
|
}
|
|
@@ -87892,10 +88121,10 @@ var ScratchDirectory = class {
|
|
|
87892
88121
|
};
|
|
87893
88122
|
/** Writes `bytes` atomically to `<group>/<name>` with owner-only permissions and returns the path. */
|
|
87894
88123
|
write = async (group, name2, bytes, signal) => {
|
|
87895
|
-
const directory =
|
|
88124
|
+
const directory = join28(this.#root, group);
|
|
87896
88125
|
await mkdir5(directory, { mode: 448, recursive: true });
|
|
87897
88126
|
signal.throwIfAborted();
|
|
87898
|
-
const path7 =
|
|
88127
|
+
const path7 = join28(directory, name2);
|
|
87899
88128
|
await atomicWrite(path7, bytes, signal);
|
|
87900
88129
|
return path7;
|
|
87901
88130
|
};
|
|
@@ -87942,7 +88171,7 @@ var LocalExternalContentStore = class {
|
|
|
87942
88171
|
#expirationTimer;
|
|
87943
88172
|
#cleanup = Promise.resolve();
|
|
87944
88173
|
constructor(stateDirectory) {
|
|
87945
|
-
this.#scratch = new ScratchDirectory(
|
|
88174
|
+
this.#scratch = new ScratchDirectory(join29(stateDirectory, "tmp", "session-content"));
|
|
87946
88175
|
this.#expirationTimer = setInterval(() => {
|
|
87947
88176
|
void this.#expire().catch(() => void 0);
|
|
87948
88177
|
}, 6e4);
|
|
@@ -88325,11 +88554,11 @@ var AgentProcessPool = class {
|
|
|
88325
88554
|
};
|
|
88326
88555
|
|
|
88327
88556
|
// src/runtime/observability/diagnostic-log.ts
|
|
88328
|
-
import { join as
|
|
88557
|
+
import { join as join32 } from "node:path";
|
|
88329
88558
|
|
|
88330
88559
|
// src/storage/logs/bounded-log.ts
|
|
88331
88560
|
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync4, readFileSync as readFileSync9, renameSync as renameSync2, statSync as statSync5, writeFileSync as writeFileSync2 } from "node:fs";
|
|
88332
|
-
import { join as
|
|
88561
|
+
import { join as join30 } from "node:path";
|
|
88333
88562
|
var BoundedLineLog = class {
|
|
88334
88563
|
#path;
|
|
88335
88564
|
#maximumBytes;
|
|
@@ -88338,7 +88567,7 @@ var BoundedLineLog = class {
|
|
|
88338
88567
|
#onWriteFailure;
|
|
88339
88568
|
constructor(directory, filename, maximumBytes, onWriteFailure = () => void 0) {
|
|
88340
88569
|
this.#directory = directory;
|
|
88341
|
-
this.#path =
|
|
88570
|
+
this.#path = join30(directory, filename);
|
|
88342
88571
|
this.#maximumBytes = maximumBytes;
|
|
88343
88572
|
this.#onWriteFailure = onWriteFailure;
|
|
88344
88573
|
}
|
|
@@ -88389,21 +88618,21 @@ var BoundedLineLog = class {
|
|
|
88389
88618
|
|
|
88390
88619
|
// src/storage/logs/log-files.ts
|
|
88391
88620
|
import { readFileSync as readFileSync10 } from "node:fs";
|
|
88392
|
-
import { join as
|
|
88621
|
+
import { join as join31, relative as relative3 } from "node:path";
|
|
88393
88622
|
var DAEMON_LOG_FILENAME = "daemon.log";
|
|
88394
88623
|
var WORKER_LIFECYCLE_LOG_FILENAME = "worker-lifecycle.log";
|
|
88395
88624
|
function unhandledRejectionLogFilename(role) {
|
|
88396
88625
|
return `unhandled-rejections-${role}.log`;
|
|
88397
88626
|
}
|
|
88398
88627
|
function logDirectory(stateDirectory) {
|
|
88399
|
-
return
|
|
88628
|
+
return join31(stateDirectory, "logs");
|
|
88400
88629
|
}
|
|
88401
88630
|
function processLogPaths(stateDirectory) {
|
|
88402
88631
|
return [
|
|
88403
88632
|
WORKER_LIFECYCLE_LOG_FILENAME,
|
|
88404
88633
|
unhandledRejectionLogFilename("manager"),
|
|
88405
88634
|
unhandledRejectionLogFilename("worker")
|
|
88406
|
-
].map((filename) =>
|
|
88635
|
+
].map((filename) => join31(logDirectory(stateDirectory), filename));
|
|
88407
88636
|
}
|
|
88408
88637
|
function readLogText(path7) {
|
|
88409
88638
|
try {
|
|
@@ -88459,7 +88688,7 @@ var RuntimeDiagnosticLog = class {
|
|
|
88459
88688
|
this.#maximumBytes = maximumBytes;
|
|
88460
88689
|
const processLogsDirectory = options.processLogsDirectory;
|
|
88461
88690
|
this.#sources = [
|
|
88462
|
-
{ maximumBytes, path:
|
|
88691
|
+
{ maximumBytes, path: join32(directory, DAEMON_LOG_FILENAME) },
|
|
88463
88692
|
// The process logs a Runtime does not own, but must read to explain its own deaths.
|
|
88464
88693
|
...processLogsDirectory === void 0 ? [] : processLogPaths(processLogsDirectory).map((path7) => ({ maximumBytes: null, path: path7 }))
|
|
88465
88694
|
];
|
|
@@ -89442,7 +89671,7 @@ function createContentWriteCommands(context) {
|
|
|
89442
89671
|
import { WebSocket as WebSocket5 } from "undici";
|
|
89443
89672
|
|
|
89444
89673
|
// src/session/content/session-files.ts
|
|
89445
|
-
import { basename as basename8, extname as extname2, isAbsolute as isAbsolute16, join as
|
|
89674
|
+
import { basename as basename8, extname as extname2, isAbsolute as isAbsolute16, join as join33, normalize as normalize3, resolve as resolve17 } from "node:path";
|
|
89446
89675
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
89447
89676
|
function requestedPath(value) {
|
|
89448
89677
|
if (value.includes("\0")) {
|
|
@@ -89466,7 +89695,7 @@ async function resolveFile(value, workingDirectory, signal) {
|
|
|
89466
89695
|
if (isAbsolute16(requested.path) && normalize3(requested.path) !== requested.path) {
|
|
89467
89696
|
return null;
|
|
89468
89697
|
}
|
|
89469
|
-
const candidates = requested.explicitUrl || workingDirectory === null ? [requested.path] : isAbsolute16(requested.path) ? [
|
|
89698
|
+
const candidates = requested.explicitUrl || workingDirectory === null ? [requested.path] : isAbsolute16(requested.path) ? [join33(workingDirectory, requested.path), requested.path] : [resolve17(workingDirectory, requested.path)];
|
|
89470
89699
|
for (const candidate of candidates) {
|
|
89471
89700
|
if (!isAbsolute16(candidate) || normalize3(candidate) !== candidate) {
|
|
89472
89701
|
continue;
|
|
@@ -91234,35 +91463,6 @@ function closeRelaySocket(socket, code, reason) {
|
|
|
91234
91463
|
}
|
|
91235
91464
|
}
|
|
91236
91465
|
}
|
|
91237
|
-
function readCommandCorrelation(encoded) {
|
|
91238
|
-
let value;
|
|
91239
|
-
try {
|
|
91240
|
-
value = JSON.parse(encoded);
|
|
91241
|
-
} catch {
|
|
91242
|
-
return { requestId: "unsupported", sessionId: "" };
|
|
91243
|
-
}
|
|
91244
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
91245
|
-
return { requestId: "unsupported", sessionId: "" };
|
|
91246
|
-
}
|
|
91247
|
-
const requestId = Reflect.get(value, "requestId");
|
|
91248
|
-
const sessionId = Reflect.get(value, "sessionId");
|
|
91249
|
-
return {
|
|
91250
|
-
requestId: typeof requestId === "string" && isIdentifier(requestId) ? requestId : "unsupported",
|
|
91251
|
-
sessionId: typeof sessionId === "string" && isIdentifier(sessionId) ? sessionId : ""
|
|
91252
|
-
};
|
|
91253
|
-
}
|
|
91254
|
-
function rejectUnsupportedCommand(socket, correlation, rejection) {
|
|
91255
|
-
if (socket.readyState !== WebSocket8.OPEN) {
|
|
91256
|
-
return;
|
|
91257
|
-
}
|
|
91258
|
-
send(socket, {
|
|
91259
|
-
code: rejection.code,
|
|
91260
|
-
kind: SESSION_OPERATION_FAILED_KIND,
|
|
91261
|
-
message: "The Relay sent a command this daemon does not support",
|
|
91262
|
-
requestId: correlation.requestId,
|
|
91263
|
-
sessionId: correlation.sessionId
|
|
91264
|
-
});
|
|
91265
|
-
}
|
|
91266
91466
|
async function runRelayConnection({
|
|
91267
91467
|
resolveAgent,
|
|
91268
91468
|
config: config2,
|
|
@@ -91415,7 +91615,10 @@ async function runRelayConnection({
|
|
|
91415
91615
|
return;
|
|
91416
91616
|
}
|
|
91417
91617
|
try {
|
|
91418
|
-
const message =
|
|
91618
|
+
const message = decodeKnownServiceToDaemonMessage(encoded);
|
|
91619
|
+
if (message === null) {
|
|
91620
|
+
return;
|
|
91621
|
+
}
|
|
91419
91622
|
const kind = message.kind;
|
|
91420
91623
|
if (kind === RUNTIME_LIVENESS_READY_KIND) {
|
|
91421
91624
|
if (ready) {
|
|
@@ -91433,26 +91636,6 @@ async function runRelayConnection({
|
|
|
91433
91636
|
}
|
|
91434
91637
|
commands.dispatch(message);
|
|
91435
91638
|
} catch (error62) {
|
|
91436
|
-
if (error62 instanceof UnsupportedProtocolMessageKindError) {
|
|
91437
|
-
const correlation = readCommandCorrelation(encoded);
|
|
91438
|
-
console.warn("Mobius daemon rejected an unsupported Relay command", {
|
|
91439
|
-
code: error62.code,
|
|
91440
|
-
direction: error62.direction,
|
|
91441
|
-
messageKind: error62.messageKind
|
|
91442
|
-
});
|
|
91443
|
-
diagnostics.daemonDiagnostic(
|
|
91444
|
-
"relay_command_unsupported",
|
|
91445
|
-
correlation.requestId,
|
|
91446
|
-
{
|
|
91447
|
-
code: error62.code,
|
|
91448
|
-
direction: error62.direction,
|
|
91449
|
-
messageKind: error62.messageKind
|
|
91450
|
-
},
|
|
91451
|
-
error62
|
|
91452
|
-
);
|
|
91453
|
-
rejectUnsupportedCommand(socket, correlation, error62);
|
|
91454
|
-
return;
|
|
91455
|
-
}
|
|
91456
91639
|
console.error("Mobius daemon rejected a message", error62);
|
|
91457
91640
|
failAndClose(
|
|
91458
91641
|
new Error("Relay sent an invalid protocol message", { cause: error62 }),
|