@moxt-ai/mobius 0.0.194 → 0.0.196

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.
Files changed (63) hide show
  1. package/dist/acp/agent-connection.d.ts.map +1 -1
  2. package/dist/acp/agent-connection.js +4 -3
  3. package/dist/acp/agent-connection.js.map +1 -1
  4. package/dist/acp/codex/app-server-client.d.ts.map +1 -1
  5. package/dist/acp/codex/app-server-client.js +4 -2
  6. package/dist/acp/codex/app-server-client.js.map +1 -1
  7. package/dist/agent-catalog/acp-readiness-probe.d.ts.map +1 -1
  8. package/dist/agent-catalog/acp-readiness-probe.js +4 -3
  9. package/dist/agent-catalog/acp-readiness-probe.js.map +1 -1
  10. package/dist/cli.js +630 -343
  11. package/dist/cli.js.map +4 -4
  12. package/dist/daemon-history-commands.d.ts.map +1 -1
  13. package/dist/daemon-history-commands.js +70 -29
  14. package/dist/daemon-history-commands.js.map +1 -1
  15. package/dist/daemon-manager.d.ts.map +1 -1
  16. package/dist/daemon-manager.js +7 -17
  17. package/dist/daemon-manager.js.map +1 -1
  18. package/dist/filesystem/path-error.d.ts +5 -0
  19. package/dist/filesystem/path-error.d.ts.map +1 -0
  20. package/dist/filesystem/path-error.js +8 -0
  21. package/dist/filesystem/path-error.js.map +1 -0
  22. package/dist/filesystem/private-path.d.ts +3 -0
  23. package/dist/filesystem/private-path.d.ts.map +1 -0
  24. package/dist/filesystem/private-path.js +550 -0
  25. package/dist/filesystem/private-path.js.map +7 -0
  26. package/dist/index.js +602 -306
  27. package/dist/index.js.map +4 -4
  28. package/dist/native-sessions/codex-history.d.ts.map +1 -1
  29. package/dist/native-sessions/codex-history.js +4 -3
  30. package/dist/native-sessions/codex-history.js.map +1 -1
  31. package/dist/platform/contracts.d.ts +21 -0
  32. package/dist/platform/contracts.d.ts.map +1 -1
  33. package/dist/platform/index.d.ts.map +1 -1
  34. package/dist/platform/index.js +5 -3
  35. package/dist/platform/index.js.map +1 -1
  36. package/dist/platform/linux.d.ts.map +1 -1
  37. package/dist/platform/linux.js +2 -1
  38. package/dist/platform/linux.js.map +1 -1
  39. package/dist/platform/macos.d.ts.map +1 -1
  40. package/dist/platform/macos.js +2 -1
  41. package/dist/platform/macos.js.map +1 -1
  42. package/dist/platform/posix.d.ts +28 -1
  43. package/dist/platform/posix.d.ts.map +1 -1
  44. package/dist/platform/posix.js +91 -1
  45. package/dist/platform/posix.js.map +1 -1
  46. package/dist/platform/windows.d.ts +3 -0
  47. package/dist/platform/windows.d.ts.map +1 -0
  48. package/dist/platform/windows.js +174 -0
  49. package/dist/platform/windows.js.map +1 -0
  50. package/dist/process/executable.d.ts +7 -5
  51. package/dist/process/executable.d.ts.map +1 -1
  52. package/dist/process/executable.js +844 -386
  53. package/dist/process/executable.js.map +7 -1
  54. package/dist/process/process-error.d.ts +5 -0
  55. package/dist/process/process-error.d.ts.map +1 -0
  56. package/dist/process/process-error.js +9 -0
  57. package/dist/process/process-error.js.map +1 -0
  58. package/dist/runtime.js +602 -306
  59. package/dist/runtime.js.map +4 -4
  60. package/dist/storage/runtime-installation-store.d.ts.map +1 -1
  61. package/dist/storage/runtime-installation-store.js +3 -0
  62. package/dist/storage/runtime-installation-store.js.map +1 -1
  63. package/package.json +72 -70
