@moxt-ai/mobius 0.0.117 → 0.0.118

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 (34) hide show
  1. package/dist/acp/codex/agent.d.ts +1 -0
  2. package/dist/acp/codex/agent.d.ts.map +1 -1
  3. package/dist/acp/codex/agent.js +29 -2
  4. package/dist/acp/codex/agent.js.map +1 -1
  5. package/dist/acp/codex/app-server-protocol.d.ts +6 -0
  6. package/dist/acp/codex/app-server-protocol.d.ts.map +1 -1
  7. package/dist/acp/codex/app-server-protocol.js +6 -0
  8. package/dist/acp/codex/app-server-protocol.js.map +1 -1
  9. package/dist/acp/in-process/acp-endpoint.d.ts +2 -0
  10. package/dist/acp/in-process/acp-endpoint.d.ts.map +1 -1
  11. package/dist/acp/process-session.d.ts +8 -1
  12. package/dist/acp/process-session.d.ts.map +1 -1
  13. package/dist/acp/process-session.js +12 -0
  14. package/dist/acp/process-session.js.map +1 -1
  15. package/dist/acp/session-manager.d.ts.map +1 -1
  16. package/dist/acp/session-manager.js +1 -1
  17. package/dist/acp/session-manager.js.map +1 -1
  18. package/dist/cli.js +73 -7
  19. package/dist/cli.js.map +2 -2
  20. package/dist/index.js +72 -6
  21. package/dist/index.js.map +2 -2
  22. package/dist/native-sessions/codex-history.d.ts +8 -1
  23. package/dist/native-sessions/codex-history.d.ts.map +1 -1
  24. package/dist/native-sessions/codex-history.js +8 -2
  25. package/dist/native-sessions/codex-history.js.map +1 -1
  26. package/dist/native-sessions/live-history-page.d.ts.map +1 -1
  27. package/dist/native-sessions/live-history-page.js +15 -1
  28. package/dist/native-sessions/live-history-page.js.map +1 -1
  29. package/dist/run-daemon.d.ts.map +1 -1
  30. package/dist/run-daemon.js +2 -2
  31. package/dist/run-daemon.js.map +1 -1
  32. package/dist/runtime.js +72 -6
  33. package/dist/runtime.js.map +2 -2
  34. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -3381,7 +3381,7 @@ var program = new Command();
3381
3381
  // package.json
