@asgard-js/core 0.0.43-canary.24 → 0.0.43-canary.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/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  var De = Object.defineProperty;
2
- var Ne = (n, t, e) => t in n ? De(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var m = (n, t, e) => Ne(n, typeof t != "symbol" ? t + "" : t, e);
4
- var K = /* @__PURE__ */ ((n) => (n.RESET_CHANNEL = "RESET_CHANNEL", n.NONE = "NONE", n))(K || {}), y = /* @__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))(y || {}), Ue = /* @__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))(Ue || {}), Y = function(n, t) {
2
+ var Ue = (n, t, e) => t in n ? De(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
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 || {}), 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 (d) {
31
- s(d);
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 (d) {
38
- s(d);
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 R(n) {
107
+ function M(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 {
@@ -131,13 +131,13 @@ function L(n, t) {
131
131
  }
132
132
  return o;
133
133
  }
134
- function M(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));
138
138
  }
139
- function C(n) {
140
- return this instanceof C ? (this.v = n, this) : new C(n);
139
+ function P(n) {
140
+ return this instanceof P ? (this.v = n, this) : new P(n);
141
141
  }
142
142
  function Ge(n, t, e) {
143
143
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
@@ -147,30 +147,30 @@ function Ge(n, t, e) {
147
147
  }, i;
148
148
  function s(l) {
149
149
  return function(v) {
150
- return Promise.resolve(v).then(l, d);
150
+ return Promise.resolve(v).then(l, y);
151
151
  };
152
152
  }
153
153
  function c(l, v) {
154
- r[l] && (i[l] = function(h) {
154
+ r[l] && (i[l] = function(d) {
155
155
  return new Promise(function(g, w) {
156
- o.push([l, h, g, w]) > 1 || a(l, h);
156
+ o.push([l, d, g, w]) > 1 || a(l, d);
157
157
  });
158
158
  }, v && (i[l] = v(i[l])));
159
159
  }
160
160
  function a(l, v) {
161
161
  try {
162
162
  u(r[l](v));
163
- } catch (h) {
164
- b(o[0][3], h);
163
+ } catch (d) {
164
+ b(o[0][3], d);
165
165
  }
166
166
  }
167
167
  function u(l) {
168
- l.value instanceof C ? Promise.resolve(l.value.v).then(f, d) : 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 d(l) {
173
+ function y(l) {
174
174
  a("throw", l);
175
175
  }
176
176
  function b(l, v) {
@@ -180,7 +180,7 @@ function Ge(n, t, e) {
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 R == "function" ? R(n) : n[Symbol.iterator](), e = {}, r("next"), r("throw"), r("return"), e[Symbol.asyncIterator] = function() {
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() {
184
184
  return this;
185
185
  }, e);
186
186
  function r(o) {
@@ -214,7 +214,7 @@ var B = fe(function(n) {
214
214
  `) : "", this.name = "UnsubscriptionError", this.errors = e;
215
215
  };
216
216
  });
217
- function U(n, t) {
217
+ function N(n, t) {
218
218
  if (n) {
219
219
  var e = n.indexOf(t);
220
220
  0 <= e && n.splice(e, 1);
@@ -232,12 +232,12 @@ var k = function() {
232
232
  if (s)
233
233
  if (this._parentage = null, Array.isArray(s))
234
234
  try {
235
- for (var c = R(s), a = c.next(); !a.done; a = c.next()) {
235
+ for (var c = M(s), a = c.next(); !a.done; a = c.next()) {
236
236
  var u = a.value;
237
237
  u.remove(this);
238
238
  }
239
- } catch (h) {
240
- t = { error: h };
239
+ } catch (d) {
240
+ t = { error: d };
241
241
  } finally {
242
242
  try {
243
243
  a && !a.done && (e = c.return) && e.call(c);
@@ -251,23 +251,23 @@ var k = function() {
251
251
  if (p(f))
252
252
  try {
253
253
  f();
254
- } catch (h) {
255
- o = h instanceof B ? h.errors : [h];
254
+ } catch (d) {
255
+ o = d instanceof B ? d.errors : [d];
256
256
  }
257
- var d = this._finalizers;
258
- if (d) {
257
+ var y = this._finalizers;
258
+ if (y) {
259
259
  this._finalizers = null;
260
260
  try {
261
- for (var b = R(d), l = b.next(); !l.done; l = b.next()) {
261
+ for (var b = M(y), l = b.next(); !l.done; l = b.next()) {
262
262
  var v = l.value;
263
263
  try {
264
264
  ee(v);
265
- } catch (h) {
266
- o = o ?? [], h instanceof B ? o = M(M([], L(o)), L(h.errors)) : o.push(h);
265
+ } catch (d) {
266
+ o = o ?? [], d instanceof B ? o = R(R([], L(o)), L(d.errors)) : o.push(d);
267
267
  }
268
268
  }
269
- } catch (h) {
270
- r = { error: h };
269
+ } catch (d) {
270
+ r = { error: d };
271
271
  } finally {
272
272
  try {
273
273
  l && !l.done && (i = b.return) && i.call(b);
@@ -300,10 +300,10 @@ var k = function() {
300
300
  this._parentage = Array.isArray(e) ? (e.push(t), e) : e ? [e, t] : t;
301
301
  }, n.prototype._removeParent = function(t) {
302
302
  var e = this._parentage;
303
- e === t ? this._parentage = null : Array.isArray(e) && U(e, t);
303
+ e === t ? this._parentage = null : Array.isArray(e) && N(e, t);
304
304
  }, n.prototype.remove = function(t) {
305
305
  var e = this._finalizers;
306
- e && U(e, t), t instanceof n && t._removeParent(this);
306
+ e && N(e, t), t instanceof n && t._removeParent(this);
307
307
  }, n.EMPTY = function() {
308
308
  var t = new n();
309
309
  return t.closed = !0, t;
@@ -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, M([n, t], L(e)));
328
+ return setTimeout.apply(void 0, R([n, t], L(e)));
329
329
  },
330
330
  clearTimeout: function(n) {
331
331
  var t = he.delegate;
@@ -340,7 +340,7 @@ function ye(n) {
340
340
  }
341
341
  function q() {
342
342
  }
343
- function N(n) {
343
+ function U(n) {
344
344
  n();
345
345
  }
346
346
  var X = function(n) {
@@ -450,7 +450,7 @@ var S = function() {
450
450
  return e.source = this, e.operator = t, e;
451
451
  }, n.prototype.subscribe = function(t, e, r) {
452
452
  var i = this, o = We(t) ? t : new W(t, e, r);
453
- return N(function() {
453
+ return U(function() {
454
454
  var s = i, c = s.operator, a = s.source;
455
455
  o.add(c ? c.call(o, a) : a ? i._subscribe(o) : i._trySubscribe(o));
456
456
  }), o;
@@ -583,12 +583,12 @@ var Xe = function(n) {
583
583
  throw new ze();
584
584
  }, t.prototype.next = function(e) {
585
585
  var r = this;
586
- N(function() {
586
+ U(function() {
587
587
  var i, o;
588
588
  if (r._throwIfClosed(), !r.isStopped) {
589
589
  r.currentObservers || (r.currentObservers = Array.from(r.observers));
590
590
  try {
591
- for (var s = R(r.currentObservers), c = s.next(); !c.done; c = s.next()) {
591
+ for (var s = M(r.currentObservers), c = s.next(); !c.done; c = s.next()) {
592
592
  var a = c.value;
593
593
  a.next(e);
594
594
  }
@@ -605,7 +605,7 @@ var Xe = function(n) {
605
605
  });
606
606
  }, t.prototype.error = function(e) {
607
607
  var r = this;
608
- N(function() {
608
+ U(function() {
609
609
  if (r._throwIfClosed(), !r.isStopped) {
610
610
  r.hasError = r.isStopped = !0, r.thrownError = e;
611
611
  for (var i = r.observers; i.length; )
@@ -614,7 +614,7 @@ var Xe = function(n) {
614
614
  });
615
615
  }, t.prototype.complete = function() {
616
616
  var e = this;
617
- N(function() {
617
+ U(function() {
618
618
  if (e._throwIfClosed(), !e.isStopped) {
619
619
  e.isStopped = !0;
620
620
  for (var r = e.observers; r.length; )
@@ -637,7 +637,7 @@ var Xe = function(n) {
637
637
  }, t.prototype._innerSubscribe = function(e) {
638
638
  var r = this, i = this, o = i.hasError, s = i.isStopped, c = i.observers;
639
639
  return o || s ? le : (this.currentObservers = null, c.push(e), new k(function() {
640
- r.currentObservers = null, U(c, e);
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;
@@ -707,7 +707,7 @@ var Xe = function(n) {
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, M([n, t], L(e)));
710
+ return setInterval.apply(void 0, R([n, t], L(e)));
711
711
  },
712
712
  clearInterval: function(n) {
713
713
  return clearInterval(n);
@@ -752,7 +752,7 @@ var Xe = function(n) {
752
752
  }, t.prototype.unsubscribe = function() {
753
753
  if (!this.closed) {
754
754
  var e = this, r = e.id, i = e.scheduler, o = i.actions;
755
- this.work = this.state = this.scheduler = null, this.pending = !1, U(o, this), r != null && (this.id = this.recycleAsyncId(i, r, null)), this.delay = null, n.prototype.unsubscribe.call(this);
755
+ this.work = this.state = this.scheduler = null, this.pending = !1, N(o, this), r != null && (this.id = this.recycleAsyncId(i, r, null)), this.delay = null, n.prototype.unsubscribe.call(this);
756
756
  }
757
757
  }, t;
758
758
  }(Ze), oe = function() {
@@ -834,13 +834,13 @@ function xe(n) {
834
834
  case 1:
835
835
  s.trys.push([1, , 9, 10]), s.label = 2;
836
836
  case 2:
837
- return [4, C(e.read())];
837
+ return [4, P(e.read())];
838
838
  case 3:
839
- return r = s.sent(), i = r.value, o = r.done, o ? [4, C(void 0)] : [3, 5];
839
+ return r = s.sent(), i = r.value, o = r.done, o ? [4, P(void 0)] : [3, 5];
840
840
  case 4:
841
841
  return [2, s.sent()];
842
842
  case 5:
843
- return [4, C(i)];
843
+ return [4, P(i)];
844
844
  case 6:
845
845
  return [4, s.sent()];
846
846
  case 7:
@@ -905,7 +905,7 @@ function ct(n) {
905
905
  return new S(function(t) {
906
906
  var e, r;
907
907
  try {
908
- for (var i = R(n), o = i.next(); !o.done; o = i.next()) {
908
+ for (var i = M(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;
@@ -978,7 +978,7 @@ function A(n, t, e, r, i) {
978
978
  if (n.add(o), !i)
979
979
  return o;
980
980
  }
981
- function Pe(n, t) {
981
+ function Ce(n, t) {
982
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() {
@@ -995,7 +995,7 @@ function Pe(n, t) {
995
995
  }));
996
996
  });
997
997
  }
998
- function Ce(n, t) {
998
+ function Pe(n, t) {
999
999
  return t === void 0 && (t = 0), T(function(e, r) {
1000
1000
  r.add(n.schedule(function() {
1001
1001
  return e.subscribe(r);
@@ -1003,10 +1003,10 @@ function Ce(n, t) {
1003
1003
  });
1004
1004
  }
1005
1005
  function dt(n, t) {
1006
- return x(n).pipe(Ce(t), Pe(t));
1006
+ return x(n).pipe(Pe(t), Ce(t));
1007
1007
  }
1008
1008
  function ht(n, t) {
1009
- return x(n).pipe(Ce(t), Pe(t));
1009
+ return x(n).pipe(Pe(t), Ce(t));
1010
1010
  }
1011
1011
  function yt(n, t) {
1012
1012
  return new S(function(e) {
@@ -1035,7 +1035,7 @@ function vt(n, t) {
1035
1035
  };
1036
1036
  });
1037
1037
  }
1038
- function Re(n, t) {
1038
+ function Me(n, t) {
1039
1039
  if (!n)
1040
1040
  throw new Error("Iterable cannot be null");
1041
1041
  return new S(function(e) {
@@ -1050,7 +1050,7 @@ function Re(n, t) {
1050
1050
  });
1051
1051
  }
1052
1052
  function pt(n, t) {
1053
- return Re(xe(n), t);
1053
+ return Me(xe(n), t);
1054
1054
  }
1055
1055
  function bt(n, t) {
1056
1056
  if (n != null) {
@@ -1061,7 +1061,7 @@ function bt(n, t) {
1061
1061
  if (ge(n))
1062
1062
  return ht(n, t);
1063
1063
  if (Ee(n))
1064
- return Re(n, t);
1064
+ return Me(n, t);
1065
1065
  if (Ae(n))
1066
1066
  return vt(n, t);
1067
1067
  if (_e(n))
@@ -1091,7 +1091,7 @@ function F(n, t) {
1091
1091
  }
1092
1092
  var gt = Array.isArray;
1093
1093
  function wt(n, t) {
1094
- return gt(t) ? n.apply(void 0, M([], L(t))) : n(t);
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) {
@@ -1119,29 +1119,29 @@ function _t(n) {
1119
1119
  function Tt(n) {
1120
1120
  return n && typeof n == "object" && It(n) === At;
1121
1121
  }
1122
- function Pt(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
  }, {});
1126
1126
  }
1127
- function Ct() {
1127
+ function Pt() {
1128
1128
  for (var n = [], t = 0; t < arguments.length; t++)
1129
1129
  n[t] = arguments[t];
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 S(Rt(o, e, s ? function(a) {
1134
- return Pt(s, a);
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
  }
1138
- function Rt(n, t, e) {
1138
+ function Mt(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 d = Z(n[f], t), b = !1;
1144
- d.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();
@@ -1156,14 +1156,14 @@ function se(n, t, e) {
1156
1156
  n ? A(e, n, t) : t();
1157
1157
  }
1158
1158
  function Lt(n, t, e, r, i, o, s, c) {
1159
- var a = [], u = 0, f = 0, d = !1, b = function() {
1160
- d && !a.length && !u && t.complete();
1161
- }, l = function(h) {
1162
- return u < r ? v(h) : a.push(h);
1163
- }, v = function(h) {
1159
+ var a = [], u = 0, f = 0, y = !1, b = function() {
1160
+ y && !a.length && !u && t.complete();
1161
+ }, l = function(d) {
1162
+ return u < r ? v(d) : a.push(d);
1163
+ }, v = function(d) {
1164
1164
  u++;
1165
1165
  var g = !1;
1166
- x(e(h, f++)).subscribe(E(t, function(w) {
1166
+ x(e(d, f++)).subscribe(E(t, function(w) {
1167
1167
  t.next(w);
1168
1168
  }, function() {
1169
1169
  g = !0;
@@ -1183,7 +1183,7 @@ function Lt(n, t, e, r, i, o, s, c) {
1183
1183
  }));
1184
1184
  };
1185
1185
  return n.subscribe(E(t, l, function() {
1186
- d = !0, b();
1186
+ y = !0, b();
1187
1187
  })), function() {
1188
1188
  };
1189
1189
  }
@@ -1208,7 +1208,7 @@ function Le(n, t, e) {
1208
1208
  }, o);
1209
1209
  });
1210
1210
  }
1211
- function Mt(n, t) {
1211
+ function Rt(n, t) {
1212
1212
  return p(t) ? $(n, t, 1) : $(n, 1);
1213
1213
  }
1214
1214
  function kt(n) {
@@ -1231,43 +1231,43 @@ function Dt(n, t) {
1231
1231
  return x(n(e, r)).pipe(kt(1), jt(e));
1232
1232
  });
1233
1233
  }
1234
- function Nt(n, t) {
1234
+ function Ut(n, t) {
1235
1235
  t === void 0 && (t = ve);
1236
1236
  var e = Le(n, t);
1237
1237
  return Dt(function() {
1238
1238
  return e;
1239
1239
  });
1240
1240
  }
1241
- function Ut(n) {
1241
+ function Nt(n) {
1242
1242
  var t;
1243
1243
  t = {
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
1247
  return r <= 0 ? G : T(function(c, a) {
1248
- var u = 0, f, d = function() {
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
1254
  var v = function() {
1255
- f ? (f.unsubscribe(), f = null, d()) : b = !0;
1255
+ f ? (f.unsubscribe(), f = null, y()) : b = !0;
1256
1256
  };
1257
1257
  if (i != null) {
1258
- var h = typeof i == "number" ? Le(i) : x(i(l, u)), g = E(a, function() {
1258
+ var d = typeof i == "number" ? Le(i) : x(i(l, u)), g = E(a, function() {
1259
1259
  g.unsubscribe(), v();
1260
1260
  }, function() {
1261
1261
  a.complete();
1262
1262
  });
1263
- h.subscribe(g);
1263
+ d.subscribe(g);
1264
1264
  } else
1265
1265
  v();
1266
1266
  } else
1267
1267
  a.error(l);
1268
- })), b && (f.unsubscribe(), f = null, d());
1268
+ })), b && (f.unsubscribe(), f = null, y());
1269
1269
  };
1270
- d();
1270
+ y();
1271
1271
  });
1272
1272
  }
1273
1273
  function $t(n) {
@@ -1330,8 +1330,8 @@ function Ht(n, t, e) {
1330
1330
  n(r.id = f);
1331
1331
  break;
1332
1332
  case "retry":
1333
- const d = parseInt(f, 10);
1334
- isNaN(d) || t(r.retry = d);
1333
+ const y = parseInt(f, 10);
1334
+ isNaN(y) || t(r.retry = y);
1335
1335
  break;
1336
1336
  }
1337
1337
  }
@@ -1360,20 +1360,20 @@ 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((d, b) => {
1363
+ return new Promise((y, b) => {
1364
1364
  const l = Object.assign({}, r);
1365
1365
  l.accept || (l.accept = J);
1366
1366
  let v;
1367
- function h() {
1367
+ function d() {
1368
1368
  v.abort(), document.hidden || H();
1369
1369
  }
1370
- a || document.addEventListener("visibilitychange", h);
1370
+ a || document.addEventListener("visibilitychange", d);
1371
1371
  let g = Kt, w = 0;
1372
1372
  function _() {
1373
- document.removeEventListener("visibilitychange", h), window.clearTimeout(w), v.abort();
1373
+ document.removeEventListener("visibilitychange", d), window.clearTimeout(w), v.abort();
1374
1374
  }
1375
1375
  e == null || e.addEventListener("abort", () => {
1376
- _(), d();
1376
+ _(), y();
1377
1377
  });
1378
1378
  const ke = u ?? window.fetch, je = i ?? qt;
1379
1379
  async function H() {
@@ -1385,7 +1385,7 @@ function Yt(n, t) {
1385
1385
  I ? l[ae] = I : delete l[ae];
1386
1386
  }, (I) => {
1387
1387
  g = I;
1388
- }, o))), s == null || s(), _(), d();
1388
+ }, o))), s == null || s(), _(), y();
1389
1389
  } catch (j) {
1390
1390
  if (!v.signal.aborted)
1391
1391
  try {
@@ -1425,24 +1425,7 @@ function Wt(n) {
1425
1425
  */
1426
1426
  openWhenHidden: !0,
1427
1427
  onopen: async (f) => {
1428
- if (!f.ok) {
1429
- let d;
1430
- try {
1431
- const l = await f.text();
1432
- d = JSON.parse(l);
1433
- } catch {
1434
- d = { message: `HTTP ${f.status}: ${f.statusText}` };
1435
- }
1436
- const b = {
1437
- response: f,
1438
- status: f.status,
1439
- statusText: f.statusText,
1440
- errorDetail: d,
1441
- isAuthError: f.status === 401,
1442
- isBotProviderError: f.status === 400 && ((d == null ? void 0 : d.code) === "BOT_PROVIDER_DISABLED" || (d == null ? void 0 : d.code) === "BOT_PROVIDER_NOT_FOUND")
1443
- };
1444
- o.error(b), s.abort();
1445
- }
1428
+ f.ok || (o.error(f), s.abort());
1446
1429
  },
1447
1430
  onmessage: (f) => {
1448
1431
  o.next(JSON.parse(f.data));
@@ -1501,43 +1484,43 @@ class zt {
1501
1484
  }
1502
1485
  handleEvent(t) {
1503
1486
  switch (t.eventType) {
1504
- case y.INIT:
1487
+ case h.INIT:
1505
1488
  this.sseEmitter.emit(
1506
- y.INIT,
1489
+ h.INIT,
1507
1490
  t
1508
1491
  );
1509
1492
  break;
1510
- case y.PROCESS_START:
1511
- case y.PROCESS_COMPLETE:
1493
+ case h.PROCESS_START:
1494
+ case h.PROCESS_COMPLETE:
1512
1495
  this.sseEmitter.emit(
1513
- y.PROCESS,
1496
+ h.PROCESS,
1514
1497
  t
1515
1498
  );
1516
1499
  break;
1517
- case y.MESSAGE_START:
1518
- case y.MESSAGE_DELTA:
1519
- case y.MESSAGE_COMPLETE:
1500
+ case h.MESSAGE_START:
1501
+ case h.MESSAGE_DELTA:
1502
+ case h.MESSAGE_COMPLETE:
1520
1503
  this.sseEmitter.emit(
1521
- y.MESSAGE,
1504
+ h.MESSAGE,
1522
1505
  t
1523
1506
  );
1524
1507
  break;
1525
- case y.TOOL_CALL_START:
1526
- case y.TOOL_CALL_COMPLETE:
1508
+ case h.TOOL_CALL_START:
1509
+ case h.TOOL_CALL_COMPLETE:
1527
1510
  this.sseEmitter.emit(
1528
- y.TOOL_CALL,
1511
+ h.TOOL_CALL,
1529
1512
  t
1530
1513
  );
1531
1514
  break;
1532
- case y.DONE:
1515
+ case h.DONE:
1533
1516
  this.sseEmitter.emit(
1534
- y.DONE,
1517
+ h.DONE,
1535
1518
  t
1536
1519
  );
1537
1520
  break;
1538
- case y.ERROR:
1521
+ case h.ERROR:
1539
1522
  this.sseEmitter.emit(
1540
- y.ERROR,
1523
+ h.ERROR,
1541
1524
  t
1542
1525
  );
1543
1526
  break;
@@ -1551,9 +1534,9 @@ class zt {
1551
1534
  debugMode: this.debugMode,
1552
1535
  payload: ((i = this.transformSsePayload) == null ? void 0 : i.call(this, t)) ?? t
1553
1536
  }).pipe(
1554
- Mt((o) => mt(o).pipe(Nt((e == null ? void 0 : e.delayTime) ?? 50))),
1537
+ Rt((o) => mt(o).pipe(Ut((e == null ? void 0 : e.delayTime) ?? 50))),
1555
1538
  $t(this.destroy$),
1556
- Ut(3)
1539
+ Nt(3)
1557
1540
  ).subscribe({
1558
1541
  next: (o) => {
1559
1542
  var s;
@@ -1573,7 +1556,7 @@ class zt {
1573
1556
  this.destroy$.next(), this.destroy$.complete();
1574
1557
  }
1575
1558
  }
1576
- class Me {
1559
+ class Re {
1577
1560
  constructor(t) {
1578
1561
  m(this, "client");
1579
1562
  m(this, "customChannelId");
@@ -1589,7 +1572,7 @@ class Me {
1589
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;
1590
1573
  }
1591
1574
  static async reset(t, e, r) {
1592
- const i = new Me(t);
1575
+ const i = new Re(t);
1593
1576
  try {
1594
1577
  return i.subscribe(), await i.resetChannel(e, r), i;
1595
1578
  } catch (o) {
@@ -1597,7 +1580,7 @@ class Me {
1597
1580
  }
1598
1581
  }
1599
1582
  subscribe() {
1600
- this.statesSubscription = Ct([
1583
+ this.statesSubscription = Pt([
1601
1584
  this.isConnecting$,
1602
1585
  this.conversation$
1603
1586
  ]).pipe(
@@ -1663,30 +1646,30 @@ class Me {
1663
1646
  this.isConnecting$.complete(), this.conversation$.complete(), (t = this.statesSubscription) == null || t.unsubscribe();
1664
1647
  }
1665
1648
  }
1666
- class P {
1649
+ class C {
1667
1650
  constructor({ messages: t }) {
1668
1651
  m(this, "messages", null);
1669
1652
  this.messages = t;
1670
1653
  }
1671
1654
  pushMessage(t) {
1672
1655
  const e = new Map(this.messages);
1673
- return e.set(t.messageId, t), new P({ messages: e });
1656
+ return e.set(t.messageId, t), new C({ messages: e });
1674
1657
  }
1675
1658
  onMessage(t) {
1676
1659
  switch (t.eventType) {
1677
- case y.MESSAGE_START:
1660
+ case h.MESSAGE_START:
1678
1661
  return this.onMessageStart(
1679
1662
  t
1680
1663
  );
1681
- case y.MESSAGE_DELTA:
1664
+ case h.MESSAGE_DELTA:
1682
1665
  return this.onMessageDelta(
1683
1666
  t
1684
1667
  );
1685
- case y.MESSAGE_COMPLETE:
1668
+ case h.MESSAGE_COMPLETE:
1686
1669
  return this.onMessageComplete(
1687
1670
  t
1688
1671
  );
1689
- case y.ERROR:
1672
+ case h.ERROR:
1690
1673
  return this.onMessageError(t);
1691
1674
  default:
1692
1675
  return this;
@@ -1696,13 +1679,13 @@ class P {
1696
1679
  const e = t.fact.messageStart.message, r = new Map(this.messages);
1697
1680
  return r.set(e.messageId, {
1698
1681
  type: "bot",
1699
- eventType: y.MESSAGE_START,
1682
+ eventType: h.MESSAGE_START,
1700
1683
  isTyping: !0,
1701
1684
  typingText: "",
1702
1685
  messageId: e.messageId,
1703
1686
  message: e,
1704
1687
  time: /* @__PURE__ */ new Date()
1705
- }), new P({ messages: r });
1688
+ }), new C({ messages: r });
1706
1689
  }
1707
1690
  onMessageDelta(t) {
1708
1691
  const e = t.fact.messageDelta.message, r = new Map(this.messages), i = r.get(e.messageId);
@@ -1710,43 +1693,43 @@ class P {
1710
1693
  const o = `${(i == null ? void 0 : i.typingText) ?? ""}${e.text}`;
1711
1694
  return r.set(e.messageId, {
1712
1695
  type: "bot",
1713
- eventType: y.MESSAGE_DELTA,
1696
+ eventType: h.MESSAGE_DELTA,
1714
1697
  isTyping: !0,
1715
1698
  typingText: o,
1716
1699
  messageId: e.messageId,
1717
1700
  message: e,
1718
1701
  time: /* @__PURE__ */ new Date()
1719
- }), new P({ messages: r });
1702
+ }), new C({ messages: r });
1720
1703
  }
1721
1704
  onMessageComplete(t) {
1722
1705
  const e = t.fact.messageComplete.message, r = new Map(this.messages);
1723
1706
  return r.set(e.messageId, {
1724
1707
  type: "bot",
1725
- eventType: y.MESSAGE_COMPLETE,
1708
+ eventType: h.MESSAGE_COMPLETE,
1726
1709
  isTyping: !1,
1727
1710
  typingText: null,
1728
1711
  messageId: e.messageId,
1729
1712
  message: e,
1730
1713
  time: /* @__PURE__ */ new Date()
1731
- }), new P({ messages: r });
1714
+ }), new C({ messages: r });
1732
1715
  }
1733
1716
  onMessageError(t) {
1734
1717
  const e = crypto.randomUUID(), r = t.fact.runError.error, i = new Map(this.messages);
1735
1718
  return i.set(e, {
1736
1719
  type: "error",
1737
- eventType: y.ERROR,
1720
+ eventType: h.ERROR,
1738
1721
  messageId: e,
1739
1722
  error: r,
1740
1723
  time: /* @__PURE__ */ new Date()
1741
- }), new P({ messages: i });
1724
+ }), new C({ messages: i });
1742
1725
  }
1743
1726
  }
1744
1727
  export {
1745
1728
  zt as AsgardServiceClient,
1746
- Me as Channel,
1747
- P as Conversation,
1748
- y as EventType,
1729
+ Re as Channel,
1730
+ C as Conversation,
1731
+ h as EventType,
1749
1732
  K as FetchSseAction,
1750
- Ue as MessageTemplateType
1733
+ Ne as MessageTemplateType
1751
1734
  };
1752
1735
  //# sourceMappingURL=index.mjs.map