@moxt-ai/mobius 0.0.46 → 0.0.47

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
@@ -31676,7 +31676,7 @@ var AcpProcessSession = class _AcpProcessSession {
31676
31676
  #preSessionUpdateBytes = 0;
31677
31677
  #agentName = "";
31678
31678
  #agentVersion = "";
31679
- #bufferedAgentText = null;
31679
+ #bufferedAgentText = [];
31680
31680
  #capabilities = {
31681
31681
  additionalDirectories: false,
31682
31682
  audioPrompt: false,
@@ -31865,20 +31865,30 @@ var AcpProcessSession = class _AcpProcessSession {
31865
31865
  });
31866
31866
  };
31867
31867
  bufferAgentText = async (text3, messageId) => {
31868
- if (this.#bufferedAgentText !== null && this.#bufferedAgentText.messageId !== messageId) {
31869
- await this.emitAgentMessage(this.#bufferedAgentText.chunks, this.#bufferedAgentText.messageId);
31870
- this.#bufferedAgentText = null;
31868
+ const previous2 = this.#bufferedAgentText.at(-1);
31869
+ if (previous2?.messageId === messageId) {
31870
+ this.#bufferedAgentText = [
31871
+ ...this.#bufferedAgentText.slice(0, -1),
31872
+ { chunks: [...previous2.chunks, text3], messageId }
31873
+ ];
31874
+ return;
31871
31875
  }
31872
- this.#bufferedAgentText = {
31873
- chunks: [...this.#bufferedAgentText?.chunks ?? [], text3],
31874
- messageId
31875
- };
31876
+ this.#bufferedAgentText = [...this.#bufferedAgentText, { chunks: [text3], messageId }];
31876
31877
  };
31877
31878
  flushAgentText = async () => {
31878
31879
  const buffered = this.#bufferedAgentText;
31879
- this.#bufferedAgentText = null;
31880
- if (buffered !== null) {
31881
- await this.emitAgentMessage(buffered.chunks, buffered.messageId);
31880
+ this.#bufferedAgentText = [];
31881
+ for (const message of buffered) {
31882
+ await this.emitAgentMessage(message.chunks, message.messageId);
31883
+ }
31884
+ };
31885
+ recordBufferedAgentTextAsProgress = async () => {
31886
+ const buffered = this.#bufferedAgentText;
31887
+ this.#bufferedAgentText = [];
31888
+ for (const message of buffered) {
31889
+ for (const chunk of message.chunks) {
31890
+ await this.#turn.activities.recordNarrative("progress", message.messageId, chunk);
31891
+ }
31882
31892
  }
31883
31893
  };
31884
31894
  prepareAgentContent = async (content3) => {
@@ -32392,7 +32402,7 @@ var AcpProcessSession = class _AcpProcessSession {
32392
32402
  cause: error62
32393
32403
  });
32394
32404
  } finally {
32395
- this.#bufferedAgentText = null;
32405
+ this.#bufferedAgentText = [];
32396
32406
  this.#turn = new IdleAcpTurn();
32397
32407
  }
32398
32408
  };
@@ -32707,6 +32717,7 @@ var AcpProcessSession = class _AcpProcessSession {
32707
32717
  return;
32708
32718
  }
32709
32719
  if (update.sessionUpdate === "tool_call") {
32720
+ await this.recordBufferedAgentTextAsProgress();
32710
32721
  await this.#turn.activities.recordToolCall(update);
32711
32722
  return;
32712
32723
  }