@asgard-js/core 0.2.27 → 0.2.28

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,4 +1,15 @@
1
- var B = /* @__PURE__ */ ((r) => (r.RESET_CHANNEL = "RESET_CHANNEL", r.NONE = "NONE", r))(B || {}), 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 || {}), De = /* @__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))(De || {}), Y = function(r, e) {
1
+ class de extends Error {
2
+ status;
3
+ statusText;
4
+ body;
5
+ constructor(e, t, n) {
6
+ super(`HTTP ${e}: ${t}`), this.name = "HttpError", this.status = e, this.statusText = t, this.body = n;
7
+ }
8
+ }
9
+ function nr(r) {
10
+ return r instanceof de;
11
+ }
12
+ var B = /* @__PURE__ */ ((r) => (r.RESET_CHANNEL = "RESET_CHANNEL", r.NONE = "NONE", r))(B || {}), h = /* @__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))(h || {}), Ne = /* @__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))(Ne || {}), Y = function(r, e) {
2
13
  return Y = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, n) {
3
14
  t.__proto__ = n;
4
15
  } || function(t, n) {
@@ -14,7 +25,7 @@ function O(r, e) {
14
25
  }
15
26
  r.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
16
27
  }
17
- function Ne(r, e, t, n) {
28
+ function He(r, e, t, n) {
18
29
  function o(i) {
19
30
  return i instanceof t ? i : new t(function(s) {
20
31
  s(i);
@@ -24,15 +35,15 @@ function Ne(r, e, t, n) {
24
35
  function a(f) {
25
36
  try {
26
37
  u(n.next(f));
27
- } catch (h) {
28
- s(h);
38
+ } catch (v) {
39
+ s(v);
29
40
  }
30
41
  }
31
42
  function c(f) {
32
43
  try {
33
44
  u(n.throw(f));
34
- } catch (h) {
35
- s(h);
45
+ } catch (v) {
46
+ s(v);
36
47
  }
37
48
  }
38
49
  function u(f) {
@@ -41,7 +52,7 @@ function Ne(r, e, t, n) {
41
52
  u((n = n.apply(r, e || [])).next());
42
53
  });
43
54
  }
44
- function de(r, e) {
55
+ function he(r, e) {
45
56
  var t = { label: 0, sent: function() {
46
57
  if (i[0] & 1) throw i[1];
47
58
  return i[1];
@@ -144,7 +155,7 @@ function Ge(r, e, t) {
144
155
  }, o;
145
156
  function s(l) {
146
157
  return function(y) {
147
- return Promise.resolve(y).then(l, h);
158
+ return Promise.resolve(y).then(l, v);
148
159
  };
149
160
  }
150
161
  function a(l, y) {
@@ -158,23 +169,23 @@ function Ge(r, e, t) {
158
169
  try {
159
170
  u(n[l](y));
160
171
  } catch (p) {
161
- v(i[0][3], p);
172
+ d(i[0][3], p);
162
173
  }
163
174
  }
164
175
  function u(l) {
165
- l.value instanceof P ? Promise.resolve(l.value.v).then(f, h) : v(i[0][2], l);
176
+ l.value instanceof P ? Promise.resolve(l.value.v).then(f, v) : d(i[0][2], l);
166
177
  }
167
178
  function f(l) {
168
179
  c("next", l);
169
180
  }
170
- function h(l) {
181
+ function v(l) {
171
182
  c("throw", l);
172
183
  }
173
- function v(l, y) {
184
+ function d(l, y) {
174
185
  l(y), i.shift(), i.length && c(i[0][0], i[0][1]);
175
186
  }
176
187
  }
177
- function He(r) {
188
+ function Fe(r) {
178
189
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
179
190
  var e = r[Symbol.asyncIterator], t;
180
191
  return e ? e.call(r) : (r = typeof M == "function" ? M(r) : r[Symbol.iterator](), t = {}, n("next"), n("throw"), n("return"), t[Symbol.asyncIterator] = function() {
@@ -196,13 +207,13 @@ function He(r) {
196
207
  function m(r) {
197
208
  return typeof r == "function";
198
209
  }
199
- function he(r) {
210
+ function ve(r) {
200
211
  var e = function(n) {
201
212
  Error.call(n), n.stack = new Error().stack;
202
213
  }, t = r(e);
203
214
  return t.prototype = Object.create(Error.prototype), t.prototype.constructor = t, t;
204
215
  }
205
- var q = he(function(r) {
216
+ var q = ve(function(r) {
206
217
  return function(t) {
207
218
  r(this), this.message = t ? t.length + ` errors occurred during unsubscription:
208
219
  ` + t.map(function(n, o) {
@@ -251,11 +262,11 @@ var U = (function() {
251
262
  } catch (p) {
252
263
  i = p instanceof q ? p.errors : [p];
253
264
  }
254
- var h = this._finalizers;
255
- if (h) {
265
+ var v = this._finalizers;
266
+ if (v) {
256
267
  this._finalizers = null;
257
268
  try {
258
- for (var v = M(h), l = v.next(); !l.done; l = v.next()) {
269
+ for (var d = M(v), l = d.next(); !l.done; l = d.next()) {
259
270
  var y = l.value;
260
271
  try {
261
272
  re(y);
@@ -267,7 +278,7 @@ var U = (function() {
267
278
  n = { error: p };
268
279
  } finally {
269
280
  try {
270
- l && !l.done && (o = v.return) && o.call(v);
281
+ l && !l.done && (o = d.return) && o.call(d);
271
282
  } finally {
272
283
  if (n) throw n.error;
273
284
  }
@@ -305,16 +316,16 @@ var U = (function() {
305
316
  var e = new r();
306
317
  return e.closed = !0, e;
307
318
  })(), r;
308
- })(), ve = U.EMPTY;
309
- function pe(r) {
319
+ })(), pe = U.EMPTY;
320
+ function ye(r) {
310
321
  return r instanceof U || r && "closed" in r && m(r.remove) && m(r.add) && m(r.unsubscribe);
311
322
  }
312
323
  function re(r) {
313
324
  m(r) ? r() : r.unsubscribe();
314
325
  }
315
- var Fe = {
326
+ var Ve = {
316
327
  Promise: void 0
317
- }, Ve = {
328
+ }, qe = {
318
329
  setTimeout: function(r, e) {
319
330
  for (var t = [], n = 2; n < arguments.length; n++)
320
331
  t[n - 2] = arguments[n];
@@ -325,8 +336,8 @@ var Fe = {
325
336
  },
326
337
  delegate: void 0
327
338
  };
328
- function ye(r) {
329
- Ve.setTimeout(function() {
339
+ function me(r) {
340
+ qe.setTimeout(function() {
330
341
  throw r;
331
342
  });
332
343
  }
@@ -339,7 +350,7 @@ var Q = (function(r) {
339
350
  O(e, r);
340
351
  function e(t) {
341
352
  var n = r.call(this) || this;
342
- return n.isStopped = !1, t ? (n.destination = t, pe(t) && t.add(n)) : n.destination = Be, n;
353
+ return n.isStopped = !1, t ? (n.destination = t, ye(t) && t.add(n)) : n.destination = Ye, n;
343
354
  }
344
355
  return e.create = function(t, n, o) {
345
356
  return new X(t, n, o);
@@ -366,7 +377,7 @@ var Q = (function(r) {
366
377
  this.unsubscribe();
367
378
  }
368
379
  }, e;
369
- })(U), qe = (function() {
380
+ })(U), Ke = (function() {
370
381
  function r(e) {
371
382
  this.partialObserver = e;
372
383
  }
@@ -405,29 +416,29 @@ var Q = (function(r) {
405
416
  next: t ?? void 0,
406
417
  error: n ?? void 0,
407
418
  complete: o ?? void 0
408
- } : s = t, i.destination = new qe(s), i;
419
+ } : s = t, i.destination = new Ke(s), i;
409
420
  }
410
421
  return e;
411
422
  })(Q);
412
423
  function $(r) {
413
- ye(r);
424
+ me(r);
414
425
  }
415
- function Ke(r) {
426
+ function Be(r) {
416
427
  throw r;
417
428
  }
418
- var Be = {
429
+ var Ye = {
419
430
  closed: !0,
420
431
  next: W,
421
- error: Ke,
432
+ error: Be,
422
433
  complete: W
423
434
  }, Z = (function() {
424
435
  return typeof Symbol == "function" && Symbol.observable || "@@observable";
425
436
  })();
426
- function G(r) {
437
+ function H(r) {
427
438
  return r;
428
439
  }
429
- function Ye(r) {
430
- return r.length === 0 ? G : r.length === 1 ? r[0] : function(t) {
440
+ function We(r) {
441
+ return r.length === 0 ? H : r.length === 1 ? r[0] : function(t) {
431
442
  return r.reduce(function(n, o) {
432
443
  return o(n);
433
444
  }, t);
@@ -441,7 +452,7 @@ var g = (function() {
441
452
  var t = new r();
442
453
  return t.source = this, t.operator = e, t;
443
454
  }, r.prototype.subscribe = function(e, t, n) {
444
- var o = this, i = Xe(e) ? e : new X(e, t, n);
455
+ var o = this, i = Je(e) ? e : new X(e, t, n);
445
456
  return j(function() {
446
457
  var s = o, a = s.operator, c = s.source;
447
458
  i.add(a ? a.call(i, c) : c ? o._subscribe(i) : o._trySubscribe(i));
@@ -476,7 +487,7 @@ var g = (function() {
476
487
  }, r.prototype.pipe = function() {
477
488
  for (var e = [], t = 0; t < arguments.length; t++)
478
489
  e[t] = arguments[t];
479
- return Ye(e)(this);
490
+ return We(e)(this);
480
491
  }, r.prototype.toPromise = function(e) {
481
492
  var t = this;
482
493
  return e = ne(e), new e(function(n, o) {
@@ -495,20 +506,20 @@ var g = (function() {
495
506
  })();
496
507
  function ne(r) {
497
508
  var e;
498
- return (e = r ?? Fe.Promise) !== null && e !== void 0 ? e : Promise;
499
- }
500
- function We(r) {
501
- return r && m(r.next) && m(r.error) && m(r.complete);
509
+ return (e = r ?? Ve.Promise) !== null && e !== void 0 ? e : Promise;
502
510
  }
503
511
  function Xe(r) {
504
- return r && r instanceof Q || We(r) && pe(r);
512
+ return r && m(r.next) && m(r.error) && m(r.complete);
505
513
  }
506
514
  function Je(r) {
515
+ return r && r instanceof Q || Xe(r) && ye(r);
516
+ }
517
+ function ze(r) {
507
518
  return m(r?.lift);
508
519
  }
509
520
  function _(r) {
510
521
  return function(e) {
511
- if (Je(e))
522
+ if (ze(e))
512
523
  return e.lift(function(t) {
513
524
  try {
514
525
  return r(t, this);
@@ -520,9 +531,9 @@ function _(r) {
520
531
  };
521
532
  }
522
533
  function I(r, e, t, n, o) {
523
- return new ze(r, e, t, n, o);
534
+ return new Qe(r, e, t, n, o);
524
535
  }
525
- var ze = (function(r) {
536
+ var Qe = (function(r) {
526
537
  O(e, r);
527
538
  function e(t, n, o, i, s, a) {
528
539
  var c = r.call(this, t) || this;
@@ -557,7 +568,7 @@ var ze = (function(r) {
557
568
  r.prototype.unsubscribe.call(this), !n && ((t = this.onFinalize) === null || t === void 0 || t.call(this));
558
569
  }
559
570
  }, e;
560
- })(Q), Qe = he(function(r) {
571
+ })(Q), Ze = ve(function(r) {
561
572
  return function() {
562
573
  r(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
563
574
  };
@@ -572,7 +583,7 @@ var ze = (function(r) {
572
583
  return n.operator = t, n;
573
584
  }, e.prototype._throwIfClosed = function() {
574
585
  if (this.closed)
575
- throw new Qe();
586
+ throw new Ze();
576
587
  }, e.prototype.next = function(t) {
577
588
  var n = this;
578
589
  j(function() {
@@ -628,7 +639,7 @@ var ze = (function(r) {
628
639
  return this._throwIfClosed(), this._checkFinalizedStatuses(t), this._innerSubscribe(t);
629
640
  }, e.prototype._innerSubscribe = function(t) {
630
641
  var n = this, o = this, i = o.hasError, s = o.isStopped, a = o.observers;
631
- return i || s ? ve : (this.currentObservers = null, a.push(t), new U(function() {
642
+ return i || s ? pe : (this.currentObservers = null, a.push(t), new U(function() {
632
643
  n.currentObservers = null, D(a, t);
633
644
  }));
634
645
  }, e.prototype._checkFinalizedStatuses = function(t) {
@@ -657,7 +668,7 @@ var ze = (function(r) {
657
668
  (n = (t = this.destination) === null || t === void 0 ? void 0 : t.complete) === null || n === void 0 || n.call(t);
658
669
  }, e.prototype._subscribe = function(t) {
659
670
  var n, o;
660
- return (o = (n = this.source) === null || n === void 0 ? void 0 : n.subscribe(t)) !== null && o !== void 0 ? o : ve;
671
+ return (o = (n = this.source) === null || n === void 0 ? void 0 : n.subscribe(t)) !== null && o !== void 0 ? o : pe;
661
672
  }, e;
662
673
  })(ee), ie = (function(r) {
663
674
  O(e, r);
@@ -682,11 +693,11 @@ var ze = (function(r) {
682
693
  }, e.prototype.next = function(t) {
683
694
  r.prototype.next.call(this, this._value = t);
684
695
  }, e;
685
- })(ee), Ze = {
696
+ })(ee), et = {
686
697
  now: function() {
687
698
  return Date.now();
688
699
  }
689
- }, et = (function(r) {
700
+ }, tt = (function(r) {
690
701
  O(e, r);
691
702
  function e(t, n) {
692
703
  return r.call(this) || this;
@@ -704,7 +715,7 @@ var ze = (function(r) {
704
715
  return clearInterval(r);
705
716
  },
706
717
  delegate: void 0
707
- }, tt = (function(r) {
718
+ }, rt = (function(r) {
708
719
  O(e, r);
709
720
  function e(t, n) {
710
721
  var o = r.call(this, t, n) || this;
@@ -746,14 +757,14 @@ var ze = (function(r) {
746
757
  this.work = this.state = this.scheduler = null, this.pending = !1, D(i, this), n != null && (this.id = this.recycleAsyncId(o, n, null)), this.delay = null, r.prototype.unsubscribe.call(this);
747
758
  }
748
759
  }, e;
749
- })(et), ae = (function() {
760
+ })(tt), ae = (function() {
750
761
  function r(e, t) {
751
762
  t === void 0 && (t = r.now), this.schedulerActionCtor = e, this.now = t;
752
763
  }
753
764
  return r.prototype.schedule = function(e, t, n) {
754
765
  return t === void 0 && (t = 0), new this.schedulerActionCtor(this, e).schedule(n, t);
755
- }, r.now = Ze.now, r;
756
- })(), rt = (function(r) {
766
+ }, r.now = et.now, r;
767
+ })(), nt = (function(r) {
757
768
  O(e, r);
758
769
  function e(t, n) {
759
770
  n === void 0 && (n = ae.now);
@@ -778,47 +789,47 @@ var ze = (function(r) {
778
789
  throw o;
779
790
  }
780
791
  }, e;
781
- })(ae), me = new rt(tt), nt = me, ot = new g(function(r) {
792
+ })(ae), be = new nt(rt), ot = be, it = new g(function(r) {
782
793
  return r.complete();
783
794
  });
784
- function be(r) {
795
+ function ge(r) {
785
796
  return r && m(r.schedule);
786
797
  }
787
- function ge(r) {
798
+ function Se(r) {
788
799
  return r[r.length - 1];
789
800
  }
790
- function it(r) {
791
- return m(ge(r)) ? r.pop() : void 0;
801
+ function st(r) {
802
+ return m(Se(r)) ? r.pop() : void 0;
792
803
  }
793
- function Se(r) {
794
- return be(ge(r)) ? r.pop() : void 0;
804
+ function we(r) {
805
+ return ge(Se(r)) ? r.pop() : void 0;
795
806
  }
796
- var we = (function(r) {
807
+ var Ee = (function(r) {
797
808
  return r && typeof r.length == "number" && typeof r != "function";
798
809
  });
799
- function Ee(r) {
810
+ function Ie(r) {
800
811
  return m(r?.then);
801
812
  }
802
- function Ie(r) {
813
+ function Oe(r) {
803
814
  return m(r[Z]);
804
815
  }
805
- function Oe(r) {
816
+ function Ae(r) {
806
817
  return Symbol.asyncIterator && m(r?.[Symbol.asyncIterator]);
807
818
  }
808
- function Ae(r) {
819
+ function xe(r) {
809
820
  return new TypeError("You provided " + (r !== null && typeof r == "object" ? "an invalid object" : "'" + r + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
810
821
  }
811
- function st() {
822
+ function at() {
812
823
  return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
813
824
  }
814
- var Ce = st();
815
- function xe(r) {
825
+ var Ce = at();
826
+ function Te(r) {
816
827
  return m(r?.[Ce]);
817
828
  }
818
- function Te(r) {
829
+ function _e(r) {
819
830
  return Ge(this, arguments, function() {
820
831
  var t, n, o, i;
821
- return de(this, function(s) {
832
+ return he(this, function(s) {
822
833
  switch (s.label) {
823
834
  case 0:
824
835
  t = r.getReader(), s.label = 1;
@@ -846,29 +857,29 @@ function Te(r) {
846
857
  });
847
858
  });
848
859
  }
849
- function _e(r) {
860
+ function Pe(r) {
850
861
  return m(r?.getReader);
851
862
  }
852
- function x(r) {
863
+ function C(r) {
853
864
  if (r instanceof g)
854
865
  return r;
855
866
  if (r != null) {
856
- if (Ie(r))
857
- return at(r);
858
- if (we(r))
867
+ if (Oe(r))
859
868
  return ct(r);
860
869
  if (Ee(r))
861
870
  return ut(r);
862
- if (Oe(r))
863
- return Pe(r);
864
- if (xe(r))
871
+ if (Ie(r))
865
872
  return lt(r);
866
- if (_e(r))
873
+ if (Ae(r))
874
+ return Me(r);
875
+ if (Te(r))
867
876
  return ft(r);
877
+ if (Pe(r))
878
+ return dt(r);
868
879
  }
869
- throw Ae(r);
880
+ throw xe(r);
870
881
  }
871
- function at(r) {
882
+ function ct(r) {
872
883
  return new g(function(e) {
873
884
  var t = r[Z]();
874
885
  if (m(t.subscribe))
@@ -876,23 +887,23 @@ function at(r) {
876
887
  throw new TypeError("Provided object does not correctly implement Symbol.observable");
877
888
  });
878
889
  }
879
- function ct(r) {
890
+ function ut(r) {
880
891
  return new g(function(e) {
881
892
  for (var t = 0; t < r.length && !e.closed; t++)
882
893
  e.next(r[t]);
883
894
  e.complete();
884
895
  });
885
896
  }
886
- function ut(r) {
897
+ function lt(r) {
887
898
  return new g(function(e) {
888
899
  r.then(function(t) {
889
900
  e.closed || (e.next(t), e.complete());
890
901
  }, function(t) {
891
902
  return e.error(t);
892
- }).then(null, ye);
903
+ }).then(null, me);
893
904
  });
894
905
  }
895
- function lt(r) {
906
+ function ft(r) {
896
907
  return new g(function(e) {
897
908
  var t, n;
898
909
  try {
@@ -913,24 +924,24 @@ function lt(r) {
913
924
  e.complete();
914
925
  });
915
926
  }
916
- function Pe(r) {
927
+ function Me(r) {
917
928
  return new g(function(e) {
918
- dt(r, e).catch(function(t) {
929
+ ht(r, e).catch(function(t) {
919
930
  return e.error(t);
920
931
  });
921
932
  });
922
933
  }
923
- function ft(r) {
924
- return Pe(Te(r));
934
+ function dt(r) {
935
+ return Me(_e(r));
925
936
  }
926
- function dt(r, e) {
937
+ function ht(r, e) {
927
938
  var t, n, o, i;
928
- return Ne(this, void 0, void 0, function() {
939
+ return He(this, void 0, void 0, function() {
929
940
  var s, a;
930
- return de(this, function(c) {
941
+ return he(this, function(c) {
931
942
  switch (c.label) {
932
943
  case 0:
933
- c.trys.push([0, 5, 6, 11]), t = He(r), c.label = 1;
944
+ c.trys.push([0, 5, 6, 11]), t = Fe(r), c.label = 1;
934
945
  case 1:
935
946
  return [4, t.next()];
936
947
  case 2:
@@ -961,7 +972,7 @@ function dt(r, e) {
961
972
  });
962
973
  });
963
974
  }
964
- function C(r, e, t, n, o) {
975
+ function x(r, e, t, n, o) {
965
976
  n === void 0 && (n = 0), o === void 0 && (o = !1);
966
977
  var i = e.schedule(function() {
967
978
  t(), o ? r.add(this.schedule(null, n)) : this.unsubscribe();
@@ -969,37 +980,37 @@ function C(r, e, t, n, o) {
969
980
  if (r.add(i), !o)
970
981
  return i;
971
982
  }
972
- function Me(r, e) {
983
+ function Le(r, e) {
973
984
  return e === void 0 && (e = 0), _(function(t, n) {
974
985
  t.subscribe(I(n, function(o) {
975
- return C(n, r, function() {
986
+ return x(n, r, function() {
976
987
  return n.next(o);
977
988
  }, e);
978
989
  }, function() {
979
- return C(n, r, function() {
990
+ return x(n, r, function() {
980
991
  return n.complete();
981
992
  }, e);
982
993
  }, function(o) {
983
- return C(n, r, function() {
994
+ return x(n, r, function() {
984
995
  return n.error(o);
985
996
  }, e);
986
997
  }));
987
998
  });
988
999
  }
989
- function Le(r, e) {
1000
+ function Re(r, e) {
990
1001
  return e === void 0 && (e = 0), _(function(t, n) {
991
1002
  n.add(r.schedule(function() {
992
1003
  return t.subscribe(n);
993
1004
  }, e));
994
1005
  });
995
1006
  }
996
- function ht(r, e) {
997
- return x(r).pipe(Le(e), Me(e));
998
- }
999
1007
  function vt(r, e) {
1000
- return x(r).pipe(Le(e), Me(e));
1008
+ return C(r).pipe(Re(e), Le(e));
1001
1009
  }
1002
1010
  function pt(r, e) {
1011
+ return C(r).pipe(Re(e), Le(e));
1012
+ }
1013
+ function yt(r, e) {
1003
1014
  return new g(function(t) {
1004
1015
  var n = 0;
1005
1016
  return e.schedule(function() {
@@ -1007,11 +1018,11 @@ function pt(r, e) {
1007
1018
  });
1008
1019
  });
1009
1020
  }
1010
- function yt(r, e) {
1021
+ function mt(r, e) {
1011
1022
  return new g(function(t) {
1012
1023
  var n;
1013
- return C(t, e, function() {
1014
- n = r[Ce](), C(t, e, function() {
1024
+ return x(t, e, function() {
1025
+ n = r[Ce](), x(t, e, function() {
1015
1026
  var o, i, s;
1016
1027
  try {
1017
1028
  o = n.next(), i = o.value, s = o.done;
@@ -1026,13 +1037,13 @@ function yt(r, e) {
1026
1037
  };
1027
1038
  });
1028
1039
  }
1029
- function Re(r, e) {
1040
+ function Ue(r, e) {
1030
1041
  if (!r)
1031
1042
  throw new Error("Iterable cannot be null");
1032
1043
  return new g(function(t) {
1033
- C(t, e, function() {
1044
+ x(t, e, function() {
1034
1045
  var n = r[Symbol.asyncIterator]();
1035
- C(t, e, function() {
1046
+ x(t, e, function() {
1036
1047
  n.next().then(function(o) {
1037
1048
  o.done ? t.complete() : t.next(o.value);
1038
1049
  });
@@ -1040,39 +1051,39 @@ function Re(r, e) {
1040
1051
  });
1041
1052
  });
1042
1053
  }
1043
- function mt(r, e) {
1044
- return Re(Te(r), e);
1045
- }
1046
1054
  function bt(r, e) {
1055
+ return Ue(_e(r), e);
1056
+ }
1057
+ function gt(r, e) {
1047
1058
  if (r != null) {
1048
- if (Ie(r))
1049
- return ht(r, e);
1050
- if (we(r))
1051
- return pt(r, e);
1052
- if (Ee(r))
1053
- return vt(r, e);
1054
1059
  if (Oe(r))
1055
- return Re(r, e);
1056
- if (xe(r))
1060
+ return vt(r, e);
1061
+ if (Ee(r))
1057
1062
  return yt(r, e);
1058
- if (_e(r))
1063
+ if (Ie(r))
1064
+ return pt(r, e);
1065
+ if (Ae(r))
1066
+ return Ue(r, e);
1067
+ if (Te(r))
1059
1068
  return mt(r, e);
1069
+ if (Pe(r))
1070
+ return bt(r, e);
1060
1071
  }
1061
- throw Ae(r);
1072
+ throw xe(r);
1062
1073
  }
1063
1074
  function te(r, e) {
1064
- return e ? bt(r, e) : x(r);
1075
+ return e ? gt(r, e) : C(r);
1065
1076
  }
1066
- function gt() {
1077
+ function St() {
1067
1078
  for (var r = [], e = 0; e < arguments.length; e++)
1068
1079
  r[e] = arguments[e];
1069
- var t = Se(r);
1080
+ var t = we(r);
1070
1081
  return te(r, t);
1071
1082
  }
1072
- function St(r) {
1083
+ function wt(r) {
1073
1084
  return r instanceof Date && !isNaN(r);
1074
1085
  }
1075
- function H(r, e) {
1086
+ function G(r, e) {
1076
1087
  return _(function(t, n) {
1077
1088
  var o = 0;
1078
1089
  t.subscribe(I(n, function(i) {
@@ -1080,23 +1091,23 @@ function H(r, e) {
1080
1091
  }));
1081
1092
  });
1082
1093
  }
1083
- var wt = Array.isArray;
1084
- function Et(r, e) {
1085
- return wt(e) ? r.apply(void 0, R([], L(e))) : r(e);
1094
+ var Et = Array.isArray;
1095
+ function It(r, e) {
1096
+ return Et(e) ? r.apply(void 0, R([], L(e))) : r(e);
1086
1097
  }
1087
- function It(r) {
1088
- return H(function(e) {
1089
- return Et(r, e);
1098
+ function Ot(r) {
1099
+ return G(function(e) {
1100
+ return It(r, e);
1090
1101
  });
1091
1102
  }
1092
- var Ot = Array.isArray, At = Object.getPrototypeOf, Ct = Object.prototype, xt = Object.keys;
1093
- function Tt(r) {
1103
+ var At = Array.isArray, xt = Object.getPrototypeOf, Ct = Object.prototype, Tt = Object.keys;
1104
+ function _t(r) {
1094
1105
  if (r.length === 1) {
1095
1106
  var e = r[0];
1096
- if (Ot(e))
1107
+ if (At(e))
1097
1108
  return { args: e, keys: null };
1098
- if (_t(e)) {
1099
- var t = xt(e);
1109
+ if (Pt(e)) {
1110
+ var t = Tt(e);
1100
1111
  return {
1101
1112
  args: t.map(function(n) {
1102
1113
  return e[n];
@@ -1107,33 +1118,33 @@ function Tt(r) {
1107
1118
  }
1108
1119
  return { args: r, keys: null };
1109
1120
  }
1110
- function _t(r) {
1111
- return r && typeof r == "object" && At(r) === Ct;
1121
+ function Pt(r) {
1122
+ return r && typeof r == "object" && xt(r) === Ct;
1112
1123
  }
1113
- function Pt(r, e) {
1124
+ function Mt(r, e) {
1114
1125
  return r.reduce(function(t, n, o) {
1115
1126
  return t[n] = e[o], t;
1116
1127
  }, {});
1117
1128
  }
1118
- function Mt() {
1129
+ function Lt() {
1119
1130
  for (var r = [], e = 0; e < arguments.length; e++)
1120
1131
  r[e] = arguments[e];
1121
- var t = Se(r), n = it(r), o = Tt(r), i = o.args, s = o.keys;
1132
+ var t = we(r), n = st(r), o = _t(r), i = o.args, s = o.keys;
1122
1133
  if (i.length === 0)
1123
1134
  return te([], t);
1124
- var a = new g(Lt(i, t, s ? function(c) {
1125
- return Pt(s, c);
1126
- } : G));
1127
- return n ? a.pipe(It(n)) : a;
1135
+ var a = new g(Rt(i, t, s ? function(c) {
1136
+ return Mt(s, c);
1137
+ } : H));
1138
+ return n ? a.pipe(Ot(n)) : a;
1128
1139
  }
1129
- function Lt(r, e, t) {
1130
- return t === void 0 && (t = G), function(n) {
1140
+ function Rt(r, e, t) {
1141
+ return t === void 0 && (t = H), function(n) {
1131
1142
  ce(e, function() {
1132
1143
  for (var o = r.length, i = new Array(o), s = o, a = o, c = function(f) {
1133
1144
  ce(e, function() {
1134
- var h = te(r[f], e), v = !1;
1135
- h.subscribe(I(n, function(l) {
1136
- i[f] = l, v || (v = !0, a--), a || n.next(t(i.slice()));
1145
+ var v = te(r[f], e), d = !1;
1146
+ v.subscribe(I(n, function(l) {
1147
+ i[f] = l, d || (d = !0, a--), a || n.next(t(i.slice()));
1137
1148
  }, function() {
1138
1149
  --s || n.complete();
1139
1150
  }));
@@ -1144,17 +1155,17 @@ function Lt(r, e, t) {
1144
1155
  };
1145
1156
  }
1146
1157
  function ce(r, e, t) {
1147
- r ? C(t, r, e) : e();
1158
+ r ? x(t, r, e) : e();
1148
1159
  }
1149
- function Rt(r, e, t, n, o, i, s, a) {
1150
- var c = [], u = 0, f = 0, h = !1, v = function() {
1151
- h && !c.length && !u && e.complete();
1160
+ function Ut(r, e, t, n, o, i, s, a) {
1161
+ var c = [], u = 0, f = 0, v = !1, d = function() {
1162
+ v && !c.length && !u && e.complete();
1152
1163
  }, l = function(p) {
1153
1164
  return u < n ? y(p) : c.push(p);
1154
1165
  }, y = function(p) {
1155
1166
  u++;
1156
1167
  var S = !1;
1157
- x(t(p, f++)).subscribe(I(e, function(w) {
1168
+ C(t(p, f++)).subscribe(I(e, function(w) {
1158
1169
  e.next(w);
1159
1170
  }, function() {
1160
1171
  S = !0;
@@ -1167,31 +1178,31 @@ function Rt(r, e, t, n, o, i, s, a) {
1167
1178
  s || y(T);
1168
1179
  }; c.length && u < n; )
1169
1180
  w();
1170
- v();
1181
+ d();
1171
1182
  } catch (T) {
1172
1183
  e.error(T);
1173
1184
  }
1174
1185
  }));
1175
1186
  };
1176
1187
  return r.subscribe(I(e, l, function() {
1177
- h = !0, v();
1188
+ v = !0, d();
1178
1189
  })), function() {
1179
1190
  };
1180
1191
  }
1181
1192
  function N(r, e, t) {
1182
1193
  return t === void 0 && (t = 1 / 0), m(e) ? N(function(n, o) {
1183
- return H(function(i, s) {
1194
+ return G(function(i, s) {
1184
1195
  return e(n, i, o, s);
1185
- })(x(r(n, o)));
1196
+ })(C(r(n, o)));
1186
1197
  }, t) : (typeof e == "number" && (t = e), _(function(n, o) {
1187
- return Rt(n, o, r, t);
1198
+ return Ut(n, o, r, t);
1188
1199
  }));
1189
1200
  }
1190
- function Ue(r, e, t) {
1191
- r === void 0 && (r = 0), t === void 0 && (t = nt);
1201
+ function ke(r, e, t) {
1202
+ r === void 0 && (r = 0), t === void 0 && (t = ot);
1192
1203
  var n = -1;
1193
- return e != null && (be(e) ? t = e : n = e), new g(function(o) {
1194
- var i = St(r) ? +r - t.now() : r;
1204
+ return e != null && (ge(e) ? t = e : n = e), new g(function(o) {
1205
+ var i = wt(r) ? +r - t.now() : r;
1195
1206
  i < 0 && (i = 0);
1196
1207
  var s = 0;
1197
1208
  return t.schedule(function() {
@@ -1199,12 +1210,12 @@ function Ue(r, e, t) {
1199
1210
  }, i);
1200
1211
  });
1201
1212
  }
1202
- function Ut(r, e) {
1213
+ function kt(r, e) {
1203
1214
  return m(e) ? N(r, e, 1) : N(r, 1);
1204
1215
  }
1205
- function kt(r) {
1216
+ function $t(r) {
1206
1217
  return r <= 0 ? function() {
1207
- return ot;
1218
+ return it;
1208
1219
  } : _(function(e, t) {
1209
1220
  var n = 0;
1210
1221
  e.subscribe(I(t, function(o) {
@@ -1212,41 +1223,41 @@ function kt(r) {
1212
1223
  }));
1213
1224
  });
1214
1225
  }
1215
- function $t(r) {
1216
- return H(function() {
1226
+ function jt(r) {
1227
+ return G(function() {
1217
1228
  return r;
1218
1229
  });
1219
1230
  }
1220
- function jt(r, e) {
1231
+ function Dt(r, e) {
1221
1232
  return N(function(t, n) {
1222
- return x(r(t, n)).pipe(kt(1), $t(t));
1233
+ return C(r(t, n)).pipe($t(1), jt(t));
1223
1234
  });
1224
1235
  }
1225
- function Dt(r, e) {
1226
- e === void 0 && (e = me);
1227
- var t = Ue(r, e);
1228
- return jt(function() {
1236
+ function Nt(r, e) {
1237
+ e === void 0 && (e = be);
1238
+ var t = ke(r, e);
1239
+ return Dt(function() {
1229
1240
  return t;
1230
1241
  });
1231
1242
  }
1232
- function Nt(r) {
1243
+ function Ht(r) {
1233
1244
  var e;
1234
1245
  e = {
1235
1246
  count: r
1236
1247
  };
1237
1248
  var t = e.count, n = t === void 0 ? 1 / 0 : t, o = e.delay, i = e.resetOnSuccess, s = i === void 0 ? !1 : i;
1238
- return n <= 0 ? G : _(function(a, c) {
1239
- var u = 0, f, h = function() {
1240
- var v = !1;
1249
+ return n <= 0 ? H : _(function(a, c) {
1250
+ var u = 0, f, v = function() {
1251
+ var d = !1;
1241
1252
  f = a.subscribe(I(c, function(l) {
1242
1253
  s && (u = 0), c.next(l);
1243
1254
  }, void 0, function(l) {
1244
1255
  if (u++ < n) {
1245
1256
  var y = function() {
1246
- f ? (f.unsubscribe(), f = null, h()) : v = !0;
1257
+ f ? (f.unsubscribe(), f = null, v()) : d = !0;
1247
1258
  };
1248
1259
  if (o != null) {
1249
- var p = typeof o == "number" ? Ue(o) : x(o(l, u)), S = I(c, function() {
1260
+ var p = typeof o == "number" ? ke(o) : C(o(l, u)), S = I(c, function() {
1250
1261
  S.unsubscribe(), y();
1251
1262
  }, function() {
1252
1263
  c.complete();
@@ -1256,28 +1267,28 @@ function Nt(r) {
1256
1267
  y();
1257
1268
  } else
1258
1269
  c.error(l);
1259
- })), v && (f.unsubscribe(), f = null, h());
1270
+ })), d && (f.unsubscribe(), f = null, v());
1260
1271
  };
1261
- h();
1272
+ v();
1262
1273
  });
1263
1274
  }
1264
1275
  function Gt(r) {
1265
1276
  return _(function(e, t) {
1266
- x(r).subscribe(I(t, function() {
1277
+ C(r).subscribe(I(t, function() {
1267
1278
  return t.complete();
1268
1279
  }, W)), !t.closed && e.subscribe(t);
1269
1280
  });
1270
1281
  }
1271
- async function Ht(r, e) {
1282
+ async function Ft(r, e) {
1272
1283
  const t = r.getReader();
1273
1284
  let n;
1274
1285
  for (; !(n = await t.read()).done; )
1275
1286
  e(n.value);
1276
1287
  }
1277
- function Ft(r) {
1288
+ function Vt(r) {
1278
1289
  let e, t, n, o = !1;
1279
1290
  return function(s) {
1280
- e === void 0 ? (e = s, t = 0, n = -1) : e = qt(e, s);
1291
+ e === void 0 ? (e = s, t = 0, n = -1) : e = Kt(e, s);
1281
1292
  const a = e.length;
1282
1293
  let c = 0;
1283
1294
  for (; t < a; ) {
@@ -1301,7 +1312,7 @@ function Ft(r) {
1301
1312
  c === a ? e = void 0 : c !== 0 && (e = e.subarray(c), t -= c);
1302
1313
  };
1303
1314
  }
1304
- function Vt(r, e, t) {
1315
+ function qt(r, e, t) {
1305
1316
  let n = ue();
1306
1317
  const o = new TextDecoder();
1307
1318
  return function(s, a) {
@@ -1321,14 +1332,14 @@ function Vt(r, e, t) {
1321
1332
  r(n.id = f);
1322
1333
  break;
1323
1334
  case "retry":
1324
- const h = parseInt(f, 10);
1325
- isNaN(h) || e(n.retry = h);
1335
+ const v = parseInt(f, 10);
1336
+ isNaN(v) || e(n.retry = v);
1326
1337
  break;
1327
1338
  }
1328
1339
  }
1329
1340
  };
1330
1341
  }
1331
- function qt(r, e) {
1342
+ function Kt(r, e) {
1332
1343
  const t = new Uint8Array(r.length + e.length);
1333
1344
  return t.set(r), t.set(e, r.length), t;
1334
1345
  }
@@ -1340,7 +1351,7 @@ function ue() {
1340
1351
  retry: void 0
1341
1352
  };
1342
1353
  }
1343
- var Kt = function(r, e) {
1354
+ var Bt = function(r, e) {
1344
1355
  var t = {};
1345
1356
  for (var n in r) Object.prototype.hasOwnProperty.call(r, n) && e.indexOf(n) < 0 && (t[n] = r[n]);
1346
1357
  if (r != null && typeof Object.getOwnPropertySymbols == "function")
@@ -1348,10 +1359,10 @@ var Kt = function(r, e) {
1348
1359
  e.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(r, n[o]) && (t[n[o]] = r[n[o]]);
1349
1360
  return t;
1350
1361
  };
1351
- const J = "text/event-stream", Bt = 1e3, le = "last-event-id";
1352
- function Yt(r, e) {
1353
- var { signal: t, headers: n, onopen: o, onmessage: i, onclose: s, onerror: a, openWhenHidden: c, fetch: u } = e, f = Kt(e, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
1354
- return new Promise((h, v) => {
1362
+ const J = "text/event-stream", Yt = 1e3, le = "last-event-id";
1363
+ function Wt(r, e) {
1364
+ var { signal: t, headers: n, onopen: o, onmessage: i, onclose: s, onerror: a, openWhenHidden: c, fetch: u } = e, f = Bt(e, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
1365
+ return new Promise((v, d) => {
1355
1366
  const l = Object.assign({}, n);
1356
1367
  l.accept || (l.accept = J);
1357
1368
  let y;
@@ -1359,43 +1370,43 @@ function Yt(r, e) {
1359
1370
  y.abort(), document.hidden || F();
1360
1371
  }
1361
1372
  c || document.addEventListener("visibilitychange", p);
1362
- let S = Bt, w = 0;
1373
+ let S = Yt, w = 0;
1363
1374
  function T() {
1364
1375
  document.removeEventListener("visibilitychange", p), window.clearTimeout(w), y.abort();
1365
1376
  }
1366
1377
  t?.addEventListener("abort", () => {
1367
- T(), h();
1378
+ T(), v();
1368
1379
  });
1369
- const $e = u ?? window.fetch, je = o ?? Wt;
1380
+ const je = u ?? window.fetch, De = o ?? Xt;
1370
1381
  async function F() {
1371
1382
  var V;
1372
1383
  y = new AbortController();
1373
1384
  try {
1374
- const k = await $e(r, Object.assign(Object.assign({}, f), { headers: l, signal: y.signal }));
1375
- await je(k), await Ht(k.body, Ft(Vt((A) => {
1385
+ const k = await je(r, Object.assign(Object.assign({}, f), { headers: l, signal: y.signal }));
1386
+ await De(k), await Ft(k.body, Vt(qt((A) => {
1376
1387
  A ? l[le] = A : delete l[le];
1377
1388
  }, (A) => {
1378
1389
  S = A;
1379
- }, i))), s?.(), T(), h();
1390
+ }, i))), s?.(), T(), v();
1380
1391
  } catch (k) {
1381
1392
  if (!y.signal.aborted)
1382
1393
  try {
1383
1394
  const A = (V = a?.(k)) !== null && V !== void 0 ? V : S;
1384
1395
  window.clearTimeout(w), w = window.setTimeout(F, A);
1385
1396
  } catch (A) {
1386
- T(), v(A);
1397
+ T(), d(A);
1387
1398
  }
1388
1399
  }
1389
1400
  }
1390
1401
  F();
1391
1402
  });
1392
1403
  }
1393
- function Wt(r) {
1404
+ function Xt(r) {
1394
1405
  const e = r.headers.get("content-type");
1395
1406
  if (!e?.startsWith(J))
1396
1407
  throw new Error(`Expected content-type to be ${J}, Actual: ${e}`);
1397
1408
  }
1398
- function Xt(r) {
1409
+ function Jt(r) {
1399
1410
  const { endpoint: e, apiKey: t, payload: n, debugMode: o, customHeaders: i } = r;
1400
1411
  return new g((s) => {
1401
1412
  const a = new AbortController();
@@ -1407,8 +1418,8 @@ function Xt(r) {
1407
1418
  t && (u["X-API-KEY"] = t);
1408
1419
  const f = new URLSearchParams();
1409
1420
  o && f.set("is_debug", "true");
1410
- const h = new URL(e);
1411
- return f.toString() && (h.search = f.toString()), Yt(h.toString(), {
1421
+ const v = new URL(e);
1422
+ return f.toString() && (v.search = f.toString()), Wt(v.toString(), {
1412
1423
  method: "POST",
1413
1424
  headers: u,
1414
1425
  body: n ? JSON.stringify(n) : void 0,
@@ -1418,25 +1429,39 @@ function Xt(r) {
1418
1429
  * https://github.com/Azure/fetch-event-source/issues/17#issuecomment-1525904929
1419
1430
  */
