@moxt-ai/mobius 0.0.314 → 0.0.316

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 (33) hide show
  1. package/dist/cli/index.d.ts.map +1 -1
  2. package/dist/cli/index.js +7 -0
  3. package/dist/cli/index.js.map +1 -1
  4. package/dist/cli.js +400 -330
  5. package/dist/cli.js.map +4 -4
  6. package/dist/runtime/command/registry/history.js +2 -2
  7. package/dist/runtime/command/registry/history.js.map +1 -1
  8. package/dist/runtime/command/registry/session.js +2 -2
  9. package/dist/runtime/command/registry/session.js.map +1 -1
  10. package/dist/runtime/config.d.ts +5 -0
  11. package/dist/runtime/config.d.ts.map +1 -1
  12. package/dist/runtime/config.js.map +1 -1
  13. package/dist/runtime/run.d.ts.map +1 -1
  14. package/dist/runtime/run.js +6 -2
  15. package/dist/runtime/run.js.map +1 -1
  16. package/dist/runtime.js +22 -15
  17. package/dist/runtime.js.map +3 -3
  18. package/dist/session/api/session-api.d.ts +1 -1
  19. package/dist/session/api/session-api.d.ts.map +1 -1
  20. package/dist/session/manager/session-manager.d.ts +2 -2
  21. package/dist/session/manager/session-manager.d.ts.map +1 -1
  22. package/dist/session/manager/session-manager.js +10 -6
  23. package/dist/session/manager/session-manager.js.map +1 -1
  24. package/dist/session/native/native-session-browser.d.ts.map +1 -1
  25. package/dist/session/native/native-session-browser.js +1 -1
  26. package/dist/session/native/native-session-browser.js.map +1 -1
  27. package/dist/session/prompt/execute-prompt.js +1 -1
  28. package/dist/session/prompt/execute-prompt.js.map +1 -1
  29. package/dist/storage/state-root.d.ts +12 -0
  30. package/dist/storage/state-root.d.ts.map +1 -0
  31. package/dist/storage/state-root.js +59 -0
  32. package/dist/storage/state-root.js.map +1 -0
  33. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2086,7 +2086,7 @@ var init_package = __esm({
2086
2086
  "package.json"() {
2087
2087
  package_default = {
2088
2088
  name: "@moxt-ai/mobius",
2089
- version: "0.0.314",
2089
+ version: "0.0.316",
2090
2090
  description: "Mobius CLI for pairing and running local AI agent services.",
2091
2091
  type: "module",
2092
2092
  bin: {
@@ -5605,6 +5605,161 @@ var init_commander = __esm({
5605
5605
  }
5606
5606
  });
5607
5607
 
5608
+ // src/util/node-error.ts
5609
+ function isNodeError(error62, code) {
5610
+ return typeof error62 === "object" && error62 !== null && "code" in error62 && error62.code === code;
5611
+ }
5612
+ var init_node_error = __esm({
5613
+ "src/util/node-error.ts"() {
5614
+ "use strict";
5615
+ }
5616
+ });
5617
+
5618
+ // src/storage/installation/installation-files.ts
5619
+ import { createHash, randomUUID } from "node:crypto";
5620
+ import { mkdir, open, readdir, rename, unlink, writeFile } from "node:fs/promises";
5621
+ import { dirname, join } from "node:path";
5622
+ function applicationDirectory(root, applicationId) {
5623
+ return join(root, "installations", applicationId);
5624
+ }
5625
+ function installationPointerPath(applicationDirectory2) {
5626
+ return join(applicationDirectory2, "current.json");
5627
+ }
5628
+ function installationDirectory(applicationDirectory2, installationId2) {
5629
+ return join(applicationDirectory2, installationId2);
5630
+ }
5631
+ function connectionDirectory(installationDirectory2) {
5632
+ return join(installationDirectory2, "connections");
5633
+ }
5634
+ function connectionFilePath(connectionDirectory2, connectionId2) {
5635
+ return join(connectionDirectory2, `${connectionId2}.json`);
5636
+ }
5637
+ function channelIndexFilePath(installationDirectory2, channelId) {
5638
+ return join(installationDirectory2, "channels", `mci_${createHash("sha256").update(channelId).digest("hex")}.json`);
5639
+ }
5640
+ async function readInstallationFile(path8) {
5641
+ let handle;
5642
+ try {
5643
+ handle = await open(path8, "r");
5644
+ } catch (cause) {
5645
+ return isNodeError(cause, "ENOENT") ? { kind: "missing", cause } : { kind: "unopenable", cause };
5646
+ }
5647
+ try {
5648
+ const metadata = await handle.stat();
5649
+ if (!metadata.isFile() || metadata.size > MAXIMUM_FILE_BYTES) {
5650
+ return { kind: "not-a-small-file" };
5651
+ }
5652
+ return { kind: "read", text: await handle.readFile({ encoding: "utf8" }) };
5653
+ } finally {
5654
+ await handle.close();
5655
+ }
5656
+ }
5657
+ async function writeInstallationFile(path8, text2, signal) {
5658
+ signal.throwIfAborted();
5659
+ const directory = dirname(path8);
5660
+ const temporaryPath = join(directory, `.${randomUUID()}.tmp`);
5661
+ try {
5662
+ await mkdir(directory, { mode: 448, recursive: true });
5663
+ signal.throwIfAborted();
5664
+ await writeFile(temporaryPath, text2, { flag: "wx", mode: 384 });
5665
+ signal.throwIfAborted();
5666
+ await rename(temporaryPath, path8);
5667
+ } catch (cause) {
5668
+ await unlink(temporaryPath).catch(() => void 0);
5669
+ throw cause;
5670
+ }
5671
+ }
5672
+ async function createInstallationFile(path8, text2) {
5673
+ await writeFile(path8, text2, { flag: "wx", mode: 384 });
5674
+ }
5675
+ async function listInstallationFiles(directory) {
5676
+ return await readdir(directory);
5677
+ }
5678
+ async function removeInstallationFile(path8) {
5679
+ await unlink(path8);
5680
+ }
5681
+ var MAXIMUM_FILE_BYTES;
5682
+ var init_installation_files = __esm({
5683
+ "src/storage/installation/installation-files.ts"() {
5684
+ "use strict";
5685
+ init_node_error();
5686
+ MAXIMUM_FILE_BYTES = 16 * 1024;
5687
+ }
5688
+ });
5689
+
5690
+ // src/storage/state-directory.ts
5691
+ import { homedir } from "node:os";
5692
+ import { join as join2, resolve } from "node:path";
5693
+ function readStateDirectory(environment = process.env) {
5694
+ const configured = environment["MOBIUS_STATE_DIRECTORY"]?.trim();
5695
+ if (configured !== void 0 && configured.length > 0) {
5696
+ return resolve(configured);
5697
+ }
5698
+ return join2(homedir(), ".mobius");
5699
+ }
5700
+ var init_state_directory = __esm({
5701
+ "src/storage/state-directory.ts"() {
5702
+ "use strict";
5703
+ }
5704
+ });
5705
+
5706
+ // src/storage/state-root.ts
5707
+ import { readFile, stat } from "node:fs/promises";
5708
+ import { basename, dirname as dirname2, join as join3 } from "node:path";
5709
+ async function exists(path8) {
5710
+ return await stat(path8).then(
5711
+ () => true,
5712
+ () => false
5713
+ );
5714
+ }
5715
+ async function owningRoot(directory) {
5716
+ const application = dirname2(directory);
5717
+ const installations = dirname2(application);
5718
+ if (basename(installations) !== "installations") {
5719
+ return null;
5720
+ }
5721
+ let pointer;
5722
+ try {
5723
+ pointer = JSON.parse(await readFile(installationPointerPath(application), "utf8"));
5724
+ } catch {
5725
+ return null;
5726
+ }
5727
+ if (typeof pointer !== "object" || pointer === null || !("installationId" in pointer) || pointer.installationId !== basename(directory)) {
5728
+ return null;
5729
+ }
5730
+ const container = dirname2(installations);
5731
+ return basename(dirname2(container)) === "versions" ? dirname2(dirname2(container)) : container;
5732
+ }
5733
+ async function validateStateRoot(environment) {
5734
+ const directory = readStateDirectory(environment);
5735
+ if (await exists(join3(directory, "current-data.txt")) || await exists(join3(directory, "versions"))) {
5736
+ return;
5737
+ }
5738
+ const root = await owningRoot(directory);
5739
+ if (root !== null) {
5740
+ throw new StateRootError(directory, root);
5741
+ }
5742
+ }
5743
+ var StateRootError;
5744
+ var init_state_root = __esm({
5745
+ "src/storage/state-root.ts"() {
5746
+ "use strict";
5747
+ init_installation_files();
5748
+ init_state_directory();
5749
+ StateRootError = class extends Error {
5750
+ code = "state_root_is_installation_data";
5751
+ owningRoot;
5752
+ constructor(stateDirectory, owningRoot2) {
5753
+ super(
5754
+ `MOBIUS_STATE_DIRECTORY (${stateDirectory}) is Mobius installation data, not a state root. Use the state root that owns it: MOBIUS_STATE_DIRECTORY=${owningRoot2}`
5755
+ );
5756
+ this.name = "StateRootError";
5757
+ this.owningRoot = owningRoot2;
5758
+ }
5759
+ };
5760
+ }
5761
+ });
5762
+
5608
5763
  // src/acp/harness/claude/parent-lifeline.ts
5609
5764
  import { spawn } from "node:child_process";
5610
5765
  import { Duplex } from "node:stream";
@@ -41746,7 +41901,7 @@ var init_background_task_notifications = __esm({
41746
41901
  });
41747
41902
 
41748
41903
  // src/acp/harness/claude/upstream/dist/elicitation.js
41749
- import { randomUUID as randomUUID2 } from "node:crypto";
41904
+ import { randomUUID as randomUUID3 } from "node:crypto";
41750
41905
  import { CreateElicitationResponse } from "@agentclientprotocol/sdk";
41751
41906
  function mcpElicitationToCreateRequest(request, sessionId) {
41752
41907
  if (request.mode === "url") {
@@ -41761,7 +41916,7 @@ function mcpElicitationToCreateRequest(request, sessionId) {
41761
41916
  // URL elicitations need a stable id so the client can correlate the
41762
41917
  // later `session/complete_elicitation` notification. MCP servers usually
41763
41918
  // provide one; fall back to a generated id if not.
41764
- elicitationId: request.elicitationId ?? randomUUID2()
41919
+ elicitationId: request.elicitationId ?? randomUUID3()
41765
41920
  };
41766
41921
  }
41767
41922
  return {
@@ -47644,7 +47799,7 @@ function isBackEdge(ctx, value) {
47644
47799
  const backEdges = ctx[STATE]?.backEdges;
47645
47800
  return backEdges !== void 0 && isRef(value) && backEdges.has(value);
47646
47801
  }
47647
- var $ZodCyclicError, STATE, NO_ISSUES, recursive, NONE, ASSUMED, PROVEN, handoff, open3, memo;
47802
+ var $ZodCyclicError, STATE, NO_ISSUES, recursive, NONE, ASSUMED, PROVEN, handoff, open4, memo;
47648
47803
  var init_memoizer = __esm({
47649
47804
  "../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/memoizer.js"() {
47650
47805
  init_util();
@@ -47660,7 +47815,7 @@ var init_memoizer = __esm({
47660
47815
  NONE = 0;
47661
47816
  ASSUMED = 1;
47662
47817
  PROVEN = 2;
47663
- open3 = [];
47818
+ open4 = [];
47664
47819
  memo = {
47665
47820
  alloc(_inst, payload, empty) {
47666
47821
  const bucket = handoff;
@@ -47669,7 +47824,7 @@ var init_memoizer = __esm({
47669
47824
  handoff = void 0;
47670
47825
  const entry = { value: empty, issues: null };
47671
47826
  bucket.set(payload.value, entry);
47672
- open3.push(entry);
47827
+ open4.push(entry);
47673
47828
  return empty;
47674
47829
  },
47675
47830
  guard(inst) {
@@ -47740,10 +47895,10 @@ var init_memoizer = __esm({
47740
47895
  return payload;
47741
47896
  }
47742
47897
  handoff = bucket;
47743
- const depth = open3.length;
47898
+ const depth = open4.length;
47744
47899
  const result = base(payload, ctx);
47745
47900
  handoff = void 0;
47746
- const entry = open3.length > depth ? open3.pop() : void 0;
47901
+ const entry = open4.length > depth ? open4.pop() : void 0;
47747
47902
  if (result instanceof Promise) {
47748
47903
  return result.then((r) => {
47749
47904
  if (entry)
@@ -65163,7 +65318,7 @@ var init_session_mode = __esm({
65163
65318
 
65164
65319
  // src/acp/harness/claude/upstream/dist/acp-agent.js
65165
65320
  import { execFile } from "node:child_process";
65166
- import { randomUUID as randomUUID3 } from "node:crypto";
65321
+ import { randomUUID as randomUUID4 } from "node:crypto";
65167
65322
  import { existsSync as existsSync3 } from "node:fs";
65168
65323
  import * as fs4 from "node:fs/promises";
65169
65324
  import * as os3 from "node:os";
@@ -65439,7 +65594,7 @@ async function authenticateMcpServer(host, sessionId, query, serverName) {
65439
65594
  if (!login.authUrl) {
65440
65595
  throw new Error("Claude Code requested user action without returning an authorization URL");
65441
65596
  }
65442
- const elicitationId = `mcp-oauth-${randomUUID3()}`;
65597
+ const elicitationId = `mcp-oauth-${randomUUID4()}`;
65443
65598
  const flowAbort = new AbortController();
65444
65599
  const abortFlow = () => flowAbort.abort(session.abortController.signal.reason);
65445
65600
  session.abortController.signal.addEventListener("abort", abortFlow, { once: true });
@@ -67294,7 +67449,7 @@ var init_acp_agent = __esm({
67294
67449
  await this.publishTaskPlan(params.sessionId, session.taskState);
67295
67450
  }
67296
67451
  const userMessage = promptToClaude(params);
67297
- const promptUuid = randomUUID3();
67452
+ const promptUuid = randomUUID4();
67298
67453
  userMessage.uuid = promptUuid;
67299
67454
  const firstText = params.prompt[0]?.type === "text" ? params.prompt[0].text : "";
67300
67455
  const isLocalOnlyCommand = firstText.startsWith("/") && LOCAL_ONLY_COMMANDS.has(firstText.split(" ", 1)[0]);
@@ -67446,7 +67601,7 @@ var init_acp_agent = __esm({
67446
67601
  prompt: params.prompt
67447
67602
  };
67448
67603
  const userMessage = promptToClaude(promptRequest);
67449
- const steeredUuid = randomUUID3();
67604
+ const steeredUuid = randomUUID4();
67450
67605
  userMessage.uuid = steeredUuid;
67451
67606
  userMessage.priority = (session.pendingUserInputCount ?? 0) > 0 ? STEER_PRIORITY_LATER : STEER_PRIORITY_NOW;
67452
67607
  turnInFlight.steeredEchoes ??= /* @__PURE__ */ new Set();
@@ -67839,7 +67994,7 @@ var init_acp_agent = __esm({
67839
67994
  case "status": {
67840
67995
  if (message.status === "compacting") {
67841
67996
  if (compaction === null) {
67842
- compaction = { id: randomUUID3() };
67997
+ compaction = { id: randomUUID4() };
67843
67998
  await sendUpdate({
67844
67999
  sessionId: message.session_id,
67845
68000
  update: {
@@ -69465,7 +69620,7 @@ ${message.api_refusal_explanation}` : "";
69465
69620
  } else if (creationOpts.resume) {
69466
69621
  sessionId = creationOpts.resume;
69467
69622
  } else {
69468
- sessionId = randomUUID3();
69623
+ sessionId = randomUUID4();
69469
69624
  }
69470
69625
  const input2 = new Pushable();
69471
69626
  const settingsManager = new SettingsManager(params.cwd, {
@@ -69663,7 +69818,7 @@ ${message.api_refusal_explanation}` : "";
69663
69818
  ...acpAdditionalDirectories
69664
69819
  ];
69665
69820
  if (creationOpts?.resume === void 0) {
69666
- options.sessionId = creationOpts.publicSessionId ? randomUUID3() : sessionId;
69821
+ options.sessionId = creationOpts.publicSessionId ? randomUUID4() : sessionId;
69667
69822
  }
69668
69823
  if (abortController?.signal.aborted) {
69669
69824
  throw new Error("Cancelled");
@@ -69923,9 +70078,9 @@ var init_path_error = __esm({
69923
70078
  // src/util/platform/posix.ts
69924
70079
  import { execFile as execFile2 } from "node:child_process";
69925
70080
  import { constants as constants3 } from "node:fs";
69926
- import { access as access2, chmod, lstat as lstat2, realpath as realpath3, unlink as unlink2 } from "node:fs/promises";
70081
+ import { access as access2, chmod, lstat as lstat2, realpath as realpath3, unlink as unlink3 } from "node:fs/promises";
69927
70082
  import { tmpdir } from "node:os";
69928
- import { join as join7 } from "node:path";
70083
+ import { join as join10 } from "node:path";
69929
70084
  function parseProcessTable(output2) {
69930
70085
  const entries = [];
69931
70086
  for (const line of output2.split("\n")) {
@@ -70005,7 +70160,7 @@ function terminateProcess(child, signal) {
70005
70160
  }
70006
70161
  async function removeControlSocket(path8) {
70007
70162
  try {
70008
- await unlink2(path8);
70163
+ await unlink3(path8);
70009
70164
  } catch (cause) {
70010
70165
  if (!(cause instanceof Error) || !("code" in cause) || cause.code !== "ENOENT") {
70011
70166
  throw cause;
@@ -70020,7 +70175,7 @@ var init_posix = __esm({
70020
70175
  PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
70021
70176
  PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
70022
70177
  posixOperations = {
70023
- controlSocketPath: (installationHash) => join7(tmpdir(), `mobius-${installationHash}.sock`),
70178
+ controlSocketPath: (installationHash) => join10(tmpdir(), `mobius-${installationHash}.sock`),
70024
70179
  prepareControlSocket: removeControlSocket,
70025
70180
  secureControlSocket: async (path8) => {
70026
70181
  await chmod(path8, 384);
@@ -70055,8 +70210,8 @@ var init_posix = __esm({
70055
70210
 
70056
70211
  // src/util/platform/linux.ts
70057
70212
  import { constants as constants4, readdirSync as readdirSync2, readFileSync as readFileSync2 } from "node:fs";
70058
- import { access as access3, readdir as readdir3, readFile as readFile3, realpath as realpath4, stat as stat3 } from "node:fs/promises";
70059
- import { isAbsolute as isAbsolute5, join as join8 } from "node:path";
70213
+ import { access as access3, readdir as readdir4, readFile as readFile4, realpath as realpath4, stat as stat4 } from "node:fs/promises";
70214
+ import { isAbsolute as isAbsolute5, join as join11 } from "node:path";
70060
70215
  function appendLinuxProcessTableEntry(entries, processId, encoded) {
70061
70216
  const closingParenthesis = encoded.lastIndexOf(")");
70062
70217
  if (!encoded.startsWith(`${processId.toString()} (`) || closingParenthesis < 0) {
@@ -70073,7 +70228,7 @@ function appendLinuxProcessTableEntry(entries, processId, encoded) {
70073
70228
  async function readLinuxProcessTable() {
70074
70229
  const entries = [];
70075
70230
  try {
70076
- const directories = await readdir3("/proc", { withFileTypes: true });
70231
+ const directories = await readdir4("/proc", { withFileTypes: true });
70077
70232
  for (const directory of directories) {
70078
70233
  if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
70079
70234
  continue;
@@ -70086,7 +70241,7 @@ async function readLinuxProcessTable() {
70086
70241
  appendLinuxProcessTableEntry(
70087
70242
  entries,
70088
70243
  processId,
70089
- await readFile3(join8("/proc", directory.name, "stat"), "utf8")
70244
+ await readFile4(join11("/proc", directory.name, "stat"), "utf8")
70090
70245
  );
70091
70246
  } catch {
70092
70247
  }
@@ -70111,7 +70266,7 @@ function readLinuxProcessTableSynchronously() {
70111
70266
  appendLinuxProcessTableEntry(
70112
70267
  entries,
70113
70268
  processId,
70114
- readFileSync2(join8("/proc", directory.name, "stat"), "utf8")
70269
+ readFileSync2(join11("/proc", directory.name, "stat"), "utf8")
70115
70270
  );
70116
70271
  } catch {
70117
70272
  }
@@ -70128,7 +70283,7 @@ async function readLinuxProcessTableWithFallback() {
70128
70283
  for (const candidate of ["/usr/bin/ps", "/bin/ps", "/run/current-system/sw/bin/ps"]) {
70129
70284
  try {
70130
70285
  const resolvedPath = await realpath4(candidate);
70131
- if (!(await stat3(resolvedPath)).isFile()) {
70286
+ if (!(await stat4(resolvedPath)).isFile()) {
70132
70287
  continue;
70133
70288
  }
70134
70289
  await access3(resolvedPath, constants4.X_OK);
@@ -70144,7 +70299,7 @@ async function readLinuxProcessTableWithFallback() {
70144
70299
  }
70145
70300
  function processExists2(processId) {
70146
70301
  try {
70147
- const encoded = readFileSync2(join8("/proc", processId.toString(), "stat"), "utf8");
70302
+ const encoded = readFileSync2(join11("/proc", processId.toString(), "stat"), "utf8");
70148
70303
  const closingParenthesis = encoded.lastIndexOf(")");
70149
70304
  if (closingParenthesis >= 0) {
70150
70305
  const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
@@ -70168,7 +70323,7 @@ var init_linux = __esm({
70168
70323
  processExists: processExists2,
70169
70324
  claudeCodeExecutablePaths: (environment) => {
70170
70325
  const homeDirectory = environment["HOME"];
70171
- return homeDirectory !== void 0 && isAbsolute5(homeDirectory) ? [join8(homeDirectory, ".local", "bin", "claude")] : [];
70326
+ return homeDirectory !== void 0 && isAbsolute5(homeDirectory) ? [join11(homeDirectory, ".local", "bin", "claude")] : [];
70172
70327
  }
70173
70328
  };
70174
70329
  }
@@ -70176,7 +70331,7 @@ var init_linux = __esm({
70176
70331
 
70177
70332
  // src/util/platform/claude-desktop.ts
70178
70333
  import { readdirSync as readdirSync3 } from "node:fs";
70179
- import { join as join9 } from "node:path";
70334
+ import { join as join12 } from "node:path";
70180
70335
  function installedDirectories(directory) {
70181
70336
  try {
70182
70337
  return readdirSync3(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
@@ -70192,14 +70347,14 @@ function claudeDesktopExecutablePaths(roots, executablePaths) {
70192
70347
  for (const root of roots) {
70193
70348
  const versions = installedDirectories(root).filter((version2) => /^\d+\.\d+\.\d+$/.test(version2)).toSorted((left, right) => right.localeCompare(left, "en", { numeric: true }));
70194
70349
  for (const version2 of versions) {
70195
- const directory = join9(root, version2);
70350
+ const directory = join12(root, version2);
70196
70351
  const installations = [
70197
70352
  directory,
70198
- ...installedDirectories(directory).map((build) => join9(directory, build))
70353
+ ...installedDirectories(directory).map((build) => join12(directory, build))
70199
70354
  ];
70200
70355
  for (const installation of installations) {
70201
70356
  for (const executablePath of executablePaths) {
70202
- paths.push(join9(installation, ...executablePath));
70357
+ paths.push(join12(installation, ...executablePath));
70203
70358
  }
70204
70359
  }
70205
70360
  }
@@ -70213,7 +70368,7 @@ var init_claude_desktop = __esm({
70213
70368
  });
70214
70369
 
70215
70370
  // src/util/platform/macos.ts
70216
- import { isAbsolute as isAbsolute6, join as join10 } from "node:path";
70371
+ import { isAbsolute as isAbsolute6, join as join13 } from "node:path";
70217
70372
  var macosPlatform;
70218
70373
  var init_macos = __esm({
70219
70374
  "src/util/platform/macos.ts"() {
@@ -70229,10 +70384,10 @@ var init_macos = __esm({
70229
70384
  const paths = ["/opt/homebrew/bin/claude", "/usr/local/bin/claude"];
70230
70385
  const homeDirectory = environment["HOME"];
70231
70386
  if (homeDirectory !== void 0 && isAbsolute6(homeDirectory)) {
70232
- paths.unshift(join10(homeDirectory, ".local", "bin", "claude"));
70387
+ paths.unshift(join13(homeDirectory, ".local", "bin", "claude"));
70233
70388
  paths.push(
70234
70389
  ...claudeDesktopExecutablePaths(
70235
- [join10(homeDirectory, "Library", "Application Support", "Claude", "claude-code")],
70390
+ [join13(homeDirectory, "Library", "Application Support", "Claude", "claude-code")],
70236
70391
  [["claude.app", "Contents", "MacOS", "claude"], ["claude"]]
70237
70392
  )
70238
70393
  );
@@ -70261,8 +70416,8 @@ var init_process_error = __esm({
70261
70416
 
70262
70417
  // src/util/platform/windows.ts
70263
70418
  import { execFile as execFile3 } from "node:child_process";
70264
- import { readFile as readFile4, realpath as realpath5 } from "node:fs/promises";
70265
- import { dirname as dirname5, extname, isAbsolute as isAbsolute7, join as join11, resolve as resolve7 } from "node:path";
70419
+ import { readFile as readFile5, realpath as realpath5 } from "node:fs/promises";
70420
+ import { dirname as dirname7, extname, isAbsolute as isAbsolute7, join as join14, resolve as resolve8 } from "node:path";
70266
70421
  import { promisify as promisify2 } from "node:util";
70267
70422
  function environmentValue(environment, name2) {
70268
70423
  return Object.entries(environment).find(([key]) => key.toUpperCase() === name2.toUpperCase())?.[1];
@@ -70271,16 +70426,16 @@ function desktopClaudeExecutablePaths(environment) {
70271
70426
  const roots = [];
70272
70427
  const localAppData = environmentValue(environment, "LOCALAPPDATA");
70273
70428
  if (localAppData !== void 0 && isAbsolute7(localAppData)) {
70274
- const dataDirectory = join11(localAppData, "Claude-Data");
70429
+ const dataDirectory = join14(localAppData, "Claude-Data");
70275
70430
  for (const installation of installedDirectories(dataDirectory)) {
70276
70431
  if (installation.startsWith("claude_")) {
70277
- roots.push(join11(dataDirectory, installation, "claude-code"));
70432
+ roots.push(join14(dataDirectory, installation, "claude-code"));
70278
70433
  }
70279
70434
  }
70280
70435
  }
70281
70436
  const appData = environmentValue(environment, "APPDATA");
70282
70437
  if (appData !== void 0 && isAbsolute7(appData)) {
70283
- roots.push(join11(appData, "Claude", "claude-code"));
70438
+ roots.push(join14(appData, "Claude", "claude-code"));
70284
70439
  }
70285
70440
  return claudeDesktopExecutablePaths(roots, [["claude.exe"]]);
70286
70441
  }
@@ -70303,13 +70458,13 @@ async function resolveExecutableTarget(path8) {
70303
70458
  resolvedPath = await realpath5(path8);
70304
70459
  }
70305
70460
  if (extname(resolvedPath).toLowerCase() === ".cmd") {
70306
- const shim = await readFile4(resolvedPath, "utf8");
70461
+ const shim = await readFile5(resolvedPath, "utf8");
70307
70462
  if (shim.includes('SET "NPM_CLI_JS=%~dp0\\node_modules\\npm\\bin\\npm-cli.js"') && shim.includes('"%NODE_EXE%" "%NPM_CLI_JS%" %*')) {
70308
- return await realpath5(resolve7(dirname5(resolvedPath), "node_modules/npm/bin/npm-cli.js"));
70463
+ return await realpath5(resolve8(dirname7(resolvedPath), "node_modules/npm/bin/npm-cli.js"));
70309
70464
  }
70310
70465
  const script = /"%_prog%"\s+"%dp0%[\\/]([^"\r\n]+\.(?:js|mjs|cjs))"\s+%\*/iu.exec(shim)?.[1];
70311
70466
  if (script !== void 0 && shim.includes("SET dp0=%~dp0")) {
70312
- resolvedPath = await realpath5(resolve7(dirname5(resolvedPath), script));
70467
+ resolvedPath = await realpath5(resolve8(dirname7(resolvedPath), script));
70313
70468
  } else {
70314
70469
  const pnpmScript = /^\s*node\s+"%~dp0[\\/]([^"\r\n]+\.(?:js|mjs|cjs))"\s+%\*\s*$/imu.exec(shim)?.[1];
70315
70470
  if (pnpmScript === void 0 || !shim.includes("@SETLOCAL")) {
@@ -70318,7 +70473,7 @@ async function resolveExecutableTarget(path8) {
70318
70473
  "Use a native executable or a verified Node entrypoint"
70319
70474
  );
70320
70475
  }
70321
- resolvedPath = await realpath5(resolve7(dirname5(resolvedPath), pnpmScript));
70476
+ resolvedPath = await realpath5(resolve8(dirname7(resolvedPath), pnpmScript));
70322
70477
  }
70323
70478
  }
70324
70479
  return resolvedPath;
@@ -70342,7 +70497,7 @@ function readProcessTable() {
70342
70497
  }
70343
70498
  return new Promise((resolveTable) => {
70344
70499
  execFile3(
70345
- join11(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
70500
+ join14(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
70346
70501
  [
70347
70502
  "-NoLogo",
70348
70503
  "-NoProfile",
@@ -70383,7 +70538,7 @@ async function validatePathPermissions(path8, _directory, privateAccess, signal)
70383
70538
  }
70384
70539
  try {
70385
70540
  await execute(
70386
- join11(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
70541
+ join14(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
70387
70542
  [
70388
70543
  "-NoLogo",
70389
70544
  "-NoProfile",
@@ -70466,11 +70621,11 @@ if ($env:MOBIUS_PERMISSION_PRIVATE -eq '1') {
70466
70621
  const paths = [];
70467
70622
  const userProfile = environmentValue(environment, "USERPROFILE");
70468
70623
  if (userProfile !== void 0 && isAbsolute7(userProfile)) {
70469
- paths.push(join11(userProfile, ".local", "bin", "claude.exe"));
70624
+ paths.push(join14(userProfile, ".local", "bin", "claude.exe"));
70470
70625
  }
70471
70626
  const localAppData = environmentValue(environment, "LOCALAPPDATA");
70472
70627
  if (localAppData !== void 0 && isAbsolute7(localAppData)) {
70473
- paths.push(join11(localAppData, "Microsoft", "WinGet", "Links", "claude.exe"));
70628
+ paths.push(join14(localAppData, "Microsoft", "WinGet", "Links", "claude.exe"));
70474
70629
  }
70475
70630
  paths.push(...desktopClaudeExecutablePaths(environment));
70476
70631
  return paths;
@@ -70508,13 +70663,13 @@ var init_platform = __esm({
70508
70663
 
70509
70664
  // src/util/process/executable.ts
70510
70665
  import { spawn as spawn3 } from "node:child_process";
70511
- import { stat as stat4 } from "node:fs/promises";
70512
- import { join as join12, resolve as resolve8 } from "node:path";
70666
+ import { stat as stat5 } from "node:fs/promises";
70667
+ import { join as join15, resolve as resolve9 } from "node:path";
70513
70668
  async function resolveExecutablePath(requestedPath2, platform2 = process.platform) {
70514
- const absoluteRequestedPath = resolve8(requestedPath2);
70669
+ const absoluteRequestedPath = resolve9(requestedPath2);
70515
70670
  try {
70516
70671
  const resolvedPath = await platformSupportFor(platform2).resolveExecutableTarget(absoluteRequestedPath);
70517
- const metadata = await stat4(resolvedPath);
70672
+ const metadata = await stat5(resolvedPath);
70518
70673
  if (!metadata.isFile()) {
70519
70674
  return null;
70520
70675
  }
@@ -70542,7 +70697,7 @@ async function findExecutableOnPath(executableName, environment, platform2 = pro
70542
70697
  continue;
70543
70698
  }
70544
70699
  for (const extension of extensions) {
70545
- const requestedPath2 = resolve8(join12(entry, `${executableName}${extension}`));
70700
+ const requestedPath2 = resolve9(join15(entry, `${executableName}${extension}`));
70546
70701
  const executable = await resolveExecutablePath(requestedPath2, platform2);
70547
70702
  if (executable !== null) {
70548
70703
  return executable;
@@ -71791,7 +71946,7 @@ var init_items = __esm({
71791
71946
  });
71792
71947
 
71793
71948
  // src/acp/harness/codex/borrowed-agent.ts
71794
- import { randomUUID as randomUUID4 } from "node:crypto";
71949
+ import { randomUUID as randomUUID5 } from "node:crypto";
71795
71950
  import { setTimeout as setTimeout2 } from "node:timers/promises";
71796
71951
  var REQUEST_TIMEOUT, POLL_INTERVAL, queueResponseSchema, queuePageSchema, CodexBorrowedAcpAgent;
71797
71952
  var init_borrowed_agent = __esm({
@@ -71959,7 +72114,7 @@ var init_borrowed_agent = __esm({
71959
72114
  if (this.#pending !== null) {
71960
72115
  throw new AcpExecutionError("Another prompt is already running", {}, "session_busy");
71961
72116
  }
71962
- const pending = { clientId: randomUUID4(), completion: Promise.withResolvers() };
72117
+ const pending = { clientId: randomUUID5(), completion: Promise.withResolvers() };
71963
72118
  this.#pending = pending;
71964
72119
  void pending.completion.promise.catch(() => {
71965
72120
  });
@@ -72071,7 +72226,7 @@ var init_borrowed_agent = __esm({
72071
72226
 
72072
72227
  // src/storage/files/local-files.ts
72073
72228
  import { createReadStream as createReadStream2 } from "node:fs";
72074
- import { mkdir as mkdir3, open as open4, readdir as readdir4, readFile as readFile5, realpath as realpath6, stat as stat5 } from "node:fs/promises";
72229
+ import { mkdir as mkdir4, open as open5, readdir as readdir5, readFile as readFile6, realpath as realpath6, stat as stat6 } from "node:fs/promises";
72075
72230
  function entryKind(entry) {
72076
72231
  if (entry.isDirectory()) {
72077
72232
  return "directory";
@@ -72094,7 +72249,7 @@ async function canonicalPath(path8) {
72094
72249
  return await realpath6(path8);
72095
72250
  }
72096
72251
  async function readPathMetadata(path8) {
72097
- const metadata = await stat5(path8);
72252
+ const metadata = await stat6(path8);
72098
72253
  return {
72099
72254
  kind: metadata.isDirectory() ? "directory" : metadata.isFile() ? "file" : "other",
72100
72255
  modifiedAt: metadata.mtime,
@@ -72103,20 +72258,20 @@ async function readPathMetadata(path8) {
72103
72258
  };
72104
72259
  }
72105
72260
  async function listDirectory(path8) {
72106
- const entries = await readdir4(path8, { withFileTypes: true });
72261
+ const entries = await readdir5(path8, { withFileTypes: true });
72107
72262
  return entries.map((entry) => ({ kind: entryKind(entry), name: entry.name }));
72108
72263
  }
72109
72264
  async function ensurePrivateDirectory(path8) {
72110
- await mkdir3(path8, { mode: 448, recursive: true });
72265
+ await mkdir4(path8, { mode: 448, recursive: true });
72111
72266
  }
72112
72267
  async function ensureCanonicalDirectory(path8) {
72113
72268
  await ensurePrivateDirectory(path8);
72114
72269
  const resolved = await realpath6(path8);
72115
- return (await stat5(resolved)).isDirectory() ? resolved : null;
72270
+ return (await stat6(resolved)).isDirectory() ? resolved : null;
72116
72271
  }
72117
72272
  async function readFileStart(path8, byteLength) {
72118
72273
  const bytes = new Uint8Array(byteLength);
72119
- const handle = await open4(path8, "r");
72274
+ const handle = await open5(path8, "r");
72120
72275
  try {
72121
72276
  await handle.read(bytes, 0, byteLength, 0);
72122
72277
  } finally {
@@ -72125,7 +72280,7 @@ async function readFileStart(path8, byteLength) {
72125
72280
  return bytes;
72126
72281
  }
72127
72282
  async function readFileBytes(path8) {
72128
- return await readFile5(path8);
72283
+ return await readFile6(path8);
72129
72284
  }
72130
72285
  function readFileChunks(path8, chunkBytes, signal) {
72131
72286
  return createReadStream2(path8, { highWaterMark: chunkBytes, signal });
@@ -72137,7 +72292,7 @@ var init_local_files = __esm({
72137
72292
  });
72138
72293
 
72139
72294
  // src/acp/content/raster.ts
72140
- import { basename as basename4, isAbsolute as isAbsolute9, normalize } from "node:path";
72295
+ import { basename as basename5, isAbsolute as isAbsolute9, normalize } from "node:path";
72141
72296
  import { fileURLToPath } from "node:url";
72142
72297
  function startsWith(bytes, signature, offset = 0) {
72143
72298
  if (bytes.byteLength < offset + signature.byteLength) {
@@ -72225,7 +72380,7 @@ async function readLocalRaster(uri, signal) {
72225
72380
  if (mimeType === null) {
72226
72381
  return null;
72227
72382
  }
72228
- return new LocalRasterImage(basename4(target) || "Image", mimeType, target);
72383
+ return new LocalRasterImage(basename5(target) || "Image", mimeType, target);
72229
72384
  }
72230
72385
  var MAX_LOCAL_RASTER_BYTES, PNG_SIGNATURE, JPEG_SIGNATURE, GIF87_SIGNATURE, GIF89_SIGNATURE, RIFF_SIGNATURE, WEBP_SIGNATURE, LocalRasterImage;
72231
72386
  var init_raster = __esm({
@@ -72355,7 +72510,7 @@ var init_history_images = __esm({
72355
72510
  });
72356
72511
 
72357
72512
  // src/acp/harness/codex/owned-agent.ts
72358
- import { randomUUID as randomUUID5 } from "node:crypto";
72513
+ import { randomUUID as randomUUID6 } from "node:crypto";
72359
72514
  import { setTimeout as delay } from "node:timers/promises";
72360
72515
  import { methods as methods2 } from "@agentclientprotocol/sdk";
72361
72516
  function permissionDecision(optionId) {
@@ -72585,7 +72740,7 @@ var init_owned_agent = __esm({
72585
72740
  signal.throwIfAborted();
72586
72741
  const open7 = this.#settleCompaction("failed", cause instanceof Error ? cause.message : String(cause));
72587
72742
  if (open7 === null && !this.#turnSettledCompaction) {
72588
- const compactionId = randomUUID5();
72743
+ const compactionId = randomUUID6();
72589
72744
  await this.#enqueue(async () => {
72590
72745
  await this.#context.emit({
72591
72746
  compactionId,
@@ -73051,7 +73206,7 @@ var init_owned_agent = __esm({
73051
73206
  });
73052
73207
 
73053
73208
  // src/acp/harness/codex/history.ts
73054
- import { createHash } from "node:crypto";
73209
+ import { createHash as createHash2 } from "node:crypto";
73055
73210
  async function replayCodexHistory(client2, threadId, emit, signal) {
73056
73211
  const deadline = AbortSignal.any([signal, AbortSignal.timeout(6e4)]);
73057
73212
  const seenCursors = /* @__PURE__ */ new Set();
@@ -73136,7 +73291,7 @@ async function replayCodexHistory(client2, threadId, emit, signal) {
73136
73291
  }
73137
73292
  }
73138
73293
  if (turn.error != null) {
73139
- const identity2 = createHash("sha256").update(threadId).update("\0").update(turn.id ?? turnIndex.toString()).digest("hex");
73294
+ const identity2 = createHash2("sha256").update(threadId).update("\0").update(turn.id ?? turnIndex.toString()).digest("hex");
73140
73295
  await emit({
73141
73296
  sessionUpdate: "tool_call",
73142
73297
  toolCallId: `agent-error-${identity2}`,
@@ -76721,8 +76876,8 @@ var init_process = __esm({
76721
76876
  const sessionFile = typeof state?.sessionFile === "string" ? state.sessionFile : null;
76722
76877
  if (sessionFile) {
76723
76878
  const { mkdirSync: mkdirSync5 } = await import("node:fs");
76724
- const { dirname: dirname12 } = await import("node:path");
76725
- mkdirSync5(dirname12(sessionFile), { recursive: true });
76879
+ const { dirname: dirname13 } = await import("node:path");
76880
+ mkdirSync5(dirname13(sessionFile), { recursive: true });
76726
76881
  }
76727
76882
  } catch {
76728
76883
  }
@@ -77028,9 +77183,9 @@ var init_auth_required = __esm({
77028
77183
  });
77029
77184
 
77030
77185
  // src/acp/harness/pi/upstream/dist/acp/environment.js
77031
- import { homedir as homedir2 } from "node:os";
77186
+ import { homedir as homedir3 } from "node:os";
77032
77187
  function environmentHome(environment) {
77033
- return environment["HOME"] ?? environment["USERPROFILE"] ?? homedir2();
77188
+ return environment["HOME"] ?? environment["USERPROFILE"] ?? homedir3();
77034
77189
  }
77035
77190
  var init_environment = __esm({
77036
77191
  "src/acp/harness/pi/upstream/dist/acp/environment.js"() {
@@ -77039,12 +77194,12 @@ var init_environment = __esm({
77039
77194
  });
77040
77195
 
77041
77196
  // src/acp/harness/pi/upstream/dist/acp/paths.js
77042
- import { join as join13 } from "node:path";
77197
+ import { join as join16 } from "node:path";
77043
77198
  function getPiAcpDir(environment = process.env) {
77044
- return join13(environmentHome(environment), ".pi", "pi-acp");
77199
+ return join16(environmentHome(environment), ".pi", "pi-acp");
77045
77200
  }
77046
77201
  function getPiAcpSessionMapPath(environment = process.env) {
77047
- return join13(getPiAcpDir(environment), "session-map.json");
77202
+ return join16(getPiAcpDir(environment), "session-map.json");
77048
77203
  }
77049
77204
  var init_paths = __esm({
77050
77205
  "src/acp/harness/pi/upstream/dist/acp/paths.js"() {
@@ -77100,13 +77255,13 @@ var init_pi_commands = __esm({
77100
77255
 
77101
77256
  // src/acp/harness/pi/upstream/dist/acp/pi-sessions.js
77102
77257
  import { closeSync as closeSync2, existsSync as existsSync4, openSync as openSync2, readdirSync as readdirSync4, readFileSync as readFileSync3, readSync as readSync2, statSync as statSync2 } from "node:fs";
77103
- import { isAbsolute as isAbsolute10, join as join14, resolve as resolve9 } from "node:path";
77258
+ import { isAbsolute as isAbsolute10, join as join17, resolve as resolve10 } from "node:path";
77104
77259
  function getPiAgentDir(environment) {
77105
77260
  const configured = environment["PI_CODING_AGENT_DIR"];
77106
- return configured ? resolve9(configured) : join14(environmentHome(environment), ".pi", "agent");
77261
+ return configured ? resolve10(configured) : join17(environmentHome(environment), ".pi", "agent");
77107
77262
  }
77108
77263
  function readSessionDirFromSettings(agentDir) {
77109
- const settingsPath = join14(agentDir, "settings.json");
77264
+ const settingsPath = join17(agentDir, "settings.json");
77110
77265
  try {
77111
77266
  if (!existsSync4(settingsPath)) {
77112
77267
  return null;
@@ -77120,25 +77275,25 @@ function readSessionDirFromSettings(agentDir) {
77120
77275
  if (typeof sessionDir !== "string" || !sessionDir.trim()) {
77121
77276
  return null;
77122
77277
  }
77123
- return isAbsolute10(sessionDir) ? sessionDir : resolve9(agentDir, sessionDir);
77278
+ return isAbsolute10(sessionDir) ? sessionDir : resolve10(agentDir, sessionDir);
77124
77279
  } catch {
77125
77280
  return null;
77126
77281
  }
77127
77282
  }
77128
77283
  function getPiSessionsDir(environment = process.env) {
77129
77284
  const agentDir = getPiAgentDir(environment);
77130
- return readSessionDirFromSettings(agentDir) ?? join14(agentDir, "sessions");
77285
+ return readSessionDirFromSettings(agentDir) ?? join17(agentDir, "sessions");
77131
77286
  }
77132
77287
  function getPiSessionDiscoveryDirs(environment) {
77133
77288
  const discoveryDirectories = [getPiSessionsDir(environment)];
77134
77289
  const mobiusSessionDirectory = environment["MOBIUS_PI_SESSION_DIR"];
77135
77290
  if (mobiusSessionDirectory !== void 0 && mobiusSessionDirectory.trim().length > 0) {
77136
- const mobiusSessionsRoot = resolve9(mobiusSessionDirectory, "..");
77291
+ const mobiusSessionsRoot = resolve10(mobiusSessionDirectory, "..");
77137
77292
  for (const entry of readdirSync4(mobiusSessionsRoot, { withFileTypes: true, encoding: "utf-8" })) {
77138
77293
  if (!entry.isDirectory()) {
77139
77294
  continue;
77140
77295
  }
77141
- const directory = join14(mobiusSessionsRoot, entry.name);
77296
+ const directory = join17(mobiusSessionsRoot, entry.name);
77142
77297
  if (!discoveryDirectories.includes(directory)) {
77143
77298
  discoveryDirectories.push(directory);
77144
77299
  }
@@ -77155,7 +77310,7 @@ function walkJsonlFiles(dir, out2) {
77155
77310
  }
77156
77311
  for (const e of entries) {
77157
77312
  const name2 = typeof e.name === "string" ? e.name : String(e.name);
77158
- const p = join14(dir, name2);
77313
+ const p = join17(dir, name2);
77159
77314
  if (e.isDirectory()) {
77160
77315
  walkJsonlFiles(p, out2);
77161
77316
  } else if (e.isFile() && name2.endsWith(".jsonl")) {
@@ -77433,7 +77588,7 @@ var init_pi_sessions = __esm({
77433
77588
 
77434
77589
  // src/acp/harness/pi/upstream/dist/acp/pi-settings.js
77435
77590
  import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:fs";
77436
- import { join as join15, resolve as resolve10 } from "node:path";
77591
+ import { join as join18, resolve as resolve11 } from "node:path";
77437
77592
  function isObject2(x) {
77438
77593
  return Boolean(x) && typeof x === "object" && !Array.isArray(x);
77439
77594
  }
@@ -77462,15 +77617,15 @@ function readJsonFile(path8) {
77462
77617
  }
77463
77618
  }
77464
77619
  function getMergedSettings(cwd, environment) {
77465
- const globalSettingsPath = join15(getAgentDir(environment), "settings.json");
77466
- const projectSettingsPath = resolve10(cwd, ".pi", "settings.json");
77620
+ const globalSettingsPath = join18(getAgentDir(environment), "settings.json");
77621
+ const projectSettingsPath = resolve11(cwd, ".pi", "settings.json");
77467
77622
  const global2 = readJsonFile(globalSettingsPath);
77468
77623
  const project = readJsonFile(projectSettingsPath);
77469
77624
  return deepMerge(global2, project);
77470
77625
  }
77471
77626
  function getAgentDir(environment = process.env) {
77472
77627
  const configured = environment["PI_CODING_AGENT_DIR"];
77473
- return configured ? resolve10(configured) : join15(environmentHome(environment), ".pi", "agent");
77628
+ return configured ? resolve11(configured) : join18(environmentHome(environment), ".pi", "agent");
77474
77629
  }
77475
77630
  function getEnableSkillCommands(cwd, environment = process.env) {
77476
77631
  const merged = getMergedSettings(cwd, environment);
@@ -77681,9 +77836,9 @@ var init_extension_questions = __esm({
77681
77836
 
77682
77837
  // src/acp/harness/pi/upstream/dist/acp/session-store.js
77683
77838
  import { mkdirSync as mkdirSync2, readFileSync as readFileSync5, writeFileSync } from "node:fs";
77684
- import { dirname as dirname6 } from "node:path";
77839
+ import { dirname as dirname8 } from "node:path";
77685
77840
  function ensureParentDir(path8) {
77686
- mkdirSync2(dirname6(path8), { recursive: true });
77841
+ mkdirSync2(dirname8(path8), { recursive: true });
77687
77842
  }
77688
77843
  function loadFile(path8) {
77689
77844
  try {
@@ -77740,7 +77895,7 @@ var init_session_store = __esm({
77740
77895
 
77741
77896
  // src/acp/harness/pi/upstream/dist/acp/slash-commands.js
77742
77897
  import { existsSync as existsSync6, readdirSync as readdirSync5, readFileSync as readFileSync6 } from "node:fs";
77743
- import { join as join16, resolve as resolve11 } from "node:path";
77898
+ import { join as join19, resolve as resolve12 } from "node:path";
77744
77899
  function parseFrontmatter(content) {
77745
77900
  const frontmatter = {};
77746
77901
  if (!content.startsWith("---")) {
@@ -77768,7 +77923,7 @@ function loadCommandsFromDir(dir, source, subdir = "") {
77768
77923
  try {
77769
77924
  const entries = readdirSync5(dir, { withFileTypes: true });
77770
77925
  for (const entry of entries) {
77771
- const fullPath = join16(dir, entry.name);
77926
+ const fullPath = join19(dir, entry.name);
77772
77927
  if (entry.isDirectory()) {
77773
77928
  const newSubdir = subdir ? `${subdir}:${entry.name}` : entry.name;
77774
77929
  commands.push(...loadCommandsFromDir(fullPath, source, newSubdir));
@@ -77808,8 +77963,8 @@ function loadCommandsFromDir(dir, source, subdir = "") {
77808
77963
  }
77809
77964
  function loadSlashCommands(cwd, environment = process.env) {
77810
77965
  const commands = [];
77811
- const userDir = join16(environmentHome(environment), ".pi", "agent", "prompts");
77812
- const projectDir = resolve11(cwd, ".pi", "prompts");
77966
+ const userDir = join19(environmentHome(environment), ".pi", "agent", "prompts");
77967
+ const projectDir = resolve12(cwd, ".pi", "prompts");
77813
77968
  commands.push(...loadCommandsFromDir(userDir, "user"));
77814
77969
  commands.push(...loadCommandsFromDir(projectDir, "project"));
77815
77970
  return commands;
@@ -77969,7 +78124,7 @@ var init_pi_tools = __esm({
77969
78124
  });
77970
78125
 
77971
78126
  // src/acp/harness/pi/upstream/dist/acp/session.js
77972
- import { randomUUID as randomUUID6 } from "node:crypto";
78127
+ import { randomUUID as randomUUID7 } from "node:crypto";
77973
78128
  import { readFileSync as readFileSync7 } from "node:fs";
77974
78129
  import { isAbsolute as isAbsolute11, resolve as resolvePath } from "node:path";
77975
78130
  import { RequestError as RequestError6 } from "@agentclientprotocol/sdk";
@@ -78248,13 +78403,13 @@ var init_session = __esm({
78248
78403
  return settled;
78249
78404
  }
78250
78405
  if (this.activeCompactionId === null) {
78251
- this.activeCompactionId = randomUUID6();
78406
+ this.activeCompactionId = randomUUID7();
78252
78407
  }
78253
78408
  return this.activeCompactionId;
78254
78409
  }
78255
78410
  /** Opening half of compactionId: always returns an id. */
78256
78411
  openCompactionId() {
78257
- return this.compactionId(true) ?? randomUUID6();
78412
+ return this.compactionId(true) ?? randomUUID7();
78258
78413
  }
78259
78414
  constructor(opts) {
78260
78415
  this.sessionId = opts.sessionId;
@@ -78895,9 +79050,9 @@ var init_prompt = __esm({
78895
79050
 
78896
79051
  // src/acp/harness/pi/upstream/dist/acp/agent.js
78897
79052
  import { spawnSync } from "node:child_process";
78898
- import { randomUUID as randomUUID7 } from "node:crypto";
79053
+ import { randomUUID as randomUUID8 } from "node:crypto";
78899
79054
  import { existsSync as existsSync7, readdirSync as readdirSync6, readFileSync as readFileSync8, realpathSync as realpathSync3, statSync as statSync3, unlinkSync as unlinkSync2 } from "node:fs";
78900
- import { basename as basename5, dirname as dirname7, isAbsolute as isAbsolute12, join as join17 } from "node:path";
79055
+ import { basename as basename6, dirname as dirname9, isAbsolute as isAbsolute12, join as join20 } from "node:path";
78901
79056
  import { RequestError as RequestError7 } from "@agentclientprotocol/sdk";
78902
79057
  function thinkingLevelName(id) {
78903
79058
  return id.split(/[_-]/u).map((part) => part.length === 0 ? part : `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
@@ -79172,7 +79327,7 @@ function buildStartupInfo(opts) {
79172
79327
  md.push("");
79173
79328
  };
79174
79329
  const contextItems = [];
79175
- const contextPath = join17(opts.cwd, "AGENTS.md");
79330
+ const contextPath = join20(opts.cwd, "AGENTS.md");
79176
79331
  if (existsSync7(contextPath)) {
79177
79332
  contextItems.push(contextPath);
79178
79333
  }
@@ -79181,7 +79336,7 @@ function buildStartupInfo(opts) {
79181
79336
  const pushSkillFromRoot = (root) => {
79182
79337
  try {
79183
79338
  for (const e of readdirSync6(root)) {
79184
- const p = join17(root, e);
79339
+ const p = join20(root, e);
79185
79340
  try {
79186
79341
  const st2 = statSync3(p);
79187
79342
  if (st2.isFile() && e.toLowerCase().endsWith(".md")) {
@@ -79206,7 +79361,7 @@ function buildStartupInfo(opts) {
79206
79361
  if (name2 === "node_modules" || name2 === ".git") {
79207
79362
  continue;
79208
79363
  }
79209
- const p = join17(dir, name2);
79364
+ const p = join20(dir, name2);
79210
79365
  let st2;
79211
79366
  try {
79212
79367
  st2 = statSync3(p);
@@ -79223,36 +79378,36 @@ function buildStartupInfo(opts) {
79223
79378
  } catch {
79224
79379
  }
79225
79380
  };
79226
- const globalSkillsDir = join17(getAgentDir(opts.environment), "skills");
79381
+ const globalSkillsDir = join20(getAgentDir(opts.environment), "skills");
79227
79382
  pushSkillFromRoot(globalSkillsDir);
79228
79383
  const home = opts.environment["HOME"] ?? opts.environment["USERPROFILE"] ?? "";
79229
- const legacyAgentsSkillsDir = join17(home, ".agents", "skills");
79384
+ const legacyAgentsSkillsDir = join20(home, ".agents", "skills");
79230
79385
  pushSkillFromRoot(legacyAgentsSkillsDir);
79231
- const projectSkillsDir = join17(opts.cwd, ".pi", "skills");
79386
+ const projectSkillsDir = join20(opts.cwd, ".pi", "skills");
79232
79387
  pushSkillFromRoot(projectSkillsDir);
79233
79388
  addSection("Skills", skillsItems);
79234
79389
  const promptsItems = [];
79235
- const promptsDir = join17(home, ".pi", "agent", "prompts");
79390
+ const promptsDir = join20(home, ".pi", "agent", "prompts");
79236
79391
  try {
79237
79392
  const prompts = readdirSync6(promptsDir).filter((f) => f.endsWith(".md"));
79238
79393
  for (const f of prompts) {
79239
- promptsItems.push(`/${basename5(f, ".md")}`);
79394
+ promptsItems.push(`/${basename6(f, ".md")}`);
79240
79395
  }
79241
79396
  } catch {
79242
79397
  }
79243
79398
  addSection("Prompts", promptsItems);
79244
79399
  const extItems = [];
79245
- const extDir = join17(home, ".pi", "agent", "extensions");
79400
+ const extDir = join20(home, ".pi", "agent", "extensions");
79246
79401
  try {
79247
79402
  const exts = readdirSync6(extDir).filter((f) => f.endsWith(".ts") || f.endsWith(".js"));
79248
79403
  for (const f of exts) {
79249
- extItems.push(join17(extDir, f));
79404
+ extItems.push(join20(extDir, f));
79250
79405
  }
79251
79406
  } catch {
79252
79407
  }
79253
79408
  const settingsPaths = [
79254
- join17(getAgentDir(opts.environment), "settings.json"),
79255
- join17(opts.cwd, ".pi", "settings.json")
79409
+ join20(getAgentDir(opts.environment), "settings.json"),
79410
+ join20(opts.cwd, ".pi", "settings.json")
79256
79411
  ];
79257
79412
  for (const settingsPath of settingsPaths) {
79258
79413
  try {
@@ -79589,7 +79744,7 @@ var init_agent2 = __esm({
79589
79744
  const args = parseCommandArgs(argsString);
79590
79745
  if (cmd === "compact") {
79591
79746
  const customInstructions = args.join(" ").trim() || void 0;
79592
- const compactionId = randomUUID7();
79747
+ const compactionId = randomUUID8();
79593
79748
  await this.conn.sessionUpdate({
79594
79749
  sessionId: session.sessionId,
79595
79750
  update: {
@@ -79814,8 +79969,8 @@ ${JSON.stringify(stats, null, 2)}`;
79814
79969
  const piPath = String(which.stdout ?? "").split(/\r?\n/)[0]?.trim();
79815
79970
  if (piPath) {
79816
79971
  const resolved = realpathSync3(piPath);
79817
- const pkgRoot = dirname7(dirname7(resolved));
79818
- const p = join17(pkgRoot, "CHANGELOG.md");
79972
+ const pkgRoot = dirname9(dirname9(resolved));
79973
+ const p = join20(pkgRoot, "CHANGELOG.md");
79819
79974
  if (existsSync7(p)) {
79820
79975
  return p;
79821
79976
  }
@@ -79826,7 +79981,7 @@ ${JSON.stringify(stats, null, 2)}`;
79826
79981
  const npmRoot = spawnSync("npm", ["root", "-g"], { encoding: "utf-8" });
79827
79982
  const root = String(npmRoot.stdout ?? "").trim();
79828
79983
  if (root) {
79829
- const p = join17(root, "@earendil-works", "pi-coding-agent", "CHANGELOG.md");
79984
+ const p = join20(root, "@earendil-works", "pi-coding-agent", "CHANGELOG.md");
79830
79985
  if (existsSync7(p)) {
79831
79986
  return p;
79832
79987
  }
@@ -79920,7 +80075,7 @@ ${JSON.stringify(stats, null, 2)}`;
79920
80075
  return { stopReason: "end_turn" };
79921
80076
  }
79922
80077
  const safeSessionId = session.sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
79923
- const outputPath = join17(session.cwd, `pi-session-${safeSessionId}.html`);
80078
+ const outputPath = join20(session.cwd, `pi-session-${safeSessionId}.html`);
79924
80079
  let resultPath = "";
79925
80080
  try {
79926
80081
  const result2 = await session.proc.exportHtml(outputPath);
@@ -80525,22 +80680,6 @@ var init_endpoint2 = __esm({
80525
80680
  }
80526
80681
  });
80527
80682
 
80528
- // src/storage/state-directory.ts
80529
- import { homedir as homedir3 } from "node:os";
80530
- import { join as join18, resolve as resolve12 } from "node:path";
80531
- function readStateDirectory(environment = process.env) {
80532
- const configured = environment["MOBIUS_STATE_DIRECTORY"]?.trim();
80533
- if (configured !== void 0 && configured.length > 0) {
80534
- return resolve12(configured);
80535
- }
80536
- return join18(homedir3(), ".mobius");
80537
- }
80538
- var init_state_directory = __esm({
80539
- "src/storage/state-directory.ts"() {
80540
- "use strict";
80541
- }
80542
- });
80543
-
80544
80683
  // src/agent/discovery/agent-probe-error.ts
80545
80684
  var AgentProbeError;
80546
80685
  var init_agent_probe_error = __esm({
@@ -80558,8 +80697,8 @@ var init_agent_probe_error = __esm({
80558
80697
  });
80559
80698
 
80560
80699
  // src/agent/specification/vendors/pi-agent.ts
80561
- import { createHash as createHash2 } from "node:crypto";
80562
- import { join as join19 } from "node:path";
80700
+ import { createHash as createHash3 } from "node:crypto";
80701
+ import { join as join21 } from "node:path";
80563
80702
  import {
80564
80703
  methods as methods6
80565
80704
  } from "@agentclientprotocol/sdk";
@@ -80579,8 +80718,8 @@ var init_pi_agent = __esm({
80579
80718
  // The Pi ACP fork inlines embedded prompt resources into the turn message, so Mobius
80580
80719
  // keeps the adapter's opt-in capability flag enabled for every launch it owns.
80581
80720
  createLaunchEnvironment = async (_agent, context) => {
80582
- const workspaceHash = createHash2("sha256").update(context.defaultWorkspace).digest("hex").slice(0, 24);
80583
- const sessionDirectory = join19(
80721
+ const workspaceHash = createHash3("sha256").update(context.defaultWorkspace).digest("hex").slice(0, 24);
80722
+ const sessionDirectory = join21(
80584
80723
  readStateDirectory(context.environment),
80585
80724
  "agents",
80586
80725
  "pi",
@@ -80786,7 +80925,7 @@ var init_agent_discovery = __esm({
80786
80925
 
80787
80926
  // src/util/process/local-executable.ts
80788
80927
  import { realpathSync as realpathSync4, statSync as statSync4 } from "node:fs";
80789
- import { realpath as realpath7, stat as stat6 } from "node:fs/promises";
80928
+ import { realpath as realpath7, stat as stat7 } from "node:fs/promises";
80790
80929
  function readExecutableIdentity(path8) {
80791
80930
  const resolvedPath = realpathSync4(path8);
80792
80931
  const metadata = statSync4(resolvedPath);
@@ -80802,7 +80941,7 @@ function readExecutableIdentity(path8) {
80802
80941
  async function resolveLaunchFiles(entry, executable) {
80803
80942
  const resolvedEntry = await realpath7(entry);
80804
80943
  const resolvedExecutable = await realpath7(executable);
80805
- if (!(await stat6(resolvedEntry)).isFile() || !(await stat6(resolvedExecutable)).isFile()) {
80944
+ if (!(await stat7(resolvedEntry)).isFile() || !(await stat7(resolvedExecutable)).isFile()) {
80806
80945
  return null;
80807
80946
  }
80808
80947
  return { entry: resolvedEntry, executable: resolvedExecutable };
@@ -83012,7 +83151,7 @@ var init_session_event_id_allocator = __esm({
83012
83151
  });
83013
83152
 
83014
83153
  // src/session/history/session-event-store.ts
83015
- import { randomUUID as randomUUID8 } from "node:crypto";
83154
+ import { randomUUID as randomUUID9 } from "node:crypto";
83016
83155
  function liveEvent(sessionId, sessionGenerationId, eventId, position, event, recordedAt = (/* @__PURE__ */ new Date()).toISOString()) {
83017
83156
  return {
83018
83157
  eventId,
@@ -83169,7 +83308,7 @@ var init_session_event_store = __esm({
83169
83308
  this.#eventIds = eventIds;
83170
83309
  }
83171
83310
  #session = (sessionId) => {
83172
- const sessionGenerationId = randomUUID8();
83311
+ const sessionGenerationId = randomUUID9();
83173
83312
  const session = this.#events.get(sessionId) ?? new SessionEvents(sessionGenerationId);
83174
83313
  this.#events.set(sessionId, session);
83175
83314
  return session;
@@ -83234,7 +83373,7 @@ var init_session_event_store = __esm({
83234
83373
  this.#events.delete(sessionId);
83235
83374
  };
83236
83375
  reset = (sessionId) => {
83237
- const sessionGenerationId = randomUUID8();
83376
+ const sessionGenerationId = randomUUID9();
83238
83377
  this.#events.set(sessionId, new SessionEvents(sessionGenerationId));
83239
83378
  };
83240
83379
  };
@@ -83250,7 +83389,7 @@ var init_session_event_store = __esm({
83250
83389
  this.#cacheTable = cacheTable;
83251
83390
  }
83252
83391
  #session = (sessionId) => {
83253
- const sessionGenerationId = randomUUID8();
83392
+ const sessionGenerationId = randomUUID9();
83254
83393
  const session = this.#sessions.get(sessionId) ?? new SessionEvents(sessionGenerationId);
83255
83394
  this.#sessions.set(sessionId, session);
83256
83395
  return session;
@@ -83376,7 +83515,7 @@ var init_session_event_store = __esm({
83376
83515
  reset = (sessionId) => {
83377
83516
  const previous = this.#sessions.get(sessionId);
83378
83517
  this.#deletePersisted(sessionId, previous?.sessionGenerationId);
83379
- const sessionGenerationId = randomUUID8();
83518
+ const sessionGenerationId = randomUUID9();
83380
83519
  this.#sessions.set(sessionId, new SessionEvents(sessionGenerationId));
83381
83520
  };
83382
83521
  materializedEventCount = (sessionId) => this.#sessions.get(sessionId)?.materializedCount ?? 0;
@@ -84557,7 +84696,7 @@ var init_sql = __esm({
84557
84696
  return new SQL([new StringChunk(str)]);
84558
84697
  }
84559
84698
  _sql.raw = raw;
84560
- function join38(chunks, separator) {
84699
+ function join39(chunks, separator) {
84561
84700
  const result = [];
84562
84701
  for (const [i, chunk] of chunks.entries()) {
84563
84702
  if (i > 0 && separator !== void 0) result.push(separator);
@@ -84565,7 +84704,7 @@ var init_sql = __esm({
84565
84704
  }
84566
84705
  return new SQL(result);
84567
84706
  }
84568
- _sql.join = join38;
84707
+ _sql.join = join39;
84569
84708
  function identifier2(value) {
84570
84709
  return new Name(value);
84571
84710
  }
@@ -86523,7 +86662,7 @@ var init_select = __esm({
86523
86662
  const baseTableName = this.tableName;
86524
86663
  const tableName = getTableLikeName(table);
86525
86664
  for (const item of extractUsedTable(table)) this.usedTables.add(item);
86526
- if (typeof tableName === "string" && this.config.joins?.some((join38) => join38.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
86665
+ if (typeof tableName === "string" && this.config.joins?.some((join39) => join39.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
86527
86666
  if (!this.isPartialSelect) {
86528
86667
  if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
86529
86668
  if (typeof tableName === "string" && !is(table, SQL)) {
@@ -87063,7 +87202,7 @@ function isNull(value) {
87063
87202
  function isNotNull(value) {
87064
87203
  return sql`(${value} is not null)`;
87065
87204
  }
87066
- function exists(subquery) {
87205
+ function exists2(subquery) {
87067
87206
  return sql`exists ${subquery}`;
87068
87207
  }
87069
87208
  function notExists(subquery) {
@@ -87498,7 +87637,7 @@ function relationsFilterToSQL(table, filter, tableRelations = {}, tablesRelation
87498
87637
  const { filter: relationFilter, joinCondition } = relationToSQL(relation, table, targetTable, throughTable);
87499
87638
  const filter2 = and(relationFilter, typeof value === "boolean" ? void 0 : relationsFilterToSQL(targetTable, value, targetConfig.relations, tablesRelations, depth + 1));
87500
87639
  const subquery = throughTable ? sql`(select * from ${getTableAsAliasSQL(targetTable)} inner join ${getTableAsAliasSQL(throughTable)} on ${joinCondition}${sql` where ${filter2}`.if(filter2)} limit 1)` : sql`(select * from ${getTableAsAliasSQL(targetTable)}${sql` where ${filter2}`.if(filter2)} limit 1)`;
87501
- if (filter2) parts.push((value ? exists : notExists)(subquery));
87640
+ if (filter2) parts.push((value ? exists2 : notExists)(subquery));
87502
87641
  }
87503
87642
  }
87504
87643
  }
@@ -87666,7 +87805,7 @@ var init_relations = __esm({
87666
87805
  and,
87667
87806
  between,
87668
87807
  eq: eq2,
87669
- exists,
87808
+ exists: exists2,
87670
87809
  gt: gt2,
87671
87810
  gte: gte2,
87672
87811
  ilike,
@@ -88120,7 +88259,7 @@ var init_dialect = __esm({
88120
88259
  if (!joins2) return;
88121
88260
  const withEntries = Object.entries(joins2).filter(([_, v]) => v);
88122
88261
  if (!withEntries.length) return;
88123
- return sql.join(withEntries.map(([k2, join38]) => {
88262
+ return sql.join(withEntries.map(([k2, join39]) => {
88124
88263
  const relation = tableConfig.relations[k2];
88125
88264
  const isSingle2 = is(relation, One2);
88126
88265
  const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
@@ -88131,7 +88270,7 @@ var init_dialect = __esm({
88131
88270
  table: targetTable,
88132
88271
  mode: isSingle2 ? "first" : "many",
88133
88272
  schema,
88134
- queryConfig: join38,
88273
+ queryConfig: join39,
88135
88274
  tableConfig: schema[relation.targetTableName],
88136
88275
  relationWhere: filter,
88137
88276
  isNested: true,
@@ -88145,7 +88284,7 @@ var init_dialect = __esm({
88145
88284
  key: k2,
88146
88285
  selection: innerQuery.selection,
88147
88286
  isArray: !isSingle2,
88148
- isOptional: (relation.optional ?? false) || join38 !== true && !!join38.where
88287
+ isOptional: (relation.optional ?? false) || join39 !== true && !!join39.where
88149
88288
  });
88150
88289
  const jsonColumns = sql.join(innerQuery.selection.map((s) => {
88151
88290
  return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
@@ -88567,7 +88706,7 @@ var init_update = __esm({
88567
88706
  createJoin(joinType) {
88568
88707
  return ((table, on2) => {
88569
88708
  const tableName = getTableLikeName(table);
88570
- if (typeof tableName === "string" && this.config.joins.some((join38) => join38.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
88709
+ if (typeof tableName === "string" && this.config.joins.some((join39) => join39.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
88571
88710
  if (typeof on2 === "function") {
88572
88711
  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;
88573
88712
  on2 = on2(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
@@ -89386,7 +89525,7 @@ var init_node_sqlite = __esm({
89386
89525
 
89387
89526
  // src/storage/sqlite/local-sqlite-database.ts
89388
89527
  import { chmodSync, mkdirSync as mkdirSync3 } from "node:fs";
89389
- import { dirname as dirname8 } from "node:path";
89528
+ import { dirname as dirname10 } from "node:path";
89390
89529
  import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
89391
89530
  var LocalSqliteDatabase;
89392
89531
  var init_local_sqlite_database = __esm({
@@ -89398,7 +89537,7 @@ var init_local_sqlite_database = __esm({
89398
89537
  orm;
89399
89538
  #sqlite;
89400
89539
  constructor(path8, label, migrations, pragmas = []) {
89401
- mkdirSync3(dirname8(path8), { mode: 448, recursive: true });
89540
+ mkdirSync3(dirname10(path8), { mode: 448, recursive: true });
89402
89541
  this.#sqlite = new DatabaseSync2(path8);
89403
89542
  chmodSync(path8, 384);
89404
89543
  try {
@@ -89452,13 +89591,13 @@ var init_local_sqlite_database = __esm({
89452
89591
  });
89453
89592
 
89454
89593
  // src/storage/sqlite/local-databases.ts
89455
- import { createHash as createHash3 } from "node:crypto";
89456
- import { join as join20 } from "node:path";
89594
+ import { createHash as createHash4 } from "node:crypto";
89595
+ import { join as join22 } from "node:path";
89457
89596
  function channelSessionDatabasePaths(stateDirectory, channelId) {
89458
- const channelHash = createHash3("sha256").update(channelId).digest("hex");
89597
+ const channelHash = createHash4("sha256").update(channelId).digest("hex");
89459
89598
  return {
89460
- events: join20(stateDirectory, "sessions", `${channelHash}.events.sqlite`),
89461
- sessions: join20(stateDirectory, "sessions", `${channelHash}.sqlite`)
89599
+ events: join22(stateDirectory, "sessions", `${channelHash}.events.sqlite`),
89600
+ sessions: join22(stateDirectory, "sessions", `${channelHash}.sqlite`)
89462
89601
  };
89463
89602
  }
89464
89603
  var openAcpSessionDatabase, openSessionEventCacheDatabase;
@@ -89691,13 +89830,13 @@ var init_session_event_cache_table = __esm({
89691
89830
  // src/storage/session/temporary-session-event-cache.ts
89692
89831
  import { mkdtempSync, rmSync as rmSync2 } from "node:fs";
89693
89832
  import { tmpdir as tmpdir2 } from "node:os";
89694
- import { join as join21 } from "node:path";
89833
+ import { join as join23 } from "node:path";
89695
89834
  function openTemporarySessionEventCache() {
89696
- const directory = mkdtempSync(join21(tmpdir2(), "mobius-preview-events-"));
89835
+ const directory = mkdtempSync(join23(tmpdir2(), "mobius-preview-events-"));
89697
89836
  const removeFiles = () => rmSync2(directory, { recursive: true, force: true });
89698
89837
  try {
89699
89838
  return {
89700
- table: new SessionEventCacheTable(openSessionEventCacheDatabase(join21(directory, "events.sqlite"))),
89839
+ table: new SessionEventCacheTable(openSessionEventCacheDatabase(join23(directory, "events.sqlite"))),
89701
89840
  removeFiles
89702
89841
  };
89703
89842
  } catch (error62) {
@@ -89822,7 +89961,7 @@ var init_tool_event = __esm({
89822
89961
  });
89823
89962
 
89824
89963
  // src/acp/adapter/codex/adapter.ts
89825
- import { createHash as createHash4 } from "node:crypto";
89964
+ import { createHash as createHash5 } from "node:crypto";
89826
89965
  var CodexAdapter;
89827
89966
  var init_adapter2 = __esm({
89828
89967
  "src/acp/adapter/codex/adapter.ts"() {
@@ -89943,7 +90082,7 @@ var init_adapter2 = __esm({
89943
90082
  },
89944
90083
  async (runtime) => await runtime.closeProcess()
89945
90084
  );
89946
- const generationId = createHash4("sha256").update(request.nativeSessionId).update("\0").update(JSON.stringify(events)).digest("hex");
90085
+ const generationId = createHash5("sha256").update(request.nativeSessionId).update("\0").update(JSON.stringify(events)).digest("hex");
89947
90086
  this.#previewCache.events.materialize(sessionId, generationId, events);
89948
90087
  return this.#previewCache.events.page(sessionId, request.eventLimit, request.cursor);
89949
90088
  };
@@ -90546,10 +90685,10 @@ var init_catalog2 = __esm({
90546
90685
  });
90547
90686
 
90548
90687
  // src/runtime/config.ts
90549
- import { join as join22, resolve as resolve14 } from "node:path";
90688
+ import { join as join24, resolve as resolve14 } from "node:path";
90550
90689
  function loadDefaultWorkspace(environment = process.env) {
90551
90690
  const { MOBIUS_DEFAULT_WORKSPACE: configuredWorkspace } = environment;
90552
- return configuredWorkspace ?? join22(readStateDirectory(environment), "workspace");
90691
+ return configuredWorkspace ?? join24(readStateDirectory(environment), "workspace");
90553
90692
  }
90554
90693
  function withRuntimeEnvironment(agent, environment) {
90555
90694
  const launchEnvironment = {};
@@ -90665,88 +90804,6 @@ var init_resolve_catalog_agent = __esm({
90665
90804
  }
90666
90805
  });
90667
90806
 
90668
- // src/util/node-error.ts
90669
- function isNodeError(error62, code) {
90670
- return typeof error62 === "object" && error62 !== null && "code" in error62 && error62.code === code;
90671
- }
90672
- var init_node_error = __esm({
90673
- "src/util/node-error.ts"() {
90674
- "use strict";
90675
- }
90676
- });
90677
-
90678
- // src/storage/installation/installation-files.ts
90679
- import { createHash as createHash5, randomUUID as randomUUID9 } from "node:crypto";
90680
- import { mkdir as mkdir4, open as open5, readdir as readdir5, rename as rename3, unlink as unlink3, writeFile } from "node:fs/promises";
90681
- import { dirname as dirname9, join as join23 } from "node:path";
90682
- function applicationDirectory(root, applicationId) {
90683
- return join23(root, "installations", applicationId);
90684
- }
90685
- function installationPointerPath(applicationDirectory2) {
90686
- return join23(applicationDirectory2, "current.json");
90687
- }
90688
- function installationDirectory(applicationDirectory2, installationId2) {
90689
- return join23(applicationDirectory2, installationId2);
90690
- }
90691
- function connectionDirectory(installationDirectory2) {
90692
- return join23(installationDirectory2, "connections");
90693
- }
90694
- function connectionFilePath(connectionDirectory2, connectionId2) {
90695
- return join23(connectionDirectory2, `${connectionId2}.json`);
90696
- }
90697
- function channelIndexFilePath(installationDirectory2, channelId) {
90698
- return join23(installationDirectory2, "channels", `mci_${createHash5("sha256").update(channelId).digest("hex")}.json`);
90699
- }
90700
- async function readInstallationFile(path8) {
90701
- let handle;
90702
- try {
90703
- handle = await open5(path8, "r");
90704
- } catch (cause) {
90705
- return isNodeError(cause, "ENOENT") ? { kind: "missing", cause } : { kind: "unopenable", cause };
90706
- }
90707
- try {
90708
- const metadata = await handle.stat();
90709
- if (!metadata.isFile() || metadata.size > MAXIMUM_FILE_BYTES) {
90710
- return { kind: "not-a-small-file" };
90711
- }
90712
- return { kind: "read", text: await handle.readFile({ encoding: "utf8" }) };
90713
- } finally {
90714
- await handle.close();
90715
- }
90716
- }
90717
- async function writeInstallationFile(path8, text2, signal) {
90718
- signal.throwIfAborted();
90719
- const directory = dirname9(path8);
90720
- const temporaryPath = join23(directory, `.${randomUUID9()}.tmp`);
90721
- try {
90722
- await mkdir4(directory, { mode: 448, recursive: true });
90723
- signal.throwIfAborted();
90724
- await writeFile(temporaryPath, text2, { flag: "wx", mode: 384 });
90725
- signal.throwIfAborted();
90726
- await rename3(temporaryPath, path8);
90727
- } catch (cause) {
90728
- await unlink3(temporaryPath).catch(() => void 0);
90729
- throw cause;
90730
- }
90731
- }
90732
- async function createInstallationFile(path8, text2) {
90733
- await writeFile(path8, text2, { flag: "wx", mode: 384 });
90734
- }
90735
- async function listInstallationFiles(directory) {
90736
- return await readdir5(directory);
90737
- }
90738
- async function removeInstallationFile(path8) {
90739
- await unlink3(path8);
90740
- }
90741
- var MAXIMUM_FILE_BYTES;
90742
- var init_installation_files = __esm({
90743
- "src/storage/installation/installation-files.ts"() {
90744
- "use strict";
90745
- init_node_error();
90746
- MAXIMUM_FILE_BYTES = 16 * 1024;
90747
- }
90748
- });
90749
-
90750
90807
  // src/util/filesystem/private-path.ts
90751
90808
  import { lstat as lstat3 } from "node:fs/promises";
90752
90809
  async function validateLocalPath(path8, directory, privateAccess, signal) {
@@ -91264,13 +91321,13 @@ var init_runtime_installation_store = __esm({
91264
91321
 
91265
91322
  // src/storage/daemon/version-data.ts
91266
91323
  import { randomUUID as randomUUID11 } from "node:crypto";
91267
- import { cp as cp2, lstat as lstat4, mkdtemp, readFile as readFile6, rename as rename4, rm as rm3, writeFile as writeFile2 } from "node:fs/promises";
91268
- import { join as join24 } from "node:path";
91324
+ import { cp as cp2, lstat as lstat4, mkdtemp, readFile as readFile7, rename as rename4, rm as rm3, writeFile as writeFile2 } from "node:fs/promises";
91325
+ import { join as join25 } from "node:path";
91269
91326
  async function readCurrentDataVersion(root, signal) {
91270
- const pointer = join24(root, "current-data.txt");
91327
+ const pointer = join25(root, "current-data.txt");
91271
91328
  try {
91272
91329
  await validateLocalPath(pointer, false, true, signal);
91273
- const value = (await readFile6(pointer, { encoding: "utf8", signal })).trim();
91330
+ const value = (await readFile7(pointer, { encoding: "utf8", signal })).trim();
91274
91331
  if (!value.startsWith("versions/")) {
91275
91332
  throw new DataInheritanceError("The current data pointer must name a version directory");
91276
91333
  }
@@ -91284,7 +91341,7 @@ async function readCurrentDataVersion(root, signal) {
91284
91341
  }
91285
91342
  async function versionDataExists(root, version2, signal) {
91286
91343
  try {
91287
- await validateLocalPath(join24(root, "versions", version2), true, true, signal);
91344
+ await validateLocalPath(join25(root, "versions", version2), true, true, signal);
91288
91345
  return true;
91289
91346
  } catch (cause) {
91290
91347
  if (!isNodeError(cause, "ENOENT")) {
@@ -91294,13 +91351,13 @@ async function versionDataExists(root, version2, signal) {
91294
91351
  }
91295
91352
  }
91296
91353
  async function copyVersionData(root, sourceVersion, targetVersion, signal) {
91297
- const versions = join24(root, "versions");
91298
- const source = join24(versions, sourceVersion);
91299
- const target = join24(versions, targetVersion);
91354
+ const versions = join25(root, "versions");
91355
+ const source = join25(versions, sourceVersion);
91356
+ const target = join25(versions, targetVersion);
91300
91357
  await validateLocalPath(root, true, true, signal);
91301
91358
  await validateLocalPath(versions, true, true, signal);
91302
91359
  await validateLocalPath(source, true, true, signal);
91303
- const staging = await mkdtemp(join24(versions, `.${targetVersion}-`));
91360
+ const staging = await mkdtemp(join25(versions, `.${targetVersion}-`));
91304
91361
  try {
91305
91362
  await cp2(source, staging, {
91306
91363
  recursive: true,
@@ -91327,13 +91384,13 @@ async function copyVersionData(root, sourceVersion, targetVersion, signal) {
91327
91384
  }
91328
91385
  async function writeCurrentDataVersion(root, version2, signal) {
91329
91386
  await validateLocalPath(root, true, true, signal);
91330
- await validateLocalPath(join24(root, "versions", version2), true, true, signal);
91331
- const temporary = join24(root, `.current-data-${randomUUID11()}.txt`);
91387
+ await validateLocalPath(join25(root, "versions", version2), true, true, signal);
91388
+ const temporary = join25(root, `.current-data-${randomUUID11()}.txt`);
91332
91389
  try {
91333
91390
  await writeFile2(temporary, `versions/${version2}
91334
91391
  `, { mode: 384, flag: "wx", signal });
91335
91392
  signal.throwIfAborted();
91336
- await rename4(temporary, join24(root, "current-data.txt"));
91393
+ await rename4(temporary, join25(root, "current-data.txt"));
91337
91394
  } finally {
91338
91395
  await rm3(temporary, { force: true });
91339
91396
  }
@@ -91353,15 +91410,15 @@ var init_version_data = __esm({
91353
91410
 
91354
91411
  // src/storage/daemon/control-token.ts
91355
91412
  import { randomBytes } from "node:crypto";
91356
- import { readFile as readFile7, writeFile as writeFile3 } from "node:fs/promises";
91357
- import { join as join25 } from "node:path";
91413
+ import { readFile as readFile8, writeFile as writeFile3 } from "node:fs/promises";
91414
+ import { join as join26 } from "node:path";
91358
91415
  function controlTokenPath(stateDirectory) {
91359
- return join25(stateDirectory, "manager.token");
91416
+ return join26(stateDirectory, "manager.token");
91360
91417
  }
91361
91418
  async function readOrCreateControlToken(stateDirectory) {
91362
91419
  const path8 = controlTokenPath(stateDirectory);
91363
91420
  try {
91364
- return (await readFile7(path8, "utf8")).trim();
91421
+ return (await readFile8(path8, "utf8")).trim();
91365
91422
  } catch (cause) {
91366
91423
  if (!isNodeError(cause, "ENOENT")) {
91367
91424
  throw cause;
@@ -91376,7 +91433,7 @@ async function readOrCreateControlToken(stateDirectory) {
91376
91433
  if (!isNodeError(cause, "EEXIST")) {
91377
91434
  throw cause;
91378
91435
  }
91379
- return (await readFile7(path8, "utf8")).trim();
91436
+ return (await readFile8(path8, "utf8")).trim();
91380
91437
  }
91381
91438
  }
91382
91439
  var init_control_token = __esm({
@@ -91578,7 +91635,7 @@ var init_data = __esm({
91578
91635
 
91579
91636
  // src/daemon/pairing/pair-local-machine.ts
91580
91637
  import { hostname as hostname3 } from "node:os";
91581
- import { basename as basename6, join as join26, resolve as resolve16 } from "node:path";
91638
+ import { basename as basename7, join as join27, resolve as resolve16 } from "node:path";
91582
91639
  import { fetch as fetch3 } from "undici";
91583
91640
  function hasExactKeys2(value, expectedKeys) {
91584
91641
  const keys = Object.keys(value);
@@ -91729,7 +91786,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, signal) {
91729
91786
  agents,
91730
91787
  machineName: hostname3(),
91731
91788
  pairingCode: options.code,
91732
- workspaceName: basename6(defaultWorkspace) || "Local workspace"
91789
+ workspaceName: basename7(defaultWorkspace) || "Local workspace"
91733
91790
  }),
91734
91791
  dispatcher: environmentProxyDispatcher,
91735
91792
  headers: { "content-type": "application/json" },
@@ -91831,7 +91888,7 @@ async function openMobiusCliInstallation(signal, environment) {
91831
91888
  return await openRuntimeInstallationStore(
91832
91889
  {
91833
91890
  applicationId: MOBIUS_CLI_APPLICATION_ID,
91834
- stateDirectory: join26(readStateDirectory(environment), "versions", package_default.version)
91891
+ stateDirectory: join27(readStateDirectory(environment), "versions", package_default.version)
91835
91892
  },
91836
91893
  signal
91837
91894
  );
@@ -92102,10 +92159,10 @@ var init_agents = __esm({
92102
92159
  });
92103
92160
 
92104
92161
  // src/storage/daemon/manager-lock.ts
92105
- import { readFile as readFile8, unlink as unlink4, writeFile as writeFile4 } from "node:fs/promises";
92106
- import { join as join27 } from "node:path";
92162
+ import { readFile as readFile9, unlink as unlink4, writeFile as writeFile4 } from "node:fs/promises";
92163
+ import { join as join28 } from "node:path";
92107
92164
  async function acquireManagerLock(stateDirectory, name2 = "manager.lock") {
92108
- const path8 = join27(stateDirectory, name2);
92165
+ const path8 = join28(stateDirectory, name2);
92109
92166
  for (let attempt = 0; attempt < 2; attempt += 1) {
92110
92167
  try {
92111
92168
  await writeFile4(path8, `${process.pid.toString()}
@@ -92115,7 +92172,7 @@ async function acquireManagerLock(stateDirectory, name2 = "manager.lock") {
92115
92172
  if (!isNodeError(cause, "EEXIST")) {
92116
92173
  throw cause;
92117
92174
  }
92118
- const encoded = await readFile8(path8, "utf8").catch(() => "");
92175
+ const encoded = await readFile9(path8, "utf8").catch(() => "");
92119
92176
  const pid = Number(encoded.trim());
92120
92177
  if (Number.isSafeInteger(pid) && pid > 1) {
92121
92178
  try {
@@ -92134,7 +92191,7 @@ async function acquireManagerLock(stateDirectory, name2 = "manager.lock") {
92134
92191
  }
92135
92192
  async function managerLockExists(stateDirectory) {
92136
92193
  try {
92137
- await readFile8(join27(stateDirectory, "manager.lock"), "utf8");
92194
+ await readFile9(join28(stateDirectory, "manager.lock"), "utf8");
92138
92195
  return true;
92139
92196
  } catch (cause) {
92140
92197
  if (isNodeError(cause, "ENOENT")) {
@@ -92222,7 +92279,7 @@ var init_local_server = __esm({
92222
92279
 
92223
92280
  // src/storage/logs/bounded-log.ts
92224
92281
  import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync4, readFileSync as readFileSync9, renameSync as renameSync2, statSync as statSync5, writeFileSync as writeFileSync2 } from "node:fs";
92225
- import { join as join28 } from "node:path";
92282
+ import { join as join29 } from "node:path";
92226
92283
  var BoundedLineLog;
92227
92284
  var init_bounded_log = __esm({
92228
92285
  "src/storage/logs/bounded-log.ts"() {
@@ -92235,7 +92292,7 @@ var init_bounded_log = __esm({
92235
92292
  #onWriteFailure;
92236
92293
  constructor(directory, filename, maximumBytes, onWriteFailure = () => void 0) {
92237
92294
  this.#directory = directory;
92238
- this.#path = join28(directory, filename);
92295
+ this.#path = join29(directory, filename);
92239
92296
  this.#maximumBytes = maximumBytes;
92240
92297
  this.#onWriteFailure = onWriteFailure;
92241
92298
  }
@@ -92288,20 +92345,20 @@ var init_bounded_log = __esm({
92288
92345
 
92289
92346
  // src/storage/logs/log-files.ts
92290
92347
  import { readFileSync as readFileSync10 } from "node:fs";
92291
- import { lstat as lstat5, readdir as readdir6, readFile as readFile9 } from "node:fs/promises";
92292
- import { join as join29, relative as relative2 } from "node:path";
92348
+ import { lstat as lstat5, readdir as readdir6, readFile as readFile10 } from "node:fs/promises";
92349
+ import { join as join30, relative as relative2 } from "node:path";
92293
92350
  function unhandledRejectionLogFilename(role) {
92294
92351
  return `unhandled-rejections-${role}.log`;
92295
92352
  }
92296
92353
  function logDirectory(stateDirectory) {
92297
- return join29(stateDirectory, "logs");
92354
+ return join30(stateDirectory, "logs");
92298
92355
  }
92299
92356
  function processLogPaths(stateDirectory) {
92300
92357
  return [
92301
92358
  WORKER_LIFECYCLE_LOG_FILENAME,
92302
92359
  unhandledRejectionLogFilename("manager"),
92303
92360
  unhandledRejectionLogFilename("worker")
92304
- ].map((filename) => join29(logDirectory(stateDirectory), filename));
92361
+ ].map((filename) => join30(logDirectory(stateDirectory), filename));
92305
92362
  }
92306
92363
  function readLogText(path8) {
92307
92364
  try {
@@ -92314,17 +92371,17 @@ function isAbsent(cause) {
92314
92371
  return typeof cause === "object" && cause !== null && Reflect.get(cause, "code") === "ENOENT";
92315
92372
  }
92316
92373
  async function findLogDirectories(root, unreadable, signal) {
92317
- const versions = join29(root, VERSIONS_DIRECTORY);
92318
- const installationsRoots = [join29(root, INSTALLATIONS_DIRECTORY)];
92374
+ const versions = join30(root, VERSIONS_DIRECTORY);
92375
+ const installationsRoots = [join30(root, INSTALLATIONS_DIRECTORY)];
92319
92376
  for (const version2 of await listDirectories(versions, root, unreadable, signal)) {
92320
- installationsRoots.push(join29(versions, version2, INSTALLATIONS_DIRECTORY));
92377
+ installationsRoots.push(join30(versions, version2, INSTALLATIONS_DIRECTORY));
92321
92378
  }
92322
92379
  const found = [];
92323
92380
  for (const installations of installationsRoots) {
92324
92381
  for (const applicationId of await listDirectories(installations, root, unreadable, signal)) {
92325
- const application = join29(installations, applicationId);
92382
+ const application = join30(installations, applicationId);
92326
92383
  for (const installationId2 of await listDirectories(application, root, unreadable, signal)) {
92327
- const logs = join29(application, installationId2, "logs");
92384
+ const logs = join30(application, installationId2, "logs");
92328
92385
  const status = await directoryStatus(logs);
92329
92386
  if (status === "listed") {
92330
92387
  found.push(logs);
@@ -92382,7 +92439,7 @@ async function readOwnedLogFile(path8, signal) {
92382
92439
  return { kind: "skipped" };
92383
92440
  }
92384
92441
  try {
92385
- return { kind: "read", content: await readFile9(path8, { encoding: "utf8", signal }) };
92442
+ return { kind: "read", content: await readFile10(path8, { encoding: "utf8", signal }) };
92386
92443
  } catch (cause) {
92387
92444
  if (signal.aborted) {
92388
92445
  throw cause;
@@ -92934,14 +92991,14 @@ var init_manager2 = __esm({
92934
92991
  });
92935
92992
 
92936
92993
  // src/storage/daemon/release-files.ts
92937
- import { readFile as readFile10, realpath as realpath8 } from "node:fs/promises";
92938
- import { join as join30 } from "node:path";
92994
+ import { readFile as readFile11, realpath as realpath8 } from "node:fs/promises";
92995
+ import { join as join31 } from "node:path";
92939
92996
  function releasePrefix(version2) {
92940
- return join30(readStateDirectory(), "npm", version2);
92997
+ return join31(readStateDirectory(), "npm", version2);
92941
92998
  }
92942
92999
  async function readInstalledRelease(prefix) {
92943
- const packageRoot = await realpath8(join30(prefix, "node_modules", "@moxt-ai", "mobius"));
92944
- return { manifest: await readFile10(join30(packageRoot, "package.json"), "utf8"), packageRoot };
93000
+ const packageRoot = await realpath8(join31(prefix, "node_modules", "@moxt-ai", "mobius"));
93001
+ return { manifest: await readFile11(join31(packageRoot, "package.json"), "utf8"), packageRoot };
92945
93002
  }
92946
93003
  var init_release_files = __esm({
92947
93004
  "src/storage/daemon/release-files.ts"() {
@@ -92951,7 +93008,7 @@ var init_release_files = __esm({
92951
93008
  });
92952
93009
 
92953
93010
  // src/daemon/upgrades/package.ts
92954
- import { isAbsolute as isAbsolute16, join as join31, relative as relative3 } from "node:path";
93011
+ import { isAbsolute as isAbsolute16, join as join32, relative as relative3 } from "node:path";
92955
93012
  async function prepareDaemonReleaseVersion(version2, signal) {
92956
93013
  runtimeUpgradeVersionSchema.parse(version2);
92957
93014
  signal.throwIfAborted();
@@ -93032,7 +93089,7 @@ async function verifyInstalledDaemonRelease(installed, prefix, version2, signal)
93032
93089
  bin: external_exports.object({ mobius: external_exports.literal("dist/cli.js") }),
93033
93090
  engines: external_exports.object({ node: external_exports.string().refine((value) => (0, import_semver.validRange)(value) !== null) })
93034
93091
  }).parse(JSON.parse(installed.manifest));
93035
- const entry = await canonicalPath(join31(installed.packageRoot, metadata.bin.mobius));
93092
+ const entry = await canonicalPath(join32(installed.packageRoot, metadata.bin.mobius));
93036
93093
  const resolved = relative3(await canonicalPath(prefix), entry);
93037
93094
  if (resolved.startsWith("..") || isAbsolute16(resolved)) {
93038
93095
  throw new Error("Installed entry escaped npm prefix");
@@ -96151,7 +96208,12 @@ var init_session_manager = __esm({
96151
96208
  return await runtime.loadHistoryEvents(eventLimit, cursor, options2.signal);
96152
96209
  });
96153
96210
  });
96154
- openNativeSession = async (options, origin) => this.#operations.run(options, async (options2) => {
96211
+ async #nativeTargetOptions(options, sessionId, resolveAgent) {
96212
+ const resolved = await resolveAgent(options.agent.id, options.signal, sessionId);
96213
+ options.signal.throwIfAborted();
96214
+ return { ...options, ...resolved, sessionId };
96215
+ }
96216
+ openNativeSession = async (options, origin, resolveAgent) => this.#operations.run(options, async (options2) => {
96155
96217
  const key = `${options2.agent.id}:${origin.nativeSessionId}`;
96156
96218
  if (this.#nativeOperations.has(key)) {
96157
96219
  throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
@@ -96170,10 +96232,8 @@ var init_session_manager = __esm({
96170
96232
  if (origin.kind === "import" && existing !== void 0) {
96171
96233
  return await this.#executionProcesses.use(existing.sessionId, async () => {
96172
96234
  this.#closedSessions.delete(existing.sessionId);
96173
- const runtime = await this.ensureSession({
96174
- ...options2,
96175
- sessionId: existing.sessionId
96176
- });
96235
+ const target2 = await this.#nativeTargetOptions(options2, existing.sessionId, resolveAgent);
96236
+ const runtime = await this.ensureSession(target2);
96177
96237
  if (this.#executions.command(existing.sessionId) !== void 0 || this.#nativeOperations.has(key)) {
96178
96238
  throw new AcpExecutionError(
96179
96239
  "Wait for the native session's running operation to finish",
@@ -96193,6 +96253,7 @@ var init_session_manager = __esm({
96193
96253
  }
96194
96254
  });
96195
96255
  }
96256
+ const target = await this.#nativeTargetOptions(options2, options2.sessionId, resolveAgent);
96196
96257
  if (this.#executionProcesses.get(options2.sessionId) !== void 0 || this.#executionProcesses.pending(options2.sessionId) !== void 0 || this.#store.read(options2.sessionId) instanceof FoundStoredSession) {
96197
96258
  throw new AcpExecutionError(
96198
96259
  "The destination conversation already exists",
@@ -96203,7 +96264,7 @@ var init_session_manager = __esm({
96203
96264
  return await this.#executionProcesses.use(options2.sessionId, async () => {
96204
96265
  this.#nativeOperations.add(key);
96205
96266
  try {
96206
- const runtime = await this.#startPreparation({ ...options2, origin }, { kind: "interactive-only" });
96267
+ const runtime = await this.#startPreparation({ ...target, origin }, { kind: "interactive-only" });
96207
96268
  const openedKey = `${options2.agent.id}:${runtime.nativeSessionId()}`;
96208
96269
  this.#nativeOperations.add(openedKey);
96209
96270
  try {
@@ -96487,7 +96548,8 @@ var init_native_session_browser = __esm({
96487
96548
  sessionId: command.targetSessionId,
96488
96549
  additionalDirectories: target.additionalDirectories
96489
96550
  },
96490
- action === "fork" ? { kind: "fork", nativeSessionId: target.info.sessionId, title: title2 } : { kind: "import", nativeSessionId: target.info.sessionId, title: title2 }
96551
+ action === "fork" ? { kind: "fork", nativeSessionId: target.info.sessionId, title: title2 } : { kind: "import", nativeSessionId: target.info.sessionId, title: title2 },
96552
+ this.#resolveAgent
96491
96553
  );
96492
96554
  signal.throwIfAborted();
96493
96555
  const ready = {
@@ -97369,7 +97431,7 @@ var init_session_turns = __esm({
97369
97431
 
97370
97432
  // src/session/workspace/workspace-directory.ts
97371
97433
  import { homedir as homedir4 } from "node:os";
97372
- import { basename as basename7, dirname as dirname10, isAbsolute as isAbsolute17, join as join32, normalize as normalize2, relative as relative4 } from "node:path";
97434
+ import { basename as basename8, dirname as dirname11, isAbsolute as isAbsolute17, join as join33, normalize as normalize2, relative as relative4 } from "node:path";
97373
97435
  function encodePath(path8) {
97374
97436
  const encoded = Buffer.from(path8, "utf8").toString("base64url");
97375
97437
  if (path8.length === 0 || path8.length > MAX_WORKSPACE_PATH_LENGTH || encoded.length + "path-".length > MAX_DIRECTORY_IDENTIFIER_LENGTH) {
@@ -97472,7 +97534,7 @@ var init_workspace_directory = __esm({
97472
97534
  return {
97473
97535
  path: path8,
97474
97536
  directoryId: encodePath(path8),
97475
- name: basename7(path8) || path8,
97537
+ name: basename8(path8) || path8,
97476
97538
  label: this.label(path8)
97477
97539
  };
97478
97540
  };
@@ -97498,7 +97560,7 @@ var init_workspace_directory = __esm({
97498
97560
  continue;
97499
97561
  }
97500
97562
  try {
97501
- const path8 = await this.resolvePath(join32(target, child.name), signal);
97563
+ const path8 = await this.resolvePath(join33(target, child.name), signal);
97502
97564
  entries.push({ directoryId: encodePath(path8), name: child.name });
97503
97565
  } catch (cause) {
97504
97566
  signal.throwIfAborted();
@@ -97508,7 +97570,7 @@ var init_workspace_directory = __esm({
97508
97570
  }
97509
97571
  }
97510
97572
  entries.sort((a, b2) => a.name.localeCompare(b2.name));
97511
- const parent = dirname10(target);
97573
+ const parent = dirname11(target);
97512
97574
  return new WorkspaceDirectoryListing(
97513
97575
  id,
97514
97576
  this.label(target),
@@ -97669,8 +97731,8 @@ var init_session_layer = __esm({
97669
97731
 
97670
97732
  // src/storage/files/scratch-directory.ts
97671
97733
  import { randomUUID as randomUUID15 } from "node:crypto";
97672
- import { lstat as lstat6, mkdir as mkdir5, readdir as readdir7, realpath as realpath9, rename as rename5, rm as rm4, stat as stat7, utimes, writeFile as writeFile5 } from "node:fs/promises";
97673
- import { dirname as dirname11, join as join33 } from "node:path";
97734
+ import { lstat as lstat6, mkdir as mkdir5, readdir as readdir7, realpath as realpath9, rename as rename5, rm as rm4, stat as stat8, utimes, writeFile as writeFile5 } from "node:fs/promises";
97735
+ import { dirname as dirname12, join as join34 } from "node:path";
97674
97736
  async function atomicWrite(path8, bytes, signal) {
97675
97737
  const temporary = `${path8}.${randomUUID15()}.tmp`;
97676
97738
  try {
@@ -97688,22 +97750,22 @@ var init_scratch_directory = __esm({
97688
97750
  ScratchDirectory = class {
97689
97751
  #root;
97690
97752
  constructor(parent) {
97691
- this.#root = join33(parent, randomUUID15());
97753
+ this.#root = join34(parent, randomUUID15());
97692
97754
  }
97693
97755
  /** Refreshes this directory's lease and removes sibling directories whose lease is older than `leaseMilliseconds`. */
97694
97756
  refreshLease = async (leaseMilliseconds) => {
97695
97757
  await mkdir5(this.#root, { mode: 448, recursive: true });
97696
97758
  const now = /* @__PURE__ */ new Date();
97697
97759
  await utimes(this.#root, now, now);
97698
- for (const directory of await readdir7(dirname11(this.#root), { withFileTypes: true })) {
97760
+ for (const directory of await readdir7(dirname12(this.#root), { withFileTypes: true })) {
97699
97761
  if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
97700
97762
  continue;
97701
97763
  }
97702
- const path8 = join33(dirname11(this.#root), directory.name);
97764
+ const path8 = join34(dirname12(this.#root), directory.name);
97703
97765
  if (path8 === this.#root) {
97704
97766
  continue;
97705
97767
  }
97706
- const modified = await stat7(path8).then(
97768
+ const modified = await stat8(path8).then(
97707
97769
  (entry) => entry.mtimeMs,
97708
97770
  () => Date.now()
97709
97771
  );
@@ -97714,10 +97776,10 @@ var init_scratch_directory = __esm({
97714
97776
  };
97715
97777
  /** Writes `bytes` atomically to `<group>/<name>` with owner-only permissions and returns the path. */
97716
97778
  write = async (group, name2, bytes, signal) => {
97717
- const directory = join33(this.#root, group);
97779
+ const directory = join34(this.#root, group);
97718
97780
  await mkdir5(directory, { mode: 448, recursive: true });
97719
97781
  signal.throwIfAborted();
97720
- const path8 = join33(directory, name2);
97782
+ const path8 = join34(directory, name2);
97721
97783
  await atomicWrite(path8, bytes, signal);
97722
97784
  return path8;
97723
97785
  };
@@ -97728,11 +97790,11 @@ var init_scratch_directory = __esm({
97728
97790
  resolveFile = async (path8) => {
97729
97791
  try {
97730
97792
  const [resolvedDirectory, resolvedPath, file2] = await Promise.all([
97731
- realpath9(dirname11(path8)),
97793
+ realpath9(dirname12(path8)),
97732
97794
  realpath9(path8),
97733
97795
  lstat6(path8)
97734
97796
  ]);
97735
- return file2.isFile() && !file2.isSymbolicLink() && dirname11(resolvedPath) === resolvedDirectory ? resolvedPath : null;
97797
+ return file2.isFile() && !file2.isSymbolicLink() && dirname12(resolvedPath) === resolvedDirectory ? resolvedPath : null;
97736
97798
  } catch {
97737
97799
  return null;
97738
97800
  }
@@ -97746,7 +97808,7 @@ var init_scratch_directory = __esm({
97746
97808
 
97747
97809
  // src/session/content/external-content-store.ts
97748
97810
  import { createHash as createHash8 } from "node:crypto";
97749
- import { join as join34 } from "node:path";
97811
+ import { join as join35 } from "node:path";
97750
97812
  var contentRequest, CONTENT_LIFETIME_MILLISECONDS, metadataSchema, LocalExternalContentStore;
97751
97813
  var init_external_content_store = __esm({
97752
97814
  "src/session/content/external-content-store.ts"() {
@@ -97768,7 +97830,7 @@ var init_external_content_store = __esm({
97768
97830
  #expirationTimer;
97769
97831
  #cleanup = Promise.resolve();
97770
97832
  constructor(stateDirectory) {
97771
- this.#scratch = new ScratchDirectory(join34(stateDirectory, "tmp", "session-content"));
97833
+ this.#scratch = new ScratchDirectory(join35(stateDirectory, "tmp", "session-content"));
97772
97834
  this.#expirationTimer = setInterval(() => {
97773
97835
  void this.#expire().catch(() => void 0);
97774
97836
  }, 6e4);
@@ -98168,7 +98230,7 @@ var init_agent_process_pool = __esm({
98168
98230
  });
98169
98231
 
98170
98232
  // src/runtime/observability/diagnostic-log.ts
98171
- import { join as join35 } from "node:path";
98233
+ import { join as join36 } from "node:path";
98172
98234
  function exportedFields(value) {
98173
98235
  const entry = {};
98174
98236
  for (const field of REMOTE_DIAGNOSTIC_FIELDS) {
@@ -98237,7 +98299,7 @@ var init_diagnostic_log = __esm({
98237
98299
  this.#maximumBytes = maximumBytes;
98238
98300
  const processLogsDirectory = options.processLogsDirectory;
98239
98301
  this.#sources = [
98240
- { maximumBytes, path: join35(directory, DAEMON_LOG_FILENAME) },
98302
+ { maximumBytes, path: join36(directory, DAEMON_LOG_FILENAME) },
98241
98303
  // The process logs a Runtime does not own, but must read to explain its own deaths.
98242
98304
  ...processLogsDirectory === void 0 ? [] : processLogPaths(processLogsDirectory).map((path8) => ({ maximumBytes: null, path: path8 }))
98243
98305
  ];
@@ -99143,7 +99205,7 @@ var init_agent_settings = __esm({
99143
99205
  });
99144
99206
 
99145
99207
  // src/session/content/session-files.ts
99146
- import { basename as basename8, extname as extname2, isAbsolute as isAbsolute18, join as join36, normalize as normalize3, resolve as resolve18 } from "node:path";
99208
+ import { basename as basename9, extname as extname2, isAbsolute as isAbsolute18, join as join37, normalize as normalize3, resolve as resolve18 } from "node:path";
99147
99209
  import { fileURLToPath as fileURLToPath2 } from "node:url";
99148
99210
  function requestedPath(value) {
99149
99211
  if (value.includes("\0")) {
@@ -99167,7 +99229,7 @@ async function resolveFile(value, workingDirectory, signal) {
99167
99229
  if (isAbsolute18(requested.path) && normalize3(requested.path) !== requested.path) {
99168
99230
  return null;
99169
99231
  }
99170
- const candidates = requested.explicitUrl || workingDirectory === null ? [requested.path] : isAbsolute18(requested.path) ? [join36(workingDirectory, requested.path), requested.path] : [resolve18(workingDirectory, requested.path)];
99232
+ const candidates = requested.explicitUrl || workingDirectory === null ? [requested.path] : isAbsolute18(requested.path) ? [join37(workingDirectory, requested.path), requested.path] : [resolve18(workingDirectory, requested.path)];
99171
99233
  for (const candidate of candidates) {
99172
99234
  if (!isAbsolute18(candidate) || normalize3(candidate) !== candidate) {
99173
99235
  continue;
@@ -99201,7 +99263,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
99201
99263
  kind: FILE_BEGIN_KIND,
99202
99264
  mediaType: external?.mediaType ?? raster?.mimeType ?? (extname2(target).toLowerCase() === ".svg" ? "image/svg+xml" : "application/octet-stream"),
99203
99265
  modifiedAt: before.modifiedAt.toISOString(),
99204
- name: external?.name ?? (basename8(target) || "file"),
99266
+ name: external?.name ?? (basename9(target) || "file"),
99205
99267
  requestId: command.requestId,
99206
99268
  sessionId: command.sessionId
99207
99269
  });
@@ -99277,7 +99339,7 @@ var init_file_read = __esm({
99277
99339
  });
99278
99340
 
99279
99341
  // src/session/workspace/resolve-session-directories.ts
99280
- import { basename as basename9 } from "node:path";
99342
+ import { basename as basename10 } from "node:path";
99281
99343
  async function resolveSessionDirectories(directories, bindingId, directoryId, additionalDirectoryIds, signal) {
99282
99344
  const selection = await directories.describe(bindingId, directoryId, signal);
99283
99345
  const cwd = selection.path;
@@ -99293,7 +99355,7 @@ async function resolveSessionDirectories(directories, bindingId, directoryId, ad
99293
99355
  additionalDirectories.push(directory);
99294
99356
  additionalDirectoryEntries.push({
99295
99357
  directoryId: additionalDirectoryId,
99296
- name: basename9(directory)
99358
+ name: basename10(directory)
99297
99359
  });
99298
99360
  }
99299
99361
  return new ResolvedSessionDirectories(cwd, selection.label, additionalDirectories, additionalDirectoryEntries);
@@ -99386,7 +99448,7 @@ async function executeSessionHistoryPageLoad(socket, command, config2, resolveAg
99386
99448
  );
99387
99449
  const loadOptions = {
99388
99450
  additionalDirectories: resolved.additionalDirectories,
99389
- ...await resolveAgent(entry.agentId, signal),
99451
+ ...await resolveAgent(entry.agentId, signal, command.sessionId),
99390
99452
  cwd: resolved.cwd,
99391
99453
  sessionId: command.sessionId,
99392
99454
  signal
@@ -99433,7 +99495,7 @@ async function executeSessionPreviewHistoryPageLoad(socket, command, config2, re
99433
99495
  );
99434
99496
  const loadOptions = {
99435
99497
  additionalDirectories: resolved.additionalDirectories,
99436
- ...await resolveAgent(command.agentId, signal),
99498
+ ...await resolveAgent(command.agentId, signal, command.sessionId),
99437
99499
  cwd: resolved.cwd,
99438
99500
  sessionId: command.sessionId,
99439
99501
  signal
@@ -100101,7 +100163,7 @@ async function executePrompt({
100101
100163
  command.additionalDirectoryIds,
100102
100164
  signal
100103
100165
  );
100104
- const { agent, adapter } = await resolveAgent(command.agentId, signal);
100166
+ const { agent, adapter } = await resolveAgent(command.agentId, signal, command.sessionId);
100105
100167
  const availability = await waitForSessionAvailability(signal);
100106
100168
  if (availability.kind === "busy") {
100107
100169
  throw new AcpExecutionError("Another prompt is already running in this conversation", {}, "session_busy");
@@ -100497,7 +100559,7 @@ async function prepareSession(command, recovery, closed, config2, resolveAgent,
100497
100559
  signal
100498
100560
  )
100499
100561
  );
100500
- const resolvedAgent = await resolveAgent(command.agentId, signal);
100562
+ const resolvedAgent = await resolveAgent(command.agentId, signal, command.sessionId);
100501
100563
  const preparation = {
100502
100564
  additionalDirectories: resolved.additionalDirectories,
100503
100565
  ...resolvedAgent,
@@ -100660,7 +100722,7 @@ async function executeSessionConfigure(socket, command, config2, resolveAgent, d
100660
100722
  );
100661
100723
  const configOptions = await sessions.configureSession({
100662
100724
  additionalDirectories: resolved.additionalDirectories,
100663
- ...await resolveAgent(command.agentId, signal),
100725
+ ...await resolveAgent(command.agentId, signal, command.sessionId),
100664
100726
  booleanValue: command.booleanValue,
100665
100727
  configId: command.configId,
100666
100728
  cwd: resolved.cwd,
@@ -101655,8 +101717,10 @@ async function runRuntime(config2, parentSignal, timer = systemTimer, options =
101655
101717
  processes,
101656
101718
  (sessionId, content, contentSignal) => externalContent.put({ ...content, sessionId, signal: contentSignal })
101657
101719
  );
101658
- const resolveAgent = async (agentId, resolveSignal) => {
101659
- const agent = await resolveCatalogAgent(config2, agentId, resolveSignal);
101720
+ const resolveAgent = async (agentId, resolveSignal, sessionId) => {
101721
+ const catalogAgent = await resolveCatalogAgent(config2, agentId, resolveSignal);
101722
+ const environment = sessionId === void 0 ? void 0 : config2.sessionEnvironment?.({ sessionId, agentId });
101723
+ const agent = environment === void 0 ? catalogAgent : catalogAgent.withEnvironment({ ...catalogAgent.environment, ...environment });
101660
101724
  return { agent, adapter: adapters.resolve(agent) };
101661
101725
  };
101662
101726
  const layer = buildSessionLayer({
@@ -102328,7 +102392,7 @@ var init_daemon = __esm({
102328
102392
  });
102329
102393
 
102330
102394
  // src/cli/handler/logs/logic/collect-local-logs.ts
102331
- import { join as join37, relative as relative5, resolve as resolve19 } from "node:path";
102395
+ import { join as join38, relative as relative5, resolve as resolve19 } from "node:path";
102332
102396
  async function collectLocalDaemonLogs(stateDirectory, tailLines, signal) {
102333
102397
  signal.throwIfAborted();
102334
102398
  const root = resolve19(stateDirectory);
@@ -102338,7 +102402,7 @@ async function collectLocalDaemonLogs(stateDirectory, tailLines, signal) {
102338
102402
  for (const directory of directories) {
102339
102403
  const names = await listLogFiles(directory, root, unreadable);
102340
102404
  for (const name2 of names) {
102341
- const path8 = join37(directory, name2);
102405
+ const path8 = join38(directory, name2);
102342
102406
  const reported = relative5(root, path8);
102343
102407
  const read = await readOwnedLogFile(path8, signal);
102344
102408
  if (read.kind === "unreadable") {
@@ -102701,10 +102765,15 @@ async function runCLI() {
102701
102765
  version: package_default.version
102702
102766
  };
102703
102767
  try {
102768
+ await validateStateRoot(process.env);
102704
102769
  await createProgram(context).parseAsync(process.argv);
102705
102770
  } catch (error62) {
102706
102771
  if (error62 instanceof CommanderError) {
102707
102772
  process.exitCode = error62.exitCode;
102773
+ } else if (error62 instanceof StateRootError) {
102774
+ process.stderr.write(`${error62.message}
102775
+ `);
102776
+ process.exitCode = 78;
102708
102777
  } else if (!shutdown.signal.aborted) {
102709
102778
  const message = error62 instanceof Error ? error62.message : "Unknown failure";
102710
102779
  process.stderr.write(`Mobius daemon failed: ${message}
@@ -102721,6 +102790,7 @@ var init_cli = __esm({
102721
102790
  "use strict";
102722
102791
  init_commander();
102723
102792
  init_package();
102793
+ init_state_root();
102724
102794
  init_agents();
102725
102795
  init_daemon();
102726
102796
  init_logs();