@asgard-js/core 0.0.23 → 0.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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 || {}), v = /* @__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.DONE = "asgard.run.done", n.ERROR = "asgard.run.error", n))(v || {}), 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) {
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 (h) {
31
- s(h);
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 (h) {
38
- s(h);
37
+ } catch (y) {
38
+ s(y);
39
39
  }
40
40
  }
41
41
  function u(f) {
@@ -104,7 +104,7 @@ function ce(n, t) {
104
104
  return { value: u[0] ? u[1] : void 0, done: !0 };
105
105
  }
106
106
  }
107
- function M(n) {
107
+ function L(n) {
108
108
  var t = typeof Symbol == "function" && Symbol.iterator, e = t && n[t], r = 0;
109
109
  if (e) return e.call(n);
110
110
  if (n && typeof n.length == "number") return {
@@ -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 R(n, t) {
117
+ function M(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 k(n, t, e) {
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,41 +146,41 @@ function Ge(n, t, e) {
146
146
  return this;
147
147
  }, i;
148
148
  function s(l) {
149
- return function(y) {
150
- return Promise.resolve(y).then(l, h);
149
+ return function(v) {
150
+ return Promise.resolve(v).then(l, y);
151
151
  };
152
152
  }
153
- function c(l, y) {
153
+ function c(l, v) {
154
154
  r[l] && (i[l] = function(d) {
155
155
  return new Promise(function(S, w) {
156
156
  o.push([l, d, S, w]) > 1 || a(l, d);
157
157
  });
158
- }, y && (i[l] = y(i[l])));
158
+ }, v && (i[l] = v(i[l])));
159
159
  }
160
- function a(l, y) {
160
+ function a(l, v) {
161
161
  try {
162
- u(r[l](y));
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, h) : b(o[0][2], l);
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 h(l) {
173
+ function y(l) {
174
174
  a("throw", l);
175
175
  }
176
- function b(l, y) {
177
- l(y), o.shift(), o.length && a(o[0][0], o[0][1]);
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) {
181
181
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
182
182
  var t = n[Symbol.asyncIterator], e;
183
- return t ? t.call(n) : (n = typeof M == "function" ? M(n) : n[Symbol.iterator](), e = {}, r("next"), r("throw"), r("return"), e[Symbol.asyncIterator] = function() {
183
+ return t ? t.call(n) : (n = typeof L == "function" ? L(n) : n[Symbol.iterator](), e = {}, r("next"), r("throw"), r("return"), e[Symbol.asyncIterator] = function() {
184
184
  return this;
185
185
  }, e);
186
186
  function r(o) {
@@ -220,7 +220,7 @@ function N(n, t) {
220
220
  0 <= e && n.splice(e, 1);
221
221
  }
222
222
  }
223
- var j = function() {
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
  }
@@ -232,7 +232,7 @@ var j = function() {
232
232
  if (s)
233
233
  if (this._parentage = null, Array.isArray(s))
234
234
  try {
235
- for (var c = M(s), a = c.next(); !a.done; a = c.next()) {
235
+ for (var c = L(s), a = c.next(); !a.done; a = c.next()) {
236
236
  var u = a.value;
237
237
  u.remove(this);
238
238
  }
@@ -254,16 +254,16 @@ var j = function() {
254
254
  } catch (d) {
255
255
  o = d instanceof B ? d.errors : [d];
256
256
  }
257
- var h = this._finalizers;
258
- if (h) {
257
+ var y = this._finalizers;
258
+ if (y) {
259
259
  this._finalizers = null;
260
260
  try {
261
- for (var b = M(h), l = b.next(); !l.done; l = b.next()) {
262
- var y = l.value;
261
+ for (var b = L(y), l = b.next(); !l.done; l = b.next()) {
262
+ var v = l.value;
263
263
  try {
264
- ee(y);
264
+ ee(v);
265
265
  } catch (d) {
266
- o = o ?? [], d instanceof B ? o = k(k([], R(o)), R(d.errors)) : o.push(d);
266
+ o = o ?? [], d instanceof B ? o = R(R([], M(o)), M(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 = j.EMPTY;
311
+ }(), le = k.EMPTY;
312
312
  function de(n) {
313
- return n instanceof j || n && "closed" in n && p(n.remove) && p(n.add) && p(n.unsubscribe);
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, k([n, t], R(e)));
328
+ return setTimeout.apply(void 0, R([n, t], M(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
- }(j), Ve = function() {
377
+ }(k), Ve = function() {
378
378
  function n(t) {
379
379
  this.partialObserver = t;
380
380
  }
@@ -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 C(n) {
517
+ function T(n) {
518
518
  return function(t) {
519
519
  if (Je(t))
520
520
  return t.lift(function(e) {
@@ -588,7 +588,7 @@ var Xe = function(n) {
588
588
  if (r._throwIfClosed(), !r.isStopped) {
589
589
  r.currentObservers || (r.currentObservers = Array.from(r.observers));
590
590
  try {
591
- for (var s = M(r.currentObservers), c = s.next(); !c.done; c = s.next()) {
591
+ for (var s = L(r.currentObservers), c = s.next(); !c.done; c = s.next()) {
592
592
  var a = c.value;
593
593
  a.next(e);
594
594
  }
@@ -636,7 +636,7 @@ 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 j(function() {
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) {
@@ -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
- }(j), ie = {
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, k([n, t], R(e)));
710
+ return setInterval.apply(void 0, R([n, t], M(e)));
711
711
  },
712
712
  clearInterval: function(n) {
713
713
  return clearInterval(n);
@@ -824,7 +824,7 @@ var Ie = ot();
824
824
  function Ae(n) {
825
825
  return p(n == null ? void 0 : n[Ie]);
826
826
  }
827
- function xe(n) {
827
+ function _e(n) {
828
828
  return Ge(this, arguments, function() {
829
829
  var e, r, i, o;
830
830
  return ce(this, function(s) {
@@ -855,10 +855,10 @@ function xe(n) {
855
855
  });
856
856
  });
857
857
  }
858
- function _e(n) {
858
+ function xe(n) {
859
859
  return p(n == null ? void 0 : n.getReader);
860
860
  }
861
- function x(n) {
861
+ function _(n) {
862
862
  if (n instanceof g)
863
863
  return n;
864
864
  if (n != null) {
@@ -869,10 +869,10 @@ function x(n) {
869
869
  if (Se(n))
870
870
  return at(n);
871
871
  if (Ee(n))
872
- return Ce(n);
872
+ return Te(n);
873
873
  if (Ae(n))
874
874
  return ct(n);
875
- if (_e(n))
875
+ if (xe(n))
876
876
  return ft(n);
877
877
  }
878
878
  throw Oe(n);
@@ -905,7 +905,7 @@ function ct(n) {
905
905
  return new g(function(t) {
906
906
  var e, r;
907
907
  try {
908
- for (var i = M(n), o = i.next(); !o.done; o = i.next()) {
908
+ for (var i = L(n), o = i.next(); !o.done; o = i.next()) {
909
909
  var s = o.value;
910
910
  if (t.next(s), t.closed)
911
911
  return;
@@ -922,7 +922,7 @@ function ct(n) {
922
922
  t.complete();
923
923
  });
924
924
  }
925
- function Ce(n) {
925
+ function Te(n) {
926
926
  return new g(function(t) {
927
927
  lt(n, t).catch(function(e) {
928
928
  return t.error(e);
@@ -930,7 +930,7 @@ function Ce(n) {
930
930
  });
931
931
  }
932
932
  function ft(n) {
933
- return Ce(xe(n));
933
+ return Te(_e(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 Te(n, t) {
982
- return t === void 0 && (t = 0), C(function(e, r) {
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,17 +996,17 @@ function Te(n, t) {
996
996
  });
997
997
  }
998
998
  function Pe(n, t) {
999
- return t === void 0 && (t = 0), C(function(e, r) {
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), Te(t));
1006
+ return _(n).pipe(Pe(t), Ce(t));
1007
1007
  }
1008
1008
  function ht(n, t) {
1009
- return x(n).pipe(Pe(t), Te(t));
1009
+ return _(n).pipe(Pe(t), Ce(t));
1010
1010
  }
1011
1011
  function yt(n, t) {
1012
1012
  return new g(function(e) {
@@ -1035,7 +1035,7 @@ function vt(n, t) {
1035
1035
  };
1036
1036
  });
1037
1037
  }
1038
- function Me(n, t) {
1038
+ function Le(n, t) {
1039
1039
  if (!n)
1040
1040
  throw new Error("Iterable cannot be null");
1041
1041
  return new g(function(e) {
@@ -1050,7 +1050,7 @@ function Me(n, t) {
1050
1050
  });
1051
1051
  }
1052
1052
  function pt(n, t) {
1053
- return Me(xe(n), t);
1053
+ return Le(_e(n), t);
1054
1054
  }
1055
1055
  function bt(n, t) {
1056
1056
  if (n != null) {
@@ -1061,16 +1061,16 @@ function bt(n, t) {
1061
1061
  if (Se(n))
1062
1062
  return ht(n, t);
1063
1063
  if (Ee(n))
1064
- return Me(n, t);
1064
+ return Le(n, t);
1065
1065
  if (Ae(n))
1066
1066
  return vt(n, t);
1067
- if (_e(n))
1067
+ if (xe(n))
1068
1068
  return pt(n, t);
1069
1069
  }
1070
1070
  throw Oe(n);
1071
1071
  }
1072
1072
  function Z(n, t) {
1073
- return t ? bt(n, t) : x(n);
1073
+ return t ? bt(n, t) : _(n);
1074
1074
  }
1075
1075
  function mt() {
1076
1076
  for (var n = [], t = 0; t < arguments.length; t++)
@@ -1082,7 +1082,7 @@ function gt(n) {
1082
1082
  return n instanceof Date && !isNaN(n);
1083
1083
  }
1084
1084
  function F(n, t) {
1085
- return C(function(e, r) {
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++));
@@ -1091,21 +1091,21 @@ function F(n, t) {
1091
1091
  }
1092
1092
  var St = Array.isArray;
1093
1093
  function wt(n, t) {
1094
- return St(t) ? n.apply(void 0, k([], R(t))) : n(t);
1094
+ return St(t) ? n.apply(void 0, R([], M(t))) : n(t);
1095
1095
  }
1096
1096
  function Et(n) {
1097
1097
  return F(function(t) {
1098
1098
  return wt(n, t);
1099
1099
  });
1100
1100
  }
1101
- var Ot = Array.isArray, It = Object.getPrototypeOf, At = Object.prototype, xt = Object.keys;
1102
- function _t(n) {
1101
+ var Ot = Array.isArray, It = Object.getPrototypeOf, At = Object.prototype, _t = Object.keys;
1102
+ function xt(n) {
1103
1103
  if (n.length === 1) {
1104
1104
  var t = n[0];
1105
1105
  if (Ot(t))
1106
1106
  return { args: t, keys: null };
1107
- if (Ct(t)) {
1108
- var e = xt(t);
1107
+ if (Tt(t)) {
1108
+ var e = _t(t);
1109
1109
  return {
1110
1110
  args: e.map(function(r) {
1111
1111
  return t[r];
@@ -1116,10 +1116,10 @@ function _t(n) {
1116
1116
  }
1117
1117
  return { args: n, keys: null };
1118
1118
  }
1119
- function Ct(n) {
1119
+ function Tt(n) {
1120
1120
  return n && typeof n == "object" && It(n) === At;
1121
1121
  }
1122
- function Tt(n, t) {
1122
+ function Ct(n, t) {
1123
1123
  return n.reduce(function(e, r, i) {
1124
1124
  return e[r] = t[i], e;
1125
1125
  }, {});
@@ -1127,21 +1127,21 @@ function Tt(n, t) {
1127
1127
  function Pt() {
1128
1128
  for (var n = [], t = 0; t < arguments.length; t++)
1129
1129
  n[t] = arguments[t];
1130
- var e = me(n), r = it(n), i = _t(n), o = i.args, s = i.keys;
1130
+ var e = me(n), r = it(n), i = xt(n), o = i.args, s = i.keys;
1131
1131
  if (o.length === 0)
1132
1132
  return Z([], e);
1133
- var c = new g(Mt(o, e, s ? function(a) {
1134
- return Tt(s, a);
1133
+ var c = new g(Lt(o, e, s ? function(a) {
1134
+ return Ct(s, a);
1135
1135
  } : G));
1136
1136
  return r ? c.pipe(Et(r)) : c;
1137
1137
  }
1138
- function Mt(n, t, e) {
1138
+ function Lt(n, t, e) {
1139
1139
  return e === void 0 && (e = G), function(r) {
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 h = Z(n[f], t), b = !1;
1144
- h.subscribe(E(r, function(l) {
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,15 +1155,15 @@ function Mt(n, t, e) {
1155
1155
  function se(n, t, e) {
1156
1156
  n ? A(e, n, t) : t();
1157
1157
  }
1158
- function Rt(n, t, e, r, i, o, s, c) {
1159
- var a = [], u = 0, f = 0, h = !1, b = function() {
1160
- h && !a.length && !u && t.complete();
1158
+ function Mt(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 ? y(d) : a.push(d);
1163
- }, y = function(d) {
1162
+ return u < r ? v(d) : a.push(d);
1163
+ }, v = function(d) {
1164
1164
  u++;
1165
1165
  var S = !1;
1166
- x(e(d, f++)).subscribe(E(t, function(w) {
1166
+ _(e(d, f++)).subscribe(E(t, function(w) {
1167
1167
  t.next(w);
1168
1168
  }, function() {
1169
1169
  S = !0;
@@ -1172,18 +1172,18 @@ function Rt(n, t, e, r, i, o, s, c) {
1172
1172
  try {
1173
1173
  u--;
1174
1174
  for (var w = function() {
1175
- var _ = a.shift();
1176
- s || y(_);
1175
+ var x = a.shift();
1176
+ s || v(x);
1177
1177
  }; a.length && u < r; )
1178
1178
  w();
1179
1179
  b();
1180
- } catch (_) {
1181
- t.error(_);
1180
+ } catch (x) {
1181
+ t.error(x);
1182
1182
  }
1183
1183
  }));
1184
1184
  };
1185
1185
  return n.subscribe(E(t, l, function() {
1186
- h = !0, b();
1186
+ y = !0, b();
1187
1187
  })), function() {
1188
1188
  };
1189
1189
  }
@@ -1191,12 +1191,12 @@ function $(n, t, e) {
1191
1191
  return e === void 0 && (e = 1 / 0), p(t) ? $(function(r, i) {
1192
1192
  return F(function(o, s) {
1193
1193
  return t(r, o, i, s);
1194
- })(x(n(r, i)));
1195
- }, e) : (typeof t == "number" && (e = t), C(function(r, i) {
1196
- return Rt(r, i, n, e);
1194
+ })(_(n(r, i)));
1195
+ }, e) : (typeof t == "number" && (e = t), T(function(r, i) {
1196
+ return Mt(r, i, n, e);
1197
1197
  }));
1198
1198
  }
1199
- function Re(n, t, e) {
1199
+ function Me(n, t, e) {
1200
1200
  n === void 0 && (n = 0), e === void 0 && (e = nt);
1201
1201
  var r = -1;
1202
1202
  return t != null && (pe(t) ? e = t : r = t), new g(function(i) {
@@ -1208,32 +1208,32 @@ function Re(n, t, e) {
1208
1208
  }, o);
1209
1209
  });
1210
1210
  }
1211
- function kt(n, t) {
1211
+ function Rt(n, t) {
1212
1212
  return p(t) ? $(n, t, 1) : $(n, 1);
1213
1213
  }
1214
- function jt(n) {
1214
+ function kt(n) {
1215
1215
  return n <= 0 ? function() {
1216
1216
  return rt;
1217
- } : C(function(t, e) {
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 Lt(n) {
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(jt(1), Lt(e));
1231
+ return _(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 = Re(n, t);
1236
+ var e = Me(n, t);
1237
1237
  return Dt(function() {
1238
1238
  return e;
1239
1239
  });
@@ -1244,35 +1244,35 @@ 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 : C(function(c, a) {
1248
- var u = 0, f, h = function() {
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 y = function() {
1255
- f ? (f.unsubscribe(), f = null, h()) : b = !0;
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" ? Re(i) : x(i(l, u)), S = E(a, function() {
1259
- S.unsubscribe(), y();
1258
+ var d = typeof i == "number" ? Me(i) : _(i(l, u)), S = E(a, function() {
1259
+ S.unsubscribe(), v();
1260
1260
  }, function() {
1261
1261
  a.complete();
1262
1262
  });
1263
1263
  d.subscribe(S);
1264
1264
  } else
1265
- y();
1265
+ v();
1266
1266
  } else
1267
1267
  a.error(l);
1268
- })), b && (f.unsubscribe(), f = null, h());
1268
+ })), b && (f.unsubscribe(), f = null, y());
1269
1269
  };
1270
- h();
1270
+ y();
1271
1271
  });
1272
1272
  }
1273
1273
  function $t(n) {
1274
- return C(function(t, e) {
1275
- x(n).subscribe(E(e, function() {
1274
+ return T(function(t, e) {
1275
+ _(n).subscribe(E(e, function() {
1276
1276
  return e.complete();
1277
1277
  }, q)), !e.closed && t.subscribe(e);
1278
1278
  });
@@ -1330,8 +1330,8 @@ function Ht(n, t, e) {
1330
1330
  n(r.id = f);
1331
1331
  break;
1332
1332
  case "retry":
1333
- const h = parseInt(f, 10);
1334
- isNaN(h) || t(r.retry = h);
1333
+ const y = parseInt(f, 10);
1334
+ isNaN(y) || t(r.retry = y);
1335
1335
  break;
1336
1336
  }
1337
1337
  }
@@ -1360,39 +1360,39 @@ 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((h, b) => {
1363
+ return new Promise((y, b) => {
1364
1364
  const l = Object.assign({}, r);
1365
1365
  l.accept || (l.accept = J);
1366
- let y;
1366
+ let v;
1367
1367
  function d() {
1368
- y.abort(), document.hidden || H();
1368
+ v.abort(), document.hidden || H();
1369
1369
  }
1370
1370
  a || document.addEventListener("visibilitychange", d);
1371
1371
  let S = Kt, w = 0;
1372
- function _() {
1373
- document.removeEventListener("visibilitychange", d), window.clearTimeout(w), y.abort();
1372
+ function x() {
1373
+ document.removeEventListener("visibilitychange", d), window.clearTimeout(w), v.abort();
1374
1374
  }
1375
1375
  e == null || e.addEventListener("abort", () => {
1376
- _(), h();
1376
+ x(), y();
1377
1377
  });
1378
- const je = u ?? window.fetch, Le = i ?? qt;
1378
+ const ke = u ?? window.fetch, je = i ?? qt;
1379
1379
  async function H() {
1380
1380
  var V;
1381
- y = new AbortController();
1381
+ v = new AbortController();
1382
1382
  try {
1383
- const L = await je(n, Object.assign(Object.assign({}, f), { headers: l, signal: y.signal }));
1384
- await Le(L), await Gt(L.body, Ft(Ht((I) => {
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
1387
  S = I;
1388
- }, o))), s == null || s(), _(), h();
1389
- } catch (L) {
1390
- if (!y.signal.aborted)
1388
+ }, o))), s == null || s(), x(), y();
1389
+ } catch (j) {
1390
+ if (!v.signal.aborted)
1391
1391
  try {
1392
- const I = (V = c == null ? void 0 : c(L)) !== null && V !== void 0 ? V : S;
1392
+ const I = (V = c == null ? void 0 : c(j)) !== null && V !== void 0 ? V : S;
1393
1393
  window.clearTimeout(w), w = window.setTimeout(H, I);
1394
1394
  } catch (I) {
1395
- _(), b(I);
1395
+ x(), b(I);
1396
1396
  }
1397
1397
  }
1398
1398
  }
@@ -1479,36 +1479,43 @@ class zt {
1479
1479
  }
1480
1480
  handleEvent(t) {
1481
1481
  switch (t.eventType) {
1482
- case v.INIT:
1482
+ case h.INIT:
1483
+ this.sseEmitter.emit(
1484
+ h.INIT,
1485
+ t
1486
+ );
1487
+ break;
1488
+ case h.PROCESS_START:
1489
+ case h.PROCESS_COMPLETE:
1483
1490
  this.sseEmitter.emit(
1484
- v.INIT,
1491
+ h.PROCESS,
1485
1492
  t
1486
1493
  );
1487
1494
  break;
1488
- case v.PROCESS_START:
1489
- case v.PROCESS_COMPLETE:
1495
+ case h.MESSAGE_START:
1496
+ case h.MESSAGE_DELTA:
1497
+ case h.MESSAGE_COMPLETE:
1490
1498
  this.sseEmitter.emit(
1491
- v.PROCESS,
1499
+ h.MESSAGE,
1492
1500
  t
1493
1501
  );
1494
1502
  break;
1495
- case v.MESSAGE_START:
1496
- case v.MESSAGE_DELTA:
1497
- case v.MESSAGE_COMPLETE:
1503
+ case h.TOOL_CALL_START:
1504
+ case h.TOOL_CALL_COMPLETE:
1498
1505
  this.sseEmitter.emit(
1499
- v.MESSAGE,
1506
+ h.TOOL_CALL,
1500
1507
  t
1501
1508
  );
1502
1509
  break;
1503
- case v.DONE:
1510
+ case h.DONE:
1504
1511
  this.sseEmitter.emit(
1505
- v.DONE,
1512
+ h.DONE,
1506
1513
  t
1507
1514
  );
1508
1515
  break;
1509
- case v.ERROR:
1516
+ case h.ERROR:
1510
1517
  this.sseEmitter.emit(
1511
- v.ERROR,
1518
+ h.ERROR,
1512
1519
  t
1513
1520
  );
1514
1521
  break;
@@ -1522,7 +1529,7 @@ class zt {
1522
1529
  debugMode: this.debugMode,
1523
1530
  payload: ((i = this.transformSsePayload) == null ? void 0 : i.call(this, t)) ?? t
1524
1531
  }).pipe(
1525
- kt((o) => mt(o).pipe(Ut((e == null ? void 0 : e.delayTime) ?? 50))),
1532
+ Rt((o) => mt(o).pipe(Ut((e == null ? void 0 : e.delayTime) ?? 50))),
1526
1533
  $t(this.destroy$),
1527
1534
  Nt(3)
1528
1535
  ).subscribe({
@@ -1544,7 +1551,7 @@ class zt {
1544
1551
  this.destroy$.next(), this.destroy$.complete();
1545
1552
  }
1546
1553
  }
1547
- class ke {
1554
+ class Re {
1548
1555
  constructor(t) {
1549
1556
  m(this, "client");
1550
1557
  m(this, "customChannelId");
@@ -1560,7 +1567,7 @@ class ke {
1560
1567
  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
1568
  }
1562
1569
  static async reset(t, e, r) {
1563
- const i = new ke(t);
1570
+ const i = new Re(t);
1564
1571
  try {
1565
1572
  return i.subscribe(), await i.resetChannel(e, r), i;
1566
1573
  } catch (o) {
@@ -1634,30 +1641,30 @@ class ke {
1634
1641
  this.isConnecting$.complete(), this.conversation$.complete(), (t = this.statesSubscription) == null || t.unsubscribe();
1635
1642
  }
1636
1643
  }
1637
- class T {
1644
+ class C {
1638
1645
  constructor({ messages: t }) {
1639
1646
  m(this, "messages", null);
1640
1647
  this.messages = t;
1641
1648
  }
1642
1649
  pushMessage(t) {
1643
1650
  const e = new Map(this.messages);
1644
- return e.set(t.messageId, t), new T({ messages: e });
1651
+ return e.set(t.messageId, t), new C({ messages: e });
1645
1652
  }
1646
1653
  onMessage(t) {
1647
1654
  switch (t.eventType) {
1648
- case v.MESSAGE_START:
1655
+ case h.MESSAGE_START:
1649
1656
  return this.onMessageStart(
1650
1657
  t
1651
1658
  );
1652
- case v.MESSAGE_DELTA:
1659
+ case h.MESSAGE_DELTA:
1653
1660
  return this.onMessageDelta(
1654
1661
  t
1655
1662
  );
1656
- case v.MESSAGE_COMPLETE:
1663
+ case h.MESSAGE_COMPLETE:
1657
1664
  return this.onMessageComplete(
1658
1665
  t
1659
1666
  );
1660
- case v.ERROR:
1667
+ case h.ERROR:
1661
1668
  return this.onMessageError(t);
1662
1669
  default:
1663
1670
  return this;
@@ -1667,13 +1674,13 @@ class T {
1667
1674
  const e = t.fact.messageStart.message, r = new Map(this.messages);
1668
1675
  return r.set(e.messageId, {
1669
1676
  type: "bot",
1670
- eventType: v.MESSAGE_START,
1677
+ eventType: h.MESSAGE_START,
1671
1678
  isTyping: !0,
1672
1679
  typingText: "",
1673
1680
  messageId: e.messageId,
1674
1681
  message: e,
1675
1682
  time: /* @__PURE__ */ new Date()
