@moxt-ai/mobius 0.0.439 → 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-FDHUTFPW.js → chunk-CDY4OZQN.js} +501 -242
  2. package/dist/{chunk-FDHUTFPW.js.map → chunk-CDY4OZQN.js.map} +4 -4
  3. package/dist/{chunk-J2RRCJX6.js → chunk-SABVCCTQ.js} +2 -2
  4. package/dist/{chunk-J2RRCJX6.js.map → chunk-SABVCCTQ.js.map} +1 -1
  5. package/dist/{cli-2UKL4IVX.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-2UKL4IVX.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-J2RRCJX6.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) => {
@@ -71239,12 +71246,12 @@ var ClaudeAgentConnection = class extends EndpointAgentConnection {
71239
71246
  // src/engine/util/process/executable.ts
71240
71247
  import { spawn as spawn3 } from "node:child_process";
71241
71248
  import { stat as stat5 } from "node:fs/promises";
71242
- import { join as join15, resolve as resolve9 } from "node:path";
71249
+ import { join as join16, resolve as resolve9 } from "node:path";
71243
71250
 
71244
71251
  // src/engine/util/process/platform/linux.ts
71245
71252
  import { constants as constants4, readdirSync as readdirSync3, readFileSync as readFileSync2 } from "node:fs";
71246
71253
  import { access as access3, readdir as readdir5, readFile as readFile4, realpath as realpath5, stat as stat4 } from "node:fs/promises";
71247
- import { join as join13 } from "node:path";
71254
+ import { join as join14 } from "node:path";
71248
71255
 
71249
71256
  // src/engine/util/process/platform/posix.ts
71250
71257
  import { execFile as execFile3 } from "node:child_process";
@@ -71374,7 +71381,7 @@ async function readLinuxProcessTable() {
71374
71381
  appendLinuxProcessTableEntry(
71375
71382
  entries,
71376
71383
  processId,
71377
- await readFile4(join13("/proc", directory.name, "stat"), "utf8")
71384
+ await readFile4(join14("/proc", directory.name, "stat"), "utf8")
71378
71385
  );
71379
71386
  } catch {
71380
71387
  }
@@ -71399,7 +71406,7 @@ function readLinuxProcessTableSynchronously() {
71399
71406
  appendLinuxProcessTableEntry(
71400
71407
  entries,
71401
71408
  processId,
71402
- readFileSync2(join13("/proc", directory.name, "stat"), "utf8")
71409
+ readFileSync2(join14("/proc", directory.name, "stat"), "utf8")
71403
71410
  );
71404
71411
  } catch {
71405
71412
  }
@@ -71432,7 +71439,7 @@ async function readLinuxProcessTableWithFallback() {
71432
71439
  }
71433
71440
  function processExists2(processId) {
71434
71441
  try {
71435
- const encoded = readFileSync2(join13("/proc", processId.toString(), "stat"), "utf8");
71442
+ const encoded = readFileSync2(join14("/proc", processId.toString(), "stat"), "utf8");
71436
71443
  const closingParenthesis = encoded.lastIndexOf(")");
71437
71444
  if (closingParenthesis >= 0) {
71438
71445
  const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
@@ -71462,7 +71469,7 @@ var macosProcessPlatform = {
71462
71469
  // src/engine/util/process/platform/windows.ts
71463
71470
  import { execFile as execFile4 } from "node:child_process";
71464
71471
  import { readFile as readFile5, realpath as realpath6 } from "node:fs/promises";
71465
- 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";
71466
71473
 
71467
71474
  // src/engine/util/process/process-error.ts
71468
71475
  var ProcessExecutionError = class extends Error {
@@ -71541,7 +71548,7 @@ function readProcessTable() {
71541
71548
  }
71542
71549
  return new Promise((resolveTable) => {
71543
71550
  execFile4(
71544
- join14(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
71551
+ join15(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
71545
71552
  [
71546
71553
  "-NoLogo",
71547
71554
  "-NoProfile",
@@ -71677,7 +71684,7 @@ async function findExecutableOnPath(executableName, environment, platform2 = pro
71677
71684
  continue;
71678
71685
  }
71679
71686
  for (const extension of extensions) {
71680
- const requestedPath2 = resolve9(join15(entry, `${executableName}${extension}`));
71687
+ const requestedPath2 = resolve9(join16(entry, `${executableName}${extension}`));
71681
71688
  const executable = await resolveExecutablePath(requestedPath2, platform2);
71682
71689
  if (executable !== null) {
71683
71690
  return executable;
@@ -75063,13 +75070,13 @@ var CodexAgentSpecification = class extends InProcessAcpAgentSpecification {
75063
75070
 
75064
75071
  // src/engine/agent/specification/vendors/pi-agent.ts
75065
75072
  import { createHash as createHash3 } from "node:crypto";
75066
- import { join as join21 } from "node:path";
75073
+ import { join as join22 } from "node:path";
75067
75074
 
75068
75075
  // src/engine/acp/harness/pi/upstream/dist/acp/agent.js
75069
75076
  import { spawnSync } from "node:child_process";
75070
75077
  import { randomUUID as randomUUID11 } from "node:crypto";
75071
75078
  import { existsSync as existsSync8, readdirSync as readdirSync6, readFileSync as readFileSync9, realpathSync as realpathSync3, statSync as statSync3, unlinkSync as unlinkSync2 } from "node:fs";
75072
- 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";
75073
75080
 
75074
75081
  // src/engine/acp/harness/pi/upstream/dist/pi-rpc/process.js
75075
75082
  import { spawn as spawn5 } from "node:child_process";
@@ -75525,7 +75532,7 @@ function maybeAuthRequiredError(err) {
75525
75532
  }
75526
75533
 
75527
75534
  // src/engine/acp/harness/pi/upstream/dist/acp/paths.js
75528
- import { join as join16 } from "node:path";
75535
+ import { join as join17 } from "node:path";
75529
75536
 
75530
75537
  // src/engine/acp/harness/pi/upstream/dist/acp/environment.js
75531
75538
  import { homedir as homedir2 } from "node:os";
@@ -75535,10 +75542,10 @@ function environmentHome(environment) {
75535
75542
 
75536
75543
  // src/engine/acp/harness/pi/upstream/dist/acp/paths.js
75537
75544
  function getPiAcpDir(environment = process.env) {
75538
- return join16(environmentHome(environment), ".pi", "pi-acp");
75545
+ return join17(environmentHome(environment), ".pi", "pi-acp");
75539
75546
  }
75540
75547
  function getPiAcpSessionMapPath(environment = process.env) {
75541
- return join16(getPiAcpDir(environment), "session-map.json");
75548
+ return join17(getPiAcpDir(environment), "session-map.json");
75542
75549
  }
75543
75550
 
75544
75551
  // src/engine/acp/harness/pi/upstream/dist/acp/pi-commands.js
@@ -75660,15 +75667,15 @@ async function readPiLatestEntryId(sessionFile) {
75660
75667
 
75661
75668
  // src/engine/acp/harness/pi/upstream/dist/acp/pi-sessions.js
75662
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";
75663
- 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";
75664
75671
  var DEFAULT_TAIL_BYTES = 256 * 1024;
75665
75672
  var DEFAULT_HEAD_BYTES = 64 * 1024;
75666
75673
  function getPiAgentDir(environment) {
75667
75674
  const configured = environment["PI_CODING_AGENT_DIR"];
75668
- return configured ? resolve10(configured) : join17(environmentHome(environment), ".pi", "agent");
75675
+ return configured ? resolve10(configured) : join18(environmentHome(environment), ".pi", "agent");
75669
75676
  }
75670
75677
  function readSessionDirFromSettings(agentDir) {
75671
- const settingsPath = join17(agentDir, "settings.json");
75678
+ const settingsPath = join18(agentDir, "settings.json");
75672
75679
  try {
75673
75680
  if (!existsSync5(settingsPath)) {
75674
75681
  return null;
@@ -75689,7 +75696,7 @@ function readSessionDirFromSettings(agentDir) {
75689
75696
  }
75690
75697
  function getPiSessionsDir(environment = process.env) {
75691
75698
  const agentDir = getPiAgentDir(environment);
75692
- return readSessionDirFromSettings(agentDir) ?? join17(agentDir, "sessions");
75699
+ return readSessionDirFromSettings(agentDir) ?? join18(agentDir, "sessions");
75693
75700
  }
75694
75701
  function getPiSessionDiscoveryDirs(environment) {
75695
75702
  const discoveryDirectories = [getPiSessionsDir(environment)];
@@ -75700,7 +75707,7 @@ function getPiSessionDiscoveryDirs(environment) {
75700
75707
  if (!entry.isDirectory()) {
75701
75708
  continue;
75702
75709
  }
75703
- const directory = join17(mobiusSessionsRoot, entry.name);
75710
+ const directory = join18(mobiusSessionsRoot, entry.name);
75704
75711
  if (!discoveryDirectories.includes(directory)) {
75705
75712
  discoveryDirectories.push(directory);
75706
75713
  }
@@ -75717,7 +75724,7 @@ function walkJsonlFiles(dir, out2) {
75717
75724
  }
75718
75725
  for (const e of entries) {
75719
75726
  const name2 = typeof e.name === "string" ? e.name : String(e.name);
75720
- const p = join17(dir, name2);
75727
+ const p = join18(dir, name2);
75721
75728
  if (e.isDirectory()) {
75722
75729
  walkJsonlFiles(p, out2);
75723
75730
  } else if (e.isFile() && name2.endsWith(".jsonl")) {
@@ -75986,7 +75993,7 @@ function findPiSession(sessionId, environment = process.env) {
75986
75993
 
75987
75994
  // src/engine/acp/harness/pi/upstream/dist/acp/pi-settings.js
75988
75995
  import { existsSync as existsSync6, readFileSync as readFileSync5 } from "node:fs";
75989
- import { join as join18, resolve as resolve11 } from "node:path";
75996
+ import { join as join19, resolve as resolve11 } from "node:path";
75990
75997
  function isObject2(x) {
75991
75998
  return Boolean(x) && typeof x === "object" && !Array.isArray(x);
75992
75999
  }
@@ -76015,7 +76022,7 @@ function readJsonFile2(path6) {
76015
76022
  }
76016
76023
  }
76017
76024
  function getMergedSettings(cwd, environment) {
76018
- const globalSettingsPath = join18(getAgentDir(environment), "settings.json");
76025
+ const globalSettingsPath = join19(getAgentDir(environment), "settings.json");
76019
76026
  const projectSettingsPath = resolve11(cwd, ".pi", "settings.json");
76020
76027
  const global2 = readJsonFile2(globalSettingsPath);
76021
76028
  const project = readJsonFile2(projectSettingsPath);
@@ -76023,7 +76030,7 @@ function getMergedSettings(cwd, environment) {
76023
76030
  }
76024
76031
  function getAgentDir(environment = process.env) {
76025
76032
  const configured = environment["PI_CODING_AGENT_DIR"];
76026
- return configured ? resolve11(configured) : join18(environmentHome(environment), ".pi", "agent");
76033
+ return configured ? resolve11(configured) : join19(environmentHome(environment), ".pi", "agent");
76027
76034
  }
76028
76035
  function getEnableSkillCommands(cwd, environment = process.env) {
76029
76036
  const merged = getMergedSettings(cwd, environment);
@@ -76277,7 +76284,7 @@ var SessionStore = class {
76277
76284
 
76278
76285
  // src/engine/acp/harness/pi/upstream/dist/acp/slash-commands.js
76279
76286
  import { existsSync as existsSync7, readdirSync as readdirSync5, readFileSync as readFileSync7 } from "node:fs";
76280
- import { join as join19, resolve as resolve12 } from "node:path";
76287
+ import { join as join20, resolve as resolve12 } from "node:path";
76281
76288
  function parseFrontmatter(content) {
76282
76289
  const frontmatter = {};
76283
76290
  if (!content.startsWith("---")) {
@@ -76305,7 +76312,7 @@ function loadCommandsFromDir(dir, source, subdir = "") {
76305
76312
  try {
76306
76313
  const entries = readdirSync5(dir, { withFileTypes: true });
76307
76314
  for (const entry of entries) {
76308
- const fullPath = join19(dir, entry.name);
76315
+ const fullPath = join20(dir, entry.name);
76309
76316
  if (entry.isDirectory()) {
76310
76317
  const newSubdir = subdir ? `${subdir}:${entry.name}` : entry.name;
76311
76318
  commands.push(...loadCommandsFromDir(fullPath, source, newSubdir));
@@ -76345,7 +76352,7 @@ function loadCommandsFromDir(dir, source, subdir = "") {
76345
76352
  }
76346
76353
  function loadSlashCommands(cwd, environment = process.env) {
76347
76354
  const commands = [];
76348
- const userDir = join19(environmentHome(environment), ".pi", "agent", "prompts");
76355
+ const userDir = join20(environmentHome(environment), ".pi", "agent", "prompts");
76349
76356
  const projectDir = resolve12(cwd, ".pi", "prompts");
76350
76357
  commands.push(...loadCommandsFromDir(userDir, "user"));
76351
76358
  commands.push(...loadCommandsFromDir(projectDir, "project"));
@@ -78014,7 +78021,7 @@ ${JSON.stringify(stats, null, 2)}`;
78014
78021
  if (piPath) {
78015
78022
  const resolved = realpathSync3(piPath);
78016
78023
  const pkgRoot = dirname8(dirname8(resolved));
78017
- const p = join20(pkgRoot, "CHANGELOG.md");
78024
+ const p = join21(pkgRoot, "CHANGELOG.md");
78018
78025
  if (existsSync8(p)) {
78019
78026
  return p;
78020
78027
  }
@@ -78025,7 +78032,7 @@ ${JSON.stringify(stats, null, 2)}`;
78025
78032
  const npmRoot = spawnSync("npm", ["root", "-g"], { encoding: "utf-8" });
78026
78033
  const root = String(npmRoot.stdout ?? "").trim();
78027
78034
  if (root) {
78028
- const p = join20(root, "@earendil-works", "pi-coding-agent", "CHANGELOG.md");
78035
+ const p = join21(root, "@earendil-works", "pi-coding-agent", "CHANGELOG.md");
78029
78036
  if (existsSync8(p)) {
78030
78037
  return p;
78031
78038
  }
@@ -78119,7 +78126,7 @@ ${JSON.stringify(stats, null, 2)}`;
78119
78126
  return { stopReason: "end_turn" };
78120
78127
  }
78121
78128
  const safeSessionId = session.sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
78122
- const outputPath = join20(session.cwd, `pi-session-${safeSessionId}.html`);
78129
+ const outputPath = join21(session.cwd, `pi-session-${safeSessionId}.html`);
78123
78130
  let resultPath = "";
78124
78131
  try {
78125
78132
  const result2 = await session.proc.exportHtml(outputPath);
@@ -78856,7 +78863,7 @@ function buildStartupInfo(opts) {
78856
78863
  md.push("");
78857
78864
  };
78858
78865
  const contextItems = [];
78859
- const contextPath = join20(opts.cwd, "AGENTS.md");
78866
+ const contextPath = join21(opts.cwd, "AGENTS.md");
78860
78867
  if (existsSync8(contextPath)) {
78861
78868
  contextItems.push(contextPath);
78862
78869
  }
@@ -78865,7 +78872,7 @@ function buildStartupInfo(opts) {
78865
78872
  const pushSkillFromRoot = (root) => {
78866
78873
  try {
78867
78874
  for (const e of readdirSync6(root)) {
78868
- const p = join20(root, e);
78875
+ const p = join21(root, e);
78869
78876
  try {
78870
78877
  const st2 = statSync3(p);
78871
78878
  if (st2.isFile() && e.toLowerCase().endsWith(".md")) {
@@ -78890,7 +78897,7 @@ function buildStartupInfo(opts) {
78890
78897
  if (name2 === "node_modules" || name2 === ".git") {
78891
78898
  continue;
78892
78899
  }
78893
- const p = join20(dir, name2);
78900
+ const p = join21(dir, name2);
78894
78901
  let st2;
78895
78902
  try {
78896
78903
  st2 = statSync3(p);
@@ -78907,16 +78914,16 @@ function buildStartupInfo(opts) {
78907
78914
  } catch {
78908
78915
  }
78909
78916
  };
78910
- const globalSkillsDir = join20(getAgentDir(opts.environment), "skills");
78917
+ const globalSkillsDir = join21(getAgentDir(opts.environment), "skills");
78911
78918
  pushSkillFromRoot(globalSkillsDir);
78912
78919
  const home = opts.environment["HOME"] ?? opts.environment["USERPROFILE"] ?? "";
78913
- const legacyAgentsSkillsDir = join20(home, ".agents", "skills");
78920
+ const legacyAgentsSkillsDir = join21(home, ".agents", "skills");
78914
78921
  pushSkillFromRoot(legacyAgentsSkillsDir);
78915
- const projectSkillsDir = join20(opts.cwd, ".pi", "skills");
78922
+ const projectSkillsDir = join21(opts.cwd, ".pi", "skills");
78916
78923
  pushSkillFromRoot(projectSkillsDir);
78917
78924
  addSection("Skills", skillsItems);
78918
78925
  const promptsItems = [];
78919
- const promptsDir = join20(home, ".pi", "agent", "prompts");
78926
+ const promptsDir = join21(home, ".pi", "agent", "prompts");
78920
78927
  try {
78921
78928
  const prompts = readdirSync6(promptsDir).filter((f) => f.endsWith(".md"));
78922
78929
  for (const f of prompts) {
@@ -78926,17 +78933,17 @@ function buildStartupInfo(opts) {
78926
78933
  }
78927
78934
  addSection("Prompts", promptsItems);
78928
78935
  const extItems = [];
78929
- const extDir = join20(home, ".pi", "agent", "extensions");
78936
+ const extDir = join21(home, ".pi", "agent", "extensions");
78930
78937
  try {
78931
78938
  const exts = readdirSync6(extDir).filter((f) => f.endsWith(".ts") || f.endsWith(".js"));
78932
78939
  for (const f of exts) {
78933
- extItems.push(join20(extDir, f));
78940
+ extItems.push(join21(extDir, f));
78934
78941
  }
78935
78942
  } catch {
78936
78943
  }
78937
78944
  const settingsPaths = [
78938
- join20(getAgentDir(opts.environment), "settings.json"),
78939
- join20(opts.cwd, ".pi", "settings.json")
78945
+ join21(getAgentDir(opts.environment), "settings.json"),
78946
+ join21(opts.cwd, ".pi", "settings.json")
78940
78947
  ];
78941
78948
  for (const settingsPath of settingsPaths) {
78942
78949
  try {
@@ -79137,7 +79144,7 @@ var PiAgentSpecification = class extends InProcessAcpAgentSpecification {
79137
79144
  // keeps the adapter's opt-in capability flag enabled for every launch it owns.
79138
79145
  createLaunchEnvironment = async (_agent, context) => {
79139
79146
  const workspaceHash = createHash3("sha256").update(context.defaultWorkspace).digest("hex").slice(0, 24);
79140
- const sessionDirectory = join21(context.dataDirectory, "agents", "pi", "sessions", workspaceHash);
79147
+ const sessionDirectory = join22(context.dataDirectory, "agents", "pi", "sessions", workspaceHash);
79141
79148
  return Object.freeze({
79142
79149
  PI_ACP_ENABLE_EMBEDDED_CONTEXT: "true",
79143
79150
  MOBIUS_PI_SESSION_DIR: sessionDirectory
@@ -81965,11 +81972,11 @@ function describeEnvironmentProxyRoute(target) {
81965
81972
  }
81966
81973
 
81967
81974
  // src/engine/runtime/observability/diagnostic-log.ts
81968
- import { join as join24 } from "node:path";
81975
+ import { join as join25 } from "node:path";
81969
81976
 
81970
81977
  // src/engine/storage/logs/bounded-log.ts
81971
81978
  import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync10, renameSync as renameSync2, statSync as statSync5, writeFileSync as writeFileSync2 } from "node:fs";
81972
- import { join as join22 } from "node:path";
81979
+ import { join as join23 } from "node:path";
81973
81980
  var BoundedLineLog = class {
81974
81981
  #path;
81975
81982
  #maximumBytes;
@@ -81978,7 +81985,7 @@ var BoundedLineLog = class {
81978
81985
  #onWriteFailure;
81979
81986
  constructor(directory, filename, maximumBytes, onWriteFailure = () => void 0) {
81980
81987
  this.#directory = directory;
81981
- this.#path = join22(directory, filename);
81988
+ this.#path = join23(directory, filename);
81982
81989
  this.#maximumBytes = maximumBytes;
81983
81990
  this.#onWriteFailure = onWriteFailure;
81984
81991
  }
@@ -82029,21 +82036,21 @@ var BoundedLineLog = class {
82029
82036
 
82030
82037
  // src/engine/storage/logs/log-files.ts
82031
82038
  import { readFileSync as readFileSync11 } from "node:fs";
82032
- import { join as join23 } from "node:path";
82039
+ import { join as join24 } from "node:path";
82033
82040
  var DAEMON_LOG_FILENAME = "daemon.log";
82034
82041
  var WORKER_LIFECYCLE_LOG_FILENAME = "worker-lifecycle.log";
82035
82042
  function unhandledRejectionLogFilename(role) {
82036
82043
  return `unhandled-rejections-${role}.log`;
82037
82044
  }
82038
82045
  function logDirectory(dataDirectory) {
82039
- return join23(dataDirectory, "logs");
82046
+ return join24(dataDirectory, "logs");
82040
82047
  }
82041
82048
  function processLogPaths(dataDirectory) {
82042
82049
  return [
82043
82050
  WORKER_LIFECYCLE_LOG_FILENAME,
82044
82051
  unhandledRejectionLogFilename("manager"),
82045
82052
  unhandledRejectionLogFilename("worker")
82046
- ].map((filename) => join23(logDirectory(dataDirectory), filename));
82053
+ ].map((filename) => join24(logDirectory(dataDirectory), filename));
82047
82054
  }
82048
82055
  function readLogText(path6) {
82049
82056
  try {
@@ -82118,7 +82125,7 @@ var RuntimeDiagnosticLog = class {
82118
82125
  this.#maximumBytes = maximumBytes;
82119
82126
  const processLogsDirectory = options.processLogsDirectory;
82120
82127
  this.#sources = [
82121
- { maximumBytes, path: join24(directory, DAEMON_LOG_FILENAME) },
82128
+ { maximumBytes, path: join25(directory, DAEMON_LOG_FILENAME) },
82122
82129
  // The process logs a Runtime does not own, but must read to explain its own deaths.
82123
82130
  ...processLogsDirectory === void 0 ? [] : processLogPaths(processLogsDirectory).map((path6) => ({ maximumBytes: null, path: path6 }))
82124
82131
  ];
@@ -83267,7 +83274,7 @@ function sql(strings, ...params) {
83267
83274
  return new SQL([new StringChunk(str)]);
83268
83275
  }
83269
83276
  _sql.raw = raw;
83270
- function join30(chunks, separator) {
83277
+ function join32(chunks, separator) {
83271
83278
  const result = [];
83272
83279
  for (const [i, chunk] of chunks.entries()) {
83273
83280
  if (i > 0 && separator !== void 0) result.push(separator);
@@ -83275,7 +83282,7 @@ function sql(strings, ...params) {
83275
83282
  }
83276
83283
  return new SQL(result);
83277
83284
  }
83278
- _sql.join = join30;
83285
+ _sql.join = join32;
83279
83286
  function identifier2(value) {
83280
83287
  return new Name(value);
83281
83288
  }
@@ -85420,7 +85427,7 @@ var SQLiteSelectBase = class extends TypedQueryBuilder {
85420
85427
  const baseTableName = this.tableName;
85421
85428
  const tableName = getTableLikeName(table);
85422
85429
  for (const item of extractUsedTable(table)) this.usedTables.add(item);
85423
- 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`);
85424
85431
  if (!this.isPartialSelect) {
85425
85432
  if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
85426
85433
  if (typeof tableName === "string" && !is(table, SQL)) {
@@ -86259,7 +86266,7 @@ var SQLiteDialect = class {
86259
86266
  if (!joins2) return;
86260
86267
  const withEntries = Object.entries(joins2).filter(([_, v]) => v);
86261
86268
  if (!withEntries.length) return;
86262
- return sql.join(withEntries.map(([k2, join30]) => {
86269
+ return sql.join(withEntries.map(([k2, join32]) => {
86263
86270
  const relation = tableConfig.relations[k2];
86264
86271
  const isSingle2 = is(relation, One2);
86265
86272
  const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
@@ -86270,7 +86277,7 @@ var SQLiteDialect = class {
86270
86277
  table: targetTable,
86271
86278
  mode: isSingle2 ? "first" : "many",
86272
86279
  schema,
86273
- queryConfig: join30,
86280
+ queryConfig: join32,
86274
86281
  tableConfig: schema[relation.targetTableName],
86275
86282
  relationWhere: filter,
86276
86283
  isNested: true,
@@ -86284,7 +86291,7 @@ var SQLiteDialect = class {
86284
86291
  key: k2,
86285
86292
  selection: innerQuery.selection,
86286
86293
  isArray: !isSingle2,
86287
- isOptional: (relation.optional ?? false) || join30 !== true && !!join30.where
86294
+ isOptional: (relation.optional ?? false) || join32 !== true && !!join32.where
86288
86295
  });
86289
86296
  const jsonColumns = sql.join(innerQuery.selection.map((s) => {
86290
86297
  return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
@@ -86900,7 +86907,7 @@ var SQLiteUpdateBase = class {
86900
86907
  createJoin(joinType) {
86901
86908
  return ((table, on2) => {
86902
86909
  const tableName = getTableLikeName(table);
86903
- 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`);
86904
86911
  if (typeof on2 === "function") {
86905
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;
86906
86913
  on2 = on2(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
@@ -87852,7 +87859,7 @@ var SessionEventCacheTable = class {
87852
87859
  // src/engine/storage/sqlite/local-databases.ts
87853
87860
  import { createHash as createHash4 } from "node:crypto";
87854
87861
  import { existsSync as existsSync9 } from "node:fs";
87855
- import { join as join25 } from "node:path";
87862
+ import { join as join26 } from "node:path";
87856
87863
  import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
87857
87864
 
87858
87865
  // src/engine/generated/acp-session-store-migrations.ts
@@ -88095,9 +88102,9 @@ var LocalSqliteDatabase = class {
88095
88102
  function channelSessionDatabasePaths(stateDirectory, channelId) {
88096
88103
  const channelHash = createHash4("sha256").update(channelId).digest("hex");
88097
88104
  return {
88098
- cancellations: join25(stateDirectory, "sessions", `${channelHash}.cancellations.sqlite`),
88099
- events: join25(stateDirectory, "sessions", `${channelHash}.events.sqlite`),
88100
- 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`)
88101
88108
  };
88102
88109
  }
88103
88110
  function recordAppliedAdmissionOrder(path6) {
@@ -90808,19 +90815,30 @@ var SessionManager2 = class {
90808
90815
  }
90809
90816
  prepareSession = async (options, metrics = unmeasuredOperationMetrics, closed = "reopen") => await this.#prepareSession(options, { kind: "interactive-only" }, closed, metrics);
90810
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
+ };
90811
90831
  /**
90812
90832
  * Opens a short-lived native ACP session only to read the local Agent's
90813
90833
  * authoritative settings. Its identity and store are private to this
90814
90834
  * operation and never become a Mobius Session.
90815
90835
  */
90816
- 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()}`;
90817
90838
  return await this.#processes.runTransient(
90818
90839
  options2.signal,
90819
90840
  async () => await AgentSession.start(
90820
- {
90821
- ...options2,
90822
- sessionId: `agent-settings-${crypto.randomUUID()}`
90823
- },
90841
+ { ...options2, sessionId },
90824
90842
  { kind: "interactive-only" },
90825
90843
  () => this.#agentSettingsObserver,
90826
90844
  () => void 0,
@@ -90830,25 +90848,56 @@ var SessionManager2 = class {
90830
90848
  ),
90831
90849
  async (runtime) => {
90832
90850
  const prepared = runtime.prepared();
90833
- const discoveredModelEffort = runtime.agentSettingsModelEffort();
90834
- 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
+ );
90835
90858
  const modelOption2 = prepared.configOptions.find(isModelOption);
90836
- const modelIsFixed = modelOption2?.type === "select" && modelOption2.values.length < 2 && modelOption2.currentValue === model;
90837
- const configOptions = model === void 0 || modelIsFixed ? prepared.configOptions : (await runtime.applyConfiguration({
90859
+ const change = async (configId, value) => (await runtime.applyConfiguration({
90838
90860
  ...options2,
90839
90861
  booleanValue: false,
90840
- configId: modelOption2?.id ?? "model",
90862
+ configId,
90841
90863
  requestId: "agent-settings-model",
90842
- sessionId: `agent-settings-${crypto.randomUUID()}`,
90843
- value: model,
90864
+ sessionId,
90865
+ value,
90844
90866
  valueType: "select"
90845
90867
  })).configOptions;
90846
- return new AgentSettingsSnapshot(
90847
- prepared.agentName,
90848
- prepared.agentVersion,
90849
- configOptions,
90850
- discoveredModelEffort === null ? { kind: "unavailable" } : { kind: "complete", value: discoveredModelEffort }
90851
- );
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 };
90852
90901
  },
90853
90902
  async (runtime) => await runtime.close()
90854
90903
  );
@@ -92407,7 +92456,7 @@ var SessionTurns = class {
92407
92456
 
92408
92457
  // src/engine/session/workspace/workspace-directory.ts
92409
92458
  import { homedir as homedir3 } from "node:os";
92410
- 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";
92411
92460
 
92412
92461
  // src/engine/session/workspace/local-authorization-error.ts
92413
92462
  var LocalAuthorizationError = class extends OperationError {
@@ -92553,7 +92602,7 @@ var WorkspaceDirectoryService = class {
92553
92602
  continue;
92554
92603
  }
92555
92604
  try {
92556
- const path6 = await this.resolvePath(join26(target, child.name), signal);
92605
+ const path6 = await this.resolvePath(join27(target, child.name), signal);
92557
92606
  entries.push({ directoryId: encodePath(path6), name: child.name });
92558
92607
  } catch (cause) {
92559
92608
  signal.throwIfAborted();
@@ -92727,13 +92776,13 @@ function buildSessionLayer(options) {
92727
92776
 
92728
92777
  // src/engine/session/content/external-content-store.ts
92729
92778
  import { createHash as createHash8 } from "node:crypto";
92730
- import { extname as extname2, join as join28 } from "node:path";
92779
+ import { extname as extname2, join as join29 } from "node:path";
92731
92780
  import { pathToFileURL as pathToFileURL3 } from "node:url";
92732
92781
 
92733
92782
  // src/engine/storage/files/scratch-directory.ts
92734
92783
  import { randomUUID as randomUUID16 } from "node:crypto";
92735
- 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";
92736
- 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";
92737
92786
  async function atomicWrite(path6, bytes, signal) {
92738
92787
  const temporary = `${path6}.${randomUUID16()}.tmp`;
92739
92788
  try {
@@ -92741,13 +92790,13 @@ async function atomicWrite(path6, bytes, signal) {
92741
92790
  signal.throwIfAborted();
92742
92791
  await rename4(temporary, path6);
92743
92792
  } finally {
92744
- await rm4(temporary, { force: true });
92793
+ await rm5(temporary, { force: true });
92745
92794
  }
92746
92795
  }
92747
92796
  var ScratchDirectory = class {
92748
92797
  #root;
92749
92798
  constructor(parent) {
92750
- this.#root = join27(parent, randomUUID16());
92799
+ this.#root = join28(parent, randomUUID16());
92751
92800
  }
92752
92801
  /** Refreshes this directory's lease and removes sibling directories whose lease is older than `leaseMilliseconds`. */
92753
92802
  refreshLease = async (leaseMilliseconds) => {
@@ -92758,7 +92807,7 @@ var ScratchDirectory = class {
92758
92807
  if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
92759
92808
  continue;
92760
92809
  }
92761
- const path6 = join27(dirname11(this.#root), directory.name);
92810
+ const path6 = join28(dirname11(this.#root), directory.name);
92762
92811
  if (path6 === this.#root) {
92763
92812
  continue;
92764
92813
  }
@@ -92767,21 +92816,21 @@ var ScratchDirectory = class {
92767
92816
  () => Date.now()
92768
92817
  );
92769
92818
  if (modified + leaseMilliseconds <= Date.now()) {
92770
- await rm4(path6, { force: true, recursive: true });
92819
+ await rm5(path6, { force: true, recursive: true });
92771
92820
  }
92772
92821
  }
92773
92822
  };
92774
92823
  /** Writes `bytes` atomically to `<group>/<name>` with owner-only permissions and returns the path. */
92775
92824
  write = async (group, name2, bytes, signal) => {
92776
- const directory = join27(this.#root, group);
92825
+ const directory = join28(this.#root, group);
92777
92826
  await mkdir5(directory, { mode: 448, recursive: true });
92778
92827
  signal.throwIfAborted();
92779
- const path6 = join27(directory, name2);
92828
+ const path6 = join28(directory, name2);
92780
92829
  await atomicWrite(path6, bytes, signal);
92781
92830
  return path6;
92782
92831
  };
92783
92832
  remove = async (path6) => {
92784
- await rm4(path6, { force: true });
92833
+ await rm5(path6, { force: true });
92785
92834
  };
92786
92835
  /** The canonical path of a written file, or null when it is gone, is not a regular file, or escapes its directory. */
92787
92836
  resolveFile = async (path6) => {
@@ -92803,7 +92852,7 @@ var ScratchDirectory = class {
92803
92852
  return resolved === null ? null : new Uint8Array(await readFile7(resolved, { signal }));
92804
92853
  };
92805
92854
  removeAll = async () => {
92806
- await rm4(this.#root, { force: true, recursive: true });
92855
+ await rm5(this.#root, { force: true, recursive: true });
92807
92856
  };
92808
92857
  };
92809
92858
 
@@ -92827,7 +92876,7 @@ var LocalExternalContentStore = class {
92827
92876
  #expirationTimer;
92828
92877
  #cleanup = Promise.resolve();
92829
92878
  constructor(stateDirectory) {
92830
- this.#scratch = new ScratchDirectory(join28(stateDirectory, "tmp", "session-content"));
92879
+ this.#scratch = new ScratchDirectory(join29(stateDirectory, "tmp", "session-content"));
92831
92880
  this.#expirationTimer = setInterval(() => {
92832
92881
  void this.#expire().catch(() => void 0);
92833
92882
  }, 6e4);
@@ -93233,6 +93282,176 @@ var AgentProcessPool = class {
93233
93282
  };
93234
93283
  };
93235
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
+
93236
93455
  // src/engine/runtime/relay/diagnostics.ts
93237
93456
  var MAX_DIAGNOSTIC_TEXT_LENGTH = 256;
93238
93457
  function sanitizeDiagnosticText(value) {
@@ -93474,7 +93693,7 @@ function discoveredEvent(command, agents) {
93474
93693
  };
93475
93694
  }
93476
93695
  function createAgentCatalogDiscoveryHandler(dependencies) {
93477
- const { config: config2, discover, diagnostics, socket, signal, timer } = dependencies;
93696
+ const { config: config2, discover, invalidateAgentSettings, diagnostics, socket, signal, timer } = dependencies;
93478
93697
  const requestIds = /* @__PURE__ */ new Set();
93479
93698
  let controller = null;
93480
93699
  let completion = null;
@@ -93500,6 +93719,7 @@ function createAgentCatalogDiscoveryHandler(dependencies) {
93500
93719
  completion = (async () => {
93501
93720
  try {
93502
93721
  const published = await refreshAgentCatalog(config2, discover, operationSignal);
93722
+ await invalidateAgentSettings(operationSignal);
93503
93723
  operationSignal.throwIfAborted();
93504
93724
  if (socket.readyState === WebSocket3.OPEN) {
93505
93725
  send(
@@ -93550,6 +93770,7 @@ function createAgentCatalogCommands(context) {
93550
93770
  discover: context.config.rediscoverAgents === void 0 ? () => {
93551
93771
  throw new Error("Agent catalog discovery is not available for this Runtime");
93552
93772
  } : context.config.rediscoverAgents,
93773
+ invalidateAgentSettings: context.settingsCache.invalidate,
93553
93774
  diagnostics: context.diagnostics,
93554
93775
  socket: context.socket,
93555
93776
  signal: context.signal,
@@ -93581,7 +93802,7 @@ var SessionError = class extends OperationError {
93581
93802
  };
93582
93803
 
93583
93804
  // src/engine/session/settings/discover-agent-settings.ts
93584
- import { createHash as createHash9 } from "node:crypto";
93805
+ import { createHash as createHash10 } from "node:crypto";
93585
93806
 
93586
93807
  // src/engine/agent/settings/agent-settings-base.ts
93587
93808
  var AgentSettingsLaunchSelectionResult = class {
@@ -93651,23 +93872,56 @@ function isUnavailableModel(cause, modelSettingId, requestedModel) {
93651
93872
  function unsupportedModelIds(unsupportedModels) {
93652
93873
  return [...new Set(unsupportedModels.map((item) => item.requestedValue))];
93653
93874
  }
93654
- async function discoverAgentSettings(command, resolveAgent, bindingId, directories, sessions, signal) {
93655
- const { agent: agent2, adapter: harnessAdapter } = await resolveAgent(command.agentId, signal);
93656
- const directoryId = command.directoryId ?? "default";
93657
- const cwd = await directories.resolve(bindingId, directoryId, signal);
93658
- const inspectedBaseSnapshot = await sessions.inspectAgentSettings({
93659
- adapter: harnessAdapter,
93660
- additionalDirectories: [],
93661
- agent: agent2,
93662
- cwd,
93663
- signal
93664
- });
93665
- const baseSnapshot = {
93666
- agentName: inspectedBaseSnapshot.agentName,
93667
- agentVersion: inspectedBaseSnapshot.agentVersion,
93668
- configOptions: inspectedBaseSnapshot.configOptions,
93669
- 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
+ );
93670
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();
93671
93925
  const baseModel = modelOption(baseSnapshot.configOptions);
93672
93926
  const unsupportedModels = [];
93673
93927
  let selectedSnapshot = baseSnapshot;
@@ -93682,14 +93936,7 @@ async function discoverAgentSettings(command, resolveAgent, bindingId, directori
93682
93936
  );
93683
93937
  } else {
93684
93938
  try {
93685
- selectedSnapshot = await sessions.inspectAgentSettings({
93686
- adapter: harnessAdapter,
93687
- additionalDirectories: [],
93688
- agent: agent2,
93689
- cwd,
93690
- model: command.model,
93691
- signal
93692
- });
93939
+ selectedSnapshot = await inspect(command.model);
93693
93940
  } catch (cause) {
93694
93941
  signal.throwIfAborted();
93695
93942
  if (!isUnavailableModel(cause, baseModel.id, command.model)) {
@@ -93700,25 +93947,21 @@ async function discoverAgentSettings(command, resolveAgent, bindingId, directori
93700
93947
  }
93701
93948
  }
93702
93949
  const adapter = agentSettingsAdapterForAgent(agent2.id);
93703
- const modelEffort = await discoverModelEffort(
93704
- command,
93705
- agent2,
93706
- harnessAdapter,
93950
+ const { modelEffort, effort } = await discoverModelEffort(
93707
93951
  adapter.modelEffortResolution,
93708
93952
  baseSnapshot.configOptions,
93709
- selectedSnapshot.configOptions,
93710
93953
  unsupportedModels,
93711
93954
  baseSnapshot.modelEffort,
93712
- cwd,
93713
- sessions,
93955
+ inspect,
93714
93956
  signal
93715
93957
  );
93958
+ const baseOptions = effort === void 0 || effortOption(baseSnapshot.configOptions) !== void 0 ? baseSnapshot.configOptions : [...baseSnapshot.configOptions, { ...effort, currentValue: "" }];
93716
93959
  const baseSettings = withoutUnsupportedModels(
93717
- settingsFromSnapshot(agent2, baseSnapshot.configOptions),
93960
+ settingsFromSnapshot(agent2, baseOptions),
93718
93961
  baseModel?.id ?? "",
93719
93962
  modelEffort.unsupportedModelIds
93720
93963
  );
93721
- const settings = withoutUnsupportedModels(
93964
+ const settings = command.model === void 0 ? baseSettings : withoutUnsupportedModels(
93722
93965
  settingsFromSnapshot(agent2, selectedSnapshot.configOptions),
93723
93966
  baseModel?.id ?? "",
93724
93967
  modelEffort.unsupportedModelIds
@@ -93728,7 +93971,7 @@ async function discoverAgentSettings(command, resolveAgent, bindingId, directori
93728
93971
  agentId: command.agentId,
93729
93972
  agentName: selectedSnapshot.agentName,
93730
93973
  agentVersion: selectedSnapshot.agentVersion,
93731
- directoryId,
93974
+ directoryId: command.directoryId ?? "default",
93732
93975
  kind: AGENT_SETTINGS_DISCOVERED_KIND,
93733
93976
  modelEffort,
93734
93977
  requestId: command.requestId,
@@ -93802,33 +94045,45 @@ function unavailableModelEffort() {
93802
94045
  valuesByModel: {}
93803
94046
  };
93804
94047
  }
93805
- async function discoverModelEffort(command, agent2, harnessAdapter, resolution, initialOptions, selectedOptions, initiallyUnsupportedModels, discoveredModelEffort, cwd, sessions, signal) {
94048
+ async function discoverModelEffort(resolution, initialOptions, initiallyUnsupportedModels, discoveredModelEffort, inspect, signal) {
93806
94049
  const model = modelOption(initialOptions);
93807
94050
  const unsupportedModels = initiallyUnsupportedModels;
93808
94051
  if (resolution !== AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE && resolution !== AGENT_MODEL_EFFORT_RESOLUTION_ON_MODEL_SELECTION) {
93809
- return { ...unavailableModelEffort(), unsupportedModelIds: unsupportedModelIds(unsupportedModels) };
94052
+ return {
94053
+ modelEffort: { ...unavailableModelEffort(), unsupportedModelIds: unsupportedModelIds(unsupportedModels) }
94054
+ };
93810
94055
  }
93811
94056
  if (model === void 0 || model.type !== "select" || model.values.length === 0) {
93812
- return { ...unavailableModelEffort(), unsupportedModelIds: unsupportedModelIds(unsupportedModels) };
94057
+ return {
94058
+ modelEffort: { ...unavailableModelEffort(), unsupportedModelIds: unsupportedModelIds(unsupportedModels) }
94059
+ };
93813
94060
  }
94061
+ const inspectModel = async (model2) => (await inspect(model2)).configOptions;
93814
94062
  if (resolution === AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE && discoveredModelEffort.kind === "complete" && discoveredModelEffort.value.resolution === AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE) {
93815
- 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 };
93816
94077
  }
93817
- const inspectModel = async (modelValue) => (await sessions.inspectAgentSettings({
93818
- adapter: harnessAdapter,
93819
- additionalDirectories: [],
93820
- agent: agent2,
93821
- cwd,
93822
- model: modelValue,
93823
- signal
93824
- })).configOptions;
93825
- const valuesByModel = {};
94078
+ const valuesByModel = /* @__PURE__ */ new Map();
93826
94079
  if (resolution === "complete") {
93827
- const effort = effortOption(initialOptions);
93828
- 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) {
93829
94082
  return {
93830
- ...unavailableModelEffort(),
93831
- unsupportedModelIds: unsupportedModelIds(unsupportedModels)
94083
+ modelEffort: {
94084
+ ...unavailableModelEffort(),
94085
+ unsupportedModelIds: unsupportedModelIds(unsupportedModels)
94086
+ }
93832
94087
  };
93833
94088
  }
93834
94089
  for (const value of model.values) {
@@ -93836,8 +94091,8 @@ async function discoverModelEffort(command, agent2, harnessAdapter, resolution,
93836
94091
  continue;
93837
94092
  }
93838
94093
  try {
93839
- const selectedEffort2 = effortOption(await inspectModel(value.value));
93840
- 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 : []);
93841
94096
  } catch (cause) {
93842
94097
  signal.throwIfAborted();
93843
94098
  if (!isUnavailableModel(cause, model.id, value.value)) {
@@ -93847,80 +94102,77 @@ async function discoverModelEffort(command, agent2, harnessAdapter, resolution,
93847
94102
  }
93848
94103
  }
93849
94104
  return {
93850
- effortSettingId: effort.id,
93851
- modelSettingId: model.id,
93852
- resolution: "complete",
93853
- unsupportedModelIds: unsupportedModelIds(unsupportedModels),
93854
- valuesByModel
94105
+ modelEffort: {
94106
+ effortSettingId: effort2.id,
94107
+ modelSettingId: model.id,
94108
+ resolution: "complete",
94109
+ unsupportedModelIds: unsupportedModelIds(unsupportedModels),
94110
+ valuesByModel: Object.fromEntries(valuesByModel)
94111
+ }
93855
94112
  };
93856
94113
  }
93857
- if (command.model !== void 0) {
93858
- const modelUnsupported = unsupportedModels.some((diagnostic) => diagnostic.requestedValue === command.model);
93859
- const selectedEffort2 = effortOption(selectedOptions);
93860
- if (!modelUnsupported) {
93861
- 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;
93862
94119
  }
93863
- return {
93864
- effortSettingId: selectedEffort2?.id ?? "",
93865
- modelSettingId: model.id,
93866
- resolution: "on_model_selection",
93867
- unsupportedModelIds: unsupportedModelIds(unsupportedModels),
93868
- valuesByModel
93869
- };
93870
- }
93871
- const defaultModel = model.type === "select" ? model.currentValue : "";
93872
- const reportedEffort = effortOption(selectedOptions);
93873
- let selectedEffort = reportedEffort;
93874
- if (defaultModel.length > 0 && reportedEffort === void 0) {
93875
94120
  try {
93876
- 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 : []);
93877
94125
  } catch (cause) {
93878
94126
  signal.throwIfAborted();
93879
- if (!isUnavailableModel(cause, model.id, defaultModel)) {
94127
+ if (!isUnavailableModel(cause, model.id, value.value)) {
93880
94128
  throw cause;
93881
94129
  }
93882
94130
  unsupportedModels.push(cause);
93883
94131
  }
93884
94132
  }
93885
- if (defaultModel.length > 0 && !unsupportedModels.some((diagnostic) => diagnostic.requestedValue === defaultModel)) {
93886
- valuesByModel[defaultModel] = selectedEffort?.type === "select" ? selectedEffort.values : [];
93887
- }
93888
94133
  return {
93889
- effortSettingId: selectedEffort?.id ?? "",
93890
- modelSettingId: model.id,
93891
- resolution: "on_model_selection",
93892
- unsupportedModelIds: unsupportedModelIds(unsupportedModels),
93893
- 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
+ }
93894
94142
  };
93895
94143
  }
93896
94144
  function settingsRevision(agent2, reportedAgentVersion, settings, modelEffort) {
93897
- const revisionModelEffort = modelEffort.resolution === AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE ? modelEffort : {
93898
- effortSettingId: "",
93899
- modelSettingId: modelEffort.modelSettingId,
93900
- resolution: modelEffort.resolution,
93901
- unsupportedModelIds: modelEffort.unsupportedModelIds,
93902
- valuesByModel: {}
93903
- };
93904
- return createHash9("sha256").update(
93905
- JSON.stringify({
93906
- adapterVersion: agent2.adapterVersion,
93907
- agentId: agent2.id,
93908
- agentVersion: agent2.agentVersion,
93909
- modelEffort: revisionModelEffort,
93910
- reportedAgentVersion,
93911
- settings
93912
- })
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
+ )
93913
94164
  ).digest("hex");
93914
94165
  }
93915
94166
 
93916
94167
  // src/engine/runtime/command/agent-settings-discovery.ts
93917
94168
  function createAgentSettingsDiscoveryHandler(dependencies) {
93918
- const { config: config2, directories, sessions, diagnostics, socket, signal, timer } = dependencies;
94169
+ const { config: config2, directories, sessions, settingsCache, diagnostics, socket, signal, timer } = dependencies;
93919
94170
  const agentSettingsDiscoveries = /* @__PURE__ */ new Map();
93920
94171
  const handle = (command) => {
93921
- const directoryId = command.directoryId ?? "default";
94172
+ const directoryId = command.directoryId;
94173
+ const generation = settingsCache.generation;
93922
94174
  const existing = [...agentSettingsDiscoveries.values()].find(
93923
- (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
93924
94176
  );
93925
94177
  if ([...agentSettingsDiscoveries.values()].some((request) => request.requestIds.has(command.requestId))) {
93926
94178
  if (socket.readyState === WebSocket4.OPEN) {
@@ -93976,6 +94228,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
93976
94228
  config2.bindingId,
93977
94229
  directories,
93978
94230
  sessions,
94231
+ settingsCache,
93979
94232
  operationSignal
93980
94233
  );
93981
94234
  for (const diagnostic of result.unsupportedModels) {
@@ -94019,6 +94272,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
94019
94272
  agentSettingsDiscoveries.set(command.requestId, {
94020
94273
  agentId: command.agentId,
94021
94274
  directoryId,
94275
+ generation,
94022
94276
  model: command.model,
94023
94277
  requestIds,
94024
94278
  completion,
@@ -94040,6 +94294,7 @@ function createAgentSettingsCommands(context) {
94040
94294
  directories: context.directories,
94041
94295
  diagnostics: context.diagnostics,
94042
94296
  sessions: context.sessions,
94297
+ settingsCache: context.settingsCache,
94043
94298
  signal: context.signal,
94044
94299
  socket: context.socket,
94045
94300
  timer: context.timer
@@ -94059,7 +94314,7 @@ function createAgentSettingsCommands(context) {
94059
94314
  }
94060
94315
 
94061
94316
  // src/engine/runtime/command/registry/content-write/index.ts
94062
- import { createHash as createHash10 } from "node:crypto";
94317
+ import { createHash as createHash11 } from "node:crypto";
94063
94318
  function createContentWriteCommands(context) {
94064
94319
  const pending = /* @__PURE__ */ new Map();
94065
94320
  const operations = /* @__PURE__ */ new Set();
@@ -94089,7 +94344,7 @@ function createContentWriteCommands(context) {
94089
94344
  pending.set(message.requestId, {
94090
94345
  bytes: new Uint8Array(message.byteLength),
94091
94346
  command: message,
94092
- hash: createHash10("sha256"),
94347
+ hash: createHash11("sha256"),
94093
94348
  receivedBytes: 0,
94094
94349
  sequence: 0
94095
94350
  });
@@ -94183,7 +94438,7 @@ function createContentWriteCommands(context) {
94183
94438
  import { WebSocket as WebSocket5 } from "undici";
94184
94439
 
94185
94440
  // src/engine/session/content/session-files.ts
94186
- 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";
94187
94442
  import { fileURLToPath as fileURLToPath2 } from "node:url";
94188
94443
  function requestedPath(value) {
94189
94444
  if (value.includes("\0")) {
@@ -94207,7 +94462,7 @@ async function resolveFile(value, workingDirectory, signal) {
94207
94462
  if (isAbsolute16(requested.path) && normalize3(requested.path) !== requested.path) {
94208
94463
  return null;
94209
94464
  }
94210
- 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)];
94211
94466
  for (const candidate of candidates) {
94212
94467
  if (!isAbsolute16(candidate) || normalize3(candidate) !== candidate) {
94213
94468
  continue;
@@ -94627,7 +94882,7 @@ async function resolveSessionDirectories(directories, bindingId, directoryId, ad
94627
94882
  }
94628
94883
 
94629
94884
  // src/engine/session/prompt/apply-session-configuration.ts
94630
- import { randomUUID as randomUUID17 } from "node:crypto";
94885
+ import { randomUUID as randomUUID18 } from "node:crypto";
94631
94886
  function invalidSessionConfiguration(message) {
94632
94887
  return new AcpExecutionError(message, {}, "invalid_session_configuration");
94633
94888
  }
@@ -94752,7 +95007,7 @@ async function applySessionConfigurationSelection(sessions, options, selection,
94752
95007
  booleanValue: selection.booleanValue,
94753
95008
  configId: selection.configId,
94754
95009
  cwd,
94755
- requestId: `cfg_${randomUUID17()}`,
95010
+ requestId: `cfg_${randomUUID18()}`,
94756
95011
  sessionId,
94757
95012
  signal,
94758
95013
  value: selection.value,
@@ -95862,6 +96117,7 @@ async function runRelayConnection({
95862
96117
  eventProjection,
95863
96118
  externalContent,
95864
96119
  sessions,
96120
+ settingsCache,
95865
96121
  connectionEpoch,
95866
96122
  diagnostics,
95867
96123
  onConnected,
@@ -95880,6 +96136,7 @@ async function runRelayConnection({
95880
96136
  config: config2,
95881
96137
  directories,
95882
96138
  sessions,
96139
+ settingsCache,
95883
96140
  nativeSessions,
95884
96141
  operations,
95885
96142
  eventProjection,
@@ -96293,6 +96550,7 @@ async function runRuntime(config2, parentSignal, timer = systemTimer, options =
96293
96550
  const shutdown = new AbortController();
96294
96551
  const signal = AbortSignal.any([parentSignal, shutdown.signal]);
96295
96552
  const stateDirectory = config2.localContext.stateDirectory;
96553
+ const settingsCache = new AgentSettingsCache(stateDirectory);
96296
96554
  const diagnostics = new RelayConnectionDiagnostics(
96297
96555
  config2.channelId,
96298
96556
  config2.relayUrl,
@@ -96390,6 +96648,7 @@ async function runRuntime(config2, parentSignal, timer = systemTimer, options =
96390
96648
  resolveAgent,
96391
96649
  directories,
96392
96650
  sessions: agentRuntime,
96651
+ settingsCache,
96393
96652
  nativeSessions,
96394
96653
  operations,
96395
96654
  publisher,
@@ -96699,4 +96958,4 @@ export {
96699
96958
  * MIT Licensed
96700
96959
  *)
96701
96960
  */
96702
- //# sourceMappingURL=chunk-FDHUTFPW.js.map
96961
+ //# sourceMappingURL=chunk-CDY4OZQN.js.map