@dtelecom/agents-js 0.1.1 → 0.1.4
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 +6 -69
- package/dist/index.d.ts +6 -69
- package/dist/index.js +22 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -16
- package/dist/index.mjs.map +1 -1
- package/dist/memory/index.d.mts +70 -0
- package/dist/memory/index.d.ts +70 -0
- package/dist/memory/index.js +486 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/index.mjs +12 -0
- package/dist/memory/index.mjs.map +1 -0
- package/dist/providers/index.d.mts +1 -1
- package/dist/providers/index.d.ts +1 -1
- package/dist/{types-Cs5uUoTC.d.mts → types-EvtHMokR.d.mts} +1 -1
- package/dist/{types-Cs5uUoTC.d.ts → types-EvtHMokR.d.ts} +1 -1
- package/package.json +6 -1
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-
|
|
5
|
-
export { c as AgentEvents, d as AudioOutput, D as DataMessageHandler,
|
|
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-EvtHMokR.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-EvtHMokR.mjs';
|
|
6
6
|
|
|
7
7
|
declare class VoiceAgent extends EventEmitter {
|
|
8
8
|
private readonly config;
|
|
@@ -111,6 +111,9 @@ declare class Pipeline extends EventEmitter {
|
|
|
111
111
|
/** Queued turn while current one is still processing */
|
|
112
112
|
private pendingTurn;
|
|
113
113
|
constructor(options: PipelineOptions);
|
|
114
|
+
/** One-shot warmup — safe to call from constructor, resolves when both LLM and TTS are ready. */
|
|
115
|
+
private _warmupPromise;
|
|
116
|
+
private warmup;
|
|
114
117
|
get processing(): boolean;
|
|
115
118
|
get running(): boolean;
|
|
116
119
|
get agentState(): AgentState;
|
|
@@ -263,72 +266,6 @@ declare class AudioInput {
|
|
|
263
266
|
close(): void;
|
|
264
267
|
}
|
|
265
268
|
|
|
266
|
-
/**
|
|
267
|
-
* MemoryStore — SQLite + sqlite-vec database layer for room memory.
|
|
268
|
-
*
|
|
269
|
-
* Single .db file stores:
|
|
270
|
-
* - turns: every spoken turn (full transcript)
|
|
271
|
-
* - sessions: meeting metadata + LLM-generated summaries
|
|
272
|
-
* - turn_vectors: embedding index for semantic turn search
|
|
273
|
-
* - session_vectors: embedding index for session summary search
|
|
274
|
-
*/
|
|
275
|
-
interface TurnRow {
|
|
276
|
-
id: number;
|
|
277
|
-
room: string;
|
|
278
|
-
session_id: string;
|
|
279
|
-
speaker: string;
|
|
280
|
-
text: string;
|
|
281
|
-
is_agent: number;
|
|
282
|
-
created_at: number;
|
|
283
|
-
}
|
|
284
|
-
interface SessionRow {
|
|
285
|
-
id: string;
|
|
286
|
-
room: string;
|
|
287
|
-
started_at: number;
|
|
288
|
-
ended_at: number | null;
|
|
289
|
-
participants: string | null;
|
|
290
|
-
summary: string | null;
|
|
291
|
-
turn_count: number;
|
|
292
|
-
}
|
|
293
|
-
interface SearchResult {
|
|
294
|
-
speaker: string;
|
|
295
|
-
text: string;
|
|
296
|
-
created_at: number;
|
|
297
|
-
session_id: string;
|
|
298
|
-
distance: number;
|
|
299
|
-
}
|
|
300
|
-
interface SessionSearchResult {
|
|
301
|
-
session_id: string;
|
|
302
|
-
summary: string;
|
|
303
|
-
started_at: number;
|
|
304
|
-
distance: number;
|
|
305
|
-
}
|
|
306
|
-
declare class MemoryStore {
|
|
307
|
-
private db;
|
|
308
|
-
constructor(dbPath: string);
|
|
309
|
-
private createTables;
|
|
310
|
-
/** Insert a turn and its embedding vector. */
|
|
311
|
-
insertTurn(room: string, sessionId: string, speaker: string, text: string, isAgent: boolean, embedding: Float32Array): number;
|
|
312
|
-
/** Create a new session record. */
|
|
313
|
-
insertSession(id: string, room: string): void;
|
|
314
|
-
/** Update a session with summary and end time. */
|
|
315
|
-
updateSessionSummary(sessionId: string, summary: string, turnCount: number, participants: string[], embedding: Float32Array): void;
|
|
316
|
-
/** End a session without summary (e.g., too few turns). */
|
|
317
|
-
endSession(sessionId: string, turnCount: number, participants: string[]): void;
|
|
318
|
-
/** KNN search turns by embedding similarity. */
|
|
319
|
-
searchTurns(room: string, queryEmbedding: Float32Array, limit: number): SearchResult[];
|
|
320
|
-
/** KNN search session summaries by embedding similarity. */
|
|
321
|
-
searchSessions(room: string, queryEmbedding: Float32Array, limit: number): SessionSearchResult[];
|
|
322
|
-
/** Get the last N turns from a specific session. */
|
|
323
|
-
getRecentTurns(room: string, sessionId: string, limit: number): TurnRow[];
|
|
324
|
-
/** Get all turns for a session (for summarization). */
|
|
325
|
-
getSessionTurns(sessionId: string): TurnRow[];
|
|
326
|
-
/** Get total turn count for a session. */
|
|
327
|
-
getSessionTurnCount(sessionId: string): number;
|
|
328
|
-
/** Close the database. */
|
|
329
|
-
close(): void;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
269
|
type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
333
270
|
declare function setLogLevel(level: LogLevel): void;
|
|
334
271
|
declare function getLogLevel(): LogLevel;
|
|
@@ -340,4 +277,4 @@ interface Logger {
|
|
|
340
277
|
}
|
|
341
278
|
declare function createLogger(tag: string): Logger;
|
|
342
279
|
|
|
343
|
-
export { AgentConfig, AgentStartOptions, AgentState, AudioInput, BargeIn, BaseSTTStream, ContextManager, type ContextManagerOptions, LLMPlugin, type LogLevel, type Logger,
|
|
280
|
+
export { AgentConfig, AgentStartOptions, AgentState, AudioInput, BargeIn, BaseSTTStream, ContextManager, type ContextManagerOptions, LLMPlugin, type LogLevel, type Logger, Message, Pipeline, PipelineOptions, RoomConnection, type RoomConnectionOptions, STTStream, SentenceSplitter, TranscriptionResult, TurnDetector, type TurnDetectorOptions, VoiceAgent, createLogger, getLogLevel, setLogLevel };
|
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-
|
|
5
|
-
export { c as AgentEvents, d as AudioOutput, D as DataMessageHandler,
|
|
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-EvtHMokR.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-EvtHMokR.js';
|
|
6
6
|
|
|
7
7
|
declare class VoiceAgent extends EventEmitter {
|
|
8
8
|
private readonly config;
|
|
@@ -111,6 +111,9 @@ declare class Pipeline extends EventEmitter {
|
|
|
111
111
|
/** Queued turn while current one is still processing */
|
|
112
112
|
private pendingTurn;
|
|
113
113
|
constructor(options: PipelineOptions);
|
|
114
|
+
/** One-shot warmup — safe to call from constructor, resolves when both LLM and TTS are ready. */
|
|
115
|
+
private _warmupPromise;
|
|
116
|
+
private warmup;
|
|
114
117
|
get processing(): boolean;
|
|
115
118
|
get running(): boolean;
|
|
116
119
|
get agentState(): AgentState;
|
|
@@ -263,72 +266,6 @@ declare class AudioInput {
|
|
|
263
266
|
close(): void;
|
|
264
267
|
}
|
|
265
268
|
|
|
266
|
-
/**
|
|
267
|
-
* MemoryStore — SQLite + sqlite-vec database layer for room memory.
|
|
268
|
-
*
|
|
269
|
-
* Single .db file stores:
|
|
270
|
-
* - turns: every spoken turn (full transcript)
|
|
271
|
-
* - sessions: meeting metadata + LLM-generated summaries
|
|
272
|
-
* - turn_vectors: embedding index for semantic turn search
|
|
273
|
-
* - session_vectors: embedding index for session summary search
|
|
274
|
-
*/
|
|
275
|
-
interface TurnRow {
|
|
276
|
-
id: number;
|
|
277
|
-
room: string;
|
|
278
|
-
session_id: string;
|
|
279
|
-
speaker: string;
|
|
280
|
-
text: string;
|
|
281
|
-
is_agent: number;
|
|
282
|
-
created_at: number;
|
|
283
|
-
}
|
|
284
|
-
interface SessionRow {
|
|
285
|
-
id: string;
|
|
286
|
-
room: string;
|
|
287
|
-
started_at: number;
|
|
288
|
-
ended_at: number | null;
|
|
289
|
-
participants: string | null;
|
|
290
|
-
summary: string | null;
|
|
291
|
-
turn_count: number;
|
|
292
|
-
}
|
|
293
|
-
interface SearchResult {
|
|
294
|
-
speaker: string;
|
|
295
|
-
text: string;
|
|
296
|
-
created_at: number;
|
|
297
|
-
session_id: string;
|
|
298
|
-
distance: number;
|
|
299
|
-
}
|
|
300
|
-
interface SessionSearchResult {
|
|
301
|
-
session_id: string;
|
|
302
|
-
summary: string;
|
|
303
|
-
started_at: number;
|
|
304
|
-
distance: number;
|
|
305
|
-
}
|
|
306
|
-
declare class MemoryStore {
|
|
307
|
-
private db;
|
|
308
|
-
constructor(dbPath: string);
|
|
309
|
-
private createTables;
|
|
310
|
-
/** Insert a turn and its embedding vector. */
|
|
311
|
-
insertTurn(room: string, sessionId: string, speaker: string, text: string, isAgent: boolean, embedding: Float32Array): number;
|
|
312
|
-
/** Create a new session record. */
|
|
313
|
-
insertSession(id: string, room: string): void;
|
|
314
|
-
/** Update a session with summary and end time. */
|
|
315
|
-
updateSessionSummary(sessionId: string, summary: string, turnCount: number, participants: string[], embedding: Float32Array): void;
|
|
316
|
-
/** End a session without summary (e.g., too few turns). */
|
|
317
|
-
endSession(sessionId: string, turnCount: number, participants: string[]): void;
|
|
318
|
-
/** KNN search turns by embedding similarity. */
|
|
319
|
-
searchTurns(room: string, queryEmbedding: Float32Array, limit: number): SearchResult[];
|
|
320
|
-
/** KNN search session summaries by embedding similarity. */
|
|
321
|
-
searchSessions(room: string, queryEmbedding: Float32Array, limit: number): SessionSearchResult[];
|
|
322
|
-
/** Get the last N turns from a specific session. */
|
|
323
|
-
getRecentTurns(room: string, sessionId: string, limit: number): TurnRow[];
|
|
324
|
-
/** Get all turns for a session (for summarization). */
|
|
325
|
-
getSessionTurns(sessionId: string): TurnRow[];
|
|
326
|
-
/** Get total turn count for a session. */
|
|
327
|
-
getSessionTurnCount(sessionId: string): number;
|
|
328
|
-
/** Close the database. */
|
|
329
|
-
close(): void;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
269
|
type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
333
270
|
declare function setLogLevel(level: LogLevel): void;
|
|
334
271
|
declare function getLogLevel(): LogLevel;
|
|
@@ -340,4 +277,4 @@ interface Logger {
|
|
|
340
277
|
}
|
|
341
278
|
declare function createLogger(tag: string): Logger;
|
|
342
279
|
|
|
343
|
-
export { AgentConfig, AgentStartOptions, AgentState, AudioInput, BargeIn, BaseSTTStream, ContextManager, type ContextManagerOptions, LLMPlugin, type LogLevel, type Logger,
|
|
280
|
+
export { AgentConfig, AgentStartOptions, AgentState, AudioInput, BargeIn, BaseSTTStream, ContextManager, type ContextManagerOptions, LLMPlugin, type LogLevel, type Logger, Message, Pipeline, PipelineOptions, RoomConnection, type RoomConnectionOptions, STTStream, SentenceSplitter, TranscriptionResult, TurnDetector, type TurnDetectorOptions, VoiceAgent, createLogger, getLogLevel, setLogLevel };
|
package/dist/index.js
CHANGED
|
@@ -519,11 +519,8 @@ __export(src_exports, {
|
|
|
519
519
|
BargeIn: () => BargeIn,
|
|
520
520
|
BaseSTTStream: () => BaseSTTStream,
|
|
521
521
|
ContextManager: () => ContextManager,
|
|
522
|
-
Embedder: () => Embedder,
|
|
523
|
-
MemoryStore: () => MemoryStore,
|
|
524
522
|
Pipeline: () => Pipeline,
|
|
525
523
|
RoomConnection: () => RoomConnection,
|
|
526
|
-
RoomMemory: () => RoomMemory,
|
|
527
524
|
SentenceSplitter: () => SentenceSplitter,
|
|
528
525
|
TurnDetector: () => TurnDetector,
|
|
529
526
|
VoiceAgent: () => VoiceAgent,
|
|
@@ -705,6 +702,9 @@ var AudioOutput = class {
|
|
|
705
702
|
startSilence() {
|
|
706
703
|
if (this.silenceInterval) return;
|
|
707
704
|
log3.debug("Starting silence keepalive (sparse, 3s interval)");
|
|
705
|
+
const immediate = new import_server_sdk_node2.AudioFrame(SILENCE, SAMPLE_RATE, CHANNELS, SAMPLES_PER_FRAME);
|
|
706
|
+
this.source.captureFrame(immediate).catch(() => {
|
|
707
|
+
});
|
|
708
708
|
this.silenceInterval = setInterval(() => {
|
|
709
709
|
if (!this._playing && !this._responding && !this._stopped) {
|
|
710
710
|
const f = new import_server_sdk_node2.AudioFrame(SILENCE, SAMPLE_RATE, CHANNELS, SAMPLES_PER_FRAME);
|
|
@@ -1176,16 +1176,27 @@ var Pipeline = class extends import_events.EventEmitter {
|
|
|
1176
1176
|
this.splitter.reset();
|
|
1177
1177
|
this.setAgentState("idle");
|
|
1178
1178
|
};
|
|
1179
|
+
this._warmupPromise = this.warmup(options.instructions);
|
|
1180
|
+
}
|
|
1181
|
+
/** One-shot warmup — safe to call from constructor, resolves when both LLM and TTS are ready. */
|
|
1182
|
+
_warmupPromise;
|
|
1183
|
+
async warmup(instructions) {
|
|
1184
|
+
const tasks = [];
|
|
1179
1185
|
if (this.llm.warmup) {
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1186
|
+
tasks.push(
|
|
1187
|
+
this.llm.warmup(instructions).catch((err) => {
|
|
1188
|
+
log7.warn("LLM warmup failed:", err);
|
|
1189
|
+
})
|
|
1190
|
+
);
|
|
1183
1191
|
}
|
|
1184
1192
|
if (this.tts?.warmup) {
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1193
|
+
tasks.push(
|
|
1194
|
+
this.tts.warmup().catch((err) => {
|
|
1195
|
+
log7.warn("TTS warmup failed:", err);
|
|
1196
|
+
})
|
|
1197
|
+
);
|
|
1188
1198
|
}
|
|
1199
|
+
await Promise.all(tasks);
|
|
1189
1200
|
}
|
|
1190
1201
|
get processing() {
|
|
1191
1202
|
return this._processing;
|
|
@@ -1292,6 +1303,7 @@ var Pipeline = class extends import_events.EventEmitter {
|
|
|
1292
1303
|
return;
|
|
1293
1304
|
}
|
|
1294
1305
|
this._processing = true;
|
|
1306
|
+
await this._warmupPromise;
|
|
1295
1307
|
const tSpeechEnd = this.lastFinalAt;
|
|
1296
1308
|
const sttDuration = this.lastSttDuration;
|
|
1297
1309
|
let tLlmFirstToken = 0;
|
|
@@ -1445,6 +1457,7 @@ var Pipeline = class extends import_events.EventEmitter {
|
|
|
1445
1457
|
return;
|
|
1446
1458
|
}
|
|
1447
1459
|
this._processing = true;
|
|
1460
|
+
await this._warmupPromise;
|
|
1448
1461
|
log7.info(`say(): "${text.slice(0, 60)}"`);
|
|
1449
1462
|
try {
|
|
1450
1463
|
const signal = this.bargeIn.startCycle();
|
|
@@ -1724,9 +1737,6 @@ var BaseSTTStream = class extends import_events3.EventEmitter {
|
|
|
1724
1737
|
};
|
|
1725
1738
|
|
|
1726
1739
|
// src/index.ts
|
|
1727
|
-
init_embedder();
|
|
1728
|
-
init_memory_store();
|
|
1729
|
-
init_room_memory();
|
|
1730
1740
|
init_logger();
|
|
1731
1741
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1732
1742
|
0 && (module.exports = {
|
|
@@ -1735,11 +1745,8 @@ init_logger();
|
|
|
1735
1745
|
BargeIn,
|
|
1736
1746
|
BaseSTTStream,
|
|
1737
1747
|
ContextManager,
|
|
1738
|
-
Embedder,
|
|
1739
|
-
MemoryStore,
|
|
1740
1748
|
Pipeline,
|
|
1741
1749
|
RoomConnection,
|
|
1742
|
-
RoomMemory,
|
|
1743
1750
|
SentenceSplitter,
|
|
1744
1751
|
TurnDetector,
|
|
1745
1752
|
VoiceAgent,
|