@dtelecom/agents-js 0.1.5 → 0.1.8

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.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _dtelecom_server_sdk_node from '@dtelecom/server-sdk-node';
2
2
  import { Room, AudioSource, RemoteAudioTrack, AudioFrame } from '@dtelecom/server-sdk-node';
3
3
  import { EventEmitter } from 'events';
4
- import { A as AgentConfig, a as AgentStartOptions, M as Message, L as LLMPlugin, P as PipelineOptions, b as AgentState, S as STTStream, T as TranscriptionResult } from './types-DWdkYmW8.mjs';
5
- export { c as AgentEvents, d as AudioOutput, D as DataMessageHandler, e as LLMChunk, f as MemoryConfig, g as PipelineEvents, R as RespondMode, h as STTPlugin, i as STTStreamOptions, j as TTSPlugin } from './types-DWdkYmW8.mjs';
4
+ import { A as AgentConfig, a as AgentStartOptions, M as Message, L as LLMPlugin, P as PipelineOptions, b as AgentState, S as STTStream, T as TranscriptionResult } from './types-f6SAlHpW.mjs';
5
+ export { c as AgentEvents, d as AudioOutput, D as DataMessageHandler, e as LLMChunk, f as MemoryConfig, g as PipelineEvents, R as RespondMode, h as STTPlugin, i as STTStreamOptions, j as TTSPlugin } from './types-f6SAlHpW.mjs';
6
6
 
7
7
  declare class VoiceAgent extends EventEmitter {
8
8
  private readonly config;
@@ -103,6 +103,8 @@ declare class Pipeline extends EventEmitter {
103
103
  private readonly nameVariants;
104
104
  private readonly beforeRespond?;
105
105
  private readonly memory?;
106
+ /** Strip provider-specific markup (e.g. SSML lang tags) for display. */
107
+ private cleanText;
106
108
  /** Active STT streams, keyed by participant identity */
107
109
  private sttStreams;
108
110
  private _processing;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _dtelecom_server_sdk_node from '@dtelecom/server-sdk-node';
2
2
  import { Room, AudioSource, RemoteAudioTrack, AudioFrame } from '@dtelecom/server-sdk-node';
3
3
  import { EventEmitter } from 'events';
4
- import { A as AgentConfig, a as AgentStartOptions, M as Message, L as LLMPlugin, P as PipelineOptions, b as AgentState, S as STTStream, T as TranscriptionResult } from './types-DWdkYmW8.js';
5
- export { c as AgentEvents, d as AudioOutput, D as DataMessageHandler, e as LLMChunk, f as MemoryConfig, g as PipelineEvents, R as RespondMode, h as STTPlugin, i as STTStreamOptions, j as TTSPlugin } from './types-DWdkYmW8.js';
4
+ import { A as AgentConfig, a as AgentStartOptions, M as Message, L as LLMPlugin, P as PipelineOptions, b as AgentState, S as STTStream, T as TranscriptionResult } from './types-f6SAlHpW.js';
5
+ export { c as AgentEvents, d as AudioOutput, D as DataMessageHandler, e as LLMChunk, f as MemoryConfig, g as PipelineEvents, R as RespondMode, h as STTPlugin, i as STTStreamOptions, j as TTSPlugin } from './types-f6SAlHpW.js';
6
6
 
7
7
  declare class VoiceAgent extends EventEmitter {
8
8
  private readonly config;
@@ -103,6 +103,8 @@ declare class Pipeline extends EventEmitter {
103
103
  private readonly nameVariants;
104
104
  private readonly beforeRespond?;
105
105
  private readonly memory?;
106
+ /** Strip provider-specific markup (e.g. SSML lang tags) for display. */
107
+ private cleanText;
106
108
  /** Active STT streams, keyed by participant identity */
107
109
  private sttStreams;
108
110
  private _processing;
package/dist/index.js CHANGED
@@ -1156,6 +1156,10 @@ var Pipeline = class extends import_events.EventEmitter {
1156
1156
  nameVariants;
1157
1157
  beforeRespond;
1158
1158
  memory;
1159
+ /** Strip provider-specific markup (e.g. SSML lang tags) for display. */
1160
+ cleanText(text) {
1161
+ return this.tts?.cleanText ? this.tts.cleanText(text) : text;
1162
+ }
1159
1163
  /** Active STT streams, keyed by participant identity */
1160
1164
  sttStreams = /* @__PURE__ */ new Map();
1161
1165
  _processing = false;
@@ -1404,12 +1408,16 @@ var Pipeline = class extends import_events.EventEmitter {
1404
1408
  log7.debug(`Skipping non-word sentence: "${sentence}"`);
1405
1409
  continue;
1406
1410
  }
1407
- await this.synthesizeAndPlay(sentence, signal, (t) => {
1411
+ let processed = sentence;
1412
+ if (this.tts?.preprocessText) {
1413
+ processed = await this.tts.preprocessText(sentence, signal);
1414
+ }
1415
+ await this.synthesizeAndPlay(processed, signal, (t) => {
1408
1416
  if (!tFirstAudioPlayed) {
1409
1417
  tFirstAudioPlayed = t;
1410
1418
  this.setAgentState("speaking");
1411
1419
  }
1412
- this.emit("sentence", sentence);
1420
+ this.emit("sentence", this.cleanText(processed));
1413
1421
  });
1414
1422
  continue;
1415
1423
  }
@@ -1437,7 +1445,7 @@ var Pipeline = class extends import_events.EventEmitter {
1437
1445
  if (fullResponse.trim()) {
1438
1446
  this.context.addAgentTurn(fullResponse.trim());
1439
1447
  this.memory?.storeTurn("assistant", fullResponse.trim(), true);
1440
- this.emit("response", fullResponse.trim());
1448
+ this.emit("response", this.cleanText(fullResponse.trim()));
1441
1449
  }
1442
1450
  await sleep2(AUDIO_DRAIN_MS);
1443
1451
  this.setAgentState("idle");
@@ -1476,15 +1484,19 @@ var Pipeline = class extends import_events.EventEmitter {
1476
1484
  const signal = this.bargeIn.startCycle();
1477
1485
  this.audioOutput.beginResponse();
1478
1486
  this.setAgentState("thinking");
1479
- await this.synthesizeAndPlay(text, signal, () => {
1487
+ let processed = text;
1488
+ if (this.tts?.preprocessText) {
1489
+ processed = await this.tts.preprocessText(text, signal);
1490
+ }
1491
+ await this.synthesizeAndPlay(processed, signal, () => {
1480
1492
  this.setAgentState("speaking");
1481
- this.emit("sentence", text);
1493
+ this.emit("sentence", this.cleanText(processed));
1482
1494
  });
1483
1495
  if (!signal.aborted) {
1484
1496
  await this.audioOutput.writeSilence(40);
1485
1497
  this.context.addAgentTurn(text);
1486
1498
  this.memory?.storeTurn("assistant", text, true);
1487
- this.emit("response", text);
1499
+ this.emit("response", this.cleanText(processed));
1488
1500
  }
1489
1501
  await sleep2(AUDIO_DRAIN_MS);
1490
1502
  this.setAgentState("idle");