1420
1431
  openWhenHidden: !0,
1421
- onopen: async (v) => {
1422
- v.ok ? c = v.headers.get("X-Trace-Id") ?? void 0 : (s.error(v), a.abort());
1432
+ onopen: async (d) => {
1433
+ if (d.ok)
1434
+ c = d.headers.get("X-Trace-Id") ?? void 0;
1435
+ else {
1436
+ let l;
1437
+ try {
1438
+ l = await d.json();
1439
+ } catch {
1440
+ try {
1441
+ l = await d.text();
1442
+ } catch {
1443
+ l = null;
1444
+ }
1445
+ }
1446
+ s.error(new de(d.status, d.statusText, l)), a.abort();
1447
+ }
1423
1448
  },
1424
- onmessage: (v) => {
1425
- const l = JSON.parse(v.data);
1449
+ onmessage: (d) => {
1450
+ const l = JSON.parse(d.data);
1426
1451
  c ? l.traceId = c : l.requestId && (l.traceId = l.requestId, c || (c = l.requestId)), s.next(l);
1427
1452
  },
1428
1453
  onclose: () => {
1429
1454
  s.complete();
1430
1455
  },
1431
- onerror: (v) => {
1432
- throw s.error(v), a.abort(), v;
1456
+ onerror: (d) => {
1457
+ throw s.error(d), a.abort(), d;
1433
1458
  }
1434
1459
  }), () => {
1435
1460
  a.abort();
1436
1461
  };
1437
1462
  });
