@d-id/client-sdk 1.1.29-staging.133 → 1.1.29-staging.136
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
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var fe = (e, t, a) =>
|
|
1
|
+
var Xe = Object.defineProperty;
|
|
2
|
+
var Ye = (e, t, a) => t in e ? Xe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
|
|
3
|
+
var fe = (e, t, a) => Ye(e, typeof t != "symbol" ? t + "" : t, a);
|
|
4
4
|
class we extends Error {
|
|
5
|
-
constructor({ kind: a, description: n, error:
|
|
5
|
+
constructor({ kind: a, description: n, error: s }) {
|
|
6
6
|
super(JSON.stringify({ kind: a, description: n }));
|
|
7
7
|
fe(this, "kind");
|
|
8
8
|
fe(this, "description");
|
|
9
9
|
fe(this, "error");
|
|
10
|
-
this.kind = a, this.description = n, this.error =
|
|
10
|
+
this.kind = a, this.description = n, this.error = s;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
class
|
|
13
|
+
class Ge extends we {
|
|
14
14
|
constructor(t, a) {
|
|
15
15
|
super({
|
|
16
16
|
kind: "ChatCreationFailed",
|
|
@@ -18,25 +18,25 @@ class Ye extends we {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
class
|
|
21
|
+
class Ze extends we {
|
|
22
22
|
constructor(t) {
|
|
23
23
|
super({ kind: "ChatModeDowngraded", description: `Chat mode downgraded to ${t}` });
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
class
|
|
26
|
+
class de extends we {
|
|
27
27
|
constructor(a, n) {
|
|
28
28
|
super({ kind: "ValidationError", description: a });
|
|
29
29
|
fe(this, "key");
|
|
30
30
|
this.key = n;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
class
|
|
33
|
+
class et extends we {
|
|
34
34
|
constructor(t) {
|
|
35
35
|
super({ kind: "WSError", description: t });
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
var
|
|
39
|
-
const
|
|
38
|
+
var tt = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(tt || {}), nt = /* @__PURE__ */ ((e) => (e.TRIAL = "deid-trial", e.PRO = "deid-pro", e.ENTERPRISE = "deid-enterprise", e.LITE = "deid-lite", e.ADVANCED = "deid-advanced", e.BUILD = "deid-api-build", e.LAUNCH = "deid-api-launch", e.SCALE = "deid-api-scale", e))(nt || {}), rt = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(rt || {}), it = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(it || {}), N = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(N || {}), Y = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(Y || {}), at = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(at || {}), ot = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(ot || {}), st = /* @__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))(st || {}), Je = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(Je || {});
|
|
39
|
+
const gn = (e) => {
|
|
40
40
|
switch (e) {
|
|
41
41
|
case "clip":
|
|
42
42
|
return "clip";
|
|
@@ -48,15 +48,15 @@ const mn = (e) => {
|
|
|
48
48
|
throw new Error(`Unknown video type: ${e}`);
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
var C = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(C || {}), re = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(re || {}),
|
|
52
|
-
const
|
|
51
|
+
var C = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(C || {}), re = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(re || {}), q = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e))(q || {}), j = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.ChatAudioTranscribed = "chat/audio-transcribed", e.StreamDone = "stream/done", e.StreamStarted = "stream/started", e.StreamFailed = "stream/error", e.StreamReady = "stream/ready", e.StreamCreated = "stream/created", e.StreamInterrupt = "stream/interrupt", e.StreamVideoCreated = "stream-video/started", e.StreamVideoDone = "stream-video/done", e.StreamVideoError = "stream-video/error", e.StreamVideoRejected = "stream-video/rejected", e))(j || {}), S = /* @__PURE__ */ ((e) => (e.New = "new", e.Fail = "fail", e.Connected = "connected", e.Connecting = "connecting", e.Closed = "closed", e.Completed = "completed", e.Disconnected = "disconnected", e))(S || {}), ae = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(ae || {}), ye = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(ye || {}), ct = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(ct || {}), dt = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(dt || {});
|
|
52
|
+
const ut = 45 * 1e3, lt = "X-Playground-Chat", ge = "https://api.d-id.com", ft = "wss://notifications.d-id.com", mt = "79f81a83a67430be2bc0fd61042b8faa", Ue = (e) => new Promise((t) => setTimeout(t, e)), ue = (e = 16) => {
|
|
53
53
|
const t = new Uint8Array(e);
|
|
54
54
|
return window.crypto.getRandomValues(t), Array.from(t, (a) => a.toString(16).padStart(2, "0")).join("").slice(0, 13);
|
|
55
|
-
},
|
|
56
|
-
function
|
|
55
|
+
}, We = (e) => e.type === "clip" && e.presenter_id.startsWith("v2_") ? "clip_v2" : e.type, Ie = (e) => e === Je.Expressive, gt = (e) => [N.TextOnly, N.Playground, N.Maintenance].includes(e), Ve = (e) => e && [N.DirectPlayback, N.Off].includes(e);
|
|
56
|
+
function ht(e, t) {
|
|
57
57
|
let a;
|
|
58
58
|
return {
|
|
59
|
-
promise: new Promise((
|
|
59
|
+
promise: new Promise((s, o) => {
|
|
60
60
|
a = setTimeout(() => o(new Error(t)), e);
|
|
61
61
|
}),
|
|
62
62
|
clear: () => clearTimeout(a)
|
|
@@ -73,16 +73,16 @@ async function Ce(e, t) {
|
|
|
73
73
|
})
|
|
74
74
|
};
|
|
75
75
|
let n;
|
|
76
|
-
for (let
|
|
76
|
+
for (let s = 1; s <= a.limit; s++)
|
|
77
77
|
try {
|
|
78
78
|
if (!a.timeout)
|
|
79
79
|
return await e();
|
|
80
|
-
const { promise: o, clear:
|
|
80
|
+
const { promise: o, clear: c } = ht(a.timeout, a.timeoutErrorMessage), i = e().finally(c);
|
|
81
81
|
return await Promise.race([i, o]);
|
|
82
82
|
} catch (o) {
|
|
83
|
-
if (n = o, !a.shouldRetryFn(o) ||
|
|
83
|
+
if (n = o, !a.shouldRetryFn(o) || s >= a.limit)
|
|
84
84
|
throw o;
|
|
85
|
-
await
|
|
85
|
+
await Ue(a.delayMs), a.onRetry(o);
|
|
86
86
|
}
|
|
87
87
|
throw n;
|
|
88
88
|
}
|
|
@@ -91,30 +91,30 @@ function ke(e) {
|
|
|
91
91
|
return window.localStorage.setItem("did_external_key_id", e), e;
|
|
92
92
|
let t = window.localStorage.getItem("did_external_key_id");
|
|
93
93
|
if (!t) {
|
|
94
|
-
let a =
|
|
94
|
+
let a = ue();
|
|
95
95
|
window.localStorage.setItem("did_external_key_id", a), t = a;
|
|
96
96
|
}
|
|
97
97
|
return t;
|
|
98
98
|
}
|
|
99
|
-
let
|
|
99
|
+
let pt = ue();
|
|
100
100
|
function Oe(e, t) {
|
|
101
101
|
if (e.type === "bearer")
|
|
102
102
|
return `Bearer ${e.token}`;
|
|
103
103
|
if (e.type === "basic")
|
|
104
104
|
return `Basic ${btoa(`${e.username}:${e.password}`)}`;
|
|
105
105
|
if (e.type === "key")
|
|
106
|
-
return `Client-Key ${e.clientKey}.${ke(t)}_${
|
|
106
|
+
return `Client-Key ${e.clientKey}.${ke(t)}_${pt}`;
|
|
107
107
|
throw new Error(`Unknown auth type: ${e}`);
|
|
108
108
|
}
|
|
109
|
-
const
|
|
109
|
+
const wt = (e) => Ce(e, {
|
|
110
110
|
limit: 3,
|
|
111
111
|
delayMs: 1e3,
|
|
112
112
|
timeout: 0,
|
|
113
113
|
shouldRetryFn: (t) => t.status === 429
|
|
114
114
|
});
|
|
115
115
|
function Te(e, t = ge, a, n) {
|
|
116
|
-
const
|
|
117
|
-
const { skipErrorHandler: i, ...r } =
|
|
116
|
+
const s = async (o, c) => {
|
|
117
|
+
const { skipErrorHandler: i, ...r } = c || {}, d = await wt(
|
|
118
118
|
() => fetch(t + (o != null && o.startsWith("/") ? o : `/${o}`), {
|
|
119
119
|
...r,
|
|
120
120
|
headers: {
|
|
@@ -125,67 +125,67 @@ function Te(e, t = ge, a, n) {
|
|
|
125
125
|
})
|
|
126
126
|
);
|
|
127
127
|
if (!d.ok) {
|
|
128
|
-
let
|
|
129
|
-
const
|
|
130
|
-
throw a && !i && a(
|
|
128
|
+
let w = await d.text().catch(() => `Failed to fetch with status ${d.status}`);
|
|
129
|
+
const p = new Error(w);
|
|
130
|
+
throw a && !i && a(p, { url: o, options: r, headers: d.headers }), p;
|
|
131
131
|
}
|
|
132
132
|
return d.json();
|
|
133
133
|
};
|
|
134
134
|
return {
|
|
135
|
-
get(o,
|
|
136
|
-
return
|
|
135
|
+
get(o, c) {
|
|
136
|
+
return s(o, { ...c, method: "GET" });
|
|
137
137
|
},
|
|
138
|
-
post(o,
|
|
139
|
-
return
|
|
138
|
+
post(o, c, i) {
|
|
139
|
+
return s(o, { ...i, body: JSON.stringify(c), method: "POST" });
|
|
140
140
|
},
|
|
141
|
-
delete(o,
|
|
142
|
-
return
|
|
141
|
+
delete(o, c, i) {
|
|
142
|
+
return s(o, { ...i, body: JSON.stringify(c), method: "DELETE" });
|
|
143
143
|
},
|
|
144
|
-
patch(o,
|
|
145
|
-
return
|
|
144
|
+
patch(o, c, i) {
|
|
145
|
+
return s(o, { ...i, body: JSON.stringify(c), method: "PATCH" });
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
|
-
function
|
|
150
|
-
const
|
|
149
|
+
function yt(e, t = ge, a, n) {
|
|
150
|
+
const s = Te(e, `${t}/agents`, a, n);
|
|
151
151
|
return {
|
|
152
|
-
create(o,
|
|
153
|
-
return
|
|
152
|
+
create(o, c) {
|
|
153
|
+
return s.post("/", o, c);
|
|
154
154
|
},
|
|
155
|
-
getAgents(o,
|
|
156
|
-
return
|
|
155
|
+
getAgents(o, c) {
|
|
156
|
+
return s.get(`/${o ? `?tag=${o}` : ""}`, c).then((i) => i ?? []);
|
|
157
157
|
},
|
|
158
|
-
getById(o,
|
|
159
|
-
return
|
|
158
|
+
getById(o, c) {
|
|
159
|
+
return s.get(`/${o}`, c);
|
|
160
160
|
},
|
|
161
|
-
delete(o,
|
|
162
|
-
return
|
|
161
|
+
delete(o, c) {
|
|
162
|
+
return s.delete(`/${o}`, void 0, c);
|
|
163
163
|
},
|
|
164
|
-
update(o,
|
|
165
|
-
return
|
|
164
|
+
update(o, c, i) {
|
|
165
|
+
return s.patch(`/${o}`, c, i);
|
|
166
166
|
},
|
|
167
|
-
newChat(o,
|
|
168
|
-
return
|
|
167
|
+
newChat(o, c, i) {
|
|
168
|
+
return s.post(`/${o}/chat`, c, i);
|
|
169
169
|
},
|
|
170
|
-
chat(o,
|
|
171
|
-
return
|
|
170
|
+
chat(o, c, i, r) {
|
|
171
|
+
return s.post(`/${o}/chat/${c}`, i, r);
|
|
172
172
|
},
|
|
173
|
-
createRating(o,
|
|
174
|
-
return
|
|
173
|
+
createRating(o, c, i, r) {
|
|
174
|
+
return s.post(`/${o}/chat/${c}/ratings`, i, r);
|
|
175
175
|
},
|
|
176
|
-
updateRating(o,
|
|
177
|
-
return
|
|
176
|
+
updateRating(o, c, i, r, d) {
|
|
177
|
+
return s.patch(`/${o}/chat/${c}/ratings/${i}`, r, d);
|
|
178
178
|
},
|
|
179
|
-
deleteRating(o,
|
|
180
|
-
return
|
|
179
|
+
deleteRating(o, c, i, r) {
|
|
180
|
+
return s.delete(`/${o}/chat/${c}/ratings/${i}`, r);
|
|
181
181
|
},
|
|
182
|
-
getSTTToken(o,
|
|
183
|
-
return
|
|
182
|
+
getSTTToken(o, c) {
|
|
183
|
+
return s.get(`/${o}/stt-token`, c);
|
|
184
184
|
}
|
|
185
185
|
};
|
|
186
186
|
}
|
|
187
|
-
function
|
|
188
|
-
var
|
|
187
|
+
function vt(e) {
|
|
188
|
+
var s, o, c, i;
|
|
189
189
|
const t = () => /Mobi|Android/i.test(navigator.userAgent) ? "Mobile" : "Desktop", a = () => {
|
|
190
190
|
const r = navigator.platform;
|
|
191
191
|
return r.toLowerCase().includes("win") ? "Windows" : r.toLowerCase().includes("mac") ? "Mac OS X" : r.toLowerCase().includes("linux") ? "Linux" : "Unknown";
|
|
@@ -195,28 +195,28 @@ function yt(e) {
|
|
|
195
195
|
isMobile: `${t() == "Mobile"}`,
|
|
196
196
|
browser: navigator.userAgent,
|
|
197
197
|
origin: window.location.origin,
|
|
198
|
-
agentType:
|
|
198
|
+
agentType: We(n),
|
|
199
199
|
agentVoice: {
|
|
200
|
-
voiceId: (o = (
|
|
201
|
-
provider: (i = (
|
|
200
|
+
voiceId: (o = (s = e.presenter) == null ? void 0 : s.voice) == null ? void 0 : o.voice_id,
|
|
201
|
+
provider: (i = (c = e.presenter) == null ? void 0 : c.voice) == null ? void 0 : i.type
|
|
202
202
|
}
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
|
-
function
|
|
206
|
-
var a, n,
|
|
205
|
+
function St(e) {
|
|
206
|
+
var a, n, s, o, c, i;
|
|
207
207
|
const t = (a = e.llm) == null ? void 0 : a.prompt_customization;
|
|
208
208
|
return {
|
|
209
|
-
agentType:
|
|
209
|
+
agentType: We(e.presenter),
|
|
210
210
|
owner_id: e.owner_id ?? "",
|
|
211
211
|
promptVersion: (n = e.llm) == null ? void 0 : n.prompt_version,
|
|
212
212
|
behavior: {
|
|
213
213
|
role: t == null ? void 0 : t.role,
|
|
214
214
|
personality: t == null ? void 0 : t.personality,
|
|
215
|
-
instructions: (
|
|
215
|
+
instructions: (s = e.llm) == null ? void 0 : s.instructions
|
|
216
216
|
},
|
|
217
217
|
temperature: (o = e.llm) == null ? void 0 : o.temperature,
|
|
218
218
|
knowledgeSource: t == null ? void 0 : t.knowledge_source,
|
|
219
|
-
starterQuestionsCount: (i = (
|
|
219
|
+
starterQuestionsCount: (i = (c = e.knowledge) == null ? void 0 : c.starter_message) == null ? void 0 : i.length,
|
|
220
220
|
topicsToAvoid: t == null ? void 0 : t.topics_to_avoid,
|
|
221
221
|
maxResponseLength: t == null ? void 0 : t.max_response_length,
|
|
222
222
|
agentId: e.id,
|
|
@@ -225,24 +225,24 @@ function vt(e) {
|
|
|
225
225
|
...e.access === "public" ? { from: "agent-template" } : {}
|
|
226
226
|
};
|
|
227
227
|
}
|
|
228
|
-
const
|
|
229
|
-
function
|
|
230
|
-
var r, d,
|
|
231
|
-
const { event: n, ...
|
|
228
|
+
const Ct = (e) => e.reduce((t, a) => t + a, 0), xe = (e) => Ct(e) / e.length;
|
|
229
|
+
function kt(e, t, a) {
|
|
230
|
+
var r, d, w;
|
|
231
|
+
const { event: n, ...s } = e, { template: o } = (t == null ? void 0 : t.llm) || {}, { language: c } = ((r = t == null ? void 0 : t.presenter) == null ? void 0 : r.voice) || {};
|
|
232
232
|
return {
|
|
233
|
-
...
|
|
234
|
-
llm: { ...
|
|
235
|
-
script: { ...
|
|
236
|
-
stitch: (t == null ? void 0 : t.presenter.type) === "talk" ? (
|
|
233
|
+
...s,
|
|
234
|
+
llm: { ...s.llm, template: o },
|
|
235
|
+
script: { ...s.script, provider: { ...(d = s == null ? void 0 : s.script) == null ? void 0 : d.provider, language: c } },
|
|
236
|
+
stitch: (t == null ? void 0 : t.presenter.type) === "talk" ? (w = t == null ? void 0 : t.presenter) == null ? void 0 : w.stitch : void 0,
|
|
237
237
|
...a
|
|
238
238
|
};
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function Be(e) {
|
|
241
241
|
"requestIdleCallback" in window ? requestIdleCallback(e, { timeout: 2e3 }) : setTimeout(e, 0);
|
|
242
242
|
}
|
|
243
243
|
let ve = {};
|
|
244
|
-
const
|
|
245
|
-
function
|
|
244
|
+
const Rt = "https://api-js.mixpanel.com/track/?verbose=1&ip=1";
|
|
245
|
+
function Dt(e) {
|
|
246
246
|
const t = window != null && window.hasOwnProperty("DID_AGENTS_API") ? "agents-ui" : "agents-sdk";
|
|
247
247
|
return {
|
|
248
248
|
token: e.token || "testKey",
|
|
@@ -253,14 +253,14 @@ function Rt(e) {
|
|
|
253
253
|
...e.mixpanelAdditionalProperties || {}
|
|
254
254
|
},
|
|
255
255
|
isEnabled: e.isEnabled ?? !0,
|
|
256
|
-
getRandom:
|
|
256
|
+
getRandom: ue,
|
|
257
257
|
enrich(a) {
|
|
258
258
|
this.additionalProperties = { ...this.additionalProperties, ...a };
|
|
259
259
|
},
|
|
260
|
-
async track(a, n,
|
|
260
|
+
async track(a, n, s) {
|
|
261
261
|
if (!this.isEnabled)
|
|
262
262
|
return Promise.resolve();
|
|
263
|
-
const { audioPath: o, ...
|
|
263
|
+
const { audioPath: o, ...c } = n || {}, i = s || Date.now(), r = {
|
|
264
264
|
method: "POST",
|
|
265
265
|
headers: {
|
|
266
266
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -271,7 +271,7 @@ function Rt(e) {
|
|
|
271
271
|
event: a,
|
|
272
272
|
properties: {
|
|
273
273
|
...this.additionalProperties,
|
|
274
|
-
...
|
|
274
|
+
...c,
|
|
275
275
|
agentId: this.agentId,
|
|
276
276
|
source: t,
|
|
277
277
|
token: this.token,
|
|
@@ -286,22 +286,22 @@ function Rt(e) {
|
|
|
286
286
|
])
|
|
287
287
|
})
|
|
288
288
|
};
|
|
289
|
-
return fetch(
|
|
289
|
+
return fetch(Rt, {
|
|
290
290
|
...r,
|
|
291
291
|
keepalive: !0
|
|
292
292
|
}).catch((d) => console.error("Analytics tracking error:", d)), Promise.resolve();
|
|
293
293
|
},
|
|
294
|
-
linkTrack(a, n,
|
|
295
|
-
ve[a] || (ve[a] = { events: {}, resolvedDependencies: [] }), o.includes(
|
|
296
|
-
const
|
|
297
|
-
if (
|
|
298
|
-
(r) =>
|
|
294
|
+
linkTrack(a, n, s, o) {
|
|
295
|
+
ve[a] || (ve[a] = { events: {}, resolvedDependencies: [] }), o.includes(s) || o.push(s);
|
|
296
|
+
const c = ve[a];
|
|
297
|
+
if (c.events[s] = { props: n }, c.resolvedDependencies.push(s), o.every(
|
|
298
|
+
(r) => c.resolvedDependencies.includes(r)
|
|
299
299
|
)) {
|
|
300
|
-
const r = o.reduce((d,
|
|
301
|
-
this.track(a, r),
|
|
300
|
+
const r = o.reduce((d, w) => c.events[w] ? { ...d, ...c.events[w].props } : d, {});
|
|
301
|
+
this.track(a, r), c.resolvedDependencies = c.resolvedDependencies.filter(
|
|
302
302
|
(d) => !o.includes(d)
|
|
303
303
|
), o.forEach((d) => {
|
|
304
|
-
delete
|
|
304
|
+
delete c.events[d];
|
|
305
305
|
});
|
|
306
306
|
}
|
|
307
307
|
}
|
|
@@ -315,22 +315,22 @@ function _e() {
|
|
|
315
315
|
get: (t = !1) => t ? Date.now() - e : e
|
|
316
316
|
};
|
|
317
317
|
}
|
|
318
|
-
const ie = _e(), Re = _e(),
|
|
319
|
-
function
|
|
320
|
-
return e ===
|
|
318
|
+
const ie = _e(), Re = _e(), Fe = _e();
|
|
319
|
+
function qe(e) {
|
|
320
|
+
return e === N.Playground ? { headers: { [lt]: "true" } } : {};
|
|
321
321
|
}
|
|
322
|
-
async function
|
|
322
|
+
async function He(e, t, a, n, s = !1, o) {
|
|
323
323
|
try {
|
|
324
|
-
return !o && !
|
|
324
|
+
return !o && !Ve(n) && (o = await t.newChat(e.id, { persist: s }, qe(n)), a.track("agent-chat", {
|
|
325
325
|
event: "created",
|
|
326
326
|
chatId: o.id,
|
|
327
327
|
mode: n
|
|
328
328
|
})), { chat: o, chatMode: (o == null ? void 0 : o.chat_mode) ?? n };
|
|
329
|
-
} catch (
|
|
330
|
-
throw
|
|
329
|
+
} catch (c) {
|
|
330
|
+
throw Mt(c) === "InsufficientCreditsError" ? new Error("InsufficientCreditsError") : new Error("Cannot create new chat");
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
|
-
const
|
|
333
|
+
const Mt = (e) => {
|
|
334
334
|
try {
|
|
335
335
|
const t = JSON.parse(e.message);
|
|
336
336
|
return t == null ? void 0 : t.kind;
|
|
@@ -338,18 +338,18 @@ const Dt = (e) => {
|
|
|
338
338
|
return "UnknownError";
|
|
339
339
|
}
|
|
340
340
|
};
|
|
341
|
-
function
|
|
341
|
+
function Et(e) {
|
|
342
342
|
return e && e.length > 0 ? e : [];
|
|
343
343
|
}
|
|
344
|
-
function
|
|
345
|
-
const
|
|
344
|
+
function It(e, t, a, n) {
|
|
345
|
+
const s = Te(e, `${t}/v2/agents/${a}`, n);
|
|
346
346
|
return {
|
|
347
347
|
async createStream(o) {
|
|
348
|
-
return
|
|
348
|
+
return s.post("/sessions", o);
|
|
349
349
|
}
|
|
350
350
|
};
|
|
351
351
|
}
|
|
352
|
-
const
|
|
352
|
+
const Qe = (e, t) => (a, n) => e && console.log(`[${t}] ${a}`, n ?? "");
|
|
353
353
|
async function Se() {
|
|
354
354
|
try {
|
|
355
355
|
return await import("./livekit-client.esm-C1GRQdZY.js");
|
|
@@ -359,7 +359,7 @@ async function Se() {
|
|
|
359
359
|
);
|
|
360
360
|
}
|
|
361
361
|
}
|
|
362
|
-
const
|
|
362
|
+
const Tt = {
|
|
363
363
|
excellent: re.Strong,
|
|
364
364
|
good: re.Strong,
|
|
365
365
|
poor: re.Weak,
|
|
@@ -371,263 +371,263 @@ const It = {
|
|
|
371
371
|
});
|
|
372
372
|
var Ae = /* @__PURE__ */ ((e) => (e.Chat = "lk.chat", e.Speak = "did.speak", e.Interrupt = "did.interrupt", e))(Ae || {});
|
|
373
373
|
function De(e, t, a, n) {
|
|
374
|
-
var
|
|
375
|
-
throw t("Failed to connect to LiveKit room:", e), n(), (
|
|
374
|
+
var s, o;
|
|
375
|
+
throw t("Failed to connect to LiveKit room:", e), n(), (s = a.onConnectionStateChange) == null || s.call(a, S.Fail), (o = a.onError) == null || o.call(a, e, { sessionId: "" }), e;
|
|
376
376
|
}
|
|
377
|
-
async function
|
|
378
|
-
var Pe,
|
|
379
|
-
const n =
|
|
380
|
-
let u = null,
|
|
377
|
+
async function _t(e, t, a) {
|
|
378
|
+
var Pe, be;
|
|
379
|
+
const n = Qe(a.debug || !1, "LiveKitStreamingManager"), { Room: s, RoomEvent: o, ConnectionState: c } = await Se(), { callbacks: i, auth: r, baseURL: d, analytics: w, microphoneStream: p } = a;
|
|
380
|
+
let u = null, P = !1;
|
|
381
381
|
const $ = ae.Fluent;
|
|
382
|
-
let
|
|
383
|
-
u = new
|
|
382
|
+
let B = !0, R = null, M = null;
|
|
383
|
+
u = new s({
|
|
384
384
|
adaptiveStream: !1,
|
|
385
385
|
// Must be false to use mediaStreamTrack directly
|
|
386
386
|
dynacast: !0
|
|
387
387
|
});
|
|
388
388
|
let z = null;
|
|
389
|
-
const
|
|
390
|
-
let W =
|
|
391
|
-
const ee =
|
|
392
|
-
let
|
|
389
|
+
const T = 2e4;
|
|
390
|
+
let W = q.Idle;
|
|
391
|
+
const ee = It(r, d || ge, e, i.onError);
|
|
392
|
+
let E, G, Z;
|
|
393
393
|
try {
|
|
394
394
|
const l = await ee.createStream({
|
|
395
395
|
transport_provider: ye.Livekit,
|
|
396
396
|
chat_persist: t.chat_persist ?? !0
|
|
397
|
-
}), { id:
|
|
398
|
-
(Pe = i.onStreamCreated) == null || Pe.call(i, { session_id:
|
|
397
|
+
}), { id: g, session_token: v, session_url: D } = l;
|
|
398
|
+
(Pe = i.onStreamCreated) == null || Pe.call(i, { session_id: g, stream_id: g, agent_id: e }), E = g, G = v, Z = D, await u.prepareConnection(Z, G);
|
|
399
399
|
} catch (l) {
|
|
400
400
|
De(l, n, i, () => {
|
|
401
|
-
|
|
401
|
+
B = !1;
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
|
-
if (!Z || !G || !
|
|
404
|
+
if (!Z || !G || !E)
|
|
405
405
|
return Promise.reject(new Error("Failed to initialize LiveKit stream"));
|
|
406
|
-
u.on(o.ConnectionStateChanged, y).on(o.ConnectionQualityChanged, k).on(o.ActiveSpeakersChanged,
|
|
407
|
-
function f(l,
|
|
406
|
+
u.on(o.ConnectionStateChanged, y).on(o.ConnectionQualityChanged, k).on(o.ActiveSpeakersChanged, _).on(o.ParticipantConnected, b).on(o.ParticipantDisconnected, I).on(o.TrackSubscribed, U).on(o.TrackUnsubscribed, H).on(o.DataReceived, Q).on(o.MediaDevicesError, L).on(o.TranscriptionReceived, f).on(o.EncryptionError, K).on(o.TrackSubscriptionFailed, X), (be = i.onConnectionStateChange) == null || be.call(i, S.New);
|
|
407
|
+
function f(l, g) {
|
|
408
408
|
var v;
|
|
409
|
-
|
|
409
|
+
g != null && g.isLocal && W === q.Talking && ((v = i.onInterruptDetected) == null || v.call(i, { type: "audio" }), W = q.Idle);
|
|
410
410
|
}
|
|
411
411
|
try {
|
|
412
412
|
await u.connect(Z, G), n("LiveKit room joined successfully"), z = setTimeout(() => {
|
|
413
413
|
var l;
|
|
414
|
-
n("Track subscription timeout - no track subscribed within 30 seconds after connect"), z = null,
|
|
414
|
+
n("Track subscription timeout - no track subscribed within 30 seconds after connect"), z = null, w.track("connectivity-error", {
|
|
415
415
|
error: "Track subscription timeout",
|
|
416
|
-
sessionId:
|
|
417
|
-
}), (l = i.onError) == null || l.call(i, new Error("Track subscription timeout"), { sessionId:
|
|
418
|
-
},
|
|
416
|
+
sessionId: E
|
|
417
|
+
}), (l = i.onError) == null || l.call(i, new Error("Track subscription timeout"), { sessionId: E }), se();
|
|
418
|
+
}, T), B = !1;
|
|
419
419
|
} catch (l) {
|
|
420
420
|
De(l, n, i, () => {
|
|
421
|
-
|
|
421
|
+
B = !1;
|
|
422
422
|
});
|
|
423
423
|
}
|
|
424
|
-
|
|
424
|
+
w.enrich({
|
|
425
425
|
"stream-type": $
|
|
426
426
|
});
|
|
427
427
|
function y(l) {
|
|
428
|
-
var
|
|
428
|
+
var g, v, D, A, O;
|
|
429
429
|
switch (n("Connection state changed:", l), l) {
|
|
430
|
-
case
|
|
431
|
-
(
|
|
430
|
+
case c.Connecting:
|
|
431
|
+
(g = i.onConnectionStateChange) == null || g.call(i, S.Connecting);
|
|
432
432
|
break;
|
|
433
|
-
case
|
|
434
|
-
n("LiveKit room connected successfully"),
|
|
433
|
+
case c.Connected:
|
|
434
|
+
n("LiveKit room connected successfully"), P = !0, B ? queueMicrotask(() => {
|
|
435
435
|
var x;
|
|
436
436
|
(x = i.onConnectionStateChange) == null || x.call(i, S.Connected);
|
|
437
437
|
}) : (v = i.onConnectionStateChange) == null || v.call(i, S.Connected);
|
|
438
438
|
break;
|
|
439
|
-
case
|
|
440
|
-
n("LiveKit room disconnected"),
|
|
439
|
+
case c.Disconnected:
|
|
440
|
+
n("LiveKit room disconnected"), P = !1, (D = i.onConnectionStateChange) == null || D.call(i, S.Disconnected);
|
|
441
441
|
break;
|
|
442
|
-
case
|
|
443
|
-
n("LiveKit room reconnecting..."), (
|
|
442
|
+
case c.Reconnecting:
|
|
443
|
+
n("LiveKit room reconnecting..."), (A = i.onConnectionStateChange) == null || A.call(i, S.Connecting);
|
|
444
444
|
break;
|
|
445
|
-
case
|
|
446
|
-
n("LiveKit room signal reconnecting..."), (
|
|
445
|
+
case c.SignalReconnecting:
|
|
446
|
+
n("LiveKit room signal reconnecting..."), (O = i.onConnectionStateChange) == null || O.call(i, S.Connecting);
|
|
447
447
|
break;
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
|
-
function k(l,
|
|
450
|
+
function k(l, g) {
|
|
451
451
|
var v;
|
|
452
|
-
n("Connection quality:", l),
|
|
452
|
+
n("Connection quality:", l), g != null && g.isLocal && ((v = i.onConnectivityStateChange) == null || v.call(i, Tt[l]));
|
|
453
453
|
}
|
|
454
|
-
function
|
|
455
|
-
|
|
456
|
-
n("Active speakers changed:", l), l.find((D) => !D.isLocal) ? (W = U.Talking, (v = i.onAgentActivityStateChange) == null || v.call(i, U.Talking)) : ((R = i.onAgentActivityStateChange) == null || R.call(i, U.Idle), W = U.Idle);
|
|
454
|
+
function _(l) {
|
|
455
|
+
n("Active speakers changed:", l);
|
|
457
456
|
}
|
|
458
|
-
function
|
|
457
|
+
function b(l) {
|
|
459
458
|
n("Participant connected:", l.identity);
|
|
460
459
|
}
|
|
461
|
-
function
|
|
460
|
+
function I(l) {
|
|
462
461
|
n("Participant disconnected:", l.identity), se();
|
|
463
462
|
}
|
|
464
|
-
function
|
|
465
|
-
var
|
|
463
|
+
function U(l, g, v) {
|
|
464
|
+
var A, O, x;
|
|
466
465
|
n(`Track subscribed: ${l.kind} from ${v.identity}`), z && (clearTimeout(z), z = null, n("Track subscription timeout cleared"));
|
|
467
|
-
const
|
|
468
|
-
if (!
|
|
466
|
+
const D = l.mediaStreamTrack;
|
|
467
|
+
if (!D) {
|
|
469
468
|
n(`No mediaStreamTrack available for ${l.kind}`);
|
|
470
469
|
return;
|
|
471
470
|
}
|
|
472
|
-
|
|
471
|
+
R ? (R.addTrack(D), n(`Added ${l.kind} track to shared MediaStream`)) : (R = new MediaStream([D]), n(`Created shared MediaStream with ${l.kind} track`)), l.kind === "video" && ((A = i.onStreamReady) == null || A.call(i), (O = i.onSrcObjectReady) == null || O.call(i, R), (x = i.onVideoStateChange) == null || x.call(i, C.Start));
|
|
473
472
|
}
|
|
474
|
-
function H(l,
|
|
475
|
-
var
|
|
476
|
-
n(`Track unsubscribed: ${l.kind} from ${v.identity}`), l.kind === "video" && ((
|
|
473
|
+
function H(l, g, v) {
|
|
474
|
+
var D;
|
|
475
|
+
n(`Track unsubscribed: ${l.kind} from ${v.identity}`), l.kind === "video" && ((D = i.onVideoStateChange) == null || D.call(i, C.Stop));
|
|
477
476
|
}
|
|
478
|
-
function Q(l,
|
|
479
|
-
var
|
|
480
|
-
const
|
|
481
|
-
n("Data received:",
|
|
477
|
+
function Q(l, g, v, D) {
|
|
478
|
+
var O, x, le, Le, je;
|
|
479
|
+
const A = new TextDecoder().decode(l);
|
|
480
|
+
n("Data received:", A);
|
|
482
481
|
try {
|
|
483
|
-
const te = JSON.parse(
|
|
484
|
-
if (
|
|
482
|
+
const te = JSON.parse(A), ce = D || te.subject;
|
|
483
|
+
if (ce === j.ChatAnswer) {
|
|
485
484
|
const ne = Y.Answer;
|
|
486
|
-
(
|
|
485
|
+
(O = i.onMessage) == null || O.call(i, ne, {
|
|
487
486
|
event: ne,
|
|
488
487
|
...te
|
|
489
488
|
});
|
|
490
|
-
} else if (
|
|
489
|
+
} else if (ce === j.ChatPartial) {
|
|
491
490
|
const ne = Y.Partial;
|
|
492
491
|
(x = i.onMessage) == null || x.call(i, ne, {
|
|
493
492
|
event: ne,
|
|
494
493
|
...te
|
|
495
494
|
});
|
|
496
|
-
} else if ([j.StreamVideoCreated, j.StreamVideoDone].includes(
|
|
497
|
-
|
|
498
|
-
|
|
495
|
+
} else if ([j.StreamVideoCreated, j.StreamVideoDone].includes(ce)) {
|
|
496
|
+
W = ce === j.StreamVideoCreated ? q.Talking : q.Idle, (le = i.onAgentActivityStateChange) == null || le.call(i, W);
|
|
497
|
+
const ne = (te == null ? void 0 : te.role) || (g == null ? void 0 : g.identity) || "datachannel";
|
|
498
|
+
(Le = i.onMessage) == null || Le.call(i, ce, {
|
|
499
499
|
[ne]: te
|
|
500
500
|
});
|
|
501
|
-
} else if (
|
|
501
|
+
} else if (ce === j.ChatAudioTranscribed) {
|
|
502
502
|
const ne = Y.Transcribe;
|
|
503
|
-
(
|
|
503
|
+
(je = i.onMessage) == null || je.call(i, ne, {
|
|
504
504
|
event: ne,
|
|
505
505
|
...te
|
|
506
506
|
}), queueMicrotask(() => {
|
|
507
|
-
var
|
|
508
|
-
(
|
|
507
|
+
var $e;
|
|
508
|
+
($e = i.onAgentActivityStateChange) == null || $e.call(i, q.Loading);
|
|
509
509
|
});
|
|
510
510
|
}
|
|
511
511
|
} catch (te) {
|
|
512
512
|
n("Failed to parse data channel message:", te);
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
|
-
function
|
|
516
|
-
var
|
|
517
|
-
n("Media devices error:", l), (
|
|
515
|
+
function L(l) {
|
|
516
|
+
var g;
|
|
517
|
+
n("Media devices error:", l), (g = i.onError) == null || g.call(i, new Error(me), { sessionId: E });
|
|
518
518
|
}
|
|
519
|
-
function
|
|
520
|
-
var
|
|
521
|
-
n("Encryption error:", l), (
|
|
519
|
+
function K(l) {
|
|
520
|
+
var g;
|
|
521
|
+
n("Encryption error:", l), (g = i.onError) == null || g.call(i, new Error(me), { sessionId: E });
|
|
522
522
|
}
|
|
523
|
-
function X(l,
|
|
524
|
-
n("Track subscription failed:", { trackSid: l, participant:
|
|
523
|
+
function X(l, g, v) {
|
|
524
|
+
n("Track subscription failed:", { trackSid: l, participant: g, reason: v });
|
|
525
525
|
}
|
|
526
526
|
async function oe(l) {
|
|
527
527
|
if (!u) return null;
|
|
528
|
-
const { Track:
|
|
528
|
+
const { Track: g } = await Se(), v = u.localParticipant.audioTrackPublications;
|
|
529
529
|
if (v) {
|
|
530
|
-
for (const [
|
|
531
|
-
if (
|
|
532
|
-
const x =
|
|
530
|
+
for (const [D, A] of v)
|
|
531
|
+
if (A.source === g.Source.Microphone && A.track) {
|
|
532
|
+
const x = A.track.mediaStreamTrack;
|
|
533
533
|
if (x === l || x && x.id === l.id)
|
|
534
|
-
return
|
|
534
|
+
return A;
|
|
535
535
|
}
|
|
536
536
|
}
|
|
537
537
|
return null;
|
|
538
538
|
}
|
|
539
|
-
function
|
|
540
|
-
if (!
|
|
539
|
+
function V(l) {
|
|
540
|
+
if (!M || !M.track)
|
|
541
541
|
return !1;
|
|
542
|
-
const
|
|
543
|
-
return
|
|
542
|
+
const g = M.track.mediaStreamTrack;
|
|
543
|
+
return g !== l && (g == null ? void 0 : g.id) !== l.id;
|
|
544
544
|
}
|
|
545
545
|
async function m(l) {
|
|
546
|
-
var
|
|
547
|
-
if (!
|
|
546
|
+
var O, x;
|
|
547
|
+
if (!P || !u)
|
|
548
548
|
throw n("Room is not connected, cannot publish microphone stream"), new Error("Room is not connected");
|
|
549
|
-
const
|
|
550
|
-
if (
|
|
549
|
+
const g = l.getAudioTracks();
|
|
550
|
+
if (g.length === 0) {
|
|
551
551
|
n("No audio track found in the provided MediaStream");
|
|
552
552
|
return;
|
|
553
553
|
}
|
|
554
|
-
const v =
|
|
555
|
-
if (
|
|
554
|
+
const v = g[0], { Track: D } = await Se(), A = await oe(v);
|
|
555
|
+
if (A) {
|
|
556
556
|
n("Microphone track is already published, skipping", {
|
|
557
557
|
trackId: v.id,
|
|
558
|
-
publishedTrackId: (x = (
|
|
559
|
-
}),
|
|
558
|
+
publishedTrackId: (x = (O = A.track) == null ? void 0 : O.mediaStreamTrack) == null ? void 0 : x.id
|
|
559
|
+
}), M = A;
|
|
560
560
|
return;
|
|
561
561
|
}
|
|
562
|
-
|
|
562
|
+
V(v) && (n("Unpublishing existing microphone track before publishing new one"), await h()), n("Publishing microphone track from provided MediaStream", { trackId: v.id });
|
|
563
563
|
try {
|
|
564
|
-
|
|
565
|
-
source:
|
|
566
|
-
}), n("Microphone track published successfully", { trackSid:
|
|
567
|
-
} catch (
|
|
568
|
-
throw n("Failed to publish microphone track:",
|
|
564
|
+
M = await u.localParticipant.publishTrack(v, {
|
|
565
|
+
source: D.Source.Microphone
|
|
566
|
+
}), n("Microphone track published successfully", { trackSid: M.trackSid });
|
|
567
|
+
} catch (le) {
|
|
568
|
+
throw n("Failed to publish microphone track:", le), le;
|
|
569
569
|
}
|
|
570
570
|
}
|
|
571
|
-
async function
|
|
572
|
-
if (!(!
|
|
571
|
+
async function h() {
|
|
572
|
+
if (!(!M || !M.track))
|
|
573
573
|
try {
|
|
574
|
-
u && (await u.localParticipant.unpublishTrack(
|
|
574
|
+
u && (await u.localParticipant.unpublishTrack(M.track), n("Microphone track unpublished"));
|
|
575
575
|
} catch (l) {
|
|
576
576
|
n("Error unpublishing microphone track:", l);
|
|
577
577
|
} finally {
|
|
578
|
-
|
|
578
|
+
M = null;
|
|
579
579
|
}
|
|
580
580
|
}
|
|
581
|
-
function
|
|
582
|
-
|
|
581
|
+
function F() {
|
|
582
|
+
R && (R.getTracks().forEach((l) => l.stop()), R = null);
|
|
583
583
|
}
|
|
584
|
-
async function
|
|
585
|
-
var v,
|
|
586
|
-
if (!
|
|
584
|
+
async function J(l, g) {
|
|
585
|
+
var v, D;
|
|
586
|
+
if (!P || !u) {
|
|
587
587
|
n("Room is not connected for sending messages"), (v = i.onError) == null || v.call(i, new Error(me), {
|
|
588
|
-
sessionId:
|
|
588
|
+
sessionId: E
|
|
589
589
|
});
|
|
590
590
|
return;
|
|
591
591
|
}
|
|
592
592
|
try {
|
|
593
|
-
await u.localParticipant.sendText(l, { topic:
|
|
594
|
-
} catch (
|
|
595
|
-
n("Failed to send message:",
|
|
593
|
+
await u.localParticipant.sendText(l, { topic: g }), n("Message sent successfully:", l);
|
|
594
|
+
} catch (A) {
|
|
595
|
+
n("Failed to send message:", A), (D = i.onError) == null || D.call(i, new Error(me), { sessionId: E });
|
|
596
596
|
}
|
|
597
597
|
}
|
|
598
598
|
async function he(l) {
|
|
599
|
-
var
|
|
599
|
+
var g;
|
|
600
600
|
try {
|
|
601
|
-
const
|
|
602
|
-
return
|
|
601
|
+
const D = JSON.parse(l).topic;
|
|
602
|
+
return J("", D);
|
|
603
603
|
} catch (v) {
|
|
604
|
-
n("Failed to send data channel message:", v), (
|
|
604
|
+
n("Failed to send data channel message:", v), (g = i.onError) == null || g.call(i, new Error(me), { sessionId: E });
|
|
605
605
|
}
|
|
606
606
|
}
|
|
607
607
|
function pe(l) {
|
|
608
|
-
return
|
|
608
|
+
return J(
|
|
609
609
|
l,
|
|
610
610
|
"lk.chat"
|
|
611
611
|
/* Chat */
|
|
612
612
|
);
|
|
613
613
|
}
|
|
614
614
|
async function se() {
|
|
615
|
-
var l,
|
|
616
|
-
z && (clearTimeout(z), z = null), u && (await
|
|
615
|
+
var l, g;
|
|
616
|
+
z && (clearTimeout(z), z = null), u && (await h(), await u.disconnect()), F(), P = !1, (l = i.onConnectionStateChange) == null || l.call(i, S.Disconnected), (g = i.onAgentActivityStateChange) == null || g.call(i, q.Idle), W = q.Idle;
|
|
617
617
|
}
|
|
618
618
|
return {
|
|
619
619
|
speak(l) {
|
|
620
|
-
const
|
|
621
|
-
return
|
|
622
|
-
|
|
620
|
+
const g = typeof l == "string" ? l : JSON.stringify(l);
|
|
621
|
+
return J(
|
|
622
|
+
g,
|
|
623
623
|
"did.speak"
|
|
624
624
|
/* Speak */
|
|
625
625
|
);
|
|
626
626
|
},
|
|
627
627
|
disconnect: se,
|
|
628
628
|
async reconnect() {
|
|
629
|
-
var l,
|
|
630
|
-
if ((u == null ? void 0 : u.state) ===
|
|
629
|
+
var l, g, v;
|
|
630
|
+
if ((u == null ? void 0 : u.state) === c.Connected) {
|
|
631
631
|
n("Room is already connected");
|
|
632
632
|
return;
|
|
633
633
|
}
|
|
@@ -635,41 +635,41 @@ async function Tt(e, t, a) {
|
|
|
635
635
|
throw n("Cannot reconnect: missing room, URL or token"), new Error("Cannot reconnect: session not available");
|
|
636
636
|
n("Reconnecting to LiveKit room, state:", u.state), (l = i.onConnectionStateChange) == null || l.call(i, S.Connecting);
|
|
637
637
|
try {
|
|
638
|
-
if (await u.connect(Z, G), n("Room reconnected"),
|
|
639
|
-
if (n("Waiting for agent to join..."), !await new Promise((
|
|
640
|
-
const
|
|
641
|
-
u == null || u.off(o.ParticipantConnected, x),
|
|
638
|
+
if (await u.connect(Z, G), n("Room reconnected"), P = !0, u.remoteParticipants.size === 0) {
|
|
639
|
+
if (n("Waiting for agent to join..."), !await new Promise((A) => {
|
|
640
|
+
const O = setTimeout(() => {
|
|
641
|
+
u == null || u.off(o.ParticipantConnected, x), A(!1);
|
|
642
642
|
}, 5e3), x = () => {
|
|
643
|
-
clearTimeout(
|
|
643
|
+
clearTimeout(O), u == null || u.off(o.ParticipantConnected, x), A(!0);
|
|
644
644
|
};
|
|
645
645
|
u == null || u.on(o.ParticipantConnected, x);
|
|
646
646
|
}))
|
|
647
647
|
throw n("Agent did not join within timeout"), await u.disconnect(), new Error("Agent did not rejoin the room");
|
|
648
648
|
n("Agent joined");
|
|
649
649
|
}
|
|
650
|
-
(
|
|
651
|
-
} catch (
|
|
652
|
-
throw n("Failed to reconnect:",
|
|
650
|
+
(g = i.onConnectionStateChange) == null || g.call(i, S.Connected);
|
|
651
|
+
} catch (D) {
|
|
652
|
+
throw n("Failed to reconnect:", D), (v = i.onConnectionStateChange) == null || v.call(i, S.Fail), D;
|
|
653
653
|
}
|
|
654
654
|
},
|
|
655
655
|
sendDataChannelMessage: he,
|
|
656
656
|
sendTextMessage: pe,
|
|
657
657
|
publishMicrophoneStream: m,
|
|
658
|
-
unpublishMicrophoneStream:
|
|
659
|
-
sessionId:
|
|
660
|
-
streamId:
|
|
658
|
+
unpublishMicrophoneStream: h,
|
|
659
|
+
sessionId: E,
|
|
660
|
+
streamId: E,
|
|
661
661
|
streamType: $,
|
|
662
662
|
interruptAvailable: !0,
|
|
663
663
|
triggersAvailable: !1
|
|
664
664
|
};
|
|
665
665
|
}
|
|
666
|
-
const
|
|
666
|
+
const At = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
667
667
|
__proto__: null,
|
|
668
668
|
DataChannelTopic: Ae,
|
|
669
|
-
createLiveKitStreamingManager:
|
|
669
|
+
createLiveKitStreamingManager: _t,
|
|
670
670
|
handleInitError: De
|
|
671
671
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
672
|
-
function
|
|
672
|
+
function Pt(e, t, a) {
|
|
673
673
|
if (!e)
|
|
674
674
|
throw new Error("Please connect to the agent first");
|
|
675
675
|
if (!e.interruptAvailable)
|
|
@@ -679,7 +679,7 @@ function At(e, t, a) {
|
|
|
679
679
|
if (!a)
|
|
680
680
|
throw new Error("No active video to interrupt");
|
|
681
681
|
}
|
|
682
|
-
async function
|
|
682
|
+
async function bt(e, t) {
|
|
683
683
|
const a = {
|
|
684
684
|
type: j.StreamInterrupt,
|
|
685
685
|
videoId: t,
|
|
@@ -693,52 +693,52 @@ async function Lt(e) {
|
|
|
693
693
|
};
|
|
694
694
|
e.sendDataChannelMessage(JSON.stringify(t));
|
|
695
695
|
}
|
|
696
|
-
function
|
|
696
|
+
function jt(e) {
|
|
697
697
|
return new Promise((t, a) => {
|
|
698
|
-
const { callbacks: n, host:
|
|
699
|
-
|
|
700
|
-
console.error(u),
|
|
701
|
-
},
|
|
702
|
-
r == null || r(u), t(
|
|
698
|
+
const { callbacks: n, host: s, auth: o, externalId: c } = e, { onMessage: i = null, onOpen: r = null, onClose: d = null, onError: w = null } = n || {}, p = new WebSocket(`${s}?authorization=${encodeURIComponent(Oe(o, c))}`);
|
|
699
|
+
p.onmessage = i, p.onclose = d, p.onerror = (u) => {
|
|
700
|
+
console.error(u), w == null || w("Websocket failed to connect", u), a(u);
|
|
701
|
+
}, p.onopen = (u) => {
|
|
702
|
+
r == null || r(u), t(p);
|
|
703
703
|
};
|
|
704
704
|
});
|
|
705
705
|
}
|
|
706
|
-
async function
|
|
706
|
+
async function $t(e) {
|
|
707
707
|
const { retries: t = 1 } = e;
|
|
708
708
|
let a = null;
|
|
709
709
|
for (let n = 0; (a == null ? void 0 : a.readyState) !== WebSocket.OPEN; n++)
|
|
710
710
|
try {
|
|
711
|
-
a = await
|
|
712
|
-
} catch (
|
|
711
|
+
a = await jt(e);
|
|
712
|
+
} catch (s) {
|
|
713
713
|
if (n === t)
|
|
714
|
-
throw
|
|
715
|
-
await
|
|
714
|
+
throw s;
|
|
715
|
+
await Ue(n * 500);
|
|
716
716
|
}
|
|
717
717
|
return a;
|
|
718
718
|
}
|
|
719
|
-
async function
|
|
720
|
-
const
|
|
719
|
+
async function xt(e, t, a, n) {
|
|
720
|
+
const s = a != null && a.onMessage ? [a.onMessage] : [], o = await $t({
|
|
721
721
|
auth: e,
|
|
722
722
|
host: t,
|
|
723
723
|
externalId: n,
|
|
724
724
|
callbacks: {
|
|
725
|
-
onError: (
|
|
725
|
+
onError: (c) => {
|
|
726
726
|
var i;
|
|
727
|
-
return (i = a.onError) == null ? void 0 : i.call(a, new
|
|
727
|
+
return (i = a.onError) == null ? void 0 : i.call(a, new et(c));
|
|
728
728
|
},
|
|
729
|
-
onMessage(
|
|
730
|
-
const i = JSON.parse(
|
|
731
|
-
|
|
729
|
+
onMessage(c) {
|
|
730
|
+
const i = JSON.parse(c.data);
|
|
731
|
+
s.forEach((r) => r(i.event, i));
|
|
732
732
|
}
|
|
733
733
|
}
|
|
734
734
|
});
|
|
735
735
|
return {
|
|
736
736
|
socket: o,
|
|
737
737
|
disconnect: () => o.close(),
|
|
738
|
-
subscribeToEvents: (
|
|
738
|
+
subscribeToEvents: (c) => s.push(c)
|
|
739
739
|
};
|
|
740
740
|
}
|
|
741
|
-
function
|
|
741
|
+
function Bt(e) {
|
|
742
742
|
if (e.answer !== void 0)
|
|
743
743
|
return e.answer;
|
|
744
744
|
let t = 0, a = "";
|
|
@@ -746,108 +746,112 @@ function xt(e) {
|
|
|
746
746
|
a += e[t++];
|
|
747
747
|
return a;
|
|
748
748
|
}
|
|
749
|
-
function
|
|
749
|
+
function Ft(e, t, a) {
|
|
750
750
|
if (!e.content)
|
|
751
751
|
return;
|
|
752
752
|
const n = t.messages[t.messages.length - 1];
|
|
753
753
|
(n == null ? void 0 : n.role) === "assistant" && !n.interrupted && (n.interrupted = !0);
|
|
754
|
-
const
|
|
754
|
+
const s = {
|
|
755
755
|
id: e.id || `user-${Date.now()}`,
|
|
756
756
|
role: e.role,
|
|
757
757
|
content: e.content,
|
|
758
758
|
created_at: e.created_at || (/* @__PURE__ */ new Date()).toISOString(),
|
|
759
759
|
transcribed: !0
|
|
760
760
|
};
|
|
761
|
-
t.messages.push(
|
|
761
|
+
t.messages.push(s), a == null || a([...t.messages], "user");
|
|
762
762
|
}
|
|
763
|
-
function
|
|
763
|
+
function Nt(e, t, a, n, s) {
|
|
764
764
|
if (e === Y.Transcribe && t.content) {
|
|
765
|
-
|
|
765
|
+
Ft(t, n, s);
|
|
766
766
|
return;
|
|
767
767
|
}
|
|
768
768
|
if (!(e === Y.Partial || e === Y.Answer))
|
|
769
769
|
return;
|
|
770
770
|
const o = n.messages[n.messages.length - 1];
|
|
771
|
-
let
|
|
771
|
+
let c;
|
|
772
772
|
if (o != null && o.transcribed && o.role === "user")
|
|
773
|
-
e === Y.Answer && t.content,
|
|
773
|
+
e === Y.Answer && t.content, c = {
|
|
774
774
|
id: t.id || `assistant-${Date.now()}`,
|
|
775
775
|
role: t.role || "assistant",
|
|
776
776
|
content: t.content || "",
|
|
777
777
|
created_at: t.created_at || (/* @__PURE__ */ new Date()).toISOString()
|
|
778
|
-
}, n.messages.push(
|
|
778
|
+
}, n.messages.push(c);
|
|
779
779
|
else if ((o == null ? void 0 : o.role) === "assistant")
|
|
780
|
-
|
|
780
|
+
c = o;
|
|
781
781
|
else
|
|
782
782
|
return;
|
|
783
783
|
const { content: i, sequence: r } = t;
|
|
784
784
|
e === Y.Partial ? a[r] = i : a.answer = i;
|
|
785
|
-
const d =
|
|
786
|
-
(
|
|
785
|
+
const d = Bt(a);
|
|
786
|
+
(c.content !== d || e === Y.Answer) && (c.content = d, s == null || s([...n.messages], e));
|
|
787
787
|
}
|
|
788
|
-
function zt(e, t, a, n,
|
|
788
|
+
function zt(e, t, a, n, s) {
|
|
789
789
|
let o = {};
|
|
790
|
+
const c = () => o = {}, i = (r, d) => {
|
|
791
|
+
var w, p;
|
|
792
|
+
d === "user" && c(), (p = (w = a.callbacks).onNewMessage) == null || p.call(w, r, d);
|
|
793
|
+
};
|
|
790
794
|
return {
|
|
791
|
-
clearQueue:
|
|
792
|
-
onMessage: (
|
|
793
|
-
var
|
|
794
|
-
if ("content" in
|
|
795
|
-
const
|
|
796
|
-
|
|
795
|
+
clearQueue: c,
|
|
796
|
+
onMessage: (r, d) => {
|
|
797
|
+
var w, p;
|
|
798
|
+
if ("content" in d) {
|
|
799
|
+
const u = r === j.ChatAnswer ? Y.Answer : r === j.ChatAudioTranscribed ? Y.Transcribe : r;
|
|
800
|
+
Nt(u, d, o, t, i), u === Y.Answer && e.track("agent-message-received", {
|
|
797
801
|
messages: t.messages.length,
|
|
798
802
|
mode: t.chatMode
|
|
799
803
|
});
|
|
800
804
|
} else {
|
|
801
|
-
const
|
|
802
|
-
if (
|
|
803
|
-
e.linkTrack("agent-video",
|
|
804
|
-
else if (
|
|
805
|
-
const
|
|
806
|
-
|
|
805
|
+
const u = j, P = [u.StreamVideoDone, u.StreamVideoError, u.StreamVideoRejected], $ = [u.StreamFailed, u.StreamVideoError, u.StreamVideoRejected], B = kt(d, n, { mode: t.chatMode });
|
|
806
|
+
if (r = r, r === u.StreamVideoCreated)
|
|
807
|
+
e.linkTrack("agent-video", B, u.StreamVideoCreated, ["start"]);
|
|
808
|
+
else if (P.includes(r)) {
|
|
809
|
+
const R = r.split("/")[1];
|
|
810
|
+
$.includes(r) ? e.track("agent-video", { ...B, event: R }) : e.linkTrack("agent-video", { ...B, event: R }, r, ["done"]);
|
|
807
811
|
}
|
|
808
|
-
|
|
812
|
+
$.includes(r) && ((p = (w = a.callbacks).onError) == null || p.call(w, new Error(`Stream failed with event ${r}`), { data: d })), d.event === u.StreamDone && s();
|
|
809
813
|
}
|
|
810
814
|
}
|
|
811
815
|
};
|
|
812
816
|
}
|
|
813
|
-
function
|
|
814
|
-
const
|
|
817
|
+
function Kt(e, t, a, n) {
|
|
818
|
+
const s = Te(e, `${t}/agents/${a}`, n);
|
|
815
819
|
return {
|
|
816
|
-
createStream(o,
|
|
817
|
-
return
|
|
820
|
+
createStream(o, c) {
|
|
821
|
+
return s.post("/streams", o, { signal: c });
|
|
818
822
|
},
|
|
819
|
-
startConnection(o,
|
|
820
|
-
return
|
|
823
|
+
startConnection(o, c, i, r) {
|
|
824
|
+
return s.post(
|
|
821
825
|
`/streams/${o}/sdp`,
|
|
822
826
|
{
|
|
823
827
|
session_id: i,
|
|
824
|
-
answer:
|
|
828
|
+
answer: c
|
|
825
829
|
},
|
|
826
830
|
{ signal: r }
|
|
827
831
|
);
|
|
828
832
|
},
|
|
829
|
-
addIceCandidate(o,
|
|
830
|
-
return
|
|
833
|
+
addIceCandidate(o, c, i, r) {
|
|
834
|
+
return s.post(
|
|
831
835
|
`/streams/${o}/ice`,
|
|
832
836
|
{
|
|
833
837
|
session_id: i,
|
|
834
|
-
...
|
|
838
|
+
...c
|
|
835
839
|
},
|
|
836
840
|
{ signal: r }
|
|
837
841
|
);
|
|
838
842
|
},
|
|
839
|
-
sendStreamRequest(o,
|
|
840
|
-
return
|
|
841
|
-
session_id:
|
|
843
|
+
sendStreamRequest(o, c, i) {
|
|
844
|
+
return s.post(`/streams/${o}`, {
|
|
845
|
+
session_id: c,
|
|
842
846
|
...i
|
|
843
847
|
});
|
|
844
848
|
},
|
|
845
|
-
close(o,
|
|
846
|
-
return
|
|
849
|
+
close(o, c) {
|
|
850
|
+
return s.delete(`/streams/${o}`, { session_id: c });
|
|
847
851
|
}
|
|
848
852
|
};
|
|
849
853
|
}
|
|
850
|
-
function
|
|
854
|
+
function Jt(e, t, a) {
|
|
851
855
|
const n = (t.timestamp - e.timestamp) / 1e3;
|
|
852
856
|
return {
|
|
853
857
|
duration: n,
|
|
@@ -867,23 +871,23 @@ function Kt(e, t, a) {
|
|
|
867
871
|
lowFpsCount: a
|
|
868
872
|
};
|
|
869
873
|
}
|
|
870
|
-
function
|
|
874
|
+
function Ut(e) {
|
|
871
875
|
return e.filter(
|
|
872
876
|
(t) => t.freezeCount > 0 || t.framesPerSecond < 21 || t.framesDropped > 0 || t.packetsLost > 0
|
|
873
877
|
).map((t) => {
|
|
874
|
-
const { timestamp: a, ...n } = t,
|
|
875
|
-
return t.freezeCount > 0 &&
|
|
878
|
+
const { timestamp: a, ...n } = t, s = [];
|
|
879
|
+
return t.freezeCount > 0 && s.push("freeze"), t.framesPerSecond < 21 && s.push("low fps"), t.framesDropped > 0 && s.push("frames dropped"), t.packetsLost > 0 && s.push("packet loss"), {
|
|
876
880
|
...n,
|
|
877
|
-
causes:
|
|
881
|
+
causes: s
|
|
878
882
|
};
|
|
879
883
|
});
|
|
880
884
|
}
|
|
881
|
-
function
|
|
885
|
+
function Wt(e) {
|
|
882
886
|
let t = "", a = 0;
|
|
883
887
|
for (const n of e.values()) {
|
|
884
888
|
if (n && n.type === "codec" && n.mimeType.startsWith("video") && (t = n.mimeType.split("/")[1]), n && n.type === "candidate-pair") {
|
|
885
|
-
const
|
|
886
|
-
|
|
889
|
+
const s = n.currentRoundTripTime, c = n.nominated === !0;
|
|
890
|
+
s > 0 && (c || a === 0) && (a = s);
|
|
887
891
|
}
|
|
888
892
|
if (n && n.type === "inbound-rtp" && n.kind === "video")
|
|
889
893
|
return {
|
|
@@ -908,7 +912,7 @@ function Ut(e) {
|
|
|
908
912
|
}
|
|
909
913
|
return {};
|
|
910
914
|
}
|
|
911
|
-
function
|
|
915
|
+
function Vt(e, t, a) {
|
|
912
916
|
const n = e.map((r, d) => d === 0 ? a ? {
|
|
913
917
|
timestamp: r.timestamp,
|
|
914
918
|
duration: 0,
|
|
@@ -960,55 +964,55 @@ function Wt(e, t, a) {
|
|
|
960
964
|
framesPerSecond: r.framesPerSecond,
|
|
961
965
|
freezeCount: r.freezeCount - e[d - 1].freezeCount,
|
|
962
966
|
freezeDuration: r.freezeDuration - e[d - 1].freezeDuration
|
|
963
|
-
}),
|
|
967
|
+
}), s = Ut(n), o = s.reduce((r, d) => r + (d.causes.includes("low fps") ? 1 : 0), 0), c = n.filter((r) => !!r.avgJitterDelayInInterval).map((r) => r.avgJitterDelayInInterval), i = n.filter((r) => !!r.rtt).map((r) => r.rtt);
|
|
964
968
|
return {
|
|
965
969
|
webRTCStats: {
|
|
966
|
-
anomalies:
|
|
970
|
+
anomalies: s,
|
|
967
971
|
minRtt: Math.min(...i),
|
|
968
|
-
avgRtt:
|
|
972
|
+
avgRtt: xe(i),
|
|
969
973
|
maxRtt: Math.max(...i),
|
|
970
|
-
aggregateReport:
|
|
971
|
-
minJitterDelayInInterval: Math.min(...
|
|
972
|
-
maxJitterDelayInInterval: Math.max(...
|
|
973
|
-
avgJitterDelayInInterval:
|
|
974
|
+
aggregateReport: Jt(e[0], e[e.length - 1], o),
|
|
975
|
+
minJitterDelayInInterval: Math.min(...c),
|
|
976
|
+
maxJitterDelayInInterval: Math.max(...c),
|
|
977
|
+
avgJitterDelayInInterval: xe(c)
|
|
974
978
|
},
|
|
975
979
|
codec: e[0].codec,
|
|
976
980
|
resolution: `${e[0].frameWidth}x${e[0].frameHeight}`
|
|
977
981
|
};
|
|
978
982
|
}
|
|
979
|
-
const Me = 100, Ot = Math.max(Math.ceil(400 / Me), 1),
|
|
980
|
-
function
|
|
983
|
+
const Me = 100, Ot = Math.max(Math.ceil(400 / Me), 1), qt = 0.25, Ht = 0.28;
|
|
984
|
+
function Qt() {
|
|
981
985
|
let e = 0, t, a, n = 0;
|
|
982
|
-
return (
|
|
983
|
-
for (const o of
|
|
986
|
+
return (s) => {
|
|
987
|
+
for (const o of s.values())
|
|
984
988
|
if (o && o.type === "inbound-rtp" && o.kind === "video") {
|
|
985
|
-
const
|
|
989
|
+
const c = o.jitterBufferDelay, i = o.jitterBufferEmittedCount;
|
|
986
990
|
if (a && i > a) {
|
|
987
|
-
const
|
|
988
|
-
n =
|
|
991
|
+
const w = c - t, p = i - a;
|
|
992
|
+
n = w / p;
|
|
989
993
|
}
|
|
990
|
-
t =
|
|
994
|
+
t = c, a = i;
|
|
991
995
|
const r = o.framesDecoded, d = r - e > 0;
|
|
992
996
|
return e = r, { isReceiving: d, avgJitterDelayInInterval: n, freezeCount: o.freezeCount };
|
|
993
997
|
}
|
|
994
998
|
return { isReceiving: !1, avgJitterDelayInInterval: n };
|
|
995
999
|
};
|
|
996
1000
|
}
|
|
997
|
-
function
|
|
998
|
-
let o = [],
|
|
999
|
-
const
|
|
1001
|
+
function Xt(e, t, a, n, s) {
|
|
1002
|
+
let o = [], c, i = 0, r = !1, d = re.Unknown, w = re.Unknown, p = 0, u = 0;
|
|
1003
|
+
const P = Qt();
|
|
1000
1004
|
return setInterval(async () => {
|
|
1001
|
-
const $ = await e.getStats(), { isReceiving:
|
|
1002
|
-
if (
|
|
1003
|
-
i = 0,
|
|
1005
|
+
const $ = await e.getStats(), { isReceiving: B, avgJitterDelayInInterval: R, freezeCount: M } = P($), z = Wt($);
|
|
1006
|
+
if (B)
|
|
1007
|
+
i = 0, p = M - u, w = R < qt ? re.Strong : R > Ht && p > 1 ? re.Weak : d, w !== d && (s == null || s(w), d = w, u += p, p = 0), r || (n == null || n(C.Start), c = o[o.length - 1], o = [], r = !0), o.push(z);
|
|
1004
1008
|
else if (r && (i++, i >= Ot)) {
|
|
1005
|
-
const
|
|
1006
|
-
n == null || n(C.Stop,
|
|
1009
|
+
const T = Vt(o, Me, c);
|
|
1010
|
+
n == null || n(C.Stop, T), t() || a(), u = M, r = !1;
|
|
1007
1011
|
}
|
|
1008
1012
|
}, Me);
|
|
1009
1013
|
}
|
|
1010
|
-
const
|
|
1011
|
-
function
|
|
1014
|
+
const Yt = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
|
|
1015
|
+
function Ne(e) {
|
|
1012
1016
|
switch (e) {
|
|
1013
1017
|
case "connected":
|
|
1014
1018
|
return S.Connected;
|
|
@@ -1028,16 +1032,16 @@ function Fe(e) {
|
|
|
1028
1032
|
return S.New;
|
|
1029
1033
|
}
|
|
1030
1034
|
}
|
|
1031
|
-
const
|
|
1035
|
+
const Gt = (e) => (t) => {
|
|
1032
1036
|
const [a, n = ""] = t.split(/:(.+)/);
|
|
1033
1037
|
try {
|
|
1034
|
-
const
|
|
1035
|
-
return e("parsed data channel message", { subject: a, data:
|
|
1036
|
-
} catch (
|
|
1037
|
-
return e("Failed to parse data channel message, returning data as string", { subject: a, rawData: n, error:
|
|
1038
|
+
const s = JSON.parse(n);
|
|
1039
|
+
return e("parsed data channel message", { subject: a, data: s }), { subject: a, data: s };
|
|
1040
|
+
} catch (s) {
|
|
1041
|
+
return e("Failed to parse data channel message, returning data as string", { subject: a, rawData: n, error: s }), { subject: a, data: n };
|
|
1038
1042
|
}
|
|
1039
1043
|
};
|
|
1040
|
-
function
|
|
1044
|
+
function Zt({
|
|
1041
1045
|
statsSignal: e,
|
|
1042
1046
|
dataChannelSignal: t,
|
|
1043
1047
|
onVideoStateChange: a,
|
|
@@ -1045,24 +1049,24 @@ function Gt({
|
|
|
1045
1049
|
}) {
|
|
1046
1050
|
e === C.Start && t === C.Start ? a == null || a(C.Start) : e === C.Stop && t === C.Stop && (a == null || a(C.Stop, n));
|
|
1047
1051
|
}
|
|
1048
|
-
function
|
|
1052
|
+
function en({
|
|
1049
1053
|
statsSignal: e,
|
|
1050
1054
|
dataChannelSignal: t,
|
|
1051
1055
|
onVideoStateChange: a,
|
|
1052
1056
|
onAgentActivityStateChange: n,
|
|
1053
|
-
report:
|
|
1057
|
+
report: s
|
|
1054
1058
|
}) {
|
|
1055
|
-
e === C.Start ? a == null || a(C.Start) : e === C.Stop && (a == null || a(C.Stop,
|
|
1059
|
+
e === C.Start ? a == null || a(C.Start) : e === C.Stop && (a == null || a(C.Stop, s)), t === C.Start ? n == null || n(q.Talking) : t === C.Stop && (n == null || n(q.Idle));
|
|
1056
1060
|
}
|
|
1057
1061
|
function ze({
|
|
1058
1062
|
statsSignal: e,
|
|
1059
1063
|
dataChannelSignal: t,
|
|
1060
1064
|
onVideoStateChange: a,
|
|
1061
1065
|
onAgentActivityStateChange: n,
|
|
1062
|
-
streamType:
|
|
1066
|
+
streamType: s,
|
|
1063
1067
|
report: o
|
|
1064
1068
|
}) {
|
|
1065
|
-
|
|
1069
|
+
s === ae.Legacy ? Zt({ statsSignal: e, dataChannelSignal: t, onVideoStateChange: a, report: o }) : s === ae.Fluent && en({
|
|
1066
1070
|
statsSignal: e,
|
|
1067
1071
|
dataChannelSignal: t,
|
|
1068
1072
|
onVideoStateChange: a,
|
|
@@ -1070,205 +1074,205 @@ function ze({
|
|
|
1070
1074
|
report: o
|
|
1071
1075
|
});
|
|
1072
1076
|
}
|
|
1073
|
-
async function
|
|
1074
|
-
var
|
|
1075
|
-
const r =
|
|
1076
|
-
let
|
|
1077
|
-
const { startConnection: $, sendStreamRequest:
|
|
1078
|
-
|
|
1077
|
+
async function tn(e, t, { debug: a = !1, callbacks: n, auth: s, baseURL: o = ge, analytics: c }, i) {
|
|
1078
|
+
var V;
|
|
1079
|
+
const r = Qe(a, "WebRTCStreamingManager"), d = Gt(r);
|
|
1080
|
+
let w = !1, p = !1, u = C.Stop, P = C.Stop;
|
|
1081
|
+
const { startConnection: $, sendStreamRequest: B, close: R, createStream: M, addIceCandidate: z } = Kt(
|
|
1082
|
+
s,
|
|
1079
1083
|
o,
|
|
1080
1084
|
e,
|
|
1081
1085
|
n.onError
|
|
1082
1086
|
), {
|
|
1083
|
-
id:
|
|
1087
|
+
id: T,
|
|
1084
1088
|
offer: W,
|
|
1085
1089
|
ice_servers: ee,
|
|
1086
|
-
session_id:
|
|
1090
|
+
session_id: E,
|
|
1087
1091
|
fluent: G,
|
|
1088
1092
|
interrupt_enabled: Z,
|
|
1089
1093
|
triggers_enabled: f
|
|
1090
|
-
} = await
|
|
1091
|
-
(
|
|
1092
|
-
const y = new
|
|
1093
|
-
if (!
|
|
1094
|
+
} = await M(t, i);
|
|
1095
|
+
(V = n.onStreamCreated) == null || V.call(n, { stream_id: T, session_id: E, agent_id: e });
|
|
1096
|
+
const y = new Yt({ iceServers: ee }), k = y.createDataChannel("JanusDataChannel");
|
|
1097
|
+
if (!E)
|
|
1094
1098
|
throw new Error("Could not create session_id");
|
|
1095
|
-
const
|
|
1096
|
-
|
|
1097
|
-
"stream-type":
|
|
1099
|
+
const _ = G ? ae.Fluent : ae.Legacy;
|
|
1100
|
+
c.enrich({
|
|
1101
|
+
"stream-type": _
|
|
1098
1102
|
});
|
|
1099
|
-
const
|
|
1103
|
+
const b = t.stream_warmup && !G, I = () => w, U = () => {
|
|
1100
1104
|
var m;
|
|
1101
|
-
|
|
1102
|
-
}, H =
|
|
1105
|
+
w = !0, p && ((m = n.onConnectionStateChange) == null || m.call(n, S.Connected));
|
|
1106
|
+
}, H = Xt(
|
|
1103
1107
|
y,
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
(m,
|
|
1107
|
-
statsSignal:
|
|
1108
|
-
dataChannelSignal:
|
|
1108
|
+
I,
|
|
1109
|
+
U,
|
|
1110
|
+
(m, h) => ze({
|
|
1111
|
+
statsSignal: P = m,
|
|
1112
|
+
dataChannelSignal: _ === ae.Legacy ? u : void 0,
|
|
1109
1113
|
onVideoStateChange: n.onVideoStateChange,
|
|
1110
1114
|
onAgentActivityStateChange: n.onAgentActivityStateChange,
|
|
1111
|
-
report:
|
|
1112
|
-
streamType:
|
|
1115
|
+
report: h,
|
|
1116
|
+
streamType: _
|
|
1113
1117
|
}),
|
|
1114
1118
|
(m) => {
|
|
1115
|
-
var
|
|
1116
|
-
return (
|
|
1119
|
+
var h;
|
|
1120
|
+
return (h = n.onConnectivityStateChange) == null ? void 0 : h.call(n, m);
|
|
1117
1121
|
}
|
|
1118
1122
|
);
|
|
1119
1123
|
y.onicecandidate = (m) => {
|
|
1120
|
-
var
|
|
1124
|
+
var h;
|
|
1121
1125
|
r("peerConnection.onicecandidate", m);
|
|
1122
1126
|
try {
|
|
1123
1127
|
m.candidate && m.candidate.sdpMid && m.candidate.sdpMLineIndex !== null ? z(
|
|
1124
|
-
|
|
1128
|
+
T,
|
|
1125
1129
|
{
|
|
1126
1130
|
candidate: m.candidate.candidate,
|
|
1127
1131
|
sdpMid: m.candidate.sdpMid,
|
|
1128
1132
|
sdpMLineIndex: m.candidate.sdpMLineIndex
|
|
1129
1133
|
},
|
|
1130
|
-
|
|
1134
|
+
E,
|
|
1131
1135
|
i
|
|
1132
|
-
) : z(
|
|
1133
|
-
} catch (
|
|
1134
|
-
(
|
|
1136
|
+
) : z(T, { candidate: null }, E, i);
|
|
1137
|
+
} catch (F) {
|
|
1138
|
+
(h = n.onError) == null || h.call(n, F, { streamId: T });
|
|
1135
1139
|
}
|
|
1136
1140
|
}, k.onopen = () => {
|
|
1137
|
-
|
|
1141
|
+
p = !0, (!b || w) && U();
|
|
1138
1142
|
};
|
|
1139
1143
|
const Q = (m) => {
|
|
1140
|
-
var
|
|
1141
|
-
(
|
|
1144
|
+
var h;
|
|
1145
|
+
(h = n.onVideoIdChange) == null || h.call(n, m);
|
|
1142
1146
|
};
|
|
1143
|
-
function
|
|
1144
|
-
if (m === j.StreamStarted && typeof
|
|
1145
|
-
const
|
|
1146
|
-
Q(
|
|
1147
|
+
function L(m, h) {
|
|
1148
|
+
if (m === j.StreamStarted && typeof h == "object" && "metadata" in h) {
|
|
1149
|
+
const F = h.metadata;
|
|
1150
|
+
Q(F.videoId);
|
|
1147
1151
|
}
|
|
1148
1152
|
m === j.StreamDone && Q(null), u = m === j.StreamStarted ? C.Start : C.Stop, ze({
|
|
1149
|
-
statsSignal:
|
|
1153
|
+
statsSignal: _ === ae.Legacy ? P : void 0,
|
|
1150
1154
|
dataChannelSignal: u,
|
|
1151
1155
|
onVideoStateChange: n.onVideoStateChange,
|
|
1152
1156
|
onAgentActivityStateChange: n.onAgentActivityStateChange,
|
|
1153
|
-
streamType:
|
|
1157
|
+
streamType: _
|
|
1154
1158
|
});
|
|
1155
1159
|
}
|
|
1156
|
-
function
|
|
1157
|
-
var
|
|
1158
|
-
const
|
|
1159
|
-
|
|
1160
|
+
function K(m, h) {
|
|
1161
|
+
var J;
|
|
1162
|
+
const F = typeof h == "string" ? h : h == null ? void 0 : h.metadata;
|
|
1163
|
+
F && c.enrich({ streamMetadata: F }), (J = n.onStreamReady) == null || J.call(n);
|
|
1160
1164
|
}
|
|
1161
1165
|
const X = {
|
|
1162
|
-
[j.StreamStarted]:
|
|
1163
|
-
[j.StreamDone]:
|
|
1164
|
-
[j.StreamReady]:
|
|
1166
|
+
[j.StreamStarted]: L,
|
|
1167
|
+
[j.StreamDone]: L,
|
|
1168
|
+
[j.StreamReady]: K
|
|
1165
1169
|
};
|
|
1166
1170
|
k.onmessage = (m) => {
|
|
1167
|
-
var
|
|
1168
|
-
const { subject:
|
|
1169
|
-
(
|
|
1171
|
+
var J;
|
|
1172
|
+
const { subject: h, data: F } = d(m.data);
|
|
1173
|
+
(J = X[h]) == null || J.call(X, h, F);
|
|
1170
1174
|
}, y.oniceconnectionstatechange = () => {
|
|
1171
|
-
var
|
|
1175
|
+
var h;
|
|
1172
1176
|
r("peerConnection.oniceconnectionstatechange => " + y.iceConnectionState);
|
|
1173
|
-
const m =
|
|
1174
|
-
m !== S.Connected && ((
|
|
1177
|
+
const m = Ne(y.iceConnectionState);
|
|
1178
|
+
m !== S.Connected && ((h = n.onConnectionStateChange) == null || h.call(n, m));
|
|
1175
1179
|
}, y.ontrack = (m) => {
|
|
1176
|
-
var
|
|
1177
|
-
r("peerConnection.ontrack", m), (
|
|
1180
|
+
var h;
|
|
1181
|
+
r("peerConnection.ontrack", m), (h = n.onSrcObjectReady) == null || h.call(n, m.streams[0]);
|
|
1178
1182
|
}, await y.setRemoteDescription(W), r("set remote description OK");
|
|
1179
1183
|
const oe = await y.createAnswer();
|
|
1180
|
-
return r("create answer OK"), await y.setLocalDescription(oe), r("set local description OK"), await $(
|
|
1184
|
+
return r("create answer OK"), await y.setLocalDescription(oe), r("set local description OK"), await $(T, oe, E, i), r("start connection OK"), {
|
|
1181
1185
|
/**
|
|
1182
1186
|
* Method to send request to server to get clip or talk depend on you payload
|
|
1183
1187
|
* @param payload
|
|
1184
1188
|
*/
|
|
1185
1189
|
speak(m) {
|
|
1186
|
-
return
|
|
1190
|
+
return B(T, E, m);
|
|
1187
1191
|
},
|
|
1188
1192
|
/**
|
|
1189
1193
|
* Method to close RTC connection
|
|
1190
1194
|
*/
|
|
1191
1195
|
async disconnect() {
|
|
1192
1196
|
var m;
|
|
1193
|
-
if (
|
|
1194
|
-
const
|
|
1197
|
+
if (T) {
|
|
1198
|
+
const h = Ne(y.iceConnectionState);
|
|
1195
1199
|
if (y) {
|
|
1196
|
-
if (
|
|
1200
|
+
if (h === S.New) {
|
|
1197
1201
|
clearInterval(H);
|
|
1198
1202
|
return;
|
|
1199
1203
|
}
|
|
1200
1204
|
y.close(), y.oniceconnectionstatechange = null, y.onnegotiationneeded = null, y.onicecandidate = null, y.ontrack = null;
|
|
1201
1205
|
}
|
|
1202
1206
|
try {
|
|
1203
|
-
|
|
1207
|
+
h === S.Connected && await R(T, E).catch((F) => {
|
|
1204
1208
|
});
|
|
1205
|
-
} catch (
|
|
1206
|
-
r("Error on close stream connection",
|
|
1209
|
+
} catch (F) {
|
|
1210
|
+
r("Error on close stream connection", F);
|
|
1207
1211
|
}
|
|
1208
|
-
(m = n.onAgentActivityStateChange) == null || m.call(n,
|
|
1212
|
+
(m = n.onAgentActivityStateChange) == null || m.call(n, q.Idle), clearInterval(H);
|
|
1209
1213
|
}
|
|
1210
1214
|
},
|
|
1211
1215
|
/**
|
|
1212
1216
|
* Method to send data channel messages to the server
|
|
1213
1217
|
*/
|
|
1214
1218
|
sendDataChannelMessage(m) {
|
|
1215
|
-
var
|
|
1216
|
-
if (!
|
|
1217
|
-
r("Data channel is not ready for sending messages"), (
|
|
1218
|
-
streamId:
|
|
1219
|
+
var h, F;
|
|
1220
|
+
if (!w || k.readyState !== "open") {
|
|
1221
|
+
r("Data channel is not ready for sending messages"), (h = n.onError) == null || h.call(n, new Error("Data channel is not ready for sending messages"), {
|
|
1222
|
+
streamId: T
|
|
1219
1223
|
});
|
|
1220
1224
|
return;
|
|
1221
1225
|
}
|
|
1222
1226
|
try {
|
|
1223
1227
|
k.send(m);
|
|
1224
|
-
} catch (
|
|
1225
|
-
r("Error sending data channel message",
|
|
1228
|
+
} catch (J) {
|
|
1229
|
+
r("Error sending data channel message", J), (F = n.onError) == null || F.call(n, J, { streamId: T });
|
|
1226
1230
|
}
|
|
1227
1231
|
},
|
|
1228
1232
|
/**
|
|
1229
1233
|
* Session identifier information, should be returned in the body of all streaming requests
|
|
1230
1234
|
*/
|
|
1231
|
-
sessionId:
|
|
1235
|
+
sessionId: E,
|
|
1232
1236
|
/**
|
|
1233
1237
|
* Id of current RTC stream
|
|
1234
1238
|
*/
|
|
1235
|
-
streamId:
|
|
1236
|
-
streamType:
|
|
1239
|
+
streamId: T,
|
|
1240
|
+
streamType: _,
|
|
1237
1241
|
interruptAvailable: Z ?? !1,
|
|
1238
1242
|
triggersAvailable: f ?? !1
|
|
1239
1243
|
};
|
|
1240
1244
|
}
|
|
1241
1245
|
var Ee = /* @__PURE__ */ ((e) => (e.V1 = "v1", e.V2 = "v2", e))(Ee || {});
|
|
1242
|
-
async function
|
|
1243
|
-
const
|
|
1246
|
+
async function nn(e, t, a, n) {
|
|
1247
|
+
const s = e.id;
|
|
1244
1248
|
switch (t.version) {
|
|
1245
1249
|
case "v1": {
|
|
1246
|
-
const { version: o, ...
|
|
1247
|
-
return
|
|
1250
|
+
const { version: o, ...c } = t;
|
|
1251
|
+
return tn(s, c, a, n);
|
|
1248
1252
|
}
|
|
1249
1253
|
case "v2": {
|
|
1250
|
-
const { version: o, ...
|
|
1251
|
-
switch (
|
|
1254
|
+
const { version: o, ...c } = t;
|
|
1255
|
+
switch (c.transport_provider) {
|
|
1252
1256
|
case ye.Livekit:
|
|
1253
|
-
const { createLiveKitStreamingManager: i } = await Promise.resolve().then(() =>
|
|
1254
|
-
return i(
|
|
1257
|
+
const { createLiveKitStreamingManager: i } = await Promise.resolve().then(() => At);
|
|
1258
|
+
return i(s, c, a);
|
|
1255
1259
|
default:
|
|
1256
|
-
throw new Error(`Unsupported transport provider: ${
|
|
1260
|
+
throw new Error(`Unsupported transport provider: ${c.transport_provider}`);
|
|
1257
1261
|
}
|
|
1258
1262
|
}
|
|
1259
1263
|
default:
|
|
1260
1264
|
throw new Error(`Invalid stream version: ${t.version}`);
|
|
1261
1265
|
}
|
|
1262
1266
|
}
|
|
1263
|
-
const
|
|
1264
|
-
function
|
|
1267
|
+
const rn = "cht";
|
|
1268
|
+
function an() {
|
|
1265
1269
|
return {
|
|
1266
1270
|
transport_provider: ye.Livekit
|
|
1267
1271
|
};
|
|
1268
1272
|
}
|
|
1269
|
-
function
|
|
1270
|
-
var
|
|
1271
|
-
const { streamOptions: t } = e ?? {}, a = ((
|
|
1273
|
+
function on(e) {
|
|
1274
|
+
var s, o;
|
|
1275
|
+
const { streamOptions: t } = e ?? {}, a = ((s = e == null ? void 0 : e.mixpanelAdditionalProperties) == null ? void 0 : s.plan) !== void 0 ? {
|
|
1272
1276
|
plan: (o = e.mixpanelAdditionalProperties) == null ? void 0 : o.plan
|
|
1273
1277
|
} : void 0;
|
|
1274
1278
|
return { ...{
|
|
@@ -1279,22 +1283,22 @@ function an(e) {
|
|
|
1279
1283
|
fluent: t == null ? void 0 : t.fluent
|
|
1280
1284
|
}, ...a && { end_user_data: a } };
|
|
1281
1285
|
}
|
|
1282
|
-
function
|
|
1283
|
-
return Ie(e.presenter.type) ? { version: Ee.V2, ...
|
|
1286
|
+
function sn(e, t) {
|
|
1287
|
+
return Ie(e.presenter.type) ? { version: Ee.V2, ...an() } : { version: Ee.V1, ...on(t) };
|
|
1284
1288
|
}
|
|
1285
|
-
function
|
|
1286
|
-
|
|
1289
|
+
function cn(e, t, a, n, s) {
|
|
1290
|
+
s === ae.Fluent ? dn(e, t, a, n, s) : ln(e, t, a, n, s);
|
|
1287
1291
|
}
|
|
1288
|
-
function
|
|
1289
|
-
e === C.Start ? n.track("stream-session", { event: "start", "stream-type":
|
|
1292
|
+
function dn(e, t, a, n, s) {
|
|
1293
|
+
e === C.Start ? n.track("stream-session", { event: "start", "stream-type": s }) : e === C.Stop && n.track("stream-session", {
|
|
1290
1294
|
event: "stop",
|
|
1291
1295
|
is_greenscreen: t.presenter.type === "clip" && t.presenter.is_greenscreen,
|
|
1292
1296
|
background: t.presenter.type === "clip" && t.presenter.background,
|
|
1293
|
-
"stream-type":
|
|
1297
|
+
"stream-type": s,
|
|
1294
1298
|
...a
|
|
1295
1299
|
});
|
|
1296
1300
|
}
|
|
1297
|
-
function
|
|
1301
|
+
function un(e, t, a, n) {
|
|
1298
1302
|
ie.get() <= 0 || (e === C.Start ? a.linkTrack(
|
|
1299
1303
|
"agent-video",
|
|
1300
1304
|
{ event: "start", latency: ie.get(!0), "stream-type": n },
|
|
@@ -1312,10 +1316,10 @@ function dn(e, t, a, n) {
|
|
|
1312
1316
|
[j.StreamVideoDone]
|
|
1313
1317
|
));
|
|
1314
1318
|
}
|
|
1315
|
-
function
|
|
1319
|
+
function ln(e, t, a, n, s) {
|
|
1316
1320
|
ie.get() <= 0 || (e === C.Start ? n.linkTrack(
|
|
1317
1321
|
"agent-video",
|
|
1318
|
-
{ event: "start", latency: ie.get(!0), "stream-type":
|
|
1322
|
+
{ event: "start", latency: ie.get(!0), "stream-type": s },
|
|
1319
1323
|
"start",
|
|
1320
1324
|
[j.StreamVideoCreated]
|
|
1321
1325
|
) : e === C.Stop && n.linkTrack(
|
|
@@ -1324,21 +1328,21 @@ function un(e, t, a, n, c) {
|
|
|
1324
1328
|
event: "stop",
|
|
1325
1329
|
is_greenscreen: t.presenter.type === "clip" && t.presenter.is_greenscreen,
|
|
1326
1330
|
background: t.presenter.type === "clip" && t.presenter.background,
|
|
1327
|
-
"stream-type":
|
|
1331
|
+
"stream-type": s,
|
|
1328
1332
|
...a
|
|
1329
1333
|
},
|
|
1330
1334
|
"done",
|
|
1331
1335
|
[j.StreamVideoDone]
|
|
1332
1336
|
));
|
|
1333
1337
|
}
|
|
1334
|
-
function
|
|
1335
|
-
return ie.reset(),
|
|
1338
|
+
function Ke(e, t, a, n) {
|
|
1339
|
+
return ie.reset(), Fe.update(), new Promise(async (s, o) => {
|
|
1336
1340
|
try {
|
|
1337
|
-
let
|
|
1338
|
-
const r =
|
|
1341
|
+
let c, i = !1;
|
|
1342
|
+
const r = sn(e, t);
|
|
1339
1343
|
a.enrich({
|
|
1340
1344
|
"stream-version": r.version.toString()
|
|
1341
|
-
}),
|
|
1345
|
+
}), c = await nn(
|
|
1342
1346
|
e,
|
|
1343
1347
|
r,
|
|
1344
1348
|
{
|
|
@@ -1347,100 +1351,100 @@ function Ne(e, t, a, n) {
|
|
|
1347
1351
|
callbacks: {
|
|
1348
1352
|
...t.callbacks,
|
|
1349
1353
|
onConnectionStateChange: (d) => {
|
|
1350
|
-
var
|
|
1351
|
-
(
|
|
1354
|
+
var w, p;
|
|
1355
|
+
(p = (w = t.callbacks).onConnectionStateChange) == null || p.call(w, d), d === S.Connected && (c ? s(c) : i = !0);
|
|
1352
1356
|
},
|
|
1353
|
-
onVideoStateChange: (d,
|
|
1354
|
-
var
|
|
1355
|
-
(u = (
|
|
1357
|
+
onVideoStateChange: (d, w) => {
|
|
1358
|
+
var p, u;
|
|
1359
|
+
(u = (p = t.callbacks).onVideoStateChange) == null || u.call(p, d), cn(
|
|
1356
1360
|
d,
|
|
1357
1361
|
e,
|
|
1358
|
-
|
|
1362
|
+
w,
|
|
1359
1363
|
a,
|
|
1360
|
-
|
|
1364
|
+
c.streamType
|
|
1361
1365
|
);
|
|
1362
1366
|
},
|
|
1363
1367
|
onAgentActivityStateChange: (d) => {
|
|
1364
|
-
var
|
|
1365
|
-
(
|
|
1366
|
-
d ===
|
|
1368
|
+
var w, p;
|
|
1369
|
+
(p = (w = t.callbacks).onAgentActivityStateChange) == null || p.call(w, d), d === q.Talking ? Re.update() : Re.reset(), un(
|
|
1370
|
+
d === q.Talking ? C.Start : C.Stop,
|
|
1367
1371
|
e,
|
|
1368
1372
|
a,
|
|
1369
|
-
|
|
1373
|
+
c.streamType
|
|
1370
1374
|
);
|
|
1371
1375
|
},
|
|
1372
1376
|
onStreamReady: () => {
|
|
1373
|
-
const d =
|
|
1377
|
+
const d = Fe.get(!0);
|
|
1374
1378
|
a.track("agent-chat", { event: "ready", latency: d });
|
|
1375
1379
|
}
|
|
1376
1380
|
}
|
|
1377
1381
|
},
|
|
1378
1382
|
n
|
|
1379
|
-
), i && c
|
|
1380
|
-
} catch (
|
|
1381
|
-
o(
|
|
1383
|
+
), i && s(c);
|
|
1384
|
+
} catch (c) {
|
|
1385
|
+
o(c);
|
|
1382
1386
|
}
|
|
1383
1387
|
});
|
|
1384
1388
|
}
|
|
1385
|
-
async function
|
|
1386
|
-
var
|
|
1389
|
+
async function fn(e, t, a, n, s) {
|
|
1390
|
+
var w, p, u, P;
|
|
1387
1391
|
const o = async () => {
|
|
1388
1392
|
if (Ie(e.presenter.type)) {
|
|
1389
|
-
const $ = await
|
|
1393
|
+
const $ = await Ke(e, t, n), B = `${rn}_${$.sessionId}`, R = (/* @__PURE__ */ new Date()).toISOString();
|
|
1390
1394
|
return { chatResult: {
|
|
1391
|
-
chatMode:
|
|
1395
|
+
chatMode: N.Functional,
|
|
1392
1396
|
chat: {
|
|
1393
|
-
id:
|
|
1397
|
+
id: B,
|
|
1394
1398
|
agent_id: e.id,
|
|
1395
1399
|
owner_id: e.owner_id ?? "",
|
|
1396
|
-
created:
|
|
1397
|
-
modified:
|
|
1398
|
-
agent_id__created_at:
|
|
1399
|
-
agent_id__modified_at:
|
|
1400
|
-
chat_mode:
|
|
1400
|
+
created: R,
|
|
1401
|
+
modified: R,
|
|
1402
|
+
agent_id__created_at: R,
|
|
1403
|
+
agent_id__modified_at: R,
|
|
1404
|
+
chat_mode: N.Functional,
|
|
1401
1405
|
messages: []
|
|
1402
1406
|
}
|
|
1403
1407
|
}, streamingManager: $ };
|
|
1404
1408
|
} else {
|
|
1405
|
-
const $ = new AbortController(),
|
|
1406
|
-
let
|
|
1409
|
+
const $ = new AbortController(), B = $.signal;
|
|
1410
|
+
let R;
|
|
1407
1411
|
try {
|
|
1408
|
-
const
|
|
1412
|
+
const M = He(
|
|
1409
1413
|
e,
|
|
1410
1414
|
a,
|
|
1411
1415
|
n,
|
|
1412
1416
|
t.mode,
|
|
1413
1417
|
t.persistentChat,
|
|
1414
|
-
|
|
1415
|
-
), z =
|
|
1416
|
-
return { chatResult:
|
|
1417
|
-
} catch (
|
|
1418
|
-
throw $.abort(),
|
|
1419
|
-
}),
|
|
1418
|
+
s
|
|
1419
|
+
), z = Ke(e, t, n, B).then((ee) => (R = ee, ee)), [T, W] = await Promise.all([M, z]);
|
|
1420
|
+
return { chatResult: T, streamingManager: W };
|
|
1421
|
+
} catch (M) {
|
|
1422
|
+
throw $.abort(), R && await R.disconnect().catch(() => {
|
|
1423
|
+
}), M;
|
|
1420
1424
|
}
|
|
1421
1425
|
}
|
|
1422
|
-
}, { chatResult:
|
|
1423
|
-
return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (
|
|
1426
|
+
}, { chatResult: c, streamingManager: i } = await o(), { chat: r, chatMode: d } = c;
|
|
1427
|
+
return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (p = (w = t.callbacks).onModeChange) == null || p.call(w, d), d !== N.Functional) ? ((P = (u = t.callbacks).onError) == null || P.call(u, new Ze(d)), i == null || i.disconnect(), { chat: r }) : { chat: r, streamingManager: i };
|
|
1424
1428
|
}
|
|
1425
|
-
async function
|
|
1426
|
-
var
|
|
1429
|
+
async function hn(e, t) {
|
|
1430
|
+
var E, G, Z;
|
|
1427
1431
|
let a = !0, n = null;
|
|
1428
|
-
const
|
|
1432
|
+
const s = t.mixpanelKey || mt, o = t.wsURL || ft, c = t.baseURL || ge, i = t.mode || N.Functional, r = {
|
|
1429
1433
|
messages: [],
|
|
1430
1434
|
chatMode: i
|
|
1431
|
-
}, d =
|
|
1432
|
-
token:
|
|
1435
|
+
}, d = Dt({
|
|
1436
|
+
token: s,
|
|
1433
1437
|
agentId: e,
|
|
1434
1438
|
isEnabled: t.enableAnalitics,
|
|
1435
1439
|
externalId: t.externalId,
|
|
1436
1440
|
mixpanelAdditionalProperties: t.mixpanelAdditionalProperties
|
|
1437
|
-
}),
|
|
1438
|
-
|
|
1439
|
-
d.track("agent-sdk", { event: "init" },
|
|
1441
|
+
}), w = Date.now();
|
|
1442
|
+
Be(() => {
|
|
1443
|
+
d.track("agent-sdk", { event: "init" }, w);
|
|
1440
1444
|
});
|
|
1441
|
-
const
|
|
1442
|
-
d.enrich(
|
|
1443
|
-
const { onMessage: $, clearQueue:
|
|
1445
|
+
const p = yt(t.auth, c, t.callbacks.onError, t.externalId), u = await p.getById(e), P = Ie(u.presenter.type);
|
|
1446
|
+
d.enrich(St(u));
|
|
1447
|
+
const { onMessage: $, clearQueue: B } = zt(
|
|
1444
1448
|
d,
|
|
1445
1449
|
r,
|
|
1446
1450
|
t,
|
|
@@ -1450,70 +1454,70 @@ async function gn(e, t) {
|
|
|
1450
1454
|
return (f = r.socketManager) == null ? void 0 : f.disconnect();
|
|
1451
1455
|
}
|
|
1452
1456
|
);
|
|
1453
|
-
r.messages =
|
|
1454
|
-
const
|
|
1457
|
+
r.messages = Et(t.initialMessages), (G = (E = t.callbacks).onNewMessage) == null || G.call(E, [...r.messages], "answer");
|
|
1458
|
+
const R = (f) => {
|
|
1455
1459
|
n = f;
|
|
1456
|
-
},
|
|
1457
|
-
var k,
|
|
1460
|
+
}, M = ({ type: f }) => {
|
|
1461
|
+
var k, _, b;
|
|
1458
1462
|
const y = r.messages[r.messages.length - 1];
|
|
1459
1463
|
d.track("agent-video-interrupt", {
|
|
1460
1464
|
type: f || "click",
|
|
1461
1465
|
video_duration_to_interrupt: Re.get(!0),
|
|
1462
1466
|
message_duration_to_interrupt: ie.get(!0)
|
|
1463
|
-
}), y.interrupted = !0, (
|
|
1467
|
+
}), y.interrupted = !0, (_ = (k = t.callbacks).onNewMessage) == null || _.call(k, [...r.messages], "answer"), P ? Lt(r.streamingManager) : (Pt(r.streamingManager, (b = r.streamingManager) == null ? void 0 : b.streamType, n), bt(r.streamingManager, n));
|
|
1464
1468
|
}, z = Date.now();
|
|
1465
|
-
|
|
1466
|
-
d.track("agent-sdk", { event: "loaded", ...
|
|
1469
|
+
Be(() => {
|
|
1470
|
+
d.track("agent-sdk", { event: "loaded", ...vt(u) }, z);
|
|
1467
1471
|
});
|
|
1468
|
-
async function
|
|
1469
|
-
var
|
|
1470
|
-
(H = (
|
|
1471
|
-
const y = i ===
|
|
1472
|
+
async function T(f) {
|
|
1473
|
+
var U, H, Q, L, K, X, oe;
|
|
1474
|
+
(H = (U = t.callbacks).onConnectionStateChange) == null || H.call(U, S.Connecting), ie.reset(), f && !a && (delete r.chat, (L = (Q = t.callbacks).onNewMessage) == null || L.call(Q, [...r.messages], "answer"));
|
|
1475
|
+
const y = i === N.DirectPlayback || P ? Promise.resolve(void 0) : xt(
|
|
1472
1476
|
t.auth,
|
|
1473
1477
|
o,
|
|
1474
1478
|
{ onMessage: $, onError: t.callbacks.onError },
|
|
1475
1479
|
t.externalId
|
|
1476
1480
|
), k = Ce(
|
|
1477
|
-
() =>
|
|
1481
|
+
() => fn(
|
|
1478
1482
|
u,
|
|
1479
1483
|
{
|
|
1480
1484
|
...t,
|
|
1481
1485
|
mode: i,
|
|
1482
1486
|
callbacks: {
|
|
1483
1487
|
...t.callbacks,
|
|
1484
|
-
onVideoIdChange:
|
|
1488
|
+
onVideoIdChange: R,
|
|
1485
1489
|
onMessage: $,
|
|
1486
|
-
onInterruptDetected:
|
|
1490
|
+
onInterruptDetected: M
|
|
1487
1491
|
}
|
|
1488
1492
|
},
|
|
1489
|
-
|
|
1493
|
+
p,
|
|
1490
1494
|
d,
|
|
1491
1495
|
r.chat
|
|
1492
1496
|
),
|
|
1493
1497
|
{
|
|
1494
1498
|
limit: 3,
|
|
1495
|
-
timeout:
|
|
1499
|
+
timeout: ut,
|
|
1496
1500
|
timeoutErrorMessage: "Timeout initializing the stream",
|
|
1497
|
-
shouldRetryFn: (
|
|
1501
|
+
shouldRetryFn: (V) => (V == null ? void 0 : V.message) !== "Could not connect" && V.status !== 429 && (V == null ? void 0 : V.message) !== "InsufficientCreditsError",
|
|
1498
1502
|
delayMs: 1e3
|
|
1499
1503
|
}
|
|
1500
|
-
).catch((
|
|
1501
|
-
var m,
|
|
1502
|
-
throw ee(
|
|
1503
|
-
}), [
|
|
1504
|
-
|
|
1505
|
-
chatId:
|
|
1506
|
-
streamId:
|
|
1504
|
+
).catch((V) => {
|
|
1505
|
+
var m, h;
|
|
1506
|
+
throw ee(N.Maintenance), (h = (m = t.callbacks).onConnectionStateChange) == null || h.call(m, S.Fail), V;
|
|
1507
|
+
}), [_, { streamingManager: b, chat: I }] = await Promise.all([y, k]);
|
|
1508
|
+
I && I.id !== ((K = r.chat) == null ? void 0 : K.id) && ((oe = (X = t.callbacks).onNewChat) == null || oe.call(X, I.id)), r.streamingManager = b, r.socketManager = _, r.chat = I, a = !1, d.enrich({
|
|
1509
|
+
chatId: I == null ? void 0 : I.id,
|
|
1510
|
+
streamId: b == null ? void 0 : b.streamId,
|
|
1507
1511
|
mode: r.chatMode
|
|
1508
|
-
}), ee((
|
|
1512
|
+
}), ee((I == null ? void 0 : I.chat_mode) ?? i);
|
|
1509
1513
|
}
|
|
1510
1514
|
async function W() {
|
|
1511
|
-
var f, y, k,
|
|
1512
|
-
(f = r.socketManager) == null || f.disconnect(), await ((y = r.streamingManager) == null ? void 0 : y.disconnect()), delete r.streamingManager, delete r.socketManager, (
|
|
1515
|
+
var f, y, k, _;
|
|
1516
|
+
(f = r.socketManager) == null || f.disconnect(), await ((y = r.streamingManager) == null ? void 0 : y.disconnect()), delete r.streamingManager, delete r.socketManager, (_ = (k = t.callbacks).onConnectionStateChange) == null || _.call(k, S.Disconnected);
|
|
1513
1517
|
}
|
|
1514
1518
|
async function ee(f) {
|
|
1515
1519
|
var y, k;
|
|
1516
|
-
f !== r.chatMode && (d.track("agent-mode-change", { mode: f }), r.chatMode = f, r.chatMode !==
|
|
1520
|
+
f !== r.chatMode && (d.track("agent-mode-change", { mode: f }), r.chatMode = f, r.chatMode !== N.Functional && await W(), (k = (y = t.callbacks).onModeChange) == null || k.call(y, f));
|
|
1517
1521
|
}
|
|
1518
1522
|
return {
|
|
1519
1523
|
agent: u,
|
|
@@ -1530,29 +1534,29 @@ async function gn(e, t) {
|
|
|
1530
1534
|
return ((f = r.streamingManager) == null ? void 0 : f.triggersAvailable) ?? !1;
|
|
1531
1535
|
},
|
|
1532
1536
|
starterMessages: ((Z = u.knowledge) == null ? void 0 : Z.starter_message) || [],
|
|
1533
|
-
getSTTToken: () =>
|
|
1537
|
+
getSTTToken: () => p.getSTTToken(u.id),
|
|
1534
1538
|
changeMode: ee,
|
|
1535
1539
|
enrichAnalytics: d.enrich,
|
|
1536
1540
|
async connect() {
|
|
1537
|
-
await
|
|
1541
|
+
await T(!0), d.track("agent-chat", {
|
|
1538
1542
|
event: "connect",
|
|
1539
1543
|
mode: r.chatMode
|
|
1540
1544
|
});
|
|
1541
1545
|
},
|
|
1542
1546
|
async reconnect() {
|
|
1543
1547
|
const f = r.streamingManager;
|
|
1544
|
-
if (
|
|
1548
|
+
if (P && (f != null && f.reconnect)) {
|
|
1545
1549
|
try {
|
|
1546
1550
|
await f.reconnect(), d.track("agent-chat", {
|
|
1547
1551
|
event: "reconnect",
|
|
1548
1552
|
mode: r.chatMode
|
|
1549
1553
|
});
|
|
1550
1554
|
} catch {
|
|
1551
|
-
await W(), await
|
|
1555
|
+
await W(), await T(!1);
|
|
1552
1556
|
}
|
|
1553
1557
|
return;
|
|
1554
1558
|
}
|
|
1555
|
-
await W(), await
|
|
1559
|
+
await W(), await T(!1), d.track("agent-chat", {
|
|
1556
1560
|
event: "reconnect",
|
|
1557
1561
|
mode: r.chatMode
|
|
1558
1562
|
});
|
|
@@ -1576,132 +1580,132 @@ async function gn(e, t) {
|
|
|
1576
1580
|
return r.streamingManager.unpublishMicrophoneStream();
|
|
1577
1581
|
},
|
|
1578
1582
|
async chat(f) {
|
|
1579
|
-
var
|
|
1583
|
+
var b, I, U, H, Q;
|
|
1580
1584
|
const y = () => {
|
|
1581
|
-
if (
|
|
1582
|
-
throw new
|
|
1585
|
+
if (Ve(i))
|
|
1586
|
+
throw new de(`${i} is enabled, chat is disabled`);
|
|
1583
1587
|
if (f.length >= 800)
|
|
1584
|
-
throw new
|
|
1588
|
+
throw new de("Message cannot be more than 800 characters");
|
|
1585
1589
|
if (f.length === 0)
|
|
1586
|
-
throw new
|
|
1587
|
-
if (r.chatMode ===
|
|
1588
|
-
throw new
|
|
1589
|
-
if (![
|
|
1590
|
+
throw new de("Message cannot be empty");
|
|
1591
|
+
if (r.chatMode === N.Maintenance)
|
|
1592
|
+
throw new de("Chat is in maintenance mode");
|
|
1593
|
+
if (![N.TextOnly, N.Playground].includes(r.chatMode)) {
|
|
1590
1594
|
if (!r.streamingManager)
|
|
1591
|
-
throw new
|
|
1595
|
+
throw new de("Streaming manager is not initialized");
|
|
1592
1596
|
if (!r.chat)
|
|
1593
|
-
throw new
|
|
1597
|
+
throw new de("Chat is not initialized");
|
|
1594
1598
|
}
|
|
1595
1599
|
}, k = async () => {
|
|
1596
|
-
var
|
|
1600
|
+
var L, K;
|
|
1597
1601
|
if (!r.chat) {
|
|
1598
|
-
const X = await
|
|
1602
|
+
const X = await He(
|
|
1599
1603
|
u,
|
|
1600
|
-
|
|
1604
|
+
p,
|
|
1601
1605
|
d,
|
|
1602
1606
|
r.chatMode,
|
|
1603
1607
|
t.persistentChat
|
|
1604
1608
|
);
|
|
1605
1609
|
if (!X.chat)
|
|
1606
|
-
throw new
|
|
1607
|
-
r.chat = X.chat, (
|
|
1610
|
+
throw new Ge(r.chatMode, !!t.persistentChat);
|
|
1611
|
+
r.chat = X.chat, (K = (L = t.callbacks).onNewChat) == null || K.call(L, r.chat.id);
|
|
1608
1612
|
}
|
|
1609
1613
|
return r.chat.id;
|
|
1610
|
-
},
|
|
1611
|
-
const X = r.chatMode ===
|
|
1612
|
-
return Ce(
|
|
1613
|
-
var m,
|
|
1614
|
-
return await ((
|
|
1614
|
+
}, _ = async (L, K) => {
|
|
1615
|
+
const X = r.chatMode === N.Playground;
|
|
1616
|
+
return Ce(P && !X ? async () => {
|
|
1617
|
+
var m, h;
|
|
1618
|
+
return await ((h = (m = r.streamingManager) == null ? void 0 : m.sendTextMessage) == null ? void 0 : h.call(m, f)), Promise.resolve({});
|
|
1615
1619
|
} : async () => {
|
|
1616
|
-
var m,
|
|
1617
|
-
return
|
|
1620
|
+
var m, h;
|
|
1621
|
+
return p.chat(
|
|
1618
1622
|
u.id,
|
|
1619
|
-
|
|
1623
|
+
K,
|
|
1620
1624
|
{
|
|
1621
1625
|
chatMode: r.chatMode,
|
|
1622
1626
|
streamId: (m = r.streamingManager) == null ? void 0 : m.streamId,
|
|
1623
|
-
sessionId: (
|
|
1624
|
-
messages:
|
|
1627
|
+
sessionId: (h = r.streamingManager) == null ? void 0 : h.sessionId,
|
|
1628
|
+
messages: L.map(({ matches: F, ...J }) => J)
|
|
1625
1629
|
},
|
|
1626
1630
|
{
|
|
1627
|
-
...
|
|
1631
|
+
...qe(r.chatMode),
|
|
1628
1632
|
skipErrorHandler: !0
|
|
1629
1633
|
}
|
|
1630
1634
|
);
|
|
1631
1635
|
}, {
|
|
1632
1636
|
limit: 2,
|
|
1633
1637
|
shouldRetryFn: (m) => {
|
|
1634
|
-
var
|
|
1635
|
-
const
|
|
1636
|
-
return !((he = m == null ? void 0 : m.message) == null ? void 0 : he.includes("Stream Error")) && !
|
|
1638
|
+
var J, he, pe, se;
|
|
1639
|
+
const h = (J = m == null ? void 0 : m.message) == null ? void 0 : J.includes("missing or invalid session_id");
|
|
1640
|
+
return !((he = m == null ? void 0 : m.message) == null ? void 0 : he.includes("Stream Error")) && !h ? ((se = (pe = t.callbacks).onError) == null || se.call(pe, m), !1) : !0;
|
|
1637
1641
|
},
|
|
1638
1642
|
onRetry: async () => {
|
|
1639
|
-
await W(), await
|
|
1643
|
+
await W(), await T(!1);
|
|
1640
1644
|
}
|
|
1641
1645
|
});
|
|
1642
1646
|
};
|
|
1643
1647
|
try {
|
|
1644
|
-
|
|
1645
|
-
id:
|
|
1648
|
+
B(), y(), r.messages.push({
|
|
1649
|
+
id: ue(),
|
|
1646
1650
|
role: "user",
|
|
1647
1651
|
content: f,
|
|
1648
1652
|
created_at: new Date(ie.update()).toISOString()
|
|
1649
|
-
}), (
|
|
1650
|
-
const
|
|
1653
|
+
}), (I = (b = t.callbacks).onNewMessage) == null || I.call(b, [...r.messages], "user");
|
|
1654
|
+
const L = await k(), K = await _([...r.messages], L);
|
|
1651
1655
|
return r.messages.push({
|
|
1652
|
-
id:
|
|
1656
|
+
id: ue(),
|
|
1653
1657
|
role: "assistant",
|
|
1654
|
-
content:
|
|
1658
|
+
content: K.result || "",
|
|
1655
1659
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1656
|
-
context:
|
|
1657
|
-
matches:
|
|
1660
|
+
context: K.context,
|
|
1661
|
+
matches: K.matches
|
|
1658
1662
|
}), d.track("agent-message-send", {
|
|
1659
1663
|
event: "success",
|
|
1660
1664
|
messages: r.messages.length + 1
|
|
1661
|
-
}),
|
|
1665
|
+
}), K.result && ((H = (U = t.callbacks).onNewMessage) == null || H.call(U, [...r.messages], "answer"), d.track("agent-message-received", {
|
|
1662
1666
|
latency: ie.get(!0),
|
|
1663
1667
|
messages: r.messages.length
|
|
1664
|
-
})),
|
|
1665
|
-
} catch (
|
|
1668
|
+
})), K;
|
|
1669
|
+
} catch (L) {
|
|
1666
1670
|
throw ((Q = r.messages[r.messages.length - 1]) == null ? void 0 : Q.role) === "assistant" && r.messages.pop(), d.track("agent-message-send", {
|
|
1667
1671
|
event: "error",
|
|
1668
1672
|
messages: r.messages.length
|
|
1669
|
-
}),
|
|
1673
|
+
}), L;
|
|
1670
1674
|
}
|
|
1671
1675
|
},
|
|
1672
1676
|
rate(f, y, k) {
|
|
1673
|
-
var
|
|
1674
|
-
const
|
|
1677
|
+
var I, U, H, Q;
|
|
1678
|
+
const _ = r.messages.find((L) => L.id === f);
|
|
1675
1679
|
if (r.chat) {
|
|
1676
|
-
if (!
|
|
1680
|
+
if (!_)
|
|
1677
1681
|
throw new Error("Message not found");
|
|
1678
1682
|
} else throw new Error("Chat is not initialized");
|
|
1679
|
-
const
|
|
1683
|
+
const b = ((I = _.matches) == null ? void 0 : I.map((L) => [L.document_id, L.id])) ?? [];
|
|
1680
1684
|
return d.track("agent-rate", {
|
|
1681
1685
|
event: k ? "update" : "create",
|
|
1682
1686
|
thumb: y === 1 ? "up" : "down",
|
|
1683
|
-
knowledge_id: ((
|
|
1684
|
-
matches:
|
|
1687
|
+
knowledge_id: ((U = u.knowledge) == null ? void 0 : U.id) ?? "",
|
|
1688
|
+
matches: b,
|
|
1685
1689
|
score: y
|
|
1686
|
-
}), k ?
|
|
1690
|
+
}), k ? p.updateRating(u.id, r.chat.id, k, {
|
|
1687
1691
|
knowledge_id: ((H = u.knowledge) == null ? void 0 : H.id) ?? "",
|
|
1688
1692
|
message_id: f,
|
|
1689
|
-
matches:
|
|
1693
|
+
matches: b,
|
|
1690
1694
|
score: y
|
|
1691
|
-
}) :
|
|
1695
|
+
}) : p.createRating(u.id, r.chat.id, {
|
|
1692
1696
|
knowledge_id: ((Q = u.knowledge) == null ? void 0 : Q.id) ?? "",
|
|
1693
1697
|
message_id: f,
|
|
1694
|
-
matches:
|
|
1698
|
+
matches: b,
|
|
1695
1699
|
score: y
|
|
1696
1700
|
});
|
|
1697
1701
|
},
|
|
1698
1702
|
deleteRate(f) {
|
|
1699
1703
|
if (!r.chat)
|
|
1700
1704
|
throw new Error("Chat is not initialized");
|
|
1701
|
-
return d.track("agent-rate-delete", { type: "text" }),
|
|
1705
|
+
return d.track("agent-rate-delete", { type: "text" }), p.deleteRating(u.id, r.chat.id, f);
|
|
1702
1706
|
},
|
|
1703
1707
|
async speak(f) {
|
|
1704
|
-
var
|
|
1708
|
+
var b, I, U;
|
|
1705
1709
|
function y() {
|
|
1706
1710
|
if (typeof f == "string") {
|
|
1707
1711
|
if (!u.presenter.voice)
|
|
@@ -1727,11 +1731,11 @@ async function gn(e, t) {
|
|
|
1727
1731
|
}
|
|
1728
1732
|
const k = y();
|
|
1729
1733
|
if (d.track("agent-speak", k), ie.update(), r.messages && k.type === "text" && (r.messages.push({
|
|
1730
|
-
id:
|
|
1734
|
+
id: ue(),
|
|
1731
1735
|
role: "assistant",
|
|
1732
1736
|
content: k.input,
|
|
1733
1737
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1734
|
-
}), (
|
|
1738
|
+
}), (I = (b = t.callbacks).onNewMessage) == null || I.call(b, [...r.messages], "answer")), gt(r.chatMode))
|
|
1735
1739
|
return {
|
|
1736
1740
|
duration: 0,
|
|
1737
1741
|
video_id: "",
|
|
@@ -1741,36 +1745,36 @@ async function gn(e, t) {
|
|
|
1741
1745
|
throw new Error("Please connect to the agent first");
|
|
1742
1746
|
return r.streamingManager.speak({
|
|
1743
1747
|
script: k,
|
|
1744
|
-
metadata: { chat_id: (
|
|
1748
|
+
metadata: { chat_id: (U = r.chat) == null ? void 0 : U.id, agent_id: u.id }
|
|
1745
1749
|
});
|
|
1746
1750
|
},
|
|
1747
|
-
interrupt:
|
|
1751
|
+
interrupt: M
|
|
1748
1752
|
};
|
|
1749
1753
|
}
|
|
1750
1754
|
export {
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1755
|
+
q as AgentActivityState,
|
|
1756
|
+
rt as AgentStatus,
|
|
1757
|
+
Ge as ChatCreationFailed,
|
|
1758
|
+
N as ChatMode,
|
|
1759
|
+
Ze as ChatModeDowngraded,
|
|
1756
1760
|
Y as ChatProgress,
|
|
1757
1761
|
S as ConnectionState,
|
|
1758
1762
|
re as ConnectivityState,
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1763
|
+
st as DocumentType,
|
|
1764
|
+
ot as KnowledgeType,
|
|
1765
|
+
nt as PlanGroup,
|
|
1766
|
+
ct as Providers,
|
|
1767
|
+
it as RateState,
|
|
1764
1768
|
j as StreamEvents,
|
|
1765
1769
|
ae as StreamType,
|
|
1766
1770
|
C as StreamingState,
|
|
1767
|
-
|
|
1771
|
+
at as Subject,
|
|
1768
1772
|
ye as TransportProvider,
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1773
|
+
tt as UserPlan,
|
|
1774
|
+
de as ValidationError,
|
|
1775
|
+
Je as VideoType,
|
|
1776
|
+
dt as VoiceAccess,
|
|
1777
|
+
et as WsError,
|
|
1778
|
+
hn as createAgentManager,
|
|
1779
|
+
gn as mapVideoType
|
|
1776
1780
|
};
|