@moxt-ai/mobius 0.0.184 → 0.0.186

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) || agentError["code"] !== "invalid_prompt") {
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",
@@ -40513,6 +40519,29 @@ var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTur
40513
40519
 
40514
40520
  // src/native-sessions/service.ts
40515
40521
  import { randomUUID as randomUUID5 } from "node:crypto";
40522
+ var MAXIMUM_SESSION_TITLE_LENGTH = 500;
40523
+ var forkSuffixPattern = / \(Fork #([1-9][0-9]*)\)$/u;
40524
+ function nextForkTitle(sourceTitle, sessions) {
40525
+ let highest = 0;
40526
+ for (const session of sessions) {
40527
+ const match = forkSuffixPattern.exec(session.title);
40528
+ const encodedNumber = match?.[1];
40529
+ if (encodedNumber === void 0) {
40530
+ continue;
40531
+ }
40532
+ const number5 = Number(encodedNumber);
40533
+ if (!Number.isSafeInteger(number5)) {
40534
+ continue;
40535
+ }
40536
+ const suffix2 = ` (Fork #${number5})`;
40537
+ if (`${sourceTitle.slice(0, MAXIMUM_SESSION_TITLE_LENGTH - suffix2.length)}${suffix2}` === session.title) {
40538
+ highest = Math.max(highest, number5);
40539
+ }
40540
+ }
40541
+ const number4 = highest + 1;
40542
+ const suffix = ` (Fork #${number4})`;
40543
+ return `${sourceTitle.slice(0, MAXIMUM_SESSION_TITLE_LENGTH - suffix.length)}${suffix}`;
40544
+ }
40516
40545
  var NativeSessionService = class {
40517
40546
  #entries = /* @__PURE__ */ new Map();
40518
40547
  #cursors = /* @__PURE__ */ new Map();
@@ -40708,6 +40737,8 @@ var NativeSessionService = class {
40708
40737
  "native_session_unsupported"
40709
40738
  );
40710
40739
  }
40740
+ const sourceTitle = target.info.title ?? "Untitled session";
40741
+ const title2 = action === "fork" ? nextForkTitle(sourceTitle, this.#sessions.listSessions(Number.MAX_SAFE_INTEGER)) : sourceTitle;
40711
40742
  const opened = await this.#sessions.openNativeSession(
40712
40743
  {
40713
40744
  ...options,
@@ -40715,7 +40746,7 @@ var NativeSessionService = class {
40715
40746
  sessionId: command.targetSessionId,
40716
40747
  additionalDirectories: target.additionalDirectories
40717
40748
  },
40718
- { kind: action, nativeSessionId: target.info.sessionId }
40749
+ action === "fork" ? { kind: "fork", nativeSessionId: target.info.sessionId, title: title2 } : { kind: "import", nativeSessionId: target.info.sessionId }
40719
40750
  );
40720
40751
  signal.throwIfAborted();
40721
40752
  const ready = {
@@ -40739,7 +40770,7 @@ var NativeSessionService = class {
40739
40770
  action,
40740
40771
  ready,
40741
40772
  targetSessionId: command.targetSessionId,
40742
- title: target.info.title ?? "Untitled session"
40773
+ title: title2
40743
40774
  };
40744
40775
  };
40745
40776
  listSessions = async (limit, signal) => await this.describeSessions(this.#sessions.listSessions(limit), signal);