felona-voice 0.1.0
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/agent.d.ts +105 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +287 -0
- package/dist/agent.js.map +1 -0
- package/dist/analytics/index.d.ts +3 -0
- package/dist/analytics/index.d.ts.map +1 -0
- package/dist/analytics/index.js +2 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/analytics/logger.d.ts +92 -0
- package/dist/analytics/logger.d.ts.map +1 -0
- package/dist/analytics/logger.js +75 -0
- package/dist/analytics/logger.js.map +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/jev/action-space.d.ts +38 -0
- package/dist/jev/action-space.d.ts.map +1 -0
- package/dist/jev/action-space.js +92 -0
- package/dist/jev/action-space.js.map +1 -0
- package/dist/jev/embeddings.d.ts +23 -0
- package/dist/jev/embeddings.d.ts.map +1 -0
- package/dist/jev/embeddings.js +63 -0
- package/dist/jev/embeddings.js.map +1 -0
- package/dist/jev/engine.d.ts +101 -0
- package/dist/jev/engine.d.ts.map +1 -0
- package/dist/jev/engine.js +173 -0
- package/dist/jev/engine.js.map +1 -0
- package/dist/jev/index.d.ts +4 -0
- package/dist/jev/index.d.ts.map +1 -0
- package/dist/jev/index.js +4 -0
- package/dist/jev/index.js.map +1 -0
- package/dist/llm/index.d.ts +2 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +2 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/openai.d.ts +22 -0
- package/dist/llm/openai.d.ts.map +1 -0
- package/dist/llm/openai.js +140 -0
- package/dist/llm/openai.js.map +1 -0
- package/dist/memory/context.d.ts +53 -0
- package/dist/memory/context.d.ts.map +1 -0
- package/dist/memory/context.js +95 -0
- package/dist/memory/context.js.map +1 -0
- package/dist/memory/index.d.ts +2 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +2 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/pipeline.d.ts +93 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +255 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/stt/deepgram.d.ts +27 -0
- package/dist/stt/deepgram.d.ts.map +1 -0
- package/dist/stt/deepgram.js +137 -0
- package/dist/stt/deepgram.js.map +1 -0
- package/dist/stt/index.d.ts +2 -0
- package/dist/stt/index.d.ts.map +1 -0
- package/dist/stt/index.js +2 -0
- package/dist/stt/index.js.map +1 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +2 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/registry.d.ts +38 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +77 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/transport/index.d.ts +2 -0
- package/dist/transport/index.d.ts.map +1 -0
- package/dist/transport/index.js +2 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/transport/websocket.d.ts +38 -0
- package/dist/transport/websocket.d.ts.map +1 -0
- package/dist/transport/websocket.js +180 -0
- package/dist/transport/websocket.js.map +1 -0
- package/dist/tts/eleven-labs.d.ts +27 -0
- package/dist/tts/eleven-labs.d.ts.map +1 -0
- package/dist/tts/eleven-labs.js +73 -0
- package/dist/tts/eleven-labs.js.map +1 -0
- package/dist/tts/index.d.ts +2 -0
- package/dist/tts/index.d.ts.map +1 -0
- package/dist/tts/index.js +2 -0
- package/dist/tts/index.js.map +1 -0
- package/dist/types.d.ts +370 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/dist/vad/energy.d.ts +49 -0
- package/dist/vad/energy.d.ts.map +1 -0
- package/dist/vad/energy.js +108 -0
- package/dist/vad/energy.js.map +1 -0
- package/dist/vad/index.d.ts +2 -0
- package/dist/vad/index.d.ts.map +1 -0
- package/dist/vad/index.js +2 -0
- package/dist/vad/index.js.map +1 -0
- package/package.json +51 -0
- package/src/agent.ts +373 -0
- package/src/analytics/index.ts +7 -0
- package/src/analytics/logger.ts +152 -0
- package/src/index.ts +121 -0
- package/src/jev/action-space.ts +119 -0
- package/src/jev/embeddings.ts +81 -0
- package/src/jev/engine.ts +225 -0
- package/src/jev/index.ts +3 -0
- package/src/llm/index.ts +1 -0
- package/src/llm/openai.ts +178 -0
- package/src/memory/context.ts +124 -0
- package/src/memory/index.ts +1 -0
- package/src/pipeline.ts +331 -0
- package/src/stt/deepgram.ts +182 -0
- package/src/stt/index.ts +1 -0
- package/src/tools/index.ts +1 -0
- package/src/tools/registry.ts +99 -0
- package/src/transport/index.ts +1 -0
- package/src/transport/websocket.ts +227 -0
- package/src/tts/eleven-labs.ts +100 -0
- package/src/tts/index.ts +1 -0
- package/src/types.ts +429 -0
- package/src/vad/energy.ts +135 -0
- package/src/vad/index.ts +1 -0
- package/tests/jev.test.ts +198 -0
- package/tests/memory.test.ts +169 -0
- package/tests/vad.test.ts +94 -0
- package/tsconfig.json +9 -0
- package/tsconfig.tsbuildinfo +1 -0
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
import type { FelAgentConfig, AgentAction } from "./types.js";
|
|
3
|
+
import { JEVEngine } from "./jev/engine.js";
|
|
4
|
+
/**
|
|
5
|
+
* FelAgent — The main entry point for building a voice agent with Felona Voice.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const agent = new FelAgent({
|
|
10
|
+
* name: "Support Bot",
|
|
11
|
+
* systemPrompt: "You are a helpful support agent.",
|
|
12
|
+
* stt: { provider: "deepgram", apiKey: "..." },
|
|
13
|
+
* tts: { provider: "elevenlabs", apiKey: "..." },
|
|
14
|
+
* llm: { provider: "openai", apiKey: "...", model: "gpt-4o-mini" },
|
|
15
|
+
* actions: [ ... ],
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* agent.listen({ port: 8080 });
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* FelAgent wires together:
|
|
22
|
+
* - Transport (WebSocket server for audio I/O)
|
|
23
|
+
* - Voice Pipeline (STT → JEV → LLM → TTS per session)
|
|
24
|
+
* - JEV Engine (action prediction)
|
|
25
|
+
* - Memory, Tools, Analytics
|
|
26
|
+
*/
|
|
27
|
+
export declare class FelAgent extends EventEmitter {
|
|
28
|
+
private readonly config;
|
|
29
|
+
private transport;
|
|
30
|
+
private readonly jev;
|
|
31
|
+
private readonly logger;
|
|
32
|
+
private readonly tools;
|
|
33
|
+
private readonly hooks;
|
|
34
|
+
private readonly sttProvider;
|
|
35
|
+
private readonly ttsProvider;
|
|
36
|
+
private readonly vadProvider;
|
|
37
|
+
private readonly llmProvider;
|
|
38
|
+
private readonly llmInterface;
|
|
39
|
+
private pipelines;
|
|
40
|
+
private initialized;
|
|
41
|
+
constructor(config: FelAgentConfig);
|
|
42
|
+
/**
|
|
43
|
+
* Start the agent — initialize JEV, start the transport, begin accepting calls.
|
|
44
|
+
*/
|
|
45
|
+
listen(options?: {
|
|
46
|
+
port?: number;
|
|
47
|
+
host?: string;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Stop the agent — shut down all pipelines and the transport.
|
|
51
|
+
*/
|
|
52
|
+
stop(): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Handle a new client connection — create a voice pipeline for this session.
|
|
55
|
+
*/
|
|
56
|
+
private handleConnect;
|
|
57
|
+
/**
|
|
58
|
+
* Handle a client disconnection — stop and clean up the pipeline.
|
|
59
|
+
*/
|
|
60
|
+
private handleDisconnect;
|
|
61
|
+
/**
|
|
62
|
+
* Handle incoming audio from a client — route to the correct pipeline.
|
|
63
|
+
*/
|
|
64
|
+
private handleAudio;
|
|
65
|
+
/** Create STT provider based on config */
|
|
66
|
+
private createSTTProvider;
|
|
67
|
+
/** Create TTS provider based on config */
|
|
68
|
+
private createTTSProvider;
|
|
69
|
+
/** Create LLM provider based on config */
|
|
70
|
+
private createLLMProvider;
|
|
71
|
+
/** Get the number of active calls */
|
|
72
|
+
get activeCallCount(): number;
|
|
73
|
+
/** Check if the agent is running */
|
|
74
|
+
get isRunning(): boolean;
|
|
75
|
+
/** Get the agent name */
|
|
76
|
+
get name(): string;
|
|
77
|
+
/** Get the JEV engine (for inspection/testing) */
|
|
78
|
+
get jevEngine(): JEVEngine;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Helper to define an action with type safety.
|
|
82
|
+
*/
|
|
83
|
+
export declare function defineAction(action: AgentAction): AgentAction;
|
|
84
|
+
/**
|
|
85
|
+
* Quick-start factory — creates a minimal agent with sensible defaults.
|
|
86
|
+
* Automatically creates a default "respond" action that uses the LLM directly.
|
|
87
|
+
*/
|
|
88
|
+
export declare function quickStart(config: {
|
|
89
|
+
llm: {
|
|
90
|
+
provider: string;
|
|
91
|
+
apiKey: string;
|
|
92
|
+
model?: string;
|
|
93
|
+
};
|
|
94
|
+
stt: {
|
|
95
|
+
provider: string;
|
|
96
|
+
apiKey: string;
|
|
97
|
+
};
|
|
98
|
+
tts: {
|
|
99
|
+
provider: string;
|
|
100
|
+
apiKey: string;
|
|
101
|
+
voice?: string;
|
|
102
|
+
};
|
|
103
|
+
systemPrompt?: string;
|
|
104
|
+
}): FelAgent;
|
|
105
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EACV,cAAc,EAGd,WAAW,EAGZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAa5C;;;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ClD,IAAI,SAAS,IAAI,SAAS,CAEzB;CACF;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAE7D;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE;IACjC,GAAG,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1D,GAAG,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C,GAAG,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,QAAQ,CAgCX"}
|
package/dist/agent.js
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
import { WebSocketTransport } from "./transport/websocket.js";
|
|
3
|
+
import { JEVEngine } from "./jev/engine.js";
|
|
4
|
+
import { OpenAIEmbeddingProvider } from "./jev/embeddings.js";
|
|
5
|
+
import { ConversationMemory } from "./memory/context.js";
|
|
6
|
+
import { ToolRegistry } from "./tools/registry.js";
|
|
7
|
+
import { CallLogger } from "./analytics/logger.js";
|
|
8
|
+
import { VoicePipeline } from "./pipeline.js";
|
|
9
|
+
// Provider imports
|
|
10
|
+
import { DeepgramSTT } from "./stt/deepgram.js";
|
|
11
|
+
import { ElevenLabsTTS } from "./tts/eleven-labs.js";
|
|
12
|
+
import { EnergyVAD } from "./vad/energy.js";
|
|
13
|
+
import { OpenAILLM } from "./llm/openai.js";
|
|
14
|
+
/**
|
|
15
|
+
* FelAgent — The main entry point for building a voice agent with Felona Voice.
|
|
16
|
+
*
|
|
17
|
+
* Usage:
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const agent = new FelAgent({
|
|
20
|
+
* name: "Support Bot",
|
|
21
|
+
* systemPrompt: "You are a helpful support agent.",
|
|
22
|
+
* stt: { provider: "deepgram", apiKey: "..." },
|
|
23
|
+
* tts: { provider: "elevenlabs", apiKey: "..." },
|
|
24
|
+
* llm: { provider: "openai", apiKey: "...", model: "gpt-4o-mini" },
|
|
25
|
+
* actions: [ ... ],
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* agent.listen({ port: 8080 });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* FelAgent wires together:
|
|
32
|
+
* - Transport (WebSocket server for audio I/O)
|
|
33
|
+
* - Voice Pipeline (STT → JEV → LLM → TTS per session)
|
|
34
|
+
* - JEV Engine (action prediction)
|
|
35
|
+
* - Memory, Tools, Analytics
|
|
36
|
+
*/
|
|
37
|
+
export class FelAgent extends EventEmitter {
|
|
38
|
+
config;
|
|
39
|
+
transport;
|
|
40
|
+
jev;
|
|
41
|
+
logger;
|
|
42
|
+
tools;
|
|
43
|
+
hooks;
|
|
44
|
+
sttProvider;
|
|
45
|
+
ttsProvider;
|
|
46
|
+
vadProvider;
|
|
47
|
+
llmProvider;
|
|
48
|
+
llmInterface;
|
|
49
|
+
// Active pipelines (one per session)
|
|
50
|
+
pipelines = new Map();
|
|
51
|
+
initialized = false;
|
|
52
|
+
constructor(config) {
|
|
53
|
+
super();
|
|
54
|
+
this.config = config;
|
|
55
|
+
this.hooks = config.hooks ?? {};
|
|
56
|
+
// Initialize logger
|
|
57
|
+
this.logger = new CallLogger({
|
|
58
|
+
logDir: config.logging?.logDir,
|
|
59
|
+
level: config.logging?.level,
|
|
60
|
+
enabled: config.logging?.enabled ?? true,
|
|
61
|
+
});
|
|
62
|
+
// Initialize tools
|
|
63
|
+
this.tools = new ToolRegistry();
|
|
64
|
+
if (config.tools) {
|
|
65
|
+
this.tools.registerAll(config.tools);
|
|
66
|
+
}
|
|
67
|
+
// Initialize providers
|
|
68
|
+
this.sttProvider = this.createSTTProvider();
|
|
69
|
+
this.ttsProvider = this.createTTSProvider();
|
|
70
|
+
this.vadProvider = new EnergyVAD();
|
|
71
|
+
this.llmProvider = this.createLLMProvider();
|
|
72
|
+
this.llmInterface = this.llmProvider.create({
|
|
73
|
+
model: config.llm.model ?? "gpt-4o-mini",
|
|
74
|
+
temperature: config.llm.temperature,
|
|
75
|
+
});
|
|
76
|
+
// Initialize JEV engine
|
|
77
|
+
const embeddingProvider = new OpenAIEmbeddingProvider({
|
|
78
|
+
apiKey: config.jev?.embeddingApiKey ??
|
|
79
|
+
config.llm.apiKey ??
|
|
80
|
+
"",
|
|
81
|
+
});
|
|
82
|
+
this.jev = new JEVEngine({
|
|
83
|
+
embeddingProvider,
|
|
84
|
+
confidenceThreshold: config.jev?.confidenceThreshold,
|
|
85
|
+
});
|
|
86
|
+
// Initialize transport
|
|
87
|
+
this.transport = new WebSocketTransport();
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Start the agent — initialize JEV, start the transport, begin accepting calls.
|
|
91
|
+
*/
|
|
92
|
+
async listen(options) {
|
|
93
|
+
const port = options?.port ?? this.config.transport?.port ?? 8080;
|
|
94
|
+
const host = options?.host ?? this.config.transport?.host;
|
|
95
|
+
this.logger.log("info", `Starting Felona Voice agent: "${this.config.name}"`);
|
|
96
|
+
// Step 1: Initialize JEV — embed all action descriptions
|
|
97
|
+
this.logger.log("info", "Initializing JEV engine...");
|
|
98
|
+
await this.jev.initialize(this.config.actions);
|
|
99
|
+
this.logger.log("info", `JEV initialized with ${this.config.actions.length} actions`);
|
|
100
|
+
// Step 2: Load predictor model if specified
|
|
101
|
+
if (this.config.jev?.predictorModel) {
|
|
102
|
+
await this.jev.loadPredictor(this.config.jev.predictorModel);
|
|
103
|
+
}
|
|
104
|
+
// Step 3: Wire up transport event handlers
|
|
105
|
+
this.transport.onConnect((session) => this.handleConnect(session));
|
|
106
|
+
this.transport.onDisconnect((session) => this.handleDisconnect(session));
|
|
107
|
+
this.transport.onAudioChunk((sessionId, chunk) => this.handleAudio(sessionId, chunk));
|
|
108
|
+
// Step 4: Start the transport server
|
|
109
|
+
await this.transport.start({ port, host });
|
|
110
|
+
this.initialized = true;
|
|
111
|
+
this.logger.log("info", `Agent "${this.config.name}" ready on port ${port}`);
|
|
112
|
+
this.logger.log("info", ` STT: ${this.sttProvider.name}`);
|
|
113
|
+
this.logger.log("info", ` TTS: ${this.ttsProvider.name}`);
|
|
114
|
+
this.logger.log("info", ` LLM: ${this.llmProvider.name}`);
|
|
115
|
+
this.logger.log("info", ` JEV: ${this.jev.hasPredictor ? "trained predictor" : "cold-start mode"}`);
|
|
116
|
+
this.logger.log("info", ` Actions: ${this.config.actions.map((a) => a.id).join(", ")}`);
|
|
117
|
+
this.emit("ready", { port, host });
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Stop the agent — shut down all pipelines and the transport.
|
|
121
|
+
*/
|
|
122
|
+
async stop() {
|
|
123
|
+
this.logger.log("info", "Stopping agent...");
|
|
124
|
+
// Stop all active pipelines
|
|
125
|
+
for (const [sessionId, pipeline] of this.pipelines) {
|
|
126
|
+
await pipeline.stop();
|
|
127
|
+
}
|
|
128
|
+
this.pipelines.clear();
|
|
129
|
+
// Stop transport
|
|
130
|
+
await this.transport.stop();
|
|
131
|
+
this.initialized = false;
|
|
132
|
+
this.logger.log("info", "Agent stopped");
|
|
133
|
+
this.emit("stopped");
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Handle a new client connection — create a voice pipeline for this session.
|
|
137
|
+
*/
|
|
138
|
+
async handleConnect(session) {
|
|
139
|
+
this.logger.log("info", `New call: ${session.id}`);
|
|
140
|
+
// Create per-session memory
|
|
141
|
+
const memory = new ConversationMemory();
|
|
142
|
+
// Create a new VAD instance per session (has internal state)
|
|
143
|
+
const vad = new EnergyVAD();
|
|
144
|
+
// Create the voice pipeline for this session
|
|
145
|
+
const pipeline = new VoicePipeline({
|
|
146
|
+
sessionId: session.id,
|
|
147
|
+
session,
|
|
148
|
+
stt: this.sttProvider,
|
|
149
|
+
tts: this.ttsProvider,
|
|
150
|
+
vad,
|
|
151
|
+
llm: this.llmInterface,
|
|
152
|
+
jev: this.jev,
|
|
153
|
+
memory,
|
|
154
|
+
tools: this.tools,
|
|
155
|
+
logger: this.logger,
|
|
156
|
+
hooks: this.hooks,
|
|
157
|
+
systemPrompt: this.config.systemPrompt,
|
|
158
|
+
sendAudio: (chunk) => this.transport.sendAudio(session.id, chunk),
|
|
159
|
+
});
|
|
160
|
+
// Forward pipeline events
|
|
161
|
+
pipeline.on("transcript", (data) => this.emit("transcript", { sessionId: session.id, ...data }));
|
|
162
|
+
pipeline.on("error", (error) => this.emit("error", { sessionId: session.id, error }));
|
|
163
|
+
pipeline.on("bargeIn", () => this.emit("bargeIn", { sessionId: session.id }));
|
|
164
|
+
this.pipelines.set(session.id, pipeline);
|
|
165
|
+
await pipeline.start();
|
|
166
|
+
this.emit("callStarted", session);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Handle a client disconnection — stop and clean up the pipeline.
|
|
170
|
+
*/
|
|
171
|
+
async handleDisconnect(session) {
|
|
172
|
+
this.logger.log("info", `Call ended: ${session.id}`);
|
|
173
|
+
const pipeline = this.pipelines.get(session.id);
|
|
174
|
+
if (pipeline) {
|
|
175
|
+
await pipeline.stop();
|
|
176
|
+
this.pipelines.delete(session.id);
|
|
177
|
+
}
|
|
178
|
+
this.emit("callEnded", session);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Handle incoming audio from a client — route to the correct pipeline.
|
|
182
|
+
*/
|
|
183
|
+
handleAudio(sessionId, chunk) {
|
|
184
|
+
const pipeline = this.pipelines.get(sessionId);
|
|
185
|
+
if (pipeline) {
|
|
186
|
+
pipeline.processAudio(chunk);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
/** Create STT provider based on config */
|
|
190
|
+
createSTTProvider() {
|
|
191
|
+
switch (this.config.stt.provider) {
|
|
192
|
+
case "deepgram":
|
|
193
|
+
return new DeepgramSTT({
|
|
194
|
+
apiKey: this.config.stt.apiKey ?? "",
|
|
195
|
+
});
|
|
196
|
+
default:
|
|
197
|
+
this.logger.log("warn", `Unknown STT provider "${this.config.stt.provider}", falling back to Deepgram`);
|
|
198
|
+
return new DeepgramSTT({
|
|
199
|
+
apiKey: this.config.stt.apiKey ?? "",
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/** Create TTS provider based on config */
|
|
204
|
+
createTTSProvider() {
|
|
205
|
+
switch (this.config.tts.provider) {
|
|
206
|
+
case "elevenlabs":
|
|
207
|
+
return new ElevenLabsTTS({
|
|
208
|
+
apiKey: this.config.tts.apiKey ?? "",
|
|
209
|
+
voice: this.config.tts.voice,
|
|
210
|
+
});
|
|
211
|
+
default:
|
|
212
|
+
this.logger.log("warn", `Unknown TTS provider "${this.config.tts.provider}", falling back to ElevenLabs`);
|
|
213
|
+
return new ElevenLabsTTS({
|
|
214
|
+
apiKey: this.config.tts.apiKey ?? "",
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/** Create LLM provider based on config */
|
|
219
|
+
createLLMProvider() {
|
|
220
|
+
switch (this.config.llm.provider) {
|
|
221
|
+
case "openai":
|
|
222
|
+
return new OpenAILLM({
|
|
223
|
+
apiKey: this.config.llm.apiKey ?? "",
|
|
224
|
+
});
|
|
225
|
+
default:
|
|
226
|
+
this.logger.log("warn", `Unknown LLM provider "${this.config.llm.provider}", falling back to OpenAI`);
|
|
227
|
+
return new OpenAILLM({
|
|
228
|
+
apiKey: this.config.llm.apiKey ?? "",
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/** Get the number of active calls */
|
|
233
|
+
get activeCallCount() {
|
|
234
|
+
return this.pipelines.size;
|
|
235
|
+
}
|
|
236
|
+
/** Check if the agent is running */
|
|
237
|
+
get isRunning() {
|
|
238
|
+
return this.initialized;
|
|
239
|
+
}
|
|
240
|
+
/** Get the agent name */
|
|
241
|
+
get name() {
|
|
242
|
+
return this.config.name;
|
|
243
|
+
}
|
|
244
|
+
/** Get the JEV engine (for inspection/testing) */
|
|
245
|
+
get jevEngine() {
|
|
246
|
+
return this.jev;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Helper to define an action with type safety.
|
|
251
|
+
*/
|
|
252
|
+
export function defineAction(action) {
|
|
253
|
+
return action;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Quick-start factory — creates a minimal agent with sensible defaults.
|
|
257
|
+
* Automatically creates a default "respond" action that uses the LLM directly.
|
|
258
|
+
*/
|
|
259
|
+
export function quickStart(config) {
|
|
260
|
+
return new FelAgent({
|
|
261
|
+
name: "Felona Agent",
|
|
262
|
+
systemPrompt: config.systemPrompt ??
|
|
263
|
+
"You are a helpful, friendly voice assistant. Keep your responses concise and conversational.",
|
|
264
|
+
stt: config.stt,
|
|
265
|
+
tts: config.tts,
|
|
266
|
+
llm: config.llm,
|
|
267
|
+
actions: [
|
|
268
|
+
defineAction({
|
|
269
|
+
id: "respond",
|
|
270
|
+
description: "Respond to the user's message helpfully and conversationally",
|
|
271
|
+
handler: async (ctx) => {
|
|
272
|
+
const response = await ctx.llm.generate(`Respond to the user naturally. User said: "${ctx.conversation.currentUtterance}"`, {
|
|
273
|
+
systemPrompt: ctx.conversation.systemPrompt,
|
|
274
|
+
history: ctx.memory
|
|
275
|
+
.getRecentTurns(10)
|
|
276
|
+
.map((t) => ({
|
|
277
|
+
role: t.role === "user" ? "user" : "assistant",
|
|
278
|
+
content: t.content,
|
|
279
|
+
})),
|
|
280
|
+
});
|
|
281
|
+
return response;
|
|
282
|
+
},
|
|
283
|
+
}),
|
|
284
|
+
],
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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B,8FAA8F;QAChG,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,OAAO,EAAE;YACP,YAAY,CAAC;gBACX,EAAE,EAAE,SAAS;gBACb,WAAW,EACT,8DAA8D;gBAChE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;oBACrB,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,QAAQ,CACrC,8CAA8C,GAAG,CAAC,YAAY,CAAC,gBAAgB,GAAG,EAClF;wBACE,YAAY,EAAE,GAAG,CAAC,YAAY,CAAC,YAAY;wBAC3C,OAAO,EAAE,GAAG,CAAC,MAAM;6BAChB,cAAc,CAAC,EAAE,CAAC;6BAClB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;4BACX,IAAI,EAAE,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAe,CAAC,CAAC,CAAC,WAAoB;4BAChE,OAAO,EAAE,CAAC,CAAC,OAAO;yBACnB,CAAC,CAAC;qBACN,CACF,CAAC;oBACF,OAAO,QAAQ,CAAC;gBAClB,CAAC;aACF,CAAC;SACH;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/analytics/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC3D,YAAY,EACV,YAAY,EACZ,cAAc,EACd,WAAW,EACX,WAAW,GACZ,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/analytics/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { ConversationTurn, Session } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* CallLogger — Logs structured conversation data for JEV training and analytics.
|
|
4
|
+
*
|
|
5
|
+
* Every completed call produces a log file with:
|
|
6
|
+
* - Session metadata
|
|
7
|
+
* - All conversation turns
|
|
8
|
+
* - JEV decisions (action selected, confidence, candidates)
|
|
9
|
+
* - Timing information
|
|
10
|
+
*
|
|
11
|
+
* These logs are the training data for the JEV predictor (Phase 2).
|
|
12
|
+
*/
|
|
13
|
+
export declare class CallLogger {
|
|
14
|
+
private readonly logDir;
|
|
15
|
+
private readonly level;
|
|
16
|
+
private readonly enabled;
|
|
17
|
+
constructor(options?: {
|
|
18
|
+
logDir?: string;
|
|
19
|
+
level?: "debug" | "info" | "warn" | "error";
|
|
20
|
+
enabled?: boolean;
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Log a complete call session.
|
|
24
|
+
* This is called when a call ends.
|
|
25
|
+
*/
|
|
26
|
+
logCall(data: CallLogEntry): Promise<string | null>;
|
|
27
|
+
/**
|
|
28
|
+
* Log a JEV decision for the current session.
|
|
29
|
+
* Used to build (context, action) training pairs.
|
|
30
|
+
*/
|
|
31
|
+
logDecision(decision: JEVDecisionLog): void;
|
|
32
|
+
/** General-purpose log */
|
|
33
|
+
log(level: "debug" | "info" | "warn" | "error", message: string, data?: Record<string, unknown>): void;
|
|
34
|
+
}
|
|
35
|
+
/** Data for a complete call log */
|
|
36
|
+
export interface CallLogEntry {
|
|
37
|
+
session: Session;
|
|
38
|
+
turns: ConversationTurn[];
|
|
39
|
+
decisions: JEVDecisionLog[];
|
|
40
|
+
metrics: CallMetrics;
|
|
41
|
+
}
|
|
42
|
+
/** A single JEV decision record */
|
|
43
|
+
export interface JEVDecisionLog {
|
|
44
|
+
/** Timestamp of the decision */
|
|
45
|
+
timestampMs: number;
|
|
46
|
+
/** The context string that was embedded */
|
|
47
|
+
contextSummary: string;
|
|
48
|
+
/** The action that was selected */
|
|
49
|
+
selectedAction: string;
|
|
50
|
+
/** Confidence score */
|
|
51
|
+
confidence: number;
|
|
52
|
+
/** Top N candidates with scores */
|
|
53
|
+
candidates: Array<{
|
|
54
|
+
actionId: string;
|
|
55
|
+
score: number;
|
|
56
|
+
}>;
|
|
57
|
+
/** Time taken for the JEV decision (ms) */
|
|
58
|
+
latencyMs: number;
|
|
59
|
+
}
|
|
60
|
+
/** Call-level metrics */
|
|
61
|
+
export interface CallMetrics {
|
|
62
|
+
/** Total number of turns */
|
|
63
|
+
totalTurns: number;
|
|
64
|
+
/** Average JEV decision latency (ms) */
|
|
65
|
+
avgJEVLatencyMs: number;
|
|
66
|
+
/** Average STT latency (ms) */
|
|
67
|
+
avgSTTLatencyMs?: number;
|
|
68
|
+
/** Average TTS latency (ms) */
|
|
69
|
+
avgTTSLatencyMs?: number;
|
|
70
|
+
/** Number of barge-in events */
|
|
71
|
+
bargeInCount: number;
|
|
72
|
+
/** Average JEV confidence */
|
|
73
|
+
avgConfidence: number;
|
|
74
|
+
}
|
|
75
|
+
/** Structure of a call log file */
|
|
76
|
+
export interface CallLogFile {
|
|
77
|
+
version: string;
|
|
78
|
+
sessionId: string;
|
|
79
|
+
startedAt: string;
|
|
80
|
+
endedAt: string;
|
|
81
|
+
durationMs: number;
|
|
82
|
+
metadata: Record<string, unknown>;
|
|
83
|
+
turns: ConversationTurn[];
|
|
84
|
+
decisions: JEVDecisionLog[];
|
|
85
|
+
metrics: CallMetrics;
|
|
86
|
+
}
|
|
87
|
+
export declare function createCallLogger(options?: {
|
|
88
|
+
logDir?: string;
|
|
89
|
+
level?: "debug" | "info" | "warn" | "error";
|
|
90
|
+
enabled?: boolean;
|
|
91
|
+
}): CallLogger;
|
|
92
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/analytics/logger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,E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KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvD,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,yBAAyB;AACzB,MAAM,WAAW,WAAW;IAC1B,4BAA4B;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,eAAe,EAAE,MAAM,CAAC;IACxB,+BAA+B;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,+BAA+B;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gCAAgC;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,6BAA6B;IAC7B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,mCAAmC;AACnC,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GAAG,UAAU,CAEb"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { writeFile, mkdir } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* CallLogger — Logs structured conversation data for JEV training and analytics.
|
|
5
|
+
*
|
|
6
|
+
* Every completed call produces a log file with:
|
|
7
|
+
* - Session metadata
|
|
8
|
+
* - All conversation turns
|
|
9
|
+
* - JEV decisions (action selected, confidence, candidates)
|
|
10
|
+
* - Timing information
|
|
11
|
+
*
|
|
12
|
+
* These logs are the training data for the JEV predictor (Phase 2).
|
|
13
|
+
*/
|
|
14
|
+
export class CallLogger {
|
|
15
|
+
logDir;
|
|
16
|
+
level;
|
|
17
|
+
enabled;
|
|
18
|
+
constructor(options) {
|
|
19
|
+
this.logDir = options?.logDir ?? "./call-logs";
|
|
20
|
+
this.level = options?.level ?? "info";
|
|
21
|
+
this.enabled = options?.enabled ?? true;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Log a complete call session.
|
|
25
|
+
* This is called when a call ends.
|
|
26
|
+
*/
|
|
27
|
+
async logCall(data) {
|
|
28
|
+
if (!this.enabled)
|
|
29
|
+
return null;
|
|
30
|
+
await mkdir(this.logDir, { recursive: true });
|
|
31
|
+
const filename = `${data.session.id}_${Date.now()}.json`;
|
|
32
|
+
const filepath = join(this.logDir, filename);
|
|
33
|
+
const logData = {
|
|
34
|
+
version: "1.0",
|
|
35
|
+
sessionId: data.session.id,
|
|
36
|
+
startedAt: data.session.startedAt.toISOString(),
|
|
37
|
+
endedAt: new Date().toISOString(),
|
|
38
|
+
durationMs: Date.now() - data.session.startedAt.getTime(),
|
|
39
|
+
metadata: data.session.metadata,
|
|
40
|
+
turns: data.turns,
|
|
41
|
+
decisions: data.decisions,
|
|
42
|
+
metrics: data.metrics,
|
|
43
|
+
};
|
|
44
|
+
await writeFile(filepath, JSON.stringify(logData, null, 2));
|
|
45
|
+
this.log("info", `Call log saved: ${filepath}`);
|
|
46
|
+
return filepath;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Log a JEV decision for the current session.
|
|
50
|
+
* Used to build (context, action) training pairs.
|
|
51
|
+
*/
|
|
52
|
+
logDecision(decision) {
|
|
53
|
+
if (!this.enabled)
|
|
54
|
+
return;
|
|
55
|
+
this.log("debug", `JEV decision: ${decision.selectedAction} (confidence: ${decision.confidence.toFixed(3)})`);
|
|
56
|
+
}
|
|
57
|
+
/** General-purpose log */
|
|
58
|
+
log(level, message, data) {
|
|
59
|
+
const levels = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
60
|
+
if (levels[level] < levels[this.level])
|
|
61
|
+
return;
|
|
62
|
+
const prefix = `[Felona/${level.toUpperCase()}]`;
|
|
63
|
+
const timestamp = new Date().toISOString();
|
|
64
|
+
if (data) {
|
|
65
|
+
console.log(`${prefix} ${timestamp} ${message}`, data);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
console.log(`${prefix} ${timestamp} ${message}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export function createCallLogger(options) {
|
|
73
|
+
return new CallLogger(options);
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/analytics/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC;;;;;;;;;;GAUG;AACH,MAAM,OAAO,UAAU;IACJ,MAAM,CAAS;IACf,KAAK,CAAsC;IAC3C,OAAO,CAAU;IAElC,YAAY,OAIX;QACC,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,aAAa,CAAC;QAC/C,IAAI,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,MAAM,CAAC;QACtC,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,IAAI,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,IAAkB;QAC9B,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC;QAE/B,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,E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Ae,EACf,IAA8B;QAE9B,MAAM,MAAM,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QACxD,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;YAAE,OAAO;QAE/C,MAAM,MAAM,GAAG,WAAW,KAAK,CAAC,WAAW,EAAE,GAAG,CAAC;QACjD,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAE3C,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,SAAS,IAAI,OAAO,EAAE,EAAE,IAAI,CAAC,CAAC;QACzD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,SAAS,IAAI,OAAO,EAAE,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;CACF;AAuDD,MAAM,UAAU,gBAAgB,CAAC,OAIhC;IACC,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Felona Voice — Open-source voice agent framework powered by JEV.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { FelAgent, defineAction } from "felona-voice";
|
|
9
|
+
*
|
|
10
|
+
* const agent = new FelAgent({
|
|
11
|
+
* name: "My Agent",
|
|
12
|
+
* systemPrompt: "You are helpful.",
|
|
13
|
+
* stt: { provider: "deepgram", apiKey: process.env.DEEPGRAM_API_KEY },
|
|
14
|
+
* tts: { provider: "elevenlabs", apiKey: process.env.ELEVEN_API_KEY },
|
|
15
|
+
* llm: { provider: "openai", apiKey: process.env.OPENAI_API_KEY, model: "gpt-4o-mini" },
|
|
16
|
+
* actions: [
|
|
17
|
+
* defineAction({
|
|
18
|
+
* id: "greet",
|
|
19
|
+
* description: "Greet the user warmly",
|
|
20
|
+
* handler: async (ctx) => ctx.llm.generate("Greet the user", {
|
|
21
|
+
* systemPrompt: ctx.conversation.systemPrompt,
|
|
22
|
+
* }),
|
|
23
|
+
* }),
|
|
24
|
+
* ],
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* agent.listen({ port: 8080 });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export { FelAgent, defineAction, quickStart } from "./agent.js";
|
|
31
|
+
export { JEVEngine, createJEVEngine } from "./jev/engine.js";
|
|
32
|
+
export { ActionSpace, cosineSimilarity } from "./jev/action-space.js";
|
|
33
|
+
export { OpenAIEmbeddingProvider } from "./jev/embeddings.js";
|
|
34
|
+
export { VoicePipeline, createPipeline } from "./pipeline.js";
|
|
35
|
+
export { WebSocketTransport, createWebSocketTransport, } from "./transport/websocket.js";
|
|
36
|
+
export { DeepgramSTT, createDeepgramSTT } from "./stt/deepgram.js";
|
|
37
|
+
export { ElevenLabsTTS, createElevenLabsTTS } from "./tts/eleven-labs.js";
|
|
38
|
+
export { EnergyVAD, createEnergyVAD } from "./vad/energy.js";
|
|
39
|
+
export { OpenAILLM, createOpenAILLM } from "./llm/openai.js";
|
|
40
|
+
export { ConversationMemory, createMemory } from "./memory/context.js";
|
|
41
|
+
export { ToolRegistry, defineTool, createToolRegistry } from "./tools/registry.js";
|
|
42
|
+
export { CallLogger, createCallLogger } from "./analytics/logger.js";
|
|
43
|
+
export type { CallLogEntry, JEVDecisionLog, CallMetrics, CallLogFile, } from "./analytics/logger.js";
|
|
44
|
+
export type { AudioChunk, Session, SessionState, ConversationTurn, ConversationContext, AgentAction, ActionContext, ActionMatch, Transport, TransportOptions, STTProvider, STTStream, STTStreamOptions, STTResult, TTSProvider, TTSOptions, VADProvider, VADResult, VADEvent, LLMProvider, LLMInterface, LLMOptions, LLMContext, AgentTool, ToolExecutor, MemoryManager, JEVEngine as JEVEngineInterface, EmbeddingProvider, AgentHooks, FelAgentConfig, } from "./types.js";
|
|
45
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGhE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG9D,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGnE,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAG1E,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAG7D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAG7D,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGvE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGnF,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACrE,YAAY,EACV,YAAY,EACZ,cAAc,EACd,WAAW,EACX,WAAW,GACZ,MAAM,uBAAuB,CAAC;AAG/B,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