@d-id/client-sdk 1.0.12 → 1.0.13
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/dist/apps/sdk/lib/index.d.ts +1 -2
- package/dist/index.js +129 -175
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
- package/dist/apps/sdk/lib/connectToSocket.d.ts +0 -15
package/dist/index.js
CHANGED
|
@@ -1,292 +1,246 @@
|
|
|
1
|
-
function
|
|
1
|
+
function k(r) {
|
|
2
2
|
return r.type === "bearer" ? "Bearer " + r.token : r.type === "basic" ? "Basic " + btoa(`${r.username}:${r.password}`) : "Client-Key " + r.clientKey;
|
|
3
3
|
}
|
|
4
|
-
function
|
|
5
|
-
const
|
|
4
|
+
function g(r, o = "https://api.d-id.com") {
|
|
5
|
+
const n = async (e, t) => {
|
|
6
6
|
const s = await fetch(o + (e != null && e.startsWith("/") ? e : `/${e}`), {
|
|
7
|
-
...
|
|
7
|
+
...t,
|
|
8
8
|
headers: {
|
|
9
|
-
...
|
|
10
|
-
Authorization:
|
|
9
|
+
...t == null ? void 0 : t.headers,
|
|
10
|
+
Authorization: k(r),
|
|
11
11
|
"Content-Type": "application/json"
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
if (!s.ok) {
|
|
15
|
-
let
|
|
15
|
+
let u = await s.text().catch(() => "Failed to fetch");
|
|
16
16
|
try {
|
|
17
|
-
const
|
|
18
|
-
|
|
17
|
+
const c = JSON.parse(u);
|
|
18
|
+
c.description ? u = c.description : c.message && (u = c.message);
|
|
19
19
|
} catch {
|
|
20
20
|
}
|
|
21
|
-
throw new Error(
|
|
21
|
+
throw new Error(u);
|
|
22
22
|
}
|
|
23
23
|
return s.json();
|
|
24
24
|
};
|
|
25
25
|
return {
|
|
26
|
-
get(e,
|
|
27
|
-
return
|
|
28
|
-
...
|
|
26
|
+
get(e, t) {
|
|
27
|
+
return n(e, {
|
|
28
|
+
...t,
|
|
29
29
|
method: "GET"
|
|
30
30
|
});
|
|
31
31
|
},
|
|
32
|
-
post(e,
|
|
33
|
-
return
|
|
32
|
+
post(e, t, s) {
|
|
33
|
+
return n(e, {
|
|
34
34
|
...s,
|
|
35
|
-
body: JSON.stringify(
|
|
35
|
+
body: JSON.stringify(t),
|
|
36
36
|
method: "POST"
|
|
37
37
|
});
|
|
38
38
|
},
|
|
39
|
-
delete(e,
|
|
40
|
-
return
|
|
39
|
+
delete(e, t, s) {
|
|
40
|
+
return n(e, {
|
|
41
41
|
...s,
|
|
42
|
-
body: JSON.stringify(
|
|
42
|
+
body: JSON.stringify(t),
|
|
43
43
|
method: "DELETE"
|
|
44
44
|
});
|
|
45
45
|
},
|
|
46
|
-
patch(e,
|
|
47
|
-
return
|
|
46
|
+
patch(e, t, s) {
|
|
47
|
+
return n(e, {
|
|
48
48
|
...s,
|
|
49
|
-
body: JSON.stringify(
|
|
49
|
+
body: JSON.stringify(t),
|
|
50
50
|
method: "PATCH"
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
function
|
|
56
|
-
const
|
|
57
|
-
return {
|
|
58
|
-
create(e) {
|
|
59
|
-
return t.post("/", e);
|
|
60
|
-
},
|
|
61
|
-
getAgents(e) {
|
|
62
|
-
return t.get(`/${e ? `?tag=${e}` : ""}`);
|
|
63
|
-
},
|
|
64
|
-
getById(e) {
|
|
65
|
-
return t.get(`/${e}`);
|
|
66
|
-
},
|
|
67
|
-
delete(e) {
|
|
68
|
-
return t.delete(`/${e}`);
|
|
69
|
-
},
|
|
70
|
-
update(e, n) {
|
|
71
|
-
return t.patch(`/${e}`, n);
|
|
72
|
-
},
|
|
73
|
-
newChat(e) {
|
|
74
|
-
return t.post(`/${e}/chat`);
|
|
75
|
-
},
|
|
76
|
-
chat(e, n, s) {
|
|
77
|
-
return t.post(`/${e}/chat/${n}`, s);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function R(r, o = "https://api.d-id.com") {
|
|
82
|
-
const t = $(r, `${o}/knowledge`);
|
|
55
|
+
function K(r, o = "https://api.d-id.com") {
|
|
56
|
+
const n = g(r, `${o}/knowledge`);
|
|
83
57
|
return {
|
|
84
58
|
createKnowledge(e) {
|
|
85
|
-
return
|
|
59
|
+
return n.post("/", e);
|
|
86
60
|
},
|
|
87
61
|
getKnowledgeBase() {
|
|
88
|
-
return
|
|
62
|
+
return n.get("/");
|
|
89
63
|
},
|
|
90
64
|
getKnowledge(e) {
|
|
91
|
-
return
|
|
65
|
+
return n.get(`/${e}`);
|
|
92
66
|
},
|
|
93
67
|
deleteKnowledge(e) {
|
|
94
|
-
return
|
|
68
|
+
return n.delete(`/${e}`);
|
|
95
69
|
},
|
|
96
|
-
createDocument(e,
|
|
97
|
-
return
|
|
70
|
+
createDocument(e, t) {
|
|
71
|
+
return n.post(`/${e}/documents`, t);
|
|
98
72
|
},
|
|
99
|
-
deleteDocument(e,
|
|
100
|
-
return
|
|
73
|
+
deleteDocument(e, t) {
|
|
74
|
+
return n.delete(`/${e}/documents/${t}`);
|
|
101
75
|
},
|
|
102
76
|
getDocuments(e) {
|
|
103
|
-
return
|
|
77
|
+
return n.get(`/${e}/documents`);
|
|
104
78
|
},
|
|
105
|
-
getDocument(e,
|
|
106
|
-
return
|
|
79
|
+
getDocument(e, t) {
|
|
80
|
+
return n.get(`/${e}/documents/${t}`);
|
|
107
81
|
},
|
|
108
|
-
getRecords(e,
|
|
109
|
-
return
|
|
82
|
+
getRecords(e, t) {
|
|
83
|
+
return n.get(`/${e}/documents/${t}/records`);
|
|
110
84
|
},
|
|
111
|
-
query(e,
|
|
112
|
-
return
|
|
113
|
-
query:
|
|
85
|
+
query(e, t) {
|
|
86
|
+
return n.post(`/${e}/query`, {
|
|
87
|
+
query: t
|
|
114
88
|
});
|
|
115
89
|
}
|
|
116
90
|
};
|
|
117
91
|
}
|
|
118
|
-
function
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
console.log(c), g == null || g(c), t(c);
|
|
142
|
-
}, u.onopen = (c) => {
|
|
143
|
-
d == null || d(c), o(u);
|
|
144
|
-
};
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
async function M(r) {
|
|
148
|
-
const {
|
|
149
|
-
retries: o = 1
|
|
150
|
-
} = r;
|
|
151
|
-
let t = null;
|
|
152
|
-
for (let e = 0; (t == null ? void 0 : t.readyState) !== WebSocket.OPEN; e++)
|
|
153
|
-
try {
|
|
154
|
-
t = await A(r);
|
|
155
|
-
} catch (n) {
|
|
156
|
-
if (e === o)
|
|
157
|
-
throw n;
|
|
158
|
-
await T(e * 500);
|
|
92
|
+
function O(r, o = "https://api.d-id.com") {
|
|
93
|
+
const n = g(r, `${o}/agents`);
|
|
94
|
+
return {
|
|
95
|
+
create(e) {
|
|
96
|
+
return n.post("/", e);
|
|
97
|
+
},
|
|
98
|
+
getAgents(e) {
|
|
99
|
+
return n.get(`/${e ? `?tag=${e}` : ""}`);
|
|
100
|
+
},
|
|
101
|
+
getById(e) {
|
|
102
|
+
return n.get(`/${e}`);
|
|
103
|
+
},
|
|
104
|
+
delete(e) {
|
|
105
|
+
return n.delete(`/${e}`);
|
|
106
|
+
},
|
|
107
|
+
update(e, t) {
|
|
108
|
+
return n.patch(`/${e}`, t);
|
|
109
|
+
},
|
|
110
|
+
newChat(e) {
|
|
111
|
+
return n.post(`/${e}/chat`);
|
|
112
|
+
},
|
|
113
|
+
chat(e, t, s) {
|
|
114
|
+
return n.post(`/${e}/chat/${t}`, s);
|
|
159
115
|
}
|
|
160
|
-
|
|
116
|
+
};
|
|
161
117
|
}
|
|
162
|
-
function
|
|
163
|
-
const
|
|
118
|
+
function A(r, o) {
|
|
119
|
+
const n = g(r, o);
|
|
164
120
|
return {
|
|
165
121
|
createStream(e) {
|
|
166
|
-
return
|
|
122
|
+
return n.post("/clips/streams", {
|
|
167
123
|
driver_id: e.driver_id,
|
|
168
124
|
presenter_id: e.presenter_id,
|
|
169
125
|
compatibility_mode: e.compatibility_mode
|
|
170
126
|
});
|
|
171
127
|
},
|
|
172
|
-
startConnection(e,
|
|
173
|
-
return
|
|
128
|
+
startConnection(e, t, s) {
|
|
129
|
+
return n.post(`/clips/streams/${e}/sdp`, {
|
|
174
130
|
session_id: s,
|
|
175
|
-
answer:
|
|
131
|
+
answer: t
|
|
176
132
|
});
|
|
177
133
|
},
|
|
178
|
-
addIceCandidate(e,
|
|
179
|
-
return
|
|
134
|
+
addIceCandidate(e, t, s) {
|
|
135
|
+
return n.post(`/clips/streams/${e}/ice`, {
|
|
180
136
|
session_id: s,
|
|
181
|
-
...
|
|
137
|
+
...t
|
|
182
138
|
});
|
|
183
139
|
},
|
|
184
|
-
sendStreamRequest(e,
|
|
185
|
-
return
|
|
186
|
-
session_id:
|
|
140
|
+
sendStreamRequest(e, t, s) {
|
|
141
|
+
return n.post(`/clips/streams/${e}`, {
|
|
142
|
+
session_id: t,
|
|
187
143
|
...s
|
|
188
144
|
});
|
|
189
145
|
},
|
|
190
|
-
close(e,
|
|
191
|
-
return
|
|
192
|
-
session_id:
|
|
146
|
+
close(e, t) {
|
|
147
|
+
return n.delete(`/clips/streams/${e}`, {
|
|
148
|
+
session_id: t
|
|
193
149
|
});
|
|
194
150
|
}
|
|
195
151
|
};
|
|
196
152
|
}
|
|
197
|
-
function
|
|
198
|
-
const
|
|
153
|
+
function T(r, o) {
|
|
154
|
+
const n = g(r, o);
|
|
199
155
|
return {
|
|
200
156
|
createStream(e) {
|
|
201
|
-
return
|
|
157
|
+
return n.post("/talks/streams", {
|
|
202
158
|
source_url: e.source_url,
|
|
203
159
|
driver_url: e.driver_url,
|
|
204
160
|
face: e.face,
|
|
205
161
|
config: e.config
|
|
206
162
|
});
|
|
207
163
|
},
|
|
208
|
-
startConnection(e,
|
|
209
|
-
return
|
|
164
|
+
startConnection(e, t, s) {
|
|
165
|
+
return n.post(`/talks/streams/${e}/sdp`, {
|
|
210
166
|
session_id: s,
|
|
211
|
-
answer:
|
|
167
|
+
answer: t
|
|
212
168
|
});
|
|
213
169
|
},
|
|
214
|
-
addIceCandidate(e,
|
|
215
|
-
return
|
|
170
|
+
addIceCandidate(e, t, s) {
|
|
171
|
+
return n.post(`/talks/streams/${e}/ice`, {
|
|
216
172
|
session_id: s,
|
|
217
|
-
...
|
|
173
|
+
...t
|
|
218
174
|
});
|
|
219
175
|
},
|
|
220
|
-
sendStreamRequest(e,
|
|
221
|
-
return
|
|
222
|
-
session_id:
|
|
176
|
+
sendStreamRequest(e, t, s) {
|
|
177
|
+
return n.post(`/talks/streams/${e}`, {
|
|
178
|
+
session_id: t,
|
|
223
179
|
...s
|
|
224
180
|
});
|
|
225
181
|
},
|
|
226
|
-
close(e,
|
|
227
|
-
return
|
|
228
|
-
session_id:
|
|
182
|
+
close(e, t) {
|
|
183
|
+
return n.delete(`/talks/streams/${e}`, {
|
|
184
|
+
session_id: t
|
|
229
185
|
});
|
|
230
186
|
}
|
|
231
187
|
};
|
|
232
188
|
}
|
|
233
|
-
var
|
|
234
|
-
let
|
|
235
|
-
const
|
|
236
|
-
async function
|
|
189
|
+
var m = /* @__PURE__ */ ((r) => (r.Idle = "IDLE", r.Streaming = "STREAMING", r))(m || {}), $ = /* @__PURE__ */ ((r) => (r.Clip = "clip", r.Talk = "talk", r))($ || {});
|
|
190
|
+
let f = !1;
|
|
191
|
+
const d = (r, o) => f && console.log(r, o), D = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
|
|
192
|
+
async function E(r, {
|
|
237
193
|
debug: o = !1,
|
|
238
|
-
callbacks:
|
|
194
|
+
callbacks: n,
|
|
239
195
|
auth: e,
|
|
240
|
-
baseURL:
|
|
196
|
+
baseURL: t = "https://api.d-id.com"
|
|
241
197
|
}) {
|
|
242
|
-
|
|
198
|
+
f = o;
|
|
243
199
|
let s = null;
|
|
244
200
|
const {
|
|
245
|
-
startConnection:
|
|
246
|
-
sendStreamRequest:
|
|
247
|
-
close:
|
|
248
|
-
createStream:
|
|
249
|
-
addIceCandidate:
|
|
250
|
-
} = r.videoType ===
|
|
251
|
-
id:
|
|
252
|
-
offer:
|
|
253
|
-
ice_servers:
|
|
254
|
-
session_id:
|
|
255
|
-
} = await
|
|
256
|
-
iceServers:
|
|
201
|
+
startConnection: u,
|
|
202
|
+
sendStreamRequest: c,
|
|
203
|
+
close: h,
|
|
204
|
+
createStream: S,
|
|
205
|
+
addIceCandidate: _
|
|
206
|
+
} = r.videoType === $.Clip ? A(e, t) : T(e, t), {
|
|
207
|
+
id: l,
|
|
208
|
+
offer: y,
|
|
209
|
+
ice_servers: I,
|
|
210
|
+
session_id: p
|
|
211
|
+
} = await S(r), a = new D({
|
|
212
|
+
iceServers: I
|
|
257
213
|
}), C = a.createDataChannel("JanusDataChannel");
|
|
258
|
-
if (!
|
|
214
|
+
if (!p)
|
|
259
215
|
throw new Error("Could not create session_id");
|
|
260
216
|
a.onicecandidate = (i) => {
|
|
261
|
-
|
|
217
|
+
d("peerConnection.onicecandidate", i), i.candidate && i.candidate.sdpMid && i.candidate.sdpMLineIndex !== null && _(l, {
|
|
262
218
|
candidate: i.candidate.candidate,
|
|
263
219
|
sdpMid: i.candidate.sdpMid,
|
|
264
220
|
sdpMLineIndex: i.candidate.sdpMLineIndex
|
|
265
|
-
},
|
|
221
|
+
}, p);
|
|
266
222
|
}, a.oniceconnectionstatechange = () => {
|
|
267
|
-
|
|
223
|
+
d("peerConnection.oniceconnectionstatechange => " + a.iceConnectionState), n.onConnectionStateChange(a.iceConnectionState);
|
|
268
224
|
}, a.ontrack = (i) => {
|
|
269
|
-
|
|
225
|
+
d("peerConnection.ontrack", i), s = i.streams[0], n.onSrcObjectReady(s);
|
|
270
226
|
}, C.onmessage = (i) => {
|
|
271
|
-
C.readyState === "open" &&
|
|
272
|
-
}, await a.setRemoteDescription(
|
|
273
|
-
const
|
|
274
|
-
return
|
|
227
|
+
C.readyState === "open" && n.onStreamingStateChange(i.data === "stream/done" ? m.Idle : m.Streaming);
|
|
228
|
+
}, await a.setRemoteDescription(y), d("set remote description OK");
|
|
229
|
+
const w = await a.createAnswer();
|
|
230
|
+
return d("create answer OK"), await a.setLocalDescription(w), d("set local description OK"), await u(l, w, p), d("start connection OK"), {
|
|
275
231
|
speak(i) {
|
|
276
|
-
return
|
|
232
|
+
return c(l, p, i);
|
|
277
233
|
},
|
|
278
234
|
async terminate() {
|
|
279
|
-
|
|
235
|
+
l && (s && (s.getTracks().forEach((i) => i.stop()), s = null), a && (a.close(), a.oniceconnectionstatechange = null, a.onnegotiationneeded = null, a.onicecandidate = null, a.ontrack = null), await h(l, p), n.onConnectionStateChange("closed"), n.onStreamingStateChange(m.Idle));
|
|
280
236
|
},
|
|
281
|
-
sessionId:
|
|
282
|
-
streamId:
|
|
237
|
+
sessionId: p,
|
|
238
|
+
streamId: l
|
|
283
239
|
};
|
|
284
240
|
}
|
|
285
241
|
export {
|
|
286
|
-
A as connect,
|
|
287
|
-
M as connectToSocket,
|
|
288
242
|
O as createAgentsApi,
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
243
|
+
g as createClient,
|
|
244
|
+
K as createKnowledgeApi,
|
|
245
|
+
E as createStreamingManager
|
|
292
246
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(c,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(c=typeof globalThis<"u"?globalThis:c||self,g(c.index={}))})(this,function(c){"use strict";function g(r){return r.type==="bearer"?"Bearer "+r.token:r.type==="basic"?"Basic "+btoa(`${r.username}:${r.password}`):"Client-Key "+r.clientKey}function f(r,o="https://api.d-id.com"){const n=async(e,t)=>{const i=await fetch(o+(e!=null&&e.startsWith("/")?e:`/${e}`),{...t,headers:{...t==null?void 0:t.headers,Authorization:g(r),"Content-Type":"application/json"}});if(!i.ok){let l=await i.text().catch(()=>"Failed to fetch");try{const u=JSON.parse(l);u.description?l=u.description:u.message&&(l=u.message)}catch{}throw new Error(l)}return i.json()};return{get(e,t){return n(e,{...t,method:"GET"})},post(e,t,i){return n(e,{...i,body:JSON.stringify(t),method:"POST"})},delete(e,t,i){return n(e,{...i,body:JSON.stringify(t),method:"DELETE"})},patch(e,t,i){return n(e,{...i,body:JSON.stringify(t),method:"PATCH"})}}}function y(r,o="https://api.d-id.com"){const n=f(r,`${o}/knowledge`);return{createKnowledge(e){return n.post("/",e)},getKnowledgeBase(){return n.get("/")},getKnowledge(e){return n.get(`/${e}`)},deleteKnowledge(e){return n.delete(`/${e}`)},createDocument(e,t){return n.post(`/${e}/documents`,t)},deleteDocument(e,t){return n.delete(`/${e}/documents/${t}`)},getDocuments(e){return n.get(`/${e}/documents`)},getDocument(e,t){return n.get(`/${e}/documents/${t}`)},getRecords(e,t){return n.get(`/${e}/documents/${t}/records`)},query(e,t){return n.post(`/${e}/query`,{query:t})}}}function _(r,o="https://api.d-id.com"){const n=f(r,`${o}/agents`);return{create(e){return n.post("/",e)},getAgents(e){return n.get(`/${e?`?tag=${e}`:""}`)},getById(e){return n.get(`/${e}`)},delete(e){return n.delete(`/${e}`)},update(e,t){return n.patch(`/${e}`,t)},newChat(e){return n.post(`/${e}/chat`)},chat(e,t,i){return n.post(`/${e}/chat/${t}`,i)}}}function A(r,o){const n=f(r,o);return{createStream(e){return n.post("/clips/streams",{driver_id:e.driver_id,presenter_id:e.presenter_id,compatibility_mode:e.compatibility_mode})},startConnection(e,t,i){return n.post(`/clips/streams/${e}/sdp`,{session_id:i,answer:t})},addIceCandidate(e,t,i){return n.post(`/clips/streams/${e}/ice`,{session_id:i,...t})},sendStreamRequest(e,t,i){return n.post(`/clips/streams/${e}`,{session_id:t,...i})},close(e,t){return n.delete(`/clips/streams/${e}`,{session_id:t})}}}function I(r,o){const n=f(r,o);return{createStream(e){return n.post("/talks/streams",{source_url:e.source_url,driver_url:e.driver_url,face:e.face,config:e.config})},startConnection(e,t,i){return n.post(`/talks/streams/${e}/sdp`,{session_id:i,answer:t})},addIceCandidate(e,t,i){return n.post(`/talks/streams/${e}/ice`,{session_id:i,...t})},sendStreamRequest(e,t,i){return n.post(`/talks/streams/${e}`,{session_id:t,...i})},close(e,t){return n.delete(`/talks/streams/${e}`,{session_id:t})}}}var C=(r=>(r.Idle="IDLE",r.Streaming="STREAMING",r))(C||{}),w=(r=>(r.Clip="clip",r.Talk="talk",r))(w||{});let h=!1;const d=(r,o)=>h&&console.log(r,o),T=(window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection).bind(window);async function k(r,{debug:o=!1,callbacks:n,auth:e,baseURL:t="https://api.d-id.com"}){h=o;let i=null;const{startConnection:l,sendStreamRequest:u,close:K,createStream:O,addIceCandidate:b}=r.videoType===w.Clip?A(e,t):I(e,t),{id:p,offer:D,ice_servers:E,session_id:m}=await O(r),a=new T({iceServers:E}),$=a.createDataChannel("JanusDataChannel");if(!m)throw new Error("Could not create session_id");a.onicecandidate=s=>{d("peerConnection.onicecandidate",s),s.candidate&&s.candidate.sdpMid&&s.candidate.sdpMLineIndex!==null&&b(p,{candidate:s.candidate.candidate,sdpMid:s.candidate.sdpMid,sdpMLineIndex:s.candidate.sdpMLineIndex},m)},a.oniceconnectionstatechange=()=>{d("peerConnection.oniceconnectionstatechange => "+a.iceConnectionState),n.onConnectionStateChange(a.iceConnectionState)},a.ontrack=s=>{d("peerConnection.ontrack",s),i=s.streams[0],n.onSrcObjectReady(i)},$.onmessage=s=>{$.readyState==="open"&&n.onStreamingStateChange(s.data==="stream/done"?C.Idle:C.Streaming)},await a.setRemoteDescription(D),d("set remote description OK");const S=await a.createAnswer();return d("create answer OK"),await a.setLocalDescription(S),d("set local description OK"),await l(p,S,m),d("start connection OK"),{speak(s){return u(p,m,s)},async terminate(){p&&(i&&(i.getTracks().forEach(s=>s.stop()),i=null),a&&(a.close(),a.oniceconnectionstatechange=null,a.onnegotiationneeded=null,a.onicecandidate=null,a.ontrack=null),await K(p,m),n.onConnectionStateChange("closed"),n.onStreamingStateChange(C.Idle))},sessionId:m,streamId:p}}c.createAgentsApi=_,c.createClient=f,c.createKnowledgeApi=y,c.createStreamingManager=k,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Auth } from '../../../common/types/src/auth';
|
|
2
|
-
interface Options {
|
|
3
|
-
auth: Auth;
|
|
4
|
-
retries?: number;
|
|
5
|
-
callbacks: {
|
|
6
|
-
onMessage: (event: MessageEvent) => void;
|
|
7
|
-
onOpen?: (event: Event) => void;
|
|
8
|
-
onClose?: (event: CloseEvent) => void;
|
|
9
|
-
onError?: (event: Event) => void;
|
|
10
|
-
};
|
|
11
|
-
host?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function connect(options: Options): Promise<WebSocket>;
|
|
14
|
-
export declare function connectToSocket(options: Options): Promise<WebSocket>;
|
|
15
|
-
export {};
|