@moxt-ai/mobius 0.0.336 → 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 +427 -353
- package/dist/cli.js.map +4 -4
- package/dist/runtime.js +350 -310
- package/dist/runtime.js.map +4 -4
- 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
|
|
@@ -23773,7 +23582,7 @@ var AcpSessionConnector = class {
|
|
|
23773
23582
|
};
|
|
23774
23583
|
|
|
23775
23584
|
// src/acp/adapter/live-sessions.ts
|
|
23776
|
-
var absolutePathSchema = external_exports.string().min(1).refine(
|
|
23585
|
+
var absolutePathSchema = external_exports.string().min(1).refine(isAbsolute);
|
|
23777
23586
|
var targetSchema = external_exports.object({
|
|
23778
23587
|
nativeSessionId: nativeSessionIdSchema,
|
|
23779
23588
|
cwd: absolutePathSchema,
|
|
@@ -25103,7 +24912,7 @@ import { createHash as createHash3 } from "node:crypto";
|
|
|
25103
24912
|
import { spawn as spawn2 } from "node:child_process";
|
|
25104
24913
|
|
|
25105
24914
|
// src/acp/harness/codex/app-server-protocol.ts
|
|
25106
|
-
import { isAbsolute as
|
|
24915
|
+
import { isAbsolute as isAbsolute2 } from "node:path";
|
|
25107
24916
|
var boundedText = (maximum) => external_exports.string().max(maximum);
|
|
25108
24917
|
var jsonValue = external_exports.lazy(() => external_exports.unknown());
|
|
25109
24918
|
var requestIdSchema = external_exports.union([external_exports.number(), external_exports.string()]).refine((value) => typeof value === "number" || value.length <= 256);
|
|
@@ -25175,7 +24984,7 @@ var imageGenerationItemSchema = external_exports.object({
|
|
|
25175
24984
|
});
|
|
25176
24985
|
var threadItemSchema = external_exports.discriminatedUnion("type", [
|
|
25177
24986
|
imageGenerationItemSchema,
|
|
25178
|
-
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) }),
|
|
25179
24988
|
external_exports.object({
|
|
25180
24989
|
id: boundedText(256),
|
|
25181
24990
|
text: boundedText(1e6),
|
|
@@ -25653,7 +25462,7 @@ var CodexAppServerClient = class {
|
|
|
25653
25462
|
import { createHash } from "node:crypto";
|
|
25654
25463
|
|
|
25655
25464
|
// src/acp/content/raster.ts
|
|
25656
|
-
import { basename, isAbsolute as
|
|
25465
|
+
import { basename, isAbsolute as isAbsolute3, normalize } from "node:path";
|
|
25657
25466
|
import { fileURLToPath } from "node:url";
|
|
25658
25467
|
|
|
25659
25468
|
// src/storage/files/local-files.ts
|
|
@@ -25760,13 +25569,13 @@ function sniffRasterMime(bytes) {
|
|
|
25760
25569
|
}
|
|
25761
25570
|
async function resolveCanonicalPath(requested, signal) {
|
|
25762
25571
|
signal.throwIfAborted();
|
|
25763
|
-
if (!
|
|
25572
|
+
if (!isAbsolute3(requested) || requested.includes("\0") || normalize(requested) !== requested) {
|
|
25764
25573
|
return null;
|
|
25765
25574
|
}
|
|
25766
25575
|
try {
|
|
25767
25576
|
const target = await canonicalPath(requested);
|
|
25768
25577
|
signal.throwIfAborted();
|
|
25769
|
-
if (!
|
|
25578
|
+
if (!isAbsolute3(target) || normalize(target) !== target) {
|
|
25770
25579
|
return null;
|
|
25771
25580
|
}
|
|
25772
25581
|
return target;
|
|
@@ -25797,7 +25606,7 @@ function parseLocalImageUri(uri) {
|
|
|
25797
25606
|
return null;
|
|
25798
25607
|
}
|
|
25799
25608
|
}
|
|
25800
|
-
if (!
|
|
25609
|
+
if (!isAbsolute3(trimmed) && /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(trimmed)) {
|
|
25801
25610
|
return null;
|
|
25802
25611
|
}
|
|
25803
25612
|
return trimmed;
|
|
@@ -27063,12 +26872,12 @@ async function replayCodexHistory(client2, threadId, emit, signal) {
|
|
|
27063
26872
|
|
|
27064
26873
|
// src/storage/session/temporary-session-event-cache.ts
|
|
27065
26874
|
import { mkdtempSync, rmSync } from "node:fs";
|
|
27066
|
-
import { tmpdir
|
|
27067
|
-
import { join as
|
|
26875
|
+
import { tmpdir } from "node:os";
|
|
26876
|
+
import { join as join5 } from "node:path";
|
|
27068
26877
|
|
|
27069
26878
|
// src/storage/sqlite/local-databases.ts
|
|
27070
26879
|
import { createHash as createHash2 } from "node:crypto";
|
|
27071
|
-
import { join as
|
|
26880
|
+
import { join as join4 } from "node:path";
|
|
27072
26881
|
|
|
27073
26882
|
// src/generated/acp-session-store-migrations.ts
|
|
27074
26883
|
var acpSessionStoreMigrations = [
|
|
@@ -27611,7 +27420,7 @@ function sql(strings, ...params) {
|
|
|
27611
27420
|
return new SQL([new StringChunk(str)]);
|
|
27612
27421
|
}
|
|
27613
27422
|
_sql.raw = raw;
|
|
27614
|
-
function
|
|
27423
|
+
function join34(chunks, separator) {
|
|
27615
27424
|
const result = [];
|
|
27616
27425
|
for (const [i, chunk] of chunks.entries()) {
|
|
27617
27426
|
if (i > 0 && separator !== void 0) result.push(separator);
|
|
@@ -27619,7 +27428,7 @@ function sql(strings, ...params) {
|
|
|
27619
27428
|
}
|
|
27620
27429
|
return new SQL(result);
|
|
27621
27430
|
}
|
|
27622
|
-
_sql.join =
|
|
27431
|
+
_sql.join = join34;
|
|
27623
27432
|
function identifier2(value) {
|
|
27624
27433
|
return new Name(value);
|
|
27625
27434
|
}
|
|
@@ -29340,7 +29149,7 @@ var SQLiteSelectBase = class extends TypedQueryBuilder {
|
|
|
29340
29149
|
const baseTableName = this.tableName;
|
|
29341
29150
|
const tableName = getTableLikeName(table);
|
|
29342
29151
|
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
29343
|
-
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`);
|
|
29344
29153
|
if (!this.isPartialSelect) {
|
|
29345
29154
|
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
|
|
29346
29155
|
if (typeof tableName === "string" && !is(table, SQL)) {
|
|
@@ -30886,7 +30695,7 @@ var SQLiteDialect = class {
|
|
|
30886
30695
|
if (!joins2) return;
|
|
30887
30696
|
const withEntries = Object.entries(joins2).filter(([_, v]) => v);
|
|
30888
30697
|
if (!withEntries.length) return;
|
|
30889
|
-
return sql.join(withEntries.map(([k2,
|
|
30698
|
+
return sql.join(withEntries.map(([k2, join34]) => {
|
|
30890
30699
|
const relation = tableConfig.relations[k2];
|
|
30891
30700
|
const isSingle2 = is(relation, One);
|
|
30892
30701
|
const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
|
|
@@ -30897,7 +30706,7 @@ var SQLiteDialect = class {
|
|
|
30897
30706
|
table: targetTable,
|
|
30898
30707
|
mode: isSingle2 ? "first" : "many",
|
|
30899
30708
|
schema,
|
|
30900
|
-
queryConfig:
|
|
30709
|
+
queryConfig: join34,
|
|
30901
30710
|
tableConfig: schema[relation.targetTableName],
|
|
30902
30711
|
relationWhere: filter,
|
|
30903
30712
|
isNested: true,
|
|
@@ -30911,7 +30720,7 @@ var SQLiteDialect = class {
|
|
|
30911
30720
|
key: k2,
|
|
30912
30721
|
selection: innerQuery.selection,
|
|
30913
30722
|
isArray: !isSingle2,
|
|
30914
|
-
isOptional: (relation.optional ?? false) ||
|
|
30723
|
+
isOptional: (relation.optional ?? false) || join34 !== true && !!join34.where
|
|
30915
30724
|
});
|
|
30916
30725
|
const jsonColumns = sql.join(innerQuery.selection.map((s) => {
|
|
30917
30726
|
return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
|
|
@@ -31265,7 +31074,7 @@ var SQLiteUpdateBase = class {
|
|
|
31265
31074
|
createJoin(joinType) {
|
|
31266
31075
|
return ((table, on2) => {
|
|
31267
31076
|
const tableName = getTableLikeName(table);
|
|
31268
|
-
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`);
|
|
31269
31078
|
if (typeof on2 === "function") {
|
|
31270
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;
|
|
31271
31080
|
on2 = on2(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
|
|
@@ -32049,8 +31858,8 @@ var LocalSqliteDatabase = class {
|
|
|
32049
31858
|
function channelSessionDatabasePaths(stateDirectory, channelId) {
|
|
32050
31859
|
const channelHash = createHash2("sha256").update(channelId).digest("hex");
|
|
32051
31860
|
return {
|
|
32052
|
-
events:
|
|
32053
|
-
sessions:
|
|
31861
|
+
events: join4(stateDirectory, "sessions", `${channelHash}.events.sqlite`),
|
|
31862
|
+
sessions: join4(stateDirectory, "sessions", `${channelHash}.sqlite`)
|
|
32054
31863
|
};
|
|
32055
31864
|
}
|
|
32056
31865
|
var openAcpSessionDatabase = (path7) => new LocalSqliteDatabase(path7, "ACP Session database", acpSessionStoreMigrations);
|
|
@@ -32228,11 +32037,11 @@ var SessionEventCacheTable = class {
|
|
|
32228
32037
|
|
|
32229
32038
|
// src/storage/session/temporary-session-event-cache.ts
|
|
32230
32039
|
function openTemporarySessionEventCache() {
|
|
32231
|
-
const directory = mkdtempSync(
|
|
32040
|
+
const directory = mkdtempSync(join5(tmpdir(), "mobius-preview-events-"));
|
|
32232
32041
|
const removeFiles = () => rmSync(directory, { recursive: true, force: true });
|
|
32233
32042
|
try {
|
|
32234
32043
|
return {
|
|
32235
|
-
table: new SessionEventCacheTable(openSessionEventCacheDatabase(
|
|
32044
|
+
table: new SessionEventCacheTable(openSessionEventCacheDatabase(join5(directory, "events.sqlite"))),
|
|
32236
32045
|
removeFiles
|
|
32237
32046
|
};
|
|
32238
32047
|
} catch (error62) {
|
|
@@ -32742,13 +32551,13 @@ var RuntimeAgentDependencies = class {
|
|
|
32742
32551
|
|
|
32743
32552
|
// src/daemon/pairing/pair-local-machine.ts
|
|
32744
32553
|
import { hostname as hostname3 } from "node:os";
|
|
32745
|
-
import { basename as basename6, join as
|
|
32554
|
+
import { basename as basename6, join as join26, resolve as resolve16 } from "node:path";
|
|
32746
32555
|
import { fetch as fetch3 } from "undici";
|
|
32747
32556
|
|
|
32748
32557
|
// package.json
|
|
32749
32558
|
var package_default = {
|
|
32750
32559
|
name: "@moxt-ai/mobius",
|
|
32751
|
-
version: "0.0.
|
|
32560
|
+
version: "0.0.337",
|
|
32752
32561
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
32753
32562
|
type: "module",
|
|
32754
32563
|
bin: {
|
|
@@ -32930,7 +32739,7 @@ import { existsSync as existsSync3 } from "node:fs";
|
|
|
32930
32739
|
import * as fs3 from "node:fs/promises";
|
|
32931
32740
|
import * as os3 from "node:os";
|
|
32932
32741
|
import * as path6 from "node:path";
|
|
32933
|
-
import { promisify
|
|
32742
|
+
import { promisify } from "node:util";
|
|
32934
32743
|
import { agent as acpAgent, CreateElicitationResponse as CreateElicitationResponse2, methods as methods7, ndJsonStream, RequestError as RequestError6 } from "@agentclientprotocol/sdk";
|
|
32935
32744
|
|
|
32936
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
|
|
@@ -72296,7 +72105,7 @@ var SessionModeManager = class {
|
|
|
72296
72105
|
|
|
72297
72106
|
// src/acp/harness/claude/upstream/dist/acp-agent.js
|
|
72298
72107
|
var CLAUDE_CONFIG_DIR = process.env.CLAUDE_CONFIG_DIR ?? path6.join(os3.homedir(), ".claude");
|
|
72299
|
-
var execFileAsync =
|
|
72108
|
+
var execFileAsync = promisify(execFile3);
|
|
72300
72109
|
var ZERO_USAGE = Object.freeze({
|
|
72301
72110
|
input_tokens: 0,
|
|
72302
72111
|
output_tokens: 0,
|
|
@@ -77063,6 +76872,237 @@ var ClaudeAgentConnection = class extends EndpointAgentConnection {
|
|
|
77063
76872
|
}
|
|
77064
76873
|
};
|
|
77065
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
|
+
|
|
77066
77106
|
// src/agent/discovery/version-output.ts
|
|
77067
77107
|
function normalizeVersionOutput(output2) {
|
|
77068
77108
|
return output2.trim().split(/\r?\n/, 1)[0]?.trim().slice(0, 128) ?? "";
|
|
@@ -78160,7 +78200,7 @@ var CodexAgentSpecification = class extends InProcessAcpAgentSpecification {
|
|
|
78160
78200
|
|
|
78161
78201
|
// src/agent/specification/vendors/pi-agent.ts
|
|
78162
78202
|
import { createHash as createHash4 } from "node:crypto";
|
|
78163
|
-
import { join as
|
|
78203
|
+
import { join as join22 } from "node:path";
|
|
78164
78204
|
import {
|
|
78165
78205
|
methods as methods11
|
|
78166
78206
|
} from "@agentclientprotocol/sdk";
|
|
@@ -78175,7 +78215,7 @@ import {
|
|
|
78175
78215
|
import { spawnSync } from "node:child_process";
|
|
78176
78216
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
78177
78217
|
import { existsSync as existsSync7, readdirSync as readdirSync6, readFileSync as readFileSync8, realpathSync as realpathSync4, statSync as statSync4, unlinkSync as unlinkSync2 } from "node:fs";
|
|
78178
|
-
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";
|
|
78179
78219
|
import { RequestError as RequestError10 } from "@agentclientprotocol/sdk";
|
|
78180
78220
|
|
|
78181
78221
|
// src/acp/harness/pi/upstream/dist/pi-rpc/process.js
|
|
@@ -78633,7 +78673,7 @@ function maybeAuthRequiredError(err) {
|
|
|
78633
78673
|
}
|
|
78634
78674
|
|
|
78635
78675
|
// src/acp/harness/pi/upstream/dist/acp/paths.js
|
|
78636
|
-
import { join as
|
|
78676
|
+
import { join as join17 } from "node:path";
|
|
78637
78677
|
|
|
78638
78678
|
// src/acp/harness/pi/upstream/dist/acp/environment.js
|
|
78639
78679
|
import { homedir as homedir2 } from "node:os";
|
|
@@ -78643,10 +78683,10 @@ function environmentHome(environment) {
|
|
|
78643
78683
|
|
|
78644
78684
|
// src/acp/harness/pi/upstream/dist/acp/paths.js
|
|
78645
78685
|
function getPiAcpDir(environment = process.env) {
|
|
78646
|
-
return
|
|
78686
|
+
return join17(environmentHome(environment), ".pi", "pi-acp");
|
|
78647
78687
|
}
|
|
78648
78688
|
function getPiAcpSessionMapPath(environment = process.env) {
|
|
78649
|
-
return
|
|
78689
|
+
return join17(getPiAcpDir(environment), "session-map.json");
|
|
78650
78690
|
}
|
|
78651
78691
|
|
|
78652
78692
|
// src/acp/harness/pi/upstream/dist/acp/pi-commands.js
|
|
@@ -78691,15 +78731,15 @@ function toAvailableCommandsFromPiGetCommands(data, opts) {
|
|
|
78691
78731
|
|
|
78692
78732
|
// src/acp/harness/pi/upstream/dist/acp/pi-sessions.js
|
|
78693
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";
|
|
78694
|
-
import { isAbsolute as isAbsolute11, join as
|
|
78734
|
+
import { isAbsolute as isAbsolute11, join as join18, resolve as resolve10 } from "node:path";
|
|
78695
78735
|
var DEFAULT_TAIL_BYTES = 256 * 1024;
|
|
78696
78736
|
var DEFAULT_HEAD_BYTES = 64 * 1024;
|
|
78697
78737
|
function getPiAgentDir(environment) {
|
|
78698
78738
|
const configured = environment["PI_CODING_AGENT_DIR"];
|
|
78699
|
-
return configured ? resolve10(configured) :
|
|
78739
|
+
return configured ? resolve10(configured) : join18(environmentHome(environment), ".pi", "agent");
|
|
78700
78740
|
}
|
|
78701
78741
|
function readSessionDirFromSettings(agentDir) {
|
|
78702
|
-
const settingsPath =
|
|
78742
|
+
const settingsPath = join18(agentDir, "settings.json");
|
|
78703
78743
|
try {
|
|
78704
78744
|
if (!existsSync4(settingsPath)) {
|
|
78705
78745
|
return null;
|
|
@@ -78720,7 +78760,7 @@ function readSessionDirFromSettings(agentDir) {
|
|
|
78720
78760
|
}
|
|
78721
78761
|
function getPiSessionsDir(environment = process.env) {
|
|
78722
78762
|
const agentDir = getPiAgentDir(environment);
|
|
78723
|
-
return readSessionDirFromSettings(agentDir) ??
|
|
78763
|
+
return readSessionDirFromSettings(agentDir) ?? join18(agentDir, "sessions");
|
|
78724
78764
|
}
|
|
78725
78765
|
function getPiSessionDiscoveryDirs(environment) {
|
|
78726
78766
|
const discoveryDirectories = [getPiSessionsDir(environment)];
|
|
@@ -78731,7 +78771,7 @@ function getPiSessionDiscoveryDirs(environment) {
|
|
|
78731
78771
|
if (!entry.isDirectory()) {
|
|
78732
78772
|
continue;
|
|
78733
78773
|
}
|
|
78734
|
-
const directory =
|
|
78774
|
+
const directory = join18(mobiusSessionsRoot, entry.name);
|
|
78735
78775
|
if (!discoveryDirectories.includes(directory)) {
|
|
78736
78776
|
discoveryDirectories.push(directory);
|
|
78737
78777
|
}
|
|
@@ -78748,7 +78788,7 @@ function walkJsonlFiles(dir, out2) {
|
|
|
78748
78788
|
}
|
|
78749
78789
|
for (const e of entries) {
|
|
78750
78790
|
const name2 = typeof e.name === "string" ? e.name : String(e.name);
|
|
78751
|
-
const p =
|
|
78791
|
+
const p = join18(dir, name2);
|
|
78752
78792
|
if (e.isDirectory()) {
|
|
78753
78793
|
walkJsonlFiles(p, out2);
|
|
78754
78794
|
} else if (e.isFile() && name2.endsWith(".jsonl")) {
|
|
@@ -79017,7 +79057,7 @@ function findPiSession(sessionId, environment = process.env) {
|
|
|
79017
79057
|
|
|
79018
79058
|
// src/acp/harness/pi/upstream/dist/acp/pi-settings.js
|
|
79019
79059
|
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:fs";
|
|
79020
|
-
import { join as
|
|
79060
|
+
import { join as join19, resolve as resolve11 } from "node:path";
|
|
79021
79061
|
function isObject2(x) {
|
|
79022
79062
|
return Boolean(x) && typeof x === "object" && !Array.isArray(x);
|
|
79023
79063
|
}
|
|
@@ -79046,7 +79086,7 @@ function readJsonFile(path7) {
|
|
|
79046
79086
|
}
|
|
79047
79087
|
}
|
|
79048
79088
|
function getMergedSettings(cwd, environment) {
|
|
79049
|
-
const globalSettingsPath =
|
|
79089
|
+
const globalSettingsPath = join19(getAgentDir(environment), "settings.json");
|
|
79050
79090
|
const projectSettingsPath = resolve11(cwd, ".pi", "settings.json");
|
|
79051
79091
|
const global2 = readJsonFile(globalSettingsPath);
|
|
79052
79092
|
const project = readJsonFile(projectSettingsPath);
|
|
@@ -79054,7 +79094,7 @@ function getMergedSettings(cwd, environment) {
|
|
|
79054
79094
|
}
|
|
79055
79095
|
function getAgentDir(environment = process.env) {
|
|
79056
79096
|
const configured = environment["PI_CODING_AGENT_DIR"];
|
|
79057
|
-
return configured ? resolve11(configured) :
|
|
79097
|
+
return configured ? resolve11(configured) : join19(environmentHome(environment), ".pi", "agent");
|
|
79058
79098
|
}
|
|
79059
79099
|
function getEnableSkillCommands(cwd, environment = process.env) {
|
|
79060
79100
|
const merged = getMergedSettings(cwd, environment);
|
|
@@ -79310,7 +79350,7 @@ var SessionStore = class {
|
|
|
79310
79350
|
|
|
79311
79351
|
// src/acp/harness/pi/upstream/dist/acp/slash-commands.js
|
|
79312
79352
|
import { existsSync as existsSync6, readdirSync as readdirSync5, readFileSync as readFileSync6 } from "node:fs";
|
|
79313
|
-
import { join as
|
|
79353
|
+
import { join as join20, resolve as resolve12 } from "node:path";
|
|
79314
79354
|
function parseFrontmatter(content) {
|
|
79315
79355
|
const frontmatter = {};
|
|
79316
79356
|
if (!content.startsWith("---")) {
|
|
@@ -79338,7 +79378,7 @@ function loadCommandsFromDir(dir, source, subdir = "") {
|
|
|
79338
79378
|
try {
|
|
79339
79379
|
const entries = readdirSync5(dir, { withFileTypes: true });
|
|
79340
79380
|
for (const entry of entries) {
|
|
79341
|
-
const fullPath =
|
|
79381
|
+
const fullPath = join20(dir, entry.name);
|
|
79342
79382
|
if (entry.isDirectory()) {
|
|
79343
79383
|
const newSubdir = subdir ? `${subdir}:${entry.name}` : entry.name;
|
|
79344
79384
|
commands.push(...loadCommandsFromDir(fullPath, source, newSubdir));
|
|
@@ -79378,7 +79418,7 @@ function loadCommandsFromDir(dir, source, subdir = "") {
|
|
|
79378
79418
|
}
|
|
79379
79419
|
function loadSlashCommands(cwd, environment = process.env) {
|
|
79380
79420
|
const commands = [];
|
|
79381
|
-
const userDir =
|
|
79421
|
+
const userDir = join20(environmentHome(environment), ".pi", "agent", "prompts");
|
|
79382
79422
|
const projectDir = resolve12(cwd, ".pi", "prompts");
|
|
79383
79423
|
commands.push(...loadCommandsFromDir(userDir, "user"));
|
|
79384
79424
|
commands.push(...loadCommandsFromDir(projectDir, "project"));
|
|
@@ -81025,7 +81065,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
81025
81065
|
if (piPath) {
|
|
81026
81066
|
const resolved = realpathSync4(piPath);
|
|
81027
81067
|
const pkgRoot = dirname8(dirname8(resolved));
|
|
81028
|
-
const p =
|
|
81068
|
+
const p = join21(pkgRoot, "CHANGELOG.md");
|
|
81029
81069
|
if (existsSync7(p)) {
|
|
81030
81070
|
return p;
|
|
81031
81071
|
}
|
|
@@ -81036,7 +81076,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
81036
81076
|
const npmRoot = spawnSync("npm", ["root", "-g"], { encoding: "utf-8" });
|
|
81037
81077
|
const root = String(npmRoot.stdout ?? "").trim();
|
|
81038
81078
|
if (root) {
|
|
81039
|
-
const p =
|
|
81079
|
+
const p = join21(root, "@earendil-works", "pi-coding-agent", "CHANGELOG.md");
|
|
81040
81080
|
if (existsSync7(p)) {
|
|
81041
81081
|
return p;
|
|
81042
81082
|
}
|
|
@@ -81130,7 +81170,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
81130
81170
|
return { stopReason: "end_turn" };
|
|
81131
81171
|
}
|
|
81132
81172
|
const safeSessionId = session.sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
81133
|
-
const outputPath =
|
|
81173
|
+
const outputPath = join21(session.cwd, `pi-session-${safeSessionId}.html`);
|
|
81134
81174
|
let resultPath = "";
|
|
81135
81175
|
try {
|
|
81136
81176
|
const result2 = await session.proc.exportHtml(outputPath);
|
|
@@ -81844,7 +81884,7 @@ function buildStartupInfo(opts) {
|
|
|
81844
81884
|
md.push("");
|
|
81845
81885
|
};
|
|
81846
81886
|
const contextItems = [];
|
|
81847
|
-
const contextPath =
|
|
81887
|
+
const contextPath = join21(opts.cwd, "AGENTS.md");
|
|
81848
81888
|
if (existsSync7(contextPath)) {
|
|
81849
81889
|
contextItems.push(contextPath);
|
|
81850
81890
|
}
|
|
@@ -81853,7 +81893,7 @@ function buildStartupInfo(opts) {
|
|
|
81853
81893
|
const pushSkillFromRoot = (root) => {
|
|
81854
81894
|
try {
|
|
81855
81895
|
for (const e of readdirSync6(root)) {
|
|
81856
|
-
const p =
|
|
81896
|
+
const p = join21(root, e);
|
|
81857
81897
|
try {
|
|
81858
81898
|
const st2 = statSync4(p);
|
|
81859
81899
|
if (st2.isFile() && e.toLowerCase().endsWith(".md")) {
|
|
@@ -81878,7 +81918,7 @@ function buildStartupInfo(opts) {
|
|
|
81878
81918
|
if (name2 === "node_modules" || name2 === ".git") {
|
|
81879
81919
|
continue;
|
|
81880
81920
|
}
|
|
81881
|
-
const p =
|
|
81921
|
+
const p = join21(dir, name2);
|
|
81882
81922
|
let st2;
|
|
81883
81923
|
try {
|
|
81884
81924
|
st2 = statSync4(p);
|
|
@@ -81895,16 +81935,16 @@ function buildStartupInfo(opts) {
|
|
|
81895
81935
|
} catch {
|
|
81896
81936
|
}
|
|
81897
81937
|
};
|
|
81898
|
-
const globalSkillsDir =
|
|
81938
|
+
const globalSkillsDir = join21(getAgentDir(opts.environment), "skills");
|
|
81899
81939
|
pushSkillFromRoot(globalSkillsDir);
|
|
81900
81940
|
const home = opts.environment["HOME"] ?? opts.environment["USERPROFILE"] ?? "";
|
|
81901
|
-
const legacyAgentsSkillsDir =
|
|
81941
|
+
const legacyAgentsSkillsDir = join21(home, ".agents", "skills");
|
|
81902
81942
|
pushSkillFromRoot(legacyAgentsSkillsDir);
|
|
81903
|
-
const projectSkillsDir =
|
|
81943
|
+
const projectSkillsDir = join21(opts.cwd, ".pi", "skills");
|
|
81904
81944
|
pushSkillFromRoot(projectSkillsDir);
|
|
81905
81945
|
addSection("Skills", skillsItems);
|
|
81906
81946
|
const promptsItems = [];
|
|
81907
|
-
const promptsDir =
|
|
81947
|
+
const promptsDir = join21(home, ".pi", "agent", "prompts");
|
|
81908
81948
|
try {
|
|
81909
81949
|
const prompts = readdirSync6(promptsDir).filter((f) => f.endsWith(".md"));
|
|
81910
81950
|
for (const f of prompts) {
|
|
@@ -81914,17 +81954,17 @@ function buildStartupInfo(opts) {
|
|
|
81914
81954
|
}
|
|
81915
81955
|
addSection("Prompts", promptsItems);
|
|
81916
81956
|
const extItems = [];
|
|
81917
|
-
const extDir =
|
|
81957
|
+
const extDir = join21(home, ".pi", "agent", "extensions");
|
|
81918
81958
|
try {
|
|
81919
81959
|
const exts = readdirSync6(extDir).filter((f) => f.endsWith(".ts") || f.endsWith(".js"));
|
|
81920
81960
|
for (const f of exts) {
|
|
81921
|
-
extItems.push(
|
|
81961
|
+
extItems.push(join21(extDir, f));
|
|
81922
81962
|
}
|
|
81923
81963
|
} catch {
|
|
81924
81964
|
}
|
|
81925
81965
|
const settingsPaths = [
|
|
81926
|
-
|
|
81927
|
-
|
|
81966
|
+
join21(getAgentDir(opts.environment), "settings.json"),
|
|
81967
|
+
join21(opts.cwd, ".pi", "settings.json")
|
|
81928
81968
|
];
|
|
81929
81969
|
for (const settingsPath of settingsPaths) {
|
|
81930
81970
|
try {
|
|
@@ -82122,7 +82162,7 @@ var PiAgentSpecification = class extends InProcessAcpAgentSpecification {
|
|
|
82122
82162
|
// keeps the adapter's opt-in capability flag enabled for every launch it owns.
|
|
82123
82163
|
createLaunchEnvironment = async (_agent, context) => {
|
|
82124
82164
|
const workspaceHash = createHash4("sha256").update(context.defaultWorkspace).digest("hex").slice(0, 24);
|
|
82125
|
-
const sessionDirectory =
|
|
82165
|
+
const sessionDirectory = join22(context.dataDirectory, "agents", "pi", "sessions", workspaceHash);
|
|
82126
82166
|
return Object.freeze({
|
|
82127
82167
|
PI_ACP_ENABLE_EMBEDDED_CONTEXT: "true",
|
|
82128
82168
|
MOBIUS_PI_SESSION_DIR: sessionDirectory
|
|
@@ -82855,7 +82895,7 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
82855
82895
|
}
|
|
82856
82896
|
|
|
82857
82897
|
// src/runtime/config.ts
|
|
82858
|
-
import { join as
|
|
82898
|
+
import { join as join24, resolve as resolve14 } from "node:path";
|
|
82859
82899
|
|
|
82860
82900
|
// src/util/serial-task-queue.ts
|
|
82861
82901
|
var SerialTaskQueue = class {
|
|
@@ -82928,19 +82968,19 @@ var LocalAgentCatalog = class {
|
|
|
82928
82968
|
|
|
82929
82969
|
// src/storage/state-directory.ts
|
|
82930
82970
|
import { homedir as homedir3 } from "node:os";
|
|
82931
|
-
import { join as
|
|
82971
|
+
import { join as join23, resolve as resolve13 } from "node:path";
|
|
82932
82972
|
var stateRootSchema = external_exports.string().brand();
|
|
82933
82973
|
function readStateDirectory(environment = process.env) {
|
|
82934
82974
|
const configured = environment["MOBIUS_STATE_DIRECTORY"]?.trim();
|
|
82935
82975
|
return stateRootSchema.parse(
|
|
82936
|
-
configured !== void 0 && configured.length > 0 ? resolve13(configured) :
|
|
82976
|
+
configured !== void 0 && configured.length > 0 ? resolve13(configured) : join23(homedir3(), ".mobius")
|
|
82937
82977
|
);
|
|
82938
82978
|
}
|
|
82939
82979
|
|
|
82940
82980
|
// src/runtime/config.ts
|
|
82941
82981
|
function loadDefaultWorkspace(dataDirectory, environment = process.env) {
|
|
82942
82982
|
const { MOBIUS_DEFAULT_WORKSPACE: configuredWorkspace } = environment;
|
|
82943
|
-
return configuredWorkspace ??
|
|
82983
|
+
return configuredWorkspace ?? join24(dataDirectory, "workspace");
|
|
82944
82984
|
}
|
|
82945
82985
|
var RuntimeLocalContext = class {
|
|
82946
82986
|
environment;
|
|
@@ -83049,7 +83089,7 @@ import { resolve as resolve15 } from "node:path";
|
|
|
83049
83089
|
// src/storage/installation/installation-files.ts
|
|
83050
83090
|
import { createHash as createHash5, randomUUID as randomUUID12 } from "node:crypto";
|
|
83051
83091
|
import { mkdir as mkdir4, open as open5, readdir as readdir5, rename as rename3, unlink as unlink3, writeFile } from "node:fs/promises";
|
|
83052
|
-
import { dirname as dirname9, join as
|
|
83092
|
+
import { dirname as dirname9, join as join25 } from "node:path";
|
|
83053
83093
|
|
|
83054
83094
|
// src/util/node-error.ts
|
|
83055
83095
|
function isNodeError(error62, code) {
|
|
@@ -83072,23 +83112,23 @@ var STATE_ROOT_ENTRY_NAMES = new Set(Object.values(STATE_ROOT_LAYOUT));
|
|
|
83072
83112
|
// src/storage/installation/installation-files.ts
|
|
83073
83113
|
var MAXIMUM_FILE_BYTES = 16 * 1024;
|
|
83074
83114
|
function applicationDirectory(root, applicationId) {
|
|
83075
|
-
return
|
|
83115
|
+
return join25(root, STATE_ROOT_LAYOUT.installations, applicationId);
|
|
83076
83116
|
}
|
|
83077
83117
|
function installationPointerPath(applicationDirectory2) {
|
|
83078
|
-
return
|
|
83118
|
+
return join25(applicationDirectory2, "current.json");
|
|
83079
83119
|
}
|
|
83080
83120
|
var installationDirectorySchema = external_exports.string().brand();
|
|
83081
83121
|
function installationDirectory(applicationDirectory2, installationId2) {
|
|
83082
|
-
return installationDirectorySchema.parse(
|
|
83122
|
+
return installationDirectorySchema.parse(join25(applicationDirectory2, installationId2));
|
|
83083
83123
|
}
|
|
83084
83124
|
function connectionDirectory(installationDirectory2) {
|
|
83085
|
-
return
|
|
83125
|
+
return join25(installationDirectory2, "connections");
|
|
83086
83126
|
}
|
|
83087
83127
|
function connectionFilePath(connectionDirectory2, connectionId2) {
|
|
83088
|
-
return
|
|
83128
|
+
return join25(connectionDirectory2, `${connectionId2}.json`);
|
|
83089
83129
|
}
|
|
83090
83130
|
function channelIndexFilePath(installationDirectory2, channelId) {
|
|
83091
|
-
return
|
|
83131
|
+
return join25(installationDirectory2, "channels", `mci_${createHash5("sha256").update(channelId).digest("hex")}.json`);
|
|
83092
83132
|
}
|
|
83093
83133
|
async function readInstallationFile(path7) {
|
|
83094
83134
|
let handle;
|
|
@@ -83110,7 +83150,7 @@ async function readInstallationFile(path7) {
|
|
|
83110
83150
|
async function writeInstallationFile(path7, text2, signal) {
|
|
83111
83151
|
signal.throwIfAborted();
|
|
83112
83152
|
const directory = dirname9(path7);
|
|
83113
|
-
const temporaryPath =
|
|
83153
|
+
const temporaryPath = join25(directory, `.${randomUUID12()}.tmp`);
|
|
83114
83154
|
try {
|
|
83115
83155
|
await mkdir4(directory, { mode: 448, recursive: true });
|
|
83116
83156
|
signal.throwIfAborted();
|
|
@@ -87766,7 +87806,7 @@ var SessionTurns = class {
|
|
|
87766
87806
|
|
|
87767
87807
|
// src/session/workspace/workspace-directory.ts
|
|
87768
87808
|
import { homedir as homedir4 } from "node:os";
|
|
87769
|
-
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";
|
|
87770
87810
|
var WorkspaceDirectoryListing = class {
|
|
87771
87811
|
directoryId;
|
|
87772
87812
|
directoryLabel;
|
|
@@ -87888,7 +87928,7 @@ var WorkspaceDirectoryService = class {
|
|
|
87888
87928
|
continue;
|
|
87889
87929
|
}
|
|
87890
87930
|
try {
|
|
87891
|
-
const path7 = await this.resolvePath(
|
|
87931
|
+
const path7 = await this.resolvePath(join27(target, child.name), signal);
|
|
87892
87932
|
entries.push({ directoryId: encodePath(path7), name: child.name });
|
|
87893
87933
|
} catch (cause) {
|
|
87894
87934
|
signal.throwIfAborted();
|
|
@@ -88036,12 +88076,12 @@ function buildSessionLayer(options) {
|
|
|
88036
88076
|
|
|
88037
88077
|
// src/session/content/external-content-store.ts
|
|
88038
88078
|
import { createHash as createHash7 } from "node:crypto";
|
|
88039
|
-
import { join as
|
|
88079
|
+
import { join as join29 } from "node:path";
|
|
88040
88080
|
|
|
88041
88081
|
// src/storage/files/scratch-directory.ts
|
|
88042
88082
|
import { randomUUID as randomUUID17 } from "node:crypto";
|
|
88043
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";
|
|
88044
|
-
import { dirname as dirname11, join as
|
|
88084
|
+
import { dirname as dirname11, join as join28 } from "node:path";
|
|
88045
88085
|
async function atomicWrite(path7, bytes, signal) {
|
|
88046
88086
|
const temporary = `${path7}.${randomUUID17()}.tmp`;
|
|
88047
88087
|
try {
|
|
@@ -88055,7 +88095,7 @@ async function atomicWrite(path7, bytes, signal) {
|
|
|
88055
88095
|
var ScratchDirectory = class {
|
|
88056
88096
|
#root;
|
|
88057
88097
|
constructor(parent) {
|
|
88058
|
-
this.#root =
|
|
88098
|
+
this.#root = join28(parent, randomUUID17());
|
|
88059
88099
|
}
|
|
88060
88100
|
/** Refreshes this directory's lease and removes sibling directories whose lease is older than `leaseMilliseconds`. */
|
|
88061
88101
|
refreshLease = async (leaseMilliseconds) => {
|
|
@@ -88066,7 +88106,7 @@ var ScratchDirectory = class {
|
|
|
88066
88106
|
if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
|
|
88067
88107
|
continue;
|
|
88068
88108
|
}
|
|
88069
|
-
const path7 =
|
|
88109
|
+
const path7 = join28(dirname11(this.#root), directory.name);
|
|
88070
88110
|
if (path7 === this.#root) {
|
|
88071
88111
|
continue;
|
|
88072
88112
|
}
|
|
@@ -88081,10 +88121,10 @@ var ScratchDirectory = class {
|
|
|
88081
88121
|
};
|
|
88082
88122
|
/** Writes `bytes` atomically to `<group>/<name>` with owner-only permissions and returns the path. */
|
|
88083
88123
|
write = async (group, name2, bytes, signal) => {
|
|
88084
|
-
const directory =
|
|
88124
|
+
const directory = join28(this.#root, group);
|
|
88085
88125
|
await mkdir5(directory, { mode: 448, recursive: true });
|
|
88086
88126
|
signal.throwIfAborted();
|
|
88087
|
-
const path7 =
|
|
88127
|
+
const path7 = join28(directory, name2);
|
|
88088
88128
|
await atomicWrite(path7, bytes, signal);
|
|
88089
88129
|
return path7;
|
|
88090
88130
|
};
|
|
@@ -88131,7 +88171,7 @@ var LocalExternalContentStore = class {
|
|
|
88131
88171
|
#expirationTimer;
|
|
88132
88172
|
#cleanup = Promise.resolve();
|
|
88133
88173
|
constructor(stateDirectory) {
|
|
88134
|
-
this.#scratch = new ScratchDirectory(
|
|
88174
|
+
this.#scratch = new ScratchDirectory(join29(stateDirectory, "tmp", "session-content"));
|
|
88135
88175
|
this.#expirationTimer = setInterval(() => {
|
|
88136
88176
|
void this.#expire().catch(() => void 0);
|
|
88137
88177
|
}, 6e4);
|
|
@@ -88514,11 +88554,11 @@ var AgentProcessPool = class {
|
|
|
88514
88554
|
};
|
|
88515
88555
|
|
|
88516
88556
|
// src/runtime/observability/diagnostic-log.ts
|
|
88517
|
-
import { join as
|
|
88557
|
+
import { join as join32 } from "node:path";
|
|
88518
88558
|
|
|
88519
88559
|
// src/storage/logs/bounded-log.ts
|
|
88520
88560
|
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync4, readFileSync as readFileSync9, renameSync as renameSync2, statSync as statSync5, writeFileSync as writeFileSync2 } from "node:fs";
|
|
88521
|
-
import { join as
|
|
88561
|
+
import { join as join30 } from "node:path";
|
|
88522
88562
|
var BoundedLineLog = class {
|
|
88523
88563
|
#path;
|
|
88524
88564
|
#maximumBytes;
|
|
@@ -88527,7 +88567,7 @@ var BoundedLineLog = class {
|
|
|
88527
88567
|
#onWriteFailure;
|
|
88528
88568
|
constructor(directory, filename, maximumBytes, onWriteFailure = () => void 0) {
|
|
88529
88569
|
this.#directory = directory;
|
|
88530
|
-
this.#path =
|
|
88570
|
+
this.#path = join30(directory, filename);
|
|
88531
88571
|
this.#maximumBytes = maximumBytes;
|
|
88532
88572
|
this.#onWriteFailure = onWriteFailure;
|
|
88533
88573
|
}
|
|
@@ -88578,21 +88618,21 @@ var BoundedLineLog = class {
|
|
|
88578
88618
|
|
|
88579
88619
|
// src/storage/logs/log-files.ts
|
|
88580
88620
|
import { readFileSync as readFileSync10 } from "node:fs";
|
|
88581
|
-
import { join as
|
|
88621
|
+
import { join as join31, relative as relative3 } from "node:path";
|
|
88582
88622
|
var DAEMON_LOG_FILENAME = "daemon.log";
|
|
88583
88623
|
var WORKER_LIFECYCLE_LOG_FILENAME = "worker-lifecycle.log";
|
|
88584
88624
|
function unhandledRejectionLogFilename(role) {
|
|
88585
88625
|
return `unhandled-rejections-${role}.log`;
|
|
88586
88626
|
}
|
|
88587
88627
|
function logDirectory(stateDirectory) {
|
|
88588
|
-
return
|
|
88628
|
+
return join31(stateDirectory, "logs");
|
|
88589
88629
|
}
|
|
88590
88630
|
function processLogPaths(stateDirectory) {
|
|
88591
88631
|
return [
|
|
88592
88632
|
WORKER_LIFECYCLE_LOG_FILENAME,
|
|
88593
88633
|
unhandledRejectionLogFilename("manager"),
|
|
88594
88634
|
unhandledRejectionLogFilename("worker")
|
|
88595
|
-
].map((filename) =>
|
|
88635
|
+
].map((filename) => join31(logDirectory(stateDirectory), filename));
|
|
88596
88636
|
}
|
|
88597
88637
|
function readLogText(path7) {
|
|
88598
88638
|
try {
|
|
@@ -88648,7 +88688,7 @@ var RuntimeDiagnosticLog = class {
|
|
|
88648
88688
|
this.#maximumBytes = maximumBytes;
|
|
88649
88689
|
const processLogsDirectory = options.processLogsDirectory;
|
|
88650
88690
|
this.#sources = [
|
|
88651
|
-
{ maximumBytes, path:
|
|
88691
|
+
{ maximumBytes, path: join32(directory, DAEMON_LOG_FILENAME) },
|
|
88652
88692
|
// The process logs a Runtime does not own, but must read to explain its own deaths.
|
|
88653
88693
|
...processLogsDirectory === void 0 ? [] : processLogPaths(processLogsDirectory).map((path7) => ({ maximumBytes: null, path: path7 }))
|
|
88654
88694
|
];
|
|
@@ -89631,7 +89671,7 @@ function createContentWriteCommands(context) {
|
|
|
89631
89671
|
import { WebSocket as WebSocket5 } from "undici";
|
|
89632
89672
|
|
|
89633
89673
|
// src/session/content/session-files.ts
|
|
89634
|
-
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";
|
|
89635
89675
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
89636
89676
|
function requestedPath(value) {
|
|
89637
89677
|
if (value.includes("\0")) {
|
|
@@ -89655,7 +89695,7 @@ async function resolveFile(value, workingDirectory, signal) {
|
|
|
89655
89695
|
if (isAbsolute16(requested.path) && normalize3(requested.path) !== requested.path) {
|
|
89656
89696
|
return null;
|
|
89657
89697
|
}
|
|
89658
|
-
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)];
|
|
89659
89699
|
for (const candidate of candidates) {
|
|
89660
89700
|
if (!isAbsolute16(candidate) || normalize3(candidate) !== candidate) {
|
|
89661
89701
|
continue;
|