@asgard-js/core 0.0.23 → 0.0.26
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 +289 -25
- package/dist/constants/enum.d.ts +3 -0
- 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 +170 -158
- package/dist/index.mjs.map +1 -1
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/types/client.d.ts +27 -4
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/sse-response.d.ts +14 -0
- package/dist/types/sse-response.d.ts.map +1 -1
- package/package.json +13 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var De = Object.defineProperty;
|
|
2
2
|
var Ue = (n, t, e) => t in n ? De(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
3
|
var m = (n, t, e) => Ue(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
-
var K = /* @__PURE__ */ ((n) => (n.RESET_CHANNEL = "RESET_CHANNEL", n.NONE = "NONE", n))(K || {}),
|
|
4
|
+
var K = /* @__PURE__ */ ((n) => (n.RESET_CHANNEL = "RESET_CHANNEL", n.NONE = "NONE", n))(K || {}), h = /* @__PURE__ */ ((n) => (n.INIT = "asgard.run.init", n.PROCESS = "asgard.process", n.PROCESS_START = "asgard.process.start", n.PROCESS_COMPLETE = "asgard.process.complete", n.MESSAGE = "asgard.message", n.MESSAGE_START = "asgard.message.start", n.MESSAGE_DELTA = "asgard.message.delta", n.MESSAGE_COMPLETE = "asgard.message.complete", n.TOOL_CALL = "asgard.tool_call", n.TOOL_CALL_START = "asgard.tool_call.start", n.TOOL_CALL_COMPLETE = "asgard.tool_call.complete", n.DONE = "asgard.run.done", n.ERROR = "asgard.run.error", n))(h || {}), Ne = /* @__PURE__ */ ((n) => (n.TEXT = "TEXT", n.HINT = "HINT", n.BUTTON = "BUTTON", n.IMAGE = "IMAGE", n.VIDEO = "VIDEO", n.AUDIO = "AUDIO", n.LOCATION = "LOCATION", n.CAROUSEL = "CAROUSEL", n.CHART = "CHART", n))(Ne || {}), Y = function(n, t) {
|
|
5
5
|
return Y = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
|
|
6
6
|
e.__proto__ = r;
|
|
7
7
|
} || function(e, r) {
|
|
@@ -27,15 +27,15 @@ function $e(n, t, e, r) {
|
|
|
27
27
|
function c(f) {
|
|
28
28
|
try {
|
|
29
29
|
u(r.next(f));
|
|
30
|
-
} catch (
|
|
31
|
-
s(
|
|
30
|
+
} catch (y) {
|
|
31
|
+
s(y);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
function a(f) {
|
|
35
35
|
try {
|
|
36
36
|
u(r.throw(f));
|
|
37
|
-
} catch (
|
|
38
|
-
s(
|
|
37
|
+
} catch (y) {
|
|
38
|
+
s(y);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
function u(f) {
|
|
@@ -114,7 +114,7 @@ function M(n) {
|
|
|
114
114
|
};
|
|
115
115
|
throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function L(n, t) {
|
|
118
118
|
var e = typeof Symbol == "function" && n[Symbol.iterator];
|
|
119
119
|
if (!e) return n;
|
|
120
120
|
var r = e.call(n), i, o = [], s;
|
|
@@ -131,7 +131,7 @@ function R(n, t) {
|
|
|
131
131
|
}
|
|
132
132
|
return o;
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function R(n, t, e) {
|
|
135
135
|
if (e || arguments.length === 2) for (var r = 0, i = t.length, o; r < i; r++)
|
|
136
136
|
(o || !(r in t)) && (o || (o = Array.prototype.slice.call(t, 0, r)), o[r] = t[r]);
|
|
137
137
|
return n.concat(o || Array.prototype.slice.call(t));
|
|
@@ -146,35 +146,35 @@ function Ge(n, t, e) {
|
|
|
146
146
|
return this;
|
|
147
147
|
}, i;
|
|
148
148
|
function s(l) {
|
|
149
|
-
return function(
|
|
150
|
-
return Promise.resolve(
|
|
149
|
+
return function(v) {
|
|
150
|
+
return Promise.resolve(v).then(l, y);
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
|
-
function c(l,
|
|
153
|
+
function c(l, v) {
|
|
154
154
|
r[l] && (i[l] = function(d) {
|
|
155
|
-
return new Promise(function(
|
|
156
|
-
o.push([l, d,
|
|
155
|
+
return new Promise(function(g, w) {
|
|
156
|
+
o.push([l, d, g, w]) > 1 || a(l, d);
|
|
157
157
|
});
|
|
158
|
-
},
|
|
158
|
+
}, v && (i[l] = v(i[l])));
|
|
159
159
|
}
|
|
160
|
-
function a(l,
|
|
160
|
+
function a(l, v) {
|
|
161
161
|
try {
|
|
162
|
-
u(r[l](
|
|
162
|
+
u(r[l](v));
|
|
163
163
|
} catch (d) {
|
|
164
164
|
b(o[0][3], d);
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
function u(l) {
|
|
168
|
-
l.value instanceof P ? Promise.resolve(l.value.v).then(f,
|
|
168
|
+
l.value instanceof P ? Promise.resolve(l.value.v).then(f, y) : b(o[0][2], l);
|
|
169
169
|
}
|
|
170
170
|
function f(l) {
|
|
171
171
|
a("next", l);
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function y(l) {
|
|
174
174
|
a("throw", l);
|
|
175
175
|
}
|
|
176
|
-
function b(l,
|
|
177
|
-
l(
|
|
176
|
+
function b(l, v) {
|
|
177
|
+
l(v), o.shift(), o.length && a(o[0][0], o[0][1]);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
function Fe(n) {
|
|
@@ -220,7 +220,7 @@ function N(n, t) {
|
|
|
220
220
|
0 <= e && n.splice(e, 1);
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
var
|
|
223
|
+
var k = function() {
|
|
224
224
|
function n(t) {
|
|
225
225
|
this.initialTeardown = t, this.closed = !1, this._parentage = null, this._finalizers = null;
|
|
226
226
|
}
|
|
@@ -254,16 +254,16 @@ var j = function() {
|
|
|
254
254
|
} catch (d) {
|
|
255
255
|
o = d instanceof B ? d.errors : [d];
|
|
256
256
|
}
|
|
257
|
-
var
|
|
258
|
-
if (
|
|
257
|
+
var y = this._finalizers;
|
|
258
|
+
if (y) {
|
|
259
259
|
this._finalizers = null;
|
|
260
260
|
try {
|
|
261
|
-
for (var b = M(
|
|
262
|
-
var
|
|
261
|
+
for (var b = M(y), l = b.next(); !l.done; l = b.next()) {
|
|
262
|
+
var v = l.value;
|
|
263
263
|
try {
|
|
264
|
-
ee(
|
|
264
|
+
ee(v);
|
|
265
265
|
} catch (d) {
|
|
266
|
-
o = o ?? [], d instanceof B ? o =
|
|
266
|
+
o = o ?? [], d instanceof B ? o = R(R([], L(o)), L(d.errors)) : o.push(d);
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
269
|
} catch (d) {
|
|
@@ -308,9 +308,9 @@ var j = function() {
|
|
|
308
308
|
var t = new n();
|
|
309
309
|
return t.closed = !0, t;
|
|
310
310
|
}(), n;
|
|
311
|
-
}(), le =
|
|
311
|
+
}(), le = k.EMPTY;
|
|
312
312
|
function de(n) {
|
|
313
|
-
return n instanceof
|
|
313
|
+
return n instanceof k || n && "closed" in n && p(n.remove) && p(n.add) && p(n.unsubscribe);
|
|
314
314
|
}
|
|
315
315
|
function ee(n) {
|
|
316
316
|
p(n) ? n() : n.unsubscribe();
|
|
@@ -325,7 +325,7 @@ var He = {
|
|
|
325
325
|
setTimeout: function(n, t) {
|
|
326
326
|
for (var e = [], r = 2; r < arguments.length; r++)
|
|
327
327
|
e[r - 2] = arguments[r];
|
|
328
|
-
return setTimeout.apply(void 0,
|
|
328
|
+
return setTimeout.apply(void 0, R([n, t], L(e)));
|
|
329
329
|
},
|
|
330
330
|
clearTimeout: function(n) {
|
|
331
331
|
var t = he.delegate;
|
|
@@ -374,7 +374,7 @@ var X = function(n) {
|
|
|
374
374
|
this.unsubscribe();
|
|
375
375
|
}
|
|
376
376
|
}, t;
|
|
377
|
-
}(
|
|
377
|
+
}(k), Ve = function() {
|
|
378
378
|
function n(t) {
|
|
379
379
|
this.partialObserver = t;
|
|
380
380
|
}
|
|
@@ -441,7 +441,7 @@ function Ye(n) {
|
|
|
441
441
|
}, e);
|
|
442
442
|
};
|
|
443
443
|
}
|
|
444
|
-
var
|
|
444
|
+
var S = function() {
|
|
445
445
|
function n(t) {
|
|
446
446
|
t && (this._subscribe = t);
|
|
447
447
|
}
|
|
@@ -514,7 +514,7 @@ function We(n) {
|
|
|
514
514
|
function Je(n) {
|
|
515
515
|
return p(n == null ? void 0 : n.lift);
|
|
516
516
|
}
|
|
517
|
-
function
|
|
517
|
+
function T(n) {
|
|
518
518
|
return function(t) {
|
|
519
519
|
if (Je(t))
|
|
520
520
|
return t.lift(function(e) {
|
|
@@ -636,19 +636,19 @@ var Xe = function(n) {
|
|
|
636
636
|
return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
|
|
637
637
|
}, t.prototype._innerSubscribe = function(e) {
|
|
638
638
|
var r = this, i = this, o = i.hasError, s = i.isStopped, c = i.observers;
|
|
639
|
-
return o || s ? le : (this.currentObservers = null, c.push(e), new
|
|
639
|
+
return o || s ? le : (this.currentObservers = null, c.push(e), new k(function() {
|
|
640
640
|
r.currentObservers = null, N(c, e);
|
|
641
641
|
}));
|
|
642
642
|
}, t.prototype._checkFinalizedStatuses = function(e) {
|
|
643
643
|
var r = this, i = r.hasError, o = r.thrownError, s = r.isStopped;
|
|
644
644
|
i ? e.error(o) : s && e.complete();
|
|
645
645
|
}, t.prototype.asObservable = function() {
|
|
646
|
-
var e = new
|
|
646
|
+
var e = new S();
|
|
647
647
|
return e.source = this, e;
|
|
648
648
|
}, t.create = function(e, r) {
|
|
649
649
|
return new ne(e, r);
|
|
650
650
|
}, t;
|
|
651
|
-
}(
|
|
651
|
+
}(S), ne = function(n) {
|
|
652
652
|
O(t, n);
|
|
653
653
|
function t(e, r) {
|
|
654
654
|
var i = n.call(this) || this;
|
|
@@ -703,11 +703,11 @@ var Xe = function(n) {
|
|
|
703
703
|
return t.prototype.schedule = function(e, r) {
|
|
704
704
|
return this;
|
|
705
705
|
}, t;
|
|
706
|
-
}(
|
|
706
|
+
}(k), ie = {
|
|
707
707
|
setInterval: function(n, t) {
|
|
708
708
|
for (var e = [], r = 2; r < arguments.length; r++)
|
|
709
709
|
e[r - 2] = arguments[r];
|
|
710
|
-
return setInterval.apply(void 0,
|
|
710
|
+
return setInterval.apply(void 0, R([n, t], L(e)));
|
|
711
711
|
},
|
|
712
712
|
clearInterval: function(n) {
|
|
713
713
|
return clearInterval(n);
|
|
@@ -787,7 +787,7 @@ var Xe = function(n) {
|
|
|
787
787
|
throw i;
|
|
788
788
|
}
|
|
789
789
|
}, t;
|
|
790
|
-
}(oe), ve = new tt(et), nt = ve, rt = new
|
|
790
|
+
}(oe), ve = new tt(et), nt = ve, rt = new S(function(n) {
|
|
791
791
|
return n.complete();
|
|
792
792
|
});
|
|
793
793
|
function pe(n) {
|
|
@@ -802,10 +802,10 @@ function it(n) {
|
|
|
802
802
|
function me(n) {
|
|
803
803
|
return pe(be(n)) ? n.pop() : void 0;
|
|
804
804
|
}
|
|
805
|
-
var
|
|
805
|
+
var Se = function(n) {
|
|
806
806
|
return n && typeof n.length == "number" && typeof n != "function";
|
|
807
807
|
};
|
|
808
|
-
function
|
|
808
|
+
function ge(n) {
|
|
809
809
|
return p(n == null ? void 0 : n.then);
|
|
810
810
|
}
|
|
811
811
|
function we(n) {
|
|
@@ -859,17 +859,17 @@ function _e(n) {
|
|
|
859
859
|
return p(n == null ? void 0 : n.getReader);
|
|
860
860
|
}
|
|
861
861
|
function x(n) {
|
|
862
|
-
if (n instanceof
|
|
862
|
+
if (n instanceof S)
|
|
863
863
|
return n;
|
|
864
864
|
if (n != null) {
|
|
865
865
|
if (we(n))
|
|
866
866
|
return st(n);
|
|
867
|
-
if (ge(n))
|
|
868
|
-
return ut(n);
|
|
869
867
|
if (Se(n))
|
|
868
|
+
return ut(n);
|
|
869
|
+
if (ge(n))
|
|
870
870
|
return at(n);
|
|
871
871
|
if (Ee(n))
|
|
872
|
-
return
|
|
872
|
+
return Te(n);
|
|
873
873
|
if (Ae(n))
|
|
874
874
|
return ct(n);
|
|
875
875
|
if (_e(n))
|
|
@@ -878,7 +878,7 @@ function x(n) {
|
|
|
878
878
|
throw Oe(n);
|
|
879
879
|
}
|
|
880
880
|
function st(n) {
|
|
881
|
-
return new
|
|
881
|
+
return new S(function(t) {
|
|
882
882
|
var e = n[z]();
|
|
883
883
|
if (p(e.subscribe))
|
|
884
884
|
return e.subscribe(t);
|
|
@@ -886,14 +886,14 @@ function st(n) {
|
|
|
886
886
|
});
|
|
887
887
|
}
|
|
888
888
|
function ut(n) {
|
|
889
|
-
return new
|
|
889
|
+
return new S(function(t) {
|
|
890
890
|
for (var e = 0; e < n.length && !t.closed; e++)
|
|
891
891
|
t.next(n[e]);
|
|
892
892
|
t.complete();
|
|
893
893
|
});
|
|
894
894
|
}
|
|
895
895
|
function at(n) {
|
|
896
|
-
return new
|
|
896
|
+
return new S(function(t) {
|
|
897
897
|
n.then(function(e) {
|
|
898
898
|
t.closed || (t.next(e), t.complete());
|
|
899
899
|
}, function(e) {
|
|
@@ -902,7 +902,7 @@ function at(n) {
|
|
|
902
902
|
});
|
|
903
903
|
}
|
|
904
904
|
function ct(n) {
|
|
905
|
-
return new
|
|
905
|
+
return new S(function(t) {
|
|
906
906
|
var e, r;
|
|
907
907
|
try {
|
|
908
908
|
for (var i = M(n), o = i.next(); !o.done; o = i.next()) {
|
|
@@ -922,15 +922,15 @@ function ct(n) {
|
|
|
922
922
|
t.complete();
|
|
923
923
|
});
|
|
924
924
|
}
|
|
925
|
-
function
|
|
926
|
-
return new
|
|
925
|
+
function Te(n) {
|
|
926
|
+
return new S(function(t) {
|
|
927
927
|
lt(n, t).catch(function(e) {
|
|
928
928
|
return t.error(e);
|
|
929
929
|
});
|
|
930
930
|
});
|
|
931
931
|
}
|
|
932
932
|
function ft(n) {
|
|
933
|
-
return
|
|
933
|
+
return Te(xe(n));
|
|
934
934
|
}
|
|
935
935
|
function lt(n, t) {
|
|
936
936
|
var e, r, i, o;
|
|
@@ -978,8 +978,8 @@ function A(n, t, e, r, i) {
|
|
|
978
978
|
if (n.add(o), !i)
|
|
979
979
|
return o;
|
|
980
980
|
}
|
|
981
|
-
function
|
|
982
|
-
return t === void 0 && (t = 0),
|
|
981
|
+
function Ce(n, t) {
|
|
982
|
+
return t === void 0 && (t = 0), T(function(e, r) {
|
|
983
983
|
e.subscribe(E(r, function(i) {
|
|
984
984
|
return A(r, n, function() {
|
|
985
985
|
return r.next(i);
|
|
@@ -996,20 +996,20 @@ function Te(n, t) {
|
|
|
996
996
|
});
|
|
997
997
|
}
|
|
998
998
|
function Pe(n, t) {
|
|
999
|
-
return t === void 0 && (t = 0),
|
|
999
|
+
return t === void 0 && (t = 0), T(function(e, r) {
|
|
1000
1000
|
r.add(n.schedule(function() {
|
|
1001
1001
|
return e.subscribe(r);
|
|
1002
1002
|
}, t));
|
|
1003
1003
|
});
|
|
1004
1004
|
}
|
|
1005
1005
|
function dt(n, t) {
|
|
1006
|
-
return x(n).pipe(Pe(t),
|
|
1006
|
+
return x(n).pipe(Pe(t), Ce(t));
|
|
1007
1007
|
}
|
|
1008
1008
|
function ht(n, t) {
|
|
1009
|
-
return x(n).pipe(Pe(t),
|
|
1009
|
+
return x(n).pipe(Pe(t), Ce(t));
|
|
1010
1010
|
}
|
|
1011
1011
|
function yt(n, t) {
|
|
1012
|
-
return new
|
|
1012
|
+
return new S(function(e) {
|
|
1013
1013
|
var r = 0;
|
|
1014
1014
|
return t.schedule(function() {
|
|
1015
1015
|
r === n.length ? e.complete() : (e.next(n[r++]), e.closed || this.schedule());
|
|
@@ -1017,7 +1017,7 @@ function yt(n, t) {
|
|
|
1017
1017
|
});
|
|
1018
1018
|
}
|
|
1019
1019
|
function vt(n, t) {
|
|
1020
|
-
return new
|
|
1020
|
+
return new S(function(e) {
|
|
1021
1021
|
var r;
|
|
1022
1022
|
return A(e, t, function() {
|
|
1023
1023
|
r = n[Ie](), A(e, t, function() {
|
|
@@ -1038,7 +1038,7 @@ function vt(n, t) {
|
|
|
1038
1038
|
function Me(n, t) {
|
|
1039
1039
|
if (!n)
|
|
1040
1040
|
throw new Error("Iterable cannot be null");
|
|
1041
|
-
return new
|
|
1041
|
+
return new S(function(e) {
|
|
1042
1042
|
A(e, t, function() {
|
|
1043
1043
|
var r = n[Symbol.asyncIterator]();
|
|
1044
1044
|
A(e, t, function() {
|
|
@@ -1056,9 +1056,9 @@ function bt(n, t) {
|
|
|
1056
1056
|
if (n != null) {
|
|
1057
1057
|
if (we(n))
|
|
1058
1058
|
return dt(n, t);
|
|
1059
|
-
if (ge(n))
|
|
1060
|
-
return yt(n, t);
|
|
1061
1059
|
if (Se(n))
|
|
1060
|
+
return yt(n, t);
|
|
1061
|
+
if (ge(n))
|
|
1062
1062
|
return ht(n, t);
|
|
1063
1063
|
if (Ee(n))
|
|
1064
1064
|
return Me(n, t);
|
|
@@ -1078,20 +1078,20 @@ function mt() {
|
|
|
1078
1078
|
var e = me(n);
|
|
1079
1079
|
return Z(n, e);
|
|
1080
1080
|
}
|
|
1081
|
-
function
|
|
1081
|
+
function St(n) {
|
|
1082
1082
|
return n instanceof Date && !isNaN(n);
|
|
1083
1083
|
}
|
|
1084
1084
|
function F(n, t) {
|
|
1085
|
-
return
|
|
1085
|
+
return T(function(e, r) {
|
|
1086
1086
|
var i = 0;
|
|
1087
1087
|
e.subscribe(E(r, function(o) {
|
|
1088
1088
|
r.next(n.call(t, o, i++));
|
|
1089
1089
|
}));
|
|
1090
1090
|
});
|
|
1091
1091
|
}
|
|
1092
|
-
var
|
|
1092
|
+
var gt = Array.isArray;
|
|
1093
1093
|
function wt(n, t) {
|
|
1094
|
-
return
|
|
1094
|
+
return gt(t) ? n.apply(void 0, R([], L(t))) : n(t);
|
|
1095
1095
|
}
|
|
1096
1096
|
function Et(n) {
|
|
1097
1097
|
return F(function(t) {
|
|
@@ -1104,7 +1104,7 @@ function _t(n) {
|
|
|
1104
1104
|
var t = n[0];
|
|
1105
1105
|
if (Ot(t))
|
|
1106
1106
|
return { args: t, keys: null };
|
|
1107
|
-
if (
|
|
1107
|
+
if (Tt(t)) {
|
|
1108
1108
|
var e = xt(t);
|
|
1109
1109
|
return {
|
|
1110
1110
|
args: e.map(function(r) {
|
|
@@ -1116,10 +1116,10 @@ function _t(n) {
|
|
|
1116
1116
|
}
|
|
1117
1117
|
return { args: n, keys: null };
|
|
1118
1118
|
}
|
|
1119
|
-
function
|
|
1119
|
+
function Tt(n) {
|
|
1120
1120
|
return n && typeof n == "object" && It(n) === At;
|
|
1121
1121
|
}
|
|
1122
|
-
function
|
|
1122
|
+
function Ct(n, t) {
|
|
1123
1123
|
return n.reduce(function(e, r, i) {
|
|
1124
1124
|
return e[r] = t[i], e;
|
|
1125
1125
|
}, {});
|
|
@@ -1130,8 +1130,8 @@ function Pt() {
|
|
|
1130
1130
|
var e = me(n), r = it(n), i = _t(n), o = i.args, s = i.keys;
|
|
1131
1131
|
if (o.length === 0)
|
|
1132
1132
|
return Z([], e);
|
|
1133
|
-
var c = new
|
|
1134
|
-
return
|
|
1133
|
+
var c = new S(Mt(o, e, s ? function(a) {
|
|
1134
|
+
return Ct(s, a);
|
|
1135
1135
|
} : G));
|
|
1136
1136
|
return r ? c.pipe(Et(r)) : c;
|
|
1137
1137
|
}
|
|
@@ -1140,8 +1140,8 @@ function Mt(n, t, e) {
|
|
|
1140
1140
|
se(t, function() {
|
|
1141
1141
|
for (var i = n.length, o = new Array(i), s = i, c = i, a = function(f) {
|
|
1142
1142
|
se(t, function() {
|
|
1143
|
-
var
|
|
1144
|
-
|
|
1143
|
+
var y = Z(n[f], t), b = !1;
|
|
1144
|
+
y.subscribe(E(r, function(l) {
|
|
1145
1145
|
o[f] = l, b || (b = !0, c--), c || r.next(e(o.slice()));
|
|
1146
1146
|
}, function() {
|
|
1147
1147
|
--s || r.complete();
|
|
@@ -1155,25 +1155,25 @@ function Mt(n, t, e) {
|
|
|
1155
1155
|
function se(n, t, e) {
|
|
1156
1156
|
n ? A(e, n, t) : t();
|
|
1157
1157
|
}
|
|
1158
|
-
function
|
|
1159
|
-
var a = [], u = 0, f = 0,
|
|
1160
|
-
|
|
1158
|
+
function Lt(n, t, e, r, i, o, s, c) {
|
|
1159
|
+
var a = [], u = 0, f = 0, y = !1, b = function() {
|
|
1160
|
+
y && !a.length && !u && t.complete();
|
|
1161
1161
|
}, l = function(d) {
|
|
1162
|
-
return u < r ?
|
|
1163
|
-
},
|
|
1162
|
+
return u < r ? v(d) : a.push(d);
|
|
1163
|
+
}, v = function(d) {
|
|
1164
1164
|
u++;
|
|
1165
|
-
var
|
|
1165
|
+
var g = !1;
|
|
1166
1166
|
x(e(d, f++)).subscribe(E(t, function(w) {
|
|
1167
1167
|
t.next(w);
|
|
1168
1168
|
}, function() {
|
|
1169
|
-
|
|
1169
|
+
g = !0;
|
|
1170
1170
|
}, void 0, function() {
|
|
1171
|
-
if (
|
|
1171
|
+
if (g)
|
|
1172
1172
|
try {
|
|
1173
1173
|
u--;
|
|
1174
1174
|
for (var w = function() {
|
|
1175
1175
|
var _ = a.shift();
|
|
1176
|
-
s ||
|
|
1176
|
+
s || v(_);
|
|
1177
1177
|
}; a.length && u < r; )
|
|
1178
1178
|
w();
|
|
1179
1179
|
b();
|
|
@@ -1183,7 +1183,7 @@ function Rt(n, t, e, r, i, o, s, c) {
|
|
|
1183
1183
|
}));
|
|
1184
1184
|
};
|
|
1185
1185
|
return n.subscribe(E(t, l, function() {
|
|
1186
|
-
|
|
1186
|
+
y = !0, b();
|
|
1187
1187
|
})), function() {
|
|
1188
1188
|
};
|
|
1189
1189
|
}
|
|
@@ -1192,15 +1192,15 @@ function $(n, t, e) {
|
|
|
1192
1192
|
return F(function(o, s) {
|
|
1193
1193
|
return t(r, o, i, s);
|
|
1194
1194
|
})(x(n(r, i)));
|
|
1195
|
-
}, e) : (typeof t == "number" && (e = t),
|
|
1196
|
-
return
|
|
1195
|
+
}, e) : (typeof t == "number" && (e = t), T(function(r, i) {
|
|
1196
|
+
return Lt(r, i, n, e);
|
|
1197
1197
|
}));
|
|
1198
1198
|
}
|
|
1199
|
-
function
|
|
1199
|
+
function Le(n, t, e) {
|
|
1200
1200
|
n === void 0 && (n = 0), e === void 0 && (e = nt);
|
|
1201
1201
|
var r = -1;
|
|
1202
|
-
return t != null && (pe(t) ? e = t : r = t), new
|
|
1203
|
-
var o =
|
|
1202
|
+
return t != null && (pe(t) ? e = t : r = t), new S(function(i) {
|
|
1203
|
+
var o = St(n) ? +n - e.now() : n;
|
|
1204
1204
|
o < 0 && (o = 0);
|
|
1205
1205
|
var s = 0;
|
|
1206
1206
|
return e.schedule(function() {
|
|
@@ -1208,32 +1208,32 @@ function Re(n, t, e) {
|
|
|
1208
1208
|
}, o);
|
|
1209
1209
|
});
|
|
1210
1210
|
}
|
|
1211
|
-
function
|
|
1211
|
+
function Rt(n, t) {
|
|
1212
1212
|
return p(t) ? $(n, t, 1) : $(n, 1);
|
|
1213
1213
|
}
|
|
1214
|
-
function
|
|
1214
|
+
function kt(n) {
|
|
1215
1215
|
return n <= 0 ? function() {
|
|
1216
1216
|
return rt;
|
|
1217
|
-
} :
|
|
1217
|
+
} : T(function(t, e) {
|
|
1218
1218
|
var r = 0;
|
|
1219
1219
|
t.subscribe(E(e, function(i) {
|
|
1220
1220
|
++r <= n && (e.next(i), n <= r && e.complete());
|
|
1221
1221
|
}));
|
|
1222
1222
|
});
|
|
1223
1223
|
}
|
|
1224
|
-
function
|
|
1224
|
+
function jt(n) {
|
|
1225
1225
|
return F(function() {
|
|
1226
1226
|
return n;
|
|
1227
1227
|
});
|
|
1228
1228
|
}
|
|
1229
1229
|
function Dt(n, t) {
|
|
1230
1230
|
return $(function(e, r) {
|
|
1231
|
-
return x(n(e, r)).pipe(
|
|
1231
|
+
return x(n(e, r)).pipe(kt(1), jt(e));
|
|
1232
1232
|
});
|
|
1233
1233
|
}
|
|
1234
1234
|
function Ut(n, t) {
|
|
1235
1235
|
t === void 0 && (t = ve);
|
|
1236
|
-
var e =
|
|
1236
|
+
var e = Le(n, t);
|
|
1237
1237
|
return Dt(function() {
|
|
1238
1238
|
return e;
|
|
1239
1239
|
});
|
|
@@ -1244,34 +1244,34 @@ function Nt(n) {
|
|
|
1244
1244
|
count: n
|
|
1245
1245
|
};
|
|
1246
1246
|
var e = t.count, r = e === void 0 ? 1 / 0 : e, i = t.delay, o = t.resetOnSuccess, s = o === void 0 ? !1 : o;
|
|
1247
|
-
return r <= 0 ? G :
|
|
1248
|
-
var u = 0, f,
|
|
1247
|
+
return r <= 0 ? G : T(function(c, a) {
|
|
1248
|
+
var u = 0, f, y = function() {
|
|
1249
1249
|
var b = !1;
|
|
1250
1250
|
f = c.subscribe(E(a, function(l) {
|
|
1251
1251
|
s && (u = 0), a.next(l);
|
|
1252
1252
|
}, void 0, function(l) {
|
|
1253
1253
|
if (u++ < r) {
|
|
1254
|
-
var
|
|
1255
|
-
f ? (f.unsubscribe(), f = null,
|
|
1254
|
+
var v = function() {
|
|
1255
|
+
f ? (f.unsubscribe(), f = null, y()) : b = !0;
|
|
1256
1256
|
};
|
|
1257
1257
|
if (i != null) {
|
|
1258
|
-
var d = typeof i == "number" ?
|
|
1259
|
-
|
|
1258
|
+
var d = typeof i == "number" ? Le(i) : x(i(l, u)), g = E(a, function() {
|
|
1259
|
+
g.unsubscribe(), v();
|
|
1260
1260
|
}, function() {
|
|
1261
1261
|
a.complete();
|
|
1262
1262
|
});
|
|
1263
|
-
d.subscribe(
|
|
1263
|
+
d.subscribe(g);
|
|
1264
1264
|
} else
|
|
1265
|
-
|
|
1265
|
+
v();
|
|
1266
1266
|
} else
|
|
1267
1267
|
a.error(l);
|
|
1268
|
-
})), b && (f.unsubscribe(), f = null,
|
|
1268
|
+
})), b && (f.unsubscribe(), f = null, y());
|
|
1269
1269
|
};
|
|
1270
|
-
|
|
1270
|
+
y();
|
|
1271
1271
|
});
|
|
1272
1272
|
}
|
|
1273
1273
|
function $t(n) {
|
|
1274
|
-
return
|
|
1274
|
+
return T(function(t, e) {
|
|
1275
1275
|
x(n).subscribe(E(e, function() {
|
|
1276
1276
|
return e.complete();
|
|
1277
1277
|
}, q)), !e.closed && t.subscribe(e);
|
|
@@ -1330,8 +1330,8 @@ function Ht(n, t, e) {
|
|
|
1330
1330
|
n(r.id = f);
|
|
1331
1331
|
break;
|
|
1332
1332
|
case "retry":
|
|
1333
|
-
const
|
|
1334
|
-
isNaN(
|
|
1333
|
+
const y = parseInt(f, 10);
|
|
1334
|
+
isNaN(y) || t(r.retry = y);
|
|
1335
1335
|
break;
|
|
1336
1336
|
}
|
|
1337
1337
|
}
|
|
@@ -1360,36 +1360,36 @@ var Bt = function(n, t) {
|
|
|
1360
1360
|
const J = "text/event-stream", Kt = 1e3, ae = "last-event-id";
|
|
1361
1361
|
function Yt(n, t) {
|
|
1362
1362
|
var { signal: e, headers: r, onopen: i, onmessage: o, onclose: s, onerror: c, openWhenHidden: a, fetch: u } = t, f = Bt(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
1363
|
-
return new Promise((
|
|
1363
|
+
return new Promise((y, b) => {
|
|
1364
1364
|
const l = Object.assign({}, r);
|
|
1365
1365
|
l.accept || (l.accept = J);
|
|
1366
|
-
let
|
|
1366
|
+
let v;
|
|
1367
1367
|
function d() {
|
|
1368
|
-
|
|
1368
|
+
v.abort(), document.hidden || H();
|
|
1369
1369
|
}
|
|
1370
1370
|
a || document.addEventListener("visibilitychange", d);
|
|
1371
|
-
let
|
|
1371
|
+
let g = Kt, w = 0;
|
|
1372
1372
|
function _() {
|
|
1373
|
-
document.removeEventListener("visibilitychange", d), window.clearTimeout(w),
|
|
1373
|
+
document.removeEventListener("visibilitychange", d), window.clearTimeout(w), v.abort();
|
|
1374
1374
|
}
|
|
1375
1375
|
e == null || e.addEventListener("abort", () => {
|
|
1376
|
-
_(),
|
|
1376
|
+
_(), y();
|
|
1377
1377
|
});
|
|
1378
|
-
const
|
|
1378
|
+
const ke = u ?? window.fetch, je = i ?? qt;
|
|
1379
1379
|
async function H() {
|
|
1380
1380
|
var V;
|
|
1381
|
-
|
|
1381
|
+
v = new AbortController();
|
|
1382
1382
|
try {
|
|
1383
|
-
const
|
|
1384
|
-
await
|
|
1383
|
+
const j = await ke(n, Object.assign(Object.assign({}, f), { headers: l, signal: v.signal }));
|
|
1384
|
+
await je(j), await Gt(j.body, Ft(Ht((I) => {
|
|
1385
1385
|
I ? l[ae] = I : delete l[ae];
|
|
1386
1386
|
}, (I) => {
|
|
1387
|
-
|
|
1388
|
-
}, o))), s == null || s(), _(),
|
|
1389
|
-
} catch (
|
|
1390
|
-
if (!
|
|
1387
|
+
g = I;
|
|
1388
|
+
}, o))), s == null || s(), _(), y();
|
|
1389
|
+
} catch (j) {
|
|
1390
|
+
if (!v.signal.aborted)
|
|
1391
1391
|
try {
|
|
1392
|
-
const I = (V = c == null ? void 0 : c(
|
|
1392
|
+
const I = (V = c == null ? void 0 : c(j)) !== null && V !== void 0 ? V : g;
|
|
1393
1393
|
window.clearTimeout(w), w = window.setTimeout(H, I);
|
|
1394
1394
|
} catch (I) {
|
|
1395
1395
|
_(), b(I);
|
|
@@ -1406,7 +1406,7 @@ function qt(n) {
|
|
|
1406
1406
|
}
|
|
1407
1407
|
function Wt(n) {
|
|
1408
1408
|
const { endpoint: t, apiKey: e, payload: r, debugMode: i } = n;
|
|
1409
|
-
return new
|
|
1409
|
+
return new S((o) => {
|
|
1410
1410
|
const s = new AbortController(), c = {
|
|
1411
1411
|
"Content-Type": "application/json"
|
|
1412
1412
|
};
|
|
@@ -1470,45 +1470,57 @@ class zt {
|
|
|
1470
1470
|
m(this, "destroy$", new Q());
|
|
1471
1471
|
m(this, "sseEmitter", new Jt());
|
|
1472
1472
|
m(this, "transformSsePayload");
|
|
1473
|
-
if (!t.endpoint)
|
|
1474
|
-
throw new Error("endpoint must be
|
|
1475
|
-
this.apiKey = t.apiKey, this.
|
|
1473
|
+
if (!t.endpoint && !t.botProviderEndpoint)
|
|
1474
|
+
throw new Error("Either endpoint or botProviderEndpoint must be provided");
|
|
1475
|
+
if (this.apiKey = t.apiKey, this.debugMode = t.debugMode, this.transformSsePayload = t.transformSsePayload, !t.endpoint && t.botProviderEndpoint) {
|
|
1476
|
+
const e = t.botProviderEndpoint.replace(/\/+$/, "");
|
|
1477
|
+
this.endpoint = `${e}/message/sse`;
|
|
1478
|
+
} else t.endpoint && (this.endpoint = t.endpoint, this.debugMode && console.warn(
|
|
1479
|
+
'[AsgardServiceClient] The "endpoint" option is deprecated and will be removed in the next major version. Please use "botProviderEndpoint" instead. The SSE endpoint will be automatically derived as "${botProviderEndpoint}/message/sse".'
|
|
1480
|
+
));
|
|
1476
1481
|
}
|
|
1477
1482
|
on(t, e) {
|
|
1478
1483
|
this.sseEmitter.remove(t), this.sseEmitter.on(t, e);
|
|
1479
1484
|
}
|
|
1480
1485
|
handleEvent(t) {
|
|
1481
1486
|
switch (t.eventType) {
|
|
1482
|
-
case
|
|
1487
|
+
case h.INIT:
|
|
1488
|
+
this.sseEmitter.emit(
|
|
1489
|
+
h.INIT,
|
|
1490
|
+
t
|
|
1491
|
+
);
|
|
1492
|
+
break;
|
|
1493
|
+
case h.PROCESS_START:
|
|
1494
|
+
case h.PROCESS_COMPLETE:
|
|
1483
1495
|
this.sseEmitter.emit(
|
|
1484
|
-
|
|
1496
|
+
h.PROCESS,
|
|
1485
1497
|
t
|
|
1486
1498
|
);
|
|
1487
1499
|
break;
|
|
1488
|
-
case
|
|
1489
|
-
case
|
|
1500
|
+
case h.MESSAGE_START:
|
|
1501
|
+
case h.MESSAGE_DELTA:
|
|
1502
|
+
case h.MESSAGE_COMPLETE:
|
|
1490
1503
|
this.sseEmitter.emit(
|
|
1491
|
-
|
|
1504
|
+
h.MESSAGE,
|
|
1492
1505
|
t
|
|
1493
1506
|
);
|
|
1494
1507
|
break;
|
|
1495
|
-
case
|
|
1496
|
-
case
|
|
1497
|
-
case v.MESSAGE_COMPLETE:
|
|
1508
|
+
case h.TOOL_CALL_START:
|
|
1509
|
+
case h.TOOL_CALL_COMPLETE:
|
|
1498
1510
|
this.sseEmitter.emit(
|
|
1499
|
-
|
|
1511
|
+
h.TOOL_CALL,
|
|
1500
1512
|
t
|
|
1501
1513
|
);
|
|
1502
1514
|
break;
|
|
1503
|
-
case
|
|
1515
|
+
case h.DONE:
|
|
1504
1516
|
this.sseEmitter.emit(
|
|
1505
|
-
|
|
1517
|
+
h.DONE,
|
|
1506
1518
|
t
|
|
1507
1519
|
);
|
|
1508
1520
|
break;
|
|
1509
|
-
case
|
|
1521
|
+
case h.ERROR:
|
|
1510
1522
|
this.sseEmitter.emit(
|
|
1511
|
-
|
|
1523
|
+
h.ERROR,
|
|
1512
1524
|
t
|
|
1513
1525
|
);
|
|
1514
1526
|
break;
|
|
@@ -1522,7 +1534,7 @@ class zt {
|
|
|
1522
1534
|
debugMode: this.debugMode,
|
|
1523
1535
|
payload: ((i = this.transformSsePayload) == null ? void 0 : i.call(this, t)) ?? t
|
|
1524
1536
|
}).pipe(
|
|
1525
|
-
|
|
1537
|
+
Rt((o) => mt(o).pipe(Ut((e == null ? void 0 : e.delayTime) ?? 50))),
|
|
1526
1538
|
$t(this.destroy$),
|
|
1527
1539
|
Nt(3)
|
|
1528
1540
|
).subscribe({
|
|
@@ -1544,7 +1556,7 @@ class zt {
|
|
|
1544
1556
|
this.destroy$.next(), this.destroy$.complete();
|
|
1545
1557
|
}
|
|
1546
1558
|
}
|
|
1547
|
-
class
|
|
1559
|
+
class Re {
|
|
1548
1560
|
constructor(t) {
|
|
1549
1561
|
m(this, "client");
|
|
1550
1562
|
m(this, "customChannelId");
|
|
@@ -1560,7 +1572,7 @@ class ke {
|
|
|
1560
1572
|
this.client = t.client, this.customChannelId = t.customChannelId, this.customMessageId = t.customMessageId, this.isConnecting$ = new re(!1), this.conversation$ = new re(t.conversation), this.statesObserver = t.statesObserver;
|
|
1561
1573
|
}
|
|
1562
1574
|
static async reset(t, e, r) {
|
|
1563
|
-
const i = new
|
|
1575
|
+
const i = new Re(t);
|
|
1564
1576
|
try {
|
|
1565
1577
|
return i.subscribe(), await i.resetChannel(e, r), i;
|
|
1566
1578
|
} catch (o) {
|
|
@@ -1634,30 +1646,30 @@ class ke {
|
|
|
1634
1646
|
this.isConnecting$.complete(), this.conversation$.complete(), (t = this.statesSubscription) == null || t.unsubscribe();
|
|
1635
1647
|
}
|
|
1636
1648
|
}
|
|
1637
|
-
class
|
|
1649
|
+
class C {
|
|
1638
1650
|
constructor({ messages: t }) {
|
|
1639
1651
|
m(this, "messages", null);
|
|
1640
1652
|
this.messages = t;
|
|
1641
1653
|
}
|
|
1642
1654
|
pushMessage(t) {
|
|
1643
1655
|
const e = new Map(this.messages);
|
|
1644
|
-
return e.set(t.messageId, t), new
|
|
1656
|
+
return e.set(t.messageId, t), new C({ messages: e });
|
|
1645
1657
|
}
|
|
1646
1658
|
onMessage(t) {
|
|
1647
1659
|
switch (t.eventType) {
|
|
1648
|
-
case
|
|
1660
|
+
case h.MESSAGE_START:
|
|
1649
1661
|
return this.onMessageStart(
|
|
1650
1662
|
t
|
|
1651
1663
|
);
|
|
1652
|
-
case
|
|
1664
|
+
case h.MESSAGE_DELTA:
|
|
1653
1665
|
return this.onMessageDelta(
|
|
1654
1666
|
t
|
|
1655
1667
|
);
|
|
1656
|
-
case
|
|
1668
|
+
case h.MESSAGE_COMPLETE:
|
|
1657
1669
|
return this.onMessageComplete(
|
|
1658
1670
|
t
|
|
1659
1671
|
);
|
|
1660
|
-
case
|
|
1672
|
+
case h.ERROR:
|
|
1661
1673
|
return this.onMessageError(t);
|
|
1662
1674
|
default:
|
|
1663
1675
|
return this;
|
|
@@ -1667,13 +1679,13 @@ class T {
|
|
|
1667
1679
|
const e = t.fact.messageStart.message, r = new Map(this.messages);
|
|
1668
1680
|
return r.set(e.messageId, {
|
|
1669
1681
|
type: "bot",
|
|
1670
|
-
eventType:
|
|
1682
|
+
eventType: h.MESSAGE_START,
|
|
1671
1683
|
isTyping: !0,
|
|
1672
1684
|
typingText: "",
|
|
1673
1685
|
messageId: e.messageId,
|
|
1674
1686
|
message: e,
|
|
1675
1687
|
time: /* @__PURE__ */ new Date()
|
|
1676
|
-
}), new
|
|
1688
|
+
}), new C({ messages: r });
|
|
1677
1689
|
}
|
|
1678
1690
|
onMessageDelta(t) {
|
|
1679
1691
|
const e = t.fact.messageDelta.message, r = new Map(this.messages), i = r.get(e.messageId);
|
|
@@ -1681,42 +1693,42 @@ class T {
|
|
|
1681
1693
|
const o = `${(i == null ? void 0 : i.typingText) ?? ""}${e.text}`;
|
|
1682
1694
|
return r.set(e.messageId, {
|
|
1683
1695
|
type: "bot",
|
|
1684
|
-
eventType:
|
|
1696
|
+
eventType: h.MESSAGE_DELTA,
|
|
1685
1697
|
isTyping: !0,
|
|
1686
1698
|
typingText: o,
|
|
1687
1699
|
messageId: e.messageId,
|
|
1688
1700
|
message: e,
|
|
1689
1701
|
time: /* @__PURE__ */ new Date()
|
|
1690
|
-
}), new
|
|
1702
|
+
}), new C({ messages: r });
|
|
1691
1703
|
}
|
|
1692
1704
|
onMessageComplete(t) {
|
|
1693
1705
|
const e = t.fact.messageComplete.message, r = new Map(this.messages);
|
|
1694
1706
|
return r.set(e.messageId, {
|
|
1695
1707
|
type: "bot",
|
|
1696
|
-
eventType:
|
|
1708
|
+
eventType: h.MESSAGE_COMPLETE,
|
|
1697
1709
|
isTyping: !1,
|
|
1698
1710
|
typingText: null,
|
|
1699
1711
|
messageId: e.messageId,
|
|
1700
1712
|
message: e,
|
|
1701
1713
|
time: /* @__PURE__ */ new Date()
|
|
1702
|
-
}), new
|
|
1714
|
+
}), new C({ messages: r });
|
|
1703
1715
|
}
|
|
1704
1716
|
onMessageError(t) {
|
|
1705
1717
|
const e = crypto.randomUUID(), r = t.fact.runError.error, i = new Map(this.messages);
|
|
1706
1718
|
return i.set(e, {
|
|
1707
1719
|
type: "error",
|
|
1708
|
-
eventType:
|
|
1720
|
+
eventType: h.ERROR,
|
|
1709
1721
|
messageId: e,
|
|
1710
1722
|
error: r,
|
|
1711
1723
|
time: /* @__PURE__ */ new Date()
|
|
1712
|
-
}), new
|
|
1724
|
+
}), new C({ messages: i });
|
|
1713
1725
|
}
|
|
1714
1726
|
}
|
|
1715
1727
|
export {
|
|
1716
1728
|
zt as AsgardServiceClient,
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1729
|
+
Re as Channel,
|
|
1730
|
+
C as Conversation,
|
|
1731
|
+
h as EventType,
|
|
1720
1732
|
K as FetchSseAction,
|
|
1721
1733
|
Ne as MessageTemplateType
|
|
1722
1734
|
};
|