@dtelecom/agents-js 0.1.17 → 0.2.1

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-AWgTLEQ-.mjs';
5
- export { c as AgentEvents, d as AudioOutput, D as DataMessageHandler, e as LLMChatOptions, f as LLMChunk, g as MemoryConfig, h as PipelineEvents, R as RespondMode, i as STTPlugin, j as STTStreamOptions, k as TTSPlugin } from './types-AWgTLEQ-.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-BBKtiPvm.mjs';
5
+ export { c as AgentEvents, d as AudioOutput, D as DataMessageHandler, e as LLMChatOptions, f as LLMChunk, g as MemoryConfig, h as PipelineEvents, R as RespondMode, i as STTPlugin, j as STTStreamOptions, k as TTSPlugin } from './types-BBKtiPvm.mjs';
6
6
 
7
7
  declare class VoiceAgent extends EventEmitter {
8
8
  private readonly config;
@@ -233,10 +233,12 @@ declare abstract class BaseSTTStream extends EventEmitter implements STTStream {
233
233
 
234
234
  interface RoomConnectionOptions {
235
235
  room: string;
236
- apiKey: string;
237
- apiSecret: string;
238
236
  identity?: string;
239
237
  name?: string;
238
+ apiKey?: string;
239
+ apiSecret?: string;
240
+ token?: string;
241
+ wsUrl?: string;
240
242
  }
241
243
  declare class RoomConnection {
242
244
  readonly room: Room;
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-AWgTLEQ-.js';
5
- export { c as AgentEvents, d as AudioOutput, D as DataMessageHandler, e as LLMChatOptions, f as LLMChunk, g as MemoryConfig, h as PipelineEvents, R as RespondMode, i as STTPlugin, j as STTStreamOptions, k as TTSPlugin } from './types-AWgTLEQ-.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-BBKtiPvm.js';
5
+ export { c as AgentEvents, d as AudioOutput, D as DataMessageHandler, e as LLMChatOptions, f as LLMChunk, g as MemoryConfig, h as PipelineEvents, R as RespondMode, i as STTPlugin, j as STTStreamOptions, k as TTSPlugin } from './types-BBKtiPvm.js';
6
6
 
7
7
  declare class VoiceAgent extends EventEmitter {
8
8
  private readonly config;
@@ -233,10 +233,12 @@ declare abstract class BaseSTTStream extends EventEmitter implements STTStream {
233
233
 
234
234
  interface RoomConnectionOptions {
235
235
  room: string;
236
- apiKey: string;
237
- apiSecret: string;
238
236
  identity?: string;
239
237
  name?: string;
238
+ apiKey?: string;
239
+ apiSecret?: string;
240
+ token?: string;
241
+ wsUrl?: string;
240
242
  }
241
243
  declare class RoomConnection {
242
244
  readonly room: Room;
package/dist/index.js CHANGED
@@ -557,22 +557,31 @@ var RoomConnection = class {
557
557
  * 4. Publish an audio track for the agent to speak through
558
558
  */
559
559
  async connect(options) {
560
- const { room: roomName, apiKey, apiSecret, identity = "agent", name } = options;
560
+ const { room: roomName, identity = "agent", name } = options;
561
561
  log.info(`Connecting to room "${roomName}" as "${identity}"...`);
562
- const { AccessToken } = await import("@dtelecom/server-sdk-js");
563
- const token = new AccessToken(apiKey, apiSecret, {
564
- identity,
565
- name: name ?? identity
566
- });
567
- token.addGrant({
568
- roomJoin: true,
569
- room: roomName,
570
- canPublish: true,
571
- canSubscribe: true,
572
- canPublishData: true
573
- });
574
- const wsUrl = await token.getWsUrl();
575
- const jwt = token.toJwt();
562
+ let jwt;
563
+ let wsUrl;
564
+ if (options.token && options.wsUrl) {
565
+ jwt = options.token;
566
+ wsUrl = options.wsUrl;
567
+ } else if (options.apiKey && options.apiSecret) {
568
+ const { AccessToken } = await import("@dtelecom/server-sdk-js");
569
+ const token = new AccessToken(options.apiKey, options.apiSecret, {
570
+ identity,
571
+ name: name ?? identity
572
+ });
573
+ token.addGrant({
574
+ roomJoin: true,
575
+ room: roomName,
576
+ canPublish: true,
577
+ canSubscribe: true,
578
+ canPublishData: true
579
+ });
580
+ wsUrl = await token.getWsUrl();
581
+ jwt = token.toJwt();
582
+ } else {
583
+ throw new Error("Either (apiKey + apiSecret) or (token + wsUrl) must be provided");
584
+ }
576
585
  log.info(`SFU URL: ${wsUrl}`);
577
586
  await this.room.connect(wsUrl, jwt, { autoSubscribe: true });
578
587
  this._connected = true;
@@ -1653,6 +1662,8 @@ var VoiceAgent = class extends import_events2.EventEmitter {
1653
1662
  room: options.room,
1654
1663
  apiKey: options.apiKey,
1655
1664
  apiSecret: options.apiSecret,
1665
+ token: options.token,
1666
+ wsUrl: options.wsUrl,
1656
1667
  identity: options.identity ?? "agent",
1657
1668
  name: options.name ?? options.identity ?? "AI Agent"
1658
1669
  });