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
package/dist/index.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* ElevenLabs Voice Agent MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Main entry point for the MCP server providing tools for voice agent development.
|
|
6
|
+
*/
|
|
7
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
9
|
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
10
|
+
import { validateApiKey } from "./utils/error-handlers.js";
|
|
11
|
+
// Import all tools
|
|
12
|
+
import { elevenlabs_create_agent, elevenlabs_get_agent, elevenlabs_update_agent, elevenlabs_delete_agent, elevenlabs_list_agents } from "./tools/agent-tools.js";
|
|
13
|
+
import { elevenlabs_add_knowledge_base } from "./tools/knowledge-tools.js";
|
|
14
|
+
import { elevenlabs_create_webhook_tool, elevenlabs_list_tools, elevenlabs_delete_tool } from "./tools/tool-tools.js";
|
|
15
|
+
import { elevenlabs_get_conversation, elevenlabs_list_conversations } from "./tools/conversation-tools.js";
|
|
16
|
+
import { elevenlabs_generate_widget_code, elevenlabs_list_voices } from "./tools/utility-tools.js";
|
|
17
|
+
import { elevenlabs_start_outbound_call } from "./tools/outbound-tools.js";
|
|
18
|
+
import { elevenlabs_submit_batch_call, elevenlabs_list_batch_calls, elevenlabs_get_batch_call } from "./tools/batch-calling-tools.js";
|
|
19
|
+
import { elevenlabs_list_phone_numbers, elevenlabs_get_phone_number, elevenlabs_import_phone_number, elevenlabs_update_phone_number, elevenlabs_delete_phone_number } from "./tools/phone-number-tools.js";
|
|
20
|
+
/**
|
|
21
|
+
* Initialize and start the MCP server
|
|
22
|
+
*/
|
|
23
|
+
async function main() {
|
|
24
|
+
// Validate API key on startup
|
|
25
|
+
try {
|
|
26
|
+
validateApiKey();
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
console.error("Failed to start MCP server:", error instanceof Error ? error.message : String(error));
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
// Create MCP server instance
|
|
33
|
+
const server = new McpServer({
|
|
34
|
+
name: "elevenlabs-voice-agent-mcp",
|
|
35
|
+
version: "1.0.0"
|
|
36
|
+
});
|
|
37
|
+
// Register all tools
|
|
38
|
+
const tools = [
|
|
39
|
+
// Tier 1: Core Agent Management
|
|
40
|
+
elevenlabs_create_agent,
|
|
41
|
+
elevenlabs_get_agent,
|
|
42
|
+
elevenlabs_update_agent,
|
|
43
|
+
elevenlabs_delete_agent,
|
|
44
|
+
elevenlabs_list_agents,
|
|
45
|
+
// Tier 2: Knowledge Base & Tools
|
|
46
|
+
elevenlabs_add_knowledge_base,
|
|
47
|
+
elevenlabs_create_webhook_tool,
|
|
48
|
+
elevenlabs_list_tools,
|
|
49
|
+
elevenlabs_delete_tool,
|
|
50
|
+
// Tier 3: Testing & Monitoring
|
|
51
|
+
elevenlabs_get_conversation,
|
|
52
|
+
elevenlabs_list_conversations,
|
|
53
|
+
elevenlabs_generate_widget_code,
|
|
54
|
+
// Tier 4: Utilities
|
|
55
|
+
elevenlabs_list_voices,
|
|
56
|
+
// Tier 5: Outbound Calling & Phone Management
|
|
57
|
+
elevenlabs_start_outbound_call,
|
|
58
|
+
elevenlabs_submit_batch_call,
|
|
59
|
+
elevenlabs_list_batch_calls,
|
|
60
|
+
elevenlabs_get_batch_call,
|
|
61
|
+
elevenlabs_list_phone_numbers,
|
|
62
|
+
elevenlabs_get_phone_number,
|
|
63
|
+
elevenlabs_import_phone_number,
|
|
64
|
+
elevenlabs_update_phone_number,
|
|
65
|
+
elevenlabs_delete_phone_number
|
|
66
|
+
];
|
|
67
|
+
// Register each tool with the server
|
|
68
|
+
for (const tool of tools) {
|
|
69
|
+
const zodSchema = tool.zodSchema;
|
|
70
|
+
const inputSchema = zodSchema ? zodToJsonSchema(zodSchema, tool.name) : undefined;
|
|
71
|
+
const annotations = tool.annotations;
|
|
72
|
+
server.registerTool(tool.name, {
|
|
73
|
+
description: tool.description,
|
|
74
|
+
...(inputSchema && { inputSchema }),
|
|
75
|
+
...(annotations && { annotations })
|
|
76
|
+
},
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
|
+
tool.handler);
|
|
79
|
+
}
|
|
80
|
+
// Set up stdio transport
|
|
81
|
+
const transport = new StdioServerTransport();
|
|
82
|
+
// Connect server to transport
|
|
83
|
+
await server.connect(transport);
|
|
84
|
+
console.error("ElevenLabs Voice Agent MCP server running on stdio");
|
|
85
|
+
console.error(`Registered ${tools.length} tools`);
|
|
86
|
+
console.error("API Key:", process.env.ELEVENLABS_API_KEY ? "✓ Set" : "✗ Not set");
|
|
87
|
+
}
|
|
88
|
+
// Start the server
|
|
89
|
+
main().catch((error) => {
|
|
90
|
+
console.error("Fatal error:", error);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,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GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;AACpF,CAAC;AAED,mBAAmB;AACnB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod validation schemas for agent-related operations
|
|
3
|
+
*
|
|
4
|
+
* Provides strict input validation for creating, updating, and managing agents.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
/**
|
|
8
|
+
* Schema for creating a new agent
|
|
9
|
+
*/
|
|
10
|
+
export declare const CreateAgentSchema: z.ZodObject<{
|
|
11
|
+
name: z.ZodString;
|
|
12
|
+
prompt: z.ZodString;
|
|
13
|
+
llm: z.ZodDefault<z.ZodEnum<["gpt-4o", "gpt-4o-mini", "claude-3-5-sonnet-20241022", "claude-3-5-haiku-20241022", "gemini-2.0-flash-exp"]>>;
|
|
14
|
+
voice_id: z.ZodDefault<z.ZodString>;
|
|
15
|
+
voice_model: z.ZodDefault<z.ZodEnum<["eleven_turbo_v2_5", "eleven_flash_v2_5", "eleven_multilingual_v2"]>>;
|
|
16
|
+
first_message: z.ZodOptional<z.ZodString>;
|
|
17
|
+
language: z.ZodDefault<z.ZodEnum<["en", "es", "fr", "de", "it", "pt", "pl", "nl", "ja", "zh", "ko", "ar", "hi"]>>;
|
|
18
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
stability: z.ZodOptional<z.ZodNumber>;
|
|
21
|
+
similarity_boost: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
widget_color: z.ZodOptional<z.ZodString>;
|
|
23
|
+
widget_avatar_url: z.ZodOptional<z.ZodString>;
|
|
24
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
25
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
26
|
+
name: z.ZodString;
|
|
27
|
+
prompt: z.ZodString;
|
|
28
|
+
llm: z.ZodDefault<z.ZodEnum<["gpt-4o", "gpt-4o-mini", "claude-3-5-sonnet-20241022", "claude-3-5-haiku-20241022", "gemini-2.0-flash-exp"]>>;
|
|
29
|
+
voice_id: z.ZodDefault<z.ZodString>;
|
|
30
|
+
voice_model: z.ZodDefault<z.ZodEnum<["eleven_turbo_v2_5", "eleven_flash_v2_5", "eleven_multilingual_v2"]>>;
|
|
31
|
+
first_message: z.ZodOptional<z.ZodString>;
|
|
32
|
+
language: z.ZodDefault<z.ZodEnum<["en", "es", "fr", "de", "it", "pt", "pl", "nl", "ja", "zh", "ko", "ar", "hi"]>>;
|
|
33
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
stability: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
similarity_boost: z.ZodOptional<z.ZodNumber>;
|
|
37
|
+
widget_color: z.ZodOptional<z.ZodString>;
|
|
38
|
+
widget_avatar_url: z.ZodOptional<z.ZodString>;
|
|
39
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
40
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
41
|
+
name: z.ZodString;
|
|
42
|
+
prompt: z.ZodString;
|
|
43
|
+
llm: z.ZodDefault<z.ZodEnum<["gpt-4o", "gpt-4o-mini", "claude-3-5-sonnet-20241022", "claude-3-5-haiku-20241022", "gemini-2.0-flash-exp"]>>;
|
|
44
|
+
voice_id: z.ZodDefault<z.ZodString>;
|
|
45
|
+
voice_model: z.ZodDefault<z.ZodEnum<["eleven_turbo_v2_5", "eleven_flash_v2_5", "eleven_multilingual_v2"]>>;
|
|
46
|
+
first_message: z.ZodOptional<z.ZodString>;
|
|
47
|
+
language: z.ZodDefault<z.ZodEnum<["en", "es", "fr", "de", "it", "pt", "pl", "nl", "ja", "zh", "ko", "ar", "hi"]>>;
|
|
48
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
50
|
+
stability: z.ZodOptional<z.ZodNumber>;
|
|
51
|
+
similarity_boost: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
widget_color: z.ZodOptional<z.ZodString>;
|
|
53
|
+
widget_avatar_url: z.ZodOptional<z.ZodString>;
|
|
54
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
55
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
56
|
+
/**
|
|
57
|
+
* Schema for getting an agent by ID
|
|
58
|
+
*/
|
|
59
|
+
export declare const GetAgentSchema: z.ZodObject<{
|
|
60
|
+
agent_id: z.ZodString;
|
|
61
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
62
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
63
|
+
agent_id: z.ZodString;
|
|
64
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
65
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
66
|
+
agent_id: z.ZodString;
|
|
67
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
68
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
69
|
+
/**
|
|
70
|
+
* Schema for updating an agent
|
|
71
|
+
*/
|
|
72
|
+
export declare const UpdateAgentSchema: z.ZodObject<{
|
|
73
|
+
agent_id: z.ZodString;
|
|
74
|
+
name: z.ZodOptional<z.ZodString>;
|
|
75
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
76
|
+
llm: z.ZodOptional<z.ZodEnum<["gpt-4o", "gpt-4o-mini", "claude-3-5-sonnet-20241022", "claude-3-5-haiku-20241022", "gemini-2.0-flash-exp"]>>;
|
|
77
|
+
voice_id: z.ZodOptional<z.ZodString>;
|
|
78
|
+
voice_model: z.ZodOptional<z.ZodEnum<["eleven_turbo_v2_5", "eleven_flash_v2_5", "eleven_multilingual_v2"]>>;
|
|
79
|
+
first_message: z.ZodOptional<z.ZodString>;
|
|
80
|
+
language: z.ZodOptional<z.ZodEnum<["en", "es", "fr", "de", "it", "pt", "pl", "nl", "ja", "zh", "ko", "ar", "hi"]>>;
|
|
81
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
82
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
83
|
+
stability: z.ZodOptional<z.ZodNumber>;
|
|
84
|
+
similarity_boost: z.ZodOptional<z.ZodNumber>;
|
|
85
|
+
widget_color: z.ZodOptional<z.ZodString>;
|
|
86
|
+
widget_avatar_url: z.ZodOptional<z.ZodString>;
|
|
87
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
88
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
89
|
+
agent_id: z.ZodString;
|
|
90
|
+
name: z.ZodOptional<z.ZodString>;
|
|
91
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
92
|
+
llm: z.ZodOptional<z.ZodEnum<["gpt-4o", "gpt-4o-mini", "claude-3-5-sonnet-20241022", "claude-3-5-haiku-20241022", "gemini-2.0-flash-exp"]>>;
|
|
93
|
+
voice_id: z.ZodOptional<z.ZodString>;
|
|
94
|
+
voice_model: z.ZodOptional<z.ZodEnum<["eleven_turbo_v2_5", "eleven_flash_v2_5", "eleven_multilingual_v2"]>>;
|
|
95
|
+
first_message: z.ZodOptional<z.ZodString>;
|
|
96
|
+
language: z.ZodOptional<z.ZodEnum<["en", "es", "fr", "de", "it", "pt", "pl", "nl", "ja", "zh", "ko", "ar", "hi"]>>;
|
|
97
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
99
|
+
stability: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
similarity_boost: z.ZodOptional<z.ZodNumber>;
|
|
101
|
+
widget_color: z.ZodOptional<z.ZodString>;
|
|
102
|
+
widget_avatar_url: z.ZodOptional<z.ZodString>;
|
|
103
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
104
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
105
|
+
agent_id: z.ZodString;
|
|
106
|
+
name: z.ZodOptional<z.ZodString>;
|
|
107
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
108
|
+
llm: z.ZodOptional<z.ZodEnum<["gpt-4o", "gpt-4o-mini", "claude-3-5-sonnet-20241022", "claude-3-5-haiku-20241022", "gemini-2.0-flash-exp"]>>;
|
|
109
|
+
voice_id: z.ZodOptional<z.ZodString>;
|
|
110
|
+
voice_model: z.ZodOptional<z.ZodEnum<["eleven_turbo_v2_5", "eleven_flash_v2_5", "eleven_multilingual_v2"]>>;
|
|
111
|
+
first_message: z.ZodOptional<z.ZodString>;
|
|
112
|
+
language: z.ZodOptional<z.ZodEnum<["en", "es", "fr", "de", "it", "pt", "pl", "nl", "ja", "zh", "ko", "ar", "hi"]>>;
|
|
113
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
114
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
115
|
+
stability: z.ZodOptional<z.ZodNumber>;
|
|
116
|
+
similarity_boost: z.ZodOptional<z.ZodNumber>;
|
|
117
|
+
widget_color: z.ZodOptional<z.ZodString>;
|
|
118
|
+
widget_avatar_url: z.ZodOptional<z.ZodString>;
|
|
119
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
120
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
121
|
+
/**
|
|
122
|
+
* Schema for deleting an agent
|
|
123
|
+
*/
|
|
124
|
+
export declare const DeleteAgentSchema: z.ZodObject<{
|
|
125
|
+
agent_id: z.ZodString;
|
|
126
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
127
|
+
agent_id: z.ZodString;
|
|
128
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
129
|
+
agent_id: z.ZodString;
|
|
130
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
131
|
+
/**
|
|
132
|
+
* Schema for listing agents
|
|
133
|
+
*/
|
|
134
|
+
export declare const ListAgentsSchema: z.ZodObject<{
|
|
135
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
136
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
137
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
138
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
139
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
140
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
141
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
142
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
143
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
144
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
145
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
146
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
147
|
+
//# sourceMappingURL=agent-schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-schemas.d.ts","sourceRoot":"","sources":["../../src/schemas/agent-schemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoBxB;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAoEd,CAAC;AAEjB;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;gCAGX,CAAC;AAEjB;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAkEd,CAAC;AAEjB;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;gCAEd,CAAC;AAEjB;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;gCAIb,CAAC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod validation schemas for agent-related operations
|
|
3
|
+
*
|
|
4
|
+
* Provides strict input validation for creating, updating, and managing agents.
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import { SUPPORTED_LLMS, SUPPORTED_VOICE_MODELS, SUPPORTED_LANGUAGES, DEFAULT_LLM, DEFAULT_VOICE_MODEL, DEFAULT_VOICE_ID, DEFAULT_LANGUAGE } from "../constants.js";
|
|
8
|
+
import { ResponseFormatSchema, LimitSchema, OffsetSchema, AgentIdSchema, VoiceIdSchema, ColorSchema, URLSchema } from "./common-schemas.js";
|
|
9
|
+
/**
|
|
10
|
+
* Schema for creating a new agent
|
|
11
|
+
*/
|
|
12
|
+
export const CreateAgentSchema = z.object({
|
|
13
|
+
name: z.string()
|
|
14
|
+
.min(1, "Agent name is required")
|
|
15
|
+
.max(100, "Name must not exceed 100 characters")
|
|
16
|
+
.describe("Display name for the agent (e.g., 'Customer Support Bot')"),
|
|
17
|
+
prompt: z.string()
|
|
18
|
+
.min(10, "Prompt must be at least 10 characters")
|
|
19
|
+
.max(5000, "Prompt must not exceed 5000 characters")
|
|
20
|
+
.describe("System prompt defining agent behavior and personality"),
|
|
21
|
+
llm: z.enum(SUPPORTED_LLMS, {
|
|
22
|
+
errorMap: () => ({ message: `LLM must be one of: ${SUPPORTED_LLMS.join(", ")}` })
|
|
23
|
+
})
|
|
24
|
+
.default(DEFAULT_LLM)
|
|
25
|
+
.describe(`LLM model to use (default: ${DEFAULT_LLM})`),
|
|
26
|
+
voice_id: VoiceIdSchema
|
|
27
|
+
.default(DEFAULT_VOICE_ID)
|
|
28
|
+
.describe(`ElevenLabs voice ID (default: ${DEFAULT_VOICE_ID} - Rachel)`),
|
|
29
|
+
voice_model: z.enum(SUPPORTED_VOICE_MODELS, {
|
|
30
|
+
errorMap: () => ({ message: `Voice model must be one of: ${SUPPORTED_VOICE_MODELS.join(", ")}` })
|
|
31
|
+
})
|
|
32
|
+
.default(DEFAULT_VOICE_MODEL)
|
|
33
|
+
.describe(`Voice model to use (default: ${DEFAULT_VOICE_MODEL})`),
|
|
34
|
+
first_message: z.string()
|
|
35
|
+
.max(500, "First message must not exceed 500 characters")
|
|
36
|
+
.optional()
|
|
37
|
+
.describe("Optional greeting message the agent will say first"),
|
|
38
|
+
language: z.enum(SUPPORTED_LANGUAGES, {
|
|
39
|
+
errorMap: () => ({ message: `Language must be one of: ${SUPPORTED_LANGUAGES.join(", ")}` })
|
|
40
|
+
})
|
|
41
|
+
.default(DEFAULT_LANGUAGE)
|
|
42
|
+
.describe(`Primary language code (default: ${DEFAULT_LANGUAGE})`),
|
|
43
|
+
temperature: z.number()
|
|
44
|
+
.min(0, "Temperature must be between 0 and 2")
|
|
45
|
+
.max(2, "Temperature must be between 0 and 2")
|
|
46
|
+
.optional()
|
|
47
|
+
.describe("LLM temperature for response randomness (0-2, higher = more creative)"),
|
|
48
|
+
max_tokens: z.number()
|
|
49
|
+
.int("Max tokens must be an integer")
|
|
50
|
+
.min(1, "Max tokens must be at least 1")
|
|
51
|
+
.max(4096, "Max tokens must not exceed 4096")
|
|
52
|
+
.optional()
|
|
53
|
+
.describe("Maximum tokens for LLM responses"),
|
|
54
|
+
stability: z.number()
|
|
55
|
+
.min(0, "Stability must be between 0 and 1")
|
|
56
|
+
.max(1, "Stability must be between 0 and 1")
|
|
57
|
+
.optional()
|
|
58
|
+
.describe("Voice stability (0-1, higher = more consistent)"),
|
|
59
|
+
similarity_boost: z.number()
|
|
60
|
+
.min(0, "Similarity boost must be between 0 and 1")
|
|
61
|
+
.max(1, "Similarity boost must be between 0 and 1")
|
|
62
|
+
.optional()
|
|
63
|
+
.describe("Voice similarity boost (0-1, higher = closer to original voice)"),
|
|
64
|
+
widget_color: ColorSchema.optional().describe("Widget theme color"),
|
|
65
|
+
widget_avatar_url: URLSchema.optional().describe("Widget avatar image URL"),
|
|
66
|
+
response_format: ResponseFormatSchema
|
|
67
|
+
}).passthrough();
|
|
68
|
+
/**
|
|
69
|
+
* Schema for getting an agent by ID
|
|
70
|
+
*/
|
|
71
|
+
export const GetAgentSchema = z.object({
|
|
72
|
+
agent_id: AgentIdSchema,
|
|
73
|
+
response_format: ResponseFormatSchema
|
|
74
|
+
}).passthrough();
|
|
75
|
+
/**
|
|
76
|
+
* Schema for updating an agent
|
|
77
|
+
*/
|
|
78
|
+
export const UpdateAgentSchema = z.object({
|
|
79
|
+
agent_id: AgentIdSchema,
|
|
80
|
+
name: z.string()
|
|
81
|
+
.min(1, "Agent name cannot be empty")
|
|
82
|
+
.max(100, "Name must not exceed 100 characters")
|
|
83
|
+
.optional()
|
|
84
|
+
.describe("New display name for the agent"),
|
|
85
|
+
prompt: z.string()
|
|
86
|
+
.min(10, "Prompt must be at least 10 characters")
|
|
87
|
+
.max(5000, "Prompt must not exceed 5000 characters")
|
|
88
|
+
.optional()
|
|
89
|
+
.describe("Updated system prompt"),
|
|
90
|
+
llm: z.enum(SUPPORTED_LLMS)
|
|
91
|
+
.optional()
|
|
92
|
+
.describe("Updated LLM model"),
|
|
93
|
+
voice_id: VoiceIdSchema
|
|
94
|
+
.optional()
|
|
95
|
+
.describe("Updated voice ID"),
|
|
96
|
+
voice_model: z.enum(SUPPORTED_VOICE_MODELS)
|
|
97
|
+
.optional()
|
|
98
|
+
.describe("Updated voice model"),
|
|
99
|
+
first_message: z.string()
|
|
100
|
+
.max(500, "First message must not exceed 500 characters")
|
|
101
|
+
.optional()
|
|
102
|
+
.describe("Updated first message"),
|
|
103
|
+
language: z.enum(SUPPORTED_LANGUAGES)
|
|
104
|
+
.optional()
|
|
105
|
+
.describe("Updated language"),
|
|
106
|
+
temperature: z.number()
|
|
107
|
+
.min(0)
|
|
108
|
+
.max(2)
|
|
109
|
+
.optional()
|
|
110
|
+
.describe("Updated temperature"),
|
|
111
|
+
max_tokens: z.number()
|
|
112
|
+
.int()
|
|
113
|
+
.min(1)
|
|
114
|
+
.max(4096)
|
|
115
|
+
.optional()
|
|
116
|
+
.describe("Updated max tokens"),
|
|
117
|
+
stability: z.number()
|
|
118
|
+
.min(0)
|
|
119
|
+
.max(1)
|
|
120
|
+
.optional()
|
|
121
|
+
.describe("Updated voice stability"),
|
|
122
|
+
similarity_boost: z.number()
|
|
123
|
+
.min(0)
|
|
124
|
+
.max(1)
|
|
125
|
+
.optional()
|
|
126
|
+
.describe("Updated similarity boost"),
|
|
127
|
+
widget_color: ColorSchema.optional().describe("Updated widget color"),
|
|
128
|
+
widget_avatar_url: URLSchema.optional().describe("Updated widget avatar URL"),
|
|
129
|
+
response_format: ResponseFormatSchema
|
|
130
|
+
}).passthrough();
|
|
131
|
+
/**
|
|
132
|
+
* Schema for deleting an agent
|
|
133
|
+
*/
|
|
134
|
+
export const DeleteAgentSchema = z.object({
|
|
135
|
+
agent_id: AgentIdSchema
|
|
136
|
+
}).passthrough();
|
|
137
|
+
/**
|
|
138
|
+
* Schema for listing agents
|
|
139
|
+
*/
|
|
140
|
+
export const ListAgentsSchema = z.object({
|
|
141
|
+
limit: LimitSchema,
|
|
142
|
+
offset: OffsetSchema,
|
|
143
|
+
response_format: ResponseFormatSchema
|
|
144
|
+
}).passthrough();
|
|
145
|
+
//# sourceMappingURL=agent-schemas.js.map
|
|
@@ -0,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MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,QAAQ,EAAE,aAAa;CACxB,CAAC,CAAC,WAAW,EAAE,CAAC;AAEjB;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,KAAK,EAAE,WAAW;IAClB,MAAM,EAAE,YAAY;IACpB,eAAe,EAAE,oBAAoB;CACtC,CAAC,CAAC,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod validation schemas for batch calling operations
|
|
3
|
+
*
|
|
4
|
+
* Provides strict input validation for submitting batch call jobs,
|
|
5
|
+
* listing batch calls, and retrieving batch call details.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
/**
|
|
9
|
+
* Batch ID schema
|
|
10
|
+
*/
|
|
11
|
+
export declare const BatchIdSchema: z.ZodString;
|
|
12
|
+
/**
|
|
13
|
+
* Recipient schema for batch calling
|
|
14
|
+
*/
|
|
15
|
+
export declare const OutboundCallRecipientSchema: z.ZodEffects<z.ZodObject<{
|
|
16
|
+
id: z.ZodOptional<z.ZodString>;
|
|
17
|
+
phone_number: z.ZodOptional<z.ZodString>;
|
|
18
|
+
whatsapp_user_id: z.ZodOptional<z.ZodString>;
|
|
19
|
+
conversation_initiation_client_data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
phone_number?: string | undefined;
|
|
22
|
+
conversation_initiation_client_data?: Record<string, any> | undefined;
|
|
23
|
+
id?: string | undefined;
|
|
24
|
+
whatsapp_user_id?: string | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
phone_number?: string | undefined;
|
|
27
|
+
conversation_initiation_client_data?: Record<string, any> | undefined;
|
|
28
|
+
id?: string | undefined;
|
|
29
|
+
whatsapp_user_id?: string | undefined;
|
|
30
|
+
}>, {
|
|
31
|
+
phone_number?: string | undefined;
|
|
32
|
+
conversation_initiation_client_data?: Record<string, any> | undefined;
|
|
33
|
+
id?: string | undefined;
|
|
34
|
+
whatsapp_user_id?: string | undefined;
|
|
35
|
+
}, {
|
|
36
|
+
phone_number?: string | undefined;
|
|
37
|
+
conversation_initiation_client_data?: Record<string, any> | undefined;
|
|
38
|
+
id?: string | undefined;
|
|
39
|
+
whatsapp_user_id?: string | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Schema for submitting a batch call job
|
|
43
|
+
*/
|
|
44
|
+
export declare const SubmitBatchCallSchema: z.ZodObject<{
|
|
45
|
+
call_name: z.ZodString;
|
|
46
|
+
agent_id: z.ZodString;
|
|
47
|
+
recipients: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
48
|
+
id: z.ZodOptional<z.ZodString>;
|
|
49
|
+
phone_number: z.ZodOptional<z.ZodString>;
|
|
50
|
+
whatsapp_user_id: z.ZodOptional<z.ZodString>;
|
|
51
|
+
conversation_initiation_client_data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
phone_number?: string | undefined;
|
|
54
|
+
conversation_initiation_client_data?: Record<string, any> | undefined;
|
|
55
|
+
id?: string | undefined;
|
|
56
|
+
whatsapp_user_id?: string | undefined;
|
|
57
|
+
}, {
|
|
58
|
+
phone_number?: string | undefined;
|
|
59
|
+
conversation_initiation_client_data?: Record<string, any> | undefined;
|
|
60
|
+
id?: string | undefined;
|
|
61
|
+
whatsapp_user_id?: string | undefined;
|
|
62
|
+
}>, {
|
|
63
|
+
phone_number?: string | undefined;
|
|
64
|
+
conversation_initiation_client_data?: Record<string, any> | undefined;
|
|
65
|
+
id?: string | undefined;
|
|
66
|
+
whatsapp_user_id?: string | undefined;
|
|
67
|
+
}, {
|
|
68
|
+
phone_number?: string | undefined;
|
|
69
|
+
conversation_initiation_client_data?: Record<string, any> | undefined;
|
|
70
|
+
id?: string | undefined;
|
|
71
|
+
whatsapp_user_id?: string | undefined;
|
|
72
|
+
}>, "many">;
|
|
73
|
+
scheduled_time_unix: z.ZodOptional<z.ZodNumber>;
|
|
74
|
+
agent_phone_number_id: z.ZodOptional<z.ZodString>;
|
|
75
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
76
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
77
|
+
call_name: z.ZodString;
|
|
78
|
+
agent_id: z.ZodString;
|
|
79
|
+
recipients: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
80
|
+
id: z.ZodOptional<z.ZodString>;
|
|
81
|
+
phone_number: z.ZodOptional<z.ZodString>;
|
|
82
|
+
whatsapp_user_id: z.ZodOptional<z.ZodString>;
|
|
83
|
+
conversation_initiation_client_data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
84
|
+
}, "strip", z.ZodTypeAny, {
|
|
85
|
+
phone_number?: string | undefined;
|
|
86
|
+
conversation_initiation_client_data?: Record<string, any> | undefined;
|
|
87
|
+
id?: string | undefined;
|
|
88
|
+
whatsapp_user_id?: string | undefined;
|
|
89
|
+
}, {
|
|
90
|
+
phone_number?: string | undefined;
|
|
91
|
+
conversation_initiation_client_data?: Record<string, any> | undefined;
|
|
92
|
+
id?: string | undefined;
|
|
93
|
+
whatsapp_user_id?: string | undefined;
|
|
94
|
+
}>, {
|
|
95
|
+
phone_number?: string | undefined;
|
|
96
|
+
conversation_initiation_client_data?: Record<string, any> | undefined;
|
|
97
|
+
id?: string | undefined;
|
|
98
|
+
whatsapp_user_id?: string | undefined;
|
|
99
|
+
}, {
|
|
100
|
+
phone_number?: string | undefined;
|
|
101
|
+
conversation_initiation_client_data?: Record<string, any> | undefined;
|
|
102
|
+
id?: string | undefined;
|
|
103
|
+
whatsapp_user_id?: string | undefined;
|
|
104
|
+
}>, "many">;
|
|
105
|
+
scheduled_time_unix: z.ZodOptional<z.ZodNumber>;
|
|
106
|
+
agent_phone_number_id: z.ZodOptional<z.ZodString>;
|
|
107
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
108
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
109
|
+
call_name: z.ZodString;
|
|
110
|
+
agent_id: z.ZodString;
|
|
111
|
+
recipients: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
112
|
+
id: z.ZodOptional<z.ZodString>;
|
|
113
|
+
phone_number: z.ZodOptional<z.ZodString>;
|
|
114
|
+
whatsapp_user_id: z.ZodOptional<z.ZodString>;
|
|
115
|
+
conversation_initiation_client_data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
116
|
+
}, "strip", z.ZodTypeAny, {
|
|
117
|
+
phone_number?: string | undefined;
|
|
118
|
+
conversation_initiation_client_data?: Record<string, any> | undefined;
|
|
119
|
+
id?: string | undefined;
|
|
120
|
+
whatsapp_user_id?: string | undefined;
|
|
121
|
+
}, {
|
|
122
|
+
phone_number?: string | undefined;
|
|
123
|
+
conversation_initiation_client_data?: Record<string, any> | undefined;
|
|
124
|
+
id?: string | undefined;
|
|
125
|
+
whatsapp_user_id?: string | undefined;
|
|
126
|
+
}>, {
|
|
127
|
+
phone_number?: string | undefined;
|
|
128
|
+
conversation_initiation_client_data?: Record<string, any> | undefined;
|
|
129
|
+
id?: string | undefined;
|
|
130
|
+
whatsapp_user_id?: string | undefined;
|
|
131
|
+
}, {
|
|
132
|
+
phone_number?: string | undefined;
|
|
133
|
+
conversation_initiation_client_data?: Record<string, any> | undefined;
|
|
134
|
+
id?: string | undefined;
|
|
135
|
+
whatsapp_user_id?: string | undefined;
|
|
136
|
+
}>, "many">;
|
|
137
|
+
scheduled_time_unix: z.ZodOptional<z.ZodNumber>;
|
|
138
|
+
agent_phone_number_id: z.ZodOptional<z.ZodString>;
|
|
139
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
140
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
141
|
+
/**
|
|
142
|
+
* Schema for listing batch calls
|
|
143
|
+
*/
|
|
144
|
+
export declare const ListBatchCallsSchema: z.ZodObject<{
|
|
145
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
146
|
+
last_doc: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
147
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
148
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
149
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
150
|
+
last_doc: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
151
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
152
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
153
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
154
|
+
last_doc: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
155
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
156
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
157
|
+
/**
|
|
158
|
+
* Schema for getting batch call details
|
|
159
|
+
*/
|
|
160
|
+
export declare const GetBatchCallSchema: z.ZodObject<{
|
|
161
|
+
batch_id: z.ZodString;
|
|
162
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
163
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
164
|
+
batch_id: z.ZodString;
|
|
165
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
166
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
167
|
+
batch_id: z.ZodString;
|
|
168
|
+
response_format: z.ZodDefault<z.ZodNativeEnum<typeof import("../types.js").ResponseFormat>>;
|
|
169
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
170
|
+
//# sourceMappingURL=batch-calling-schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-calling-schemas.d.ts","sourceRoot":"","sources":["../../src/schemas/batch-calling-schemas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;GAEG;AACH,eAAO,MAAM,aAAa,aAG6B,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;EAqBvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAwBlB,CAAC;AAEjB;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;gCASjB,CAAC;AAEjB;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;gCAIf,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod validation schemas for batch calling operations
|
|
3
|
+
*
|
|
4
|
+
* Provides strict input validation for submitting batch call jobs,
|
|
5
|
+
* listing batch calls, and retrieving batch call details.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { ResponseFormatSchema, AgentIdSchema, LimitSchema } from "./common-schemas.js";
|
|
9
|
+
import { PhoneNumberSchema, PhoneNumberIdSchema } from "./outbound-schemas.js";
|
|
10
|
+
/**
|
|
11
|
+
* Batch ID schema
|
|
12
|
+
*/
|
|
13
|
+
export const BatchIdSchema = z.string()
|
|
14
|
+
.min(1, "Batch ID is required")
|
|
15
|
+
.regex(/^[a-zA-Z0-9_-]+$/, "Batch ID must contain only alphanumeric characters, hyphens, and underscores")
|
|
16
|
+
.describe("Unique identifier for the batch call job");
|
|
17
|
+
/**
|
|
18
|
+
* Recipient schema for batch calling
|
|
19
|
+
*/
|
|
20
|
+
export const OutboundCallRecipientSchema = z.object({
|
|
21
|
+
id: z.string()
|
|
22
|
+
.optional()
|
|
23
|
+
.describe("Optional recipient identifier for tracking"),
|
|
24
|
+
phone_number: PhoneNumberSchema
|
|
25
|
+
.optional()
|
|
26
|
+
.describe("Recipient phone number (required if whatsapp_user_id not provided)"),
|
|
27
|
+
whatsapp_user_id: z.string()
|
|
28
|
+
.optional()
|
|
29
|
+
.describe("WhatsApp user ID (alternative to phone_number)"),
|
|
30
|
+
conversation_initiation_client_data: z.record(z.any())
|
|
31
|
+
.optional()
|
|
32
|
+
.describe("Personalization data for this recipient (e.g., {dynamic_variables: {name: 'John', account_id: '123'}})")
|
|
33
|
+
}).refine((data) => data.phone_number || data.whatsapp_user_id, {
|
|
34
|
+
message: "Either phone_number or whatsapp_user_id must be provided"
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Schema for submitting a batch call job
|
|
38
|
+
*/
|
|
39
|
+
export const SubmitBatchCallSchema = z.object({
|
|
40
|
+
call_name: z.string()
|
|
41
|
+
.min(1, "Call name is required")
|
|
42
|
+
.max(200, "Call name must not exceed 200 characters")
|
|
43
|
+
.describe("Descriptive name for this batch call job"),
|
|
44
|
+
agent_id: AgentIdSchema,
|
|
45
|
+
recipients: z.array(OutboundCallRecipientSchema)
|
|
46
|
+
.min(1, "At least one recipient is required")
|
|
47
|
+
.max(10000, "Maximum 10,000 recipients per batch")
|
|
48
|
+
.describe("Array of recipients to call"),
|
|
49
|
+
scheduled_time_unix: z.number()
|
|
50
|
+
.int("Scheduled time must be a Unix timestamp")
|
|
51
|
+
.positive("Scheduled time must be in the future")
|
|
52
|
+
.optional()
|
|
53
|
+
.describe("Optional Unix timestamp to schedule the batch for future execution"),
|
|
54
|
+
agent_phone_number_id: PhoneNumberIdSchema
|
|
55
|
+
.optional()
|
|
56
|
+
.describe("Phone number to use as caller ID (optional)"),
|
|
57
|
+
response_format: ResponseFormatSchema
|
|
58
|
+
}).passthrough();
|
|
59
|
+
/**
|
|
60
|
+
* Schema for listing batch calls
|
|
61
|
+
*/
|
|
62
|
+
export const ListBatchCallsSchema = z.object({
|
|
63
|
+
limit: LimitSchema,
|
|
64
|
+
last_doc: z.string()
|
|
65
|
+
.optional()
|
|
66
|
+
.nullable()
|
|
67
|
+
.describe("Pagination cursor from previous response"),
|
|
68
|
+
response_format: ResponseFormatSchema
|
|
69
|
+
}).passthrough();
|
|
70
|
+
/**
|
|
71
|
+
* Schema for getting batch call details
|
|
72
|
+
*/
|
|
73
|
+
export const GetBatchCallSchema = z.object({
|
|
74
|
+
batch_id: BatchIdSchema,
|
|
75
|
+
response_format: ResponseFormatSchema
|
|
76
|
+
}).passthrough();
|
|
77
|
+
//# sourceMappingURL=batch-calling-schemas.js.map
|