@moxt-ai/mobius 0.0.192 → 0.0.194

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 (97) hide show
  1. package/dist/acp/agent-runtime-manager.d.ts +1 -1
  2. package/dist/acp/agent-runtime-manager.d.ts.map +1 -1
  3. package/dist/acp/agent-runtime-manager.js +5 -2
  4. package/dist/acp/agent-runtime-manager.js.map +1 -1
  5. package/dist/acp/agent-session.d.ts +13 -0
  6. package/dist/acp/agent-session.d.ts.map +1 -1
  7. package/dist/acp/agent-session.js +11 -2
  8. package/dist/acp/agent-session.js.map +1 -1
  9. package/dist/acp/codex/agent.d.ts +13 -0
  10. package/dist/acp/codex/agent.d.ts.map +1 -1
  11. package/dist/acp/codex/agent.js +1 -0
  12. package/dist/acp/codex/agent.js.map +1 -1
  13. package/dist/acp/codex/settings.d.ts +2 -0
  14. package/dist/acp/codex/settings.d.ts.map +1 -1
  15. package/dist/acp/codex/settings.js +23 -9
  16. package/dist/acp/codex/settings.js.map +1 -1
  17. package/dist/acp/in-process/acp-endpoint.d.ts +3 -0
  18. package/dist/acp/in-process/acp-endpoint.d.ts.map +1 -1
  19. package/dist/acp/in-process/acp-endpoint.js.map +1 -1
  20. package/dist/acp/native-session.d.ts +1 -0
  21. package/dist/acp/native-session.d.ts.map +1 -1
  22. package/dist/acp/session-contracts.d.ts +11 -2
  23. package/dist/acp/session-contracts.d.ts.map +1 -1
  24. package/dist/acp/session-contracts.js +3 -1
  25. package/dist/acp/session-contracts.js.map +1 -1
  26. package/dist/agent-catalog/agents/workbuddy-agent.d.ts.map +1 -1
  27. package/dist/agent-catalog/agents/workbuddy-agent.js +5 -19
  28. package/dist/agent-catalog/agents/workbuddy-agent.js.map +1 -1
  29. package/dist/agent-catalog/discover-agent-settings.d.ts.map +1 -1
  30. package/dist/agent-catalog/discover-agent-settings.js +10 -3
  31. package/dist/agent-catalog/discover-agent-settings.js.map +1 -1
  32. package/dist/agent-catalog/resolve-catalog-agent.d.ts +15 -0
  33. package/dist/agent-catalog/resolve-catalog-agent.d.ts.map +1 -0
  34. package/dist/agent-catalog/resolve-catalog-agent.js +65 -0
  35. package/dist/agent-catalog/resolve-catalog-agent.js.map +1 -0
  36. package/dist/agent-installation/grok-managed-package.d.ts.map +1 -1
  37. package/dist/agent-installation/grok-managed-package.js +5 -16
  38. package/dist/agent-installation/grok-managed-package.js.map +1 -1
  39. package/dist/agent-installation/opencode-managed-release.d.ts.map +1 -1
  40. package/dist/agent-installation/opencode-managed-release.js +9 -16
  41. package/dist/agent-installation/opencode-managed-release.js.map +1 -1
  42. package/dist/cli.js +5660 -5488
  43. package/dist/cli.js.map +4 -4
  44. package/dist/config.d.ts +7 -1
  45. package/dist/config.d.ts.map +1 -1
  46. package/dist/config.js +2 -1
  47. package/dist/config.js.map +1 -1
  48. package/dist/daemon-history-commands.d.ts.map +1 -1
  49. package/dist/daemon-history-commands.js +3 -2
  50. package/dist/daemon-history-commands.js.map +1 -1
  51. package/dist/daemon-prompt-executor.d.ts.map +1 -1
  52. package/dist/daemon-prompt-executor.js +3 -2
  53. package/dist/daemon-prompt-executor.js.map +1 -1
  54. package/dist/daemon-session-commands.d.ts +2 -1
  55. package/dist/daemon-session-commands.d.ts.map +1 -1
  56. package/dist/daemon-session-commands.js +6 -2
  57. package/dist/daemon-session-commands.js.map +1 -1
  58. package/dist/index.js +945 -762
  59. package/dist/index.js.map +4 -4
  60. package/dist/native-sessions/service.d.ts.map +1 -1
  61. package/dist/native-sessions/service.js +5 -2
  62. package/dist/native-sessions/service.js.map +1 -1
  63. package/dist/pairing/pair-local-machine.d.ts.map +1 -1
  64. package/dist/pairing/pair-local-machine.js +12 -5
  65. package/dist/pairing/pair-local-machine.js.map +1 -1
  66. package/dist/platform/contracts.d.ts +26 -0
  67. package/dist/platform/contracts.d.ts.map +1 -0
  68. package/dist/platform/contracts.js +2 -0
  69. package/dist/platform/contracts.js.map +1 -0
  70. package/dist/platform/index.d.ts +3 -0
  71. package/dist/platform/index.d.ts.map +1 -0
  72. package/dist/platform/index.js +21 -0
  73. package/dist/platform/index.js.map +1 -0
  74. package/dist/platform/linux.d.ts +3 -0
  75. package/dist/platform/linux.d.ts.map +1 -0
  76. package/dist/platform/linux.js +146 -0
  77. package/dist/platform/linux.js.map +1 -0
  78. package/dist/platform/macos.d.ts +3 -0
  79. package/dist/platform/macos.d.ts.map +1 -0
  80. package/dist/platform/macos.js +49 -0
  81. package/dist/platform/macos.js.map +1 -0
  82. package/dist/platform/posix.d.ts +4 -0
  83. package/dist/platform/posix.d.ts.map +1 -0
  84. package/dist/platform/posix.js +47 -0
  85. package/dist/platform/posix.js.map +1 -0
  86. package/dist/process/executable.d.ts +2 -4
  87. package/dist/process/executable.d.ts.map +1 -1
  88. package/dist/process/executable.js +11 -166
  89. package/dist/process/executable.js.map +1 -1
  90. package/dist/runtime.d.ts.map +1 -1
  91. package/dist/runtime.js +963 -780
  92. package/dist/runtime.js.map +4 -4
  93. package/dist/session-event-log-v2.d.ts +3 -1
  94. package/dist/session-event-log-v2.d.ts.map +1 -1
  95. package/dist/session-event-log-v2.js +17 -3
  96. package/dist/session-event-log-v2.js.map +1 -1
  97. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ var createAcpClient = (handler) => client({ name: "mobius" }).onRequest(
32
32
  })).onNotification("cursor/update_todos", discardExtensionParams, async () => Promise.resolve()).onNotification("cursor/task", discardExtensionParams, async () => Promise.resolve()).onNotification("cursor/generate_image", discardExtensionParams, async () => Promise.resolve());
33
33
 
34
34
  // src/config.ts
35
- import { join as join3, resolve as resolve3 } from "node:path";
35
+ import { join as join5, resolve as resolve3 } from "node:path";
36
36
 
37
37
  // ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/external.js
38
38
  var external_exports = {};