package/dist/cli.js CHANGED
@@ -8,7 +8,7 @@ var __export = (target, all) => {
8
8
  // src/cli.ts
9
9
  import { constants as constants3 } from "node:fs";
10
10
  import { mkdir as mkdir7, open as open6 } from "node:fs/promises";
11
- import { resolve as resolve8 } from "node:path";
11
+ import { resolve as resolve9 } from "node:path";
12
12
 
13
13
  // ../../node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
14
14
  var CommanderError = class extends Error {
@@ -3381,7 +3381,7 @@ var program = new Command();
3381
3381
  // package.json
3382
3382
  var package_default = {
3383
3383
  name: "@moxt-ai/mobius",
3384
- version: "0.0.194",
3384
+ version: "0.0.196",
3385
3385
  description: "Mobius CLI for pairing and running local AI agent services.",
3386
3386
  type: "module",
3387
3387
  bin: {
@@ -3390,7 +3390,9 @@ var package_default = {
3390
3390
  types: "./src/index.ts",
3391
3391
  exports: {
3392
3392
  ".": "./src/index.ts",
3393
- "./runtime": "./src/runtime.ts"
3393
+ "./runtime": "./src/runtime.ts",
3394
+ "./process": "./src/process/executable.ts",
3395
+ "./filesystem": "./src/filesystem/private-path.ts"
3394
3396
  },
3395
3397
  files: [
3396
3398
  "dist"
@@ -3409,6 +3411,14 @@ var package_default = {
3409
3411
  "./runtime": {
3410
3412
  types: "./dist/runtime.d.ts",
3411
3413
  import: "./dist/runtime.js"
3414
+ },
3415
+ "./process": {
3416
+ types: "./dist/process/executable.d.ts",
3417
+ import: "./dist/process/executable.js"
3418
+ },
3419
+ "./filesystem": {
3420
+ types: "./dist/filesystem/private-path.d.ts",
3421
+ import: "./dist/filesystem/private-path.js"
3412
3422
  }
3413
3423
  }
3414
3424
  },
@@ -3418,7 +3428,7 @@ var package_default = {
3418
3428
  directory: "packages/cli"
3419
3429
  },
3420
3430
  scripts: {
3421
- build: "tsc --project tsconfig.build.json && esbuild src/cli.ts src/index.ts src/runtime.ts --bundle --platform=node --format=esm --sourcemap --outdir=dist --external:@agentclientprotocol/* --external:undici",
3431
+ build: "tsc --project tsconfig.build.json && esbuild src/cli.ts src/index.ts src/runtime.ts src/process/executable.ts src/filesystem/private-path.ts --bundle --platform=node --format=esm --sourcemap --outdir=dist --external:@agentclientprotocol/* --external:undici",
3422
3432
  dev: "node --watch src/cli.ts",
3423
3433
  prepack: "pnpm build",
3424
3434
  start: "node dist/cli.js",
@@ -3506,17 +3516,31 @@ function normalizeAcpCapabilities(initialized) {
3506
3516
 
3507
3517
  // src/process/executable.ts
3508
3518
  import { spawn } from "node:child_process";
3509
- import { constants as constants2 } from "node:fs";
3510
- import { access as access2, realpath as realpath2, stat as stat2 } from "node:fs/promises";
3511
- import { join as join3, resolve } from "node:path";
3519
+ import { stat as stat2 } from "node:fs/promises";
3520
+ import { join as join5, resolve as resolve2 } from "node:path";
3512
3521
 
3513
3522
  // src/platform/linux.ts
3514
- import { constants, readdirSync, readFileSync } from "node:fs";
3515
- import { access, readdir, readFile, realpath, stat } from "node:fs/promises";
3516
- import { join } from "node:path";
3523
+ import { constants as constants2, readdirSync, readFileSync } from "node:fs";
3524
+ import { access as access2, readdir, readFile, realpath as realpath2, stat } from "node:fs/promises";
3525
+ import { join as join2 } from "node:path";
3517
3526
 
3518
3527
  // src/platform/posix.ts
3519
3528
  import { execFile } from "node:child_process";
3529
+ import { constants } from "node:fs";
3530
+ import { access, chmod, lstat, realpath, unlink } from "node:fs/promises";
3531
+ import { tmpdir } from "node:os";
3532
+ import { join } from "node:path";
3533
+
3534
+ // src/filesystem/path-error.ts
3535
+ var LocalPathError = class extends Error {
3536
+ code = "unsafe_local_path";
3537
+ constructor(message, options = {}) {
3538
+ super(message, options);
3539
+ this.name = "LocalPathError";
3540
+ }
3541
+ };
3542
+
3543
+ // src/platform/posix.ts
3520
3544
  var PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
3521
3545
  var PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
3522
3546
  function parseProcessTable(output2) {
@@ -3561,6 +3585,81 @@ function processExists(processId) {
3561
3585
  return false;
3562
3586
  }
3563
3587
  }
3588
+ function signalCapturedProcesses(processes, rootProcessId, signal) {
3589
+ const processIds = new Set(processes.map((identity2) => identity2.processId));
3590
+ const signalledGroups = /* @__PURE__ */ new Set();
3591
+ for (const identity2 of processes) {
3592
+ const isRootProcessGroup = identity2.processGroupId === rootProcessId;
3593
+ if (!isRootProcessGroup && !processIds.has(identity2.processGroupId) || signalledGroups.has(identity2.processGroupId)) {
3594
+ continue;
3595
+ }
3596
+ try {
3597
+ process.kill(-identity2.processGroupId, signal);
3598
+ signalledGroups.add(identity2.processGroupId);
3599
+ } catch {
3600
+ }
3601
+ }
3602
+ for (const identity2 of processes) {
3603
+ if (identity2.processId === rootProcessId || identity2.processGroupId === rootProcessId || signalledGroups.has(identity2.processGroupId)) {
3604
+ continue;
3605
+ }
3606
+ try {
3607
+ process.kill(identity2.processId, signal);
3608
+ } catch {
3609
+ }
3610
+ }
3611
+ }
3612
+ function terminateProcess(child2, signal) {
3613
+ if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
3614
+ return;
3615
+ }
3616
+ try {
3617
+ process.kill(-child2.pid, signal);
3618
+ return;
3619
+ } catch {
3620
+ }
3621
+ child2.kill(signal);
3622
+ }
3623
+ async function removeControlSocket(path3) {
3624
+ try {
3625
+ await unlink(path3);
3626
+ } catch (cause) {
3627
+ if (!(cause instanceof Error) || !("code" in cause) || cause.code !== "ENOENT") {
3628
+ throw cause;
3629
+ }
3630
+ }
3631
+ }
3632
+ var posixOperations = {
3633
+ controlSocketPath: (installationHash) => join(tmpdir(), `mobius-${installationHash}.sock`),
3634
+ prepareControlSocket: removeControlSocket,
3635
+ secureControlSocket: async (path3) => {
3636
+ await chmod(path3, 384);
3637
+ },
3638
+ removeControlSocket,
3639
+ pathDelimiter: ":",
3640
+ environmentValue: (environment, name2) => environment[name2],
3641
+ executableExtensions: () => [""],
3642
+ resolveExecutableTarget: async (path3) => {
3643
+ const target = await realpath(path3);
3644
+ await access(target, constants.X_OK);
3645
+ return target;
3646
+ },
3647
+ executableLaunch: (command, args) => ({ command, arguments: args }),
3648
+ spawnOptions: { detached: true, windowsHide: true },
3649
+ signalCapturedProcesses,
3650
+ terminateProcess,
3651
+ validatePathPermissions: async (path3, directory, privateAccess, signal) => {
3652
+ signal.throwIfAborted();
3653
+ const metadata = await lstat(path3);
3654
+ if (process.getuid === void 0 || metadata.uid !== process.getuid()) {
3655
+ throw new LocalPathError("Path is not user-owned");
3656
+ }
3657
+ if (privateAccess) {
3658
+ await chmod(path3, directory ? 448 : 384);
3659
+ }
3660
+ signal.throwIfAborted();
3661
+ }
3662
+ };
3564
3663
 
3565
3664
  // src/platform/linux.ts
3566
3665
  function appendLinuxProcessTableEntry(entries, processId, encoded) {
@@ -3592,7 +3691,7 @@ async function readLinuxProcessTable() {
3592
3691
  appendLinuxProcessTableEntry(
3593
3692
  entries,
3594
3693
  processId,
3595
- await readFile(join("/proc", directory.name, "stat"), "utf8")
3694
+ await readFile(join2("/proc", directory.name, "stat"), "utf8")
3596
3695
  );
3597
3696
  } catch {
3598
3697
  }
@@ -3617,7 +3716,7 @@ function readLinuxProcessTableSynchronously() {
3617
3716
  appendLinuxProcessTableEntry(
3618
3717
  entries,
3619
3718
  processId,
3620
- readFileSync(join("/proc", directory.name, "stat"), "utf8")
3719
+ readFileSync(join2("/proc", directory.name, "stat"), "utf8")
3621
3720
  );
3622
3721
  } catch {
3623
3722
  }
@@ -3633,11 +3732,11 @@ async function readLinuxProcessTableWithFallback() {
3633
3732
  }
3634
3733
  for (const candidate of ["/usr/bin/ps", "/bin/ps", "/run/current-system/sw/bin/ps"]) {
3635
3734
  try {
3636
- const resolvedPath = await realpath(candidate);
3735
+ const resolvedPath = await realpath2(candidate);
3637
3736
  if (!(await stat(resolvedPath)).isFile()) {
3638
3737
  continue;
3639
3738
  }
3640
- await access(resolvedPath, constants.X_OK);
3739
+ await access2(resolvedPath, constants2.X_OK);
3641
3740
  } catch {
3642
3741
  continue;
3643
3742
  }
@@ -3650,7 +3749,7 @@ async function readLinuxProcessTableWithFallback() {
3650
3749
  }
3651
3750
  function processExists2(processId) {
3652
3751
  try {
3653
- const encoded = readFileSync(join("/proc", processId.toString(), "stat"), "utf8");
3752
+ const encoded = readFileSync(join2("/proc", processId.toString(), "stat"), "utf8");
3654
3753
  const closingParenthesis = encoded.lastIndexOf(")");
3655
3754
  if (closingParenthesis >= 0) {
3656
3755
  const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
@@ -3663,6 +3762,7 @@ function processExists2(processId) {
3663
3762
  return processExists(processId);
3664
3763
  }
3665
3764
  var linuxPlatform = {
3765
+ ...posixOperations,
3666
3766
  readProcessTable: readLinuxProcessTableWithFallback,
3667
3767
  readProcessTableSynchronously: readLinuxProcessTableSynchronously,
3668
3768
  processExists: processExists2,
@@ -3694,7 +3794,7 @@ var linuxPlatform = {
3694
3794
  };
3695
3795
 
3696
3796
  // src/platform/macos.ts
3697
- import { isAbsolute, join as join2 } from "node:path";
3797
+ import { isAbsolute, join as join3 } from "node:path";
3698
3798
  var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
3699
3799
  "WorkBuddy.app",
3700
3800
  "Contents",
@@ -3705,14 +3805,15 @@ var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
3705
3805
  "codebuddy"
3706
3806
  ]);
3707
3807
  var macosPlatform = {
3808
+ ...posixOperations,
3708
3809
  readProcessTable: () => readProcessTableWithPs("/bin/ps"),
3709
3810
  readProcessTableSynchronously: () => [],
3710
3811
  processExists,
3711
3812
  workBuddyExecutablePaths: (environment) => {
3712
- const paths = [join2("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
3813
+ const paths = [join3("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
3713
3814
  const homeDirectory = environment["HOME"];
3714
3815
  if (homeDirectory !== void 0 && isAbsolute(homeDirectory)) {
3715
- paths.unshift(join2(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
3816
+ paths.unshift(join3(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
3716
3817
  }
3717
3818
  return paths;
3718
3819
  },
@@ -3742,8 +3843,199 @@ var macosPlatform = {
3742
3843
  }
3743
3844
  };
3744
3845
 
3846
+ // src/platform/windows.ts
3847
+ import { execFile as execFile2 } from "node:child_process";
3848
+ import { readFile as readFile2, realpath as realpath3 } from "node:fs/promises";
3849
+ import { dirname, extname, join as join4, resolve } from "node:path";
3850
+ import { promisify } from "node:util";
3851
+
3852
+ // src/process/process-error.ts
3853
+ var ProcessExecutionError = class extends Error {
3854
+ code;
3855
+ constructor(code, message, options = {}) {
3856
+ super(message, options);
3857
+ this.code = code;
3858
+ this.name = "ProcessExecutionError";
3859
+ }
3860
+ };
3861
+
3862
+ // src/platform/windows.ts
3863
+ var execute = promisify(execFile2);
3864
+ function environmentValue(environment, name2) {
3865
+ return Object.entries(environment).find(([key]) => key.toUpperCase() === name2.toUpperCase())?.[1];
3866
+ }
3867
+ function executableExtensions(executableName, environment) {
3868
+ if (/\.[a-zA-Z0-9]+$/.test(executableName)) {
3869
+ return [""];
3870
+ }
3871
+ const configured = environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD";
3872
+ const extensions = configured.split(";").map((extension) => extension.trim()).filter((extension) => extension.length > 0).map((extension) => extension.startsWith(".") ? extension : `.${extension}`);
3873
+ return extensions.length > 0 ? extensions : [".EXE"];
3874
+ }
3875
+ async function resolveExecutableTarget(path3) {
3876
+ let resolvedPath;
3877
+ try {
3878
+ resolvedPath = await realpath3(extname(path3) === "" ? `${path3}.cmd` : path3);
3879
+ } catch (cause) {
3880
+ if (extname(path3) !== "" || !(cause instanceof Error) || !("code" in cause) || cause.code !== "ENOENT") {
3881
+ throw cause;
3882
+ }
3883
+ resolvedPath = await realpath3(path3);
3884
+ }
3885
+ if (extname(resolvedPath).toLowerCase() === ".cmd") {
3886
+ const shim = await readFile2(resolvedPath, "utf8");
3887
+ const script = /"%_prog%"\s+"%dp0%[\\/]([^"\r\n]+\.(?:js|mjs|cjs))"\s+%\*/iu.exec(shim)?.[1];
3888
+ if (script !== void 0 && shim.includes("SET dp0=%~dp0")) {
3889
+ resolvedPath = await realpath3(resolve(dirname(resolvedPath), script));
3890
+ } else {
3891
+ const pnpmScript = /^\s*node\s+"%~dp0[\\/]([^"\r\n]+\.(?:js|mjs|cjs))"\s+%\*\s*$/imu.exec(shim)?.[1];
3892
+ if (pnpmScript === void 0 || !shim.includes("@SETLOCAL")) {
3893
+ throw new ProcessExecutionError(
3894
+ "process_unsupported_script",
3895
+ "Use a native executable or a verified Node entrypoint"
3896
+ );
3897
+ }
3898
+ resolvedPath = await realpath3(resolve(dirname(resolvedPath), pnpmScript));
3899
+ }
3900
+ }
3901
+ return resolvedPath;
3902
+ }
3903
+ function executableLaunch(command, args) {
3904
+ if (/\.(?:js|mjs|cjs)$/iu.test(command)) {
3905
+ return { command: process.execPath, arguments: [command, ...args] };
3906
+ }
3907
+ if (/\.(?:cmd|bat)$/iu.test(command)) {
3908
+ throw new ProcessExecutionError(
3909
+ "process_unsupported_script",
3910
+ "Use a native executable or a verified Node entrypoint"
3911
+ );
3912
+ }
3913
+ return { command, arguments: args };
3914
+ }
3915
+ function readProcessTable() {
3916
+ const systemRoot = environmentValue(process.env, "SystemRoot");
3917
+ if (systemRoot === void 0) {
3918
+ return Promise.resolve([]);
3919
+ }
3920
+ return new Promise((resolveTable) => {
3921
+ execFile2(
3922
+ join4(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
3923
+ [
3924
+ "-NoLogo",
3925
+ "-NoProfile",
3926
+ "-NonInteractive",
3927
+ "-Command",
3928
+ "Get-CimInstance Win32_Process | ForEach-Object { '{0} {1} {0}' -f $_.ProcessId, $_.ParentProcessId }"
3929
+ ],
3930
+ {
3931
+ encoding: "utf8",
3932
+ windowsHide: true,
3933
+ timeout: 1e4,
3934
+ signal: AbortSignal.timeout(1e4),
3935
+ maxBuffer: 1024 * 1024
3936
+ },
3937
+ (error62, stdout) => resolveTable(error62 === null ? parseProcessTable(stdout) : [])
3938
+ );
3939
+ });
3940
+ }
3941
+ function signalCapturedProcesses2(processes, _rootProcessId, signal) {
3942
+ for (const identity2 of [...processes].reverse()) {
3943
+ try {
3944
+ process.kill(identity2.processId, signal);
3945
+ } catch {
3946
+ }
3947
+ }
3948
+ }
3949
+ function terminateProcess2(child2, signal) {
3950
+ if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
3951
+ return;
3952
+ }
3953
+ child2.kill(signal);
3954
+ }
3955
+ var windowsPermissions = `
3956
+ $ErrorActionPreference = 'Stop'
3957
+ Import-Module (Join-Path $PSHOME 'Modules/Microsoft.PowerShell.Security/Microsoft.PowerShell.Security.psd1')
3958
+ $item = Get-Item -LiteralPath $env:MOBIUS_PERMISSION_PATH -Force
3959
+ if (($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0) { throw 'Unsafe path' }
3960
+ $sid = [Security.Principal.WindowsIdentity]::GetCurrent().User
3961
+ $acl = Get-Acl -LiteralPath $item.FullName
3962
+ $owner = $acl.GetOwner([Security.Principal.SecurityIdentifier])
3963
+ 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' }
3964
+ if ($env:MOBIUS_PERMISSION_PRIVATE -eq '1') {
3965
+ if ($item.PSIsContainer) {
3966
+ $private = New-Object Security.AccessControl.DirectorySecurity
3967
+ $rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'ContainerInherit,ObjectInherit', 'None', 'Allow')
3968
+ } else {
3969
+ $private = New-Object Security.AccessControl.FileSecurity
3970
+ $rule = New-Object Security.AccessControl.FileSystemAccessRule($sid, 'FullControl', 'Allow')
3971
+ }
3972
+ $private.SetOwner($sid)
3973
+ $private.SetAccessRuleProtection($true, $false)
3974
+ $private.AddAccessRule($rule)
3975
+ Set-Acl -LiteralPath $item.FullName -AclObject $private
3976
+ }
3977
+ `;
3978
+ async function validatePathPermissions(path3, _directory, privateAccess, signal) {
3979
+ signal.throwIfAborted();
3980
+ const systemRoot = environmentValue(process.env, "SystemRoot");
3981
+ if (systemRoot === void 0) {
3982
+ throw new LocalPathError("Windows system directory is unavailable");
3983
+ }
3984
+ try {
3985
+ await execute(
3986
+ join4(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
3987
+ [
3988
+ "-NoLogo",
3989
+ "-NoProfile",
3990
+ "-NonInteractive",
3991
+ "-EncodedCommand",
3992
+ Buffer.from(windowsPermissions, "utf16le").toString("base64")
3993
+ ],
3994
+ {
3995
+ env: {
3996
+ ...process.env,
3997
+ MOBIUS_PERMISSION_PATH: path3,
3998
+ MOBIUS_PERMISSION_PRIVATE: privateAccess ? "1" : "0"
3999
+ },
4000
+ windowsHide: true,
4001
+ signal: AbortSignal.any([signal, AbortSignal.timeout(1e4)]),
4002
+ timeout: 1e4,
4003
+ maxBuffer: 16384
4004
+ }
4005
+ );
4006
+ } catch (cause) {
4007
+ signal.throwIfAborted();
4008
+ throw new LocalPathError("The local path permissions could not be secured", { cause });
4009
+ }
4010
+ }
4011
+ var windowsPlatform = {
4012
+ controlSocketPath: (installationHash) => `\\\\.\\pipe\\mobius-${installationHash}`,
4013
+ prepareControlSocket: async () => {
4014
+ },
4015
+ secureControlSocket: async () => {
4016
+ },
4017
+ removeControlSocket: async () => {
4018
+ },
4019
+ pathDelimiter: ";",
4020
+ environmentValue,
4021
+ executableExtensions,
4022
+ resolveExecutableTarget,
4023
+ executableLaunch,
4024
+ spawnOptions: { detached: false, windowsHide: true },
4025
+ signalCapturedProcesses: signalCapturedProcesses2,
4026
+ terminateProcess: terminateProcess2,
4027
+ validatePathPermissions,
4028
+ readProcessTable,
4029
+ readProcessTableSynchronously: () => [],
4030
+ processExists,
4031
+ workBuddyExecutablePaths: () => [],
4032
+ openCodeArchives: {},
4033
+ grokDependencies: {}
4034
+ };
4035
+
3745
4036
  // src/platform/index.ts
3746
4037
  var fallbackPlatform = {
4038
+ ...posixOperations,
3747
4039
  readProcessTable: () => readProcessTableWithPs("/usr/bin/ps"),
3748
4040
  readProcessTableSynchronously: () => [],
3749
4041
  processExists,
@@ -3754,7 +4046,7 @@ var fallbackPlatform = {
3754
4046
  var platforms = /* @__PURE__ */ new Map([
3755
4047
  ["linux", linuxPlatform],
3756
4048
  ["darwin", macosPlatform],
3757
- ["win32", { ...fallbackPlatform, readProcessTable: () => Promise.resolve([]) }]
4049
+ ["win32", windowsPlatform]
3758
4050
  ]);
3759
4051
  function platformSupportFor(platform) {
3760
4052
  return platforms.get(platform) ?? fallbackPlatform;
@@ -3793,14 +4085,6 @@ var ResolvedExecutable = class {
3793
4085
  this.path = identity2.realPath;
3794
4086
  }
3795
4087
  };
3796
- var ProcessExecutionError = class extends Error {
3797
- code;
3798
- constructor(code, message, options = {}) {
3799
- super(message, options);
3800
- this.code = code;
3801
- this.name = "ProcessExecutionError";
3802
- }
3803
- };
3804
4088
  var ProcessResult = class {
3805
4089
  stderr;
3806
4090
  stdout;
@@ -3809,28 +4093,14 @@ var ProcessResult = class {
3809
4093
  this.stdout = stdout;
3810
4094
  }
3811
4095
  };
3812
- function executableExtensions(executableName, environment, platform) {
3813
- if (platform !== "win32") {
3814
- return [""];
3815
- }
3816
- if (/\.[a-zA-Z0-9]+$/.test(executableName)) {
3817
- return [""];
3818
- }
3819
- const configured = environment["PATHEXT"] ?? ".COM;.EXE;.BAT;.CMD";
3820
- const extensions = configured.split(";").map((extension) => extension.trim()).filter((extension) => extension.length > 0).map((extension) => extension.startsWith(".") ? extension : `.${extension}`);
3821
- return extensions.length > 0 ? extensions : [".EXE"];
3822
- }
3823
4096
  async function resolveExecutablePath(requestedPath2, platform = process.platform) {
3824
- const absoluteRequestedPath = resolve(requestedPath2);
4097
+ const absoluteRequestedPath = resolve2(requestedPath2);
3825
4098
  try {
3826
- const resolvedPath = await realpath2(absoluteRequestedPath);
4099
+ const resolvedPath = await platformSupportFor(platform).resolveExecutableTarget(absoluteRequestedPath);
3827
4100
  const metadata = await stat2(resolvedPath);
3828
4101
  if (!metadata.isFile()) {
3829
4102
  return null;
3830
4103
  }
3831
- if (platform !== "win32") {
3832
- await access2(resolvedPath, constants2.X_OK);
3833
- }
3834
4104
  return new ResolvedExecutable(
3835
4105
  new ExecutableIdentity(
3836
4106
  absoluteRequestedPath,
@@ -3846,15 +4116,16 @@ async function resolveExecutablePath(requestedPath2, platform = process.platform
3846
4116
  }
3847
4117
  }
3848
4118
  async function findExecutableOnPath(executableName, environment, platform = process.platform) {
3849
- const encodedPath = environment["PATH"] ?? "";
3850
- const separator = platform === "win32" ? ";" : ":";
3851
- const extensions = executableExtensions(executableName, environment, platform);
4119
+ const support = platformSupportFor(platform);
4120
+ const encodedPath = support.environmentValue(environment, "PATH") ?? "";
4121
+ const separator = support.pathDelimiter;
4122
+ const extensions = support.executableExtensions(executableName, environment);
3852
4123
  for (const entry of encodedPath.split(separator)) {
3853
4124
  if (entry.length === 0) {
3854
4125
  continue;
3855
4126
  }
3856
4127
  for (const extension of extensions) {
3857
- const requestedPath2 = resolve(join3(entry, `${executableName}${extension}`));
4128
+ const requestedPath2 = resolve2(join5(entry, `${executableName}${extension}`));
3858
4129
  const executable = await resolveExecutablePath(requestedPath2, platform);
3859
4130
  if (executable !== null) {
3860
4131
  return executable;
@@ -3875,7 +4146,7 @@ function appendBounded(chunks, chunk, currentBytes, limitBytes) {
3875
4146
  chunks.push(chunk);
3876
4147
  return nextBytes;
3877
4148
  }
3878
- function readProcessTable() {
4149
+ function readProcessTable2() {
3879
4150
  return hostPlatform.readProcessTable();
3880
4151
  }
3881
4152
  function selectProcessTree(entries, rootProcessId) {
@@ -3910,38 +4181,14 @@ function mergeProcessTrees(captured, current) {
3910
4181
  return [...processes.values()];
3911
4182
  }
3912
4183
  async function captureProcessTree(child2) {
3913
- if (process.platform === "win32" || child2.pid === void 0) {
4184
+ if (child2.pid === void 0) {
3914
4185
  return [];
3915
4186
  }
3916
4187
  const entries = hostPlatform.readProcessTableSynchronously();
3917
4188
  if (entries.length > 0) {
3918
4189
  return selectProcessTree(entries, child2.pid);
3919
4190
  }
3920
- return selectProcessTree(await readProcessTable(), child2.pid);
3921
- }
3922
- function signalCapturedProcessGroups(processes, rootProcessId, signal) {
3923
- const processIds = new Set(processes.map((identity2) => identity2.processId));
3924
- const signalledGroups = /* @__PURE__ */ new Set();
3925
- for (const identity2 of processes) {
3926
- const isRootProcessGroup = identity2.processGroupId === rootProcessId;
3927
- if (!isRootProcessGroup && !processIds.has(identity2.processGroupId) || signalledGroups.has(identity2.processGroupId)) {
3928
- continue;
3929
- }
3930
- try {
3931
- process.kill(-identity2.processGroupId, signal);
3932
- signalledGroups.add(identity2.processGroupId);
3933
- } catch {
3934
- }
3935
- }
3936
- for (const identity2 of processes) {
3937
- if (identity2.processId === rootProcessId || identity2.processGroupId === rootProcessId || signalledGroups.has(identity2.processGroupId)) {
3938
- continue;
3939
- }
3940
- try {
3941
- process.kill(identity2.processId, signal);
3942
- } catch {
3943
- }
3944
- }
4191
+ return selectProcessTree(await readProcessTable2(), child2.pid);
3945
4192
  }
3946
4193
  async function waitForCapturedProcessesExit(processes, rootProcessId) {
3947
4194
  const processIds = processes.map((identity2) => identity2.processId).filter((processId) => processId !== rootProcessId);
@@ -3949,36 +4196,10 @@ async function waitForCapturedProcessesExit(processes, rootProcessId) {
3949
4196
  if (processIds.every((processId) => !hostPlatform.processExists(processId))) {
3950
4197
  return true;
3951
4198
  }
3952
- await readProcessTable();
4199
+ await readProcessTable2();
3953
4200
  }
3954
4201
  return processIds.every((processId) => !hostPlatform.processExists(processId));
3955
4202
  }
3956
- function terminateProcess(child2) {
3957
- if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
3958
- return;
3959
- }
3960
- if (process.platform !== "win32") {
3961
- try {
3962
- process.kill(-child2.pid, "SIGTERM");
3963
- return;
3964
- } catch {
3965
- }
3966
- }
3967
- child2.kill("SIGTERM");
3968
- }
3969
- function forceTerminateProcess(child2) {
3970
- if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
3971
- return;
3972
- }
3973
- if (process.platform !== "win32") {
3974
- try {
3975
- process.kill(-child2.pid, "SIGKILL");
3976
- return;
3977
- } catch {
3978
- }
3979
- }
3980
- child2.kill("SIGKILL");
3981
- }
3982
4203
  async function stopProcessTree(child2, capturedProcesses = []) {
3983
4204
  const childProcessId = child2.pid;
3984
4205
  if (childProcessId === void 0) {
@@ -3989,8 +4210,8 @@ async function stopProcessTree(child2, capturedProcesses = []) {
3989
4210
  if (childExited && processes.length === 0) {
3990
4211
  return;
3991
4212
  }
3992
- signalCapturedProcessGroups(processes, childProcessId, GRACEFUL_STOP_SIGNAL);
3993
- terminateProcess(child2);
4213
+ hostPlatform.signalCapturedProcesses(processes, childProcessId, GRACEFUL_STOP_SIGNAL);
4214
+ hostPlatform.terminateProcess(child2, "SIGTERM");
3994
4215
  const [exitedAfterTermination, descendantsExitedAfterTermination] = await Promise.all([
3995
4216
  waitForProcessExit(child2, PROCESS_GRACEFUL_STOP_TIMEOUT_MILLISECONDS),
3996
4217
  waitForCapturedProcessesExit(processes, childProcessId)
@@ -3998,8 +4219,8 @@ async function stopProcessTree(child2, capturedProcesses = []) {
3998
4219
  if (exitedAfterTermination && descendantsExitedAfterTermination) {
3999
4220
  return;
4000
4221
  }
4001
- signalCapturedProcessGroups(processes, childProcessId, FORCED_STOP_SIGNAL);
4002
- forceTerminateProcess(child2);
4222
+ hostPlatform.signalCapturedProcesses(processes, childProcessId, FORCED_STOP_SIGNAL);
4223
+ hostPlatform.terminateProcess(child2, "SIGKILL");
4003
4224
  const [exitedAfterForce, descendantsExitedAfterForce] = await Promise.all([
4004
4225
  waitForProcessExit(child2, PROCESS_FORCED_STOP_TIMEOUT_MILLISECONDS),
4005
4226
  waitForCapturedProcessesExit(processes, childProcessId)
@@ -4034,9 +4255,10 @@ function waitForProcessExit(child2, timeoutMilliseconds) {
4034
4255
  async function runBoundedProcess(options) {
4035
4256
  options.signal.throwIfAborted();
4036
4257
  const outputLimitBytes = options.outputLimitBytes ?? DEFAULT_OUTPUT_LIMIT_BYTES;
4037
- const child2 = spawn(options.command, [...options.arguments], {
4258
+ const launch = executableLaunch2(options.command, options.arguments);
4259
+ const child2 = spawn(launch.command, [...launch.arguments], {
4038
4260
  cwd: options.cwd,
4039
- detached: process.platform !== "win32",
4261
+ ...hostPlatform.spawnOptions,
4040
4262
  env: { ...options.environment },
4041
4263
  shell: false,
4042
4264
  stdio: ["ignore", "pipe", "pipe"]
@@ -4145,6 +4367,10 @@ async function runBoundedProcess(options) {
4145
4367
  }
4146
4368
  }
4147
4369
  }
4370
+ function executableLaunch2(command, args) {
4371
+ return hostPlatform.executableLaunch(command, args);
4372
+ }
4373
+ var platformSpawnOptions = hostPlatform.spawnOptions;
4148
4374
 
4149
4375
  // src/agent-catalog/local-agent.ts
4150
4376
  function readTrustedIdentity(path3) {
@@ -4537,8 +4763,8 @@ function formatAgentDiagnostics(inventory, json2, verbose = false) {
4537
4763
  }
4538
4764
 
4539
4765
  // src/agent-installation/managed-npm-package.ts
4540
- import { mkdir, mkdtemp, open, realpath as realpath3, rename, rm, stat as stat3 } from "node:fs/promises";
4541
- import { delimiter, dirname, isAbsolute as isAbsolute2, join as join4, relative, sep } from "node:path";
4766
+ import { mkdir, mkdtemp, open, realpath as realpath4, rename, rm, stat as stat3 } from "node:fs/promises";
4767
+ import { delimiter, dirname as dirname2, isAbsolute as isAbsolute2, join as join6, relative, sep } from "node:path";
4542
4768
  var INSTALL_TIMEOUT_MILLISECONDS = 5 * 60 * 1e3;
4543
4769
  var PACKAGE_METADATA_LIMIT_BYTES = 64 * 1024;
4544
4770
  var PACKAGE_LOCK_LIMIT_BYTES = 8 * 1024 * 1024;
@@ -4589,7 +4815,7 @@ function isRecord2(value) {
4589
4815
  return typeof value === "object" && value !== null && !Array.isArray(value);
4590
4816
  }
4591
4817
  function packagePath(root, packageName) {
4592
- return join4(root, "node_modules", ...packageName.split("/"));
4818
+ return join6(root, "node_modules", ...packageName.split("/"));
4593
4819
  }
4594
4820
  function isContainedPath(root, candidate) {
4595
4821
  const difference = relative(root, candidate);
@@ -4694,14 +4920,14 @@ function verifyPackageLockEntry(lock, definition, verifyDependencyClosure) {
4694
4920
  }
4695
4921
  }
4696
4922
  async function verifyRequiredDependency(rootPath, lock, definition) {
4697
- const dependencyRoot = await realpath3(packagePath(rootPath, definition.packageName));
4923
+ const dependencyRoot = await realpath4(packagePath(rootPath, definition.packageName));
4698
4924
  if (!isContainedPath(rootPath, dependencyRoot)) {
4699
4925
  throw new ManagedNpmPackageError(
4700
4926
  "managed_package_verification_failed",
4701
4927
  "The required managed npm dependency escaped its private cache"
4702
4928
  );
4703
4929
  }
4704
- const metadata = await readJsonRecord(join4(dependencyRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
4930
+ const metadata = await readJsonRecord(join6(dependencyRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
4705
4931
  if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
4706
4932
  throw new ManagedNpmPackageError(
4707
4933
  "managed_package_verification_failed",
@@ -4723,15 +4949,15 @@ async function validateManagedNpmPackage(root, definition) {
4723
4949
  }
4724
4950
  }
4725
4951
  async function validateManagedNpmPackageContents(root, definition) {
4726
- const rootPath = await realpath3(root);
4727
- const packageRoot = await realpath3(packagePath(rootPath, definition.packageName));
4952
+ const rootPath = await realpath4(root);
4953
+ const packageRoot = await realpath4(packagePath(rootPath, definition.packageName));
4728
4954
  if (!isContainedPath(rootPath, packageRoot)) {
4729
4955
  throw new ManagedNpmPackageError(
4730
4956
  "managed_package_verification_failed",
4731
4957
  "The managed npm package escaped its private cache"
4732
4958
  );
4733
4959
  }
4734
- const metadata = await readJsonRecord(join4(packageRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
4960
+ const metadata = await readJsonRecord(join6(packageRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
4735
4961
  if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
4736
4962
  throw new ManagedNpmPackageError(
4737
4963
  "managed_package_verification_failed",
@@ -4739,14 +4965,14 @@ async function validateManagedNpmPackageContents(root, definition) {
4739
4965
  );
4740
4966
  }
4741
4967
  if (definition instanceof SriManagedNpmPackageDefinition) {
4742
- const lock = await readJsonRecord(join4(rootPath, "package-lock.json"), PACKAGE_LOCK_LIMIT_BYTES);
4968
+ const lock = await readJsonRecord(join6(rootPath, "package-lock.json"), PACKAGE_LOCK_LIMIT_BYTES);
4743
4969
  verifyPackageLockEntry(lock, definition, definition.verifyDependencyClosure);
4744
4970
  for (const dependency of definition.requiredDependencies) {
4745
4971
  await verifyRequiredDependency(rootPath, lock, dependency);
4746
4972
  }
4747
4973
  }
4748
4974
  const declaredBin = readBinPath(metadata, definition.executableName);
4749
- const executable = await resolveExecutablePath(join4(packageRoot, declaredBin));
4975
+ const executable = await resolveExecutablePath(join6(packageRoot, declaredBin));
4750
4976
  if (executable === null || !isContainedPath(rootPath, executable.path)) {
4751
4977
  throw new ManagedNpmPackageError(
4752
4978
  "managed_package_verification_failed",
@@ -4768,9 +4994,9 @@ var ManagedNpmPackageInstaller = class {
4768
4994
  throw error62;
4769
4995
  }
4770
4996
  }
4771
- const parent = dirname(root);
4997
+ const parent = dirname2(root);
4772
4998
  await mkdir(parent, { mode: 448, recursive: true });
4773
- const staging = await mkdtemp(join4(parent, `.${definition.version}.staging-`));
4999
+ const staging = await mkdtemp(join6(parent, `.${definition.version}.staging-`));
4774
5000
  try {
4775
5001
  const npm = await findExecutableOnPath(process.platform === "win32" ? "npm.cmd" : "npm", environment);
4776
5002
  if (npm === null) {
@@ -4796,14 +5022,14 @@ var ManagedNpmPackageInstaller = class {
4796
5022
  `${definition.packageName}@${definition.version}`
4797
5023
  );
4798
5024
  const installEnvironment = {
4799
- HOME: join4(staging, "home"),
5025
+ HOME: join6(staging, "home"),
4800
5026
  NPM_CONFIG_AUDIT: "false",
4801
- NPM_CONFIG_CACHE: join4(staging, ".npm-cache"),
5027
+ NPM_CONFIG_CACHE: join6(staging, ".npm-cache"),
4802
5028
  NPM_CONFIG_FUND: "false",
4803
5029
  NPM_CONFIG_IGNORE_SCRIPTS: "true",
4804
5030
  NPM_CONFIG_PACKAGE_LOCK: "true",
4805
5031
  NPM_CONFIG_REGISTRY: "https://registry.npmjs.org/",
4806
- PATH: `${dirname(process.execPath)}${delimiter}/usr/bin${delimiter}/bin`
5032
+ PATH: `${dirname2(process.execPath)}${delimiter}/usr/bin${delimiter}/bin`
4807
5033
  };
4808
5034
  if (definition.includeOptionalDependencies) {
4809
5035
  installEnvironment["NPM_CONFIG_INCLUDE"] = "optional";
@@ -4820,8 +5046,8 @@ var ManagedNpmPackageInstaller = class {
4820
5046
  timeoutMilliseconds: INSTALL_TIMEOUT_MILLISECONDS
4821
5047
  });
4822
5048
  await Promise.all([
4823
- rm(join4(staging, ".npm-cache"), { force: true, recursive: true }),
4824
- rm(join4(staging, "home"), { force: true, recursive: true })
5049
+ rm(join6(staging, ".npm-cache"), { force: true, recursive: true }),
5050
+ rm(join6(staging, "home"), { force: true, recursive: true })
4825
5051
  ]);
4826
5052
  await validateManagedNpmPackage(staging, definition);
4827
5053
  try {
@@ -4857,7 +5083,7 @@ var ManagedNpmPackageInstaller = class {
4857
5083
  };
4858
5084
 
4859
5085
  // src/agent-catalog/agent-specification.ts
4860
- import { join as join5 } from "node:path";
5086
+ import { join as join7 } from "node:path";
4861
5087
 
4862
5088
  // src/agent-catalog/version-output.ts
4863
5089
  function normalizeVersionOutput(output2) {
@@ -4880,7 +5106,7 @@ var LocalAgentSpecification = class {
4880
5106
  resolveManagedAgent = async (stateDirectory, platform, signal) => {
4881
5107
  signal.throwIfAborted();
4882
5108
  const executable = await resolveExecutablePath(
4883
- join5(stateDirectory, ...this.managedAgentExecutablePath),
5109
+ join7(stateDirectory, ...this.managedAgentExecutablePath),
4884
5110
  platform
4885
5111
  );
4886
5112
  signal.throwIfAborted();
@@ -10112,7 +10338,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
10112
10338
  var NONE = 0;
10113
10339
  var ASSUMED = 1;
10114
10340
  var PROVEN = 2;
10115
- function isRecursive(inst, stack, resolve9) {
10341
+ function isRecursive(inst, stack, resolve10) {
10116
10342
  const cached2 = recursive.get(inst);
10117
10343
  if (cached2 !== void 0)
10118
10344
  return cached2 ? PROVEN : NONE;
@@ -10122,7 +10348,7 @@ function isRecursive(inst, stack, resolve9) {
10122
10348
  let result = NONE;
10123
10349
  const check2 = (child2) => {
10124
10350
  if (result !== PROVEN && child2?._zod) {
10125
- const answer = isRecursive(child2, stack, resolve9);
10351
+ const answer = isRecursive(child2, stack, resolve10);
10126
10352
  if (answer > result)
10127
10353
  result = answer;
10128
10354
  }
@@ -10133,7 +10359,7 @@ function isRecursive(inst, stack, resolve9) {
10133
10359
  const desc2 = Object.getOwnPropertyDescriptor(sh, key);
10134
10360
  if (spread && !desc2.enumerable)
10135
10361
  continue;
10136
- const child2 = desc2.get ? ASSUMED : desc2.value?._zod ? isRecursive(desc2.value, stack, resolve9) : NONE;
10362
+ const child2 = desc2.get ? ASSUMED : desc2.value?._zod ? isRecursive(desc2.value, stack, resolve10) : NONE;
10137
10363
  if (child2 > answer)
10138
10364
  answer = child2;
10139
10365
  }
@@ -10197,7 +10423,7 @@ function isRecursive(inst, stack, resolve9) {
10197
10423
  break;
10198
10424
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
10199
10425
  case "lazy": {
10200
- const inner = def._cachedInner ?? (resolve9 ? inst._zod.innerType : void 0);
10426
+ const inner = def._cachedInner ?? (resolve10 ? inst._zod.innerType : void 0);
10201
10427
  merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
10202
10428
  break;
10203
10429
  }
@@ -25032,9 +25258,10 @@ var CodexAppServerClient = class {
25032
25258
  #pendingFragments = [];
25033
25259
  constructor(options) {
25034
25260
  this.#handlers = options.handlers;
25035
- this.#child = spawn2(options.command, ["app-server"], {
25261
+ const launch = executableLaunch2(options.command, ["app-server"]);
25262
+ this.#child = spawn2(launch.command, [...launch.arguments], {
25036
25263
  cwd: options.cwd,
25037
- detached: process.platform !== "win32",
25264
+ ...platformSpawnOptions,
25038
25265
  env: { ...process.env, ...options.environment },
25039
25266
  shell: false,
25040
25267
  stdio: ["pipe", "pipe", "pipe"]
@@ -27091,6 +27318,7 @@ var provenanceSchema = external_exports.discriminatedUnion("kind", [
27091
27318
  ]);
27092
27319
  var sessionEventFieldsV2 = {
27093
27320
  eventId: identifierStringSchema,
27321
+ mobiusMetadata: external_exports.object({ omitted: external_exports.literal(true).optional() }).readonly().optional(),
27094
27322
  position: positionSchema,
27095
27323
  provenance: provenanceSchema,
27096
27324
  recordedAt: external_exports.iso.datetime({ offset: true }),
@@ -27157,7 +27385,12 @@ var sessionEventLogPageV2Schema = external_exports.object({
27157
27385
  truncated: external_exports.boolean(),
27158
27386
  version: external_exports.literal(2)
27159
27387
  }).readonly();
27160
- var nativeEventPageRequestV2Schema = external_exports.object({ cursor: external_exports.string().min(1).max(512).nullable(), eventLimit: external_exports.number().int().min(1).max(1e4) }).readonly();
27388
+ var sessionEventOmissionV2Schema = external_exports.literal("agent-reasoning");
27389
+ var nativeEventPageRequestV2Schema = external_exports.object({
27390
+ cursor: external_exports.string().min(1).max(512).nullable(),
27391
+ eventLimit: external_exports.number().int().min(1).max(1e4),
27392
+ omit: external_exports.array(sessionEventOmissionV2Schema).max(1).readonly().optional()
27393
+ }).readonly();
27161
27394
  var queuedPromptRequestEventLogV2Schema = external_exports.object({
27162
27395
  commandId: identifierStringSchema,
27163
27396
  content: external_exports.array(contentBlockV2Schema).min(1).max(100).readonly(),
@@ -27204,6 +27437,7 @@ var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-
27204
27437
  var pageRequestFields = {
27205
27438
  cursor: external_exports.string().min(1).max(512).nullable(),
27206
27439
  eventLimit: external_exports.number().int().min(1).max(1e4),
27440
+ omit: external_exports.array(sessionEventOmissionV2Schema).max(1).readonly().optional(),
27207
27441
  requestId: identifierStringSchema,
27208
27442
  sessionId: identifierStringSchema
27209
27443
  };
@@ -28760,7 +28994,7 @@ var AgentProbeError = class extends Error {
28760
28994
  };
28761
28995
 
28762
28996
  // src/agent-catalog/agents/resolve-user-local-executable.ts
28763
- import { isAbsolute as isAbsolute4, join as join6 } from "node:path";
28997
+ import { isAbsolute as isAbsolute4, join as join8 } from "node:path";
28764
28998
  async function resolveUserLocalExecutable(executableName, context) {
28765
28999
  context.signal.throwIfAborted();
28766
29000
  const platform = context.platform ?? process.platform;
@@ -28768,7 +29002,7 @@ async function resolveUserLocalExecutable(executableName, context) {
28768
29002
  if (platform === "win32" || homeDirectory === void 0 || !isAbsolute4(homeDirectory)) {
28769
29003
  return [];
28770
29004
  }
28771
- const executable = await resolveExecutablePath(join6(homeDirectory, ".local", "bin", executableName), platform);
29005
+ const executable = await resolveExecutablePath(join8(homeDirectory, ".local", "bin", executableName), platform);
28772
29006
  context.signal.throwIfAborted();
28773
29007
  return executable === null ? [] : [executable];
28774
29008
  }
@@ -28857,8 +29091,8 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
28857
29091
  };
28858
29092
 
28859
29093
  // src/agent-catalog/agents/deepseek-harness-agent.ts
28860
- import { mkdir as mkdir2, realpath as realpath4, stat as stat4, writeFile } from "node:fs/promises";
28861
- import { isAbsolute as isAbsolute5, join as join8, normalize } from "node:path";
29094
+ import { mkdir as mkdir2, realpath as realpath5, stat as stat4, writeFile } from "node:fs/promises";
29095
+ import { isAbsolute as isAbsolute5, join as join10, normalize } from "node:path";
28862
29096
 
28863
29097
  // src/agent-installation/deepseek-managed-package.ts
28864
29098
  var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
@@ -28876,13 +29110,13 @@ var DEEPSEEK_HARNESS_PACKAGE = new DeepSeekHarnessManagedPackage(
28876
29110
 
28877
29111
  // src/storage/state-directory.ts
28878
29112
  import { homedir } from "node:os";
28879
- import { join as join7, resolve as resolve2 } from "node:path";
29113
+ import { join as join9, resolve as resolve3 } from "node:path";
28880
29114
  function readStateDirectory(environment = process.env) {
28881
29115
  const configured = environment["MOBIUS_STATE_DIRECTORY"]?.trim();
28882
29116
  if (configured !== void 0 && configured.length > 0) {
28883
- return resolve2(configured);
29117
+ return resolve3(configured);
28884
29118
  }
28885
- return join7(homedir(), ".mobius");
29119
+ return join9(homedir(), ".mobius");
28886
29120
  }
28887
29121
 
28888
29122
  // src/agent-catalog/agents/deepseek-harness-agent.ts
@@ -28900,13 +29134,13 @@ async function prepareAgentHome(path3, imagePrompts) {
28900
29134
  if (imagePrompts) {
28901
29135
  await mkdir2(path3, { mode: 448, recursive: true });
28902
29136
  }
28903
- const resolved = await realpath4(path3);
29137
+ const resolved = await realpath5(path3);
28904
29138
  const metadata = await stat4(resolved);
28905
29139
  if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
28906
29140
  throw new Error("Agent home is not a user-owned directory");
28907
29141
  }
28908
29142
  if (imagePrompts) {
28909
- await writeFile(join8(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
29143
+ await writeFile(join10(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
28910
29144
  mode: 384
28911
29145
  });
28912
29146
  }
@@ -28954,7 +29188,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
28954
29188
  context.signal
28955
29189
  );
28956
29190
  if (managed.path === agent.path) {
28957
- selectedHome = join8(readStateDirectory(context.environment), "agents", this.id, "home");
29191
+ selectedHome = join10(readStateDirectory(context.environment), "agents", this.id, "home");
28958
29192
  managedHome = true;
28959
29193
  }
28960
29194
  } catch {
@@ -28970,7 +29204,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
28970
29204
  resolveManagedAgent = async (stateDirectory, _platform, signal) => {
28971
29205
  signal.throwIfAborted();
28972
29206
  const executable = await validateManagedNpmPackage(
28973
- join8(stateDirectory, "agents", this.id, DEEPSEEK_HARNESS_PACKAGE.version),
29207
+ join10(stateDirectory, "agents", this.id, DEEPSEEK_HARNESS_PACKAGE.version),
28974
29208
  DEEPSEEK_HARNESS_PACKAGE
28975
29209
  );
28976
29210
  signal.throwIfAborted();
@@ -29024,8 +29258,8 @@ var GeminiCliAgentSpecification = class extends DirectAcpAgentDefinition {
29024
29258
  };
29025
29259
 
29026
29260
  // src/agent-catalog/agents/grok-build-agent.ts
29027
- import { realpath as realpath5 } from "node:fs/promises";
29028
- import { isAbsolute as isAbsolute6, join as join9, relative as relative2, sep as sep2 } from "node:path";
29261
+ import { realpath as realpath6 } from "node:fs/promises";
29262
+ import { isAbsolute as isAbsolute6, join as join11, relative as relative2, sep as sep2 } from "node:path";
29029
29263
  import {
29030
29264
  RequestError
29031
29265
  } from "@agentclientprotocol/sdk";
@@ -29095,8 +29329,8 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
29095
29329
  );
29096
29330
  if (managed.path === agent.path) {
29097
29331
  return Object.freeze({
29098
- GROK_HOME: await realpath5(
29099
- join9(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION, "home")
29332
+ GROK_HOME: await realpath6(
29333
+ join11(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION, "home")
29100
29334
  )
29101
29335
  });
29102
29336
  }
@@ -29107,9 +29341,9 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
29107
29341
  };
29108
29342
  resolveManagedAgent = async (stateDirectory, platform, signal) => {
29109
29343
  signal.throwIfAborted();
29110
- const versionRoot = await realpath5(join9(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION));
29111
- await validateManagedNpmPackage(join9(versionRoot, "package"), grokBuildManagedPackage(platform, process.arch));
29112
- const executable = await resolveExecutablePath(join9(versionRoot, "home", "bin", "grok"), platform);
29344
+ const versionRoot = await realpath6(join11(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION));
29345
+ await validateManagedNpmPackage(join11(versionRoot, "package"), grokBuildManagedPackage(platform, process.arch));
29346
+ const executable = await resolveExecutablePath(join11(versionRoot, "home", "bin", "grok"), platform);
29113
29347
  signal.throwIfAborted();
29114
29348
  if (executable === null || !isContainedPath2(versionRoot, executable.path)) {
29115
29349
  throw new AgentProbeError("managed_agent_invalid", "The managed Grok Build executable is invalid");
@@ -29209,13 +29443,13 @@ var OhMyPiAgentSpecification = class extends DirectAcpAgentDefinition {
29209
29443
  };
29210
29444
 
29211
29445
  // src/agent-catalog/agents/opencode-agent.ts
29212
- import { join as join11 } from "node:path";
29446
+ import { join as join13 } from "node:path";
29213
29447
 
29214
29448
  // src/agent-installation/managed-agent-archive.ts
29215
29449
  import { createHash } from "node:crypto";
29216
29450
  import { createReadStream } from "node:fs";
29217
- import { chmod, copyFile, mkdir as mkdir3, mkdtemp as mkdtemp2, open as open3, realpath as realpath6, rename as rename2, rm as rm2, stat as stat5, writeFile as writeFile2 } from "node:fs/promises";
29218
- import { delimiter as delimiter2, dirname as dirname2, isAbsolute as isAbsolute7, join as join10, relative as relative3, sep as sep3 } from "node:path";
29451
+ import { chmod as chmod2, copyFile, mkdir as mkdir3, mkdtemp as mkdtemp2, open as open3, realpath as realpath7, rename as rename2, rm as rm2, stat as stat5, writeFile as writeFile2 } from "node:fs/promises";
29452
+ import { delimiter as delimiter2, dirname as dirname3, isAbsolute as isAbsolute7, join as join12, relative as relative3, sep as sep3 } from "node:path";
29219
29453
 
29220
29454
  // src/agent-installation/verified-download.ts
29221
29455
  import { fetch } from "undici";
@@ -29395,16 +29629,16 @@ async function readManifest(path3) {
29395
29629
  }
29396
29630
  async function validateManagedAgentArchive(root, definition, signal) {
29397
29631
  try {
29398
- const rootPath = await realpath6(root);
29632
+ const rootPath = await realpath7(root);
29399
29633
  const rootMetadata = await stat5(rootPath);
29400
29634
  if (!rootMetadata.isDirectory() || typeof process.getuid === "function" && rootMetadata.uid !== process.getuid()) {
29401
29635
  throw new Error("Managed Agent root is not user-owned");
29402
29636
  }
29403
- const manifest = await readManifest(join10(rootPath, "archive.json"));
29637
+ const manifest = await readManifest(join12(rootPath, "archive.json"));
29404
29638
  if (manifest["archiveSha256"] !== definition.archiveSha256 || manifest["archiveUrl"] !== definition.archiveUrl.toString() || manifest["version"] !== definition.version || typeof manifest["executableSha256"] !== "string") {
29405
29639
  throw new Error("Managed Agent archive identity is invalid");
29406
29640
  }
29407
- const executable = await resolveExecutablePath(join10(rootPath, "bin", definition.executableName));
29641
+ const executable = await resolveExecutablePath(join12(rootPath, "bin", definition.executableName));
29408
29642
  if (executable === null || !isContainedPath3(rootPath, executable.path) || await hashFile(executable.path, signal) !== manifest["executableSha256"]) {
29409
29643
  throw new Error("Managed Agent executable is invalid");
29410
29644
  }
@@ -29570,7 +29804,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
29570
29804
  return Object.freeze(environment);
29571
29805
  };
29572
29806
  resolveManagedAgent = async (stateDirectory, platform, signal) => await validateManagedAgentArchive(
29573
- join11(stateDirectory, "agents", this.id, OPENCODE_MANAGED_VERSION),
29807
+ join13(stateDirectory, "agents", this.id, OPENCODE_MANAGED_VERSION),
29574
29808
  openCodeManagedArchive(platform, process.arch),
29575
29809
  signal
29576
29810
  );
@@ -29588,7 +29822,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
29588
29822
  };
29589
29823
 
29590
29824
  // src/agent-catalog/agents/pi-agent.ts
29591
- import { join as join12 } from "node:path";
29825
+ import { join as join14 } from "node:path";
29592
29826
  import {
29593
29827
  methods as methods4
29594
29828
  } from "@agentclientprotocol/sdk";
@@ -29647,7 +29881,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
29647
29881
  resolveManagedAgent = async (stateDirectory, _platform, signal) => {
29648
29882
  signal.throwIfAborted();
29649
29883
  const executable = await validateManagedNpmPackage(
29650
- join12(stateDirectory, "agents", this.id, PI_AGENT_PACKAGE.version),
29884
+ join14(stateDirectory, "agents", this.id, PI_AGENT_PACKAGE.version),
29651
29885
  PI_AGENT_PACKAGE
29652
29886
  );
29653
29887
  signal.throwIfAborted();
@@ -29685,7 +29919,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
29685
29919
  };
29686
29920
 
29687
29921
  // src/agent-catalog/agents/workbuddy-agent.ts
29688
- import { join as join13 } from "node:path";
29922
+ import { join as join15 } from "node:path";
29689
29923
 
29690
29924
  // src/agent-installation/workbuddy-managed-package.ts
29691
29925
  var WORKBUDDY_MANAGED_VERSION = "2.146.0";
@@ -29731,7 +29965,7 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
29731
29965
  resolveManagedAgent = async (stateDirectory, _platform, signal) => {
29732
29966
  signal.throwIfAborted();
29733
29967
  const executable = await validateManagedNpmPackage(
29734
- join13(stateDirectory, "agents", this.id, WORKBUDDY_MANAGED_VERSION),
29968
+ join15(stateDirectory, "agents", this.id, WORKBUDDY_MANAGED_VERSION),
29735
29969
  WORKBUDDY_MANAGED_PACKAGE
29736
29970
  );
29737
29971
  signal.throwIfAborted();
@@ -29968,9 +30202,10 @@ async function probeAcpReadiness(specification, agent, environment, defaultWorks
29968
30202
  signal.removeEventListener("abort", abort);
29969
30203
  }
29970
30204
  }
29971
- const child2 = spawn3(agent.adapterPath, [...agent.arguments], {
30205
+ const launch = executableLaunch2(agent.adapterPath, agent.arguments);
30206
+ const child2 = spawn3(launch.command, [...launch.arguments], {
29972
30207
  cwd: defaultWorkspace,
29973
- detached: process.platform !== "win32",
30208
+ ...platformSpawnOptions,
29974
30209
  env: { ...environment, ...agent.environment },
29975
30210
  shell: false,
29976
30211
  stdio: ["pipe", "pipe", "pipe"]
@@ -30103,10 +30338,10 @@ function isAgentVersionSupported(reportedVersion, minimumSupportedVersion) {
30103
30338
  }
30104
30339
 
30105
30340
  // src/agent-catalog/executable-discovery.ts
30106
- import { isAbsolute as isAbsolute8, join as join15 } from "node:path";
30341
+ import { isAbsolute as isAbsolute8, join as join17 } from "node:path";
30107
30342
 
30108
30343
  // src/agent-installation/managed-adapter-installer.ts
30109
- import { join as join14 } from "node:path";
30344
+ import { join as join16 } from "node:path";
30110
30345
  var ManagedAdapterInstallError = class extends Error {
30111
30346
  code;
30112
30347
  constructor(code, message, options = {}) {
@@ -30163,7 +30398,7 @@ var ManagedAdapterInstaller = class {
30163
30398
  this.#stateDirectory = options.stateDirectory;
30164
30399
  }
30165
30400
  install = async (specification, signal) => {
30166
- const root = join14(this.#stateDirectory, "adapters", specification.id, specification.adapterVersion);
30401
+ const root = join16(this.#stateDirectory, "adapters", specification.id, specification.adapterVersion);
30167
30402
  try {
30168
30403
  return await this.#npmInstaller.install(
30169
30404
  root,
@@ -30197,7 +30432,7 @@ async function resolveManagedAdapterExecutable(specification, context) {
30197
30432
  let managed;
30198
30433
  try {
30199
30434
  managed = await validateManagedAdapter(
30200
- join15(readStateDirectory(context.environment), "adapters", specification.id, specification.adapterVersion),
30435
+ join17(readStateDirectory(context.environment), "adapters", specification.id, specification.adapterVersion),
30201
30436
  specification
30202
30437
  );
30203
30438
  } catch {
@@ -30511,16 +30746,16 @@ async function discoverLocalAgentInventory(options) {
30511
30746
  }
30512
30747
 
30513
30748
  // src/config.ts
30514
- import { join as join16, resolve as resolve3 } from "node:path";
30749
+ import { join as join18, resolve as resolve4 } from "node:path";
30515
30750
  function loadDefaultWorkspace(environment = process.env) {
30516
30751
  const { MOBIUS_DEFAULT_WORKSPACE: configuredWorkspace } = environment;
30517
- return configuredWorkspace ?? join16(readStateDirectory(environment), "workspace");
30752
+ return configuredWorkspace ?? join18(readStateDirectory(environment), "workspace");
30518
30753
  }
30519
30754
  var DaemonLocalContext = class {
30520
30755
  environment;
30521
30756
  stateDirectory;
30522
30757
  constructor(stateDirectory, environment = process.env) {
30523
- this.stateDirectory = resolve3(stateDirectory);
30758
+ this.stateDirectory = resolve4(stateDirectory);
30524
30759
  this.environment = Object.freeze({ ...environment, MOBIUS_STATE_DIRECTORY: this.stateDirectory });
30525
30760
  }
30526
30761
  };
@@ -30563,15 +30798,14 @@ function createDaemonConfig(connection, agents = [], installableAgents = [], loc
30563
30798
  // src/daemon-manager.ts
30564
30799
  import { spawn as spawn6 } from "node:child_process";
30565
30800
  import { createHash as createHash9, randomBytes } from "node:crypto";
30566
- import { readFile as readFile3, unlink as unlink2, writeFile as writeFile5 } from "node:fs/promises";
30801
+ import { readFile as readFile4, unlink as unlink3, writeFile as writeFile5 } from "node:fs/promises";
30567
30802
  import { createConnection, createServer } from "node:net";
30568
- import { tmpdir } from "node:os";
30569
- import { join as join22 } from "node:path";
30803
+ import { join as join24 } from "node:path";
30570
30804
 
30571
30805
  // src/pairing/pair-local-machine.ts
30572
- import { mkdir as mkdir5, realpath as realpath7, stat as stat6 } from "node:fs/promises";
30806
+ import { mkdir as mkdir5, realpath as realpath8, stat as stat6 } from "node:fs/promises";
30573
30807
  import { hostname as hostname3 } from "node:os";
30574
- import { basename, resolve as resolve5 } from "node:path";
30808
+ import { basename, resolve as resolve6 } from "node:path";
30575
30809
  import { fetch as fetch3 } from "undici";
30576
30810
 
30577
30811
  // src/agent-catalog/publish-agent-catalog.ts
@@ -30742,8 +30976,21 @@ async function unchangedIdentity(agent, signal) {
30742
30976
 
30743
30977
  // src/storage/runtime-installation-store.ts
30744
30978
  import { createHash as createHash2, randomUUID } from "node:crypto";
30745
- import { mkdir as mkdir4, open as open4, readdir as readdir2, rename as rename3, unlink, writeFile as writeFile3 } from "node:fs/promises";
30746
- import { dirname as dirname3, join as join17, resolve as resolve4 } from "node:path";
30979
+ import { mkdir as mkdir4, open as open4, readdir as readdir2, rename as rename3, unlink as unlink2, writeFile as writeFile3 } from "node:fs/promises";
30980
+ import { dirname as dirname4, join as join19, resolve as resolve5 } from "node:path";
30981
+
30982
+ // src/filesystem/private-path.ts
30983
+ import { lstat as lstat2 } from "node:fs/promises";
30984
+ async function validateLocalPath(path3, directory, privateAccess, signal) {
30985
+ signal.throwIfAborted();
30986
+ const metadata = await lstat2(path3);
30987
+ if (metadata.isSymbolicLink() || (directory ? !metadata.isDirectory() : !metadata.isFile())) {
30988
+ throw new LocalPathError("Unsafe local path");
30989
+ }
30990
+ await platformSupportFor(process.platform).validatePathPermissions(path3, directory, privateAccess, signal);
30991
+ }
30992
+
30993
+ // src/storage/runtime-installation-store.ts
30747
30994
  var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
30748
30995
  var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
30749
30996
  var INSTALLATION_ID_PATTERN = /^min_[a-f0-9]{32}$/;
@@ -30985,8 +31232,8 @@ async function readJsonFile(path3, signal, missingCode) {
30985
31232
  }
30986
31233
  async function writeJsonAtomically(path3, value, signal) {
30987
31234
  signal.throwIfAborted();
30988
- const directory = dirname3(path3);
30989
- const temporaryPath = join17(directory, `.${randomUUID()}.tmp`);
31235
+ const directory = dirname4(path3);
31236
+ const temporaryPath = join19(directory, `.${randomUUID()}.tmp`);
30990
31237
  try {
30991
31238
  await mkdir4(directory, { mode: 448, recursive: true });
30992
31239
  signal.throwIfAborted();
@@ -30995,7 +31242,7 @@ async function writeJsonAtomically(path3, value, signal) {
30995
31242
  signal.throwIfAborted();
30996
31243
  await rename3(temporaryPath, path3);
30997
31244
  } catch (cause) {
30998
- await unlink(temporaryPath).catch(() => void 0);
31245
+ await unlink2(temporaryPath).catch(() => void 0);
30999
31246
  signal.throwIfAborted();
31000
31247
  throw new RuntimeInstallationStoreError("connection_unavailable", "The local Runtime state cannot be written", {
31001
31248
  cause
@@ -31012,15 +31259,17 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
31012
31259
  this.applicationId = applicationId;
31013
31260
  this.installationId = installationId2;
31014
31261
  this.stateDirectory = stateDirectory;
31015
- this.#channelDirectory = join17(stateDirectory, "channels");
31016
- this.#connectionDirectory = join17(stateDirectory, "connections");
31262
+ this.#channelDirectory = join19(stateDirectory, "channels");
31263
+ this.#connectionDirectory = join19(stateDirectory, "connections");
31017
31264
  }
31018
31265
  static open = async (options, signal) => {
31019
31266
  signal.throwIfAborted();
31020
31267
  const applicationId = validateApplicationId(options.applicationId);
31021
- const rootDirectory = resolve4(options.stateDirectory);
31022
- const applicationDirectory = join17(rootDirectory, "installations", applicationId);
31268
+ const rootDirectory = resolve5(options.stateDirectory);
31269
+ const applicationDirectory = join19(rootDirectory, "installations", applicationId);
31023
31270
  try {
31271
+ await mkdir4(rootDirectory, { mode: 448, recursive: true });
31272
+ await validateLocalPath(rootDirectory, true, true, signal);
31024
31273
  await mkdir4(applicationDirectory, { mode: 448, recursive: true });
31025
31274
  } catch (cause) {
31026
31275
  throw new RuntimeInstallationStoreError(
@@ -31032,7 +31281,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
31032
31281
  );
31033
31282
  }
31034
31283
  const storedInstallationId = await readOrCreateInstallationId(applicationDirectory, signal);
31035
- const stateDirectory = join17(applicationDirectory, storedInstallationId);
31284
+ const stateDirectory = join19(applicationDirectory, storedInstallationId);
31036
31285
  try {
31037
31286
  await mkdir4(stateDirectory, { mode: 448, recursive: true });
31038
31287
  } catch (cause) {
@@ -31047,8 +31296,8 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
31047
31296
  signal.throwIfAborted();
31048
31297
  return new _RuntimeInstallationStore(applicationId, storedInstallationId, stateDirectory);
31049
31298
  };
31050
- connectionPath = (connectionId2) => join17(this.#connectionDirectory, `${validateConnectionId(connectionId2)}.json`);
31051
- channelIndexPath = (channelId) => join17(this.#channelDirectory, channelIndexFileName(validateIdentifier(channelId, "invalid_channel_id")));
31299
+ connectionPath = (connectionId2) => join19(this.#connectionDirectory, `${validateConnectionId(connectionId2)}.json`);
31300
+ channelIndexPath = (channelId) => join19(this.#channelDirectory, channelIndexFileName(validateIdentifier(channelId, "invalid_channel_id")));
31052
31301
  readConnection = async (connectionId2, signal) => {
31053
31302
  const stored = decodeConnection(
31054
31303
  await readJsonFile(this.connectionPath(connectionId2), signal, "connection_not_found")
@@ -31171,9 +31420,9 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
31171
31420
  const connection = await this.readConnection(connectionId2, signal);
31172
31421
  signal.throwIfAborted();
31173
31422
  try {
31174
- await unlink(this.connectionPath(connection.connectionId));
31423
+ await unlink2(this.connectionPath(connection.connectionId));
31175
31424
  signal.throwIfAborted();
31176
- await unlink(this.channelIndexPath(connection.channelId));
31425
+ await unlink2(this.channelIndexPath(connection.channelId));
31177
31426
  } catch (cause) {
31178
31427
  signal.throwIfAborted();
31179
31428
  if (isNodeError(cause, "ENOENT")) {
@@ -31210,7 +31459,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
31210
31459
  };
31211
31460
  };
31212
31461
  async function readOrCreateInstallationId(applicationDirectory, signal) {
31213
- const pointerPath = join17(applicationDirectory, "current.json");
31462
+ const pointerPath = join19(applicationDirectory, "current.json");
31214
31463
  try {
31215
31464
  return decodeInstallationPointer(await readJsonFile(pointerPath, signal, "installation_not_found")).installationId;
31216
31465
  } catch (cause) {
@@ -31348,10 +31597,10 @@ function parseResumeConnectionId(arguments_) {
31348
31597
  return value;
31349
31598
  }
31350
31599
  async function resolveDefaultWorkspace(path3) {
31351
- const requestedWorkspace = resolve5(path3);
31600
+ const requestedWorkspace = resolve6(path3);
31352
31601
  try {
31353
31602
  await mkdir5(requestedWorkspace, { recursive: true, mode: 448 });
31354
- const defaultWorkspace = await realpath7(requestedWorkspace);
31603
+ const defaultWorkspace = await realpath8(requestedWorkspace);
31355
31604
  const metadata = await stat6(defaultWorkspace);
31356
31605
  if (!metadata.isDirectory()) {
31357
31606
  throw new PairingClientError("invalid_workspace", "The default workspace is not a directory");
@@ -31573,7 +31822,7 @@ var AuditStore = class {
31573
31822
 
31574
31823
  // src/run-daemon.ts
31575
31824
  import { createHash as createHash8, randomUUID as randomUUID9 } from "node:crypto";
31576
- import { join as join21 } from "node:path";
31825
+ import { join as join23 } from "node:path";
31577
31826
  import { styleText } from "node:util";
31578
31827
 
31579
31828
  // src/acp/active-executions.ts
@@ -31664,7 +31913,7 @@ import {
31664
31913
  } from "@agentclientprotocol/sdk";
31665
31914
 
31666
31915
  // src/authorization/local-raster.ts
31667
- import { open as open5, readFile as readFile2, realpath as realpath8, stat as stat7 } from "node:fs/promises";
31916
+ import { open as open5, readFile as readFile3, realpath as realpath9, stat as stat7 } from "node:fs/promises";
31668
31917
  import { basename as basename2, isAbsolute as isAbsolute9, normalize as normalize2 } from "node:path";
31669
31918
  import { fileURLToPath } from "node:url";
31670
31919
  var MAX_LOCAL_RASTER_BYTES = 128 * 1024 * 1024;
@@ -31687,7 +31936,7 @@ var LocalRasterImage = class {
31687
31936
  this.sourceUri = sourceUri;
31688
31937
  }
31689
31938
  base64 = async () => {
31690
- const bytes = this.bytes ?? new Uint8Array(await readFile2(this.sourceUri));
31939
+ const bytes = this.bytes ?? new Uint8Array(await readFile3(this.sourceUri));
31691
31940
  return Buffer.from(bytes).toString("base64");
31692
31941
  };
31693
31942
  };
@@ -31735,7 +31984,7 @@ async function resolveCanonicalPath(requested, signal) {
31735
31984
  return null;
31736
31985
  }
31737
31986
  try {
31738
- const target = await realpath8(requested);
31987
+ const target = await realpath9(requested);
31739
31988
  signal.throwIfAborted();
31740
31989
  if (!isAbsolute9(target) || normalize2(target) !== target) {
31741
31990
  return null;
@@ -32316,7 +32565,7 @@ function createWritableAcpStream(output2) {
32316
32565
  if (outputFailure !== void 0) {
32317
32566
  return Promise.reject(outputFailure);
32318
32567
  }
32319
- return new Promise((resolve9, reject) => {
32568
+ return new Promise((resolve10, reject) => {
32320
32569
  pendingWriteFailures.add(reject);
32321
32570
  output2.write(chunk, (error62) => {
32322
32571
  pendingWriteFailures.delete(reject);
@@ -32329,7 +32578,7 @@ function createWritableAcpStream(output2) {
32329
32578
  reject(outputFailure);
32330
32579
  return;
32331
32580
  }
32332
- resolve9();
32581
+ resolve10();
32333
32582
  });
32334
32583
  });
32335
32584
  }
@@ -32351,9 +32600,10 @@ var AgentConnection = class {
32351
32600
  this.connection = createAcpClient(client2).connect(inProcess.app());
32352
32601
  return;
32353
32602
  }
32354
- const child2 = spawn4(agent.adapterPath, [...agent.arguments], {
32603
+ const launch = executableLaunch2(agent.adapterPath, agent.arguments);
32604
+ const child2 = spawn4(launch.command, [...launch.arguments], {
32355
32605
  cwd,
32356
- detached: process.platform !== "win32",
32606
+ ...platformSpawnOptions,
32357
32607
  env: { ...process.env, ...agent.environment },
32358
32608
  shell: false,
32359
32609
  stdio: ["pipe", "pipe", "pipe"]
@@ -32370,12 +32620,12 @@ var AgentConnection = class {
32370
32620
  stderr.on("data", (chunk) => {
32371
32621
  process.stderr.write(`[${agent.id}-acp] ${chunk}`);
32372
32622
  });
32373
- this.termination = new Promise((resolve9) => {
32623
+ this.termination = new Promise((resolve10) => {
32374
32624
  child2.once("error", (cause) => {
32375
- resolve9({ kind: "failed", error: new AcpExecutionError("The ACP process could not run", { cause }) });
32625
+ resolve10({ kind: "failed", error: new AcpExecutionError("The ACP process could not run", { cause }) });
32376
32626
  });
32377
32627
  child2.once("exit", (code, signal) => {
32378
- resolve9({
32628
+ resolve10({
32379
32629
  kind: "failed",
32380
32630
  error: new AcpExecutionError("The ACP process stopped", { cause: { code, signal } })
32381
32631
  });
@@ -34531,7 +34781,7 @@ function sql(strings, ...params) {
34531
34781
  return new SQL([new StringChunk(str)]);
34532
34782
  }
34533
34783
  _sql.raw = raw;
34534
- function join23(chunks, separator) {
34784
+ function join25(chunks, separator) {
34535
34785
  const result = [];
34536
34786
  for (const [i, chunk] of chunks.entries()) {
34537
34787
  if (i > 0 && separator !== void 0) result.push(separator);
@@ -34539,7 +34789,7 @@ function sql(strings, ...params) {
34539
34789
  }
34540
34790
  return new SQL(result);
34541
34791
  }
34542
- _sql.join = join23;
34792
+ _sql.join = join25;
34543
34793
  function identifier2(value) {
34544
34794
  return new Name(value);
34545
34795
  }
@@ -36684,7 +36934,7 @@ var SQLiteSelectBase = class extends TypedQueryBuilder {
36684
36934
  const baseTableName = this.tableName;
36685
36935
  const tableName = getTableLikeName(table);
36686
36936
  for (const item of extractUsedTable(table)) this.usedTables.add(item);
36687
- if (typeof tableName === "string" && this.config.joins?.some((join23) => join23.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
36937
+ if (typeof tableName === "string" && this.config.joins?.some((join25) => join25.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
36688
36938
  if (!this.isPartialSelect) {
36689
36939
  if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
36690
36940
  if (typeof tableName === "string" && !is(table, SQL)) {
@@ -37523,7 +37773,7 @@ var SQLiteDialect = class {
37523
37773
  if (!joins2) return;
37524
37774
  const withEntries = Object.entries(joins2).filter(([_, v]) => v);
37525
37775
  if (!withEntries.length) return;
37526
- return sql.join(withEntries.map(([k, join23]) => {
37776
+ return sql.join(withEntries.map(([k, join25]) => {
37527
37777
  const relation = tableConfig.relations[k];
37528
37778
  const isSingle2 = is(relation, One);
37529
37779
  const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
@@ -37534,7 +37784,7 @@ var SQLiteDialect = class {
37534
37784
  table: targetTable,
37535
37785
  mode: isSingle2 ? "first" : "many",
37536
37786
  schema,
37537
- queryConfig: join23,
37787
+ queryConfig: join25,
37538
37788
  tableConfig: schema[relation.targetTableName],
37539
37789
  relationWhere: filter,
37540
37790
  isNested: true,
@@ -37548,7 +37798,7 @@ var SQLiteDialect = class {
37548
37798
  key: k,
37549
37799
  selection: innerQuery.selection,
37550
37800
  isArray: !isSingle2,
37551
- isOptional: (relation.optional ?? false) || join23 !== true && !!join23.where
37801
+ isOptional: (relation.optional ?? false) || join25 !== true && !!join25.where
37552
37802
  });
37553
37803
  const jsonColumns = sql.join(innerQuery.selection.map((s) => {
37554
37804
  return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
@@ -38164,7 +38414,7 @@ var SQLiteUpdateBase = class {
38164
38414
  createJoin(joinType) {
38165
38415
  return ((table, on) => {
38166
38416
  const tableName = getTableLikeName(table);
38167
- if (typeof tableName === "string" && this.config.joins.some((join23) => join23.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
38417
+ if (typeof tableName === "string" && this.config.joins.some((join25) => join25.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
38168
38418
  if (typeof on === "function") {
38169
38419
  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;
38170
38420
  on = on(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
@@ -40823,8 +41073,8 @@ var AcpContentExternalizer = class {
40823
41073
 
40824
41074
  // src/external-content/local-external-content-store.ts
40825
41075
  import { createHash as createHash3, randomUUID as randomUUID3 } from "node:crypto";
40826
- import { lstat, mkdir as mkdir6, readdir as readdir3, realpath as realpath9, rename as rename4, rm as rm3, stat as stat8, utimes, writeFile as writeFile4 } from "node:fs/promises";
40827
- import { dirname as dirname4, join as join18 } from "node:path";
41076
+ import { lstat as lstat3, mkdir as mkdir6, readdir as readdir3, realpath as realpath10, rename as rename4, rm as rm3, stat as stat8, utimes, writeFile as writeFile4 } from "node:fs/promises";
41077
+ import { dirname as dirname5, join as join20 } from "node:path";
40828
41078
  var contentRequest = /^mobius-content:(image|audio|resource):([a-f0-9]{64})$/u;
40829
41079
  var CONTENT_LIFETIME_MILLISECONDS = 24 * 60 * 60 * 1e3;
40830
41080
  var metadataSchema2 = external_exports.strictObject({
@@ -40860,7 +41110,7 @@ var LocalExternalContentStore = class {
40860
41110
  #expirationTimer;
40861
41111
  #cleanup = Promise.resolve();
40862
41112
  constructor(stateDirectory) {
40863
- this.#root = join18(stateDirectory, "tmp", "session-content", randomUUID3());
41113
+ this.#root = join20(stateDirectory, "tmp", "session-content", randomUUID3());
40864
41114
  this.#expirationTimer = setInterval(() => {
40865
41115
  void this.#expire().catch(() => void 0);
40866
41116
  }, 6e4);
@@ -40871,11 +41121,11 @@ var LocalExternalContentStore = class {
40871
41121
  await mkdir6(this.#root, { mode: 448, recursive: true });
40872
41122
  const now = /* @__PURE__ */ new Date();
40873
41123
  await utimes(this.#root, now, now);
40874
- for (const directory of await readdir3(dirname4(this.#root), { withFileTypes: true })) {
41124
+ for (const directory of await readdir3(dirname5(this.#root), { withFileTypes: true })) {
40875
41125
  if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
40876
41126
  continue;
40877
41127
  }
40878
- const path3 = join18(dirname4(this.#root), directory.name);
41128
+ const path3 = join20(dirname5(this.#root), directory.name);
40879
41129
  if (path3 === this.#root) {
40880
41130
  continue;
40881
41131
  }
@@ -40925,10 +41175,10 @@ var LocalExternalContentStore = class {
40925
41175
  }
40926
41176
  await this.#expire();
40927
41177
  active.throwIfAborted();
40928
- const directory = join18(this.#root, kind);
41178
+ const directory = join20(this.#root, kind);
40929
41179
  await mkdir6(directory, { mode: 448, recursive: true });
40930
41180
  active.throwIfAborted();
40931
- const path3 = join18(directory, key);
41181
+ const path3 = join20(directory, key);
40932
41182
  const write = atomicWrite(path3, bytes, active);
40933
41183
  await write;
40934
41184
  active.throwIfAborted();
@@ -40961,12 +41211,12 @@ var LocalExternalContentStore = class {
40961
41211
  }
40962
41212
  try {
40963
41213
  const [resolvedDirectory, resolvedPath, file2] = await Promise.all([
40964
- realpath9(dirname4(entry.path)),
40965
- realpath9(entry.path),
40966
- lstat(entry.path)
41214
+ realpath10(dirname5(entry.path)),
41215
+ realpath10(entry.path),
41216
+ lstat3(entry.path)
40967
41217
  ]);
40968
41218
  signal.throwIfAborted();
40969
- if (!file2.isFile() || file2.isSymbolicLink() || dirname4(resolvedPath) !== resolvedDirectory) {
41219
+ if (!file2.isFile() || file2.isSymbolicLink() || dirname5(resolvedPath) !== resolvedDirectory) {
40970
41220
  return null;
40971
41221
  }
40972
41222
  return { mediaType: entry.mediaType, name: entry.name, path: resolvedPath };
@@ -42267,7 +42517,7 @@ var AgentInstallationManager = class {
42267
42517
 
42268
42518
  // src/agent-installation/fixed-installation-executor.ts
42269
42519
  import { realpathSync as realpathSync2, statSync as statSync2 } from "node:fs";
42270
- import { resolve as resolve6 } from "node:path";
42520
+ import { resolve as resolve7 } from "node:path";
42271
42521
  function findSpecification(specifications, agentId) {
42272
42522
  for (const specification of specifications) {
42273
42523
  if (specification.id === agentId) {
@@ -42278,7 +42528,7 @@ function findSpecification(specifications, agentId) {
42278
42528
  }
42279
42529
  function resolveDefaultWorkspace2(path3) {
42280
42530
  try {
42281
- const directory = realpathSync2(resolve6(path3));
42531
+ const directory = realpathSync2(resolve7(path3));
42282
42532
  if (!statSync2(directory).isDirectory()) {
42283
42533
  throw new Error("Default workspace is not a directory");
42284
42534
  }
@@ -42293,7 +42543,7 @@ function resolveDefaultWorkspace2(path3) {
42293
42543
  }
42294
42544
  function resolveIntegrationStateDirectory(path3) {
42295
42545
  try {
42296
- const directory = realpathSync2(resolve6(path3));
42546
+ const directory = realpathSync2(resolve7(path3));
42297
42547
  const metadata = statSync2(directory);
42298
42548
  if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
42299
42549
  throw new Error("Installation directory is not user-owned");
@@ -42465,9 +42715,9 @@ var FixedInstallationExecutor = class {
42465
42715
  };
42466
42716
 
42467
42717
  // src/authorization/workspace-directory.ts
42468
- import { readdir as readdir4, realpath as realpath10, stat as stat9 } from "node:fs/promises";
42718
+ import { readdir as readdir4, realpath as realpath11, stat as stat9 } from "node:fs/promises";
42469
42719
  import { homedir as homedir2 } from "node:os";
42470
- import { basename as basename4, dirname as dirname5, isAbsolute as isAbsolute10, join as join19, normalize as normalize3, relative as relative4 } from "node:path";
42720
+ import { basename as basename4, dirname as dirname6, isAbsolute as isAbsolute10, join as join21, normalize as normalize3, relative as relative4 } from "node:path";
42471
42721
 
42472
42722
  // src/authorization/local-authorization-error.ts
42473
42723
  var LocalAuthorizationError = class extends Error {
@@ -42546,7 +42796,7 @@ var WorkspaceDirectoryService = class {
42546
42796
  throw new LocalAuthorizationError("The local directory path is invalid");
42547
42797
  }
42548
42798
  try {
42549
- const target = await realpath10(requested);
42799
+ const target = await realpath11(requested);
42550
42800
  signal.throwIfAborted();
42551
42801
  const metadata = await stat9(target);
42552
42802
  signal.throwIfAborted();
@@ -42596,7 +42846,7 @@ var WorkspaceDirectoryService = class {
42596
42846
  continue;
42597
42847
  }
42598
42848
  try {
42599
- const path3 = await this.resolvePath(join19(target, child2.name), signal);
42849
+ const path3 = await this.resolvePath(join21(target, child2.name), signal);
42600
42850
  entries.push({ directoryId: encodePath(path3), name: child2.name });
42601
42851
  } catch (cause) {
42602
42852
  signal.throwIfAborted();
@@ -42606,7 +42856,7 @@ var WorkspaceDirectoryService = class {
42606
42856
  }
42607
42857
  }
42608
42858
  entries.sort((a, b) => a.name.localeCompare(b.name));
42609
- const parent = dirname5(target);
42859
+ const parent = dirname6(target);
42610
42860
  return new WorkspaceDirectoryListing(
42611
42861
  id,
42612
42862
  this.label(target),
@@ -42632,15 +42882,15 @@ var WorkspaceDirectoryService = class {
42632
42882
 
42633
42883
  // src/daemon-diagnostic-log.ts
42634
42884
  import { appendFileSync, mkdirSync, readFileSync as readFileSync2, renameSync, statSync as statSync3, writeFileSync } from "node:fs";
42635
- import { join as join20 } from "node:path";
42885
+ import { join as join22 } from "node:path";
42636
42886
  var MAXIMUM_DAEMON_LOG_BYTES = 1 * 1024 * 1024;
42637
42887
  var DaemonDiagnosticLog = class {
42638
42888
  #directory;
42639
42889
  #path;
42640
42890
  #maximumBytes;
42641
42891
  constructor(stateDirectory, maximumBytes = MAXIMUM_DAEMON_LOG_BYTES) {
42642
- this.#directory = join20(stateDirectory, "logs");
42643
- this.#path = join20(this.#directory, "daemon.log");
42892
+ this.#directory = join22(stateDirectory, "logs");
42893
+ this.#path = join22(this.#directory, "daemon.log");
42644
42894
  this.#maximumBytes = maximumBytes;
42645
42895
  }
42646
42896
  // Export only correlation and failure metadata. Local messages and paths stay local.
@@ -43456,7 +43706,7 @@ var ActiveDaemonTurn = class {
43456
43706
  var MAX_SESSIONS_WITH_COMPLETED_RECOVERY = 32;
43457
43707
  var waitForTurnCompletion = (turn, waitSignal) => {
43458
43708
  waitSignal.throwIfAborted();
43459
- return new Promise((resolve9, reject) => {
43709
+ return new Promise((resolve10, reject) => {
43460
43710
  let settled = false;
43461
43711
  const finish = (result) => {
43462
43712
  if (settled) {
@@ -43465,7 +43715,7 @@ var waitForTurnCompletion = (turn, waitSignal) => {
43465
43715
  settled = true;
43466
43716
  waitSignal.removeEventListener("abort", onAbort);
43467
43717
  if (result.kind === "completed") {
43468
- resolve9();
43718
+ resolve10();
43469
43719
  } else {
43470
43720
  reject(result.error);
43471
43721
  }
@@ -43663,7 +43913,7 @@ var sessionEventCacheMigrations = [
43663
43913
 
43664
43914
  // src/infra/local-sqlite-database.ts
43665
43915
  import { chmodSync, mkdirSync as mkdirSync2 } from "node:fs";
43666
- import { dirname as dirname6 } from "node:path";
43916
+ import { dirname as dirname7 } from "node:path";
43667
43917
  import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
43668
43918
 
43669
43919
  // ../../node_modules/.pnpm/drizzle-orm@1.0.0-rc.4_@cloudflare+workers-types@5.20260918.1_@types+better-sqlite3@7.6_f872c171b7e1945bb1fa42180063dab2/node_modules/drizzle-orm/node-sqlite/session.js
@@ -43774,7 +44024,7 @@ var LocalSqliteDatabase = class {
43774
44024
  orm;
43775
44025
  #sqlite;
43776
44026
  constructor(path3, label, migrations, pragmas = []) {
43777
- mkdirSync2(dirname6(path3), { mode: 448, recursive: true });
44027
+ mkdirSync2(dirname7(path3), { mode: 448, recursive: true });
43778
44028
  this.#sqlite = new DatabaseSync2(path3);
43779
44029
  chmodSync(path3, 384);
43780
44030
  try {
@@ -44333,10 +44583,11 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
44333
44583
  );
44334
44584
  }
44335
44585
  signal.throwIfAborted();
44336
- const child2 = spawn5(agent.agentIdentity.realPath, ["app-server"], {
44586
+ const launch = executableLaunch2(agent.agentIdentity.realPath, ["app-server"]);
44587
+ const child2 = spawn5(launch.command, [...launch.arguments], {
44337
44588
  cwd,
44338
44589
  env: { ...process.env, ...agent.environment },
44339
- detached: process.platform !== "win32",
44590
+ ...platformSpawnOptions,
44340
44591
  shell: false,
44341
44592
  stdio: ["pipe", "pipe", "ignore"]
44342
44593
  });
@@ -45762,8 +46013,8 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
45762
46013
 
45763
46014
  // src/artifacts/local-file-streamer.ts
45764
46015
  import { createReadStream as createReadStream2 } from "node:fs";
45765
- import { realpath as realpath11, stat as stat10 } from "node:fs/promises";
45766
- import { basename as basename5, extname, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve7 } from "node:path";
46016
+ import { realpath as realpath12, stat as stat10 } from "node:fs/promises";
46017
+ import { basename as basename5, extname as extname2, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve8 } from "node:path";
45767
46018
  import { fileURLToPath as fileURLToPath2 } from "node:url";
45768
46019
  var CHUNK_BYTES = 192 * 1024;
45769
46020
  function requestedPath(value) {
@@ -45785,12 +46036,12 @@ async function resolveFile(value, workingDirectory, signal) {
45785
46036
  if (path3 === null || !isAbsolute11(path3) && workingDirectory === null) {
45786
46037
  return null;
45787
46038
  }
45788
- const requested = workingDirectory === null ? path3 : resolve7(workingDirectory, path3);
46039
+ const requested = workingDirectory === null ? path3 : resolve8(workingDirectory, path3);
45789
46040
  if (!isAbsolute11(requested) || isAbsolute11(path3) && normalize4(path3) !== path3) {
45790
46041
  return null;
45791
46042
  }
45792
46043
  try {
45793
- const target = await realpath11(requested);
46044
+ const target = await realpath12(requested);
45794
46045
  signal.throwIfAborted();
45795
46046
  return isAbsolute11(target) && normalize4(target) === target ? target : null;
45796
46047
  } catch {
@@ -45813,7 +46064,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
45813
46064
  send2({
45814
46065
  byteLength: before.size,
45815
46066
  kind: FILE_BEGIN_KIND,
45816
- mediaType: external?.mediaType ?? raster?.mimeType ?? (extname(target).toLowerCase() === ".svg" ? "image/svg+xml" : "application/octet-stream"),
46067
+ mediaType: external?.mediaType ?? raster?.mimeType ?? (extname2(target).toLowerCase() === ".svg" ? "image/svg+xml" : "application/octet-stream"),
45817
46068
  modifiedAt: before.mtime.toISOString(),
45818
46069
  name: external?.name ?? (basename5(target) || "file"),
45819
46070
  requestId: command.requestId,
@@ -46103,6 +46354,78 @@ async function executeSessionConfigure(socket, command, config2, directories, au
46103
46354
  }
46104
46355
 
46105
46356
  // src/daemon-history-commands.ts
46357
+ function isAgentReasoning(event) {
46358
+ return event?.type === "acp" && event.payload.sessionUpdate === "agent_thought_chunk";
46359
+ }
46360
+ function omitAgentReasoning(events) {
46361
+ const retained = [];
46362
+ let previousReasoningMessageId;
46363
+ for (const event of events) {
46364
+ if (event.type !== "acp" || event.payload.sessionUpdate !== "agent_thought_chunk") {
46365
+ previousReasoningMessageId = void 0;
46366
+ retained.push(event);
46367
+ continue;
46368
+ }
46369
+ const messageId = event.payload.messageId ?? null;
46370
+ if (previousReasoningMessageId === void 0 || previousReasoningMessageId !== messageId) {
46371
+ retained.push({
46372
+ ...event,
46373
+ mobiusMetadata: { omitted: true },
46374
+ payload: { ...event.payload, content: { text: "", type: "text" } }
46375
+ });
46376
+ }
46377
+ previousReasoningMessageId = messageId;
46378
+ }
46379
+ return retained;
46380
+ }
46381
+ async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoning, queuedPromptRequests, load, eventLogV2) {
46382
+ let cursor = initialCursor;
46383
+ let loaded = [];
46384
+ let sessionGenerationId = null;
46385
+ let sourceNextCursor = null;
46386
+ do {
46387
+ const replay = await load(eventLimit, cursor);
46388
+ if (sessionGenerationId !== null && replay.sessionGenerationId !== sessionGenerationId) {
46389
+ throw new AcpExecutionError("The Session reloaded while history was loading", {}, "session_reloaded");
46390
+ }
46391
+ sessionGenerationId = replay.sessionGenerationId;
46392
+ const events2 = replay.events.map(
46393
+ (event, index2) => eventLogV2.event(
46394
+ sessionId,
46395
+ replay.sessionGenerationId,
46396
+ replay.startPosition + index2,
46397
+ event,
46398
+ "1970-01-01T00:00:00.000Z"
46399
+ )
46400
+ );
46401
+ loaded = [...events2, ...loaded];
46402
+ sourceNextCursor = replay.nextCursor;
46403
+ const visible2 = omitReasoning ? omitAgentReasoning(loaded) : loaded;
46404
+ const reasoningContinuesBeforePage = sourceNextCursor !== null && isAgentReasoning(loaded[0]);
46405
+ if (visible2.length >= eventLimit && !reasoningContinuesBeforePage) {
46406
+ break;
46407
+ }
46408
+ cursor = sourceNextCursor;
46409
+ } while (cursor !== null);
46410
+ if (sessionGenerationId === null) {
46411
+ throw new AcpExecutionError("The Session history is unavailable", {}, "session_history_unavailable");
46412
+ }
46413
+ const visible = omitReasoning ? omitAgentReasoning(loaded) : loaded;
46414
+ const events = visible.slice(-eventLimit);
46415
+ const firstPosition = events[0] === void 0 ? 0 : Number(events[0].position);
46416
+ const nextCursor = firstPosition <= 1 ? null : (firstPosition - 1).toString();
46417
+ return {
46418
+ events: {
46419
+ events,
46420
+ nextCursor,
46421
+ sessionGenerationId,
46422
+ tailCursor: events.at(-1)?.eventId ?? "",
46423
+ truncated: nextCursor !== null,
46424
+ version: 2
46425
+ },
46426
+ queuedPromptRequests
46427
+ };
46428
+ }
46106
46429
  async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, nativeSessions, eventLogV2, signal) {
46107
46430
  let agentId;
46108
46431
  try {
@@ -46126,35 +46449,23 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
46126
46449
  signal
46127
46450
  };
46128
46451
  const recovery = eventLogV2.promptRequestRecovery(command.sessionId);
46129
- const replay = await sessions.loadSessionEventsV2(loadOptions, command.eventLimit, command.cursor);
46130
- signal.throwIfAborted();
46131
- const events = replay.events.map(
46132
- (event, index2) => eventLogV2.event(
46133
- command.sessionId,
46134
- replay.sessionGenerationId,
46135
- replay.startPosition + index2,
46136
- event,
46137
- "1970-01-01T00:00:00.000Z"
46138
- )
46452
+ const events = await loadHistoryPage(
46453
+ command.sessionId,
46454
+ command.eventLimit,
46455
+ command.cursor,
46456
+ command.omit?.includes("agent-reasoning") === true,
46457
+ recovery.queuedPromptRequests,
46458
+ async (eventLimit, cursor) => await sessions.loadSessionEventsV2(loadOptions, eventLimit, cursor),
46459
+ eventLogV2
46139
46460
  );
46140
- const tailCursor = events.at(-1)?.eventId ?? "";
46461
+ signal.throwIfAborted();
46141
46462
  audit.record({
46142
46463
  commandId: command.requestId,
46143
46464
  event: "session_event_log_v2_loaded",
46144
46465
  sessionId: command.sessionId
46145
46466
  });
46146
46467
  send(socket, {
46147
- events: {
46148
- events: {
46149
- events,
46150
- nextCursor: replay.nextCursor,
46151
- sessionGenerationId: replay.sessionGenerationId,
46152
- tailCursor,
46153
- truncated: replay.truncated,
46154
- version: 2
46155
- },
46156
- queuedPromptRequests: recovery.queuedPromptRequests
46157
- },
46468
+ events,
46158
46469
  kind: SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND,
46159
46470
  requestId: command.requestId,
46160
46471
  sessionId: command.sessionId
@@ -46193,46 +46504,30 @@ async function executeSessionPreviewHistoryPageLoad(socket, command, config2, di
46193
46504
  command.additionalDirectoryIds,
46194
46505
  signal
46195
46506
  );
46196
- const replay = await sessions.previewNativeSessionEventsV2(
46197
- {
46198
- additionalDirectories: resolved.additionalDirectories,
46199
- agent: await resolveCatalogAgent(config2, command.agentId, signal),
46200
- cwd: resolved.cwd,
46201
- sessionId: command.sessionId,
46202
- signal
46203
- },
46507
+ const loadOptions = {
46508
+ additionalDirectories: resolved.additionalDirectories,
46509
+ agent: await resolveCatalogAgent(config2, command.agentId, signal),
46510
+ cwd: resolved.cwd,
46511
+ sessionId: command.sessionId,
46512
+ signal
46513
+ };
46514
+ const events = await loadHistoryPage(
46204
46515
  command.sessionId,
46205
46516
  command.eventLimit,
46206
- command.cursor
46517
+ command.cursor,
46518
+ command.omit?.includes("agent-reasoning") === true,
46519
+ [],
46520
+ async (eventLimit, cursor) => await sessions.previewNativeSessionEventsV2(loadOptions, command.sessionId, eventLimit, cursor),
46521
+ eventLogV2
46207
46522
  );
46208
46523
  signal.throwIfAborted();
46209
- const events = replay.events.map(
46210
- (event, index2) => eventLogV2.event(
46211
- command.sessionId,
46212
- replay.sessionGenerationId,
46213
- replay.startPosition + index2,
46214
- event,
46215
- "1970-01-01T00:00:00.000Z"
46216
- )
46217
- );
46218
- const tailCursor = events.at(-1)?.eventId ?? "";
46219
46524
  audit.record({
46220
46525
  commandId: command.requestId,
46221
46526
  event: "session_event_log_v2_loaded",
46222
46527
  sessionId: command.sessionId
46223
46528
  });
46224
46529
  send(socket, {
46225
- events: {
46226
- events: {
46227
- events,
46228
- nextCursor: replay.nextCursor,
46229
- sessionGenerationId: replay.sessionGenerationId,
46230
- tailCursor,
46231
- truncated: replay.truncated,
46232
- version: 2
46233
- },
46234
- queuedPromptRequests: []
46235
- },
46530
+ events,
46236
46531
  kind: SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND,
46237
46532
  requestId: command.requestId,
46238
46533
  sessionId: command.sessionId
@@ -46671,13 +46966,13 @@ function createNativeSessionRequestHandler(dependencies) {
46671
46966
  operationSignal.throwIfAborted();
46672
46967
  const skipPrevious = command.action === "active-turn";
46673
46968
  if (previous.length > 0 && !skipPrevious) {
46674
- await new Promise((resolve9, reject) => {
46969
+ await new Promise((resolve10, reject) => {
46675
46970
  const onAbort = () => reject(operationSignal.reason);
46676
46971
  operationSignal.addEventListener("abort", onAbort, { once: true });
46677
46972
  void Promise.all(previous.map((request) => request.completion)).then(
46678
46973
  () => {
46679
46974
  operationSignal.removeEventListener("abort", onAbort);
46680
- resolve9();
46975
+ resolve10();
46681
46976
  },
46682
46977
  (error62) => {
46683
46978
  operationSignal.removeEventListener("abort", onAbort);
@@ -47111,7 +47406,7 @@ var RelayConnectionError = class extends Error {
47111
47406
  };
47112
47407
  function connectRelay(url2, signal) {
47113
47408
  signal.throwIfAborted();
47114
- return new Promise((resolve9, reject) => {
47409
+ return new Promise((resolve10, reject) => {
47115
47410
  const endpoint = new URL(url2);
47116
47411
  const headers = runtimeAuthorization(endpoint);
47117
47412
  endpoint.searchParams.delete("token");
@@ -47178,7 +47473,7 @@ function connectRelay(url2, signal) {
47178
47473
  }
47179
47474
  finished = true;
47180
47475
  cleanup();
47181
- resolve9(socket);
47476
+ resolve10(socket);
47182
47477
  };
47183
47478
  function onTimeout() {
47184
47479
  fail(
@@ -47360,7 +47655,7 @@ async function runRelayConnection({
47360
47655
  installationObserver.connect(socket);
47361
47656
  onConnected();
47362
47657
  try {
47363
- await new Promise((resolve9, reject) => {
47658
+ await new Promise((resolve10, reject) => {
47364
47659
  let finished = false;
47365
47660
  const cleanup = () => {
47366
47661
  connectionLiveness.close();
@@ -47378,7 +47673,7 @@ async function runRelayConnection({
47378
47673
  }
47379
47674
  finished = true;
47380
47675
  cleanup();
47381
- resolve9();
47676
+ resolve10();
47382
47677
  };
47383
47678
  const rejectConnection = (failure2) => {
47384
47679
  if (finished) {
@@ -47764,12 +48059,12 @@ function waitForRelayRetry(signal, timer) {
47764
48059
  if (signal.aborted) {
47765
48060
  return Promise.resolve();
47766
48061
  }
47767
- return new Promise((resolve9) => {
48062
+ return new Promise((resolve10) => {
47768
48063
  const retry = timer.schedule(finish, RELAY_RECONNECT_DELAY_MILLISECONDS);
47769
48064
  function finish() {
47770
48065
  retry.cancel();
47771
48066
  signal.removeEventListener("abort", finish);
47772
- resolve9();
48067
+ resolve10();
47773
48068
  }
47774
48069
  signal.addEventListener("abort", finish, { once: true });
47775
48070
  });
@@ -47825,11 +48120,11 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
47825
48120
  stateDirectory
47826
48121
  });
47827
48122
  const channelHash = createHash8("sha256").update(config2.channelId).digest("hex");
47828
- const sessionDatabase = openAcpSessionDatabase(join21(stateDirectory, "sessions", `${channelHash}.sqlite`));
48123
+ const sessionDatabase = openAcpSessionDatabase(join23(stateDirectory, "sessions", `${channelHash}.sqlite`));
47829
48124
  let eventsV2;
47830
48125
  try {
47831
48126
  eventsV2 = new CachedAcpSessionEventStoreV2(
47832
- openSessionEventCacheV2Database(join21(stateDirectory, "sessions", `${channelHash}.events.sqlite`))
48127
+ openSessionEventCacheV2Database(join23(stateDirectory, "sessions", `${channelHash}.events.sqlite`))
47833
48128
  );
47834
48129
  } catch (error62) {
47835
48130
  sessionDatabase.close();
@@ -48096,17 +48391,17 @@ var START_TIMEOUT_MILLISECONDS = 12e4;
48096
48391
  var MAXIMUM_MESSAGE_BYTES = 64 * 1024;
48097
48392
  var CONNECTION_ID_PATTERN2 = /^mcn_[a-f0-9]{32}$/;
48098
48393
  async function acquireManagerLock(stateDirectory) {
48099
- const path3 = join22(stateDirectory, "manager.lock");
48394
+ const path3 = join24(stateDirectory, "manager.lock");
48100
48395
  for (let attempt = 0; attempt < 2; attempt += 1) {
48101
48396
  try {
48102
48397
  await writeFile5(path3, `${process.pid.toString()}
48103
48398
  `, { flag: "wx", mode: 384 });
48104
- return async () => await unlink2(path3).catch(() => void 0);
48399
+ return async () => await unlink3(path3).catch(() => void 0);
48105
48400
  } catch (cause) {
48106
48401
  if (!isNodeError2(cause, "EEXIST")) {
48107
48402
  throw cause;
48108
48403
  }
48109
- const encoded = await readFile3(path3, "utf8").catch(() => "");
48404
+ const encoded = await readFile4(path3, "utf8").catch(() => "");
48110
48405
  const pid = Number(encoded.trim());
48111
48406
  if (Number.isSafeInteger(pid) && pid > 1) {
48112
48407
  try {
@@ -48118,7 +48413,7 @@ async function acquireManagerLock(stateDirectory) {
48118
48413
  }
48119
48414
  }
48120
48415
  }
48121
- await unlink2(path3).catch(() => void 0);
48416
+ await unlink3(path3).catch(() => void 0);
48122
48417
  }
48123
48418
  }
48124
48419
  return null;
@@ -48126,17 +48421,18 @@ async function acquireManagerLock(stateDirectory) {
48126
48421
  function isRecord12(value) {
48127
48422
  return typeof value === "object" && value !== null && !Array.isArray(value);
48128
48423
  }
48424
+ var managerPlatform = platformSupportFor(process.platform);
48129
48425
  function controlSocketPath(stateDirectory) {
48130
48426
  const installationHash = createHash9("sha256").update(stateDirectory).digest("hex").slice(0, 32);
48131
- return process.platform === "win32" ? `\\\\.\\pipe\\mobius-${installationHash}` : join22(tmpdir(), `mobius-${installationHash}.sock`);
48427
+ return managerPlatform.controlSocketPath(installationHash);
48132
48428
  }
48133
48429
  function controlTokenPath(stateDirectory) {
48134
- return join22(stateDirectory, "manager.token");
48430
+ return join24(stateDirectory, "manager.token");
48135
48431
  }
48136
48432
  async function readOrCreateControlToken(stateDirectory) {
48137
48433
  const path3 = controlTokenPath(stateDirectory);
48138
48434
  try {
48139
- return (await readFile3(path3, "utf8")).trim();
48435
+ return (await readFile4(path3, "utf8")).trim();
48140
48436
  } catch (cause) {
48141
48437
  if (!isNodeError2(cause, "ENOENT")) {
48142
48438
  throw cause;
@@ -48151,7 +48447,7 @@ async function readOrCreateControlToken(stateDirectory) {
48151
48447
  if (!isNodeError2(cause, "EEXIST")) {
48152
48448
  throw cause;
48153
48449
  }
48154
- return (await readFile3(path3, "utf8")).trim();
48450
+ return (await readFile4(path3, "utf8")).trim();
48155
48451
  }
48156
48452
  }
48157
48453
  function isNodeError2(error62, code) {
@@ -48370,9 +48666,9 @@ async function waitForReady(active, signal) {
48370
48666
  return;
48371
48667
  }
48372
48668
  const deadline = AbortSignal.any([signal, AbortSignal.timeout(START_TIMEOUT_MILLISECONDS)]);
48373
- await new Promise((resolve9, reject) => {
48669
+ await new Promise((resolve10, reject) => {
48374
48670
  const abort = () => reject(deadline.reason);
48375
- active.ready.then(resolve9, reject).finally(() => deadline.removeEventListener("abort", abort));
48671
+ active.ready.then(resolve10, reject).finally(() => deadline.removeEventListener("abort", abort));
48376
48672
  deadline.addEventListener("abort", abort, { once: true });
48377
48673
  });
48378
48674
  if (active.status === "failed") {
@@ -48383,7 +48679,7 @@ function errorMessage2(error62) {
48383
48679
  return error62 instanceof Error ? error62.message : "Unknown failure";
48384
48680
  }
48385
48681
  async function readSocketMessage(socket, signal) {
48386
- return await new Promise((resolve9, reject) => {
48682
+ return await new Promise((resolve10, reject) => {
48387
48683
  let encoded = "";
48388
48684
  const finish = (error62, value) => {
48389
48685
  signal.removeEventListener("abort", abort);
@@ -48391,7 +48687,7 @@ async function readSocketMessage(socket, signal) {
48391
48687
  socket.removeAllListeners("error");
48392
48688
  socket.removeAllListeners("end");
48393
48689
  if (error62 === void 0) {
48394
- resolve9(value);
48690
+ resolve10(value);
48395
48691
  } else {
48396
48692
  reject(error62);
48397
48693
  }
@@ -48426,14 +48722,14 @@ async function sendControlRequest(stateDirectory, command, signal) {
48426
48722
  const deadline = AbortSignal.any([signal, AbortSignal.timeout(CONTROL_TIMEOUT_MILLISECONDS)]);
48427
48723
  const socket = createConnection(controlSocketPath(stateDirectory));
48428
48724
  try {
48429
- await new Promise((resolve9, reject) => {
48725
+ await new Promise((resolve10, reject) => {
48430
48726
  const abort = () => {
48431
48727
  socket.destroy();
48432
48728
  reject(deadline.reason);
48433
48729
  };
48434
48730
  socket.once("connect", () => {
48435
48731
  deadline.removeEventListener("abort", abort);
48436
- resolve9();
48732
+ resolve10();
48437
48733
  });
48438
48734
  socket.once("error", reject);
48439
48735
  deadline.addEventListener("abort", abort, { once: true });
@@ -48448,6 +48744,7 @@ async function sendControlRequest(stateDirectory, command, signal) {
48448
48744
  async function spawnManager() {
48449
48745
  const child2 = spawn6(process.execPath, [process.argv[1] ?? "", "__manager"], {
48450
48746
  detached: true,
48747
+ windowsHide: true,
48451
48748
  env: process.env,
48452
48749
  stdio: "ignore"
48453
48750
  });
@@ -48463,20 +48760,20 @@ async function waitForManagerExit(stateDirectory, signal) {
48463
48760
  const deadline = AbortSignal.any([signal, AbortSignal.timeout(1e4)]);
48464
48761
  while (!deadline.aborted) {
48465
48762
  try {
48466
- await readFile3(join22(stateDirectory, "manager.lock"), "utf8");
48763
+ await readFile4(join24(stateDirectory, "manager.lock"), "utf8");
48467
48764
  } catch (cause) {
48468
48765
  if (isNodeError2(cause, "ENOENT")) {
48469
48766
  return;
48470
48767
  }
48471
48768
  throw cause;
48472
48769
  }
48473
- await new Promise((resolve9, reject) => {
48770
+ await new Promise((resolve10, reject) => {
48474
48771
  const timeout = setTimeout(finish, 20);
48475
48772
  const abort = () => finish(deadline.reason);
48476
48773
  function finish(cause) {
48477
48774
  clearTimeout(timeout);
48478
48775
  deadline.removeEventListener("abort", abort);
48479
- cause === void 0 ? resolve9() : reject(cause);
48776
+ cause === void 0 ? resolve10() : reject(cause);
48480
48777
  }
48481
48778
  deadline.addEventListener("abort", abort, { once: true });
48482
48779
  });
@@ -48526,13 +48823,13 @@ async function ensureMatchingManager(stateDirectory, managerVersion, signal) {
48526
48823
  await launchManager(managerVersion);
48527
48824
  managerStarted = true;
48528
48825
  }
48529
- await new Promise((resolve9, reject) => {
48826
+ await new Promise((resolve10, reject) => {
48530
48827
  const timeout = setTimeout(finish, 50);
48531
48828
  const abort = () => finish(signal.reason);
48532
48829
  function finish(cause2) {
48533
48830
  clearTimeout(timeout);
48534
48831
  signal.removeEventListener("abort", abort);
48535
- cause2 === void 0 ? resolve9() : reject(cause2);
48832
+ cause2 === void 0 ? resolve10() : reject(cause2);
48536
48833
  }
48537
48834
  signal.addEventListener("abort", abort, { once: true });
48538
48835
  });
@@ -48619,33 +48916,23 @@ async function runManager(installation, managerVersion, signal) {
48619
48916
  }
48620
48917
  })();
48621
48918
  });
48622
- if (process.platform !== "win32") {
48623
- await unlink2(socketPath).catch((cause) => {
48624
- if (!isNodeError2(cause, "ENOENT")) {
48625
- throw cause;
48626
- }
48627
- });
48628
- }
48919
+ await managerPlatform.prepareControlSocket(socketPath);
48629
48920
  server.listen(socketPath);
48630
- await new Promise((resolve9, reject) => {
48631
- server.once("listening", resolve9);
48921
+ await new Promise((resolve10, reject) => {
48922
+ server.once("listening", resolve10);
48632
48923
  server.once("error", reject);
48633
48924
  });
48634
- if (process.platform !== "win32") {
48635
- await import("node:fs/promises").then(async ({ chmod: chmod2 }) => await chmod2(socketPath, 384));
48636
- }
48925
+ await managerPlatform.secureControlSocket(socketPath);
48637
48926
  try {
48638
- await new Promise((resolve9) => combined.addEventListener("abort", () => resolve9(), { once: true }));
48639
- const serverClosed = new Promise((resolve9) => server.close(() => resolve9()));
48927
+ await new Promise((resolve10) => combined.addEventListener("abort", () => resolve10(), { once: true }));
48928
+ const serverClosed = new Promise((resolve10) => server.close(() => resolve10()));
48640
48929
  for (const socket of sockets) {
48641
48930
  socket.destroy();
48642
48931
  }
48643
48932
  await serverClosed;
48644
48933
  await supervisor.close();
48645
48934
  } finally {
48646
- if (process.platform !== "win32") {
48647
- await unlink2(socketPath).catch(() => void 0);
48648
- }
48935
+ await managerPlatform.removeControlSocket(socketPath).catch(() => void 0);
48649
48936
  await releaseLock();
48650
48937
  }
48651
48938
  }
@@ -48788,7 +49075,7 @@ function createProgram() {
48788
49075
  });
48789
49076
  pair.command("list").description("list saved pairings").addOption(valueOption("--output-json <existing-file.json>", "write JSON to an existing file")).action(async (options) => {
48790
49077
  const installation = await openMobiusCliInstallation(shutdown.signal, process.env);
48791
- const outputPath = options.outputJson === void 0 ? null : resolve8(options.outputJson);
49078
+ const outputPath = options.outputJson === void 0 ? null : resolve9(options.outputJson);
48792
49079
  const response = await requestManager(
48793
49080
  installation,
48794
49081
  package_default.version,