@dtelecom/agents-js 0.2.2 → 0.3.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.
@@ -85,6 +85,9 @@ declare class AudioOutput {
85
85
  private _responding;
86
86
  private _stopped;
87
87
  private silenceInterval;
88
+ /** Resolves when the RTP transport is ready and initial silence has been sent. */
89
+ readonly whenReady: Promise<void>;
90
+ private _resolveReady?;
88
91
  /** When set, raw PCM from TTS is saved to this directory as WAV files for debugging. */
89
92
  dumpDir: string | null;
90
93
  private dumpCounter;
@@ -164,6 +167,19 @@ interface Message {
164
167
  role: 'system' | 'user' | 'assistant';
165
168
  content: string;
166
169
  }
170
+ interface ToolDefinition {
171
+ type: 'function';
172
+ function: {
173
+ name: string;
174
+ description: string;
175
+ parameters: Record<string, unknown>;
176
+ };
177
+ }
178
+ interface ToolCallResult {
179
+ id: string;
180
+ name: string;
181
+ arguments: string;
182
+ }
167
183
  interface LLMChunk {
168
184
  type: 'token' | 'segment' | 'tool_call' | 'done';
169
185
  token?: string;
@@ -171,10 +187,7 @@ interface LLMChunk {
171
187
  lang: string;
172
188
  text: string;
173
189
  };
174
- toolCall?: {
175
- name: string;
176
- arguments: string;
177
- };
190
+ toolCall?: ToolCallResult;
178
191
  usage?: {
179
192
  promptTokens: number;
180
193
  completionTokens: number;
@@ -183,6 +196,8 @@ interface LLMChunk {
183
196
  interface LLMChatOptions {
184
197
  /** Skip structured output (responseFormat) for this call — return plain text tokens. */
185
198
  plainText?: boolean;
199
+ /** Tool definitions to pass to the LLM for function calling. */
200
+ tools?: ToolDefinition[];
186
201
  }
187
202
  interface LLMPlugin {
188
203
  chat(messages: Message[], signal?: AbortSignal, options?: LLMChatOptions): AsyncGenerator<LLMChunk>;
@@ -226,6 +241,8 @@ interface AgentConfig {
226
241
  memory?: MemoryConfig;
227
242
  /** Max context tokens before triggering summarization (default: 5000) */
228
243
  maxContextTokens?: number;
244
+ /** Tool definitions for LLM function calling. */
245
+ tools?: ToolDefinition[];
229
246
  }
230
247
  interface AgentStartOptions {
231
248
  room: string;
@@ -260,6 +277,8 @@ interface PipelineOptions {
260
277
  memory?: RoomMemory;
261
278
  /** Max context tokens before triggering summarization (default: 5000) */
262
279
  maxContextTokens?: number;
280
+ /** Tool definitions for LLM function calling. */
281
+ tools?: ToolDefinition[];
263
282
  }
264
283
  type AgentState = 'idle' | 'listening' | 'thinking' | 'speaking';
265
284
  interface AgentEvents {
@@ -272,6 +291,8 @@ interface AgentEvents {
272
291
  response: (text: string) => void;
273
292
  /** Agent state: idle → listening (STT active) → thinking (LLM) → speaking (audio) → idle. */
274
293
  agentState: (state: AgentState) => void;
294
+ /** Emitted when the LLM invokes a tool. */
295
+ toolCall: (toolCall: ToolCallResult) => void;
275
296
  error: (error: Error) => void;
276
297
  connected: () => void;
277
298
  disconnected: (reason?: string) => void;
@@ -283,7 +304,9 @@ interface PipelineEvents {
283
304
  sentence: (text: string) => void;
284
305
  response: (text: string) => void;
285
306
  agentState: (state: AgentState) => void;
307
+ /** Emitted when the LLM invokes a tool. */
308
+ toolCall: (toolCall: ToolCallResult) => void;
286
309
  error: (error: Error) => void;
287
310
  }
288
311
 
289
- export { type AgentConfig as A, type DataMessageHandler as D, Embedder as E, type LLMPlugin as L, type Message as M, type PipelineOptions as P, type RespondMode as R, type STTStream as S, type TranscriptionResult as T, type AgentStartOptions as a, type AgentState as b, type AgentEvents as c, AudioOutput as d, type LLMChatOptions as e, type LLMChunk as f, type MemoryConfig as g, type PipelineEvents as h, type STTPlugin as i, type STTStreamOptions as j, type TTSPlugin as k, RoomMemory as l, type RoomMemoryConfig as m };
312
+ export { type AgentConfig as A, type DataMessageHandler as D, Embedder as E, type LLMPlugin as L, type Message as M, type PipelineOptions as P, type RespondMode as R, type STTStream as S, type TranscriptionResult as T, type AgentStartOptions as a, type AgentState as b, type AgentEvents as c, AudioOutput as d, type LLMChatOptions as e, type LLMChunk as f, type MemoryConfig as g, type PipelineEvents as h, type STTPlugin as i, type STTStreamOptions as j, type TTSPlugin as k, type ToolCallResult as l, type ToolDefinition as m, RoomMemory as n, type RoomMemoryConfig as o };
@@ -85,6 +85,9 @@ declare class AudioOutput {
85
85
  private _responding;
86
86
  private _stopped;
87
87
  private silenceInterval;
88
+ /** Resolves when the RTP transport is ready and initial silence has been sent. */
89
+ readonly whenReady: Promise<void>;
90
+ private _resolveReady?;
88
91
  /** When set, raw PCM from TTS is saved to this directory as WAV files for debugging. */
89
92
  dumpDir: string | null;
90
93
  private dumpCounter;
@@ -164,6 +167,19 @@ interface Message {
164
167
  role: 'system' | 'user' | 'assistant';
165
168
  content: string;
166
169
  }
170
+ interface ToolDefinition {
171
+ type: 'function';
172
+ function: {
173
+ name: string;
174
+ description: string;
175
+ parameters: Record<string, unknown>;
176
+ };
177
+ }
178
+ interface ToolCallResult {
179
+ id: string;
180
+ name: string;
181
+ arguments: string;
182
+ }
167
183
  interface LLMChunk {
168
184
  type: 'token' | 'segment' | 'tool_call' | 'done';
169
185
  token?: string;
@@ -171,10 +187,7 @@ interface LLMChunk {
171
187
  lang: string;
172
188
  text: string;
173
189
  };
174
- toolCall?: {
175
- name: string;
176
- arguments: string;
177
- };
190
+ toolCall?: ToolCallResult;
178
191
  usage?: {
179
192
  promptTokens: number;
180
193
  completionTokens: number;
@@ -183,6 +196,8 @@ interface LLMChunk {
183
196
  interface LLMChatOptions {
184
197
  /** Skip structured output (responseFormat) for this call — return plain text tokens. */
185
198
  plainText?: boolean;
199
+ /** Tool definitions to pass to the LLM for function calling. */
200
+ tools?: ToolDefinition[];
186
201
  }
187
202
  interface LLMPlugin {
188
203
  chat(messages: Message[], signal?: AbortSignal, options?: LLMChatOptions): AsyncGenerator<LLMChunk>;
@@ -226,6 +241,8 @@ interface AgentConfig {
226
241
  memory?: MemoryConfig;
227
242
  /** Max context tokens before triggering summarization (default: 5000) */
228
243
  maxContextTokens?: number;
244
+ /** Tool definitions for LLM function calling. */
245
+ tools?: ToolDefinition[];
229
246
  }
230
247
  interface AgentStartOptions {
231
248
  room: string;
@@ -260,6 +277,8 @@ interface PipelineOptions {
260
277
  memory?: RoomMemory;
261
278
  /** Max context tokens before triggering summarization (default: 5000) */
262
279
  maxContextTokens?: number;
280
+ /** Tool definitions for LLM function calling. */
281
+ tools?: ToolDefinition[];
263
282
  }
264
283
  type AgentState = 'idle' | 'listening' | 'thinking' | 'speaking';
265
284
  interface AgentEvents {
@@ -272,6 +291,8 @@ interface AgentEvents {
272
291
  response: (text: string) => void;
273
292
  /** Agent state: idle → listening (STT active) → thinking (LLM) → speaking (audio) → idle. */
274
293
  agentState: (state: AgentState) => void;
294
+ /** Emitted when the LLM invokes a tool. */
295
+ toolCall: (toolCall: ToolCallResult) => void;
275
296
  error: (error: Error) => void;
276
297
  connected: () => void;
277
298
  disconnected: (reason?: string) => void;
@@ -283,7 +304,9 @@ interface PipelineEvents {
283
304
  sentence: (text: string) => void;
284
305
  response: (text: string) => void;
285
306
  agentState: (state: AgentState) => void;
307
+ /** Emitted when the LLM invokes a tool. */
308
+ toolCall: (toolCall: ToolCallResult) => void;
286
309
  error: (error: Error) => void;
287
310
  }
288
311
 
289
- export { type AgentConfig as A, type DataMessageHandler as D, Embedder as E, type LLMPlugin as L, type Message as M, type PipelineOptions as P, type RespondMode as R, type STTStream as S, type TranscriptionResult as T, type AgentStartOptions as a, type AgentState as b, type AgentEvents as c, AudioOutput as d, type LLMChatOptions as e, type LLMChunk as f, type MemoryConfig as g, type PipelineEvents as h, type STTPlugin as i, type STTStreamOptions as j, type TTSPlugin as k, RoomMemory as l, type RoomMemoryConfig as m };
312
+ export { type AgentConfig as A, type DataMessageHandler as D, Embedder as E, type LLMPlugin as L, type Message as M, type PipelineOptions as P, type RespondMode as R, type STTStream as S, type TranscriptionResult as T, type AgentStartOptions as a, type AgentState as b, type AgentEvents as c, AudioOutput as d, type LLMChatOptions as e, type LLMChunk as f, type MemoryConfig as g, type PipelineEvents as h, type STTPlugin as i, type STTStreamOptions as j, type TTSPlugin as k, type ToolCallResult as l, type ToolDefinition as m, RoomMemory as n, type RoomMemoryConfig as o };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dtelecom/agents-js",
3
- "version": "0.2.2",
3
+ "version": "0.3.1",
4
4
  "description": "AI voice agent framework for dTelecom rooms",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",