@moxt-ai/mobius 0.0.185 → 0.0.187

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.
package/dist/index.js CHANGED
@@ -23248,11 +23248,14 @@ function requestErrorMessage(error62) {
23248
23248
  return fallback;
23249
23249
  }
23250
23250
  const agentError = error62.data["error"];
23251
- if (!isRecord4(agentError)) {
23252
- return fallback;
23251
+ if (isRecord4(agentError)) {
23252
+ const message = agentError["message"];
23253
+ if (typeof message === "string" && message.length > 0) {
23254
+ return truncate2(message, 500);
23255
+ }
23253
23256
  }
23254
- const message = agentError["message"];
23255
- return typeof message === "string" && message.length > 0 ? truncate2(message, 500) : fallback;
23257
+ const details = error62.data["details"];
23258
+ return typeof details === "string" && details.length > 0 ? truncate2(details, 500) : fallback;
23256
23259
  }
23257
23260
  function readableWebStream(input2) {
23258
23261
  let streamOpen = true;
@@ -30515,6 +30518,9 @@ var AgentSession = class _AgentSession {
30515
30518
  );
30516
30519
  }
30517
30520
  initialize = async (signal, recovery, origin) => {
30521
+ if (origin?.kind === "fork") {
30522
+ this.#sessionTitle = origin.title;
30523
+ }
30518
30524
  await this.#initializeAgent(signal);
30519
30525
  let stored = this.#metrics.measureSync(
30520
30526
  "session-state-read",
@@ -34753,7 +34759,9 @@ var CodexAcpAgent = class {
34753
34759
  "thread/fork",
34754
34760
  {
34755
34761
  cwd: context.params.cwd,
34756
- excludeTurns: false,
34762
+ // Fork keeps the native context; its response only needs the new identity
34763
+ // and settings. History is read through the separate history boundary.
34764
+ excludeTurns: true,
34757
34765
  threadId: context.params.sessionId
34758
34766
  },
34759
34767
  AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
@@ -34762,7 +34770,6 @@ var CodexAcpAgent = class {
34762
34770
  this.#nativeSessionId = forked.thread.id;
34763
34771
  this.#settings.selectRestoredThread(forked);
34764
34772
  await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
34765
- await this.#replayHistory(forked.thread.turns);
34766
34773
  await this.#emitAvailableCommands();
34767
34774
  return { configOptions: this.#settings.configOptions(), sessionId: forked.thread.id };
34768
34775
  }).onRequest(methods4.agent.session.resume, async (context) => {
@@ -40513,6 +40520,29 @@ var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTur
40513
40520
 
40514
40521
  // src/native-sessions/service.ts
40515
40522
  import { randomUUID as randomUUID5 } from "node:crypto";
40523
+ var MAXIMUM_SESSION_TITLE_LENGTH = 500;
40524
+ var forkSuffixPattern = / \(Fork #([1-9][0-9]*)\)$/u;
40525
+ function nextForkTitle(sourceTitle, sessions) {
40526
+ let highest = 0;
40527
+ for (const session of sessions) {
40528
+ const match = forkSuffixPattern.exec(session.title);
40529
+ const encodedNumber = match?.[1];
40530
+ if (encodedNumber === void 0) {
40531
+ continue;
40532
+ }
40533
+ const number5 = Number(encodedNumber);
40534
+ if (!Number.isSafeInteger(number5)) {
40535
+ continue;
40536
+ }
40537
+ const suffix2 = ` (Fork #${number5})`;
40538
+ if (`${sourceTitle.slice(0, MAXIMUM_SESSION_TITLE_LENGTH - suffix2.length)}${suffix2}` === session.title) {
40539
+ highest = Math.max(highest, number5);
40540
+ }
40541
+ }
40542
+ const number4 = highest + 1;
40543
+ const suffix = ` (Fork #${number4})`;
40544
+ return `${sourceTitle.slice(0, MAXIMUM_SESSION_TITLE_LENGTH - suffix.length)}${suffix}`;
40545
+ }
40516
40546
  var NativeSessionService = class {
40517
40547
  #entries = /* @__PURE__ */ new Map();
40518
40548
  #cursors = /* @__PURE__ */ new Map();
@@ -40708,6 +40738,8 @@ var NativeSessionService = class {
40708
40738
  "native_session_unsupported"
40709
40739
  );
40710
40740
  }
40741
+ const sourceTitle = target.info.title ?? "Untitled session";
40742
+ const title2 = action === "fork" ? nextForkTitle(sourceTitle, this.#sessions.listSessions(Number.MAX_SAFE_INTEGER)) : sourceTitle;
40711
40743
  const opened = await this.#sessions.openNativeSession(
40712
40744
  {
40713
40745
  ...options,
@@ -40715,7 +40747,7 @@ var NativeSessionService = class {
40715
40747
  sessionId: command.targetSessionId,
40716
40748
  additionalDirectories: target.additionalDirectories
40717
40749
  },
40718
- { kind: action, nativeSessionId: target.info.sessionId }
40750
+ action === "fork" ? { kind: "fork", nativeSessionId: target.info.sessionId, title: title2 } : { kind: "import", nativeSessionId: target.info.sessionId }
40719
40751
  );
40720
40752
  signal.throwIfAborted();
40721
40753
  const ready = {
@@ -40739,7 +40771,7 @@ var NativeSessionService = class {
40739
40771
  action,
40740
40772
  ready,
40741
40773
  targetSessionId: command.targetSessionId,
40742
- title: target.info.title ?? "Untitled session"
40774
+ title: title2
40743
40775
  };
40744
40776
  };
40745
40777
  listSessions = async (limit, signal) => await this.describeSessions(this.#sessions.listSessions(limit), signal);