elevenlabs-voice-agent-mcp 1.0.14 → 1.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/README.md +202 -23
- package/dist/__tests__/mocks/fixtures.d.ts +136 -0
- package/dist/__tests__/mocks/fixtures.d.ts.map +1 -0
- package/dist/__tests__/mocks/fixtures.js +393 -0
- package/dist/__tests__/mocks/fixtures.js.map +1 -0
- package/dist/__tests__/schemas/schemas.test.d.ts +7 -0
- package/dist/__tests__/schemas/schemas.test.d.ts.map +1 -0
- package/dist/__tests__/schemas/schemas.test.js +537 -0
- package/dist/__tests__/schemas/schemas.test.js.map +1 -0
- package/dist/__tests__/services/elevenlabs-api.test.d.ts +7 -0
- package/dist/__tests__/services/elevenlabs-api.test.d.ts.map +1 -0
- package/dist/__tests__/services/elevenlabs-api.test.js +272 -0
- package/dist/__tests__/services/elevenlabs-api.test.js.map +1 -0
- package/dist/__tests__/services/formatters.test.d.ts +7 -0
- package/dist/__tests__/services/formatters.test.d.ts.map +1 -0
- package/dist/__tests__/services/formatters.test.js +387 -0
- package/dist/__tests__/services/formatters.test.js.map +1 -0
- package/dist/__tests__/setup.d.ts +7 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/__tests__/setup.js +25 -0
- package/dist/__tests__/setup.js.map +1 -0
- package/dist/__tests__/tools/agent-tools.test.d.ts +7 -0
- package/dist/__tests__/tools/agent-tools.test.d.ts.map +1 -0
- package/dist/__tests__/tools/agent-tools.test.js +343 -0
- package/dist/__tests__/tools/agent-tools.test.js.map +1 -0
- package/dist/__tests__/tools/batch-calling-tools.test.d.ts +7 -0
- package/dist/__tests__/tools/batch-calling-tools.test.d.ts.map +1 -0
- package/dist/__tests__/tools/batch-calling-tools.test.js +236 -0
- package/dist/__tests__/tools/batch-calling-tools.test.js.map +1 -0
- package/dist/__tests__/tools/conversation-tools.test.d.ts +7 -0
- package/dist/__tests__/tools/conversation-tools.test.d.ts.map +1 -0
- package/dist/__tests__/tools/conversation-tools.test.js +212 -0
- package/dist/__tests__/tools/conversation-tools.test.js.map +1 -0
- package/dist/__tests__/tools/knowledge-tools.test.d.ts +7 -0
- package/dist/__tests__/tools/knowledge-tools.test.d.ts.map +1 -0
- package/dist/__tests__/tools/knowledge-tools.test.js +209 -0
- package/dist/__tests__/tools/knowledge-tools.test.js.map +1 -0
- package/dist/__tests__/tools/outbound-tools.test.d.ts +7 -0
- package/dist/__tests__/tools/outbound-tools.test.d.ts.map +1 -0
- package/dist/__tests__/tools/outbound-tools.test.js +194 -0
- package/dist/__tests__/tools/outbound-tools.test.js.map +1 -0
- package/dist/__tests__/tools/phone-number-tools.test.d.ts +7 -0
- package/dist/__tests__/tools/phone-number-tools.test.d.ts.map +1 -0
- package/dist/__tests__/tools/phone-number-tools.test.js +314 -0
- package/dist/__tests__/tools/phone-number-tools.test.js.map +1 -0
- package/dist/__tests__/tools/tool-tools.test.d.ts +7 -0
- package/dist/__tests__/tools/tool-tools.test.d.ts.map +1 -0
- package/dist/__tests__/tools/tool-tools.test.js +287 -0
- package/dist/__tests__/tools/tool-tools.test.js.map +1 -0
- package/dist/__tests__/tools/utility-tools.test.d.ts +7 -0
- package/dist/__tests__/tools/utility-tools.test.d.ts.map +1 -0
- package/dist/__tests__/tools/utility-tools.test.js +207 -0
- package/dist/__tests__/tools/utility-tools.test.js.map +1 -0
- package/dist/__tests__/utils/error-handlers.test.d.ts +7 -0
- package/dist/__tests__/utils/error-handlers.test.d.ts.map +1 -0
- package/dist/__tests__/utils/error-handlers.test.js +237 -0
- package/dist/__tests__/utils/error-handlers.test.js.map +1 -0
- package/dist/__tests__/utils/phone-normalizer.test.d.ts +7 -0
- package/dist/__tests__/utils/phone-normalizer.test.d.ts.map +1 -0
- package/dist/__tests__/utils/phone-normalizer.test.js +224 -0
- package/dist/__tests__/utils/phone-normalizer.test.js.map +1 -0
- package/dist/__tests__/utils/truncation.test.d.ts +7 -0
- package/dist/__tests__/utils/truncation.test.d.ts.map +1 -0
- package/dist/__tests__/utils/truncation.test.js +208 -0
- package/dist/__tests__/utils/truncation.test.js.map +1 -0
- package/dist/constants.d.ts +129 -5
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +150 -24
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +13 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -3
- package/dist/index.js.map +1 -1
- package/dist/schemas/agent-schemas.d.ts +23 -8
- package/dist/schemas/agent-schemas.d.ts.map +1 -1
- package/dist/schemas/agent-schemas.js +23 -8
- package/dist/schemas/agent-schemas.js.map +1 -1
- package/dist/schemas/batch-calling-schemas.d.ts +24 -9
- package/dist/schemas/batch-calling-schemas.d.ts.map +1 -1
- package/dist/schemas/batch-calling-schemas.js +24 -9
- package/dist/schemas/batch-calling-schemas.js.map +1 -1
- package/dist/schemas/common-schemas.d.ts +45 -13
- package/dist/schemas/common-schemas.d.ts.map +1 -1
- package/dist/schemas/common-schemas.js +45 -13
- package/dist/schemas/common-schemas.js.map +1 -1
- package/dist/schemas/conversation-schemas.d.ts +12 -5
- package/dist/schemas/conversation-schemas.d.ts.map +1 -1
- package/dist/schemas/conversation-schemas.js +12 -5
- package/dist/schemas/conversation-schemas.js.map +1 -1
- package/dist/schemas/outbound-schemas.d.ts +23 -8
- package/dist/schemas/outbound-schemas.d.ts.map +1 -1
- package/dist/schemas/outbound-schemas.js +23 -8
- package/dist/schemas/outbound-schemas.js.map +1 -1
- package/dist/schemas/phone-number-schemas.d.ts +37 -14
- package/dist/schemas/phone-number-schemas.d.ts.map +1 -1
- package/dist/schemas/phone-number-schemas.js +37 -14
- package/dist/schemas/phone-number-schemas.js.map +1 -1
- package/dist/schemas/tool-schemas.d.ts +27 -9
- package/dist/schemas/tool-schemas.d.ts.map +1 -1
- package/dist/schemas/tool-schemas.js +34 -11
- package/dist/schemas/tool-schemas.js.map +1 -1
- package/dist/services/elevenlabs-api.d.ts +108 -14
- package/dist/services/elevenlabs-api.d.ts.map +1 -1
- package/dist/services/elevenlabs-api.js +108 -14
- package/dist/services/elevenlabs-api.js.map +1 -1
- package/dist/services/formatters.d.ts +147 -21
- package/dist/services/formatters.d.ts.map +1 -1
- package/dist/services/formatters.js +147 -21
- package/dist/services/formatters.js.map +1 -1
- package/dist/tools/agent-tools.d.ts +5 -3
- package/dist/tools/agent-tools.d.ts.map +1 -1
- package/dist/tools/agent-tools.js +5 -3
- package/dist/tools/agent-tools.js.map +1 -1
- package/dist/tools/batch-calling-tools.d.ts +5 -3
- package/dist/tools/batch-calling-tools.d.ts.map +1 -1
- package/dist/tools/batch-calling-tools.js +5 -3
- package/dist/tools/batch-calling-tools.js.map +1 -1
- package/dist/tools/conversation-tools.d.ts +5 -3
- package/dist/tools/conversation-tools.d.ts.map +1 -1
- package/dist/tools/conversation-tools.js +5 -3
- package/dist/tools/conversation-tools.js.map +1 -1
- package/dist/tools/knowledge-tools.d.ts +5 -3
- package/dist/tools/knowledge-tools.d.ts.map +1 -1
- package/dist/tools/knowledge-tools.js +5 -3
- package/dist/tools/knowledge-tools.js.map +1 -1
- package/dist/tools/outbound-tools.d.ts +5 -3
- package/dist/tools/outbound-tools.d.ts.map +1 -1
- package/dist/tools/outbound-tools.js +5 -3
- package/dist/tools/outbound-tools.js.map +1 -1
- package/dist/tools/phone-number-tools.d.ts +5 -4
- package/dist/tools/phone-number-tools.d.ts.map +1 -1
- package/dist/tools/phone-number-tools.js +5 -4
- package/dist/tools/phone-number-tools.js.map +1 -1
- package/dist/tools/tool-tools.d.ts +5 -3
- package/dist/tools/tool-tools.d.ts.map +1 -1
- package/dist/tools/tool-tools.js +5 -3
- package/dist/tools/tool-tools.js.map +1 -1
- package/dist/tools/utility-tools.d.ts +5 -3
- package/dist/tools/utility-tools.d.ts.map +1 -1
- package/dist/tools/utility-tools.js +5 -3
- package/dist/tools/utility-tools.js.map +1 -1
- package/dist/types.d.ts +457 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +15 -3
- package/dist/types.js.map +1 -1
- package/dist/utils/error-handlers.d.ts +47 -14
- package/dist/utils/error-handlers.d.ts.map +1 -1
- package/dist/utils/error-handlers.js +47 -14
- package/dist/utils/error-handlers.js.map +1 -1
- package/dist/utils/phone-normalizer.d.ts +43 -22
- package/dist/utils/phone-normalizer.d.ts.map +1 -1
- package/dist/utils/phone-normalizer.js +43 -22
- package/dist/utils/phone-normalizer.js.map +1 -1
- package/dist/utils/truncation.d.ts +46 -22
- package/dist/utils/truncation.d.ts.map +1 -1
- package/dist/utils/truncation.js +46 -22
- package/dist/utils/truncation.js.map +1 -1
- package/package.json +10 -4
|
@@ -1,37 +1,131 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ElevenLabs API client service
|
|
3
|
-
*
|
|
4
|
-
* Provides core HTTP request functionality for interacting with the
|
|
2
|
+
* @fileoverview ElevenLabs API client service
|
|
3
|
+
* @description Provides core HTTP request functionality for interacting with the
|
|
5
4
|
* ElevenLabs Voice Agent API, including authentication and error handling.
|
|
5
|
+
* This module serves as the central communication layer for all API operations.
|
|
6
|
+
* @module services/elevenlabs-api
|
|
6
7
|
*/
|
|
7
8
|
/**
|
|
8
|
-
* Makes an authenticated request to the ElevenLabs API
|
|
9
|
+
* Makes an authenticated request to the ElevenLabs API.
|
|
10
|
+
* @description Core function that handles all HTTP communication with ElevenLabs.
|
|
11
|
+
* Automatically adds authentication headers and handles errors consistently.
|
|
12
|
+
*
|
|
13
|
+
* @template T - The expected response data type
|
|
14
|
+
* @param {("GET" | "POST" | "PUT" | "PATCH" | "DELETE")} method - HTTP method to use
|
|
15
|
+
* @param {string} endpoint - API endpoint path (e.g., "/convai/agents")
|
|
16
|
+
* @param {unknown} [data] - Request body data (for POST, PUT, PATCH methods)
|
|
17
|
+
* @param {Record<string, unknown>} [params] - URL query parameters
|
|
18
|
+
* @returns {Promise<T>} Response data from the API
|
|
19
|
+
* @throws {Error} If ELEVENLABS_API_KEY is not set
|
|
20
|
+
* @throws {Error} If the API request fails (with user-friendly message)
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // GET request
|
|
24
|
+
* const agent = await makeElevenLabsRequest<Agent>("GET", "/convai/agents/ag_123");
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // POST request with data
|
|
28
|
+
* const newAgent = await makeElevenLabsRequest<Agent>("POST", "/convai/agents/create", {
|
|
29
|
+
* name: "Support Bot",
|
|
30
|
+
* // ... config
|
|
31
|
+
* });
|
|
9
32
|
*
|
|
10
|
-
* @
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
33
|
+
* @example
|
|
34
|
+
* // GET request with query params
|
|
35
|
+
* const agents = await makeElevenLabsRequest<{agents: Agent[]}>("GET", "/convai/agents", undefined, {
|
|
36
|
+
* limit: 20,
|
|
37
|
+
* offset: 0
|
|
38
|
+
* });
|
|
15
39
|
*/
|
|
16
40
|
export declare function makeElevenLabsRequest<T = unknown>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", endpoint: string, data?: unknown, params?: Record<string, unknown>): Promise<T>;
|
|
17
41
|
/**
|
|
18
|
-
* GET request
|
|
42
|
+
* Performs an authenticated GET request to the ElevenLabs API.
|
|
43
|
+
* @description Convenience wrapper for GET requests that fetch data without a body.
|
|
44
|
+
*
|
|
45
|
+
* @template T - The expected response data type
|
|
46
|
+
* @param {string} endpoint - API endpoint path (e.g., "/convai/agents/ag_123")
|
|
47
|
+
* @param {Record<string, unknown>} [params] - Optional URL query parameters
|
|
48
|
+
* @returns {Promise<T>} Response data from the API
|
|
49
|
+
* @throws {Error} If the request fails
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* // Fetch a single agent
|
|
53
|
+
* const agent = await getRequest<Agent>("/convai/agents/ag_abc123");
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // Fetch agents with pagination
|
|
57
|
+
* const response = await getRequest<{agents: Agent[]}>("/convai/agents", {
|
|
58
|
+
* limit: 20,
|
|
59
|
+
* offset: 0
|
|
60
|
+
* });
|
|
19
61
|
*/
|
|
20
62
|
export declare function getRequest<T>(endpoint: string, params?: Record<string, unknown>): Promise<T>;
|
|
21
63
|
/**
|
|
22
|
-
* POST request
|
|
64
|
+
* Performs an authenticated POST request to the ElevenLabs API.
|
|
65
|
+
* @description Convenience wrapper for POST requests that create new resources.
|
|
66
|
+
*
|
|
67
|
+
* @template T - The expected response data type
|
|
68
|
+
* @param {string} endpoint - API endpoint path (e.g., "/convai/agents/create")
|
|
69
|
+
* @param {unknown} data - Request body data to send
|
|
70
|
+
* @param {Record<string, unknown>} [params] - Optional URL query parameters
|
|
71
|
+
* @returns {Promise<T>} Response data from the API
|
|
72
|
+
* @throws {Error} If the request fails
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* // Create a new agent
|
|
76
|
+
* const agent = await postRequest<Agent>("/convai/agents/create", {
|
|
77
|
+
* name: "Customer Support",
|
|
78
|
+
* conversation_config: { ... }
|
|
79
|
+
* });
|
|
23
80
|
*/
|
|
24
81
|
export declare function postRequest<T>(endpoint: string, data: unknown, params?: Record<string, unknown>): Promise<T>;
|
|
25
82
|
/**
|
|
26
|
-
* PUT request
|
|
83
|
+
* Performs an authenticated PUT request to the ElevenLabs API.
|
|
84
|
+
* @description Convenience wrapper for PUT requests that replace resources entirely.
|
|
85
|
+
*
|
|
86
|
+
* @template T - The expected response data type
|
|
87
|
+
* @param {string} endpoint - API endpoint path
|
|
88
|
+
* @param {unknown} data - Request body data to send
|
|
89
|
+
* @param {Record<string, unknown>} [params] - Optional URL query parameters
|
|
90
|
+
* @returns {Promise<T>} Response data from the API
|
|
91
|
+
* @throws {Error} If the request fails
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* // Replace a resource
|
|
95
|
+
* const updated = await putRequest<Resource>("/resource/123", { ... });
|
|
27
96
|
*/
|
|
28
97
|
export declare function putRequest<T>(endpoint: string, data: unknown, params?: Record<string, unknown>): Promise<T>;
|
|
29
98
|
/**
|
|
30
|
-
* PATCH request
|
|
99
|
+
* Performs an authenticated PATCH request to the ElevenLabs API.
|
|
100
|
+
* @description Convenience wrapper for PATCH requests that partially update resources.
|
|
101
|
+
*
|
|
102
|
+
* @template T - The expected response data type
|
|
103
|
+
* @param {string} endpoint - API endpoint path (e.g., "/convai/agents/ag_123")
|
|
104
|
+
* @param {unknown} data - Partial update data to send
|
|
105
|
+
* @param {Record<string, unknown>} [params] - Optional URL query parameters
|
|
106
|
+
* @returns {Promise<T>} Response data from the API
|
|
107
|
+
* @throws {Error} If the request fails
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* // Update specific agent fields
|
|
111
|
+
* const updated = await patchRequest<Agent>("/convai/agents/ag_abc123", {
|
|
112
|
+
* name: "Updated Name"
|
|
113
|
+
* });
|
|
31
114
|
*/
|
|
32
115
|
export declare function patchRequest<T>(endpoint: string, data: unknown, params?: Record<string, unknown>): Promise<T>;
|
|
33
116
|
/**
|
|
34
|
-
* DELETE request
|
|
117
|
+
* Performs an authenticated DELETE request to the ElevenLabs API.
|
|
118
|
+
* @description Convenience wrapper for DELETE requests that remove resources.
|
|
119
|
+
*
|
|
120
|
+
* @template T - The expected response data type (often void or confirmation)
|
|
121
|
+
* @param {string} endpoint - API endpoint path (e.g., "/convai/agents/ag_123")
|
|
122
|
+
* @param {Record<string, unknown>} [params] - Optional URL query parameters
|
|
123
|
+
* @returns {Promise<T>} Response data from the API (may be empty)
|
|
124
|
+
* @throws {Error} If the request fails
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* // Delete an agent
|
|
128
|
+
* await deleteRequest("/convai/agents/ag_abc123");
|
|
35
129
|
*/
|
|
36
130
|
export declare function deleteRequest<T>(endpoint: string, params?: Record<string, unknown>): Promise<T>;
|
|
37
131
|
//# sourceMappingURL=elevenlabs-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elevenlabs-api.d.ts","sourceRoot":"","sources":["../../src/services/elevenlabs-api.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"elevenlabs-api.d.ts","sourceRoot":"","sources":["../../src/services/elevenlabs-api.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAsB,qBAAqB,CAAC,CAAC,GAAG,OAAO,EACrD,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,EACnD,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,OAAO,EACd,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,CAAC,CAAC,CAkCZ;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,UAAU,CAAC,CAAC,EAChC,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,WAAW,CAAC,CAAC,EACjC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,EACb,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,UAAU,CAAC,CAAC,EAChC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,EACb,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAClC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,EACb,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,aAAa,CAAC,CAAC,EACnC,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAAC,CAAC,CAAC,CAEZ"}
|
|
@@ -1,20 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ElevenLabs API client service
|
|
3
|
-
*
|
|
4
|
-
* Provides core HTTP request functionality for interacting with the
|
|
2
|
+
* @fileoverview ElevenLabs API client service
|
|
3
|
+
* @description Provides core HTTP request functionality for interacting with the
|
|
5
4
|
* ElevenLabs Voice Agent API, including authentication and error handling.
|
|
5
|
+
* This module serves as the central communication layer for all API operations.
|
|
6
|
+
* @module services/elevenlabs-api
|
|
6
7
|
*/
|
|
7
8
|
import axios from "axios";
|
|
8
9
|
import { API_BASE_URL, REQUEST_TIMEOUT } from "../constants.js";
|
|
9
10
|
import { handleElevenLabsError } from "../utils/error-handlers.js";
|
|
10
11
|
/**
|
|
11
|
-
* Makes an authenticated request to the ElevenLabs API
|
|
12
|
+
* Makes an authenticated request to the ElevenLabs API.
|
|
13
|
+
* @description Core function that handles all HTTP communication with ElevenLabs.
|
|
14
|
+
* Automatically adds authentication headers and handles errors consistently.
|
|
15
|
+
*
|
|
16
|
+
* @template T - The expected response data type
|
|
17
|
+
* @param {("GET" | "POST" | "PUT" | "PATCH" | "DELETE")} method - HTTP method to use
|
|
18
|
+
* @param {string} endpoint - API endpoint path (e.g., "/convai/agents")
|
|
19
|
+
* @param {unknown} [data] - Request body data (for POST, PUT, PATCH methods)
|
|
20
|
+
* @param {Record<string, unknown>} [params] - URL query parameters
|
|
21
|
+
* @returns {Promise<T>} Response data from the API
|
|
22
|
+
* @throws {Error} If ELEVENLABS_API_KEY is not set
|
|
23
|
+
* @throws {Error} If the API request fails (with user-friendly message)
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // GET request
|
|
27
|
+
* const agent = await makeElevenLabsRequest<Agent>("GET", "/convai/agents/ag_123");
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // POST request with data
|
|
31
|
+
* const newAgent = await makeElevenLabsRequest<Agent>("POST", "/convai/agents/create", {
|
|
32
|
+
* name: "Support Bot",
|
|
33
|
+
* // ... config
|
|
34
|
+
* });
|
|
12
35
|
*
|
|
13
|
-
* @
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
36
|
+
* @example
|
|
37
|
+
* // GET request with query params
|
|
38
|
+
* const agents = await makeElevenLabsRequest<{agents: Agent[]}>("GET", "/convai/agents", undefined, {
|
|
39
|
+
* limit: 20,
|
|
40
|
+
* offset: 0
|
|
41
|
+
* });
|
|
18
42
|
*/
|
|
19
43
|
export async function makeElevenLabsRequest(method, endpoint, data, params) {
|
|
20
44
|
const apiKey = process.env.ELEVENLABS_API_KEY;
|
|
@@ -46,31 +70,101 @@ export async function makeElevenLabsRequest(method, endpoint, data, params) {
|
|
|
46
70
|
}
|
|
47
71
|
}
|
|
48
72
|
/**
|
|
49
|
-
* GET request
|
|
73
|
+
* Performs an authenticated GET request to the ElevenLabs API.
|
|
74
|
+
* @description Convenience wrapper for GET requests that fetch data without a body.
|
|
75
|
+
*
|
|
76
|
+
* @template T - The expected response data type
|
|
77
|
+
* @param {string} endpoint - API endpoint path (e.g., "/convai/agents/ag_123")
|
|
78
|
+
* @param {Record<string, unknown>} [params] - Optional URL query parameters
|
|
79
|
+
* @returns {Promise<T>} Response data from the API
|
|
80
|
+
* @throws {Error} If the request fails
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* // Fetch a single agent
|
|
84
|
+
* const agent = await getRequest<Agent>("/convai/agents/ag_abc123");
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* // Fetch agents with pagination
|
|
88
|
+
* const response = await getRequest<{agents: Agent[]}>("/convai/agents", {
|
|
89
|
+
* limit: 20,
|
|
90
|
+
* offset: 0
|
|
91
|
+
* });
|
|
50
92
|
*/
|
|
51
93
|
export async function getRequest(endpoint, params) {
|
|
52
94
|
return makeElevenLabsRequest("GET", endpoint, undefined, params);
|
|
53
95
|
}
|
|
54
96
|
/**
|
|
55
|
-
* POST request
|
|
97
|
+
* Performs an authenticated POST request to the ElevenLabs API.
|
|
98
|
+
* @description Convenience wrapper for POST requests that create new resources.
|
|
99
|
+
*
|
|
100
|
+
* @template T - The expected response data type
|
|
101
|
+
* @param {string} endpoint - API endpoint path (e.g., "/convai/agents/create")
|
|
102
|
+
* @param {unknown} data - Request body data to send
|
|
103
|
+
* @param {Record<string, unknown>} [params] - Optional URL query parameters
|
|
104
|
+
* @returns {Promise<T>} Response data from the API
|
|
105
|
+
* @throws {Error} If the request fails
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* // Create a new agent
|
|
109
|
+
* const agent = await postRequest<Agent>("/convai/agents/create", {
|
|
110
|
+
* name: "Customer Support",
|
|
111
|
+
* conversation_config: { ... }
|
|
112
|
+
* });
|
|
56
113
|
*/
|
|
57
114
|
export async function postRequest(endpoint, data, params) {
|
|
58
115
|
return makeElevenLabsRequest("POST", endpoint, data, params);
|
|
59
116
|
}
|
|
60
117
|
/**
|
|
61
|
-
* PUT request
|
|
118
|
+
* Performs an authenticated PUT request to the ElevenLabs API.
|
|
119
|
+
* @description Convenience wrapper for PUT requests that replace resources entirely.
|
|
120
|
+
*
|
|
121
|
+
* @template T - The expected response data type
|
|
122
|
+
* @param {string} endpoint - API endpoint path
|
|
123
|
+
* @param {unknown} data - Request body data to send
|
|
124
|
+
* @param {Record<string, unknown>} [params] - Optional URL query parameters
|
|
125
|
+
* @returns {Promise<T>} Response data from the API
|
|
126
|
+
* @throws {Error} If the request fails
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* // Replace a resource
|
|
130
|
+
* const updated = await putRequest<Resource>("/resource/123", { ... });
|
|
62
131
|
*/
|
|
63
132
|
export async function putRequest(endpoint, data, params) {
|
|
64
133
|
return makeElevenLabsRequest("PUT", endpoint, data, params);
|
|
65
134
|
}
|
|
66
135
|
/**
|
|
67
|
-
* PATCH request
|
|
136
|
+
* Performs an authenticated PATCH request to the ElevenLabs API.
|
|
137
|
+
* @description Convenience wrapper for PATCH requests that partially update resources.
|
|
138
|
+
*
|
|
139
|
+
* @template T - The expected response data type
|
|
140
|
+
* @param {string} endpoint - API endpoint path (e.g., "/convai/agents/ag_123")
|
|
141
|
+
* @param {unknown} data - Partial update data to send
|
|
142
|
+
* @param {Record<string, unknown>} [params] - Optional URL query parameters
|
|
143
|
+
* @returns {Promise<T>} Response data from the API
|
|
144
|
+
* @throws {Error} If the request fails
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* // Update specific agent fields
|
|
148
|
+
* const updated = await patchRequest<Agent>("/convai/agents/ag_abc123", {
|
|
149
|
+
* name: "Updated Name"
|
|
150
|
+
* });
|
|
68
151
|
*/
|
|
69
152
|
export async function patchRequest(endpoint, data, params) {
|
|
70
153
|
return makeElevenLabsRequest("PATCH", endpoint, data, params);
|
|
71
154
|
}
|
|
72
155
|
/**
|
|
73
|
-
* DELETE request
|
|
156
|
+
* Performs an authenticated DELETE request to the ElevenLabs API.
|
|
157
|
+
* @description Convenience wrapper for DELETE requests that remove resources.
|
|
158
|
+
*
|
|
159
|
+
* @template T - The expected response data type (often void or confirmation)
|
|
160
|
+
* @param {string} endpoint - API endpoint path (e.g., "/convai/agents/ag_123")
|
|
161
|
+
* @param {Record<string, unknown>} [params] - Optional URL query parameters
|
|
162
|
+
* @returns {Promise<T>} Response data from the API (may be empty)
|
|
163
|
+
* @throws {Error} If the request fails
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* // Delete an agent
|
|
167
|
+
* await deleteRequest("/convai/agents/ag_abc123");
|
|
74
168
|
*/
|
|
75
169
|
export async function deleteRequest(endpoint, params) {
|
|
76
170
|
return makeElevenLabsRequest("DELETE", endpoint, undefined, params);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elevenlabs-api.js","sourceRoot":"","sources":["../../src/services/elevenlabs-api.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"elevenlabs-api.js","sourceRoot":"","sources":["../../src/services/elevenlabs-api.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAA4C,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAAmD,EACnD,QAAgB,EAChB,IAAc,EACd,MAAgC;IAEhC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IAE9C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,sDAAsD;YACtD,2CAA2C,CAC5C,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAuB;QACjC,MAAM;QACN,GAAG,EAAE,GAAG,YAAY,GAAG,QAAQ,EAAE;QACjC,OAAO,EAAE;YACP,YAAY,EAAE,MAAM;YACpB,cAAc,EAAE,kBAAkB;SACnC;QACD,OAAO,EAAE,eAAe;KACzB,CAAC;IAEF,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,QAAQ,GAAqB,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC;QACvD,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB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ting utilities
|
|
3
|
+
* @description Converts API responses to human-readable Markdown or structured JSON format.
|
|
4
|
+
* Provides consistent formatting across all MCP tools for optimal readability.
|
|
5
|
+
* @module services/formatters
|
|
6
6
|
*/
|
|
7
7
|
import { Agent, ConversationMetadata, ToolConfig, Voice, ResponseFormat, OutboundCallResponse, BatchCallResponse, BatchCallDetailedResponse, WorkspaceBatchCallsResponse, PhoneNumber, ImportPhoneNumberResponse } from "../types.js";
|
|
8
8
|
/**
|
|
9
|
-
* Formats
|
|
9
|
+
* Formats a single agent in human-readable Markdown format.
|
|
10
|
+
* @description Creates a comprehensive Markdown representation of an agent
|
|
11
|
+
* including configuration, prompt, tools, and widget settings.
|
|
12
|
+
*
|
|
13
|
+
* @param {Agent} agent - The agent object to format
|
|
14
|
+
* @returns {string} Formatted Markdown string
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const markdown = formatAgentMarkdown(agent);
|
|
18
|
+
* // Returns:
|
|
19
|
+
* // # Agent: Customer Support (ag_abc123)
|
|
20
|
+
* // **Created**: 2025-01-01T00:00:00.000Z
|
|
21
|
+
* // ## Configuration
|
|
22
|
+
* // - **LLM**: claude-sonnet-4-5@20250929
|
|
23
|
+
* // ...
|
|
10
24
|
*/
|
|
11
25
|
export declare function formatAgentMarkdown(agent: Agent): string;
|
|
12
26
|
/**
|
|
13
|
-
* Formats a list of agents in Markdown format
|
|
27
|
+
* Formats a paginated list of agents in Markdown format.
|
|
28
|
+
* @description Creates a Markdown list with agent summaries and pagination guidance.
|
|
29
|
+
*
|
|
30
|
+
* @param {Agent[]} agents - Array of agent objects to format
|
|
31
|
+
* @param {number} total - Total number of agents available
|
|
32
|
+
* @param {number} offset - Current pagination offset
|
|
33
|
+
* @param {boolean} hasMore - Whether more agents are available
|
|
34
|
+
* @returns {string} Formatted Markdown string with pagination info
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* const markdown = formatAgentListMarkdown(agents, 50, 0, true);
|
|
38
|
+
* // Returns:
|
|
39
|
+
* // # Agents (20 of 50)
|
|
40
|
+
* // ## 1. Customer Support
|
|
41
|
+
* // - **ID**: ag_abc123
|
|
42
|
+
* // ...
|
|
14
43
|
*/
|
|
15
44
|
export declare function formatAgentListMarkdown(agents: Agent[], total: number, offset: number, hasMore: boolean): string;
|
|
16
45
|
/**
|
|
17
|
-
* Formats a conversation in Markdown format
|
|
46
|
+
* Formats a conversation with full transcript in Markdown format.
|
|
47
|
+
* @description Creates a detailed Markdown representation including metadata,
|
|
48
|
+
* transcript entries, tool calls, and conversation analysis.
|
|
49
|
+
*
|
|
50
|
+
* @param {ConversationMetadata} conversation - The conversation object to format
|
|
51
|
+
* @returns {string} Formatted Markdown string with transcript
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* const markdown = formatConversationMarkdown(conversation);
|
|
55
|
+
* // Returns:
|
|
56
|
+
* // # Conversation: conv_xyz789
|
|
57
|
+
* // - **Agent ID**: ag_abc123
|
|
58
|
+
* // - **Status**: completed
|
|
59
|
+
* // ## Transcript (5 messages)
|
|
60
|
+
* // ...
|
|
18
61
|
*/
|
|
19
62
|
export declare function formatConversationMarkdown(conversation: ConversationMetadata): string;
|
|
20
63
|
/**
|
|
21
|
-
* Formats a list of conversations in Markdown format
|
|
64
|
+
* Formats a paginated list of conversations in Markdown format.
|
|
65
|
+
* @description Creates a Markdown list with conversation summaries and pagination guidance.
|
|
66
|
+
*
|
|
67
|
+
* @param {ConversationMetadata[]} conversations - Array of conversations to format
|
|
68
|
+
* @param {number} total - Total number of conversations available
|
|
69
|
+
* @param {number} offset - Current pagination offset
|
|
70
|
+
* @param {boolean} hasMore - Whether more conversations are available
|
|
71
|
+
* @returns {string} Formatted Markdown string with pagination info
|
|
22
72
|
*/
|
|
23
73
|
export declare function formatConversationListMarkdown(conversations: ConversationMetadata[], total: number, offset: number, hasMore: boolean): string;
|
|
24
74
|
/**
|
|
25
|
-
* Formats a tool configuration in Markdown format
|
|
75
|
+
* Formats a single tool configuration in Markdown format.
|
|
76
|
+
* @description Creates a detailed Markdown representation of a webhook tool
|
|
77
|
+
* including parameters, URL, and method.
|
|
78
|
+
*
|
|
79
|
+
* @param {ToolConfig} tool - The tool configuration to format
|
|
80
|
+
* @returns {string} Formatted Markdown string
|
|
26
81
|
*/
|
|
27
82
|
export declare function formatToolMarkdown(tool: ToolConfig): string;
|
|
28
83
|
/**
|
|
29
|
-
* Formats a list of
|
|
84
|
+
* Formats a list of tool configurations in Markdown format.
|
|
85
|
+
* @description Creates a summary list of all tools configured for an agent.
|
|
86
|
+
*
|
|
87
|
+
* @param {ToolConfig[]} tools - Array of tool configurations to format
|
|
88
|
+
* @returns {string} Formatted Markdown string
|
|
30
89
|
*/
|
|
31
90
|
export declare function formatToolListMarkdown(tools: ToolConfig[]): string;
|
|
32
91
|
/**
|
|
33
|
-
* Formats a list of voices in Markdown format
|
|
92
|
+
* Formats a list of available voices in Markdown format.
|
|
93
|
+
* @description Creates a browseable list of voices with labels and preview URLs.
|
|
94
|
+
*
|
|
95
|
+
* @param {Voice[]} voices - Array of voice objects to format
|
|
96
|
+
* @returns {string} Formatted Markdown string
|
|
34
97
|
*/
|
|
35
98
|
export declare function formatVoiceListMarkdown(voices: Voice[]): string;
|
|
36
99
|
/**
|
|
37
|
-
*
|
|
100
|
+
* Generates HTML embed code for a voice agent widget.
|
|
101
|
+
* @description Creates ready-to-use HTML/JavaScript code for embedding
|
|
102
|
+
* a voice agent widget on a webpage.
|
|
103
|
+
*
|
|
104
|
+
* @param {string} agentId - The agent ID to embed
|
|
105
|
+
* @param {string} [color] - Optional widget theme color (hex format)
|
|
106
|
+
* @param {string} [avatarUrl] - Optional avatar image URL
|
|
107
|
+
* @returns {string} Formatted Markdown with HTML code block
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* const code = formatWidgetCode("ag_abc123", "#4A90E2");
|
|
111
|
+
* // Returns Markdown with embeddable script tag
|
|
38
112
|
*/
|
|
39
113
|
export declare function formatWidgetCode(agentId: string, color?: string, avatarUrl?: string): string;
|
|
40
114
|
/**
|
|
41
|
-
* Formats an outbound call response in Markdown format
|
|
115
|
+
* Formats an outbound call response in Markdown format.
|
|
116
|
+
* @description Creates a status summary for a call initiation attempt
|
|
117
|
+
* including conversation ID and Twilio call SID.
|
|
118
|
+
*
|
|
119
|
+
* @param {OutboundCallResponse} response - The outbound call response to format
|
|
120
|
+
* @returns {string} Formatted Markdown string
|
|
42
121
|
*/
|
|
43
122
|
export declare function formatOutboundCallMarkdown(response: OutboundCallResponse): string;
|
|
44
123
|
/**
|
|
45
|
-
* Formats a batch call
|
|
124
|
+
* Formats a batch call job summary in Markdown format.
|
|
125
|
+
* @description Creates a status summary for a batch calling job
|
|
126
|
+
* including timing and call statistics.
|
|
127
|
+
*
|
|
128
|
+
* @param {BatchCallResponse} batch - The batch call response to format
|
|
129
|
+
* @returns {string} Formatted Markdown string
|
|
46
130
|
*/
|
|
47
131
|
export declare function formatBatchCallMarkdown(batch: BatchCallResponse): string;
|
|
48
132
|
/**
|
|
49
|
-
* Formats a batch
|
|
133
|
+
* Formats a paginated list of batch calls in Markdown format.
|
|
134
|
+
* @description Creates a summary list of batch calling jobs with status info.
|
|
135
|
+
*
|
|
136
|
+
* @param {WorkspaceBatchCallsResponse} response - The batch list response to format
|
|
137
|
+
* @returns {string} Formatted Markdown string with pagination cursor
|
|
50
138
|
*/
|
|
51
139
|
export declare function formatBatchCallListMarkdown(response: WorkspaceBatchCallsResponse): string;
|
|
52
140
|
/**
|
|
53
|
-
* Formats detailed batch call information with recipient statuses
|
|
141
|
+
* Formats detailed batch call information with all recipient statuses.
|
|
142
|
+
* @description Creates a comprehensive view of a batch job including
|
|
143
|
+
* status breakdown and individual recipient details.
|
|
144
|
+
*
|
|
145
|
+
* @param {BatchCallDetailedResponse} batch - The detailed batch response to format
|
|
146
|
+
* @returns {string} Formatted Markdown string with recipient statuses
|
|
54
147
|
*/
|
|
55
148
|
export declare function formatBatchCallDetailMarkdown(batch: BatchCallDetailedResponse): string;
|
|
56
149
|
/**
|
|
57
|
-
* Formats a list of phone numbers in Markdown format
|
|
150
|
+
* Formats a list of phone numbers in Markdown format.
|
|
151
|
+
* @description Creates a summary list of phone numbers with capabilities and assignments.
|
|
152
|
+
*
|
|
153
|
+
* @param {PhoneNumber[]} phoneNumbers - Array of phone numbers to format
|
|
154
|
+
* @returns {string} Formatted Markdown string
|
|
58
155
|
*/
|
|
59
156
|
export declare function formatPhoneNumberListMarkdown(phoneNumbers: PhoneNumber[]): string;
|
|
60
157
|
/**
|
|
61
|
-
* Formats a single phone number in Markdown format
|
|
158
|
+
* Formats a single phone number with full details in Markdown format.
|
|
159
|
+
* @description Creates a detailed view of a phone number including
|
|
160
|
+
* capabilities, assignment, and provider-specific configuration.
|
|
161
|
+
*
|
|
162
|
+
* @param {PhoneNumber} phone - The phone number object to format
|
|
163
|
+
* @returns {string} Formatted Markdown string
|
|
62
164
|
*/
|
|
63
165
|
export declare function formatPhoneNumberMarkdown(phone: PhoneNumber): string;
|
|
64
166
|
/**
|
|
65
|
-
* Formats phone number import response in Markdown format
|
|
167
|
+
* Formats a phone number import success response in Markdown format.
|
|
168
|
+
* @description Creates a confirmation message with next steps guidance.
|
|
169
|
+
*
|
|
170
|
+
* @param {ImportPhoneNumberResponse} response - The import response to format
|
|
171
|
+
* @returns {string} Formatted Markdown string with next steps
|
|
66
172
|
*/
|
|
67
173
|
export declare function formatPhoneNumberImportMarkdown(response: ImportPhoneNumberResponse): string;
|
|
68
174
|
/**
|
|
69
|
-
* Formats any response as JSON
|
|
175
|
+
* Formats any response data as a JSON string.
|
|
176
|
+
* @description Converts data to pretty-printed JSON with automatic truncation
|
|
177
|
+
* if the output exceeds character limits.
|
|
178
|
+
*
|
|
179
|
+
* @param {unknown} data - Any data to format as JSON
|
|
180
|
+
* @returns {string} Pretty-printed JSON string
|
|
70
181
|
*/
|
|
71
182
|
export declare function formatAsJSON(data: unknown): string;
|
|
72
183
|
/**
|
|
73
|
-
* Main formatting function that routes to appropriate formatter
|
|
184
|
+
* Main formatting function that routes to the appropriate formatter.
|
|
185
|
+
* @description Central dispatch function that formats data based on the requested
|
|
186
|
+
* format (JSON or Markdown) and data type. Used by all MCP tool handlers.
|
|
187
|
+
*
|
|
188
|
+
* @param {unknown} data - The data to format
|
|
189
|
+
* @param {ResponseFormat} format - Output format (JSON or Markdown)
|
|
190
|
+
* @param {string} type - Data type identifier for selecting the appropriate formatter
|
|
191
|
+
* @returns {string} Formatted output string
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* // Format an agent as Markdown
|
|
195
|
+
* const output = formatResponse(agent, ResponseFormat.MARKDOWN, "agent");
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* // Format agent list as JSON
|
|
199
|
+
* const output = formatResponse(agents, ResponseFormat.JSON, "agent_list");
|
|
74
200
|
*/
|
|
75
201
|
export declare function formatResponse(data: unknown, format: ResponseFormat, type: "agent" | "agent_list" | "conversation" | "conversation_list" | "tool" | "tool_list" | "voice_list" | "widget" | "outbound_call" | "batch_call" | "batch_call_list" | "batch_call_detail" | "phone_number_list" | "phone_number" | "phone_number_import" | "generic"): string;
|
|
76
202
|
//# sourceMappingURL=formatters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../src/services/formatters.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,KAAK,EACL,oBAAoB,EACpB,UAAU,EACV,KAAK,EACL,cAAc,EAEd,oBAAoB,EACpB,iBAAiB,EACjB,yBAAyB,EACzB,2BAA2B,EAC3B,WAAW,EACX,yBAAyB,EAC1B,MAAM,aAAa,CAAC;AAGrB
|
|
1
|
+
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../src/services/formatters.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,KAAK,EACL,oBAAoB,EACpB,UAAU,EACV,KAAK,EACL,c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