@kognitivedev/cloud-voice 0.2.29
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/.turbo/turbo-build.log +2 -0
- package/.turbo/turbo-test.log +13 -0
- package/CHANGELOG.md +10 -0
- package/README.md +226 -0
- package/dist/browser.d.ts +7 -0
- package/dist/browser.js +301 -0
- package/dist/client.d.ts +219 -0
- package/dist/client.js +535 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +15 -0
- package/dist/server.d.ts +58 -0
- package/dist/server.js +92 -0
- package/dist/server.test.d.ts +1 -0
- package/dist/server.test.js +78 -0
- package/dist/sse.d.ts +7 -0
- package/dist/sse.js +75 -0
- package/dist/types.d.ts +865 -0
- package/dist/types.js +2 -0
- package/package.json +52 -0
- package/src/__tests__/browser.test.ts +196 -0
- package/src/__tests__/client.test.ts +482 -0
- package/src/__tests__/server.test.ts +84 -0
- package/src/browser.ts +342 -0
- package/src/client.ts +610 -0
- package/src/index.ts +100 -0
- package/src/server.ts +140 -0
- package/src/sse.ts +57 -0
- package/src/types.ts +927 -0
- package/tsconfig.json +14 -0
- package/vitest.config.ts +8 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { HttpTransport } from "@kognitivedev/client-core";
|
|
2
|
+
import type { CloudVoiceAgentRecord, CloudVoiceClientConfig, CloudVoiceEmbedConfig, CloudVoiceSessionBootstrap, CloudVoiceSessionEventRecord, CloudVoiceSessionRecord, CloudVoiceToolCatalog, CloudVoiceCustomVoiceRecord, CloudVoiceCallWaitOptions, CloudVoiceCallWaitResult, CloudVoiceCallLegRecord, CloudVoiceLiveCallRecord, CloudVoicePhoneBridgeHealth, CloudVoicePhoneConnectionRecord, CloudVoicePhoneNumberRecord, CloudVoiceSipDiagnostics, CloudVoiceRecordingAsset, CloudVoiceHandoffRecord, CloudVoiceListenTokenResult, CreateCloudVoicePhoneConnectionInput, CreateCloudVoicePhoneNumberInput, CreateCloudVoiceOutboundCallInput, CreateCloudVoiceAgentInput, CreateCloudVoiceSessionInput, ImportCloudVoiceCustomVoiceInput, CloneCloudVoiceCustomVoiceInput, CreateCloudVoiceHandoffInput, AcceptCloudVoiceHandoffInput, CancelCloudVoiceHandoffInput, UpdateCloudVoicePhoneNumberInput, UpdateCloudVoiceAgentInput, UpdateCloudVoiceCustomVoiceInput, SyncCloudVoiceToolCatalogInput, UseCloudVoiceAgentInput, UseCloudVoiceAgentResult } from "./types";
|
|
3
|
+
export declare class KognitiveCloudVoiceClient {
|
|
4
|
+
private readonly transport;
|
|
5
|
+
readonly agents: {
|
|
6
|
+
list: () => Promise<CloudVoiceAgentRecord[]>;
|
|
7
|
+
get: (slug: string) => Promise<CloudVoiceAgentRecord>;
|
|
8
|
+
use: (slug: string, input?: UseCloudVoiceAgentInput) => Promise<UseCloudVoiceAgentResult>;
|
|
9
|
+
management: {
|
|
10
|
+
list: () => Promise<CloudVoiceAgentRecord[]>;
|
|
11
|
+
create: (input: CreateCloudVoiceAgentInput) => Promise<CloudVoiceAgentRecord>;
|
|
12
|
+
createOrUse: (slug: string, input?: UseCloudVoiceAgentInput) => Promise<UseCloudVoiceAgentResult>;
|
|
13
|
+
get: (slug: string) => Promise<CloudVoiceAgentRecord>;
|
|
14
|
+
update: (slug: string, input: UpdateCloudVoiceAgentInput) => Promise<CloudVoiceAgentRecord>;
|
|
15
|
+
delete: (slug: string) => Promise<{
|
|
16
|
+
success: boolean;
|
|
17
|
+
}>;
|
|
18
|
+
publish: (slug: string) => Promise<CloudVoiceAgentRecord>;
|
|
19
|
+
unpublish: (slug: string) => Promise<CloudVoiceAgentRecord>;
|
|
20
|
+
use: (slug: string, input?: UseCloudVoiceAgentInput) => Promise<UseCloudVoiceAgentResult>;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
readonly sessions: {
|
|
24
|
+
list: (agentId?: string) => Promise<CloudVoiceSessionRecord[]>;
|
|
25
|
+
create: (agentSlug: string, input?: Omit<CreateCloudVoiceSessionInput, "agentSlug" | "agent">) => Promise<CloudVoiceSessionBootstrap>;
|
|
26
|
+
get: (sessionId: string) => Promise<CloudVoiceSessionRecord>;
|
|
27
|
+
cancel: (sessionId: string, reason?: string) => Promise<CloudVoiceSessionRecord>;
|
|
28
|
+
events: (sessionId: string) => Promise<CloudVoiceSessionEventRecord[]>;
|
|
29
|
+
appendEvent: (sessionId: string, event: Record<string, unknown>) => Promise<CloudVoiceSessionEventRecord>;
|
|
30
|
+
stream: (sessionId: string, init?: RequestInit) => Promise<Response>;
|
|
31
|
+
subscribe: (sessionId: string, init?: RequestInit) => Promise<AsyncGenerator<CloudVoiceSessionEventRecord | {
|
|
32
|
+
type: "unknown";
|
|
33
|
+
frame: unknown;
|
|
34
|
+
}, any, any>>;
|
|
35
|
+
executeTool: (sessionId: string, toolId: string, input: unknown) => Promise<{
|
|
36
|
+
result: unknown;
|
|
37
|
+
}>;
|
|
38
|
+
recordings: (sessionId: string) => Promise<{
|
|
39
|
+
recording: unknown | null;
|
|
40
|
+
assets: CloudVoiceRecordingAsset[];
|
|
41
|
+
}>;
|
|
42
|
+
};
|
|
43
|
+
readonly calls: {
|
|
44
|
+
list: () => Promise<CloudVoiceCallLegRecord[]>;
|
|
45
|
+
live: (input?: {
|
|
46
|
+
status?: "live" | "all";
|
|
47
|
+
limit?: number;
|
|
48
|
+
}) => Promise<CloudVoiceLiveCallRecord[]>;
|
|
49
|
+
get: (sessionId: string) => Promise<CloudVoiceLiveCallRecord>;
|
|
50
|
+
create: (input: CreateCloudVoiceOutboundCallInput) => Promise<{
|
|
51
|
+
session: CloudVoiceSessionBootstrap;
|
|
52
|
+
callLeg: CloudVoiceCallLegRecord;
|
|
53
|
+
providerCall: unknown;
|
|
54
|
+
}>;
|
|
55
|
+
wait: (sessionId: string, options?: CloudVoiceCallWaitOptions) => Promise<CloudVoiceCallWaitResult>;
|
|
56
|
+
hangup: (sessionId: string, reason?: string) => Promise<{
|
|
57
|
+
call: CloudVoiceLiveCallRecord;
|
|
58
|
+
result: unknown;
|
|
59
|
+
}>;
|
|
60
|
+
listenToken: (sessionId: string, input?: {
|
|
61
|
+
managerId?: string;
|
|
62
|
+
takeover?: boolean;
|
|
63
|
+
}) => Promise<CloudVoiceListenTokenResult>;
|
|
64
|
+
handoff: {
|
|
65
|
+
create: (sessionId: string, input?: CreateCloudVoiceHandoffInput) => Promise<{
|
|
66
|
+
handoff: CloudVoiceHandoffRecord;
|
|
67
|
+
}>;
|
|
68
|
+
accept: (sessionId: string, handoffId: string, input?: AcceptCloudVoiceHandoffInput) => Promise<{
|
|
69
|
+
handoff: CloudVoiceHandoffRecord;
|
|
70
|
+
}>;
|
|
71
|
+
cancel: (sessionId: string, handoffId: string, input?: CancelCloudVoiceHandoffInput) => Promise<{
|
|
72
|
+
handoff: CloudVoiceHandoffRecord;
|
|
73
|
+
}>;
|
|
74
|
+
};
|
|
75
|
+
events: (sessionId: string) => Promise<CloudVoiceSessionEventRecord[]>;
|
|
76
|
+
stream: (sessionId: string, init?: RequestInit) => Promise<Response>;
|
|
77
|
+
subscribe: (sessionId: string, init?: RequestInit) => Promise<AsyncGenerator<CloudVoiceSessionEventRecord | {
|
|
78
|
+
type: "unknown";
|
|
79
|
+
frame: unknown;
|
|
80
|
+
}, any, any>>;
|
|
81
|
+
executeTool: (sessionId: string, toolId: string, input: unknown) => Promise<{
|
|
82
|
+
result: unknown;
|
|
83
|
+
}>;
|
|
84
|
+
};
|
|
85
|
+
readonly phone: {
|
|
86
|
+
connections: {
|
|
87
|
+
list: () => Promise<CloudVoicePhoneConnectionRecord[]>;
|
|
88
|
+
create: (input: CreateCloudVoicePhoneConnectionInput) => Promise<CloudVoicePhoneConnectionRecord>;
|
|
89
|
+
};
|
|
90
|
+
numbers: {
|
|
91
|
+
list: () => Promise<CloudVoicePhoneNumberRecord[]>;
|
|
92
|
+
create: (input: CreateCloudVoicePhoneNumberInput) => Promise<CloudVoicePhoneNumberRecord>;
|
|
93
|
+
update: (input: UpdateCloudVoicePhoneNumberInput) => Promise<CloudVoicePhoneNumberRecord | null>;
|
|
94
|
+
};
|
|
95
|
+
bridge: {
|
|
96
|
+
health: () => Promise<CloudVoicePhoneBridgeHealth>;
|
|
97
|
+
};
|
|
98
|
+
sip: {
|
|
99
|
+
diagnostics: () => Promise<CloudVoiceSipDiagnostics>;
|
|
100
|
+
reload: () => Promise<Record<string, unknown>>;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
readonly recordings: {
|
|
104
|
+
getForSession: (sessionId: string) => Promise<{
|
|
105
|
+
recording: unknown | null;
|
|
106
|
+
assets: CloudVoiceRecordingAsset[];
|
|
107
|
+
}>;
|
|
108
|
+
};
|
|
109
|
+
readonly tools: {
|
|
110
|
+
catalog: {
|
|
111
|
+
list: () => Promise<CloudVoiceToolCatalog>;
|
|
112
|
+
sync: (input: SyncCloudVoiceToolCatalogInput) => Promise<CloudVoiceToolCatalog>;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
readonly customVoices: {
|
|
116
|
+
list: () => Promise<CloudVoiceCustomVoiceRecord[]>;
|
|
117
|
+
import: (input: ImportCloudVoiceCustomVoiceInput) => Promise<CloudVoiceCustomVoiceRecord>;
|
|
118
|
+
clone: (input: CloneCloudVoiceCustomVoiceInput) => Promise<CloudVoiceCustomVoiceRecord>;
|
|
119
|
+
update: (voiceId: string, input: UpdateCloudVoiceCustomVoiceInput) => Promise<CloudVoiceCustomVoiceRecord>;
|
|
120
|
+
delete: (voiceId: string) => Promise<{
|
|
121
|
+
success: boolean;
|
|
122
|
+
}>;
|
|
123
|
+
};
|
|
124
|
+
constructor(config: CloudVoiceClientConfig | HttpTransport);
|
|
125
|
+
listAgents(): Promise<CloudVoiceAgentRecord[]>;
|
|
126
|
+
getAgent(slug: string): Promise<CloudVoiceAgentRecord>;
|
|
127
|
+
createAgent(input: CreateCloudVoiceAgentInput): Promise<CloudVoiceAgentRecord>;
|
|
128
|
+
listCustomVoices(): Promise<CloudVoiceCustomVoiceRecord[]>;
|
|
129
|
+
importCustomVoice(input: ImportCloudVoiceCustomVoiceInput): Promise<CloudVoiceCustomVoiceRecord>;
|
|
130
|
+
cloneCustomVoice(input: CloneCloudVoiceCustomVoiceInput): Promise<CloudVoiceCustomVoiceRecord>;
|
|
131
|
+
updateCustomVoice(voiceId: string, input: UpdateCloudVoiceCustomVoiceInput): Promise<CloudVoiceCustomVoiceRecord>;
|
|
132
|
+
deleteCustomVoice(voiceId: string): Promise<{
|
|
133
|
+
success: boolean;
|
|
134
|
+
}>;
|
|
135
|
+
updateAgent(slug: string, input: UpdateCloudVoiceAgentInput): Promise<CloudVoiceAgentRecord>;
|
|
136
|
+
useAgent(slug: string, input?: UseCloudVoiceAgentInput): Promise<UseCloudVoiceAgentResult>;
|
|
137
|
+
deleteAgent(slug: string): Promise<{
|
|
138
|
+
success: boolean;
|
|
139
|
+
}>;
|
|
140
|
+
publishAgent(slug: string): Promise<CloudVoiceAgentRecord>;
|
|
141
|
+
unpublishAgent(slug: string): Promise<CloudVoiceAgentRecord>;
|
|
142
|
+
listSessions(agentId?: string): Promise<CloudVoiceSessionRecord[]>;
|
|
143
|
+
createSession(input: CreateCloudVoiceSessionInput): Promise<CloudVoiceSessionBootstrap>;
|
|
144
|
+
getSession(sessionId: string): Promise<CloudVoiceSessionRecord>;
|
|
145
|
+
cancelSession(sessionId: string, reason?: string): Promise<CloudVoiceSessionRecord>;
|
|
146
|
+
getSessionEvents(sessionId: string): Promise<CloudVoiceSessionEventRecord[]>;
|
|
147
|
+
appendSessionEvent(sessionId: string, event: Record<string, unknown>): Promise<CloudVoiceSessionEventRecord>;
|
|
148
|
+
streamSessionEvents(sessionId: string, init?: RequestInit): Promise<Response>;
|
|
149
|
+
subscribeToSession(sessionId: string, init?: RequestInit): Promise<AsyncGenerator<CloudVoiceSessionEventRecord | {
|
|
150
|
+
type: "unknown";
|
|
151
|
+
frame: unknown;
|
|
152
|
+
}>>;
|
|
153
|
+
executeTool(sessionId: string, toolId: string, input: unknown): Promise<{
|
|
154
|
+
result: unknown;
|
|
155
|
+
}>;
|
|
156
|
+
getSessionRecordings(sessionId: string): Promise<{
|
|
157
|
+
recording: unknown | null;
|
|
158
|
+
assets: CloudVoiceRecordingAsset[];
|
|
159
|
+
}>;
|
|
160
|
+
listPhoneConnections(): Promise<CloudVoicePhoneConnectionRecord[]>;
|
|
161
|
+
createPhoneConnection(input: CreateCloudVoicePhoneConnectionInput): Promise<CloudVoicePhoneConnectionRecord>;
|
|
162
|
+
listPhoneNumbers(): Promise<CloudVoicePhoneNumberRecord[]>;
|
|
163
|
+
createPhoneNumber(input: CreateCloudVoicePhoneNumberInput): Promise<CloudVoicePhoneNumberRecord>;
|
|
164
|
+
updatePhoneNumber(input: UpdateCloudVoicePhoneNumberInput): Promise<CloudVoicePhoneNumberRecord | null>;
|
|
165
|
+
getPhoneBridgeHealth(): Promise<CloudVoicePhoneBridgeHealth>;
|
|
166
|
+
getSipDiagnostics(): Promise<CloudVoiceSipDiagnostics>;
|
|
167
|
+
reloadSipBridge(): Promise<Record<string, unknown>>;
|
|
168
|
+
listToolCatalog(): Promise<CloudVoiceToolCatalog>;
|
|
169
|
+
syncToolCatalog(input: SyncCloudVoiceToolCatalogInput): Promise<CloudVoiceToolCatalog>;
|
|
170
|
+
listCalls(): Promise<CloudVoiceCallLegRecord[]>;
|
|
171
|
+
listLiveCalls(input?: {
|
|
172
|
+
status?: "live" | "all";
|
|
173
|
+
limit?: number;
|
|
174
|
+
}): Promise<CloudVoiceLiveCallRecord[]>;
|
|
175
|
+
getCall(sessionId: string): Promise<CloudVoiceLiveCallRecord>;
|
|
176
|
+
createCall(input: CreateCloudVoiceOutboundCallInput): Promise<{
|
|
177
|
+
session: CloudVoiceSessionBootstrap;
|
|
178
|
+
callLeg: CloudVoiceCallLegRecord;
|
|
179
|
+
providerCall: unknown;
|
|
180
|
+
}>;
|
|
181
|
+
finalizeCall(sessionId: string): Promise<CloudVoiceCallWaitResult>;
|
|
182
|
+
waitForCall(sessionId: string, options?: CloudVoiceCallWaitOptions): Promise<CloudVoiceCallWaitResult>;
|
|
183
|
+
executeCallTool(sessionId: string, toolId: string, input: unknown): Promise<{
|
|
184
|
+
result: unknown;
|
|
185
|
+
}>;
|
|
186
|
+
hangupCall(sessionId: string, reason?: string): Promise<{
|
|
187
|
+
call: CloudVoiceLiveCallRecord;
|
|
188
|
+
result: unknown;
|
|
189
|
+
}>;
|
|
190
|
+
createCallListenToken(sessionId: string, input?: {
|
|
191
|
+
managerId?: string;
|
|
192
|
+
takeover?: boolean;
|
|
193
|
+
}): Promise<CloudVoiceListenTokenResult>;
|
|
194
|
+
createCallHandoff(sessionId: string, input?: CreateCloudVoiceHandoffInput): Promise<{
|
|
195
|
+
handoff: CloudVoiceHandoffRecord;
|
|
196
|
+
}>;
|
|
197
|
+
acceptCallHandoff(sessionId: string, handoffId: string, input?: AcceptCloudVoiceHandoffInput): Promise<{
|
|
198
|
+
handoff: CloudVoiceHandoffRecord;
|
|
199
|
+
}>;
|
|
200
|
+
cancelCallHandoff(sessionId: string, handoffId: string, input?: CancelCloudVoiceHandoffInput): Promise<{
|
|
201
|
+
handoff: CloudVoiceHandoffRecord;
|
|
202
|
+
}>;
|
|
203
|
+
}
|
|
204
|
+
export declare class KognitiveCloudVoiceEmbedClient {
|
|
205
|
+
private readonly baseUrl;
|
|
206
|
+
private readonly publicKey;
|
|
207
|
+
private readonly fetchImpl;
|
|
208
|
+
constructor(config: {
|
|
209
|
+
baseUrl: string;
|
|
210
|
+
publicKey: string;
|
|
211
|
+
fetch?: typeof fetch;
|
|
212
|
+
});
|
|
213
|
+
private headers;
|
|
214
|
+
config(agent: string): Promise<CloudVoiceEmbedConfig>;
|
|
215
|
+
createSession(input: CreateCloudVoiceSessionInput): Promise<CloudVoiceSessionBootstrap>;
|
|
216
|
+
executeTool(sessionId: string, toolId: string, input: unknown): Promise<{
|
|
217
|
+
result: unknown;
|
|
218
|
+
}>;
|
|
219
|
+
}
|