1676
- }), new T({ messages: r });
1683
+ }), new C({ messages: r });
1677
1684
  }
1678
1685
  onMessageDelta(t) {
1679
1686
  const e = t.fact.messageDelta.message, r = new Map(this.messages), i = r.get(e.messageId);
@@ -1681,42 +1688,42 @@ class T {
1681
1688
  const o = `${(i == null ? void 0 : i.typingText) ?? ""}${e.text}`;
1682
1689
  return r.set(e.messageId, {
1683
1690
  type: "bot",
1684
- eventType: v.MESSAGE_DELTA,
1691
+ eventType: h.MESSAGE_DELTA,
1685
1692
  isTyping: !0,
1686
1693
  typingText: o,
1687
1694
  messageId: e.messageId,
1688
1695
  message: e,
1689
1696
  time: /* @__PURE__ */ new Date()
1690
- }), new T({ messages: r });
1697
+ }), new C({ messages: r });
1691
1698
  }
1692
1699
  onMessageComplete(t) {
1693
1700
  const e = t.fact.messageComplete.message, r = new Map(this.messages);
1694
1701
  return r.set(e.messageId, {
1695
1702
  type: "bot",
1696
- eventType: v.MESSAGE_COMPLETE,
1703
+ eventType: h.MESSAGE_COMPLETE,
1697
1704
  isTyping: !1,
1698
1705
  typingText: null,
1699
1706
  messageId: e.messageId,
1700
1707
  message: e,
1701
1708
  time: /* @__PURE__ */ new Date()
1702
- }), new T({ messages: r });
1709
+ }), new C({ messages: r });
1703
1710
  }
1704
1711
  onMessageError(t) {
1705
1712
  const e = crypto.randomUUID(), r = t.fact.runError.error, i = new Map(this.messages);
1706
1713
  return i.set(e, {
1707
1714
  type: "error",
1708
- eventType: v.ERROR,
1715
+ eventType: h.ERROR,
1709
1716
  messageId: e,
1710
1717
  error: r,
1711
1718
  time: /* @__PURE__ */ new Date()
1712
- }), new T({ messages: i });
1719
+ }), new C({ messages: i });
1713
1720
  }
1714
1721
  }
1715
1722
  export {
1716
1723
  zt as AsgardServiceClient,
1717
- ke as Channel,
1718
- T as Conversation,
1719
- v as EventType,
1724
+ Re as Channel,
1725
+ C as Conversation,
1726
+ h as EventType,
1720
1727
  K as FetchSseAction,
1721
1728
  Ne as MessageTemplateType
1722
1729
  };