@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/cli.js
CHANGED
|
@@ -2086,7 +2086,7 @@ var init_package = __esm({
|
|
|
2086
2086
|
"package.json"() {
|
|
2087
2087
|
package_default = {
|
|
2088
2088
|
name: "@moxt-ai/mobius",
|
|
2089
|
-
version: "0.0.
|
|
2089
|
+
version: "0.0.337",
|
|
2090
2090
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
2091
2091
|
type: "module",
|
|
2092
2092
|
bin: {
|
|
@@ -70440,11 +70440,270 @@ var init_path_error = __esm({
|
|
|
70440
70440
|
});
|
|
70441
70441
|
|
|
70442
70442
|
// src/util/platform/posix.ts
|
|
70443
|
-
import {
|
|
70444
|
-
import { constants as constants3 } from "node:fs";
|
|
70445
|
-
import { access as access2, chmod, lstat as lstat2, realpath as realpath3, unlink as unlink3 } from "node:fs/promises";
|
|
70443
|
+
import { chmod, lstat as lstat2, unlink as unlink3 } from "node:fs/promises";
|
|
70446
70444
|
import { tmpdir } from "node:os";
|
|
70447
70445
|
import { join as join10 } from "node:path";
|
|
70446
|
+
async function removeControlSocket(path8) {
|
|
70447
|
+
try {
|
|
70448
|
+
await unlink3(path8);
|
|
70449
|
+
} catch (cause) {
|
|
70450
|
+
if (!(cause instanceof Error) || !("code" in cause) || cause.code !== "ENOENT") {
|
|
70451
|
+
throw cause;
|
|
70452
|
+
}
|
|
70453
|
+
}
|
|
70454
|
+
}
|
|
70455
|
+
var posixOperations;
|
|
70456
|
+
var init_posix = __esm({
|
|
70457
|
+
"src/util/platform/posix.ts"() {
|
|
70458
|
+
"use strict";
|
|
70459
|
+
init_path_error();
|
|
70460
|
+
posixOperations = {
|
|
70461
|
+
controlSocketPath: (installationHash) => join10(tmpdir(), `mobius-${installationHash}.sock`),
|
|
70462
|
+
prepareControlSocket: removeControlSocket,
|
|
70463
|
+
secureControlSocket: async (path8) => {
|
|
70464
|
+
await chmod(path8, 384);
|
|
70465
|
+
},
|
|
70466
|
+
removeControlSocket,
|
|
70467
|
+
validatePathPermissions: async (path8, directory, privateAccess, signal) => {
|
|
70468
|
+
signal.throwIfAborted();
|
|
70469
|
+
const metadata = await lstat2(path8);
|
|
70470
|
+
if (process.getuid === void 0 || metadata.uid !== process.getuid()) {
|
|
70471
|
+
throw new LocalPathError("Path is not user-owned");
|
|
70472
|
+
}
|
|
70473
|
+
if (privateAccess) {
|
|
70474
|
+
await chmod(path8, directory ? 448 : 384);
|
|
70475
|
+
}
|
|
70476
|
+
signal.throwIfAborted();
|
|
70477
|
+
}
|
|
70478
|
+
};
|
|
70479
|
+
}
|
|
70480
|
+
});
|
|
70481
|
+
|
|
70482
|
+
// src/util/platform/linux.ts
|
|
70483
|
+
import { isAbsolute as isAbsolute5, join as join11 } from "node:path";
|
|
70484
|
+
var linuxPlatform;
|
|
70485
|
+
var init_linux = __esm({
|
|
70486
|
+
"src/util/platform/linux.ts"() {
|
|
70487
|
+
"use strict";
|
|
70488
|
+
init_posix();
|
|
70489
|
+
linuxPlatform = {
|
|
70490
|
+
...posixOperations,
|
|
70491
|
+
claudeCodeExecutablePaths: (environment) => {
|
|
70492
|
+
const homeDirectory = environment["HOME"];
|
|
70493
|
+
return homeDirectory !== void 0 && isAbsolute5(homeDirectory) ? [join11(homeDirectory, ".local", "bin", "claude")] : [];
|
|
70494
|
+
}
|
|
70495
|
+
};
|
|
70496
|
+
}
|
|
70497
|
+
});
|
|
70498
|
+
|
|
70499
|
+
// src/util/platform/claude-desktop.ts
|
|
70500
|
+
import { readdirSync as readdirSync2 } from "node:fs";
|
|
70501
|
+
import { join as join12 } from "node:path";
|
|
70502
|
+
function installedDirectories(directory) {
|
|
70503
|
+
try {
|
|
70504
|
+
return readdirSync2(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
70505
|
+
} catch (cause) {
|
|
70506
|
+
if (cause instanceof Error && "code" in cause && (cause.code === "ENOENT" || cause.code === "ENOTDIR" || cause.code === "EACCES")) {
|
|
70507
|
+
return [];
|
|
70508
|
+
}
|
|
70509
|
+
throw cause;
|
|
70510
|
+
}
|
|
70511
|
+
}
|
|
70512
|
+
function claudeDesktopExecutablePaths(roots, executablePaths) {
|
|
70513
|
+
const paths = [];
|
|
70514
|
+
for (const root of roots) {
|
|
70515
|
+
const versions = installedDirectories(root).filter((version2) => /^\d+\.\d+\.\d+$/.test(version2)).toSorted((left, right) => right.localeCompare(left, "en", { numeric: true }));
|
|
70516
|
+
for (const version2 of versions) {
|
|
70517
|
+
const directory = join12(root, version2);
|
|
70518
|
+
const installations = [
|
|
70519
|
+
directory,
|
|
70520
|
+
...installedDirectories(directory).map((build) => join12(directory, build))
|
|
70521
|
+
];
|
|
70522
|
+
for (const installation of installations) {
|
|
70523
|
+
for (const executablePath of executablePaths) {
|
|
70524
|
+
paths.push(join12(installation, ...executablePath));
|
|
70525
|
+
}
|
|
70526
|
+
}
|
|
70527
|
+
}
|
|
70528
|
+
}
|
|
70529
|
+
return paths;
|
|
70530
|
+
}
|
|
70531
|
+
var init_claude_desktop = __esm({
|
|
70532
|
+
"src/util/platform/claude-desktop.ts"() {
|
|
70533
|
+
"use strict";
|
|
70534
|
+
}
|
|
70535
|
+
});
|
|
70536
|
+
|
|
70537
|
+
// src/util/platform/macos.ts
|
|
70538
|
+
import { isAbsolute as isAbsolute6, join as join13 } from "node:path";
|
|
70539
|
+
var macosPlatform;
|
|
70540
|
+
var init_macos = __esm({
|
|
70541
|
+
"src/util/platform/macos.ts"() {
|
|
70542
|
+
"use strict";
|
|
70543
|
+
init_claude_desktop();
|
|
70544
|
+
init_posix();
|
|
70545
|
+
macosPlatform = {
|
|
70546
|
+
...posixOperations,
|
|
70547
|
+
claudeCodeExecutablePaths: (environment) => {
|
|
70548
|
+
const paths = ["/opt/homebrew/bin/claude", "/usr/local/bin/claude"];
|
|
70549
|
+
const homeDirectory = environment["HOME"];
|
|
70550
|
+
if (homeDirectory !== void 0 && isAbsolute6(homeDirectory)) {
|
|
70551
|
+
paths.unshift(join13(homeDirectory, ".local", "bin", "claude"));
|
|
70552
|
+
paths.push(
|
|
70553
|
+
...claudeDesktopExecutablePaths(
|
|
70554
|
+
[join13(homeDirectory, "Library", "Application Support", "Claude", "claude-code")],
|
|
70555
|
+
[["claude.app", "Contents", "MacOS", "claude"], ["claude"]]
|
|
70556
|
+
)
|
|
70557
|
+
);
|
|
70558
|
+
}
|
|
70559
|
+
return paths;
|
|
70560
|
+
}
|
|
70561
|
+
};
|
|
70562
|
+
}
|
|
70563
|
+
});
|
|
70564
|
+
|
|
70565
|
+
// src/util/platform/windows.ts
|
|
70566
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
70567
|
+
import { isAbsolute as isAbsolute7, join as join14 } from "node:path";
|
|
70568
|
+
import { promisify as promisify2 } from "node:util";
|
|
70569
|
+
function environmentValue(environment, name2) {
|
|
70570
|
+
return Object.entries(environment).find(([key]) => key.toUpperCase() === name2.toUpperCase())?.[1];
|
|
70571
|
+
}
|
|
70572
|
+
function desktopClaudeExecutablePaths(environment) {
|
|
70573
|
+
const roots = [];
|
|
70574
|
+
const localAppData = environmentValue(environment, "LOCALAPPDATA");
|
|
70575
|
+
if (localAppData !== void 0 && isAbsolute7(localAppData)) {
|
|
70576
|
+
const dataDirectory = join14(localAppData, "Claude-Data");
|
|
70577
|
+
for (const installation of installedDirectories(dataDirectory)) {
|
|
70578
|
+
if (installation.startsWith("claude_")) {
|
|
70579
|
+
roots.push(join14(dataDirectory, installation, "claude-code"));
|
|
70580
|
+
}
|
|
70581
|
+
}
|
|
70582
|
+
}
|
|
70583
|
+
const appData = environmentValue(environment, "APPDATA");
|
|
70584
|
+
if (appData !== void 0 && isAbsolute7(appData)) {
|
|
70585
|
+
roots.push(join14(appData, "Claude", "claude-code"));
|
|
70586
|
+
}
|
|
70587
|
+
return claudeDesktopExecutablePaths(roots, [["claude.exe"]]);
|
|
70588
|
+
}
|
|
70589
|
+
async function validatePathPermissions(path8, _directory, privateAccess, signal) {
|
|
70590
|
+
signal.throwIfAborted();
|
|
70591
|
+
const systemRoot = environmentValue(process.env, "SystemRoot");
|
|
70592
|
+
if (systemRoot === void 0) {
|
|
70593
|
+
throw new LocalPathError("Windows system directory is unavailable");
|
|
70594
|
+
}
|
|
70595
|
+
try {
|
|
70596
|
+
await execute(
|
|
70597
|
+
join14(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
70598
|
+
[
|
|
70599
|
+
"-NoLogo",
|
|
70600
|
+
"-NoProfile",
|
|
70601
|
+
"-NonInteractive",
|
|
70602
|
+
"-EncodedCommand",
|
|
70603
|
+
Buffer.from(windowsPermissions, "utf16le").toString("base64")
|
|
70604
|
+
],
|
|
70605
|
+
{
|
|
70606
|
+
env: {
|
|
70607
|
+
...process.env,
|
|
70608
|
+
MOBIUS_PERMISSION_PATH: path8,
|
|
70609
|
+
MOBIUS_PERMISSION_PRIVATE: privateAccess ? "1" : "0"
|
|
70610
|
+
},
|
|
70611
|
+
windowsHide: true,
|
|
70612
|
+
signal: AbortSignal.any([signal, AbortSignal.timeout(windowsPermissionsTimeoutMs)]),
|
|
70613
|
+
timeout: windowsPermissionsTimeoutMs,
|
|
70614
|
+
maxBuffer: 16384
|
|
70615
|
+
}
|
|
70616
|
+
);
|
|
70617
|
+
} catch (cause) {
|
|
70618
|
+
signal.throwIfAborted();
|
|
70619
|
+
throw new LocalPathError("The local path permissions could not be secured", { cause });
|
|
70620
|
+
}
|
|
70621
|
+
}
|
|
70622
|
+
var execute, windowsPermissions, windowsPermissionsTimeoutMs, windowsPlatform;
|
|
70623
|
+
var init_windows = __esm({
|
|
70624
|
+
"src/util/platform/windows.ts"() {
|
|
70625
|
+
"use strict";
|
|
70626
|
+
init_path_error();
|
|
70627
|
+
init_claude_desktop();
|
|
70628
|
+
execute = promisify2(execFile2);
|
|
70629
|
+
windowsPermissions = `
|
|
70630
|
+
$ErrorActionPreference = 'Stop'
|
|
70631
|
+
$ProgressPreference = 'SilentlyContinue'
|
|
70632
|
+
$item = Get-Item -LiteralPath $env:MOBIUS_PERMISSION_PATH -Force
|
|
70633
|
+
if (($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0) { throw 'Unsafe path' }
|
|
70634
|
+
$sid = [Security.Principal.WindowsIdentity]::GetCurrent().User
|
|
70635
|
+
$acl = $item.GetAccessControl()
|
|
70636
|
+
$owner = $acl.GetOwner([Security.Principal.SecurityIdentifier])
|
|
70637
|
+
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' }
|
|
70638
|
+
if ($env:MOBIUS_PERMISSION_PRIVATE -eq '1') {
|
|
70639
|
+
if ($item.PSIsContainer) {
|
|
70640
|
+
$private = New-Object Security.AccessControl.DirectorySecurity
|
|
70641
|
+
$rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'ContainerInherit,ObjectInherit', 'None', 'Allow')
|
|
70642
|
+
} else {
|
|
70643
|
+
$private = New-Object Security.AccessControl.FileSecurity
|
|
70644
|
+
$rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'Allow')
|
|
70645
|
+
}
|
|
70646
|
+
$private.SetOwner($sid)
|
|
70647
|
+
$private.SetAccessRuleProtection($true, $false)
|
|
70648
|
+
$private.AddAccessRule($rule)
|
|
70649
|
+
$item.SetAccessControl($private)
|
|
70650
|
+
}
|
|
70651
|
+
`;
|
|
70652
|
+
windowsPermissionsTimeoutMs = 3e4;
|
|
70653
|
+
windowsPlatform = {
|
|
70654
|
+
controlSocketPath: (installationHash) => `\\\\.\\pipe\\mobius-${installationHash}`,
|
|
70655
|
+
prepareControlSocket: async () => {
|
|
70656
|
+
},
|
|
70657
|
+
secureControlSocket: async () => {
|
|
70658
|
+
},
|
|
70659
|
+
removeControlSocket: async () => {
|
|
70660
|
+
},
|
|
70661
|
+
validatePathPermissions,
|
|
70662
|
+
claudeCodeExecutablePaths: (environment) => {
|
|
70663
|
+
const paths = [];
|
|
70664
|
+
const userProfile = environmentValue(environment, "USERPROFILE");
|
|
70665
|
+
if (userProfile !== void 0 && isAbsolute7(userProfile)) {
|
|
70666
|
+
paths.push(join14(userProfile, ".local", "bin", "claude.exe"));
|
|
70667
|
+
}
|
|
70668
|
+
const localAppData = environmentValue(environment, "LOCALAPPDATA");
|
|
70669
|
+
if (localAppData !== void 0 && isAbsolute7(localAppData)) {
|
|
70670
|
+
paths.push(join14(localAppData, "Microsoft", "WinGet", "Links", "claude.exe"));
|
|
70671
|
+
}
|
|
70672
|
+
paths.push(...desktopClaudeExecutablePaths(environment));
|
|
70673
|
+
return paths;
|
|
70674
|
+
}
|
|
70675
|
+
};
|
|
70676
|
+
}
|
|
70677
|
+
});
|
|
70678
|
+
|
|
70679
|
+
// src/util/platform/index.ts
|
|
70680
|
+
function platformSupportFor(platform2) {
|
|
70681
|
+
return platforms.get(platform2) ?? fallbackPlatform;
|
|
70682
|
+
}
|
|
70683
|
+
var fallbackPlatform, platforms;
|
|
70684
|
+
var init_platform = __esm({
|
|
70685
|
+
"src/util/platform/index.ts"() {
|
|
70686
|
+
"use strict";
|
|
70687
|
+
init_linux();
|
|
70688
|
+
init_macos();
|
|
70689
|
+
init_posix();
|
|
70690
|
+
init_windows();
|
|
70691
|
+
fallbackPlatform = {
|
|
70692
|
+
...posixOperations,
|
|
70693
|
+
claudeCodeExecutablePaths: () => []
|
|
70694
|
+
};
|
|
70695
|
+
platforms = /* @__PURE__ */ new Map([
|
|
70696
|
+
["linux", linuxPlatform],
|
|
70697
|
+
["darwin", macosPlatform],
|
|
70698
|
+
["win32", windowsPlatform]
|
|
70699
|
+
]);
|
|
70700
|
+
}
|
|
70701
|
+
});
|
|
70702
|
+
|
|
70703
|
+
// src/util/process/platform/posix.ts
|
|
70704
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
70705
|
+
import { constants as constants3 } from "node:fs";
|
|
70706
|
+
import { access as access2, realpath as realpath3 } from "node:fs/promises";
|
|
70448
70707
|
function parseProcessTable(output2) {
|
|
70449
70708
|
const entries = [];
|
|
70450
70709
|
for (const line of output2.split("\n")) {
|
|
@@ -70464,7 +70723,7 @@ function parseProcessTable(output2) {
|
|
|
70464
70723
|
}
|
|
70465
70724
|
function readProcessTableWithPs(executable) {
|
|
70466
70725
|
return new Promise((resolveTable) => {
|
|
70467
|
-
|
|
70726
|
+
execFile3(
|
|
70468
70727
|
executable,
|
|
70469
70728
|
["-axo", "pid=,ppid=,pgid="],
|
|
70470
70729
|
{
|
|
@@ -70522,29 +70781,13 @@ function terminateProcess(child, signal) {
|
|
|
70522
70781
|
}
|
|
70523
70782
|
child.kill(signal);
|
|
70524
70783
|
}
|
|
70525
|
-
|
|
70526
|
-
|
|
70527
|
-
|
|
70528
|
-
} catch (cause) {
|
|
70529
|
-
if (!(cause instanceof Error) || !("code" in cause) || cause.code !== "ENOENT") {
|
|
70530
|
-
throw cause;
|
|
70531
|
-
}
|
|
70532
|
-
}
|
|
70533
|
-
}
|
|
70534
|
-
var PROCESS_TABLE_TIMEOUT_MILLISECONDS, PROCESS_TABLE_OUTPUT_LIMIT_BYTES, posixOperations;
|
|
70535
|
-
var init_posix = __esm({
|
|
70536
|
-
"src/util/platform/posix.ts"() {
|
|
70784
|
+
var PROCESS_TABLE_TIMEOUT_MILLISECONDS, PROCESS_TABLE_OUTPUT_LIMIT_BYTES, posixOperations2;
|
|
70785
|
+
var init_posix2 = __esm({
|
|
70786
|
+
"src/util/process/platform/posix.ts"() {
|
|
70537
70787
|
"use strict";
|
|
70538
|
-
init_path_error();
|
|
70539
70788
|
PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
|
|
70540
70789
|
PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
|
|
70541
|
-
|
|
70542
|
-
controlSocketPath: (installationHash) => join10(tmpdir(), `mobius-${installationHash}.sock`),
|
|
70543
|
-
prepareControlSocket: removeControlSocket,
|
|
70544
|
-
secureControlSocket: async (path8) => {
|
|
70545
|
-
await chmod(path8, 384);
|
|
70546
|
-
},
|
|
70547
|
-
removeControlSocket,
|
|
70790
|
+
posixOperations2 = {
|
|
70548
70791
|
pathDelimiter: ":",
|
|
70549
70792
|
environmentValue: (environment, name2) => environment[name2],
|
|
70550
70793
|
executableExtensions: () => [""],
|
|
@@ -70556,26 +70799,15 @@ var init_posix = __esm({
|
|
|
70556
70799
|
executableLaunch: (command, args) => ({ command, arguments: args }),
|
|
70557
70800
|
spawnOptions: { detached: true, windowsHide: true },
|
|
70558
70801
|
signalCapturedProcesses,
|
|
70559
|
-
terminateProcess
|
|
70560
|
-
validatePathPermissions: async (path8, directory, privateAccess, signal) => {
|
|
70561
|
-
signal.throwIfAborted();
|
|
70562
|
-
const metadata = await lstat2(path8);
|
|
70563
|
-
if (process.getuid === void 0 || metadata.uid !== process.getuid()) {
|
|
70564
|
-
throw new LocalPathError("Path is not user-owned");
|
|
70565
|
-
}
|
|
70566
|
-
if (privateAccess) {
|
|
70567
|
-
await chmod(path8, directory ? 448 : 384);
|
|
70568
|
-
}
|
|
70569
|
-
signal.throwIfAborted();
|
|
70570
|
-
}
|
|
70802
|
+
terminateProcess
|
|
70571
70803
|
};
|
|
70572
70804
|
}
|
|
70573
70805
|
});
|
|
70574
70806
|
|
|
70575
|
-
// src/util/platform/linux.ts
|
|
70576
|
-
import { constants as constants4, readdirSync as
|
|
70807
|
+
// src/util/process/platform/linux.ts
|
|
70808
|
+
import { constants as constants4, readdirSync as readdirSync3, readFileSync as readFileSync2 } from "node:fs";
|
|
70577
70809
|
import { access as access3, readdir as readdir4, readFile as readFile4, realpath as realpath4, stat as stat4 } from "node:fs/promises";
|
|
70578
|
-
import {
|
|
70810
|
+
import { join as join15 } from "node:path";
|
|
70579
70811
|
function appendLinuxProcessTableEntry(entries, processId, encoded) {
|
|
70580
70812
|
const closingParenthesis = encoded.lastIndexOf(")");
|
|
70581
70813
|
if (!encoded.startsWith(`${processId.toString()} (`) || closingParenthesis < 0) {
|
|
@@ -70605,7 +70837,7 @@ async function readLinuxProcessTable() {
|
|
|
70605
70837
|
appendLinuxProcessTableEntry(
|
|
70606
70838
|
entries,
|
|
70607
70839
|
processId,
|
|
70608
|
-
await readFile4(
|
|
70840
|
+
await readFile4(join15("/proc", directory.name, "stat"), "utf8")
|
|
70609
70841
|
);
|
|
70610
70842
|
} catch {
|
|
70611
70843
|
}
|
|
@@ -70617,7 +70849,7 @@ async function readLinuxProcessTable() {
|
|
|
70617
70849
|
function readLinuxProcessTableSynchronously() {
|
|
70618
70850
|
const entries = [];
|
|
70619
70851
|
try {
|
|
70620
|
-
const directories =
|
|
70852
|
+
const directories = readdirSync3("/proc", { withFileTypes: true });
|
|
70621
70853
|
for (const directory of directories) {
|
|
70622
70854
|
if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
|
|
70623
70855
|
continue;
|
|
@@ -70630,7 +70862,7 @@ function readLinuxProcessTableSynchronously() {
|
|
|
70630
70862
|
appendLinuxProcessTableEntry(
|
|
70631
70863
|
entries,
|
|
70632
70864
|
processId,
|
|
70633
|
-
readFileSync2(
|
|
70865
|
+
readFileSync2(join15("/proc", directory.name, "stat"), "utf8")
|
|
70634
70866
|
);
|
|
70635
70867
|
} catch {
|
|
70636
70868
|
}
|
|
@@ -70663,7 +70895,7 @@ async function readLinuxProcessTableWithFallback() {
|
|
|
70663
70895
|
}
|
|
70664
70896
|
function processExists2(processId) {
|
|
70665
70897
|
try {
|
|
70666
|
-
const encoded = readFileSync2(
|
|
70898
|
+
const encoded = readFileSync2(join15("/proc", processId.toString(), "stat"), "utf8");
|
|
70667
70899
|
const closingParenthesis = encoded.lastIndexOf(")");
|
|
70668
70900
|
if (closingParenthesis >= 0) {
|
|
70669
70901
|
const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
|
|
@@ -70675,89 +70907,31 @@ function processExists2(processId) {
|
|
|
70675
70907
|
}
|
|
70676
70908
|
return processExists(processId);
|
|
70677
70909
|
}
|
|
70678
|
-
var
|
|
70679
|
-
var
|
|
70680
|
-
"src/util/platform/linux.ts"() {
|
|
70910
|
+
var linuxProcessPlatform;
|
|
70911
|
+
var init_linux2 = __esm({
|
|
70912
|
+
"src/util/process/platform/linux.ts"() {
|
|
70681
70913
|
"use strict";
|
|
70682
|
-
|
|
70683
|
-
|
|
70684
|
-
...
|
|
70914
|
+
init_posix2();
|
|
70915
|
+
linuxProcessPlatform = {
|
|
70916
|
+
...posixOperations2,
|
|
70685
70917
|
readProcessTable: readLinuxProcessTableWithFallback,
|
|
70686
70918
|
readProcessTableSynchronously: readLinuxProcessTableSynchronously,
|
|
70687
|
-
processExists: processExists2
|
|
70688
|
-
claudeCodeExecutablePaths: (environment) => {
|
|
70689
|
-
const homeDirectory = environment["HOME"];
|
|
70690
|
-
return homeDirectory !== void 0 && isAbsolute5(homeDirectory) ? [join11(homeDirectory, ".local", "bin", "claude")] : [];
|
|
70691
|
-
}
|
|
70919
|
+
processExists: processExists2
|
|
70692
70920
|
};
|
|
70693
70921
|
}
|
|
70694
70922
|
});
|
|
70695
70923
|
|
|
70696
|
-
// src/util/platform/
|
|
70697
|
-
|
|
70698
|
-
|
|
70699
|
-
|
|
70700
|
-
try {
|
|
70701
|
-
return readdirSync3(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
70702
|
-
} catch (cause) {
|
|
70703
|
-
if (cause instanceof Error && "code" in cause && (cause.code === "ENOENT" || cause.code === "ENOTDIR" || cause.code === "EACCES")) {
|
|
70704
|
-
return [];
|
|
70705
|
-
}
|
|
70706
|
-
throw cause;
|
|
70707
|
-
}
|
|
70708
|
-
}
|
|
70709
|
-
function claudeDesktopExecutablePaths(roots, executablePaths) {
|
|
70710
|
-
const paths = [];
|
|
70711
|
-
for (const root of roots) {
|
|
70712
|
-
const versions = installedDirectories(root).filter((version2) => /^\d+\.\d+\.\d+$/.test(version2)).toSorted((left, right) => right.localeCompare(left, "en", { numeric: true }));
|
|
70713
|
-
for (const version2 of versions) {
|
|
70714
|
-
const directory = join12(root, version2);
|
|
70715
|
-
const installations = [
|
|
70716
|
-
directory,
|
|
70717
|
-
...installedDirectories(directory).map((build) => join12(directory, build))
|
|
70718
|
-
];
|
|
70719
|
-
for (const installation of installations) {
|
|
70720
|
-
for (const executablePath of executablePaths) {
|
|
70721
|
-
paths.push(join12(installation, ...executablePath));
|
|
70722
|
-
}
|
|
70723
|
-
}
|
|
70724
|
-
}
|
|
70725
|
-
}
|
|
70726
|
-
return paths;
|
|
70727
|
-
}
|
|
70728
|
-
var init_claude_desktop = __esm({
|
|
70729
|
-
"src/util/platform/claude-desktop.ts"() {
|
|
70730
|
-
"use strict";
|
|
70731
|
-
}
|
|
70732
|
-
});
|
|
70733
|
-
|
|
70734
|
-
// src/util/platform/macos.ts
|
|
70735
|
-
import { isAbsolute as isAbsolute6, join as join13 } from "node:path";
|
|
70736
|
-
var macosPlatform;
|
|
70737
|
-
var init_macos = __esm({
|
|
70738
|
-
"src/util/platform/macos.ts"() {
|
|
70924
|
+
// src/util/process/platform/macos.ts
|
|
70925
|
+
var macosProcessPlatform;
|
|
70926
|
+
var init_macos2 = __esm({
|
|
70927
|
+
"src/util/process/platform/macos.ts"() {
|
|
70739
70928
|
"use strict";
|
|
70740
|
-
|
|
70741
|
-
|
|
70742
|
-
|
|
70743
|
-
...posixOperations,
|
|
70929
|
+
init_posix2();
|
|
70930
|
+
macosProcessPlatform = {
|
|
70931
|
+
...posixOperations2,
|
|
70744
70932
|
readProcessTable: () => readProcessTableWithPs("/bin/ps"),
|
|
70745
70933
|
readProcessTableSynchronously: () => [],
|
|
70746
|
-
processExists
|
|
70747
|
-
claudeCodeExecutablePaths: (environment) => {
|
|
70748
|
-
const paths = ["/opt/homebrew/bin/claude", "/usr/local/bin/claude"];
|
|
70749
|
-
const homeDirectory = environment["HOME"];
|
|
70750
|
-
if (homeDirectory !== void 0 && isAbsolute6(homeDirectory)) {
|
|
70751
|
-
paths.unshift(join13(homeDirectory, ".local", "bin", "claude"));
|
|
70752
|
-
paths.push(
|
|
70753
|
-
...claudeDesktopExecutablePaths(
|
|
70754
|
-
[join13(homeDirectory, "Library", "Application Support", "Claude", "claude-code")],
|
|
70755
|
-
[["claude.app", "Contents", "MacOS", "claude"], ["claude"]]
|
|
70756
|
-
)
|
|
70757
|
-
);
|
|
70758
|
-
}
|
|
70759
|
-
return paths;
|
|
70760
|
-
}
|
|
70934
|
+
processExists
|
|
70761
70935
|
};
|
|
70762
70936
|
}
|
|
70763
70937
|
});
|
|
@@ -70778,36 +70952,18 @@ var init_process_error = __esm({
|
|
|
70778
70952
|
}
|
|
70779
70953
|
});
|
|
70780
70954
|
|
|
70781
|
-
// src/util/platform/windows.ts
|
|
70782
|
-
import { execFile as
|
|
70955
|
+
// src/util/process/platform/windows.ts
|
|
70956
|
+
import { execFile as execFile4 } from "node:child_process";
|
|
70783
70957
|
import { readFile as readFile5, realpath as realpath5 } from "node:fs/promises";
|
|
70784
|
-
import { dirname as dirname7, extname,
|
|
70785
|
-
|
|
70786
|
-
function environmentValue(environment, name2) {
|
|
70958
|
+
import { dirname as dirname7, extname, join as join16, resolve as resolve8 } from "node:path";
|
|
70959
|
+
function environmentValue2(environment, name2) {
|
|
70787
70960
|
return Object.entries(environment).find(([key]) => key.toUpperCase() === name2.toUpperCase())?.[1];
|
|
70788
70961
|
}
|
|
70789
|
-
function desktopClaudeExecutablePaths(environment) {
|
|
70790
|
-
const roots = [];
|
|
70791
|
-
const localAppData = environmentValue(environment, "LOCALAPPDATA");
|
|
70792
|
-
if (localAppData !== void 0 && isAbsolute7(localAppData)) {
|
|
70793
|
-
const dataDirectory = join14(localAppData, "Claude-Data");
|
|
70794
|
-
for (const installation of installedDirectories(dataDirectory)) {
|
|
70795
|
-
if (installation.startsWith("claude_")) {
|
|
70796
|
-
roots.push(join14(dataDirectory, installation, "claude-code"));
|
|
70797
|
-
}
|
|
70798
|
-
}
|
|
70799
|
-
}
|
|
70800
|
-
const appData = environmentValue(environment, "APPDATA");
|
|
70801
|
-
if (appData !== void 0 && isAbsolute7(appData)) {
|
|
70802
|
-
roots.push(join14(appData, "Claude", "claude-code"));
|
|
70803
|
-
}
|
|
70804
|
-
return claudeDesktopExecutablePaths(roots, [["claude.exe"]]);
|
|
70805
|
-
}
|
|
70806
70962
|
function executableExtensions(executableName, environment) {
|
|
70807
70963
|
if (/\.[a-zA-Z0-9]+$/.test(executableName)) {
|
|
70808
70964
|
return [""];
|
|
70809
70965
|
}
|
|
70810
|
-
const configured =
|
|
70966
|
+
const configured = environmentValue2(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD";
|
|
70811
70967
|
const extensions = configured.split(";").map((extension) => extension.trim()).filter((extension) => extension.length > 0).map((extension) => extension.startsWith(".") ? extension : `.${extension}`);
|
|
70812
70968
|
return extensions.length > 0 ? extensions : [".EXE"];
|
|
70813
70969
|
}
|
|
@@ -70855,13 +71011,13 @@ function executableLaunch(command, args) {
|
|
|
70855
71011
|
return { command, arguments: args };
|
|
70856
71012
|
}
|
|
70857
71013
|
function readProcessTable() {
|
|
70858
|
-
const systemRoot =
|
|
71014
|
+
const systemRoot = environmentValue2(process.env, "SystemRoot");
|
|
70859
71015
|
if (systemRoot === void 0) {
|
|
70860
71016
|
return Promise.resolve([]);
|
|
70861
71017
|
}
|
|
70862
71018
|
return new Promise((resolveTable) => {
|
|
70863
|
-
|
|
70864
|
-
|
|
71019
|
+
execFile4(
|
|
71020
|
+
join16(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
70865
71021
|
[
|
|
70866
71022
|
"-NoLogo",
|
|
70867
71023
|
"-NoProfile",
|
|
@@ -70894,132 +71050,50 @@ function terminateProcess2(child, signal) {
|
|
|
70894
71050
|
}
|
|
70895
71051
|
child.kill(signal);
|
|
70896
71052
|
}
|
|
70897
|
-
|
|
70898
|
-
|
|
70899
|
-
|
|
70900
|
-
if (systemRoot === void 0) {
|
|
70901
|
-
throw new LocalPathError("Windows system directory is unavailable");
|
|
70902
|
-
}
|
|
70903
|
-
try {
|
|
70904
|
-
await execute(
|
|
70905
|
-
join14(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
70906
|
-
[
|
|
70907
|
-
"-NoLogo",
|
|
70908
|
-
"-NoProfile",
|
|
70909
|
-
"-NonInteractive",
|
|
70910
|
-
"-EncodedCommand",
|
|
70911
|
-
Buffer.from(windowsPermissions, "utf16le").toString("base64")
|
|
70912
|
-
],
|
|
70913
|
-
{
|
|
70914
|
-
env: {
|
|
70915
|
-
...process.env,
|
|
70916
|
-
MOBIUS_PERMISSION_PATH: path8,
|
|
70917
|
-
MOBIUS_PERMISSION_PRIVATE: privateAccess ? "1" : "0"
|
|
70918
|
-
},
|
|
70919
|
-
windowsHide: true,
|
|
70920
|
-
signal: AbortSignal.any([signal, AbortSignal.timeout(windowsPermissionsTimeoutMs)]),
|
|
70921
|
-
timeout: windowsPermissionsTimeoutMs,
|
|
70922
|
-
maxBuffer: 16384
|
|
70923
|
-
}
|
|
70924
|
-
);
|
|
70925
|
-
} catch (cause) {
|
|
70926
|
-
signal.throwIfAborted();
|
|
70927
|
-
throw new LocalPathError("The local path permissions could not be secured", { cause });
|
|
70928
|
-
}
|
|
70929
|
-
}
|
|
70930
|
-
var execute, windowsPermissions, windowsPermissionsTimeoutMs, windowsPlatform;
|
|
70931
|
-
var init_windows = __esm({
|
|
70932
|
-
"src/util/platform/windows.ts"() {
|
|
71053
|
+
var windowsProcessPlatform;
|
|
71054
|
+
var init_windows2 = __esm({
|
|
71055
|
+
"src/util/process/platform/windows.ts"() {
|
|
70933
71056
|
"use strict";
|
|
70934
|
-
init_path_error();
|
|
70935
71057
|
init_process_error();
|
|
70936
|
-
|
|
70937
|
-
|
|
70938
|
-
execute = promisify2(execFile3);
|
|
70939
|
-
windowsPermissions = `
|
|
70940
|
-
$ErrorActionPreference = 'Stop'
|
|
70941
|
-
$ProgressPreference = 'SilentlyContinue'
|
|
70942
|
-
$item = Get-Item -LiteralPath $env:MOBIUS_PERMISSION_PATH -Force
|
|
70943
|
-
if (($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0) { throw 'Unsafe path' }
|
|
70944
|
-
$sid = [Security.Principal.WindowsIdentity]::GetCurrent().User
|
|
70945
|
-
$acl = $item.GetAccessControl()
|
|
70946
|
-
$owner = $acl.GetOwner([Security.Principal.SecurityIdentifier])
|
|
70947
|
-
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' }
|
|
70948
|
-
if ($env:MOBIUS_PERMISSION_PRIVATE -eq '1') {
|
|
70949
|
-
if ($item.PSIsContainer) {
|
|
70950
|
-
$private = New-Object Security.AccessControl.DirectorySecurity
|
|
70951
|
-
$rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'ContainerInherit,ObjectInherit', 'None', 'Allow')
|
|
70952
|
-
} else {
|
|
70953
|
-
$private = New-Object Security.AccessControl.FileSecurity
|
|
70954
|
-
$rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'Allow')
|
|
70955
|
-
}
|
|
70956
|
-
$private.SetOwner($sid)
|
|
70957
|
-
$private.SetAccessRuleProtection($true, $false)
|
|
70958
|
-
$private.AddAccessRule($rule)
|
|
70959
|
-
$item.SetAccessControl($private)
|
|
70960
|
-
}
|
|
70961
|
-
`;
|
|
70962
|
-
windowsPermissionsTimeoutMs = 3e4;
|
|
70963
|
-
windowsPlatform = {
|
|
70964
|
-
controlSocketPath: (installationHash) => `\\\\.\\pipe\\mobius-${installationHash}`,
|
|
70965
|
-
prepareControlSocket: async () => {
|
|
70966
|
-
},
|
|
70967
|
-
secureControlSocket: async () => {
|
|
70968
|
-
},
|
|
70969
|
-
removeControlSocket: async () => {
|
|
70970
|
-
},
|
|
71058
|
+
init_posix2();
|
|
71059
|
+
windowsProcessPlatform = {
|
|
70971
71060
|
pathDelimiter: ";",
|
|
70972
|
-
environmentValue,
|
|
71061
|
+
environmentValue: environmentValue2,
|
|
70973
71062
|
executableExtensions,
|
|
70974
71063
|
resolveExecutableTarget,
|
|
70975
71064
|
executableLaunch,
|
|
70976
71065
|
spawnOptions: { detached: false, windowsHide: true },
|
|
70977
71066
|
signalCapturedProcesses: signalCapturedProcesses2,
|
|
70978
71067
|
terminateProcess: terminateProcess2,
|
|
70979
|
-
validatePathPermissions,
|
|
70980
71068
|
readProcessTable,
|
|
70981
71069
|
readProcessTableSynchronously: () => [],
|
|
70982
|
-
processExists
|
|
70983
|
-
claudeCodeExecutablePaths: (environment) => {
|
|
70984
|
-
const paths = [];
|
|
70985
|
-
const userProfile = environmentValue(environment, "USERPROFILE");
|
|
70986
|
-
if (userProfile !== void 0 && isAbsolute7(userProfile)) {
|
|
70987
|
-
paths.push(join14(userProfile, ".local", "bin", "claude.exe"));
|
|
70988
|
-
}
|
|
70989
|
-
const localAppData = environmentValue(environment, "LOCALAPPDATA");
|
|
70990
|
-
if (localAppData !== void 0 && isAbsolute7(localAppData)) {
|
|
70991
|
-
paths.push(join14(localAppData, "Microsoft", "WinGet", "Links", "claude.exe"));
|
|
70992
|
-
}
|
|
70993
|
-
paths.push(...desktopClaudeExecutablePaths(environment));
|
|
70994
|
-
return paths;
|
|
70995
|
-
}
|
|
71070
|
+
processExists
|
|
70996
71071
|
};
|
|
70997
71072
|
}
|
|
70998
71073
|
});
|
|
70999
71074
|
|
|
71000
|
-
// src/util/platform/index.ts
|
|
71001
|
-
function
|
|
71002
|
-
return
|
|
71075
|
+
// src/util/process/platform/index.ts
|
|
71076
|
+
function processPlatformSupportFor(platform2) {
|
|
71077
|
+
return platforms2.get(platform2) ?? fallbackPlatform2;
|
|
71003
71078
|
}
|
|
71004
|
-
var
|
|
71005
|
-
var
|
|
71006
|
-
"src/util/platform/index.ts"() {
|
|
71079
|
+
var fallbackPlatform2, platforms2;
|
|
71080
|
+
var init_platform2 = __esm({
|
|
71081
|
+
"src/util/process/platform/index.ts"() {
|
|
71007
71082
|
"use strict";
|
|
71008
|
-
|
|
71009
|
-
|
|
71010
|
-
|
|
71011
|
-
|
|
71012
|
-
|
|
71013
|
-
...
|
|
71083
|
+
init_linux2();
|
|
71084
|
+
init_macos2();
|
|
71085
|
+
init_posix2();
|
|
71086
|
+
init_windows2();
|
|
71087
|
+
fallbackPlatform2 = {
|
|
71088
|
+
...posixOperations2,
|
|
71014
71089
|
readProcessTable: () => readProcessTableWithPs("/usr/bin/ps"),
|
|
71015
71090
|
readProcessTableSynchronously: () => [],
|
|
71016
|
-
processExists
|
|
71017
|
-
claudeCodeExecutablePaths: () => []
|
|
71091
|
+
processExists
|
|
71018
71092
|
};
|
|
71019
|
-
|
|
71020
|
-
["linux",
|
|
71021
|
-
["darwin",
|
|
71022
|
-
["win32",
|
|
71093
|
+
platforms2 = /* @__PURE__ */ new Map([
|
|
71094
|
+
["linux", linuxProcessPlatform],
|
|
71095
|
+
["darwin", macosProcessPlatform],
|
|
71096
|
+
["win32", windowsProcessPlatform]
|
|
71023
71097
|
]);
|
|
71024
71098
|
}
|
|
71025
71099
|
});
|
|
@@ -71027,11 +71101,11 @@ var init_platform = __esm({
|
|
|
71027
71101
|
// src/util/process/executable.ts
|
|
71028
71102
|
import { spawn as spawn3 } from "node:child_process";
|
|
71029
71103
|
import { stat as stat5 } from "node:fs/promises";
|
|
71030
|
-
import { join as
|
|
71104
|
+
import { join as join17, resolve as resolve9 } from "node:path";
|
|
71031
71105
|
async function resolveExecutablePath(requestedPath2, platform2 = process.platform) {
|
|
71032
71106
|
const absoluteRequestedPath = resolve9(requestedPath2);
|
|
71033
71107
|
try {
|
|
71034
|
-
const resolvedPath = await
|
|
71108
|
+
const resolvedPath = await processPlatformSupportFor(platform2).resolveExecutableTarget(absoluteRequestedPath);
|
|
71035
71109
|
const metadata = await stat5(resolvedPath);
|
|
71036
71110
|
if (!metadata.isFile()) {
|
|
71037
71111
|
return null;
|
|
@@ -71051,7 +71125,7 @@ async function resolveExecutablePath(requestedPath2, platform2 = process.platfor
|
|
|
71051
71125
|
}
|
|
71052
71126
|
}
|
|
71053
71127
|
async function findExecutableOnPath(executableName, environment, platform2 = process.platform) {
|
|
71054
|
-
const support =
|
|
71128
|
+
const support = processPlatformSupportFor(platform2);
|
|
71055
71129
|
const encodedPath = support.environmentValue(environment, "PATH") ?? "";
|
|
71056
71130
|
const separator = support.pathDelimiter;
|
|
71057
71131
|
const extensions = support.executableExtensions(executableName, environment);
|
|
@@ -71060,7 +71134,7 @@ async function findExecutableOnPath(executableName, environment, platform2 = pro
|
|
|
71060
71134
|
continue;
|
|
71061
71135
|
}
|
|
71062
71136
|
for (const extension of extensions) {
|
|
71063
|
-
const requestedPath2 = resolve9(
|
|
71137
|
+
const requestedPath2 = resolve9(join17(entry, `${executableName}${extension}`));
|
|
71064
71138
|
const executable = await resolveExecutablePath(requestedPath2, platform2);
|
|
71065
71139
|
if (executable !== null) {
|
|
71066
71140
|
return executable;
|
|
@@ -71309,10 +71383,10 @@ var hostPlatform, DEFAULT_OUTPUT_LIMIT_BYTES, PROCESS_GRACEFUL_STOP_TIMEOUT_MILL
|
|
|
71309
71383
|
var init_executable = __esm({
|
|
71310
71384
|
"src/util/process/executable.ts"() {
|
|
71311
71385
|
"use strict";
|
|
71312
|
-
|
|
71386
|
+
init_platform2();
|
|
71313
71387
|
init_process_error();
|
|
71314
71388
|
init_process_error();
|
|
71315
|
-
hostPlatform =
|
|
71389
|
+
hostPlatform = processPlatformSupportFor(process.platform);
|
|
71316
71390
|
DEFAULT_OUTPUT_LIMIT_BYTES = 16 * 1024;
|
|
71317
71391
|
PROCESS_GRACEFUL_STOP_TIMEOUT_MILLISECONDS = 1e3;
|
|
71318
71392
|
PROCESS_FORCED_STOP_TIMEOUT_MILLISECONDS = 5e3;
|
|
@@ -73958,7 +74032,7 @@ function decodeZodValue(value, schema) {
|
|
|
73958
74032
|
function encodeZodMessage(message, schema) {
|
|
73959
74033
|
return JSON.stringify(decodeZodValue(message, schema));
|
|
73960
74034
|
}
|
|
73961
|
-
var ProtocolMessageError
|
|
74035
|
+
var ProtocolMessageError;
|
|
73962
74036
|
var init_message_codec = __esm({
|
|
73963
74037
|
"../mobius-sdk/src/protocol/shared/message-codec.ts"() {
|
|
73964
74038
|
"use strict";
|
|
@@ -73971,17 +74045,6 @@ var init_message_codec = __esm({
|
|
|
73971
74045
|
this.name = "ProtocolMessageError";
|
|
73972
74046
|
}
|
|
73973
74047
|
};
|
|
73974
|
-
UnsupportedProtocolMessageKindError = class extends Error {
|
|
73975
|
-
code = "unsupported_protocol_message_kind";
|
|
73976
|
-
direction;
|
|
73977
|
-
messageKind;
|
|
73978
|
-
constructor(direction, messageKind) {
|
|
73979
|
-
super(`Unsupported ${direction} message kind: ${messageKind}`);
|
|
73980
|
-
this.name = "UnsupportedProtocolMessageKindError";
|
|
73981
|
-
this.direction = direction;
|
|
73982
|
-
this.messageKind = messageKind;
|
|
73983
|
-
}
|
|
73984
|
-
};
|
|
73985
74048
|
}
|
|
73986
74049
|
});
|
|
73987
74050
|
|
|
@@ -75278,6 +75341,86 @@ var init_native = __esm({
|
|
|
75278
75341
|
});
|
|
75279
75342
|
|
|
75280
75343
|
// ../mobius-sdk/src/protocol/session/observability/event-log.ts
|
|
75344
|
+
function isRecord4(value) {
|
|
75345
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
75346
|
+
}
|
|
75347
|
+
function hasUnknownDiscriminator(value, key, known) {
|
|
75348
|
+
if (!isRecord4(value)) {
|
|
75349
|
+
return false;
|
|
75350
|
+
}
|
|
75351
|
+
const variant = value[key];
|
|
75352
|
+
return typeof variant === "string" && !known.has(variant);
|
|
75353
|
+
}
|
|
75354
|
+
function containsUnknownContentBlock(value) {
|
|
75355
|
+
return hasUnknownDiscriminator(value, "type", knownContentBlockTypes);
|
|
75356
|
+
}
|
|
75357
|
+
function containsUnknownToolCallContent(value) {
|
|
75358
|
+
if (hasUnknownDiscriminator(value, "type", knownToolCallContentTypes)) {
|
|
75359
|
+
return true;
|
|
75360
|
+
}
|
|
75361
|
+
return isRecord4(value) && value["type"] === "content" && containsUnknownContentBlock(value["content"]);
|
|
75362
|
+
}
|
|
75363
|
+
function arrayContainsUnknown(value, predicate) {
|
|
75364
|
+
return Array.isArray(value) && value.some(predicate);
|
|
75365
|
+
}
|
|
75366
|
+
function containsUnknownAcpVariant(payload) {
|
|
75367
|
+
const update = payload["sessionUpdate"];
|
|
75368
|
+
if (typeof update !== "string") {
|
|
75369
|
+
return false;
|
|
75370
|
+
}
|
|
75371
|
+
if (!knownSessionUpdates.has(update)) {
|
|
75372
|
+
return true;
|
|
75373
|
+
}
|
|
75374
|
+
if (["user_message_chunk", "agent_message_chunk", "agent_thought_chunk", "compaction_summary_chunk"].includes(
|
|
75375
|
+
update
|
|
75376
|
+
)) {
|
|
75377
|
+
return containsUnknownContentBlock(payload["content"]);
|
|
75378
|
+
}
|
|
75379
|
+
if (update === "tool_call" || update === "tool_call_update") {
|
|
75380
|
+
return arrayContainsUnknown(payload["content"], containsUnknownToolCallContent);
|
|
75381
|
+
}
|
|
75382
|
+
if (update === "plan_update") {
|
|
75383
|
+
return hasUnknownDiscriminator(payload["plan"], "type", knownPlanTypes);
|
|
75384
|
+
}
|
|
75385
|
+
if (update === "config_option_update") {
|
|
75386
|
+
return arrayContainsUnknown(
|
|
75387
|
+
payload["configOptions"],
|
|
75388
|
+
(option) => hasUnknownDiscriminator(option, "type", knownConfigOptionTypes)
|
|
75389
|
+
);
|
|
75390
|
+
}
|
|
75391
|
+
if (update === "compaction_update") {
|
|
75392
|
+
return arrayContainsUnknown(payload["summary"], containsUnknownContentBlock);
|
|
75393
|
+
}
|
|
75394
|
+
return false;
|
|
75395
|
+
}
|
|
75396
|
+
function isKnownSessionEventVariant(value) {
|
|
75397
|
+
if (!isRecord4(value)) {
|
|
75398
|
+
return true;
|
|
75399
|
+
}
|
|
75400
|
+
const type = value["type"];
|
|
75401
|
+
if (typeof type !== "string") {
|
|
75402
|
+
return true;
|
|
75403
|
+
}
|
|
75404
|
+
if (type === "acp") {
|
|
75405
|
+
const payload = value["payload"];
|
|
75406
|
+
return !isRecord4(payload) || !containsUnknownAcpVariant(payload);
|
|
75407
|
+
}
|
|
75408
|
+
if (type === "lifecycle-metadata") {
|
|
75409
|
+
const payload = value["payload"];
|
|
75410
|
+
if (!isRecord4(payload)) {
|
|
75411
|
+
return true;
|
|
75412
|
+
}
|
|
75413
|
+
const kind = payload["kind"];
|
|
75414
|
+
if (typeof kind === "string" && !knownLifecycleKinds.has(kind)) {
|
|
75415
|
+
return false;
|
|
75416
|
+
}
|
|
75417
|
+
return kind !== "prompt.requested" || !arrayContainsUnknown(payload["content"], containsUnknownContentBlock);
|
|
75418
|
+
}
|
|
75419
|
+
return false;
|
|
75420
|
+
}
|
|
75421
|
+
function filterKnownSessionEventVariants(events) {
|
|
75422
|
+
return Array.isArray(events) ? events.filter(isKnownSessionEventVariant) : events;
|
|
75423
|
+
}
|
|
75281
75424
|
function inputValue(value) {
|
|
75282
75425
|
if (typeof value !== "string") {
|
|
75283
75426
|
return value;
|
|
@@ -75300,7 +75443,22 @@ function decode4(value, schema) {
|
|
|
75300
75443
|
function encode3(value, schema) {
|
|
75301
75444
|
return JSON.stringify(decode4(value, schema));
|
|
75302
75445
|
}
|
|
75303
|
-
|
|
75446
|
+
function sanitizeKnownNativeSessionEvents(value) {
|
|
75447
|
+
const input2 = inputValue(value);
|
|
75448
|
+
if (!isRecord4(input2)) {
|
|
75449
|
+
return input2;
|
|
75450
|
+
}
|
|
75451
|
+
const page = input2["events"];
|
|
75452
|
+
const queuedPromptRequests = input2["queuedPromptRequests"];
|
|
75453
|
+
return {
|
|
75454
|
+
...input2,
|
|
75455
|
+
events: isRecord4(page) ? { ...page, events: filterKnownSessionEventVariants(page["events"]) } : page,
|
|
75456
|
+
queuedPromptRequests: Array.isArray(queuedPromptRequests) ? queuedPromptRequests.filter(
|
|
75457
|
+
(prompt) => !isRecord4(prompt) || !arrayContainsUnknown(prompt["content"], containsUnknownContentBlock)
|
|
75458
|
+
) : queuedPromptRequests
|
|
75459
|
+
};
|
|
75460
|
+
}
|
|
75461
|
+
var MAX_EVENT_COUNT, MAX_COLLECTION_SIZE2, MAX_CONTENT_LENGTH2, SESSION_EVENT_KIND, SESSION_EVENT_BATCH_MAX_SIZE, boundedString2, shortString, externalContentKeySchema, annotationsSchema, contentFields, textContentSchema, imageContentSchema, audioContentSchema, externalImageContentSchema, externalAudioContentSchema, externalResourceContentSchema, resourceLinkSchema, textResourceSchema, blobResourceSchema, embeddedResourceSchema, contentBlockSchema, toolCallContentSchema, toolKindSchema, toolStatusSchema, backgroundTaskSchema, toolPatchFields, planEntrySchema, planContentSchema, commandSchema, configSelectOptionSchema, configSelectGroupSchema, configBaseFields, sessionConfigOptionSchema2, contentChunkFields, acpSessionUpdateSchema, lifecycleBase, promptExecutionContextSchema, lifecycleMetadataSchema, sessionEventPayloadSchema, positionSchema, sharedSessionEventFields, sessionLiveEventFields, sessionEventSchema, sessionLiveEventSchema, wireLifecyclePayloadSchema, wireEventFields, sessionWireEventSchema, sessionWireEnvelopeSchema, knownContentBlockTypes, knownToolCallContentTypes, knownPlanTypes, knownConfigOptionTypes, knownSessionUpdates, knownLifecycleKinds, sessionEventBatchSchema, sessionLiveEventBatchSchema, sessionExportSchema, mobiusSessionExportSchema, sessionEventEnvelopeSchema, sessionEventLogPageSchema, sessionEventOmissionSchema, nativeEventPageRequestSchema, queuedPromptRequestEventLogSchema, nativeSessionEventsSchema, knownSessionLiveEventBatchSchema, decodeSessionEvent, decodeKnownSessionEventPayload, decodeSessionEventEnvelope, encodeSessionEventEnvelope, decodeAcpSessionUpdate, decodeKnownNativeSessionEvents;
|
|
75304
75462
|
var init_event_log = __esm({
|
|
75305
75463
|
"../mobius-sdk/src/protocol/session/observability/event-log.ts"() {
|
|
75306
75464
|
"use strict";
|
|
@@ -75642,7 +75800,49 @@ var init_event_log = __esm({
|
|
|
75642
75800
|
sessionWireEnvelopeSchema = external_exports.object({
|
|
75643
75801
|
kind: external_exports.literal(SESSION_EVENT_KIND),
|
|
75644
75802
|
events: external_exports.array(sessionWireEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly()
|
|
75645
|
-
}).readonly();
|
|
75803
|
+
}).passthrough().readonly();
|
|
75804
|
+
knownContentBlockTypes = /* @__PURE__ */ new Set([
|
|
75805
|
+
"text",
|
|
75806
|
+
"image",
|
|
75807
|
+
"audio",
|
|
75808
|
+
"resource_link",
|
|
75809
|
+
"resource",
|
|
75810
|
+
"external_image",
|
|
75811
|
+
"external_audio",
|
|
75812
|
+
"external_resource"
|
|
75813
|
+
]);
|
|
75814
|
+
knownToolCallContentTypes = /* @__PURE__ */ new Set(["content", "diff", "terminal"]);
|
|
75815
|
+
knownPlanTypes = /* @__PURE__ */ new Set(["items", "file", "markdown"]);
|
|
75816
|
+
knownConfigOptionTypes = /* @__PURE__ */ new Set(["select", "boolean"]);
|
|
75817
|
+
knownSessionUpdates = /* @__PURE__ */ new Set([
|
|
75818
|
+
"user_message_chunk",
|
|
75819
|
+
"agent_message_chunk",
|
|
75820
|
+
"agent_thought_chunk",
|
|
75821
|
+
"tool_call",
|
|
75822
|
+
"tool_call_update",
|
|
75823
|
+
"plan",
|
|
75824
|
+
"plan_update",
|
|
75825
|
+
"plan_removed",
|
|
75826
|
+
"available_commands_update",
|
|
75827
|
+
"current_mode_update",
|
|
75828
|
+
"config_option_update",
|
|
75829
|
+
"session_info_update",
|
|
75830
|
+
"usage_update",
|
|
75831
|
+
"compaction_update",
|
|
75832
|
+
"compaction_summary_chunk"
|
|
75833
|
+
]);
|
|
75834
|
+
knownLifecycleKinds = /* @__PURE__ */ new Set([
|
|
75835
|
+
"session.queue.changed",
|
|
75836
|
+
"session.permission.requested",
|
|
75837
|
+
"session.permission.resolved",
|
|
75838
|
+
"session.elicitation.requested",
|
|
75839
|
+
"session.elicitation.resolved",
|
|
75840
|
+
"prompt.requested",
|
|
75841
|
+
"prompt.started",
|
|
75842
|
+
"prompt.completed",
|
|
75843
|
+
"prompt.failed-before-start",
|
|
75844
|
+
"prompt.failed"
|
|
75845
|
+
]);
|
|
75646
75846
|
sessionEventBatchSchema = external_exports.array(sessionEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
75647
75847
|
sessionLiveEventBatchSchema = external_exports.array(sessionLiveEventSchema).min(1).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
75648
75848
|
sessionExportSchema = external_exports.object({
|
|
@@ -75706,10 +75906,13 @@ var init_event_log = __esm({
|
|
|
75706
75906
|
events: sessionEventLogPageSchema,
|
|
75707
75907
|
queuedPromptRequests: external_exports.array(queuedPromptRequestEventLogSchema).max(MAX_COLLECTION_SIZE2).readonly()
|
|
75708
75908
|
}).readonly();
|
|
75909
|
+
knownSessionLiveEventBatchSchema = external_exports.array(sessionLiveEventSchema).max(SESSION_EVENT_BATCH_MAX_SIZE).readonly();
|
|
75709
75910
|
decodeSessionEvent = (value) => decode4(value, sessionEventSchema);
|
|
75911
|
+
decodeKnownSessionEventPayload = (value) => isKnownSessionEventVariant(value) ? decode4(value, sessionEventPayloadSchema) : null;
|
|
75710
75912
|
decodeSessionEventEnvelope = (value) => decode4(value, sessionEventEnvelopeSchema);
|
|
75711
75913
|
encodeSessionEventEnvelope = (value) => encode3(value, sessionEventEnvelopeSchema);
|
|
75712
75914
|
decodeAcpSessionUpdate = (value) => decode4(value, acpSessionUpdateSchema);
|
|
75915
|
+
decodeKnownNativeSessionEvents = (value) => decode4(sanitizeKnownNativeSessionEvents(value), nativeSessionEventsSchema);
|
|
75713
75916
|
}
|
|
75714
75917
|
});
|
|
75715
75918
|
|
|
@@ -75722,7 +75925,18 @@ function decode5(schema, encoded) {
|
|
|
75722
75925
|
throw new ProtocolMessageError("Invalid live Session history message", { cause });
|
|
75723
75926
|
}
|
|
75724
75927
|
}
|
|
75725
|
-
|
|
75928
|
+
function decodeLoaded(schema, encoded) {
|
|
75929
|
+
try {
|
|
75930
|
+
const value = JSON.parse(encoded);
|
|
75931
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
75932
|
+
return schema.parse(value);
|
|
75933
|
+
}
|
|
75934
|
+
return schema.parse({ ...value, events: decodeKnownNativeSessionEvents(Reflect.get(value, "events")) });
|
|
75935
|
+
} catch (cause) {
|
|
75936
|
+
throw new ProtocolMessageError("Invalid live Session history message", { cause });
|
|
75937
|
+
}
|
|
75938
|
+
}
|
|
75939
|
+
var SESSION_HISTORY_PAGE_LOAD_KIND, SESSION_HISTORY_PAGE_LOADED_KIND, SESSION_PREVIEW_HISTORY_PAGE_LOAD_KIND, SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND, pageRequestFields, sessionHistoryPageLoadSchema, sessionPreviewHistoryPageLoadSchema, pageLoadedFields, sessionHistoryPageLoadedSchema, sessionPreviewHistoryPageLoadedSchema, wireNativeSessionEventsSchema, sessionHistoryWirePageLoadedSchema, sessionPreviewHistoryWirePageLoadedSchema, decodeSessionHistoryPageLoad, decodeSessionHistoryPageLoaded, decodeSessionPreviewHistoryPageLoad, decodeSessionPreviewHistoryPageLoaded, encodeSessionHistoryPageLoad, encodeSessionHistoryPageLoaded, encodeSessionPreviewHistoryPageLoad, encodeSessionPreviewHistoryPageLoaded;
|
|
75726
75940
|
var init_history2 = __esm({
|
|
75727
75941
|
"../mobius-sdk/src/protocol/session/observability/history.ts"() {
|
|
75728
75942
|
"use strict";
|
|
@@ -75759,10 +75973,34 @@ var init_history2 = __esm({
|
|
|
75759
75973
|
};
|
|
75760
75974
|
sessionHistoryPageLoadedSchema = external_exports.object({ ...pageLoadedFields, kind: external_exports.literal(SESSION_HISTORY_PAGE_LOADED_KIND) }).readonly();
|
|
75761
75975
|
sessionPreviewHistoryPageLoadedSchema = external_exports.object({ ...pageLoadedFields, kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND) }).readonly();
|
|
75976
|
+
wireNativeSessionEventsSchema = external_exports.object({
|
|
75977
|
+
events: external_exports.object({
|
|
75978
|
+
events: external_exports.array(external_exports.unknown()).max(1e4).readonly(),
|
|
75979
|
+
nextCursor: external_exports.string().min(1).max(512).nullable(),
|
|
75980
|
+
sessionGenerationId: identifierStringSchema,
|
|
75981
|
+
tailCursor: external_exports.string().max(512),
|
|
75982
|
+
throughPosition: external_exports.string().regex(/^(0|[1-9][0-9]*)$/u).optional(),
|
|
75983
|
+
truncated: external_exports.boolean(),
|
|
75984
|
+
version: external_exports.literal(2)
|
|
75985
|
+
}).passthrough().readonly(),
|
|
75986
|
+
queuedPromptRequests: external_exports.array(external_exports.unknown()).max(1e3).readonly()
|
|
75987
|
+
}).passthrough().readonly();
|
|
75988
|
+
sessionHistoryWirePageLoadedSchema = external_exports.object({
|
|
75989
|
+
events: wireNativeSessionEventsSchema,
|
|
75990
|
+
kind: external_exports.literal(SESSION_HISTORY_PAGE_LOADED_KIND),
|
|
75991
|
+
requestId: identifierStringSchema,
|
|
75992
|
+
sessionId: identifierStringSchema
|
|
75993
|
+
}).passthrough().readonly();
|
|
75994
|
+
sessionPreviewHistoryWirePageLoadedSchema = external_exports.object({
|
|
75995
|
+
events: wireNativeSessionEventsSchema,
|
|
75996
|
+
kind: external_exports.literal(SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND),
|
|
75997
|
+
requestId: identifierStringSchema,
|
|
75998
|
+
sessionId: identifierStringSchema
|
|
75999
|
+
}).passthrough().readonly();
|
|
75762
76000
|
decodeSessionHistoryPageLoad = (encoded) => decode5(sessionHistoryPageLoadSchema, encoded);
|
|
75763
|
-
decodeSessionHistoryPageLoaded = (encoded) =>
|
|
76001
|
+
decodeSessionHistoryPageLoaded = (encoded) => decodeLoaded(sessionHistoryPageLoadedSchema, encoded);
|
|
75764
76002
|
decodeSessionPreviewHistoryPageLoad = (encoded) => decode5(sessionPreviewHistoryPageLoadSchema, encoded);
|
|
75765
|
-
decodeSessionPreviewHistoryPageLoaded = (encoded) =>
|
|
76003
|
+
decodeSessionPreviewHistoryPageLoaded = (encoded) => decodeLoaded(sessionPreviewHistoryPageLoadedSchema, encoded);
|
|
75766
76004
|
encodeSessionHistoryPageLoad = (value) => JSON.stringify(sessionHistoryPageLoadSchema.parse(value));
|
|
75767
76005
|
encodeSessionHistoryPageLoaded = (value) => JSON.stringify(sessionHistoryPageLoadedSchema.parse(value));
|
|
75768
76006
|
encodeSessionPreviewHistoryPageLoad = (value) => JSON.stringify(sessionPreviewHistoryPageLoadSchema.parse(value));
|
|
@@ -76094,7 +76332,7 @@ var init_turn_history = __esm({
|
|
|
76094
76332
|
});
|
|
76095
76333
|
|
|
76096
76334
|
// ../mobius-sdk/src/protocol/session/recording/webhooks.ts
|
|
76097
|
-
var isoTimestamp2, shortText2, promptSucceededOutcome2, promptCancelledOutcome2, promptFailedOutcome2, sessionStatusWebhookCommandSchema, sessionStatusWebhookBodySchema;
|
|
76335
|
+
var isoTimestamp2, shortText2, promptSucceededOutcome2, promptCancelledOutcome2, promptFailedOutcome2, sessionStatusWebhookCommandSchema, sessionStatusWebhookBodyFields, sessionStatusWebhookBodySchema, consumedSessionStatusWebhookBodySchema;
|
|
76098
76336
|
var init_webhooks = __esm({
|
|
76099
76337
|
"../mobius-sdk/src/protocol/session/recording/webhooks.ts"() {
|
|
76100
76338
|
"use strict";
|
|
@@ -76127,13 +76365,20 @@ var init_webhooks = __esm({
|
|
|
76127
76365
|
outcome: external_exports.literal("failed")
|
|
76128
76366
|
}).readonly()
|
|
76129
76367
|
]);
|
|
76130
|
-
|
|
76368
|
+
sessionStatusWebhookBodyFields = {
|
|
76131
76369
|
appId: identifierStringSchema,
|
|
76132
|
-
commands: external_exports.array(sessionStatusWebhookCommandSchema).min(1).readonly(),
|
|
76133
76370
|
projectId: identifierStringSchema,
|
|
76134
76371
|
runtimeId: identifierStringSchema,
|
|
76135
76372
|
sessionId: identifierStringSchema,
|
|
76136
76373
|
status: sessionRecordingStatusSchema
|
|
76374
|
+
};
|
|
76375
|
+
sessionStatusWebhookBodySchema = external_exports.object({
|
|
76376
|
+
...sessionStatusWebhookBodyFields,
|
|
76377
|
+
commands: external_exports.array(sessionStatusWebhookCommandSchema).min(1).readonly()
|
|
76378
|
+
}).readonly();
|
|
76379
|
+
consumedSessionStatusWebhookBodySchema = external_exports.object({
|
|
76380
|
+
...sessionStatusWebhookBodyFields,
|
|
76381
|
+
commands: external_exports.array(sessionStatusWebhookCommandSchema).readonly()
|
|
76137
76382
|
}).readonly();
|
|
76138
76383
|
}
|
|
76139
76384
|
});
|
|
@@ -76251,18 +76496,32 @@ function defineMessageSignature(kind, encoder, decoder) {
|
|
|
76251
76496
|
schema
|
|
76252
76497
|
};
|
|
76253
76498
|
}
|
|
76254
|
-
function
|
|
76499
|
+
function isRecord5(value) {
|
|
76500
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
76501
|
+
}
|
|
76502
|
+
function hasUnknownDiscriminator2(value, key, known) {
|
|
76503
|
+
if (!isRecord5(value)) {
|
|
76504
|
+
return false;
|
|
76505
|
+
}
|
|
76506
|
+
const variant = value[key];
|
|
76507
|
+
return typeof variant === "string" && !known.has(variant);
|
|
76508
|
+
}
|
|
76509
|
+
function hasUnknownServiceVariant(kind, value) {
|
|
76510
|
+
return kind === NATIVE_SESSION_REQUEST_KIND && hasUnknownDiscriminator2(value, "action", knownNativeActions);
|
|
76511
|
+
}
|
|
76512
|
+
function decodeKnownServiceToDaemonMessage(encoded) {
|
|
76255
76513
|
const kind = decodeMessageKind(encoded);
|
|
76256
76514
|
const signature = serviceToDaemonRegistry[kind];
|
|
76257
76515
|
if (signature === void 0) {
|
|
76258
|
-
|
|
76516
|
+
return null;
|
|
76259
76517
|
}
|
|
76260
|
-
|
|
76518
|
+
const value = parseJson(encoded);
|
|
76519
|
+
return hasUnknownServiceVariant(kind, value) ? null : signature.decoder(encoded);
|
|
76261
76520
|
}
|
|
76262
76521
|
function encodeDaemonToServiceMessage(message) {
|
|
76263
76522
|
return daemonToServiceSignatures[message.kind].encoder(message);
|
|
76264
76523
|
}
|
|
76265
|
-
var serviceToDaemonSignatures, serviceToDaemonRegistry, daemonToServiceSignatures;
|
|
76524
|
+
var serviceToDaemonSignatures, serviceToDaemonRegistry, knownNativeActions, daemonToServiceSignatures;
|
|
76266
76525
|
var init_daemon_transport = __esm({
|
|
76267
76526
|
"../mobius-sdk/src/protocol/transport/daemon-transport.ts"() {
|
|
76268
76527
|
"use strict";
|
|
@@ -76413,6 +76672,7 @@ var init_daemon_transport = __esm({
|
|
|
76413
76672
|
)
|
|
76414
76673
|
};
|
|
76415
76674
|
serviceToDaemonRegistry = serviceToDaemonSignatures;
|
|
76675
|
+
knownNativeActions = /* @__PURE__ */ new Set(["active-turn", "find", "list", "import", "fork"]);
|
|
76416
76676
|
daemonToServiceSignatures = {
|
|
76417
76677
|
[SESSION_CLOSED_KIND]: defineMessageSignature(
|
|
76418
76678
|
SESSION_CLOSED_KIND,
|
|
@@ -76574,7 +76834,6 @@ var init_protocol = __esm({
|
|
|
76574
76834
|
init_workspace();
|
|
76575
76835
|
init_directory();
|
|
76576
76836
|
init_identifier();
|
|
76577
|
-
init_message_codec();
|
|
76578
76837
|
init_daemon_transport();
|
|
76579
76838
|
}
|
|
76580
76839
|
});
|
|
@@ -77856,12 +78115,12 @@ var init_environment = __esm({
|
|
|
77856
78115
|
});
|
|
77857
78116
|
|
|
77858
78117
|
// src/acp/harness/pi/upstream/dist/acp/paths.js
|
|
77859
|
-
import { join as
|
|
78118
|
+
import { join as join18 } from "node:path";
|
|
77860
78119
|
function getPiAcpDir(environment = process.env) {
|
|
77861
|
-
return
|
|
78120
|
+
return join18(environmentHome(environment), ".pi", "pi-acp");
|
|
77862
78121
|
}
|
|
77863
78122
|
function getPiAcpSessionMapPath(environment = process.env) {
|
|
77864
|
-
return
|
|
78123
|
+
return join18(getPiAcpDir(environment), "session-map.json");
|
|
77865
78124
|
}
|
|
77866
78125
|
var init_paths = __esm({
|
|
77867
78126
|
"src/acp/harness/pi/upstream/dist/acp/paths.js"() {
|
|
@@ -77917,13 +78176,13 @@ var init_pi_commands = __esm({
|
|
|
77917
78176
|
|
|
77918
78177
|
// src/acp/harness/pi/upstream/dist/acp/pi-sessions.js
|
|
77919
78178
|
import { closeSync as closeSync2, existsSync as existsSync4, openSync as openSync2, readdirSync as readdirSync4, readFileSync as readFileSync3, readSync as readSync2, statSync as statSync2 } from "node:fs";
|
|
77920
|
-
import { isAbsolute as isAbsolute10, join as
|
|
78179
|
+
import { isAbsolute as isAbsolute10, join as join19, resolve as resolve10 } from "node:path";
|
|
77921
78180
|
function getPiAgentDir(environment) {
|
|
77922
78181
|
const configured = environment["PI_CODING_AGENT_DIR"];
|
|
77923
|
-
return configured ? resolve10(configured) :
|
|
78182
|
+
return configured ? resolve10(configured) : join19(environmentHome(environment), ".pi", "agent");
|
|
77924
78183
|
}
|
|
77925
78184
|
function readSessionDirFromSettings(agentDir) {
|
|
77926
|
-
const settingsPath =
|
|
78185
|
+
const settingsPath = join19(agentDir, "settings.json");
|
|
77927
78186
|
try {
|
|
77928
78187
|
if (!existsSync4(settingsPath)) {
|
|
77929
78188
|
return null;
|
|
@@ -77944,7 +78203,7 @@ function readSessionDirFromSettings(agentDir) {
|
|
|
77944
78203
|
}
|
|
77945
78204
|
function getPiSessionsDir(environment = process.env) {
|
|
77946
78205
|
const agentDir = getPiAgentDir(environment);
|
|
77947
|
-
return readSessionDirFromSettings(agentDir) ??
|
|
78206
|
+
return readSessionDirFromSettings(agentDir) ?? join19(agentDir, "sessions");
|
|
77948
78207
|
}
|
|
77949
78208
|
function getPiSessionDiscoveryDirs(environment) {
|
|
77950
78209
|
const discoveryDirectories = [getPiSessionsDir(environment)];
|
|
@@ -77955,7 +78214,7 @@ function getPiSessionDiscoveryDirs(environment) {
|
|
|
77955
78214
|
if (!entry.isDirectory()) {
|
|
77956
78215
|
continue;
|
|
77957
78216
|
}
|
|
77958
|
-
const directory =
|
|
78217
|
+
const directory = join19(mobiusSessionsRoot, entry.name);
|
|
77959
78218
|
if (!discoveryDirectories.includes(directory)) {
|
|
77960
78219
|
discoveryDirectories.push(directory);
|
|
77961
78220
|
}
|
|
@@ -77972,7 +78231,7 @@ function walkJsonlFiles(dir, out2) {
|
|
|
77972
78231
|
}
|
|
77973
78232
|
for (const e of entries) {
|
|
77974
78233
|
const name2 = typeof e.name === "string" ? e.name : String(e.name);
|
|
77975
|
-
const p =
|
|
78234
|
+
const p = join19(dir, name2);
|
|
77976
78235
|
if (e.isDirectory()) {
|
|
77977
78236
|
walkJsonlFiles(p, out2);
|
|
77978
78237
|
} else if (e.isFile() && name2.endsWith(".jsonl")) {
|
|
@@ -78250,7 +78509,7 @@ var init_pi_sessions = __esm({
|
|
|
78250
78509
|
|
|
78251
78510
|
// src/acp/harness/pi/upstream/dist/acp/pi-settings.js
|
|
78252
78511
|
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:fs";
|
|
78253
|
-
import { join as
|
|
78512
|
+
import { join as join20, resolve as resolve11 } from "node:path";
|
|
78254
78513
|
function isObject2(x) {
|
|
78255
78514
|
return Boolean(x) && typeof x === "object" && !Array.isArray(x);
|
|
78256
78515
|
}
|
|
@@ -78279,7 +78538,7 @@ function readJsonFile(path8) {
|
|
|
78279
78538
|
}
|
|
78280
78539
|
}
|
|
78281
78540
|
function getMergedSettings(cwd, environment) {
|
|
78282
|
-
const globalSettingsPath =
|
|
78541
|
+
const globalSettingsPath = join20(getAgentDir(environment), "settings.json");
|
|
78283
78542
|
const projectSettingsPath = resolve11(cwd, ".pi", "settings.json");
|
|
78284
78543
|
const global2 = readJsonFile(globalSettingsPath);
|
|
78285
78544
|
const project = readJsonFile(projectSettingsPath);
|
|
@@ -78287,7 +78546,7 @@ function getMergedSettings(cwd, environment) {
|
|
|
78287
78546
|
}
|
|
78288
78547
|
function getAgentDir(environment = process.env) {
|
|
78289
78548
|
const configured = environment["PI_CODING_AGENT_DIR"];
|
|
78290
|
-
return configured ? resolve11(configured) :
|
|
78549
|
+
return configured ? resolve11(configured) : join20(environmentHome(environment), ".pi", "agent");
|
|
78291
78550
|
}
|
|
78292
78551
|
function getEnableSkillCommands(cwd, environment = process.env) {
|
|
78293
78552
|
const merged = getMergedSettings(cwd, environment);
|
|
@@ -78557,7 +78816,7 @@ var init_session_store = __esm({
|
|
|
78557
78816
|
|
|
78558
78817
|
// src/acp/harness/pi/upstream/dist/acp/slash-commands.js
|
|
78559
78818
|
import { existsSync as existsSync6, readdirSync as readdirSync5, readFileSync as readFileSync6 } from "node:fs";
|
|
78560
|
-
import { join as
|
|
78819
|
+
import { join as join21, resolve as resolve12 } from "node:path";
|
|
78561
78820
|
function parseFrontmatter(content) {
|
|
78562
78821
|
const frontmatter = {};
|
|
78563
78822
|
if (!content.startsWith("---")) {
|
|
@@ -78585,7 +78844,7 @@ function loadCommandsFromDir(dir, source, subdir = "") {
|
|
|
78585
78844
|
try {
|
|
78586
78845
|
const entries = readdirSync5(dir, { withFileTypes: true });
|
|
78587
78846
|
for (const entry of entries) {
|
|
78588
|
-
const fullPath =
|
|
78847
|
+
const fullPath = join21(dir, entry.name);
|
|
78589
78848
|
if (entry.isDirectory()) {
|
|
78590
78849
|
const newSubdir = subdir ? `${subdir}:${entry.name}` : entry.name;
|
|
78591
78850
|
commands.push(...loadCommandsFromDir(fullPath, source, newSubdir));
|
|
@@ -78625,7 +78884,7 @@ function loadCommandsFromDir(dir, source, subdir = "") {
|
|
|
78625
78884
|
}
|
|
78626
78885
|
function loadSlashCommands(cwd, environment = process.env) {
|
|
78627
78886
|
const commands = [];
|
|
78628
|
-
const userDir =
|
|
78887
|
+
const userDir = join21(environmentHome(environment), ".pi", "agent", "prompts");
|
|
78629
78888
|
const projectDir = resolve12(cwd, ".pi", "prompts");
|
|
78630
78889
|
commands.push(...loadCommandsFromDir(userDir, "user"));
|
|
78631
78890
|
commands.push(...loadCommandsFromDir(projectDir, "project"));
|
|
@@ -79717,7 +79976,7 @@ var init_prompt = __esm({
|
|
|
79717
79976
|
import { spawnSync } from "node:child_process";
|
|
79718
79977
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
79719
79978
|
import { existsSync as existsSync7, readdirSync as readdirSync6, readFileSync as readFileSync8, realpathSync as realpathSync3, statSync as statSync3, unlinkSync as unlinkSync2 } from "node:fs";
|
|
79720
|
-
import { basename as basename6, dirname as dirname9, isAbsolute as isAbsolute12, join as
|
|
79979
|
+
import { basename as basename6, dirname as dirname9, isAbsolute as isAbsolute12, join as join22 } from "node:path";
|
|
79721
79980
|
import { RequestError as RequestError10 } from "@agentclientprotocol/sdk";
|
|
79722
79981
|
function thinkingLevelName(id) {
|
|
79723
79982
|
return id.split(/[_-]/u).map((part) => part.length === 0 ? part : `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
|
|
@@ -79992,7 +80251,7 @@ function buildStartupInfo(opts) {
|
|
|
79992
80251
|
md.push("");
|
|
79993
80252
|
};
|
|
79994
80253
|
const contextItems = [];
|
|
79995
|
-
const contextPath =
|
|
80254
|
+
const contextPath = join22(opts.cwd, "AGENTS.md");
|
|
79996
80255
|
if (existsSync7(contextPath)) {
|
|
79997
80256
|
contextItems.push(contextPath);
|
|
79998
80257
|
}
|
|
@@ -80001,7 +80260,7 @@ function buildStartupInfo(opts) {
|
|
|
80001
80260
|
const pushSkillFromRoot = (root) => {
|
|
80002
80261
|
try {
|
|
80003
80262
|
for (const e of readdirSync6(root)) {
|
|
80004
|
-
const p =
|
|
80263
|
+
const p = join22(root, e);
|
|
80005
80264
|
try {
|
|
80006
80265
|
const st2 = statSync3(p);
|
|
80007
80266
|
if (st2.isFile() && e.toLowerCase().endsWith(".md")) {
|
|
@@ -80026,7 +80285,7 @@ function buildStartupInfo(opts) {
|
|
|
80026
80285
|
if (name2 === "node_modules" || name2 === ".git") {
|
|
80027
80286
|
continue;
|
|
80028
80287
|
}
|
|
80029
|
-
const p =
|
|
80288
|
+
const p = join22(dir, name2);
|
|
80030
80289
|
let st2;
|
|
80031
80290
|
try {
|
|
80032
80291
|
st2 = statSync3(p);
|
|
@@ -80043,16 +80302,16 @@ function buildStartupInfo(opts) {
|
|
|
80043
80302
|
} catch {
|
|
80044
80303
|
}
|
|
80045
80304
|
};
|
|
80046
|
-
const globalSkillsDir =
|
|
80305
|
+
const globalSkillsDir = join22(getAgentDir(opts.environment), "skills");
|
|
80047
80306
|
pushSkillFromRoot(globalSkillsDir);
|
|
80048
80307
|
const home = opts.environment["HOME"] ?? opts.environment["USERPROFILE"] ?? "";
|
|
80049
|
-
const legacyAgentsSkillsDir =
|
|
80308
|
+
const legacyAgentsSkillsDir = join22(home, ".agents", "skills");
|
|
80050
80309
|
pushSkillFromRoot(legacyAgentsSkillsDir);
|
|
80051
|
-
const projectSkillsDir =
|
|
80310
|
+
const projectSkillsDir = join22(opts.cwd, ".pi", "skills");
|
|
80052
80311
|
pushSkillFromRoot(projectSkillsDir);
|
|
80053
80312
|
addSection("Skills", skillsItems);
|
|
80054
80313
|
const promptsItems = [];
|
|
80055
|
-
const promptsDir =
|
|
80314
|
+
const promptsDir = join22(home, ".pi", "agent", "prompts");
|
|
80056
80315
|
try {
|
|
80057
80316
|
const prompts = readdirSync6(promptsDir).filter((f) => f.endsWith(".md"));
|
|
80058
80317
|
for (const f of prompts) {
|
|
@@ -80062,17 +80321,17 @@ function buildStartupInfo(opts) {
|
|
|
80062
80321
|
}
|
|
80063
80322
|
addSection("Prompts", promptsItems);
|
|
80064
80323
|
const extItems = [];
|
|
80065
|
-
const extDir =
|
|
80324
|
+
const extDir = join22(home, ".pi", "agent", "extensions");
|
|
80066
80325
|
try {
|
|
80067
80326
|
const exts = readdirSync6(extDir).filter((f) => f.endsWith(".ts") || f.endsWith(".js"));
|
|
80068
80327
|
for (const f of exts) {
|
|
80069
|
-
extItems.push(
|
|
80328
|
+
extItems.push(join22(extDir, f));
|
|
80070
80329
|
}
|
|
80071
80330
|
} catch {
|
|
80072
80331
|
}
|
|
80073
80332
|
const settingsPaths = [
|
|
80074
|
-
|
|
80075
|
-
|
|
80333
|
+
join22(getAgentDir(opts.environment), "settings.json"),
|
|
80334
|
+
join22(opts.cwd, ".pi", "settings.json")
|
|
80076
80335
|
];
|
|
80077
80336
|
for (const settingsPath of settingsPaths) {
|
|
80078
80337
|
try {
|
|
@@ -80663,7 +80922,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
80663
80922
|
if (piPath) {
|
|
80664
80923
|
const resolved = realpathSync3(piPath);
|
|
80665
80924
|
const pkgRoot = dirname9(dirname9(resolved));
|
|
80666
|
-
const p =
|
|
80925
|
+
const p = join22(pkgRoot, "CHANGELOG.md");
|
|
80667
80926
|
if (existsSync7(p)) {
|
|
80668
80927
|
return p;
|
|
80669
80928
|
}
|
|
@@ -80674,7 +80933,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
80674
80933
|
const npmRoot = spawnSync("npm", ["root", "-g"], { encoding: "utf-8" });
|
|
80675
80934
|
const root = String(npmRoot.stdout ?? "").trim();
|
|
80676
80935
|
if (root) {
|
|
80677
|
-
const p =
|
|
80936
|
+
const p = join22(root, "@earendil-works", "pi-coding-agent", "CHANGELOG.md");
|
|
80678
80937
|
if (existsSync7(p)) {
|
|
80679
80938
|
return p;
|
|
80680
80939
|
}
|
|
@@ -80768,7 +81027,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
80768
81027
|
return { stopReason: "end_turn" };
|
|
80769
81028
|
}
|
|
80770
81029
|
const safeSessionId = session.sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
80771
|
-
const outputPath =
|
|
81030
|
+
const outputPath = join22(session.cwd, `pi-session-${safeSessionId}.html`);
|
|
80772
81031
|
let resultPath = "";
|
|
80773
81032
|
try {
|
|
80774
81033
|
const result2 = await session.proc.exportHtml(outputPath);
|
|
@@ -81461,7 +81720,7 @@ var init_agent_probe_error = __esm({
|
|
|
81461
81720
|
|
|
81462
81721
|
// src/agent/specification/vendors/pi-agent.ts
|
|
81463
81722
|
import { createHash as createHash3 } from "node:crypto";
|
|
81464
|
-
import { join as
|
|
81723
|
+
import { join as join23 } from "node:path";
|
|
81465
81724
|
import {
|
|
81466
81725
|
methods as methods7
|
|
81467
81726
|
} from "@agentclientprotocol/sdk";
|
|
@@ -81481,7 +81740,7 @@ var init_pi_agent = __esm({
|
|
|
81481
81740
|
// keeps the adapter's opt-in capability flag enabled for every launch it owns.
|
|
81482
81741
|
createLaunchEnvironment = async (_agent, context) => {
|
|
81483
81742
|
const workspaceHash = createHash3("sha256").update(context.defaultWorkspace).digest("hex").slice(0, 24);
|
|
81484
|
-
const sessionDirectory =
|
|
81743
|
+
const sessionDirectory = join23(context.dataDirectory, "agents", "pi", "sessions", workspaceHash);
|
|
81485
81744
|
return Object.freeze({
|
|
81486
81745
|
PI_ACP_ENABLE_EMBEDDED_CONTEXT: "true",
|
|
81487
81746
|
MOBIUS_PI_SESSION_DIR: sessionDirectory
|
|
@@ -82393,7 +82652,7 @@ var init_native_session = __esm({
|
|
|
82393
82652
|
|
|
82394
82653
|
// src/acp/protocol/session-config-protocol.ts
|
|
82395
82654
|
import { methods as methods9 } from "@agentclientprotocol/sdk";
|
|
82396
|
-
function
|
|
82655
|
+
function isRecord6(value) {
|
|
82397
82656
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
82398
82657
|
}
|
|
82399
82658
|
function readString3(value, fallback = "") {
|
|
@@ -82424,7 +82683,7 @@ function normalizeConfigValues(value) {
|
|
|
82424
82683
|
}
|
|
82425
82684
|
const normalized = [];
|
|
82426
82685
|
for (const entry of value) {
|
|
82427
|
-
if (!
|
|
82686
|
+
if (!isRecord6(entry)) {
|
|
82428
82687
|
continue;
|
|
82429
82688
|
}
|
|
82430
82689
|
const groupedOptions = entry["options"];
|
|
@@ -82432,7 +82691,7 @@ function normalizeConfigValues(value) {
|
|
|
82432
82691
|
const groupId = readString3(entry["group"]);
|
|
82433
82692
|
const groupName = readString3(entry["name"]);
|
|
82434
82693
|
for (const groupedOption of groupedOptions) {
|
|
82435
|
-
if (
|
|
82694
|
+
if (isRecord6(groupedOption)) {
|
|
82436
82695
|
const normalizedValue = normalizeConfigValue(groupedOption, groupId, groupName);
|
|
82437
82696
|
if (normalizedValue !== void 0) {
|
|
82438
82697
|
normalized.push(normalizedValue);
|
|
@@ -82457,7 +82716,7 @@ function normalizeConfigOptions(value, modes) {
|
|
|
82457
82716
|
const normalized = [];
|
|
82458
82717
|
if (Array.isArray(value)) {
|
|
82459
82718
|
for (const option of value) {
|
|
82460
|
-
if (!
|
|
82719
|
+
if (!isRecord6(option)) {
|
|
82461
82720
|
continue;
|
|
82462
82721
|
}
|
|
82463
82722
|
const id = truncate3(readString3(option["id"]), 128);
|
|
@@ -82497,12 +82756,12 @@ function normalizeConfigOptions(value, modes) {
|
|
|
82497
82756
|
}
|
|
82498
82757
|
}
|
|
82499
82758
|
}
|
|
82500
|
-
if (
|
|
82759
|
+
if (isRecord6(modes)) {
|
|
82501
82760
|
const values = [];
|
|
82502
82761
|
const availableModes = modes["availableModes"];
|
|
82503
82762
|
if (Array.isArray(availableModes)) {
|
|
82504
82763
|
for (const mode of availableModes) {
|
|
82505
|
-
if (!
|
|
82764
|
+
if (!isRecord6(mode)) {
|
|
82506
82765
|
continue;
|
|
82507
82766
|
}
|
|
82508
82767
|
const id = truncate3(readString3(mode["id"]), 500);
|
|
@@ -82535,7 +82794,7 @@ function normalizeConfigOptions(value, modes) {
|
|
|
82535
82794
|
return normalized.slice(0, MAXIMUM_CONFIG_OPTIONS);
|
|
82536
82795
|
}
|
|
82537
82796
|
function normalizeStandardLifecycle(response) {
|
|
82538
|
-
const lifecycle =
|
|
82797
|
+
const lifecycle = isRecord6(response) ? response : {};
|
|
82539
82798
|
return normalizeConfigOptions(lifecycle["configOptions"], lifecycle["modes"]);
|
|
82540
82799
|
}
|
|
82541
82800
|
function replaceStandardConfigOptions(current, value) {
|
|
@@ -82592,7 +82851,7 @@ var init_session_config_protocol = __esm({
|
|
|
82592
82851
|
"ACP agent exited while changing session configuration",
|
|
82593
82852
|
change.signal
|
|
82594
82853
|
);
|
|
82595
|
-
if (!
|
|
82854
|
+
if (!isRecord6(response) || !Array.isArray(response["configOptions"])) {
|
|
82596
82855
|
throw new SessionConfigProtocolError("The Agent returned an invalid session configuration response");
|
|
82597
82856
|
}
|
|
82598
82857
|
return replaceStandardConfigOptions(current, response["configOptions"]);
|
|
@@ -84960,7 +85219,7 @@ var init_sql = __esm({
|
|
|
84960
85219
|
return new SQL([new StringChunk(str)]);
|
|
84961
85220
|
}
|
|
84962
85221
|
_sql.raw = raw;
|
|
84963
|
-
function
|
|
85222
|
+
function join41(chunks, separator) {
|
|
84964
85223
|
const result = [];
|
|
84965
85224
|
for (const [i, chunk] of chunks.entries()) {
|
|
84966
85225
|
if (i > 0 && separator !== void 0) result.push(separator);
|
|
@@ -84968,7 +85227,7 @@ var init_sql = __esm({
|
|
|
84968
85227
|
}
|
|
84969
85228
|
return new SQL(result);
|
|
84970
85229
|
}
|
|
84971
|
-
_sql.join =
|
|
85230
|
+
_sql.join = join41;
|
|
84972
85231
|
function identifier2(value) {
|
|
84973
85232
|
return new Name(value);
|
|
84974
85233
|
}
|
|
@@ -86926,7 +87185,7 @@ var init_select = __esm({
|
|
|
86926
87185
|
const baseTableName = this.tableName;
|
|
86927
87186
|
const tableName = getTableLikeName(table);
|
|
86928
87187
|
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
86929
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
87188
|
+
if (typeof tableName === "string" && this.config.joins?.some((join41) => join41.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
86930
87189
|
if (!this.isPartialSelect) {
|
|
86931
87190
|
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
|
|
86932
87191
|
if (typeof tableName === "string" && !is(table, SQL)) {
|
|
@@ -88523,7 +88782,7 @@ var init_dialect = __esm({
|
|
|
88523
88782
|
if (!joins2) return;
|
|
88524
88783
|
const withEntries = Object.entries(joins2).filter(([_, v]) => v);
|
|
88525
88784
|
if (!withEntries.length) return;
|
|
88526
|
-
return sql.join(withEntries.map(([k2,
|
|
88785
|
+
return sql.join(withEntries.map(([k2, join41]) => {
|
|
88527
88786
|
const relation = tableConfig.relations[k2];
|
|
88528
88787
|
const isSingle2 = is(relation, One2);
|
|
88529
88788
|
const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
|
|
@@ -88534,7 +88793,7 @@ var init_dialect = __esm({
|
|
|
88534
88793
|
table: targetTable,
|
|
88535
88794
|
mode: isSingle2 ? "first" : "many",
|
|
88536
88795
|
schema,
|
|
88537
|
-
queryConfig:
|
|
88796
|
+
queryConfig: join41,
|
|
88538
88797
|
tableConfig: schema[relation.targetTableName],
|
|
88539
88798
|
relationWhere: filter,
|
|
88540
88799
|
isNested: true,
|
|
@@ -88548,7 +88807,7 @@ var init_dialect = __esm({
|
|
|
88548
88807
|
key: k2,
|
|
88549
88808
|
selection: innerQuery.selection,
|
|
88550
88809
|
isArray: !isSingle2,
|
|
88551
|
-
isOptional: (relation.optional ?? false) ||
|
|
88810
|
+
isOptional: (relation.optional ?? false) || join41 !== true && !!join41.where
|
|
88552
88811
|
});
|
|
88553
88812
|
const jsonColumns = sql.join(innerQuery.selection.map((s) => {
|
|
88554
88813
|
return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
|
|
@@ -88970,7 +89229,7 @@ var init_update = __esm({
|
|
|
88970
89229
|
createJoin(joinType) {
|
|
88971
89230
|
return ((table, on2) => {
|
|
88972
89231
|
const tableName = getTableLikeName(table);
|
|
88973
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
89232
|
+
if (typeof tableName === "string" && this.config.joins.some((join41) => join41.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
88974
89233
|
if (typeof on2 === "function") {
|
|
88975
89234
|
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;
|
|
88976
89235
|
on2 = on2(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
|
|
@@ -89856,12 +90115,12 @@ var init_local_sqlite_database = __esm({
|
|
|
89856
90115
|
|
|
89857
90116
|
// src/storage/sqlite/local-databases.ts
|
|
89858
90117
|
import { createHash as createHash4 } from "node:crypto";
|
|
89859
|
-
import { join as
|
|
90118
|
+
import { join as join24 } from "node:path";
|
|
89860
90119
|
function channelSessionDatabasePaths(stateDirectory, channelId) {
|
|
89861
90120
|
const channelHash = createHash4("sha256").update(channelId).digest("hex");
|
|
89862
90121
|
return {
|
|
89863
|
-
events:
|
|
89864
|
-
sessions:
|
|
90122
|
+
events: join24(stateDirectory, "sessions", `${channelHash}.events.sqlite`),
|
|
90123
|
+
sessions: join24(stateDirectory, "sessions", `${channelHash}.sqlite`)
|
|
89865
90124
|
};
|
|
89866
90125
|
}
|
|
89867
90126
|
var openAcpSessionDatabase, openSessionEventCacheDatabase;
|
|
@@ -90094,13 +90353,13 @@ var init_session_event_cache_table = __esm({
|
|
|
90094
90353
|
// src/storage/session/temporary-session-event-cache.ts
|
|
90095
90354
|
import { mkdtempSync, rmSync as rmSync2 } from "node:fs";
|
|
90096
90355
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
90097
|
-
import { join as
|
|
90356
|
+
import { join as join25 } from "node:path";
|
|
90098
90357
|
function openTemporarySessionEventCache() {
|
|
90099
|
-
const directory = mkdtempSync(
|
|
90358
|
+
const directory = mkdtempSync(join25(tmpdir2(), "mobius-preview-events-"));
|
|
90100
90359
|
const removeFiles = () => rmSync2(directory, { recursive: true, force: true });
|
|
90101
90360
|
try {
|
|
90102
90361
|
return {
|
|
90103
|
-
table: new SessionEventCacheTable(openSessionEventCacheDatabase(
|
|
90362
|
+
table: new SessionEventCacheTable(openSessionEventCacheDatabase(join25(directory, "events.sqlite"))),
|
|
90104
90363
|
removeFiles
|
|
90105
90364
|
};
|
|
90106
90365
|
} catch (error62) {
|
|
@@ -90431,7 +90690,7 @@ function decodeBase64(data) {
|
|
|
90431
90690
|
}
|
|
90432
90691
|
return bytes;
|
|
90433
90692
|
}
|
|
90434
|
-
function
|
|
90693
|
+
function isRecord7(value) {
|
|
90435
90694
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
90436
90695
|
}
|
|
90437
90696
|
var MAXIMUM_ENCODED_CONTENT_CHARACTERS, embeddedImageSchema, inlineImageUrlSchema, toolImageSchema, AcpContentExternalizer;
|
|
@@ -90568,13 +90827,13 @@ var init_content_externalizer = __esm({
|
|
|
90568
90827
|
}
|
|
90569
90828
|
return result2;
|
|
90570
90829
|
}
|
|
90571
|
-
if (!
|
|
90830
|
+
if (!isRecord7(value)) {
|
|
90572
90831
|
return value;
|
|
90573
90832
|
}
|
|
90574
90833
|
const image = toolImageSchema.safeParse(value);
|
|
90575
90834
|
if (image.success && image.data.data.length > 0) {
|
|
90576
90835
|
const prepared = await this.#content(sessionId, image.data, signal);
|
|
90577
|
-
if (
|
|
90836
|
+
if (isRecord7(prepared.event) && typeof prepared.event["imageKey"] === "string") {
|
|
90578
90837
|
images.set(prepared.event["imageKey"], prepared);
|
|
90579
90838
|
} else {
|
|
90580
90839
|
images.set(`unavailable:${images.size}`, prepared);
|
|
@@ -90605,7 +90864,7 @@ var init_content_externalizer = __esm({
|
|
|
90605
90864
|
const prepared = await this.#content(sessionId, content, signal);
|
|
90606
90865
|
agentContent.push({ ...item, content: prepared.agent });
|
|
90607
90866
|
eventContent.push({ ...item, content: prepared.event });
|
|
90608
|
-
if (
|
|
90867
|
+
if (isRecord7(prepared.event) && typeof prepared.event["imageKey"] === "string") {
|
|
90609
90868
|
images.delete(prepared.event["imageKey"]);
|
|
90610
90869
|
}
|
|
90611
90870
|
}
|
|
@@ -90766,7 +91025,7 @@ var init_relay_authentication = __esm({
|
|
|
90766
91025
|
|
|
90767
91026
|
// src/runtime/catalog/publish-agent-catalog.ts
|
|
90768
91027
|
import { fetch as fetch2 } from "undici";
|
|
90769
|
-
function
|
|
91028
|
+
function isRecord8(value) {
|
|
90770
91029
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
90771
91030
|
}
|
|
90772
91031
|
function isSafeRelayErrorMessage(value) {
|
|
@@ -90779,7 +91038,7 @@ async function rejectedCatalogError(response) {
|
|
|
90779
91038
|
} catch {
|
|
90780
91039
|
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
90781
91040
|
}
|
|
90782
|
-
if (!
|
|
91041
|
+
if (!isRecord8(value) || !isRecord8(value["error"])) {
|
|
90783
91042
|
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
90784
91043
|
}
|
|
90785
91044
|
const code = value["error"]["code"];
|
|
@@ -90949,10 +91208,10 @@ var init_catalog2 = __esm({
|
|
|
90949
91208
|
});
|
|
90950
91209
|
|
|
90951
91210
|
// src/runtime/config.ts
|
|
90952
|
-
import { join as
|
|
91211
|
+
import { join as join26, resolve as resolve14 } from "node:path";
|
|
90953
91212
|
function loadDefaultWorkspace(dataDirectory, environment = process.env) {
|
|
90954
91213
|
const { MOBIUS_DEFAULT_WORKSPACE: configuredWorkspace } = environment;
|
|
90955
|
-
return configuredWorkspace ??
|
|
91214
|
+
return configuredWorkspace ?? join26(dataDirectory, "workspace");
|
|
90956
91215
|
}
|
|
90957
91216
|
function withRuntimeEnvironment(agent, environment) {
|
|
90958
91217
|
const launchEnvironment = {};
|
|
@@ -91128,7 +91387,7 @@ var init_runtime_connection = __esm({
|
|
|
91128
91387
|
// src/runtime/connection/runtime-installation-store.ts
|
|
91129
91388
|
import { randomUUID as randomUUID13 } from "node:crypto";
|
|
91130
91389
|
import { resolve as resolve15 } from "node:path";
|
|
91131
|
-
function
|
|
91390
|
+
function isRecord9(value) {
|
|
91132
91391
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
91133
91392
|
}
|
|
91134
91393
|
function hasExactKeys(value, expectedKeys) {
|
|
@@ -91195,7 +91454,7 @@ function installationId() {
|
|
|
91195
91454
|
return `min_${randomUUID13().replaceAll("-", "")}`;
|
|
91196
91455
|
}
|
|
91197
91456
|
function decodeInstallationPointer(value) {
|
|
91198
|
-
if (!
|
|
91457
|
+
if (!isRecord9(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {
|
|
91199
91458
|
throw new RuntimeInstallationStoreError("invalid_installation", "The local installation record is invalid");
|
|
91200
91459
|
}
|
|
91201
91460
|
const storedInstallationId = value["installationId"];
|
|
@@ -91205,7 +91464,7 @@ function decodeInstallationPointer(value) {
|
|
|
91205
91464
|
return { installationId: validateInstallationId(storedInstallationId) };
|
|
91206
91465
|
}
|
|
91207
91466
|
function decodeChannelIndex(value) {
|
|
91208
|
-
if (!
|
|
91467
|
+
if (!isRecord9(value) || !hasExactKeys(value, CHANNEL_INDEX_KEYS) || value["version"] !== 1) {
|
|
91209
91468
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
91210
91469
|
}
|
|
91211
91470
|
const applicationId = value["applicationId"];
|
|
@@ -91255,7 +91514,7 @@ function decodeVerifiedConnection(value) {
|
|
|
91255
91514
|
);
|
|
91256
91515
|
}
|
|
91257
91516
|
function decodeConnection(value) {
|
|
91258
|
-
if (!
|
|
91517
|
+
if (!isRecord9(value)) {
|
|
91259
91518
|
throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
|
|
91260
91519
|
}
|
|
91261
91520
|
return decodeVerifiedConnection(value);
|
|
@@ -91589,9 +91848,9 @@ var init_runtime_installation_store = __esm({
|
|
|
91589
91848
|
// src/storage/daemon/version-data.ts
|
|
91590
91849
|
import { randomUUID as randomUUID14 } from "node:crypto";
|
|
91591
91850
|
import { cp as cp2, lstat as lstat4, mkdtemp, readFile as readFile7, rename as rename4, rm as rm3, writeFile as writeFile2 } from "node:fs/promises";
|
|
91592
|
-
import { join as
|
|
91851
|
+
import { join as join27, relative as relative2, sep as sep5 } from "node:path";
|
|
91593
91852
|
async function readCurrentDataVersion(root, signal) {
|
|
91594
|
-
const pointer =
|
|
91853
|
+
const pointer = join27(root, STATE_ROOT_LAYOUT.currentData);
|
|
91595
91854
|
try {
|
|
91596
91855
|
await validateLocalPath(pointer, false, true, signal);
|
|
91597
91856
|
const value = (await readFile7(pointer, { encoding: "utf8", signal })).trim();
|
|
@@ -91608,7 +91867,7 @@ async function readCurrentDataVersion(root, signal) {
|
|
|
91608
91867
|
}
|
|
91609
91868
|
async function versionDataExists(root, version2, signal) {
|
|
91610
91869
|
try {
|
|
91611
|
-
await validateLocalPath(
|
|
91870
|
+
await validateLocalPath(join27(root, STATE_ROOT_LAYOUT.versions, version2), true, true, signal);
|
|
91612
91871
|
return true;
|
|
91613
91872
|
} catch (cause) {
|
|
91614
91873
|
if (!isNodeError(cause, "ENOENT")) {
|
|
@@ -91622,13 +91881,13 @@ function nestedRootEntry(segments) {
|
|
|
91622
91881
|
}
|
|
91623
91882
|
async function copyVersionData(root, sourceVersion, targetVersion, signal) {
|
|
91624
91883
|
const leftBehind = [];
|
|
91625
|
-
const versions =
|
|
91626
|
-
const source =
|
|
91627
|
-
const target =
|
|
91884
|
+
const versions = join27(root, STATE_ROOT_LAYOUT.versions);
|
|
91885
|
+
const source = join27(versions, sourceVersion);
|
|
91886
|
+
const target = join27(versions, targetVersion);
|
|
91628
91887
|
await validateLocalPath(root, true, true, signal);
|
|
91629
91888
|
await validateLocalPath(versions, true, true, signal);
|
|
91630
91889
|
await validateLocalPath(source, true, true, signal);
|
|
91631
|
-
const staging = await mkdtemp(
|
|
91890
|
+
const staging = await mkdtemp(join27(versions, `.${targetVersion}-`));
|
|
91632
91891
|
try {
|
|
91633
91892
|
await cp2(source, staging, {
|
|
91634
91893
|
recursive: true,
|
|
@@ -91665,10 +91924,10 @@ async function discardVersionData(root, version2, signal) {
|
|
|
91665
91924
|
if (await readCurrentDataVersion(root, signal) === version2 || !await versionDataExists(root, version2, signal)) {
|
|
91666
91925
|
return;
|
|
91667
91926
|
}
|
|
91668
|
-
const versions =
|
|
91669
|
-
const discarded =
|
|
91927
|
+
const versions = join27(root, STATE_ROOT_LAYOUT.versions);
|
|
91928
|
+
const discarded = join27(versions, `.${version2}-discarded-${randomUUID14()}`);
|
|
91670
91929
|
try {
|
|
91671
|
-
await rename4(
|
|
91930
|
+
await rename4(join27(versions, version2), discarded);
|
|
91672
91931
|
} catch (cause) {
|
|
91673
91932
|
if (isNodeError(cause, "ENOENT")) {
|
|
91674
91933
|
return;
|
|
@@ -91679,13 +91938,13 @@ async function discardVersionData(root, version2, signal) {
|
|
|
91679
91938
|
}
|
|
91680
91939
|
async function writeCurrentDataVersion(root, version2, signal) {
|
|
91681
91940
|
await validateLocalPath(root, true, true, signal);
|
|
91682
|
-
await validateLocalPath(
|
|
91683
|
-
const temporary =
|
|
91941
|
+
await validateLocalPath(join27(root, STATE_ROOT_LAYOUT.versions, version2), true, true, signal);
|
|
91942
|
+
const temporary = join27(root, `.current-data-${randomUUID14()}.txt`);
|
|
91684
91943
|
try {
|
|
91685
91944
|
await writeFile2(temporary, `versions/${version2}
|
|
91686
91945
|
`, { mode: 384, flag: "wx", signal });
|
|
91687
91946
|
signal.throwIfAborted();
|
|
91688
|
-
await rename4(temporary,
|
|
91947
|
+
await rename4(temporary, join27(root, STATE_ROOT_LAYOUT.currentData));
|
|
91689
91948
|
} finally {
|
|
91690
91949
|
await rm3(temporary, { force: true });
|
|
91691
91950
|
}
|
|
@@ -91706,7 +91965,7 @@ var init_version_data = __esm({
|
|
|
91706
91965
|
|
|
91707
91966
|
// src/daemon/pairing/pair-local-machine.ts
|
|
91708
91967
|
import { hostname as hostname3 } from "node:os";
|
|
91709
|
-
import { basename as basename7, join as
|
|
91968
|
+
import { basename as basename7, join as join28, resolve as resolve16 } from "node:path";
|
|
91710
91969
|
import { fetch as fetch3 } from "undici";
|
|
91711
91970
|
function hasExactKeys2(value, expectedKeys) {
|
|
91712
91971
|
const keys = Object.keys(value);
|
|
@@ -91967,7 +92226,7 @@ async function openMobiusVersionInstallation(version2, signal, environment) {
|
|
|
91967
92226
|
return await openRuntimeInstallationStore(
|
|
91968
92227
|
{
|
|
91969
92228
|
applicationId: MOBIUS_CLI_APPLICATION_ID,
|
|
91970
|
-
stateDirectory:
|
|
92229
|
+
stateDirectory: join28(readStateDirectory(environment), "versions", version2)
|
|
91971
92230
|
},
|
|
91972
92231
|
signal
|
|
91973
92232
|
);
|
|
@@ -92240,9 +92499,9 @@ var init_agents = __esm({
|
|
|
92240
92499
|
|
|
92241
92500
|
// src/storage/daemon/manager-lock.ts
|
|
92242
92501
|
import { readFile as readFile8, unlink as unlink4, writeFile as writeFile3 } from "node:fs/promises";
|
|
92243
|
-
import { join as
|
|
92502
|
+
import { join as join29 } from "node:path";
|
|
92244
92503
|
async function acquireManagerLock(stateDirectory, name2 = "manager.lock") {
|
|
92245
|
-
const path8 =
|
|
92504
|
+
const path8 = join29(stateDirectory, name2);
|
|
92246
92505
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
92247
92506
|
try {
|
|
92248
92507
|
await writeFile3(path8, `${process.pid.toString()}
|
|
@@ -92271,7 +92530,7 @@ async function acquireManagerLock(stateDirectory, name2 = "manager.lock") {
|
|
|
92271
92530
|
}
|
|
92272
92531
|
async function managerLockExists(stateDirectory) {
|
|
92273
92532
|
try {
|
|
92274
|
-
await readFile8(
|
|
92533
|
+
await readFile8(join29(stateDirectory, "manager.lock"), "utf8");
|
|
92275
92534
|
return true;
|
|
92276
92535
|
} catch (cause) {
|
|
92277
92536
|
if (isNodeError(cause, "ENOENT")) {
|
|
@@ -92290,9 +92549,9 @@ var init_manager_lock = __esm({
|
|
|
92290
92549
|
// src/storage/daemon/control-token.ts
|
|
92291
92550
|
import { randomBytes } from "node:crypto";
|
|
92292
92551
|
import { readFile as readFile9, writeFile as writeFile4 } from "node:fs/promises";
|
|
92293
|
-
import { join as
|
|
92552
|
+
import { join as join30 } from "node:path";
|
|
92294
92553
|
function controlTokenPath(stateDirectory) {
|
|
92295
|
-
return
|
|
92554
|
+
return join30(stateDirectory, "manager.token");
|
|
92296
92555
|
}
|
|
92297
92556
|
async function readOrCreateControlToken(stateDirectory) {
|
|
92298
92557
|
const path8 = controlTokenPath(stateDirectory);
|
|
@@ -92477,7 +92736,10 @@ var init_local_server = __esm({
|
|
|
92477
92736
|
});
|
|
92478
92737
|
|
|
92479
92738
|
// src/daemon/control/protocol.ts
|
|
92480
|
-
|
|
92739
|
+
function hasUnknownKind(value, known) {
|
|
92740
|
+
return typeof value === "object" && value !== null && "kind" in value && typeof value.kind === "string" && !known.has(value.kind);
|
|
92741
|
+
}
|
|
92742
|
+
var workerLaunch, transition, daemonSwitchState, lifecycleCommand, lifecycleResponse, lifecycleCommandKinds, lifecycleResponseKinds, daemonSwitchStateKinds, decodeKnownLifecycleCommand, decodeKnownLifecycleResponse;
|
|
92481
92743
|
var init_protocol2 = __esm({
|
|
92482
92744
|
"src/daemon/control/protocol.ts"() {
|
|
92483
92745
|
"use strict";
|
|
@@ -92529,15 +92791,28 @@ var init_protocol2 = __esm({
|
|
|
92529
92791
|
external_exports.object({ kind: external_exports.literal("switching") }),
|
|
92530
92792
|
external_exports.object({ kind: external_exports.literal("error"), code: external_exports.string(), message: external_exports.string() })
|
|
92531
92793
|
]).readonly();
|
|
92794
|
+
lifecycleCommandKinds = /* @__PURE__ */ new Set(["ensure", "status", "stop", "switch", "switch-status"]);
|
|
92795
|
+
lifecycleResponseKinds = /* @__PURE__ */ new Set(["error", "status", "stopped", "switching", "switch-status"]);
|
|
92796
|
+
daemonSwitchStateKinds = /* @__PURE__ */ new Set(["rolled-back", "switched", "switching"]);
|
|
92797
|
+
decodeKnownLifecycleCommand = (value) => hasUnknownKind(value, lifecycleCommandKinds) ? null : lifecycleCommand.parse(value);
|
|
92798
|
+
decodeKnownLifecycleResponse = (value) => {
|
|
92799
|
+
if (hasUnknownKind(value, lifecycleResponseKinds)) {
|
|
92800
|
+
return null;
|
|
92801
|
+
}
|
|
92802
|
+
if (typeof value === "object" && value !== null && "kind" in value && value.kind === "switch-status" && "state" in value && hasUnknownKind(value.state, daemonSwitchStateKinds)) {
|
|
92803
|
+
return lifecycleResponse.parse({ ...value, state: null });
|
|
92804
|
+
}
|
|
92805
|
+
return lifecycleResponse.parse(value);
|
|
92806
|
+
};
|
|
92532
92807
|
}
|
|
92533
92808
|
});
|
|
92534
92809
|
|
|
92535
92810
|
// src/daemon/control/switch-status.ts
|
|
92536
92811
|
async function readSwitchStatus(directory, signal, wait = false) {
|
|
92537
|
-
const response =
|
|
92812
|
+
const response = decodeKnownLifecycleResponse(
|
|
92538
92813
|
await sendLocalRequest(directory, "manager", { kind: "switch-status", wait }, signal)
|
|
92539
92814
|
);
|
|
92540
|
-
if (response
|
|
92815
|
+
if (response?.kind !== "switch-status") {
|
|
92541
92816
|
throw new Error("The manager could not return the switch status");
|
|
92542
92817
|
}
|
|
92543
92818
|
return response.state;
|
|
@@ -92600,7 +92875,7 @@ var init_data = __esm({
|
|
|
92600
92875
|
|
|
92601
92876
|
// src/storage/logs/bounded-log.ts
|
|
92602
92877
|
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync4, readFileSync as readFileSync9, renameSync as renameSync2, statSync as statSync5, writeFileSync as writeFileSync2 } from "node:fs";
|
|
92603
|
-
import { join as
|
|
92878
|
+
import { join as join31 } from "node:path";
|
|
92604
92879
|
var BoundedLineLog;
|
|
92605
92880
|
var init_bounded_log = __esm({
|
|
92606
92881
|
"src/storage/logs/bounded-log.ts"() {
|
|
@@ -92613,7 +92888,7 @@ var init_bounded_log = __esm({
|
|
|
92613
92888
|
#onWriteFailure;
|
|
92614
92889
|
constructor(directory, filename, maximumBytes, onWriteFailure = () => void 0) {
|
|
92615
92890
|
this.#directory = directory;
|
|
92616
|
-
this.#path =
|
|
92891
|
+
this.#path = join31(directory, filename);
|
|
92617
92892
|
this.#maximumBytes = maximumBytes;
|
|
92618
92893
|
this.#onWriteFailure = onWriteFailure;
|
|
92619
92894
|
}
|
|
@@ -92667,19 +92942,19 @@ var init_bounded_log = __esm({
|
|
|
92667
92942
|
// src/storage/logs/log-files.ts
|
|
92668
92943
|
import { readFileSync as readFileSync10 } from "node:fs";
|
|
92669
92944
|
import { lstat as lstat5, readdir as readdir6, readFile as readFile10 } from "node:fs/promises";
|
|
92670
|
-
import { join as
|
|
92945
|
+
import { join as join32, relative as relative3 } from "node:path";
|
|
92671
92946
|
function unhandledRejectionLogFilename(role) {
|
|
92672
92947
|
return `unhandled-rejections-${role}.log`;
|
|
92673
92948
|
}
|
|
92674
92949
|
function logDirectory(stateDirectory) {
|
|
92675
|
-
return
|
|
92950
|
+
return join32(stateDirectory, "logs");
|
|
92676
92951
|
}
|
|
92677
92952
|
function processLogPaths(stateDirectory) {
|
|
92678
92953
|
return [
|
|
92679
92954
|
WORKER_LIFECYCLE_LOG_FILENAME,
|
|
92680
92955
|
unhandledRejectionLogFilename("manager"),
|
|
92681
92956
|
unhandledRejectionLogFilename("worker")
|
|
92682
|
-
].map((filename) =>
|
|
92957
|
+
].map((filename) => join32(logDirectory(stateDirectory), filename));
|
|
92683
92958
|
}
|
|
92684
92959
|
function readLogText(path8) {
|
|
92685
92960
|
try {
|
|
@@ -92692,17 +92967,17 @@ function isAbsent(cause) {
|
|
|
92692
92967
|
return typeof cause === "object" && cause !== null && Reflect.get(cause, "code") === "ENOENT";
|
|
92693
92968
|
}
|
|
92694
92969
|
async function findLogDirectories(root, unreadable, signal) {
|
|
92695
|
-
const versions =
|
|
92696
|
-
const installationsRoots = [
|
|
92970
|
+
const versions = join32(root, VERSIONS_DIRECTORY);
|
|
92971
|
+
const installationsRoots = [join32(root, INSTALLATIONS_DIRECTORY)];
|
|
92697
92972
|
for (const version2 of await listDirectories(versions, root, unreadable, signal)) {
|
|
92698
|
-
installationsRoots.push(
|
|
92973
|
+
installationsRoots.push(join32(versions, version2, INSTALLATIONS_DIRECTORY));
|
|
92699
92974
|
}
|
|
92700
92975
|
const found = [];
|
|
92701
92976
|
for (const installations of installationsRoots) {
|
|
92702
92977
|
for (const applicationId of await listDirectories(installations, root, unreadable, signal)) {
|
|
92703
|
-
const application =
|
|
92978
|
+
const application = join32(installations, applicationId);
|
|
92704
92979
|
for (const installationId2 of await listDirectories(application, root, unreadable, signal)) {
|
|
92705
|
-
const logs =
|
|
92980
|
+
const logs = join32(application, installationId2, "logs");
|
|
92706
92981
|
const status = await directoryStatus(logs);
|
|
92707
92982
|
if (status === "listed") {
|
|
92708
92983
|
found.push(logs);
|
|
@@ -93190,15 +93465,10 @@ async function runManager(stateDirectory, signal) {
|
|
|
93190
93465
|
}
|
|
93191
93466
|
};
|
|
93192
93467
|
const handle = async (value, requestSignal) => {
|
|
93193
|
-
const
|
|
93194
|
-
if (
|
|
93195
|
-
return
|
|
93196
|
-
kind: "error",
|
|
93197
|
-
code: "unsupported_lifecycle_command",
|
|
93198
|
-
message: "The manager only accepts lifecycle commands"
|
|
93199
|
-
};
|
|
93468
|
+
const command = decodeKnownLifecycleCommand(value);
|
|
93469
|
+
if (command === null) {
|
|
93470
|
+
return null;
|
|
93200
93471
|
}
|
|
93201
|
-
const command = parsed.data;
|
|
93202
93472
|
if (command.kind === "switch-status" && !command.wait) {
|
|
93203
93473
|
return { kind: "switch-status", state: switchState };
|
|
93204
93474
|
}
|
|
@@ -93315,13 +93585,13 @@ var init_manager2 = __esm({
|
|
|
93315
93585
|
|
|
93316
93586
|
// src/storage/daemon/release-files.ts
|
|
93317
93587
|
import { readFile as readFile11, realpath as realpath8 } from "node:fs/promises";
|
|
93318
|
-
import { join as
|
|
93588
|
+
import { join as join33 } from "node:path";
|
|
93319
93589
|
function releasePrefix(version2) {
|
|
93320
|
-
return
|
|
93590
|
+
return join33(readStateDirectory(), STATE_ROOT_LAYOUT.releases, version2);
|
|
93321
93591
|
}
|
|
93322
93592
|
async function readInstalledRelease(prefix) {
|
|
93323
|
-
const packageRoot = await realpath8(
|
|
93324
|
-
return { manifest: await readFile11(
|
|
93593
|
+
const packageRoot = await realpath8(join33(prefix, "node_modules", "@moxt-ai", "mobius"));
|
|
93594
|
+
return { manifest: await readFile11(join33(packageRoot, "package.json"), "utf8"), packageRoot };
|
|
93325
93595
|
}
|
|
93326
93596
|
var init_release_files = __esm({
|
|
93327
93597
|
"src/storage/daemon/release-files.ts"() {
|
|
@@ -93332,7 +93602,7 @@ var init_release_files = __esm({
|
|
|
93332
93602
|
});
|
|
93333
93603
|
|
|
93334
93604
|
// src/daemon/upgrades/package.ts
|
|
93335
|
-
import { isAbsolute as isAbsolute16, join as
|
|
93605
|
+
import { isAbsolute as isAbsolute16, join as join34, relative as relative4 } from "node:path";
|
|
93336
93606
|
async function prepareDaemonReleaseVersion(version2, signal) {
|
|
93337
93607
|
runtimeUpgradeVersionSchema.parse(version2);
|
|
93338
93608
|
signal.throwIfAborted();
|
|
@@ -93413,7 +93683,7 @@ async function verifyInstalledDaemonRelease(installed, prefix, version2, signal)
|
|
|
93413
93683
|
bin: external_exports.object({ mobius: external_exports.literal("dist/cli.js") }),
|
|
93414
93684
|
engines: external_exports.object({ node: external_exports.string().refine((value) => (0, import_semver.validRange)(value) !== null) })
|
|
93415
93685
|
}).parse(JSON.parse(installed.manifest));
|
|
93416
|
-
const entry = await canonicalPath(
|
|
93686
|
+
const entry = await canonicalPath(join34(installed.packageRoot, metadata.bin.mobius));
|
|
93417
93687
|
const resolved = relative4(await canonicalPath(prefix), entry);
|
|
93418
93688
|
if (resolved.startsWith("..") || isAbsolute16(resolved)) {
|
|
93419
93689
|
throw new Error("Installed entry escaped npm prefix");
|
|
@@ -93537,24 +93807,24 @@ async function ensureWorkingProcess(stateDirectory, cliVersion, signal) {
|
|
|
93537
93807
|
const launch = await prepareDaemonReleaseVersion(version2, signal);
|
|
93538
93808
|
const deadline = AbortSignal.any([signal, AbortSignal.timeout(CONTROL_TIMEOUT_MILLISECONDS)]);
|
|
93539
93809
|
await ensureManager(stateDirectory, launch, deadline);
|
|
93540
|
-
const response =
|
|
93810
|
+
const response = decodeKnownLifecycleResponse(
|
|
93541
93811
|
await sendLocalRequest(stateDirectory, "manager", { kind: "ensure", launch }, deadline)
|
|
93542
93812
|
);
|
|
93543
|
-
if (response
|
|
93813
|
+
if (response?.kind === "error") {
|
|
93544
93814
|
throw new Error(response.message);
|
|
93545
93815
|
}
|
|
93546
|
-
if (response
|
|
93816
|
+
if (response?.kind !== "status" || response.worker?.version !== version2) {
|
|
93547
93817
|
throw new Error("The working daemon did not start");
|
|
93548
93818
|
}
|
|
93549
93819
|
return version2;
|
|
93550
93820
|
}
|
|
93551
93821
|
async function readWorkingProcessVersion(stateDirectory, signal) {
|
|
93552
93822
|
try {
|
|
93553
|
-
const response =
|
|
93823
|
+
const response = decodeKnownLifecycleResponse(
|
|
93554
93824
|
await sendLocalRequest(stateDirectory, "manager", { kind: "status" }, signal)
|
|
93555
93825
|
);
|
|
93556
|
-
if (response
|
|
93557
|
-
return response.
|
|
93826
|
+
if (response?.kind === "status") {
|
|
93827
|
+
return response.worker?.version ?? null;
|
|
93558
93828
|
}
|
|
93559
93829
|
} catch (cause) {
|
|
93560
93830
|
if (!isNodeError(cause, "ENOENT") && !isNodeError(cause, "ECONNREFUSED")) {
|
|
@@ -93567,10 +93837,10 @@ async function ensureManager(stateDirectory, launch, signal) {
|
|
|
93567
93837
|
let managerStarted = false;
|
|
93568
93838
|
while (!signal.aborted) {
|
|
93569
93839
|
try {
|
|
93570
|
-
const response =
|
|
93840
|
+
const response = decodeKnownLifecycleResponse(
|
|
93571
93841
|
await sendLocalRequest(stateDirectory, "manager", { kind: "status" }, signal)
|
|
93572
93842
|
);
|
|
93573
|
-
if (response
|
|
93843
|
+
if (response?.kind === "status") {
|
|
93574
93844
|
if (managerStarted) {
|
|
93575
93845
|
process.stdout.write(`Mobius daemon ${launch.version} started
|
|
93576
93846
|
`);
|
|
@@ -93604,13 +93874,13 @@ async function ensureManager(stateDirectory, launch, signal) {
|
|
|
93604
93874
|
}
|
|
93605
93875
|
async function stopManager(stateDirectory, signal) {
|
|
93606
93876
|
try {
|
|
93607
|
-
const response =
|
|
93877
|
+
const response = decodeKnownLifecycleResponse(
|
|
93608
93878
|
await sendLocalRequest(stateDirectory, "manager", { kind: "stop" }, signal)
|
|
93609
93879
|
);
|
|
93610
|
-
if (response
|
|
93880
|
+
if (response?.kind === "error") {
|
|
93611
93881
|
throw new Error(response.message);
|
|
93612
93882
|
}
|
|
93613
|
-
if (response
|
|
93883
|
+
if (response?.kind !== "stopped") {
|
|
93614
93884
|
throw new Error("The Mobius manager returned an unexpected response");
|
|
93615
93885
|
}
|
|
93616
93886
|
await waitForManagerExit(stateDirectory, signal);
|
|
@@ -93798,7 +94068,10 @@ function legacyState(receipt) {
|
|
|
93798
94068
|
if (receipt.outcome === null) {
|
|
93799
94069
|
return receipt.started ? "running" : "dispatching";
|
|
93800
94070
|
}
|
|
93801
|
-
const event =
|
|
94071
|
+
const event = decodeKnownSessionEventPayload(JSON.parse(receipt.outcome));
|
|
94072
|
+
if (event === null) {
|
|
94073
|
+
return "failed";
|
|
94074
|
+
}
|
|
93802
94075
|
return event.type === "lifecycle-metadata" && event.payload.kind === "prompt.completed" ? event.payload.stopReason === "cancelled" ? "cancelled" : "succeeded" : "failed";
|
|
93803
94076
|
}
|
|
93804
94077
|
var receiptSchema, identitySchema, ExecutionReceiptTable;
|
|
@@ -94782,7 +95055,11 @@ var init_session_configurations = __esm({
|
|
|
94782
95055
|
external_exports.object({ configId: external_exports.string().max(128), type: external_exports.literal("select"), value: external_exports.string().max(500) })
|
|
94783
95056
|
])
|
|
94784
95057
|
).max(100);
|
|
94785
|
-
decodeStoredSessionConfigurations = (value) => storedSessionConfigurationsSchema.parse(
|
|
95058
|
+
decodeStoredSessionConfigurations = (value) => storedSessionConfigurationsSchema.parse(
|
|
95059
|
+
Array.isArray(value) ? value.filter(
|
|
95060
|
+
(configuration) => typeof configuration !== "object" || configuration === null || !("type" in configuration) || typeof configuration.type !== "string" || configuration.type === "boolean" || configuration.type === "select"
|
|
95061
|
+
) : value
|
|
95062
|
+
);
|
|
94786
95063
|
SessionConfigurations = class {
|
|
94787
95064
|
#selected = [];
|
|
94788
95065
|
stored = () => this.#selected;
|
|
@@ -97405,7 +97682,7 @@ var init_execution_receipts = __esm({
|
|
|
97405
97682
|
};
|
|
97406
97683
|
outcome = (commandId) => {
|
|
97407
97684
|
const receipt = this.#executions.get(commandId);
|
|
97408
|
-
return receipt?.outcome === null || receipt === void 0 ? void 0 :
|
|
97685
|
+
return receipt?.outcome === null || receipt === void 0 ? void 0 : decodeKnownSessionEventPayload(JSON.parse(receipt.outcome)) ?? void 0;
|
|
97409
97686
|
};
|
|
97410
97687
|
/** Reserves an unseen command for cancellation before a delayed prompt can claim its identity. */
|
|
97411
97688
|
recordCancellationBeforeAdmission = (commandId, sessionId) => {
|
|
@@ -97468,7 +97745,10 @@ var init_execution_receipts = __esm({
|
|
|
97468
97745
|
code: "runtime_restarted",
|
|
97469
97746
|
message: "The local runtime restarted before this request started"
|
|
97470
97747
|
}
|
|
97471
|
-
} :
|
|
97748
|
+
} : decodeKnownSessionEventPayload(JSON.parse(receipt.outcome));
|
|
97749
|
+
if (event === null) {
|
|
97750
|
+
continue;
|
|
97751
|
+
}
|
|
97472
97752
|
const recordedAt = receipt.outcome === null ? (/* @__PURE__ */ new Date()).toISOString() : external_exports.object({ recordedAt: external_exports.string() }).parse(JSON.parse(receipt.outcome)).recordedAt;
|
|
97473
97753
|
recovered.push({ sessionId: receipt.sessionId, event, recordedAt });
|
|
97474
97754
|
if (receipt.outcome === null) {
|
|
@@ -97921,7 +98201,7 @@ var init_session_turns = __esm({
|
|
|
97921
98201
|
|
|
97922
98202
|
// src/session/workspace/workspace-directory.ts
|
|
97923
98203
|
import { homedir as homedir4 } from "node:os";
|
|
97924
|
-
import { basename as basename8, dirname as dirname11, isAbsolute as isAbsolute17, join as
|
|
98204
|
+
import { basename as basename8, dirname as dirname11, isAbsolute as isAbsolute17, join as join35, normalize as normalize2, relative as relative5 } from "node:path";
|
|
97925
98205
|
function encodePath(path8) {
|
|
97926
98206
|
const encoded = Buffer.from(path8, "utf8").toString("base64url");
|
|
97927
98207
|
if (path8.length === 0 || path8.length > MAX_WORKSPACE_PATH_LENGTH || encoded.length + "path-".length > MAX_DIRECTORY_IDENTIFIER_LENGTH) {
|
|
@@ -98050,7 +98330,7 @@ var init_workspace_directory = __esm({
|
|
|
98050
98330
|
continue;
|
|
98051
98331
|
}
|
|
98052
98332
|
try {
|
|
98053
|
-
const path8 = await this.resolvePath(
|
|
98333
|
+
const path8 = await this.resolvePath(join35(target, child.name), signal);
|
|
98054
98334
|
entries.push({ directoryId: encodePath(path8), name: child.name });
|
|
98055
98335
|
} catch (cause) {
|
|
98056
98336
|
signal.throwIfAborted();
|
|
@@ -98222,7 +98502,7 @@ var init_session_layer = __esm({
|
|
|
98222
98502
|
// src/storage/files/scratch-directory.ts
|
|
98223
98503
|
import { randomUUID as randomUUID18 } from "node:crypto";
|
|
98224
98504
|
import { lstat as lstat6, mkdir as mkdir5, readdir as readdir7, readFile as readFile12, realpath as realpath9, rename as rename5, rm as rm4, stat as stat8, utimes, writeFile as writeFile5 } from "node:fs/promises";
|
|
98225
|
-
import { dirname as dirname12, join as
|
|
98505
|
+
import { dirname as dirname12, join as join36 } from "node:path";
|
|
98226
98506
|
async function atomicWrite(path8, bytes, signal) {
|
|
98227
98507
|
const temporary = `${path8}.${randomUUID18()}.tmp`;
|
|
98228
98508
|
try {
|
|
@@ -98240,7 +98520,7 @@ var init_scratch_directory = __esm({
|
|
|
98240
98520
|
ScratchDirectory = class {
|
|
98241
98521
|
#root;
|
|
98242
98522
|
constructor(parent) {
|
|
98243
|
-
this.#root =
|
|
98523
|
+
this.#root = join36(parent, randomUUID18());
|
|
98244
98524
|
}
|
|
98245
98525
|
/** Refreshes this directory's lease and removes sibling directories whose lease is older than `leaseMilliseconds`. */
|
|
98246
98526
|
refreshLease = async (leaseMilliseconds) => {
|
|
@@ -98251,7 +98531,7 @@ var init_scratch_directory = __esm({
|
|
|
98251
98531
|
if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
|
|
98252
98532
|
continue;
|
|
98253
98533
|
}
|
|
98254
|
-
const path8 =
|
|
98534
|
+
const path8 = join36(dirname12(this.#root), directory.name);
|
|
98255
98535
|
if (path8 === this.#root) {
|
|
98256
98536
|
continue;
|
|
98257
98537
|
}
|
|
@@ -98266,10 +98546,10 @@ var init_scratch_directory = __esm({
|
|
|
98266
98546
|
};
|
|
98267
98547
|
/** Writes `bytes` atomically to `<group>/<name>` with owner-only permissions and returns the path. */
|
|
98268
98548
|
write = async (group, name2, bytes, signal) => {
|
|
98269
|
-
const directory =
|
|
98549
|
+
const directory = join36(this.#root, group);
|
|
98270
98550
|
await mkdir5(directory, { mode: 448, recursive: true });
|
|
98271
98551
|
signal.throwIfAborted();
|
|
98272
|
-
const path8 =
|
|
98552
|
+
const path8 = join36(directory, name2);
|
|
98273
98553
|
await atomicWrite(path8, bytes, signal);
|
|
98274
98554
|
return path8;
|
|
98275
98555
|
};
|
|
@@ -98304,7 +98584,7 @@ var init_scratch_directory = __esm({
|
|
|
98304
98584
|
|
|
98305
98585
|
// src/session/content/external-content-store.ts
|
|
98306
98586
|
import { createHash as createHash8 } from "node:crypto";
|
|
98307
|
-
import { join as
|
|
98587
|
+
import { join as join37 } from "node:path";
|
|
98308
98588
|
var contentRequest, CONTENT_LIFETIME_MILLISECONDS, metadataSchema, LocalExternalContentStore;
|
|
98309
98589
|
var init_external_content_store = __esm({
|
|
98310
98590
|
"src/session/content/external-content-store.ts"() {
|
|
@@ -98326,7 +98606,7 @@ var init_external_content_store = __esm({
|
|
|
98326
98606
|
#expirationTimer;
|
|
98327
98607
|
#cleanup = Promise.resolve();
|
|
98328
98608
|
constructor(stateDirectory) {
|
|
98329
|
-
this.#scratch = new ScratchDirectory(
|
|
98609
|
+
this.#scratch = new ScratchDirectory(join37(stateDirectory, "tmp", "session-content"));
|
|
98330
98610
|
this.#expirationTimer = setInterval(() => {
|
|
98331
98611
|
void this.#expire().catch(() => void 0);
|
|
98332
98612
|
}, 6e4);
|
|
@@ -98731,7 +99011,7 @@ var init_agent_process_pool = __esm({
|
|
|
98731
99011
|
});
|
|
98732
99012
|
|
|
98733
99013
|
// src/runtime/observability/diagnostic-log.ts
|
|
98734
|
-
import { join as
|
|
99014
|
+
import { join as join38 } from "node:path";
|
|
98735
99015
|
function exportedFields(value) {
|
|
98736
99016
|
const entry = {};
|
|
98737
99017
|
for (const field of REMOTE_DIAGNOSTIC_FIELDS) {
|
|
@@ -98800,7 +99080,7 @@ var init_diagnostic_log = __esm({
|
|
|
98800
99080
|
this.#maximumBytes = maximumBytes;
|
|
98801
99081
|
const processLogsDirectory = options.processLogsDirectory;
|
|
98802
99082
|
this.#sources = [
|
|
98803
|
-
{ maximumBytes, path:
|
|
99083
|
+
{ maximumBytes, path: join38(directory, DAEMON_LOG_FILENAME) },
|
|
98804
99084
|
// The process logs a Runtime does not own, but must read to explain its own deaths.
|
|
98805
99085
|
...processLogsDirectory === void 0 ? [] : processLogPaths(processLogsDirectory).map((path8) => ({ maximumBytes: null, path: path8 }))
|
|
98806
99086
|
];
|
|
@@ -99840,7 +100120,7 @@ var init_content_write = __esm({
|
|
|
99840
100120
|
});
|
|
99841
100121
|
|
|
99842
100122
|
// src/session/content/session-files.ts
|
|
99843
|
-
import { basename as basename9, extname as extname2, isAbsolute as isAbsolute18, join as
|
|
100123
|
+
import { basename as basename9, extname as extname2, isAbsolute as isAbsolute18, join as join39, normalize as normalize3, resolve as resolve18 } from "node:path";
|
|
99844
100124
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
99845
100125
|
function requestedPath(value) {
|
|
99846
100126
|
if (value.includes("\0")) {
|
|
@@ -99864,7 +100144,7 @@ async function resolveFile(value, workingDirectory, signal) {
|
|
|
99864
100144
|
if (isAbsolute18(requested.path) && normalize3(requested.path) !== requested.path) {
|
|
99865
100145
|
return null;
|
|
99866
100146
|
}
|
|
99867
|
-
const candidates = requested.explicitUrl || workingDirectory === null ? [requested.path] : isAbsolute18(requested.path) ? [
|
|
100147
|
+
const candidates = requested.explicitUrl || workingDirectory === null ? [requested.path] : isAbsolute18(requested.path) ? [join39(workingDirectory, requested.path), requested.path] : [resolve18(workingDirectory, requested.path)];
|
|
99868
100148
|
for (const candidate of candidates) {
|
|
99869
100149
|
if (!isAbsolute18(candidate) || normalize3(candidate) !== candidate) {
|
|
99870
100150
|
continue;
|
|
@@ -101793,35 +102073,6 @@ function closeRelaySocket(socket, code, reason) {
|
|
|
101793
102073
|
}
|
|
101794
102074
|
}
|
|
101795
102075
|
}
|
|
101796
|
-
function readCommandCorrelation(encoded) {
|
|
101797
|
-
let value;
|
|
101798
|
-
try {
|
|
101799
|
-
value = JSON.parse(encoded);
|
|
101800
|
-
} catch {
|
|
101801
|
-
return { requestId: "unsupported", sessionId: "" };
|
|
101802
|
-
}
|
|
101803
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
101804
|
-
return { requestId: "unsupported", sessionId: "" };
|
|
101805
|
-
}
|
|
101806
|
-
const requestId = Reflect.get(value, "requestId");
|
|
101807
|
-
const sessionId = Reflect.get(value, "sessionId");
|
|
101808
|
-
return {
|
|
101809
|
-
requestId: typeof requestId === "string" && isIdentifier(requestId) ? requestId : "unsupported",
|
|
101810
|
-
sessionId: typeof sessionId === "string" && isIdentifier(sessionId) ? sessionId : ""
|
|
101811
|
-
};
|
|
101812
|
-
}
|
|
101813
|
-
function rejectUnsupportedCommand(socket, correlation, rejection) {
|
|
101814
|
-
if (socket.readyState !== WebSocket8.OPEN) {
|
|
101815
|
-
return;
|
|
101816
|
-
}
|
|
101817
|
-
send(socket, {
|
|
101818
|
-
code: rejection.code,
|
|
101819
|
-
kind: SESSION_OPERATION_FAILED_KIND,
|
|
101820
|
-
message: "The Relay sent a command this daemon does not support",
|
|
101821
|
-
requestId: correlation.requestId,
|
|
101822
|
-
sessionId: correlation.sessionId
|
|
101823
|
-
});
|
|
101824
|
-
}
|
|
101825
102076
|
async function runRelayConnection({
|
|
101826
102077
|
resolveAgent,
|
|
101827
102078
|
config: config2,
|
|
@@ -101974,7 +102225,10 @@ async function runRelayConnection({
|
|
|
101974
102225
|
return;
|
|
101975
102226
|
}
|
|
101976
102227
|
try {
|
|
101977
|
-
const message =
|
|
102228
|
+
const message = decodeKnownServiceToDaemonMessage(encoded);
|
|
102229
|
+
if (message === null) {
|
|
102230
|
+
return;
|
|
102231
|
+
}
|
|
101978
102232
|
const kind = message.kind;
|
|
101979
102233
|
if (kind === RUNTIME_LIVENESS_READY_KIND) {
|
|
101980
102234
|
if (ready) {
|
|
@@ -101992,26 +102246,6 @@ async function runRelayConnection({
|
|
|
101992
102246
|
}
|
|
101993
102247
|
commands.dispatch(message);
|
|
101994
102248
|
} catch (error62) {
|
|
101995
|
-
if (error62 instanceof UnsupportedProtocolMessageKindError) {
|
|
101996
|
-
const correlation = readCommandCorrelation(encoded);
|
|
101997
|
-
console.warn("Mobius daemon rejected an unsupported Relay command", {
|
|
101998
|
-
code: error62.code,
|
|
101999
|
-
direction: error62.direction,
|
|
102000
|
-
messageKind: error62.messageKind
|
|
102001
|
-
});
|
|
102002
|
-
diagnostics.daemonDiagnostic(
|
|
102003
|
-
"relay_command_unsupported",
|
|
102004
|
-
correlation.requestId,
|
|
102005
|
-
{
|
|
102006
|
-
code: error62.code,
|
|
102007
|
-
direction: error62.direction,
|
|
102008
|
-
messageKind: error62.messageKind
|
|
102009
|
-
},
|
|
102010
|
-
error62
|
|
102011
|
-
);
|
|
102012
|
-
rejectUnsupportedCommand(socket, correlation, error62);
|
|
102013
|
-
return;
|
|
102014
|
-
}
|
|
102015
102249
|
console.error("Mobius daemon rejected a message", error62);
|
|
102016
102250
|
failAndClose(
|
|
102017
102251
|
new Error("Relay sent an invalid protocol message", { cause: error62 }),
|
|
@@ -102583,13 +102817,13 @@ async function requestDaemonReleaseUpgrade(stateDirectory, currentVersion, signa
|
|
|
102583
102817
|
}
|
|
102584
102818
|
async function requestInstalledDaemonReleaseSwitch(stateDirectory, launch, signal) {
|
|
102585
102819
|
const id = randomUUID20();
|
|
102586
|
-
const response =
|
|
102820
|
+
const response = decodeKnownLifecycleResponse(
|
|
102587
102821
|
await sendLocalRequest(stateDirectory, "manager", { kind: "switch", id, context: "npm", launch }, signal)
|
|
102588
102822
|
);
|
|
102589
|
-
if (response
|
|
102823
|
+
if (response?.kind === "error") {
|
|
102590
102824
|
throw new DaemonReleaseUpgradeError(response.code, response.message);
|
|
102591
102825
|
}
|
|
102592
|
-
if (response
|
|
102826
|
+
if (response?.kind !== "switching") {
|
|
102593
102827
|
throw new DaemonReleaseUpgradeError("manager_incompatible", "The manager does not support daemon switching");
|
|
102594
102828
|
}
|
|
102595
102829
|
return { kind: "requested", id, version: launch.version };
|
|
@@ -102957,7 +103191,7 @@ var init_daemon = __esm({
|
|
|
102957
103191
|
});
|
|
102958
103192
|
|
|
102959
103193
|
// src/cli/handler/logs/logic/collect-local-logs.ts
|
|
102960
|
-
import { join as
|
|
103194
|
+
import { join as join40, relative as relative6, resolve as resolve19 } from "node:path";
|
|
102961
103195
|
async function collectLocalDaemonLogs(stateDirectory, tailLines, signal) {
|
|
102962
103196
|
signal.throwIfAborted();
|
|
102963
103197
|
const root = resolve19(stateDirectory);
|
|
@@ -102967,7 +103201,7 @@ async function collectLocalDaemonLogs(stateDirectory, tailLines, signal) {
|
|
|
102967
103201
|
for (const directory of directories) {
|
|
102968
103202
|
const names = await listLogFiles(directory, root, unreadable);
|
|
102969
103203
|
for (const name2 of names) {
|
|
102970
|
-
const path8 =
|
|
103204
|
+
const path8 = join40(directory, name2);
|
|
102971
103205
|
const reported = relative6(root, path8);
|
|
102972
103206
|
const read = await readOwnedLogFile(path8, signal);
|
|
102973
103207
|
if (read.kind === "unreadable") {
|