3382
3382
  var package_default = {
3383
3383
  name: "@moxt-ai/mobius",
3384
- version: "0.0.117",
3384
+ version: "0.0.118",
3385
3385
  description: "Mobius CLI for pairing and running local AI agent services.",
3386
3386
  type: "module",
3387
3387
  bin: {
@@ -24648,6 +24648,12 @@ var requestUserInputParamsSchema = external_exports.object({
24648
24648
  threadId: boundedText(256),
24649
24649
  turnId: boundedText(256)
24650
24650
  });
24651
+ var reasoningTextDeltaParamsSchema = external_exports.object({
24652
+ delta: boundedText(1e5),
24653
+ itemId: boundedText(256),
24654
+ threadId: boundedText(256),
24655
+ turnId: boundedText(256)
24656
+ });
24651
24657
  var mcpElicitationParamsSchema = external_exports.object({
24652
24658
  message: boundedText(4096),
24653
24659
  mode: external_exports.enum(["form", "url"]).or(external_exports.string()),
@@ -25383,7 +25389,9 @@ var CodexAcpAgent = class {
25383
25389
  // rather than break every turn.
25384
25390
  #collaborationModeSupported = null;
25385
25391
  #selection;
25392
+ #streamedReasoningItemIds = /* @__PURE__ */ new Set();
25386
25393
  #turn = null;
25394
+ #nativeTurnId = null;
25387
25395
  #updateTail = Promise.resolve();
25388
25396
  constructor(options) {
25389
25397
  this.#selection = {
@@ -25522,6 +25530,7 @@ var CodexAcpAgent = class {
25522
25530
  }
25523
25531
  /** The ACP agent app Mobius connects its own ACP client to, in-process. */
25524
25532
  app = () => this.#app;
25533
+ nativeTurnId = () => this.#nativeTurnId;
25525
25534
  /** Starts the app-server, performs its handshake, and reads the model catalog Codex offers. */
25526
25535
  initialize = async (signal) => {
25527
25536
  await this.#appServer.initialize(signal);
@@ -25793,6 +25802,7 @@ var CodexAcpAgent = class {
25793
25802
  const decoded = turnNotificationSchema.safeParse(params);
25794
25803
  if (decoded.success && decoded.data.threadId === this.#nativeSessionId && this.#turn !== null) {
25795
25804
  this.#turn.turn.id = decoded.data.turn.id;
25805
+ this.#nativeTurnId = decoded.data.turn.id;
25796
25806
  }
25797
25807
  return;
25798
25808
  }
@@ -25839,6 +25849,20 @@ var CodexAcpAgent = class {
25839
25849
  }
25840
25850
  return;
25841
25851
  }
25852
+ if (method === "item/reasoning/summaryTextDelta" || method === "item/reasoning/textDelta") {
25853
+ const decoded = reasoningTextDeltaParamsSchema.safeParse(params);
25854
+ if (decoded.success && decoded.data.threadId === this.#nativeSessionId && this.#turn !== null && decoded.data.turnId === this.#turn.turn.id && decoded.data.delta.length > 0) {
25855
+ this.#streamedReasoningItemIds.add(decoded.data.itemId);
25856
+ await this.#enqueue(async () => {
25857
+ await this.#emit({
25858
+ content: { text: decoded.data.delta, type: "text" },
25859
+ messageId: decoded.data.itemId,
25860
+ sessionUpdate: "agent_thought_chunk"
25861
+ });
25862
+ });
25863
+ }
25864
+ return;
25865
+ }
25842
25866
  if (method !== "item/started" && method !== "item/completed") {
25843
25867
  return;
25844
25868
  }
@@ -25862,7 +25886,8 @@ var CodexAcpAgent = class {
25862
25886
  }
25863
25887
  const reasoning = reasoningText(item);
25864
25888
  if (reasoning !== null) {
25865
- if (method === "item/completed" && reasoning.length > 0) {
25889
+ const streamed = method === "item/completed" && this.#streamedReasoningItemIds.delete(item.id);
25890
+ if (method === "item/completed" && reasoning.length > 0 && !streamed) {
25866
25891
  await this.#enqueue(async () => {
25867
25892
  await this.#emit({
25868
25893
  content: { text: reasoning, type: "text" },
@@ -26009,7 +26034,9 @@ var CodexAcpAgent = class {
26009
26034
  };
26010
26035
  signal.addEventListener("abort", aborted2, { once: true });
26011
26036
  const turn = { completion, turn: { id: "" } };
26037
+ this.#streamedReasoningItemIds.clear();
26012
26038
  this.#turn = turn;
26039
+ this.#nativeTurnId = null;
26013
26040
  try {
26014
26041
  const selection = this.#selection;
26015
26042
  const mode = AGENT_MODES.find((candidate) => candidate.id === selection.mode) ?? DEFAULT_MODE;
@@ -26050,12 +26077,14 @@ var CodexAcpAgent = class {
26050
26077
  );
26051
26078
  if (this.#turn === turn) {
26052
26079
  turn.turn.id = started.id;
26080
+ this.#nativeTurnId = started.id;
26053
26081
  }
26054
26082
  return await completion.promise;
26055
26083
  } finally {
26056
26084
  signal.removeEventListener("abort", aborted2);
26057
26085
  if (this.#turn === turn) {
26058
26086
  this.#turn = null;
26087
+ this.#streamedReasoningItemIds.clear();
26059
26088
  }
26060
26089
  }
26061
26090
  };
@@ -38233,6 +38262,7 @@ var AcpProcessSession = class _AcpProcessSession {
38233
38262
  #configOptions = [];
38234
38263
  #nativeSessionId = "";
38235
38264
  #prompted = false;
38265
+ #nativePrompt = null;
38236
38266
  #replay = {
38237
38267
  kind: "idle"
38238
38268
  };
@@ -38890,6 +38920,11 @@ var AcpProcessSession = class _AcpProcessSession {
38890
38920
  }
38891
38921
  return prompt;
38892
38922
  };
38923
+ nativeHistoryTurn = () => {
38924
+ const prompt = this.#nativePrompt;
38925
+ const nativeTurnId = this.#inProcessAgent?.nativeTurnId?.() ?? null;
38926
+ return prompt === null || nativeTurnId === null || nativeTurnId === prompt.previousTurnId ? null : { commandId: prompt.commandId, nativeTurnId };
38927
+ };
38893
38928
  prompt = async (options) => {
38894
38929
  if (this.#turn.running) {
38895
38930
  throw new AcpExecutionError("Another prompt is already running in this conversation", {}, "session_busy");
@@ -38918,6 +38953,10 @@ var AcpProcessSession = class _AcpProcessSession {
38918
38953
  this.prepareAgentContent
38919
38954
  );
38920
38955
  this.#turn = running;
38956
+ this.#nativePrompt = {
38957
+ commandId: options.commandId,
38958
+ previousTurnId: this.#inProcessAgent?.nativeTurnId?.() ?? null
38959
+ };
38921
38960
  try {
38922
38961
  const response = await this.race(
38923
38962
  this.#connection.agent.request(
@@ -40359,7 +40398,11 @@ var AcpSessionManager = class {
40359
40398
  const runtime = await this.ensureSession(options);
40360
40399
  const stored = this.#store.read(options.sessionId);
40361
40400
  if (stored instanceof FoundAcpStoredSession && this.#nativeHistoryReader !== null) {
40362
- const history = await this.#nativeHistoryReader.read(options, stored.session.nativeSessionId);
40401
+ const history = await this.#nativeHistoryReader.read(
40402
+ options,
40403
+ stored.session.nativeSessionId,
40404
+ runtime.nativeHistoryTurn
40405
+ );
40363
40406
  if (history !== null) {
40364
40407
  return history;
40365
40408
  }
@@ -41001,8 +41044,19 @@ function paginateLiveSessionHistory(history, activeTurn, sessionId, cursor, limi
41001
41044
  truncated: activeTurn.truncated || activeText.length !== activeTurn.text.length
41002
41045
  };
41003
41046
  }
41047
+ const activeUserIndex = history.coveredCommandIds.includes(activeTurn.commandId) ? history.messages.findLastIndex((message) => message.role === "user") : -1;
41048
+ if (activeUserIndex >= 0) {
41049
+ history = {
41050
+ ...history,
41051
+ coveredCommandIds: history.coveredCommandIds.filter((id) => id !== activeTurn.commandId),
41052
+ coveredMessageIds: history.coveredMessageIds.filter(
41053
+ (id) => id !== `${activeTurn.commandId}:user` && id !== `${activeTurn.commandId}:agent`
41054
+ ),
41055
+ messages: history.messages.slice(0, activeUserIndex + 1)
41056
+ };
41057
+ }
41004
41058
  const latestNativeMessage = history.messages.at(-1);
41005
- const activeMessages = latestNativeMessage?.role === "user" && latestNativeMessage.text === activeTurn.prompt ? completeActiveMessages.slice(1) : completeActiveMessages;
41059
+ const activeMessages = activeUserIndex >= 0 || latestNativeMessage?.role === "user" && latestNativeMessage.text === activeTurn.prompt ? completeActiveMessages.slice(1) : completeActiveMessages;
41006
41060
  let historicalMessageCount = 0;
41007
41061
  let remainingCharacters = SESSION_HISTORY_CHARACTER_LIMIT - activeText.length - activeMessageOverhead - activeStructuredCharacters - (activeMessages.length === completeActiveMessages.length ? activeTurn.prompt.length : 0);
41008
41062
  const historicalMessageLimit = Math.max(0, limit - activeMessages.length);
@@ -43661,6 +43715,7 @@ var threadSchema = external_exports.object({
43661
43715
  var turnsSchema = external_exports.object({
43662
43716
  data: external_exports.array(
43663
43717
  external_exports.object({
43718
+ id: external_exports.string().min(1),
43664
43719
  error: external_exports.unknown().nullish(),
43665
43720
  items: external_exports.array(external_exports.unknown()).max(1e5)
43666
43721
  })
@@ -43723,6 +43778,8 @@ function messageSize(message) {
43723
43778
  }
43724
43779
  function decodeHistory(thread, value, options) {
43725
43780
  const page = turnsSchema.parse(value);
43781
+ const nativeTurn = options.nativeTurn?.();
43782
+ const coveredCommandIds = nativeTurn != null && page.data[0]?.id === nativeTurn.nativeTurnId ? [nativeTurn.commandId] : [];
43726
43783
  const messages = [];
43727
43784
  let characters = 0;
43728
43785
  let truncated = page.nextCursor != null;
@@ -43866,7 +43923,7 @@ function decodeHistory(thread, value, options) {
43866
43923
  status: "available",
43867
43924
  messages,
43868
43925
  truncated,
43869
- coveredCommandIds: [],
43926
+ coveredCommandIds,
43870
43927
  coveredMessageIds: []
43871
43928
  }
43872
43929
  };
@@ -44066,7 +44123,10 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
44066
44123
  }
44067
44124
  }
44068
44125
  var readCodexHistory = async (agent, cwd, nativeSessionId, signal) => await readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal, { detail: "messages" });
44069
- var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal) => await readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal, { detail: "rich" });
44126
+ var readCodexFullHistory = async (agent, cwd, nativeSessionId, signal, nativeTurn) => await readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal, {
44127
+ detail: "rich",
44128
+ ...nativeTurn === void 0 ? {} : { nativeTurn }
44129
+ });
44070
44130
 
44071
44131
  // src/native-sessions/handle-native-requests.ts
44072
44132
  import { WebSocket as WebSocket5 } from "undici";
@@ -45717,7 +45777,13 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
45717
45777
  new DaemonAcpObserver(recordSessionEvent),
45718
45778
  sessionStore,
45719
45779
  {
45720
- read: async (options2, nativeSessionId) => options2.agent.id === "codex" ? (await readCodexFullHistory(options2.agent, options2.cwd, nativeSessionId, options2.signal)).history : null
45780
+ read: async (options2, nativeSessionId, nativeTurn) => options2.agent.id === "codex" ? (await readCodexFullHistory(
45781
+ options2.agent,
45782
+ options2.cwd,
45783
+ nativeSessionId,
45784
+ options2.signal,
45785
+ nativeTurn
45786
+ )).history : null
45721
45787
  },
45722
45788
  "native"
45723
45789
  );