@moxt-ai/mobius 0.0.132 → 0.0.133

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
@@ -23593,33 +23593,6 @@ var AcpActivityTracker = class {
23593
23593
  // src/acp/agent-turn.ts
23594
23594
  var SESSION_CONTROL_COMMAND_ID = "session-control";
23595
23595
  var AcpTurnState = class {
23596
- #bufferedText = [];
23597
- bufferText = (text2, messageId) => {
23598
- const previous = this.#bufferedText.at(-1);
23599
- if (previous?.messageId === messageId) {
23600
- previous.chunks.push(text2);
23601
- } else {
23602
- this.#bufferedText.push({ chunks: [text2], messageId });
23603
- }
23604
- };
23605
- flushText = async () => {
23606
- const buffered = this.#bufferedText;
23607
- this.#bufferedText = [];
23608
- for (const message of buffered) {
23609
- for (const chunk of message.chunks) {
23610
- await this.onText(chunk, message.messageId);
23611
- }
23612
- }
23613
- };
23614
- recordTextAsProgress = async () => {
23615
- const buffered = this.#bufferedText;
23616
- this.#bufferedText = [];
23617
- for (const message of buffered) {
23618
- for (const chunk of message.chunks) {
23619
- await this.activities.recordNarrative("progress", message.messageId, chunk);
23620
- }
23621
- }
23622
- };
23623
23596
  };
23624
23597
  var IdleAcpTurn = class extends AcpTurnState {
23625
23598
  commandId = SESSION_CONTROL_COMMAND_ID;
@@ -30991,7 +30964,6 @@ var AgentSession = class _AgentSession {
30991
30964
  options.signal
30992
30965
  );
30993
30966
  await this.#updates.drained();
30994
- await this.#turn.flushText();
30995
30967
  await running.activities.finish();
30996
30968
  let result;
30997
30969
  try {
@@ -31113,11 +31085,10 @@ var AgentSession = class _AgentSession {
31113
31085
  );
31114
31086
  } else {
31115
31087
  await this.#turn.activities.finishNarrative();
31116
- this.#turn.bufferText(update.content.text, truncate2(update.messageId ?? "", 255));
31088
+ await this.#turn.onText(update.content.text, truncate2(update.messageId ?? "", 255));
31117
31089
  }
31118
31090
  } else {
31119
31091
  await this.#turn.activities.finishNarrative();
31120
- await this.#turn.flushText();
31121
31092
  await this.emitAgentContent(
31122
31093
  normalizeContentBlock(update.content),
31123
31094
  truncate2(update.messageId ?? "", 255)
@@ -31136,7 +31107,6 @@ var AgentSession = class _AgentSession {
31136
31107
  return;
31137
31108
  }
31138
31109
  if (update.sessionUpdate === "tool_call") {
31139
- await this.#turn.recordTextAsProgress();
31140
31110
  await this.#turn.activities.recordToolCall(update);
31141
31111
  return;
31142
31112
  }
@@ -34081,6 +34051,7 @@ var CodexAcpAgent = class {
34081
34051
  #settings;
34082
34052
  #nativeSessionId = "";
34083
34053
  #streamedReasoningItemIds = /* @__PURE__ */ new Set();
34054
+ #streamedAgentMessageItemIds = /* @__PURE__ */ new Set();
34084
34055
  #turn = null;
34085
34056
  #nativeTurnId = null;
34086
34057
  #updateTail = Promise.resolve();
@@ -34390,6 +34361,20 @@ var CodexAcpAgent = class {
34390
34361
  }
34391
34362
  return;
34392
34363
  }
34364
+ if (method === "item/agentMessage/delta") {
34365
+ const decoded = reasoningTextDeltaParamsSchema.safeParse(params);
34366
+ if (decoded.success && decoded.data.threadId === this.#nativeSessionId && this.#turn !== null && decoded.data.turnId === this.#turn.turn.id && decoded.data.delta.length > 0) {
34367
+ this.#streamedAgentMessageItemIds.add(decoded.data.itemId);
34368
+ await this.#enqueue(async () => {
34369
+ await this.#emit({
34370
+ content: { text: decoded.data.delta, type: "text" },
34371
+ messageId: decoded.data.itemId,
34372
+ sessionUpdate: "agent_message_chunk"
34373
+ });
34374
+ });
34375
+ }
34376
+ return;
34377
+ }
34393
34378
  if (method !== "item/started" && method !== "item/completed") {
34394
34379
  return;
34395
34380
  }
@@ -34398,7 +34383,7 @@ var CodexAcpAgent = class {
34398
34383
  return;
34399
34384
  }
34400
34385
  if (item.type === "agentMessage") {
34401
- if (method === "item/started") {
34386
+ if (method === "item/started" || this.#streamedAgentMessageItemIds.delete(item.id)) {
34402
34387
  return;
34403
34388
  }
34404
34389
  await this.#enqueue(async () => {
@@ -34561,6 +34546,7 @@ var CodexAcpAgent = class {
34561
34546
  };
34562
34547
  signal.addEventListener("abort", aborted2, { once: true });
34563
34548
  const turn = { completion, turn: { id: "" } };
34549
+ this.#streamedAgentMessageItemIds.clear();
34564
34550
  this.#streamedReasoningItemIds.clear();
34565
34551
  this.#turn = turn;
34566
34552
  this.#nativeTurnId = null;
@@ -34585,6 +34571,7 @@ var CodexAcpAgent = class {
34585
34571
  signal.removeEventListener("abort", aborted2);
34586
34572
  if (this.#turn === turn) {
34587
34573
  this.#turn = null;
34574
+ this.#streamedAgentMessageItemIds.clear();
34588
34575
  this.#streamedReasoningItemIds.clear();
34589
34576
  }
34590
34577
  }