@moxt-ai/mobius 0.0.193 → 0.0.195

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 (74) hide show
  1. package/dist/acp/agent-runtime-manager.js +1 -1
  2. package/dist/acp/agent-runtime-manager.js.map +1 -1
  3. package/dist/acp/agent-session.js +2 -2
  4. package/dist/acp/agent-session.js.map +1 -1
  5. package/dist/acp/native-session.d.ts +1 -0
  6. package/dist/acp/native-session.d.ts.map +1 -1
  7. package/dist/agent-catalog/agents/workbuddy-agent.d.ts.map +1 -1
  8. package/dist/agent-catalog/agents/workbuddy-agent.js +5 -19
  9. package/dist/agent-catalog/agents/workbuddy-agent.js.map +1 -1
  10. package/dist/agent-catalog/discover-agent-settings.d.ts.map +1 -1
  11. package/dist/agent-catalog/discover-agent-settings.js +2 -1
  12. package/dist/agent-catalog/discover-agent-settings.js.map +1 -1
  13. package/dist/agent-catalog/resolve-catalog-agent.d.ts +15 -0
  14. package/dist/agent-catalog/resolve-catalog-agent.d.ts.map +1 -0
  15. package/dist/agent-catalog/resolve-catalog-agent.js +65 -0
  16. package/dist/agent-catalog/resolve-catalog-agent.js.map +1 -0
  17. package/dist/agent-installation/grok-managed-package.d.ts.map +1 -1
  18. package/dist/agent-installation/grok-managed-package.js +5 -16
  19. package/dist/agent-installation/grok-managed-package.js.map +1 -1
  20. package/dist/agent-installation/opencode-managed-release.d.ts.map +1 -1
  21. package/dist/agent-installation/opencode-managed-release.js +9 -16
  22. package/dist/agent-installation/opencode-managed-release.js.map +1 -1
  23. package/dist/cli.js +965 -800
  24. package/dist/cli.js.map +4 -4
  25. package/dist/config.d.ts +7 -1
  26. package/dist/config.d.ts.map +1 -1
  27. package/dist/config.js +2 -1
  28. package/dist/config.js.map +1 -1
  29. package/dist/daemon-history-commands.d.ts.map +1 -1
  30. package/dist/daemon-history-commands.js +73 -31
  31. package/dist/daemon-history-commands.js.map +1 -1
  32. package/dist/daemon-prompt-executor.d.ts.map +1 -1
  33. package/dist/daemon-prompt-executor.js +2 -1
  34. package/dist/daemon-prompt-executor.js.map +1 -1
  35. package/dist/daemon-session-commands.d.ts +2 -1
  36. package/dist/daemon-session-commands.d.ts.map +1 -1
  37. package/dist/daemon-session-commands.js +6 -2
  38. package/dist/daemon-session-commands.js.map +1 -1
  39. package/dist/index.js +970 -796
  40. package/dist/index.js.map +4 -4
  41. package/dist/native-sessions/service.d.ts.map +1 -1
  42. package/dist/native-sessions/service.js +5 -2
  43. package/dist/native-sessions/service.js.map +1 -1
  44. package/dist/pairing/pair-local-machine.d.ts.map +1 -1
  45. package/dist/pairing/pair-local-machine.js +12 -5
  46. package/dist/pairing/pair-local-machine.js.map +1 -1
  47. package/dist/platform/contracts.d.ts +26 -0
  48. package/dist/platform/contracts.d.ts.map +1 -0
  49. package/dist/platform/contracts.js +2 -0
  50. package/dist/platform/contracts.js.map +1 -0
  51. package/dist/platform/index.d.ts +3 -0
  52. package/dist/platform/index.d.ts.map +1 -0
  53. package/dist/platform/index.js +21 -0
  54. package/dist/platform/index.js.map +1 -0
  55. package/dist/platform/linux.d.ts +3 -0
  56. package/dist/platform/linux.d.ts.map +1 -0
  57. package/dist/platform/linux.js +146 -0
  58. package/dist/platform/linux.js.map +1 -0
  59. package/dist/platform/macos.d.ts +3 -0
  60. package/dist/platform/macos.d.ts.map +1 -0
  61. package/dist/platform/macos.js +49 -0
  62. package/dist/platform/macos.js.map +1 -0
  63. package/dist/platform/posix.d.ts +4 -0
  64. package/dist/platform/posix.d.ts.map +1 -0
  65. package/dist/platform/posix.js +47 -0
  66. package/dist/platform/posix.js.map +1 -0
  67. package/dist/process/executable.d.ts +2 -4
  68. package/dist/process/executable.d.ts.map +1 -1
  69. package/dist/process/executable.js +11 -166
  70. package/dist/process/executable.js.map +1 -1
  71. package/dist/runtime.d.ts.map +1 -1
  72. package/dist/runtime.js +988 -814
  73. package/dist/runtime.js.map +4 -4
  74. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
  };
7
7
 
8
8
  // src/cli.ts
9
- import { constants as constants2 } from "node:fs";
9
+ import { constants as constants3 } from "node:fs";
10
10
  import { mkdir as mkdir7, open as open6 } from "node:fs/promises";
11
11
  import { resolve as resolve8 } from "node:path";
12
12
 
@@ -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.193",
3384
+ version: "0.0.195",
3385
3385
  description: "Mobius CLI for pairing and running local AI agent services.",
3386
3386
  type: "module",
