@d-id/client-sdk 1.2.8-staging.365 → 1.2.8-staging.366
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.
|
@@ -14,7 +14,7 @@ class G extends Error {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function Tn(e) {
|
|
18
18
|
return e instanceof Error && typeof e.kind == "string";
|
|
19
19
|
}
|
|
20
20
|
class ot extends G {
|
|
@@ -89,7 +89,7 @@ class ut extends G {
|
|
|
89
89
|
super(t, "WSError");
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
var ft = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(ft || {}), mt = /* @__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))(mt || {}), ht = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(ht || {}), gt = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(gt || {}),
|
|
92
|
+
var ft = /* @__PURE__ */ ((e) => (e.TRIAL = "trial", e.BASIC = "basic", e.ENTERPRISE = "enterprise", e.LITE = "lite", e.ADVANCED = "advanced", e))(ft || {}), mt = /* @__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))(mt || {}), ht = /* @__PURE__ */ ((e) => (e.Created = "created", e.Started = "started", e.Done = "done", e.Error = "error", e.Rejected = "rejected", e.Ready = "ready", e))(ht || {}), gt = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(gt || {}), T = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintenance = "Maintenance", e.Playground = "Playground", e.DirectPlayback = "DirectPlayback", e.Off = "Off", e))(T || {}), F = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Transcribe = "transcribe", e.Complete = "done", e))(F || {}), pt = /* @__PURE__ */ ((e) => (e.KnowledgeProcessing = "knowledge/processing", e.KnowledgeIndexing = "knowledge/indexing", e.KnowledgeFailed = "knowledge/error", e.KnowledgeDone = "knowledge/done", e))(pt || {}), wt = /* @__PURE__ */ ((e) => (e.Knowledge = "knowledge", e.Document = "document", e.Record = "record", e))(wt || {}), yt = /* @__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))(yt || {}), He = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e.Expressive = "expressive", e))(He || {});
|
|
93
93
|
const An = (e) => {
|
|
94
94
|
switch (e) {
|
|
95
95
|
case "clip":
|
|
@@ -102,7 +102,7 @@ const An = (e) => {
|
|
|
102
102
|
throw new Error(`Unknown video type: ${e}`);
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
|
-
var
|
|
105
|
+
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 || {}), ie = /* @__PURE__ */ ((e) => (e.Idle = "IDLE", e.Loading = "LOADING", e.Talking = "TALKING", e.ToolActive = "TOOL_ACTIVE", e))(ie || {}), x = /* @__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))(x || {}), A = /* @__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))(A || {}), W = /* @__PURE__ */ ((e) => (e.Legacy = "legacy", e.Fluent = "fluent", e))(W || {}), Se = /* @__PURE__ */ ((e) => (e.Livekit = "livekit", e))(Se || {}), vt = /* @__PURE__ */ ((e) => (e.Amazon = "amazon", e.AzureOpenAi = "azure-openai", e.Microsoft = "microsoft", e.Afflorithmics = "afflorithmics", e.Elevenlabs = "elevenlabs", e))(vt || {}), kt = /* @__PURE__ */ ((e) => (e.Public = "public", e.Premium = "premium", e.Private = "private", e))(kt || {});
|
|
106
106
|
const xn = (...e) => {
|
|
107
107
|
}, qe = (e) => new Promise((t) => setTimeout(t, e)), ee = (e = 16) => {
|
|
108
108
|
const t = new Uint8Array(e);
|
|
@@ -119,7 +119,7 @@ function we(e) {
|
|
|
119
119
|
return t;
|
|
120
120
|
}
|
|
121
121
|
let ue = ee();
|
|
122
|
-
function
|
|
122
|
+
function Ct() {
|
|
123
123
|
ue = ee();
|
|
124
124
|
}
|
|
125
125
|
function Xe(e, t) {
|
|
@@ -140,10 +140,10 @@ const St = 45 * 1e3, Mt = "X-Playground-Chat", be = 2e3, me = "https://api.d-id.
|
|
|
140
140
|
case "talk":
|
|
141
141
|
return "v2";
|
|
142
142
|
}
|
|
143
|
-
}, Et = (e) => e.type === "talk" ? e.source_url : e.presenter_id, Me = (e) => e === He.Expressive, bt = (e) => [
|
|
144
|
-
function
|
|
143
|
+
}, Et = (e) => e.type === "talk" ? e.source_url : e.presenter_id, Me = (e) => e === He.Expressive, bt = (e) => [T.TextOnly, T.Playground, T.Maintenance].includes(e), Qe = (e) => e && [T.DirectPlayback, T.Off].includes(e), _e = /\[!\[([^\[\]]*)\]\(([^)\s]+)\)\]\(([^)\s]+)\)/g, Te = /!\[([^\[\]]*)\]\(([^)\s]+)\)/g, _t = [".mp4", ".webm", ".mkv", ".mov", ".m4v", ".ogv"];
|
|
144
|
+
function Tt(e) {
|
|
145
145
|
const t = e.split("?")[0].split("#")[0].toLowerCase();
|
|
146
|
-
return
|
|
146
|
+
return _t.some((n) => t.endsWith(n));
|
|
147
147
|
}
|
|
148
148
|
const Ae = new RegExp("(?<!!)\\[([^\\[\\]]+)\\]\\(([^)\\s]+)\\)", "g"), xe = /<a\s+href="([^"]*)"[^>]*?>([^<]*)<\/a>/gi;
|
|
149
149
|
function At(e) {
|
|
@@ -151,17 +151,17 @@ function At(e) {
|
|
|
151
151
|
return [];
|
|
152
152
|
const t = [];
|
|
153
153
|
let n;
|
|
154
|
-
for (
|
|
154
|
+
for (_e.lastIndex = 0; (n = _e.exec(e)) !== null; )
|
|
155
155
|
t.push({
|
|
156
156
|
index: n.index,
|
|
157
157
|
length: n[0].length,
|
|
158
158
|
part: { type: "video", src: n[3], alt: n[1], thumbnail: n[2] }
|
|
159
159
|
});
|
|
160
|
-
for (
|
|
160
|
+
for (Te.lastIndex = 0; (n = Te.exec(e)) !== null; )
|
|
161
161
|
if (!t.some((s) => n.index >= s.index && n.index < s.index + s.length)) {
|
|
162
162
|
const s = n[2], r = n[1];
|
|
163
163
|
let a;
|
|
164
|
-
|
|
164
|
+
Tt(s) ? a = { type: "video", src: s, alt: r } : (a = { type: "image", src: s, alt: r }, s.toLowerCase().endsWith(".gif") && (a.mimeType = "image/gif")), t.push({ index: n.index, length: n[0].length, part: a });
|
|
165
165
|
}
|
|
166
166
|
for (Ae.lastIndex = 0; (n = Ae.exec(e)) !== null; )
|
|
167
167
|
t.some((s) => n.index >= s.index && n.index < s.index + s.length) || t.push({
|
|
@@ -395,7 +395,7 @@ function Be(e) {
|
|
|
395
395
|
function ge(e) {
|
|
396
396
|
return e instanceof G ? e.toJson() : { kind: "UnknownError", message: Bt(e) || "UnknownError" };
|
|
397
397
|
}
|
|
398
|
-
const Jt = "1.2.8-staging.
|
|
398
|
+
const Jt = "1.2.8-staging.366", Ot = "https://api-js.mixpanel.com/track/?verbose=1&ip=1", Ze = 50, Z = [];
|
|
399
399
|
let pe = !1;
|
|
400
400
|
async function et(e) {
|
|
401
401
|
const t = await fetch(Ot, {
|
|
@@ -485,9 +485,9 @@ function Re() {
|
|
|
485
485
|
get: (t = !1) => t ? Date.now() - e : e
|
|
486
486
|
};
|
|
487
487
|
}
|
|
488
|
-
const X = Re(),
|
|
488
|
+
const X = Re(), ke = Re(), Fe = Re();
|
|
489
489
|
function tt(e) {
|
|
490
|
-
return e ===
|
|
490
|
+
return e === T.Playground ? { headers: { [Mt]: "true" } } : {};
|
|
491
491
|
}
|
|
492
492
|
async function nt(e, t, n, i, c = !1, o) {
|
|
493
493
|
return !o && !Qe(i) && (o = await t.newChat(e.id, { persist: c }, tt(i)), n.track("agent-chat", {
|
|
@@ -912,10 +912,10 @@ function fn(e, t, n, i, c) {
|
|
|
912
912
|
return;
|
|
913
913
|
const { isReceiving: b, avgJitterDelayInInterval: P, freezeCount: E } = v(I), Q = on(I);
|
|
914
914
|
if (b)
|
|
915
|
-
a = 0, f = E - w, u = P < dn ? re.Strong : P > ln && f > 1 ? re.Weak : m, u !== m && (c == null || c(u), m = u, w += f, f = 0), d || (i == null || i(
|
|
915
|
+
a = 0, f = E - w, u = P < dn ? re.Strong : P > ln && f > 1 ? re.Weak : m, u !== m && (c == null || c(u), m = u, w += f, f = 0), d || (i == null || i(C.Start), r = s[s.length - 1], s = [], d = !0), s.push(Q);
|
|
916
916
|
else if (d && (a++, a >= cn)) {
|
|
917
917
|
const H = Ne(s, fe, r);
|
|
918
|
-
i == null || i(
|
|
918
|
+
i == null || i(C.Stop, H), t() || n(), w = E, d = !1;
|
|
919
919
|
}
|
|
920
920
|
}
|
|
921
921
|
return {
|
|
@@ -965,7 +965,7 @@ function gn({
|
|
|
965
965
|
report: i,
|
|
966
966
|
log: c
|
|
967
967
|
}) {
|
|
968
|
-
e ===
|
|
968
|
+
e === C.Start && t === C.Start ? (c("CALLBACK: onVideoStateChange(Start)"), n == null || n(C.Start)) : e === C.Stop && t === C.Stop && (c("CALLBACK: onVideoStateChange(Stop)"), n == null || n(C.Stop, i));
|
|
969
969
|
}
|
|
970
970
|
function pn({
|
|
971
971
|
statsSignal: e,
|
|
@@ -975,7 +975,7 @@ function pn({
|
|
|
975
975
|
report: c,
|
|
976
976
|
log: o
|
|
977
977
|
}) {
|
|
978
|
-
e ===
|
|
978
|
+
e === C.Start ? (o("CALLBACK: onVideoStateChange(Start)"), n == null || n(C.Start)) : e === C.Stop && (o("CALLBACK: onVideoStateChange(Stop)"), n == null || n(C.Stop, c)), t === C.Start ? i == null || i(ie.Talking) : t === C.Stop && (i == null || i(ie.Idle));
|
|
979
979
|
}
|
|
980
980
|
function Ue({
|
|
981
981
|
statsSignal: e,
|
|
@@ -998,7 +998,7 @@ function Ue({
|
|
|
998
998
|
async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = me, analytics: s }, r) {
|
|
999
999
|
var N;
|
|
1000
1000
|
const a = tn(n, "WebRTCStreamingManager"), d = hn(a);
|
|
1001
|
-
let m = !1, u = !1, f =
|
|
1001
|
+
let m = !1, u = !1, f = C.Stop, w = C.Stop;
|
|
1002
1002
|
const { startConnection: v, sendStreamRequest: j, close: I, createStream: b, addIceCandidate: P } = en(
|
|
1003
1003
|
c,
|
|
1004
1004
|
o,
|
|
@@ -1066,12 +1066,12 @@ async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = me,
|
|
|
1066
1066
|
var p;
|
|
1067
1067
|
g = h, (p = i.onVideoIdChange) == null || p.call(i, h);
|
|
1068
1068
|
};
|
|
1069
|
-
function
|
|
1069
|
+
function k(h, p) {
|
|
1070
1070
|
if (h === x.StreamStarted && typeof p == "object" && "metadata" in p) {
|
|
1071
1071
|
const D = p.metadata;
|
|
1072
1072
|
y(D.videoId);
|
|
1073
1073
|
}
|
|
1074
|
-
h === x.StreamDone && y(null), f = h === x.StreamStarted ?
|
|
1074
|
+
h === x.StreamDone && y(null), f = h === x.StreamStarted ? C.Start : C.Stop, Ue({
|
|
1075
1075
|
statsSignal: U === W.Legacy ? w : void 0,
|
|
1076
1076
|
dataChannelSignal: f,
|
|
1077
1077
|
onVideoStateChange: i.onVideoStateChange,
|
|
@@ -1086,8 +1086,8 @@ async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = me,
|
|
|
1086
1086
|
D && s.enrich({ streamMetadata: D }), (B = i.onStreamReady) == null || B.call(i);
|
|
1087
1087
|
}
|
|
1088
1088
|
const M = {
|
|
1089
|
-
[x.StreamStarted]:
|
|
1090
|
-
[x.StreamDone]:
|
|
1089
|
+
[x.StreamStarted]: k,
|
|
1090
|
+
[x.StreamDone]: k,
|
|
1091
1091
|
[x.StreamReady]: S
|
|
1092
1092
|
};
|
|
1093
1093
|
q.onmessage = (h) => {
|
|
@@ -1178,7 +1178,7 @@ async function wn(e, t, { debug: n = !1, callbacks: i, auth: c, baseURL: o = me,
|
|
|
1178
1178
|
}
|
|
1179
1179
|
};
|
|
1180
1180
|
}
|
|
1181
|
-
var
|
|
1181
|
+
var Ce = /* @__PURE__ */ ((e) => (e.V1 = "v1", e.V2 = "v2", e))(Ce || {});
|
|
1182
1182
|
async function yn(e, t, n, i) {
|
|
1183
1183
|
const c = e.id;
|
|
1184
1184
|
switch (t.version) {
|
|
@@ -1190,7 +1190,7 @@ async function yn(e, t, n, i) {
|
|
|
1190
1190
|
const { version: o, ...s } = t;
|
|
1191
1191
|
switch (s.transport.provider) {
|
|
1192
1192
|
case Se.Livekit:
|
|
1193
|
-
const { createLiveKitStreamingManager: r } = await import("./livekit-manager-
|
|
1193
|
+
const { createLiveKitStreamingManager: r } = await import("./livekit-manager-C3HASruw.js");
|
|
1194
1194
|
return r(c, s, n);
|
|
1195
1195
|
default:
|
|
1196
1196
|
throw new Error(`Unsupported transport provider: ${s.transport.provider}`);
|
|
@@ -1201,14 +1201,14 @@ async function yn(e, t, n, i) {
|
|
|
1201
1201
|
}
|
|
1202
1202
|
}
|
|
1203
1203
|
const vn = "cht";
|
|
1204
|
-
function
|
|
1204
|
+
function kn() {
|
|
1205
1205
|
return {
|
|
1206
1206
|
transport: {
|
|
1207
1207
|
provider: Se.Livekit
|
|
1208
1208
|
}
|
|
1209
1209
|
};
|
|
1210
1210
|
}
|
|
1211
|
-
function
|
|
1211
|
+
function Cn(e) {
|
|
1212
1212
|
var c, o;
|
|
1213
1213
|
const { streamOptions: t } = e ?? {}, n = ((c = e == null ? void 0 : e.mixpanelAdditionalProperties) == null ? void 0 : c.plan) !== void 0 ? {
|
|
1214
1214
|
plan: (o = e.mixpanelAdditionalProperties) == null ? void 0 : o.plan
|
|
@@ -1222,7 +1222,7 @@ function kn(e) {
|
|
|
1222
1222
|
}, ...n && { end_user_data: n } };
|
|
1223
1223
|
}
|
|
1224
1224
|
function Sn(e, t) {
|
|
1225
|
-
return Me(e.presenter.type) ? { version:
|
|
1225
|
+
return Me(e.presenter.type) ? { version: Ce.V2, ...kn() } : { version: Ce.V1, ...Cn(t) };
|
|
1226
1226
|
}
|
|
1227
1227
|
function Mn(e, t, n) {
|
|
1228
1228
|
n.track("agent-connection-state-change", { state: e, ...t && { reason: t } });
|
|
@@ -1231,7 +1231,7 @@ function Rn(e, t, n, i, c) {
|
|
|
1231
1231
|
c === W.Fluent ? Dn(e, t, n, i, c) : In(e, t, n, i, c);
|
|
1232
1232
|
}
|
|
1233
1233
|
function Dn(e, t, n, i, c) {
|
|
1234
|
-
e ===
|
|
1234
|
+
e === C.Start ? i.track("stream-session", { event: "start", "stream-type": c }) : e === C.Stop && i.track("stream-session", {
|
|
1235
1235
|
event: "stop",
|
|
1236
1236
|
is_greenscreen: t.presenter.type === "clip" && t.presenter.is_greenscreen,
|
|
1237
1237
|
background: t.presenter.type === "clip" && t.presenter.background,
|
|
@@ -1240,9 +1240,9 @@ function Dn(e, t, n, i, c) {
|
|
|
1240
1240
|
});
|
|
1241
1241
|
}
|
|
1242
1242
|
function Je(e, t, n, i, c) {
|
|
1243
|
-
e ===
|
|
1243
|
+
e === C.Start ? n.linkTrack("agent-video", { event: "start", ...c, "stream-type": i }, "start", [
|
|
1244
1244
|
x.StreamVideoCreated
|
|
1245
|
-
]) : e ===
|
|
1245
|
+
]) : e === C.Stop && n.linkTrack(
|
|
1246
1246
|
"agent-video",
|
|
1247
1247
|
{
|
|
1248
1248
|
event: "stop",
|
|
@@ -1255,12 +1255,12 @@ function Je(e, t, n, i, c) {
|
|
|
1255
1255
|
);
|
|
1256
1256
|
}
|
|
1257
1257
|
function In(e, t, n, i, c) {
|
|
1258
|
-
e ===
|
|
1258
|
+
e === C.Start ? i.linkTrack(
|
|
1259
1259
|
"agent-video",
|
|
1260
1260
|
{ event: "start", latency: X.get(!0), "stream-type": c },
|
|
1261
1261
|
"start",
|
|
1262
1262
|
[x.StreamVideoCreated]
|
|
1263
|
-
) : e ===
|
|
1263
|
+
) : e === C.Stop && i.linkTrack(
|
|
1264
1264
|
"agent-video",
|
|
1265
1265
|
{
|
|
1266
1266
|
event: "stop",
|
|
@@ -1324,16 +1324,16 @@ function Oe(e, t, n, i) {
|
|
|
1324
1324
|
},
|
|
1325
1325
|
onAgentActivityStateChange: (u) => {
|
|
1326
1326
|
var f, w;
|
|
1327
|
-
(w = (f = t.callbacks).onAgentActivityStateChange) == null || w.call(f, u), u === ie.Talking ? (
|
|
1327
|
+
(w = (f = t.callbacks).onAgentActivityStateChange) == null || w.call(f, u), u === ie.Talking ? (ke.update(), d = (v) => {
|
|
1328
1328
|
Je(
|
|
1329
|
-
|
|
1329
|
+
C.Start,
|
|
1330
1330
|
e,
|
|
1331
1331
|
n,
|
|
1332
1332
|
s.streamType,
|
|
1333
1333
|
v
|
|
1334
1334
|
), d = null;
|
|
1335
|
-
}, m || d({ latency: X.get(!0) })) : (
|
|
1336
|
-
|
|
1335
|
+
}, m || d({ latency: X.get(!0) })) : (ke.reset(), d = null, Je(
|
|
1336
|
+
C.Stop,
|
|
1337
1337
|
e,
|
|
1338
1338
|
n,
|
|
1339
1339
|
s.streamType
|
|
@@ -1365,7 +1365,7 @@ async function bn(e, t, n, i, c) {
|
|
|
1365
1365
|
if (Me(e.presenter.type)) {
|
|
1366
1366
|
const v = await Oe(e, t, i), j = `${vn}_${v.sessionId}`, I = (/* @__PURE__ */ new Date()).toISOString();
|
|
1367
1367
|
return { chatResult: {
|
|
1368
|
-
chatMode:
|
|
1368
|
+
chatMode: T.Functional,
|
|
1369
1369
|
chat: {
|
|
1370
1370
|
id: j,
|
|
1371
1371
|
agent_id: e.id,
|
|
@@ -1374,7 +1374,7 @@ async function bn(e, t, n, i, c) {
|
|
|
1374
1374
|
modified: I,
|
|
1375
1375
|
agent_id__created_at: I,
|
|
1376
1376
|
agent_id__modified_at: I,
|
|
1377
|
-
chat_mode:
|
|
1377
|
+
chat_mode: T.Functional,
|
|
1378
1378
|
messages: []
|
|
1379
1379
|
}
|
|
1380
1380
|
}, streamingManager: v };
|
|
@@ -1397,12 +1397,12 @@ async function bn(e, t, n, i, c) {
|
|
|
1397
1397
|
}
|
|
1398
1398
|
}
|
|
1399
1399
|
}, { chatResult: s, streamingManager: r } = await o(), { chat: a, chatMode: d } = s;
|
|
1400
|
-
return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (u = (m = t.callbacks).onModeChange) == null || u.call(m, d), d !==
|
|
1400
|
+
return d && t.mode !== void 0 && d !== t.mode && (t.mode = d, (u = (m = t.callbacks).onModeChange) == null || u.call(m, d), d !== T.Functional) ? ((w = (f = t.callbacks).onError) == null || w.call(f, new ct(d)), r == null || r.disconnect(), { chat: a }) : { chat: a, streamingManager: r };
|
|
1401
1401
|
}
|
|
1402
1402
|
async function Ln(e, t) {
|
|
1403
1403
|
var U, oe, ce, te;
|
|
1404
1404
|
let n = !0;
|
|
1405
|
-
const i = t.mixpanelKey || Dt, c = t.wsURL || Rt, o = t.baseURL || me, s = t.mode ||
|
|
1405
|
+
const i = t.mixpanelKey || Dt, c = t.wsURL || Rt, o = t.baseURL || me, s = t.mode || T.Functional, r = {
|
|
1406
1406
|
messages: [],
|
|
1407
1407
|
chatMode: s
|
|
1408
1408
|
}, a = Wt({
|
|
@@ -1431,12 +1431,12 @@ async function Ln(e, t) {
|
|
|
1431
1431
|
const I = (l) => {
|
|
1432
1432
|
a.enrich({ videoId: l });
|
|
1433
1433
|
}, b = ({ type: l }) => {
|
|
1434
|
-
var y,
|
|
1435
|
-
if (!((y = r.streamingManager) != null && y.interruptAvailable) || !((
|
|
1434
|
+
var y, k, S, M;
|
|
1435
|
+
if (!((y = r.streamingManager) != null && y.interruptAvailable) || !((k = r.streamingManager) != null && k.isInterruptible)) return;
|
|
1436
1436
|
const g = r.messages[r.messages.length - 1];
|
|
1437
1437
|
a.track("agent-video-interrupt", {
|
|
1438
1438
|
type: l || "click",
|
|
1439
|
-
video_duration_to_interrupt:
|
|
1439
|
+
video_duration_to_interrupt: ke.get(!0),
|
|
1440
1440
|
message_duration_to_interrupt: X.get(!0)
|
|
1441
1441
|
}), g.interrupted = !0, (M = (S = t.callbacks).onNewMessage) == null || M.call(S, [...r.messages], "answer"), r.streamingManager.interrupt(l);
|
|
1442
1442
|
}, P = /* @__PURE__ */ new Map();
|
|
@@ -1446,22 +1446,22 @@ async function Ln(e, t) {
|
|
|
1446
1446
|
if (!y)
|
|
1447
1447
|
throw new Error(`No handler registered for client tool: ${l}`);
|
|
1448
1448
|
try {
|
|
1449
|
-
const
|
|
1450
|
-
return await y(
|
|
1451
|
-
} catch (
|
|
1452
|
-
throw new Error(`Client tool "${l}" failed: ${
|
|
1449
|
+
const k = JSON.parse(g.payload);
|
|
1450
|
+
return await y(k);
|
|
1451
|
+
} catch (k) {
|
|
1452
|
+
throw new Error(`Client tool "${l}" failed: ${k.message}`);
|
|
1453
1453
|
}
|
|
1454
1454
|
};
|
|
1455
1455
|
}
|
|
1456
1456
|
function Q() {
|
|
1457
|
-
var l, g, y,
|
|
1457
|
+
var l, g, y, k;
|
|
1458
1458
|
for (const [S] of P)
|
|
1459
|
-
(g = (l = r.streamingManager) == null ? void 0 : l.unregisterRpcMethod) == null || g.call(l, S), (
|
|
1459
|
+
(g = (l = r.streamingManager) == null ? void 0 : l.unregisterRpcMethod) == null || g.call(l, S), (k = (y = r.streamingManager) == null ? void 0 : y.registerRpcMethod) == null || k.call(y, S, E(S));
|
|
1460
1460
|
}
|
|
1461
1461
|
function H(l, g) {
|
|
1462
|
-
var
|
|
1462
|
+
var k, S;
|
|
1463
1463
|
const y = !P.has(l);
|
|
1464
|
-
P.set(l, g), y && ((S = (
|
|
1464
|
+
P.set(l, g), y && ((S = (k = r.streamingManager) == null ? void 0 : k.registerRpcMethod) == null || S.call(k, l, E(l)));
|
|
1465
1465
|
}
|
|
1466
1466
|
function V(l) {
|
|
1467
1467
|
var g, y;
|
|
@@ -1473,8 +1473,8 @@ async function Ln(e, t) {
|
|
|
1473
1473
|
});
|
|
1474
1474
|
async function Y(l) {
|
|
1475
1475
|
var L, z, N, h, p, D, B;
|
|
1476
|
-
|
|
1477
|
-
const g = s ===
|
|
1476
|
+
Ct(), (z = (L = t.callbacks).onConnectionStateChange) == null || z.call(L, A.Connecting), X.reset(), l && !n && (delete r.chat, (h = (N = t.callbacks).onNewMessage) == null || h.call(N, [...r.messages], "answer"));
|
|
1477
|
+
const g = s === T.DirectPlayback || w ? Promise.resolve(void 0) : Gt(
|
|
1478
1478
|
t.auth,
|
|
1479
1479
|
c,
|
|
1480
1480
|
{ onMessage: v, onError: t.callbacks.onError },
|
|
@@ -1503,22 +1503,22 @@ async function Ln(e, t) {
|
|
|
1503
1503
|
delayMs: 1e3
|
|
1504
1504
|
}
|
|
1505
1505
|
).catch((O) => {
|
|
1506
|
-
var
|
|
1507
|
-
throw q(
|
|
1508
|
-
}), [
|
|
1509
|
-
M && M.id !== ((p = r.chat) == null ? void 0 : p.id) && ((B = (D = t.callbacks).onNewChat) == null || B.call(D, M.id)), r.streamingManager = S, r.socketManager =
|
|
1506
|
+
var _, J;
|
|
1507
|
+
throw q(T.Maintenance), (J = (_ = t.callbacks).onConnectionStateChange) == null || J.call(_, A.Fail), O;
|
|
1508
|
+
}), [k, { streamingManager: S, chat: M }] = await Promise.all([g, y]);
|
|
1509
|
+
M && M.id !== ((p = r.chat) == null ? void 0 : p.id) && ((B = (D = t.callbacks).onNewChat) == null || B.call(D, M.id)), r.streamingManager = S, r.socketManager = k, r.chat = M, Q(), n = !1, a.enrich({
|
|
1510
1510
|
chatId: M == null ? void 0 : M.id,
|
|
1511
1511
|
streamId: S == null ? void 0 : S.streamId,
|
|
1512
1512
|
mode: r.chatMode
|
|
1513
1513
|
}), q((M == null ? void 0 : M.chat_mode) ?? s);
|
|
1514
1514
|
}
|
|
1515
1515
|
async function R() {
|
|
1516
|
-
var l, g, y,
|
|
1517
|
-
(l = r.socketManager) == null || l.disconnect(), await ((g = r.streamingManager) == null ? void 0 : g.disconnect()), delete r.streamingManager, delete r.socketManager, (
|
|
1516
|
+
var l, g, y, k;
|
|
1517
|
+
(l = r.socketManager) == null || l.disconnect(), await ((g = r.streamingManager) == null ? void 0 : g.disconnect()), delete r.streamingManager, delete r.socketManager, (k = (y = t.callbacks).onConnectionStateChange) == null || k.call(y, A.Disconnected);
|
|
1518
1518
|
}
|
|
1519
1519
|
async function q(l) {
|
|
1520
1520
|
var g, y;
|
|
1521
|
-
l !== r.chatMode && (a.track("agent-mode-change", { mode: l }), r.chatMode = l, r.chatMode !==
|
|
1521
|
+
l !== r.chatMode && (a.track("agent-mode-change", { mode: l }), r.chatMode = l, r.chatMode !== T.Functional && await R(), (y = (g = t.callbacks).onModeChange) == null || y.call(g, l));
|
|
1522
1522
|
}
|
|
1523
1523
|
return {
|
|
1524
1524
|
agent: f,
|
|
@@ -1593,9 +1593,9 @@ async function Ln(e, t) {
|
|
|
1593
1593
|
throw new $(`Message cannot be more than ${be} characters`);
|
|
1594
1594
|
if (l.length === 0)
|
|
1595
1595
|
throw new $("Message cannot be empty");
|
|
1596
|
-
if (r.chatMode ===
|
|
1596
|
+
if (r.chatMode === T.Maintenance)
|
|
1597
1597
|
throw new $("Chat is in maintenance mode");
|
|
1598
|
-
if (![
|
|
1598
|
+
if (![T.TextOnly, T.Playground].includes(r.chatMode)) {
|
|
1599
1599
|
if (!r.streamingManager)
|
|
1600
1600
|
throw new $("Streaming manager is not initialized");
|
|
1601
1601
|
if (!r.chat)
|
|
@@ -1616,19 +1616,19 @@ async function Ln(e, t) {
|
|
|
1616
1616
|
r.chat = D.chat, (p = (h = t.callbacks).onNewChat) == null || p.call(h, r.chat.id);
|
|
1617
1617
|
}
|
|
1618
1618
|
return r.chat.id;
|
|
1619
|
-
},
|
|
1620
|
-
const D = r.chatMode ===
|
|
1619
|
+
}, k = async (h, p) => {
|
|
1620
|
+
const D = r.chatMode === T.Playground;
|
|
1621
1621
|
return ye(w && !D ? async () => {
|
|
1622
|
-
var
|
|
1623
|
-
return await ((J = (
|
|
1622
|
+
var _, J;
|
|
1623
|
+
return await ((J = (_ = r.streamingManager) == null ? void 0 : _.sendTextMessage) == null ? void 0 : J.call(_, l)), Promise.resolve({});
|
|
1624
1624
|
} : async () => {
|
|
1625
|
-
var
|
|
1625
|
+
var _, J;
|
|
1626
1626
|
return u.chat(
|
|
1627
1627
|
f.id,
|
|
1628
1628
|
p,
|
|
1629
1629
|
{
|
|
1630
1630
|
chatMode: r.chatMode,
|
|
1631
|
-
streamId: (
|
|
1631
|
+
streamId: (_ = r.streamingManager) == null ? void 0 : _.streamId,
|
|
1632
1632
|
sessionId: (J = r.streamingManager) == null ? void 0 : J.sessionId,
|
|
1633
1633
|
messages: h.map(({ matches: at, ...de }) => de)
|
|
1634
1634
|
},
|
|
@@ -1639,10 +1639,10 @@ async function Ln(e, t) {
|
|
|
1639
1639
|
);
|
|
1640
1640
|
}, {
|
|
1641
1641
|
limit: 2,
|
|
1642
|
-
shouldRetryFn: (
|
|
1642
|
+
shouldRetryFn: (_) => {
|
|
1643
1643
|
var de, De, Ie, Ee;
|
|
1644
|
-
const J = (de =
|
|
1645
|
-
return !((De =
|
|
1644
|
+
const J = (de = _ == null ? void 0 : _.message) == null ? void 0 : de.includes("missing or invalid session_id");
|
|
1645
|
+
return !((De = _ == null ? void 0 : _.message) == null ? void 0 : De.includes("Stream Error")) && !J ? ((Ee = (Ie = t.callbacks).onError) == null || Ee.call(Ie, _), !1) : !0;
|
|
1646
1646
|
},
|
|
1647
1647
|
onRetry: async () => {
|
|
1648
1648
|
await R(), await Y(!1);
|
|
@@ -1657,7 +1657,7 @@ async function Ln(e, t) {
|
|
|
1657
1657
|
parts: ae(l),
|
|
1658
1658
|
created_at: new Date(X.update()).toISOString()
|
|
1659
1659
|
}), (M = (S = t.callbacks).onNewMessage) == null || M.call(S, [...r.messages], "user");
|
|
1660
|
-
const h = await y(), p = await
|
|
1660
|
+
const h = await y(), p = await k([...r.messages], h);
|
|
1661
1661
|
return p.result && r.messages.push({
|
|
1662
1662
|
id: ee(),
|
|
1663
1663
|
role: "assistant",
|
|
@@ -1683,12 +1683,12 @@ async function Ln(e, t) {
|
|
|
1683
1683
|
},
|
|
1684
1684
|
rate(l, g, y) {
|
|
1685
1685
|
var M, L, z, N;
|
|
1686
|
-
const
|
|
1686
|
+
const k = r.messages.find((h) => h.id === l);
|
|
1687
1687
|
if (r.chat) {
|
|
1688
|
-
if (!
|
|
1688
|
+
if (!k)
|
|
1689
1689
|
throw new $("Message not found");
|
|
1690
1690
|
} else throw new $("Chat is not initialized");
|
|
1691
|
-
const S = ((M =
|
|
1691
|
+
const S = ((M = k.matches) == null ? void 0 : M.map((h) => [h.document_id, h.id])) ?? [];
|
|
1692
1692
|
return a.track("agent-rate", {
|
|
1693
1693
|
event: y ? "update" : "create",
|
|
1694
1694
|
thumb: g === 1 ? "up" : "down",
|
|
@@ -1737,7 +1737,8 @@ async function Ln(e, t) {
|
|
|
1737
1737
|
type: "text",
|
|
1738
1738
|
provider: f.presenter.voice,
|
|
1739
1739
|
input: l.input,
|
|
1740
|
-
ssml: l.ssml
|
|
1740
|
+
ssml: l.ssml,
|
|
1741
|
+
should_queue_speaks: l.should_queue_speaks
|
|
1741
1742
|
};
|
|
1742
1743
|
}
|
|
1743
1744
|
return l;
|
|
@@ -1791,21 +1792,21 @@ export {
|
|
|
1791
1792
|
re as g,
|
|
1792
1793
|
fn as h,
|
|
1793
1794
|
Pn as i,
|
|
1794
|
-
|
|
1795
|
+
C as j,
|
|
1795
1796
|
ht as k,
|
|
1796
1797
|
X as l,
|
|
1797
1798
|
ot as m,
|
|
1798
1799
|
xn as n,
|
|
1799
|
-
|
|
1800
|
+
T as o,
|
|
1800
1801
|
ct as p,
|
|
1801
1802
|
vt as q,
|
|
1802
1803
|
Jt as r,
|
|
1803
1804
|
pt as s,
|
|
1804
1805
|
ge as t,
|
|
1805
1806
|
He as u,
|
|
1806
|
-
|
|
1807
|
+
kt as v,
|
|
1807
1808
|
Ln as w,
|
|
1808
|
-
|
|
1809
|
+
Tn as x,
|
|
1809
1810
|
An as y,
|
|
1810
1811
|
At as z
|
|
1811
1812
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as e, k as r, B as t, m as o, o as n, p as i, C as S, f as p, g as d, D as g, H as c, K as E, N as m, P as y, q as C, R as P, r as T, e as v, S as A, b as D, j as V, s as l, T as u, U as h, V as w, u as M, v as K, W as N, w as R, x as b, y as f, z as j } from "./index-
|
|
1
|
+
import { A as e, k as r, B as t, m as o, o as n, p as i, C as S, f as p, g as d, D as g, H as c, K as E, N as m, P as y, q as C, R as P, r as T, e as v, S as A, b as D, j as V, s as l, T as u, U as h, V as w, u as M, v as K, W as N, w as R, x as b, y as f, z as j } from "./index-DutjNwn9.js";
|
|
2
2
|
export {
|
|
3
3
|
e as AgentActivityState,
|
|
4
4
|
r as AgentStatus,
|