@asgard-js/core 0.1.25 → 0.1.27
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/README.md +35 -1
- package/dist/constants/enum.d.ts +2 -1
- package/dist/constants/enum.d.ts.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +270 -265
- package/dist/index.mjs.map +1 -1
- package/dist/lib/client.d.ts +1 -0
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/lib/create-sse-observable.d.ts +1 -0
- package/dist/lib/create-sse-observable.d.ts.map +1 -1
- package/dist/types/client.d.ts +10 -0
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/sse-response.d.ts +22 -1
- package/dist/types/sse-response.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Ne = Object.defineProperty;
|
|
2
2
|
var Ge = (r, t, e) => t in r ? Ne(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
3
|
var b = (r, t, e) => Ge(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
var Y = /* @__PURE__ */ ((r) => (r.RESET_CHANNEL = "RESET_CHANNEL", r.NONE = "NONE", r))(Y || {}),
|
|
4
|
+
var Y = /* @__PURE__ */ ((r) => (r.RESET_CHANNEL = "RESET_CHANNEL", r.NONE = "NONE", r))(Y || {}), d = /* @__PURE__ */ ((r) => (r.INIT = "asgard.run.init", r.PROCESS = "asgard.process", r.PROCESS_START = "asgard.process.start", r.PROCESS_COMPLETE = "asgard.process.complete", r.MESSAGE = "asgard.message", r.MESSAGE_START = "asgard.message.start", r.MESSAGE_DELTA = "asgard.message.delta", r.MESSAGE_COMPLETE = "asgard.message.complete", r.TOOL_CALL = "asgard.tool_call", r.TOOL_CALL_START = "asgard.tool_call.start", r.TOOL_CALL_COMPLETE = "asgard.tool_call.complete", r.DONE = "asgard.run.done", r.ERROR = "asgard.run.error", r))(d || {}), He = /* @__PURE__ */ ((r) => (r.TEXT = "TEXT", r.HINT = "HINT", r.BUTTON = "BUTTON", r.IMAGE = "IMAGE", r.VIDEO = "VIDEO", r.AUDIO = "AUDIO", r.LOCATION = "LOCATION", r.CAROUSEL = "CAROUSEL", r.CHART = "CHART", r.TABLE = "TABLE", r))(He || {}), W = function(r, t) {
|
|
5
5
|
return W = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, n) {
|
|
6
6
|
e.__proto__ = n;
|
|
7
7
|
} || function(e, n) {
|
|
@@ -17,29 +17,29 @@ function A(r, t) {
|
|
|
17
17
|
}
|
|
18
18
|
r.prototype = t === null ? Object.create(t) : (e.prototype = t.prototype, new e());
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function Fe(r, t, e, n) {
|
|
21
21
|
function i(o) {
|
|
22
22
|
return o instanceof e ? o : new e(function(s) {
|
|
23
23
|
s(o);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
return new (e || (e = Promise))(function(o, s) {
|
|
27
|
-
function
|
|
27
|
+
function c(f) {
|
|
28
28
|
try {
|
|
29
|
-
u(n.next(
|
|
30
|
-
} catch (
|
|
31
|
-
s(
|
|
29
|
+
u(n.next(f));
|
|
30
|
+
} catch (h) {
|
|
31
|
+
s(h);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function a(f) {
|
|
35
35
|
try {
|
|
36
|
-
u(n.throw(
|
|
37
|
-
} catch (
|
|
38
|
-
s(
|
|
36
|
+
u(n.throw(f));
|
|
37
|
+
} catch (h) {
|
|
38
|
+
s(h);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
function u(
|
|
42
|
-
|
|
41
|
+
function u(f) {
|
|
42
|
+
f.done ? o(f.value) : i(f.value).then(c, a);
|
|
43
43
|
}
|
|
44
44
|
u((n = n.apply(r, t || [])).next());
|
|
45
45
|
});
|
|
@@ -49,15 +49,15 @@ function de(r, t) {
|
|
|
49
49
|
if (o[0] & 1) throw o[1];
|
|
50
50
|
return o[1];
|
|
51
51
|
}, trys: [], ops: [] }, n, i, o, s = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
|
|
52
|
-
return s.next =
|
|
52
|
+
return s.next = c(0), s.throw = c(1), s.return = c(2), typeof Symbol == "function" && (s[Symbol.iterator] = function() {
|
|
53
53
|
return this;
|
|
54
54
|
}), s;
|
|
55
|
-
function
|
|
56
|
-
return function(
|
|
57
|
-
return
|
|
55
|
+
function c(u) {
|
|
56
|
+
return function(f) {
|
|
57
|
+
return a([u, f]);
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function a(u) {
|
|
61
61
|
if (n) throw new TypeError("Generator is already executing.");
|
|
62
62
|
for (; s && (s = 0, u[0] && (e = 0)), e; ) try {
|
|
63
63
|
if (n = 1, i && (o = u[0] & 2 ? i.return : u[0] ? i.throw || ((o = i.return) && o.call(i), 0) : i.next) && !(o = o.call(i, u[1])).done) return o;
|
|
@@ -95,8 +95,8 @@ function de(r, t) {
|
|
|
95
95
|
continue;
|
|
96
96
|
}
|
|
97
97
|
u = t.call(r, e);
|
|
98
|
-
} catch (
|
|
99
|
-
u = [6,
|
|
98
|
+
} catch (f) {
|
|
99
|
+
u = [6, f], i = 0;
|
|
100
100
|
} finally {
|
|
101
101
|
n = o = 0;
|
|
102
102
|
}
|
|
@@ -104,7 +104,7 @@ function de(r, t) {
|
|
|
104
104
|
return { value: u[0] ? u[1] : void 0, done: !0 };
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function M(r) {
|
|
108
108
|
var t = typeof Symbol == "function" && Symbol.iterator, e = t && r[t], n = 0;
|
|
109
109
|
if (e) return e.call(r);
|
|
110
110
|
if (r && typeof r.length == "number") return {
|
|
@@ -120,8 +120,8 @@ function R(r, t) {
|
|
|
120
120
|
var n = e.call(r), i, o = [], s;
|
|
121
121
|
try {
|
|
122
122
|
for (; (t === void 0 || t-- > 0) && !(i = n.next()).done; ) o.push(i.value);
|
|
123
|
-
} catch (
|
|
124
|
-
s = { error:
|
|
123
|
+
} catch (c) {
|
|
124
|
+
s = { error: c };
|
|
125
125
|
} finally {
|
|
126
126
|
try {
|
|
127
127
|
i && !i.done && (e = n.return) && e.call(n);
|
|
@@ -136,63 +136,63 @@ function U(r, t, e) {
|
|
|
136
136
|
(o || !(n in t)) && (o || (o = Array.prototype.slice.call(t, 0, n)), o[n] = t[n]);
|
|
137
137
|
return r.concat(o || Array.prototype.slice.call(t));
|
|
138
138
|
}
|
|
139
|
-
function
|
|
140
|
-
return this instanceof
|
|
139
|
+
function L(r) {
|
|
140
|
+
return this instanceof L ? (this.v = r, this) : new L(r);
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function Ve(r, t, e) {
|
|
143
143
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
144
144
|
var n = e.apply(r, t || []), i, o = [];
|
|
145
|
-
return i = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype),
|
|
145
|
+
return i = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), c("next"), c("throw"), c("return", s), i[Symbol.asyncIterator] = function() {
|
|
146
146
|
return this;
|
|
147
147
|
}, i;
|
|
148
|
-
function s(
|
|
148
|
+
function s(l) {
|
|
149
149
|
return function(p) {
|
|
150
|
-
return Promise.resolve(p).then(
|
|
150
|
+
return Promise.resolve(p).then(l, h);
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
|
-
function
|
|
154
|
-
n[
|
|
153
|
+
function c(l, p) {
|
|
154
|
+
n[l] && (i[l] = function(y) {
|
|
155
155
|
return new Promise(function(w, E) {
|
|
156
|
-
o.push([
|
|
156
|
+
o.push([l, y, w, E]) > 1 || a(l, y);
|
|
157
157
|
});
|
|
158
|
-
}, p && (i[
|
|
158
|
+
}, p && (i[l] = p(i[l])));
|
|
159
159
|
}
|
|
160
|
-
function
|
|
160
|
+
function a(l, p) {
|
|
161
161
|
try {
|
|
162
|
-
u(n[
|
|
163
|
-
} catch (
|
|
164
|
-
|
|
162
|
+
u(n[l](p));
|
|
163
|
+
} catch (y) {
|
|
164
|
+
v(o[0][3], y);
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
function u(
|
|
168
|
-
|
|
167
|
+
function u(l) {
|
|
168
|
+
l.value instanceof L ? Promise.resolve(l.value.v).then(f, h) : v(o[0][2], l);
|
|
169
169
|
}
|
|
170
|
-
function l
|
|
171
|
-
|
|
170
|
+
function f(l) {
|
|
171
|
+
a("next", l);
|
|
172
172
|
}
|
|
173
|
-
function
|
|
174
|
-
|
|
173
|
+
function h(l) {
|
|
174
|
+
a("throw", l);
|
|
175
175
|
}
|
|
176
|
-
function
|
|
177
|
-
|
|
176
|
+
function v(l, p) {
|
|
177
|
+
l(p), o.shift(), o.length && a(o[0][0], o[0][1]);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
function
|
|
180
|
+
function qe(r) {
|
|
181
181
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
182
182
|
var t = r[Symbol.asyncIterator], e;
|
|
183
|
-
return t ? t.call(r) : (r = typeof
|
|
183
|
+
return t ? t.call(r) : (r = typeof M == "function" ? M(r) : r[Symbol.iterator](), e = {}, n("next"), n("throw"), n("return"), e[Symbol.asyncIterator] = function() {
|
|
184
184
|
return this;
|
|
185
185
|
}, e);
|
|
186
186
|
function n(o) {
|
|
187
187
|
e[o] = r[o] && function(s) {
|
|
188
|
-
return new Promise(function(
|
|
189
|
-
s = r[o](s), i(
|
|
188
|
+
return new Promise(function(c, a) {
|
|
189
|
+
s = r[o](s), i(c, a, s.done, s.value);
|
|
190
190
|
});
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
|
-
function i(o, s,
|
|
194
|
-
Promise.resolve(
|
|
195
|
-
o({ value: u, done:
|
|
193
|
+
function i(o, s, c, a) {
|
|
194
|
+
Promise.resolve(a).then(function(u) {
|
|
195
|
+
o({ value: u, done: c });
|
|
196
196
|
}, s);
|
|
197
197
|
}
|
|
198
198
|
}
|
|
@@ -232,45 +232,45 @@ var k = (function() {
|
|
|
232
232
|
if (s)
|
|
233
233
|
if (this._parentage = null, Array.isArray(s))
|
|
234
234
|
try {
|
|
235
|
-
for (var
|
|
236
|
-
var u =
|
|
235
|
+
for (var c = M(s), a = c.next(); !a.done; a = c.next()) {
|
|
236
|
+
var u = a.value;
|
|
237
237
|
u.remove(this);
|
|
238
238
|
}
|
|
239
|
-
} catch (
|
|
240
|
-
t = { error:
|
|
239
|
+
} catch (y) {
|
|
240
|
+
t = { error: y };
|
|
241
241
|
} finally {
|
|
242
242
|
try {
|
|
243
|
-
|
|
243
|
+
a && !a.done && (e = c.return) && e.call(c);
|
|
244
244
|
} finally {
|
|
245
245
|
if (t) throw t.error;
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
else
|
|
249
249
|
s.remove(this);
|
|
250
|
-
var
|
|
251
|
-
if (m(
|
|
250
|
+
var f = this.initialTeardown;
|
|
251
|
+
if (m(f))
|
|
252
252
|
try {
|
|
253
|
-
|
|
254
|
-
} catch (
|
|
255
|
-
o =
|
|
253
|
+
f();
|
|
254
|
+
} catch (y) {
|
|
255
|
+
o = y instanceof K ? y.errors : [y];
|
|
256
256
|
}
|
|
257
|
-
var
|
|
258
|
-
if (
|
|
257
|
+
var h = this._finalizers;
|
|
258
|
+
if (h) {
|
|
259
259
|
this._finalizers = null;
|
|
260
260
|
try {
|
|
261
|
-
for (var
|
|
262
|
-
var p =
|
|
261
|
+
for (var v = M(h), l = v.next(); !l.done; l = v.next()) {
|
|
262
|
+
var p = l.value;
|
|
263
263
|
try {
|
|
264
264
|
re(p);
|
|
265
|
-
} catch (
|
|
266
|
-
o = o ?? [],
|
|
265
|
+
} catch (y) {
|
|
266
|
+
o = o ?? [], y instanceof K ? o = U(U([], R(o)), R(y.errors)) : o.push(y);
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
|
-
} catch (
|
|
270
|
-
n = { error:
|
|
269
|
+
} catch (y) {
|
|
270
|
+
n = { error: y };
|
|
271
271
|
} finally {
|
|
272
272
|
try {
|
|
273
|
-
|
|
273
|
+
l && !l.done && (i = v.return) && i.call(v);
|
|
274
274
|
} finally {
|
|
275
275
|
if (n) throw n.error;
|
|
276
276
|
}
|
|
@@ -426,11 +426,11 @@ var Xe = {
|
|
|
426
426
|
}, Z = (function() {
|
|
427
427
|
return typeof Symbol == "function" && Symbol.observable || "@@observable";
|
|
428
428
|
})();
|
|
429
|
-
function
|
|
429
|
+
function H(r) {
|
|
430
430
|
return r;
|
|
431
431
|
}
|
|
432
432
|
function Je(r) {
|
|
433
|
-
return r.length === 0 ?
|
|
433
|
+
return r.length === 0 ? H : r.length === 1 ? r[0] : function(e) {
|
|
434
434
|
return r.reduce(function(n, i) {
|
|
435
435
|
return i(n);
|
|
436
436
|
}, e);
|
|
@@ -446,8 +446,8 @@ var S = (function() {
|
|
|
446
446
|
}, r.prototype.subscribe = function(t, e, n) {
|
|
447
447
|
var i = this, o = Qe(t) ? t : new J(t, e, n);
|
|
448
448
|
return D(function() {
|
|
449
|
-
var s = i,
|
|
450
|
-
o.add(
|
|
449
|
+
var s = i, c = s.operator, a = s.source;
|
|
450
|
+
o.add(c ? c.call(o, a) : a ? i._subscribe(o) : i._trySubscribe(o));
|
|
451
451
|
}), o;
|
|
452
452
|
}, r.prototype._trySubscribe = function(t) {
|
|
453
453
|
try {
|
|
@@ -459,11 +459,11 @@ var S = (function() {
|
|
|
459
459
|
var n = this;
|
|
460
460
|
return e = ne(e), new e(function(i, o) {
|
|
461
461
|
var s = new J({
|
|
462
|
-
next: function(
|
|
462
|
+
next: function(c) {
|
|
463
463
|
try {
|
|
464
|
-
t(
|
|
465
|
-
} catch (
|
|
466
|
-
o(
|
|
464
|
+
t(c);
|
|
465
|
+
} catch (a) {
|
|
466
|
+
o(a), s.unsubscribe();
|
|
467
467
|
}
|
|
468
468
|
},
|
|
469
469
|
error: o,
|
|
@@ -527,23 +527,23 @@ function O(r, t, e, n, i) {
|
|
|
527
527
|
}
|
|
528
528
|
var et = (function(r) {
|
|
529
529
|
A(t, r);
|
|
530
|
-
function t(e, n, i, o, s,
|
|
531
|
-
var
|
|
532
|
-
return
|
|
530
|
+
function t(e, n, i, o, s, c) {
|
|
531
|
+
var a = r.call(this, e) || this;
|
|
532
|
+
return a.onFinalize = s, a.shouldUnsubscribe = c, a._next = n ? function(u) {
|
|
533
533
|
try {
|
|
534
534
|
n(u);
|
|
535
|
-
} catch (
|
|
536
|
-
e.error(
|
|
535
|
+
} catch (f) {
|
|
536
|
+
e.error(f);
|
|
537
537
|
}
|
|
538
|
-
} : r.prototype._next,
|
|
538
|
+
} : r.prototype._next, a._error = o ? function(u) {
|
|
539
539
|
try {
|
|
540
540
|
o(u);
|
|
541
|
-
} catch (
|
|
542
|
-
e.error(
|
|
541
|
+
} catch (f) {
|
|
542
|
+
e.error(f);
|
|
543
543
|
} finally {
|
|
544
544
|
this.unsubscribe();
|
|
545
545
|
}
|
|
546
|
-
} : r.prototype._error,
|
|
546
|
+
} : r.prototype._error, a._complete = i ? function() {
|
|
547
547
|
try {
|
|
548
548
|
i();
|
|
549
549
|
} catch (u) {
|
|
@@ -551,7 +551,7 @@ var et = (function(r) {
|
|
|
551
551
|
} finally {
|
|
552
552
|
this.unsubscribe();
|
|
553
553
|
}
|
|
554
|
-
} : r.prototype._complete,
|
|
554
|
+
} : r.prototype._complete, a;
|
|
555
555
|
}
|
|
556
556
|
return t.prototype.unsubscribe = function() {
|
|
557
557
|
var e;
|
|
@@ -583,15 +583,15 @@ var et = (function(r) {
|
|
|
583
583
|
if (n._throwIfClosed(), !n.isStopped) {
|
|
584
584
|
n.currentObservers || (n.currentObservers = Array.from(n.observers));
|
|
585
585
|
try {
|
|
586
|
-
for (var s =
|
|
587
|
-
var
|
|
588
|
-
|
|
586
|
+
for (var s = M(n.currentObservers), c = s.next(); !c.done; c = s.next()) {
|
|
587
|
+
var a = c.value;
|
|
588
|
+
a.next(e);
|
|
589
589
|
}
|
|
590
590
|
} catch (u) {
|
|
591
591
|
i = { error: u };
|
|
592
592
|
} finally {
|
|
593
593
|
try {
|
|
594
|
-
|
|
594
|
+
c && !c.done && (o = s.return) && o.call(s);
|
|
595
595
|
} finally {
|
|
596
596
|
if (i) throw i.error;
|
|
597
597
|
}
|
|
@@ -630,9 +630,9 @@ var et = (function(r) {
|
|
|
630
630
|
}, t.prototype._subscribe = function(e) {
|
|
631
631
|
return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
|
|
632
632
|
}, t.prototype._innerSubscribe = function(e) {
|
|
633
|
-
var n = this, i = this, o = i.hasError, s = i.isStopped,
|
|
634
|
-
return o || s ? ve : (this.currentObservers = null,
|
|
635
|
-
n.currentObservers = null, N(
|
|
633
|
+
var n = this, i = this, o = i.hasError, s = i.isStopped, c = i.observers;
|
|
634
|
+
return o || s ? ve : (this.currentObservers = null, c.push(e), new k(function() {
|
|
635
|
+
n.currentObservers = null, N(c, e);
|
|
636
636
|
}));
|
|
637
637
|
}, t.prototype._checkFinalizedStatuses = function(e) {
|
|
638
638
|
var n = this, i = n.hasError, o = n.thrownError, s = n.isStopped;
|
|
@@ -819,7 +819,7 @@ function _e(r) {
|
|
|
819
819
|
return m(r == null ? void 0 : r[Ce]);
|
|
820
820
|
}
|
|
821
821
|
function Te(r) {
|
|
822
|
-
return
|
|
822
|
+
return Ve(this, arguments, function() {
|
|
823
823
|
var e, n, i, o;
|
|
824
824
|
return de(this, function(s) {
|
|
825
825
|
switch (s.label) {
|
|
@@ -828,13 +828,13 @@ function Te(r) {
|
|
|
828
828
|
case 1:
|
|
829
829
|
s.trys.push([1, , 9, 10]), s.label = 2;
|
|
830
830
|
case 2:
|
|
831
|
-
return [4,
|
|
831
|
+
return [4, L(e.read())];
|
|
832
832
|
case 3:
|
|
833
|
-
return n = s.sent(), i = n.value, o = n.done, o ? [4,
|
|
833
|
+
return n = s.sent(), i = n.value, o = n.done, o ? [4, L(void 0)] : [3, 5];
|
|
834
834
|
case 4:
|
|
835
835
|
return [2, s.sent()];
|
|
836
836
|
case 5:
|
|
837
|
-
return [4,
|
|
837
|
+
return [4, L(i)];
|
|
838
838
|
case 6:
|
|
839
839
|
return [4, s.sent()];
|
|
840
840
|
case 7:
|
|
@@ -899,13 +899,13 @@ function ht(r) {
|
|
|
899
899
|
return new S(function(t) {
|
|
900
900
|
var e, n;
|
|
901
901
|
try {
|
|
902
|
-
for (var i =
|
|
902
|
+
for (var i = M(r), o = i.next(); !o.done; o = i.next()) {
|
|
903
903
|
var s = o.value;
|
|
904
904
|
if (t.next(s), t.closed)
|
|
905
905
|
return;
|
|
906
906
|
}
|
|
907
|
-
} catch (
|
|
908
|
-
e = { error:
|
|
907
|
+
} catch (c) {
|
|
908
|
+
e = { error: c };
|
|
909
909
|
} finally {
|
|
910
910
|
try {
|
|
911
911
|
o && !o.done && (n = i.return) && n.call(i);
|
|
@@ -928,29 +928,29 @@ function vt(r) {
|
|
|
928
928
|
}
|
|
929
929
|
function yt(r, t) {
|
|
930
930
|
var e, n, i, o;
|
|
931
|
-
return
|
|
932
|
-
var s,
|
|
933
|
-
return de(this, function(
|
|
934
|
-
switch (
|
|
931
|
+
return Fe(this, void 0, void 0, function() {
|
|
932
|
+
var s, c;
|
|
933
|
+
return de(this, function(a) {
|
|
934
|
+
switch (a.label) {
|
|
935
935
|
case 0:
|
|
936
|
-
|
|
936
|
+
a.trys.push([0, 5, 6, 11]), e = qe(r), a.label = 1;
|
|
937
937
|
case 1:
|
|
938
938
|
return [4, e.next()];
|
|
939
939
|
case 2:
|
|
940
|
-
if (n =
|
|
940
|
+
if (n = a.sent(), !!n.done) return [3, 4];
|
|
941
941
|
if (s = n.value, t.next(s), t.closed)
|
|
942
942
|
return [2];
|
|
943
|
-
|
|
943
|
+
a.label = 3;
|
|
944
944
|
case 3:
|
|
945
945
|
return [3, 1];
|
|
946
946
|
case 4:
|
|
947
947
|
return [3, 11];
|
|
948
948
|
case 5:
|
|
949
|
-
return
|
|
949
|
+
return c = a.sent(), i = { error: c }, [3, 11];
|
|
950
950
|
case 6:
|
|
951
|
-
return
|
|
951
|
+
return a.trys.push([6, , 9, 10]), n && !n.done && (o = e.return) ? [4, o.call(e)] : [3, 8];
|
|
952
952
|
case 7:
|
|
953
|
-
|
|
953
|
+
a.sent(), a.label = 8;
|
|
954
954
|
case 8:
|
|
955
955
|
return [3, 10];
|
|
956
956
|
case 9:
|
|
@@ -972,7 +972,7 @@ function _(r, t, e, n, i) {
|
|
|
972
972
|
if (r.add(o), !i)
|
|
973
973
|
return o;
|
|
974
974
|
}
|
|
975
|
-
function
|
|
975
|
+
function Le(r, t) {
|
|
976
976
|
return t === void 0 && (t = 0), P(function(e, n) {
|
|
977
977
|
e.subscribe(O(n, function(i) {
|
|
978
978
|
return _(n, r, function() {
|
|
@@ -989,7 +989,7 @@ function Me(r, t) {
|
|
|
989
989
|
}));
|
|
990
990
|
});
|
|
991
991
|
}
|
|
992
|
-
function
|
|
992
|
+
function Me(r, t) {
|
|
993
993
|
return t === void 0 && (t = 0), P(function(e, n) {
|
|
994
994
|
n.add(r.schedule(function() {
|
|
995
995
|
return e.subscribe(n);
|
|
@@ -997,10 +997,10 @@ function Le(r, t) {
|
|
|
997
997
|
});
|
|
998
998
|
}
|
|
999
999
|
function pt(r, t) {
|
|
1000
|
-
return T(r).pipe(
|
|
1000
|
+
return T(r).pipe(Me(t), Le(t));
|
|
1001
1001
|
}
|
|
1002
1002
|
function mt(r, t) {
|
|
1003
|
-
return T(r).pipe(
|
|
1003
|
+
return T(r).pipe(Me(t), Le(t));
|
|
1004
1004
|
}
|
|
1005
1005
|
function bt(r, t) {
|
|
1006
1006
|
return new S(function(e) {
|
|
@@ -1018,8 +1018,8 @@ function gt(r, t) {
|
|
|
1018
1018
|
var i, o, s;
|
|
1019
1019
|
try {
|
|
1020
1020
|
i = n.next(), o = i.value, s = i.done;
|
|
1021
|
-
} catch (
|
|
1022
|
-
e.error(
|
|
1021
|
+
} catch (c) {
|
|
1022
|
+
e.error(c);
|
|
1023
1023
|
return;
|
|
1024
1024
|
}
|
|
1025
1025
|
s ? e.complete() : e.next(o);
|
|
@@ -1075,7 +1075,7 @@ function Et() {
|
|
|
1075
1075
|
function It(r) {
|
|
1076
1076
|
return r instanceof Date && !isNaN(r);
|
|
1077
1077
|
}
|
|
1078
|
-
function
|
|
1078
|
+
function F(r, t) {
|
|
1079
1079
|
return P(function(e, n) {
|
|
1080
1080
|
var i = 0;
|
|
1081
1081
|
e.subscribe(O(n, function(o) {
|
|
@@ -1088,17 +1088,17 @@ function At(r, t) {
|
|
|
1088
1088
|
return Ot(t) ? r.apply(void 0, U([], R(t))) : r(t);
|
|
1089
1089
|
}
|
|
1090
1090
|
function Ct(r) {
|
|
1091
|
-
return
|
|
1091
|
+
return F(function(t) {
|
|
1092
1092
|
return At(r, t);
|
|
1093
1093
|
});
|
|
1094
1094
|
}
|
|
1095
1095
|
var _t = Array.isArray, Tt = Object.getPrototypeOf, xt = Object.prototype, Pt = Object.keys;
|
|
1096
|
-
function
|
|
1096
|
+
function Lt(r) {
|
|
1097
1097
|
if (r.length === 1) {
|
|
1098
1098
|
var t = r[0];
|
|
1099
1099
|
if (_t(t))
|
|
1100
1100
|
return { args: t, keys: null };
|
|
1101
|
-
if (
|
|
1101
|
+
if (Mt(t)) {
|
|
1102
1102
|
var e = Pt(t);
|
|
1103
1103
|
return {
|
|
1104
1104
|
args: e.map(function(n) {
|
|
@@ -1110,7 +1110,7 @@ function Mt(r) {
|
|
|
1110
1110
|
}
|
|
1111
1111
|
return { args: r, keys: null };
|
|
1112
1112
|
}
|
|
1113
|
-
function
|
|
1113
|
+
function Mt(r) {
|
|
1114
1114
|
return r && typeof r == "object" && Tt(r) === xt;
|
|
1115
1115
|
}
|
|
1116
1116
|
function Rt(r, t) {
|
|
@@ -1121,43 +1121,43 @@ function Rt(r, t) {
|
|
|
1121
1121
|
function Ut() {
|
|
1122
1122
|
for (var r = [], t = 0; t < arguments.length; t++)
|
|
1123
1123
|
r[t] = arguments[t];
|
|
1124
|
-
var e = Se(r), n = ct(r), i =
|
|
1124
|
+
var e = Se(r), n = ct(r), i = Lt(r), o = i.args, s = i.keys;
|
|
1125
1125
|
if (o.length === 0)
|
|
1126
1126
|
return te([], e);
|
|
1127
|
-
var
|
|
1128
|
-
return Rt(s,
|
|
1129
|
-
} :
|
|
1130
|
-
return n ?
|
|
1127
|
+
var c = new S(kt(o, e, s ? function(a) {
|
|
1128
|
+
return Rt(s, a);
|
|
1129
|
+
} : H));
|
|
1130
|
+
return n ? c.pipe(Ct(n)) : c;
|
|
1131
1131
|
}
|
|
1132
1132
|
function kt(r, t, e) {
|
|
1133
|
-
return e === void 0 && (e =
|
|
1133
|
+
return e === void 0 && (e = H), function(n) {
|
|
1134
1134
|
ce(t, function() {
|
|
1135
|
-
for (var i = r.length, o = new Array(i), s = i,
|
|
1135
|
+
for (var i = r.length, o = new Array(i), s = i, c = i, a = function(f) {
|
|
1136
1136
|
ce(t, function() {
|
|
1137
|
-
var
|
|
1138
|
-
|
|
1139
|
-
o[
|
|
1137
|
+
var h = te(r[f], t), v = !1;
|
|
1138
|
+
h.subscribe(O(n, function(l) {
|
|
1139
|
+
o[f] = l, v || (v = !0, c--), c || n.next(e(o.slice()));
|
|
1140
1140
|
}, function() {
|
|
1141
1141
|
--s || n.complete();
|
|
1142
1142
|
}));
|
|
1143
1143
|
}, n);
|
|
1144
1144
|
}, u = 0; u < i; u++)
|
|
1145
|
-
|
|
1145
|
+
a(u);
|
|
1146
1146
|
}, n);
|
|
1147
1147
|
};
|
|
1148
1148
|
}
|
|
1149
1149
|
function ce(r, t, e) {
|
|
1150
1150
|
r ? _(e, r, t) : t();
|
|
1151
1151
|
}
|
|
1152
|
-
function $t(r, t, e, n, i, o, s,
|
|
1153
|
-
var
|
|
1154
|
-
|
|
1155
|
-
},
|
|
1156
|
-
return u < n ? p(
|
|
1157
|
-
}, p = function(
|
|
1152
|
+
function $t(r, t, e, n, i, o, s, c) {
|
|
1153
|
+
var a = [], u = 0, f = 0, h = !1, v = function() {
|
|
1154
|
+
h && !a.length && !u && t.complete();
|
|
1155
|
+
}, l = function(y) {
|
|
1156
|
+
return u < n ? p(y) : a.push(y);
|
|
1157
|
+
}, p = function(y) {
|
|
1158
1158
|
u++;
|
|
1159
1159
|
var w = !1;
|
|
1160
|
-
T(e(
|
|
1160
|
+
T(e(y, f++)).subscribe(O(t, function(E) {
|
|
1161
1161
|
t.next(E);
|
|
1162
1162
|
}, function() {
|
|
1163
1163
|
w = !0;
|
|
@@ -1166,24 +1166,24 @@ function $t(r, t, e, n, i, o, s, a) {
|
|
|
1166
1166
|
try {
|
|
1167
1167
|
u--;
|
|
1168
1168
|
for (var E = function() {
|
|
1169
|
-
var x =
|
|
1169
|
+
var x = a.shift();
|
|
1170
1170
|
s || p(x);
|
|
1171
|
-
};
|
|
1171
|
+
}; a.length && u < n; )
|
|
1172
1172
|
E();
|
|
1173
|
-
|
|
1173
|
+
v();
|
|
1174
1174
|
} catch (x) {
|
|
1175
1175
|
t.error(x);
|
|
1176
1176
|
}
|
|
1177
1177
|
}));
|
|
1178
1178
|
};
|
|
1179
|
-
return r.subscribe(O(t,
|
|
1180
|
-
|
|
1179
|
+
return r.subscribe(O(t, l, function() {
|
|
1180
|
+
h = !0, v();
|
|
1181
1181
|
})), function() {
|
|
1182
1182
|
};
|
|
1183
1183
|
}
|
|
1184
1184
|
function G(r, t, e) {
|
|
1185
1185
|
return e === void 0 && (e = 1 / 0), m(t) ? G(function(n, i) {
|
|
1186
|
-
return
|
|
1186
|
+
return F(function(o, s) {
|
|
1187
1187
|
return t(n, o, i, s);
|
|
1188
1188
|
})(T(r(n, i)));
|
|
1189
1189
|
}, e) : (typeof t == "number" && (e = t), P(function(n, i) {
|
|
@@ -1216,7 +1216,7 @@ function Dt(r) {
|
|
|
1216
1216
|
});
|
|
1217
1217
|
}
|
|
1218
1218
|
function Nt(r) {
|
|
1219
|
-
return
|
|
1219
|
+
return F(function() {
|
|
1220
1220
|
return r;
|
|
1221
1221
|
});
|
|
1222
1222
|
}
|
|
@@ -1225,53 +1225,53 @@ function Gt(r, t) {
|
|
|
1225
1225
|
return T(r(e, n)).pipe(Dt(1), Nt(e));
|
|
1226
1226
|
});
|
|
1227
1227
|
}
|
|
1228
|
-
function
|
|
1228
|
+
function Ht(r, t) {
|
|
1229
1229
|
t === void 0 && (t = me);
|
|
1230
1230
|
var e = Ue(r, t);
|
|
1231
1231
|
return Gt(function() {
|
|
1232
1232
|
return e;
|
|
1233
1233
|
});
|
|
1234
1234
|
}
|
|
1235
|
-
function
|
|
1235
|
+
function Ft(r) {
|
|
1236
1236
|
var t;
|
|
1237
1237
|
t = {
|
|
1238
1238
|
count: r
|
|
1239
1239
|
};
|
|
1240
1240
|
var e = t.count, n = e === void 0 ? 1 / 0 : e, i = t.delay, o = t.resetOnSuccess, s = o === void 0 ? !1 : o;
|
|
1241
|
-
return n <= 0 ?
|
|
1242
|
-
var u = 0,
|
|
1243
|
-
var
|
|
1244
|
-
|
|
1245
|
-
s && (u = 0),
|
|
1246
|
-
}, void 0, function(
|
|
1241
|
+
return n <= 0 ? H : P(function(c, a) {
|
|
1242
|
+
var u = 0, f, h = function() {
|
|
1243
|
+
var v = !1;
|
|
1244
|
+
f = c.subscribe(O(a, function(l) {
|
|
1245
|
+
s && (u = 0), a.next(l);
|
|
1246
|
+
}, void 0, function(l) {
|
|
1247
1247
|
if (u++ < n) {
|
|
1248
1248
|
var p = function() {
|
|
1249
|
-
|
|
1249
|
+
f ? (f.unsubscribe(), f = null, h()) : v = !0;
|
|
1250
1250
|
};
|
|
1251
1251
|
if (i != null) {
|
|
1252
|
-
var
|
|
1252
|
+
var y = typeof i == "number" ? Ue(i) : T(i(l, u)), w = O(a, function() {
|
|
1253
1253
|
w.unsubscribe(), p();
|
|
1254
1254
|
}, function() {
|
|
1255
|
-
|
|
1255
|
+
a.complete();
|
|
1256
1256
|
});
|
|
1257
|
-
|
|
1257
|
+
y.subscribe(w);
|
|
1258
1258
|
} else
|
|
1259
1259
|
p();
|
|
1260
1260
|
} else
|
|
1261
|
-
|
|
1262
|
-
})),
|
|
1261
|
+
a.error(l);
|
|
1262
|
+
})), v && (f.unsubscribe(), f = null, h());
|
|
1263
1263
|
};
|
|
1264
|
-
|
|
1264
|
+
h();
|
|
1265
1265
|
});
|
|
1266
1266
|
}
|
|
1267
|
-
function
|
|
1267
|
+
function Vt(r) {
|
|
1268
1268
|
return P(function(t, e) {
|
|
1269
1269
|
T(r).subscribe(O(e, function() {
|
|
1270
1270
|
return e.complete();
|
|
1271
1271
|
}, X)), !e.closed && t.subscribe(e);
|
|
1272
1272
|
});
|
|
1273
1273
|
}
|
|
1274
|
-
async function
|
|
1274
|
+
async function qt(r, t) {
|
|
1275
1275
|
const e = r.getReader();
|
|
1276
1276
|
let n;
|
|
1277
1277
|
for (; !(n = await e.read()).done; )
|
|
@@ -1281,15 +1281,15 @@ function Kt(r) {
|
|
|
1281
1281
|
let t, e, n, i = !1;
|
|
1282
1282
|
return function(s) {
|
|
1283
1283
|
t === void 0 ? (t = s, e = 0, n = -1) : t = Yt(t, s);
|
|
1284
|
-
const
|
|
1285
|
-
let
|
|
1286
|
-
for (; e <
|
|
1287
|
-
i && (t[e] === 10 && (
|
|
1284
|
+
const c = t.length;
|
|
1285
|
+
let a = 0;
|
|
1286
|
+
for (; e < c; ) {
|
|
1287
|
+
i && (t[e] === 10 && (a = ++e), i = !1);
|
|
1288
1288
|
let u = -1;
|
|
1289
|
-
for (; e <
|
|
1289
|
+
for (; e < c && u === -1; ++e)
|
|
1290
1290
|
switch (t[e]) {
|
|
1291
1291
|
case 58:
|
|
1292
|
-
n === -1 && (n = e -
|
|
1292
|
+
n === -1 && (n = e - a);
|
|
1293
1293
|
break;
|
|
1294
1294
|
case 13:
|
|
1295
1295
|
i = !0;
|
|
@@ -1299,33 +1299,33 @@ function Kt(r) {
|
|
|
1299
1299
|
}
|
|
1300
1300
|
if (u === -1)
|
|
1301
1301
|
break;
|
|
1302
|
-
r(t.subarray(
|
|
1302
|
+
r(t.subarray(a, u), n), a = e, n = -1;
|
|
1303
1303
|
}
|
|
1304
|
-
|
|
1304
|
+
a === c ? t = void 0 : a !== 0 && (t = t.subarray(a), e -= a);
|
|
1305
1305
|
};
|
|
1306
1306
|
}
|
|
1307
1307
|
function Bt(r, t, e) {
|
|
1308
1308
|
let n = ue();
|
|
1309
1309
|
const i = new TextDecoder();
|
|
1310
|
-
return function(s,
|
|
1310
|
+
return function(s, c) {
|
|
1311
1311
|
if (s.length === 0)
|
|
1312
1312
|
e == null || e(n), n = ue();
|
|
1313
|
-
else if (
|
|
1314
|
-
const
|
|
1315
|
-
switch (
|
|
1313
|
+
else if (c > 0) {
|
|
1314
|
+
const a = i.decode(s.subarray(0, c)), u = c + (s[c + 1] === 32 ? 2 : 1), f = i.decode(s.subarray(u));
|
|
1315
|
+
switch (a) {
|
|
1316
1316
|
case "data":
|
|
1317
1317
|
n.data = n.data ? n.data + `
|
|
1318
|
-
` +
|
|
1318
|
+
` + f : f;
|
|
1319
1319
|
break;
|
|
1320
1320
|
case "event":
|
|
1321
|
-
n.event =
|
|
1321
|
+
n.event = f;
|
|
1322
1322
|
break;
|
|
1323
1323
|
case "id":
|
|
1324
|
-
r(n.id =
|
|
1324
|
+
r(n.id = f);
|
|
1325
1325
|
break;
|
|
1326
1326
|
case "retry":
|
|
1327
|
-
const
|
|
1328
|
-
isNaN(
|
|
1327
|
+
const h = parseInt(f, 10);
|
|
1328
|
+
isNaN(h) || t(n.retry = h);
|
|
1329
1329
|
break;
|
|
1330
1330
|
}
|
|
1331
1331
|
}
|
|
@@ -1353,44 +1353,44 @@ var Wt = function(r, t) {
|
|
|
1353
1353
|
};
|
|
1354
1354
|
const z = "text/event-stream", Xt = 1e3, le = "last-event-id";
|
|
1355
1355
|
function Jt(r, t) {
|
|
1356
|
-
var { signal: e, headers: n, onopen: i, onmessage: o, onclose: s, onerror:
|
|
1357
|
-
return new Promise((
|
|
1358
|
-
const
|
|
1359
|
-
|
|
1356
|
+
var { signal: e, headers: n, onopen: i, onmessage: o, onclose: s, onerror: c, openWhenHidden: a, fetch: u } = t, f = Wt(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
1357
|
+
return new Promise((h, v) => {
|
|
1358
|
+
const l = Object.assign({}, n);
|
|
1359
|
+
l.accept || (l.accept = z);
|
|
1360
1360
|
let p;
|
|
1361
|
-
function
|
|
1362
|
-
p.abort(), document.hidden ||
|
|
1361
|
+
function y() {
|
|
1362
|
+
p.abort(), document.hidden || V();
|
|
1363
1363
|
}
|
|
1364
|
-
|
|
1364
|
+
a || document.addEventListener("visibilitychange", y);
|
|
1365
1365
|
let w = Xt, E = 0;
|
|
1366
1366
|
function x() {
|
|
1367
|
-
document.removeEventListener("visibilitychange",
|
|
1367
|
+
document.removeEventListener("visibilitychange", y), window.clearTimeout(E), p.abort();
|
|
1368
1368
|
}
|
|
1369
1369
|
e == null || e.addEventListener("abort", () => {
|
|
1370
|
-
x(),
|
|
1370
|
+
x(), h();
|
|
1371
1371
|
});
|
|
1372
1372
|
const je = u ?? window.fetch, De = i ?? zt;
|
|
1373
|
-
async function
|
|
1374
|
-
var
|
|
1373
|
+
async function V() {
|
|
1374
|
+
var q;
|
|
1375
1375
|
p = new AbortController();
|
|
1376
1376
|
try {
|
|
1377
|
-
const $ = await je(r, Object.assign(Object.assign({},
|
|
1378
|
-
await De($), await
|
|
1379
|
-
C ?
|
|
1377
|
+
const $ = await je(r, Object.assign(Object.assign({}, f), { headers: l, signal: p.signal }));
|
|
1378
|
+
await De($), await qt($.body, Kt(Bt((C) => {
|
|
1379
|
+
C ? l[le] = C : delete l[le];
|
|
1380
1380
|
}, (C) => {
|
|
1381
1381
|
w = C;
|
|
1382
|
-
}, o))), s == null || s(), x(),
|
|
1382
|
+
}, o))), s == null || s(), x(), h();
|
|
1383
1383
|
} catch ($) {
|
|
1384
1384
|
if (!p.signal.aborted)
|
|
1385
1385
|
try {
|
|
1386
|
-
const C = (
|
|
1387
|
-
window.clearTimeout(E), E = window.setTimeout(
|
|
1386
|
+
const C = (q = c == null ? void 0 : c($)) !== null && q !== void 0 ? q : w;
|
|
1387
|
+
window.clearTimeout(E), E = window.setTimeout(V, C);
|
|
1388
1388
|
} catch (C) {
|
|
1389
|
-
x(),
|
|
1389
|
+
x(), v(C);
|
|
1390
1390
|
}
|
|
1391
1391
|
}
|
|
1392
1392
|
}
|
|
1393
|
-
|
|
1393
|
+
V();
|
|
1394
1394
|
});
|
|
1395
1395
|
}
|
|
1396
1396
|
function zt(r) {
|
|
@@ -1399,42 +1399,43 @@ function zt(r) {
|
|
|
1399
1399
|
throw new Error(`Expected content-type to be ${z}, Actual: ${t}`);
|
|
1400
1400
|
}
|
|
1401
1401
|
function Qt(r) {
|
|
1402
|
-
const { endpoint: t, apiKey: e, payload: n, debugMode: i } = r;
|
|
1403
|
-
return new S((
|
|
1404
|
-
const
|
|
1402
|
+
const { endpoint: t, apiKey: e, payload: n, debugMode: i, customHeaders: o } = r;
|
|
1403
|
+
return new S((s) => {
|
|
1404
|
+
const c = new AbortController();
|
|
1405
1405
|
let a;
|
|
1406
|
-
const
|
|
1407
|
-
"Content-Type": "application/json"
|
|
1406
|
+
const u = {
|
|
1407
|
+
"Content-Type": "application/json",
|
|
1408
|
+
...o
|
|
1408
1409
|
};
|
|
1409
|
-
e && (
|
|
1410
|
-
const
|
|
1411
|
-
i &&
|
|
1412
|
-
const
|
|
1413
|
-
return
|
|
1410
|
+
e && (u["X-API-KEY"] = e);
|
|
1411
|
+
const f = new URLSearchParams();
|
|
1412
|
+
i && f.set("is_debug", "true");
|
|
1413
|
+
const h = new URL(t);
|
|
1414
|
+
return f.toString() && (h.search = f.toString()), Jt(h.toString(), {
|
|
1414
1415
|
method: "POST",
|
|
1415
|
-
headers:
|
|
1416
|
+
headers: u,
|
|
1416
1417
|
body: n ? JSON.stringify(n) : void 0,
|
|
1417
|
-
signal:
|
|
1418
|
+
signal: c.signal,
|
|
1418
1419
|
/**
|
|
1419
1420
|
* Allow SSE to work when the page is hidden.
|
|
1420
1421
|
* https://github.com/Azure/fetch-event-source/issues/17#issuecomment-1525904929
|
|
1421
1422
|
*/
|
|
1422
1423
|
openWhenHidden: !0,
|
|
1423
|
-
onopen: async (
|
|
1424
|
-
|
|
1424
|
+
onopen: async (v) => {
|
|
1425
|
+
v.ok ? a = v.headers.get("X-Trace-Id") ?? void 0 : (s.error(v), c.abort());
|
|
1425
1426
|
},
|
|
1426
|
-
onmessage: (
|
|
1427
|
-
const
|
|
1428
|
-
a ?
|
|
1427
|
+
onmessage: (v) => {
|
|
1428
|
+
const l = JSON.parse(v.data);
|
|
1429
|
+
a ? l.traceId = a : l.requestId && (l.traceId = l.requestId, a || (a = l.requestId)), s.next(l);
|
|
1429
1430
|
},
|
|
1430
1431
|
onclose: () => {
|
|
1431
|
-
|
|
1432
|
+
s.complete();
|
|
1432
1433
|
},
|
|
1433
|
-
onerror: (
|
|
1434
|
-
throw
|
|
1434
|
+
onerror: (v) => {
|
|
1435
|
+
throw s.error(v), c.abort(), v;
|
|
1435
1436
|
}
|
|
1436
1437
|
}), () => {
|
|
1437
|
-
|
|
1438
|
+
c.abort();
|
|
1438
1439
|
};
|
|
1439
1440
|
});
|
|
1440
1441
|
}
|
|
@@ -1468,9 +1469,10 @@ class sr {
|
|
|
1468
1469
|
b(this, "destroy$", new ee());
|
|
1469
1470
|
b(this, "sseEmitter", new Zt());
|
|
1470
1471
|
b(this, "transformSsePayload");
|
|
1472
|
+
b(this, "customHeaders");
|
|
1471
1473
|
if (!t.endpoint && !t.botProviderEndpoint)
|
|
1472
1474
|
throw new Error("Either endpoint or botProviderEndpoint must be provided");
|
|
1473
|
-
if (this.apiKey = t.apiKey, this.debugMode = t.debugMode, this.transformSsePayload = t.transformSsePayload, this.botProviderEndpoint = t.botProviderEndpoint, !t.endpoint && t.botProviderEndpoint) {
|
|
1475
|
+
if (this.apiKey = t.apiKey, this.debugMode = t.debugMode, this.transformSsePayload = t.transformSsePayload, this.botProviderEndpoint = t.botProviderEndpoint, this.customHeaders = t.customHeaders, !t.endpoint && t.botProviderEndpoint) {
|
|
1474
1476
|
const e = t.botProviderEndpoint.replace(/\/+$/, "");
|
|
1475
1477
|
this.endpoint = `${e}/message/sse`;
|
|
1476
1478
|
} else t.endpoint && (this.endpoint = t.endpoint, this.debugMode && console.warn(
|
|
@@ -1482,27 +1484,27 @@ class sr {
|
|
|
1482
1484
|
}
|
|
1483
1485
|
handleEvent(t) {
|
|
1484
1486
|
switch (t.eventType) {
|
|
1485
|
-
case
|
|
1486
|
-
this.sseEmitter.emit(
|
|
1487
|
+
case d.INIT:
|
|
1488
|
+
this.sseEmitter.emit(d.INIT, t);
|
|
1487
1489
|
break;
|
|
1488
|
-
case
|
|
1489
|
-
case
|
|
1490
|
-
this.sseEmitter.emit(
|
|
1490
|
+
case d.PROCESS_START:
|
|
1491
|
+
case d.PROCESS_COMPLETE:
|
|
1492
|
+
this.sseEmitter.emit(d.PROCESS, t);
|
|
1491
1493
|
break;
|
|
1492
|
-
case
|
|
1493
|
-
case
|
|
1494
|
-
case
|
|
1495
|
-
this.sseEmitter.emit(
|
|
1494
|
+
case d.MESSAGE_START:
|
|
1495
|
+
case d.MESSAGE_DELTA:
|
|
1496
|
+
case d.MESSAGE_COMPLETE:
|
|
1497
|
+
this.sseEmitter.emit(d.MESSAGE, t);
|
|
1496
1498
|
break;
|
|
1497
|
-
case
|
|
1498
|
-
case
|
|
1499
|
-
this.sseEmitter.emit(
|
|
1499
|
+
case d.TOOL_CALL_START:
|
|
1500
|
+
case d.TOOL_CALL_COMPLETE:
|
|
1501
|
+
this.sseEmitter.emit(d.TOOL_CALL, t);
|
|
1500
1502
|
break;
|
|
1501
|
-
case
|
|
1502
|
-
this.sseEmitter.emit(
|
|
1503
|
+
case d.DONE:
|
|
1504
|
+
this.sseEmitter.emit(d.DONE, t);
|
|
1503
1505
|
break;
|
|
1504
|
-
case
|
|
1505
|
-
this.sseEmitter.emit(
|
|
1506
|
+
case d.ERROR:
|
|
1507
|
+
this.sseEmitter.emit(d.ERROR, t);
|
|
1506
1508
|
break;
|
|
1507
1509
|
}
|
|
1508
1510
|
}
|
|
@@ -1512,11 +1514,12 @@ class sr {
|
|
|
1512
1514
|
apiKey: this.apiKey,
|
|
1513
1515
|
endpoint: this.endpoint,
|
|
1514
1516
|
debugMode: this.debugMode,
|
|
1515
|
-
payload: ((i = this.transformSsePayload) == null ? void 0 : i.call(this, t)) ?? t
|
|
1517
|
+
payload: ((i = this.transformSsePayload) == null ? void 0 : i.call(this, t)) ?? t,
|
|
1518
|
+
customHeaders: this.customHeaders
|
|
1516
1519
|
}).pipe(
|
|
1517
|
-
jt((o) => Et(o).pipe(
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
+
jt((o) => Et(o).pipe(Ht((e == null ? void 0 : e.delayTime) ?? 50))),
|
|
1521
|
+
Vt(this.destroy$),
|
|
1522
|
+
Ft(3)
|
|
1520
1523
|
).subscribe({
|
|
1521
1524
|
next: (o) => {
|
|
1522
1525
|
var s;
|
|
@@ -1545,7 +1548,9 @@ class sr {
|
|
|
1545
1548
|
throw new Error("Unable to derive blob endpoint. Please provide botProviderEndpoint in config.");
|
|
1546
1549
|
const i = new FormData();
|
|
1547
1550
|
i.append("file", t), i.append("customChannelId", e);
|
|
1548
|
-
const o = {
|
|
1551
|
+
const o = {
|
|
1552
|
+
...this.customHeaders
|
|
1553
|
+
};
|
|
1549
1554
|
this.apiKey && (o["X-API-KEY"] = this.apiKey);
|
|
1550
1555
|
try {
|
|
1551
1556
|
const s = await fetch(n, {
|
|
@@ -1555,8 +1560,8 @@ class sr {
|
|
|
1555
1560
|
});
|
|
1556
1561
|
if (!s.ok)
|
|
1557
1562
|
throw new Error(`Upload failed: ${s.status} ${s.statusText}`);
|
|
1558
|
-
const
|
|
1559
|
-
return this.debugMode && console.log("[AsgardServiceClient] File upload response:",
|
|
1563
|
+
const c = await s.json();
|
|
1564
|
+
return this.debugMode && console.log("[AsgardServiceClient] File upload response:", c), c;
|
|
1560
1565
|
} catch (s) {
|
|
1561
1566
|
throw console.error("[AsgardServiceClient] File upload error:", s), s;
|
|
1562
1567
|
}
|
|
@@ -1619,17 +1624,17 @@ class I {
|
|
|
1619
1624
|
}
|
|
1620
1625
|
onMessage(t) {
|
|
1621
1626
|
switch (t.eventType) {
|
|
1622
|
-
case
|
|
1627
|
+
case d.MESSAGE_START:
|
|
1623
1628
|
return this.onMessageStart(t);
|
|
1624
|
-
case
|
|
1629
|
+
case d.MESSAGE_DELTA:
|
|
1625
1630
|
return this.onMessageDelta(t);
|
|
1626
|
-
case
|
|
1631
|
+
case d.MESSAGE_COMPLETE:
|
|
1627
1632
|
return this.onMessageComplete(t);
|
|
1628
|
-
case
|
|
1633
|
+
case d.TOOL_CALL_START:
|
|
1629
1634
|
return this.onToolCallStart(t);
|
|
1630
|
-
case
|
|
1635
|
+
case d.TOOL_CALL_COMPLETE:
|
|
1631
1636
|
return this.onToolCallComplete(t);
|
|
1632
|
-
case
|
|
1637
|
+
case d.ERROR:
|
|
1633
1638
|
return this.onMessageError(t);
|
|
1634
1639
|
default:
|
|
1635
1640
|
return this;
|
|
@@ -1639,7 +1644,7 @@ class I {
|
|
|
1639
1644
|
const e = t.fact.messageStart.message, n = new Map(this.messages);
|
|
1640
1645
|
return n.set(e.messageId, {
|
|
1641
1646
|
type: "bot",
|
|
1642
|
-
eventType:
|
|
1647
|
+
eventType: d.MESSAGE_START,
|
|
1643
1648
|
isTyping: !0,
|
|
1644
1649
|
typingText: "",
|
|
1645
1650
|
messageId: e.messageId,
|
|
@@ -1655,7 +1660,7 @@ class I {
|
|
|
1655
1660
|
const o = `${(i == null ? void 0 : i.typingText) ?? ""}${e.text}`;
|
|
1656
1661
|
return n.set(e.messageId, {
|
|
1657
1662
|
type: "bot",
|
|
1658
|
-
eventType:
|
|
1663
|
+
eventType: d.MESSAGE_DELTA,
|
|
1659
1664
|
isTyping: !0,
|
|
1660
1665
|
typingText: o,
|
|
1661
1666
|
messageId: e.messageId,
|
|
@@ -1669,7 +1674,7 @@ class I {
|
|
|
1669
1674
|
const e = t.fact.messageComplete.message, n = new Map(this.messages), i = n.get(e.messageId);
|
|
1670
1675
|
return n.set(e.messageId, {
|
|
1671
1676
|
type: "bot",
|
|
1672
|
-
eventType:
|
|
1677
|
+
eventType: d.MESSAGE_COMPLETE,
|
|
1673
1678
|
isTyping: !1,
|
|
1674
1679
|
typingText: null,
|
|
1675
1680
|
messageId: e.messageId,
|
|
@@ -1683,7 +1688,7 @@ class I {
|
|
|
1683
1688
|
const e = ke(), n = t.fact.runError.error, i = new Map(this.messages);
|
|
1684
1689
|
return i.set(e, {
|
|
1685
1690
|
type: "error",
|
|
1686
|
-
eventType:
|
|
1691
|
+
eventType: d.ERROR,
|
|
1687
1692
|
messageId: e,
|
|
1688
1693
|
error: n,
|
|
1689
1694
|
time: /* @__PURE__ */ new Date(),
|
|
@@ -1693,7 +1698,7 @@ class I {
|
|
|
1693
1698
|
onToolCallStart(t) {
|
|
1694
1699
|
const e = t.fact.toolCallStart, n = new Map(this.messages), i = `${e.processId}-${e.callSeq}`, o = {
|
|
1695
1700
|
type: "tool-call",
|
|
1696
|
-
eventType:
|
|
1701
|
+
eventType: d.TOOL_CALL_START,
|
|
1697
1702
|
messageId: i,
|
|
1698
1703
|
processId: e.processId,
|
|
1699
1704
|
callSeq: e.callSeq,
|
|
@@ -1711,7 +1716,7 @@ class I {
|
|
|
1711
1716
|
if ((o == null ? void 0 : o.type) === "tool-call") {
|
|
1712
1717
|
const s = {
|
|
1713
1718
|
...o,
|
|
1714
|
-
eventType:
|
|
1719
|
+
eventType: d.TOOL_CALL_COMPLETE,
|
|
1715
1720
|
result: e.toolCallResult,
|
|
1716
1721
|
isComplete: !0,
|
|
1717
1722
|
traceId: t.traceId ?? o.traceId
|
|
@@ -1747,7 +1752,7 @@ class $e {
|
|
|
1747
1752
|
}
|
|
1748
1753
|
subscribe() {
|
|
1749
1754
|
this.statesSubscription = Ut([this.isConnecting$, this.conversation$]).pipe(
|
|
1750
|
-
|
|
1755
|
+
F(([t, e]) => ({
|
|
1751
1756
|
isConnecting: t,
|
|
1752
1757
|
conversation: e
|
|
1753
1758
|
}))
|
|
@@ -1760,11 +1765,11 @@ class $e {
|
|
|
1760
1765
|
onSseMessage: (o) => {
|
|
1761
1766
|
var s;
|
|
1762
1767
|
if ((s = e == null ? void 0 : e.onSseMessage) == null || s.call(e, o), this.currentUserMessageId && o.traceId) {
|
|
1763
|
-
const
|
|
1764
|
-
|
|
1765
|
-
...
|
|
1768
|
+
const c = new Map(this.conversation$.value.messages), a = c.get(this.currentUserMessageId);
|
|
1769
|
+
a && a.type === "user" && (c.set(this.currentUserMessageId, {
|
|
1770
|
+
...a,
|
|
1766
1771
|
traceId: o.traceId
|
|
1767
|
-
}), this.conversation$.next(new I({ messages:
|
|
1772
|
+
}), this.conversation$.next(new I({ messages: c }))), this.currentUserMessageId = void 0;
|
|
1768
1773
|
}
|
|
1769
1774
|
this.conversation$.next(this.conversation$.value.onMessage(o));
|
|
1770
1775
|
},
|
|
@@ -1824,8 +1829,8 @@ export {
|
|
|
1824
1829
|
sr as AsgardServiceClient,
|
|
1825
1830
|
$e as Channel,
|
|
1826
1831
|
I as Conversation,
|
|
1827
|
-
|
|
1832
|
+
d as EventType,
|
|
1828
1833
|
Y as FetchSseAction,
|
|
1829
|
-
|
|
1834
|
+
He as MessageTemplateType
|
|
1830
1835
|
};
|
|
1831
1836
|
//# sourceMappingURL=index.mjs.map
|