dalvon-mcp 3.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 +7 -0
- package/README.md +743 -0
- package/dist/clients/dalvon.d.ts +258 -0
- package/dist/clients/dalvon.d.ts.map +1 -0
- package/dist/clients/dalvon.js +1240 -0
- package/dist/clients/dalvon.js.map +1 -0
- package/dist/clients/knowledge.d.ts +59 -0
- package/dist/clients/knowledge.d.ts.map +1 -0
- package/dist/clients/knowledge.js +267 -0
- package/dist/clients/knowledge.js.map +1 -0
- package/dist/clients/telefonieren.d.ts +258 -0
- package/dist/clients/telefonieren.d.ts.map +1 -0
- package/dist/clients/telefonieren.js +1240 -0
- package/dist/clients/telefonieren.js.map +1 -0
- package/dist/config.d.ts +43 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +76 -0
- package/dist/config.js.map +1 -0
- package/dist/environment.d.ts +33 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/environment.js +63 -0
- package/dist/environment.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/agents.d.ts +8 -0
- package/dist/tools/agents.d.ts.map +1 -0
- package/dist/tools/agents.js +1880 -0
- package/dist/tools/agents.js.map +1 -0
- package/dist/tools/billing.d.ts +8 -0
- package/dist/tools/billing.d.ts.map +1 -0
- package/dist/tools/billing.js +205 -0
- package/dist/tools/billing.js.map +1 -0
- package/dist/tools/calendar.d.ts +8 -0
- package/dist/tools/calendar.d.ts.map +1 -0
- package/dist/tools/calendar.js +347 -0
- package/dist/tools/calendar.js.map +1 -0
- package/dist/tools/calls.d.ts +8 -0
- package/dist/tools/calls.d.ts.map +1 -0
- package/dist/tools/calls.js +508 -0
- package/dist/tools/calls.js.map +1 -0
- package/dist/tools/campaigns.d.ts +8 -0
- package/dist/tools/campaigns.d.ts.map +1 -0
- package/dist/tools/campaigns.js +531 -0
- package/dist/tools/campaigns.js.map +1 -0
- package/dist/tools/channels.d.ts +8 -0
- package/dist/tools/channels.d.ts.map +1 -0
- package/dist/tools/channels.js +165 -0
- package/dist/tools/channels.js.map +1 -0
- package/dist/tools/chats.d.ts +8 -0
- package/dist/tools/chats.d.ts.map +1 -0
- package/dist/tools/chats.js +142 -0
- package/dist/tools/chats.js.map +1 -0
- package/dist/tools/collections.d.ts +8 -0
- package/dist/tools/collections.d.ts.map +1 -0
- package/dist/tools/collections.js +389 -0
- package/dist/tools/collections.js.map +1 -0
- package/dist/tools/contacts.d.ts +8 -0
- package/dist/tools/contacts.d.ts.map +1 -0
- package/dist/tools/contacts.js +430 -0
- package/dist/tools/contacts.js.map +1 -0
- package/dist/tools/crawler.d.ts +8 -0
- package/dist/tools/crawler.d.ts.map +1 -0
- package/dist/tools/crawler.js +263 -0
- package/dist/tools/crawler.js.map +1 -0
- package/dist/tools/dnc.d.ts +8 -0
- package/dist/tools/dnc.d.ts.map +1 -0
- package/dist/tools/dnc.js +287 -0
- package/dist/tools/dnc.js.map +1 -0
- package/dist/tools/documents.d.ts +9 -0
- package/dist/tools/documents.d.ts.map +1 -0
- package/dist/tools/documents.js +518 -0
- package/dist/tools/documents.js.map +1 -0
- package/dist/tools/engines.d.ts +8 -0
- package/dist/tools/engines.d.ts.map +1 -0
- package/dist/tools/engines.js +271 -0
- package/dist/tools/engines.js.map +1 -0
- package/dist/tools/environment.d.ts +9 -0
- package/dist/tools/environment.d.ts.map +1 -0
- package/dist/tools/environment.js +59 -0
- package/dist/tools/environment.js.map +1 -0
- package/dist/tools/forwarding.d.ts +8 -0
- package/dist/tools/forwarding.d.ts.map +1 -0
- package/dist/tools/forwarding.js +30 -0
- package/dist/tools/forwarding.js.map +1 -0
- package/dist/tools/index.d.ts +58 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +158 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/integrations.d.ts +8 -0
- package/dist/tools/integrations.d.ts.map +1 -0
- package/dist/tools/integrations.js +234 -0
- package/dist/tools/integrations.js.map +1 -0
- package/dist/tools/mailbox.d.ts +8 -0
- package/dist/tools/mailbox.d.ts.map +1 -0
- package/dist/tools/mailbox.js +105 -0
- package/dist/tools/mailbox.js.map +1 -0
- package/dist/tools/media.d.ts +8 -0
- package/dist/tools/media.d.ts.map +1 -0
- package/dist/tools/media.js +223 -0
- package/dist/tools/media.js.map +1 -0
- package/dist/tools/numbers.d.ts +8 -0
- package/dist/tools/numbers.d.ts.map +1 -0
- package/dist/tools/numbers.js +560 -0
- package/dist/tools/numbers.js.map +1 -0
- package/dist/tools/organizations.d.ts +8 -0
- package/dist/tools/organizations.d.ts.map +1 -0
- package/dist/tools/organizations.js +234 -0
- package/dist/tools/organizations.js.map +1 -0
- package/dist/tools/postprocessing.d.ts +8 -0
- package/dist/tools/postprocessing.d.ts.map +1 -0
- package/dist/tools/postprocessing.js +383 -0
- package/dist/tools/postprocessing.js.map +1 -0
- package/dist/tools/pronunciations.d.ts +8 -0
- package/dist/tools/pronunciations.d.ts.map +1 -0
- package/dist/tools/pronunciations.js +236 -0
- package/dist/tools/pronunciations.js.map +1 -0
- package/dist/tools/rules.d.ts +8 -0
- package/dist/tools/rules.d.ts.map +1 -0
- package/dist/tools/rules.js +465 -0
- package/dist/tools/rules.js.map +1 -0
- package/dist/tools/statistics.d.ts +8 -0
- package/dist/tools/statistics.d.ts.map +1 -0
- package/dist/tools/statistics.js +120 -0
- package/dist/tools/statistics.js.map +1 -0
- package/dist/tools/templates.d.ts +8 -0
- package/dist/tools/templates.d.ts.map +1 -0
- package/dist/tools/templates.js +211 -0
- package/dist/tools/templates.js.map +1 -0
- package/dist/tools/tests.d.ts +8 -0
- package/dist/tools/tests.d.ts.map +1 -0
- package/dist/tools/tests.js +329 -0
- package/dist/tools/tests.js.map +1 -0
- package/dist/tools/users.d.ts +8 -0
- package/dist/tools/users.d.ts.map +1 -0
- package/dist/tools/users.js +484 -0
- package/dist/tools/users.js.map +1 -0
- package/dist/tools/voice-preview.d.ts +8 -0
- package/dist/tools/voice-preview.d.ts.map +1 -0
- package/dist/tools/voice-preview.js +100 -0
- package/dist/tools/voice-preview.js.map +1 -0
- package/dist/tools/voices.d.ts +8 -0
- package/dist/tools/voices.d.ts.map +1 -0
- package/dist/tools/voices.js +110 -0
- package/dist/tools/voices.js.map +1 -0
- package/dist/tools/whitelabels.d.ts +8 -0
- package/dist/tools/whitelabels.d.ts.map +1 -0
- package/dist/tools/whitelabels.js +199 -0
- package/dist/tools/whitelabels.js.map +1 -0
- package/dist/tools/widget-config.d.ts +8 -0
- package/dist/tools/widget-config.d.ts.map +1 -0
- package/dist/tools/widget-config.js +116 -0
- package/dist/tools/widget-config.js.map +1 -0
- package/dist/types/api.d.ts +303 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +6 -0
- package/dist/types/api.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/tools.d.ts +41 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +6 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/utils/errors.d.ts +31 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +77 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.d.ts +11 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +25 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/validation.d.ts +34 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +68 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Organization Management Tools for dalvon-mcp
|
|
3
|
+
* Phase 4: 6 Tools for organization management (Admin)
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { formatApiError, createError, createSuccess, isApiError } from '../utils/errors.js';
|
|
7
|
+
import { validateUUID } from '../utils/validation.js';
|
|
8
|
+
// ==================== SCHEMAS ====================
|
|
9
|
+
const ListOrganizationsSchema = z.object({
|
|
10
|
+
status: z.enum(['active', 'inactive', 'suspended']).optional(),
|
|
11
|
+
whitelabel_id: z.string().uuid().optional(),
|
|
12
|
+
limit: z.number().min(1).max(100).optional().default(30),
|
|
13
|
+
offset: z.number().min(0).optional().default(0),
|
|
14
|
+
});
|
|
15
|
+
const CreateOrganizationSchema = z.object({
|
|
16
|
+
name: z.string().min(1),
|
|
17
|
+
description: z.string().optional(),
|
|
18
|
+
whitelabel_id: z.string().uuid().optional(),
|
|
19
|
+
settings: z.record(z.unknown()).optional(),
|
|
20
|
+
});
|
|
21
|
+
const VoiceBackendConfigSchema = z.object({
|
|
22
|
+
type: z.enum(['pipecat', 'elevenlabs_convai', 'PC', 'EL']).optional(),
|
|
23
|
+
pipecat_url: z.string().nullable().optional(),
|
|
24
|
+
stt_provider: z.enum(['deepgram', 'elevenlabs', 'DG', 'EL']).nullable().optional(),
|
|
25
|
+
allow_voice2voice: z.boolean().optional(),
|
|
26
|
+
}).optional();
|
|
27
|
+
const UpdateOrganizationSchema = z.object({
|
|
28
|
+
organization_id: z.string().uuid(),
|
|
29
|
+
name: z.string().optional(),
|
|
30
|
+
description: z.string().optional(),
|
|
31
|
+
status: z.enum(['active', 'inactive', 'suspended']).optional(),
|
|
32
|
+
voice_backend_config: VoiceBackendConfigSchema,
|
|
33
|
+
business_hours: z.record(z.unknown()).optional(),
|
|
34
|
+
});
|
|
35
|
+
// ==================== TOOLS ====================
|
|
36
|
+
export function createOrganizationTools(client) {
|
|
37
|
+
return [
|
|
38
|
+
// Tool 1: list_organizations
|
|
39
|
+
{
|
|
40
|
+
name: 'list_organizations',
|
|
41
|
+
description: `List all organizations.
|
|
42
|
+
|
|
43
|
+
**Admin Only:** Requires admin permissions.
|
|
44
|
+
|
|
45
|
+
Filter by status or whitelabel.`,
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {
|
|
49
|
+
status: { type: 'string', enum: ['active', 'inactive', 'suspended'], description: 'Filter by status' },
|
|
50
|
+
whitelabel_id: { type: 'string', description: 'Filter by whitelabel UUID' },
|
|
51
|
+
limit: { type: 'number', description: 'Number of results (default: 30)' },
|
|
52
|
+
offset: { type: 'number', description: 'Offset for pagination' },
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
handler: async (args) => {
|
|
56
|
+
const parsed = ListOrganizationsSchema.safeParse(args);
|
|
57
|
+
if (!parsed.success) {
|
|
58
|
+
return createError(`Invalid arguments: ${parsed.error.message}`);
|
|
59
|
+
}
|
|
60
|
+
const result = await client.listOrganizations(parsed.data);
|
|
61
|
+
if (!result.success || isApiError(result)) {
|
|
62
|
+
return formatApiError(result, 'list_organizations', 'Requires admin permissions');
|
|
63
|
+
}
|
|
64
|
+
const organizations = result.data || [];
|
|
65
|
+
return createSuccess({ count: organizations.length, organizations });
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
// Tool 2: get_organization
|
|
69
|
+
{
|
|
70
|
+
name: 'get_organization',
|
|
71
|
+
description: `Get details of a specific organization.
|
|
72
|
+
|
|
73
|
+
**Admin Only:** Requires admin permissions.`,
|
|
74
|
+
inputSchema: {
|
|
75
|
+
type: 'object',
|
|
76
|
+
properties: {
|
|
77
|
+
organization_id: { type: 'string', description: 'Organization UUID' },
|
|
78
|
+
},
|
|
79
|
+
required: ['organization_id'],
|
|
80
|
+
},
|
|
81
|
+
handler: async (args) => {
|
|
82
|
+
const { organization_id } = args;
|
|
83
|
+
const validationError = validateUUID(organization_id, 'organization_id');
|
|
84
|
+
if (validationError)
|
|
85
|
+
return validationError;
|
|
86
|
+
const result = await client.getOrganization(organization_id);
|
|
87
|
+
if (!result.success || isApiError(result)) {
|
|
88
|
+
return formatApiError(result, 'get_organization', 'Requires admin permissions');
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
// Tool 3: create_organization
|
|
94
|
+
{
|
|
95
|
+
name: 'create_organization',
|
|
96
|
+
description: `Create a new organization.
|
|
97
|
+
|
|
98
|
+
**Admin Only:** Requires admin permissions.`,
|
|
99
|
+
inputSchema: {
|
|
100
|
+
type: 'object',
|
|
101
|
+
properties: {
|
|
102
|
+
name: { type: 'string', description: 'Organization name' },
|
|
103
|
+
description: { type: 'string', description: 'Organization description' },
|
|
104
|
+
whitelabel_id: { type: 'string', description: 'Parent whitelabel UUID' },
|
|
105
|
+
settings: { type: 'object', description: 'Organization settings' },
|
|
106
|
+
},
|
|
107
|
+
required: ['name'],
|
|
108
|
+
},
|
|
109
|
+
handler: async (args) => {
|
|
110
|
+
const parsed = CreateOrganizationSchema.safeParse(args);
|
|
111
|
+
if (!parsed.success) {
|
|
112
|
+
return createError(`Invalid arguments: ${parsed.error.message}`);
|
|
113
|
+
}
|
|
114
|
+
const result = await client.createOrganization(parsed.data);
|
|
115
|
+
if (!result.success || isApiError(result)) {
|
|
116
|
+
return formatApiError(result, 'create_organization', 'Requires admin permissions');
|
|
117
|
+
}
|
|
118
|
+
const org = result.data;
|
|
119
|
+
return createSuccess({
|
|
120
|
+
message: 'Organization created',
|
|
121
|
+
organization_id: org.id,
|
|
122
|
+
name: org.name,
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
// Tool 4: update_organization
|
|
127
|
+
{
|
|
128
|
+
name: 'update_organization',
|
|
129
|
+
description: `Update an organization.
|
|
130
|
+
|
|
131
|
+
**Admin Only:** Requires admin permissions.`,
|
|
132
|
+
inputSchema: {
|
|
133
|
+
type: 'object',
|
|
134
|
+
properties: {
|
|
135
|
+
organization_id: { type: 'string', description: 'Organization UUID' },
|
|
136
|
+
name: { type: 'string', description: 'Updated name' },
|
|
137
|
+
description: { type: 'string', description: 'Updated description' },
|
|
138
|
+
status: { type: 'string', enum: ['active', 'inactive', 'suspended'], description: 'Status' },
|
|
139
|
+
voice_backend_config: {
|
|
140
|
+
type: 'object',
|
|
141
|
+
description: 'Voice backend config: {type, pipecat_url, stt_provider, allow_voice2voice}',
|
|
142
|
+
properties: {
|
|
143
|
+
type: { type: 'string', enum: ['pipecat', 'elevenlabs_convai', 'PC', 'EL'], description: 'Voice backend type' },
|
|
144
|
+
pipecat_url: { type: 'string', description: 'Pipecat WebSocket URL (null for default)' },
|
|
145
|
+
stt_provider: { type: 'string', enum: ['deepgram', 'elevenlabs', 'DG', 'EL'], description: 'STT provider' },
|
|
146
|
+
allow_voice2voice: { type: 'boolean', description: 'Allow Voice2Voice (Deepslate) mode for agents' },
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
business_hours: { type: 'object', description: 'Business hours config' },
|
|
150
|
+
},
|
|
151
|
+
required: ['organization_id'],
|
|
152
|
+
},
|
|
153
|
+
handler: async (args) => {
|
|
154
|
+
const parsed = UpdateOrganizationSchema.safeParse(args);
|
|
155
|
+
if (!parsed.success) {
|
|
156
|
+
return createError(`Invalid arguments: ${parsed.error.message}`);
|
|
157
|
+
}
|
|
158
|
+
const { organization_id, ...orgData } = parsed.data;
|
|
159
|
+
const validationError = validateUUID(organization_id, 'organization_id');
|
|
160
|
+
if (validationError)
|
|
161
|
+
return validationError;
|
|
162
|
+
if (Object.keys(orgData).length === 0) {
|
|
163
|
+
return createError('No fields to update');
|
|
164
|
+
}
|
|
165
|
+
const result = await client.updateOrganization(organization_id, orgData);
|
|
166
|
+
if (!result.success || isApiError(result)) {
|
|
167
|
+
return formatApiError(result, 'update_organization', 'Requires admin permissions');
|
|
168
|
+
}
|
|
169
|
+
return createSuccess({
|
|
170
|
+
message: 'Organization updated',
|
|
171
|
+
organization_id,
|
|
172
|
+
updated_fields: Object.keys(orgData),
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
// Tool 5: delete_organization
|
|
177
|
+
{
|
|
178
|
+
name: 'delete_organization',
|
|
179
|
+
description: `Delete an organization.
|
|
180
|
+
|
|
181
|
+
**Admin Only:** Requires admin permissions.
|
|
182
|
+
**Warning:** This deletes all organization data!`,
|
|
183
|
+
inputSchema: {
|
|
184
|
+
type: 'object',
|
|
185
|
+
properties: {
|
|
186
|
+
organization_id: { type: 'string', description: 'Organization UUID' },
|
|
187
|
+
},
|
|
188
|
+
required: ['organization_id'],
|
|
189
|
+
},
|
|
190
|
+
handler: async (args) => {
|
|
191
|
+
const { organization_id } = args;
|
|
192
|
+
const validationError = validateUUID(organization_id, 'organization_id');
|
|
193
|
+
if (validationError)
|
|
194
|
+
return validationError;
|
|
195
|
+
const result = await client.deleteOrganization(organization_id);
|
|
196
|
+
if (!result.success || isApiError(result)) {
|
|
197
|
+
return formatApiError(result, 'delete_organization', 'Requires admin permissions');
|
|
198
|
+
}
|
|
199
|
+
return createSuccess({
|
|
200
|
+
message: 'Organization deleted',
|
|
201
|
+
organization_id,
|
|
202
|
+
deleted: true,
|
|
203
|
+
warning: 'All organization data has been removed',
|
|
204
|
+
});
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
// Tool 6: get_organization_settings
|
|
208
|
+
{
|
|
209
|
+
name: 'get_organization_settings',
|
|
210
|
+
description: `Get settings for an organization.
|
|
211
|
+
|
|
212
|
+
**Admin Only:** Requires admin permissions.`,
|
|
213
|
+
inputSchema: {
|
|
214
|
+
type: 'object',
|
|
215
|
+
properties: {
|
|
216
|
+
organization_id: { type: 'string', description: 'Organization UUID' },
|
|
217
|
+
},
|
|
218
|
+
required: ['organization_id'],
|
|
219
|
+
},
|
|
220
|
+
handler: async (args) => {
|
|
221
|
+
const { organization_id } = args;
|
|
222
|
+
const validationError = validateUUID(organization_id, 'organization_id');
|
|
223
|
+
if (validationError)
|
|
224
|
+
return validationError;
|
|
225
|
+
const result = await client.getOrganizationSettings(organization_id);
|
|
226
|
+
if (!result.success || isApiError(result)) {
|
|
227
|
+
return formatApiError(result, 'get_organization_settings', 'Requires admin permissions');
|
|
228
|
+
}
|
|
229
|
+
return result;
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
];
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=organizations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organizations.js","sourceRoot":"","sources":["../../src/tools/organizations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,oDAAoD;AAEpD,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC9D,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAC3C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IACxD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;CAChD,CAAC,CAAC;AAEH,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACv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,CAAC,CAAC;gBACrF,CAAC;gBAED,OAAO,aAAa,CAAC;oBACnB,OAAO,EAAE,sBAAsB;oBAC/B,eAAe;oBACf,OAAO,EAAE,IAAI;oBACb,OAAO,EAAE,wCAAwC;iBAClD,CAAC,CAAC;YACL,CAAC;SACF;QAED,oCAAoC;QACpC;YACE,IAAI,EAAE,2BAA2B;YACjC,WAAW,EAAE;;4CAEyB;YACtC,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,eAAe,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,mBAAmB,EAAE;iBACtE;gBACD,QAAQ,EAAE,CAAC,iBAAiB,CAAC;aAC9B;YACD,OAAO,EAAE,KAAK,EAAE,IAAa,EAAyB,EAAE;gBACtD,MAAM,EAAE,eAAe,EAAE,GAAG,IAAmC,CAAC;gBAChE,MAAM,eAAe,GAAG,YAAY,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;gBACzE,IAAI,eAAe;oBAAE,OAAO,eAAe,CAAC;gBAE5C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,eAAe,CAAC,CAAC;gBACrE,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;oBAC1C,OAAO,cAAc,CAAC,MAAM,EAAE,2BAA2B,EAAE,4BAA4B,CAAC,CAAC;gBAC3F,CAAC;gBACD,OAAO,MAAM,CAAC;YAChB,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Postprocessing Tools for dalvon-mcp
|
|
3
|
+
* Phase 3: 7 Tools for managing call postprocessing results
|
|
4
|
+
*/
|
|
5
|
+
import type { DalvonClient } from '../clients/dalvon.js';
|
|
6
|
+
import type { McpTool } from '../types/index.js';
|
|
7
|
+
export declare function createPostprocessingTools(client: DalvonClient): McpTool[];
|
|
8
|
+
//# sourceMappingURL=postprocessing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postprocessing.d.ts","sourceRoot":"","sources":["../../src/tools/postprocessing.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,mBAAmB,CAAC;AA+C/D,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,EAAE,CA4WzE"}
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Postprocessing Tools for dalvon-mcp
|
|
3
|
+
* Phase 3: 7 Tools for managing call postprocessing results
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { formatApiError, createError, createSuccess, isApiError } from '../utils/errors.js';
|
|
7
|
+
import { validateUUID } from '../utils/validation.js';
|
|
8
|
+
// ==================== SCHEMAS ====================
|
|
9
|
+
const ListPostprocessingSchema = z.object({
|
|
10
|
+
target_user_id: z.string().uuid().optional().describe('Impersonate user to see their postprocessing (requires admin/platform permissions)'),
|
|
11
|
+
scope: z.enum(['user', 'organization', 'whitelabel', 'platform']).optional().describe('Expand view scope (admin only)'),
|
|
12
|
+
visibility: z.array(z.enum(['user', 'organization', 'whitelabel', 'platform'])).optional().describe('Filter by visibility levels'),
|
|
13
|
+
name: z.string().optional().describe('Filter by name'),
|
|
14
|
+
type: z.array(z.string()).optional().describe('Filter by type'),
|
|
15
|
+
limit: z.number().min(1).max(100).optional().default(30).describe('Number of results'),
|
|
16
|
+
skip: z.number().min(0).optional().default(0).describe('Offset for pagination'),
|
|
17
|
+
});
|
|
18
|
+
const TriggerPostprocessingSchema = z.object({
|
|
19
|
+
call_id: z.string().uuid().describe('Call ID to process'),
|
|
20
|
+
force: z.boolean().optional().default(false).describe('Force reprocessing even if already done'),
|
|
21
|
+
processors: z.array(z.string()).optional().describe('Specific processors to run (e.g., ["transcription", "summary", "sentiment"])'),
|
|
22
|
+
});
|
|
23
|
+
const UpdatePostprocessingSchema = z.object({
|
|
24
|
+
result_id: z.string().uuid().describe('Postprocessing result ID'),
|
|
25
|
+
summary: z.string().optional().describe('Updated summary'),
|
|
26
|
+
categories: z.array(z.string()).optional().describe('Updated categories'),
|
|
27
|
+
tags: z.array(z.string()).optional().describe('Updated tags'),
|
|
28
|
+
custom_data: z.record(z.unknown()).optional().describe('Custom data to add'),
|
|
29
|
+
});
|
|
30
|
+
const UpdateCallFromPostprocessingSchema = z.object({
|
|
31
|
+
call_id: z.string().uuid().describe('Call ID to update'),
|
|
32
|
+
apply_summary: z.boolean().optional().default(true).describe('Apply generated summary to call'),
|
|
33
|
+
apply_categories: z.boolean().optional().default(true).describe('Apply detected categories'),
|
|
34
|
+
apply_sentiment: z.boolean().optional().default(true).describe('Apply sentiment analysis'),
|
|
35
|
+
apply_action_items: z.boolean().optional().default(true).describe('Apply extracted action items'),
|
|
36
|
+
});
|
|
37
|
+
const TransferPostprocessingSchema = z.object({
|
|
38
|
+
source_call_id: z.string().uuid().describe('Source call ID'),
|
|
39
|
+
target_call_id: z.string().uuid().describe('Target call ID'),
|
|
40
|
+
data_types: z.array(z.enum(['transcription', 'summary', 'categories', 'sentiment', 'action_items'])).optional()
|
|
41
|
+
.describe('Which data types to transfer (default: all)'),
|
|
42
|
+
});
|
|
43
|
+
// ==================== TOOLS ====================
|
|
44
|
+
export function createPostprocessingTools(client) {
|
|
45
|
+
return [
|
|
46
|
+
// Tool 1: list_postprocessing_results
|
|
47
|
+
{
|
|
48
|
+
name: 'list_postprocessing_results',
|
|
49
|
+
description: `List postprocessing results for calls with optional filtering.
|
|
50
|
+
|
|
51
|
+
Postprocessing includes:
|
|
52
|
+
- **Transcription**: Full call transcript
|
|
53
|
+
- **Summary**: AI-generated call summary
|
|
54
|
+
- **Sentiment**: Sentiment analysis of the conversation
|
|
55
|
+
- **Categories**: Auto-detected call categories
|
|
56
|
+
- **Action Items**: Extracted follow-up actions
|
|
57
|
+
|
|
58
|
+
Filter by call, agent, status, or date range.`,
|
|
59
|
+
inputSchema: {
|
|
60
|
+
type: 'object',
|
|
61
|
+
properties: {
|
|
62
|
+
target_user_id: { type: 'string', description: 'Impersonate user to see their postprocessing (requires admin/platform permissions)' },
|
|
63
|
+
scope: { type: 'string', enum: ['user', 'organization', 'whitelabel', 'platform'], description: 'Expand view scope (admin only)' },
|
|
64
|
+
visibility: { type: 'array', items: { type: 'string', enum: ['user', 'organization', 'whitelabel', 'platform'] }, description: 'Filter by visibility levels' },
|
|
65
|
+
call_id: { type: 'string', description: 'Filter by specific call ID' },
|
|
66
|
+
agent_id: { type: 'string', description: 'Filter by agent ID' },
|
|
67
|
+
status: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
enum: ['pending', 'processing', 'completed', 'failed'],
|
|
70
|
+
description: 'Filter by processing status',
|
|
71
|
+
},
|
|
72
|
+
from_date: { type: 'string', description: 'From date (ISO 8601)' },
|
|
73
|
+
to_date: { type: 'string', description: 'To date (ISO 8601)' },
|
|
74
|
+
limit: { type: 'number', description: 'Number of results (default: 30)' },
|
|
75
|
+
offset: { type: 'number', description: 'Offset for pagination' },
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
handler: async (args) => {
|
|
79
|
+
const parsed = ListPostprocessingSchema.safeParse(args);
|
|
80
|
+
if (!parsed.success) {
|
|
81
|
+
return createError(`Invalid arguments: ${parsed.error.message}`);
|
|
82
|
+
}
|
|
83
|
+
const result = await client.listPostprocessingResults(parsed.data);
|
|
84
|
+
if (!result.success || isApiError(result)) {
|
|
85
|
+
return formatApiError(result, 'list_postprocessing_results');
|
|
86
|
+
}
|
|
87
|
+
const results = result.data || [];
|
|
88
|
+
return createSuccess({
|
|
89
|
+
count: results.length,
|
|
90
|
+
results,
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
// Tool 2: get_postprocessing_result
|
|
95
|
+
{
|
|
96
|
+
name: 'get_postprocessing_result',
|
|
97
|
+
description: `Get detailed postprocessing result for a specific call or result ID.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
- Full transcription
|
|
101
|
+
- Generated summary
|
|
102
|
+
- Sentiment scores
|
|
103
|
+
- Detected categories and topics
|
|
104
|
+
- Extracted action items
|
|
105
|
+
- Processing metadata`,
|
|
106
|
+
inputSchema: {
|
|
107
|
+
type: 'object',
|
|
108
|
+
properties: {
|
|
109
|
+
result_id: { type: 'string', description: 'Postprocessing result ID (UUID)' },
|
|
110
|
+
target_user_id: { type: 'string', description: 'Impersonate user (requires admin/platform permissions)' },
|
|
111
|
+
},
|
|
112
|
+
required: ['result_id'],
|
|
113
|
+
},
|
|
114
|
+
handler: async (args) => {
|
|
115
|
+
const { result_id, target_user_id } = args;
|
|
116
|
+
const validationError = validateUUID(result_id, 'result_id');
|
|
117
|
+
if (validationError)
|
|
118
|
+
return validationError;
|
|
119
|
+
const result = await client.getPostprocessingResult(result_id, target_user_id);
|
|
120
|
+
if (!result.success || isApiError(result)) {
|
|
121
|
+
return formatApiError(result, 'get_postprocessing_result', 'Check if the result_id is correct using list_postprocessing_results');
|
|
122
|
+
}
|
|
123
|
+
return result;
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
// Tool 3: trigger_postprocessing
|
|
127
|
+
{
|
|
128
|
+
name: 'trigger_postprocessing',
|
|
129
|
+
description: `Manually trigger postprocessing for a call.
|
|
130
|
+
|
|
131
|
+
Use this when:
|
|
132
|
+
- Automatic postprocessing failed
|
|
133
|
+
- You want to reprocess with updated settings
|
|
134
|
+
- You want to run specific processors only
|
|
135
|
+
|
|
136
|
+
**Available Processors:**
|
|
137
|
+
- transcription: Generate call transcript
|
|
138
|
+
- summary: Create AI summary
|
|
139
|
+
- sentiment: Analyze sentiment
|
|
140
|
+
- categories: Detect categories
|
|
141
|
+
- action_items: Extract action items`,
|
|
142
|
+
inputSchema: {
|
|
143
|
+
type: 'object',
|
|
144
|
+
properties: {
|
|
145
|
+
call_id: { type: 'string', description: 'Call ID to process' },
|
|
146
|
+
force: { type: 'boolean', description: 'Force reprocessing even if already done' },
|
|
147
|
+
processors: {
|
|
148
|
+
type: 'array',
|
|
149
|
+
items: { type: 'string' },
|
|
150
|
+
description: 'Specific processors to run (default: all)',
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
required: ['call_id'],
|
|
154
|
+
},
|
|
155
|
+
handler: async (args) => {
|
|
156
|
+
const parsed = TriggerPostprocessingSchema.safeParse(args);
|
|
157
|
+
if (!parsed.success) {
|
|
158
|
+
return createError(`Invalid arguments: ${parsed.error.message}`);
|
|
159
|
+
}
|
|
160
|
+
const validationError = validateUUID(parsed.data.call_id, 'call_id');
|
|
161
|
+
if (validationError)
|
|
162
|
+
return validationError;
|
|
163
|
+
const result = await client.triggerPostprocessing(parsed.data.call_id, {
|
|
164
|
+
force: parsed.data.force,
|
|
165
|
+
processors: parsed.data.processors,
|
|
166
|
+
});
|
|
167
|
+
if (!result.success || isApiError(result)) {
|
|
168
|
+
return formatApiError(result, 'trigger_postprocessing');
|
|
169
|
+
}
|
|
170
|
+
const data = result.data;
|
|
171
|
+
return createSuccess({
|
|
172
|
+
message: 'Postprocessing triggered successfully',
|
|
173
|
+
call_id: parsed.data.call_id,
|
|
174
|
+
job_id: data.job_id || data.id,
|
|
175
|
+
status: data.status || 'pending',
|
|
176
|
+
processors: parsed.data.processors || 'all',
|
|
177
|
+
});
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
// Tool 4: update_postprocessing_result
|
|
181
|
+
{
|
|
182
|
+
name: 'update_postprocessing_result',
|
|
183
|
+
description: `Update a postprocessing result with corrections or additional data.
|
|
184
|
+
|
|
185
|
+
Use this to:
|
|
186
|
+
- Correct auto-generated summaries
|
|
187
|
+
- Add or modify categories
|
|
188
|
+
- Add custom tags
|
|
189
|
+
- Attach additional metadata`,
|
|
190
|
+
inputSchema: {
|
|
191
|
+
type: 'object',
|
|
192
|
+
properties: {
|
|
193
|
+
result_id: { type: 'string', description: 'Postprocessing result ID' },
|
|
194
|
+
summary: { type: 'string', description: 'Corrected or updated summary' },
|
|
195
|
+
categories: {
|
|
196
|
+
type: 'array',
|
|
197
|
+
items: { type: 'string' },
|
|
198
|
+
description: 'Updated categories',
|
|
199
|
+
},
|
|
200
|
+
tags: {
|
|
201
|
+
type: 'array',
|
|
202
|
+
items: { type: 'string' },
|
|
203
|
+
description: 'Tags to add',
|
|
204
|
+
},
|
|
205
|
+
custom_data: {
|
|
206
|
+
type: 'object',
|
|
207
|
+
description: 'Custom metadata to attach',
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
required: ['result_id'],
|
|
211
|
+
},
|
|
212
|
+
handler: async (args) => {
|
|
213
|
+
const parsed = UpdatePostprocessingSchema.safeParse(args);
|
|
214
|
+
if (!parsed.success) {
|
|
215
|
+
return createError(`Invalid arguments: ${parsed.error.message}`);
|
|
216
|
+
}
|
|
217
|
+
const { result_id, ...updateData } = parsed.data;
|
|
218
|
+
const validationError = validateUUID(result_id, 'result_id');
|
|
219
|
+
if (validationError)
|
|
220
|
+
return validationError;
|
|
221
|
+
if (Object.keys(updateData).length === 0) {
|
|
222
|
+
return createError('No update data provided', 'Provide at least one field to update');
|
|
223
|
+
}
|
|
224
|
+
const result = await client.updatePostprocessingResult(result_id, updateData);
|
|
225
|
+
if (!result.success || isApiError(result)) {
|
|
226
|
+
return formatApiError(result, 'update_postprocessing_result');
|
|
227
|
+
}
|
|
228
|
+
return createSuccess({
|
|
229
|
+
message: 'Postprocessing result updated successfully',
|
|
230
|
+
result_id,
|
|
231
|
+
updated_fields: Object.keys(updateData),
|
|
232
|
+
});
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
// Tool 5: delete_postprocessing_result
|
|
236
|
+
{
|
|
237
|
+
name: 'delete_postprocessing_result',
|
|
238
|
+
description: `Delete a postprocessing result.
|
|
239
|
+
|
|
240
|
+
**Warning:** This permanently removes the postprocessing data including:
|
|
241
|
+
- Transcription
|
|
242
|
+
- Summary
|
|
243
|
+
- Sentiment analysis
|
|
244
|
+
- Categories and tags
|
|
245
|
+
|
|
246
|
+
The original call recording is NOT affected.`,
|
|
247
|
+
inputSchema: {
|
|
248
|
+
type: 'object',
|
|
249
|
+
properties: {
|
|
250
|
+
result_id: { type: 'string', description: 'Postprocessing result ID to delete' },
|
|
251
|
+
},
|
|
252
|
+
required: ['result_id'],
|
|
253
|
+
},
|
|
254
|
+
handler: async (args) => {
|
|
255
|
+
const { result_id } = args;
|
|
256
|
+
const validationError = validateUUID(result_id, 'result_id');
|
|
257
|
+
if (validationError)
|
|
258
|
+
return validationError;
|
|
259
|
+
const result = await client.deletePostprocessingResult(result_id);
|
|
260
|
+
if (!result.success || isApiError(result)) {
|
|
261
|
+
return formatApiError(result, 'delete_postprocessing_result');
|
|
262
|
+
}
|
|
263
|
+
return createSuccess({
|
|
264
|
+
message: 'Postprocessing result deleted successfully',
|
|
265
|
+
result_id,
|
|
266
|
+
deleted: true,
|
|
267
|
+
});
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
// Tool 6: update_call_from_postprocessing
|
|
271
|
+
{
|
|
272
|
+
name: 'update_call_from_postprocessing',
|
|
273
|
+
description: `Apply postprocessing results to the original call record.
|
|
274
|
+
|
|
275
|
+
This syncs processed data back to the call, including:
|
|
276
|
+
- AI-generated summary → Call summary field
|
|
277
|
+
- Detected categories → Call categories
|
|
278
|
+
- Sentiment scores → Call metadata
|
|
279
|
+
- Action items → Call follow-up tasks
|
|
280
|
+
|
|
281
|
+
Useful when postprocessing was done separately and needs to be merged.`,
|
|
282
|
+
inputSchema: {
|
|
283
|
+
type: 'object',
|
|
284
|
+
properties: {
|
|
285
|
+
call_id: { type: 'string', description: 'Call ID to update' },
|
|
286
|
+
apply_summary: { type: 'boolean', description: 'Apply generated summary (default: true)' },
|
|
287
|
+
apply_categories: { type: 'boolean', description: 'Apply detected categories (default: true)' },
|
|
288
|
+
apply_sentiment: { type: 'boolean', description: 'Apply sentiment analysis (default: true)' },
|
|
289
|
+
apply_action_items: { type: 'boolean', description: 'Apply action items (default: true)' },
|
|
290
|
+
},
|
|
291
|
+
required: ['call_id'],
|
|
292
|
+
},
|
|
293
|
+
handler: async (args) => {
|
|
294
|
+
const parsed = UpdateCallFromPostprocessingSchema.safeParse(args);
|
|
295
|
+
if (!parsed.success) {
|
|
296
|
+
return createError(`Invalid arguments: ${parsed.error.message}`);
|
|
297
|
+
}
|
|
298
|
+
const validationError = validateUUID(parsed.data.call_id, 'call_id');
|
|
299
|
+
if (validationError)
|
|
300
|
+
return validationError;
|
|
301
|
+
const result = await client.updateCallFromPostprocessing(parsed.data.call_id, {
|
|
302
|
+
apply_summary: parsed.data.apply_summary,
|
|
303
|
+
apply_categories: parsed.data.apply_categories,
|
|
304
|
+
apply_sentiment: parsed.data.apply_sentiment,
|
|
305
|
+
apply_action_items: parsed.data.apply_action_items,
|
|
306
|
+
});
|
|
307
|
+
if (!result.success || isApiError(result)) {
|
|
308
|
+
return formatApiError(result, 'update_call_from_postprocessing');
|
|
309
|
+
}
|
|
310
|
+
const data = result.data;
|
|
311
|
+
return createSuccess({
|
|
312
|
+
message: 'Call updated from postprocessing successfully',
|
|
313
|
+
call_id: parsed.data.call_id,
|
|
314
|
+
applied: {
|
|
315
|
+
summary: parsed.data.apply_summary,
|
|
316
|
+
categories: parsed.data.apply_categories,
|
|
317
|
+
sentiment: parsed.data.apply_sentiment,
|
|
318
|
+
action_items: parsed.data.apply_action_items,
|
|
319
|
+
},
|
|
320
|
+
result: data,
|
|
321
|
+
});
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
// Tool 7: transfer_postprocessing_data
|
|
325
|
+
{
|
|
326
|
+
name: 'transfer_postprocessing_data',
|
|
327
|
+
description: `Transfer postprocessing data from one call to another.
|
|
328
|
+
|
|
329
|
+
Useful when:
|
|
330
|
+
- A call was split and data needs to be merged
|
|
331
|
+
- Testing with sample data
|
|
332
|
+
- Migrating data between environments
|
|
333
|
+
|
|
334
|
+
You can choose which data types to transfer.`,
|
|
335
|
+
inputSchema: {
|
|
336
|
+
type: 'object',
|
|
337
|
+
properties: {
|
|
338
|
+
source_call_id: { type: 'string', description: 'Source call ID to copy from' },
|
|
339
|
+
target_call_id: { type: 'string', description: 'Target call ID to copy to' },
|
|
340
|
+
data_types: {
|
|
341
|
+
type: 'array',
|
|
342
|
+
items: {
|
|
343
|
+
type: 'string',
|
|
344
|
+
enum: ['transcription', 'summary', 'categories', 'sentiment', 'action_items'],
|
|
345
|
+
},
|
|
346
|
+
description: 'Which data types to transfer (default: all)',
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
required: ['source_call_id', 'target_call_id'],
|
|
350
|
+
},
|
|
351
|
+
handler: async (args) => {
|
|
352
|
+
const parsed = TransferPostprocessingSchema.safeParse(args);
|
|
353
|
+
if (!parsed.success) {
|
|
354
|
+
return createError(`Invalid arguments: ${parsed.error.message}`);
|
|
355
|
+
}
|
|
356
|
+
const sourceValidation = validateUUID(parsed.data.source_call_id, 'source_call_id');
|
|
357
|
+
if (sourceValidation)
|
|
358
|
+
return sourceValidation;
|
|
359
|
+
const targetValidation = validateUUID(parsed.data.target_call_id, 'target_call_id');
|
|
360
|
+
if (targetValidation)
|
|
361
|
+
return targetValidation;
|
|
362
|
+
if (parsed.data.source_call_id === parsed.data.target_call_id) {
|
|
363
|
+
return createError('Source and target call IDs must be different');
|
|
364
|
+
}
|
|
365
|
+
const result = await client.transferPostprocessingData({
|
|
366
|
+
source_call_id: parsed.data.source_call_id,
|
|
367
|
+
target_call_id: parsed.data.target_call_id,
|
|
368
|
+
data_types: parsed.data.data_types,
|
|
369
|
+
});
|
|
370
|
+
if (!result.success || isApiError(result)) {
|
|
371
|
+
return formatApiError(result, 'transfer_postprocessing_data');
|
|
372
|
+
}
|
|
373
|
+
return createSuccess({
|
|
374
|
+
message: 'Postprocessing data transferred successfully',
|
|
375
|
+
source_call_id: parsed.data.source_call_id,
|
|
376
|
+
target_call_id: parsed.data.target_call_id,
|
|
377
|
+
transferred: parsed.data.data_types || 'all',
|
|
378
|
+
});
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
];
|
|
382
|
+
}
|
|
383
|
+
//# sourceMappingURL=postprocessing.js.map
|