@charivo/realtime 0.8.1 → 0.8.3

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.
@@ -400,7 +400,7 @@ var OpenAIRealtimeAgentsClient = class {
400
400
  isCleaningUp = false;
401
401
  assistant = { text: "", started: false };
402
402
  assistantCompletionMetadata = {};
403
- latestHistory = [];
403
+ latestAssistantText = "";
404
404
  currentSessionConfig;
405
405
  teardownTransportLifecycle;
406
406
  iceDisconnectDebouncer = createIceDisconnectDebouncer(() => {
@@ -557,7 +557,7 @@ var OpenAIRealtimeAgentsClient = class {
557
557
  this.emitEvent({ type: "audio.output.ended" });
558
558
  });
559
559
  session.on("history_updated", (history) => {
560
- this.latestHistory = history;
560
+ this.latestAssistantText = this.extractLatestAssistantText(history);
561
561
  });
562
562
  session.on("error", ({ error }) => {
563
563
  this.emitEvent({
@@ -622,7 +622,7 @@ var OpenAIRealtimeAgentsClient = class {
622
622
  if (!this.assistant.text && !output.trim()) {
623
623
  return;
624
624
  }
625
- const finalText = this.getLatestAssistantText() || output || this.assistant.text;
625
+ const finalText = this.latestAssistantText || output || this.assistant.text;
626
626
  this.ensureAssistantStarted();
627
627
  if (finalText && finalText.startsWith(this.assistant.text) && finalText !== this.assistant.text) {
628
628
  const delta = finalText.slice(this.assistant.text.length);
@@ -640,9 +640,9 @@ var OpenAIRealtimeAgentsClient = class {
640
640
  });
641
641
  this.resetAssistantTracking();
642
642
  }
643
- getLatestAssistantText() {
644
- for (let index = this.latestHistory.length - 1; index >= 0; index -= 1) {
645
- const item = this.latestHistory[index];
643
+ extractLatestAssistantText(history) {
644
+ for (let index = history.length - 1; index >= 0; index -= 1) {
645
+ const item = history[index];
646
646
  if (item.type === "message" && item.role === "assistant" && Array.isArray(item.content)) {
647
647
  const text = item.content.map((content) => {
648
648
  if (content.type === "output_audio") {
@@ -844,7 +844,7 @@ var OpenAIRealtimeAgentsClient = class {
844
844
  }
845
845
  this.peerConnection = null;
846
846
  this.audioSender = null;
847
- this.latestHistory = [];
847
+ this.latestAssistantText = "";
848
848
  this.connectionLossNotified = false;
849
849
  this.isCleaningUp = false;
850
850
  this.resetAssistantTracking();