@chanl/sdk 2.0.1
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 +59 -0
- package/dist/adapters/openai.d.ts +106 -0
- package/dist/adapters/openai.d.ts.map +1 -0
- package/dist/adapters/openai.js +185 -0
- package/dist/adapters/openai.js.map +1 -0
- package/dist/client.d.ts +74 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +293 -0
- package/dist/client.js.map +1 -0
- package/dist/errors/index.d.ts +179 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +319 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +76 -0
- package/dist/index.js.map +1 -0
- package/dist/live/index.d.ts +9 -0
- package/dist/live/index.d.ts.map +1 -0
- package/dist/live/index.js +16 -0
- package/dist/live/index.js.map +1 -0
- package/dist/live/live-call.d.ts +48 -0
- package/dist/live/live-call.d.ts.map +1 -0
- package/dist/live/live-call.js +148 -0
- package/dist/live/live-call.js.map +1 -0
- package/dist/live/live-chat.d.ts +71 -0
- package/dist/live/live-chat.d.ts.map +1 -0
- package/dist/live/live-chat.js +95 -0
- package/dist/live/live-chat.js.map +1 -0
- package/dist/live/live-execution.d.ts +55 -0
- package/dist/live/live-execution.d.ts.map +1 -0
- package/dist/live/live-execution.js +170 -0
- package/dist/live/live-execution.js.map +1 -0
- package/dist/live/typed-emitter.d.ts +15 -0
- package/dist/live/typed-emitter.d.ts.map +1 -0
- package/dist/live/typed-emitter.js +40 -0
- package/dist/live/typed-emitter.js.map +1 -0
- package/dist/live/types.d.ts +24 -0
- package/dist/live/types.d.ts.map +1 -0
- package/dist/live/types.js +6 -0
- package/dist/live/types.js.map +1 -0
- package/dist/modules/agents.d.ts +378 -0
- package/dist/modules/agents.d.ts.map +1 -0
- package/dist/modules/agents.js +259 -0
- package/dist/modules/agents.js.map +1 -0
- package/dist/modules/alerts.d.ts +43 -0
- package/dist/modules/alerts.d.ts.map +1 -0
- package/dist/modules/alerts.js +56 -0
- package/dist/modules/alerts.js.map +1 -0
- package/dist/modules/audio.d.ts +47 -0
- package/dist/modules/audio.d.ts.map +1 -0
- package/dist/modules/audio.js +75 -0
- package/dist/modules/audio.js.map +1 -0
- package/dist/modules/auth.d.ts +76 -0
- package/dist/modules/auth.d.ts.map +1 -0
- package/dist/modules/auth.js +59 -0
- package/dist/modules/auth.js.map +1 -0
- package/dist/modules/calls.d.ts +825 -0
- package/dist/modules/calls.d.ts.map +1 -0
- package/dist/modules/calls.js +398 -0
- package/dist/modules/calls.js.map +1 -0
- package/dist/modules/chat.d.ts +165 -0
- package/dist/modules/chat.d.ts.map +1 -0
- package/dist/modules/chat.js +169 -0
- package/dist/modules/chat.js.map +1 -0
- package/dist/modules/health.d.ts +45 -0
- package/dist/modules/health.d.ts.map +1 -0
- package/dist/modules/health.js +22 -0
- package/dist/modules/health.js.map +1 -0
- package/dist/modules/knowledge.d.ts +202 -0
- package/dist/modules/knowledge.d.ts.map +1 -0
- package/dist/modules/knowledge.js +147 -0
- package/dist/modules/knowledge.js.map +1 -0
- package/dist/modules/mcp.d.ts +140 -0
- package/dist/modules/mcp.d.ts.map +1 -0
- package/dist/modules/mcp.js +110 -0
- package/dist/modules/mcp.js.map +1 -0
- package/dist/modules/memory.d.ts +163 -0
- package/dist/modules/memory.d.ts.map +1 -0
- package/dist/modules/memory.js +208 -0
- package/dist/modules/memory.js.map +1 -0
- package/dist/modules/personas.d.ts +168 -0
- package/dist/modules/personas.d.ts.map +1 -0
- package/dist/modules/personas.js +106 -0
- package/dist/modules/personas.js.map +1 -0
- package/dist/modules/prompts.d.ts +128 -0
- package/dist/modules/prompts.d.ts.map +1 -0
- package/dist/modules/prompts.js +93 -0
- package/dist/modules/prompts.js.map +1 -0
- package/dist/modules/scenarios.d.ts +294 -0
- package/dist/modules/scenarios.d.ts.map +1 -0
- package/dist/modules/scenarios.js +349 -0
- package/dist/modules/scenarios.js.map +1 -0
- package/dist/modules/scorecard.d.ts +642 -0
- package/dist/modules/scorecard.d.ts.map +1 -0
- package/dist/modules/scorecard.js +327 -0
- package/dist/modules/scorecard.js.map +1 -0
- package/dist/modules/tools.d.ts +222 -0
- package/dist/modules/tools.d.ts.map +1 -0
- package/dist/modules/tools.js +302 -0
- package/dist/modules/tools.js.map +1 -0
- package/dist/modules/toolsets.d.ts +173 -0
- package/dist/modules/toolsets.d.ts.map +1 -0
- package/dist/modules/toolsets.js +216 -0
- package/dist/modules/toolsets.js.map +1 -0
- package/dist/modules/transcript.d.ts +60 -0
- package/dist/modules/transcript.d.ts.map +1 -0
- package/dist/modules/transcript.js +69 -0
- package/dist/modules/transcript.js.map +1 -0
- package/dist/modules/workspace.d.ts +48 -0
- package/dist/modules/workspace.d.ts.map +1 -0
- package/dist/modules/workspace.js +49 -0
- package/dist/modules/workspace.js.map +1 -0
- package/dist/types/api.d.ts +8 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/api.js +25 -0
- package/dist/types/api.js.map +1 -0
- package/dist/types/config.d.ts +70 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +3 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/memory.d.ts +243 -0
- package/dist/types/memory.d.ts.map +1 -0
- package/dist/types/memory.js +9 -0
- package/dist/types/memory.js.map +1 -0
- package/dist/types/tool-calls.d.ts +61 -0
- package/dist/types/tool-calls.d.ts.map +1 -0
- package/dist/types/tool-calls.js +9 -0
- package/dist/types/tool-calls.js.map +1 -0
- package/dist/types/tools.d.ts +321 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +9 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/types/toolsets.d.ts +149 -0
- package/dist/types/toolsets.d.ts.map +1 -0
- package/dist/types/toolsets.js +8 -0
- package/dist/types/toolsets.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for live monitoring classes
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* A single transcript segment from a call or voice scenario
|
|
6
|
+
*/
|
|
7
|
+
export interface TranscriptSegment {
|
|
8
|
+
speaker: string;
|
|
9
|
+
text: string;
|
|
10
|
+
start: number;
|
|
11
|
+
end: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Options for live monitoring (polling-based)
|
|
15
|
+
*/
|
|
16
|
+
export interface LiveOptions {
|
|
17
|
+
/** Poll interval in ms (default: 2000) */
|
|
18
|
+
pollInterval?: number;
|
|
19
|
+
/** Max polls before timeout (default: 150 = 5 min) */
|
|
20
|
+
maxPolls?: number;
|
|
21
|
+
/** External AbortSignal for cancellation */
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/live/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,0CAA0C;IAC1C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sDAAsD;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/live/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentsModule - SDK module for agent management
|
|
3
|
+
*
|
|
4
|
+
* Provides operations for AI agents.
|
|
5
|
+
*/
|
|
6
|
+
import { ChanlSDK } from '../client';
|
|
7
|
+
import { ApiResponse } from '../types/config';
|
|
8
|
+
export interface Agent {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
provider?: string;
|
|
13
|
+
providerId?: string;
|
|
14
|
+
status?: 'active' | 'inactive';
|
|
15
|
+
workspaceId: string;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
updatedAt: string;
|
|
18
|
+
}
|
|
19
|
+
export interface AgentFilters {
|
|
20
|
+
status?: string;
|
|
21
|
+
provider?: string;
|
|
22
|
+
page?: number;
|
|
23
|
+
limit?: number;
|
|
24
|
+
sortBy?: string;
|
|
25
|
+
sortOrder?: 'asc' | 'desc';
|
|
26
|
+
}
|
|
27
|
+
export interface AgentListResponse {
|
|
28
|
+
agents: Agent[];
|
|
29
|
+
pagination?: {
|
|
30
|
+
total: number;
|
|
31
|
+
page: number;
|
|
32
|
+
limit: number;
|
|
33
|
+
pages: number;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface AgentResponse {
|
|
37
|
+
agent: Agent;
|
|
38
|
+
}
|
|
39
|
+
export interface AgentConfiguration {
|
|
40
|
+
prompt?: string;
|
|
41
|
+
model?: string;
|
|
42
|
+
voice?: string;
|
|
43
|
+
transcriber?: string;
|
|
44
|
+
vapi?: {
|
|
45
|
+
webhookUrl?: string;
|
|
46
|
+
firstMessage?: string;
|
|
47
|
+
tools?: unknown[];
|
|
48
|
+
};
|
|
49
|
+
deepgram?: Record<string, unknown>;
|
|
50
|
+
elevenlabs?: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
export interface CreateAgentData {
|
|
53
|
+
platform: 'vapi' | 'bland' | 'twilio' | 'openai' | 'deepgram' | 'elevenlabs' | 'custom';
|
|
54
|
+
name: string;
|
|
55
|
+
platformAgentId?: string;
|
|
56
|
+
type?: 'Voice Assistant' | 'Conversation AI' | 'Speech-to-Text' | 'Text-to-Speech' | 'Analysis Engine';
|
|
57
|
+
status?: 'active' | 'inactive' | 'error' | 'training' | 'maintenance';
|
|
58
|
+
useCase?: 'support' | 'sales' | 'booking' | 'technical' | 'analytics';
|
|
59
|
+
description?: string;
|
|
60
|
+
configuration?: AgentConfiguration;
|
|
61
|
+
platformRawData?: unknown;
|
|
62
|
+
phoneNumbers?: string[];
|
|
63
|
+
testPhoneNumber?: string;
|
|
64
|
+
defaultScorecardId?: string;
|
|
65
|
+
autoAnalysisEnabled?: boolean;
|
|
66
|
+
defaultSimulationChannel?: 'websocket' | 'phoneCall';
|
|
67
|
+
simulationMode?: 'text' | 'websocket' | 'phone';
|
|
68
|
+
}
|
|
69
|
+
export interface UpdateAgentData extends Partial<CreateAgentData> {
|
|
70
|
+
syncToVapi?: boolean;
|
|
71
|
+
syncStatus?: {
|
|
72
|
+
lastSynced?: Date;
|
|
73
|
+
syncedBy?: string;
|
|
74
|
+
syncErrors?: string[];
|
|
75
|
+
isOutOfSync?: boolean;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export interface ImportAgentOptions {
|
|
79
|
+
platform: string;
|
|
80
|
+
externalAgentId: string;
|
|
81
|
+
name?: string;
|
|
82
|
+
}
|
|
83
|
+
export interface ImportAgentResponse {
|
|
84
|
+
agent: Agent & {
|
|
85
|
+
deployments?: Array<{
|
|
86
|
+
orchestrator: string;
|
|
87
|
+
externalId: string;
|
|
88
|
+
status: string;
|
|
89
|
+
}>;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export interface PublishAgentOptions {
|
|
93
|
+
platform: string;
|
|
94
|
+
targetExternalId?: string;
|
|
95
|
+
includeMcp?: boolean;
|
|
96
|
+
}
|
|
97
|
+
export interface PublishResult {
|
|
98
|
+
externalId: string;
|
|
99
|
+
platform: string;
|
|
100
|
+
status: string;
|
|
101
|
+
mcpUrl?: string;
|
|
102
|
+
action: 'created' | 'updated';
|
|
103
|
+
}
|
|
104
|
+
export interface PushMcpOptions {
|
|
105
|
+
platform: string;
|
|
106
|
+
targetExternalId?: string;
|
|
107
|
+
}
|
|
108
|
+
export interface PushMcpResult {
|
|
109
|
+
mcpUrl: string;
|
|
110
|
+
platform: string;
|
|
111
|
+
externalId: string;
|
|
112
|
+
status: string;
|
|
113
|
+
}
|
|
114
|
+
export interface DeleteAgentOptions {
|
|
115
|
+
deleteFromIntegration?: boolean;
|
|
116
|
+
}
|
|
117
|
+
export interface DeleteAgentResponse {
|
|
118
|
+
success: boolean;
|
|
119
|
+
message?: string;
|
|
120
|
+
}
|
|
121
|
+
export interface SyncAgentsOptions {
|
|
122
|
+
platform?: 'vapi' | 'bland' | 'twilio' | 'all';
|
|
123
|
+
agentIds?: string[];
|
|
124
|
+
forceUpdate?: boolean;
|
|
125
|
+
syncConfiguration?: boolean;
|
|
126
|
+
updateMetrics?: boolean;
|
|
127
|
+
cleanBeforeSync?: boolean;
|
|
128
|
+
}
|
|
129
|
+
export interface SyncAgentsResult {
|
|
130
|
+
message: string;
|
|
131
|
+
processed: number;
|
|
132
|
+
created: number;
|
|
133
|
+
updated: number;
|
|
134
|
+
errors: number;
|
|
135
|
+
details: Array<{
|
|
136
|
+
agentId: string;
|
|
137
|
+
name: string;
|
|
138
|
+
status: 'created' | 'updated' | 'skipped' | 'error';
|
|
139
|
+
message?: string;
|
|
140
|
+
}>;
|
|
141
|
+
}
|
|
142
|
+
export interface SyncAgentsResponse {
|
|
143
|
+
result: SyncAgentsResult;
|
|
144
|
+
}
|
|
145
|
+
export interface AgentStats {
|
|
146
|
+
totalAgents: number;
|
|
147
|
+
avgScore: number | null;
|
|
148
|
+
toolFailures: number;
|
|
149
|
+
topProvider: string | null;
|
|
150
|
+
byPlatform: Record<string, number>;
|
|
151
|
+
byStatus: Record<string, number>;
|
|
152
|
+
}
|
|
153
|
+
export interface AgentStatsResponse {
|
|
154
|
+
stats: AgentStats;
|
|
155
|
+
}
|
|
156
|
+
export declare class AgentsModule {
|
|
157
|
+
private sdk;
|
|
158
|
+
constructor(sdk: ChanlSDK);
|
|
159
|
+
/**
|
|
160
|
+
* List all agents with optional filters
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* const { data } = await sdk.agents.list();
|
|
165
|
+
* console.log(data.agents);
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
list(filters?: AgentFilters): Promise<ApiResponse<AgentListResponse>>;
|
|
169
|
+
/**
|
|
170
|
+
* Get a single agent by ID
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```typescript
|
|
174
|
+
* const { data } = await sdk.agents.get('agent_abc');
|
|
175
|
+
* console.log(data.agent.name);
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
get(id: string): Promise<ApiResponse<AgentResponse>>;
|
|
179
|
+
/**
|
|
180
|
+
* Create a new agent
|
|
181
|
+
*
|
|
182
|
+
* Creates an agent with platform configuration. Use platform 'custom' for
|
|
183
|
+
* internally-managed agents, or specify a platform like 'vapi' for external
|
|
184
|
+
* integrations.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* // Create a custom agent
|
|
189
|
+
* const { data } = await sdk.agents.create({
|
|
190
|
+
* platform: 'custom',
|
|
191
|
+
* name: 'Support Agent',
|
|
192
|
+
* type: 'Voice Assistant',
|
|
193
|
+
* useCase: 'support',
|
|
194
|
+
* configuration: {
|
|
195
|
+
* prompt: 'You are a helpful customer support agent.',
|
|
196
|
+
* model: 'gpt-4o'
|
|
197
|
+
* }
|
|
198
|
+
* });
|
|
199
|
+
*
|
|
200
|
+
* // Create a VAPI agent
|
|
201
|
+
* const { data } = await sdk.agents.create({
|
|
202
|
+
* platform: 'vapi',
|
|
203
|
+
* platformAgentId: 'asst_abc123',
|
|
204
|
+
* name: 'VAPI Sales Bot',
|
|
205
|
+
* type: 'Voice Assistant',
|
|
206
|
+
* phoneNumbers: ['+1234567890']
|
|
207
|
+
* });
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
create(data: CreateAgentData): Promise<ApiResponse<AgentResponse>>;
|
|
211
|
+
/**
|
|
212
|
+
* Update an existing agent
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* const { data } = await sdk.agents.update('agent_abc', {
|
|
217
|
+
* status: 'active',
|
|
218
|
+
* configuration: { prompt: 'Updated prompt' },
|
|
219
|
+
* syncToVapi: true // Sync changes back to VAPI
|
|
220
|
+
* });
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
update(id: string, data: UpdateAgentData): Promise<ApiResponse<AgentResponse>>;
|
|
224
|
+
/**
|
|
225
|
+
* Delete an agent
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```typescript
|
|
229
|
+
* // Delete locally only
|
|
230
|
+
* await sdk.agents.delete('agent_abc');
|
|
231
|
+
*
|
|
232
|
+
* // Also delete from integration platform
|
|
233
|
+
* await sdk.agents.delete('agent_abc', {
|
|
234
|
+
* deleteFromIntegration: true
|
|
235
|
+
* });
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
delete(id: string, options?: DeleteAgentOptions): Promise<ApiResponse<DeleteAgentResponse>>;
|
|
239
|
+
/**
|
|
240
|
+
* Sync agents from an external platform
|
|
241
|
+
*
|
|
242
|
+
* Imports agents from VAPI, ElevenLabs, or other platforms into your workspace.
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```typescript
|
|
246
|
+
* // Sync all agents from VAPI
|
|
247
|
+
* const { data } = await sdk.agents.sync('vapi');
|
|
248
|
+
*
|
|
249
|
+
* // Force update with clean sync
|
|
250
|
+
* const { data } = await sdk.agents.sync('vapi', {
|
|
251
|
+
* forceUpdate: true,
|
|
252
|
+
* cleanBeforeSync: true
|
|
253
|
+
* });
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
sync(platform: 'vapi' | 'bland' | 'twilio', options?: Omit<SyncAgentsOptions, 'platform'>): Promise<ApiResponse<SyncAgentsResponse>>;
|
|
257
|
+
/**
|
|
258
|
+
* Sync agents from all configured platforms
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```typescript
|
|
262
|
+
* const { data } = await sdk.agents.syncAll('ws_123', {
|
|
263
|
+
* forceUpdate: true
|
|
264
|
+
* });
|
|
265
|
+
* console.log(`Synced ${data.result.processed} agents`);
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
syncAll(options?: Omit<SyncAgentsOptions, 'platform'>): Promise<ApiResponse<SyncAgentsResponse>>;
|
|
269
|
+
/**
|
|
270
|
+
* Import a specific agent from a third-party platform
|
|
271
|
+
*
|
|
272
|
+
* Imports one agent by its external ID from VAPI, Retell, Bland, or other
|
|
273
|
+
* platforms. The agent is created in Chanl with a deployment reference
|
|
274
|
+
* linking it back to the external platform.
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```typescript
|
|
278
|
+
* // Import a VAPI agent
|
|
279
|
+
* const { data } = await sdk.agents.importFromPlatform('ws_123', {
|
|
280
|
+
* platform: 'vapi',
|
|
281
|
+
* externalAgentId: 'asst_abc123',
|
|
282
|
+
* });
|
|
283
|
+
* console.log(data.agent.name);
|
|
284
|
+
* console.log(data.agent.deployments[0].externalId);
|
|
285
|
+
*
|
|
286
|
+
* // Import with name override
|
|
287
|
+
* const { data } = await sdk.agents.importFromPlatform('ws_123', {
|
|
288
|
+
* platform: 'retell',
|
|
289
|
+
* externalAgentId: 'ret_xyz',
|
|
290
|
+
* name: 'My Custom Name',
|
|
291
|
+
* });
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
importFromPlatform(options: ImportAgentOptions): Promise<ApiResponse<ImportAgentResponse>>;
|
|
295
|
+
/**
|
|
296
|
+
* Publish an agent to a third-party platform
|
|
297
|
+
*
|
|
298
|
+
* Creates or updates the agent on an external platform (VAPI, Retell, Bland).
|
|
299
|
+
* Optionally includes the MCP URL for tool access.
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```typescript
|
|
303
|
+
* // Publish to VAPI (creates new)
|
|
304
|
+
* const { data } = await sdk.agents.publish('agent_abc', {
|
|
305
|
+
* platform: 'vapi',
|
|
306
|
+
* includeMcp: true,
|
|
307
|
+
* });
|
|
308
|
+
* console.log(data.action); // 'created'
|
|
309
|
+
* console.log(data.externalId); // 'ext_vapi_789'
|
|
310
|
+
*
|
|
311
|
+
* // Update existing external agent
|
|
312
|
+
* const { data } = await sdk.agents.publish('agent_abc', {
|
|
313
|
+
* platform: 'vapi',
|
|
314
|
+
* targetExternalId: 'existing_ext_456',
|
|
315
|
+
* });
|
|
316
|
+
* console.log(data.action); // 'updated'
|
|
317
|
+
* ```
|
|
318
|
+
*/
|
|
319
|
+
publish(agentId: string, options: PublishAgentOptions): Promise<ApiResponse<PublishResult>>;
|
|
320
|
+
/**
|
|
321
|
+
* Push MCP URL to a third-party agent
|
|
322
|
+
*
|
|
323
|
+
* Configures a third-party agent to use the Chanl MCP server for tool access.
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```typescript
|
|
327
|
+
* const { data } = await sdk.agents.pushMcp('ws_123', 'agent_abc', {
|
|
328
|
+
* platform: 'vapi',
|
|
329
|
+
* });
|
|
330
|
+
* console.log(data.mcpUrl); // 'https://my-workspace.chanl.dev/mcp'
|
|
331
|
+
* console.log(data.externalId); // 'ext_vapi_789'
|
|
332
|
+
*
|
|
333
|
+
* // Push to specific external agent
|
|
334
|
+
* const { data } = await sdk.agents.pushMcp('ws_123', 'agent_abc', {
|
|
335
|
+
* platform: 'vapi',
|
|
336
|
+
* targetExternalId: 'existing_ext_456',
|
|
337
|
+
* });
|
|
338
|
+
* ```
|
|
339
|
+
*/
|
|
340
|
+
pushMcp(agentId: string, options: PushMcpOptions): Promise<ApiResponse<PushMcpResult>>;
|
|
341
|
+
/**
|
|
342
|
+
* Get agent statistics for the workspace
|
|
343
|
+
*
|
|
344
|
+
* Returns aggregate stats including total agents, average scores,
|
|
345
|
+
* tool failures, and breakdowns by platform and status.
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* ```typescript
|
|
349
|
+
* const { data } = await sdk.agents.getStats('ws_123');
|
|
350
|
+
* console.log('Total agents:', data.stats.totalAgents);
|
|
351
|
+
* console.log('By platform:', data.stats.byPlatform);
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
getStats(): Promise<ApiResponse<AgentStatsResponse>>;
|
|
355
|
+
/**
|
|
356
|
+
* Build full agent context in one call.
|
|
357
|
+
* Returns system prompt, memories, knowledge, tools, and token usage.
|
|
358
|
+
*/
|
|
359
|
+
context(agentId: string, options?: {
|
|
360
|
+
customerId?: string;
|
|
361
|
+
sessionId?: string;
|
|
362
|
+
maxTokens?: number;
|
|
363
|
+
include?: string[];
|
|
364
|
+
}): Promise<ApiResponse<{
|
|
365
|
+
agent: {
|
|
366
|
+
id: string;
|
|
367
|
+
name: string;
|
|
368
|
+
model?: Record<string, unknown>;
|
|
369
|
+
};
|
|
370
|
+
systemPrompt: string;
|
|
371
|
+
memories: Array<Record<string, unknown>>;
|
|
372
|
+
tools: Array<Record<string, unknown>>;
|
|
373
|
+
tokenUsage: {
|
|
374
|
+
total: number;
|
|
375
|
+
};
|
|
376
|
+
}>>;
|
|
377
|
+
}
|
|
378
|
+
//# sourceMappingURL=agents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/modules/agents.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAA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AAM,EAAE,OAAO,CAAC,EAAE;QACvC,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;KACpB,GAAG,OAAO,CAAC,WAAW,CAAC;QACtB,KAAK,EAAE;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;SAAE,CAAC;QACrE,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QACzC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QACtC,UAAU,EAAE;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC;KAC/B,CAAC,CAAC;CAGJ"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AgentsModule - SDK module for agent management
|
|
4
|
+
*
|
|
5
|
+
* Provides operations for AI agents.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.AgentsModule = void 0;
|
|
9
|
+
class AgentsModule {
|
|
10
|
+
constructor(sdk) {
|
|
11
|
+
this.sdk = sdk;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* List all agents with optional filters
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const { data } = await sdk.agents.list();
|
|
19
|
+
* console.log(data.agents);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
async list(filters) {
|
|
23
|
+
const queryParams = new URLSearchParams();
|
|
24
|
+
if (filters?.status)
|
|
25
|
+
queryParams.append('status', filters.status);
|
|
26
|
+
if (filters?.provider)
|
|
27
|
+
queryParams.append('provider', filters.provider);
|
|
28
|
+
if (filters?.page)
|
|
29
|
+
queryParams.append('page', filters.page.toString());
|
|
30
|
+
if (filters?.limit)
|
|
31
|
+
queryParams.append('limit', filters.limit.toString());
|
|
32
|
+
if (filters?.sortBy)
|
|
33
|
+
queryParams.append('sortBy', filters.sortBy);
|
|
34
|
+
if (filters?.sortOrder)
|
|
35
|
+
queryParams.append('sortOrder', filters.sortOrder);
|
|
36
|
+
const url = `/api/v1/agents${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
|
|
37
|
+
return this.sdk.request('GET', url);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get a single agent by ID
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const { data } = await sdk.agents.get('agent_abc');
|
|
45
|
+
* console.log(data.agent.name);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
async get(id) {
|
|
49
|
+
return this.sdk.request('GET', `/api/v1/agents/${id}`);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create a new agent
|
|
53
|
+
*
|
|
54
|
+
* Creates an agent with platform configuration. Use platform 'custom' for
|
|
55
|
+
* internally-managed agents, or specify a platform like 'vapi' for external
|
|
56
|
+
* integrations.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* // Create a custom agent
|
|
61
|
+
* const { data } = await sdk.agents.create({
|
|
62
|
+
* platform: 'custom',
|
|
63
|
+
* name: 'Support Agent',
|
|
64
|
+
* type: 'Voice Assistant',
|
|
65
|
+
* useCase: 'support',
|
|
66
|
+
* configuration: {
|
|
67
|
+
* prompt: 'You are a helpful customer support agent.',
|
|
68
|
+
* model: 'gpt-4o'
|
|
69
|
+
* }
|
|
70
|
+
* });
|
|
71
|
+
*
|
|
72
|
+
* // Create a VAPI agent
|
|
73
|
+
* const { data } = await sdk.agents.create({
|
|
74
|
+
* platform: 'vapi',
|
|
75
|
+
* platformAgentId: 'asst_abc123',
|
|
76
|
+
* name: 'VAPI Sales Bot',
|
|
77
|
+
* type: 'Voice Assistant',
|
|
78
|
+
* phoneNumbers: ['+1234567890']
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
async create(data) {
|
|
83
|
+
return this.sdk.request('POST', '/api/v1/agents', data);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Update an existing agent
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const { data } = await sdk.agents.update('agent_abc', {
|
|
91
|
+
* status: 'active',
|
|
92
|
+
* configuration: { prompt: 'Updated prompt' },
|
|
93
|
+
* syncToVapi: true // Sync changes back to VAPI
|
|
94
|
+
* });
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
async update(id, data) {
|
|
98
|
+
return this.sdk.request('PATCH', `/api/v1/agents/${id}`, data);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Delete an agent
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* // Delete locally only
|
|
106
|
+
* await sdk.agents.delete('agent_abc');
|
|
107
|
+
*
|
|
108
|
+
* // Also delete from integration platform
|
|
109
|
+
* await sdk.agents.delete('agent_abc', {
|
|
110
|
+
* deleteFromIntegration: true
|
|
111
|
+
* });
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
async delete(id, options) {
|
|
115
|
+
const queryParams = new URLSearchParams();
|
|
116
|
+
if (options?.deleteFromIntegration) {
|
|
117
|
+
queryParams.append('deleteFromIntegration', 'true');
|
|
118
|
+
}
|
|
119
|
+
const url = `/api/v1/agents/${id}${queryParams.toString() ? `?${queryParams.toString()}` : ''}`;
|
|
120
|
+
return this.sdk.request('DELETE', url);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Sync agents from an external platform
|
|
124
|
+
*
|
|
125
|
+
* Imports agents from VAPI, ElevenLabs, or other platforms into your workspace.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* // Sync all agents from VAPI
|
|
130
|
+
* const { data } = await sdk.agents.sync('vapi');
|
|
131
|
+
*
|
|
132
|
+
* // Force update with clean sync
|
|
133
|
+
* const { data } = await sdk.agents.sync('vapi', {
|
|
134
|
+
* forceUpdate: true,
|
|
135
|
+
* cleanBeforeSync: true
|
|
136
|
+
* });
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
async sync(platform, options) {
|
|
140
|
+
return this.sdk.request('POST', `/api/v1/agents/sync/${platform}`, options || {});
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Sync agents from all configured platforms
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* const { data } = await sdk.agents.syncAll('ws_123', {
|
|
148
|
+
* forceUpdate: true
|
|
149
|
+
* });
|
|
150
|
+
* console.log(`Synced ${data.result.processed} agents`);
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
async syncAll(options) {
|
|
154
|
+
return this.sdk.request('POST', '/api/v1/agents/sync/all', options || {});
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Import a specific agent from a third-party platform
|
|
158
|
+
*
|
|
159
|
+
* Imports one agent by its external ID from VAPI, Retell, Bland, or other
|
|
160
|
+
* platforms. The agent is created in Chanl with a deployment reference
|
|
161
|
+
* linking it back to the external platform.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* // Import a VAPI agent
|
|
166
|
+
* const { data } = await sdk.agents.importFromPlatform('ws_123', {
|
|
167
|
+
* platform: 'vapi',
|
|
168
|
+
* externalAgentId: 'asst_abc123',
|
|
169
|
+
* });
|
|
170
|
+
* console.log(data.agent.name);
|
|
171
|
+
* console.log(data.agent.deployments[0].externalId);
|
|
172
|
+
*
|
|
173
|
+
* // Import with name override
|
|
174
|
+
* const { data } = await sdk.agents.importFromPlatform('ws_123', {
|
|
175
|
+
* platform: 'retell',
|
|
176
|
+
* externalAgentId: 'ret_xyz',
|
|
177
|
+
* name: 'My Custom Name',
|
|
178
|
+
* });
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
async importFromPlatform(options) {
|
|
182
|
+
return this.sdk.request('POST', '/api/v1/agents/import', options);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Publish an agent to a third-party platform
|
|
186
|
+
*
|
|
187
|
+
* Creates or updates the agent on an external platform (VAPI, Retell, Bland).
|
|
188
|
+
* Optionally includes the MCP URL for tool access.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```typescript
|
|
192
|
+
* // Publish to VAPI (creates new)
|
|
193
|
+
* const { data } = await sdk.agents.publish('agent_abc', {
|
|
194
|
+
* platform: 'vapi',
|
|
195
|
+
* includeMcp: true,
|
|
196
|
+
* });
|
|
197
|
+
* console.log(data.action); // 'created'
|
|
198
|
+
* console.log(data.externalId); // 'ext_vapi_789'
|
|
199
|
+
*
|
|
200
|
+
* // Update existing external agent
|
|
201
|
+
* const { data } = await sdk.agents.publish('agent_abc', {
|
|
202
|
+
* platform: 'vapi',
|
|
203
|
+
* targetExternalId: 'existing_ext_456',
|
|
204
|
+
* });
|
|
205
|
+
* console.log(data.action); // 'updated'
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
async publish(agentId, options) {
|
|
209
|
+
return this.sdk.request('POST', `/api/v1/agents/${agentId}/deploy`, options);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Push MCP URL to a third-party agent
|
|
213
|
+
*
|
|
214
|
+
* Configures a third-party agent to use the Chanl MCP server for tool access.
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```typescript
|
|
218
|
+
* const { data } = await sdk.agents.pushMcp('ws_123', 'agent_abc', {
|
|
219
|
+
* platform: 'vapi',
|
|
220
|
+
* });
|
|
221
|
+
* console.log(data.mcpUrl); // 'https://my-workspace.chanl.dev/mcp'
|
|
222
|
+
* console.log(data.externalId); // 'ext_vapi_789'
|
|
223
|
+
*
|
|
224
|
+
* // Push to specific external agent
|
|
225
|
+
* const { data } = await sdk.agents.pushMcp('ws_123', 'agent_abc', {
|
|
226
|
+
* platform: 'vapi',
|
|
227
|
+
* targetExternalId: 'existing_ext_456',
|
|
228
|
+
* });
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
async pushMcp(agentId, options) {
|
|
232
|
+
return this.sdk.request('POST', `/api/v1/agents/${agentId}/push-mcp`, options);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Get agent statistics for the workspace
|
|
236
|
+
*
|
|
237
|
+
* Returns aggregate stats including total agents, average scores,
|
|
238
|
+
* tool failures, and breakdowns by platform and status.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```typescript
|
|
242
|
+
* const { data } = await sdk.agents.getStats('ws_123');
|
|
243
|
+
* console.log('Total agents:', data.stats.totalAgents);
|
|
244
|
+
* console.log('By platform:', data.stats.byPlatform);
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
async getStats() {
|
|
248
|
+
return this.sdk.request('GET', '/api/v1/agents/stats');
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Build full agent context in one call.
|
|
252
|
+
* Returns system prompt, memories, knowledge, tools, and token usage.
|
|
253
|
+
*/
|
|
254
|
+
async context(agentId, options) {
|
|
255
|
+
return this.sdk.request('POST', `/api/v1/agents/${agentId}/context`, options || {});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
exports.AgentsModule = AgentsModule;
|
|
259
|
+
//# sourceMappingURL=agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.js","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