@moxt-ai/mobius 0.0.132 → 0.0.134

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/runtime.js CHANGED
@@ -23984,6 +23984,7 @@ var CodexAcpAgent = class {
23984
23984
  #settings;
23985
23985
  #nativeSessionId = "";
23986
23986
  #streamedReasoningItemIds = /* @__PURE__ */ new Set();
23987
+ #streamedAgentMessageItemIds = /* @__PURE__ */ new Set();
23987
23988
  #turn = null;
23988
23989
  #nativeTurnId = null;
23989
23990
  #updateTail = Promise.resolve();
@@ -24293,6 +24294,20 @@ var CodexAcpAgent = class {
24293
24294
  }
24294
24295
  return;
24295
24296
  }
24297
+ if (method === "item/agentMessage/delta") {
24298
+ const decoded = reasoningTextDeltaParamsSchema.safeParse(params);
24299
+ if (decoded.success && decoded.data.threadId === this.#nativeSessionId && this.#turn !== null && decoded.data.turnId === this.#turn.turn.id && decoded.data.delta.length > 0) {
24300
+ this.#streamedAgentMessageItemIds.add(decoded.data.itemId);
24301
+ await this.#enqueue(async () => {
24302
+ await this.#emit({
24303
+ content: { text: decoded.data.delta, type: "text" },
24304
+ messageId: decoded.data.itemId,
24305
+ sessionUpdate: "agent_message_chunk"
24306
+ });
24307
+ });
24308
+ }
24309
+ return;
24310
+ }
24296
24311
  if (method !== "item/started" && method !== "item/completed") {
24297
24312
  return;
24298
24313
  }
@@ -24301,7 +24316,7 @@ var CodexAcpAgent = class {
24301
24316
  return;
24302
24317
  }
24303
24318
  if (item.type === "agentMessage") {
24304
- if (method === "item/started") {
24319
+ if (method === "item/started" || this.#streamedAgentMessageItemIds.delete(item.id)) {
24305
24320
  return;
24306
24321
  }
24307
24322
  await this.#enqueue(async () => {
@@ -24464,6 +24479,7 @@ var CodexAcpAgent = class {
24464
24479
  };
24465
24480
  signal.addEventListener("abort", aborted2, { once: true });
24466
24481
  const turn = { completion, turn: { id: "" } };
24482
+ this.#streamedAgentMessageItemIds.clear();
24467
24483
  this.#streamedReasoningItemIds.clear();
24468
24484
  this.#turn = turn;
24469
24485
  this.#nativeTurnId = null;
@@ -24488,6 +24504,7 @@ var CodexAcpAgent = class {
24488
24504
  signal.removeEventListener("abort", aborted2);
24489
24505
  if (this.#turn === turn) {
24490
24506
  this.#turn = null;
24507
+ this.#streamedAgentMessageItemIds.clear();
24491
24508
  this.#streamedReasoningItemIds.clear();
24492
24509
  }
24493
24510
  }
@@ -27668,33 +27685,6 @@ var AcpActivityTracker = class {
27668
27685
  // src/acp/agent-turn.ts
27669
27686
  var SESSION_CONTROL_COMMAND_ID = "session-control";
27670
27687
  var AcpTurnState = class {
27671
- #bufferedText = [];
27672
- bufferText = (text2, messageId) => {
27673
- const previous = this.#bufferedText.at(-1);
27674
- if (previous?.messageId === messageId) {
27675
- previous.chunks.push(text2);
27676
- } else {
27677
- this.#bufferedText.push({ chunks: [text2], messageId });
27678
- }
27679
- };
27680
- flushText = async () => {
27681
- const buffered = this.#bufferedText;
27682
- this.#bufferedText = [];
27683
- for (const message of buffered) {
27684
- for (const chunk of message.chunks) {
27685
- await this.onText(chunk, message.messageId);
27686
- }
27687
- }
27688
- };
27689
- recordTextAsProgress = async () => {
27690
- const buffered = this.#bufferedText;
27691
- this.#bufferedText = [];
27692
- for (const message of buffered) {
27693
- for (const chunk of message.chunks) {
27694
- await this.activities.recordNarrative("progress", message.messageId, chunk);
27695
- }
27696
- }
27697
- };
27698
27688
  };
27699
27689
  var IdleAcpTurn = class extends AcpTurnState {
27700
27690
  commandId = SESSION_CONTROL_COMMAND_ID;
@@ -35066,7 +35056,6 @@ var AgentSession = class _AgentSession {
35066
35056
  options.signal
35067
35057
  );
35068
35058
  await this.#updates.drained();
35069
- await this.#turn.flushText();
35070
35059
  await running.activities.finish();
35071
35060
  let result;
35072
35061
  try {
@@ -35188,11 +35177,10 @@ var AgentSession = class _AgentSession {
35188
35177
  );
35189
35178
  } else {
35190
35179
  await this.#turn.activities.finishNarrative();
35191
- this.#turn.bufferText(update.content.text, truncate3(update.messageId ?? "", 255));
35180
+ await this.#turn.onText(update.content.text, truncate3(update.messageId ?? "", 255));
35192
35181
  }
35193
35182
  } else {
35194
35183
  await this.#turn.activities.finishNarrative();
35195
- await this.#turn.flushText();
35196
35184
  await this.emitAgentContent(
35197
35185
  normalizeContentBlock(update.content),
35198
35186
  truncate3(update.messageId ?? "", 255)
@@ -35211,7 +35199,6 @@ var AgentSession = class _AgentSession {
35211
35199
  return;
35212
35200
  }
35213
35201
  if (update.sessionUpdate === "tool_call") {
35214
- await this.#turn.recordTextAsProgress();
35215
35202
  await this.#turn.activities.recordToolCall(update);
35216
35203
  return;
35217
35204
  }
@@ -35850,7 +35837,7 @@ var AgentRuntimeManager = class {
35850
35837
  } finally {
35851
35838
  if (retained && this.#sessionIdentity === "native") {
35852
35839
  const stored = this.#store.read(sessionId);
35853
- if (stored instanceof FoundAcpStoredSession && isNativeChatSessionId(stored.session.agentId, sessionId)) {
35840
+ if (stored instanceof FoundAcpStoredSession && stored.session.nativeSessionId === sessionId && isNativeChatSessionId(stored.session.agentId, sessionId)) {
35854
35841
  this.#store.remove(sessionId);
35855
35842
  }
35856
35843
  }