@d-id/client-sdk 1.0.18-beta.3 → 1.0.18-beta.4
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/index.js +271 -262
- package/dist/index.umd.cjs +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/lib/api/agents.d.ts +1 -1
- package/dist/src/lib/api/clipStream.d.ts +1 -1
- package/dist/src/lib/api/getClient.d.ts +1 -1
- package/dist/src/lib/api/knowledge.d.ts +1 -1
- package/dist/src/lib/api/ratings.d.ts +1 -1
- package/dist/src/lib/api/talkStream.d.ts +1 -1
- package/dist/src/lib/auth/getAuthHeader.d.ts +1 -1
- package/dist/src/lib/connectToSocket.d.ts +1 -1
- package/dist/src/lib/createAgentManager.d.ts +1 -1
- package/dist/src/lib/createStreamingManager.d.ts +2 -2
- package/dist/{src/types → types}/entities/agents/manager.d.ts +1 -1
- package/package.json +1 -1
- /package/dist/{src/types → types}/StreamScript.d.ts +0 -0
- /package/dist/{src/types → types}/auth.d.ts +0 -0
- /package/dist/{src/types → types}/entities/agents/agent.d.ts +0 -0
- /package/dist/{src/types → types}/entities/agents/chat.d.ts +0 -0
- /package/dist/{src/types → types}/entities/agents/index.d.ts +0 -0
- /package/dist/{src/types → types}/entities/agents/knowledge.d.ts +0 -0
- /package/dist/{src/types → types}/entities/agents/llm.d.ts +0 -0
- /package/dist/{src/types → types}/entities/agents/presenter.d.ts +0 -0
- /package/dist/{src/types → types}/entities/index.d.ts +0 -0
- /package/dist/{src/types → types}/entities/knowledge/document.d.ts +0 -0
- /package/dist/{src/types → types}/entities/knowledge/index.d.ts +0 -0
- /package/dist/{src/types → types}/entities/knowledge/knowledge.d.ts +0 -0
- /package/dist/{src/types → types}/entities/knowledge/record.d.ts +0 -0
- /package/dist/{src/types → types}/entities/knowledge/retrival.d.ts +0 -0
- /package/dist/{src/types → types}/entities/video.d.ts +0 -0
- /package/dist/{src/types → types}/index.d.ts +0 -0
- /package/dist/{src/types → types}/stream/api/clip.d.ts +0 -0
- /package/dist/{src/types → types}/stream/api/index.d.ts +0 -0
- /package/dist/{src/types → types}/stream/api/talk.d.ts +0 -0
- /package/dist/{src/types → types}/stream/index.d.ts +0 -0
- /package/dist/{src/types → types}/stream/rtc.d.ts +0 -0
- /package/dist/{src/types → types}/stream/stream.d.ts +0 -0
- /package/dist/{src/types → types}/tts.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,444 +1,453 @@
|
|
|
1
|
-
const f = "https://api-dev.d-id.com",
|
|
2
|
-
function
|
|
3
|
-
if (
|
|
4
|
-
return `Bearer ${
|
|
5
|
-
if (
|
|
6
|
-
return `Basic ${btoa(`${
|
|
7
|
-
if (
|
|
8
|
-
return `Client-Key ${
|
|
9
|
-
throw new Error(`Unknown auth type: ${
|
|
1
|
+
const f = "https://api-dev.d-id.com", b = "wss://notifications.d-id.com";
|
|
2
|
+
function M(e) {
|
|
3
|
+
if (e.type === "bearer")
|
|
4
|
+
return `Bearer ${e.token}`;
|
|
5
|
+
if (e.type === "basic")
|
|
6
|
+
return `Basic ${btoa(`${e.username}:${e.password}`)}`;
|
|
7
|
+
if (e.type === "key")
|
|
8
|
+
return `Client-Key ${e.clientKey}`;
|
|
9
|
+
throw new Error(`Unknown auth type: ${e}`);
|
|
10
10
|
}
|
|
11
|
-
function S(
|
|
12
|
-
const o = async (
|
|
13
|
-
const
|
|
14
|
-
...
|
|
11
|
+
function S(e, a = f) {
|
|
12
|
+
const o = async (t, n) => {
|
|
13
|
+
const r = await fetch(a + (t != null && t.startsWith("/") ? t : `/${t}`), {
|
|
14
|
+
...n,
|
|
15
15
|
headers: {
|
|
16
|
-
...
|
|
17
|
-
Authorization:
|
|
16
|
+
...n == null ? void 0 : n.headers,
|
|
17
|
+
Authorization: M(e),
|
|
18
18
|
"Content-Type": "application/json"
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
|
-
if (!
|
|
22
|
-
let c = await
|
|
21
|
+
if (!r.ok) {
|
|
22
|
+
let c = await r.text().catch(() => "Failed to fetch");
|
|
23
23
|
throw new Error(c);
|
|
24
24
|
}
|
|
25
|
-
return
|
|
25
|
+
return r.json();
|
|
26
26
|
};
|
|
27
27
|
return {
|
|
28
|
-
get(
|
|
29
|
-
return o(
|
|
30
|
-
...
|
|
28
|
+
get(t, n) {
|
|
29
|
+
return o(t, {
|
|
30
|
+
...n,
|
|
31
31
|
method: "GET"
|
|
32
32
|
});
|
|
33
33
|
},
|
|
34
|
-
post(
|
|
35
|
-
return o(
|
|
36
|
-
...
|
|
37
|
-
body: JSON.stringify(
|
|
34
|
+
post(t, n, r) {
|
|
35
|
+
return o(t, {
|
|
36
|
+
...r,
|
|
37
|
+
body: JSON.stringify(n),
|
|
38
38
|
method: "POST"
|
|
39
39
|
});
|
|
40
40
|
},
|
|
41
|
-
delete(
|
|
42
|
-
return o(
|
|
43
|
-
...
|
|
44
|
-
body: JSON.stringify(
|
|
41
|
+
delete(t, n, r) {
|
|
42
|
+
return o(t, {
|
|
43
|
+
...r,
|
|
44
|
+
body: JSON.stringify(n),
|
|
45
45
|
method: "DELETE"
|
|
46
46
|
});
|
|
47
47
|
},
|
|
48
|
-
patch(
|
|
49
|
-
return o(
|
|
50
|
-
...
|
|
51
|
-
body: JSON.stringify(
|
|
48
|
+
patch(t, n, r) {
|
|
49
|
+
return o(t, {
|
|
50
|
+
...r,
|
|
51
|
+
body: JSON.stringify(n),
|
|
52
52
|
method: "PATCH"
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
const o = S(
|
|
57
|
+
function z(e, a = f) {
|
|
58
|
+
const o = S(e, `${a}/agents`);
|
|
59
59
|
return {
|
|
60
|
-
create(
|
|
61
|
-
return o.post("/",
|
|
60
|
+
create(t, n) {
|
|
61
|
+
return o.post("/", t, n);
|
|
62
62
|
},
|
|
63
|
-
getAgents(
|
|
64
|
-
return o.get(`/${
|
|
63
|
+
getAgents(t, n) {
|
|
64
|
+
return o.get(`/${t ? `?tag=${t}` : ""}`, n).then((r) => r ?? []);
|
|
65
65
|
},
|
|
66
|
-
getById(
|
|
67
|
-
return o.get(`/${
|
|
66
|
+
getById(t, n) {
|
|
67
|
+
return o.get(`/${t}`, n);
|
|
68
68
|
},
|
|
69
|
-
delete(
|
|
70
|
-
return o.delete(`/${
|
|
69
|
+
delete(t, n) {
|
|
70
|
+
return o.delete(`/${t}`, void 0, n);
|
|
71
71
|
},
|
|
72
|
-
update(
|
|
73
|
-
return o.patch(`/${
|
|
72
|
+
update(t, n, r) {
|
|
73
|
+
return o.patch(`/${t}`, n, r);
|
|
74
74
|
},
|
|
75
|
-
newChat(
|
|
76
|
-
return o.post(`/${
|
|
75
|
+
newChat(t, n) {
|
|
76
|
+
return o.post(`/${t}/chat`, void 0, n);
|
|
77
77
|
},
|
|
78
|
-
chat(
|
|
79
|
-
return o.post(`/${
|
|
78
|
+
chat(t, n, r, c) {
|
|
79
|
+
return o.post(`/${t}/chat/${n}`, r, c);
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
const o = S(
|
|
83
|
+
function Z(e, a = f) {
|
|
84
|
+
const o = S(e, `${a}/knowledge`);
|
|
85
85
|
return {
|
|
86
|
-
createKnowledge(
|
|
87
|
-
return o.post("/",
|
|
86
|
+
createKnowledge(t, n) {
|
|
87
|
+
return o.post("/", t, n);
|
|
88
88
|
},
|
|
89
|
-
getKnowledgeBase(
|
|
90
|
-
return o.get("/",
|
|
89
|
+
getKnowledgeBase(t) {
|
|
90
|
+
return o.get("/", t);
|
|
91
91
|
},
|
|
92
|
-
getKnowledge(
|
|
93
|
-
return o.get(`/${
|
|
92
|
+
getKnowledge(t, n) {
|
|
93
|
+
return o.get(`/${t}`, n);
|
|
94
94
|
},
|
|
95
|
-
deleteKnowledge(
|
|
96
|
-
return o.delete(`/${
|
|
95
|
+
deleteKnowledge(t, n) {
|
|
96
|
+
return o.delete(`/${t}`, void 0, n);
|
|
97
97
|
},
|
|
98
|
-
createDocument(
|
|
99
|
-
return o.post(`/${
|
|
98
|
+
createDocument(t, n, r) {
|
|
99
|
+
return o.post(`/${t}/documents`, n, r);
|
|
100
100
|
},
|
|
101
|
-
deleteDocument(
|
|
102
|
-
return o.delete(`/${
|
|
101
|
+
deleteDocument(t, n, r) {
|
|
102
|
+
return o.delete(`/${t}/documents/${n}`, void 0, r);
|
|
103
103
|
},
|
|
104
|
-
getDocuments(
|
|
105
|
-
return o.get(`/${
|
|
104
|
+
getDocuments(t, n) {
|
|
105
|
+
return o.get(`/${t}/documents`, n);
|
|
106
106
|
},
|
|
107
|
-
getDocument(
|
|
108
|
-
return o.get(`/${
|
|
107
|
+
getDocument(t, n, r) {
|
|
108
|
+
return o.get(`/${t}/documents/${n}`, r);
|
|
109
109
|
},
|
|
110
|
-
getRecords(
|
|
111
|
-
return o.get(`/${
|
|
110
|
+
getRecords(t, n, r) {
|
|
111
|
+
return o.get(`/${t}/documents/${n}/records`, r);
|
|
112
112
|
},
|
|
113
|
-
query(
|
|
114
|
-
return o.post(`/${
|
|
115
|
-
query:
|
|
116
|
-
},
|
|
113
|
+
query(t, n, r) {
|
|
114
|
+
return o.post(`/${t}/query`, {
|
|
115
|
+
query: n
|
|
116
|
+
}, r);
|
|
117
117
|
}
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
|
-
const
|
|
121
|
-
function
|
|
120
|
+
const T = (e) => new Promise((a) => setTimeout(a, e));
|
|
121
|
+
function U(e) {
|
|
122
122
|
return new Promise((a, o) => {
|
|
123
123
|
const {
|
|
124
|
-
callbacks:
|
|
125
|
-
host:
|
|
126
|
-
auth:
|
|
127
|
-
} =
|
|
124
|
+
callbacks: t,
|
|
125
|
+
host: n,
|
|
126
|
+
auth: r
|
|
127
|
+
} = e, {
|
|
128
128
|
onMessage: c = null,
|
|
129
|
-
onOpen:
|
|
130
|
-
onClose:
|
|
131
|
-
onError:
|
|
132
|
-
} =
|
|
133
|
-
d.onmessage = c, d.onclose =
|
|
134
|
-
console.log(
|
|
135
|
-
}, d.onopen = (
|
|
136
|
-
|
|
129
|
+
onOpen: u = null,
|
|
130
|
+
onClose: m = null,
|
|
131
|
+
onError: g = null
|
|
132
|
+
} = t || {}, d = new WebSocket(`${n}?authorization=${M(r)}`);
|
|
133
|
+
d.onmessage = c, d.onclose = m, d.onerror = (i) => {
|
|
134
|
+
console.log(i), g == null || g(i), o(i);
|
|
135
|
+
}, d.onopen = (i) => {
|
|
136
|
+
u == null || u(i), a(d);
|
|
137
137
|
};
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
|
-
async function
|
|
140
|
+
async function q(e) {
|
|
141
141
|
const {
|
|
142
142
|
retries: a = 1
|
|
143
|
-
} =
|
|
143
|
+
} = e;
|
|
144
144
|
let o = null;
|
|
145
|
-
for (let
|
|
145
|
+
for (let t = 0; (o == null ? void 0 : o.readyState) !== WebSocket.OPEN; t++)
|
|
146
146
|
try {
|
|
147
|
-
o = await
|
|
148
|
-
} catch (
|
|
149
|
-
if (
|
|
150
|
-
throw
|
|
151
|
-
await
|
|
147
|
+
o = await U(e);
|
|
148
|
+
} catch (n) {
|
|
149
|
+
if (t === a)
|
|
150
|
+
throw n;
|
|
151
|
+
await T(t * 500);
|
|
152
152
|
}
|
|
153
153
|
return o;
|
|
154
154
|
}
|
|
155
|
-
async function
|
|
156
|
-
const o = [],
|
|
157
|
-
auth:
|
|
155
|
+
async function B(e, a = b) {
|
|
156
|
+
const o = [], t = await q({
|
|
157
|
+
auth: e,
|
|
158
158
|
host: a,
|
|
159
159
|
callbacks: {
|
|
160
|
-
onMessage: (
|
|
161
|
-
console.log("event",
|
|
160
|
+
onMessage: (n) => {
|
|
161
|
+
console.log("event", n), o.forEach((r) => r(n));
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
});
|
|
165
165
|
return {
|
|
166
|
-
socket:
|
|
167
|
-
terminate: () =>
|
|
168
|
-
subscribeToEvents: (
|
|
169
|
-
o.push(
|
|
166
|
+
socket: t,
|
|
167
|
+
terminate: () => t.close(),
|
|
168
|
+
subscribeToEvents: (n) => {
|
|
169
|
+
o.push(n);
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
|
-
var
|
|
174
|
-
function
|
|
175
|
-
const o = S(
|
|
173
|
+
var L = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(L || {}), N = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(N || {}), v = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(v || {}), A = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.StreamDone = "stream/done", e.StreamStarted = "stream/started", e))(A || {}), J = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(J || {}), W = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(W || {}), F = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(F || {}), H = /* @__PURE__ */ ((e) => (e.Pdf = "pdf", e.Text = "text", e.Html = "html", e.Word = "word", e.Json = "json", e.Markdown = "markdown", e.Csv = "csv", e.Excel = "excel", e.Powerpoint = "powerpoint", e.Archive = "archive", e.Image = "image", e.Audio = "audio", e.Video = "video", e))(H || {}), $ = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e))($ || {});
|
|
174
|
+
function V(e, a = f) {
|
|
175
|
+
const o = S(e, `${a}/chats/ratings`);
|
|
176
176
|
return {
|
|
177
|
-
create(
|
|
178
|
-
return o.post("/",
|
|
177
|
+
create(t, n) {
|
|
178
|
+
return o.post("/", t, n);
|
|
179
179
|
},
|
|
180
|
-
getByKnowledge(
|
|
181
|
-
return o.get(`/${
|
|
180
|
+
getByKnowledge(t, n) {
|
|
181
|
+
return o.get(`/${t}`, n).then((r) => r ?? []);
|
|
182
182
|
},
|
|
183
|
-
update(
|
|
184
|
-
return o.patch(`/${
|
|
183
|
+
update(t, n, r) {
|
|
184
|
+
return o.patch(`/${t}`, n, r);
|
|
185
185
|
},
|
|
186
|
-
delete(
|
|
187
|
-
return o.delete(`/${
|
|
186
|
+
delete(t, n) {
|
|
187
|
+
return o.delete(`/${t}`, n);
|
|
188
188
|
}
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
|
-
function
|
|
192
|
-
return
|
|
191
|
+
function D(e) {
|
|
192
|
+
return e.presenter.type === $.Clip ? {
|
|
193
193
|
videoType: $.Clip,
|
|
194
|
-
driver_id:
|
|
195
|
-
presenter_id:
|
|
194
|
+
driver_id: e.presenter.driver_id,
|
|
195
|
+
presenter_id: e.presenter.presenter_id
|
|
196
196
|
} : {
|
|
197
197
|
videoType: $.Talk,
|
|
198
|
-
source_url:
|
|
198
|
+
source_url: e.presenter.source_url
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
|
-
function
|
|
202
|
-
return new Promise(async (
|
|
203
|
-
var
|
|
204
|
-
const
|
|
205
|
-
a.callbacks.onConnectionStateChange = async (
|
|
206
|
-
if (
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
chat:
|
|
201
|
+
function K(e, a, o) {
|
|
202
|
+
return new Promise(async (t, n) => {
|
|
203
|
+
var u;
|
|
204
|
+
const r = ((u = a.callbacks) == null ? void 0 : u.onConnectionStateChange) ?? null;
|
|
205
|
+
a.callbacks.onConnectionStateChange = async (m) => {
|
|
206
|
+
if (r && r(m), m === "connected") {
|
|
207
|
+
const g = await o.newChat(e.id);
|
|
208
|
+
r && c.onCallback("onConnectionStateChange", r), t({
|
|
209
|
+
chat: g,
|
|
210
210
|
streamingAPI: c
|
|
211
211
|
});
|
|
212
212
|
} else
|
|
213
|
-
|
|
213
|
+
m === "failed" && n(new Error("Cannot create connection"));
|
|
214
214
|
};
|
|
215
|
-
const c = await
|
|
215
|
+
const c = await Y(D(e), a);
|
|
216
216
|
});
|
|
217
217
|
}
|
|
218
|
-
async function
|
|
219
|
-
const o = a.baseURL || f,
|
|
220
|
-
return
|
|
218
|
+
async function O(e, a) {
|
|
219
|
+
const o = a.baseURL || f, t = new AbortController(), n = z(a.auth, o), r = V(a.auth, o), c = await n.getById(e), u = await B(a.auth);
|
|
220
|
+
return K(c, a, n).then((m) => {
|
|
221
221
|
let {
|
|
222
|
-
chat:
|
|
222
|
+
chat: g,
|
|
223
223
|
streamingAPI: d
|
|
224
|
-
} =
|
|
224
|
+
} = m;
|
|
225
225
|
return {
|
|
226
226
|
agent: c,
|
|
227
227
|
async reconnectToChat() {
|
|
228
|
-
await
|
|
229
|
-
|
|
228
|
+
await K(c, a, n).then((i) => {
|
|
229
|
+
g = i.chat, d = i.streamingAPI;
|
|
230
230
|
});
|
|
231
231
|
},
|
|
232
232
|
terminate() {
|
|
233
|
-
return
|
|
233
|
+
return t.abort(), u.terminate(), d.terminate();
|
|
234
234
|
},
|
|
235
|
-
chatId:
|
|
236
|
-
chat(
|
|
237
|
-
return
|
|
235
|
+
chatId: g.id,
|
|
236
|
+
chat(i) {
|
|
237
|
+
return n.chat(e, g.id, {
|
|
238
238
|
sessionId: d.sessionId,
|
|
239
239
|
streamId: d.streamId,
|
|
240
|
-
messages:
|
|
240
|
+
messages: i
|
|
241
241
|
}, {
|
|
242
|
-
signal:
|
|
242
|
+
signal: t.signal
|
|
243
243
|
});
|
|
244
244
|
},
|
|
245
|
-
rate(
|
|
246
|
-
return
|
|
245
|
+
rate(i, w) {
|
|
246
|
+
return w ? r.update(w, i) : r.create(i);
|
|
247
247
|
},
|
|
248
|
-
speak(
|
|
248
|
+
speak(i) {
|
|
249
249
|
if (!c)
|
|
250
250
|
throw new Error("Agent not initializated");
|
|
251
|
-
let
|
|
252
|
-
return
|
|
251
|
+
let w;
|
|
252
|
+
return i.type === "text" ? w = {
|
|
253
253
|
script: {
|
|
254
254
|
type: "text",
|
|
255
|
-
provider:
|
|
256
|
-
input:
|
|
257
|
-
ssml:
|
|
255
|
+
provider: i.provider,
|
|
256
|
+
input: i.input,
|
|
257
|
+
ssml: i.ssml || !1
|
|
258
258
|
}
|
|
259
|
-
} :
|
|
259
|
+
} : i.type === "audio" && (w = {
|
|
260
260
|
script: {
|
|
261
261
|
type: "audio",
|
|
262
|
-
audio_url:
|
|
262
|
+
audio_url: i.audio_url
|
|
263
263
|
}
|
|
264
|
-
}), d.speak(
|
|
264
|
+
}), d.speak(w);
|
|
265
265
|
},
|
|
266
|
-
onChatEvents(
|
|
267
|
-
|
|
266
|
+
onChatEvents(i) {
|
|
267
|
+
u.subscribeToEvents(i);
|
|
268
268
|
},
|
|
269
|
-
onConnectionEvents(
|
|
270
|
-
d.onCallback("onConnectionStateChange",
|
|
269
|
+
onConnectionEvents(i) {
|
|
270
|
+
d.onCallback("onConnectionStateChange", i);
|
|
271
271
|
},
|
|
272
|
-
onVideoEvents(
|
|
273
|
-
d.onCallback("onVideoStateChange",
|
|
272
|
+
onVideoEvents(i) {
|
|
273
|
+
d.onCallback("onVideoStateChange", i);
|
|
274
274
|
}
|
|
275
275
|
};
|
|
276
276
|
});
|
|
277
277
|
}
|
|
278
|
-
function
|
|
279
|
-
const o = S(
|
|
278
|
+
function G(e, a) {
|
|
279
|
+
const o = S(e, a);
|
|
280
280
|
return {
|
|
281
|
-
createStream(
|
|
281
|
+
createStream(t) {
|
|
282
282
|
return o.post("/clips/streams", {
|
|
283
|
-
driver_id:
|
|
284
|
-
presenter_id:
|
|
285
|
-
compatibility_mode:
|
|
283
|
+
driver_id: t.driver_id,
|
|
284
|
+
presenter_id: t.presenter_id,
|
|
285
|
+
compatibility_mode: t.compatibility_mode
|
|
286
286
|
});
|
|
287
287
|
},
|
|
288
|
-
startConnection(
|
|
289
|
-
return o.post(`/clips/streams/${
|
|
290
|
-
session_id:
|
|
291
|
-
answer:
|
|
288
|
+
startConnection(t, n, r) {
|
|
289
|
+
return o.post(`/clips/streams/${t}/sdp`, {
|
|
290
|
+
session_id: r,
|
|
291
|
+
answer: n
|
|
292
292
|
});
|
|
293
293
|
},
|
|
294
|
-
addIceCandidate(
|
|
295
|
-
return o.post(`/clips/streams/${
|
|
296
|
-
session_id:
|
|
297
|
-
...
|
|
294
|
+
addIceCandidate(t, n, r) {
|
|
295
|
+
return o.post(`/clips/streams/${t}/ice`, {
|
|
296
|
+
session_id: r,
|
|
297
|
+
...n
|
|
298
298
|
});
|
|
299
299
|
},
|
|
300
|
-
sendStreamRequest(
|
|
301
|
-
return o.post(`/clips/streams/${
|
|
302
|
-
session_id:
|
|
303
|
-
...
|
|
300
|
+
sendStreamRequest(t, n, r) {
|
|
301
|
+
return o.post(`/clips/streams/${t}`, {
|
|
302
|
+
session_id: n,
|
|
303
|
+
...r
|
|
304
304
|
});
|
|
305
305
|
},
|
|
306
|
-
close(
|
|
307
|
-
return o.delete(`/clips/streams/${
|
|
308
|
-
session_id:
|
|
306
|
+
close(t, n) {
|
|
307
|
+
return o.delete(`/clips/streams/${t}`, {
|
|
308
|
+
session_id: n
|
|
309
309
|
});
|
|
310
310
|
}
|
|
311
311
|
};
|
|
312
312
|
}
|
|
313
|
-
function
|
|
314
|
-
const o = S(
|
|
313
|
+
function Q(e, a) {
|
|
314
|
+
const o = S(e, a);
|
|
315
315
|
return {
|
|
316
|
-
createStream(
|
|
316
|
+
createStream(t, n) {
|
|
317
317
|
return o.post("/talks/streams", {
|
|
318
|
-
source_url:
|
|
319
|
-
driver_url:
|
|
320
|
-
face:
|
|
321
|
-
config:
|
|
322
|
-
},
|
|
323
|
-
},
|
|
324
|
-
startConnection(e, t, n, c) {
|
|
325
|
-
return o.post(`/talks/streams/${e}/sdp`, {
|
|
326
|
-
session_id: n,
|
|
327
|
-
answer: t
|
|
328
|
-
}, c);
|
|
318
|
+
source_url: t.source_url,
|
|
319
|
+
driver_url: t.driver_url,
|
|
320
|
+
face: t.face,
|
|
321
|
+
config: t.config
|
|
322
|
+
}, n);
|
|
329
323
|
},
|
|
330
|
-
|
|
331
|
-
return o.post(`/talks/streams/${
|
|
332
|
-
session_id:
|
|
333
|
-
|
|
324
|
+
startConnection(t, n, r, c) {
|
|
325
|
+
return o.post(`/talks/streams/${t}/sdp`, {
|
|
326
|
+
session_id: r,
|
|
327
|
+
answer: n
|
|
334
328
|
}, c);
|
|
335
329
|
},
|
|
336
|
-
|
|
337
|
-
return o.post(`/talks/streams/${
|
|
338
|
-
session_id:
|
|
330
|
+
addIceCandidate(t, n, r, c) {
|
|
331
|
+
return o.post(`/talks/streams/${t}/ice`, {
|
|
332
|
+
session_id: r,
|
|
339
333
|
...n
|
|
340
334
|
}, c);
|
|
341
335
|
},
|
|
342
|
-
|
|
343
|
-
return o.
|
|
344
|
-
session_id:
|
|
345
|
-
|
|
336
|
+
sendStreamRequest(t, n, r, c) {
|
|
337
|
+
return o.post(`/talks/streams/${t}`, {
|
|
338
|
+
session_id: n,
|
|
339
|
+
...r
|
|
340
|
+
}, c);
|
|
341
|
+
},
|
|
342
|
+
close(t, n, r) {
|
|
343
|
+
return o.delete(`/talks/streams/${t}`, {
|
|
344
|
+
session_id: n
|
|
345
|
+
}, r);
|
|
346
346
|
}
|
|
347
347
|
};
|
|
348
348
|
}
|
|
349
|
-
let
|
|
350
|
-
const
|
|
351
|
-
async function
|
|
349
|
+
let E = !1;
|
|
350
|
+
const C = (e, a) => E && console.log(e, a), X = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
|
|
351
|
+
async function Y(e, {
|
|
352
352
|
debug: a = !1,
|
|
353
353
|
callbacks: o,
|
|
354
|
-
auth:
|
|
355
|
-
baseURL:
|
|
354
|
+
auth: t,
|
|
355
|
+
baseURL: n = f
|
|
356
356
|
}) {
|
|
357
|
-
|
|
358
|
-
const
|
|
357
|
+
E = a;
|
|
358
|
+
const r = {
|
|
359
359
|
...o
|
|
360
360
|
}, {
|
|
361
361
|
startConnection: c,
|
|
362
|
-
sendStreamRequest:
|
|
363
|
-
close:
|
|
364
|
-
createStream:
|
|
362
|
+
sendStreamRequest: u,
|
|
363
|
+
close: m,
|
|
364
|
+
createStream: g,
|
|
365
365
|
addIceCandidate: d
|
|
366
|
-
} =
|
|
367
|
-
id:
|
|
368
|
-
offer:
|
|
369
|
-
ice_servers:
|
|
370
|
-
session_id:
|
|
371
|
-
} = await
|
|
372
|
-
iceServers:
|
|
373
|
-
}),
|
|
374
|
-
if (!
|
|
366
|
+
} = e.videoType === $.Clip ? G(t, n) : Q(t, n), {
|
|
367
|
+
id: i,
|
|
368
|
+
offer: w,
|
|
369
|
+
ice_servers: R,
|
|
370
|
+
session_id: h
|
|
371
|
+
} = await g(e), l = new X({
|
|
372
|
+
iceServers: R
|
|
373
|
+
}), y = l.createDataChannel("JanusDataChannel");
|
|
374
|
+
if (!h)
|
|
375
375
|
throw new Error("Could not create session_id");
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
candidate:
|
|
379
|
-
sdpMid:
|
|
380
|
-
sdpMLineIndex:
|
|
381
|
-
},
|
|
382
|
-
},
|
|
383
|
-
var
|
|
384
|
-
|
|
385
|
-
},
|
|
386
|
-
var
|
|
387
|
-
|
|
388
|
-
},
|
|
389
|
-
var
|
|
390
|
-
if (
|
|
391
|
-
const [
|
|
392
|
-
|
|
376
|
+
l.onicecandidate = (s) => {
|
|
377
|
+
C("peerConnection.onicecandidate", s), s.candidate && s.candidate.sdpMid && s.candidate.sdpMLineIndex !== null && d(i, {
|
|
378
|
+
candidate: s.candidate.candidate,
|
|
379
|
+
sdpMid: s.candidate.sdpMid,
|
|
380
|
+
sdpMLineIndex: s.candidate.sdpMLineIndex
|
|
381
|
+
}, h);
|
|
382
|
+
}, l.oniceconnectionstatechange = () => {
|
|
383
|
+
var s;
|
|
384
|
+
C("peerConnection.oniceconnectionstatechange => " + l.iceConnectionState), (s = r.onConnectionStateChange) == null || s.call(r, l.iceConnectionState);
|
|
385
|
+
}, l.ontrack = (s) => {
|
|
386
|
+
var p;
|
|
387
|
+
C("peerConnection.ontrack", s), (p = r.onSrcObjectReady) == null || p.call(r, s.streams[0]);
|
|
388
|
+
}, y.onmessage = (s) => {
|
|
389
|
+
var p, k, P;
|
|
390
|
+
if (y.readyState === "open") {
|
|
391
|
+
const [_, x] = s.data.split(":");
|
|
392
|
+
_ === A.StreamDone ? (p = r.onVideoStateChange) == null || p.call(r, v.Stop) : _ === A.StreamStarted ? (k = r.onVideoStateChange) == null || k.call(r, v.Start) : (P = r.onMessage) == null || P.call(r, _, decodeURIComponent(x));
|
|
393
393
|
}
|
|
394
|
-
}, await
|
|
395
|
-
const
|
|
396
|
-
return
|
|
394
|
+
}, await l.setRemoteDescription(w), C("set remote description OK");
|
|
395
|
+
const I = await l.createAnswer();
|
|
396
|
+
return C("create answer OK"), await l.setLocalDescription(I), C("set local description OK"), await c(i, I, h), C("start connection OK"), {
|
|
397
397
|
/**
|
|
398
398
|
* Method to send request to server to get clip or talk depend on you payload
|
|
399
399
|
* @param payload
|
|
400
400
|
*/
|
|
401
|
-
speak(
|
|
402
|
-
return
|
|
401
|
+
speak(s) {
|
|
402
|
+
return u(i, h, s);
|
|
403
403
|
},
|
|
404
404
|
/**
|
|
405
405
|
* Method to close RTC connection
|
|
406
406
|
*/
|
|
407
407
|
async terminate() {
|
|
408
|
-
var
|
|
409
|
-
|
|
410
|
-
}), (
|
|
408
|
+
var s, p;
|
|
409
|
+
i && (l && (l.close(), l.oniceconnectionstatechange = null, l.onnegotiationneeded = null, l.onicecandidate = null, l.ontrack = null), await m(i, h).catch((k) => {
|
|
410
|
+
}), (s = r.onConnectionStateChange) == null || s.call(r, "closed"), (p = r.onVideoStateChange) == null || p.call(r, v.Stop));
|
|
411
411
|
},
|
|
412
412
|
/**
|
|
413
413
|
* Session identifier information, should be returned in the body of all streaming requests
|
|
414
414
|
*/
|
|
415
|
-
sessionId:
|
|
415
|
+
sessionId: h,
|
|
416
416
|
/**
|
|
417
417
|
* Id of current RTC stream
|
|
418
418
|
*/
|
|
419
|
-
streamId:
|
|
419
|
+
streamId: i,
|
|
420
420
|
/**
|
|
421
421
|
* Method to add callback that will be trigered on supported events
|
|
422
422
|
* @param eventName
|
|
423
423
|
* @param callback
|
|
424
424
|
*/
|
|
425
|
-
onCallback(
|
|
426
|
-
|
|
425
|
+
onCallback(s, p) {
|
|
426
|
+
r[s] = p;
|
|
427
427
|
},
|
|
428
428
|
/**
|
|
429
429
|
* existing callback is internal method to pass calbacks added after create in new connection
|
|
430
430
|
*/
|
|
431
431
|
getCallbacks() {
|
|
432
|
-
return
|
|
432
|
+
return r;
|
|
433
433
|
}
|
|
434
434
|
};
|
|
435
435
|
}
|
|
436
436
|
export {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
437
|
+
H as DocumentType,
|
|
438
|
+
F as KnowledgeType,
|
|
439
|
+
L as Providers,
|
|
440
|
+
J as RateState,
|
|
441
|
+
B as SocketManager,
|
|
442
|
+
A as StreamEvents,
|
|
443
|
+
v as StreamingState,
|
|
444
|
+
W as Subject,
|
|
445
|
+
$ as VideoType,
|
|
446
|
+
N as VoiceAccess,
|
|
447
|
+
O as createAgentManager,
|
|
448
|
+
z as createAgentsApi,
|
|
440
449
|
S as createClient,
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
450
|
+
Z as createKnowledgeApi,
|
|
451
|
+
Y as createStreamingManager,
|
|
452
|
+
D as getAgentStreamArgs
|
|
444
453
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(c,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(c=typeof globalThis<"u"?globalThis:c||self,f(c.index={}))})(this,function(c){"use strict";const f="https://api-dev.d-id.com",W="wss://notifications.d-id.com";function P(e){if(e.type==="bearer")return`Bearer ${e.token}`;if(e.type==="basic")return`Basic ${btoa(`${e.username}:${e.password}`)}`;if(e.type==="key")return`Client-Key ${e.clientKey}`;throw new Error(`Unknown auth type: ${e}`)}function S(e,i=f){const a=async(t,n)=>{const r=await fetch(i+(t!=null&&t.startsWith("/")?t:`/${t}`),{...n,headers:{...n==null?void 0:n.headers,Authorization:P(e),"Content-Type":"application/json"}});if(!r.ok){let d=await r.text().catch(()=>"Failed to fetch");throw new Error(d)}return r.json()};return{get(t,n){return a(t,{...n,method:"GET"})},post(t,n,r){return a(t,{...r,body:JSON.stringify(n),method:"POST"})},delete(t,n,r){return a(t,{...r,body:JSON.stringify(n),method:"DELETE"})},patch(t,n,r){return a(t,{...r,body:JSON.stringify(n),method:"PATCH"})}}}function I(e,i=f){const a=S(e,`${i}/agents`);return{create(t,n){return a.post("/",t,n)},getAgents(t,n){return a.get(`/${t?`?tag=${t}`:""}`,n).then(r=>r??[])},getById(t,n){return a.get(`/${t}`,n)},delete(t,n){return a.delete(`/${t}`,void 0,n)},update(t,n,r){return a.patch(`/${t}`,n,r)},newChat(t,n){return a.post(`/${t}/chat`,void 0,n)},chat(t,n,r,d){return a.post(`/${t}/chat/${n}`,r,d)}}}function D(e,i=f){const a=S(e,`${i}/knowledge`);return{createKnowledge(t,n){return a.post("/",t,n)},getKnowledgeBase(t){return a.get("/",t)},getKnowledge(t,n){return a.get(`/${t}`,n)},deleteKnowledge(t,n){return a.delete(`/${t}`,void 0,n)},createDocument(t,n,r){return a.post(`/${t}/documents`,n,r)},deleteDocument(t,n,r){return a.delete(`/${t}/documents/${n}`,void 0,r)},getDocuments(t,n){return a.get(`/${t}/documents`,n)},getDocument(t,n,r){return a.get(`/${t}/documents/${n}`,r)},getRecords(t,n,r){return a.get(`/${t}/documents/${n}/records`,r)},query(t,n,r){return a.post(`/${t}/query`,{query:n},r)}}}const F=e=>new Promise(i=>setTimeout(i,e));function H(e){return new Promise((i,a)=>{const{callbacks:t,host:n,auth:r}=e,{onMessage:d=null,onOpen:g=null,onClose:h=null,onError:m=null}=t||{},l=new WebSocket(`${n}?authorization=${P(r)}`);l.onmessage=d,l.onclose=h,l.onerror=o=>{console.log(o),m==null||m(o),a(o)},l.onopen=o=>{g==null||g(o),i(l)}})}async function G(e){const{retries:i=1}=e;let a=null;for(let t=0;(a==null?void 0:a.readyState)!==WebSocket.OPEN;t++)try{a=await H(e)}catch(n){if(t===i)throw n;await F(t*500)}return a}async function M(e,i=W){const a=[],t=await G({auth:e,host:i,callbacks:{onMessage:n=>{console.log("event",n),a.forEach(r=>r(n))}}});return{socket:t,terminate:()=>t.close(),subscribeToEvents:n=>{a.push(n)}}}var K=(e=>(e.Amazon="amazon",e.Microsoft="microsoft",e.Afflorithmics="afflorithmics",e.Elevenlabs="elevenlabs",e))(K||{}),E=(e=>(e.Public="public",e.Premium="premium",e.Private="private",e))(E||{}),A=(e=>(e.Start="START",e.Stop="STOP",e))(A||{}),k=(e=>(e.ChatAnswer="chat/answer",e.ChatPartial="chat/partial",e.StreamDone="stream/done",e.StreamStarted="stream/started",e))(k||{}),R=(e=>(e.Unrated="Unrated",e.Positive="Positive",e.Negative="Negative",e))(R||{}),T=(e=>(e.KnowledgeProcessing="knowledge/processing",e.KnowledgeIndexing="knowledge/indexing",e.KnowledgeFailed="knowledge/error",e.KnowledgeDone="knowledge/done",e))(T||{}),b=(e=>(e.Knowledge="knowledge",e.Document="document",e.Record="record",e))(b||{}),z=(e=>(e.Pdf="pdf",e.Text="text",e.Html="html",e.Word="word",e.Json="json",e.Markdown="markdown",e.Csv="csv",e.Excel="excel",e.Powerpoint="powerpoint",e.Archive="archive",e.Image="image",e.Audio="audio",e.Video="video",e))(z||{}),$=(e=>(e.Clip="clip",e.Talk="talk",e))($||{});function x(e,i=f){const a=S(e,`${i}/chats/ratings`);return{create(t,n){return a.post("/",t,n)},getByKnowledge(t,n){return a.get(`/${t}`,n).then(r=>r??[])},update(t,n,r){return a.patch(`/${t}`,n,r)},delete(t,n){return a.delete(`/${t}`,n)}}}function U(e){return e.presenter.type===$.Clip?{videoType:$.Clip,driver_id:e.presenter.driver_id,presenter_id:e.presenter.presenter_id}:{videoType:$.Talk,source_url:e.presenter.source_url}}function q(e,i,a){return new Promise(async(t,n)=>{var g;const r=((g=i.callbacks)==null?void 0:g.onConnectionStateChange)??null;i.callbacks.onConnectionStateChange=async h=>{if(r&&r(h),h==="connected"){const m=await a.newChat(e.id);r&&d.onCallback("onConnectionStateChange",r),t({chat:m,streamingAPI:d})}else h==="failed"&&n(new Error("Cannot create connection"))};const d=await L(U(e),i)})}async function Q(e,i){const a=i.baseURL||f,t=new AbortController,n=I(i.auth,a),r=x(i.auth,a),d=await n.getById(e),g=await M(i.auth);return q(d,i,n).then(h=>{let{chat:m,streamingAPI:l}=h;return{agent:d,async reconnectToChat(){await q(d,i,n).then(o=>{m=o.chat,l=o.streamingAPI})},terminate(){return t.abort(),g.terminate(),l.terminate()},chatId:m.id,chat(o){return n.chat(e,m.id,{sessionId:l.sessionId,streamId:l.streamId,messages:o},{signal:t.signal})},rate(o,p){return p?r.update(p,o):r.create(o)},speak(o){if(!d)throw new Error("Agent not initializated");let p;return o.type==="text"?p={script:{type:"text",provider:o.provider,input:o.input,ssml:o.ssml||!1}}:o.type==="audio"&&(p={script:{type:"audio",audio_url:o.audio_url}}),l.speak(p)},onChatEvents(o){g.subscribeToEvents(o)},onConnectionEvents(o){l.onCallback("onConnectionStateChange",o)},onVideoEvents(o){l.onCallback("onVideoStateChange",o)}}})}function X(e,i){const a=S(e,i);return{createStream(t){return a.post("/clips/streams",{driver_id:t.driver_id,presenter_id:t.presenter_id,compatibility_mode:t.compatibility_mode})},startConnection(t,n,r){return a.post(`/clips/streams/${t}/sdp`,{session_id:r,answer:n})},addIceCandidate(t,n,r){return a.post(`/clips/streams/${t}/ice`,{session_id:r,...n})},sendStreamRequest(t,n,r){return a.post(`/clips/streams/${t}`,{session_id:n,...r})},close(t,n){return a.delete(`/clips/streams/${t}`,{session_id:n})}}}function Y(e,i){const a=S(e,i);return{createStream(t,n){return a.post("/talks/streams",{source_url:t.source_url,driver_url:t.driver_url,face:t.face,config:t.config},n)},startConnection(t,n,r,d){return a.post(`/talks/streams/${t}/sdp`,{session_id:r,answer:n},d)},addIceCandidate(t,n,r,d){return a.post(`/talks/streams/${t}/ice`,{session_id:r,...n},d)},sendStreamRequest(t,n,r,d){return a.post(`/talks/streams/${t}`,{session_id:n,...r},d)},close(t,n,r){return a.delete(`/talks/streams/${t}`,{session_id:n},r)}}}let B=!1;const C=(e,i)=>B&&console.log(e,i),Z=(window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection).bind(window);async function L(e,{debug:i=!1,callbacks:a,auth:t,baseURL:n=f}){B=i;const r={...a},{startConnection:d,sendStreamRequest:g,close:h,createStream:m,addIceCandidate:l}=e.videoType===$.Clip?X(t,n):Y(t,n),{id:o,offer:p,ice_servers:O,session_id:v}=await m(e),u=new Z({iceServers:O}),N=u.createDataChannel("JanusDataChannel");if(!v)throw new Error("Could not create session_id");u.onicecandidate=s=>{C("peerConnection.onicecandidate",s),s.candidate&&s.candidate.sdpMid&&s.candidate.sdpMLineIndex!==null&&l(o,{candidate:s.candidate.candidate,sdpMid:s.candidate.sdpMid,sdpMLineIndex:s.candidate.sdpMLineIndex},v)},u.oniceconnectionstatechange=()=>{var s;C("peerConnection.oniceconnectionstatechange => "+u.iceConnectionState),(s=r.onConnectionStateChange)==null||s.call(r,u.iceConnectionState)},u.ontrack=s=>{var w;C("peerConnection.ontrack",s),(w=r.onSrcObjectReady)==null||w.call(r,s.streams[0])},N.onmessage=s=>{var w,_,V;if(N.readyState==="open"){const[y,j]=s.data.split(":");y===k.StreamDone?(w=r.onVideoStateChange)==null||w.call(r,A.Stop):y===k.StreamStarted?(_=r.onVideoStateChange)==null||_.call(r,A.Start):(V=r.onMessage)==null||V.call(r,y,decodeURIComponent(j))}},await u.setRemoteDescription(p),C("set remote description OK");const J=await u.createAnswer();return C("create answer OK"),await u.setLocalDescription(J),C("set local description OK"),await d(o,J,v),C("start connection OK"),{speak(s){return g(o,v,s)},async terminate(){var s,w;o&&(u&&(u.close(),u.oniceconnectionstatechange=null,u.onnegotiationneeded=null,u.onicecandidate=null,u.ontrack=null),await h(o,v).catch(_=>{}),(s=r.onConnectionStateChange)==null||s.call(r,"closed"),(w=r.onVideoStateChange)==null||w.call(r,A.Stop))},sessionId:v,streamId:o,onCallback(s,w){r[s]=w},getCallbacks(){return r}}}c.DocumentType=z,c.KnowledgeType=b,c.Providers=K,c.RateState=R,c.SocketManager=M,c.StreamEvents=k,c.StreamingState=A,c.Subject=T,c.VideoType=$,c.VoiceAccess=E,c.createAgentManager=Q,c.createAgentsApi=I,c.createClient=S,c.createKnowledgeApi=D,c.createStreamingManager=L,c.getAgentStreamArgs=U,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Agent, AgentPayload, Auth, Chat, ChatPayload, ChatResponse } from '
|
|
1
|
+
import { Agent, AgentPayload, Auth, Chat, ChatPayload, ChatResponse } from '../../../types/index';
|
|
2
2
|
export declare function createAgentsApi(auth: Auth, host?: string): {
|
|
3
3
|
create(payload: AgentPayload, options?: RequestInit): Promise<Agent>;
|
|
4
4
|
getAgents(tag?: string, options?: RequestInit): Promise<Agent[]>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Auth, RtcApi } from '
|
|
1
|
+
import { Auth, RtcApi } from '../../../types/index';
|
|
2
2
|
export declare function createApi(auth: Auth, host: string): RtcApi;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Auth } from '
|
|
1
|
+
import { Auth } from '../../../types/auth';
|
|
2
2
|
export declare function createClient(auth: Auth, host?: string): {
|
|
3
3
|
get<T = any>(url: string, options?: RequestInit): Promise<T>;
|
|
4
4
|
post<T_1 = any>(url: string, body?: any, options?: RequestInit): Promise<T_1>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Auth, CreateDocumentPayload, DocumentData, KnowledgeData, KnowledgePayload, QueryResult, RecordData } from '
|
|
1
|
+
import { Auth, CreateDocumentPayload, DocumentData, KnowledgeData, KnowledgePayload, QueryResult, RecordData } from '../../../types/index';
|
|
2
2
|
export declare function createKnowledgeApi(auth: Auth, host?: string): {
|
|
3
3
|
createKnowledge(payload: KnowledgePayload, options?: RequestInit): Promise<KnowledgeData>;
|
|
4
4
|
getKnowledgeBase(options?: RequestInit): Promise<KnowledgeData[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Auth, RatingEntity, RatingPayload } from '../../
|
|
1
|
+
import { Auth, RatingEntity, RatingPayload } from '../../index';
|
|
2
2
|
export declare function createRatingsApi(auth: Auth, host?: string): {
|
|
3
3
|
create(payload: RatingPayload, options?: RequestInit): Promise<RatingEntity>;
|
|
4
4
|
getByKnowledge(knowledgeId?: string, options?: RequestInit): Promise<RatingEntity[]>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Auth, RtcApi } from '
|
|
1
|
+
import { Auth, RtcApi } from '../../../types/index';
|
|
2
2
|
export declare function createApi(auth: Auth, host: string): RtcApi;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Auth } from '
|
|
1
|
+
import { Auth } from '../../../types/auth';
|
|
2
2
|
export declare function getAuthHeader(auth: Auth): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Agent, AgentManagerOptions, AgentsManagerAPI, CreateStreamOptions } from '
|
|
1
|
+
import { Agent, AgentManagerOptions, AgentsManagerAPI, CreateStreamOptions } from '../../types/index';
|
|
2
2
|
export declare function getAgentStreamArgs(agent: Agent): CreateStreamOptions;
|
|
3
3
|
/**
|
|
4
4
|
* Creates a new Agent Manager instance for interacting with an agent, chat, and related connections.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CreateStreamOptions, ManagerCallbacks, PayloadType, StreamingManagerOptions } from '
|
|
1
|
+
import { CreateStreamOptions, ManagerCallbacks, PayloadType, StreamingManagerOptions } from '../../types/index';
|
|
2
2
|
export declare function createStreamingManager<T extends CreateStreamOptions>(agent: T, { debug, callbacks, auth, baseURL }: StreamingManagerOptions): Promise<{
|
|
3
3
|
/**
|
|
4
4
|
* Method to send request to server to get clip or talk depend on you payload
|
|
5
5
|
* @param payload
|
|
6
6
|
*/
|
|
7
|
-
speak(payload: PayloadType<T>): Promise<import('
|
|
7
|
+
speak(payload: PayloadType<T>): Promise<import('../../types/index').SendStreamPayloadResponse>;
|
|
8
8
|
/**
|
|
9
9
|
* Method to close RTC connection
|
|
10
10
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SupportedStreamScipt } from '
|
|
1
|
+
import { SupportedStreamScipt } from '../../StreamScript';
|
|
2
2
|
import { Auth } from '../../auth';
|
|
3
3
|
import { SendStreamPayloadResponse, StreamingState } from '../../stream';
|
|
4
4
|
import { Agent } from './agent';
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|