@d-id/client-sdk 1.1.65-staging.302 → 1.1.65-staging.305
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var Z = (e, t, r) =>
|
|
1
|
+
var We = Object.defineProperty;
|
|
2
|
+
var Je = (e, t, r) => t in e ? We(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var Z = (e, t, r) => Je(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
4
|
class ce extends Error {
|
|
5
5
|
constructor({ kind: r, description: a, error: c }) {
|
|
6
6
|
super(JSON.stringify({ kind: r, description: a }));
|
|
@@ -35,8 +35,8 @@ class qe extends ce {
|
|
|
35
35
|
super({ kind: "WSError", description: t });
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
var Xe = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(Xe || {}), Ye = /* @__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))(Ye || {}), Ge = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(Ge || {}), Qe = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(Qe || {}), x = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(x || {}),
|
|
39
|
-
const
|
|
38
|
+
var Xe = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(Xe || {}), Ye = /* @__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))(Ye || {}), Ge = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(Ge || {}), Qe = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(Qe || {}), x = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(x || {}), U = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(U || {}), Ze = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(Ze || {}), et = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(et || {}), tt = /* @__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))(tt || {}), Pe = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(Pe || {});
|
|
39
|
+
const sr = (e) => {
|
|
40
40
|
switch (e) {
|
|
41
41
|
case "clip":
|
|
42
42
|
return "clip";
|
|
@@ -48,8 +48,8 @@ const ar = (e) => {
|
|
|
48
48
|
throw new Error(`Unknown video type: ${e}`);
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
var S = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(S || {}), te = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(te || {}), ne = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e.ToolActive = "TOOL_ACTIVE", e))(ne || {}), P = /* @__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.ToolCallStarted = "tool-call/started", e.ToolCallDone = "tool-call/done", e.ToolCallError = "tool-call/error", e))(P || {}), L = /* @__PURE__ */ ((e) => (e.New = "new", e.Fail = "fail", e.Connected = "connected", e.Connecting = "connecting", e.Closed = "closed", e.Completed = "completed", e.Disconnecting = "disconnecting", e.Disconnected = "disconnected", e))(L || {}),
|
|
52
|
-
const at = 45 * 1e3, it = "X-Playground-Chat", de = "https://api.d-id.com", st = "wss://notifications.d-id.com", ot = "79f81a83a67430be2bc0fd61042b8faa",
|
|
51
|
+
var S = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(S || {}), te = /* @__PURE__ */ ((e) => (e.Strong = "STRONG", e.Weak = "WEAK", e.Unknown = "UNKNOWN", e))(te || {}), ne = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e.ToolActive = "TOOL_ACTIVE", e))(ne || {}), P = /* @__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.ToolCallStarted = "tool-call/started", e.ToolCallDone = "tool-call/done", e.ToolCallError = "tool-call/error", e))(P || {}), L = /* @__PURE__ */ ((e) => (e.New = "new", e.Fail = "fail", e.Connected = "connected", e.Connecting = "connecting", e.Closed = "closed", e.Completed = "completed", e.Disconnecting = "disconnecting", e.Disconnected = "disconnected", e))(L || {}), W = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(W || {}), he = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(he || {}), rt = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(rt || {}), nt = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(nt || {});
|
|
52
|
+
const at = 45 * 1e3, it = "X-Playground-Chat", de = "https://api.d-id.com", st = "wss://notifications.d-id.com", ot = "79f81a83a67430be2bc0fd61042b8faa", or = (...e) => {
|
|
53
53
|
}, je = (e) => new Promise((t) => setTimeout(t, e)), Q = (e = 16) => {
|
|
54
54
|
const t = new Uint8Array(e);
|
|
55
55
|
return window.crypto.getRandomValues(t), Array.from(t, (r) => r.toString(16).padStart(2, "0")).join("").slice(0, 13);
|
|
@@ -62,8 +62,13 @@ const at = 45 * 1e3, it = "X-Playground-Chat", de = "https://api.d-id.com", st =
|
|
|
62
62
|
case "talk":
|
|
63
63
|
return "v2";
|
|
64
64
|
}
|
|
65
|
-
}, dt = (e) => e.type === "talk" ? e.source_url : e.presenter_id, pe = (e) => e === Pe.Expressive, lt = (e) => [x.TextOnly, x.Playground, x.Maintenance].includes(e), $e = (e) => e && [x.DirectPlayback, x.Off].includes(e), Se = /\[!\[([^\[\]]*)\]\(([^)\s]+)\)\]\(([^)\s]+)\)/g, ke = /!\[([^\[\]]*)\]\(([^)\s]+)\)/g,
|
|
66
|
-
function
|
|
65
|
+
}, dt = (e) => e.type === "talk" ? e.source_url : e.presenter_id, pe = (e) => e === Pe.Expressive, lt = (e) => [x.TextOnly, x.Playground, x.Maintenance].includes(e), $e = (e) => e && [x.DirectPlayback, x.Off].includes(e), Se = /\[!\[([^\[\]]*)\]\(([^)\s]+)\)\]\(([^)\s]+)\)/g, ke = /!\[([^\[\]]*)\]\(([^)\s]+)\)/g, ut = [".mp4", ".webm", ".mkv", ".mov", ".m4v", ".ogv"];
|
|
66
|
+
function mt(e) {
|
|
67
|
+
const t = e.split("?")[0].split("#")[0].toLowerCase();
|
|
68
|
+
return ut.some((r) => t.endsWith(r));
|
|
69
|
+
}
|
|
70
|
+
const Re = new RegExp("(?<!!)\\[([^\\[\\]]+)\\]\\(([^)\\s]+)\\)", "g"), De = /<a\s+href="([^"]*)"[^>]*?>([^<]*)<\/a>/gi;
|
|
71
|
+
function ft(e) {
|
|
67
72
|
if (e.length === 0)
|
|
68
73
|
return [];
|
|
69
74
|
const t = [];
|
|
@@ -76,8 +81,9 @@ function ut(e) {
|
|
|
76
81
|
});
|
|
77
82
|
for (ke.lastIndex = 0; (r = ke.exec(e)) !== null; )
|
|
78
83
|
if (!t.some((o) => r.index >= o.index && r.index < o.index + o.length)) {
|
|
79
|
-
const o = r[2], n =
|
|
80
|
-
|
|
84
|
+
const o = r[2], n = r[1];
|
|
85
|
+
let i;
|
|
86
|
+
mt(o) ? i = { type: "video", src: o, alt: n } : (i = { type: "image", src: o, alt: n }, o.toLowerCase().endsWith(".gif") && (i.mimeType = "image/gif")), t.push({ index: r.index, length: r[0].length, part: i });
|
|
81
87
|
}
|
|
82
88
|
for (Re.lastIndex = 0; (r = Re.exec(e)) !== null; )
|
|
83
89
|
t.some((o) => r.index >= o.index && r.index < o.index + o.length) || t.push({
|
|
@@ -102,9 +108,9 @@ function ut(e) {
|
|
|
102
108
|
}
|
|
103
109
|
let Ie = "", le = [];
|
|
104
110
|
function re(e) {
|
|
105
|
-
return e === Ie || (Ie = e, le =
|
|
111
|
+
return e === Ie || (Ie = e, le = ft(e)), le;
|
|
106
112
|
}
|
|
107
|
-
function
|
|
113
|
+
function gt(e, t) {
|
|
108
114
|
let r;
|
|
109
115
|
return {
|
|
110
116
|
promise: new Promise((c, s) => {
|
|
@@ -128,7 +134,7 @@ async function ue(e, t) {
|
|
|
128
134
|
try {
|
|
129
135
|
if (!r.timeout)
|
|
130
136
|
return await e();
|
|
131
|
-
const { promise: s, clear: o } =
|
|
137
|
+
const { promise: s, clear: o } = gt(r.timeout, r.timeoutErrorMessage), n = e().finally(o);
|
|
132
138
|
return await Promise.race([n, s]);
|
|
133
139
|
} catch (s) {
|
|
134
140
|
if (a = s, !r.shouldRetryFn(s) || c >= r.limit)
|
|
@@ -147,17 +153,17 @@ function me(e) {
|
|
|
147
153
|
}
|
|
148
154
|
return t;
|
|
149
155
|
}
|
|
150
|
-
let
|
|
156
|
+
let ht = Q();
|
|
151
157
|
function ze(e, t) {
|
|
152
158
|
if (e.type === "bearer")
|
|
153
159
|
return `Bearer ${e.token}`;
|
|
154
160
|
if (e.type === "basic")
|
|
155
161
|
return `Basic ${"token" in e ? e.token : btoa(`${e.username}:${e.password}`)}`;
|
|
156
162
|
if (e.type === "key")
|
|
157
|
-
return `Client-Key ${e.clientKey}.${me(t)}_${
|
|
163
|
+
return `Client-Key ${e.clientKey}.${me(t)}_${ht}`;
|
|
158
164
|
throw new Error(`Unknown auth type: ${e}`);
|
|
159
165
|
}
|
|
160
|
-
const
|
|
166
|
+
const pt = (e) => ue(e, {
|
|
161
167
|
limit: 3,
|
|
162
168
|
delayMs: 1e3,
|
|
163
169
|
timeout: 0,
|
|
@@ -165,7 +171,7 @@ const gt = (e) => ue(e, {
|
|
|
165
171
|
});
|
|
166
172
|
function Fe(e, t = de, r, a) {
|
|
167
173
|
const c = async (s, o) => {
|
|
168
|
-
const { skipErrorHandler: n, ...i } = o || {}, d = await
|
|
174
|
+
const { skipErrorHandler: n, ...i } = o || {}, d = await pt(
|
|
169
175
|
() => fetch(t + (s != null && s.startsWith("/") ? s : `/${s}`), {
|
|
170
176
|
...i,
|
|
171
177
|
headers: {
|
|
@@ -197,7 +203,7 @@ function Fe(e, t = de, r, a) {
|
|
|
197
203
|
}
|
|
198
204
|
};
|
|
199
205
|
}
|
|
200
|
-
function
|
|
206
|
+
function wt(e, t = de, r, a) {
|
|
201
207
|
const c = Fe(e, `${t}/agents`, r, a);
|
|
202
208
|
return {
|
|
203
209
|
create(s, o) {
|
|
@@ -235,7 +241,7 @@ function ht(e, t = de, r, a) {
|
|
|
235
241
|
}
|
|
236
242
|
};
|
|
237
243
|
}
|
|
238
|
-
function
|
|
244
|
+
function vt(e) {
|
|
239
245
|
var c, s, o, n;
|
|
240
246
|
const t = () => /Mobi|Android/i.test(navigator.userAgent) ? "Mobile" : "Desktop", r = () => {
|
|
241
247
|
const i = navigator.platform;
|
|
@@ -253,7 +259,7 @@ function pt(e) {
|
|
|
253
259
|
}
|
|
254
260
|
};
|
|
255
261
|
}
|
|
256
|
-
function
|
|
262
|
+
function yt(e) {
|
|
257
263
|
var r, a, c, s, o, n;
|
|
258
264
|
const t = (r = e.llm) == null ? void 0 : r.prompt_customization;
|
|
259
265
|
return {
|
|
@@ -278,8 +284,8 @@ function wt(e) {
|
|
|
278
284
|
...e.access === "public" ? { from: "agent-template" } : {}
|
|
279
285
|
};
|
|
280
286
|
}
|
|
281
|
-
const
|
|
282
|
-
function
|
|
287
|
+
const Ct = (e) => e.reduce((t, r) => t + r, 0), Me = (e) => Ct(e) / e.length;
|
|
288
|
+
function St(e, t, r) {
|
|
283
289
|
var i, d, m;
|
|
284
290
|
const { event: a, ...c } = e, { template: s } = (t == null ? void 0 : t.llm) || {}, { language: o } = ((i = t == null ? void 0 : t.presenter) == null ? void 0 : i.voice) || {};
|
|
285
291
|
return {
|
|
@@ -293,8 +299,8 @@ function yt(e, t, r) {
|
|
|
293
299
|
function Ee(e) {
|
|
294
300
|
"requestIdleCallback" in window ? requestIdleCallback(e, { timeout: 2e3 }) : setTimeout(e, 0);
|
|
295
301
|
}
|
|
296
|
-
const
|
|
297
|
-
function
|
|
302
|
+
const kt = "https://api-js.mixpanel.com/track/?verbose=1&ip=1";
|
|
303
|
+
function Rt(e) {
|
|
298
304
|
const t = window != null && window.hasOwnProperty("DID_AGENTS_API") ? "agents-ui" : "agents-sdk", r = {};
|
|
299
305
|
return {
|
|
300
306
|
token: e.token || "testKey",
|
|
@@ -338,7 +344,7 @@ function St(e) {
|
|
|
338
344
|
])
|
|
339
345
|
})
|
|
340
346
|
};
|
|
341
|
-
return fetch(
|
|
347
|
+
return fetch(kt, d).catch((m) => console.error("Analytics tracking error:", m)), Promise.resolve();
|
|
342
348
|
},
|
|
343
349
|
linkTrack(a, c, s, o) {
|
|
344
350
|
r[a] || (r[a] = { events: {}, resolvedDependencies: [] }), o.includes(s) || o.push(s);
|
|
@@ -368,7 +374,7 @@ const H = we(), fe = we(), Te = we();
|
|
|
368
374
|
function Ne(e) {
|
|
369
375
|
return e === x.Playground ? { headers: { [it]: "true" } } : {};
|
|
370
376
|
}
|
|
371
|
-
async function
|
|
377
|
+
async function Ve(e, t, r, a, c = !1, s) {
|
|
372
378
|
try {
|
|
373
379
|
return !s && !$e(a) && (s = await t.newChat(e.id, { persist: c }, Ne(a)), r.track("agent-chat", {
|
|
374
380
|
event: "created",
|
|
@@ -376,10 +382,10 @@ async function Ke(e, t, r, a, c = !1, s) {
|
|
|
376
382
|
mode: a
|
|
377
383
|
})), { chat: s, chatMode: (s == null ? void 0 : s.chat_mode) ?? a };
|
|
378
384
|
} catch (o) {
|
|
379
|
-
throw
|
|
385
|
+
throw Dt(o) === "InsufficientCreditsError" ? new Error("InsufficientCreditsError") : new Error("Cannot create new chat");
|
|
380
386
|
}
|
|
381
387
|
}
|
|
382
|
-
const
|
|
388
|
+
const Dt = (e) => {
|
|
383
389
|
try {
|
|
384
390
|
const t = JSON.parse(e.message);
|
|
385
391
|
return t == null ? void 0 : t.kind;
|
|
@@ -387,10 +393,10 @@ const kt = (e) => {
|
|
|
387
393
|
return "UnknownError";
|
|
388
394
|
}
|
|
389
395
|
};
|
|
390
|
-
function
|
|
396
|
+
function It(e) {
|
|
391
397
|
return e && e.length > 0 ? e : [];
|
|
392
398
|
}
|
|
393
|
-
function
|
|
399
|
+
function Mt(e) {
|
|
394
400
|
return new Promise((t, r) => {
|
|
395
401
|
const { callbacks: a, host: c, auth: s, externalId: o } = e, { onMessage: n = null, onOpen: i = null, onClose: d = null, onError: m = null } = a || {}, l = new WebSocket(`${c}?authorization=${encodeURIComponent(ze(s, o))}`);
|
|
396
402
|
l.onmessage = n, l.onclose = d, l.onerror = (w) => {
|
|
@@ -400,12 +406,12 @@ function Dt(e) {
|
|
|
400
406
|
};
|
|
401
407
|
});
|
|
402
408
|
}
|
|
403
|
-
async function
|
|
409
|
+
async function Et(e) {
|
|
404
410
|
const { retries: t = 1 } = e;
|
|
405
411
|
let r = null;
|
|
406
412
|
for (let a = 0; (r == null ? void 0 : r.readyState) !== WebSocket.OPEN; a++)
|
|
407
413
|
try {
|
|
408
|
-
r = await
|
|
414
|
+
r = await Mt(e);
|
|
409
415
|
} catch (c) {
|
|
410
416
|
if (a === t)
|
|
411
417
|
throw c;
|
|
@@ -413,8 +419,8 @@ async function It(e) {
|
|
|
413
419
|
}
|
|
414
420
|
return r;
|
|
415
421
|
}
|
|
416
|
-
async function
|
|
417
|
-
const c = r != null && r.onMessage ? [r.onMessage] : [], s = await
|
|
422
|
+
async function Tt(e, t, r, a) {
|
|
423
|
+
const c = r != null && r.onMessage ? [r.onMessage] : [], s = await Et({
|
|
418
424
|
auth: e,
|
|
419
425
|
host: t,
|
|
420
426
|
externalId: a,
|
|
@@ -435,7 +441,7 @@ async function Mt(e, t, r, a) {
|
|
|
435
441
|
subscribeToEvents: (o) => c.push(o)
|
|
436
442
|
};
|
|
437
443
|
}
|
|
438
|
-
function
|
|
444
|
+
function _t(e) {
|
|
439
445
|
if (e.answer !== void 0)
|
|
440
446
|
return e.answer;
|
|
441
447
|
let t = 0, r = "";
|
|
@@ -443,7 +449,7 @@ function Et(e) {
|
|
|
443
449
|
r += e[t++];
|
|
444
450
|
return r;
|
|
445
451
|
}
|
|
446
|
-
function
|
|
452
|
+
function bt(e, t, r) {
|
|
447
453
|
if (!e.content)
|
|
448
454
|
return;
|
|
449
455
|
const a = t.messages[t.messages.length - 1];
|
|
@@ -458,12 +464,12 @@ function Tt(e, t, r) {
|
|
|
458
464
|
};
|
|
459
465
|
t.messages.push(c), r == null || r([...t.messages], "user");
|
|
460
466
|
}
|
|
461
|
-
function
|
|
462
|
-
if (e ===
|
|
463
|
-
|
|
467
|
+
function At(e, t, r, a, c, s) {
|
|
468
|
+
if (e === U.Transcribe && t.content) {
|
|
469
|
+
bt(t, a, c);
|
|
464
470
|
return;
|
|
465
471
|
}
|
|
466
|
-
if (!(e ===
|
|
472
|
+
if (!(e === U.Partial || e === U.Answer))
|
|
467
473
|
return;
|
|
468
474
|
const o = a.messages[a.messages.length - 1], n = t.id && (o == null ? void 0 : o.role) === "assistant" && o.id !== t.id;
|
|
469
475
|
let i;
|
|
@@ -480,11 +486,11 @@ function _t(e, t, r, a, c, s) {
|
|
|
480
486
|
else
|
|
481
487
|
return;
|
|
482
488
|
const { content: d, sequence: m } = t;
|
|
483
|
-
e ===
|
|
484
|
-
const l =
|
|
485
|
-
(i.content !== l || e ===
|
|
489
|
+
e === U.Partial ? r[m] = d : r.answer = d;
|
|
490
|
+
const l = _t(r);
|
|
491
|
+
(i.content !== l || e === U.Answer) && (i.content = l, i.parts = re(l), c == null || c([...a.messages], e));
|
|
486
492
|
}
|
|
487
|
-
function
|
|
493
|
+
function xt(e, t, r, a, c) {
|
|
488
494
|
let s = {};
|
|
489
495
|
const o = () => s = {};
|
|
490
496
|
let n = "answer";
|
|
@@ -497,14 +503,14 @@ function bt(e, t, r, a, c) {
|
|
|
497
503
|
onMessage: (d, m) => {
|
|
498
504
|
var l, w;
|
|
499
505
|
if ("content" in m) {
|
|
500
|
-
const v = d === P.ChatAnswer ?
|
|
501
|
-
|
|
506
|
+
const v = d === P.ChatAnswer ? U.Answer : d === P.ChatAudioTranscribed ? U.Transcribe : d;
|
|
507
|
+
At(v, m, s, t, i, o), v === U.Answer && e.track("agent-message-received", {
|
|
502
508
|
content: m.content,
|
|
503
509
|
messages: t.messages.length,
|
|
504
510
|
mode: t.chatMode
|
|
505
511
|
});
|
|
506
512
|
} else {
|
|
507
|
-
const v = P, k = [v.StreamVideoDone, v.StreamVideoError, v.StreamVideoRejected], B = [v.StreamFailed, v.StreamVideoError, v.StreamVideoRejected], M =
|
|
513
|
+
const v = P, k = [v.StreamVideoDone, v.StreamVideoError, v.StreamVideoRejected], B = [v.StreamFailed, v.StreamVideoError, v.StreamVideoRejected], M = St(m, a, { mode: t.chatMode });
|
|
508
514
|
if (d = d, d === v.StreamVideoCreated && (e.linkTrack("agent-video", M, v.StreamVideoCreated, ["start"]), m.sentiment)) {
|
|
509
515
|
const D = t.messages[t.messages.length - 1];
|
|
510
516
|
if ((D == null ? void 0 : D.role) === "assistant") {
|
|
@@ -521,7 +527,7 @@ function bt(e, t, r, a, c) {
|
|
|
521
527
|
}
|
|
522
528
|
};
|
|
523
529
|
}
|
|
524
|
-
function
|
|
530
|
+
function Lt(e, t, r, a) {
|
|
525
531
|
const c = Fe(e, `${t}/agents/${r}`, a);
|
|
526
532
|
return {
|
|
527
533
|
createStream(s, o) {
|
|
@@ -558,8 +564,8 @@ function At(e, t, r, a) {
|
|
|
558
564
|
}
|
|
559
565
|
};
|
|
560
566
|
}
|
|
561
|
-
const
|
|
562
|
-
function
|
|
567
|
+
const Pt = (e, t) => (r, a) => e && console.log(`[${t}] ${r}`, a ?? "");
|
|
568
|
+
function jt(e, t, r) {
|
|
563
569
|
const a = (t.timestamp - e.timestamp) / 1e3;
|
|
564
570
|
return {
|
|
565
571
|
duration: a,
|
|
@@ -579,7 +585,7 @@ function Lt(e, t, r) {
|
|
|
579
585
|
lowFpsCount: r
|
|
580
586
|
};
|
|
581
587
|
}
|
|
582
|
-
function
|
|
588
|
+
function Bt(e) {
|
|
583
589
|
return e.filter(
|
|
584
590
|
(t) => t.freezeCount > 0 || t.framesPerSecond < 21 || t.framesDropped > 0 || t.packetsLost > 0
|
|
585
591
|
).map((t) => {
|
|
@@ -590,7 +596,7 @@ function Pt(e) {
|
|
|
590
596
|
};
|
|
591
597
|
});
|
|
592
598
|
}
|
|
593
|
-
function
|
|
599
|
+
function $t(e) {
|
|
594
600
|
var o;
|
|
595
601
|
let t = "", r = 0, a = null;
|
|
596
602
|
const c = /* @__PURE__ */ new Map();
|
|
@@ -677,14 +683,14 @@ function _e(e, t, r) {
|
|
|
677
683
|
framesPerSecond: i.framesPerSecond,
|
|
678
684
|
freezeCount: i.freezeCount - e[d - 1].freezeCount,
|
|
679
685
|
freezeDuration: i.freezeDuration - e[d - 1].freezeDuration
|
|
680
|
-
}), c =
|
|
686
|
+
}), c = Bt(a), s = c.reduce((i, d) => i + (d.causes.includes("low fps") ? 1 : 0), 0), o = a.filter((i) => !!i.avgJitterDelayInInterval).map((i) => i.avgJitterDelayInInterval), n = a.filter((i) => !!i.rtt).map((i) => i.rtt);
|
|
681
687
|
return {
|
|
682
688
|
webRTCStats: {
|
|
683
689
|
anomalies: c,
|
|
684
690
|
minRtt: Math.min(...n),
|
|
685
691
|
avgRtt: Me(n),
|
|
686
692
|
maxRtt: Math.max(...n),
|
|
687
|
-
aggregateReport:
|
|
693
|
+
aggregateReport: jt(e[0], e[e.length - 1], s),
|
|
688
694
|
minJitterDelayInInterval: Math.min(...o),
|
|
689
695
|
maxJitterDelayInInterval: Math.max(...o),
|
|
690
696
|
avgJitterDelayInInterval: Me(o)
|
|
@@ -693,14 +699,14 @@ function _e(e, t, r) {
|
|
|
693
699
|
resolution: `${e[0].frameWidth}x${e[0].frameHeight}`
|
|
694
700
|
};
|
|
695
701
|
}
|
|
696
|
-
function
|
|
702
|
+
function Ke(e, t) {
|
|
697
703
|
for (const r of e.values())
|
|
698
704
|
if ((r == null ? void 0 : r.type) === "inbound-rtp" && r.kind === t)
|
|
699
705
|
return r;
|
|
700
706
|
return null;
|
|
701
707
|
}
|
|
702
708
|
const ee = 10;
|
|
703
|
-
function
|
|
709
|
+
function cr(e, t) {
|
|
704
710
|
let r = !1, a = !1, c = null, s = 0, o = 0, n = {};
|
|
705
711
|
async function i() {
|
|
706
712
|
if (r) {
|
|
@@ -710,7 +716,7 @@ function sr(e, t) {
|
|
|
710
716
|
c = setTimeout(i, ee);
|
|
711
717
|
return;
|
|
712
718
|
}
|
|
713
|
-
const m =
|
|
719
|
+
const m = Ke(d, "audio");
|
|
714
720
|
if (!m) {
|
|
715
721
|
c = setTimeout(i, ee);
|
|
716
722
|
return;
|
|
@@ -739,11 +745,11 @@ function sr(e, t) {
|
|
|
739
745
|
}
|
|
740
746
|
};
|
|
741
747
|
}
|
|
742
|
-
const oe = 100,
|
|
743
|
-
function
|
|
748
|
+
const oe = 100, zt = Math.max(Math.ceil(400 / oe), 1), Ft = 0.25, Nt = 0.28;
|
|
749
|
+
function Vt() {
|
|
744
750
|
let e = 0, t, r, a = 0;
|
|
745
751
|
return (c) => {
|
|
746
|
-
const s =
|
|
752
|
+
const s = Ke(c, "video");
|
|
747
753
|
if (!s)
|
|
748
754
|
return { isReceiving: !1, avgJitterDelayInInterval: a };
|
|
749
755
|
const o = s.jitterBufferDelay, n = s.jitterBufferEmittedCount;
|
|
@@ -756,19 +762,19 @@ function Ft() {
|
|
|
756
762
|
return e = i, { isReceiving: d, avgJitterDelayInInterval: a, freezeCount: s.freezeCount };
|
|
757
763
|
};
|
|
758
764
|
}
|
|
759
|
-
function
|
|
765
|
+
function Kt(e, t, r, a, c) {
|
|
760
766
|
let s = null, o = [], n, i = 0, d = !1, m = te.Unknown, l = te.Unknown, w = 0, v = 0;
|
|
761
|
-
const k =
|
|
767
|
+
const k = Vt();
|
|
762
768
|
async function B() {
|
|
763
769
|
const M = await e();
|
|
764
770
|
if (!M)
|
|
765
771
|
return;
|
|
766
|
-
const { isReceiving: D, avgJitterDelayInInterval: $, freezeCount: _ } = k(M), q =
|
|
772
|
+
const { isReceiving: D, avgJitterDelayInInterval: $, freezeCount: _ } = k(M), q = $t(M);
|
|
767
773
|
if (D)
|
|
768
|
-
i = 0, w = _ - v, l = $ <
|
|
769
|
-
else if (d && (i++, i >=
|
|
770
|
-
const
|
|
771
|
-
a == null || a(S.Stop,
|
|
774
|
+
i = 0, w = _ - v, l = $ < Ft ? te.Strong : $ > Nt && w > 1 ? te.Weak : m, l !== m && (c == null || c(l), m = l, v += w, w = 0), d || (a == null || a(S.Start), n = o[o.length - 1], o = [], d = !0), o.push(q);
|
|
775
|
+
else if (d && (i++, i >= zt)) {
|
|
776
|
+
const J = _e(o, oe, n);
|
|
777
|
+
a == null || a(S.Stop, J), t() || r(), v = _, d = !1;
|
|
772
778
|
}
|
|
773
779
|
}
|
|
774
780
|
return {
|
|
@@ -781,7 +787,7 @@ function Nt(e, t, r, a, c) {
|
|
|
781
787
|
getReport: () => _e(o, oe, n)
|
|
782
788
|
};
|
|
783
789
|
}
|
|
784
|
-
const
|
|
790
|
+
const Ut = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
|
|
785
791
|
function be(e) {
|
|
786
792
|
switch (e) {
|
|
787
793
|
case "connected":
|
|
@@ -802,7 +808,7 @@ function be(e) {
|
|
|
802
808
|
return L.New;
|
|
803
809
|
}
|
|
804
810
|
}
|
|
805
|
-
const
|
|
811
|
+
const Wt = (e) => (t) => {
|
|
806
812
|
const [r, a = ""] = t.split(/:(.+)/);
|
|
807
813
|
try {
|
|
808
814
|
const c = JSON.parse(a);
|
|
@@ -820,7 +826,7 @@ function Jt({
|
|
|
820
826
|
}) {
|
|
821
827
|
e === S.Start && t === S.Start ? (c("CALLBACK: onVideoStateChange(Start)"), r == null || r(S.Start)) : e === S.Stop && t === S.Stop && (c("CALLBACK: onVideoStateChange(Stop)"), r == null || r(S.Stop, a));
|
|
822
828
|
}
|
|
823
|
-
function
|
|
829
|
+
function Ot({
|
|
824
830
|
statsSignal: e,
|
|
825
831
|
dataChannelSignal: t,
|
|
826
832
|
onVideoStateChange: r,
|
|
@@ -839,7 +845,7 @@ function Ae({
|
|
|
839
845
|
report: s,
|
|
840
846
|
log: o
|
|
841
847
|
}) {
|
|
842
|
-
c ===
|
|
848
|
+
c === W.Legacy ? Jt({ statsSignal: e, dataChannelSignal: t, onVideoStateChange: r, report: s, log: o }) : c === W.Fluent && Ot({
|
|
843
849
|
statsSignal: e,
|
|
844
850
|
dataChannelSignal: t,
|
|
845
851
|
onVideoStateChange: r,
|
|
@@ -848,11 +854,11 @@ function Ae({
|
|
|
848
854
|
log: o
|
|
849
855
|
});
|
|
850
856
|
}
|
|
851
|
-
async function
|
|
857
|
+
async function Ht(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de, analytics: o }, n) {
|
|
852
858
|
var E;
|
|
853
|
-
const i =
|
|
859
|
+
const i = Pt(r, "WebRTCStreamingManager"), d = Wt(i);
|
|
854
860
|
let m = !1, l = !1, w = S.Stop, v = S.Stop;
|
|
855
|
-
const { startConnection: k, sendStreamRequest: B, close: M, createStream: D, addIceCandidate: $ } =
|
|
861
|
+
const { startConnection: k, sendStreamRequest: B, close: M, createStream: D, addIceCandidate: $ } = Lt(
|
|
856
862
|
c,
|
|
857
863
|
s,
|
|
858
864
|
e,
|
|
@@ -860,33 +866,33 @@ async function Wt(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
860
866
|
), {
|
|
861
867
|
id: _,
|
|
862
868
|
offer: q,
|
|
863
|
-
ice_servers:
|
|
869
|
+
ice_servers: J,
|
|
864
870
|
session_id: N,
|
|
865
871
|
fluent: X,
|
|
866
872
|
interrupt_enabled: O
|
|
867
873
|
} = await D(t, n);
|
|
868
874
|
(E = a.onStreamCreated) == null || E.call(a, { stream_id: _, session_id: N, agent_id: e });
|
|
869
|
-
const I = new
|
|
875
|
+
const I = new Ut({ iceServers: J }), Y = I.createDataChannel("JanusDataChannel");
|
|
870
876
|
if (!N)
|
|
871
877
|
throw new Error("Could not create session_id");
|
|
872
|
-
const
|
|
878
|
+
const V = X ? W.Fluent : W.Legacy;
|
|
873
879
|
o.enrich({
|
|
874
|
-
"stream-type":
|
|
880
|
+
"stream-type": V
|
|
875
881
|
});
|
|
876
882
|
const ae = t.stream_warmup && !X, ie = () => m, u = () => {
|
|
877
883
|
var f;
|
|
878
884
|
m = !0, l && (i("CALLBACK: onConnectionStateChange(Connected)"), (f = a.onConnectionStateChange) == null || f.call(a, L.Connected));
|
|
879
|
-
}, g =
|
|
885
|
+
}, g = Kt(
|
|
880
886
|
() => I.getStats(),
|
|
881
887
|
ie,
|
|
882
888
|
u,
|
|
883
889
|
(f, h) => Ae({
|
|
884
890
|
statsSignal: v = f,
|
|
885
|
-
dataChannelSignal:
|
|
891
|
+
dataChannelSignal: V === W.Legacy ? w : void 0,
|
|
886
892
|
onVideoStateChange: a.onVideoStateChange,
|
|
887
893
|
onAgentActivityStateChange: a.onAgentActivityStateChange,
|
|
888
894
|
report: h,
|
|
889
|
-
streamType:
|
|
895
|
+
streamType: V,
|
|
890
896
|
log: i
|
|
891
897
|
}),
|
|
892
898
|
(f) => {
|
|
@@ -925,11 +931,11 @@ async function Wt(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
925
931
|
y(b.videoId);
|
|
926
932
|
}
|
|
927
933
|
f === P.StreamDone && y(null), w = f === P.StreamStarted ? S.Start : S.Stop, Ae({
|
|
928
|
-
statsSignal:
|
|
934
|
+
statsSignal: V === W.Legacy ? v : void 0,
|
|
929
935
|
dataChannelSignal: w,
|
|
930
936
|
onVideoStateChange: a.onVideoStateChange,
|
|
931
937
|
onAgentActivityStateChange: a.onAgentActivityStateChange,
|
|
932
|
-
streamType:
|
|
938
|
+
streamType: V,
|
|
933
939
|
log: i
|
|
934
940
|
});
|
|
935
941
|
}
|
|
@@ -1012,13 +1018,13 @@ async function Wt(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
1012
1018
|
* Id of current RTC stream
|
|
1013
1019
|
*/
|
|
1014
1020
|
streamId: _,
|
|
1015
|
-
streamType:
|
|
1021
|
+
streamType: V,
|
|
1016
1022
|
interruptAvailable: O ?? !1,
|
|
1017
1023
|
isInterruptible: !0,
|
|
1018
1024
|
interrupt(f) {
|
|
1019
1025
|
if (!O)
|
|
1020
1026
|
throw new Error("Interrupt is not enabled for this stream");
|
|
1021
|
-
if (
|
|
1027
|
+
if (V !== W.Fluent)
|
|
1022
1028
|
throw new Error("Interrupt only available for Fluent streams");
|
|
1023
1029
|
if (!p)
|
|
1024
1030
|
throw new Error("No active video to interrupt");
|
|
@@ -1032,18 +1038,18 @@ async function Wt(e, t, { debug: r = !1, callbacks: a, auth: c, baseURL: s = de,
|
|
|
1032
1038
|
};
|
|
1033
1039
|
}
|
|
1034
1040
|
var ge = /* @__PURE__ */ ((e) => (e.V1 = "v1", e.V2 = "v2", e))(ge || {});
|
|
1035
|
-
async function
|
|
1041
|
+
async function qt(e, t, r, a) {
|
|
1036
1042
|
const c = e.id;
|
|
1037
1043
|
switch (t.version) {
|
|
1038
1044
|
case "v1": {
|
|
1039
1045
|
const { version: s, ...o } = t;
|
|
1040
|
-
return
|
|
1046
|
+
return Ht(c, o, r, a);
|
|
1041
1047
|
}
|
|
1042
1048
|
case "v2": {
|
|
1043
1049
|
const { version: s, ...o } = t;
|
|
1044
1050
|
switch (o.transport.provider) {
|
|
1045
1051
|
case he.Livekit:
|
|
1046
|
-
const { createLiveKitStreamingManager: n } = await import("./livekit-manager-
|
|
1052
|
+
const { createLiveKitStreamingManager: n } = await import("./livekit-manager-zAbqmsie.js");
|
|
1047
1053
|
return n(c, o, r);
|
|
1048
1054
|
default:
|
|
1049
1055
|
throw new Error(`Unsupported transport provider: ${o.transport.provider}`);
|
|
@@ -1053,15 +1059,15 @@ async function Ot(e, t, r, a) {
|
|
|
1053
1059
|
throw new Error(`Invalid stream version: ${t.version}`);
|
|
1054
1060
|
}
|
|
1055
1061
|
}
|
|
1056
|
-
const
|
|
1057
|
-
function
|
|
1062
|
+
const Xt = "cht";
|
|
1063
|
+
function Yt() {
|
|
1058
1064
|
return {
|
|
1059
1065
|
transport: {
|
|
1060
1066
|
provider: he.Livekit
|
|
1061
1067
|
}
|
|
1062
1068
|
};
|
|
1063
1069
|
}
|
|
1064
|
-
function
|
|
1070
|
+
function Gt(e) {
|
|
1065
1071
|
var c, s;
|
|
1066
1072
|
const { streamOptions: t } = e ?? {}, r = ((c = e == null ? void 0 : e.mixpanelAdditionalProperties) == null ? void 0 : c.plan) !== void 0 ? {
|
|
1067
1073
|
plan: (s = e.mixpanelAdditionalProperties) == null ? void 0 : s.plan
|
|
@@ -1074,16 +1080,16 @@ function Xt(e) {
|
|
|
1074
1080
|
fluent: t == null ? void 0 : t.fluent
|
|
1075
1081
|
}, ...r && { end_user_data: r } };
|
|
1076
1082
|
}
|
|
1077
|
-
function
|
|
1078
|
-
return pe(e.presenter.type) ? { version: ge.V2, ...
|
|
1083
|
+
function Qt(e, t) {
|
|
1084
|
+
return pe(e.presenter.type) ? { version: ge.V2, ...Yt() } : { version: ge.V1, ...Gt(t) };
|
|
1079
1085
|
}
|
|
1080
|
-
function
|
|
1086
|
+
function Zt(e, t, r) {
|
|
1081
1087
|
r.track("agent-connection-state-change", { state: e, ...t && { reason: t } });
|
|
1082
1088
|
}
|
|
1083
|
-
function
|
|
1084
|
-
c ===
|
|
1089
|
+
function er(e, t, r, a, c) {
|
|
1090
|
+
c === W.Fluent ? tr(e, t, r, a, c) : rr(e, t, r, a, c);
|
|
1085
1091
|
}
|
|
1086
|
-
function
|
|
1092
|
+
function tr(e, t, r, a, c) {
|
|
1087
1093
|
e === S.Start ? a.track("stream-session", { event: "start", "stream-type": c }) : e === S.Stop && a.track("stream-session", {
|
|
1088
1094
|
event: "stop",
|
|
1089
1095
|
is_greenscreen: t.presenter.type === "clip" && t.presenter.is_greenscreen,
|
|
@@ -1107,7 +1113,7 @@ function xe(e, t, r, a, c) {
|
|
|
1107
1113
|
[P.StreamVideoDone]
|
|
1108
1114
|
);
|
|
1109
1115
|
}
|
|
1110
|
-
function
|
|
1116
|
+
function rr(e, t, r, a, c) {
|
|
1111
1117
|
e === S.Start ? a.linkTrack(
|
|
1112
1118
|
"agent-video",
|
|
1113
1119
|
{ event: "start", latency: H.get(!0), "stream-type": c },
|
|
@@ -1126,7 +1132,7 @@ function er(e, t, r, a, c) {
|
|
|
1126
1132
|
[P.StreamVideoDone]
|
|
1127
1133
|
);
|
|
1128
1134
|
}
|
|
1129
|
-
function
|
|
1135
|
+
function nr(e, t, r) {
|
|
1130
1136
|
const a = {
|
|
1131
1137
|
call_id: t.call_id,
|
|
1132
1138
|
name: t.name
|
|
@@ -1147,13 +1153,13 @@ function Le(e, t, r, a) {
|
|
|
1147
1153
|
return H.reset(), Te.update(), new Promise(async (c, s) => {
|
|
1148
1154
|
try {
|
|
1149
1155
|
let o, n = !1;
|
|
1150
|
-
const i =
|
|
1156
|
+
const i = Qt(e, t);
|
|
1151
1157
|
r.enrich({
|
|
1152
1158
|
"stream-version": i.version.toString()
|
|
1153
1159
|
});
|
|
1154
1160
|
let d = null;
|
|
1155
1161
|
const m = e.presenter.type === "expressive";
|
|
1156
|
-
o = await
|
|
1162
|
+
o = await qt(
|
|
1157
1163
|
e,
|
|
1158
1164
|
i,
|
|
1159
1165
|
{
|
|
@@ -1163,11 +1169,11 @@ function Le(e, t, r, a) {
|
|
|
1163
1169
|
...t.callbacks,
|
|
1164
1170
|
onConnectionStateChange: (l, w) => {
|
|
1165
1171
|
var v, k;
|
|
1166
|
-
(k = (v = t.callbacks).onConnectionStateChange) == null || k.call(v, l),
|
|
1172
|
+
(k = (v = t.callbacks).onConnectionStateChange) == null || k.call(v, l), Zt(l, w, r), l === L.Connected && (o ? c(o) : n = !0);
|
|
1167
1173
|
},
|
|
1168
1174
|
onVideoStateChange: (l, w) => {
|
|
1169
1175
|
var v, k;
|
|
1170
|
-
(k = (v = t.callbacks).onVideoStateChange) == null || k.call(v, l),
|
|
1176
|
+
(k = (v = t.callbacks).onVideoStateChange) == null || k.call(v, l), er(
|
|
1171
1177
|
l,
|
|
1172
1178
|
e,
|
|
1173
1179
|
w,
|
|
@@ -1201,7 +1207,7 @@ function Le(e, t, r, a) {
|
|
|
1201
1207
|
},
|
|
1202
1208
|
onToolEvent: (l, w) => {
|
|
1203
1209
|
var v, k;
|
|
1204
|
-
(k = (v = t.callbacks).onToolEvent) == null || k.call(v, l, w),
|
|
1210
|
+
(k = (v = t.callbacks).onToolEvent) == null || k.call(v, l, w), nr(l, w, r);
|
|
1205
1211
|
}
|
|
1206
1212
|
}
|
|
1207
1213
|
},
|
|
@@ -1212,11 +1218,11 @@ function Le(e, t, r, a) {
|
|
|
1212
1218
|
}
|
|
1213
1219
|
});
|
|
1214
1220
|
}
|
|
1215
|
-
async function
|
|
1221
|
+
async function ar(e, t, r, a, c) {
|
|
1216
1222
|
var m, l, w, v;
|
|
1217
1223
|
const s = async () => {
|
|
1218
1224
|
if (pe(e.presenter.type)) {
|
|
1219
|
-
const k = await Le(e, t, a), B = `${
|
|
1225
|
+
const k = await Le(e, t, a), B = `${Xt}_${k.sessionId}`, M = (/* @__PURE__ */ new Date()).toISOString();
|
|
1220
1226
|
return { chatResult: {
|
|
1221
1227
|
chatMode: x.Functional,
|
|
1222
1228
|
chat: {
|
|
@@ -1235,14 +1241,14 @@ async function rr(e, t, r, a, c) {
|
|
|
1235
1241
|
const k = new AbortController(), B = k.signal;
|
|
1236
1242
|
let M;
|
|
1237
1243
|
try {
|
|
1238
|
-
const D =
|
|
1244
|
+
const D = Ve(
|
|
1239
1245
|
e,
|
|
1240
1246
|
r,
|
|
1241
1247
|
a,
|
|
1242
1248
|
t.mode,
|
|
1243
1249
|
t.persistentChat,
|
|
1244
1250
|
c
|
|
1245
|
-
), $ = Le(e, t, a, B).then((
|
|
1251
|
+
), $ = Le(e, t, a, B).then((J) => (M = J, J)), [_, q] = await Promise.all([D, $]);
|
|
1246
1252
|
return { chatResult: _, streamingManager: q };
|
|
1247
1253
|
} catch (D) {
|
|
1248
1254
|
throw k.abort(), M && await M.disconnect().catch(() => {
|
|
@@ -1252,13 +1258,13 @@ async function rr(e, t, r, a, c) {
|
|
|
1252
1258
|
}, { chatResult: o, streamingManager: n } = await s(), { chat: i, chatMode: d } = o;
|
|
1253
1259
|
return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (l = (m = t.callbacks).onModeChange) == null || l.call(m, d), d !== x.Functional) ? ((v = (w = t.callbacks).onError) == null || v.call(w, new He(d)), n == null || n.disconnect(), { chat: i }) : { chat: i, streamingManager: n };
|
|
1254
1260
|
}
|
|
1255
|
-
async function
|
|
1256
|
-
var Y,
|
|
1261
|
+
async function dr(e, t) {
|
|
1262
|
+
var Y, V, ae, ie;
|
|
1257
1263
|
let r = !0;
|
|
1258
1264
|
const a = t.mixpanelKey || ot, c = t.wsURL || st, s = t.baseURL || de, o = t.mode || x.Functional, n = {
|
|
1259
1265
|
messages: [],
|
|
1260
1266
|
chatMode: o
|
|
1261
|
-
}, i =
|
|
1267
|
+
}, i = Rt({
|
|
1262
1268
|
token: a,
|
|
1263
1269
|
agentId: e,
|
|
1264
1270
|
isEnabled: t.enableAnalitics,
|
|
@@ -1268,15 +1274,15 @@ async function or(e, t) {
|
|
|
1268
1274
|
Ee(() => {
|
|
1269
1275
|
i.track("agent-sdk", { event: "init" }, d);
|
|
1270
1276
|
});
|
|
1271
|
-
const m =
|
|
1277
|
+
const m = wt(t.auth, s, t.callbacks.onError, t.externalId), l = await m.getById(e);
|
|
1272
1278
|
t.debug = t.debug || ((Y = l == null ? void 0 : l.advanced_settings) == null ? void 0 : Y.ui_debug_mode);
|
|
1273
1279
|
const w = pe(l.presenter.type);
|
|
1274
|
-
i.enrich(
|
|
1275
|
-
const { onMessage: v, clearQueue: k } =
|
|
1280
|
+
i.enrich(yt(l));
|
|
1281
|
+
const { onMessage: v, clearQueue: k } = xt(i, n, t, l, () => {
|
|
1276
1282
|
var u, g, p;
|
|
1277
1283
|
(u = n.socketManager) == null || u.disconnect(), (p = (g = t.callbacks).onConnectionStateChange) == null || p.call(g, L.Disconnected);
|
|
1278
1284
|
});
|
|
1279
|
-
n.messages =
|
|
1285
|
+
n.messages = It(t.initialMessages), (ae = (V = t.callbacks).onNewMessage) == null || ae.call(V, [...n.messages], "answer");
|
|
1280
1286
|
const B = (u) => {
|
|
1281
1287
|
}, M = ({ type: u }) => {
|
|
1282
1288
|
var p, y, C, R;
|
|
@@ -1311,24 +1317,24 @@ async function or(e, t) {
|
|
|
1311
1317
|
const p = !D.has(u);
|
|
1312
1318
|
D.set(u, g), p && ((C = (y = n.streamingManager) == null ? void 0 : y.registerRpcMethod) == null || C.call(y, u, $(u)));
|
|
1313
1319
|
}
|
|
1314
|
-
function
|
|
1320
|
+
function J(u) {
|
|
1315
1321
|
var g, p;
|
|
1316
1322
|
D.delete(u), (p = (g = n.streamingManager) == null ? void 0 : g.unregisterRpcMethod) == null || p.call(g, u);
|
|
1317
1323
|
}
|
|
1318
1324
|
const N = Date.now();
|
|
1319
1325
|
Ee(() => {
|
|
1320
|
-
i.track("agent-sdk", { event: "loaded", ...
|
|
1326
|
+
i.track("agent-sdk", { event: "loaded", ...vt(l) }, N);
|
|
1321
1327
|
});
|
|
1322
1328
|
async function X(u) {
|
|
1323
1329
|
var j, z, F, E, f, h, b;
|
|
1324
1330
|
(z = (j = t.callbacks).onConnectionStateChange) == null || z.call(j, L.Connecting), H.reset(), u && !r && (delete n.chat, (E = (F = t.callbacks).onNewMessage) == null || E.call(F, [...n.messages], "answer"));
|
|
1325
|
-
const g = o === x.DirectPlayback || w ? Promise.resolve(void 0) :
|
|
1331
|
+
const g = o === x.DirectPlayback || w ? Promise.resolve(void 0) : Tt(
|
|
1326
1332
|
t.auth,
|
|
1327
1333
|
c,
|
|
1328
1334
|
{ onMessage: v, onError: t.callbacks.onError },
|
|
1329
1335
|
t.externalId
|
|
1330
1336
|
), p = ue(
|
|
1331
|
-
() =>
|
|
1337
|
+
() => ar(
|
|
1332
1338
|
l,
|
|
1333
1339
|
{
|
|
1334
1340
|
...t,
|
|
@@ -1351,8 +1357,8 @@ async function or(e, t) {
|
|
|
1351
1357
|
delayMs: 1e3
|
|
1352
1358
|
}
|
|
1353
1359
|
).catch((T) => {
|
|
1354
|
-
var A,
|
|
1355
|
-
throw I(x.Maintenance), (
|
|
1360
|
+
var A, K;
|
|
1361
|
+
throw I(x.Maintenance), (K = (A = t.callbacks).onConnectionStateChange) == null || K.call(A, L.Fail), T;
|
|
1356
1362
|
}), [y, { streamingManager: C, chat: R }] = await Promise.all([g, p]);
|
|
1357
1363
|
R && R.id !== ((f = n.chat) == null ? void 0 : f.id) && ((b = (h = t.callbacks).onNewChat) == null || b.call(h, R.id)), n.streamingManager = C, n.socketManager = y, n.chat = R, _(), r = !1, i.enrich({
|
|
1358
1364
|
chatId: R == null ? void 0 : R.id,
|
|
@@ -1452,7 +1458,7 @@ async function or(e, t) {
|
|
|
1452
1458
|
}, p = async () => {
|
|
1453
1459
|
var E, f;
|
|
1454
1460
|
if (!n.chat) {
|
|
1455
|
-
const h = await
|
|
1461
|
+
const h = await Ve(
|
|
1456
1462
|
l,
|
|
1457
1463
|
m,
|
|
1458
1464
|
i,
|
|
@@ -1467,18 +1473,18 @@ async function or(e, t) {
|
|
|
1467
1473
|
}, y = async (E, f) => {
|
|
1468
1474
|
const h = n.chatMode === x.Playground;
|
|
1469
1475
|
return ue(w && !h ? async () => {
|
|
1470
|
-
var A,
|
|
1471
|
-
return await ((
|
|
1476
|
+
var A, K;
|
|
1477
|
+
return await ((K = (A = n.streamingManager) == null ? void 0 : A.sendTextMessage) == null ? void 0 : K.call(A, u)), Promise.resolve({});
|
|
1472
1478
|
} : async () => {
|
|
1473
|
-
var A,
|
|
1479
|
+
var A, K;
|
|
1474
1480
|
return m.chat(
|
|
1475
1481
|
l.id,
|
|
1476
1482
|
f,
|
|
1477
1483
|
{
|
|
1478
1484
|
chatMode: n.chatMode,
|
|
1479
1485
|
streamId: (A = n.streamingManager) == null ? void 0 : A.streamId,
|
|
1480
|
-
sessionId: (
|
|
1481
|
-
messages: E.map(({ matches:
|
|
1486
|
+
sessionId: (K = n.streamingManager) == null ? void 0 : K.sessionId,
|
|
1487
|
+
messages: E.map(({ matches: Ue, ...se }) => se)
|
|
1482
1488
|
},
|
|
1483
1489
|
{
|
|
1484
1490
|
...Ne(n.chatMode),
|
|
@@ -1489,8 +1495,8 @@ async function or(e, t) {
|
|
|
1489
1495
|
limit: 2,
|
|
1490
1496
|
shouldRetryFn: (A) => {
|
|
1491
1497
|
var se, ve, ye, Ce;
|
|
1492
|
-
const
|
|
1493
|
-
return !((ve = A == null ? void 0 : A.message) == null ? void 0 : ve.includes("Stream Error")) && !
|
|
1498
|
+
const K = (se = A == null ? void 0 : A.message) == null ? void 0 : se.includes("missing or invalid session_id");
|
|
1499
|
+
return !((ve = A == null ? void 0 : A.message) == null ? void 0 : ve.includes("Stream Error")) && !K ? ((Ce = (ye = t.callbacks).onError) == null || Ce.call(ye, A), !1) : !0;
|
|
1494
1500
|
},
|
|
1495
1501
|
onRetry: async () => {
|
|
1496
1502
|
await O(), await X(!1);
|
|
@@ -1606,12 +1612,12 @@ async function or(e, t) {
|
|
|
1606
1612
|
},
|
|
1607
1613
|
interrupt: M,
|
|
1608
1614
|
registerClientTool: q,
|
|
1609
|
-
unregisterClientTool:
|
|
1615
|
+
unregisterClientTool: J
|
|
1610
1616
|
};
|
|
1611
1617
|
}
|
|
1612
1618
|
export {
|
|
1613
1619
|
ne as A,
|
|
1614
|
-
|
|
1620
|
+
U as C,
|
|
1615
1621
|
tt as D,
|
|
1616
1622
|
et as K,
|
|
1617
1623
|
Ye as P,
|
|
@@ -1621,26 +1627,26 @@ export {
|
|
|
1621
1627
|
Xe as U,
|
|
1622
1628
|
G as V,
|
|
1623
1629
|
qe as W,
|
|
1624
|
-
|
|
1625
|
-
|
|
1630
|
+
Pt as a,
|
|
1631
|
+
W as b,
|
|
1626
1632
|
Fe as c,
|
|
1627
1633
|
de as d,
|
|
1628
1634
|
L as e,
|
|
1629
1635
|
te as f,
|
|
1630
|
-
|
|
1631
|
-
|
|
1636
|
+
Kt as g,
|
|
1637
|
+
cr as h,
|
|
1632
1638
|
S as i,
|
|
1633
1639
|
Oe as j,
|
|
1634
1640
|
He as k,
|
|
1635
1641
|
H as l,
|
|
1636
|
-
|
|
1637
|
-
|
|
1642
|
+
dr as m,
|
|
1643
|
+
or as n,
|
|
1638
1644
|
Ge as o,
|
|
1639
|
-
|
|
1645
|
+
ft as p,
|
|
1640
1646
|
x as q,
|
|
1641
1647
|
Ze as r,
|
|
1642
1648
|
Pe as s,
|
|
1643
|
-
|
|
1649
|
+
sr as t,
|
|
1644
1650
|
rt as u,
|
|
1645
1651
|
nt as v
|
|
1646
1652
|
};
|