1438
1463
  }
1439
- class Jt {
1464
+ class zt {
1440
1465
  listeners = {};
1441
1466
  on(e, t) {
1442
1467
  this.listeners = Object.assign({}, this.listeners, {
@@ -1455,13 +1480,13 @@ class Jt {
1455
1480
  this.listeners[e] && this.listeners[e].forEach((n) => n(...t));
1456
1481
  }
1457
1482
  }
1458
- class rr {
1483
+ class or {
1459
1484
  apiKey;
1460
1485
  endpoint;
1461
1486
  botProviderEndpoint;
1462
1487
  debugMode;
1463
1488
  destroy$ = new ee();
1464
- sseEmitter = new Jt();
1489
+ sseEmitter = new zt();
1465
1490
  transformSsePayload;
1466
1491
  customHeaders;
1467
1492
  constructor(e) {
@@ -1479,41 +1504,41 @@ class rr {
1479
1504
  }
1480
1505
  handleEvent(e) {
1481
1506
  switch (e.eventType) {
1482
- case d.INIT:
1483
- this.sseEmitter.emit(d.INIT, e);
1507
+ case h.INIT:
1508
+ this.sseEmitter.emit(h.INIT, e);
1484
1509
  break;
1485
- case d.PROCESS_START:
1486
- case d.PROCESS_COMPLETE:
1487
- this.sseEmitter.emit(d.PROCESS, e);
1510
+ case h.PROCESS_START:
1511
+ case h.PROCESS_COMPLETE:
1512
+ this.sseEmitter.emit(h.PROCESS, e);
1488
1513
  break;
1489
- case d.MESSAGE_START:
1490
- case d.MESSAGE_DELTA:
1491
- case d.MESSAGE_COMPLETE:
1492
- this.sseEmitter.emit(d.MESSAGE, e);
1514
+ case h.MESSAGE_START:
1515
+ case h.MESSAGE_DELTA:
1516
+ case h.MESSAGE_COMPLETE:
1517
+ this.sseEmitter.emit(h.MESSAGE, e);
1493
1518
  break;
1494
- case d.TOOL_CALL_START:
1495
- case d.TOOL_CALL_COMPLETE:
1496
- this.sseEmitter.emit(d.TOOL_CALL, e);
1519
+ case h.TOOL_CALL_START:
1520
+ case h.TOOL_CALL_COMPLETE:
1521
+ this.sseEmitter.emit(h.TOOL_CALL, e);
1497
1522
  break;
1498
- case d.DONE:
1499
- this.sseEmitter.emit(d.DONE, e);
1523
+ case h.DONE:
1524
+ this.sseEmitter.emit(h.DONE, e);
1500
1525
  break;
1501
- case d.ERROR:
1502
- this.sseEmitter.emit(d.ERROR, e);
1526
+ case h.ERROR:
1527
+ this.sseEmitter.emit(h.ERROR, e);
1503
1528
  break;
1504
1529
  }
1505
1530
  }
1506
1531
  fetchSse(e, t) {
1507
- t?.onSseStart?.(), Xt({
1532
+ t?.onSseStart?.(), Jt({
1508
1533
  apiKey: this.apiKey,
1509
1534
  endpoint: this.endpoint,
1510
1535
  debugMode: this.debugMode,
1511
1536
  payload: this.transformSsePayload?.(e) ?? e,
1512
1537
  customHeaders: this.customHeaders
1513
1538
  }).pipe(
1514
- Ut((n) => gt(n).pipe(Dt(t?.delayTime ?? 50))),
1539
+ kt((n) => St(n).pipe(Nt(t?.delayTime ?? 50))),
1515
1540
  Gt(this.destroy$),
1516
- Nt(3)
1541
+ Ht(3)
1517
1542
  ).subscribe({
1518
1543
  next: (n) => {
1519
1544
  t?.onSseMessage?.(n), this.handleEvent(n);
@@ -1570,29 +1595,29 @@ class rr {
1570
1595
  const b = [];
1571
1596
  for (let r = 0; r < 256; ++r)
1572
1597
  b.push((r + 256).toString(16).slice(1));
1573
- function zt(r, e = 0) {
1598
+ function Qt(r, e = 0) {
1574
1599
  return (b[r[e + 0]] + b[r[e + 1]] + b[r[e + 2]] + b[r[e + 3]] + "-" + b[r[e + 4]] + b[r[e + 5]] + "-" + b[r[e + 6]] + b[r[e + 7]] + "-" + b[r[e + 8]] + b[r[e + 9]] + "-" + b[r[e + 10]] + b[r[e + 11]] + b[r[e + 12]] + b[r[e + 13]] + b[r[e + 14]] + b[r[e + 15]]).toLowerCase();
1575
1600
  }
1576
1601
  let K;
1577
- const Qt = new Uint8Array(16);
1578
- function Zt() {
1602
+ const Zt = new Uint8Array(16);
1603
+ function er() {
1579
1604
  if (!K) {
1580
1605
  if (typeof crypto > "u" || !crypto.getRandomValues)
1581
1606
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
1582
1607
  K = crypto.getRandomValues.bind(crypto);
1583
1608
  }
1584
- return K(Qt);
1609
+ return K(Zt);
1585
1610
  }
1586
- const er = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), fe = { randomUUID: er };
1587
- function tr(r, e, t) {
1611
+ const tr = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), fe = { randomUUID: tr };
1612
+ function rr(r, e, t) {
1588
1613
  r = r || {};
1589
- const n = r.random ?? r.rng?.() ?? Zt();
1614
+ const n = r.random ?? r.rng?.() ?? er();
1590
1615
  if (n.length < 16)
1591
1616
  throw new Error("Random bytes length must be >= 16");
1592
- return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, zt(n);
1617
+ return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, Qt(n);
1593
1618
  }
1594
- function ke(r, e, t) {
1595
- return fe.randomUUID && !r ? fe.randomUUID() : tr(r);
1619
+ function $e(r, e, t) {
1620
+ return fe.randomUUID && !r ? fe.randomUUID() : rr(r);
1596
1621
  }
1597
1622
  class E {
1598
1623
  messages = null;
@@ -1605,17 +1630,17 @@ class E {
1605
1630
  }
1606
1631
  onMessage(e) {
1607
1632
  switch (e.eventType) {
1608
- case d.MESSAGE_START:
1633
+ case h.MESSAGE_START:
1609
1634
  return this.onMessageStart(e);
1610
- case d.MESSAGE_DELTA:
1635
+ case h.MESSAGE_DELTA:
1611
1636
  return this.onMessageDelta(e);
1612
- case d.MESSAGE_COMPLETE:
1637
+ case h.MESSAGE_COMPLETE:
1613
1638
  return this.onMessageComplete(e);
1614
- case d.TOOL_CALL_START:
1639
+ case h.TOOL_CALL_START:
1615
1640
  return this.onToolCallStart(e);
1616
- case d.TOOL_CALL_COMPLETE:
1641
+ case h.TOOL_CALL_COMPLETE:
1617
1642
  return this.onToolCallComplete(e);
1618
- case d.ERROR:
1643
+ case h.ERROR:
1619
1644
  return this.onMessageError(e);
1620
1645
  default:
1621
1646
  return this;
@@ -1625,7 +1650,7 @@ class E {
1625
1650
  const t = e.fact.messageStart.message, n = new Map(this.messages);
1626
1651
  return n.set(t.messageId, {
1627
1652
  type: "bot",
1628
- eventType: d.MESSAGE_START,
1653
+ eventType: h.MESSAGE_START,
1629
1654
  isTyping: !0,
1630
1655
  typingText: "",
1631
1656
  messageId: t.messageId,
@@ -1641,7 +1666,7 @@ class E {
1641
1666
  const i = `${o?.typingText ?? ""}${t.text}`;
1642
1667
  return n.set(t.messageId, {
1643
1668
  type: "bot",
1644
- eventType: d.MESSAGE_DELTA,
1669
+ eventType: h.MESSAGE_DELTA,
1645
1670
  isTyping: !0,
1646
1671
  typingText: i,
1647
1672
  messageId: t.messageId,
@@ -1655,7 +1680,7 @@ class E {
1655
1680
  const t = e.fact.messageComplete.message, n = new Map(this.messages), o = n.get(t.messageId);
1656
1681
  return n.set(t.messageId, {
1657
1682
  type: "bot",
1658
- eventType: d.MESSAGE_COMPLETE,
1683
+ eventType: h.MESSAGE_COMPLETE,
1659
1684
  isTyping: !1,
1660
1685
  typingText: null,
1661
1686
  messageId: t.messageId,
@@ -1666,10 +1691,10 @@ class E {
1666
1691
  }), new E({ messages: n });
1667
1692
  }
1668
1693
  onMessageError(e) {
1669
- const t = ke(), n = e.fact.runError.error, o = new Map(this.messages);
1694
+ const t = $e(), n = e.fact.runError.error, o = new Map(this.messages);
1670
1695
  return o.set(t, {
1671
1696
  type: "error",
1672
- eventType: d.ERROR,
1697
+ eventType: h.ERROR,
1673
1698
  messageId: t,
1674
1699
  error: n,
1675
1700
  time: /* @__PURE__ */ new Date(),
@@ -1679,7 +1704,7 @@ class E {
1679
1704
  onToolCallStart(e) {
1680
1705
  const t = e.fact.toolCallStart, n = new Map(this.messages), o = `${t.processId}-${t.callSeq}`, i = {
1681
1706
  type: "tool-call",
1682
- eventType: d.TOOL_CALL_START,
1707
+ eventType: h.TOOL_CALL_START,
1683
1708
  messageId: o,
1684
1709
  processId: t.processId,
1685
1710
  callSeq: t.callSeq,
@@ -1697,7 +1722,7 @@ class E {
1697
1722
  if (i?.type === "tool-call") {
1698
1723
  const s = {
1699
1724
  ...i,
1700
- eventType: d.TOOL_CALL_COMPLETE,
1725
+ eventType: h.TOOL_CALL_COMPLETE,
1701
1726
  result: t.toolCallResult,
1702
1727
  isComplete: !0,
1703
1728
  traceId: e.traceId ?? i.traceId
@@ -1736,8 +1761,8 @@ class z {
1736
1761
  }
1737
1762
  }
1738
1763
  subscribe() {
1739
- this.statesSubscription = Mt([this.isConnecting$, this.conversation$]).pipe(
1740
- H(([e, t]) => ({
1764
+ this.statesSubscription = Lt([this.isConnecting$, this.conversation$]).pipe(
1765
+ G(([e, t]) => ({
1741
1766
  isConnecting: e,
1742
1767
  conversation: t
1743
1768
  }))
@@ -1793,7 +1818,7 @@ class z {
1793
1818
  );
1794
1819
  }
1795
1820
  sendMessage(e, t) {
1796
- const n = e.text.trim(), o = e.customMessageId ?? ke();
1821
+ const n = e.text.trim(), o = e.customMessageId ?? $e();
1797
1822
  return this.currentUserMessageId = o, this.conversation$.next(
1798
1823
  this.conversation$.value.pushMessage({
1799
1824
  type: "user",
@@ -1821,11 +1846,13 @@ class z {
1821
1846
  }
1822
1847
  }
1823
1848
  export {
1824
- rr as AsgardServiceClient,
1849
+ or as AsgardServiceClient,
1825
1850
  z as Channel,
1826
1851
  E as Conversation,
1827
- d as EventType,
1852
+ h as EventType,
1828
1853
  B as FetchSseAction,
1829
- De as MessageTemplateType
1854
+ de as HttpError,
1855
+ Ne as MessageTemplateType,
1856
+ nr as isHttpError
1830
1857
  };
1831
1858
  //# sourceMappingURL=index.mjs.map