@moxt-ai/mobius 0.0.438 → 0.0.440

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 (52) hide show
  1. package/dist/{chunk-INF4TYV5.js → chunk-CDY4OZQN.js} +575 -243
  2. package/dist/{chunk-INF4TYV5.js.map → chunk-CDY4OZQN.js.map} +4 -4
  3. package/dist/{chunk-XKWYAXD7.js → chunk-SABVCCTQ.js} +2 -2
  4. package/dist/{chunk-XKWYAXD7.js.map → chunk-SABVCCTQ.js.map} +1 -1
  5. package/dist/{cli-UWIJRRRY.js → cli-R4RCIINT.js} +3 -3
  6. package/dist/cli.js +2 -2
  7. package/dist/engine/runtime/catalog/handle-agent-catalog-discovery.d.ts +1 -0
  8. package/dist/engine/runtime/catalog/handle-agent-catalog-discovery.d.ts.map +1 -1
  9. package/dist/engine/runtime/catalog/handle-agent-catalog-discovery.js +2 -1
  10. package/dist/engine/runtime/catalog/handle-agent-catalog-discovery.js.map +1 -1
  11. package/dist/engine/runtime/command/agent-settings-discovery.d.ts +2 -0
  12. package/dist/engine/runtime/command/agent-settings-discovery.d.ts.map +1 -1
  13. package/dist/engine/runtime/command/agent-settings-discovery.js +6 -3
  14. package/dist/engine/runtime/command/agent-settings-discovery.js.map +1 -1
  15. package/dist/engine/runtime/command/context.d.ts +2 -0
  16. package/dist/engine/runtime/command/context.d.ts.map +1 -1
  17. package/dist/engine/runtime/command/registry/agent-catalog.d.ts.map +1 -1
  18. package/dist/engine/runtime/command/registry/agent-catalog.js +1 -0
  19. package/dist/engine/runtime/command/registry/agent-catalog.js.map +1 -1
  20. package/dist/engine/runtime/command/registry/agent-settings.d.ts.map +1 -1
  21. package/dist/engine/runtime/command/registry/agent-settings.js +1 -0
  22. package/dist/engine/runtime/command/registry/agent-settings.js.map +1 -1
  23. package/dist/engine/runtime/relay/run-relay-connection.d.ts +3 -1
  24. package/dist/engine/runtime/relay/run-relay-connection.d.ts.map +1 -1
  25. package/dist/engine/runtime/relay/run-relay-connection.js +2 -1
  26. package/dist/engine/runtime/relay/run-relay-connection.js.map +1 -1
  27. package/dist/engine/runtime/run.d.ts.map +1 -1
  28. package/dist/engine/runtime/run.js +3 -0
  29. package/dist/engine/runtime/run.js.map +1 -1
  30. package/dist/engine/session/manager/session-manager.d.ts +2 -6
  31. package/dist/engine/session/manager/session-manager.d.ts.map +1 -1
  32. package/dist/engine/session/manager/session-manager.js +68 -28
  33. package/dist/engine/session/manager/session-manager.js.map +1 -1
  34. package/dist/engine/session/settings/agent-settings-cache.d.ts +19 -0
  35. package/dist/engine/session/settings/agent-settings-cache.d.ts.map +1 -0
  36. package/dist/engine/session/settings/agent-settings-cache.js +167 -0
  37. package/dist/engine/session/settings/agent-settings-cache.js.map +1 -0
  38. package/dist/engine/session/settings/discover-agent-settings.d.ts +2 -1
  39. package/dist/engine/session/settings/discover-agent-settings.d.ts.map +1 -1
  40. package/dist/engine/session/settings/discover-agent-settings.js +121 -95
  41. package/dist/engine/session/settings/discover-agent-settings.js.map +1 -1
  42. package/dist/engine/storage/files/local-files.d.ts +4 -0
  43. package/dist/engine/storage/files/local-files.d.ts.map +1 -1
  44. package/dist/engine/storage/files/local-files.js +7 -1
  45. package/dist/engine/storage/files/local-files.js.map +1 -1
  46. package/dist/engine/storage/installation/installation-files.d.ts +1 -1
  47. package/dist/engine/storage/installation/installation-files.d.ts.map +1 -1
  48. package/dist/engine/storage/installation/installation-files.js +2 -2
  49. package/dist/engine/storage/installation/installation-files.js.map +1 -1
  50. package/dist/engine.js +2 -2
  51. package/package.json +1 -1
  52. /package/dist/{cli-UWIJRRRY.js.map → cli-R4RCIINT.js.map} +0 -0
@@ -3,7 +3,7 @@ import {
3
3
  __export,
4
4
  __using,
5
5
  package_default
6
- } from "./chunk-XKWYAXD7.js";
6
+ } from "./chunk-SABVCCTQ.js";
7
7
 
8
8
  // src/engine/runtime/relay/runtime-revocation.ts
9
9
  var runtimeRevocationCloseCode = 1008;
@@ -20291,6 +20291,7 @@ var sessionConfigUpdatedEventSchema = external_exports.object({
20291
20291
  sessionId: identifierStringSchema
20292
20292
  }).readonly();
20293
20293
  var decodeSessionConfigurationSelections = (value) => decodeZodValue(value, sessionConfigurationSelectionsSchema);
20294
+ var decodeSessionConfigOptions = (value) => decodeZodValue(value, sessionConfigOptionsSchema);
20294
20295
  var decodeSessionConfigureCommand = (encoded) => decodeZodMessage(encoded, sessionConfigureCommandSchema);
20295
20296
  var encodeSessionConfigureCommand = (message) => encodeZodMessage(message, sessionConfigureCommandSchema);
20296
20297
  var decodeSessionConfigUpdatedEvent = (encoded) => decodeZodMessage(encoded, sessionConfigUpdatedEventSchema);