@@ -21310,8 +21310,10 @@ var lifecycleMetadataV2Schema = external_exports.discriminatedUnion("kind", [
21310
21310
  external_exports.object({
21311
21311
  ...lifecycleBase,
21312
21312
  content: external_exports.array(contentBlockV2Schema).min(1).max(100).readonly(),
21313
+ disposition: shortString.optional(),
21313
21314
  kind: external_exports.literal("prompt.requested"),
21314
- context: promptExecutionContextV2Schema.optional()
21315
+ context: promptExecutionContextV2Schema.optional(),
21316
+ targetCommandId: identifierStringSchema.optional()
21315
21317
  }).readonly(),
21316
21318
  external_exports.object({ ...lifecycleBase, attemptId: identifierStringSchema, epoch: identifierStringSchema, kind: external_exports.literal("prompt.started") }).readonly(),
21317
21319
  external_exports.object({ ...lifecycleBase, kind: external_exports.literal("prompt.completed"), stopReason: shortString }).readonly(),
@@ -21420,7 +21422,9 @@ var sessionEventLogPageV2Schema = external_exports.object({
21420
21422
  var nativeEventPageRequestV2Schema = external_exports.object({ cursor: external_exports.string().min(1).max(512).nullable(), eventLimit: external_exports.number().int().min(1).max(1e4) }).readonly();
21421
21423
  var queuedPromptRequestEventLogV2Schema = external_exports.object({
21422
21424
  commandId: identifierStringSchema,
21423
- content: external_exports.array(contentBlockV2Schema).min(1).max(100).readonly()
21425
+ content: external_exports.array(contentBlockV2Schema).min(1).max(100).readonly(),
21426
+ disposition: shortString.optional(),
21427
+ targetCommandId: identifierStringSchema.optional()
21424
21428
  }).readonly();
21425
21429
  var nativeSessionEventsV2Schema = external_exports.object({
21426
21430
  events: sessionEventLogPageV2Schema,
@@ -21818,15 +21822,266 @@ function normalizeAcpCapabilities(initialized) {
21818
21822
  }
21819
21823
 
21820
21824
  // src/process/executable.ts
21821
- import { execFile, spawn } from "node:child_process";
21825
+ import { spawn } from "node:child_process";
21826
+ import { constants as constants2 } from "node:fs";
21827
+ import { access as access2, realpath as realpath2, stat as stat2 } from "node:fs/promises";
21828
+ import { join as join3, resolve } from "node:path";
21829
+
21830
+ // src/platform/linux.ts
21822
21831
  import { constants, readdirSync, readFileSync } from "node:fs";
21823
21832
  import { access, readdir, readFile, realpath, stat } from "node:fs/promises";
21824
- import { join, resolve } from "node:path";
21833
+ import { join } from "node:path";
21834
+
21835
+ // src/platform/posix.ts
21836
+ import { execFile } from "node:child_process";
21837
+ var PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
21838
+ var PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
21839
+ function parseProcessTable(output2) {
21840
+ const entries = [];
21841
+ for (const line of output2.split("\n")) {
21842
+ const groups = /^\s*(?<pid>\d+)\s+(?<ppid>\d+)\s+(?<pgid>\d+)\s*$/.exec(line)?.groups;
21843
+ if (groups === void 0) {
21844
+ continue;
21845
+ }
21846
+ const processId = Number(groups["pid"]);
21847
+ const parentProcessId = Number(groups["ppid"]);
21848
+ const processGroupId = Number(groups["pgid"]);
21849
+ if (!Number.isSafeInteger(processId) || processId <= 0 || !Number.isSafeInteger(parentProcessId) || parentProcessId < 0 || !Number.isSafeInteger(processGroupId) || processGroupId <= 0) {
21850
+ continue;
21851
+ }
21852
+ entries.push({ parentProcessId, processGroupId, processId });
21853
+ }
21854
+ return entries;
21855
+ }
21856
+ function readProcessTableWithPs(executable) {
21857
+ return new Promise((resolveTable) => {
21858
+ execFile(
21859
+ executable,
21860
+ ["-axo", "pid=,ppid=,pgid="],
21861
+ {
21862
+ encoding: "utf8",
21863
+ maxBuffer: PROCESS_TABLE_OUTPUT_LIMIT_BYTES,
21864
+ signal: AbortSignal.timeout(PROCESS_TABLE_TIMEOUT_MILLISECONDS),
21865
+ timeout: PROCESS_TABLE_TIMEOUT_MILLISECONDS
21866
+ },
21867
+ (error62, stdout) => {
21868
+ resolveTable(error62 === null ? parseProcessTable(stdout) : []);
21869
+ }
21870
+ );
21871
+ });
21872
+ }
21873
+ function processExists(processId) {
21874
+ try {
21875
+ process.kill(processId, 0);
21876
+ return true;
21877
+ } catch {
21878
+ return false;
21879
+ }
21880
+ }
21881
+
21882
+ // src/platform/linux.ts
21883
+ function appendLinuxProcessTableEntry(entries, processId, encoded) {
21884
+ const closingParenthesis = encoded.lastIndexOf(")");
21885
+ if (!encoded.startsWith(`${processId.toString()} (`) || closingParenthesis < 0) {
21886
+ return;
21887
+ }
21888
+ const fields = encoded.slice(closingParenthesis + 1).trim().split(/\s+/);
21889
+ const parentProcessId = Number(fields[1]);
21890
+ const processGroupId = Number(fields[2]);
21891
+ if (!Number.isSafeInteger(parentProcessId) || parentProcessId < 0 || !Number.isSafeInteger(processGroupId) || processGroupId <= 0) {
21892
+ return;
21893
+ }
21894
+ entries.push({ parentProcessId, processGroupId, processId });
21895
+ }
21896
+ async function readLinuxProcessTable() {
21897
+ const entries = [];
21898
+ try {
21899
+ const directories = await readdir("/proc", { withFileTypes: true });
21900
+ for (const directory of directories) {
21901
+ if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
21902
+ continue;
21903
+ }
21904
+ const processId = Number(directory.name);
21905
+ if (!Number.isSafeInteger(processId) || processId <= 0) {
21906
+ continue;
21907
+ }
21908
+ try {
21909
+ appendLinuxProcessTableEntry(
21910
+ entries,
21911
+ processId,
21912
+ await readFile(join("/proc", directory.name, "stat"), "utf8")
21913
+ );
21914
+ } catch {
21915
+ }
21916
+ }
21917
+ } catch {
21918
+ }
21919
+ return entries;
21920
+ }
21921
+ function readLinuxProcessTableSynchronously() {
21922
+ const entries = [];
21923
+ try {
21924
+ const directories = readdirSync("/proc", { withFileTypes: true });
21925
+ for (const directory of directories) {
21926
+ if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
21927
+ continue;
21928
+ }
21929
+ const processId = Number(directory.name);
21930
+ if (!Number.isSafeInteger(processId) || processId <= 0) {
21931
+ continue;
21932
+ }
21933
+ try {
21934
+ appendLinuxProcessTableEntry(
21935
+ entries,
21936
+ processId,
21937
+ readFileSync(join("/proc", directory.name, "stat"), "utf8")
21938
+ );
21939
+ } catch {
21940
+ }
21941
+ }
21942
+ } catch {
21943
+ }
21944
+ return entries;
21945
+ }
21946
+ async function readLinuxProcessTableWithFallback() {
21947
+ const procfsEntries = await readLinuxProcessTable();
21948
+ if (procfsEntries.length > 0) {
21949
+ return procfsEntries;
21950
+ }
21951
+ for (const candidate of ["/usr/bin/ps", "/bin/ps", "/run/current-system/sw/bin/ps"]) {
21952
+ try {
21953
+ const resolvedPath = await realpath(candidate);
21954
+ if (!(await stat(resolvedPath)).isFile()) {
21955
+ continue;
21956
+ }
21957
+ await access(resolvedPath, constants.X_OK);
21958
+ } catch {
21959
+ continue;
21960
+ }
21961
+ const entries = await readProcessTableWithPs(candidate);
21962
+ if (entries.length > 0) {
21963
+ return entries;
21964
+ }
21965
+ }
21966
+ return [];
21967
+ }
21968
+ function processExists2(processId) {
21969
+ try {
21970
+ const encoded = readFileSync(join("/proc", processId.toString(), "stat"), "utf8");
21971
+ const closingParenthesis = encoded.lastIndexOf(")");
21972
+ if (closingParenthesis >= 0) {
21973
+ const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
21974
+ if (processState === "Z" || processState === "X") {
21975
+ return false;
21976
+ }
21977
+ }
21978
+ } catch {
21979
+ }
21980
+ return processExists(processId);
21981
+ }
21982
+ var linuxPlatform = {
21983
+ readProcessTable: readLinuxProcessTableWithFallback,
21984
+ readProcessTableSynchronously: readLinuxProcessTableSynchronously,
21985
+ processExists: processExists2,
21986
+ workBuddyExecutablePaths: () => [],
21987
+ openCodeArchives: {
21988
+ arm64: {
21989
+ asset: "opencode-linux-arm64.tar.gz",
21990
+ sha256: "70baf769395ca4e7a68924026530c390eace194f3b7e4919d4efcb2aa2eed3c0",
21991
+ format: "tar.gz"
21992
+ },
21993
+ x64: {
21994
+ asset: "opencode-linux-x64.tar.gz",
21995
+ sha256: "ea800b7ff56226b70952126c9fc1e2517ca4c4b5682fd9d3f9e87449697a1194",
21996
+ format: "tar.gz"
21997
+ }
21998
+ },
21999
+ grokDependencies: {
22000
+ arm64: {
22001
+ name: "@xai-official/grok-linux-arm64",
22002
+ integrity: "sha512-Jlwz9XtZPNKz/V/ydifC8OVu3hIZz7pmoStt8c4KCqkSWjWiZ/PBIC0iJiq8rvByhx5Z0EdSyq8ZXVwtocceGA==",
22003
+ tarballUrl: "https://registry.npmjs.org/@xai-official/grok-linux-arm64/-/grok-linux-arm64-1.0.21.tgz"
22004
+ },
22005
+ x64: {
22006
+ name: "@xai-official/grok-linux-x64",
22007
+ integrity: "sha512-AjDV5ifEz5LFG2Jt5IlhAeEkJati/wOvCchVbR4eIj2ogjvmXoXlzBrYRXuAJpXBy5q0se/Yuez5FxDU9Ju81w==",
22008
+ tarballUrl: "https://registry.npmjs.org/@xai-official/grok-linux-x64/-/grok-linux-x64-1.0.21.tgz"
22009
+ }
22010
+ }
22011
+ };
22012
+
22013
+ // src/platform/macos.ts
22014
+ import { isAbsolute, join as join2 } from "node:path";
22015
+ var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
22016
+ "WorkBuddy.app",
22017
+ "Contents",
22018
+ "Resources",
22019
+ "app.asar.unpacked",
22020
+ "cli",
22021
+ "bin",
22022
+ "codebuddy"
22023
+ ]);
22024
+ var macosPlatform = {
22025
+ readProcessTable: () => readProcessTableWithPs("/bin/ps"),
22026
+ readProcessTableSynchronously: () => [],
22027
+ processExists,
22028
+ workBuddyExecutablePaths: (environment) => {
22029
+ const paths = [join2("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
22030
+ const homeDirectory = environment["HOME"];
22031
+ if (homeDirectory !== void 0 && isAbsolute(homeDirectory)) {
22032
+ paths.unshift(join2(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
22033
+ }
22034
+ return paths;
22035
+ },
22036
+ openCodeArchives: {
22037
+ arm64: {
22038
+ asset: "opencode-darwin-arm64.zip",
22039
+ sha256: "fe764f7f360c584a83e18dd5f23fb1a6b2725f5ee8854b0252fe558f7798e946",
22040
+ format: "zip"
22041
+ },
22042
+ x64: {
22043
+ asset: "opencode-darwin-x64.zip",
22044
+ sha256: "9858853e7bacdbbd22c2d70c377e009dc4b354dd04f5588705411e7afb89fd2d",
22045
+ format: "zip"
22046
+ }
22047
+ },
22048
+ grokDependencies: {
22049
+ arm64: {
22050
+ name: "@xai-official/grok-darwin-arm64",
22051
+ integrity: "sha512-I4pKZGnR6Mv4MJOJsB9B/i2o0ODF4eZtp4jHN5feoTqKIeAUVg38OzBtE8aN/wZa7Xg+qhnf6Jd1tcAFvMoFtQ==",
22052
+ tarballUrl: "https://registry.npmjs.org/@xai-official/grok-darwin-arm64/-/grok-darwin-arm64-1.0.21.tgz"
22053
+ },
22054
+ x64: {
22055
+ name: "@xai-official/grok-darwin-x64",
22056
+ integrity: "sha512-h0nFj3NZ9Kz8w6fQ6UDxxeSIhC1WjwwoRE92iNbG//tZy6YGkppR3s7oRVtt4Xl0CJANKUt0EusyIYnnAvKLzw==",
22057
+ tarballUrl: "https://registry.npmjs.org/@xai-official/grok-darwin-x64/-/grok-darwin-x64-1.0.21.tgz"
22058
+ }
22059
+ }
22060
+ };
22061
+
22062
+ // src/platform/index.ts
22063
+ var fallbackPlatform = {
22064
+ readProcessTable: () => readProcessTableWithPs("/usr/bin/ps"),
22065
+ readProcessTableSynchronously: () => [],
22066
+ processExists,
22067
+ workBuddyExecutablePaths: () => [],
22068
+ openCodeArchives: {},
22069
+ grokDependencies: {}
22070
+ };
22071
+ var platforms = /* @__PURE__ */ new Map([
22072
+ ["linux", linuxPlatform],
22073
+ ["darwin", macosPlatform],
22074
+ ["win32", { ...fallbackPlatform, readProcessTable: () => Promise.resolve([]) }]
22075
+ ]);
22076
+ function platformSupportFor(platform) {
22077
+ return platforms.get(platform) ?? fallbackPlatform;
22078
+ }
22079
+
22080
+ // src/process/executable.ts
22081
+ var hostPlatform = platformSupportFor(process.platform);
21825
22082
  var DEFAULT_OUTPUT_LIMIT_BYTES = 16 * 1024;
21826
22083
  var PROCESS_GRACEFUL_STOP_TIMEOUT_MILLISECONDS = 1e3;
21827
22084
  var PROCESS_FORCED_STOP_TIMEOUT_MILLISECONDS = 5e3;
21828
- var PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
21829
- var PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
21830
22085
  var PROCESS_EXIT_CHECK_ATTEMPTS = 16;
21831
22086
  var GRACEFUL_STOP_SIGNAL = 15;
21832
22087
  var FORCED_STOP_SIGNAL = 9;
@@ -21885,13 +22140,13 @@ function executableExtensions(executableName, environment, platform) {
21885
22140
  async function resolveExecutablePath(requestedPath2, platform = process.platform) {
21886
22141
  const absoluteRequestedPath = resolve(requestedPath2);
21887
22142
  try {
21888
- const resolvedPath = await realpath(absoluteRequestedPath);
21889
- const metadata = await stat(resolvedPath);
22143
+ const resolvedPath = await realpath2(absoluteRequestedPath);
22144
+ const metadata = await stat2(resolvedPath);
21890
22145
  if (!metadata.isFile()) {
21891
22146
  return null;
21892
22147
  }
21893
22148
  if (platform !== "win32") {
21894
- await access(resolvedPath, constants.X_OK);
22149
+ await access2(resolvedPath, constants2.X_OK);
21895
22150
  }
21896
22151
  return new ResolvedExecutable(
21897
22152
  new ExecutableIdentity(
@@ -21916,7 +22171,7 @@ async function findExecutableOnPath(executableName, environment, platform = proc
21916
22171
  continue;
21917
22172
  }
21918
22173
  for (const extension of extensions) {
21919
- const requestedPath2 = resolve(join(entry, `${executableName}${extension}`));
22174
+ const requestedPath2 = resolve(join3(entry, `${executableName}${extension}`));
21920
22175
  const executable = await resolveExecutablePath(requestedPath2, platform);
21921
22176
  if (executable !== null) {
21922
22177
  return executable;
@@ -21937,128 +22192,8 @@ function appendBounded(chunks, chunk, currentBytes, limitBytes) {
21937
22192
  chunks.push(chunk);
21938
22193
  return nextBytes;
21939
22194
  }
21940
- function parseProcessTable(output2) {
21941
- const entries = [];
21942
- for (const line of output2.split("\n")) {
21943
- const groups = /^\s*(?<pid>\d+)\s+(?<ppid>\d+)\s+(?<pgid>\d+)\s*$/.exec(line)?.groups;
21944
- if (groups === void 0) {
21945
- continue;
21946
- }
21947
- const processId = Number(groups["pid"]);
21948
- const parentProcessId = Number(groups["ppid"]);
21949
- const processGroupId = Number(groups["pgid"]);
21950
- if (!Number.isSafeInteger(processId) || processId <= 0 || !Number.isSafeInteger(parentProcessId) || parentProcessId < 0 || !Number.isSafeInteger(processGroupId) || processGroupId <= 0) {
21951
- continue;
21952
- }
21953
- entries.push({ parentProcessId, processGroupId, processId });
21954
- }
21955
- return entries;
21956
- }
21957
- function appendLinuxProcessTableEntry(entries, processId, encoded) {
21958
- const closingParenthesis = encoded.lastIndexOf(")");
21959
- if (!encoded.startsWith(`${processId.toString()} (`) || closingParenthesis < 0) {
21960
- return;
21961
- }
21962
- const fields = encoded.slice(closingParenthesis + 1).trim().split(/\s+/);
21963
- const parentProcessId = Number(fields[1]);
21964
- const processGroupId = Number(fields[2]);
21965
- if (!Number.isSafeInteger(parentProcessId) || parentProcessId < 0 || !Number.isSafeInteger(processGroupId) || processGroupId <= 0) {
21966
- return;
21967
- }
21968
- entries.push({ parentProcessId, processGroupId, processId });
21969
- }
21970
- async function readLinuxProcessTable() {
21971
- const entries = [];
21972
- try {
21973
- const directories = await readdir("/proc", { withFileTypes: true });
21974
- for (const directory of directories) {
21975
- if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
21976
- continue;
21977
- }
21978
- const processId = Number(directory.name);
21979
- if (!Number.isSafeInteger(processId) || processId <= 0) {
21980
- continue;
21981
- }
21982
- try {
21983
- appendLinuxProcessTableEntry(
21984
- entries,
21985
- processId,
21986
- await readFile(join("/proc", directory.name, "stat"), "utf8")
21987
- );
21988
- } catch {
21989
- }
21990
- }
21991
- } catch {
21992
- }
21993
- return entries;
21994
- }
21995
- function readLinuxProcessTableSynchronously() {
21996
- const entries = [];
21997
- try {
21998
- const directories = readdirSync("/proc", { withFileTypes: true });
21999
- for (const directory of directories) {
22000
- if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
22001
- continue;
22002
- }
22003
- const processId = Number(directory.name);
22004
- if (!Number.isSafeInteger(processId) || processId <= 0) {
22005
- continue;
22006
- }
22007
- try {
22008
- appendLinuxProcessTableEntry(
22009
- entries,
22010
- processId,
22011
- readFileSync(join("/proc", directory.name, "stat"), "utf8")
22012
- );
22013
- } catch {
22014
- }
22015
- }
22016
- } catch {
22017
- }
22018
- return entries;
22019
- }
22020
- function readProcessTableWithPs(executable) {
22021
- return new Promise((resolveTable) => {
22022
- execFile(
22023
- executable,
22024
- ["-axo", "pid=,ppid=,pgid="],
22025
- {
22026
- encoding: "utf8",
22027
- maxBuffer: PROCESS_TABLE_OUTPUT_LIMIT_BYTES,
22028
- signal: AbortSignal.timeout(PROCESS_TABLE_TIMEOUT_MILLISECONDS),
22029
- timeout: PROCESS_TABLE_TIMEOUT_MILLISECONDS
22030
- },
22031
- (error62, stdout) => {
22032
- resolveTable(error62 === null ? parseProcessTable(stdout) : []);
22033
- }
22034
- );
22035
- });
22036
- }
22037
- async function readLinuxProcessTableWithFallback() {
22038
- const procfsEntries = await readLinuxProcessTable();
22039
- if (procfsEntries.length > 0) {
22040
- return procfsEntries;
22041
- }
22042
- for (const candidate of ["/usr/bin/ps", "/bin/ps", "/run/current-system/sw/bin/ps"]) {
22043
- const executable = await resolveExecutablePath(candidate);
22044
- if (executable === null) {
22045
- continue;
22046
- }
22047
- const entries = await readProcessTableWithPs(executable.identity.requestedPath);
22048
- if (entries.length > 0) {
22049
- return entries;
22050
- }
22051
- }
22052
- return [];
22053
- }
22054
22195
  function readProcessTable() {
22055
- if (process.platform === "win32") {
22056
- return Promise.resolve([]);
22057
- }
22058
- if (process.platform === "linux") {
22059
- return readLinuxProcessTableWithFallback();
22060
- }
22061
- return readProcessTableWithPs(process.platform === "darwin" ? "/bin/ps" : "/usr/bin/ps");
22196
+ return hostPlatform.readProcessTable();
22062
22197
  }
22063
22198
  function selectProcessTree(entries, rootProcessId) {
22064
22199
  const processIds = /* @__PURE__ */ new Set([rootProcessId]);
@@ -22095,11 +22230,9 @@ async function captureProcessTree(child2) {
22095
22230
  if (process.platform === "win32" || child2.pid === void 0) {
22096
22231
  return [];
22097
22232
  }
22098
- if (process.platform === "linux") {
22099
- const procfsEntries = readLinuxProcessTableSynchronously();
22100
- if (procfsEntries.length > 0) {
22101
- return selectProcessTree(procfsEntries, child2.pid);
22102
- }
22233
+ const entries = hostPlatform.readProcessTableSynchronously();
22234
+ if (entries.length > 0) {
22235
+ return selectProcessTree(entries, child2.pid);
22103
22236
  }
22104
22237
  return selectProcessTree(await readProcessTable(), child2.pid);
22105
22238
  }
@@ -22127,36 +22260,15 @@ function signalCapturedProcessGroups(processes, rootProcessId, signal) {
22127
22260
  }
22128
22261
  }
22129
22262
  }
22130
- function processExists(processId) {
22131
- if (process.platform === "linux") {
22132
- try {
22133
- const encoded = readFileSync(join("/proc", processId.toString(), "stat"), "utf8");
22134
- const closingParenthesis = encoded.lastIndexOf(")");
22135
- if (closingParenthesis >= 0) {
22136
- const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
22137
- if (processState === "Z" || processState === "X") {
22138
- return false;
22139
- }
22140
- }
22141
- } catch {
22142
- }
22143
- }
22144
- try {
22145
- process.kill(processId, 0);
22146
- return true;
22147
- } catch {
22148
- return false;
22149
- }
22150
- }
22151
22263
  async function waitForCapturedProcessesExit(processes, rootProcessId) {
22152
22264
  const processIds = processes.map((identity2) => identity2.processId).filter((processId) => processId !== rootProcessId);
22153
22265
  for (let attempt = 0; attempt < PROCESS_EXIT_CHECK_ATTEMPTS; attempt += 1) {
22154
- if (processIds.every((processId) => !processExists(processId))) {
22266
+ if (processIds.every((processId) => !hostPlatform.processExists(processId))) {
22155
22267
  return true;
22156
22268
  }
22157
22269
  await readProcessTable();
22158
22270
  }
22159
- return processIds.every((processId) => !processExists(processId));
22271
+ return processIds.every((processId) => !hostPlatform.processExists(processId));
22160
22272
  }
22161
22273
  function terminateProcess(child2) {
22162
22274
  if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
@@ -22504,19 +22616,19 @@ var LocalAgentCatalog = class {
22504
22616
 
22505
22617
  // src/storage/state-directory.ts
22506
22618
  import { homedir } from "node:os";
22507
- import { join as join2, resolve as resolve2 } from "node:path";
22619
+ import { join as join4, resolve as resolve2 } from "node:path";
22508
22620
  function readStateDirectory(environment = process.env) {
22509
22621
  const configured = environment["MOBIUS_STATE_DIRECTORY"]?.trim();
22510
22622
  if (configured !== void 0 && configured.length > 0) {
22511
22623
  return resolve2(configured);
22512
22624
  }
22513
- return join2(homedir(), ".mobius");
22625
+ return join4(homedir(), ".mobius");
22514
22626
  }
22515
22627
 
22516
22628
  // src/config.ts
22517
22629
  function loadDefaultWorkspace(environment = process.env) {
22518
22630
  const { MOBIUS_DEFAULT_WORKSPACE: configuredWorkspace } = environment;
22519
- return configuredWorkspace ?? join3(readStateDirectory(environment), "workspace");
22631
+ return configuredWorkspace ?? join5(readStateDirectory(environment), "workspace");
22520
22632
  }
22521
22633
  var DaemonLocalContext = class {
22522
22634
  environment;
@@ -22546,7 +22658,7 @@ var OpaqueDaemonReconnectTarget = class extends DaemonReconnectTarget {
22546
22658
  this.commandArgument = `--connection ${connectionId2}`;
22547
22659
  }
22548
22660
  };
22549
- function createDaemonConfig(connection, agents = [], installableAgents = [], localContext = new DaemonLocalContext(readStateDirectory(), process.env), reconnectTarget = null) {
22661
+ function createDaemonConfig(connection, agents = [], installableAgents = [], localContext = new DaemonLocalContext(readStateDirectory(), process.env), reconnectTarget = null, resolveAgent) {
22550
22662
  const daemonAgents = agents.map((agent) => withDaemonEnvironment(agent, localContext.environment));
22551
22663
  return {
22552
22664
  agents: daemonAgents,
@@ -22557,7 +22669,8 @@ function createDaemonConfig(connection, agents = [], installableAgents = [], loc
22557
22669
  installableAgents,
22558
22670
  localContext,
22559
22671
  reconnectTarget,
22560
- relayUrl: connection.relayUrl
22672
+ relayUrl: connection.relayUrl,
22673
+ ...resolveAgent === void 0 ? {} : { resolveAgent }
22561
22674
  };
22562
22675
  }
22563
22676
  function loadDaemonConfig() {
@@ -22691,8 +22804,8 @@ import {
22691
22804
  } from "@agentclientprotocol/sdk";
22692
22805
 
22693
22806
  // src/authorization/local-raster.ts
22694
- import { open as open2, readFile as readFile2, realpath as realpath2, stat as stat2 } from "node:fs/promises";
22695
- import { basename, isAbsolute, normalize } from "node:path";
22807
+ import { open as open2, readFile as readFile2, realpath as realpath3, stat as stat3 } from "node:fs/promises";
22808
+ import { basename, isAbsolute as isAbsolute2, normalize } from "node:path";
22696
22809
  import { fileURLToPath } from "node:url";
22697
22810
  var MAX_LOCAL_RASTER_BYTES = 128 * 1024 * 1024;
22698
22811
  var MAX_INLINE_RASTER_BYTES = 3e6;
@@ -22758,13 +22871,13 @@ function readInlineRaster(data, name2 = "Image") {
22758
22871
  }
22759
22872
  async function resolveCanonicalPath(requested, signal) {
22760
22873
  signal.throwIfAborted();
22761
- if (!isAbsolute(requested) || requested.includes("\0") || normalize(requested) !== requested) {
22874
+ if (!isAbsolute2(requested) || requested.includes("\0") || normalize(requested) !== requested) {
22762
22875
  return null;
22763
22876
  }
22764
22877
  try {
22765
- const target = await realpath2(requested);
22878
+ const target = await realpath3(requested);
22766
22879
  signal.throwIfAborted();
22767
- if (!isAbsolute(target) || normalize(target) !== target) {
22880
+ if (!isAbsolute2(target) || normalize(target) !== target) {
22768
22881
  return null;
22769
22882
  }
22770
22883
  return target;
@@ -22810,7 +22923,7 @@ async function readLocalRaster(uri, signal) {
22810
22923
  if (target === null) {
22811
22924
  return null;
22812
22925
  }
22813
- const targetMetadata = await stat2(target);
22926
+ const targetMetadata = await stat3(target);
22814
22927
  signal.throwIfAborted();
22815
22928
  if (!targetMetadata.isFile() || targetMetadata.size < 1 || targetMetadata.size > MAX_LOCAL_RASTER_BYTES) {
22816
22929
  return null;
@@ -24273,10 +24386,12 @@ var AcpAgentSettingsSnapshot = class {
24273
24386
  agentName;
24274
24387
  agentVersion;
24275
24388
  configOptions;
24276
- constructor(agentName, agentVersion, configOptions) {
24389
+ modelEffort;
24390
+ constructor(agentName, agentVersion, configOptions, modelEffort) {
24277
24391
  this.agentName = agentName;
24278
24392
  this.agentVersion = agentVersion;
24279
24393
  this.configOptions = configOptions;
24394
+ this.modelEffort = modelEffort;
24280
24395
  }
24281
24396
  };
24282
24397
 
@@ -25640,7 +25755,7 @@ function sql(strings, ...params) {
25640
25755
  return new SQL([new StringChunk(str)]);
25641
25756
  }
25642
25757
  _sql.raw = raw;
25643
- function join20(chunks, separator) {
25758
+ function join22(chunks, separator) {
25644
25759
  const result = [];
25645
25760
  for (const [i, chunk] of chunks.entries()) {
25646
25761
  if (i > 0 && separator !== void 0) result.push(separator);
@@ -25648,7 +25763,7 @@ function sql(strings, ...params) {
25648
25763
  }
25649
25764
  return new SQL(result);
25650
25765
  }
25651
- _sql.join = join20;
25766
+ _sql.join = join22;
25652
25767
  function identifier2(value) {
25653
25768
  return new Name(value);
25654
25769
  }
@@ -27793,7 +27908,7 @@ var SQLiteSelectBase = class extends TypedQueryBuilder {
27793
27908
  const baseTableName = this.tableName;
27794
27909
  const tableName = getTableLikeName(table);
27795
27910
  for (const item of extractUsedTable(table)) this.usedTables.add(item);
27796
- if (typeof tableName === "string" && this.config.joins?.some((join20) => join20.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
27911
+ if (typeof tableName === "string" && this.config.joins?.some((join22) => join22.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
27797
27912
  if (!this.isPartialSelect) {
27798
27913
  if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
27799
27914
  if (typeof tableName === "string" && !is(table, SQL)) {
@@ -28632,7 +28747,7 @@ var SQLiteDialect = class {
28632
28747
  if (!joins2) return;
28633
28748
  const withEntries = Object.entries(joins2).filter(([_, v]) => v);
28634
28749
  if (!withEntries.length) return;
28635
- return sql.join(withEntries.map(([k, join20]) => {
28750
+ return sql.join(withEntries.map(([k, join22]) => {
28636
28751
  const relation = tableConfig.relations[k];
28637
28752
  const isSingle2 = is(relation, One);
28638
28753
  const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
@@ -28643,7 +28758,7 @@ var SQLiteDialect = class {
28643
28758
  table: targetTable,
28644
28759
  mode: isSingle2 ? "first" : "many",
28645
28760
  schema,
28646
- queryConfig: join20,
28761
+ queryConfig: join22,
28647
28762
  tableConfig: schema[relation.targetTableName],
28648
28763
  relationWhere: filter,
28649
28764
  isNested: true,
@@ -28657,7 +28772,7 @@ var SQLiteDialect = class {
28657
28772
  key: k,
28658
28773
  selection: innerQuery.selection,
28659
28774
  isArray: !isSingle2,
28660
- isOptional: (relation.optional ?? false) || join20 !== true && !!join20.where
28775
+ isOptional: (relation.optional ?? false) || join22 !== true && !!join22.where
28661
28776
  });
28662
28777
  const jsonColumns = sql.join(innerQuery.selection.map((s) => {
28663
28778
  return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
@@ -29273,7 +29388,7 @@ var SQLiteUpdateBase = class {
29273
29388
  createJoin(joinType) {
29274
29389
  return ((table, on) => {
29275
29390
  const tableName = getTableLikeName(table);
29276
- if (typeof tableName === "string" && this.config.joins.some((join20) => join20.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
29391
+ if (typeof tableName === "string" && this.config.joins.some((join22) => join22.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
29277
29392
  if (typeof on === "function") {
29278
29393
  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;
29279
29394
  on = on(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
@@ -30679,7 +30794,7 @@ var AgentSession = class _AgentSession {
30679
30794
  );
30680
30795
  }
30681
30796
  initialize = async (signal, recovery, origin) => {
30682
- if (origin?.kind === "fork") {
30797
+ if (origin !== void 0) {
30683
30798
  this.#sessionTitle = origin.title;
30684
30799
  }
30685
30800
  await this.#initializeAgent(signal);
@@ -30693,7 +30808,7 @@ var AgentSession = class _AgentSession {
30693
30808
  this.#cwd,
30694
30809
  this.#additionalDirectories,
30695
30810
  true,
30696
- ""
30811
+ origin.title
30697
30812
  )
30698
30813
  ) : this.#store.read(this.#mobiusSessionId)
30699
30814
  );
@@ -31043,8 +31158,10 @@ var AgentSession = class _AgentSession {
31043
31158
  payload: {
31044
31159
  commandId: options.commandId,
31045
31160
  content: lifecycleV2.content,
31161
+ ...lifecycleV2.disposition === void 0 ? {} : { disposition: lifecycleV2.disposition },
31046
31162
  kind: "prompt.requested",
31047
- ...lifecycleV2.context === void 0 ? {} : { context: lifecycleV2.context }
31163
+ ...lifecycleV2.context === void 0 ? {} : { context: lifecycleV2.context },
31164
+ ...lifecycleV2.targetCommandId === void 0 ? {} : { targetCommandId: lifecycleV2.targetCommandId }
31048
31165
  },
31049
31166
  type: "lifecycle-metadata"
31050
31167
  });
@@ -31151,8 +31268,10 @@ var AgentSession = class _AgentSession {
31151
31268
  payload: {
31152
31269
  commandId: options.commandId,
31153
31270
  content: lifecycleV2.content,
31271
+ ...lifecycleV2.disposition === void 0 ? {} : { disposition: lifecycleV2.disposition },
31154
31272
  kind: "prompt.requested",
31155
- ...lifecycleV2.context === void 0 ? {} : { context: lifecycleV2.context }
31273
+ ...lifecycleV2.context === void 0 ? {} : { context: lifecycleV2.context },
31274
+ ...lifecycleV2.targetCommandId === void 0 ? {} : { targetCommandId: lifecycleV2.targetCommandId }
31156
31275
  },
31157
31276
  type: "lifecycle-metadata"
31158
31277
  });
@@ -31422,6 +31541,7 @@ var AgentSession = class _AgentSession {
31422
31541
  }
31423
31542
  };
31424
31543
  closeProcess = () => this.#connection.closeProcess();
31544
+ agentSettingsModelEffort = () => this.#connection.inProcessAgent?.agentSettingsModelEffort?.() ?? null;
31425
31545
  race = (operation, exitMessage, signal) => this.#connection.race(operation, exitMessage, signal);
31426
31546
  assertNativeSession = (sessionId) => {
31427
31547
  if (sessionId !== this.#updates.sessionId()) {
@@ -31927,8 +32047,8 @@ var AcpContentExternalizer = class {
31927
32047
 
31928
32048
  // src/external-content/local-external-content-store.ts
31929
32049
  import { createHash, randomUUID as randomUUID2 } from "node:crypto";
31930
- import { lstat, mkdir, readdir as readdir2, realpath as realpath3, rename, rm, stat as stat3, utimes, writeFile } from "node:fs/promises";
31931
- import { dirname, join as join4 } from "node:path";
32050
+ import { lstat, mkdir, readdir as readdir2, realpath as realpath4, rename, rm, stat as stat4, utimes, writeFile } from "node:fs/promises";
32051
+ import { dirname, join as join6 } from "node:path";
31932
32052
  var contentRequest = /^mobius-content:(image|audio|resource):([a-f0-9]{64})$/u;
31933
32053
  var CONTENT_LIFETIME_MILLISECONDS = 24 * 60 * 60 * 1e3;
31934
32054
  var metadataSchema2 = external_exports.strictObject({
@@ -31964,7 +32084,7 @@ var LocalExternalContentStore = class {
31964
32084
  #expirationTimer;
31965
32085
  #cleanup = Promise.resolve();
31966
32086
  constructor(stateDirectory) {
31967
- this.#root = join4(stateDirectory, "tmp", "session-content", randomUUID2());
32087
+ this.#root = join6(stateDirectory, "tmp", "session-content", randomUUID2());
31968
32088
  this.#expirationTimer = setInterval(() => {
31969
32089
  void this.#expire().catch(() => void 0);
31970
32090
  }, 6e4);
@@ -31979,11 +32099,11 @@ var LocalExternalContentStore = class {
31979
32099
  if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
31980
32100
  continue;
31981
32101
  }
31982
- const path2 = join4(dirname(this.#root), directory.name);
32102
+ const path2 = join6(dirname(this.#root), directory.name);
31983
32103
  if (path2 === this.#root) {
31984
32104
  continue;
31985
32105
  }
31986
- const modified = await stat3(path2).then(
32106
+ const modified = await stat4(path2).then(
31987
32107
  (entry) => entry.mtimeMs,
31988
32108
  () => Date.now()
31989
32109
  );
@@ -32029,10 +32149,10 @@ var LocalExternalContentStore = class {
32029
32149
  }
32030
32150
  await this.#expire();
32031
32151
  active.throwIfAborted();
32032
- const directory = join4(this.#root, kind);
32152
+ const directory = join6(this.#root, kind);
32033
32153
  await mkdir(directory, { mode: 448, recursive: true });
32034
32154
  active.throwIfAborted();
32035
- const path2 = join4(directory, key);
32155
+ const path2 = join6(directory, key);
32036
32156
  const write = atomicWrite(path2, bytes, active);
32037
32157
  await write;
32038
32158
  active.throwIfAborted();
@@ -32065,8 +32185,8 @@ var LocalExternalContentStore = class {
32065
32185
  }
32066
32186
  try {
32067
32187
  const [resolvedDirectory, resolvedPath, file2] = await Promise.all([
32068
- realpath3(dirname(entry.path)),
32069
- realpath3(entry.path),
32188
+ realpath4(dirname(entry.path)),
32189
+ realpath4(entry.path),
32070
32190
  lstat(entry.path)
32071
32191
  ]);
32072
32192
  signal.throwIfAborted();
@@ -32504,7 +32624,7 @@ var AgentRuntimeManager = class {
32504
32624
  return await this.#startRetainedSessionProcess(
32505
32625
  options,
32506
32626
  async () => await AgentSession.start(
32507
- 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,
32627
+ 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,
32508
32628
  recovery,
32509
32629
  () => this.#observer,
32510
32630
  this.#store,
@@ -32660,6 +32780,7 @@ var AgentRuntimeManager = class {
32660
32780
  ),
32661
32781
  async (runtime) => {
32662
32782
  const prepared = runtime.prepared();
32783
+ const discoveredModelEffort = runtime.agentSettingsModelEffort();
32663
32784
  const model = options2.model;
32664
32785
  const configOptions = model === void 0 ? prepared.configOptions : await runtime.configure({
32665
32786
  ...options2,
@@ -32672,7 +32793,12 @@ var AgentRuntimeManager = class {
32672
32793
  value: model,
32673
32794
  valueType: "select"
32674
32795
  });
32675
- return new AcpAgentSettingsSnapshot(prepared.agentName, prepared.agentVersion, configOptions);
32796
+ return new AcpAgentSettingsSnapshot(
32797
+ prepared.agentName,
32798
+ prepared.agentVersion,
32799
+ configOptions,
32800
+ discoveredModelEffort === null ? { kind: "unavailable" } : { kind: "complete", value: discoveredModelEffort }
32801
+ );
32676
32802
  },
32677
32803
  async (runtime) => await runtime.close()
32678
32804
  );
@@ -33157,10 +33283,10 @@ var LocalAuthorizationError = class extends Error {
33157
33283
  };
33158
33284
 
33159
33285
  // src/pairing/pair-local-machine.ts
33160
- import { mkdir as mkdir6, realpath as realpath8, stat as stat7 } from "node:fs/promises";
33286
+ import { mkdir as mkdir6, realpath as realpath9, stat as stat8 } from "node:fs/promises";
33161
33287
  import { hostname as hostname3 } from "node:os";
33162
33288
  import { basename as basename3, resolve as resolve5 } from "node:path";
33163
- import { fetch as fetch2 } from "undici";
33289
+ import { fetch as fetch3 } from "undici";
33164
33290
 
33165
33291
  // src/agent-catalog/agent-discovery.ts
33166
33292
  var AgentDiscovery = class {
@@ -33302,8 +33428,8 @@ var LocalAgentInventory = class {
33302
33428
  };
33303
33429
 
33304
33430
  // src/agent-installation/managed-npm-package.ts
33305
- import { mkdir as mkdir2, mkdtemp, open as open3, realpath as realpath4, rename as rename2, rm as rm2, stat as stat4 } from "node:fs/promises";
33306
- import { delimiter, dirname as dirname2, isAbsolute as isAbsolute2, join as join5, relative, sep } from "node:path";
33431
+ import { mkdir as mkdir2, mkdtemp, open as open3, realpath as realpath5, rename as rename2, rm as rm2, stat as stat5 } from "node:fs/promises";
33432
+ import { delimiter, dirname as dirname2, isAbsolute as isAbsolute3, join as join7, relative, sep } from "node:path";
33307
33433
  var INSTALL_TIMEOUT_MILLISECONDS = 5 * 60 * 1e3;
33308
33434
  var PACKAGE_METADATA_LIMIT_BYTES = 64 * 1024;
33309
33435
  var PACKAGE_LOCK_LIMIT_BYTES = 8 * 1024 * 1024;
@@ -33354,11 +33480,11 @@ function isRecord7(value) {
33354
33480
  return typeof value === "object" && value !== null && !Array.isArray(value);
33355
33481
  }
33356
33482
  function packagePath(root, packageName) {
33357
- return join5(root, "node_modules", ...packageName.split("/"));
33483
+ return join7(root, "node_modules", ...packageName.split("/"));
33358
33484
  }
33359
33485
  function isContainedPath(root, candidate) {
33360
33486
  const difference = relative(root, candidate);
33361
- return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep}`) && !isAbsolute2(difference);
33487
+ return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep}`) && !isAbsolute3(difference);
33362
33488
  }
33363
33489
  async function readJsonRecord(path2, maximumBytes) {
33364
33490
  try {
@@ -33459,14 +33585,14 @@ function verifyPackageLockEntry(lock, definition, verifyDependencyClosure) {
33459
33585
  }
33460
33586
  }
33461
33587
  async function verifyRequiredDependency(rootPath, lock, definition) {
33462
- const dependencyRoot = await realpath4(packagePath(rootPath, definition.packageName));
33588
+ const dependencyRoot = await realpath5(packagePath(rootPath, definition.packageName));
33463
33589
  if (!isContainedPath(rootPath, dependencyRoot)) {
33464
33590
  throw new ManagedNpmPackageError(
33465
33591
  "managed_package_verification_failed",
33466
33592
  "The required managed npm dependency escaped its private cache"
33467
33593
  );
33468
33594
  }
33469
- const metadata = await readJsonRecord(join5(dependencyRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
33595
+ const metadata = await readJsonRecord(join7(dependencyRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
33470
33596
  if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
33471
33597
  throw new ManagedNpmPackageError(
33472
33598
  "managed_package_verification_failed",
@@ -33488,15 +33614,15 @@ async function validateManagedNpmPackage(root, definition) {
33488
33614
  }
33489
33615
  }
33490
33616
  async function validateManagedNpmPackageContents(root, definition) {
33491
- const rootPath = await realpath4(root);
33492
- const packageRoot = await realpath4(packagePath(rootPath, definition.packageName));
33617
+ const rootPath = await realpath5(root);
33618
+ const packageRoot = await realpath5(packagePath(rootPath, definition.packageName));
33493
33619
  if (!isContainedPath(rootPath, packageRoot)) {
33494
33620
  throw new ManagedNpmPackageError(
33495
33621
  "managed_package_verification_failed",
33496
33622
  "The managed npm package escaped its private cache"
33497
33623
  );
33498
33624
  }
33499
- const metadata = await readJsonRecord(join5(packageRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
33625
+ const metadata = await readJsonRecord(join7(packageRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
33500
33626
  if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
33501
33627
  throw new ManagedNpmPackageError(
33502
33628
  "managed_package_verification_failed",
@@ -33504,14 +33630,14 @@ async function validateManagedNpmPackageContents(root, definition) {
33504
33630
  );
33505
33631
  }
33506
33632
  if (definition instanceof SriManagedNpmPackageDefinition) {
33507
- const lock = await readJsonRecord(join5(rootPath, "package-lock.json"), PACKAGE_LOCK_LIMIT_BYTES);
33633
+ const lock = await readJsonRecord(join7(rootPath, "package-lock.json"), PACKAGE_LOCK_LIMIT_BYTES);
33508
33634
  verifyPackageLockEntry(lock, definition, definition.verifyDependencyClosure);
33509
33635
  for (const dependency of definition.requiredDependencies) {
33510
33636
  await verifyRequiredDependency(rootPath, lock, dependency);
33511
33637
  }
33512
33638
  }
33513
33639
  const declaredBin = readBinPath(metadata, definition.executableName);
33514
- const executable = await resolveExecutablePath(join5(packageRoot, declaredBin));
33640
+ const executable = await resolveExecutablePath(join7(packageRoot, declaredBin));
33515
33641
  if (executable === null || !isContainedPath(rootPath, executable.path)) {
33516
33642
  throw new ManagedNpmPackageError(
33517
33643
  "managed_package_verification_failed",
@@ -33524,7 +33650,7 @@ var ManagedNpmPackageInstaller = class {
33524
33650
  install = async (root, definition, environment, signal) => {
33525
33651
  signal.throwIfAborted();
33526
33652
  try {
33527
- const metadata = await stat4(root);
33653
+ const metadata = await stat5(root);
33528
33654
  if (metadata.isDirectory()) {
33529
33655
  return await validateManagedNpmPackage(root, definition);
33530
33656
  }
@@ -33535,7 +33661,7 @@ var ManagedNpmPackageInstaller = class {
33535
33661
  }
33536
33662
  const parent = dirname2(root);
33537
33663
  await mkdir2(parent, { mode: 448, recursive: true });
33538
- const staging = await mkdtemp(join5(parent, `.${definition.version}.staging-`));
33664
+ const staging = await mkdtemp(join7(parent, `.${definition.version}.staging-`));
33539
33665
  try {
33540
33666
  const npm = await findExecutableOnPath(process.platform === "win32" ? "npm.cmd" : "npm", environment);
33541
33667
  if (npm === null) {
@@ -33561,9 +33687,9 @@ var ManagedNpmPackageInstaller = class {
33561
33687
  `${definition.packageName}@${definition.version}`
33562
33688
  );
33563
33689
  const installEnvironment = {
33564
- HOME: join5(staging, "home"),
33690
+ HOME: join7(staging, "home"),
33565
33691
  NPM_CONFIG_AUDIT: "false",
33566
- NPM_CONFIG_CACHE: join5(staging, ".npm-cache"),
33692
+ NPM_CONFIG_CACHE: join7(staging, ".npm-cache"),
33567
33693
  NPM_CONFIG_FUND: "false",
33568
33694
  NPM_CONFIG_IGNORE_SCRIPTS: "true",
33569
33695
  NPM_CONFIG_PACKAGE_LOCK: "true",
@@ -33585,8 +33711,8 @@ var ManagedNpmPackageInstaller = class {
33585
33711
  timeoutMilliseconds: INSTALL_TIMEOUT_MILLISECONDS
33586
33712
  });
33587
33713
  await Promise.all([
33588
- rm2(join5(staging, ".npm-cache"), { force: true, recursive: true }),
33589
- rm2(join5(staging, "home"), { force: true, recursive: true })
33714
+ rm2(join7(staging, ".npm-cache"), { force: true, recursive: true }),
33715
+ rm2(join7(staging, "home"), { force: true, recursive: true })
33590
33716
  ]);
33591
33717
  await validateManagedNpmPackage(staging, definition);
33592
33718
  try {
@@ -33622,7 +33748,7 @@ var ManagedNpmPackageInstaller = class {
33622
33748
  };
33623
33749
 
33624
33750
  // src/agent-catalog/agent-specification.ts
33625
- import { join as join6 } from "node:path";
33751
+ import { join as join8 } from "node:path";
33626
33752
 
33627
33753
  // src/agent-catalog/version-output.ts
33628
33754
  function normalizeVersionOutput(output2) {
@@ -33645,7 +33771,7 @@ var LocalAgentSpecification = class {
33645
33771
  resolveManagedAgent = async (stateDirectory, platform, signal) => {
33646
33772
  signal.throwIfAborted();
33647
33773
  const executable = await resolveExecutablePath(
33648
- join6(stateDirectory, ...this.managedAgentExecutablePath),
33774
+ join8(stateDirectory, ...this.managedAgentExecutablePath),
33649
33775
  platform
33650
33776
  );
33651
33777
  signal.throwIfAborted();
@@ -33743,7 +33869,7 @@ import {
33743
33869
  import { spawn as spawn3 } from "node:child_process";
33744
33870
 
33745
33871
  // src/acp/codex/app-server-protocol.ts
33746
- import { isAbsolute as isAbsolute3 } from "node:path";
33872
+ import { isAbsolute as isAbsolute4 } from "node:path";
33747
33873
  var boundedText = (maximum) => external_exports.string().max(maximum);
33748
33874
  var jsonValue = external_exports.lazy(() => external_exports.unknown());
33749
33875
  var requestIdSchema = external_exports.union([external_exports.number(), external_exports.string()]).refine((value) => typeof value === "number" || value.length <= 256);
@@ -33814,7 +33940,7 @@ var imageGenerationItemSchema = external_exports.object({
33814
33940
  });
33815
33941
  var threadItemSchema = external_exports.discriminatedUnion("type", [
33816
33942
  imageGenerationItemSchema,
33817
- external_exports.object({ type: external_exports.literal("imageView"), id: boundedText(256), path: boundedText(32768).refine(isAbsolute3) }),
33943
+ external_exports.object({ type: external_exports.literal("imageView"), id: boundedText(256), path: boundedText(32768).refine(isAbsolute4) }),
33818
33944
  external_exports.object({
33819
33945
  id: boundedText(256),
33820
33946
  text: boundedText(1e6),
@@ -34497,7 +34623,7 @@ function effortValues(model) {
34497
34623
  }));
34498
34624
  }
34499
34625
  function supportedSelection(models, reportedModel, reportedEffort) {
34500
- const model = models.find((candidate) => candidate.id === reportedModel) ?? models.find((candidate) => candidate.isDefault === true) ?? models[0];
34626
+ const model = models.find((candidate) => candidate.id === reportedModel);
34501
34627
  if (model === void 0) {
34502
34628
  return { model: reportedModel, effort: reportedEffort };
34503
34629
  }
@@ -34508,7 +34634,11 @@ function supportedSelection(models, reportedModel, reportedEffort) {
34508
34634
  };
34509
34635
  }
34510
34636
  function modelSetting(models, currentValue) {
34511
- const values = modelValues(models);
34637
+ const catalogValues = modelValues(models);
34638
+ const values = currentValue.length > 0 && !catalogValues.some((value) => value.value === currentValue) ? [
34639
+ { description: "Current model configured in Codex", name: currentValue, value: currentValue },
34640
+ ...catalogValues
34641
+ ] : catalogValues;
34512
34642
  const current = values.some((value) => value.value === currentValue) ? currentValue : models.find((model) => model.isDefault === true)?.id ?? values[0]?.value ?? "";
34513
34643
  if (current.length === 0) {
34514
34644
  return null;
@@ -34626,7 +34756,8 @@ var CodexSettings = class {
34626
34756
  turnParameters = () => {
34627
34757
  const selection = this.#selection;
34628
34758
  const mode = AGENT_MODES.find((candidate) => candidate.id === selection.mode) ?? DEFAULT_MODE;
34629
- const supportsFast = this.#model(selection.model)?.additionalSpeedTiers?.includes(FAST_TIER) === true;
34759
+ const model = this.#model(selection.model);
34760
+ const supportsFast = model?.additionalSpeedTiers?.includes(FAST_TIER) === true;
34630
34761
  return {
34631
34762
  approvalPolicy: mode.approvalPolicy,
34632
34763
  approvalsReviewer: mode.approvalsReviewer,
@@ -34644,8 +34775,8 @@ var CodexSettings = class {
34644
34775
  }
34645
34776
  }
34646
34777
  } : {},
34647
- ...selection.effort.length === 0 ? {} : { effort: selection.effort },
34648
- ...selection.model.length === 0 ? {} : { model: selection.model },
34778
+ ...model === void 0 || selection.effort.length === 0 ? {} : { effort: selection.effort },
34779
+ ...model === void 0 ? {} : { model: model.id },
34649
34780
  ...selection.fastMode && supportsFast ? { serviceTier: SERVICE_TIER_FAST } : {}
34650
34781
  };
34651
34782
  };
@@ -34714,6 +34845,18 @@ var CodexSettings = class {
34714
34845
  options.push(modeSetting(this.#selection.mode));
34715
34846
  return options;
34716
34847
  };
34848
+ agentModelEffort = () => ({
34849
+ effortSettingId: REASONING_EFFORT_SETTING_ID,
34850
+ modelSettingId: MODEL_SETTING_ID,
34851
+ resolution: AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE,
34852
+ unsupportedModelIds: [],
34853
+ valuesByModel: Object.fromEntries(
34854
+ this.#models.map((model) => [
34855
+ model.id,
34856
+ effortValues(model).map((value) => ({ ...value, groupId: "", groupName: "" }))
34857
+ ])
34858
+ )
34859
+ });
34717
34860
  selectRestoredThread = (thread) => {
34718
34861
  const supported = supportedSelection(
34719
34862
  this.#models,
@@ -35099,6 +35242,7 @@ var CodexAcpAgent = class {
35099
35242
  await this.#interruptTurn();
35100
35243
  });
35101
35244
  }
35245
+ agentSettingsModelEffort = () => this.#settings.agentModelEffort();
35102
35246
  /** The ACP agent app Mobius connects its own ACP client to, in-process. */
35103
35247
  app = () => this.#app;
35104
35248
  nativeTurnId = () => this.#nativeTurnId;
@@ -35662,15 +35806,15 @@ var AgentProbeError = class extends Error {
35662
35806
  };
35663
35807
 
35664
35808
  // src/agent-catalog/agents/resolve-user-local-executable.ts
35665
- import { isAbsolute as isAbsolute4, join as join7 } from "node:path";
35809
+ import { isAbsolute as isAbsolute5, join as join9 } from "node:path";
35666
35810
  async function resolveUserLocalExecutable(executableName, context) {
35667
35811
  context.signal.throwIfAborted();
35668
35812
  const platform = context.platform ?? process.platform;
35669
35813
  const homeDirectory = context.environment["HOME"];
35670
- if (platform === "win32" || homeDirectory === void 0 || !isAbsolute4(homeDirectory)) {
35814
+ if (platform === "win32" || homeDirectory === void 0 || !isAbsolute5(homeDirectory)) {
35671
35815
  return [];
35672
35816
  }
35673
- const executable = await resolveExecutablePath(join7(homeDirectory, ".local", "bin", executableName), platform);
35817
+ const executable = await resolveExecutablePath(join9(homeDirectory, ".local", "bin", executableName), platform);
35674
35818
  context.signal.throwIfAborted();
35675
35819
  return executable === null ? [] : [executable];
35676
35820
  }
@@ -35759,8 +35903,8 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
35759
35903
  };
35760
35904
 
35761
35905
  // src/agent-catalog/agents/deepseek-harness-agent.ts
35762
- import { mkdir as mkdir3, realpath as realpath5, stat as stat5, writeFile as writeFile2 } from "node:fs/promises";
35763
- import { isAbsolute as isAbsolute5, join as join8, normalize as normalize2 } from "node:path";
35906
+ import { mkdir as mkdir3, realpath as realpath6, stat as stat6, writeFile as writeFile2 } from "node:fs/promises";
35907
+ import { isAbsolute as isAbsolute6, join as join10, normalize as normalize2 } from "node:path";
35764
35908
 
35765
35909
  // src/agent-installation/deepseek-managed-package.ts
35766
35910
  var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
@@ -35784,20 +35928,20 @@ var DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH = `# Managed by Mobius: pin the ACP brid
35784
35928
  model: deepseek-v4-flash-vision-exp
35785
35929
  `;
35786
35930
  async function prepareAgentHome(path2, imagePrompts) {
35787
- if (!isAbsolute5(path2) || normalize2(path2) !== path2) {
35931
+ if (!isAbsolute6(path2) || normalize2(path2) !== path2) {
35788
35932
  throw new AgentProbeError("agent_environment_invalid", "The configured Agent home is invalid");
35789
35933
  }
35790
35934
  try {
35791
35935
  if (imagePrompts) {
35792
35936
  await mkdir3(path2, { mode: 448, recursive: true });
35793
35937
  }
35794
- const resolved = await realpath5(path2);
35795
- const metadata = await stat5(resolved);
35938
+ const resolved = await realpath6(path2);
35939
+ const metadata = await stat6(resolved);
35796
35940
  if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
35797
35941
  throw new Error("Agent home is not a user-owned directory");
35798
35942
  }
35799
35943
  if (imagePrompts) {
35800
- await writeFile2(join8(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
35944
+ await writeFile2(join10(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
35801
35945
  mode: 384
35802
35946
  });
35803
35947
  }
@@ -35845,7 +35989,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
35845
35989
  context.signal
35846
35990
  );
35847
35991
  if (managed.path === agent.path) {
35848
- selectedHome = join8(readStateDirectory(context.environment), "agents", this.id, "home");
35992
+ selectedHome = join10(readStateDirectory(context.environment), "agents", this.id, "home");
35849
35993
  managedHome = true;
35850
35994
  }
35851
35995
  } catch {
@@ -35861,7 +36005,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
35861
36005
  resolveManagedAgent = async (stateDirectory, _platform, signal) => {
35862
36006
  signal.throwIfAborted();
35863
36007
  const executable = await validateManagedNpmPackage(
35864
- join8(stateDirectory, "agents", this.id, DEEPSEEK_HARNESS_PACKAGE.version),
36008
+ join10(stateDirectory, "agents", this.id, DEEPSEEK_HARNESS_PACKAGE.version),
35865
36009
  DEEPSEEK_HARNESS_PACKAGE
35866
36010
  );
35867
36011
  signal.throwIfAborted();
@@ -35915,8 +36059,8 @@ var GeminiCliAgentSpecification = class extends DirectAcpAgentDefinition {
35915
36059
  };
35916
36060
 
35917
36061
  // src/agent-catalog/agents/grok-build-agent.ts
35918
- import { realpath as realpath6 } from "node:fs/promises";
35919
- import { isAbsolute as isAbsolute6, join as join9, relative as relative2, sep as sep2 } from "node:path";
36062
+ import { realpath as realpath7 } from "node:fs/promises";
36063
+ import { isAbsolute as isAbsolute7, join as join11, relative as relative2, sep as sep2 } from "node:path";
35920
36064
  import {
35921
36065
  RequestError as RequestError2
35922
36066
  } from "@agentclientprotocol/sdk";
@@ -35939,50 +36083,25 @@ var GrokBuildManagedPackage = class extends SriManagedNpmPackageDefinition {
35939
36083
  this.requiredDependencies = Object.freeze([requiredDependency]);
35940
36084
  }
35941
36085
  };
35942
- var GROK_DARWIN_ARM64_PACKAGE = new SriManagedNpmDependencyDefinition(
35943
- "@xai-official/grok-darwin-arm64",
35944
- GROK_BUILD_MANAGED_VERSION,
35945
- "sha512-I4pKZGnR6Mv4MJOJsB9B/i2o0ODF4eZtp4jHN5feoTqKIeAUVg38OzBtE8aN/wZa7Xg+qhnf6Jd1tcAFvMoFtQ==",
35946
- "https://registry.npmjs.org/@xai-official/grok-darwin-arm64/-/grok-darwin-arm64-1.0.21.tgz"
35947
- );
35948
- var GROK_DARWIN_X64_PACKAGE = new SriManagedNpmDependencyDefinition(
35949
- "@xai-official/grok-darwin-x64",
35950
- GROK_BUILD_MANAGED_VERSION,
35951
- "sha512-h0nFj3NZ9Kz8w6fQ6UDxxeSIhC1WjwwoRE92iNbG//tZy6YGkppR3s7oRVtt4Xl0CJANKUt0EusyIYnnAvKLzw==",
35952
- "https://registry.npmjs.org/@xai-official/grok-darwin-x64/-/grok-darwin-x64-1.0.21.tgz"
35953
- );
35954
- var GROK_LINUX_ARM64_PACKAGE = new SriManagedNpmDependencyDefinition(
35955
- "@xai-official/grok-linux-arm64",
35956
- GROK_BUILD_MANAGED_VERSION,
35957
- "sha512-Jlwz9XtZPNKz/V/ydifC8OVu3hIZz7pmoStt8c4KCqkSWjWiZ/PBIC0iJiq8rvByhx5Z0EdSyq8ZXVwtocceGA==",
35958
- "https://registry.npmjs.org/@xai-official/grok-linux-arm64/-/grok-linux-arm64-1.0.21.tgz"
35959
- );
35960
- var GROK_LINUX_X64_PACKAGE = new SriManagedNpmDependencyDefinition(
35961
- "@xai-official/grok-linux-x64",
35962
- GROK_BUILD_MANAGED_VERSION,
35963
- "sha512-AjDV5ifEz5LFG2Jt5IlhAeEkJati/wOvCchVbR4eIj2ogjvmXoXlzBrYRXuAJpXBy5q0se/Yuez5FxDU9Ju81w==",
35964
- "https://registry.npmjs.org/@xai-official/grok-linux-x64/-/grok-linux-x64-1.0.21.tgz"
35965
- );
35966
36086
  function grokBuildManagedPackage(platform, architecture) {
35967
- if (platform === "darwin" && architecture === "arm64") {
35968
- return new GrokBuildManagedPackage(GROK_DARWIN_ARM64_PACKAGE);
35969
- }
35970
- if (platform === "darwin" && architecture === "x64") {
35971
- return new GrokBuildManagedPackage(GROK_DARWIN_X64_PACKAGE);
35972
- }
35973
- if (platform === "linux" && architecture === "arm64") {
35974
- return new GrokBuildManagedPackage(GROK_LINUX_ARM64_PACKAGE);
36087
+ const release = platformSupportFor(platform).grokDependencies[architecture];
36088
+ if (release === void 0) {
36089
+ throw new Error("Grok Build does not publish a package for this platform");
35975
36090
  }
35976
- if (platform === "linux" && architecture === "x64") {
35977
- return new GrokBuildManagedPackage(GROK_LINUX_X64_PACKAGE);
35978
- }
35979
- throw new Error("Grok Build does not publish a package for this platform");
36091
+ return new GrokBuildManagedPackage(
36092
+ new SriManagedNpmDependencyDefinition(
36093
+ release.name,
36094
+ GROK_BUILD_MANAGED_VERSION,
36095
+ release.integrity,
36096
+ release.tarballUrl
36097
+ )
36098
+ );
35980
36099
  }
35981
36100
 
35982
36101
  // src/agent-catalog/agents/grok-build-agent.ts
35983
36102
  function isContainedPath2(root, candidate) {
35984
36103
  const difference = relative2(root, candidate);
35985
- return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep2}`) && !isAbsolute6(difference);
36104
+ return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep2}`) && !isAbsolute7(difference);
35986
36105
  }
35987
36106
  var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
35988
36107
  adapterVersion = GROK_BUILD_MANAGED_VERSION;
@@ -36011,8 +36130,8 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
36011
36130
  );
36012
36131
  if (managed.path === agent.path) {
36013
36132
  return Object.freeze({
36014
- GROK_HOME: await realpath6(
36015
- join9(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION, "home")
36133
+ GROK_HOME: await realpath7(
36134
+ join11(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION, "home")
36016
36135
  )
36017
36136
  });
36018
36137
  }
@@ -36023,9 +36142,9 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
36023
36142
  };
36024
36143
  resolveManagedAgent = async (stateDirectory, platform, signal) => {
36025
36144
  signal.throwIfAborted();
36026
- const versionRoot = await realpath6(join9(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION));
36027
- await validateManagedNpmPackage(join9(versionRoot, "package"), grokBuildManagedPackage(platform, process.arch));
36028
- const executable = await resolveExecutablePath(join9(versionRoot, "home", "bin", "grok"), platform);
36145
+ const versionRoot = await realpath7(join11(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION));
36146
+ await validateManagedNpmPackage(join11(versionRoot, "package"), grokBuildManagedPackage(platform, process.arch));
36147
+ const executable = await resolveExecutablePath(join11(versionRoot, "home", "bin", "grok"), platform);
36029
36148
  signal.throwIfAborted();
36030
36149
  if (executable === null || !isContainedPath2(versionRoot, executable.path)) {
36031
36150
  throw new AgentProbeError("managed_agent_invalid", "The managed Grok Build executable is invalid");
@@ -36125,13 +36244,13 @@ var OhMyPiAgentSpecification = class extends DirectAcpAgentDefinition {
36125
36244
  };
36126
36245
 
36127
36246
  // src/agent-catalog/agents/opencode-agent.ts
36128
- import { join as join11 } from "node:path";
36247
+ import { join as join13 } from "node:path";
36129
36248
 
36130
36249
  // src/agent-installation/managed-agent-archive.ts
36131
36250
  import { createHash as createHash3 } from "node:crypto";
36132
36251
  import { createReadStream } from "node:fs";
36133
- import { chmod, copyFile, mkdir as mkdir4, mkdtemp as mkdtemp2, open as open4, realpath as realpath7, rename as rename3, rm as rm3, stat as stat6, writeFile as writeFile3 } from "node:fs/promises";
36134
- import { delimiter as delimiter2, dirname as dirname3, isAbsolute as isAbsolute7, join as join10, relative as relative3, sep as sep3 } from "node:path";
36252
+ import { chmod, copyFile, mkdir as mkdir4, mkdtemp as mkdtemp2, open as open4, realpath as realpath8, rename as rename3, rm as rm3, stat as stat7, writeFile as writeFile3 } from "node:fs/promises";
36253
+ import { delimiter as delimiter2, dirname as dirname3, isAbsolute as isAbsolute8, join as join12, relative as relative3, sep as sep3 } from "node:path";
36135
36254
 
36136
36255
  // src/agent-installation/verified-download.ts
36137
36256
  import { fetch } from "undici";
@@ -36237,7 +36356,7 @@ function isRecord8(value) {
36237
36356
  }
36238
36357
  function isContainedPath3(root, candidate) {
36239
36358
  const difference = relative3(root, candidate);
36240
- return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !isAbsolute7(difference);
36359
+ return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !isAbsolute8(difference);
36241
36360
  }
36242
36361
  async function hashFile(path2, signal) {
36243
36362
  signal.throwIfAborted();
@@ -36311,16 +36430,16 @@ async function readManifest(path2) {
36311
36430
  }
36312
36431
  async function validateManagedAgentArchive(root, definition, signal) {
36313
36432
  try {
36314
- const rootPath = await realpath7(root);
36315
- const rootMetadata = await stat6(rootPath);
36433
+ const rootPath = await realpath8(root);
36434
+ const rootMetadata = await stat7(rootPath);
36316
36435
  if (!rootMetadata.isDirectory() || typeof process.getuid === "function" && rootMetadata.uid !== process.getuid()) {
36317
36436
  throw new Error("Managed Agent root is not user-owned");
36318
36437
  }
36319
- const manifest = await readManifest(join10(rootPath, "archive.json"));
36438
+ const manifest = await readManifest(join12(rootPath, "archive.json"));
36320
36439
  if (manifest["archiveSha256"] !== definition.archiveSha256 || manifest["archiveUrl"] !== definition.archiveUrl.toString() || manifest["version"] !== definition.version || typeof manifest["executableSha256"] !== "string") {
36321
36440
  throw new Error("Managed Agent archive identity is invalid");
36322
36441
  }
36323
- const executable = await resolveExecutablePath(join10(rootPath, "bin", definition.executableName));
36442
+ const executable = await resolveExecutablePath(join12(rootPath, "bin", definition.executableName));
36324
36443
  if (executable === null || !isContainedPath3(rootPath, executable.path) || await hashFile(executable.path, signal) !== manifest["executableSha256"]) {
36325
36444
  throw new Error("Managed Agent executable is invalid");
36326
36445
  }
@@ -36346,47 +36465,21 @@ function releaseUrl(asset) {
36346
36465
  return new URL(`https://github.com/anomalyco/opencode/releases/download/v${OPENCODE_MANAGED_VERSION}/${asset}`);
36347
36466
  }
36348
36467
  function openCodeManagedArchive(platform, architecture) {
36349
- if (platform === "darwin" && architecture === "arm64") {
36350
- const asset = "opencode-darwin-arm64.zip";
36351
- return new ZipManagedAgentArchiveDefinition(
36352
- OPENCODE_MANAGED_VERSION,
36353
- asset,
36354
- releaseUrl(asset),
36355
- "fe764f7f360c584a83e18dd5f23fb1a6b2725f5ee8854b0252fe558f7798e946",
36356
- "opencode"
36357
- );
36358
- }
36359
- if (platform === "darwin" && architecture === "x64") {
36360
- const asset = "opencode-darwin-x64.zip";
36361
- return new ZipManagedAgentArchiveDefinition(
36362
- OPENCODE_MANAGED_VERSION,
36363
- asset,
36364
- releaseUrl(asset),
36365
- "9858853e7bacdbbd22c2d70c377e009dc4b354dd04f5588705411e7afb89fd2d",
36366
- "opencode"
36367
- );
36368
- }
36369
- if (platform === "linux" && architecture === "arm64") {
36370
- const asset = "opencode-linux-arm64.tar.gz";
36371
- return new TarGzipManagedAgentArchiveDefinition(
36372
- OPENCODE_MANAGED_VERSION,
36373
- asset,
36374
- releaseUrl(asset),
36375
- "70baf769395ca4e7a68924026530c390eace194f3b7e4919d4efcb2aa2eed3c0",
36376
- "opencode"
36377
- );
36378
- }
36379
- if (platform === "linux" && architecture === "x64") {
36380
- const asset = "opencode-linux-x64.tar.gz";
36381
- return new TarGzipManagedAgentArchiveDefinition(
36382
- OPENCODE_MANAGED_VERSION,
36383
- asset,
36384
- releaseUrl(asset),
36385
- "ea800b7ff56226b70952126c9fc1e2517ca4c4b5682fd9d3f9e87449697a1194",
36386
- "opencode"
36387
- );
36388
- }
36389
- throw new Error("OpenCode does not publish an approved archive for this platform");
36468
+ const release = platformSupportFor(platform).openCodeArchives[architecture];
36469
+ if (release === void 0) {
36470
+ throw new Error("OpenCode does not publish an approved archive for this platform");
36471
+ }
36472
+ const Definition = {
36473
+ zip: ZipManagedAgentArchiveDefinition,
36474
+ "tar.gz": TarGzipManagedAgentArchiveDefinition
36475
+ }[release.format];
36476
+ return new Definition(
36477
+ OPENCODE_MANAGED_VERSION,
36478
+ release.asset,
36479
+ releaseUrl(release.asset),
36480
+ release.sha256,
36481
+ "opencode"
36482
+ );
36390
36483
  }
36391
36484
 
36392
36485
  // src/agent-catalog/agents/opencode-agent.ts
@@ -36512,7 +36605,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
36512
36605
  return Object.freeze(environment);
36513
36606
  };
36514
36607
  resolveManagedAgent = async (stateDirectory, platform, signal) => await validateManagedAgentArchive(
36515
- join11(stateDirectory, "agents", this.id, OPENCODE_MANAGED_VERSION),
36608
+ join13(stateDirectory, "agents", this.id, OPENCODE_MANAGED_VERSION),
36516
36609
  openCodeManagedArchive(platform, process.arch),
36517
36610
  signal
36518
36611
  );
@@ -36530,7 +36623,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
36530
36623
  };
36531
36624
 
36532
36625
  // src/agent-catalog/agents/pi-agent.ts
36533
- import { join as join12 } from "node:path";
36626
+ import { join as join14 } from "node:path";
36534
36627
  import {
36535
36628
  methods as methods7
36536
36629
  } from "@agentclientprotocol/sdk";
@@ -36589,7 +36682,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
36589
36682
  resolveManagedAgent = async (stateDirectory, _platform, signal) => {
36590
36683
  signal.throwIfAborted();
36591
36684
  const executable = await validateManagedNpmPackage(
36592
- join12(stateDirectory, "agents", this.id, PI_AGENT_PACKAGE.version),
36685
+ join14(stateDirectory, "agents", this.id, PI_AGENT_PACKAGE.version),
36593
36686
  PI_AGENT_PACKAGE
36594
36687
  );
36595
36688
  signal.throwIfAborted();
@@ -36627,7 +36720,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
36627
36720
  };
36628
36721
 
36629
36722
  // src/agent-catalog/agents/workbuddy-agent.ts
36630
- import { isAbsolute as isAbsolute8, join as join13 } from "node:path";
36723
+ import { join as join15 } from "node:path";
36631
36724
 
36632
36725
  // src/agent-installation/workbuddy-managed-package.ts
36633
36726
  var WORKBUDDY_MANAGED_VERSION = "2.146.0";
@@ -36645,15 +36738,6 @@ var WORKBUDDY_MANAGED_PACKAGE = new WorkBuddyManagedPackage(
36645
36738
  );
36646
36739
 
36647
36740
  // src/agent-catalog/agents/workbuddy-agent.ts
36648
- var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
36649
- "WorkBuddy.app",
36650
- "Contents",
36651
- "Resources",
36652
- "app.asar.unpacked",
36653
- "cli",
36654
- "bin",
36655
- "codebuddy"
36656
- ]);
36657
36741
  var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
36658
36742
  adapterVersion = WORKBUDDY_MANAGED_VERSION;
36659
36743
  authenticationCommand = () => "codebuddy";
@@ -36682,7 +36766,7 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
36682
36766
  resolveManagedAgent = async (stateDirectory, _platform, signal) => {
36683
36767
  signal.throwIfAborted();
36684
36768
  const executable = await validateManagedNpmPackage(
36685
- join13(stateDirectory, "agents", this.id, WORKBUDDY_MANAGED_VERSION),
36769
+ join15(stateDirectory, "agents", this.id, WORKBUDDY_MANAGED_VERSION),
36686
36770
  WORKBUDDY_MANAGED_PACKAGE
36687
36771
  );
36688
36772
  signal.throwIfAborted();
@@ -36690,17 +36774,11 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
36690
36774
  };
36691
36775
  resolveInstalledAgentExecutables = async (context) => {
36692
36776
  context.signal.throwIfAborted();
36693
- if ((context.platform ?? process.platform) !== "darwin") {
36694
- return [];
36695
- }
36696
- const requestedPaths = [join13("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
36697
- const homeDirectory = context.environment["HOME"];
36698
- if (homeDirectory !== void 0 && isAbsolute8(homeDirectory)) {
36699
- requestedPaths.unshift(join13(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
36700
- }
36777
+ const platform = context.platform ?? process.platform;
36778
+ const requestedPaths = platformSupportFor(platform).workBuddyExecutablePaths(context.environment);
36701
36779
  const executables = [];
36702
36780
  for (const requestedPath2 of requestedPaths) {
36703
- const executable = await resolveExecutablePath(requestedPath2, "darwin");
36781
+ const executable = await resolveExecutablePath(requestedPath2, platform);
36704
36782
  context.signal.throwIfAborted();
36705
36783
  if (executable !== null) {
36706
36784
  executables.push(executable);
@@ -37031,10 +37109,10 @@ function isAgentVersionSupported(reportedVersion, minimumSupportedVersion) {
37031
37109
  }
37032
37110
 
37033
37111
  // src/agent-catalog/executable-discovery.ts
37034
- import { isAbsolute as isAbsolute9, join as join15 } from "node:path";
37112
+ import { isAbsolute as isAbsolute9, join as join17 } from "node:path";
37035
37113
 
37036
37114
  // src/agent-installation/managed-adapter-installer.ts
37037
- import { join as join14 } from "node:path";
37115
+ import { join as join16 } from "node:path";
37038
37116
  var ManagedAdapterInstallError = class extends Error {
37039
37117
  code;
37040
37118
  constructor(code, message, options = {}) {
@@ -37091,7 +37169,7 @@ var ManagedAdapterInstaller = class {
37091
37169
  this.#stateDirectory = options.stateDirectory;
37092
37170
  }
37093
37171
  install = async (specification, signal) => {
37094
- const root = join14(this.#stateDirectory, "adapters", specification.id, specification.adapterVersion);
37172
+ const root = join16(this.#stateDirectory, "adapters", specification.id, specification.adapterVersion);
37095
37173
  try {
37096
37174
  return await this.#npmInstaller.install(
37097
37175
  root,
@@ -37125,7 +37203,7 @@ async function resolveManagedAdapterExecutable(specification, context) {
37125
37203
  let managed;
37126
37204
  try {
37127
37205
  managed = await validateManagedAdapter(
37128
- join15(readStateDirectory(context.environment), "adapters", specification.id, specification.adapterVersion),
37206
+ join17(readStateDirectory(context.environment), "adapters", specification.id, specification.adapterVersion),
37129
37207
  specification
37130
37208
  );
37131
37209
  } catch {
@@ -37438,10 +37516,176 @@ async function discoverLocalAgentInventory(options) {
37438
37516
  return new LocalAgentInventory(results);
37439
37517
  }
37440
37518
 
37519
+ // src/agent-catalog/publish-agent-catalog.ts
37520
+ import { fetch as fetch2 } from "undici";
37521
+
37522
+ // src/relay-connection/runtime-authentication.ts
37523
+ function runtimeCredential(relayUrl) {
37524
+ return relayUrl.searchParams.get("token") ?? "";
37525
+ }
37526
+ function runtimeAuthorization(relayUrl) {
37527
+ const credential = runtimeCredential(relayUrl);
37528
+ return credential.length === 0 ? {} : { authorization: `Bearer ${credential}` };
37529
+ }
37530
+ function relayHttpEndpoint(relayUrl) {
37531
+ const endpoint = new URL(relayUrl);
37532
+ endpoint.protocol = endpoint.protocol === "wss:" ? "https:" : "http:";
37533
+ endpoint.search = "";
37534
+ return endpoint;
37535
+ }
37536
+
37537
+ // src/agent-catalog/publish-agent-catalog.ts
37538
+ var CATALOG_UPDATE_TIMEOUT_MILLISECONDS = 2e4;
37539
+ var AgentCatalogPublishError = class extends Error {
37540
+ code = "agent_catalog_update_failed";
37541
+ diagnosticDetails;
37542
+ constructor(message, options = {}, diagnosticDetails = {}) {
37543
+ super(message, options);
37544
+ this.diagnosticDetails = diagnosticDetails;
37545
+ this.name = "AgentCatalogPublishError";
37546
+ }
37547
+ };
37548
+ function isRecord9(value) {
37549
+ return typeof value === "object" && value !== null && !Array.isArray(value);
37550
+ }
37551
+ function isSafeRelayErrorMessage(value) {
37552
+ return value.length > 0 && value.length <= 512 && Array.from(value).every((character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127);
37553
+ }
37554
+ async function rejectedCatalogError(response) {
37555
+ let value;
37556
+ try {
37557
+ value = await response.json();
37558
+ } catch {
37559
+ return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
37560
+ }
37561
+ if (!isRecord9(value) || !isRecord9(value["error"])) {
37562
+ return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
37563
+ }
37564
+ const code = value["error"]["code"];
37565
+ const message = value["error"]["message"];
37566
+ if (typeof code !== "string" || !/^[a-z][a-z0-9_]{0,63}$/.test(code) || typeof message !== "string" || !isSafeRelayErrorMessage(message)) {
37567
+ return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
37568
+ }
37569
+ return new AgentCatalogPublishError(
37570
+ `The Relay rejected the Agent catalog update (${code}): ${message}`,
37571
+ {},
37572
+ {
37573
+ relayErrorCode: code
37574
+ }
37575
+ );
37576
+ }
37577
+ function catalogEndpoint(config2) {
37578
+ const endpoint = relayHttpEndpoint(config2.relayUrl);
37579
+ if (endpoint.pathname.endsWith("/daemon")) {
37580
+ endpoint.pathname = `${endpoint.pathname.slice(0, -"/daemon".length)}/catalog`;
37581
+ return endpoint;
37582
+ }
37583
+ const runtimePath = "/v1/runtimes/connect";
37584
+ if (endpoint.pathname.endsWith(runtimePath)) {
37585
+ endpoint.pathname = `${endpoint.pathname.slice(0, -runtimePath.length)}/channels/${encodeURIComponent(config2.channelId)}/catalog`;
37586
+ return endpoint;
37587
+ }
37588
+ throw new AgentCatalogPublishError("The Relay URL is invalid");
37589
+ }
37590
+ async function publishAgentCatalog(config2, signal) {
37591
+ signal.throwIfAborted();
37592
+ const timeoutSignal = AbortSignal.timeout(CATALOG_UPDATE_TIMEOUT_MILLISECONDS);
37593
+ const requestSignal = AbortSignal.any([signal, timeoutSignal]);
37594
+ let response;
37595
+ const catalog = config2.catalog.read();
37596
+ try {
37597
+ response = await fetch2(catalogEndpoint(config2), {
37598
+ body: JSON.stringify({
37599
+ agents: catalog.agents.map((agent) => ({
37600
+ agentPath: agent.agentIdentity.requestedPath,
37601
+ agentVersion: agent.agentVersion,
37602
+ agentSettingsDiscovery: true,
37603
+ capabilities: agent.capabilities,
37604
+ id: agent.id,
37605
+ label: agent.label,
37606
+ sessionTurnConfiguration: true
37607
+ })),
37608
+ installableAgents: catalog.installableAgents
37609
+ }),
37610
+ dispatcher: environmentProxyDispatcher,
37611
+ headers: { ...runtimeAuthorization(config2.relayUrl), "content-type": "application/json" },
37612
+ method: "PUT",
37613
+ signal: requestSignal
37614
+ });
37615
+ } catch (error62) {
37616
+ if (signal.aborted) {
37617
+ signal.throwIfAborted();
37618
+ }
37619
+ throw new AgentCatalogPublishError(
37620
+ timeoutSignal.aborted ? "The Agent catalog update timed out" : "The Agent catalog could not be updated",
37621
+ { cause: error62 }
37622
+ );
37623
+ }
37624
+ if (!response.ok) {
37625
+ throw await rejectedCatalogError(response);
37626
+ }
37627
+ await response.body?.cancel();
37628
+ }
37629
+
37630
+ // src/agent-catalog/resolve-catalog-agent.ts
37631
+ function createCatalogAgentResolver(discover, readConfig, publish) {
37632
+ const swaps = /* @__PURE__ */ new Map();
37633
+ return async (agent, signal) => {
37634
+ const config2 = readConfig();
37635
+ const pending = swaps.get(agent.id);
37636
+ if (pending !== void 0) {
37637
+ await pending;
37638
+ return config2.catalog.find(agent.id);
37639
+ }
37640
+ let release = () => void 0;
37641
+ const gate = new Promise((resolveGate) => {
37642
+ release = resolveGate;
37643
+ });
37644
+ swaps.set(agent.id, gate);
37645
+ try {
37646
+ if (await unchangedIdentity(agent, signal)) {
37647
+ return agent;
37648
+ }
37649
+ signal.throwIfAborted();
37650
+ const inventory = await discover(signal);
37651
+ signal.throwIfAborted();
37652
+ const previous = config2.catalog.read();
37653
+ const previousAgent = previous.agents.find((entry) => entry.id === agent.id);
37654
+ if (previousAgent === void 0) {
37655
+ throw new Error(`The local Agent ${agent.id} left the catalog before its refresh completed`);
37656
+ }
37657
+ config2.catalog.transition(
37658
+ [
37659
+ ...previous.agents.filter((entry) => entry.id !== agent.id),
37660
+ ...inventory.readyAgents().map((ready) => withDaemonEnvironment(ready, config2.localContext.environment))
37661
+ ],
37662
+ [...previous.installableAgents.filter((entry) => entry.id !== agent.id), ...inventory.installable]
37663
+ );
37664
+ try {
37665
+ await publish(config2, signal);
37666
+ } catch (error62) {
37667
+ config2.catalog.transition(previous.agents, previous.installableAgents);
37668
+ throw error62;
37669
+ }
37670
+ return config2.catalog.find(agent.id);
37671
+ } finally {
37672
+ swaps.delete(agent.id);
37673
+ release();
37674
+ }
37675
+ };
37676
+ }
37677
+ async function unchangedIdentity(agent, signal) {
37678
+ if (!await revalidateExecutable(agent.agentIdentity)) {
37679
+ return false;
37680
+ }
37681
+ signal.throwIfAborted();
37682
+ return agent.kind !== "acp-adapter-process" || await revalidateExecutable(agent.adapterIdentity);
37683
+ }
37684
+
37441
37685
  // src/storage/runtime-installation-store.ts
37442
37686
  import { createHash as createHash4, randomUUID as randomUUID3 } from "node:crypto";
37443
37687
  import { mkdir as mkdir5, open as open5, readdir as readdir3, rename as rename4, unlink, writeFile as writeFile4 } from "node:fs/promises";
37444
- import { dirname as dirname4, join as join16, resolve as resolve4 } from "node:path";
37688
+ import { dirname as dirname4, join as join18, resolve as resolve4 } from "node:path";
37445
37689
  var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
37446
37690
  var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
37447
37691
  var INSTALLATION_ID_PATTERN = /^min_[a-f0-9]{32}$/;
@@ -37505,7 +37749,7 @@ var VerifiedRuntimeConnection = class {
37505
37749
  this.runtimeId = runtimeId;
37506
37750
  }
37507
37751
  };
37508
- function isRecord9(value) {
37752
+ function isRecord10(value) {
37509
37753
  return typeof value === "object" && value !== null && !Array.isArray(value);
37510
37754
  }
37511
37755
  function hasExactKeys(value, expectedKeys) {
@@ -37578,7 +37822,7 @@ function channelIndexFileName(channelId) {
37578
37822
  return `mci_${createHash4("sha256").update(channelId).digest("hex")}.json`;
37579
37823
  }
37580
37824
  function decodeInstallationPointer(value) {
37581
- if (!isRecord9(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {
37825
+ if (!isRecord10(value) || !hasExactKeys(value, INSTALLATION_POINTER_KEYS) || value["version"] !== 1) {
37582
37826
  throw new RuntimeInstallationStoreError("invalid_installation", "The local installation record is invalid");
37583
37827
  }
37584
37828
  const storedInstallationId = value["installationId"];
@@ -37588,7 +37832,7 @@ function decodeInstallationPointer(value) {
37588
37832
  return { installationId: validateInstallationId(storedInstallationId) };
37589
37833
  }
37590
37834
  function decodeChannelIndex(value) {
37591
- if (!isRecord9(value) || !hasExactKeys(value, CHANNEL_INDEX_KEYS) || value["version"] !== 1) {
37835
+ if (!isRecord10(value) || !hasExactKeys(value, CHANNEL_INDEX_KEYS) || value["version"] !== 1) {
37592
37836
  throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
37593
37837
  }
37594
37838
  const applicationId = value["applicationId"];
@@ -37638,7 +37882,7 @@ function decodeVerifiedConnection(value) {
37638
37882
  );
37639
37883
  }
37640
37884
  function decodeConnection(value) {
37641
- if (!isRecord9(value)) {
37885
+ if (!isRecord10(value)) {
37642
37886
  throw new RuntimeInstallationStoreError("invalid_connection", "The saved Runtime connection is invalid");
37643
37887
  }
37644
37888
  return decodeVerifiedConnection(value);
@@ -37684,7 +37928,7 @@ async function readJsonFile(path2, signal, missingCode) {
37684
37928
  async function writeJsonAtomically(path2, value, signal) {
37685
37929
  signal.throwIfAborted();
37686
37930
  const directory = dirname4(path2);
37687
- const temporaryPath = join16(directory, `.${randomUUID3()}.tmp`);
37931
+ const temporaryPath = join18(directory, `.${randomUUID3()}.tmp`);
37688
37932
  try {
37689
37933
  await mkdir5(directory, { mode: 448, recursive: true });
37690
37934
  signal.throwIfAborted();
@@ -37710,14 +37954,14 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
37710
37954
  this.applicationId = applicationId;
37711
37955
  this.installationId = installationId2;
37712
37956
  this.stateDirectory = stateDirectory;
37713
- this.#channelDirectory = join16(stateDirectory, "channels");
37714
- this.#connectionDirectory = join16(stateDirectory, "connections");
37957
+ this.#channelDirectory = join18(stateDirectory, "channels");
37958
+ this.#connectionDirectory = join18(stateDirectory, "connections");
37715
37959
  }
37716
37960
  static open = async (options, signal) => {
37717
37961
  signal.throwIfAborted();
37718
37962
  const applicationId = validateApplicationId(options.applicationId);
37719
37963
  const rootDirectory = resolve4(options.stateDirectory);
37720
- const applicationDirectory = join16(rootDirectory, "installations", applicationId);
37964
+ const applicationDirectory = join18(rootDirectory, "installations", applicationId);
37721
37965
  try {
37722
37966
  await mkdir5(applicationDirectory, { mode: 448, recursive: true });
37723
37967
  } catch (cause) {
@@ -37730,7 +37974,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
37730
37974
  );
37731
37975
  }
37732
37976
  const storedInstallationId = await readOrCreateInstallationId(applicationDirectory, signal);
37733
- const stateDirectory = join16(applicationDirectory, storedInstallationId);
37977
+ const stateDirectory = join18(applicationDirectory, storedInstallationId);
37734
37978
  try {
37735
37979
  await mkdir5(stateDirectory, { mode: 448, recursive: true });
37736
37980
  } catch (cause) {
@@ -37745,8 +37989,8 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
37745
37989
  signal.throwIfAborted();
37746
37990
  return new _RuntimeInstallationStore(applicationId, storedInstallationId, stateDirectory);
37747
37991
  };
37748
- connectionPath = (connectionId2) => join16(this.#connectionDirectory, `${validateConnectionId(connectionId2)}.json`);
37749
- channelIndexPath = (channelId) => join16(this.#channelDirectory, channelIndexFileName(validateIdentifier(channelId, "invalid_channel_id")));
37992
+ connectionPath = (connectionId2) => join18(this.#connectionDirectory, `${validateConnectionId(connectionId2)}.json`);
37993
+ channelIndexPath = (channelId) => join18(this.#channelDirectory, channelIndexFileName(validateIdentifier(channelId, "invalid_channel_id")));
37750
37994
  readConnection = async (connectionId2, signal) => {
37751
37995
  const stored = decodeConnection(
37752
37996
  await readJsonFile(this.connectionPath(connectionId2), signal, "connection_not_found")
@@ -37908,7 +38152,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
37908
38152
  };
37909
38153
  };
37910
38154
  async function readOrCreateInstallationId(applicationDirectory, signal) {
37911
- const pointerPath = join16(applicationDirectory, "current.json");
38155
+ const pointerPath = join18(applicationDirectory, "current.json");
37912
38156
  try {
37913
38157
  return decodeInstallationPointer(await readJsonFile(pointerPath, signal, "installation_not_found")).installationId;
37914
38158
  } catch (cause) {
@@ -37956,7 +38200,7 @@ var PairingClientError = class extends Error {
37956
38200
  this.name = "PairingClientError";
37957
38201
  }
37958
38202
  };
37959
- function isRecord10(value) {
38203
+ function isRecord11(value) {
37960
38204
  return typeof value === "object" && value !== null && !Array.isArray(value);
37961
38205
  }
37962
38206
  function hasExactKeys2(value, expectedKeys) {
@@ -38049,8 +38293,8 @@ async function resolveDefaultWorkspace(path2) {
38049
38293
  const requestedWorkspace = resolve5(path2);
38050
38294
  try {
38051
38295
  await mkdir6(requestedWorkspace, { recursive: true, mode: 448 });
38052
- const defaultWorkspace = await realpath8(requestedWorkspace);
38053
- const metadata = await stat7(defaultWorkspace);
38296
+ const defaultWorkspace = await realpath9(requestedWorkspace);
38297
+ const metadata = await stat8(defaultWorkspace);
38054
38298
  if (!metadata.isDirectory()) {
38055
38299
  throw new PairingClientError("invalid_workspace", "The default workspace is not a directory");
38056
38300
  }
@@ -38079,9 +38323,9 @@ async function readJsonResponse(response) {
38079
38323
  }
38080
38324
  }
38081
38325
  function readRelayError(value) {
38082
- if (isRecord10(value)) {
38326
+ if (isRecord11(value)) {
38083
38327
  const error62 = value["error"];
38084
- if (isRecord10(error62)) {
38328
+ if (isRecord11(error62)) {
38085
38329
  const code = error62["code"];
38086
38330
  const message = error62["message"];
38087
38331
  if (typeof code === "string" && typeof message === "string") {
@@ -38092,7 +38336,7 @@ function readRelayError(value) {
38092
38336
  return new PairingClientError("pairing_failed", "The relay could not pair this machine");
38093
38337
  }
38094
38338
  function decodePairingResponse(value, credentialField, expectedKeys) {
38095
- if (!isRecord10(value) || !hasExactKeys2(value, expectedKeys)) {
38339
+ if (!isRecord11(value) || !hasExactKeys2(value, expectedKeys)) {
38096
38340
  throw new PairingClientError("invalid_relay_response", "The relay returned an invalid pairing response");
38097
38341
  }
38098
38342
  const appId = value["appId"];
@@ -38117,7 +38361,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
38117
38361
  const endpoint = options.pairingId.length > 0 ? mobiusApiUrl(options.relayOrigin, `/v1/runtime-pairings/${encodeURIComponent(options.pairingId)}/redeem`) : mobiusApiUrl(options.relayOrigin, "/pairings/claim");
38118
38362
  let response;
38119
38363
  try {
38120
- response = await fetch2(endpoint, {
38364
+ response = await fetch3(endpoint, {
38121
38365
  body: JSON.stringify({
38122
38366
  agents,
38123
38367
  installableAgents,
@@ -38149,20 +38393,30 @@ function buildPairedDaemon(installation, connection, defaultWorkspace, inventory
38149
38393
  const relayUrl = mobiusApiUrl(connection.relayOrigin, "/v1/runtimes/connect");
38150
38394
  relayUrl.protocol = relayUrl.protocol === "https:" ? "wss:" : "ws:";
38151
38395
  relayUrl.searchParams.set("token", connection.runtimeCredential);
38396
+ const config2 = createDaemonConfig(
38397
+ {
38398
+ defaultWorkspace,
38399
+ channelId: connection.channelId,
38400
+ relayUrl
38401
+ },
38402
+ inventory.readyAgents(),
38403
+ inventory.installable,
38404
+ localContext,
38405
+ new OpaqueDaemonReconnectTarget(connection.connectionId),
38406
+ createCatalogAgentResolver(
38407
+ (refreshSignal) => discoverLocalAgentInventory({
38408
+ defaultWorkspace,
38409
+ environment: localContext.environment,
38410
+ signal: refreshSignal
38411
+ }),
38412
+ () => config2,
38413
+ publishAgentCatalog
38414
+ )
38415
+ );
38152
38416
  return {
38153
38417
  channelUrl: new URL(`/channels/${encodeURIComponent(connection.channelId)}`, connection.relayOrigin).toString(),
38154
38418
  connectionId: connection.connectionId,
38155
- config: createDaemonConfig(
38156
- {
38157
- defaultWorkspace,
38158
- channelId: connection.channelId,
38159
- relayUrl
38160
- },
38161
- inventory.readyAgents(),
38162
- inventory.installable,
38163
- localContext,
38164
- new OpaqueDaemonReconnectTarget(connection.connectionId)
38165
- ),
38419
+ config: config2,
38166
38420
  connectionPath: installation.connectionPath(connection.connectionId)
38167
38421
  };
38168
38422
  }
@@ -38275,120 +38529,9 @@ function isRuntimeRelayRevocation(closeCode, closeReason) {
38275
38529
 
38276
38530
  // src/run-daemon.ts
38277
38531
  import { createHash as createHash8, randomUUID as randomUUID9 } from "node:crypto";
38278
- import { join as join19 } from "node:path";
38532
+ import { join as join21 } from "node:path";
38279
38533
  import { styleText } from "node:util";
38280
38534
 
38281
- // src/agent-catalog/publish-agent-catalog.ts
38282
- import { fetch as fetch3 } from "undici";
38283
-
38284
- // src/relay-connection/runtime-authentication.ts
38285
- function runtimeCredential(relayUrl) {
38286
- return relayUrl.searchParams.get("token") ?? "";
38287
- }
38288
- function runtimeAuthorization(relayUrl) {
38289
- const credential = runtimeCredential(relayUrl);
38290
- return credential.length === 0 ? {} : { authorization: `Bearer ${credential}` };
38291
- }
38292
- function relayHttpEndpoint(relayUrl) {
38293
- const endpoint = new URL(relayUrl);
38294
- endpoint.protocol = endpoint.protocol === "wss:" ? "https:" : "http:";
38295
- endpoint.search = "";
38296
- return endpoint;
38297
- }
38298
-
38299
- // src/agent-catalog/publish-agent-catalog.ts
38300
- var CATALOG_UPDATE_TIMEOUT_MILLISECONDS = 2e4;
38301
- var AgentCatalogPublishError = class extends Error {
38302
- code = "agent_catalog_update_failed";
38303
- diagnosticDetails;
38304
- constructor(message, options = {}, diagnosticDetails = {}) {
38305
- super(message, options);
38306
- this.diagnosticDetails = diagnosticDetails;
38307
- this.name = "AgentCatalogPublishError";
38308
- }
38309
- };
38310
- function isRecord11(value) {
38311
- return typeof value === "object" && value !== null && !Array.isArray(value);
38312
- }
38313
- function isSafeRelayErrorMessage(value) {
38314
- return value.length > 0 && value.length <= 512 && Array.from(value).every((character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127);
38315
- }
38316
- async function rejectedCatalogError(response) {
38317
- let value;
38318
- try {
38319
- value = await response.json();
38320
- } catch {
38321
- return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
38322
- }
38323
- if (!isRecord11(value) || !isRecord11(value["error"])) {
38324
- return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
38325
- }
38326
- const code = value["error"]["code"];
38327
- const message = value["error"]["message"];
38328
- if (typeof code !== "string" || !/^[a-z][a-z0-9_]{0,63}$/.test(code) || typeof message !== "string" || !isSafeRelayErrorMessage(message)) {
38329
- return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
38330
- }
38331
- return new AgentCatalogPublishError(
38332
- `The Relay rejected the Agent catalog update (${code}): ${message}`,
38333
- {},
38334
- {
38335
- relayErrorCode: code
38336
- }
38337
- );
38338
- }
38339
- function catalogEndpoint(config2) {
38340
- const endpoint = relayHttpEndpoint(config2.relayUrl);
38341
- if (endpoint.pathname.endsWith("/daemon")) {
38342
- endpoint.pathname = `${endpoint.pathname.slice(0, -"/daemon".length)}/catalog`;
38343
- return endpoint;
38344
- }
38345
- const runtimePath = "/v1/runtimes/connect";
38346
- if (endpoint.pathname.endsWith(runtimePath)) {
38347
- endpoint.pathname = `${endpoint.pathname.slice(0, -runtimePath.length)}/channels/${encodeURIComponent(config2.channelId)}/catalog`;
38348
- return endpoint;
38349
- }
38350
- throw new AgentCatalogPublishError("The Relay URL is invalid");
38351
- }
38352
- async function publishAgentCatalog(config2, signal) {
38353
- signal.throwIfAborted();
38354
- const timeoutSignal = AbortSignal.timeout(CATALOG_UPDATE_TIMEOUT_MILLISECONDS);
38355
- const requestSignal = AbortSignal.any([signal, timeoutSignal]);
38356
- let response;
38357
- const catalog = config2.catalog.read();
38358
- try {
38359
- response = await fetch3(catalogEndpoint(config2), {
38360
- body: JSON.stringify({
38361
- agents: catalog.agents.map((agent) => ({
38362
- agentPath: agent.agentIdentity.requestedPath,
38363
- agentVersion: agent.agentVersion,
38364
- agentSettingsDiscovery: true,
38365
- capabilities: agent.capabilities,
38366
- id: agent.id,
38367
- label: agent.label,
38368
- sessionTurnConfiguration: true
38369
- })),
38370
- installableAgents: catalog.installableAgents
38371
- }),
38372
- dispatcher: environmentProxyDispatcher,
38373
- headers: { ...runtimeAuthorization(config2.relayUrl), "content-type": "application/json" },
38374
- method: "PUT",
38375
- signal: requestSignal
38376
- });
38377
- } catch (error62) {
38378
- if (signal.aborted) {
38379
- signal.throwIfAborted();
38380
- }
38381
- throw new AgentCatalogPublishError(
38382
- timeoutSignal.aborted ? "The Agent catalog update timed out" : "The Agent catalog could not be updated",
38383
- { cause: error62 }
38384
- );
38385
- }
38386
- if (!response.ok) {
38387
- throw await rejectedCatalogError(response);
38388
- }
38389
- await response.body?.cancel();
38390
- }
38391
-
38392
38535
  // src/agent-installation/agent-installation-manager.ts
38393
38536
  var INSTALLATION_DEADLINE_MILLISECONDS = 10 * 60 * 1e3;
38394
38537
  var AgentInstallation = class {
@@ -38851,9 +38994,9 @@ var FixedInstallationExecutor = class {
38851
38994
  };
38852
38995
 
38853
38996
  // src/authorization/workspace-directory.ts
38854
- import { readdir as readdir4, realpath as realpath9, stat as stat8 } from "node:fs/promises";
38997
+ import { readdir as readdir4, realpath as realpath10, stat as stat9 } from "node:fs/promises";
38855
38998
  import { homedir as homedir2 } from "node:os";
38856
- import { basename as basename4, dirname as dirname5, isAbsolute as isAbsolute10, join as join17, normalize as normalize3, relative as relative4 } from "node:path";
38999
+ import { basename as basename4, dirname as dirname5, isAbsolute as isAbsolute10, join as join19, normalize as normalize3, relative as relative4 } from "node:path";
38857
39000
  var WorkspaceDirectoryListing = class {
38858
39001
  directoryId;
38859
39002
  directoryLabel;
@@ -38921,9 +39064,9 @@ var WorkspaceDirectoryService = class {
38921
39064
  throw new LocalAuthorizationError("The local directory path is invalid");
38922
39065
  }
38923
39066
  try {
38924
- const target = await realpath9(requested);
39067
+ const target = await realpath10(requested);
38925
39068
  signal.throwIfAborted();
38926
- const metadata = await stat8(target);
39069
+ const metadata = await stat9(target);
38927
39070
  signal.throwIfAborted();
38928
39071
  if (!isAbsolute10(target) || normalize3(target) !== target || !metadata.isDirectory()) {
38929
39072
  throw new LocalAuthorizationError("The selected location is not a directory");
@@ -38971,7 +39114,7 @@ var WorkspaceDirectoryService = class {
38971
39114
  continue;
38972
39115
  }
38973
39116
  try {
38974
- const path2 = await this.resolvePath(join17(target, child2.name), signal);
39117
+ const path2 = await this.resolvePath(join19(target, child2.name), signal);
38975
39118
  entries.push({ directoryId: encodePath(path2), name: child2.name });
38976
39119
  } catch (cause) {
38977
39120
  signal.throwIfAborted();
@@ -39007,15 +39150,15 @@ var WorkspaceDirectoryService = class {
39007
39150
 
39008
39151
  // src/daemon-diagnostic-log.ts
39009
39152
  import { appendFileSync, mkdirSync, readFileSync as readFileSync2, renameSync, statSync as statSync3, writeFileSync } from "node:fs";
39010
- import { join as join18 } from "node:path";
39153
+ import { join as join20 } from "node:path";
39011
39154
  var MAXIMUM_DAEMON_LOG_BYTES = 1 * 1024 * 1024;
39012
39155
  var DaemonDiagnosticLog = class {
39013
39156
  #directory;
39014
39157
  #path;
39015
39158
  #maximumBytes;
39016
39159
  constructor(stateDirectory, maximumBytes = MAXIMUM_DAEMON_LOG_BYTES) {
39017
- this.#directory = join18(stateDirectory, "logs");
39018
- this.#path = join18(this.#directory, "daemon.log");
39160
+ this.#directory = join20(stateDirectory, "logs");
39161
+ this.#path = join20(this.#directory, "daemon.log");
39019
39162
  this.#maximumBytes = maximumBytes;
39020
39163
  }
39021
39164
  // Export only correlation and failure metadata. Local messages and paths stay local.
@@ -40960,9 +41103,10 @@ var NativeSessionService = class {
40960
41103
  signal
40961
41104
  );
40962
41105
  signal.throwIfAborted();
41106
+ const cataloged = this.#config.catalog.find(command.agentId);
40963
41107
  const options = {
40964
41108
  additionalDirectories,
40965
- agent: this.#config.catalog.find(command.agentId),
41109
+ agent: this.#config.resolveAgent === void 0 ? cataloged : await this.#config.resolveAgent(cataloged, signal),
40966
41110
  cwd,
40967
41111
  sessionId: command.sessionId,
40968
41112
  signal
@@ -41140,7 +41284,7 @@ var NativeSessionService = class {
41140
41284
  sessionId: command.targetSessionId,
41141
41285
  additionalDirectories: target.additionalDirectories
41142
41286
  },
41143
- action === "fork" ? { kind: "fork", nativeSessionId: target.info.sessionId, title: title2 } : { kind: "import", nativeSessionId: target.info.sessionId }
41287
+ action === "fork" ? { kind: "fork", nativeSessionId: target.info.sessionId, title: title2 } : { kind: "import", nativeSessionId: target.info.sessionId, title: title2 }
41144
41288
  );
41145
41289
  signal.throwIfAborted();
41146
41290
  const ready = {
@@ -41514,7 +41658,7 @@ import { WebSocket as WebSocket5 } from "undici";
41514
41658
  // package.json
41515
41659
  var package_default = {
41516
41660
  name: "@moxt-ai/mobius",
41517
- version: "0.0.192",
41661
+ version: "0.0.194",
41518
41662
  description: "Mobius CLI for pairing and running local AI agent services.",
41519
41663
  type: "module",
41520
41664
  bin: {
@@ -41817,7 +41961,8 @@ function unsupportedModelIds(unsupportedModels) {
41817
41961
  return [...new Set(unsupportedModels.map((item) => item.requestedValue))];
41818
41962
  }
41819
41963
  async function discoverAgentSettings(command, config2, directories, sessions, signal) {
41820
- const agent = config2.catalog.find(command.agentId);
41964
+ const cataloged = config2.catalog.find(command.agentId);
41965
+ const agent = config2.resolveAgent === void 0 ? cataloged : await config2.resolveAgent(cataloged, signal);
41821
41966
  const cwd = await directories.resolve(config2.bindingId, "default", signal);
41822
41967
  const inspectedBaseSnapshot = await sessions.inspectAgentSettings({
41823
41968
  additionalDirectories: [],
@@ -41828,7 +41973,8 @@ async function discoverAgentSettings(command, config2, directories, sessions, si
41828
41973
  const baseSnapshot = {
41829
41974
  agentName: inspectedBaseSnapshot.agentName,
41830
41975
  agentVersion: inspectedBaseSnapshot.agentVersion,
41831
- configOptions: await discoverOpenCodeModelOptions(agent, cwd, inspectedBaseSnapshot.configOptions, signal)
41976
+ configOptions: await discoverOpenCodeModelOptions(agent, cwd, inspectedBaseSnapshot.configOptions, signal),
41977
+ modelEffort: inspectedBaseSnapshot.modelEffort
41832
41978
  };
41833
41979
  const baseModel = modelOption(baseSnapshot.configOptions);
41834
41980
  const unsupportedModels = [];
@@ -41868,6 +42014,7 @@ async function discoverAgentSettings(command, config2, directories, sessions, si
41868
42014
  baseSnapshot.configOptions,
41869
42015
  selectedSnapshot.configOptions,
41870
42016
  unsupportedModels,
42017
+ baseSnapshot.modelEffort,
41871
42018
  cwd,
41872
42019
  sessions,
41873
42020
  signal
@@ -41960,7 +42107,7 @@ function unavailableModelEffort() {
41960
42107
  valuesByModel: {}
41961
42108
  };
41962
42109
  }
41963
- async function discoverModelEffort(command, agent, resolution, initialOptions, selectedOptions, initiallyUnsupportedModels, cwd, sessions, signal) {
42110
+ async function discoverModelEffort(command, agent, resolution, initialOptions, selectedOptions, initiallyUnsupportedModels, discoveredModelEffort, cwd, sessions, signal) {
41964
42111
  const model = modelOption(initialOptions);
41965
42112
  const unsupportedModels = initiallyUnsupportedModels;
41966
42113
  if (resolution !== AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE && resolution !== AGENT_MODEL_EFFORT_RESOLUTION_ON_MODEL_SELECTION) {
@@ -41969,6 +42116,9 @@ async function discoverModelEffort(command, agent, resolution, initialOptions, s
41969
42116
  if (model === void 0 || model.type !== "select" || model.values.length === 0) {
41970
42117
  return { ...unavailableModelEffort(), unsupportedModelIds: unsupportedModelIds(unsupportedModels) };
41971
42118
  }
42119
+ if (resolution === AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE && discoveredModelEffort.kind === "complete" && discoveredModelEffort.value.resolution === AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE) {
42120
+ return discoveredModelEffort.value;
42121
+ }
41972
42122
  const inspectModel = async (modelValue) => (await sessions.inspectAgentSettings({
41973
42123
  additionalDirectories: [],
41974
42124
  agent,
@@ -42206,7 +42356,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
42206
42356
 
42207
42357
  // src/artifacts/local-file-streamer.ts
42208
42358
  import { createReadStream as createReadStream2 } from "node:fs";
42209
- import { realpath as realpath10, stat as stat9 } from "node:fs/promises";
42359
+ import { realpath as realpath11, stat as stat10 } from "node:fs/promises";
42210
42360
  import { basename as basename5, extname, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve7 } from "node:path";
42211
42361
  import { fileURLToPath as fileURLToPath2 } from "node:url";
42212
42362
  var CHUNK_BYTES = 192 * 1024;
@@ -42234,7 +42384,7 @@ async function resolveFile(value, workingDirectory, signal) {
42234
42384
  return null;
42235
42385
  }
42236
42386
  try {
42237
- const target = await realpath10(requested);
42387
+ const target = await realpath11(requested);
42238
42388
  signal.throwIfAborted();
42239
42389
  return isAbsolute11(target) && normalize4(target) === target ? target : null;
42240
42390
  } catch {
@@ -42248,7 +42398,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
42248
42398
  if (target === null) {
42249
42399
  throw new Error("The local file is unavailable");
42250
42400
  }
42251
- const before = await stat9(target);
42401
+ const before = await stat10(target);
42252
42402
  signal.throwIfAborted();
42253
42403
  if (!before.isFile() || before.size < 1 || before.size > command.maxBytes) {
42254
42404
  throw new Error("The local file is too large to read");
@@ -42276,7 +42426,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
42276
42426
  });
42277
42427
  sequence += 1;
42278
42428
  }
42279
- const after = await stat9(target);
42429
+ const after = await stat10(target);
42280
42430
  signal.throwIfAborted();
42281
42431
  if (after.size !== before.size || after.mtimeMs !== before.mtimeMs) {
42282
42432
  throw new Error("The local file changed during transfer");
@@ -42320,6 +42470,232 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
42320
42470
  return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
42321
42471
  }
42322
42472
 
42473
+ // src/daemon-session-commands.ts
42474
+ async function resolveCatalogAgent(config2, agentId, signal) {
42475
+ const agent = config2.catalog.find(agentId);
42476
+ return config2.resolveAgent === void 0 ? agent : await config2.resolveAgent(agent, signal);
42477
+ }
42478
+ async function prepareSession(command, recovery, config2, directories, audit, sessions, metrics, signal) {
42479
+ return await metrics.measure("prepare-total", async () => {
42480
+ const resolved = await metrics.measure(
42481
+ "workspace-resolve",
42482
+ async () => await resolveSessionDirectories(
42483
+ directories,
42484
+ config2.bindingId,
42485
+ command.directoryId,
42486
+ command.additionalDirectoryIds,
42487
+ signal
42488
+ )
42489
+ );
42490
+ const agent = await resolveCatalogAgent(config2, command.agentId, signal);
42491
+ const preparation = {
42492
+ additionalDirectories: resolved.additionalDirectories,
42493
+ agent,
42494
+ cwd: resolved.cwd,
42495
+ sessionId: command.sessionId,
42496
+ signal
42497
+ };
42498
+ const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : recovery.kind === "history-required" ? await sessions.restoreSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
42499
+ const configuration = command.configuration;
42500
+ const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
42501
+ "configuration",
42502
+ async () => await sessions.configureSession({
42503
+ ...preparation,
42504
+ booleanValue: configuration.booleanValue,
42505
+ configId: configuration.configId,
42506
+ requestId: command.requestId,
42507
+ value: configuration.value,
42508
+ valueType: configuration.valueType
42509
+ })
42510
+ );
42511
+ const listing = await metrics.measure(
42512
+ "workspace-list",
42513
+ async () => await directories.list(config2.bindingId, command.directoryId, signal)
42514
+ );
42515
+ audit.record({
42516
+ commandId: command.requestId,
42517
+ event: "session_prepared",
42518
+ sessionId: command.sessionId
42519
+ });
42520
+ if (command.configuration !== void 0) {
42521
+ audit.record({
42522
+ commandId: command.requestId,
42523
+ event: "session_configured",
42524
+ sessionId: command.sessionId
42525
+ });
42526
+ }
42527
+ return {
42528
+ additionalDirectories: resolved.additionalDirectoryEntries,
42529
+ agentId: command.agentId,
42530
+ agentName: prepared.agentName,
42531
+ agentVersion: prepared.agentVersion,
42532
+ capabilities: prepared.capabilities,
42533
+ commands: prepared.commands,
42534
+ configOptions,
42535
+ directoryId: command.directoryId,
42536
+ directoryLabel: listing.directoryLabel,
42537
+ kind: "session.ready",
42538
+ requestId: command.requestId,
42539
+ restored: prepared.restored,
42540
+ sessionId: command.sessionId
42541
+ };
42542
+ });
42543
+ }
42544
+ async function executeWorkspaceList(socket, command, directories, audit, signal) {
42545
+ try {
42546
+ const listing = await directories.list(command.bindingId, command.directoryId, signal);
42547
+ audit.record({
42548
+ commandId: command.requestId,
42549
+ event: "workspace_list_authorized",
42550
+ sessionId: "workspace-browser"
42551
+ });
42552
+ send(socket, {
42553
+ bindingId: command.bindingId,
42554
+ directoryId: listing.directoryId,
42555
+ directoryLabel: listing.directoryLabel,
42556
+ entries: listing.entries,
42557
+ kind: "workspace.entries",
42558
+ parentDirectoryId: listing.parentDirectoryId,
42559
+ requestId: command.requestId
42560
+ });
42561
+ } catch (error62) {
42562
+ reportOperationFailure(socket, command.requestId, "", error62);
42563
+ }
42564
+ }
42565
+ async function executeSessionPrepare(socket, command, config2, directories, audit, sessions, diagnostics, signal) {
42566
+ const metrics = new AccumulatingOperationMetrics();
42567
+ try {
42568
+ const readyEvent = await prepareSession(
42569
+ command,
42570
+ { kind: "interactive-only" },
42571
+ config2,
42572
+ directories,
42573
+ audit,
42574
+ sessions,
42575
+ metrics,
42576
+ signal
42577
+ );
42578
+ send(socket, {
42579
+ ...readyEvent,
42580
+ runtimeTimings: metrics.snapshot()
42581
+ });
42582
+ } catch (error62) {
42583
+ diagnostics.daemonDiagnostic(
42584
+ "session_prepare_failed",
42585
+ command.requestId,
42586
+ {
42587
+ agentId: command.agentId,
42588
+ code: operationErrorCode(error62),
42589
+ sessionId: command.sessionId
42590
+ },
42591
+ error62
42592
+ );
42593
+ audit.record({
42594
+ commandId: command.requestId,
42595
+ details: {
42596
+ agentId: command.agentId,
42597
+ code: operationErrorCode(error62)
42598
+ },
42599
+ event: "session_prepare_failed",
42600
+ sessionId: command.sessionId
42601
+ });
42602
+ reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
42603
+ }
42604
+ }
42605
+ async function executeSessionRestore(socket, command, config2, directories, audit, sessions, nativeSessions, diagnostics, signal) {
42606
+ const metrics = new AccumulatingOperationMetrics();
42607
+ try {
42608
+ const entry = await metrics.measure("session-lookup", async () => {
42609
+ const [found] = await nativeSessions.querySessions([command.sessionId], signal);
42610
+ if (found === void 0) {
42611
+ throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
42612
+ }
42613
+ return found;
42614
+ });
42615
+ const ready = await prepareSession(
42616
+ {
42617
+ additionalDirectoryIds: entry.additionalDirectories.map((directory) => directory.directoryId),
42618
+ agentId: entry.agentId,
42619
+ bindingId: config2.bindingId,
42620
+ directoryId: entry.directoryId,
42621
+ kind: "session.prepare",
42622
+ requestId: command.requestId,
42623
+ sessionId: command.sessionId,
42624
+ sessionState: "provisioned"
42625
+ },
42626
+ { kind: "history-required" },
42627
+ config2,
42628
+ directories,
42629
+ audit,
42630
+ sessions,
42631
+ metrics,
42632
+ signal
42633
+ );
42634
+ send(socket, {
42635
+ entry,
42636
+ kind: "session.restored",
42637
+ ready: { ...ready, runtimeTimings: metrics.snapshot() },
42638
+ requestId: command.requestId
42639
+ });
42640
+ } catch (error62) {
42641
+ diagnostics.daemonDiagnostic(
42642
+ "session_restore_failed",
42643
+ command.requestId,
42644
+ {
42645
+ code: operationErrorCode(error62),
42646
+ sessionId: command.sessionId
42647
+ },
42648
+ error62
42649
+ );
42650
+ audit.record({
42651
+ commandId: command.requestId,
42652
+ details: { code: operationErrorCode(error62) },
42653
+ event: "session_restore_failed",
42654
+ sessionId: command.sessionId
42655
+ });
42656
+ reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
42657
+ }
42658
+ }
42659
+ async function executeSessionConfigure(socket, command, config2, directories, audit, sessions, signal) {
42660
+ try {
42661
+ const resolved = await resolveSessionDirectories(
42662
+ directories,
42663
+ config2.bindingId,
42664
+ command.directoryId,
42665
+ command.additionalDirectoryIds,
42666
+ signal
42667
+ );
42668
+ const configOptions = await sessions.configureSession({
42669
+ additionalDirectories: resolved.additionalDirectories,
42670
+ agent: await resolveCatalogAgent(config2, command.agentId, signal),
42671
+ booleanValue: command.booleanValue,
42672
+ configId: command.configId,
42673
+ cwd: resolved.cwd,
42674
+ requestId: command.requestId,
42675
+ sessionId: command.sessionId,
42676
+ signal,
42677
+ value: command.value,
42678
+ valueType: command.valueType
42679
+ });
42680
+ audit.record({
42681
+ commandId: command.requestId,
42682
+ event: "session_configured",
42683
+ sessionId: command.sessionId
42684
+ });
42685
+ send(socket, {
42686
+ configOptions,
42687
+ kind: "session.config.updated",
42688
+ requestId: command.requestId,
42689
+ sessionId: command.sessionId
42690
+ });
42691
+ } catch (error62) {
42692
+ if (signal.aborted) {
42693
+ signal.throwIfAborted();
42694
+ }
42695
+ reportOperationFailure(socket, command.requestId, command.sessionId, error62);
42696
+ }
42697
+ }
42698
+
42323
42699
  // src/daemon-history-commands.ts
42324
42700
  async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, nativeSessions, eventLogV2, signal) {
42325
42701
  let agentId;
@@ -42338,7 +42714,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
42338
42714
  );
42339
42715
  const loadOptions = {
42340
42716
  additionalDirectories: resolved.additionalDirectories,
42341
- agent: config2.catalog.find(entry.agentId),
42717
+ agent: await resolveCatalogAgent(config2, entry.agentId, signal),
42342
42718
  cwd: resolved.cwd,
42343
42719
  sessionId: command.sessionId,
42344
42720
  signal
@@ -42414,7 +42790,7 @@ async function executeSessionPreviewHistoryPageLoad(socket, command, config2, di
42414
42790
  const replay = await sessions.previewNativeSessionEventsV2(
42415
42791
  {
42416
42792
  additionalDirectories: resolved.additionalDirectories,
42417
- agent: config2.catalog.find(command.agentId),
42793
+ agent: await resolveCatalogAgent(config2, command.agentId, signal),
42418
42794
  cwd: resolved.cwd,
42419
42795
  sessionId: command.sessionId,
42420
42796
  signal
@@ -42706,7 +43082,7 @@ async function executePrompt({
42706
43082
  command.additionalDirectoryIds,
42707
43083
  signal
42708
43084
  );
42709
- const agent = config2.catalog.find(command.agentId);
43085
+ const agent = await resolveCatalogAgent(config2, command.agentId, signal);
42710
43086
  const availability = await waitForSessionAvailability(signal);
42711
43087
  if (availability.kind === "busy") {
42712
43088
  throw new AcpExecutionError("Another prompt is already running in this conversation", {}, "session_busy");
@@ -42764,7 +43140,13 @@ async function executePrompt({
42764
43140
  }
42765
43141
  }
42766
43142
  const stream = activateAttempt();
42767
- const lifecycleV2 = eventLogV2.started(command.sessionId, command.commandId, attemptId, stream.epoch);
43143
+ const lifecycleV2 = eventLogV2.started(
43144
+ command.sessionId,
43145
+ command.commandId,
43146
+ attemptId,
43147
+ stream.epoch,
43148
+ availability.disposition
43149
+ );
42768
43150
  const attachments = await resolvePromptArtifacts(config2, command, signal);
42769
43151
  let stopReason;
42770
43152
  if (availability.disposition === SessionPromptDisposition.Steer) {
@@ -42845,228 +43227,6 @@ async function executePrompt({
42845
43227
  }
42846
43228
  }
42847
43229
 
42848
- // src/daemon-session-commands.ts
42849
- async function prepareSession(command, recovery, config2, directories, audit, sessions, metrics, signal) {
42850
- return await metrics.measure("prepare-total", async () => {
42851
- const resolved = await metrics.measure(
42852
- "workspace-resolve",
42853
- async () => await resolveSessionDirectories(
42854
- directories,
42855
- config2.bindingId,
42856
- command.directoryId,
42857
- command.additionalDirectoryIds,
42858
- signal
42859
- )
42860
- );
42861
- const agent = config2.catalog.find(command.agentId);
42862
- const preparation = {
42863
- additionalDirectories: resolved.additionalDirectories,
42864
- agent,
42865
- cwd: resolved.cwd,
42866
- sessionId: command.sessionId,
42867
- signal
42868
- };
42869
- const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : recovery.kind === "history-required" ? await sessions.restoreSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
42870
- const configuration = command.configuration;
42871
- const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
42872
- "configuration",
42873
- async () => await sessions.configureSession({
42874
- ...preparation,
42875
- booleanValue: configuration.booleanValue,
42876
- configId: configuration.configId,
42877
- requestId: command.requestId,
42878
- value: configuration.value,
42879
- valueType: configuration.valueType
42880
- })
42881
- );
42882
- const listing = await metrics.measure(
42883
- "workspace-list",
42884
- async () => await directories.list(config2.bindingId, command.directoryId, signal)
42885
- );
42886
- audit.record({
42887
- commandId: command.requestId,
42888
- event: "session_prepared",
42889
- sessionId: command.sessionId
42890
- });
42891
- if (command.configuration !== void 0) {
42892
- audit.record({
42893
- commandId: command.requestId,
42894
- event: "session_configured",
42895
- sessionId: command.sessionId
42896
- });
42897
- }
42898
- return {
42899
- additionalDirectories: resolved.additionalDirectoryEntries,
42900
- agentId: command.agentId,
42901
- agentName: prepared.agentName,
42902
- agentVersion: prepared.agentVersion,
42903
- capabilities: prepared.capabilities,
42904
- commands: prepared.commands,
42905
- configOptions,
42906
- directoryId: command.directoryId,
42907
- directoryLabel: listing.directoryLabel,
42908
- kind: "session.ready",
42909
- requestId: command.requestId,
42910
- restored: prepared.restored,
42911
- sessionId: command.sessionId
42912
- };
42913
- });
42914
- }
42915
- async function executeWorkspaceList(socket, command, directories, audit, signal) {
42916
- try {
42917
- const listing = await directories.list(command.bindingId, command.directoryId, signal);
42918
- audit.record({
42919
- commandId: command.requestId,
42920
- event: "workspace_list_authorized",
42921
- sessionId: "workspace-browser"
42922
- });
42923
- send(socket, {
42924
- bindingId: command.bindingId,
42925
- directoryId: listing.directoryId,
42926
- directoryLabel: listing.directoryLabel,
42927
- entries: listing.entries,
42928
- kind: "workspace.entries",
42929
- parentDirectoryId: listing.parentDirectoryId,
42930
- requestId: command.requestId
42931
- });
42932
- } catch (error62) {
42933
- reportOperationFailure(socket, command.requestId, "", error62);
42934
- }
42935
- }
42936
- async function executeSessionPrepare(socket, command, config2, directories, audit, sessions, diagnostics, signal) {
42937
- const metrics = new AccumulatingOperationMetrics();
42938
- try {
42939
- const readyEvent = await prepareSession(
42940
- command,
42941
- { kind: "interactive-only" },
42942
- config2,
42943
- directories,
42944
- audit,
42945
- sessions,
42946
- metrics,
42947
- signal
42948
- );
42949
- send(socket, {
42950
- ...readyEvent,
42951
- runtimeTimings: metrics.snapshot()
42952
- });
42953
- } catch (error62) {
42954
- diagnostics.daemonDiagnostic(
42955
- "session_prepare_failed",
42956
- command.requestId,
42957
- {
42958
- agentId: command.agentId,
42959
- code: operationErrorCode(error62),
42960
- sessionId: command.sessionId
42961
- },
42962
- error62
42963
- );
42964
- audit.record({
42965
- commandId: command.requestId,
42966
- details: {
42967
- agentId: command.agentId,
42968
- code: operationErrorCode(error62)
42969
- },
42970
- event: "session_prepare_failed",
42971
- sessionId: command.sessionId
42972
- });
42973
- reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
42974
- }
42975
- }
42976
- async function executeSessionRestore(socket, command, config2, directories, audit, sessions, nativeSessions, diagnostics, signal) {
42977
- const metrics = new AccumulatingOperationMetrics();
42978
- try {
42979
- const entry = await metrics.measure("session-lookup", async () => {
42980
- const [found] = await nativeSessions.querySessions([command.sessionId], signal);
42981
- if (found === void 0) {
42982
- throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
42983
- }
42984
- return found;
42985
- });
42986
- const ready = await prepareSession(
42987
- {
42988
- additionalDirectoryIds: entry.additionalDirectories.map((directory) => directory.directoryId),
42989
- agentId: entry.agentId,
42990
- bindingId: config2.bindingId,
42991
- directoryId: entry.directoryId,
42992
- kind: "session.prepare",
42993
- requestId: command.requestId,
42994
- sessionId: command.sessionId,
42995
- sessionState: "provisioned"
42996
- },
42997
- { kind: "history-required" },
42998
- config2,
42999
- directories,
43000
- audit,
43001
- sessions,
43002
- metrics,
43003
- signal
43004
- );
43005
- send(socket, {
43006
- entry,
43007
- kind: "session.restored",
43008
- ready: { ...ready, runtimeTimings: metrics.snapshot() },
43009
- requestId: command.requestId
43010
- });
43011
- } catch (error62) {
43012
- diagnostics.daemonDiagnostic(
43013
- "session_restore_failed",
43014
- command.requestId,
43015
- {
43016
- code: operationErrorCode(error62),
43017
- sessionId: command.sessionId
43018
- },
43019
- error62
43020
- );
43021
- audit.record({
43022
- commandId: command.requestId,
43023
- details: { code: operationErrorCode(error62) },
43024
- event: "session_restore_failed",
43025
- sessionId: command.sessionId
43026
- });
43027
- reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
43028
- }
43029
- }
43030
- async function executeSessionConfigure(socket, command, config2, directories, audit, sessions, signal) {
43031
- try {
43032
- const resolved = await resolveSessionDirectories(
43033
- directories,
43034
- config2.bindingId,
43035
- command.directoryId,
43036
- command.additionalDirectoryIds,
43037
- signal
43038
- );
43039
- const configOptions = await sessions.configureSession({
43040
- additionalDirectories: resolved.additionalDirectories,
43041
- agent: config2.catalog.find(command.agentId),
43042
- booleanValue: command.booleanValue,
43043
- configId: command.configId,
43044
- cwd: resolved.cwd,
43045
- requestId: command.requestId,
43046
- sessionId: command.sessionId,
43047
- signal,
43048
- value: command.value,
43049
- valueType: command.valueType
43050
- });
43051
- audit.record({
43052
- commandId: command.requestId,
43053
- event: "session_configured",
43054
- sessionId: command.sessionId
43055
- });
43056
- send(socket, {
43057
- configOptions,
43058
- kind: "session.config.updated",
43059
- requestId: command.requestId,
43060
- sessionId: command.sessionId
43061
- });
43062
- } catch (error62) {
43063
- if (signal.aborted) {
43064
- signal.throwIfAborted();
43065
- }
43066
- reportOperationFailure(socket, command.requestId, command.sessionId, error62);
43067
- }
43068
- }
43069
-
43070
43230
  // src/native-sessions/handle-native-requests.ts
43071
43231
  import { WebSocket as WebSocket4 } from "undici";
43072
43232
  function createNativeSessionRequestHandler(dependencies) {
@@ -44054,20 +44214,29 @@ var DaemonSessionEventLogV2 = class {
44054
44214
  this.#queued.set(command.commandId, {
44055
44215
  commandId: command.commandId,
44056
44216
  content: promptContent(command),
44217
+ ...command.disposition === void 0 ? {} : { disposition: command.disposition },
44057
44218
  context: {
44058
44219
  agentId: command.agentId,
44059
44220
  directoryId: command.directoryId,
44060
44221
  additionalDirectoryIds: command.additionalDirectoryIds
44061
44222
  },
44062
44223
  phase: "queued",
44063
- sessionId: command.sessionId
44224
+ sessionId: command.sessionId,
44225
+ ...command.targetCommandId.length === 0 ? {} : { targetCommandId: command.targetCommandId }
44064
44226
  });
44065
44227
  };
44066
- started = (sessionId, commandId, attemptId, epoch) => {
44228
+ started = (sessionId, commandId, attemptId, epoch, disposition) => {
44067
44229
  const request = this.#queued.get(commandId);
44068
44230
  if (request?.sessionId === sessionId) {
44069
44231
  this.#queued.set(commandId, { ...request, phase: "running" });
44070
- return { attemptId, content: request.content, epoch, context: request.context };
44232
+ return {
44233
+ attemptId,
44234
+ content: request.content,
44235
+ disposition,
44236
+ epoch,
44237
+ context: request.context,
44238
+ ...request.targetCommandId === void 0 ? {} : { targetCommandId: request.targetCommandId }
44239
+ };
44071
44240
  }
44072
44241
  throw new Error("The executing prompt was not registered in the V2 queue");
44073
44242
  };
@@ -44154,7 +44323,12 @@ var DaemonSessionEventLogV2 = class {
44154
44323
  }
44155
44324
  };
44156
44325
  promptRequestRecovery = (sessionId) => ({
44157
- queuedPromptRequests: [...this.#queued.values()].filter((request) => request.sessionId === sessionId && request.phase === "queued").map(({ commandId, content }) => ({ commandId, content }))
44326
+ queuedPromptRequests: [...this.#queued.values()].filter((request) => request.sessionId === sessionId && request.phase === "queued").map(({ commandId, content, disposition, targetCommandId }) => ({
44327
+ commandId,
44328
+ content,
44329
+ ...disposition === void 0 ? {} : { disposition },
44330
+ ...targetCommandId === void 0 ? {} : { targetCommandId }
44331
+ }))
44158
44332
  });
44159
44333
  };
44160
44334
 
@@ -44225,11 +44399,11 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
44225
44399
  stateDirectory
44226
44400
  });
44227
44401
  const channelHash = createHash8("sha256").update(config2.channelId).digest("hex");
44228
- const sessionDatabase = openAcpSessionDatabase(join19(stateDirectory, "sessions", `${channelHash}.sqlite`));
44402
+ const sessionDatabase = openAcpSessionDatabase(join21(stateDirectory, "sessions", `${channelHash}.sqlite`));
44229
44403
  let eventsV2;
44230
44404
  try {
44231
44405
  eventsV2 = new CachedAcpSessionEventStoreV2(
44232
- openSessionEventCacheV2Database(join19(stateDirectory, "sessions", `${channelHash}.events.sqlite`))
44406
+ openSessionEventCacheV2Database(join21(stateDirectory, "sessions", `${channelHash}.events.sqlite`))
44233
44407
  );
44234
44408
  } catch (error62) {
44235
44409
  sessionDatabase.close();
@@ -44432,7 +44606,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
44432
44606
  }
44433
44607
 
44434
44608
  // src/runtime.ts
44435
- import { mkdir as mkdir7, realpath as realpath11, stat as stat10 } from "node:fs/promises";
44609
+ import { mkdir as mkdir7, realpath as realpath12, stat as stat11 } from "node:fs/promises";
44436
44610
  import { resolve as resolve8 } from "node:path";
44437
44611
  var RUNTIME_CREDENTIAL_PATTERN2 = /^[a-zA-Z0-9_-]{32,256}$/;
44438
44612
  var MobiusRuntimeConfigurationError = class extends Error {
@@ -44499,8 +44673,8 @@ async function resolveWorkspace(path2) {
44499
44673
  const requested = resolve8(path2);
44500
44674
  try {
44501
44675
  await mkdir7(requested, { recursive: true, mode: 448 });
44502
- const resolved = await realpath11(requested);
44503
- const metadata = await stat10(resolved);
44676
+ const resolved = await realpath12(requested);
44677
+ const metadata = await stat11(resolved);
44504
44678
  if (!metadata.isDirectory()) {
44505
44679
  throw new MobiusRuntimeConfigurationError("The Runtime workspace is not a directory");
44506
44680
  }
@@ -44517,26 +44691,35 @@ async function createMobiusRuntimeEngine(connection, signal, environment = proce
44517
44691
  const localContext = new DaemonLocalContext(readStateDirectory(environment), environment);
44518
44692
  const relayUrl = relayUrlFromConnection(connection);
44519
44693
  const defaultWorkspace = await resolveWorkspace(connection.defaultWorkspace);
44520
- const inventory = await discoverLocalAgentInventory({
44694
+ const specifications = supportedLocalAgentSpecifications();
44695
+ const discoveryEnvironment = localContext.environment;
44696
+ const discover = async (refreshSignal) => await discoverLocalAgentInventory({
44521
44697
  defaultWorkspace,
44522
- environment: localContext.environment,
44523
- signal
44698
+ environment: discoveryEnvironment,
44699
+ signal: refreshSignal,
44700
+ specifications
44524
44701
  });
44702
+ const inventory = await discover(signal);
44525
44703
  if (inventory.available.length + inventory.installable.length === 0) {
44526
44704
  throw new MobiusRuntimeConfigurationError("No supported Agent is available for the local Runtime");
44527
44705
  }
44528
- return new MobiusRuntimeEngine(
44529
- createDaemonConfig(
44530
- {
44531
- channelId: connection.channelId,
44532
- defaultWorkspace,
44533
- relayUrl
44534
- },
44535
- inventory.readyAgents(),
44536
- inventory.installable,
44537
- localContext
44706
+ const config2 = createDaemonConfig(
44707
+ {
44708
+ channelId: connection.channelId,
44709
+ defaultWorkspace,
44710
+ relayUrl
44711
+ },
44712
+ inventory.readyAgents(),
44713
+ inventory.installable,
44714
+ localContext,
44715
+ null,
44716
+ createCatalogAgentResolver(
44717
+ (refreshSignal) => discover(refreshSignal),
44718
+ () => config2,
44719
+ publishAgentCatalog
44538
44720
  )
44539
44721
  );
44722
+ return new MobiusRuntimeEngine(config2);
44540
44723
  }
44541
44724
  var MobiusRuntimeEngine = class {
44542
44725
  #config;