elevenlabs-voice-agent-mcp 1.0.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/LICENSE +21 -0
- package/README.md +533 -0
- package/dist/constants.d.ts +25 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +51 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +93 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/agent-schemas.d.ts +147 -0
- package/dist/schemas/agent-schemas.d.ts.map +1 -0
- package/dist/schemas/agent-schemas.js +145 -0
- package/dist/schemas/agent-schemas.js.map +1 -0
- package/dist/schemas/batch-calling-schemas.d.ts +170 -0
- package/dist/schemas/batch-calling-schemas.d.ts.map +1 -0
- package/dist/schemas/batch-calling-schemas.js +77 -0
- package/dist/schemas/batch-calling-schemas.js.map +1 -0
- package/dist/schemas/common-schemas.d.ts +54 -0
- package/dist/schemas/common-schemas.d.ts.map +1 -0
- package/dist/schemas/common-schemas.js +72 -0
- package/dist/schemas/common-schemas.js.map +1 -0
- package/dist/schemas/conversation-schemas.d.ts +72 -0
- package/dist/schemas/conversation-schemas.d.ts.map +1 -0
- package/dist/schemas/conversation-schemas.js +30 -0
- package/dist/schemas/conversation-schemas.js.map +1 -0
- package/dist/schemas/outbound-schemas.d.ts +115 -0
- package/dist/schemas/outbound-schemas.d.ts.map +1 -0
- package/dist/schemas/outbound-schemas.js +61 -0
- package/dist/schemas/outbound-schemas.js.map +1 -0
- package/dist/schemas/phone-number-schemas.d.ts +168 -0
- package/dist/schemas/phone-number-schemas.d.ts.map +1 -0
- package/dist/schemas/phone-number-schemas.js +116 -0
- package/dist/schemas/phone-number-schemas.js.map +1 -0
- package/dist/schemas/tool-schemas.d.ts +208 -0
- package/dist/schemas/tool-schemas.d.ts.map +1 -0
- package/dist/schemas/tool-schemas.js +131 -0
- package/dist/schemas/tool-schemas.js.map +1 -0
- package/dist/services/elevenlabs-api.d.ts +37 -0
- package/dist/services/elevenlabs-api.d.ts.map +1 -0
- package/dist/services/elevenlabs-api.js +78 -0
- package/dist/services/elevenlabs-api.js.map +1 -0
- package/dist/services/formatters.d.ts +76 -0
- package/dist/services/formatters.d.ts.map +1 -0
- package/dist/services/formatters.js +475 -0
- package/dist/services/formatters.js.map +1 -0
- package/dist/tools/agent-tools.d.ts +228 -0
- package/dist/tools/agent-tools.d.ts.map +1 -0
- package/dist/tools/agent-tools.js +369 -0
- package/dist/tools/agent-tools.js.map +1 -0
- package/dist/tools/batch-calling-tools.d.ts +183 -0
- package/dist/tools/batch-calling-tools.d.ts.map +1 -0
- package/dist/tools/batch-calling-tools.js +203 -0
- package/dist/tools/batch-calling-tools.js.map +1 -0
- package/dist/tools/conversation-tools.d.ts +103 -0
- package/dist/tools/conversation-tools.d.ts.map +1 -0
- package/dist/tools/conversation-tools.js +140 -0
- package/dist/tools/conversation-tools.js.map +1 -0
- package/dist/tools/knowledge-tools.d.ts +75 -0
- package/dist/tools/knowledge-tools.d.ts.map +1 -0
- package/dist/tools/knowledge-tools.js +63 -0
- package/dist/tools/knowledge-tools.js.map +1 -0
- package/dist/tools/outbound-tools.d.ts +44 -0
- package/dist/tools/outbound-tools.d.ts.map +1 -0
- package/dist/tools/outbound-tools.js +84 -0
- package/dist/tools/outbound-tools.js.map +1 -0
- package/dist/tools/phone-number-tools.d.ts +215 -0
- package/dist/tools/phone-number-tools.d.ts.map +1 -0
- package/dist/tools/phone-number-tools.js +295 -0
- package/dist/tools/phone-number-tools.js.map +1 -0
- package/dist/tools/tool-tools.d.ts +165 -0
- package/dist/tools/tool-tools.d.ts.map +1 -0
- package/dist/tools/tool-tools.js +166 -0
- package/dist/tools/tool-tools.js.map +1 -0
- package/dist/tools/utility-tools.d.ts +76 -0
- package/dist/tools/utility-tools.d.ts.map +1 -0
- package/dist/tools/utility-tools.js +121 -0
- package/dist/tools/utility-tools.js.map +1 -0
- package/dist/types.d.ts +282 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/error-handlers.d.ts +29 -0
- package/dist/utils/error-handlers.d.ts.map +1 -0
- package/dist/utils/error-handlers.js +90 -0
- package/dist/utils/error-handlers.js.map +1 -0
- package/dist/utils/truncation.d.ts +41 -0
- package/dist/utils/truncation.d.ts.map +1 -0
- package/dist/utils/truncation.js +78 -0
- package/dist/utils/truncation.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility tools
|
|
3
|
+
*
|
|
4
|
+
* MCP tools for widget generation, voice browsing, and other utilities.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Generates widget embed code for testing an agent
|
|
8
|
+
*/
|
|
9
|
+
export declare const elevenlabs_generate_widget_code: {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
zodSchema: import("zod").ZodObject<{
|
|
13
|
+
agent_id: import("zod").ZodString;
|
|
14
|
+
color: import("zod").ZodOptional<import("zod").ZodString>;
|
|
15
|
+
avatar_url: import("zod").ZodOptional<import("zod").ZodString>;
|
|
16
|
+
}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{
|
|
17
|
+
agent_id: import("zod").ZodString;
|
|
18
|
+
color: import("zod").ZodOptional<import("zod").ZodString>;
|
|
19
|
+
avatar_url: import("zod").ZodOptional<import("zod").ZodString>;
|
|
20
|
+
}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{
|
|
21
|
+
agent_id: import("zod").ZodString;
|
|
22
|
+
color: import("zod").ZodOptional<import("zod").ZodString>;
|
|
23
|
+
avatar_url: import("zod").ZodOptional<import("zod").ZodString>;
|
|
24
|
+
}, import("zod").ZodTypeAny, "passthrough">>;
|
|
25
|
+
annotations: {
|
|
26
|
+
readOnlyHint: boolean;
|
|
27
|
+
destructiveHint: boolean;
|
|
28
|
+
idempotentHint: boolean;
|
|
29
|
+
openWorldHint: boolean;
|
|
30
|
+
};
|
|
31
|
+
handler: (args: unknown) => Promise<{
|
|
32
|
+
content: {
|
|
33
|
+
type: string;
|
|
34
|
+
text: string;
|
|
35
|
+
}[];
|
|
36
|
+
}>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Lists available voices with filtering
|
|
40
|
+
*/
|
|
41
|
+
export declare const elevenlabs_list_voices: {
|
|
42
|
+
name: string;
|
|
43
|
+
description: string;
|
|
44
|
+
zodSchema: import("zod").ZodObject<{
|
|
45
|
+
language: import("zod").ZodOptional<import("zod").ZodString>;
|
|
46
|
+
gender: import("zod").ZodOptional<import("zod").ZodEnum<["male", "female"]>>;
|
|
47
|
+
age: import("zod").ZodOptional<import("zod").ZodEnum<["young", "middle_aged", "old"]>>;
|
|
48
|
+
limit: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
49
|
+
response_format: import("zod").ZodDefault<import("zod").ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
50
|
+
}, "passthrough", import("zod").ZodTypeAny, import("zod").objectOutputType<{
|
|
51
|
+
language: import("zod").ZodOptional<import("zod").ZodString>;
|
|
52
|
+
gender: import("zod").ZodOptional<import("zod").ZodEnum<["male", "female"]>>;
|
|
53
|
+
age: import("zod").ZodOptional<import("zod").ZodEnum<["young", "middle_aged", "old"]>>;
|
|
54
|
+
limit: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
55
|
+
response_format: import("zod").ZodDefault<import("zod").ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
56
|
+
}, import("zod").ZodTypeAny, "passthrough">, import("zod").objectInputType<{
|
|
57
|
+
language: import("zod").ZodOptional<import("zod").ZodString>;
|
|
58
|
+
gender: import("zod").ZodOptional<import("zod").ZodEnum<["male", "female"]>>;
|
|
59
|
+
age: import("zod").ZodOptional<import("zod").ZodEnum<["young", "middle_aged", "old"]>>;
|
|
60
|
+
limit: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
61
|
+
response_format: import("zod").ZodDefault<import("zod").ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
62
|
+
}, import("zod").ZodTypeAny, "passthrough">>;
|
|
63
|
+
annotations: {
|
|
64
|
+
readOnlyHint: boolean;
|
|
65
|
+
destructiveHint: boolean;
|
|
66
|
+
idempotentHint: boolean;
|
|
67
|
+
openWorldHint: boolean;
|
|
68
|
+
};
|
|
69
|
+
handler: (args: unknown) => Promise<{
|
|
70
|
+
content: {
|
|
71
|
+
type: string;
|
|
72
|
+
text: string;
|
|
73
|
+
}[];
|
|
74
|
+
}>;
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=utility-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utility-tools.d.ts","sourceRoot":"","sources":["../../src/tools/utility-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH;;GAEG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;oBAiCpB,OAAO;;;;;;CAqB9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAwCX,OAAO;;;;;;CA8B9B,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility tools
|
|
3
|
+
*
|
|
4
|
+
* MCP tools for widget generation, voice browsing, and other utilities.
|
|
5
|
+
*/
|
|
6
|
+
import { getRequest } from "../services/elevenlabs-api.js";
|
|
7
|
+
import { formatResponse, formatWidgetCode } from "../services/formatters.js";
|
|
8
|
+
import { GenerateWidgetCodeSchema, ListVoicesSchema } from "../schemas/tool-schemas.js";
|
|
9
|
+
/**
|
|
10
|
+
* Generates widget embed code for testing an agent
|
|
11
|
+
*/
|
|
12
|
+
export const elevenlabs_generate_widget_code = {
|
|
13
|
+
name: "elevenlabs_generate_widget_code",
|
|
14
|
+
description: `Generate HTML embed code to test a voice agent on a webpage.
|
|
15
|
+
|
|
16
|
+
This tool creates ready-to-use HTML code that embeds a voice agent widget on any webpage. The widget appears as a floating button that users can click to start a voice conversation with the agent. Perfect for testing agents or deploying them on websites.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
- agent_id (string): Agent to generate widget code for
|
|
20
|
+
- color (string): Optional widget color in hex format (e.g., "#FF5733")
|
|
21
|
+
- avatar_url (string): Optional avatar image URL for the widget
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
HTML code snippet with <script> tags ready to paste into a webpage.
|
|
25
|
+
|
|
26
|
+
Examples:
|
|
27
|
+
- Use when: "Generate embed code to test this agent"
|
|
28
|
+
- Use when: "Create a widget for agent ag_abc123"
|
|
29
|
+
- Use when: "I want to add this agent to my website"
|
|
30
|
+
- Don't use when: You want to create a new agent (use elevenlabs_create_agent)
|
|
31
|
+
|
|
32
|
+
Error Handling:
|
|
33
|
+
- Returns "Error: Agent not found" if agent_id doesn't exist
|
|
34
|
+
- Returns "Error: Invalid color format" if color is not valid hex`,
|
|
35
|
+
zodSchema: GenerateWidgetCodeSchema,
|
|
36
|
+
annotations: {
|
|
37
|
+
readOnlyHint: true,
|
|
38
|
+
destructiveHint: false,
|
|
39
|
+
idempotentHint: true,
|
|
40
|
+
openWorldHint: true
|
|
41
|
+
},
|
|
42
|
+
handler: async (args) => {
|
|
43
|
+
const parsed = GenerateWidgetCodeSchema.parse(args);
|
|
44
|
+
// Verify agent exists
|
|
45
|
+
await getRequest(`/convai/agents/${parsed.agent_id}`);
|
|
46
|
+
const widgetCode = formatWidgetCode(parsed.agent_id, parsed.color, parsed.avatar_url);
|
|
47
|
+
return {
|
|
48
|
+
content: [
|
|
49
|
+
{
|
|
50
|
+
type: "text",
|
|
51
|
+
text: widgetCode
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Lists available voices with filtering
|
|
59
|
+
*/
|
|
60
|
+
export const elevenlabs_list_voices = {
|
|
61
|
+
name: "elevenlabs_list_voices",
|
|
62
|
+
description: `Browse available ElevenLabs voices with optional filtering.
|
|
63
|
+
|
|
64
|
+
This tool retrieves voices you can use for your agents. Filter by language, gender, or age to find the perfect voice. Each voice includes a preview URL so you can listen before choosing.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
- language (string): Optional - filter by language code (e.g., 'en', 'es', 'fr')
|
|
68
|
+
- gender ('male' | 'female'): Optional - filter by gender
|
|
69
|
+
- age ('young' | 'middle_aged' | 'old'): Optional - filter by age category
|
|
70
|
+
- limit (number): Maximum voices to return (1-100, default: 20)
|
|
71
|
+
- response_format ('markdown' | 'json'): Output format
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
List of voices with:
|
|
75
|
+
- Voice ID (for use in agent configuration)
|
|
76
|
+
- Voice name and description
|
|
77
|
+
- Labels (gender, age, accent, use case)
|
|
78
|
+
- Preview URL to listen to the voice
|
|
79
|
+
|
|
80
|
+
Examples:
|
|
81
|
+
- Use when: "Show me all female voices"
|
|
82
|
+
- Use when: "Find voices suitable for customer service"
|
|
83
|
+
- Use when: "List English voices with British accents"
|
|
84
|
+
- Use when: "I need to choose a voice for my agent"
|
|
85
|
+
- Don't use when: You already know the voice_id you want to use
|
|
86
|
+
|
|
87
|
+
Error Handling:
|
|
88
|
+
- Returns empty list if no voices match filters
|
|
89
|
+
- Returns "Error: Invalid API key" if authentication fails`,
|
|
90
|
+
zodSchema: ListVoicesSchema,
|
|
91
|
+
annotations: {
|
|
92
|
+
readOnlyHint: true,
|
|
93
|
+
destructiveHint: false,
|
|
94
|
+
idempotentHint: true,
|
|
95
|
+
openWorldHint: true
|
|
96
|
+
},
|
|
97
|
+
handler: async (args) => {
|
|
98
|
+
const parsed = ListVoicesSchema.parse(args);
|
|
99
|
+
const params = {};
|
|
100
|
+
if (parsed.language) {
|
|
101
|
+
params.language = parsed.language;
|
|
102
|
+
}
|
|
103
|
+
if (parsed.gender) {
|
|
104
|
+
params.gender = parsed.gender;
|
|
105
|
+
}
|
|
106
|
+
if (parsed.age) {
|
|
107
|
+
params.age = parsed.age;
|
|
108
|
+
}
|
|
109
|
+
const response = await getRequest("/voices", params);
|
|
110
|
+
const voices = (response.voices || []).slice(0, parsed.limit);
|
|
111
|
+
return {
|
|
112
|
+
content: [
|
|
113
|
+
{
|
|
114
|
+
type: "text",
|
|
115
|
+
text: formatResponse(voices, parsed.response_format, "voice_list")
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=utility-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utility-tools.js","sourceRoot":"","sources":["../../src/tools/utility-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7E,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AAEpC;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC7C,IAAI,EAAE,iCAAiC;IACvC,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;oEAoBqD;IAElE,SAAS,EAAE,wBAAwB;IAEnC,WAAW,EAAE;QACX,YAAY,EAAE,IAAI;QAClB,eAAe,EAAE,KAAK;QACtB,cAAc,EAAE,IAAI;QACpB,aAAa,EAAE,IAAI;KACpB;IAED,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;QAC/B,MAAM,MAAM,GAAG,wBAAwB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEpD,sBAAsB;QACtB,MAAM,UAAU,CAAC,kBAAkB,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEtD,MAAM,UAAU,GAAG,gBAA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AI,EAAE,MAAM;oBACZ,IAAI,EAAE,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,EAAE,YAAY,CAAC;iBACnE;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript type definitions for ElevenLabs Voice Agent API
|
|
3
|
+
*
|
|
4
|
+
* Defines interfaces for agents, conversations, tools, and API responses.
|
|
5
|
+
*/
|
|
6
|
+
import { SUPPORTED_LLMS, SUPPORTED_VOICE_MODELS, SUPPORTED_LANGUAGES, AUTH_TYPES } from "./constants.js";
|
|
7
|
+
export declare enum ResponseFormat {
|
|
8
|
+
MARKDOWN = "markdown",
|
|
9
|
+
JSON = "json"
|
|
10
|
+
}
|
|
11
|
+
export type LLMModel = typeof SUPPORTED_LLMS[number];
|
|
12
|
+
export type VoiceModel = typeof SUPPORTED_VOICE_MODELS[number];
|
|
13
|
+
export type Language = typeof SUPPORTED_LANGUAGES[number];
|
|
14
|
+
export type AuthType = typeof AUTH_TYPES[number];
|
|
15
|
+
export interface AgentPromptConfig {
|
|
16
|
+
prompt: string;
|
|
17
|
+
llm: LLMModel;
|
|
18
|
+
temperature?: number;
|
|
19
|
+
max_tokens?: number;
|
|
20
|
+
tools?: ToolConfig[];
|
|
21
|
+
knowledge_base?: string[];
|
|
22
|
+
}
|
|
23
|
+
export interface TTSConfig {
|
|
24
|
+
voice_id: string;
|
|
25
|
+
model_id: VoiceModel;
|
|
26
|
+
optimize_streaming_latency?: number;
|
|
27
|
+
stability?: number;
|
|
28
|
+
similarity_boost?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface ASRConfig {
|
|
31
|
+
quality?: "low" | "medium" | "high";
|
|
32
|
+
user_input_audio_format?: "pcm_16000" | "pcm_22050" | "pcm_44100";
|
|
33
|
+
}
|
|
34
|
+
export interface ConversationConfig {
|
|
35
|
+
agent: {
|
|
36
|
+
prompt: AgentPromptConfig;
|
|
37
|
+
first_message?: string;
|
|
38
|
+
language: Language;
|
|
39
|
+
};
|
|
40
|
+
tts: TTSConfig;
|
|
41
|
+
asr?: ASRConfig;
|
|
42
|
+
}
|
|
43
|
+
export interface PlatformSettings {
|
|
44
|
+
widget?: {
|
|
45
|
+
color?: string;
|
|
46
|
+
avatar_url?: string;
|
|
47
|
+
};
|
|
48
|
+
auth?: {
|
|
49
|
+
type: AuthType;
|
|
50
|
+
open_auth_allowed?: boolean;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export interface Agent {
|
|
54
|
+
agent_id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
conversation_config: ConversationConfig;
|
|
57
|
+
platform_settings?: PlatformSettings;
|
|
58
|
+
created_at: string;
|
|
59
|
+
updated_at?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface ToolParameter {
|
|
62
|
+
name: string;
|
|
63
|
+
type: "string" | "number" | "boolean" | "object" | "array";
|
|
64
|
+
description: string;
|
|
65
|
+
required: boolean;
|
|
66
|
+
enum?: string[];
|
|
67
|
+
}
|
|
68
|
+
export interface ToolConfig {
|
|
69
|
+
name: string;
|
|
70
|
+
description: string;
|
|
71
|
+
type: "webhook" | "client";
|
|
72
|
+
url?: string;
|
|
73
|
+
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
74
|
+
headers?: Record<string, string>;
|
|
75
|
+
parameters: ToolParameter[];
|
|
76
|
+
}
|
|
77
|
+
export interface ConversationMetadata {
|
|
78
|
+
conversation_id: string;
|
|
79
|
+
agent_id: string;
|
|
80
|
+
status: "in_progress" | "completed" | "failed";
|
|
81
|
+
started_at: string;
|
|
82
|
+
ended_at?: string;
|
|
83
|
+
duration_seconds?: number;
|
|
84
|
+
transcript?: TranscriptEntry[];
|
|
85
|
+
analysis?: ConversationAnalysis;
|
|
86
|
+
}
|
|
87
|
+
export interface TranscriptEntry {
|
|
88
|
+
role: "agent" | "user";
|
|
89
|
+
message: string;
|
|
90
|
+
timestamp: string;
|
|
91
|
+
tool_calls?: ToolCall[];
|
|
92
|
+
}
|
|
93
|
+
export interface ToolCall {
|
|
94
|
+
tool_name: string;
|
|
95
|
+
parameters: Record<string, unknown>;
|
|
96
|
+
result?: unknown;
|
|
97
|
+
error?: string;
|
|
98
|
+
}
|
|
99
|
+
export interface ConversationAnalysis {
|
|
100
|
+
user_sentiment?: "positive" | "neutral" | "negative";
|
|
101
|
+
agent_performance?: number;
|
|
102
|
+
key_topics?: string[];
|
|
103
|
+
}
|
|
104
|
+
export interface Voice {
|
|
105
|
+
voice_id: string;
|
|
106
|
+
name: string;
|
|
107
|
+
category?: string;
|
|
108
|
+
description?: string;
|
|
109
|
+
preview_url?: string;
|
|
110
|
+
labels?: {
|
|
111
|
+
accent?: string;
|
|
112
|
+
description?: string;
|
|
113
|
+
age?: string;
|
|
114
|
+
gender?: string;
|
|
115
|
+
use_case?: string;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export interface PaginatedResponse<T> {
|
|
119
|
+
total: number;
|
|
120
|
+
count: number;
|
|
121
|
+
offset: number;
|
|
122
|
+
items: T[];
|
|
123
|
+
has_more: boolean;
|
|
124
|
+
next_offset?: number;
|
|
125
|
+
}
|
|
126
|
+
export interface APIResponse<T> {
|
|
127
|
+
success: boolean;
|
|
128
|
+
data?: T;
|
|
129
|
+
error?: string;
|
|
130
|
+
}
|
|
131
|
+
export interface KnowledgeBaseDocument {
|
|
132
|
+
type: "text" | "url" | "file";
|
|
133
|
+
content: string;
|
|
134
|
+
metadata?: Record<string, string>;
|
|
135
|
+
}
|
|
136
|
+
export interface WidgetConfig {
|
|
137
|
+
agent_id: string;
|
|
138
|
+
color?: string;
|
|
139
|
+
avatar_url?: string;
|
|
140
|
+
}
|
|
141
|
+
export interface OutboundCallRequest {
|
|
142
|
+
agent_id: string;
|
|
143
|
+
agent_phone_number_id: string;
|
|
144
|
+
to_number: string;
|
|
145
|
+
/**
|
|
146
|
+
* Conversation initiation data for personalization
|
|
147
|
+
* @example
|
|
148
|
+
* {
|
|
149
|
+
* dynamic_variables: {
|
|
150
|
+
* customer_name: "John Smith",
|
|
151
|
+
* account_id: "12345"
|
|
152
|
+
* },
|
|
153
|
+
* conversation_config_override: {
|
|
154
|
+
* agent: {
|
|
155
|
+
* first_message: "Custom greeting"
|
|
156
|
+
* }
|
|
157
|
+
* }
|
|
158
|
+
* }
|
|
159
|
+
*/
|
|
160
|
+
conversation_initiation_client_data?: Record<string, unknown> | null;
|
|
161
|
+
}
|
|
162
|
+
export interface OutboundCallResponse {
|
|
163
|
+
success: boolean;
|
|
164
|
+
message: string;
|
|
165
|
+
conversation_id: string | null;
|
|
166
|
+
callSid: string | null;
|
|
167
|
+
}
|
|
168
|
+
export type BatchStatus = "pending" | "in_progress" | "completed" | "failed" | "cancelled";
|
|
169
|
+
export type RecipientStatus = BatchStatus | "initiated" | "voicemail";
|
|
170
|
+
export type PhoneProvider = "twilio" | "sip_trunk";
|
|
171
|
+
export interface OutboundCallRecipient {
|
|
172
|
+
id?: string;
|
|
173
|
+
phone_number?: string;
|
|
174
|
+
whatsapp_user_id?: string;
|
|
175
|
+
/**
|
|
176
|
+
* Conversation initiation data for personalization
|
|
177
|
+
* @example
|
|
178
|
+
* {
|
|
179
|
+
* dynamic_variables: {
|
|
180
|
+
* name: "Alice Johnson",
|
|
181
|
+
* account_id: "A123"
|
|
182
|
+
* }
|
|
183
|
+
* }
|
|
184
|
+
*/
|
|
185
|
+
conversation_initiation_client_data?: Record<string, unknown>;
|
|
186
|
+
}
|
|
187
|
+
export interface BatchCallRequest {
|
|
188
|
+
call_name: string;
|
|
189
|
+
agent_id: string;
|
|
190
|
+
recipients: OutboundCallRecipient[];
|
|
191
|
+
scheduled_time_unix?: number | null;
|
|
192
|
+
agent_phone_number_id?: string | null;
|
|
193
|
+
}
|
|
194
|
+
export interface BatchCallResponse {
|
|
195
|
+
id: string;
|
|
196
|
+
name: string;
|
|
197
|
+
agent_id: string;
|
|
198
|
+
agent_name: string;
|
|
199
|
+
status: BatchStatus;
|
|
200
|
+
created_at_unix: number;
|
|
201
|
+
scheduled_time_unix: number;
|
|
202
|
+
last_updated_at_unix: number;
|
|
203
|
+
total_calls_dispatched: number;
|
|
204
|
+
total_calls_scheduled: number;
|
|
205
|
+
phone_number_id: string | null;
|
|
206
|
+
phone_provider: PhoneProvider | null;
|
|
207
|
+
}
|
|
208
|
+
export interface BatchCallRecipient {
|
|
209
|
+
id: string;
|
|
210
|
+
phone_number?: string;
|
|
211
|
+
whatsapp_user_id?: string;
|
|
212
|
+
status: RecipientStatus;
|
|
213
|
+
conversation_id: string;
|
|
214
|
+
created_at_unix: number;
|
|
215
|
+
updated_at_unix: number;
|
|
216
|
+
/**
|
|
217
|
+
* Conversation initiation data for personalization
|
|
218
|
+
* @example
|
|
219
|
+
* {
|
|
220
|
+
* dynamic_variables: {
|
|
221
|
+
* name: "Bob Wilson",
|
|
222
|
+
* appointment_time: "3pm"
|
|
223
|
+
* }
|
|
224
|
+
* }
|
|
225
|
+
*/
|
|
226
|
+
conversation_initiation_client_data?: Record<string, unknown>;
|
|
227
|
+
}
|
|
228
|
+
export interface BatchCallDetailedResponse extends BatchCallResponse {
|
|
229
|
+
recipients: BatchCallRecipient[];
|
|
230
|
+
}
|
|
231
|
+
export interface WorkspaceBatchCallsResponse {
|
|
232
|
+
batch_calls: BatchCallResponse[];
|
|
233
|
+
next_doc: string | null;
|
|
234
|
+
has_more: boolean;
|
|
235
|
+
}
|
|
236
|
+
export interface TwilioPhoneNumber {
|
|
237
|
+
phone_number: string;
|
|
238
|
+
label: string;
|
|
239
|
+
phone_number_id: string;
|
|
240
|
+
supports_inbound: boolean;
|
|
241
|
+
supports_outbound: boolean;
|
|
242
|
+
provider: "twilio";
|
|
243
|
+
assigned_agent: {
|
|
244
|
+
agent_id: string;
|
|
245
|
+
agent_name: string;
|
|
246
|
+
} | null;
|
|
247
|
+
}
|
|
248
|
+
export interface SIPTrunkPhoneNumber {
|
|
249
|
+
phone_number: string;
|
|
250
|
+
label: string;
|
|
251
|
+
phone_number_id: string;
|
|
252
|
+
supports_inbound: boolean;
|
|
253
|
+
supports_outbound: boolean;
|
|
254
|
+
provider: "sip_trunk";
|
|
255
|
+
livekit_stack: "standard" | "static";
|
|
256
|
+
assigned_agent: {
|
|
257
|
+
agent_id: string;
|
|
258
|
+
agent_name: string;
|
|
259
|
+
} | null;
|
|
260
|
+
outbound_trunk?: Record<string, unknown> | null;
|
|
261
|
+
inbound_trunk?: Record<string, unknown> | null;
|
|
262
|
+
provider_config?: Record<string, unknown> | null;
|
|
263
|
+
}
|
|
264
|
+
export type PhoneNumber = TwilioPhoneNumber | SIPTrunkPhoneNumber;
|
|
265
|
+
export interface ImportPhoneNumberRequest {
|
|
266
|
+
phone_number: string;
|
|
267
|
+
label: string;
|
|
268
|
+
sid: string;
|
|
269
|
+
token: string;
|
|
270
|
+
provider: "twilio";
|
|
271
|
+
supports_inbound?: boolean;
|
|
272
|
+
supports_outbound?: boolean;
|
|
273
|
+
region_config?: {
|
|
274
|
+
region_id: "us1" | "ie1" | "au1";
|
|
275
|
+
token: string;
|
|
276
|
+
edge_location: "ashburn" | "dublin" | "frankfurt" | "sao-paulo" | "singapore" | "sydney" | "tokyo" | "umatilla" | "roaming";
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
export interface ImportPhoneNumberResponse {
|
|
280
|
+
phone_number_id: string;
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGzG,oBAAY,cAAc;IACxB,QAAQ,aAAa;IACrB,IAAI,SAAS;CACd;AAED,MAAM,MAAM,QAAQ,GAAG,OAAO,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AAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,aAAa,CAAC,EAAE;QACd,SAAS,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;QACjC,KAAK,EAAE,MAAM,CAAC;QACd,aAAa,EAAE,SAAS,GAAG,QAAQ,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;KAC7H,CAAC;CACH;AAED,MAAM,WAAW,yBAAyB;IACxC,eAAe,EAAE,MAAM,CAAC;CACzB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript type definitions for ElevenLabs Voice Agent API
|
|
3
|
+
*
|
|
4
|
+
* Defines interfaces for agents, conversations, tools, and API responses.
|
|
5
|
+
*/
|
|
6
|
+
// Enums
|
|
7
|
+
export var ResponseFormat;
|
|
8
|
+
(function (ResponseFormat) {
|
|
9
|
+
ResponseFormat["MARKDOWN"] = "markdown";
|
|
10
|
+
ResponseFormat["JSON"] = "json";
|
|
11
|
+
})(ResponseFormat || (ResponseFormat = {}));
|
|
12
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,QAAQ;AACR,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,uCAAqB,CAAA;IACrB,+BAAa,CAAA;AACf,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error handling utilities for ElevenLabs API requests
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent error handling and user-friendly error messages
|
|
5
|
+
* for various API error scenarios.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Handles errors from ElevenLabs API requests
|
|
9
|
+
*
|
|
10
|
+
* @param error - The error object from axios or other sources
|
|
11
|
+
* @param context - Additional context about the operation (e.g., "creating agent")
|
|
12
|
+
* @returns User-friendly error message with actionable guidance
|
|
13
|
+
*/
|
|
14
|
+
export declare function handleElevenLabsError(error: unknown, context?: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Validates that the API key is present in environment
|
|
17
|
+
*
|
|
18
|
+
* @throws Error if ELEVENLABS_API_KEY is not set
|
|
19
|
+
*/
|
|
20
|
+
export declare function validateApiKey(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Wraps an async function with error handling
|
|
23
|
+
*
|
|
24
|
+
* @param fn - The async function to wrap
|
|
25
|
+
* @param context - Context for error messages
|
|
26
|
+
* @returns Wrapped function that handles errors consistently
|
|
27
|
+
*/
|
|
28
|
+
export declare function withErrorHandling<T extends unknown[], R>(fn: (...args: T) => Promise<R>, context?: string): (...args: T) => Promise<R>;
|
|
29
|
+
//# sourceMappingURL=error-handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handlers.d.ts","sourceRoot":"","sources":["../../src/utils/error-handlers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CA+C9E;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAOrC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,EACtD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,EAC9B,OAAO,CAAC,EAAE,MAAM,GACf,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAQ5B"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error handling utilities for ElevenLabs API requests
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent error handling and user-friendly error messages
|
|
5
|
+
* for various API error scenarios.
|
|
6
|
+
*/
|
|
7
|
+
import axios from "axios";
|
|
8
|
+
/**
|
|
9
|
+
* Handles errors from ElevenLabs API requests
|
|
10
|
+
*
|
|
11
|
+
* @param error - The error object from axios or other sources
|
|
12
|
+
* @param context - Additional context about the operation (e.g., "creating agent")
|
|
13
|
+
* @returns User-friendly error message with actionable guidance
|
|
14
|
+
*/
|
|
15
|
+
export function handleElevenLabsError(error, context) {
|
|
16
|
+
const prefix = context ? `Error ${context}: ` : "Error: ";
|
|
17
|
+
if (axios.isAxiosError(error)) {
|
|
18
|
+
if (error.response) {
|
|
19
|
+
// Server responded with error status
|
|
20
|
+
const status = error.response.status;
|
|
21
|
+
const data = error.response.data;
|
|
22
|
+
const detail = data?.detail || data?.message;
|
|
23
|
+
switch (status) {
|
|
24
|
+
case 400:
|
|
25
|
+
return `${prefix}Invalid request - ${detail || "Check your parameters"}`;
|
|
26
|
+
case 401:
|
|
27
|
+
return `${prefix}Invalid API key. Please check your ELEVENLABS_API_KEY environment variable.`;
|
|
28
|
+
case 403:
|
|
29
|
+
return `${prefix}Access forbidden. Your API key may not have permission for this operation.`;
|
|
30
|
+
case 404:
|
|
31
|
+
return `${prefix}Resource not found. Please verify the ID is correct.`;
|
|
32
|
+
case 409:
|
|
33
|
+
return `${prefix}Conflict - ${detail || "Resource already exists or is in use"}`;
|
|
34
|
+
case 422:
|
|
35
|
+
return `${prefix}Validation error - ${detail || "Invalid data format"}`;
|
|
36
|
+
case 429:
|
|
37
|
+
return `${prefix}Rate limit exceeded. Please wait 60 seconds before retrying.`;
|
|
38
|
+
case 500:
|
|
39
|
+
return `${prefix}ElevenLabs server error. Please try again in a few moments.`;
|
|
40
|
+
case 503:
|
|
41
|
+
return `${prefix}Service temporarily unavailable. Please try again later.`;
|
|
42
|
+
default:
|
|
43
|
+
return `${prefix}API request failed with status ${status}${detail ? `: ${detail}` : ""}`;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else if (error.code === "ECONNABORTED") {
|
|
47
|
+
return `${prefix}Request timed out. Please try again or check your network connection.`;
|
|
48
|
+
}
|
|
49
|
+
else if (error.code === "ENOTFOUND" || error.code === "ECONNREFUSED") {
|
|
50
|
+
return `${prefix}Cannot connect to ElevenLabs API. Please check your internet connection.`;
|
|
51
|
+
}
|
|
52
|
+
else if (error.message) {
|
|
53
|
+
return `${prefix}Network error - ${error.message}`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Generic error handling
|
|
57
|
+
if (error instanceof Error) {
|
|
58
|
+
return `${prefix}${error.message}`;
|
|
59
|
+
}
|
|
60
|
+
return `${prefix}Unexpected error occurred: ${String(error)}`;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Validates that the API key is present in environment
|
|
64
|
+
*
|
|
65
|
+
* @throws Error if ELEVENLABS_API_KEY is not set
|
|
66
|
+
*/
|
|
67
|
+
export function validateApiKey() {
|
|
68
|
+
if (!process.env.ELEVENLABS_API_KEY) {
|
|
69
|
+
throw new Error("ELEVENLABS_API_KEY environment variable is not set. " +
|
|
70
|
+
"Please set it to your ElevenLabs API key.");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Wraps an async function with error handling
|
|
75
|
+
*
|
|
76
|
+
* @param fn - The async function to wrap
|
|
77
|
+
* @param context - Context for error messages
|
|
78
|
+
* @returns Wrapped function that handles errors consistently
|
|
79
|
+
*/
|
|
80
|
+
export function withErrorHandling(fn, context) {
|
|
81
|
+
return async (...args) => {
|
|
82
|
+
try {
|
|
83
|
+
return await fn(...args);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
throw new Error(handleElevenLabsError(error, context));
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=error-handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handlers.js","sourceRoot":"","sources":["../../src/utils/error-handlers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAc,EAAE,OAAgB;IACpE,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,OAAO,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAE1D,IAAI,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACnB,qCAAqC;YACrC,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;YACrC,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,IAA6C,CAAC;YAC1E,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,IAAI,EAAE,OAAO,CAAC;YAE7C,QAAQ,MAAM,EAAE,CAAC;gBACf,KAAK,GAAG;oBACN,OAAO,GAAG,MAAM,qBAAqB,MAAM,IAAI,uBAAuB,EAAE,CAAC;gBAC3E,KAAK,GAAG;oBACN,OAAO,GAAG,MAAM,6EAA6E,CAAC;gBAChG,KAAK,GAAG;oBACN,OAAO,GAAG,MAAM,4EAA4E,CAAC;gBAC/F,KAAK,GAAG;oBACN,OAAO,GAAG,MAAM,sDAAsD,CAAC;gBACzE,KAAK,GAAG;oBACN,OAAO,GAAG,MAAM,cAAc,MAAM,IAAI,sCAAsC,EAAE,CAAC;gBACnF,KAAK,GAAG;oBACN,OAAO,GAAG,MAAM,sBAAsB,MAAM,IAAI,qBAAqB,EAAE,CAAC;gBAC1E,KAAK,GAAG;oBACN,OAAO,GAAG,MAAM,8DAA8D,CAAC;gBACjF,KAAK,GAAG;oBACN,OAAO,GAAG,MAAM,6DAA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