@@ -22073,7 +22074,9 @@ function encodeDaemonToServiceMessage(message) {
22073
22074
 
22074
22075
  // src/engine/storage/files/local-files.ts
22075
22076
  import { createReadStream } from "node:fs";
22076
- import { mkdir, open as open2, readdir, readFile, realpath, stat } from "node:fs/promises";
22077
+ import { mkdir, mkdtemp, open as open2, readdir, readFile, realpath, rm, stat } from "node:fs/promises";
22078
+ import { tmpdir } from "node:os";
22079
+ import { join } from "node:path";
22077
22080
  function entryKind(entry) {
22078
22081
  if (entry.isDirectory()) {
22079
22082
  return "directory";
@@ -22108,6 +22111,10 @@ async function listDirectory(path6) {
22108
22111
  const entries = await readdir(path6, { withFileTypes: true });
22109
22112
  return entries.map((entry) => ({ kind: entryKind(entry), name: entry.name }));
22110
22113
  }
22114
+ async function createTemporaryDirectory(prefix) {
22115
+ const path6 = await mkdtemp(join(tmpdir(), prefix));
22116
+ return { path: path6, dispose: async () => await rm(path6, { recursive: true, force: true }) };
22117
+ }
22111
22118
  async function ensurePrivateDirectory(path6) {
22112
22119
  await mkdir(path6, { mode: 448, recursive: true });
22113
22120
  }
@@ -22135,8 +22142,8 @@ function readFileChunks(path6, chunkBytes, signal) {
22135
22142
 
22136
22143
  // src/engine/storage/installation/installation-files.ts
22137
22144
  import { createHash, randomUUID } from "node:crypto";
22138
- import { link, mkdir as mkdir2, open as open3, readdir as readdir2, rename, rm, unlink, writeFile } from "node:fs/promises";
22139
- import { dirname, join } from "node:path";
22145
+ import { link, mkdir as mkdir2, open as open3, readdir as readdir2, rename, rm as rm2, unlink, writeFile } from "node:fs/promises";
22146
+ import { dirname, join as join2 } from "node:path";
22140
22147
 
22141
22148
  // src/engine/util/node-error.ts
22142
22149
  function isNodeError(error62, code) {
@@ -22146,22 +22153,22 @@ function isNodeError(error62, code) {
22146
22153
  // src/engine/storage/installation/installation-files.ts
22147
22154
  var MAXIMUM_FILE_BYTES = 16 * 1024;
22148
22155
  function installationPointerPath(engineDataDir) {
22149
- return join(engineDataDir, "current.json");
22156
+ return join2(engineDataDir, "current.json");
22150
22157
  }
22151
22158
  var installationDirectorySchema = external_exports.string().brand();
22152
22159
  function installationDirectory(engineDataDir, installationId2) {
22153
- return installationDirectorySchema.parse(join(engineDataDir, installationId2));
22160
+ return installationDirectorySchema.parse(join2(engineDataDir, installationId2));
22154
22161
  }
22155
22162
  function connectionDirectory(installationDirectory2) {
22156
- return join(installationDirectory2, "connections");
22163
+ return join2(installationDirectory2, "connections");
22157
22164
  }
22158
22165
  function connectionFilePath(connectionDirectory2, connectionId2) {
22159
- return join(connectionDirectory2, `${connectionId2}.json`);
22166
+ return join2(connectionDirectory2, `${connectionId2}.json`);
22160
22167
  }
22161
22168
  function channelIndexFilePath(installationDirectory2, channelId) {
22162
- return join(installationDirectory2, "channels", `mci_${createHash("sha256").update(channelId).digest("hex")}.json`);
22169
+ return join2(installationDirectory2, "channels", `mci_${createHash("sha256").update(channelId).digest("hex")}.json`);
22163
22170
  }
22164
- async function readInstallationFile(path6) {
22171
+ async function readInstallationFile(path6, maximumBytes = MAXIMUM_FILE_BYTES) {
22165
22172
  let handle;
22166
22173
  try {
22167
22174
  handle = await open3(path6, "r");
@@ -22170,7 +22177,7 @@ async function readInstallationFile(path6) {
22170
22177
  }
22171
22178
  try {
22172
22179
  const metadata = await handle.stat();
22173
- if (!metadata.isFile() || metadata.size > MAXIMUM_FILE_BYTES) {
22180
+ if (!metadata.isFile() || metadata.size > maximumBytes) {
22174
22181
  return { kind: "not-a-small-file" };
22175
22182
  }
22176
22183
  return { kind: "read", text: await handle.readFile({ encoding: "utf8" }) };
@@ -22181,7 +22188,7 @@ async function readInstallationFile(path6) {
22181
22188
  async function writeInstallationFile(path6, text2, signal) {
22182
22189
  signal.throwIfAborted();
22183
22190
  const directory = dirname(path6);
22184
- const temporaryPath = join(directory, `.${randomUUID()}.tmp`);
22191
+ const temporaryPath = join2(directory, `.${randomUUID()}.tmp`);
22185
22192
  try {
22186
22193
  await mkdir2(directory, { mode: 448, recursive: true });
22187
22194
  signal.throwIfAborted();
@@ -22194,12 +22201,12 @@ async function writeInstallationFile(path6, text2, signal) {
22194
22201
  }
22195
22202
  }
22196
22203
  async function createInstallationFile(path6, text2) {
22197
- const temporaryPath = join(dirname(path6), `.${randomUUID()}.tmp`);
22204
+ const temporaryPath = join2(dirname(path6), `.${randomUUID()}.tmp`);
22198
22205
  try {
22199
22206
  await writeFile(temporaryPath, text2, { flag: "wx", mode: 384 });
22200
22207
  await link(temporaryPath, path6);
22201
22208
  } finally {
22202
- await rm(temporaryPath, { force: true });
22209
+ await rm2(temporaryPath, { force: true });
22203
22210
  }
22204
22211
  }
22205
22212
  async function listInstallationFiles(directory) {
@@ -22213,12 +22220,12 @@ async function removeInstallationFile(path6) {
22213
22220
  import { lstat as lstat2 } from "node:fs/promises";
22214
22221
 
22215
22222
  // src/engine/util/platform/linux.ts
22216
- import { isAbsolute, join as join3 } from "node:path";
22223
+ import { isAbsolute, join as join4 } from "node:path";
22217
22224
 
22218
22225
  // src/engine/util/platform/posix.ts
22219
22226
  import { chmod, lstat, unlink as unlink2 } from "node:fs/promises";
22220
- import { tmpdir } from "node:os";
22221
- import { join as join2 } from "node:path";
22227
+ import { tmpdir as tmpdir2 } from "node:os";
22228
+ import { join as join3 } from "node:path";
22222
22229
 
22223
22230
  // src/engine/util/filesystem/path-error.ts
22224
22231
  var LocalPathError = class extends Error {
@@ -22240,7 +22247,7 @@ async function removeControlSocket(path6) {
22240
22247
  }
22241
22248
  }
22242
22249
  var posixOperations = {
22243
- controlSocketPath: (installationHash) => join2(tmpdir(), `mobius-${installationHash}.sock`),
22250
+ controlSocketPath: (installationHash) => join3(tmpdir2(), `mobius-${installationHash}.sock`),
22244
22251
  prepareControlSocket: removeControlSocket,
22245
22252
  secureControlSocket: async (path6) => {
22246
22253
  await chmod(path6, 384);
@@ -22264,16 +22271,16 @@ var linuxPlatform = {
22264
22271
  ...posixOperations,
22265
22272
  claudeCodeExecutablePaths: (environment) => {
22266
22273
  const homeDirectory = environment["HOME"];
22267
- return homeDirectory !== void 0 && isAbsolute(homeDirectory) ? [join3(homeDirectory, ".local", "bin", "claude")] : [];
22274
+ return homeDirectory !== void 0 && isAbsolute(homeDirectory) ? [join4(homeDirectory, ".local", "bin", "claude")] : [];
22268
22275
  }
22269
22276
  };
22270
22277
 
22271
22278
  // src/engine/util/platform/macos.ts
22272
- import { isAbsolute as isAbsolute2, join as join5 } from "node:path";
22279
+ import { isAbsolute as isAbsolute2, join as join6 } from "node:path";
22273
22280
 
22274
22281
  // src/engine/util/platform/claude-desktop.ts
22275
22282
  import { readdirSync } from "node:fs";
22276
- import { join as join4 } from "node:path";
22283
+ import { join as join5 } from "node:path";
22277
22284
  function installedDirectories(directory) {
22278
22285
  try {
22279
22286
  return readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
@@ -22289,14 +22296,14 @@ function claudeDesktopExecutablePaths(roots, executablePaths) {
22289
22296
  for (const root of roots) {
22290
22297
  const versions = installedDirectories(root).filter((version3) => /^\d+\.\d+\.\d+$/.test(version3)).toSorted((left, right) => right.localeCompare(left, "en", { numeric: true }));
22291
22298
  for (const version3 of versions) {
22292
- const directory = join4(root, version3);
22299
+ const directory = join5(root, version3);
22293
22300
  const installations = [
22294
22301
  directory,
22295
- ...installedDirectories(directory).map((build) => join4(directory, build))
22302
+ ...installedDirectories(directory).map((build) => join5(directory, build))
22296
22303
  ];
22297
22304
  for (const installation of installations) {
22298
22305
  for (const executablePath of executablePaths) {
22299
- paths.push(join4(installation, ...executablePath));
22306
+ paths.push(join5(installation, ...executablePath));
22300
22307
  }
22301
22308
  }
22302
22309
  }
@@ -22311,10 +22318,10 @@ var macosPlatform = {
22311
22318
  const paths = ["/opt/homebrew/bin/claude", "/usr/local/bin/claude"];
22312
22319
  const homeDirectory = environment["HOME"];
22313
22320
  if (homeDirectory !== void 0 && isAbsolute2(homeDirectory)) {
22314
- paths.unshift(join5(homeDirectory, ".local", "bin", "claude"));
22321
+ paths.unshift(join6(homeDirectory, ".local", "bin", "claude"));
22315
22322
  paths.push(
22316
22323
  ...claudeDesktopExecutablePaths(
22317
- [join5(homeDirectory, "Library", "Application Support", "Claude", "claude-code")],
22324
+ [join6(homeDirectory, "Library", "Application Support", "Claude", "claude-code")],
22318
22325
  [["claude.app", "Contents", "MacOS", "claude"], ["claude"]]
22319
22326
  )
22320
22327
  );
@@ -22325,7 +22332,7 @@ var macosPlatform = {
22325
22332
 
22326
22333
  // src/engine/util/platform/windows.ts
22327
22334
  import { execFile } from "node:child_process";
22328
- import { isAbsolute as isAbsolute3, join as join6 } from "node:path";
22335
+ import { isAbsolute as isAbsolute3, join as join7 } from "node:path";
22329
22336
  import { promisify } from "node:util";
22330
22337
  var execute = promisify(execFile);
22331
22338
  function environmentValue(environment, name2) {
@@ -22335,16 +22342,16 @@ function desktopClaudeExecutablePaths(environment) {
22335
22342
  const roots = [];
22336
22343
  const localAppData = environmentValue(environment, "LOCALAPPDATA");
22337
22344
  if (localAppData !== void 0 && isAbsolute3(localAppData)) {
22338
- const dataDirectory = join6(localAppData, "Claude-Data");
22345
+ const dataDirectory = join7(localAppData, "Claude-Data");
22339
22346
  for (const installation of installedDirectories(dataDirectory)) {
22340
22347
  if (installation.startsWith("claude_")) {
22341
- roots.push(join6(dataDirectory, installation, "claude-code"));
22348
+ roots.push(join7(dataDirectory, installation, "claude-code"));
22342
22349
  }
22343
22350
  }
22344
22351
  }
22345
22352
  const appData = environmentValue(environment, "APPDATA");
22346
22353
  if (appData !== void 0 && isAbsolute3(appData)) {
22347
- roots.push(join6(appData, "Claude", "claude-code"));
22354
+ roots.push(join7(appData, "Claude", "claude-code"));
22348
22355
  }
22349
22356
  return claudeDesktopExecutablePaths(roots, [["claude.exe"]]);
22350
22357
  }
@@ -22380,7 +22387,7 @@ async function validatePathPermissions(path6, _directory, privateAccess, signal)
22380
22387
  }
22381
22388
  try {
22382
22389
  await execute(
22383
- join6(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
22390
+ join7(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
22384
22391
  [
22385
22392
  "-NoLogo",
22386
22393
  "-NoProfile",
@@ -22418,11 +22425,11 @@ var windowsPlatform = {
22418
22425
  const paths = [];
22419
22426
  const userProfile = environmentValue(environment, "USERPROFILE");
22420
22427
  if (userProfile !== void 0 && isAbsolute3(userProfile)) {
22421
- paths.push(join6(userProfile, ".local", "bin", "claude.exe"));
22428
+ paths.push(join7(userProfile, ".local", "bin", "claude.exe"));
22422
22429
  }
22423
22430
  const localAppData = environmentValue(environment, "LOCALAPPDATA");
22424
22431
  if (localAppData !== void 0 && isAbsolute3(localAppData)) {
22425
- paths.push(join6(localAppData, "Microsoft", "WinGet", "Links", "claude.exe"));
22432
+ paths.push(join7(localAppData, "Microsoft", "WinGet", "Links", "claude.exe"));
22426
22433
  }
22427
22434
  paths.push(...desktopClaudeExecutablePaths(environment));
22428
22435
  return paths;
@@ -52719,7 +52726,7 @@ var JC = class {
52719
52726
  function nm(e) {
52720
52727
  return typeof e === "number" && Number.isInteger(e) && e > 0 ? e : void 0;
52721
52728
  }
52722
- var rm3 = /* @__PURE__ */ Symbol("suppressControlResponse");
52729
+ var rm4 = /* @__PURE__ */ Symbol("suppressControlResponse");
52723
52730
  var Gy = class _Gy {
52724
52731
  transport;
52725
52732
  isSingleUserTurn;
@@ -52924,7 +52931,7 @@ var Gy = class _Gy {
52924
52931
  try {
52925
52932
  let n = await this.processControlRequest(e, t.signal);
52926
52933
  if (this.cleanupPerformed) return;
52927
- if (n === rm3) return;
52934
+ if (n === rm4) return;
52928
52935
  let r = { type: "control_response", response: { subtype: "success", request_id: e.request_id, response: n } };
52929
52936
  await Promise.resolve(this.transport.write(me(r) + `
52930
52937
  `));
@@ -52949,7 +52956,7 @@ var Gy = class _Gy {
52949
52956
  if (e.request.subtype === "can_use_tool") {
52950
52957
  if (!this.canUseTool) throw Error("canUseTool callback is not provided.");
52951
52958
  let n = await this.canUseTool(e.request.tool_name, e.request.input, { signal: t, suggestions: e.request.permission_suggestions, blockedPath: e.request.blocked_path, decisionReason: e.request.decision_reason, title: e.request.title, displayName: e.request.display_name, description: e.request.description, toolUseID: e.request.tool_use_id, agentID: e.request.agent_id, requestId: e.request_id, ...e.request.matched_ask_rule && { matchedAskRule: { source: e.request.matched_ask_rule.source, toolName: e.request.matched_ask_rule.tool_name, ...e.request.matched_ask_rule.rule_content !== void 0 && { ruleContent: e.request.matched_ask_rule.rule_content } } } });
52952
- if (n === null) return rm3;
52959
+ if (n === null) return rm4;
52953
52960
  return { ...n, toolUseID: e.request.tool_use_id };
52954
52961
  } else if (e.request.subtype === "hook_callback") return await this.handleHookCallbacks(e.request.callback_id, e.request.input, e.request.tool_use_id, t);
52955
52962
  else if (e.request.subtype === "mcp_message") {
@@ -52964,17 +52971,17 @@ var Gy = class _Gy {
52964
52971
  let n = e.request;
52965
52972
  if (this.onElicitation) {
52966
52973
  let r = await this.onElicitation({ serverName: n.mcp_server_name, message: n.message, mode: n.mode, url: n.url, elicitationId: n.elicitation_id, requestedSchema: n.requested_schema, title: n.title, displayName: n.display_name, description: n.description }, { signal: t, requestId: e.request_id });
52967
- if (r === null) return rm3;
52974
+ if (r === null) return rm4;
52968
52975
  return r;
52969
52976
  }
52970
52977
  return { action: "decline" };
52971
52978
  } else if (e.request.subtype === "request_user_dialog") {
52972
52979
  if (this.onUserDialog) {
52973
52980
  let n = await this.onUserDialog({ dialogKind: e.request.dialog_kind, payload: e.request.payload, toolUseID: e.request.tool_use_id }, { signal: t, requestId: e.request_id });
52974
- if (n === null) return rm3;
52981
+ if (n === null) return rm4;
52975
52982
  return n;
52976
52983
  }
52977
- return ce(`[Query] No onUserDialog handler for request_user_dialog (kind=${e.request.dialog_kind}) \u2014 staying silent so a capable client (or the worker's park deadline) settles it`), Li("tengu_request_user_dialog_response_ignored", { shape: yi("auto_cancel") }), rm3;
52984
+ return ce(`[Query] No onUserDialog handler for request_user_dialog (kind=${e.request.dialog_kind}) \u2014 staying silent so a capable client (or the worker's park deadline) settles it`), Li("tengu_request_user_dialog_response_ignored", { shape: yi("auto_cancel") }), rm4;
52978
52985
  } else if (e.request.subtype === "oauth_token_refresh") {
52979
52986
  if (!this.getOAuthToken) throw Error("getOAuthToken callback is not provided.");
52980
52987
  let n, r = await this.getOAuthToken({ signal: t, onDecline: (o) => {
@@ -63952,6 +63959,21 @@ function toGoalSnapshot(message) {
63952
63959
  };
63953
63960
  }
63954
63961
 
63962
+ // src/engine/acp/harness/claude/upstream/dist/permissions/bypass-requests.js
63963
+ var QUESTION_MESSAGE = "This session does not ask the user questions (bypass permissions mode), so the question was not shown. Decide with your best judgment, state the assumption you made, and continue. If the work cannot continue without an answer, end your turn and ask the question in your final message.";
63964
+ var BYPASS_PLAN_MODE_MESSAGE = "Plan mode is not available in this session: leaving it takes the user's approval, and the session does not ask for approval (bypass permissions mode). Continue the work in the current mode. If the user asked for a plan first, present it in your reply instead.";
63965
+ function declineBypassRequest(toolName, toolUseID, decisionReason) {
63966
+ if (toolName === "AskUserQuestion") {
63967
+ return { behavior: "deny", message: QUESTION_MESSAGE, toolUseID };
63968
+ }
63969
+ const reason = decisionReason?.trim();
63970
+ return {
63971
+ behavior: "deny",
63972
+ message: `This ${toolName} call needs the user's approval${reason ? ` (${reason})` : ""}, and this session does not ask for approval (bypass permissions mode), so it was not run. Repeating the same call will be declined again. If the step is still needed, do it in a way that needs no approval, such as a simpler or more narrowly targeted call; otherwise leave it undone and report it in your final message.`,
63973
+ toolUseID
63974
+ };
63975
+ }
63976
+
63955
63977
  // src/engine/acp/harness/claude/upstream/dist/permissions/modes.js
63956
63978
  var IS_ROOT = (process.geteuid?.() ?? process.getuid?.()) === 0;
63957
63979
  var ALLOW_BYPASS = !IS_ROOT || !!process.env.IS_SANDBOX;
@@ -66081,6 +66103,8 @@ var SessionModeManager = class {
66081
66103
  this.options.logError(`permissions.defaultMode "${effectiveMode}" is not available in this session; falling back to "default".`);
66082
66104
  effectiveMode = "default";
66083
66105
  await this.trySyncMode(query, effectiveMode, "Failed to sync clamped permissionMode to SDK:");
66106
+ } else if (effectiveMode === "bypassPermissions" && !await this.acceptsBypass(query)) {
66107
+ effectiveMode = "default";
66084
66108
  }
66085
66109
  return {
66086
66110
  modes: { currentModeId: effectiveMode, availableModes },
@@ -66110,6 +66134,12 @@ var SessionModeManager = class {
66110
66134
  availableModeIds(modes) {
66111
66135
  return modes.availableModes.map((mode) => mode.id);
66112
66136
  }
66137
+ /** Whether the session must not wait for the user. Claude Code still sends
66138
+ * some requests for a person under bypassPermissions; the adapter answers
66139
+ * them itself (see permissions/bypass-requests.ts). */
66140
+ neverAsksUser(session) {
66141
+ return session.modes.currentModeId === "bypassPermissions";
66142
+ }
66113
66143
  effectiveMode(session, requestedMode) {
66114
66144
  return requestedMode === "auto" && this.isAutoUnavailable(session) ? AUTO_MODE_FALLBACK : requestedMode;
66115
66145
  }
@@ -66261,12 +66291,25 @@ var SessionModeManager = class {
66261
66291
  modes.push({
66262
66292
  id: "bypassPermissions",
66263
66293
  name: "Bypass permissions",
66264
- description: "Accepts all permissions",
66294
+ description: "Never asks the user: runs tools without approval and declines anything that would need a person's approval or answer",
66265
66295
  _meta: { kind: "full_access" }
66266
66296
  });
66267
66297
  }
66268
66298
  return modes;
66269
66299
  }
66300
+ /** Claude Code starts in the default mode, without an error, when its
66301
+ * settings disable bypassPermissions; only selecting the mode reports that.
66302
+ * A session shown as bypassing permissions must really do so, because it
66303
+ * answers Claude Code's remaining requests itself (see neverAsksUser). */
66304
+ async acceptsBypass(query) {
66305
+ try {
66306
+ await query.setPermissionMode("bypassPermissions");
66307
+ return true;
66308
+ } catch (error62) {
66309
+ this.options.logError('permissions.defaultMode "bypassPermissions" was not accepted by Claude Code; falling back to "default".', error62);
66310
+ return false;
66311
+ }
66312
+ }
66270
66313
  async trySyncMode(query, mode, errorMessage) {
66271
66314
  try {
66272
66315
  await query.setPermissionMode(mode);
@@ -69055,6 +69098,10 @@ ${message.api_refusal_explanation}` : "";
69055
69098
  message: "Session not found"
69056
69099
  };
69057
69100
  }
69101
+ if (this.sessionModes.neverAsksUser(session)) {
69102
+ this.logger.log(`[claude-agent-acp] Declined ${toolName} without asking: the session bypasses permissions`);
69103
+ return declineBypassRequest(toolName, toolUseID, decisionReason);
69104
+ }
69058
69105
  const parentToolUseId = agentID ? session.liveBackgroundTasks.get(agentID)?.parentToolUseId ?? "" : void 0;
69059
69106
  if (agentID && parentToolUseId === "") {
69060
69107
  this.logger.log(`[claude-agent-acp] No parent tool_use recorded for subagent ${agentID}; sending the ${toolName} permission request unattributed`);
@@ -69138,6 +69185,10 @@ ${message.api_refusal_explanation}` : "";
69138
69185
  if (isUrl && !support.url || !isUrl && !support.form) {
69139
69186
  return { action: "decline" };
69140
69187
  }
69188
+ const session = this.sessions[sessionId];
69189
+ if (session && this.sessionModes.neverAsksUser(session)) {
69190
+ return { action: "decline" };
69191
+ }
69141
69192
  const createRequest = mcpElicitationToCreateRequest(request, sessionId);
69142
69193
  if (!createRequest) {
69143
69194
  return { action: "decline" };
@@ -69200,6 +69251,10 @@ ${message.api_refusal_explanation}` : "";
69200
69251
  if (request.dialogKind !== REFUSAL_FALLBACK_DIALOG_KIND) {
69201
69252
  return { behavior: "cancelled" };
69202
69253
  }
69254
+ const session = this.sessions[sessionId];
69255
+ if (session && this.sessionModes.neverAsksUser(session)) {
69256
+ return { behavior: "cancelled" };
69257
+ }
69203
69258
  const prompt = extractRefusalFallbackPrompt(request.payload);
69204
69259
  if (!prompt) {
69205
69260
  this.logger.error(`refusal_fallback_prompt payload had an unexpected shape; cancelling the dialog: ${JSON.stringify(request.payload)}`);
@@ -69585,6 +69640,31 @@ ${message.api_refusal_explanation}` : "";
69585
69640
  tools,
69586
69641
  hooks: {
69587
69642
  ...userProvidedOptions?.hooks,
69643
+ // Claude enters plan mode without asking under bypassPermissions, but
69644
+ // only the user's approval of the plan leaves it, and that mode never
69645
+ // asks. Keep the session out of plan mode, where Claude could neither
69646
+ // write nor leave.
69647
+ PreToolUse: [
69648
+ ...userProvidedOptions?.hooks?.PreToolUse || [],
69649
+ {
69650
+ matcher: "EnterPlanMode",
69651
+ hooks: [
69652
+ async (input3) => {
69653
+ const live = this.sessions[sessionId];
69654
+ if (input3.hook_event_name !== "PreToolUse" || !live || !this.sessionModes.neverAsksUser(live)) {
69655
+ return { continue: true };
69656
+ }
69657
+ return {
69658
+ hookSpecificOutput: {
69659
+ hookEventName: "PreToolUse",
69660
+ permissionDecision: "deny",
69661
+ permissionDecisionReason: BYPASS_PLAN_MODE_MESSAGE
69662
+ }
69663
+ };
69664
+ }
69665
+ ]
69666
+ }
69667
+ ],
69588
69668
  PostToolUse: [
69589
69669
  ...userProvidedOptions?.hooks?.PostToolUse || [],
69590
69670
  {
@@ -71166,12 +71246,12 @@ var ClaudeAgentConnection = class extends EndpointAgentConnection {
71166
71246
  // src/engine/util/process/executable.ts
71167
71247
  import { spawn as spawn3 } from "node:child_process";
71168
71248
  import { stat as stat5 } from "node:fs/promises";
71169
- import { join as join15, resolve as resolve9 } from "node:path";
71249
+ import { join as join16, resolve as resolve9 } from "node:path";
71170
71250
 
71171
71251
  // src/engine/util/process/platform/linux.ts
71172
71252
  import { constants as constants4, readdirSync as readdirSync3, readFileSync as readFileSync2 } from "node:fs";
71173
71253
  import { access as access3, readdir as readdir5, readFile as readFile4, realpath as realpath5, stat as stat4 } from "node:fs/promises";
71174
- import { join as join13 } from "node:path";
71254
+ import { join as join14 } from "node:path";
71175
71255
 
71176
71256
  // src/engine/util/process/platform/posix.ts
71177
71257
  import { execFile as execFile3 } from "node:child_process";
@@ -71301,7 +71381,7 @@ async function readLinuxProcessTable() {
71301
71381
  appendLinuxProcessTableEntry(
71302
71382
  entries,
71303
71383
  processId,
71304
- await readFile4(join13("/proc", directory.name, "stat"), "utf8")
71384
+ await readFile4(join14("/proc", directory.name, "stat"), "utf8")
71305
71385
  );
71306
71386
  } catch {
71307
71387
  }
@@ -71326,7 +71406,7 @@ function readLinuxProcessTableSynchronously() {
71326
71406
  appendLinuxProcessTableEntry(
71327
71407
  entries,
71328
71408
  processId,
71329
- readFileSync2(join13("/proc", directory.name, "stat"), "utf8")
71409
+ readFileSync2(join14("/proc", directory.name, "stat"), "utf8")
71330
71410
  );
71331
71411
  } catch {
71332
71412
  }
@@ -71359,7 +71439,7 @@ async function readLinuxProcessTableWithFallback() {
71359
71439
  }
71360
71440
  function processExists2(processId) {
71361
71441
  try {
71362
- const encoded = readFileSync2(join13("/proc", processId.toString(), "stat"), "utf8");
71442
+ const encoded = readFileSync2(join14("/proc", processId.toString(), "stat"), "utf8");
71363
71443
  const closingParenthesis = encoded.lastIndexOf(")");
71364
71444
  if (closingParenthesis >= 0) {
71365
71445
  const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
@@ -71389,7 +71469,7 @@ var macosProcessPlatform = {
71389
71469
  // src/engine/util/process/platform/windows.ts
71390
71470
  import { execFile as execFile4 } from "node:child_process";
71391
71471
  import { readFile as readFile5, realpath as realpath6 } from "node:fs/promises";
71392
- import { dirname as dirname6, extname, join as join14, resolve as resolve8 } from "node:path";
71472
+ import { dirname as dirname6, extname, join as join15, resolve as resolve8 } from "node:path";
71393
71473
 
71394
71474
  // src/engine/util/process/process-error.ts
71395
71475
  var ProcessExecutionError = class extends Error {
@@ -71468,7 +71548,7 @@ function readProcessTable() {
71468
71548
  }
71469
71549
  return new Promise((resolveTable) => {
71470
71550
  execFile4(
71471
- join14(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
71551
+ join15(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
71472
71552
  [
71473
71553
  "-NoLogo",
71474
71554
  "-NoProfile",
@@ -71604,7 +71684,7 @@ async function findExecutableOnPath(executableName, environment, platform2 = pro
71604
71684
  continue;
71605
71685
  }
71606
71686
  for (const extension of extensions) {
71607
- const requestedPath2 = resolve9(join15(entry, `${executableName}${extension}`));
71687
+ const requestedPath2 = resolve9(join16(entry, `${executableName}${extension}`));
71608
71688
  const executable = await resolveExecutablePath(requestedPath2, platform2);
71609
71689
  if (executable !== null) {
71610
71690
  return executable;
@@ -74990,13 +75070,13 @@ var CodexAgentSpecification = class extends InProcessAcpAgentSpecification {
74990
75070
 
74991
75071
  // src/engine/agent/specification/vendors/pi-agent.ts
74992
75072
  import { createHash as createHash3 } from "node:crypto";
74993
- import { join as join21 } from "node:path";
75073
+ import { join as join22 } from "node:path";
74994
75074
 
74995
75075
  // src/engine/acp/harness/pi/upstream/dist/acp/agent.js
74996
75076
  import { spawnSync } from "node:child_process";
74997
75077
  import { randomUUID as randomUUID11 } from "node:crypto";
74998
75078
  import { existsSync as existsSync8, readdirSync as readdirSync6, readFileSync as readFileSync9, realpathSync as realpathSync3, statSync as statSync3, unlinkSync as unlinkSync2 } from "node:fs";
74999
- import { basename as basename5, dirname as dirname8, isAbsolute as isAbsolute12, join as join20 } from "node:path";
75079
+ import { basename as basename5, dirname as dirname8, isAbsolute as isAbsolute12, join as join21 } from "node:path";
75000
75080
 
75001
75081
  // src/engine/acp/harness/pi/upstream/dist/pi-rpc/process.js
75002
75082
  import { spawn as spawn5 } from "node:child_process";
@@ -75452,7 +75532,7 @@ function maybeAuthRequiredError(err) {
75452
75532
  }
75453
75533
 
75454
75534
  // src/engine/acp/harness/pi/upstream/dist/acp/paths.js
75455
- import { join as join16 } from "node:path";
75535
+ import { join as join17 } from "node:path";
75456
75536
 
75457
75537
  // src/engine/acp/harness/pi/upstream/dist/acp/environment.js
75458
75538
  import { homedir as homedir2 } from "node:os";
@@ -75462,10 +75542,10 @@ function environmentHome(environment) {
75462
75542
 
75463
75543
  // src/engine/acp/harness/pi/upstream/dist/acp/paths.js
75464
75544
  function getPiAcpDir(environment = process.env) {
75465
- return join16(environmentHome(environment), ".pi", "pi-acp");
75545
+ return join17(environmentHome(environment), ".pi", "pi-acp");
75466
75546
  }
75467
75547
  function getPiAcpSessionMapPath(environment = process.env) {
75468
- return join16(getPiAcpDir(environment), "session-map.json");
75548
+ return join17(getPiAcpDir(environment), "session-map.json");
75469
75549
  }
75470
75550
 
75471
75551
  // src/engine/acp/harness/pi/upstream/dist/acp/pi-commands.js
@@ -75587,15 +75667,15 @@ async function readPiLatestEntryId(sessionFile) {
75587
75667
 
75588
75668
  // src/engine/acp/harness/pi/upstream/dist/acp/pi-sessions.js
75589
75669
  import { closeSync as closeSync2, existsSync as existsSync5, openSync as openSync2, readdirSync as readdirSync4, readFileSync as readFileSync4, readSync as readSync2, statSync as statSync2 } from "node:fs";
75590
- import { isAbsolute as isAbsolute10, join as join17, resolve as resolve10 } from "node:path";
75670
+ import { isAbsolute as isAbsolute10, join as join18, resolve as resolve10 } from "node:path";
75591
75671
  var DEFAULT_TAIL_BYTES = 256 * 1024;
75592
75672
  var DEFAULT_HEAD_BYTES = 64 * 1024;
75593
75673
  function getPiAgentDir(environment) {
75594
75674
  const configured = environment["PI_CODING_AGENT_DIR"];
75595
- return configured ? resolve10(configured) : join17(environmentHome(environment), ".pi", "agent");
75675
+ return configured ? resolve10(configured) : join18(environmentHome(environment), ".pi", "agent");
75596
75676
  }
75597
75677
  function readSessionDirFromSettings(agentDir) {
75598
- const settingsPath = join17(agentDir, "settings.json");
75678
+ const settingsPath = join18(agentDir, "settings.json");
75599
75679
  try {
75600
75680
  if (!existsSync5(settingsPath)) {
75601
75681
  return null;
@@ -75616,7 +75696,7 @@ function readSessionDirFromSettings(agentDir) {
75616
75696
  }
75617
75697
  function getPiSessionsDir(environment = process.env) {
75618
75698
  const agentDir = getPiAgentDir(environment);
75619
- return readSessionDirFromSettings(agentDir) ?? join17(agentDir, "sessions");
75699
+ return readSessionDirFromSettings(agentDir) ?? join18(agentDir, "sessions");
75620
75700
  }
75621
75701
  function getPiSessionDiscoveryDirs(environment) {
75622
75702
  const discoveryDirectories = [getPiSessionsDir(environment)];
@@ -75627,7 +75707,7 @@ function getPiSessionDiscoveryDirs(environment) {
75627
75707
  if (!entry.isDirectory()) {
75628
75708
  continue;
75629
75709
  }
75630
- const directory = join17(mobiusSessionsRoot, entry.name);
75710
+ const directory = join18(mobiusSessionsRoot, entry.name);
75631
75711
  if (!discoveryDirectories.includes(directory)) {
75632
75712
  discoveryDirectories.push(directory);
75633
75713
  }
@@ -75644,7 +75724,7 @@ function walkJsonlFiles(dir, out2) {
75644
75724
  }
75645
75725
  for (const e of entries) {
75646
75726
  const name2 = typeof e.name === "string" ? e.name : String(e.name);
75647
- const p = join17(dir, name2);
75727
+ const p = join18(dir, name2);
75648
75728
  if (e.isDirectory()) {
75649
75729
  walkJsonlFiles(p, out2);
75650
75730
  } else if (e.isFile() && name2.endsWith(".jsonl")) {
@@ -75913,7 +75993,7 @@ function findPiSession(sessionId, environment = process.env) {
75913
75993
 
75914
75994
  // src/engine/acp/harness/pi/upstream/dist/acp/pi-settings.js
75915
75995
  import { existsSync as existsSync6, readFileSync as readFileSync5 } from "node:fs";
75916
- import { join as join18, resolve as resolve11 } from "node:path";
75996
+ import { join as join19, resolve as resolve11 } from "node:path";
75917
75997
  function isObject2(x) {
75918
75998
  return Boolean(x) && typeof x === "object" && !Array.isArray(x);
75919
75999
  }
@@ -75942,7 +76022,7 @@ function readJsonFile2(path6) {
75942
76022
  }
75943
76023
  }
75944
76024
  function getMergedSettings(cwd, environment) {
75945
- const globalSettingsPath = join18(getAgentDir(environment), "settings.json");
76025
+ const globalSettingsPath = join19(getAgentDir(environment), "settings.json");
75946
76026
  const projectSettingsPath = resolve11(cwd, ".pi", "settings.json");
75947
76027
  const global2 = readJsonFile2(globalSettingsPath);
75948
76028
  const project = readJsonFile2(projectSettingsPath);
@@ -75950,7 +76030,7 @@ function getMergedSettings(cwd, environment) {
75950
76030
  }
75951
76031
  function getAgentDir(environment = process.env) {
75952
76032
  const configured = environment["PI_CODING_AGENT_DIR"];
75953
- return configured ? resolve11(configured) : join18(environmentHome(environment), ".pi", "agent");
76033
+ return configured ? resolve11(configured) : join19(environmentHome(environment), ".pi", "agent");
75954
76034
  }
75955
76035
  function getEnableSkillCommands(cwd, environment = process.env) {
75956
76036
  const merged = getMergedSettings(cwd, environment);
@@ -76204,7 +76284,7 @@ var SessionStore = class {
76204
76284
 
76205
76285
  // src/engine/acp/harness/pi/upstream/dist/acp/slash-commands.js
76206
76286
  import { existsSync as existsSync7, readdirSync as readdirSync5, readFileSync as readFileSync7 } from "node:fs";
76207
- import { join as join19, resolve as resolve12 } from "node:path";
76287
+ import { join as join20, resolve as resolve12 } from "node:path";
76208
76288
  function parseFrontmatter(content) {
76209
76289
  const frontmatter = {};
76210
76290
  if (!content.startsWith("---")) {
@@ -76232,7 +76312,7 @@ function loadCommandsFromDir(dir, source, subdir = "") {
76232
76312
  try {
76233
76313
  const entries = readdirSync5(dir, { withFileTypes: true });
76234
76314
  for (const entry of entries) {
76235
- const fullPath = join19(dir, entry.name);
76315
+ const fullPath = join20(dir, entry.name);
76236
76316
  if (entry.isDirectory()) {
76237
76317
  const newSubdir = subdir ? `${subdir}:${entry.name}` : entry.name;
76238
76318
  commands.push(...loadCommandsFromDir(fullPath, source, newSubdir));
@@ -76272,7 +76352,7 @@ function loadCommandsFromDir(dir, source, subdir = "") {
76272
76352
  }
76273
76353
  function loadSlashCommands(cwd, environment = process.env) {
76274
76354
  const commands = [];
76275
- const userDir = join19(environmentHome(environment), ".pi", "agent", "prompts");
76355
+ const userDir = join20(environmentHome(environment), ".pi", "agent", "prompts");
76276
76356
  const projectDir = resolve12(cwd, ".pi", "prompts");
76277
76357
  commands.push(...loadCommandsFromDir(userDir, "user"));
76278
76358
  commands.push(...loadCommandsFromDir(projectDir, "project"));
@@ -77941,7 +78021,7 @@ ${JSON.stringify(stats, null, 2)}`;
77941
78021
  if (piPath) {
77942
78022
  const resolved = realpathSync3(piPath);
77943
78023
  const pkgRoot = dirname8(dirname8(resolved));
77944
- const p = join20(pkgRoot, "CHANGELOG.md");
78024
+ const p = join21(pkgRoot, "CHANGELOG.md");
77945
78025
  if (existsSync8(p)) {
77946
78026
  return p;
77947
78027
  }
@@ -77952,7 +78032,7 @@ ${JSON.stringify(stats, null, 2)}`;
77952
78032
  const npmRoot = spawnSync("npm", ["root", "-g"], { encoding: "utf-8" });
77953
78033
  const root = String(npmRoot.stdout ?? "").trim();
77954
78034
  if (root) {
77955
- const p = join20(root, "@earendil-works", "pi-coding-agent", "CHANGELOG.md");
78035
+ const p = join21(root, "@earendil-works", "pi-coding-agent", "CHANGELOG.md");
77956
78036
  if (existsSync8(p)) {
77957
78037
  return p;
77958
78038
  }
@@ -78046,7 +78126,7 @@ ${JSON.stringify(stats, null, 2)}`;
78046
78126
  return { stopReason: "end_turn" };
78047
78127
  }
78048
78128
  const safeSessionId = session.sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
78049
- const outputPath = join20(session.cwd, `pi-session-${safeSessionId}.html`);
78129
+ const outputPath = join21(session.cwd, `pi-session-${safeSessionId}.html`);
78050
78130
  let resultPath = "";
78051
78131
  try {
78052
78132
  const result2 = await session.proc.exportHtml(outputPath);
@@ -78783,7 +78863,7 @@ function buildStartupInfo(opts) {
78783
78863
  md.push("");
78784
78864
  };
78785
78865
  const contextItems = [];
78786
- const contextPath = join20(opts.cwd, "AGENTS.md");
78866
+ const contextPath = join21(opts.cwd, "AGENTS.md");
78787
78867
  if (existsSync8(contextPath)) {
78788
78868
  contextItems.push(contextPath);
78789
78869
  }
@@ -78792,7 +78872,7 @@ function buildStartupInfo(opts) {
78792
78872
  const pushSkillFromRoot = (root) => {
78793
78873
  try {
78794
78874
  for (const e of readdirSync6(root)) {
78795
- const p = join20(root, e);
78875
+ const p = join21(root, e);
78796
78876
  try {
78797
78877
  const st2 = statSync3(p);
78798
78878
  if (st2.isFile() && e.toLowerCase().endsWith(".md")) {
@@ -78817,7 +78897,7 @@ function buildStartupInfo(opts) {
78817
78897
  if (name2 === "node_modules" || name2 === ".git") {
78818
78898
  continue;
78819
78899
  }
78820
- const p = join20(dir, name2);
78900
+ const p = join21(dir, name2);
78821
78901
  let st2;
78822
78902
  try {
78823
78903
  st2 = statSync3(p);
@@ -78834,16 +78914,16 @@ function buildStartupInfo(opts) {
78834
78914
  } catch {
78835
78915
  }
78836
78916
  };
78837
- const globalSkillsDir = join20(getAgentDir(opts.environment), "skills");
78917
+ const globalSkillsDir = join21(getAgentDir(opts.environment), "skills");
78838
78918
  pushSkillFromRoot(globalSkillsDir);
78839
78919
  const home = opts.environment["HOME"] ?? opts.environment["USERPROFILE"] ?? "";
78840
- const legacyAgentsSkillsDir = join20(home, ".agents", "skills");
78920
+ const legacyAgentsSkillsDir = join21(home, ".agents", "skills");
78841
78921
  pushSkillFromRoot(legacyAgentsSkillsDir);
78842
- const projectSkillsDir = join20(opts.cwd, ".pi", "skills");
78922
+ const projectSkillsDir = join21(opts.cwd, ".pi", "skills");
78843
78923
  pushSkillFromRoot(projectSkillsDir);
78844
78924
  addSection("Skills", skillsItems);
78845
78925
  const promptsItems = [];
78846
- const promptsDir = join20(home, ".pi", "agent", "prompts");
78926
+ const promptsDir = join21(home, ".pi", "agent", "prompts");
78847
78927
  try {
78848
78928
  const prompts = readdirSync6(promptsDir).filter((f) => f.endsWith(".md"));
78849
78929
  for (const f of prompts) {
@@ -78853,17 +78933,17 @@ function buildStartupInfo(opts) {
78853
78933
  }
78854
78934
  addSection("Prompts", promptsItems);
78855
78935
  const extItems = [];
78856
- const extDir = join20(home, ".pi", "agent", "extensions");
78936
+ const extDir = join21(home, ".pi", "agent", "extensions");
78857
78937
  try {
78858
78938
  const exts = readdirSync6(extDir).filter((f) => f.endsWith(".ts") || f.endsWith(".js"));
78859
78939
  for (const f of exts) {
78860
- extItems.push(join20(extDir, f));
78940
+ extItems.push(join21(extDir, f));
78861
78941
  }
78862
78942
  } catch {
78863
78943
  }
78864
78944
  const settingsPaths = [
78865
- join20(getAgentDir(opts.environment), "settings.json"),
78866
- join20(opts.cwd, ".pi", "settings.json")
78945
+ join21(getAgentDir(opts.environment), "settings.json"),
78946
+ join21(opts.cwd, ".pi", "settings.json")
78867
78947
  ];
78868
78948
  for (const settingsPath of settingsPaths) {
78869
78949
  try {
@@ -79064,7 +79144,7 @@ var PiAgentSpecification = class extends InProcessAcpAgentSpecification {
79064
79144
  // keeps the adapter's opt-in capability flag enabled for every launch it owns.
79065
79145
  createLaunchEnvironment = async (_agent, context) => {
79066
79146
  const workspaceHash = createHash3("sha256").update(context.defaultWorkspace).digest("hex").slice(0, 24);
79067
- const sessionDirectory = join21(context.dataDirectory, "agents", "pi", "sessions", workspaceHash);
79147
+ const sessionDirectory = join22(context.dataDirectory, "agents", "pi", "sessions", workspaceHash);
79068
79148
  return Object.freeze({
79069
79149
  PI_ACP_ENABLE_EMBEDDED_CONTEXT: "true",
79070
79150
  MOBIUS_PI_SESSION_DIR: sessionDirectory
@@ -81892,11 +81972,11 @@ function describeEnvironmentProxyRoute(target) {
81892
81972
  }
81893
81973
 
81894
81974
  // src/engine/runtime/observability/diagnostic-log.ts
81895
- import { join as join24 } from "node:path";
81975
+ import { join as join25 } from "node:path";
81896
81976
 
81897
81977
  // src/engine/storage/logs/bounded-log.ts
81898
81978
  import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync10, renameSync as renameSync2, statSync as statSync5, writeFileSync as writeFileSync2 } from "node:fs";
81899
- import { join as join22 } from "node:path";
81979
+ import { join as join23 } from "node:path";
81900
81980
  var BoundedLineLog = class {
81901
81981
  #path;
81902
81982
  #maximumBytes;
@@ -81905,7 +81985,7 @@ var BoundedLineLog = class {
81905
81985
  #onWriteFailure;
81906
81986
  constructor(directory, filename, maximumBytes, onWriteFailure = () => void 0) {
81907
81987
  this.#directory = directory;
81908
- this.#path = join22(directory, filename);
81988
+ this.#path = join23(directory, filename);
81909
81989
  this.#maximumBytes = maximumBytes;
81910
81990
  this.#onWriteFailure = onWriteFailure;
81911
81991
  }
@@ -81956,21 +82036,21 @@ var BoundedLineLog = class {
81956
82036
 
81957
82037
  // src/engine/storage/logs/log-files.ts
81958
82038
  import { readFileSync as readFileSync11 } from "node:fs";
81959
- import { join as join23 } from "node:path";
82039
+ import { join as join24 } from "node:path";
81960
82040
  var DAEMON_LOG_FILENAME = "daemon.log";
81961
82041
  var WORKER_LIFECYCLE_LOG_FILENAME = "worker-lifecycle.log";
81962
82042
  function unhandledRejectionLogFilename(role) {
81963
82043
  return `unhandled-rejections-${role}.log`;
81964
82044
  }
81965
82045
  function logDirectory(dataDirectory) {
81966
- return join23(dataDirectory, "logs");
82046
+ return join24(dataDirectory, "logs");
81967
82047
  }
81968
82048
  function processLogPaths(dataDirectory) {
81969
82049
  return [
81970
82050
  WORKER_LIFECYCLE_LOG_FILENAME,
81971
82051
  unhandledRejectionLogFilename("manager"),
81972
82052
  unhandledRejectionLogFilename("worker")
81973
- ].map((filename) => join23(logDirectory(dataDirectory), filename));
82053
+ ].map((filename) => join24(logDirectory(dataDirectory), filename));
81974
82054
  }
81975
82055
  function readLogText(path6) {
81976
82056
  try {
@@ -82045,7 +82125,7 @@ var RuntimeDiagnosticLog = class {
82045
82125
  this.#maximumBytes = maximumBytes;
82046
82126
  const processLogsDirectory = options.processLogsDirectory;
82047
82127
  this.#sources = [
82048
- { maximumBytes, path: join24(directory, DAEMON_LOG_FILENAME) },
82128
+ { maximumBytes, path: join25(directory, DAEMON_LOG_FILENAME) },
82049
82129
  // The process logs a Runtime does not own, but must read to explain its own deaths.
82050
82130
  ...processLogsDirectory === void 0 ? [] : processLogPaths(processLogsDirectory).map((path6) => ({ maximumBytes: null, path: path6 }))
82051
82131
  ];
@@ -83194,7 +83274,7 @@ function sql(strings, ...params) {
83194
83274
  return new SQL([new StringChunk(str)]);
83195
83275
  }
83196
83276
  _sql.raw = raw;
83197
- function join30(chunks, separator) {
83277
+ function join32(chunks, separator) {
83198
83278
  const result = [];
83199
83279
  for (const [i, chunk] of chunks.entries()) {
83200
83280
  if (i > 0 && separator !== void 0) result.push(separator);
@@ -83202,7 +83282,7 @@ function sql(strings, ...params) {
83202
83282
  }
83203
83283
  return new SQL(result);
83204
83284
  }
83205
- _sql.join = join30;
83285
+ _sql.join = join32;
83206
83286
  function identifier2(value) {
83207
83287
  return new Name(value);
83208
83288
  }
@@ -85347,7 +85427,7 @@ var SQLiteSelectBase = class extends TypedQueryBuilder {
85347
85427
  const baseTableName = this.tableName;
85348
85428
  const tableName = getTableLikeName(table);
85349
85429
  for (const item of extractUsedTable(table)) this.usedTables.add(item);
85350
- if (typeof tableName === "string" && this.config.joins?.some((join30) => join30.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
85430
+ if (typeof tableName === "string" && this.config.joins?.some((join32) => join32.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
85351
85431
  if (!this.isPartialSelect) {
85352
85432
  if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
85353
85433
  if (typeof tableName === "string" && !is(table, SQL)) {
@@ -86186,7 +86266,7 @@ var SQLiteDialect = class {
86186
86266
  if (!joins2) return;
86187
86267
  const withEntries = Object.entries(joins2).filter(([_, v]) => v);
86188
86268
  if (!withEntries.length) return;
86189
- return sql.join(withEntries.map(([k2, join30]) => {
86269
+ return sql.join(withEntries.map(([k2, join32]) => {
86190
86270
  const relation = tableConfig.relations[k2];
86191
86271
  const isSingle2 = is(relation, One2);
86192
86272
  const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
@@ -86197,7 +86277,7 @@ var SQLiteDialect = class {
86197
86277
  table: targetTable,
86198
86278
  mode: isSingle2 ? "first" : "many",
86199
86279
  schema,
86200
- queryConfig: join30,
86280
+ queryConfig: join32,
86201
86281
  tableConfig: schema[relation.targetTableName],
86202
86282
  relationWhere: filter,
86203
86283
  isNested: true,
@@ -86211,7 +86291,7 @@ var SQLiteDialect = class {
86211
86291
  key: k2,
86212
86292
  selection: innerQuery.selection,
86213
86293
  isArray: !isSingle2,
86214
- isOptional: (relation.optional ?? false) || join30 !== true && !!join30.where
86294
+ isOptional: (relation.optional ?? false) || join32 !== true && !!join32.where
86215
86295
  });
86216
86296
  const jsonColumns = sql.join(innerQuery.selection.map((s) => {
86217
86297
  return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
@@ -86827,7 +86907,7 @@ var SQLiteUpdateBase = class {
86827
86907
  createJoin(joinType) {
86828
86908
  return ((table, on2) => {
86829
86909
  const tableName = getTableLikeName(table);
86830
- if (typeof tableName === "string" && this.config.joins.some((join30) => join30.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
86910
+ if (typeof tableName === "string" && this.config.joins.some((join32) => join32.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
86831
86911
  if (typeof on2 === "function") {
86832
86912
  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;
86833
86913
  on2 = on2(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
@@ -87779,7 +87859,7 @@ var SessionEventCacheTable = class {
87779
87859
  // src/engine/storage/sqlite/local-databases.ts
87780
87860
  import { createHash as createHash4 } from "node:crypto";
87781
87861
  import { existsSync as existsSync9 } from "node:fs";
87782
- import { join as join25 } from "node:path";
87862
+ import { join as join26 } from "node:path";
87783
87863
  import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
87784
87864
 
87785
87865
  // src/engine/generated/acp-session-store-migrations.ts
@@ -88022,9 +88102,9 @@ var LocalSqliteDatabase = class {
88022
88102
  function channelSessionDatabasePaths(stateDirectory, channelId) {
88023
88103
  const channelHash = createHash4("sha256").update(channelId).digest("hex");
88024
88104
  return {
88025
- cancellations: join25(stateDirectory, "sessions", `${channelHash}.cancellations.sqlite`),
88026
- events: join25(stateDirectory, "sessions", `${channelHash}.events.sqlite`),
88027
- sessions: join25(stateDirectory, "sessions", `${channelHash}.sqlite`)
88105
+ cancellations: join26(stateDirectory, "sessions", `${channelHash}.cancellations.sqlite`),
88106
+ events: join26(stateDirectory, "sessions", `${channelHash}.events.sqlite`),
88107
+ sessions: join26(stateDirectory, "sessions", `${channelHash}.sqlite`)
88028
88108
  };
88029
88109
  }
88030
88110
  function recordAppliedAdmissionOrder(path6) {
@@ -90735,19 +90815,30 @@ var SessionManager2 = class {
90735
90815
  }
90736
90816
  prepareSession = async (options, metrics = unmeasuredOperationMetrics, closed = "reopen") => await this.#prepareSession(options, { kind: "interactive-only" }, closed, metrics);
90737
90817
  restoreSession = async (options, metrics = unmeasuredOperationMetrics, closed = "reopen") => await this.#prepareSession(options, { kind: "history-required" }, closed, metrics);
90818
+ inspectAgentSettings = async (options, models = /* @__PURE__ */ new Map()) => {
90819
+ options.signal.throwIfAborted();
90820
+ const inspections = await this.#probeAgentSettings(options);
90821
+ options.signal.throwIfAborted();
90822
+ for (const [model, result] of inspections.models) {
90823
+ models.set(model, result);
90824
+ }
90825
+ models.set(options.model, inspections.requested);
90826
+ if (inspections.requested instanceof AcpConfigurationValueUnavailableError) {
90827
+ throw inspections.requested;
90828
+ }
90829
+ return inspections.requested;
90830
+ };
90738
90831
  /**
90739
90832
  * Opens a short-lived native ACP session only to read the local Agent's
90740
90833
  * authoritative settings. Its identity and store are private to this
90741
90834
  * operation and never become a Mobius Session.
90742
90835
  */
90743
- inspectAgentSettings = async (options) => this.#operations.run(options, async (options2) => {
90836
+ #probeAgentSettings = async (options) => this.#operations.run(options, async (options2) => {
90837
+ const sessionId = `agent-settings-${crypto.randomUUID()}`;
90744
90838
  return await this.#processes.runTransient(
90745
90839
  options2.signal,
90746
90840
  async () => await AgentSession.start(
90747
- {
90748
- ...options2,
90749
- sessionId: `agent-settings-${crypto.randomUUID()}`
90750
- },
90841
+ { ...options2, sessionId },
90751
90842
  { kind: "interactive-only" },
90752
90843
  () => this.#agentSettingsObserver,
90753
90844
  () => void 0,
@@ -90757,25 +90848,56 @@ var SessionManager2 = class {
90757
90848
  ),
90758
90849
  async (runtime) => {
90759
90850
  const prepared = runtime.prepared();
90760
- const discoveredModelEffort = runtime.agentSettingsModelEffort();
90761
- const model = options2.model;
90851
+ const nativeEffort = runtime.agentSettingsModelEffort();
90852
+ const snapshot = (configOptions) => new AgentSettingsSnapshot(
90853
+ prepared.agentName,
90854
+ prepared.agentVersion,
90855
+ configOptions,
90856
+ nativeEffort === null ? { kind: "unavailable" } : { kind: "complete", value: nativeEffort }
90857
+ );
90762
90858
  const modelOption2 = prepared.configOptions.find(isModelOption);
90763
- const modelIsFixed = modelOption2?.type === "select" && modelOption2.values.length < 2 && modelOption2.currentValue === model;
90764
- const configOptions = model === void 0 || modelIsFixed ? prepared.configOptions : (await runtime.applyConfiguration({
90859
+ const change = async (configId, value) => (await runtime.applyConfiguration({
90765
90860
  ...options2,
90766
90861
  booleanValue: false,
90767
- configId: modelOption2?.id ?? "model",
90862
+ configId,
90768
90863
  requestId: "agent-settings-model",
90769
- sessionId: `agent-settings-${crypto.randomUUID()}`,
90770
- value: model,
90864
+ sessionId,
90865
+ value,
90771
90866
  valueType: "select"
90772
90867
  })).configOptions;
90773
- return new AgentSettingsSnapshot(
90774
- prepared.agentName,
90775
- prepared.agentVersion,
90776
- configOptions,
90777
- discoveredModelEffort === null ? { kind: "unavailable" } : { kind: "complete", value: discoveredModelEffort }
90778
- );
90868
+ const inspectModel = async (model) => {
90869
+ if (modelOption2?.type === "select" && modelOption2.values.length < 2 && modelOption2.currentValue === model) {
90870
+ return snapshot(prepared.configOptions);
90871
+ }
90872
+ try {
90873
+ return snapshot(await change(modelOption2?.id ?? "model", model));
90874
+ } catch (error62) {
90875
+ options2.signal.throwIfAborted();
90876
+ if (error62 instanceof AcpConfigurationValueUnavailableError && error62.configId === (modelOption2?.id ?? "model") && error62.requestedValue === model) {
90877
+ return error62;
90878
+ }
90879
+ throw error62;
90880
+ }
90881
+ };
90882
+ const models = /* @__PURE__ */ new Map();
90883
+ if (options2.model !== void 0) {
90884
+ return { requested: await inspectModel(options2.model), models };
90885
+ }
90886
+ if (nativeEffort?.resolution === AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE && modelOption2?.type === "select" && Object.hasOwn(nativeEffort.valuesByModel, modelOption2.currentValue)) {
90887
+ const effort = prepared.configOptions.find(
90888
+ (option) => option.id === nativeEffort.effortSettingId
90889
+ );
90890
+ for (const { value } of modelOption2.values) {
90891
+ models.set(value, await inspectModel(value));
90892
+ if (value !== modelOption2.currentValue && modelOption2.currentValue !== "") {
90893
+ await change(modelOption2.id, modelOption2.currentValue);
90894
+ if (effort?.type === "select" && effort.currentValue !== "") {
90895
+ await change(effort.id, effort.currentValue);
90896
+ }
90897
+ }
90898
+ }
90899
+ }
90900
+ return { requested: snapshot(prepared.configOptions), models };
90779
90901
  },
90780
90902
  async (runtime) => await runtime.close()
90781
90903
  );
@@ -92334,7 +92456,7 @@ var SessionTurns = class {
92334
92456
 
92335
92457
  // src/engine/session/workspace/workspace-directory.ts
92336
92458
  import { homedir as homedir3 } from "node:os";
92337
- import { basename as basename7, dirname as dirname10, isAbsolute as isAbsolute15, join as join26, normalize as normalize2, relative as relative2 } from "node:path";
92459
+ import { basename as basename7, dirname as dirname10, isAbsolute as isAbsolute15, join as join27, normalize as normalize2, relative as relative2 } from "node:path";
92338
92460
 
92339
92461
  // src/engine/session/workspace/local-authorization-error.ts
92340
92462
  var LocalAuthorizationError = class extends OperationError {
@@ -92480,7 +92602,7 @@ var WorkspaceDirectoryService = class {
92480
92602
  continue;
92481
92603
  }
92482
92604
  try {
92483
- const path6 = await this.resolvePath(join26(target, child.name), signal);
92605
+ const path6 = await this.resolvePath(join27(target, child.name), signal);
92484
92606
  entries.push({ directoryId: encodePath(path6), name: child.name });
92485
92607
  } catch (cause) {
92486
92608
  signal.throwIfAborted();
@@ -92654,13 +92776,13 @@ function buildSessionLayer(options) {
92654
92776
 
92655
92777
  // src/engine/session/content/external-content-store.ts
92656
92778
  import { createHash as createHash8 } from "node:crypto";
92657
- import { extname as extname2, join as join28 } from "node:path";
92779
+ import { extname as extname2, join as join29 } from "node:path";
92658
92780
  import { pathToFileURL as pathToFileURL3 } from "node:url";
92659
92781
 
92660
92782
  // src/engine/storage/files/scratch-directory.ts
92661
92783
  import { randomUUID as randomUUID16 } from "node:crypto";
92662
- import { lstat as lstat4, mkdir as mkdir5, readdir as readdir6, readFile as readFile7, realpath as realpath7, rename as rename4, rm as rm4, stat as stat6, utimes, writeFile as writeFile2 } from "node:fs/promises";
92663
- import { dirname as dirname11, join as join27 } from "node:path";
92784
+ import { lstat as lstat4, mkdir as mkdir5, readdir as readdir6, readFile as readFile7, realpath as realpath7, rename as rename4, rm as rm5, stat as stat6, utimes, writeFile as writeFile2 } from "node:fs/promises";
92785
+ import { dirname as dirname11, join as join28 } from "node:path";
92664
92786
  async function atomicWrite(path6, bytes, signal) {
92665
92787
  const temporary = `${path6}.${randomUUID16()}.tmp`;
92666
92788
  try {
@@ -92668,13 +92790,13 @@ async function atomicWrite(path6, bytes, signal) {
92668
92790
  signal.throwIfAborted();
92669
92791
  await rename4(temporary, path6);
92670
92792
  } finally {
92671
- await rm4(temporary, { force: true });
92793
+ await rm5(temporary, { force: true });
92672
92794
  }
92673
92795
  }
92674
92796
  var ScratchDirectory = class {
92675
92797
  #root;
92676
92798
  constructor(parent) {
92677
- this.#root = join27(parent, randomUUID16());
92799
+ this.#root = join28(parent, randomUUID16());
92678
92800
  }
92679
92801
  /** Refreshes this directory's lease and removes sibling directories whose lease is older than `leaseMilliseconds`. */
92680
92802
  refreshLease = async (leaseMilliseconds) => {
@@ -92685,7 +92807,7 @@ var ScratchDirectory = class {
92685
92807
  if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
92686
92808
  continue;
92687
92809
  }
92688
- const path6 = join27(dirname11(this.#root), directory.name);
92810
+ const path6 = join28(dirname11(this.#root), directory.name);
92689
92811
  if (path6 === this.#root) {
92690
92812
  continue;
92691
92813
  }
@@ -92694,21 +92816,21 @@ var ScratchDirectory = class {
92694
92816
  () => Date.now()
92695
92817
  );
92696
92818
  if (modified + leaseMilliseconds <= Date.now()) {
92697
- await rm4(path6, { force: true, recursive: true });
92819
+ await rm5(path6, { force: true, recursive: true });
92698
92820
  }
92699
92821
  }
92700
92822
  };
92701
92823
  /** Writes `bytes` atomically to `<group>/<name>` with owner-only permissions and returns the path. */
92702
92824
  write = async (group, name2, bytes, signal) => {
92703
- const directory = join27(this.#root, group);
92825
+ const directory = join28(this.#root, group);
92704
92826
  await mkdir5(directory, { mode: 448, recursive: true });
92705
92827
  signal.throwIfAborted();
92706
- const path6 = join27(directory, name2);
92828
+ const path6 = join28(directory, name2);
92707
92829
  await atomicWrite(path6, bytes, signal);
92708
92830
  return path6;
92709
92831
  };
92710
92832
  remove = async (path6) => {
92711
- await rm4(path6, { force: true });
92833
+ await rm5(path6, { force: true });
92712
92834
  };
92713
92835
  /** The canonical path of a written file, or null when it is gone, is not a regular file, or escapes its directory. */
92714
92836
  resolveFile = async (path6) => {
@@ -92730,7 +92852,7 @@ var ScratchDirectory = class {
92730
92852
  return resolved === null ? null : new Uint8Array(await readFile7(resolved, { signal }));
92731
92853
  };
92732
92854
  removeAll = async () => {
92733
- await rm4(this.#root, { force: true, recursive: true });
92855
+ await rm5(this.#root, { force: true, recursive: true });
92734
92856
  };
92735
92857
  };
92736
92858
 
@@ -92754,7 +92876,7 @@ var LocalExternalContentStore = class {
92754
92876
  #expirationTimer;
92755
92877
  #cleanup = Promise.resolve();
92756
92878
  constructor(stateDirectory) {
92757
- this.#scratch = new ScratchDirectory(join28(stateDirectory, "tmp", "session-content"));
92879
+ this.#scratch = new ScratchDirectory(join29(stateDirectory, "tmp", "session-content"));
92758
92880
  this.#expirationTimer = setInterval(() => {
92759
92881
  void this.#expire().catch(() => void 0);
92760
92882
  }, 6e4);
@@ -93160,6 +93282,176 @@ var AgentProcessPool = class {
93160
93282
  };
93161
93283
  };
93162
93284
 
93285
+ // src/engine/session/settings/agent-settings-cache.ts
93286
+ import { createHash as createHash9, randomUUID as randomUUID17 } from "node:crypto";
93287
+ import { join as join30 } from "node:path";
93288
+ var CACHE_FILE_LIMIT = 32 * 1024 * 1024;
93289
+ var CACHE_FORMAT = 1;
93290
+ var generationSchema = external_exports.union([external_exports.literal("initial"), external_exports.uuid()]);
93291
+ var modelEffortSchema = external_exports.discriminatedUnion("kind", [
93292
+ external_exports.object({ kind: external_exports.literal("unavailable") }),
93293
+ external_exports.object({
93294
+ kind: external_exports.literal("complete"),
93295
+ value: external_exports.object({
93296
+ effortSettingId: external_exports.string(),
93297
+ modelSettingId: external_exports.string(),
93298
+ resolution: external_exports.enum(["complete", "on_model_selection", "unavailable"]),
93299
+ unsupportedModelIds: external_exports.array(external_exports.string()),
93300
+ valuesByModel: external_exports.record(
93301
+ external_exports.string(),
93302
+ external_exports.array(
93303
+ external_exports.object({
93304
+ description: external_exports.string(),
93305
+ groupId: external_exports.string(),
93306
+ groupName: external_exports.string(),
93307
+ name: external_exports.string(),
93308
+ value: external_exports.string()
93309
+ })
93310
+ )
93311
+ )
93312
+ })
93313
+ })
93314
+ ]);
93315
+ var cacheSchema = external_exports.object({
93316
+ format: external_exports.literal(CACHE_FORMAT),
93317
+ generation: generationSchema,
93318
+ fingerprint: external_exports.string(),
93319
+ inspections: external_exports.array(
93320
+ external_exports.object({
93321
+ model: external_exports.string().nullable(),
93322
+ result: external_exports.discriminatedUnion("kind", [
93323
+ external_exports.object({
93324
+ kind: external_exports.literal("snapshot"),
93325
+ agentName: external_exports.string(),
93326
+ agentVersion: external_exports.string(),
93327
+ configOptions: external_exports.unknown(),
93328
+ modelEffort: modelEffortSchema
93329
+ }),
93330
+ external_exports.object({
93331
+ kind: external_exports.literal("unavailable"),
93332
+ configId: external_exports.string(),
93333
+ requestedValue: external_exports.string(),
93334
+ offeredValues: external_exports.array(external_exports.string())
93335
+ })
93336
+ ])
93337
+ })
93338
+ ).max(1001)
93339
+ });
93340
+ function hash2(value) {
93341
+ return createHash9("sha256").update(JSON.stringify(value)).digest("hex");
93342
+ }
93343
+ async function readCache(path6) {
93344
+ const result = await readInstallationFile(path6, CACHE_FILE_LIMIT);
93345
+ return result.kind === "read" ? cacheSchema.parse(JSON.parse(result.text)) : void 0;
93346
+ }
93347
+ var AgentSettingsCache = class {
93348
+ #directory;
93349
+ #generationPath;
93350
+ #generation = 0;
93351
+ constructor(stateDirectory) {
93352
+ this.#directory = join30(stateDirectory, "agent-settings");
93353
+ this.#generationPath = join30(this.#directory, "generation");
93354
+ }
93355
+ get generation() {
93356
+ return this.#generation;
93357
+ }
93358
+ invalidate = async (signal) => {
93359
+ await writeInstallationFile(this.#generationPath, randomUUID17(), signal);
93360
+ this.#generation += 1;
93361
+ };
93362
+ open = async (agent2, signal) => {
93363
+ const inspections = /* @__PURE__ */ new Map();
93364
+ const path6 = join30(this.#directory, `${hash2(agent2.id)}.json`);
93365
+ const fingerprint = hash2([
93366
+ agent2.agentVersion,
93367
+ agent2.adapterVersion,
93368
+ agent2.runtimeExecutables,
93369
+ // An installation can serve different harness profiles, which may expose different providers.
93370
+ [
93371
+ "HOME",
93372
+ "USERPROFILE",
93373
+ "CODEX_HOME",
93374
+ "CLAUDE_CONFIG_DIR",
93375
+ "XDG_CONFIG_HOME",
93376
+ "OPENCODE_CONFIG_DIR",
93377
+ "OPENCODE_CONFIG",
93378
+ "PI_CODING_AGENT_DIR"
93379
+ ].map((name2) => agent2.environment[name2])
93380
+ ]);
93381
+ let generation;
93382
+ try {
93383
+ generation = await this.#readGeneration();
93384
+ } catch {
93385
+ signal.throwIfAborted();
93386
+ return { inspections, save: async () => void 0 };
93387
+ }
93388
+ try {
93389
+ const cached2 = await readCache(path6);
93390
+ if (cached2?.generation === generation && cached2.fingerprint === fingerprint) {
93391
+ for (const { model, result } of cached2.inspections) {
93392
+ inspections.set(
93393
+ model ?? void 0,
93394
+ result.kind === "snapshot" ? new AgentSettingsSnapshot(
93395
+ result.agentName,
93396
+ result.agentVersion,
93397
+ decodeSessionConfigOptions(result.configOptions),
93398
+ result.modelEffort
93399
+ ) : new AcpConfigurationValueUnavailableError(
93400
+ result.configId,
93401
+ result.requestedValue,
93402
+ result.offeredValues
93403
+ )
93404
+ );
93405
+ }
93406
+ }
93407
+ } catch {
93408
+ inspections.clear();
93409
+ }
93410
+ signal.throwIfAborted();
93411
+ return {
93412
+ inspections,
93413
+ save: async (saveSignal) => {
93414
+ const data = JSON.stringify({
93415
+ format: CACHE_FORMAT,
93416
+ fingerprint,
93417
+ generation,
93418
+ inspections: [...inspections].map(([model, result]) => ({
93419
+ model: model ?? null,
93420
+ result: result instanceof AcpConfigurationValueUnavailableError ? {
93421
+ kind: "unavailable",
93422
+ configId: result.configId,
93423
+ requestedValue: result.requestedValue,
93424
+ offeredValues: result.offeredValues
93425
+ } : {
93426
+ kind: "snapshot",
93427
+ ...result,
93428
+ // Only the base snapshot supplies the complete native model catalog.
93429
+ modelEffort: model === void 0 ? result.modelEffort : { kind: "unavailable" }
93430
+ }
93431
+ }))
93432
+ });
93433
+ try {
93434
+ if (Buffer.byteLength(data) <= CACHE_FILE_LIMIT && generation === await this.#readGeneration()) {
93435
+ await writeInstallationFile(path6, data, saveSignal);
93436
+ }
93437
+ } catch {
93438
+ saveSignal.throwIfAborted();
93439
+ }
93440
+ }
93441
+ };
93442
+ };
93443
+ #readGeneration = async () => {
93444
+ const result = await readInstallationFile(this.#generationPath);
93445
+ if (result.kind === "missing") {
93446
+ return "initial";
93447
+ }
93448
+ if (result.kind === "read") {
93449
+ return generationSchema.parse(result.text);
93450
+ }
93451
+ throw new Error("The Agent settings cache generation cannot be read");
93452
+ };
93453
+ };
93454
+
93163
93455
  // src/engine/runtime/relay/diagnostics.ts
93164
93456
  var MAX_DIAGNOSTIC_TEXT_LENGTH = 256;
93165
93457
  function sanitizeDiagnosticText(value) {
@@ -93401,7 +93693,7 @@ function discoveredEvent(command, agents) {
93401
93693
  };
93402
93694
  }
93403
93695
  function createAgentCatalogDiscoveryHandler(dependencies) {
93404
- const { config: config2, discover, diagnostics, socket, signal, timer } = dependencies;
93696
+ const { config: config2, discover, invalidateAgentSettings, diagnostics, socket, signal, timer } = dependencies;
93405
93697
  const requestIds = /* @__PURE__ */ new Set();
93406
93698
  let controller = null;
93407
93699
  let completion = null;
@@ -93427,6 +93719,7 @@ function createAgentCatalogDiscoveryHandler(dependencies) {
93427
93719
  completion = (async () => {
93428
93720
  try {
93429
93721
  const published = await refreshAgentCatalog(config2, discover, operationSignal);
93722
+ await invalidateAgentSettings(operationSignal);
93430
93723
  operationSignal.throwIfAborted();
93431
93724
  if (socket.readyState === WebSocket3.OPEN) {
93432
93725
  send(
@@ -93477,6 +93770,7 @@ function createAgentCatalogCommands(context) {
93477
93770
  discover: context.config.rediscoverAgents === void 0 ? () => {
93478
93771
  throw new Error("Agent catalog discovery is not available for this Runtime");
93479
93772
  } : context.config.rediscoverAgents,
93773
+ invalidateAgentSettings: context.settingsCache.invalidate,
93480
93774
  diagnostics: context.diagnostics,
93481
93775
  socket: context.socket,
93482
93776
  signal: context.signal,
@@ -93508,7 +93802,7 @@ var SessionError = class extends OperationError {
93508
93802
  };
93509
93803
 
93510
93804
  // src/engine/session/settings/discover-agent-settings.ts
93511
- import { createHash as createHash9 } from "node:crypto";
93805
+ import { createHash as createHash10 } from "node:crypto";
93512
93806
 
93513
93807
  // src/engine/agent/settings/agent-settings-base.ts
93514
93808
  var AgentSettingsLaunchSelectionResult = class {
@@ -93578,23 +93872,56 @@ function isUnavailableModel(cause, modelSettingId, requestedModel) {
93578
93872
  function unsupportedModelIds(unsupportedModels) {
93579
93873
  return [...new Set(unsupportedModels.map((item) => item.requestedValue))];
93580
93874
  }
93581
- async function discoverAgentSettings(command, resolveAgent, bindingId, directories, sessions, signal) {
93582
- const { agent: agent2, adapter: harnessAdapter } = await resolveAgent(command.agentId, signal);
93583
- const directoryId = command.directoryId ?? "default";
93584
- const cwd = await directories.resolve(bindingId, directoryId, signal);
93585
- const inspectedBaseSnapshot = await sessions.inspectAgentSettings({
93586
- adapter: harnessAdapter,
93587
- additionalDirectories: [],
93588
- agent: agent2,
93589
- cwd,
93590
- signal
93591
- });
93592
- const baseSnapshot = {
93593
- agentName: inspectedBaseSnapshot.agentName,
93594
- agentVersion: inspectedBaseSnapshot.agentVersion,
93595
- configOptions: inspectedBaseSnapshot.configOptions,
93596
- modelEffort: inspectedBaseSnapshot.modelEffort
93875
+ async function discoverAgentSettings(command, resolveAgent, bindingId, directories, sessions, settingsCache, signal) {
93876
+ const { agent: agent2, adapter } = await resolveAgent(command.agentId, signal);
93877
+ const directoryId = command.directoryId;
93878
+ const cache = directoryId === void 0 ? await settingsCache.open(agent2, signal) : void 0;
93879
+ const inspections = cache?.inspections ?? /* @__PURE__ */ new Map();
93880
+ const initialSize = inspections.size;
93881
+ let cwd;
93882
+ let probeDirectory;
93883
+ const inspect = async (model) => {
93884
+ signal.throwIfAborted();
93885
+ const cached2 = inspections.get(model);
93886
+ if (cached2 instanceof AcpConfigurationValueUnavailableError) {
93887
+ throw cached2;
93888
+ }
93889
+ if (cached2 !== void 0) {
93890
+ return cached2;
93891
+ }
93892
+ if (cwd === void 0) {
93893
+ if (directoryId === void 0) {
93894
+ probeDirectory = await createTemporaryDirectory("mobius-agent-settings-");
93895
+ cwd = probeDirectory.path;
93896
+ } else {
93897
+ cwd = await directories.resolve(bindingId, directoryId, signal);
93898
+ }
93899
+ }
93900
+ return await sessions.inspectAgentSettings(
93901
+ {
93902
+ adapter,
93903
+ additionalDirectories: [],
93904
+ agent: agent2,
93905
+ cwd,
93906
+ ...model === void 0 ? {} : { model },
93907
+ signal
93908
+ },
93909
+ inspections
93910
+ );
93597
93911
  };
93912
+ try {
93913
+ const result = await collectAgentSettings(command, agent2, inspect, signal);
93914
+ if (inspections.size !== initialSize) {
93915
+ await cache?.save(signal);
93916
+ }
93917
+ signal.throwIfAborted();
93918
+ return result;
93919
+ } finally {
93920
+ await probeDirectory?.dispose();
93921
+ }
93922
+ }
93923
+ async function collectAgentSettings(command, agent2, inspect, signal) {
93924
+ const baseSnapshot = await inspect();
93598
93925
  const baseModel = modelOption(baseSnapshot.configOptions);
93599
93926
  const unsupportedModels = [];
93600
93927
  let selectedSnapshot = baseSnapshot;
@@ -93609,14 +93936,7 @@ async function discoverAgentSettings(command, resolveAgent, bindingId, directori
93609
93936
  );
93610
93937
  } else {
93611
93938
  try {
93612
- selectedSnapshot = await sessions.inspectAgentSettings({
93613
- adapter: harnessAdapter,
93614
- additionalDirectories: [],
93615
- agent: agent2,
93616
- cwd,
93617
- model: command.model,
93618
- signal
93619
- });
93939
+ selectedSnapshot = await inspect(command.model);
93620
93940
  } catch (cause) {
93621
93941
  signal.throwIfAborted();
93622
93942
  if (!isUnavailableModel(cause, baseModel.id, command.model)) {
@@ -93627,25 +93947,21 @@ async function discoverAgentSettings(command, resolveAgent, bindingId, directori
93627
93947
  }
93628
93948
  }
93629
93949
  const adapter = agentSettingsAdapterForAgent(agent2.id);
93630
- const modelEffort = await discoverModelEffort(
93631
- command,
93632
- agent2,
93633
- harnessAdapter,
93950
+ const { modelEffort, effort } = await discoverModelEffort(
93634
93951
  adapter.modelEffortResolution,
93635
93952
  baseSnapshot.configOptions,
93636
- selectedSnapshot.configOptions,
93637
93953
  unsupportedModels,
93638
93954
  baseSnapshot.modelEffort,
93639
- cwd,
93640
- sessions,
93955
+ inspect,
93641
93956
  signal
93642
93957
  );
93958
+ const baseOptions = effort === void 0 || effortOption(baseSnapshot.configOptions) !== void 0 ? baseSnapshot.configOptions : [...baseSnapshot.configOptions, { ...effort, currentValue: "" }];
93643
93959
  const baseSettings = withoutUnsupportedModels(
93644
- settingsFromSnapshot(agent2, baseSnapshot.configOptions),
93960
+ settingsFromSnapshot(agent2, baseOptions),
93645
93961
  baseModel?.id ?? "",
93646
93962
  modelEffort.unsupportedModelIds
93647
93963
  );
93648
- const settings = withoutUnsupportedModels(
93964
+ const settings = command.model === void 0 ? baseSettings : withoutUnsupportedModels(
93649
93965
  settingsFromSnapshot(agent2, selectedSnapshot.configOptions),
93650
93966
  baseModel?.id ?? "",
93651
93967
  modelEffort.unsupportedModelIds
@@ -93655,7 +93971,7 @@ async function discoverAgentSettings(command, resolveAgent, bindingId, directori
93655
93971
  agentId: command.agentId,
93656
93972
  agentName: selectedSnapshot.agentName,
93657
93973
  agentVersion: selectedSnapshot.agentVersion,
93658
- directoryId,
93974
+ directoryId: command.directoryId ?? "default",
93659
93975
  kind: AGENT_SETTINGS_DISCOVERED_KIND,
93660
93976
  modelEffort,
93661
93977
  requestId: command.requestId,
@@ -93729,33 +94045,45 @@ function unavailableModelEffort() {
93729
94045
  valuesByModel: {}
93730
94046
  };
93731
94047
  }
93732
- async function discoverModelEffort(command, agent2, harnessAdapter, resolution, initialOptions, selectedOptions, initiallyUnsupportedModels, discoveredModelEffort, cwd, sessions, signal) {
94048
+ async function discoverModelEffort(resolution, initialOptions, initiallyUnsupportedModels, discoveredModelEffort, inspect, signal) {
93733
94049
  const model = modelOption(initialOptions);
93734
94050
  const unsupportedModels = initiallyUnsupportedModels;
93735
94051
  if (resolution !== AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE && resolution !== AGENT_MODEL_EFFORT_RESOLUTION_ON_MODEL_SELECTION) {
93736
- return { ...unavailableModelEffort(), unsupportedModelIds: unsupportedModelIds(unsupportedModels) };
94052
+ return {
94053
+ modelEffort: { ...unavailableModelEffort(), unsupportedModelIds: unsupportedModelIds(unsupportedModels) }
94054
+ };
93737
94055
  }
93738
94056
  if (model === void 0 || model.type !== "select" || model.values.length === 0) {
93739
- return { ...unavailableModelEffort(), unsupportedModelIds: unsupportedModelIds(unsupportedModels) };
94057
+ return {
94058
+ modelEffort: { ...unavailableModelEffort(), unsupportedModelIds: unsupportedModelIds(unsupportedModels) }
94059
+ };
93740
94060
  }
94061
+ const inspectModel = async (model2) => (await inspect(model2)).configOptions;
93741
94062
  if (resolution === AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE && discoveredModelEffort.kind === "complete" && discoveredModelEffort.value.resolution === AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE) {
93742
- return discoveredModelEffort.value;
94063
+ for (const { value } of model.values) {
94064
+ if (value !== model.currentValue) {
94065
+ try {
94066
+ await inspectModel(value);
94067
+ } catch (cause) {
94068
+ signal.throwIfAborted();
94069
+ if (!isUnavailableModel(cause, model.id, value)) {
94070
+ throw cause;
94071
+ }
94072
+ unsupportedModels.push(cause);
94073
+ }
94074
+ }
94075
+ }
94076
+ return { modelEffort: discoveredModelEffort.value };
93743
94077
  }
93744
- const inspectModel = async (modelValue) => (await sessions.inspectAgentSettings({
93745
- adapter: harnessAdapter,
93746
- additionalDirectories: [],
93747
- agent: agent2,
93748
- cwd,
93749
- model: modelValue,
93750
- signal
93751
- })).configOptions;
93752
- const valuesByModel = {};
94078
+ const valuesByModel = /* @__PURE__ */ new Map();
93753
94079
  if (resolution === "complete") {
93754
- const effort = effortOption(initialOptions);
93755
- if (effort === void 0 || effort.type !== "select" || effort.values.length < 2) {
94080
+ const effort2 = effortOption(initialOptions);
94081
+ if (effort2 === void 0 || effort2.type !== "select" || effort2.values.length < 2) {
93756
94082
  return {
93757
- ...unavailableModelEffort(),
93758
- unsupportedModelIds: unsupportedModelIds(unsupportedModels)
94083
+ modelEffort: {
94084
+ ...unavailableModelEffort(),
94085
+ unsupportedModelIds: unsupportedModelIds(unsupportedModels)
94086
+ }
93759
94087
  };
93760
94088
  }
93761
94089
  for (const value of model.values) {
@@ -93763,8 +94091,8 @@ async function discoverModelEffort(command, agent2, harnessAdapter, resolution,
93763
94091
  continue;
93764
94092
  }
93765
94093
  try {
93766
- const selectedEffort2 = effortOption(await inspectModel(value.value));
93767
- valuesByModel[value.value] = selectedEffort2?.type === "select" ? selectedEffort2.values : [];
94094
+ const selectedEffort = effortOption(await inspectModel(value.value));
94095
+ valuesByModel.set(value.value, selectedEffort?.type === "select" ? selectedEffort.values : []);
93768
94096
  } catch (cause) {
93769
94097
  signal.throwIfAborted();
93770
94098
  if (!isUnavailableModel(cause, model.id, value.value)) {
@@ -93774,80 +94102,77 @@ async function discoverModelEffort(command, agent2, harnessAdapter, resolution,
93774
94102
  }
93775
94103
  }
93776
94104
  return {
93777
- effortSettingId: effort.id,
93778
- modelSettingId: model.id,
93779
- resolution: "complete",
93780
- unsupportedModelIds: unsupportedModelIds(unsupportedModels),
93781
- valuesByModel
94105
+ modelEffort: {
94106
+ effortSettingId: effort2.id,
94107
+ modelSettingId: model.id,
94108
+ resolution: "complete",
94109
+ unsupportedModelIds: unsupportedModelIds(unsupportedModels),
94110
+ valuesByModel: Object.fromEntries(valuesByModel)
94111
+ }
93782
94112
  };
93783
94113
  }
93784
- if (command.model !== void 0) {
93785
- const modelUnsupported = unsupportedModels.some((diagnostic) => diagnostic.requestedValue === command.model);
93786
- const selectedEffort2 = effortOption(selectedOptions);
93787
- if (!modelUnsupported) {
93788
- valuesByModel[command.model] = selectedEffort2?.type === "select" ? selectedEffort2.values : [];
94114
+ const defaultEffort = effortOption(initialOptions);
94115
+ let effort = defaultEffort;
94116
+ for (const value of model.values) {
94117
+ if (unsupportedModels.some((diagnostic) => diagnostic.requestedValue === value.value)) {
94118
+ continue;
93789
94119
  }
93790
- return {
93791
- effortSettingId: selectedEffort2?.id ?? "",
93792
- modelSettingId: model.id,
93793
- resolution: "on_model_selection",
93794
- unsupportedModelIds: unsupportedModelIds(unsupportedModels),
93795
- valuesByModel
93796
- };
93797
- }
93798
- const defaultModel = model.type === "select" ? model.currentValue : "";
93799
- const reportedEffort = effortOption(selectedOptions);
93800
- let selectedEffort = reportedEffort;
93801
- if (defaultModel.length > 0 && reportedEffort === void 0) {
93802
94120
  try {
93803
- selectedEffort = effortOption(await inspectModel(defaultModel));
94121
+ const inspectedEffort = effortOption(await inspectModel(value.value));
94122
+ const selectedEffort = value.value === model.currentValue ? defaultEffort ?? inspectedEffort : inspectedEffort;
94123
+ effort ??= selectedEffort;
94124
+ valuesByModel.set(value.value, selectedEffort?.type === "select" ? selectedEffort.values : []);
93804
94125
  } catch (cause) {
93805
94126
  signal.throwIfAborted();
93806
- if (!isUnavailableModel(cause, model.id, defaultModel)) {
94127
+ if (!isUnavailableModel(cause, model.id, value.value)) {
93807
94128
  throw cause;
93808
94129
  }
93809
94130
  unsupportedModels.push(cause);
93810
94131
  }
93811
94132
  }
93812
- if (defaultModel.length > 0 && !unsupportedModels.some((diagnostic) => diagnostic.requestedValue === defaultModel)) {
93813
- valuesByModel[defaultModel] = selectedEffort?.type === "select" ? selectedEffort.values : [];
93814
- }
93815
94133
  return {
93816
- effortSettingId: selectedEffort?.id ?? "",
93817
- modelSettingId: model.id,
93818
- resolution: "on_model_selection",
93819
- unsupportedModelIds: unsupportedModelIds(unsupportedModels),
93820
- valuesByModel
94134
+ ...effort === void 0 ? {} : { effort },
94135
+ modelEffort: {
94136
+ effortSettingId: effort?.id ?? "",
94137
+ modelSettingId: model.id,
94138
+ resolution: "on_model_selection",
94139
+ unsupportedModelIds: unsupportedModelIds(unsupportedModels),
94140
+ valuesByModel: Object.fromEntries(valuesByModel)
94141
+ }
93821
94142
  };
93822
94143
  }
93823
94144
  function settingsRevision(agent2, reportedAgentVersion, settings, modelEffort) {
93824
- const revisionModelEffort = modelEffort.resolution === AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE ? modelEffort : {
93825
- effortSettingId: "",
93826
- modelSettingId: modelEffort.modelSettingId,
93827
- resolution: modelEffort.resolution,
93828
- unsupportedModelIds: modelEffort.unsupportedModelIds,
93829
- valuesByModel: {}
93830
- };
93831
- return createHash9("sha256").update(
93832
- JSON.stringify({
93833
- adapterVersion: agent2.adapterVersion,
93834
- agentId: agent2.id,
93835
- agentVersion: agent2.agentVersion,
93836
- modelEffort: revisionModelEffort,
93837
- reportedAgentVersion,
93838
- settings
93839
- })
94145
+ return createHash10("sha256").update(
94146
+ JSON.stringify(
94147
+ {
94148
+ adapterVersion: agent2.adapterVersion,
94149
+ agentId: agent2.id,
94150
+ agentVersion: agent2.agentVersion,
94151
+ modelEffort,
94152
+ reportedAgentVersion,
94153
+ settings
94154
+ },
94155
+ (_key, value) => {
94156
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
94157
+ return value;
94158
+ }
94159
+ return Object.fromEntries(
94160
+ Object.entries(value).sort(([left], [right]) => left < right ? -1 : Number(left > right))
94161
+ );
94162
+ }
94163
+ )
93840
94164
  ).digest("hex");
93841
94165
  }
93842
94166
 
93843
94167
  // src/engine/runtime/command/agent-settings-discovery.ts
93844
94168
  function createAgentSettingsDiscoveryHandler(dependencies) {
93845
- const { config: config2, directories, sessions, diagnostics, socket, signal, timer } = dependencies;
94169
+ const { config: config2, directories, sessions, settingsCache, diagnostics, socket, signal, timer } = dependencies;
93846
94170
  const agentSettingsDiscoveries = /* @__PURE__ */ new Map();
93847
94171
  const handle = (command) => {
93848
- const directoryId = command.directoryId ?? "default";
94172
+ const directoryId = command.directoryId;
94173
+ const generation = settingsCache.generation;
93849
94174
  const existing = [...agentSettingsDiscoveries.values()].find(
93850
- (request) => request.agentId === command.agentId && request.directoryId === directoryId && !request.controller.signal.aborted
94175
+ (request) => request.agentId === command.agentId && request.directoryId === directoryId && request.generation === generation && !request.controller.signal.aborted
93851
94176
  );
93852
94177
  if ([...agentSettingsDiscoveries.values()].some((request) => request.requestIds.has(command.requestId))) {
93853
94178
  if (socket.readyState === WebSocket4.OPEN) {
@@ -93903,6 +94228,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
93903
94228
  config2.bindingId,
93904
94229
  directories,
93905
94230
  sessions,
94231
+ settingsCache,
93906
94232
  operationSignal
93907
94233
  );
93908
94234
  for (const diagnostic of result.unsupportedModels) {
@@ -93946,6 +94272,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
93946
94272
  agentSettingsDiscoveries.set(command.requestId, {
93947
94273
  agentId: command.agentId,
93948
94274
  directoryId,
94275
+ generation,
93949
94276
  model: command.model,
93950
94277
  requestIds,
93951
94278
  completion,
@@ -93967,6 +94294,7 @@ function createAgentSettingsCommands(context) {
93967
94294
  directories: context.directories,
93968
94295
  diagnostics: context.diagnostics,
93969
94296
  sessions: context.sessions,
94297
+ settingsCache: context.settingsCache,
93970
94298
  signal: context.signal,
93971
94299
  socket: context.socket,
93972
94300
  timer: context.timer
@@ -93986,7 +94314,7 @@ function createAgentSettingsCommands(context) {
93986
94314
  }
93987
94315
 
93988
94316
  // src/engine/runtime/command/registry/content-write/index.ts
93989
- import { createHash as createHash10 } from "node:crypto";
94317
+ import { createHash as createHash11 } from "node:crypto";
93990
94318
  function createContentWriteCommands(context) {
93991
94319
  const pending = /* @__PURE__ */ new Map();
93992
94320
  const operations = /* @__PURE__ */ new Set();
@@ -94016,7 +94344,7 @@ function createContentWriteCommands(context) {
94016
94344
  pending.set(message.requestId, {
94017
94345
  bytes: new Uint8Array(message.byteLength),
94018
94346
  command: message,
94019
- hash: createHash10("sha256"),
94347
+ hash: createHash11("sha256"),
94020
94348
  receivedBytes: 0,
94021
94349
  sequence: 0
94022
94350
  });
@@ -94110,7 +94438,7 @@ function createContentWriteCommands(context) {
94110
94438
  import { WebSocket as WebSocket5 } from "undici";
94111
94439
 
94112
94440
  // src/engine/session/content/session-files.ts
94113
- import { basename as basename8, extname as extname3, isAbsolute as isAbsolute16, join as join29, normalize as normalize3, resolve as resolve16 } from "node:path";
94441
+ import { basename as basename8, extname as extname3, isAbsolute as isAbsolute16, join as join31, normalize as normalize3, resolve as resolve16 } from "node:path";
94114
94442
  import { fileURLToPath as fileURLToPath2 } from "node:url";
94115
94443
  function requestedPath(value) {
94116
94444
  if (value.includes("\0")) {
@@ -94134,7 +94462,7 @@ async function resolveFile(value, workingDirectory, signal) {
94134
94462
  if (isAbsolute16(requested.path) && normalize3(requested.path) !== requested.path) {
94135
94463
  return null;
94136
94464
  }
94137
- const candidates = requested.explicitUrl || workingDirectory === null ? [requested.path] : isAbsolute16(requested.path) ? [join29(workingDirectory, requested.path), requested.path] : [resolve16(workingDirectory, requested.path)];
94465
+ const candidates = requested.explicitUrl || workingDirectory === null ? [requested.path] : isAbsolute16(requested.path) ? [join31(workingDirectory, requested.path), requested.path] : [resolve16(workingDirectory, requested.path)];
94138
94466
  for (const candidate of candidates) {
94139
94467
  if (!isAbsolute16(candidate) || normalize3(candidate) !== candidate) {
94140
94468
  continue;
@@ -94554,7 +94882,7 @@ async function resolveSessionDirectories(directories, bindingId, directoryId, ad
94554
94882
  }
94555
94883
 
94556
94884
  // src/engine/session/prompt/apply-session-configuration.ts
94557
- import { randomUUID as randomUUID17 } from "node:crypto";
94885
+ import { randomUUID as randomUUID18 } from "node:crypto";
94558
94886
  function invalidSessionConfiguration(message) {
94559
94887
  return new AcpExecutionError(message, {}, "invalid_session_configuration");
94560
94888
  }
@@ -94679,7 +95007,7 @@ async function applySessionConfigurationSelection(sessions, options, selection,
94679
95007
  booleanValue: selection.booleanValue,
94680
95008
  configId: selection.configId,
94681
95009
  cwd,
94682
- requestId: `cfg_${randomUUID17()}`,
95010
+ requestId: `cfg_${randomUUID18()}`,
94683
95011
  sessionId,
94684
95012
  signal,
94685
95013
  value: selection.value,
@@ -95789,6 +96117,7 @@ async function runRelayConnection({
95789
96117
  eventProjection,
95790
96118
  externalContent,
95791
96119
  sessions,
96120
+ settingsCache,
95792
96121
  connectionEpoch,
95793
96122
  diagnostics,
95794
96123
  onConnected,
@@ -95807,6 +96136,7 @@ async function runRelayConnection({
95807
96136
  config: config2,
95808
96137
  directories,
95809
96138
  sessions,
96139
+ settingsCache,
95810
96140
  nativeSessions,
95811
96141
  operations,
95812
96142
  eventProjection,
@@ -96220,6 +96550,7 @@ async function runRuntime(config2, parentSignal, timer = systemTimer, options =
96220
96550
  const shutdown = new AbortController();
96221
96551
  const signal = AbortSignal.any([parentSignal, shutdown.signal]);
96222
96552
  const stateDirectory = config2.localContext.stateDirectory;
96553
+ const settingsCache = new AgentSettingsCache(stateDirectory);
96223
96554
  const diagnostics = new RelayConnectionDiagnostics(
96224
96555
  config2.channelId,
96225
96556
  config2.relayUrl,
@@ -96317,6 +96648,7 @@ async function runRuntime(config2, parentSignal, timer = systemTimer, options =
96317
96648
  resolveAgent,
96318
96649
  directories,
96319
96650
  sessions: agentRuntime,
96651
+ settingsCache,
96320
96652
  nativeSessions,
96321
96653
  operations,
96322
96654
  publisher,
@@ -96626,4 +96958,4 @@ export {
96626
96958
  * MIT Licensed
96627
96959
  *)
96628
96960
  */
96629
- //# sourceMappingURL=chunk-INF4TYV5.js.map
96961
+ //# sourceMappingURL=chunk-CDY4OZQN.js.map