3387
3387
  bin: {
@@ -3505,15 +3505,266 @@ function normalizeAcpCapabilities(initialized) {
3505
3505
  }
3506
3506
 
3507
3507
  // src/process/executable.ts
3508
- import { execFile, spawn } from "node:child_process";
3508
+ 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";
3512
+
3513
+ // src/platform/linux.ts
3509
3514
  import { constants, readdirSync, readFileSync } from "node:fs";
3510
3515
  import { access, readdir, readFile, realpath, stat } from "node:fs/promises";
3511
- import { join, resolve } from "node:path";
3516
+ import { join } from "node:path";
3517
+
3518
+ // src/platform/posix.ts
3519
+ import { execFile } from "node:child_process";
3520
+ var PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
3521
+ var PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
3522
+ function parseProcessTable(output2) {
3523
+ const entries = [];
3524
+ for (const line of output2.split("\n")) {
3525
+ const groups = /^\s*(?<pid>\d+)\s+(?<ppid>\d+)\s+(?<pgid>\d+)\s*$/.exec(line)?.groups;
3526
+ if (groups === void 0) {
3527
+ continue;
3528
+ }
3529
+ const processId = Number(groups["pid"]);
3530
+ const parentProcessId = Number(groups["ppid"]);
3531
+ const processGroupId = Number(groups["pgid"]);
3532
+ if (!Number.isSafeInteger(processId) || processId <= 0 || !Number.isSafeInteger(parentProcessId) || parentProcessId < 0 || !Number.isSafeInteger(processGroupId) || processGroupId <= 0) {
3533
+ continue;
3534
+ }
3535
+ entries.push({ parentProcessId, processGroupId, processId });
3536
+ }
3537
+ return entries;
3538
+ }
3539
+ function readProcessTableWithPs(executable) {
3540
+ return new Promise((resolveTable) => {
3541
+ execFile(
3542
+ executable,
3543
+ ["-axo", "pid=,ppid=,pgid="],
3544
+ {
3545
+ encoding: "utf8",
3546
+ maxBuffer: PROCESS_TABLE_OUTPUT_LIMIT_BYTES,
3547
+ signal: AbortSignal.timeout(PROCESS_TABLE_TIMEOUT_MILLISECONDS),
3548
+ timeout: PROCESS_TABLE_TIMEOUT_MILLISECONDS
3549
+ },
3550
+ (error62, stdout) => {
3551
+ resolveTable(error62 === null ? parseProcessTable(stdout) : []);
3552
+ }
3553
+ );
3554
+ });
3555
+ }
3556
+ function processExists(processId) {
3557
+ try {
3558
+ process.kill(processId, 0);
3559
+ return true;
3560
+ } catch {
3561
+ return false;
3562
+ }
3563
+ }
3564
+
3565
+ // src/platform/linux.ts
3566
+ function appendLinuxProcessTableEntry(entries, processId, encoded) {
3567
+ const closingParenthesis = encoded.lastIndexOf(")");
3568
+ if (!encoded.startsWith(`${processId.toString()} (`) || closingParenthesis < 0) {
3569
+ return;
3570
+ }
3571
+ const fields = encoded.slice(closingParenthesis + 1).trim().split(/\s+/);
3572
+ const parentProcessId = Number(fields[1]);
3573
+ const processGroupId = Number(fields[2]);
3574
+ if (!Number.isSafeInteger(parentProcessId) || parentProcessId < 0 || !Number.isSafeInteger(processGroupId) || processGroupId <= 0) {
3575
+ return;
3576
+ }
3577
+ entries.push({ parentProcessId, processGroupId, processId });
3578
+ }
3579
+ async function readLinuxProcessTable() {
3580
+ const entries = [];
3581
+ try {
3582
+ const directories = await readdir("/proc", { withFileTypes: true });
3583
+ for (const directory of directories) {
3584
+ if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
3585
+ continue;
3586
+ }
3587
+ const processId = Number(directory.name);
3588
+ if (!Number.isSafeInteger(processId) || processId <= 0) {
3589
+ continue;
3590
+ }
3591
+ try {
3592
+ appendLinuxProcessTableEntry(
3593
+ entries,
3594
+ processId,
3595
+ await readFile(join("/proc", directory.name, "stat"), "utf8")
3596
+ );
3597
+ } catch {
3598
+ }
3599
+ }
3600
+ } catch {
3601
+ }
3602
+ return entries;
3603
+ }
3604
+ function readLinuxProcessTableSynchronously() {
3605
+ const entries = [];
3606
+ try {
3607
+ const directories = readdirSync("/proc", { withFileTypes: true });
3608
+ for (const directory of directories) {
3609
+ if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
3610
+ continue;
3611
+ }
3612
+ const processId = Number(directory.name);
3613
+ if (!Number.isSafeInteger(processId) || processId <= 0) {
3614
+ continue;
3615
+ }
3616
+ try {
3617
+ appendLinuxProcessTableEntry(
3618
+ entries,
3619
+ processId,
3620
+ readFileSync(join("/proc", directory.name, "stat"), "utf8")
3621
+ );
3622
+ } catch {
3623
+ }
3624
+ }
3625
+ } catch {
3626
+ }
3627
+ return entries;
3628
+ }
3629
+ async function readLinuxProcessTableWithFallback() {
3630
+ const procfsEntries = await readLinuxProcessTable();
3631
+ if (procfsEntries.length > 0) {
3632
+ return procfsEntries;
3633
+ }
3634
+ for (const candidate of ["/usr/bin/ps", "/bin/ps", "/run/current-system/sw/bin/ps"]) {
3635
+ try {
3636
+ const resolvedPath = await realpath(candidate);
3637
+ if (!(await stat(resolvedPath)).isFile()) {
3638
+ continue;
3639
+ }
3640
+ await access(resolvedPath, constants.X_OK);
3641
+ } catch {
3642
+ continue;
3643
+ }
3644
+ const entries = await readProcessTableWithPs(candidate);
3645
+ if (entries.length > 0) {
3646
+ return entries;
3647
+ }
3648
+ }
3649
+ return [];
3650
+ }
3651
+ function processExists2(processId) {
3652
+ try {
3653
+ const encoded = readFileSync(join("/proc", processId.toString(), "stat"), "utf8");
3654
+ const closingParenthesis = encoded.lastIndexOf(")");
3655
+ if (closingParenthesis >= 0) {
3656
+ const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
3657
+ if (processState === "Z" || processState === "X") {
3658
+ return false;
3659
+ }
3660
+ }
3661
+ } catch {
3662
+ }
3663
+ return processExists(processId);
3664
+ }
3665
+ var linuxPlatform = {
3666
+ readProcessTable: readLinuxProcessTableWithFallback,
3667
+ readProcessTableSynchronously: readLinuxProcessTableSynchronously,
3668
+ processExists: processExists2,
3669
+ workBuddyExecutablePaths: () => [],
3670
+ openCodeArchives: {
3671
+ arm64: {
3672
+ asset: "opencode-linux-arm64.tar.gz",
3673
+ sha256: "70baf769395ca4e7a68924026530c390eace194f3b7e4919d4efcb2aa2eed3c0",
3674
+ format: "tar.gz"
3675
+ },
3676
+ x64: {
3677
+ asset: "opencode-linux-x64.tar.gz",
3678
+ sha256: "ea800b7ff56226b70952126c9fc1e2517ca4c4b5682fd9d3f9e87449697a1194",
3679
+ format: "tar.gz"
3680
+ }
3681
+ },
3682
+ grokDependencies: {
3683
+ arm64: {
3684
+ name: "@xai-official/grok-linux-arm64",
3685
+ integrity: "sha512-Jlwz9XtZPNKz/V/ydifC8OVu3hIZz7pmoStt8c4KCqkSWjWiZ/PBIC0iJiq8rvByhx5Z0EdSyq8ZXVwtocceGA==",
3686
+ tarballUrl: "https://registry.npmjs.org/@xai-official/grok-linux-arm64/-/grok-linux-arm64-1.0.21.tgz"
3687
+ },
3688
+ x64: {
3689
+ name: "@xai-official/grok-linux-x64",
3690
+ integrity: "sha512-AjDV5ifEz5LFG2Jt5IlhAeEkJati/wOvCchVbR4eIj2ogjvmXoXlzBrYRXuAJpXBy5q0se/Yuez5FxDU9Ju81w==",
3691
+ tarballUrl: "https://registry.npmjs.org/@xai-official/grok-linux-x64/-/grok-linux-x64-1.0.21.tgz"
3692
+ }
3693
+ }
3694
+ };
3695
+
3696
+ // src/platform/macos.ts
3697
+ import { isAbsolute, join as join2 } from "node:path";
3698
+ var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
3699
+ "WorkBuddy.app",
3700
+ "Contents",
3701
+ "Resources",
3702
+ "app.asar.unpacked",
3703
+ "cli",
3704
+ "bin",
3705
+ "codebuddy"
3706
+ ]);
3707
+ var macosPlatform = {
3708
+ readProcessTable: () => readProcessTableWithPs("/bin/ps"),
3709
+ readProcessTableSynchronously: () => [],
3710
+ processExists,
3711
+ workBuddyExecutablePaths: (environment) => {
3712
+ const paths = [join2("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
3713
+ const homeDirectory = environment["HOME"];
3714
+ if (homeDirectory !== void 0 && isAbsolute(homeDirectory)) {
3715
+ paths.unshift(join2(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
3716
+ }
3717
+ return paths;
3718
+ },
3719
+ openCodeArchives: {
3720
+ arm64: {
3721
+ asset: "opencode-darwin-arm64.zip",
3722
+ sha256: "fe764f7f360c584a83e18dd5f23fb1a6b2725f5ee8854b0252fe558f7798e946",
3723
+ format: "zip"
3724
+ },
3725
+ x64: {
3726
+ asset: "opencode-darwin-x64.zip",
3727
+ sha256: "9858853e7bacdbbd22c2d70c377e009dc4b354dd04f5588705411e7afb89fd2d",
3728
+ format: "zip"
3729
+ }
3730
+ },
3731
+ grokDependencies: {
3732
+ arm64: {
3733
+ name: "@xai-official/grok-darwin-arm64",
3734
+ integrity: "sha512-I4pKZGnR6Mv4MJOJsB9B/i2o0ODF4eZtp4jHN5feoTqKIeAUVg38OzBtE8aN/wZa7Xg+qhnf6Jd1tcAFvMoFtQ==",
3735
+ tarballUrl: "https://registry.npmjs.org/@xai-official/grok-darwin-arm64/-/grok-darwin-arm64-1.0.21.tgz"
3736
+ },
3737
+ x64: {
3738
+ name: "@xai-official/grok-darwin-x64",
3739
+ integrity: "sha512-h0nFj3NZ9Kz8w6fQ6UDxxeSIhC1WjwwoRE92iNbG//tZy6YGkppR3s7oRVtt4Xl0CJANKUt0EusyIYnnAvKLzw==",
3740
+ tarballUrl: "https://registry.npmjs.org/@xai-official/grok-darwin-x64/-/grok-darwin-x64-1.0.21.tgz"
3741
+ }
3742
+ }
3743
+ };
3744
+
3745
+ // src/platform/index.ts
3746
+ var fallbackPlatform = {
3747
+ readProcessTable: () => readProcessTableWithPs("/usr/bin/ps"),
3748
+ readProcessTableSynchronously: () => [],
3749
+ processExists,
3750
+ workBuddyExecutablePaths: () => [],
3751
+ openCodeArchives: {},
3752
+ grokDependencies: {}
3753
+ };
3754
+ var platforms = /* @__PURE__ */ new Map([
3755
+ ["linux", linuxPlatform],
3756
+ ["darwin", macosPlatform],
3757
+ ["win32", { ...fallbackPlatform, readProcessTable: () => Promise.resolve([]) }]
3758
+ ]);
3759
+ function platformSupportFor(platform) {
3760
+ return platforms.get(platform) ?? fallbackPlatform;
3761
+ }
3762
+
3763
+ // src/process/executable.ts
3764
+ var hostPlatform = platformSupportFor(process.platform);
3512
3765
  var DEFAULT_OUTPUT_LIMIT_BYTES = 16 * 1024;
3513
3766
  var PROCESS_GRACEFUL_STOP_TIMEOUT_MILLISECONDS = 1e3;
3514
3767
  var PROCESS_FORCED_STOP_TIMEOUT_MILLISECONDS = 5e3;
3515
- var PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
3516
- var PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
3517
3768
  var PROCESS_EXIT_CHECK_ATTEMPTS = 16;
3518
3769
  var GRACEFUL_STOP_SIGNAL = 15;
3519
3770
  var FORCED_STOP_SIGNAL = 9;
@@ -3572,13 +3823,13 @@ function executableExtensions(executableName, environment, platform) {
3572
3823
  async function resolveExecutablePath(requestedPath2, platform = process.platform) {
3573
3824
  const absoluteRequestedPath = resolve(requestedPath2);
3574
3825
  try {
3575
- const resolvedPath = await realpath(absoluteRequestedPath);
3576
- const metadata = await stat(resolvedPath);
3826
+ const resolvedPath = await realpath2(absoluteRequestedPath);
3827
+ const metadata = await stat2(resolvedPath);
3577
3828
  if (!metadata.isFile()) {
3578
3829
  return null;
3579
3830
  }
3580
3831
  if (platform !== "win32") {
3581
- await access(resolvedPath, constants.X_OK);
3832
+ await access2(resolvedPath, constants2.X_OK);
3582
3833
  }
3583
3834
  return new ResolvedExecutable(
3584
3835
  new ExecutableIdentity(
@@ -3603,7 +3854,7 @@ async function findExecutableOnPath(executableName, environment, platform = proc
3603
3854
  continue;
3604
3855
  }
3605
3856
  for (const extension of extensions) {
3606
- const requestedPath2 = resolve(join(entry, `${executableName}${extension}`));
3857
+ const requestedPath2 = resolve(join3(entry, `${executableName}${extension}`));
3607
3858
  const executable = await resolveExecutablePath(requestedPath2, platform);
3608
3859
  if (executable !== null) {
3609
3860
  return executable;
@@ -3624,128 +3875,8 @@ function appendBounded(chunks, chunk, currentBytes, limitBytes) {
3624
3875
  chunks.push(chunk);
3625
3876
  return nextBytes;
3626
3877
  }
3627
- function parseProcessTable(output2) {
3628
- const entries = [];
3629
- for (const line of output2.split("\n")) {
3630
- const groups = /^\s*(?<pid>\d+)\s+(?<ppid>\d+)\s+(?<pgid>\d+)\s*$/.exec(line)?.groups;
3631
- if (groups === void 0) {
3632
- continue;
3633
- }
3634
- const processId = Number(groups["pid"]);
3635
- const parentProcessId = Number(groups["ppid"]);
3636
- const processGroupId = Number(groups["pgid"]);
3637
- if (!Number.isSafeInteger(processId) || processId <= 0 || !Number.isSafeInteger(parentProcessId) || parentProcessId < 0 || !Number.isSafeInteger(processGroupId) || processGroupId <= 0) {
3638
- continue;
3639
- }
3640
- entries.push({ parentProcessId, processGroupId, processId });
3641
- }
3642
- return entries;
3643
- }
3644
- function appendLinuxProcessTableEntry(entries, processId, encoded) {
3645
- const closingParenthesis = encoded.lastIndexOf(")");
3646
- if (!encoded.startsWith(`${processId.toString()} (`) || closingParenthesis < 0) {
3647
- return;
3648
- }
3649
- const fields = encoded.slice(closingParenthesis + 1).trim().split(/\s+/);
3650
- const parentProcessId = Number(fields[1]);
3651
- const processGroupId = Number(fields[2]);
3652
- if (!Number.isSafeInteger(parentProcessId) || parentProcessId < 0 || !Number.isSafeInteger(processGroupId) || processGroupId <= 0) {
3653
- return;
3654
- }
3655
- entries.push({ parentProcessId, processGroupId, processId });
3656
- }
3657
- async function readLinuxProcessTable() {
3658
- const entries = [];
3659
- try {
3660
- const directories = await readdir("/proc", { withFileTypes: true });
3661
- for (const directory of directories) {
3662
- if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
3663
- continue;
3664
- }
3665
- const processId = Number(directory.name);
3666
- if (!Number.isSafeInteger(processId) || processId <= 0) {
3667
- continue;
3668
- }
3669
- try {
3670
- appendLinuxProcessTableEntry(
3671
- entries,
3672
- processId,
3673
- await readFile(join("/proc", directory.name, "stat"), "utf8")
3674
- );
3675
- } catch {
3676
- }
3677
- }
3678
- } catch {
3679
- }
3680
- return entries;
3681
- }
3682
- function readLinuxProcessTableSynchronously() {
3683
- const entries = [];
3684
- try {
3685
- const directories = readdirSync("/proc", { withFileTypes: true });
3686
- for (const directory of directories) {
3687
- if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
3688
- continue;
3689
- }
3690
- const processId = Number(directory.name);
3691
- if (!Number.isSafeInteger(processId) || processId <= 0) {
3692
- continue;
3693
- }
3694
- try {
3695
- appendLinuxProcessTableEntry(
3696
- entries,
3697
- processId,
3698
- readFileSync(join("/proc", directory.name, "stat"), "utf8")
3699
- );
3700
- } catch {
3701
- }
3702
- }
3703
- } catch {
3704
- }
3705
- return entries;
3706
- }
3707
- function readProcessTableWithPs(executable) {
3708
- return new Promise((resolveTable) => {
3709
- execFile(
3710
- executable,
3711
- ["-axo", "pid=,ppid=,pgid="],
3712
- {
3713
- encoding: "utf8",
3714
- maxBuffer: PROCESS_TABLE_OUTPUT_LIMIT_BYTES,
3715
- signal: AbortSignal.timeout(PROCESS_TABLE_TIMEOUT_MILLISECONDS),
3716
- timeout: PROCESS_TABLE_TIMEOUT_MILLISECONDS
3717
- },
3718
- (error62, stdout) => {
3719
- resolveTable(error62 === null ? parseProcessTable(stdout) : []);
3720
- }
3721
- );
3722
- });
3723
- }
3724
- async function readLinuxProcessTableWithFallback() {
3725
- const procfsEntries = await readLinuxProcessTable();
3726
- if (procfsEntries.length > 0) {
3727
- return procfsEntries;
3728
- }
3729
- for (const candidate of ["/usr/bin/ps", "/bin/ps", "/run/current-system/sw/bin/ps"]) {
3730
- const executable = await resolveExecutablePath(candidate);
3731
- if (executable === null) {
3732
- continue;
3733
- }
3734
- const entries = await readProcessTableWithPs(executable.identity.requestedPath);
3735
- if (entries.length > 0) {
3736
- return entries;
3737
- }
3738
- }
3739
- return [];
3740
- }
3741
3878
  function readProcessTable() {
3742
- if (process.platform === "win32") {
3743
- return Promise.resolve([]);
3744
- }
3745
- if (process.platform === "linux") {
3746
- return readLinuxProcessTableWithFallback();
3747
- }
3748
- return readProcessTableWithPs(process.platform === "darwin" ? "/bin/ps" : "/usr/bin/ps");
3879
+ return hostPlatform.readProcessTable();
3749
3880
  }
3750
3881
  function selectProcessTree(entries, rootProcessId) {
3751
3882
  const processIds = /* @__PURE__ */ new Set([rootProcessId]);
@@ -3782,11 +3913,9 @@ async function captureProcessTree(child2) {
3782
3913
  if (process.platform === "win32" || child2.pid === void 0) {
3783
3914
  return [];
3784
3915
  }
3785
- if (process.platform === "linux") {
3786
- const procfsEntries = readLinuxProcessTableSynchronously();
3787
- if (procfsEntries.length > 0) {
3788
- return selectProcessTree(procfsEntries, child2.pid);
3789
- }
3916
+ const entries = hostPlatform.readProcessTableSynchronously();
3917
+ if (entries.length > 0) {
3918
+ return selectProcessTree(entries, child2.pid);
3790
3919
  }
3791
3920
  return selectProcessTree(await readProcessTable(), child2.pid);
3792
3921
  }
@@ -3814,36 +3943,15 @@ function signalCapturedProcessGroups(processes, rootProcessId, signal) {
3814
3943
  }
3815
3944
  }
3816
3945
  }
3817
- function processExists(processId) {
3818
- if (process.platform === "linux") {
3819
- try {
3820
- const encoded = readFileSync(join("/proc", processId.toString(), "stat"), "utf8");
3821
- const closingParenthesis = encoded.lastIndexOf(")");
3822
- if (closingParenthesis >= 0) {
3823
- const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
3824
- if (processState === "Z" || processState === "X") {
3825
- return false;
3826
- }
3827
- }
3828
- } catch {
3829
- }
3830
- }
3831
- try {
3832
- process.kill(processId, 0);
3833
- return true;
3834
- } catch {
3835
- return false;
3836
- }
3837
- }
3838
3946
  async function waitForCapturedProcessesExit(processes, rootProcessId) {
3839
3947
  const processIds = processes.map((identity2) => identity2.processId).filter((processId) => processId !== rootProcessId);
3840
3948
  for (let attempt = 0; attempt < PROCESS_EXIT_CHECK_ATTEMPTS; attempt += 1) {
3841
- if (processIds.every((processId) => !processExists(processId))) {
3949
+ if (processIds.every((processId) => !hostPlatform.processExists(processId))) {
3842
3950
  return true;
3843
3951
  }
3844
3952
  await readProcessTable();
3845
3953
  }
3846
- return processIds.every((processId) => !processExists(processId));
3954
+ return processIds.every((processId) => !hostPlatform.processExists(processId));
3847
3955
  }
3848
3956
  function terminateProcess(child2) {
3849
3957
  if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
@@ -4429,8 +4537,8 @@ function formatAgentDiagnostics(inventory, json2, verbose = false) {
4429
4537
  }
4430
4538
 
4431
4539
  // src/agent-installation/managed-npm-package.ts
4432
- import { mkdir, mkdtemp, open, realpath as realpath2, rename, rm, stat as stat2 } from "node:fs/promises";
4433
- import { delimiter, dirname, isAbsolute, join as join2, relative, sep } from "node:path";
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";
4434
4542
  var INSTALL_TIMEOUT_MILLISECONDS = 5 * 60 * 1e3;
4435
4543
  var PACKAGE_METADATA_LIMIT_BYTES = 64 * 1024;
4436
4544
  var PACKAGE_LOCK_LIMIT_BYTES = 8 * 1024 * 1024;
@@ -4481,11 +4589,11 @@ function isRecord2(value) {
4481
4589
  return typeof value === "object" && value !== null && !Array.isArray(value);
4482
4590
  }
4483
4591
  function packagePath(root, packageName) {
4484
- return join2(root, "node_modules", ...packageName.split("/"));
4592
+ return join4(root, "node_modules", ...packageName.split("/"));
4485
4593
  }
4486
4594
  function isContainedPath(root, candidate) {
4487
4595
  const difference = relative(root, candidate);
4488
- return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep}`) && !isAbsolute(difference);
4596
+ return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep}`) && !isAbsolute2(difference);
4489
4597
  }
4490
4598
  async function readJsonRecord(path3, maximumBytes) {
4491
4599
  try {
@@ -4586,14 +4694,14 @@ function verifyPackageLockEntry(lock, definition, verifyDependencyClosure) {
4586
4694
  }
4587
4695
  }
4588
4696
  async function verifyRequiredDependency(rootPath, lock, definition) {
4589
- const dependencyRoot = await realpath2(packagePath(rootPath, definition.packageName));
4697
+ const dependencyRoot = await realpath3(packagePath(rootPath, definition.packageName));
4590
4698
  if (!isContainedPath(rootPath, dependencyRoot)) {
4591
4699
  throw new ManagedNpmPackageError(
4592
4700
  "managed_package_verification_failed",
4593
4701
  "The required managed npm dependency escaped its private cache"
4594
4702
  );
4595
4703
  }
4596
- const metadata = await readJsonRecord(join2(dependencyRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
4704
+ const metadata = await readJsonRecord(join4(dependencyRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
4597
4705
  if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
4598
4706
  throw new ManagedNpmPackageError(
4599
4707
  "managed_package_verification_failed",
@@ -4615,15 +4723,15 @@ async function validateManagedNpmPackage(root, definition) {
4615
4723
  }
4616
4724
  }
4617
4725
  async function validateManagedNpmPackageContents(root, definition) {
4618
- const rootPath = await realpath2(root);
4619
- const packageRoot = await realpath2(packagePath(rootPath, definition.packageName));
4726
+ const rootPath = await realpath3(root);
4727
+ const packageRoot = await realpath3(packagePath(rootPath, definition.packageName));
4620
4728
  if (!isContainedPath(rootPath, packageRoot)) {
4621
4729
  throw new ManagedNpmPackageError(
4622
4730
  "managed_package_verification_failed",
4623
4731
  "The managed npm package escaped its private cache"
4624
4732
  );
4625
4733
  }
4626
- const metadata = await readJsonRecord(join2(packageRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
4734
+ const metadata = await readJsonRecord(join4(packageRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
4627
4735
  if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
4628
4736
  throw new ManagedNpmPackageError(
4629
4737
  "managed_package_verification_failed",
@@ -4631,14 +4739,14 @@ async function validateManagedNpmPackageContents(root, definition) {
4631
4739
  );
4632
4740
  }
4633
4741
  if (definition instanceof SriManagedNpmPackageDefinition) {
4634
- const lock = await readJsonRecord(join2(rootPath, "package-lock.json"), PACKAGE_LOCK_LIMIT_BYTES);
4742
+ const lock = await readJsonRecord(join4(rootPath, "package-lock.json"), PACKAGE_LOCK_LIMIT_BYTES);
4635
4743
  verifyPackageLockEntry(lock, definition, definition.verifyDependencyClosure);
4636
4744
  for (const dependency of definition.requiredDependencies) {
4637
4745
  await verifyRequiredDependency(rootPath, lock, dependency);
4638
4746
  }
4639
4747
  }
4640
4748
  const declaredBin = readBinPath(metadata, definition.executableName);
4641
- const executable = await resolveExecutablePath(join2(packageRoot, declaredBin));
4749
+ const executable = await resolveExecutablePath(join4(packageRoot, declaredBin));
4642
4750
  if (executable === null || !isContainedPath(rootPath, executable.path)) {
4643
4751
  throw new ManagedNpmPackageError(
4644
4752
  "managed_package_verification_failed",
@@ -4651,7 +4759,7 @@ var ManagedNpmPackageInstaller = class {
4651
4759
  install = async (root, definition, environment, signal) => {
4652
4760
  signal.throwIfAborted();
4653
4761
  try {
4654
- const metadata = await stat2(root);
4762
+ const metadata = await stat3(root);
4655
4763
  if (metadata.isDirectory()) {
4656
4764
  return await validateManagedNpmPackage(root, definition);
4657
4765
  }
@@ -4662,7 +4770,7 @@ var ManagedNpmPackageInstaller = class {
4662
4770
  }
4663
4771
  const parent = dirname(root);
4664
4772
  await mkdir(parent, { mode: 448, recursive: true });
4665
- const staging = await mkdtemp(join2(parent, `.${definition.version}.staging-`));
4773
+ const staging = await mkdtemp(join4(parent, `.${definition.version}.staging-`));
4666
4774
  try {
4667
4775
  const npm = await findExecutableOnPath(process.platform === "win32" ? "npm.cmd" : "npm", environment);
4668
4776
  if (npm === null) {
@@ -4688,9 +4796,9 @@ var ManagedNpmPackageInstaller = class {
4688
4796
  `${definition.packageName}@${definition.version}`
4689
4797
  );
4690
4798
  const installEnvironment = {
4691
- HOME: join2(staging, "home"),
4799
+ HOME: join4(staging, "home"),
4692
4800
  NPM_CONFIG_AUDIT: "false",
4693
- NPM_CONFIG_CACHE: join2(staging, ".npm-cache"),
4801
+ NPM_CONFIG_CACHE: join4(staging, ".npm-cache"),
4694
4802
  NPM_CONFIG_FUND: "false",
4695
4803
  NPM_CONFIG_IGNORE_SCRIPTS: "true",
4696
4804
  NPM_CONFIG_PACKAGE_LOCK: "true",
@@ -4712,8 +4820,8 @@ var ManagedNpmPackageInstaller = class {
4712
4820
  timeoutMilliseconds: INSTALL_TIMEOUT_MILLISECONDS
4713
4821
  });
4714
4822
  await Promise.all([
4715
- rm(join2(staging, ".npm-cache"), { force: true, recursive: true }),
4716
- rm(join2(staging, "home"), { force: true, recursive: true })
4823
+ rm(join4(staging, ".npm-cache"), { force: true, recursive: true }),
4824
+ rm(join4(staging, "home"), { force: true, recursive: true })
4717
4825
  ]);
4718
4826
  await validateManagedNpmPackage(staging, definition);
4719
4827
  try {
@@ -4749,7 +4857,7 @@ var ManagedNpmPackageInstaller = class {
4749
4857
  };
4750
4858
 
4751
4859
  // src/agent-catalog/agent-specification.ts
4752
- import { join as join3 } from "node:path";
4860
+ import { join as join5 } from "node:path";
4753
4861
 
4754
4862
  // src/agent-catalog/version-output.ts
4755
4863
  function normalizeVersionOutput(output2) {
@@ -4772,7 +4880,7 @@ var LocalAgentSpecification = class {
4772
4880
  resolveManagedAgent = async (stateDirectory, platform, signal) => {
4773
4881
  signal.throwIfAborted();
4774
4882
  const executable = await resolveExecutablePath(
4775
- join3(stateDirectory, ...this.managedAgentExecutablePath),
4883
+ join5(stateDirectory, ...this.managedAgentExecutablePath),
4776
4884
  platform
4777
4885
  );
4778
4886
  signal.throwIfAborted();
@@ -4976,7 +5084,7 @@ function sessionFailureMeta(failure2) {
4976
5084
  import { spawn as spawn2 } from "node:child_process";
4977
5085
 
4978
5086
  // src/acp/codex/app-server-protocol.ts
4979
- import { isAbsolute as isAbsolute2 } from "node:path";
5087
+ import { isAbsolute as isAbsolute3 } from "node:path";
4980
5088
 
4981
5089
  // ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/external.js
4982
5090
  var external_exports = {};
@@ -24717,7 +24825,7 @@ var imageGenerationItemSchema = external_exports.object({
24717
24825
  });
24718
24826
  var threadItemSchema = external_exports.discriminatedUnion("type", [
24719
24827
  imageGenerationItemSchema,
24720
- external_exports.object({ type: external_exports.literal("imageView"), id: boundedText(256), path: boundedText(32768).refine(isAbsolute2) }),
24828
+ external_exports.object({ type: external_exports.literal("imageView"), id: boundedText(256), path: boundedText(32768).refine(isAbsolute3) }),
24721
24829
  external_exports.object({
24722
24830
  id: boundedText(256),
24723
24831
  text: boundedText(1e6),
@@ -26983,6 +27091,7 @@ var provenanceSchema = external_exports.discriminatedUnion("kind", [
26983
27091
  ]);
26984
27092
  var sessionEventFieldsV2 = {
26985
27093
  eventId: identifierStringSchema,
27094
+ mobiusMetadata: external_exports.object({ omitted: external_exports.literal(true).optional() }).readonly().optional(),
26986
27095
  position: positionSchema,
26987
27096
  provenance: provenanceSchema,
26988
27097
  recordedAt: external_exports.iso.datetime({ offset: true }),
@@ -27049,7 +27158,12 @@ var sessionEventLogPageV2Schema = external_exports.object({
27049
27158
  truncated: external_exports.boolean(),
27050
27159
  version: external_exports.literal(2)
27051
27160
  }).readonly();
27052
- var nativeEventPageRequestV2Schema = external_exports.object({ cursor: external_exports.string().min(1).max(512).nullable(), eventLimit: external_exports.number().int().min(1).max(1e4) }).readonly();
27161
+ var sessionEventOmissionV2Schema = external_exports.literal("agent-reasoning");
27162
+ var nativeEventPageRequestV2Schema = external_exports.object({
27163
+ cursor: external_exports.string().min(1).max(512).nullable(),
27164
+ eventLimit: external_exports.number().int().min(1).max(1e4),
27165
+ omit: external_exports.array(sessionEventOmissionV2Schema).max(1).readonly().optional()
27166
+ }).readonly();
27053
27167
  var queuedPromptRequestEventLogV2Schema = external_exports.object({
27054
27168
  commandId: identifierStringSchema,
27055
27169
  content: external_exports.array(contentBlockV2Schema).min(1).max(100).readonly(),
@@ -27096,6 +27210,7 @@ var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-
27096
27210
  var pageRequestFields = {
27097
27211
  cursor: external_exports.string().min(1).max(512).nullable(),
27098
27212
  eventLimit: external_exports.number().int().min(1).max(1e4),
27213
+ omit: external_exports.array(sessionEventOmissionV2Schema).max(1).readonly().optional(),
27099
27214
  requestId: identifierStringSchema,
27100
27215
  sessionId: identifierStringSchema
27101
27216
  };
@@ -28652,15 +28767,15 @@ var AgentProbeError = class extends Error {
28652
28767
  };
28653
28768
 
28654
28769
  // src/agent-catalog/agents/resolve-user-local-executable.ts
28655
- import { isAbsolute as isAbsolute3, join as join4 } from "node:path";
28770
+ import { isAbsolute as isAbsolute4, join as join6 } from "node:path";
28656
28771
  async function resolveUserLocalExecutable(executableName, context) {
28657
28772
  context.signal.throwIfAborted();
28658
28773
  const platform = context.platform ?? process.platform;
28659
28774
  const homeDirectory = context.environment["HOME"];
28660
- if (platform === "win32" || homeDirectory === void 0 || !isAbsolute3(homeDirectory)) {
28775
+ if (platform === "win32" || homeDirectory === void 0 || !isAbsolute4(homeDirectory)) {
28661
28776
  return [];
28662
28777
  }
28663
- const executable = await resolveExecutablePath(join4(homeDirectory, ".local", "bin", executableName), platform);
28778
+ const executable = await resolveExecutablePath(join6(homeDirectory, ".local", "bin", executableName), platform);
28664
28779
  context.signal.throwIfAborted();
28665
28780
  return executable === null ? [] : [executable];
28666
28781
  }
@@ -28749,8 +28864,8 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
28749
28864
  };
28750
28865
 
28751
28866
  // src/agent-catalog/agents/deepseek-harness-agent.ts
28752
- import { mkdir as mkdir2, realpath as realpath3, stat as stat3, writeFile } from "node:fs/promises";
28753
- import { isAbsolute as isAbsolute4, join as join6, normalize } from "node:path";
28867
+ import { mkdir as mkdir2, realpath as realpath4, stat as stat4, writeFile } from "node:fs/promises";
28868
+ import { isAbsolute as isAbsolute5, join as join8, normalize } from "node:path";
28754
28869
 
28755
28870
  // src/agent-installation/deepseek-managed-package.ts
28756
28871
  var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
@@ -28768,13 +28883,13 @@ var DEEPSEEK_HARNESS_PACKAGE = new DeepSeekHarnessManagedPackage(
28768
28883
 
28769
28884
  // src/storage/state-directory.ts
28770
28885
  import { homedir } from "node:os";
28771
- import { join as join5, resolve as resolve2 } from "node:path";
28886
+ import { join as join7, resolve as resolve2 } from "node:path";
28772
28887
  function readStateDirectory(environment = process.env) {
28773
28888
  const configured = environment["MOBIUS_STATE_DIRECTORY"]?.trim();
28774
28889
  if (configured !== void 0 && configured.length > 0) {
28775
28890
  return resolve2(configured);
28776
28891
  }
28777
- return join5(homedir(), ".mobius");
28892
+ return join7(homedir(), ".mobius");
28778
28893
  }
28779
28894
 
28780
28895
  // src/agent-catalog/agents/deepseek-harness-agent.ts
@@ -28785,20 +28900,20 @@ var DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH = `# Managed by Mobius: pin the ACP brid
28785
28900
  model: deepseek-v4-flash-vision-exp
28786
28901
  `;
28787
28902
  async function prepareAgentHome(path3, imagePrompts) {
28788
- if (!isAbsolute4(path3) || normalize(path3) !== path3) {
28903
+ if (!isAbsolute5(path3) || normalize(path3) !== path3) {
28789
28904
  throw new AgentProbeError("agent_environment_invalid", "The configured Agent home is invalid");
28790
28905
  }
28791
28906
  try {
28792
28907
  if (imagePrompts) {
28793
28908
  await mkdir2(path3, { mode: 448, recursive: true });
28794
28909
  }
28795
- const resolved = await realpath3(path3);
28796
- const metadata = await stat3(resolved);
28910
+ const resolved = await realpath4(path3);
28911
+ const metadata = await stat4(resolved);
28797
28912
  if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
28798
28913
  throw new Error("Agent home is not a user-owned directory");
28799
28914
  }
28800
28915
  if (imagePrompts) {
28801
- await writeFile(join6(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
28916
+ await writeFile(join8(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
28802
28917
  mode: 384
28803
28918
  });
28804
28919
  }
@@ -28846,7 +28961,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
28846
28961
  context.signal
28847
28962
  );
28848
28963
  if (managed.path === agent.path) {
28849
- selectedHome = join6(readStateDirectory(context.environment), "agents", this.id, "home");
28964
+ selectedHome = join8(readStateDirectory(context.environment), "agents", this.id, "home");
28850
28965
  managedHome = true;
28851
28966
  }
28852
28967
  } catch {
@@ -28862,7 +28977,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
28862
28977
  resolveManagedAgent = async (stateDirectory, _platform, signal) => {
28863
28978
  signal.throwIfAborted();
28864
28979
  const executable = await validateManagedNpmPackage(
28865
- join6(stateDirectory, "agents", this.id, DEEPSEEK_HARNESS_PACKAGE.version),
28980
+ join8(stateDirectory, "agents", this.id, DEEPSEEK_HARNESS_PACKAGE.version),
28866
28981
  DEEPSEEK_HARNESS_PACKAGE
28867
28982
  );
28868
28983
  signal.throwIfAborted();
@@ -28916,8 +29031,8 @@ var GeminiCliAgentSpecification = class extends DirectAcpAgentDefinition {
28916
29031
  };
28917
29032
 
28918
29033
  // src/agent-catalog/agents/grok-build-agent.ts
28919
- import { realpath as realpath4 } from "node:fs/promises";
28920
- import { isAbsolute as isAbsolute5, join as join7, relative as relative2, sep as sep2 } from "node:path";
29034
+ import { realpath as realpath5 } from "node:fs/promises";
29035
+ import { isAbsolute as isAbsolute6, join as join9, relative as relative2, sep as sep2 } from "node:path";
28921
29036
  import {
28922
29037
  RequestError
28923
29038
  } from "@agentclientprotocol/sdk";
@@ -28940,50 +29055,25 @@ var GrokBuildManagedPackage = class extends SriManagedNpmPackageDefinition {
28940
29055
  this.requiredDependencies = Object.freeze([requiredDependency]);
28941
29056
  }
28942
29057
  };
28943
- var GROK_DARWIN_ARM64_PACKAGE = new SriManagedNpmDependencyDefinition(
28944
- "@xai-official/grok-darwin-arm64",
28945
- GROK_BUILD_MANAGED_VERSION,
28946
- "sha512-I4pKZGnR6Mv4MJOJsB9B/i2o0ODF4eZtp4jHN5feoTqKIeAUVg38OzBtE8aN/wZa7Xg+qhnf6Jd1tcAFvMoFtQ==",
28947
- "https://registry.npmjs.org/@xai-official/grok-darwin-arm64/-/grok-darwin-arm64-1.0.21.tgz"
28948
- );
28949
- var GROK_DARWIN_X64_PACKAGE = new SriManagedNpmDependencyDefinition(
28950
- "@xai-official/grok-darwin-x64",
28951
- GROK_BUILD_MANAGED_VERSION,
28952
- "sha512-h0nFj3NZ9Kz8w6fQ6UDxxeSIhC1WjwwoRE92iNbG//tZy6YGkppR3s7oRVtt4Xl0CJANKUt0EusyIYnnAvKLzw==",
28953
- "https://registry.npmjs.org/@xai-official/grok-darwin-x64/-/grok-darwin-x64-1.0.21.tgz"
28954
- );
28955
- var GROK_LINUX_ARM64_PACKAGE = new SriManagedNpmDependencyDefinition(
28956
- "@xai-official/grok-linux-arm64",
28957
- GROK_BUILD_MANAGED_VERSION,
28958
- "sha512-Jlwz9XtZPNKz/V/ydifC8OVu3hIZz7pmoStt8c4KCqkSWjWiZ/PBIC0iJiq8rvByhx5Z0EdSyq8ZXVwtocceGA==",
28959
- "https://registry.npmjs.org/@xai-official/grok-linux-arm64/-/grok-linux-arm64-1.0.21.tgz"
28960
- );
28961
- var GROK_LINUX_X64_PACKAGE = new SriManagedNpmDependencyDefinition(
28962
- "@xai-official/grok-linux-x64",
28963
- GROK_BUILD_MANAGED_VERSION,
28964
- "sha512-AjDV5ifEz5LFG2Jt5IlhAeEkJati/wOvCchVbR4eIj2ogjvmXoXlzBrYRXuAJpXBy5q0se/Yuez5FxDU9Ju81w==",
28965
- "https://registry.npmjs.org/@xai-official/grok-linux-x64/-/grok-linux-x64-1.0.21.tgz"
28966
- );
28967
29058
  function grokBuildManagedPackage(platform, architecture) {
28968
- if (platform === "darwin" && architecture === "arm64") {
28969
- return new GrokBuildManagedPackage(GROK_DARWIN_ARM64_PACKAGE);
28970
- }
28971
- if (platform === "darwin" && architecture === "x64") {
28972
- return new GrokBuildManagedPackage(GROK_DARWIN_X64_PACKAGE);
28973
- }
28974
- if (platform === "linux" && architecture === "arm64") {
28975
- return new GrokBuildManagedPackage(GROK_LINUX_ARM64_PACKAGE);
29059
+ const release = platformSupportFor(platform).grokDependencies[architecture];
29060
+ if (release === void 0) {
29061
+ throw new Error("Grok Build does not publish a package for this platform");
28976
29062
  }
28977
- if (platform === "linux" && architecture === "x64") {
28978
- return new GrokBuildManagedPackage(GROK_LINUX_X64_PACKAGE);
28979
- }
28980
- throw new Error("Grok Build does not publish a package for this platform");
29063
+ return new GrokBuildManagedPackage(
29064
+ new SriManagedNpmDependencyDefinition(
29065
+ release.name,
29066
+ GROK_BUILD_MANAGED_VERSION,
29067
+ release.integrity,
29068
+ release.tarballUrl
29069
+ )
29070
+ );
28981
29071
  }
28982
29072
 
28983
29073
  // src/agent-catalog/agents/grok-build-agent.ts
28984
29074
  function isContainedPath2(root, candidate) {
28985
29075
  const difference = relative2(root, candidate);
28986
- return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep2}`) && !isAbsolute5(difference);
29076
+ return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep2}`) && !isAbsolute6(difference);
28987
29077
  }
28988
29078
  var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
28989
29079
  adapterVersion = GROK_BUILD_MANAGED_VERSION;
@@ -29012,8 +29102,8 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
29012
29102
  );
29013
29103
  if (managed.path === agent.path) {
29014
29104
  return Object.freeze({
29015
- GROK_HOME: await realpath4(
29016
- join7(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION, "home")
29105
+ GROK_HOME: await realpath5(
29106
+ join9(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION, "home")
29017
29107
  )
29018
29108
  });
29019
29109
  }
@@ -29024,9 +29114,9 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
29024
29114
  };
29025
29115
  resolveManagedAgent = async (stateDirectory, platform, signal) => {
29026
29116
  signal.throwIfAborted();
29027
- const versionRoot = await realpath4(join7(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION));
29028
- await validateManagedNpmPackage(join7(versionRoot, "package"), grokBuildManagedPackage(platform, process.arch));
29029
- const executable = await resolveExecutablePath(join7(versionRoot, "home", "bin", "grok"), platform);
29117
+ const versionRoot = await realpath5(join9(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION));
29118
+ await validateManagedNpmPackage(join9(versionRoot, "package"), grokBuildManagedPackage(platform, process.arch));
29119
+ const executable = await resolveExecutablePath(join9(versionRoot, "home", "bin", "grok"), platform);
29030
29120
  signal.throwIfAborted();
29031
29121
  if (executable === null || !isContainedPath2(versionRoot, executable.path)) {
29032
29122
  throw new AgentProbeError("managed_agent_invalid", "The managed Grok Build executable is invalid");
@@ -29126,13 +29216,13 @@ var OhMyPiAgentSpecification = class extends DirectAcpAgentDefinition {
29126
29216
  };
29127
29217
 
29128
29218
  // src/agent-catalog/agents/opencode-agent.ts
29129
- import { join as join9 } from "node:path";
29219
+ import { join as join11 } from "node:path";
29130
29220
 
29131
29221
  // src/agent-installation/managed-agent-archive.ts
29132
29222
  import { createHash } from "node:crypto";
29133
29223
  import { createReadStream } from "node:fs";
29134
- import { chmod, copyFile, mkdir as mkdir3, mkdtemp as mkdtemp2, open as open3, realpath as realpath5, rename as rename2, rm as rm2, stat as stat4, writeFile as writeFile2 } from "node:fs/promises";
29135
- import { delimiter as delimiter2, dirname as dirname2, isAbsolute as isAbsolute6, join as join8, relative as relative3, sep as sep3 } from "node:path";
29224
+ 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";
29225
+ import { delimiter as delimiter2, dirname as dirname2, isAbsolute as isAbsolute7, join as join10, relative as relative3, sep as sep3 } from "node:path";
29136
29226
 
29137
29227
  // src/agent-installation/verified-download.ts
29138
29228
  import { fetch } from "undici";
@@ -29238,7 +29328,7 @@ function isRecord5(value) {
29238
29328
  }
29239
29329
  function isContainedPath3(root, candidate) {
29240
29330
  const difference = relative3(root, candidate);
29241
- return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !isAbsolute6(difference);
29331
+ return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !isAbsolute7(difference);
29242
29332
  }
29243
29333
  async function hashFile(path3, signal) {
29244
29334
  signal.throwIfAborted();
@@ -29312,16 +29402,16 @@ async function readManifest(path3) {
29312
29402
  }
29313
29403
  async function validateManagedAgentArchive(root, definition, signal) {
29314
29404
  try {
29315
- const rootPath = await realpath5(root);
29316
- const rootMetadata = await stat4(rootPath);
29405
+ const rootPath = await realpath6(root);
29406
+ const rootMetadata = await stat5(rootPath);
29317
29407
  if (!rootMetadata.isDirectory() || typeof process.getuid === "function" && rootMetadata.uid !== process.getuid()) {
29318
29408
  throw new Error("Managed Agent root is not user-owned");
29319
29409
  }
29320
- const manifest = await readManifest(join8(rootPath, "archive.json"));
29410
+ const manifest = await readManifest(join10(rootPath, "archive.json"));
29321
29411
  if (manifest["archiveSha256"] !== definition.archiveSha256 || manifest["archiveUrl"] !== definition.archiveUrl.toString() || manifest["version"] !== definition.version || typeof manifest["executableSha256"] !== "string") {
29322
29412
  throw new Error("Managed Agent archive identity is invalid");
29323
29413
  }
29324
- const executable = await resolveExecutablePath(join8(rootPath, "bin", definition.executableName));
29414
+ const executable = await resolveExecutablePath(join10(rootPath, "bin", definition.executableName));
29325
29415
  if (executable === null || !isContainedPath3(rootPath, executable.path) || await hashFile(executable.path, signal) !== manifest["executableSha256"]) {
29326
29416
  throw new Error("Managed Agent executable is invalid");
29327
29417
  }
@@ -29347,47 +29437,21 @@ function releaseUrl(asset) {
29347
29437
  return new URL(`https://github.com/anomalyco/opencode/releases/download/v${OPENCODE_MANAGED_VERSION}/${asset}`);
29348
29438
  }
29349
29439
  function openCodeManagedArchive(platform, architecture) {
29350
- if (platform === "darwin" && architecture === "arm64") {
29351
- const asset = "opencode-darwin-arm64.zip";
29352
- return new ZipManagedAgentArchiveDefinition(
29353
- OPENCODE_MANAGED_VERSION,
29354
- asset,
29355
- releaseUrl(asset),
29356
- "fe764f7f360c584a83e18dd5f23fb1a6b2725f5ee8854b0252fe558f7798e946",
29357
- "opencode"
29358
- );
29359
- }
29360
- if (platform === "darwin" && architecture === "x64") {
29361
- const asset = "opencode-darwin-x64.zip";
29362
- return new ZipManagedAgentArchiveDefinition(
29363
- OPENCODE_MANAGED_VERSION,
29364
- asset,
29365
- releaseUrl(asset),
29366
- "9858853e7bacdbbd22c2d70c377e009dc4b354dd04f5588705411e7afb89fd2d",
29367
- "opencode"
29368
- );
29369
- }
29370
- if (platform === "linux" && architecture === "arm64") {
29371
- const asset = "opencode-linux-arm64.tar.gz";
29372
- return new TarGzipManagedAgentArchiveDefinition(
29373
- OPENCODE_MANAGED_VERSION,
29374
- asset,
29375
- releaseUrl(asset),
29376
- "70baf769395ca4e7a68924026530c390eace194f3b7e4919d4efcb2aa2eed3c0",
29377
- "opencode"
29378
- );
29379
- }
29380
- if (platform === "linux" && architecture === "x64") {
29381
- const asset = "opencode-linux-x64.tar.gz";
29382
- return new TarGzipManagedAgentArchiveDefinition(
29383
- OPENCODE_MANAGED_VERSION,
29384
- asset,
29385
- releaseUrl(asset),
29386
- "ea800b7ff56226b70952126c9fc1e2517ca4c4b5682fd9d3f9e87449697a1194",
29387
- "opencode"
29388
- );
29389
- }
29390
- throw new Error("OpenCode does not publish an approved archive for this platform");
29440
+ const release = platformSupportFor(platform).openCodeArchives[architecture];
29441
+ if (release === void 0) {
29442
+ throw new Error("OpenCode does not publish an approved archive for this platform");
29443
+ }
29444
+ const Definition = {
29445
+ zip: ZipManagedAgentArchiveDefinition,
29446
+ "tar.gz": TarGzipManagedAgentArchiveDefinition
29447
+ }[release.format];
29448
+ return new Definition(
29449
+ OPENCODE_MANAGED_VERSION,
29450
+ release.asset,
29451
+ releaseUrl(release.asset),
29452
+ release.sha256,
29453
+ "opencode"
29454
+ );
29391
29455
  }
29392
29456
 
29393
29457
  // src/agent-catalog/agents/opencode-agent.ts
@@ -29513,7 +29577,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
29513
29577
  return Object.freeze(environment);
29514
29578
  };
29515
29579
  resolveManagedAgent = async (stateDirectory, platform, signal) => await validateManagedAgentArchive(
29516
- join9(stateDirectory, "agents", this.id, OPENCODE_MANAGED_VERSION),
29580
+ join11(stateDirectory, "agents", this.id, OPENCODE_MANAGED_VERSION),
29517
29581
  openCodeManagedArchive(platform, process.arch),
29518
29582
  signal
29519
29583
  );
@@ -29531,7 +29595,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
29531
29595
  };
29532
29596
 
29533
29597
  // src/agent-catalog/agents/pi-agent.ts
29534
- import { join as join10 } from "node:path";
29598
+ import { join as join12 } from "node:path";
29535
29599
  import {
29536
29600
  methods as methods4
29537
29601
  } from "@agentclientprotocol/sdk";
@@ -29590,7 +29654,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
29590
29654
  resolveManagedAgent = async (stateDirectory, _platform, signal) => {
29591
29655
  signal.throwIfAborted();
29592
29656
  const executable = await validateManagedNpmPackage(
29593
- join10(stateDirectory, "agents", this.id, PI_AGENT_PACKAGE.version),
29657
+ join12(stateDirectory, "agents", this.id, PI_AGENT_PACKAGE.version),
29594
29658
  PI_AGENT_PACKAGE
29595
29659
  );
29596
29660
  signal.throwIfAborted();
@@ -29628,7 +29692,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
29628
29692
  };
29629
29693
 
29630
29694
  // src/agent-catalog/agents/workbuddy-agent.ts
29631
- import { isAbsolute as isAbsolute7, join as join11 } from "node:path";
29695
+ import { join as join13 } from "node:path";
29632
29696
 
29633
29697
  // src/agent-installation/workbuddy-managed-package.ts
29634
29698
  var WORKBUDDY_MANAGED_VERSION = "2.146.0";
@@ -29646,15 +29710,6 @@ var WORKBUDDY_MANAGED_PACKAGE = new WorkBuddyManagedPackage(
29646
29710
  );
29647
29711
 
29648
29712
  // src/agent-catalog/agents/workbuddy-agent.ts
29649
- var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
29650
- "WorkBuddy.app",
29651
- "Contents",
29652
- "Resources",
29653
- "app.asar.unpacked",
29654
- "cli",
29655
- "bin",
29656
- "codebuddy"
29657
- ]);
29658
29713
  var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
29659
29714
  adapterVersion = WORKBUDDY_MANAGED_VERSION;
29660
29715
  authenticationCommand = () => "codebuddy";
@@ -29683,7 +29738,7 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
29683
29738
  resolveManagedAgent = async (stateDirectory, _platform, signal) => {
29684
29739
  signal.throwIfAborted();
29685
29740
  const executable = await validateManagedNpmPackage(
29686
- join11(stateDirectory, "agents", this.id, WORKBUDDY_MANAGED_VERSION),
29741
+ join13(stateDirectory, "agents", this.id, WORKBUDDY_MANAGED_VERSION),
29687
29742
  WORKBUDDY_MANAGED_PACKAGE
29688
29743
  );
29689
29744
  signal.throwIfAborted();
@@ -29691,17 +29746,11 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
29691
29746
  };
29692
29747
  resolveInstalledAgentExecutables = async (context) => {
29693
29748
  context.signal.throwIfAborted();
29694
- if ((context.platform ?? process.platform) !== "darwin") {
29695
- return [];
29696
- }
29697
- const requestedPaths = [join11("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
29698
- const homeDirectory = context.environment["HOME"];
29699
- if (homeDirectory !== void 0 && isAbsolute7(homeDirectory)) {
29700
- requestedPaths.unshift(join11(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
29701
- }
29749
+ const platform = context.platform ?? process.platform;
29750
+ const requestedPaths = platformSupportFor(platform).workBuddyExecutablePaths(context.environment);
29702
29751
  const executables = [];
29703
29752
  for (const requestedPath2 of requestedPaths) {
29704
- const executable = await resolveExecutablePath(requestedPath2, "darwin");
29753
+ const executable = await resolveExecutablePath(requestedPath2, platform);
29705
29754
  context.signal.throwIfAborted();
29706
29755
  if (executable !== null) {
29707
29756
  executables.push(executable);
@@ -30061,10 +30110,10 @@ function isAgentVersionSupported(reportedVersion, minimumSupportedVersion) {
30061
30110
  }
30062
30111
 
30063
30112
  // src/agent-catalog/executable-discovery.ts
30064
- import { isAbsolute as isAbsolute8, join as join13 } from "node:path";
30113
+ import { isAbsolute as isAbsolute8, join as join15 } from "node:path";
30065
30114
 
30066
30115
  // src/agent-installation/managed-adapter-installer.ts
30067
- import { join as join12 } from "node:path";
30116
+ import { join as join14 } from "node:path";
30068
30117
  var ManagedAdapterInstallError = class extends Error {
30069
30118
  code;
30070
30119
  constructor(code, message, options = {}) {
@@ -30121,7 +30170,7 @@ var ManagedAdapterInstaller = class {
30121
30170
  this.#stateDirectory = options.stateDirectory;
30122
30171
  }
30123
30172
  install = async (specification, signal) => {
30124
- const root = join12(this.#stateDirectory, "adapters", specification.id, specification.adapterVersion);
30173
+ const root = join14(this.#stateDirectory, "adapters", specification.id, specification.adapterVersion);
30125
30174
  try {
30126
30175
  return await this.#npmInstaller.install(
30127
30176
  root,
@@ -30155,7 +30204,7 @@ async function resolveManagedAdapterExecutable(specification, context) {
30155
30204
  let managed;
30156
30205
  try {
30157
30206
  managed = await validateManagedAdapter(
30158
- join13(readStateDirectory(context.environment), "adapters", specification.id, specification.adapterVersion),
30207
+ join15(readStateDirectory(context.environment), "adapters", specification.id, specification.adapterVersion),
30159
30208
  specification
30160
30209
  );
30161
30210
  } catch {
@@ -30469,10 +30518,10 @@ async function discoverLocalAgentInventory(options) {
30469
30518
  }
30470
30519
 
30471
30520
  // src/config.ts
30472
- import { join as join14, resolve as resolve3 } from "node:path";
30521
+ import { join as join16, resolve as resolve3 } from "node:path";
30473
30522
  function loadDefaultWorkspace(environment = process.env) {
30474
30523
  const { MOBIUS_DEFAULT_WORKSPACE: configuredWorkspace } = environment;
30475
- return configuredWorkspace ?? join14(readStateDirectory(environment), "workspace");
30524
+ return configuredWorkspace ?? join16(readStateDirectory(environment), "workspace");
30476
30525
  }
30477
30526
  var DaemonLocalContext = class {
30478
30527
  environment;
@@ -30502,7 +30551,7 @@ var OpaqueDaemonReconnectTarget = class extends DaemonReconnectTarget {
30502
30551
  this.commandArgument = `--connection ${connectionId2}`;
30503
30552
  }
30504
30553
  };
30505
- function createDaemonConfig(connection, agents = [], installableAgents = [], localContext = new DaemonLocalContext(readStateDirectory(), process.env), reconnectTarget = null) {
30554
+ function createDaemonConfig(connection, agents = [], installableAgents = [], localContext = new DaemonLocalContext(readStateDirectory(), process.env), reconnectTarget = null, resolveAgent) {
30506
30555
  const daemonAgents = agents.map((agent) => withDaemonEnvironment(agent, localContext.environment));
30507
30556
  return {
30508
30557
  agents: daemonAgents,
@@ -30513,7 +30562,8 @@ function createDaemonConfig(connection, agents = [], installableAgents = [], loc
30513
30562
  installableAgents,
30514
30563
  localContext,
30515
30564
  reconnectTarget,
30516
- relayUrl: connection.relayUrl
30565
+ relayUrl: connection.relayUrl,
30566
+ ...resolveAgent === void 0 ? {} : { resolveAgent }
30517
30567
  };
30518
30568
  }
30519
30569
 
@@ -30523,18 +30573,184 @@ import { createHash as createHash9, randomBytes } from "node:crypto";
30523
30573
  import { readFile as readFile3, unlink as unlink2, writeFile as writeFile5 } from "node:fs/promises";
30524
30574
  import { createConnection, createServer } from "node:net";
30525
30575
  import { tmpdir } from "node:os";
30526
- import { join as join20 } from "node:path";
30576
+ import { join as join22 } from "node:path";
30527
30577
 
30528
30578
  // src/pairing/pair-local-machine.ts
30529
- import { mkdir as mkdir5, realpath as realpath6, stat as stat5 } from "node:fs/promises";
30579
+ import { mkdir as mkdir5, realpath as realpath7, stat as stat6 } from "node:fs/promises";
30530
30580
  import { hostname as hostname3 } from "node:os";
30531
30581
  import { basename, resolve as resolve5 } from "node:path";
30582
+ import { fetch as fetch3 } from "undici";
30583
+
30584
+ // src/agent-catalog/publish-agent-catalog.ts
30532
30585
  import { fetch as fetch2 } from "undici";
30533
30586
 
30587
+ // src/relay-connection/runtime-authentication.ts
30588
+ function runtimeCredential(relayUrl) {
30589
+ return relayUrl.searchParams.get("token") ?? "";
30590
+ }
30591
+ function runtimeAuthorization(relayUrl) {
30592
+ const credential = runtimeCredential(relayUrl);
30593
+ return credential.length === 0 ? {} : { authorization: `Bearer ${credential}` };
30594
+ }
30595
+ function relayHttpEndpoint(relayUrl) {
30596
+ const endpoint = new URL(relayUrl);
30597
+ endpoint.protocol = endpoint.protocol === "wss:" ? "https:" : "http:";
30598
+ endpoint.search = "";
30599
+ return endpoint;
30600
+ }
30601
+
30602
+ // src/agent-catalog/publish-agent-catalog.ts
30603
+ var CATALOG_UPDATE_TIMEOUT_MILLISECONDS = 2e4;
30604
+ var AgentCatalogPublishError = class extends Error {
30605
+ code = "agent_catalog_update_failed";
30606
+ diagnosticDetails;
30607
+ constructor(message, options = {}, diagnosticDetails = {}) {
30608
+ super(message, options);
30609
+ this.diagnosticDetails = diagnosticDetails;
30610
+ this.name = "AgentCatalogPublishError";
30611
+ }
30612
+ };
30613
+ function isRecord6(value) {
30614
+ return typeof value === "object" && value !== null && !Array.isArray(value);
30615
+ }
30616
+ function isSafeRelayErrorMessage(value) {
30617
+ return value.length > 0 && value.length <= 512 && Array.from(value).every((character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127);
30618
+ }
30619
+ async function rejectedCatalogError(response) {
30620
+ let value;
30621
+ try {
30622
+ value = await response.json();
30623
+ } catch {
30624
+ return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
30625
+ }
30626
+ if (!isRecord6(value) || !isRecord6(value["error"])) {
30627
+ return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
30628
+ }
30629
+ const code = value["error"]["code"];
30630
+ const message = value["error"]["message"];
30631
+ if (typeof code !== "string" || !/^[a-z][a-z0-9_]{0,63}$/.test(code) || typeof message !== "string" || !isSafeRelayErrorMessage(message)) {
30632
+ return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
30633
+ }
30634
+ return new AgentCatalogPublishError(
30635
+ `The Relay rejected the Agent catalog update (${code}): ${message}`,
30636
+ {},
30637
+ {
30638
+ relayErrorCode: code
30639
+ }
30640
+ );
30641
+ }
30642
+ function catalogEndpoint(config2) {
30643
+ const endpoint = relayHttpEndpoint(config2.relayUrl);
30644
+ if (endpoint.pathname.endsWith("/daemon")) {
30645
+ endpoint.pathname = `${endpoint.pathname.slice(0, -"/daemon".length)}/catalog`;
30646
+ return endpoint;
30647
+ }
30648
+ const runtimePath = "/v1/runtimes/connect";
30649
+ if (endpoint.pathname.endsWith(runtimePath)) {
30650
+ endpoint.pathname = `${endpoint.pathname.slice(0, -runtimePath.length)}/channels/${encodeURIComponent(config2.channelId)}/catalog`;
30651
+ return endpoint;
30652
+ }
30653
+ throw new AgentCatalogPublishError("The Relay URL is invalid");
30654
+ }
30655
+ async function publishAgentCatalog(config2, signal) {
30656
+ signal.throwIfAborted();
30657
+ const timeoutSignal = AbortSignal.timeout(CATALOG_UPDATE_TIMEOUT_MILLISECONDS);
30658
+ const requestSignal = AbortSignal.any([signal, timeoutSignal]);
30659
+ let response;
30660
+ const catalog = config2.catalog.read();
30661
+ try {
30662
+ response = await fetch2(catalogEndpoint(config2), {
30663
+ body: JSON.stringify({
30664
+ agents: catalog.agents.map((agent) => ({
30665
+ agentPath: agent.agentIdentity.requestedPath,
30666
+ agentVersion: agent.agentVersion,
30667
+ agentSettingsDiscovery: true,
30668
+ capabilities: agent.capabilities,
30669
+ id: agent.id,
30670
+ label: agent.label,
30671
+ sessionTurnConfiguration: true
30672
+ })),
30673
+ installableAgents: catalog.installableAgents
30674
+ }),
30675
+ dispatcher: environmentProxyDispatcher,
30676
+ headers: { ...runtimeAuthorization(config2.relayUrl), "content-type": "application/json" },
30677
+ method: "PUT",
30678
+ signal: requestSignal
30679
+ });
30680
+ } catch (error62) {
30681
+ if (signal.aborted) {
30682
+ signal.throwIfAborted();
30683
+ }
30684
+ throw new AgentCatalogPublishError(
30685
+ timeoutSignal.aborted ? "The Agent catalog update timed out" : "The Agent catalog could not be updated",
30686
+ { cause: error62 }
30687
+ );
30688
+ }
30689
+ if (!response.ok) {
30690
+ throw await rejectedCatalogError(response);
30691
+ }
30692
+ await response.body?.cancel();
30693
+ }
30694
+
30695
+ // src/agent-catalog/resolve-catalog-agent.ts
30696
+ function createCatalogAgentResolver(discover, readConfig, publish) {
30697
+ const swaps = /* @__PURE__ */ new Map();
30698
+ return async (agent, signal) => {
30699
+ const config2 = readConfig();
30700
+ const pending = swaps.get(agent.id);
30701
+ if (pending !== void 0) {
30702
+ await pending;
30703
+ return config2.catalog.find(agent.id);
30704
+ }
30705
+ let release = () => void 0;
30706
+ const gate = new Promise((resolveGate) => {
30707
+ release = resolveGate;
30708
+ });
30709
+ swaps.set(agent.id, gate);
30710
+ try {
30711
+ if (await unchangedIdentity(agent, signal)) {
30712
+ return agent;
30713
+ }
30714
+ signal.throwIfAborted();
30715
+ const inventory = await discover(signal);
30716
+ signal.throwIfAborted();
30717
+ const previous = config2.catalog.read();
30718
+ const previousAgent = previous.agents.find((entry) => entry.id === agent.id);
30719
+ if (previousAgent === void 0) {
30720
+ throw new Error(`The local Agent ${agent.id} left the catalog before its refresh completed`);
30721
+ }
30722
+ config2.catalog.transition(
30723
+ [
30724
+ ...previous.agents.filter((entry) => entry.id !== agent.id),
30725
+ ...inventory.readyAgents().map((ready) => withDaemonEnvironment(ready, config2.localContext.environment))
30726
+ ],
30727
+ [...previous.installableAgents.filter((entry) => entry.id !== agent.id), ...inventory.installable]
30728
+ );
30729
+ try {
30730
+ await publish(config2, signal);
30731
+ } catch (error62) {
30732
+ config2.catalog.transition(previous.agents, previous.installableAgents);
30733
+ throw error62;
30734
+ }
30735
+ return config2.catalog.find(agent.id);
30736
+ } finally {
30737
+ swaps.delete(agent.id);
30738
+ release();
30739
+ }
30740
+ };
30741
+ }
30742
+ async function unchangedIdentity(agent, signal) {
30743
+ if (!await revalidateExecutable(agent.agentIdentity)) {
30744
+ return false;
30745
+ }
30746
+ signal.throwIfAborted();
30747
+ return agent.kind !== "acp-adapter-process" || await revalidateExecutable(agent.adapterIdentity);
30748
+ }
30749
+
30534
30750
  // src/storage/runtime-installation-store.ts
30535
30751
  import { createHash as createHash2, randomUUID } from "node:crypto";
30536
30752
  import { mkdir as mkdir4, open as open4, readdir as readdir2, rename as rename3, unlink, writeFile as writeFile3 } from "node:fs/promises";
30537
- import { dirname as dirname3, join as join15, resolve as resolve4 } from "node:path";
30753
+ import { dirname as dirname3, join as join17, resolve as resolve4 } from "node:path";
30538
30754
  var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
30539
30755
  var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
30540
30756
  var INSTALLATION_ID_PATTERN = /^min_[a-f0-9]{32}$/;
@@ -30598,7 +30814,7 @@ var VerifiedRuntimeConnection = class {
30598
30814
  this.runtimeId = runtimeId;
30599
30815
  }
30600
30816
  };
30601
- function isRecord6(value) {
30817
+ function isRecord7(value) {
30602
30818
  return typeof value === "object" && value !== null && !Array.isArray(value);
30603
30819
  }
30604
30820
  function hasExactKeys(value, expectedKeys) {
@@ -30671,7 +30887,7 @@ function channelIndexFileName(channelId) {
30671
30887
  return `mci_${createHash2("sha256").update(channelId).digest("hex")}.json`;
30672
30888
  }
30673
30889
  function decodeInstallationPointer(value) {
30674
- if (!isRecord6(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {
30890
+ if (!isRecord7(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {
30675
30891
  throw new RuntimeInstallationStoreError("invalid_installation", "The local installation record is invalid");
30676
30892
  }
30677
30893
  const storedInstallationId = value["installationId"];
@@ -30681,7 +30897,7 @@ function decodeInstallationPointer(value) {
30681
30897
  return { installationId: validateInstallationId(storedInstallationId) };
30682
30898
  }
30683
30899
  function decodeChannelIndex(value) {
30684
- if (!isRecord6(value) || !hasExactKeys(value, CHANNEL_INDEX_KEYS) || value["version"] !== 1) {
30900
+ if (!isRecord7(value) || !hasExactKeys(value, CHANNEL_INDEX_KEYS) || value["version"] !== 1) {
30685
30901
  throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
30686
30902
  }
30687
30903
  const applicationId = value["applicationId"];
@@ -30731,7 +30947,7 @@ function decodeVerifiedConnection(value) {
30731
30947
  );
30732
30948
  }
30733
30949
  function decodeConnection(value) {
30734
- if (!isRecord6(value)) {
30950
+ if (!isRecord7(value)) {
30735
30951
  throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
30736
30952
  }
30737
30953
  return decodeVerifiedConnection(value);
@@ -30777,7 +30993,7 @@ async function readJsonFile(path3, signal, missingCode) {
30777
30993
  async function writeJsonAtomically(path3, value, signal) {
30778
30994
  signal.throwIfAborted();
30779
30995
  const directory = dirname3(path3);
30780
- const temporaryPath = join15(directory, `.${randomUUID()}.tmp`);
30996
+ const temporaryPath = join17(directory, `.${randomUUID()}.tmp`);
30781
30997
  try {
30782
30998
  await mkdir4(directory, { mode: 448, recursive: true });
30783
30999
  signal.throwIfAborted();
@@ -30803,14 +31019,14 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
30803
31019
  this.applicationId = applicationId;
30804
31020
  this.installationId = installationId2;
30805
31021
  this.stateDirectory = stateDirectory;
30806
- this.#channelDirectory = join15(stateDirectory, "channels");
30807
- this.#connectionDirectory = join15(stateDirectory, "connections");
31022
+ this.#channelDirectory = join17(stateDirectory, "channels");
31023
+ this.#connectionDirectory = join17(stateDirectory, "connections");
30808
31024
  }
30809
31025
  static open = async (options, signal) => {
30810
31026
  signal.throwIfAborted();
30811
31027
  const applicationId = validateApplicationId(options.applicationId);
30812
31028
  const rootDirectory = resolve4(options.stateDirectory);
30813
- const applicationDirectory = join15(rootDirectory, "installations", applicationId);
31029
+ const applicationDirectory = join17(rootDirectory, "installations", applicationId);
30814
31030
  try {
30815
31031
  await mkdir4(applicationDirectory, { mode: 448, recursive: true });
30816
31032
  } catch (cause) {
@@ -30823,7 +31039,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
30823
31039
  );
30824
31040
  }
30825
31041
  const storedInstallationId = await readOrCreateInstallationId(applicationDirectory, signal);
30826
- const stateDirectory = join15(applicationDirectory, storedInstallationId);
31042
+ const stateDirectory = join17(applicationDirectory, storedInstallationId);
30827
31043
  try {
30828
31044
  await mkdir4(stateDirectory, { mode: 448, recursive: true });
30829
31045
  } catch (cause) {
@@ -30838,8 +31054,8 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
30838
31054
  signal.throwIfAborted();
30839
31055
  return new _RuntimeInstallationStore(applicationId, storedInstallationId, stateDirectory);
30840
31056
  };
30841
- connectionPath = (connectionId2) => join15(this.#connectionDirectory, `${validateConnectionId(connectionId2)}.json`);
30842
- channelIndexPath = (channelId) => join15(this.#channelDirectory, channelIndexFileName(validateIdentifier(channelId, "invalid_channel_id")));
31057
+ connectionPath = (connectionId2) => join17(this.#connectionDirectory, `${validateConnectionId(connectionId2)}.json`);
31058
+ channelIndexPath = (channelId) => join17(this.#channelDirectory, channelIndexFileName(validateIdentifier(channelId, "invalid_channel_id")));
30843
31059
  readConnection = async (connectionId2, signal) => {
30844
31060
  const stored = decodeConnection(
30845
31061
  await readJsonFile(this.connectionPath(connectionId2), signal, "connection_not_found")
@@ -31001,7 +31217,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
31001
31217
  };
31002
31218
  };
31003
31219
  async function readOrCreateInstallationId(applicationDirectory, signal) {
31004
- const pointerPath = join15(applicationDirectory, "current.json");
31220
+ const pointerPath = join17(applicationDirectory, "current.json");
31005
31221
  try {
31006
31222
  return decodeInstallationPointer(await readJsonFile(pointerPath, signal, "installation_not_found")).installationId;
31007
31223
  } catch (cause) {
@@ -31049,7 +31265,7 @@ var PairingClientError = class extends Error {
31049
31265
  this.name = "PairingClientError";
31050
31266
  }
31051
31267
  };
31052
- function isRecord7(value) {
31268
+ function isRecord8(value) {
31053
31269
  return typeof value === "object" && value !== null && !Array.isArray(value);
31054
31270
  }
31055
31271
  function hasExactKeys2(value, expectedKeys) {
@@ -31142,8 +31358,8 @@ async function resolveDefaultWorkspace(path3) {
31142
31358
  const requestedWorkspace = resolve5(path3);
31143
31359
  try {
31144
31360
  await mkdir5(requestedWorkspace, { recursive: true, mode: 448 });
31145
- const defaultWorkspace = await realpath6(requestedWorkspace);
31146
- const metadata = await stat5(defaultWorkspace);
31361
+ const defaultWorkspace = await realpath7(requestedWorkspace);
31362
+ const metadata = await stat6(defaultWorkspace);
31147
31363
  if (!metadata.isDirectory()) {
31148
31364
  throw new PairingClientError("invalid_workspace", "The default workspace is not a directory");
31149
31365
  }
@@ -31172,9 +31388,9 @@ async function readJsonResponse(response) {
31172
31388
  }
31173
31389
  }
31174
31390
  function readRelayError(value) {
31175
- if (isRecord7(value)) {
31391
+ if (isRecord8(value)) {
31176
31392
  const error62 = value["error"];
31177
- if (isRecord7(error62)) {
31393
+ if (isRecord8(error62)) {
31178
31394
  const code = error62["code"];
31179
31395
  const message = error62["message"];
31180
31396
  if (typeof code === "string" && typeof message === "string") {
@@ -31185,7 +31401,7 @@ function readRelayError(value) {
31185
31401
  return new PairingClientError("pairing_failed", "The relay could not pair this machine");
31186
31402
  }
31187
31403
  function decodePairingResponse(value, credentialField, expectedKeys) {
31188
- if (!isRecord7(value) || !hasExactKeys2(value, expectedKeys)) {
31404
+ if (!isRecord8(value) || !hasExactKeys2(value, expectedKeys)) {
31189
31405
  throw new PairingClientError("invalid_relay_response", "The relay returned an invalid pairing response");
31190
31406
  }
31191
31407
  const appId = value["appId"];
@@ -31210,7 +31426,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
31210
31426
  const endpoint = options.pairingId.length > 0 ? mobiusApiUrl(options.relayOrigin, `/v1/runtime-pairings/${encodeURIComponent(options.pairingId)}/redeem`) : mobiusApiUrl(options.relayOrigin, "/pairings/claim");
31211
31427
  let response;
31212
31428
  try {
31213
- response = await fetch2(endpoint, {
31429
+ response = await fetch3(endpoint, {
31214
31430
  body: JSON.stringify({
31215
31431
  agents,
31216
31432
  installableAgents,
@@ -31242,20 +31458,30 @@ function buildPairedDaemon(installation, connection, defaultWorkspace, inventory
31242
31458
  const relayUrl = mobiusApiUrl(connection.relayOrigin, "/v1/runtimes/connect");
31243
31459
  relayUrl.protocol = relayUrl.protocol === "https:" ? "wss:" : "ws:";
31244
31460
  relayUrl.searchParams.set("token", connection.runtimeCredential);
31461
+ const config2 = createDaemonConfig(
31462
+ {
31463
+ defaultWorkspace,
31464
+ channelId: connection.channelId,
31465
+ relayUrl
31466
+ },
31467
+ inventory.readyAgents(),
31468
+ inventory.installable,
31469
+ localContext,
31470
+ new OpaqueDaemonReconnectTarget(connection.connectionId),
31471
+ createCatalogAgentResolver(
31472
+ (refreshSignal) => discoverLocalAgentInventory({
31473
+ defaultWorkspace,
31474
+ environment: localContext.environment,
31475
+ signal: refreshSignal
31476
+ }),
31477
+ () => config2,
31478
+ publishAgentCatalog
31479
+ )
31480
+ );
31245
31481
  return {
31246
31482
  channelUrl: new URL(`/channels/${encodeURIComponent(connection.channelId)}`, connection.relayOrigin).toString(),
31247
31483
  connectionId: connection.connectionId,
31248
- config: createDaemonConfig(
31249
- {
31250
- defaultWorkspace,
31251
- channelId: connection.channelId,
31252
- relayUrl
31253
- },
31254
- inventory.readyAgents(),
31255
- inventory.installable,
31256
- localContext,
31257
- new OpaqueDaemonReconnectTarget(connection.connectionId)
31258
- ),
31484
+ config: config2,
31259
31485
  connectionPath: installation.connectionPath(connection.connectionId)
31260
31486
  };
31261
31487
  }
@@ -31354,7 +31580,7 @@ var AuditStore = class {
31354
31580
 
31355
31581
  // src/run-daemon.ts
31356
31582
  import { createHash as createHash8, randomUUID as randomUUID9 } from "node:crypto";
31357
- import { join as join19 } from "node:path";
31583
+ import { join as join21 } from "node:path";
31358
31584
  import { styleText } from "node:util";
31359
31585
 
31360
31586
  // src/acp/active-executions.ts
@@ -31445,7 +31671,7 @@ import {
31445
31671
  } from "@agentclientprotocol/sdk";
31446
31672
 
31447
31673
  // src/authorization/local-raster.ts
31448
- import { open as open5, readFile as readFile2, realpath as realpath7, stat as stat6 } from "node:fs/promises";
31674
+ import { open as open5, readFile as readFile2, realpath as realpath8, stat as stat7 } from "node:fs/promises";
31449
31675
  import { basename as basename2, isAbsolute as isAbsolute9, normalize as normalize2 } from "node:path";
31450
31676
  import { fileURLToPath } from "node:url";
31451
31677
  var MAX_LOCAL_RASTER_BYTES = 128 * 1024 * 1024;
@@ -31516,7 +31742,7 @@ async function resolveCanonicalPath(requested, signal) {
31516
31742
  return null;
31517
31743
  }
31518
31744
  try {
31519
- const target = await realpath7(requested);
31745
+ const target = await realpath8(requested);
31520
31746
  signal.throwIfAborted();
31521
31747
  if (!isAbsolute9(target) || normalize2(target) !== target) {
31522
31748
  return null;
@@ -31564,7 +31790,7 @@ async function readLocalRaster(uri, signal) {
31564
31790
  if (target === null) {
31565
31791
  return null;
31566
31792
  }
31567
- const targetMetadata = await stat6(target);
31793
+ const targetMetadata = await stat7(target);
31568
31794
  signal.throwIfAborted();
31569
31795
  if (!targetMetadata.isFile() || targetMetadata.size < 1 || targetMetadata.size > MAX_LOCAL_RASTER_BYTES) {
31570
31796
  return null;
@@ -31743,7 +31969,7 @@ async function replaceImageMarkers(text2, replace) {
31743
31969
 
31744
31970
  // src/acp/activity-content.ts
31745
31971
  var TRUNCATION_MARKER = "\n\u2026 output truncated by Mobius";
31746
- function isRecord8(value) {
31972
+ function isRecord9(value) {
31747
31973
  return typeof value === "object" && value !== null && !Array.isArray(value);
31748
31974
  }
31749
31975
  function truncate3(value, maximumLength) {
@@ -31927,16 +32153,16 @@ async function normalizeToolContent(content, prepareContent) {
31927
32153
  return normalized;
31928
32154
  }
31929
32155
  function rawMcpToolContent(rawOutput) {
31930
- if (!isRecord8(rawOutput)) {
32156
+ if (!isRecord9(rawOutput)) {
31931
32157
  return [];
31932
32158
  }
31933
- const result = isRecord8(rawOutput["result"]) ? rawOutput["result"] : rawOutput;
32159
+ const result = isRecord9(rawOutput["result"]) ? rawOutput["result"] : rawOutput;
31934
32160
  const content = result["content"];
31935
32161
  if (!Array.isArray(content)) {
31936
32162
  return [];
31937
32163
  }
31938
32164
  return content.flatMap((item) => {
31939
- if (!isRecord8(item) || item["type"] !== "image" || typeof item["data"] !== "string" || typeof item["mimeType"] !== "string") {
32165
+ if (!isRecord9(item) || item["type"] !== "image" || typeof item["data"] !== "string" || typeof item["mimeType"] !== "string") {
31940
32166
  return [];
31941
32167
  }
31942
32168
  const uri = item["uri"];
@@ -32013,7 +32239,7 @@ function contentPhase(content) {
32013
32239
  return "";
32014
32240
  }
32015
32241
  const codex = metadata["codex"];
32016
- if (!isRecord8(codex)) {
32242
+ if (!isRecord9(codex)) {
32017
32243
  return "";
32018
32244
  }
32019
32245
  const phase = codex["phase"];
@@ -32720,7 +32946,7 @@ var SessionConfigProtocolError = class extends Error {
32720
32946
  this.name = "SessionConfigProtocolError";
32721
32947
  }
32722
32948
  };
32723
- function isRecord9(value) {
32949
+ function isRecord10(value) {
32724
32950
  return typeof value === "object" && value !== null && !Array.isArray(value);
32725
32951
  }
32726
32952
  function readString3(value, fallback = "") {
@@ -32751,7 +32977,7 @@ function normalizeConfigValues(value) {
32751
32977
  }
32752
32978
  const normalized = [];
32753
32979
  for (const entry of value) {
32754
- if (!isRecord9(entry)) {
32980
+ if (!isRecord10(entry)) {
32755
32981
  continue;
32756
32982
  }
32757
32983
  const groupedOptions = entry["options"];
@@ -32759,7 +32985,7 @@ function normalizeConfigValues(value) {
32759
32985
  const groupId = readString3(entry["group"]);
32760
32986
  const groupName = readString3(entry["name"]);
32761
32987
  for (const groupedOption of groupedOptions) {
32762
- if (isRecord9(groupedOption)) {
32988
+ if (isRecord10(groupedOption)) {
32763
32989
  const normalizedValue = normalizeConfigValue(groupedOption, groupId, groupName);
32764
32990
  if (normalizedValue !== void 0) {
32765
32991
  normalized.push(normalizedValue);
@@ -32779,7 +33005,7 @@ function normalizeConfigOptions(value, modes) {
32779
33005
  const normalized = [];
32780
33006
  if (Array.isArray(value)) {
32781
33007
  for (const option of value) {
32782
- if (!isRecord9(option)) {
33008
+ if (!isRecord10(option)) {
32783
33009
  continue;
32784
33010
  }
32785
33011
  const id = truncate4(readString3(option["id"]), 128);
@@ -32819,12 +33045,12 @@ function normalizeConfigOptions(value, modes) {
32819
33045
  }
32820
33046
  }
32821
33047
  }
32822
- if (isRecord9(modes)) {
33048
+ if (isRecord10(modes)) {
32823
33049
  const values = [];
32824
33050
  const availableModes = modes["availableModes"];
32825
33051
  if (Array.isArray(availableModes)) {
32826
33052
  for (const mode of availableModes) {
32827
- if (!isRecord9(mode)) {
33053
+ if (!isRecord10(mode)) {
32828
33054
  continue;
32829
33055
  }
32830
33056
  const id = truncate4(readString3(mode["id"]), 500);
@@ -32857,7 +33083,7 @@ function normalizeConfigOptions(value, modes) {
32857
33083
  return normalized.slice(0, MAXIMUM_CONFIG_OPTIONS);
32858
33084
  }
32859
33085
  function normalizeStandardLifecycle(response) {
32860
- const lifecycle = isRecord9(response) ? response : {};
33086
+ const lifecycle = isRecord10(response) ? response : {};
32861
33087
  return normalizeConfigOptions(lifecycle["configOptions"], lifecycle["modes"]);
32862
33088
  }
32863
33089
  function replaceStandardConfigOptions(current, value) {
@@ -32899,7 +33125,7 @@ var StandardSessionConfigProtocol = class {
32899
33125
  "ACP agent exited while changing session configuration",
32900
33126
  change.signal
32901
33127
  );
32902
- if (!isRecord9(response) || !Array.isArray(response["configOptions"])) {
33128
+ if (!isRecord10(response) || !Array.isArray(response["configOptions"])) {
32903
33129
  throw new SessionConfigProtocolError("The Agent returned an invalid session configuration response");
32904
33130
  }
32905
33131
  return replaceStandardConfigOptions(current, response["configOptions"]);
@@ -34312,7 +34538,7 @@ function sql(strings, ...params) {
34312
34538
  return new SQL([new StringChunk(str)]);
34313
34539
  }
34314
34540
  _sql.raw = raw;
34315
- function join21(chunks, separator) {
34541
+ function join23(chunks, separator) {
34316
34542
  const result = [];
34317
34543
  for (const [i, chunk] of chunks.entries()) {
34318
34544
  if (i > 0 && separator !== void 0) result.push(separator);
@@ -34320,7 +34546,7 @@ function sql(strings, ...params) {
34320
34546
  }
34321
34547
  return new SQL(result);
34322
34548
  }
34323
- _sql.join = join21;
34549
+ _sql.join = join23;
34324
34550
  function identifier2(value) {
34325
34551
  return new Name(value);
34326
34552
  }
@@ -36465,7 +36691,7 @@ var SQLiteSelectBase = class extends TypedQueryBuilder {
36465
36691
  const baseTableName = this.tableName;
36466
36692
  const tableName = getTableLikeName(table);
36467
36693
  for (const item of extractUsedTable(table)) this.usedTables.add(item);
36468
- if (typeof tableName === "string" && this.config.joins?.some((join21) => join21.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
36694
+ if (typeof tableName === "string" && this.config.joins?.some((join23) => join23.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
36469
36695
  if (!this.isPartialSelect) {
36470
36696
  if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
36471
36697
  if (typeof tableName === "string" && !is(table, SQL)) {
@@ -37304,7 +37530,7 @@ var SQLiteDialect = class {
37304
37530
  if (!joins2) return;
37305
37531
  const withEntries = Object.entries(joins2).filter(([_, v]) => v);
37306
37532
  if (!withEntries.length) return;
37307
- return sql.join(withEntries.map(([k, join21]) => {
37533
+ return sql.join(withEntries.map(([k, join23]) => {
37308
37534
  const relation = tableConfig.relations[k];
37309
37535
  const isSingle2 = is(relation, One);
37310
37536
  const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
@@ -37315,7 +37541,7 @@ var SQLiteDialect = class {
37315
37541
  table: targetTable,
37316
37542
  mode: isSingle2 ? "first" : "many",
37317
37543
  schema,
37318
- queryConfig: join21,
37544
+ queryConfig: join23,
37319
37545
  tableConfig: schema[relation.targetTableName],
37320
37546
  relationWhere: filter,
37321
37547
  isNested: true,
@@ -37329,7 +37555,7 @@ var SQLiteDialect = class {
37329
37555
  key: k,
37330
37556
  selection: innerQuery.selection,
37331
37557
  isArray: !isSingle2,
37332
- isOptional: (relation.optional ?? false) || join21 !== true && !!join21.where
37558
+ isOptional: (relation.optional ?? false) || join23 !== true && !!join23.where
37333
37559
  });
37334
37560
  const jsonColumns = sql.join(innerQuery.selection.map((s) => {
37335
37561
  return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
@@ -37945,7 +38171,7 @@ var SQLiteUpdateBase = class {
37945
38171
  createJoin(joinType) {
37946
38172
  return ((table, on) => {
37947
38173
  const tableName = getTableLikeName(table);
37948
- if (typeof tableName === "string" && this.config.joins.some((join21) => join21.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
38174
+ if (typeof tableName === "string" && this.config.joins.some((join23) => join23.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
37949
38175
  if (typeof on === "function") {
37950
38176
  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;
37951
38177
  on = on(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
@@ -39351,7 +39577,7 @@ var AgentSession = class _AgentSession {
39351
39577
  );
39352
39578
  }
39353
39579
  initialize = async (signal, recovery, origin) => {
39354
- if (origin?.kind === "fork") {
39580
+ if (origin !== void 0) {
39355
39581
  this.#sessionTitle = origin.title;
39356
39582
  }
39357
39583
  await this.#initializeAgent(signal);
@@ -39365,7 +39591,7 @@ var AgentSession = class _AgentSession {
39365
39591
  this.#cwd,
39366
39592
  this.#additionalDirectories,
39367
39593
  true,
39368
- ""
39594
+ origin.title
39369
39595
  )
39370
39596
  ) : this.#store.read(this.#mobiusSessionId)
39371
39597
  );
@@ -40393,7 +40619,7 @@ var toolImageSchema = external_exports.union([
40393
40619
  file: external_exports.object({ base64: external_exports.string(), type: external_exports.string() })
40394
40620
  }).transform(({ file: file2 }) => ({ type: "image", data: file2.base64, mimeType: file2.type }))
40395
40621
  ]);
40396
- function isRecord10(value) {
40622
+ function isRecord11(value) {
40397
40623
  return typeof value === "object" && value !== null && !Array.isArray(value);
40398
40624
  }
40399
40625
  var AcpContentExternalizer = class {
@@ -40509,13 +40735,13 @@ var AcpContentExternalizer = class {
40509
40735
  }
40510
40736
  return result2;
40511
40737
  }
40512
- if (!isRecord10(value)) {
40738
+ if (!isRecord11(value)) {
40513
40739
  return value;
40514
40740
  }
40515
40741
  const image = toolImageSchema.safeParse(value);
40516
40742
  if (image.success && image.data.data.length > 0) {
40517
40743
  const prepared = await this.#content(sessionId, image.data, signal);
40518
- if (isRecord10(prepared.event) && typeof prepared.event["imageKey"] === "string") {
40744
+ if (isRecord11(prepared.event) && typeof prepared.event["imageKey"] === "string") {
40519
40745
  images.set(prepared.event["imageKey"], prepared);
40520
40746
  } else {
40521
40747
  images.set(`unavailable:${images.size}`, prepared);
@@ -40546,7 +40772,7 @@ var AcpContentExternalizer = class {
40546
40772
  const prepared = await this.#content(sessionId, content, signal);
40547
40773
  agentContent.push({ ...item, content: prepared.agent });
40548
40774
  eventContent.push({ ...item, content: prepared.event });
40549
- if (isRecord10(prepared.event) && typeof prepared.event["imageKey"] === "string") {
40775
+ if (isRecord11(prepared.event) && typeof prepared.event["imageKey"] === "string") {
40550
40776
  images.delete(prepared.event["imageKey"]);
40551
40777
  }
40552
40778
  }
@@ -40604,8 +40830,8 @@ var AcpContentExternalizer = class {
40604
40830
 
40605
40831
  // src/external-content/local-external-content-store.ts
40606
40832
  import { createHash as createHash3, randomUUID as randomUUID3 } from "node:crypto";
40607
- import { lstat, mkdir as mkdir6, readdir as readdir3, realpath as realpath8, rename as rename4, rm as rm3, stat as stat7, utimes, writeFile as writeFile4 } from "node:fs/promises";
40608
- import { dirname as dirname4, join as join16 } from "node:path";
40833
+ 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";
40834
+ import { dirname as dirname4, join as join18 } from "node:path";
40609
40835
  var contentRequest = /^mobius-content:(image|audio|resource):([a-f0-9]{64})$/u;
40610
40836
  var CONTENT_LIFETIME_MILLISECONDS = 24 * 60 * 60 * 1e3;
40611
40837
  var metadataSchema2 = external_exports.strictObject({
@@ -40641,7 +40867,7 @@ var LocalExternalContentStore = class {
40641
40867
  #expirationTimer;
40642
40868
  #cleanup = Promise.resolve();
40643
40869
  constructor(stateDirectory) {
40644
- this.#root = join16(stateDirectory, "tmp", "session-content", randomUUID3());
40870
+ this.#root = join18(stateDirectory, "tmp", "session-content", randomUUID3());
40645
40871
  this.#expirationTimer = setInterval(() => {
40646
40872
  void this.#expire().catch(() => void 0);
40647
40873
  }, 6e4);
@@ -40656,11 +40882,11 @@ var LocalExternalContentStore = class {
40656
40882
  if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
40657
40883
  continue;
40658
40884
  }
40659
- const path3 = join16(dirname4(this.#root), directory.name);
40885
+ const path3 = join18(dirname4(this.#root), directory.name);
40660
40886
  if (path3 === this.#root) {
40661
40887
  continue;
40662
40888
  }
40663
- const modified = await stat7(path3).then(
40889
+ const modified = await stat8(path3).then(
40664
40890
  (entry) => entry.mtimeMs,
40665
40891
  () => Date.now()
40666
40892
  );
@@ -40706,10 +40932,10 @@ var LocalExternalContentStore = class {
40706
40932
  }
40707
40933
  await this.#expire();
40708
40934
  active.throwIfAborted();
40709
- const directory = join16(this.#root, kind);
40935
+ const directory = join18(this.#root, kind);
40710
40936
  await mkdir6(directory, { mode: 448, recursive: true });
40711
40937
  active.throwIfAborted();
40712
- const path3 = join16(directory, key);
40938
+ const path3 = join18(directory, key);
40713
40939
  const write = atomicWrite(path3, bytes, active);
40714
40940
  await write;
40715
40941
  active.throwIfAborted();
@@ -40742,8 +40968,8 @@ var LocalExternalContentStore = class {
40742
40968
  }
40743
40969
  try {
40744
40970
  const [resolvedDirectory, resolvedPath, file2] = await Promise.all([
40745
- realpath8(dirname4(entry.path)),
40746
- realpath8(entry.path),
40971
+ realpath9(dirname4(entry.path)),
40972
+ realpath9(entry.path),
40747
40973
  lstat(entry.path)
40748
40974
  ]);
40749
40975
  signal.throwIfAborted();
@@ -41181,7 +41407,7 @@ var AgentRuntimeManager = class {
41181
41407
  return await this.#startRetainedSessionProcess(
41182
41408
  options,
41183
41409
  async () => await AgentSession.start(
41184
- options.origin === void 0 && this.#sessionIdentity === "native" && isNativeChatSessionId(options.agent.id, options.sessionId) && this.#store.read(options.sessionId) instanceof MissingAcpStoredSession ? { ...options, origin: { kind: "import", nativeSessionId: options.sessionId } } : options,
41410
+ options.origin === void 0 && this.#sessionIdentity === "native" && isNativeChatSessionId(options.agent.id, options.sessionId) && this.#store.read(options.sessionId) instanceof MissingAcpStoredSession ? { ...options, origin: { kind: "import", nativeSessionId: options.sessionId, title: "" } } : options,
41185
41411
  recovery,
41186
41412
  () => this.#observer,
41187
41413
  this.#store,
@@ -41784,117 +42010,6 @@ var AgentRuntimeManager = class {
41784
42010
  });
41785
42011
  };
41786
42012
 
41787
- // src/agent-catalog/publish-agent-catalog.ts
41788
- import { fetch as fetch3 } from "undici";
41789
-
41790
- // src/relay-connection/runtime-authentication.ts
41791
- function runtimeCredential(relayUrl) {
41792
- return relayUrl.searchParams.get("token") ?? "";
41793
- }
41794
- function runtimeAuthorization(relayUrl) {
41795
- const credential = runtimeCredential(relayUrl);
41796
- return credential.length === 0 ? {} : { authorization: `Bearer ${credential}` };
41797
- }
41798
- function relayHttpEndpoint(relayUrl) {
41799
- const endpoint = new URL(relayUrl);
41800
- endpoint.protocol = endpoint.protocol === "wss:" ? "https:" : "http:";
41801
- endpoint.search = "";
41802
- return endpoint;
41803
- }
41804
-
41805
- // src/agent-catalog/publish-agent-catalog.ts
41806
- var CATALOG_UPDATE_TIMEOUT_MILLISECONDS = 2e4;
41807
- var AgentCatalogPublishError = class extends Error {
41808
- code = "agent_catalog_update_failed";
41809
- diagnosticDetails;
41810
- constructor(message, options = {}, diagnosticDetails = {}) {
41811
- super(message, options);
41812
- this.diagnosticDetails = diagnosticDetails;
41813
- this.name = "AgentCatalogPublishError";
41814
- }
41815
- };
41816
- function isRecord11(value) {
41817
- return typeof value === "object" && value !== null && !Array.isArray(value);
41818
- }
41819
- function isSafeRelayErrorMessage(value) {
41820
- return value.length > 0 && value.length <= 512 && Array.from(value).every((character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127);
41821
- }
41822
- async function rejectedCatalogError(response) {
41823
- let value;
41824
- try {
41825
- value = await response.json();
41826
- } catch {
41827
- return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
41828
- }
41829
- if (!isRecord11(value) || !isRecord11(value["error"])) {
41830
- return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
41831
- }
41832
- const code = value["error"]["code"];
41833
- const message = value["error"]["message"];
41834
- if (typeof code !== "string" || !/^[a-z][a-z0-9_]{0,63}$/.test(code) || typeof message !== "string" || !isSafeRelayErrorMessage(message)) {
41835
- return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
41836
- }
41837
- return new AgentCatalogPublishError(
41838
- `The Relay rejected the Agent catalog update (${code}): ${message}`,
41839
- {},
41840
- {
41841
- relayErrorCode: code
41842
- }
41843
- );
41844
- }
41845
- function catalogEndpoint(config2) {
41846
- const endpoint = relayHttpEndpoint(config2.relayUrl);
41847
- if (endpoint.pathname.endsWith("/daemon")) {
41848
- endpoint.pathname = `${endpoint.pathname.slice(0, -"/daemon".length)}/catalog`;
41849
- return endpoint;
41850
- }
41851
- const runtimePath = "/v1/runtimes/connect";
41852
- if (endpoint.pathname.endsWith(runtimePath)) {
41853
- endpoint.pathname = `${endpoint.pathname.slice(0, -runtimePath.length)}/channels/${encodeURIComponent(config2.channelId)}/catalog`;
41854
- return endpoint;
41855
- }
41856
- throw new AgentCatalogPublishError("The Relay URL is invalid");
41857
- }
41858
- async function publishAgentCatalog(config2, signal) {
41859
- signal.throwIfAborted();
41860
- const timeoutSignal = AbortSignal.timeout(CATALOG_UPDATE_TIMEOUT_MILLISECONDS);
41861
- const requestSignal = AbortSignal.any([signal, timeoutSignal]);
41862
- let response;
41863
- const catalog = config2.catalog.read();
41864
- try {
41865
- response = await fetch3(catalogEndpoint(config2), {
41866
- body: JSON.stringify({
41867
- agents: catalog.agents.map((agent) => ({
41868
- agentPath: agent.agentIdentity.requestedPath,
41869
- agentVersion: agent.agentVersion,
41870
- agentSettingsDiscovery: true,
41871
- capabilities: agent.capabilities,
41872
- id: agent.id,
41873
- label: agent.label,
41874
- sessionTurnConfiguration: true
41875
- })),
41876
- installableAgents: catalog.installableAgents
41877
- }),
41878
- dispatcher: environmentProxyDispatcher,
41879
- headers: { ...runtimeAuthorization(config2.relayUrl), "content-type": "application/json" },
41880
- method: "PUT",
41881
- signal: requestSignal
41882
- });
41883
- } catch (error62) {
41884
- if (signal.aborted) {
41885
- signal.throwIfAborted();
41886
- }
41887
- throw new AgentCatalogPublishError(
41888
- timeoutSignal.aborted ? "The Agent catalog update timed out" : "The Agent catalog could not be updated",
41889
- { cause: error62 }
41890
- );
41891
- }
41892
- if (!response.ok) {
41893
- throw await rejectedCatalogError(response);
41894
- }
41895
- await response.body?.cancel();
41896
- }
41897
-
41898
42013
  // src/agent-installation/agent-installation-manager.ts
41899
42014
  var INSTALLATION_DEADLINE_MILLISECONDS = 10 * 60 * 1e3;
41900
42015
  var AgentInstallation = class {
@@ -42357,9 +42472,9 @@ var FixedInstallationExecutor = class {
42357
42472
  };
42358
42473
 
42359
42474
  // src/authorization/workspace-directory.ts
42360
- import { readdir as readdir4, realpath as realpath9, stat as stat8 } from "node:fs/promises";
42475
+ import { readdir as readdir4, realpath as realpath10, stat as stat9 } from "node:fs/promises";
42361
42476
  import { homedir as homedir2 } from "node:os";
42362
- import { basename as basename4, dirname as dirname5, isAbsolute as isAbsolute10, join as join17, normalize as normalize3, relative as relative4 } from "node:path";
42477
+ import { basename as basename4, dirname as dirname5, isAbsolute as isAbsolute10, join as join19, normalize as normalize3, relative as relative4 } from "node:path";
42363
42478
 
42364
42479
  // src/authorization/local-authorization-error.ts
42365
42480
  var LocalAuthorizationError = class extends Error {
@@ -42438,9 +42553,9 @@ var WorkspaceDirectoryService = class {
42438
42553
  throw new LocalAuthorizationError("The local directory path is invalid");
42439
42554
  }
42440
42555
  try {
42441
- const target = await realpath9(requested);
42556
+ const target = await realpath10(requested);
42442
42557
  signal.throwIfAborted();
42443
- const metadata = await stat8(target);
42558
+ const metadata = await stat9(target);
42444
42559
  signal.throwIfAborted();
42445
42560
  if (!isAbsolute10(target) || normalize3(target) !== target || !metadata.isDirectory()) {
42446
42561
  throw new LocalAuthorizationError("The selected location is not a directory");
@@ -42488,7 +42603,7 @@ var WorkspaceDirectoryService = class {
42488
42603
  continue;
42489
42604
  }
42490
42605
  try {
42491
- const path3 = await this.resolvePath(join17(target, child2.name), signal);
42606
+ const path3 = await this.resolvePath(join19(target, child2.name), signal);
42492
42607
  entries.push({ directoryId: encodePath(path3), name: child2.name });
42493
42608
  } catch (cause) {
42494
42609
  signal.throwIfAborted();
@@ -42524,15 +42639,15 @@ var WorkspaceDirectoryService = class {
42524
42639
 
42525
42640
  // src/daemon-diagnostic-log.ts
42526
42641
  import { appendFileSync, mkdirSync, readFileSync as readFileSync2, renameSync, statSync as statSync3, writeFileSync } from "node:fs";
42527
- import { join as join18 } from "node:path";
42642
+ import { join as join20 } from "node:path";
42528
42643
  var MAXIMUM_DAEMON_LOG_BYTES = 1 * 1024 * 1024;
42529
42644
  var DaemonDiagnosticLog = class {
42530
42645
  #directory;
42531
42646
  #path;
42532
42647
  #maximumBytes;
42533
42648
  constructor(stateDirectory, maximumBytes = MAXIMUM_DAEMON_LOG_BYTES) {
42534
- this.#directory = join18(stateDirectory, "logs");
42535
- this.#path = join18(this.#directory, "daemon.log");
42649
+ this.#directory = join20(stateDirectory, "logs");
42650
+ this.#path = join20(this.#directory, "daemon.log");
42536
42651
  this.#maximumBytes = maximumBytes;
42537
42652
  }
42538
42653
  // Export only correlation and failure metadata. Local messages and paths stay local.
@@ -44477,9 +44592,10 @@ var NativeSessionService = class {
44477
44592
  signal
44478
44593
  );
44479
44594
  signal.throwIfAborted();
44595
+ const cataloged = this.#config.catalog.find(command.agentId);
44480
44596
  const options = {
44481
44597
  additionalDirectories,
44482
- agent: this.#config.catalog.find(command.agentId),
44598
+ agent: this.#config.resolveAgent === void 0 ? cataloged : await this.#config.resolveAgent(cataloged, signal),
44483
44599
  cwd,
44484
44600
  sessionId: command.sessionId,
44485
44601
  signal
@@ -44657,7 +44773,7 @@ var NativeSessionService = class {
44657
44773
  sessionId: command.targetSessionId,
44658
44774
  additionalDirectories: target.additionalDirectories
44659
44775
  },
44660
- action === "fork" ? { kind: "fork", nativeSessionId: target.info.sessionId, title: title2 } : { kind: "import", nativeSessionId: target.info.sessionId }
44776
+ action === "fork" ? { kind: "fork", nativeSessionId: target.info.sessionId, title: title2 } : { kind: "import", nativeSessionId: target.info.sessionId, title: title2 }
44661
44777
  );
44662
44778
  signal.throwIfAborted();
44663
44779
  const ready = {
@@ -45258,7 +45374,8 @@ function unsupportedModelIds(unsupportedModels) {
45258
45374
  return [...new Set(unsupportedModels.map((item) => item.requestedValue))];
45259
45375
  }
45260
45376
  async function discoverAgentSettings(command, config2, directories, sessions, signal) {
45261
- const agent = config2.catalog.find(command.agentId);
45377
+ const cataloged = config2.catalog.find(command.agentId);
45378
+ const agent = config2.resolveAgent === void 0 ? cataloged : await config2.resolveAgent(cataloged, signal);
45262
45379
  const cwd = await directories.resolve(config2.bindingId, "default", signal);
45263
45380
  const inspectedBaseSnapshot = await sessions.inspectAgentSettings({
45264
45381
  additionalDirectories: [],
@@ -45652,7 +45769,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
45652
45769
 
45653
45770
  // src/artifacts/local-file-streamer.ts
45654
45771
  import { createReadStream as createReadStream2 } from "node:fs";
45655
- import { realpath as realpath10, stat as stat9 } from "node:fs/promises";
45772
+ import { realpath as realpath11, stat as stat10 } from "node:fs/promises";
45656
45773
  import { basename as basename5, extname, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve7 } from "node:path";
45657
45774
  import { fileURLToPath as fileURLToPath2 } from "node:url";
45658
45775
  var CHUNK_BYTES = 192 * 1024;
@@ -45680,7 +45797,7 @@ async function resolveFile(value, workingDirectory, signal) {
45680
45797
  return null;
45681
45798
  }
45682
45799
  try {
45683
- const target = await realpath10(requested);
45800
+ const target = await realpath11(requested);
45684
45801
  signal.throwIfAborted();
45685
45802
  return isAbsolute11(target) && normalize4(target) === target ? target : null;
45686
45803
  } catch {
@@ -45694,7 +45811,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
45694
45811
  if (target === null) {
45695
45812
  throw new Error("The local file is unavailable");
45696
45813
  }
45697
- const before = await stat9(target);
45814
+ const before = await stat10(target);
45698
45815
  signal.throwIfAborted();
45699
45816
  if (!before.isFile() || before.size < 1 || before.size > command.maxBytes) {
45700
45817
  throw new Error("The local file is too large to read");
@@ -45722,7 +45839,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
45722
45839
  });
45723
45840
  sequence += 1;
45724
45841
  }
45725
- const after = await stat9(target);
45842
+ const after = await stat10(target);
45726
45843
  signal.throwIfAborted();
45727
45844
  if (after.size !== before.size || after.mtimeMs !== before.mtimeMs) {
45728
45845
  throw new Error("The local file changed during transfer");
@@ -45766,7 +45883,305 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
45766
45883
  return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
45767
45884
  }
45768
45885
 
45886
+ // src/daemon-session-commands.ts
45887
+ async function resolveCatalogAgent(config2, agentId, signal) {
45888
+ const agent = config2.catalog.find(agentId);
45889
+ return config2.resolveAgent === void 0 ? agent : await config2.resolveAgent(agent, signal);
45890
+ }
45891
+ async function prepareSession(command, recovery, config2, directories, audit, sessions, metrics, signal) {
45892
+ return await metrics.measure("prepare-total", async () => {
45893
+ const resolved = await metrics.measure(
45894
+ "workspace-resolve",
45895
+ async () => await resolveSessionDirectories(
45896
+ directories,
45897
+ config2.bindingId,
45898
+ command.directoryId,
45899
+ command.additionalDirectoryIds,
45900
+ signal
45901
+ )
45902
+ );
45903
+ const agent = await resolveCatalogAgent(config2, command.agentId, signal);
45904
+ const preparation = {
45905
+ additionalDirectories: resolved.additionalDirectories,
45906
+ agent,
45907
+ cwd: resolved.cwd,
45908
+ sessionId: command.sessionId,
45909
+ signal
45910
+ };
45911
+ const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : recovery.kind === "history-required" ? await sessions.restoreSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
45912
+ const configuration = command.configuration;
45913
+ const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
45914
+ "configuration",
45915
+ async () => await sessions.configureSession({
45916
+ ...preparation,
45917
+ booleanValue: configuration.booleanValue,
45918
+ configId: configuration.configId,
45919
+ requestId: command.requestId,
45920
+ value: configuration.value,
45921
+ valueType: configuration.valueType
45922
+ })
45923
+ );
45924
+ const listing = await metrics.measure(
45925
+ "workspace-list",
45926
+ async () => await directories.list(config2.bindingId, command.directoryId, signal)
45927
+ );
45928
+ audit.record({
45929
+ commandId: command.requestId,
45930
+ event: "session_prepared",
45931
+ sessionId: command.sessionId
45932
+ });
45933
+ if (command.configuration !== void 0) {
45934
+ audit.record({
45935
+ commandId: command.requestId,
45936
+ event: "session_configured",
45937
+ sessionId: command.sessionId
45938
+ });
45939
+ }
45940
+ return {
45941
+ additionalDirectories: resolved.additionalDirectoryEntries,
45942
+ agentId: command.agentId,
45943
+ agentName: prepared.agentName,
45944
+ agentVersion: prepared.agentVersion,
45945
+ capabilities: prepared.capabilities,
45946
+ commands: prepared.commands,
45947
+ configOptions,
45948
+ directoryId: command.directoryId,
45949
+ directoryLabel: listing.directoryLabel,
45950
+ kind: "session.ready",
45951
+ requestId: command.requestId,
45952
+ restored: prepared.restored,
45953
+ sessionId: command.sessionId
45954
+ };
45955
+ });
45956
+ }
45957
+ async function executeWorkspaceList(socket, command, directories, audit, signal) {
45958
+ try {
45959
+ const listing = await directories.list(command.bindingId, command.directoryId, signal);
45960
+ audit.record({
45961
+ commandId: command.requestId,
45962
+ event: "workspace_list_authorized",
45963
+ sessionId: "workspace-browser"
45964
+ });
45965
+ send(socket, {
45966
+ bindingId: command.bindingId,
45967
+ directoryId: listing.directoryId,
45968
+ directoryLabel: listing.directoryLabel,
45969
+ entries: listing.entries,
45970
+ kind: "workspace.entries",
45971
+ parentDirectoryId: listing.parentDirectoryId,
45972
+ requestId: command.requestId
45973
+ });
45974
+ } catch (error62) {
45975
+ reportOperationFailure(socket, command.requestId, "", error62);
45976
+ }
45977
+ }
45978
+ async function executeSessionPrepare(socket, command, config2, directories, audit, sessions, diagnostics, signal) {
45979
+ const metrics = new AccumulatingOperationMetrics();
45980
+ try {
45981
+ const readyEvent = await prepareSession(
45982
+ command,
45983
+ { kind: "interactive-only" },
45984
+ config2,
45985
+ directories,
45986
+ audit,
45987
+ sessions,
45988
+ metrics,
45989
+ signal
45990
+ );
45991
+ send(socket, {
45992
+ ...readyEvent,
45993
+ runtimeTimings: metrics.snapshot()
45994
+ });
45995
+ } catch (error62) {
45996
+ diagnostics.daemonDiagnostic(
45997
+ "session_prepare_failed",
45998
+ command.requestId,
45999
+ {
46000
+ agentId: command.agentId,
46001
+ code: operationErrorCode(error62),
46002
+ sessionId: command.sessionId
46003
+ },
46004
+ error62
46005
+ );
46006
+ audit.record({
46007
+ commandId: command.requestId,
46008
+ details: {
46009
+ agentId: command.agentId,
46010
+ code: operationErrorCode(error62)
46011
+ },
46012
+ event: "session_prepare_failed",
46013
+ sessionId: command.sessionId
46014
+ });
46015
+ reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
46016
+ }
46017
+ }
46018
+ async function executeSessionRestore(socket, command, config2, directories, audit, sessions, nativeSessions, diagnostics, signal) {
46019
+ const metrics = new AccumulatingOperationMetrics();
46020
+ try {
46021
+ const entry = await metrics.measure("session-lookup", async () => {
46022
+ const [found] = await nativeSessions.querySessions([command.sessionId], signal);
46023
+ if (found === void 0) {
46024
+ throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
46025
+ }
46026
+ return found;
46027
+ });
46028
+ const ready = await prepareSession(
46029
+ {
46030
+ additionalDirectoryIds: entry.additionalDirectories.map((directory) => directory.directoryId),
46031
+ agentId: entry.agentId,
46032
+ bindingId: config2.bindingId,
46033
+ directoryId: entry.directoryId,
46034
+ kind: "session.prepare",
46035
+ requestId: command.requestId,
46036
+ sessionId: command.sessionId,
46037
+ sessionState: "provisioned"
46038
+ },
46039
+ { kind: "history-required" },
46040
+ config2,
46041
+ directories,
46042
+ audit,
46043
+ sessions,
46044
+ metrics,
46045
+ signal
46046
+ );
46047
+ send(socket, {
46048
+ entry,
46049
+ kind: "session.restored",
46050
+ ready: { ...ready, runtimeTimings: metrics.snapshot() },
46051
+ requestId: command.requestId
46052
+ });
46053
+ } catch (error62) {
46054
+ diagnostics.daemonDiagnostic(
46055
+ "session_restore_failed",
46056
+ command.requestId,
46057
+ {
46058
+ code: operationErrorCode(error62),
46059
+ sessionId: command.sessionId
46060
+ },
46061
+ error62
46062
+ );
46063
+ audit.record({
46064
+ commandId: command.requestId,
46065
+ details: { code: operationErrorCode(error62) },
46066
+ event: "session_restore_failed",
46067
+ sessionId: command.sessionId
46068
+ });
46069
+ reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
46070
+ }
46071
+ }
46072
+ async function executeSessionConfigure(socket, command, config2, directories, audit, sessions, signal) {
46073
+ try {
46074
+ const resolved = await resolveSessionDirectories(
46075
+ directories,
46076
+ config2.bindingId,
46077
+ command.directoryId,
46078
+ command.additionalDirectoryIds,
46079
+ signal
46080
+ );
46081
+ const configOptions = await sessions.configureSession({
46082
+ additionalDirectories: resolved.additionalDirectories,
46083
+ agent: await resolveCatalogAgent(config2, command.agentId, signal),
46084
+ booleanValue: command.booleanValue,
46085
+ configId: command.configId,
46086
+ cwd: resolved.cwd,
46087
+ requestId: command.requestId,
46088
+ sessionId: command.sessionId,
46089
+ signal,
46090
+ value: command.value,
46091
+ valueType: command.valueType
46092
+ });
46093
+ audit.record({
46094
+ commandId: command.requestId,
46095
+ event: "session_configured",
46096
+ sessionId: command.sessionId
46097
+ });
46098
+ send(socket, {
46099
+ configOptions,
46100
+ kind: "session.config.updated",
46101
+ requestId: command.requestId,
46102
+ sessionId: command.sessionId
46103
+ });
46104
+ } catch (error62) {
46105
+ if (signal.aborted) {
46106
+ signal.throwIfAborted();
46107
+ }
46108
+ reportOperationFailure(socket, command.requestId, command.sessionId, error62);
46109
+ }
46110
+ }
46111
+
45769
46112
  // src/daemon-history-commands.ts
46113
+ function isAgentReasoning(event) {
46114
+ return event?.type === "acp" && event.payload.sessionUpdate === "agent_thought_chunk";
46115
+ }
46116
+ function omitAgentReasoning(events) {
46117
+ const retained = [];
46118
+ let previousReasoningMessageId;
46119
+ for (const event of events) {
46120
+ if (event.type !== "acp" || event.payload.sessionUpdate !== "agent_thought_chunk") {
46121
+ previousReasoningMessageId = void 0;
46122
+ retained.push(event);
46123
+ continue;
46124
+ }
46125
+ const messageId = event.payload.messageId ?? null;
46126
+ if (previousReasoningMessageId === void 0 || previousReasoningMessageId !== messageId) {
46127
+ retained.push({
46128
+ ...event,
46129
+ mobiusMetadata: { omitted: true },
46130
+ payload: { ...event.payload, content: { text: "", type: "text" } }
46131
+ });
46132
+ }
46133
+ previousReasoningMessageId = messageId;
46134
+ }
46135
+ return retained;
46136
+ }
46137
+ async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoning, queuedPromptRequests, load, eventLogV2) {
46138
+ let cursor = initialCursor;
46139
+ let loaded = [];
46140
+ let sessionGenerationId = null;
46141
+ let sourceNextCursor = null;
46142
+ do {
46143
+ const replay = await load(eventLimit, cursor);
46144
+ if (sessionGenerationId !== null && replay.sessionGenerationId !== sessionGenerationId) {
46145
+ throw new AcpExecutionError("The Session reloaded while history was loading", {}, "session_reloaded");
46146
+ }
46147
+ sessionGenerationId = replay.sessionGenerationId;
46148
+ const events2 = replay.events.map(
46149
+ (event, index2) => eventLogV2.event(
46150
+ sessionId,
46151
+ replay.sessionGenerationId,
46152
+ replay.startPosition + index2,
46153
+ event,
46154
+ "1970-01-01T00:00:00.000Z"
46155
+ )
46156
+ );
46157
+ loaded = [...events2, ...loaded];
46158
+ sourceNextCursor = replay.nextCursor;
46159
+ const visible2 = omitReasoning ? omitAgentReasoning(loaded) : loaded;
46160
+ const reasoningContinuesBeforePage = sourceNextCursor !== null && isAgentReasoning(loaded[0]);
46161
+ if (visible2.length >= eventLimit && !reasoningContinuesBeforePage) {
46162
+ break;
46163
+ }
46164
+ cursor = sourceNextCursor;
46165
+ } while (cursor !== null);
46166
+ if (sessionGenerationId === null) {
46167
+ throw new AcpExecutionError("The Session history is unavailable", {}, "session_history_unavailable");
46168
+ }
46169
+ const visible = omitReasoning ? omitAgentReasoning(loaded) : loaded;
46170
+ const events = visible.slice(-eventLimit);
46171
+ const firstPosition = events[0] === void 0 ? 0 : Number(events[0].position);
46172
+ const nextCursor = firstPosition <= 1 ? null : (firstPosition - 1).toString();
46173
+ return {
46174
+ events: {
46175
+ events,
46176
+ nextCursor,
46177
+ sessionGenerationId,
46178
+ tailCursor: events.at(-1)?.eventId ?? "",
46179
+ truncated: nextCursor !== null,
46180
+ version: 2
46181
+ },
46182
+ queuedPromptRequests
46183
+ };
46184
+ }
45770
46185
  async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, nativeSessions, eventLogV2, signal) {
45771
46186
  let agentId;
45772
46187
  try {
@@ -45784,41 +46199,29 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
45784
46199
  );
45785
46200
  const loadOptions = {
45786
46201
  additionalDirectories: resolved.additionalDirectories,
45787
- agent: config2.catalog.find(entry.agentId),
46202
+ agent: await resolveCatalogAgent(config2, entry.agentId, signal),
45788
46203
  cwd: resolved.cwd,
45789
46204
  sessionId: command.sessionId,
45790
46205
  signal
45791
46206
  };
45792
46207
  const recovery = eventLogV2.promptRequestRecovery(command.sessionId);
45793
- const replay = await sessions.loadSessionEventsV2(loadOptions, command.eventLimit, command.cursor);
45794
- signal.throwIfAborted();
45795
- const events = replay.events.map(
45796
- (event, index2) => eventLogV2.event(
45797
- command.sessionId,
45798
- replay.sessionGenerationId,
45799
- replay.startPosition + index2,
45800
- event,
45801
- "1970-01-01T00:00:00.000Z"
45802
- )
46208
+ const events = await loadHistoryPage(
46209
+ command.sessionId,
46210
+ command.eventLimit,
46211
+ command.cursor,
46212
+ command.omit?.includes("agent-reasoning") === true,
46213
+ recovery.queuedPromptRequests,
46214
+ async (eventLimit, cursor) => await sessions.loadSessionEventsV2(loadOptions, eventLimit, cursor),
46215
+ eventLogV2
45803
46216
  );
45804
- const tailCursor = events.at(-1)?.eventId ?? "";
46217
+ signal.throwIfAborted();
45805
46218
  audit.record({
45806
46219
  commandId: command.requestId,
45807
46220
  event: "session_event_log_v2_loaded",
45808
46221
  sessionId: command.sessionId
45809
46222
  });
45810
46223
  send(socket, {
45811
- events: {
45812
- events: {
45813
- events,
45814
- nextCursor: replay.nextCursor,
45815
- sessionGenerationId: replay.sessionGenerationId,
45816
- tailCursor,
45817
- truncated: replay.truncated,
45818
- version: 2
45819
- },
45820
- queuedPromptRequests: recovery.queuedPromptRequests
45821
- },
46224
+ events,
45822
46225
  kind: SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND,
45823
46226
  requestId: command.requestId,
45824
46227
  sessionId: command.sessionId
@@ -45857,46 +46260,30 @@ async function executeSessionPreviewHistoryPageLoad(socket, command, config2, di
45857
46260
  command.additionalDirectoryIds,
45858
46261
  signal
45859
46262
  );
45860
- const replay = await sessions.previewNativeSessionEventsV2(
45861
- {
45862
- additionalDirectories: resolved.additionalDirectories,
45863
- agent: config2.catalog.find(command.agentId),
45864
- cwd: resolved.cwd,
45865
- sessionId: command.sessionId,
45866
- signal
45867
- },
46263
+ const loadOptions = {
46264
+ additionalDirectories: resolved.additionalDirectories,
46265
+ agent: await resolveCatalogAgent(config2, command.agentId, signal),
46266
+ cwd: resolved.cwd,
46267
+ sessionId: command.sessionId,
46268
+ signal
46269
+ };
46270
+ const events = await loadHistoryPage(
45868
46271
  command.sessionId,
45869
46272
  command.eventLimit,
45870
- command.cursor
46273
+ command.cursor,
46274
+ command.omit?.includes("agent-reasoning") === true,
46275
+ [],
46276
+ async (eventLimit, cursor) => await sessions.previewNativeSessionEventsV2(loadOptions, command.sessionId, eventLimit, cursor),
46277
+ eventLogV2
45871
46278
  );
45872
46279
  signal.throwIfAborted();
45873
- const events = replay.events.map(
45874
- (event, index2) => eventLogV2.event(
45875
- command.sessionId,
45876
- replay.sessionGenerationId,
45877
- replay.startPosition + index2,
45878
- event,
45879
- "1970-01-01T00:00:00.000Z"
45880
- )
45881
- );
45882
- const tailCursor = events.at(-1)?.eventId ?? "";
45883
46280
  audit.record({
45884
46281
  commandId: command.requestId,
45885
46282
  event: "session_event_log_v2_loaded",
45886
46283
  sessionId: command.sessionId
45887
46284
  });
45888
46285
  send(socket, {
45889
- events: {
45890
- events: {
45891
- events,
45892
- nextCursor: replay.nextCursor,
45893
- sessionGenerationId: replay.sessionGenerationId,
45894
- tailCursor,
45895
- truncated: replay.truncated,
45896
- version: 2
45897
- },
45898
- queuedPromptRequests: []
45899
- },
46286
+ events,
45900
46287
  kind: SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND,
45901
46288
  requestId: command.requestId,
45902
46289
  sessionId: command.sessionId
@@ -46152,7 +46539,7 @@ async function executePrompt({
46152
46539
  command.additionalDirectoryIds,
46153
46540
  signal
46154
46541
  );
46155
- const agent = config2.catalog.find(command.agentId);
46542
+ const agent = await resolveCatalogAgent(config2, command.agentId, signal);
46156
46543
  const availability = await waitForSessionAvailability(signal);
46157
46544
  if (availability.kind === "busy") {
46158
46545
  throw new AcpExecutionError("Another prompt is already running in this conversation", {}, "session_busy");
@@ -46297,228 +46684,6 @@ async function executePrompt({
46297
46684
  }
46298
46685
  }
46299
46686
 
46300
- // src/daemon-session-commands.ts
46301
- async function prepareSession(command, recovery, config2, directories, audit, sessions, metrics, signal) {
46302
- return await metrics.measure("prepare-total", async () => {
46303
- const resolved = await metrics.measure(
46304
- "workspace-resolve",
46305
- async () => await resolveSessionDirectories(
46306
- directories,
46307
- config2.bindingId,
46308
- command.directoryId,
46309
- command.additionalDirectoryIds,
46310
- signal
46311
- )
46312
- );
46313
- const agent = config2.catalog.find(command.agentId);
46314
- const preparation = {
46315
- additionalDirectories: resolved.additionalDirectories,
46316
- agent,
46317
- cwd: resolved.cwd,
46318
- sessionId: command.sessionId,
46319
- signal
46320
- };
46321
- const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : recovery.kind === "history-required" ? await sessions.restoreSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
46322
- const configuration = command.configuration;
46323
- const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
46324
- "configuration",
46325
- async () => await sessions.configureSession({
46326
- ...preparation,
46327
- booleanValue: configuration.booleanValue,
46328
- configId: configuration.configId,
46329
- requestId: command.requestId,
46330
- value: configuration.value,
46331
- valueType: configuration.valueType
46332
- })
46333
- );
46334
- const listing = await metrics.measure(
46335
- "workspace-list",
46336
- async () => await directories.list(config2.bindingId, command.directoryId, signal)
46337
- );
46338
- audit.record({
46339
- commandId: command.requestId,
46340
- event: "session_prepared",
46341
- sessionId: command.sessionId
46342
- });
46343
- if (command.configuration !== void 0) {
46344
- audit.record({
46345
- commandId: command.requestId,
46346
- event: "session_configured",
46347
- sessionId: command.sessionId
46348
- });
46349
- }
46350
- return {
46351
- additionalDirectories: resolved.additionalDirectoryEntries,
46352
- agentId: command.agentId,
46353
- agentName: prepared.agentName,
46354
- agentVersion: prepared.agentVersion,
46355
- capabilities: prepared.capabilities,
46356
- commands: prepared.commands,
46357
- configOptions,
46358
- directoryId: command.directoryId,
46359
- directoryLabel: listing.directoryLabel,
46360
- kind: "session.ready",
46361
- requestId: command.requestId,
46362
- restored: prepared.restored,
46363
- sessionId: command.sessionId
46364
- };
46365
- });
46366
- }
46367
- async function executeWorkspaceList(socket, command, directories, audit, signal) {
46368
- try {
46369
- const listing = await directories.list(command.bindingId, command.directoryId, signal);
46370
- audit.record({
46371
- commandId: command.requestId,
46372
- event: "workspace_list_authorized",
46373
- sessionId: "workspace-browser"
46374
- });
46375
- send(socket, {
46376
- bindingId: command.bindingId,
46377
- directoryId: listing.directoryId,
46378
- directoryLabel: listing.directoryLabel,
46379
- entries: listing.entries,
46380
- kind: "workspace.entries",
46381
- parentDirectoryId: listing.parentDirectoryId,
46382
- requestId: command.requestId
46383
- });
46384
- } catch (error62) {
46385
- reportOperationFailure(socket, command.requestId, "", error62);
46386
- }
46387
- }
46388
- async function executeSessionPrepare(socket, command, config2, directories, audit, sessions, diagnostics, signal) {
46389
- const metrics = new AccumulatingOperationMetrics();
46390
- try {
46391
- const readyEvent = await prepareSession(
46392
- command,
46393
- { kind: "interactive-only" },
46394
- config2,
46395
- directories,
46396
- audit,
46397
- sessions,
46398
- metrics,
46399
- signal
46400
- );
46401
- send(socket, {
46402
- ...readyEvent,
46403
- runtimeTimings: metrics.snapshot()
46404
- });
46405
- } catch (error62) {
46406
- diagnostics.daemonDiagnostic(
46407
- "session_prepare_failed",
46408
- command.requestId,
46409
- {
46410
- agentId: command.agentId,
46411
- code: operationErrorCode(error62),
46412
- sessionId: command.sessionId
46413
- },
46414
- error62
46415
- );
46416
- audit.record({
46417
- commandId: command.requestId,
46418
- details: {
46419
- agentId: command.agentId,
46420
- code: operationErrorCode(error62)
46421
- },
46422
- event: "session_prepare_failed",
46423
- sessionId: command.sessionId
46424
- });
46425
- reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
46426
- }
46427
- }
46428
- async function executeSessionRestore(socket, command, config2, directories, audit, sessions, nativeSessions, diagnostics, signal) {
46429
- const metrics = new AccumulatingOperationMetrics();
46430
- try {
46431
- const entry = await metrics.measure("session-lookup", async () => {
46432
- const [found] = await nativeSessions.querySessions([command.sessionId], signal);
46433
- if (found === void 0) {
46434
- throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
46435
- }
46436
- return found;
46437
- });
46438
- const ready = await prepareSession(
46439
- {
46440
- additionalDirectoryIds: entry.additionalDirectories.map((directory) => directory.directoryId),
46441
- agentId: entry.agentId,
46442
- bindingId: config2.bindingId,
46443
- directoryId: entry.directoryId,
46444
- kind: "session.prepare",
46445
- requestId: command.requestId,
46446
- sessionId: command.sessionId,
46447
- sessionState: "provisioned"
46448
- },
46449
- { kind: "history-required" },
46450
- config2,
46451
- directories,
46452
- audit,
46453
- sessions,
46454
- metrics,
46455
- signal
46456
- );
46457
- send(socket, {
46458
- entry,
46459
- kind: "session.restored",
46460
- ready: { ...ready, runtimeTimings: metrics.snapshot() },
46461
- requestId: command.requestId
46462
- });
46463
- } catch (error62) {
46464
- diagnostics.daemonDiagnostic(
46465
- "session_restore_failed",
46466
- command.requestId,
46467
- {
46468
- code: operationErrorCode(error62),
46469
- sessionId: command.sessionId
46470
- },
46471
- error62
46472
- );
46473
- audit.record({
46474
- commandId: command.requestId,
46475
- details: { code: operationErrorCode(error62) },
46476
- event: "session_restore_failed",
46477
- sessionId: command.sessionId
46478
- });
46479
- reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
46480
- }
46481
- }
46482
- async function executeSessionConfigure(socket, command, config2, directories, audit, sessions, signal) {
46483
- try {
46484
- const resolved = await resolveSessionDirectories(
46485
- directories,
46486
- config2.bindingId,
46487
- command.directoryId,
46488
- command.additionalDirectoryIds,
46489
- signal
46490
- );
46491
- const configOptions = await sessions.configureSession({
46492
- additionalDirectories: resolved.additionalDirectories,
46493
- agent: config2.catalog.find(command.agentId),
46494
- booleanValue: command.booleanValue,
46495
- configId: command.configId,
46496
- cwd: resolved.cwd,
46497
- requestId: command.requestId,
46498
- sessionId: command.sessionId,
46499
- signal,
46500
- value: command.value,
46501
- valueType: command.valueType
46502
- });
46503
- audit.record({
46504
- commandId: command.requestId,
46505
- event: "session_configured",
46506
- sessionId: command.sessionId
46507
- });
46508
- send(socket, {
46509
- configOptions,
46510
- kind: "session.config.updated",
46511
- requestId: command.requestId,
46512
- sessionId: command.sessionId
46513
- });
46514
- } catch (error62) {
46515
- if (signal.aborted) {
46516
- signal.throwIfAborted();
46517
- }
46518
- reportOperationFailure(socket, command.requestId, command.sessionId, error62);
46519
- }
46520
- }
46521
-
46522
46687
  // src/native-sessions/handle-native-requests.ts
46523
46688
  import { WebSocket as WebSocket4 } from "undici";
46524
46689
  function createNativeSessionRequestHandler(dependencies) {
@@ -47711,11 +47876,11 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
47711
47876
  stateDirectory
47712
47877
  });
47713
47878
  const channelHash = createHash8("sha256").update(config2.channelId).digest("hex");
47714
- const sessionDatabase = openAcpSessionDatabase(join19(stateDirectory, "sessions", `${channelHash}.sqlite`));
47879
+ const sessionDatabase = openAcpSessionDatabase(join21(stateDirectory, "sessions", `${channelHash}.sqlite`));
47715
47880
  let eventsV2;
47716
47881
  try {
47717
47882
  eventsV2 = new CachedAcpSessionEventStoreV2(
47718
- openSessionEventCacheV2Database(join19(stateDirectory, "sessions", `${channelHash}.events.sqlite`))
47883
+ openSessionEventCacheV2Database(join21(stateDirectory, "sessions", `${channelHash}.events.sqlite`))
47719
47884
  );
47720
47885
  } catch (error62) {
47721
47886
  sessionDatabase.close();
@@ -47982,7 +48147,7 @@ var START_TIMEOUT_MILLISECONDS = 12e4;
47982
48147
  var MAXIMUM_MESSAGE_BYTES = 64 * 1024;
47983
48148
  var CONNECTION_ID_PATTERN2 = /^mcn_[a-f0-9]{32}$/;
47984
48149
  async function acquireManagerLock(stateDirectory) {
47985
- const path3 = join20(stateDirectory, "manager.lock");
48150
+ const path3 = join22(stateDirectory, "manager.lock");
47986
48151
  for (let attempt = 0; attempt < 2; attempt += 1) {
47987
48152
  try {
47988
48153
  await writeFile5(path3, `${process.pid.toString()}
@@ -48014,10 +48179,10 @@ function isRecord12(value) {
48014
48179
  }
48015
48180
  function controlSocketPath(stateDirectory) {
48016
48181
  const installationHash = createHash9("sha256").update(stateDirectory).digest("hex").slice(0, 32);
48017
- return process.platform === "win32" ? `\\\\.\\pipe\\mobius-${installationHash}` : join20(tmpdir(), `mobius-${installationHash}.sock`);
48182
+ return process.platform === "win32" ? `\\\\.\\pipe\\mobius-${installationHash}` : join22(tmpdir(), `mobius-${installationHash}.sock`);
48018
48183
  }
48019
48184
  function controlTokenPath(stateDirectory) {
48020
- return join20(stateDirectory, "manager.token");
48185
+ return join22(stateDirectory, "manager.token");
48021
48186
  }
48022
48187
  async function readOrCreateControlToken(stateDirectory) {
48023
48188
  const path3 = controlTokenPath(stateDirectory);
@@ -48349,7 +48514,7 @@ async function waitForManagerExit(stateDirectory, signal) {
48349
48514
  const deadline = AbortSignal.any([signal, AbortSignal.timeout(1e4)]);
48350
48515
  while (!deadline.aborted) {
48351
48516
  try {
48352
- await readFile3(join20(stateDirectory, "manager.lock"), "utf8");
48517
+ await readFile3(join22(stateDirectory, "manager.lock"), "utf8");
48353
48518
  } catch (cause) {
48354
48519
  if (isNodeError2(cause, "ENOENT")) {
48355
48520
  return;
@@ -48586,7 +48751,7 @@ async function writePairList(path3, pairs) {
48586
48751
  shutdown.signal.throwIfAborted();
48587
48752
  let file2;
48588
48753
  try {
48589
- file2 = await open6(path3, constants2.O_WRONLY | constants2.O_NOFOLLOW);
48754
+ file2 = await open6(path3, constants3.O_WRONLY | constants3.O_NOFOLLOW);
48590
48755
  } catch (cause) {
48591
48756
  if (typeof cause === "object" && cause !== null && "code" in cause && cause.code === "ENOENT") {
48592
48757
  throw new Error("The JSON output file does not exist", { cause });