@asgard-js/core 0.0.41-canary.2 → 0.0.41-canary.3

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 je = Object.defineProperty;
2
- var $e = (r, t, e) => t in r ? je(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var m = (r, t, e) => $e(r, typeof t != "symbol" ? t + "" : t, e);
4
- 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))(De || {}), Y = function(r, t) {
2
+ var De = (r, t, e) => t in r ? je(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var m = (r, t, e) => De(r, typeof t != "symbol" ? t + "" : t, e);
4
+ var K = /* @__PURE__ */ ((r) => (r.RESET_CHANNEL = "RESET_CHANNEL", r.NONE = "NONE", r))(K || {}), 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 || {}), Ue = /* @__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))(Ue || {}), Y = function(r, t) {
5
5
  return Y = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, n) {
6
6
  e.__proto__ = n;
7
7
  } || function(e, n) {
@@ -17,7 +17,7 @@ function O(r, t) {
17
17
  }
18
18
  r.prototype = t === null ? Object.create(t) : (e.prototype = t.prototype, new e());
19
19
  }
20
- function Ue(r, t, e, n) {
20
+ function $e(r, t, e, n) {
21
21
  function i(o) {
22
22
  return o instanceof e ? o : new e(function(s) {
23
23
  s(o);
@@ -136,8 +136,8 @@ function R(r, t, e) {
136
136
  (o || !(n in t)) && (o || (o = Array.prototype.slice.call(t, 0, n)), o[n] = t[n]);
137
137
  return r.concat(o || Array.prototype.slice.call(t));
138
138
  }
139
- function C(r) {
140
- return this instanceof C ? (this.v = r, this) : new C(r);
139
+ function P(r) {
140
+ return this instanceof P ? (this.v = r, this) : new P(r);
141
141
  }
142
142
  function Ne(r, t, e) {
143
143
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
@@ -152,8 +152,8 @@ function Ne(r, t, e) {
152
152
  }
153
153
  function c(f, y) {
154
154
  n[f] && (i[f] = function(h) {
155
- return new Promise(function(S, w) {
156
- o.push([f, h, S, w]) > 1 || u(f, h);
155
+ return new Promise(function(g, w) {
156
+ o.push([f, h, g, w]) > 1 || u(f, h);
157
157
  });
158
158
  }, y && (i[f] = y(i[f])));
159
159
  }
@@ -165,7 +165,7 @@ function Ne(r, t, e) {
165
165
  }
166
166
  }
167
167
  function a(f) {
168
- f.value instanceof C ? Promise.resolve(f.value.v).then(l, v) : b(o[0][2], f);
168
+ f.value instanceof P ? Promise.resolve(f.value.v).then(l, v) : b(o[0][2], f);
169
169
  }
170
170
  function l(f) {
171
171
  u("next", f);
@@ -205,7 +205,7 @@ function le(r) {
205
205
  }, e = r(t);
206
206
  return e.prototype = Object.create(Error.prototype), e.prototype.constructor = e, e;
207
207
  }
208
- var K = le(function(r) {
208
+ var B = le(function(r) {
209
209
  return function(e) {
210
210
  r(this), this.message = e ? e.length + ` errors occurred during unsubscription:
211
211
  ` + e.map(function(n, i) {
@@ -214,7 +214,7 @@ var K = le(function(r) {
214
214
  `) : "", this.name = "UnsubscriptionError", this.errors = e;
215
215
  };
216
216
  });
217
- function U(r, t) {
217
+ function $(r, t) {
218
218
  if (r) {
219
219
  var e = r.indexOf(t);
220
220
  0 <= e && r.splice(e, 1);
@@ -252,7 +252,7 @@ var k = function() {
252
252
  try {
253
253
  l();
254
254
  } catch (h) {
255
- o = h instanceof K ? h.errors : [h];
255
+ o = h instanceof B ? h.errors : [h];
256
256
  }
257
257
  var v = this._finalizers;
258
258
  if (v) {
@@ -263,7 +263,7 @@ var k = function() {
263
263
  try {
264
264
  ee(y);
265
265
  } catch (h) {
266
- o = o ?? [], h instanceof K ? o = R(R([], L(o)), L(h.errors)) : o.push(h);
266
+ o = o ?? [], h instanceof B ? o = R(R([], L(o)), L(h.errors)) : o.push(h);
267
267
  }
268
268
  }
269
269
  } catch (h) {
@@ -277,7 +277,7 @@ var k = function() {
277
277
  }
278
278
  }
279
279
  if (o)
280
- throw new K(o);
280
+ throw new B(o);
281
281
  }
282
282
  }, r.prototype.add = function(t) {
283
283
  var e;
@@ -300,10 +300,10 @@ var k = function() {
300
300
  this._parentage = Array.isArray(e) ? (e.push(t), e) : e ? [e, t] : t;
301
301
  }, r.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) && $(e, t);
304
304
  }, r.prototype.remove = function(t) {
305
305
  var e = this._finalizers;
306
- e && U(e, t), t instanceof r && t._removeParent(this);
306
+ e && $(e, t), t instanceof r && t._removeParent(this);
307
307
  }, r.EMPTY = function() {
308
308
  var t = new r();
309
309
  return t.closed = !0, t;
@@ -335,14 +335,14 @@ function de(r) {
335
335
  }
336
336
  function q() {
337
337
  }
338
- function D(r) {
338
+ function U(r) {
339
339
  r();
340
340
  }
341
- var J = function(r) {
341
+ var X = function(r) {
342
342
  O(t, r);
343
343
  function t(e) {
344
344
  var n = r.call(this) || this;
345
- return n.isStopped = !1, e ? (n.destination = e, he(e) && e.add(n)) : n.destination = Be, n;
345
+ return n.isStopped = !1, e ? (n.destination = e, he(e) && e.add(n)) : n.destination = Ke, n;
346
346
  }
347
347
  return t.create = function(e, n, i) {
348
348
  return new W(e, n, i);
@@ -379,7 +379,7 @@ var J = function(r) {
379
379
  try {
380
380
  e.next(t);
381
381
  } catch (n) {
382
- $(n);
382
+ D(n);
383
383
  }
384
384
  }, r.prototype.error = function(t) {
385
385
  var e = this.partialObserver;
@@ -387,17 +387,17 @@ var J = function(r) {
387
387
  try {
388
388
  e.error(t);
389
389
  } catch (n) {
390
- $(n);
390
+ D(n);
391
391
  }
392
392
  else
393
- $(t);
393
+ D(t);
394
394
  }, r.prototype.complete = function() {
395
395
  var t = this.partialObserver;
396
396
  if (t.complete)
397
397
  try {
398
398
  t.complete();
399
399
  } catch (e) {
400
- $(e);
400
+ D(e);
401
401
  }
402
402
  }, r;
403
403
  }(), W = function(r) {
@@ -411,17 +411,17 @@ var J = function(r) {
411
411
  } : s = e, o.destination = new Ve(s), o;
412
412
  }
413
413
  return t;
414
- }(J);
415
- function $(r) {
414
+ }(X);
415
+ function D(r) {
416
416
  de(r);
417
417
  }
418
- function Ke(r) {
418
+ function Be(r) {
419
419
  throw r;
420
420
  }
421
- var Be = {
421
+ var Ke = {
422
422
  closed: !0,
423
423
  next: q,
424
- error: Ke,
424
+ error: Be,
425
425
  complete: q
426
426
  }, z = function() {
427
427
  return typeof Symbol == "function" && Symbol.observable || "@@observable";
@@ -436,7 +436,7 @@ function Ye(r) {
436
436
  }, e);
437
437
  };
438
438
  }
439
- var g = function() {
439
+ var S = function() {
440
440
  function r(t) {
441
441
  t && (this._subscribe = t);
442
442
  }
@@ -445,7 +445,7 @@ var g = function() {
445
445
  return e.source = this, e.operator = t, e;
446
446
  }, r.prototype.subscribe = function(t, e, n) {
447
447
  var i = this, o = We(t) ? t : new W(t, e, n);
448
- return D(function() {
448
+ return U(function() {
449
449
  var s = i, c = s.operator, u = s.source;
450
450
  o.add(c ? c.call(o, u) : u ? i._subscribe(o) : i._trySubscribe(o));
451
451
  }), o;
@@ -504,14 +504,14 @@ function qe(r) {
504
504
  return r && p(r.next) && p(r.error) && p(r.complete);
505
505
  }
506
506
  function We(r) {
507
- return r && r instanceof J || qe(r) && he(r);
507
+ return r && r instanceof X || qe(r) && he(r);
508
508
  }
509
- function Xe(r) {
509
+ function Je(r) {
510
510
  return p(r == null ? void 0 : r.lift);
511
511
  }
512
- function P(r) {
512
+ function T(r) {
513
513
  return function(t) {
514
- if (Xe(t))
514
+ if (Je(t))
515
515
  return t.lift(function(e) {
516
516
  try {
517
517
  return r(e, this);
@@ -523,9 +523,9 @@ function P(r) {
523
523
  };
524
524
  }
525
525
  function E(r, t, e, n, i) {
526
- return new Je(r, t, e, n, i);
526
+ return new Xe(r, t, e, n, i);
527
527
  }
528
- var Je = function(r) {
528
+ var Xe = function(r) {
529
529
  O(t, r);
530
530
  function t(e, n, i, o, s, c) {
531
531
  var u = r.call(this, e) || this;
@@ -560,7 +560,7 @@ var Je = function(r) {
560
560
  r.prototype.unsubscribe.call(this), !n && ((e = this.onFinalize) === null || e === void 0 || e.call(this));
561
561
  }
562
562
  }, t;
563
- }(J), ze = le(function(r) {
563
+ }(X), ze = le(function(r) {
564
564
  return function() {
565
565
  r(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
566
566
  };
@@ -578,7 +578,7 @@ var Je = function(r) {
578
578
  throw new ze();
579
579
  }, t.prototype.next = function(e) {
580
580
  var n = this;
581
- D(function() {
581
+ U(function() {
582
582
  var i, o;
583
583
  if (n._throwIfClosed(), !n.isStopped) {
584
584
  n.currentObservers || (n.currentObservers = Array.from(n.observers));
@@ -600,7 +600,7 @@ var Je = function(r) {
600
600
  });
601
601
  }, t.prototype.error = function(e) {
602
602
  var n = this;
603
- D(function() {
603
+ U(function() {
604
604
  if (n._throwIfClosed(), !n.isStopped) {
605
605
  n.hasError = n.isStopped = !0, n.thrownError = e;
606
606
  for (var i = n.observers; i.length; )
@@ -609,7 +609,7 @@ var Je = function(r) {
609
609
  });
610
610
  }, t.prototype.complete = function() {
611
611
  var e = this;
612
- D(function() {
612
+ U(function() {
613
613
  if (e._throwIfClosed(), !e.isStopped) {
614
614
  e.isStopped = !0;
615
615
  for (var n = e.observers; n.length; )
@@ -632,18 +632,18 @@ var Je = function(r) {
632
632
  }, t.prototype._innerSubscribe = function(e) {
633
633
  var n = this, i = this, o = i.hasError, s = i.isStopped, c = i.observers;
634
634
  return o || s ? fe : (this.currentObservers = null, c.push(e), new k(function() {
635
- n.currentObservers = null, U(c, e);
635
+ n.currentObservers = null, $(c, e);
636
636
  }));
637
637
  }, t.prototype._checkFinalizedStatuses = function(e) {
638
638
  var n = this, i = n.hasError, o = n.thrownError, s = n.isStopped;
639
639
  i ? e.error(o) : s && e.complete();
640
640
  }, t.prototype.asObservable = function() {
641
- var e = new g();
641
+ var e = new S();
642
642
  return e.source = this, e;
643
643
  }, t.create = function(e, n) {
644
644
  return new re(e, n);
645
645
  }, t;
646
- }(g), re = function(r) {
646
+ }(S), re = function(r) {
647
647
  O(t, r);
648
648
  function t(e, n) {
649
649
  var i = r.call(this) || this;
@@ -746,7 +746,7 @@ var Je = function(r) {
746
746
  }, t.prototype.unsubscribe = function() {
747
747
  if (!this.closed) {
748
748
  var e = this, n = e.id, i = e.scheduler, o = i.actions;
749
- this.work = this.state = this.scheduler = null, this.pending = !1, U(o, this), n != null && (this.id = this.recycleAsyncId(i, n, null)), this.delay = null, r.prototype.unsubscribe.call(this);
749
+ this.work = this.state = this.scheduler = null, this.pending = !1, $(o, this), n != null && (this.id = this.recycleAsyncId(i, n, null)), this.delay = null, r.prototype.unsubscribe.call(this);
750
750
  }
751
751
  }, t;
752
752
  }(Ze), oe = function() {
@@ -781,7 +781,7 @@ var Je = function(r) {
781
781
  throw i;
782
782
  }
783
783
  }, t;
784
- }(oe), ve = new tt(et), rt = ve, nt = new g(function(r) {
784
+ }(oe), ve = new tt(et), rt = ve, nt = new S(function(r) {
785
785
  return r.complete();
786
786
  });
787
787
  function ye(r) {
@@ -799,10 +799,10 @@ function be(r) {
799
799
  var me = function(r) {
800
800
  return r && typeof r.length == "number" && typeof r != "function";
801
801
  };
802
- function ge(r) {
802
+ function Se(r) {
803
803
  return p(r == null ? void 0 : r.then);
804
804
  }
805
- function Se(r) {
805
+ function ge(r) {
806
806
  return p(r[z]);
807
807
  }
808
808
  function we(r) {
@@ -828,13 +828,13 @@ function Ae(r) {
828
828
  case 1:
829
829
  s.trys.push([1, , 9, 10]), s.label = 2;
830
830
  case 2:
831
- return [4, C(e.read())];
831
+ return [4, P(e.read())];
832
832
  case 3:
833
- return n = s.sent(), i = n.value, o = n.done, o ? [4, C(void 0)] : [3, 5];
833
+ return n = s.sent(), i = n.value, o = n.done, o ? [4, P(void 0)] : [3, 5];
834
834
  case 4:
835
835
  return [2, s.sent()];
836
836
  case 5:
837
- return [4, C(i)];
837
+ return [4, P(i)];
838
838
  case 6:
839
839
  return [4, s.sent()];
840
840
  case 7:
@@ -853,14 +853,14 @@ function _e(r) {
853
853
  return p(r == null ? void 0 : r.getReader);
854
854
  }
855
855
  function _(r) {
856
- if (r instanceof g)
856
+ if (r instanceof S)
857
857
  return r;
858
858
  if (r != null) {
859
- if (Se(r))
859
+ if (ge(r))
860
860
  return st(r);
861
861
  if (me(r))
862
862
  return at(r);
863
- if (ge(r))
863
+ if (Se(r))
864
864
  return ut(r);
865
865
  if (we(r))
866
866
  return xe(r);
@@ -872,7 +872,7 @@ function _(r) {
872
872
  throw Ee(r);
873
873
  }
874
874
  function st(r) {
875
- return new g(function(t) {
875
+ return new S(function(t) {
876
876
  var e = r[z]();
877
877
  if (p(e.subscribe))
878
878
  return e.subscribe(t);
@@ -880,14 +880,14 @@ function st(r) {
880
880
  });
881
881
  }
882
882
  function at(r) {
883
- return new g(function(t) {
883
+ return new S(function(t) {
884
884
  for (var e = 0; e < r.length && !t.closed; e++)
885
885
  t.next(r[e]);
886
886
  t.complete();
887
887
  });
888
888
  }
889
889
  function ut(r) {
890
- return new g(function(t) {
890
+ return new S(function(t) {
891
891
  r.then(function(e) {
892
892
  t.closed || (t.next(e), t.complete());
893
893
  }, function(e) {
@@ -896,7 +896,7 @@ function ut(r) {
896
896
  });
897
897
  }
898
898
  function ct(r) {
899
- return new g(function(t) {
899
+ return new S(function(t) {
900
900
  var e, n;
901
901
  try {
902
902
  for (var i = M(r), o = i.next(); !o.done; o = i.next()) {
@@ -917,7 +917,7 @@ function ct(r) {
917
917
  });
918
918
  }
919
919
  function xe(r) {
920
- return new g(function(t) {
920
+ return new S(function(t) {
921
921
  ft(r, t).catch(function(e) {
922
922
  return t.error(e);
923
923
  });
@@ -928,7 +928,7 @@ function lt(r) {
928
928
  }
929
929
  function ft(r, t) {
930
930
  var e, n, i, o;
931
- return Ue(this, void 0, void 0, function() {
931
+ return $e(this, void 0, void 0, function() {
932
932
  var s, c;
933
933
  return ce(this, function(u) {
934
934
  switch (u.label) {
@@ -972,8 +972,8 @@ function A(r, t, e, n, i) {
972
972
  if (r.add(o), !i)
973
973
  return o;
974
974
  }
975
- function Pe(r, t) {
976
- return t === void 0 && (t = 0), P(function(e, n) {
975
+ function Te(r, t) {
976
+ return t === void 0 && (t = 0), T(function(e, n) {
977
977
  e.subscribe(E(n, function(i) {
978
978
  return A(n, r, function() {
979
979
  return n.next(i);
@@ -989,21 +989,21 @@ function Pe(r, t) {
989
989
  }));
990
990
  });
991
991
  }
992
- function Te(r, t) {
993
- return t === void 0 && (t = 0), P(function(e, n) {
992
+ function Ce(r, t) {
993
+ return t === void 0 && (t = 0), T(function(e, n) {
994
994
  n.add(r.schedule(function() {
995
995
  return e.subscribe(n);
996
996
  }, t));
997
997
  });
998
998
  }
999
999
  function ht(r, t) {
1000
- return _(r).pipe(Te(t), Pe(t));
1000
+ return _(r).pipe(Ce(t), Te(t));
1001
1001
  }
1002
1002
  function dt(r, t) {
1003
- return _(r).pipe(Te(t), Pe(t));
1003
+ return _(r).pipe(Ce(t), Te(t));
1004
1004
  }
1005
1005
  function vt(r, t) {
1006
- return new g(function(e) {
1006
+ return new S(function(e) {
1007
1007
  var n = 0;
1008
1008
  return t.schedule(function() {
1009
1009
  n === r.length ? e.complete() : (e.next(r[n++]), e.closed || this.schedule());
@@ -1011,7 +1011,7 @@ function vt(r, t) {
1011
1011
  });
1012
1012
  }
1013
1013
  function yt(r, t) {
1014
- return new g(function(e) {
1014
+ return new S(function(e) {
1015
1015
  var n;
1016
1016
  return A(e, t, function() {
1017
1017
  n = r[Oe](), A(e, t, function() {
@@ -1029,10 +1029,10 @@ function yt(r, t) {
1029
1029
  };
1030
1030
  });
1031
1031
  }
1032
- function Ce(r, t) {
1032
+ function Pe(r, t) {
1033
1033
  if (!r)
1034
1034
  throw new Error("Iterable cannot be null");
1035
- return new g(function(e) {
1035
+ return new S(function(e) {
1036
1036
  A(e, t, function() {
1037
1037
  var n = r[Symbol.asyncIterator]();
1038
1038
  A(e, t, function() {
@@ -1044,18 +1044,18 @@ function Ce(r, t) {
1044
1044
  });
1045
1045
  }
1046
1046
  function pt(r, t) {
1047
- return Ce(Ae(r), t);
1047
+ return Pe(Ae(r), t);
1048
1048
  }
1049
1049
  function bt(r, t) {
1050
1050
  if (r != null) {
1051
- if (Se(r))
1051
+ if (ge(r))
1052
1052
  return ht(r, t);
1053
1053
  if (me(r))
1054
1054
  return vt(r, t);
1055
- if (ge(r))
1055
+ if (Se(r))
1056
1056
  return dt(r, t);
1057
1057
  if (we(r))
1058
- return Ce(r, t);
1058
+ return Pe(r, t);
1059
1059
  if (Ie(r))
1060
1060
  return yt(r, t);
1061
1061
  if (_e(r))
@@ -1072,20 +1072,20 @@ function mt() {
1072
1072
  var e = be(r);
1073
1073
  return Z(r, e);
1074
1074
  }
1075
- function gt(r) {
1075
+ function St(r) {
1076
1076
  return r instanceof Date && !isNaN(r);
1077
1077
  }
1078
1078
  function F(r, t) {
1079
- return P(function(e, n) {
1079
+ return T(function(e, n) {
1080
1080
  var i = 0;
1081
1081
  e.subscribe(E(n, function(o) {
1082
1082
  n.next(r.call(t, o, i++));
1083
1083
  }));
1084
1084
  });
1085
1085
  }
1086
- var St = Array.isArray;
1086
+ var gt = Array.isArray;
1087
1087
  function wt(r, t) {
1088
- return St(t) ? r.apply(void 0, R([], L(t))) : r(t);
1088
+ return gt(t) ? r.apply(void 0, R([], L(t))) : r(t);
1089
1089
  }
1090
1090
  function Et(r) {
1091
1091
  return F(function(t) {
@@ -1098,7 +1098,7 @@ function xt(r) {
1098
1098
  var t = r[0];
1099
1099
  if (Ot(t))
1100
1100
  return { args: t, keys: null };
1101
- if (Pt(t)) {
1101
+ if (Tt(t)) {
1102
1102
  var e = _t(t);
1103
1103
  return {
1104
1104
  args: e.map(function(n) {
@@ -1110,22 +1110,22 @@ function xt(r) {
1110
1110
  }
1111
1111
  return { args: r, keys: null };
1112
1112
  }
1113
- function Pt(r) {
1113
+ function Tt(r) {
1114
1114
  return r && typeof r == "object" && It(r) === At;
1115
1115
  }
1116
- function Tt(r, t) {
1116
+ function Ct(r, t) {
1117
1117
  return r.reduce(function(e, n, i) {
1118
1118
  return e[n] = t[i], e;
1119
1119
  }, {});
1120
1120
  }
1121
- function Ct() {
1121
+ function Pt() {
1122
1122
  for (var r = [], t = 0; t < arguments.length; t++)
1123
1123
  r[t] = arguments[t];
1124
1124
  var e = be(r), n = it(r), i = xt(r), o = i.args, s = i.keys;
1125
1125
  if (o.length === 0)
1126
1126
  return Z([], e);
1127
- var c = new g(Mt(o, e, s ? function(u) {
1128
- return Tt(s, u);
1127
+ var c = new S(Mt(o, e, s ? function(u) {
1128
+ return Ct(s, u);
1129
1129
  } : G));
1130
1130
  return n ? c.pipe(Et(n)) : c;
1131
1131
  }
@@ -1156,13 +1156,13 @@ function Lt(r, t, e, n, i, o, s, c) {
1156
1156
  return a < n ? y(h) : u.push(h);
1157
1157
  }, y = function(h) {
1158
1158
  a++;
1159
- var S = !1;
1159
+ var g = !1;
1160
1160
  _(e(h, l++)).subscribe(E(t, function(w) {
1161
1161
  t.next(w);
1162
1162
  }, function() {
1163
- S = !0;
1163
+ g = !0;
1164
1164
  }, void 0, function() {
1165
- if (S)
1165
+ if (g)
1166
1166
  try {
1167
1167
  a--;
1168
1168
  for (var w = function() {
@@ -1186,15 +1186,15 @@ function N(r, t, e) {
1186
1186
  return F(function(o, s) {
1187
1187
  return t(n, o, i, s);
1188
1188
  })(_(r(n, i)));
1189
- }, e) : (typeof t == "number" && (e = t), P(function(n, i) {
1189
+ }, e) : (typeof t == "number" && (e = t), T(function(n, i) {
1190
1190
  return Lt(n, i, r, e);
1191
1191
  }));
1192
1192
  }
1193
1193
  function Me(r, t, e) {
1194
1194
  r === void 0 && (r = 0), e === void 0 && (e = rt);
1195
1195
  var n = -1;
1196
- return t != null && (ye(t) ? e = t : n = t), new g(function(i) {
1197
- var o = gt(r) ? +r - e.now() : r;
1196
+ return t != null && (ye(t) ? e = t : n = t), new S(function(i) {
1197
+ var o = St(r) ? +r - e.now() : r;
1198
1198
  o < 0 && (o = 0);
1199
1199
  var s = 0;
1200
1200
  return e.schedule(function() {
@@ -1208,7 +1208,7 @@ function Rt(r, t) {
1208
1208
  function kt(r) {
1209
1209
  return r <= 0 ? function() {
1210
1210
  return nt;
1211
- } : P(function(t, e) {
1211
+ } : T(function(t, e) {
1212
1212
  var n = 0;
1213
1213
  t.subscribe(E(e, function(i) {
1214
1214
  ++n <= r && (e.next(i), r <= n && e.complete());
@@ -1220,25 +1220,25 @@ function jt(r) {
1220
1220
  return r;
1221
1221
  });
1222
1222
  }
1223
- function $t(r, t) {
1223
+ function Dt(r, t) {
1224
1224
  return N(function(e, n) {
1225
1225
  return _(r(e, n)).pipe(kt(1), jt(e));
1226
1226
  });
1227
1227
  }
1228
- function Dt(r, t) {
1228
+ function Ut(r, t) {
1229
1229
  t === void 0 && (t = ve);
1230
1230
  var e = Me(r, t);
1231
- return $t(function() {
1231
+ return Dt(function() {
1232
1232
  return e;
1233
1233
  });
1234
1234
  }
1235
- function Ut(r) {
1235
+ function $t(r) {
1236
1236
  var t;
1237
1237
  t = {
1238
1238
  count: r
1239
1239
  };
1240
1240
  var e = t.count, n = e === void 0 ? 1 / 0 : e, i = t.delay, o = t.resetOnSuccess, s = o === void 0 ? !1 : o;
1241
- return n <= 0 ? G : P(function(c, u) {
1241
+ return n <= 0 ? G : T(function(c, u) {
1242
1242
  var a = 0, l, v = function() {
1243
1243
  var b = !1;
1244
1244
  l = c.subscribe(E(u, function(f) {
@@ -1249,12 +1249,12 @@ function Ut(r) {
1249
1249
  l ? (l.unsubscribe(), l = null, v()) : b = !0;
1250
1250
  };
1251
1251
  if (i != null) {
1252
- var h = typeof i == "number" ? Me(i) : _(i(f, a)), S = E(u, function() {
1253
- S.unsubscribe(), y();
1252
+ var h = typeof i == "number" ? Me(i) : _(i(f, a)), g = E(u, function() {
1253
+ g.unsubscribe(), y();
1254
1254
  }, function() {
1255
1255
  u.complete();
1256
1256
  });
1257
- h.subscribe(S);
1257
+ h.subscribe(g);
1258
1258
  } else
1259
1259
  y();
1260
1260
  } else
@@ -1265,7 +1265,7 @@ function Ut(r) {
1265
1265
  });
1266
1266
  }
1267
1267
  function Nt(r) {
1268
- return P(function(t, e) {
1268
+ return T(function(t, e) {
1269
1269
  _(r).subscribe(E(e, function() {
1270
1270
  return e.complete();
1271
1271
  }, q)), !e.closed && t.subscribe(e);
@@ -1343,7 +1343,7 @@ function ae() {
1343
1343
  retry: void 0
1344
1344
  };
1345
1345
  }
1346
- var Kt = function(r, t) {
1346
+ var Bt = function(r, t) {
1347
1347
  var e = {};
1348
1348
  for (var n in r) Object.prototype.hasOwnProperty.call(r, n) && t.indexOf(n) < 0 && (e[n] = r[n]);
1349
1349
  if (r != null && typeof Object.getOwnPropertySymbols == "function")
@@ -1351,18 +1351,18 @@ var Kt = function(r, t) {
1351
1351
  t.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(r, n[i]) && (e[n[i]] = r[n[i]]);
1352
1352
  return e;
1353
1353
  };
1354
- const X = "text/event-stream", Bt = 1e3, ue = "last-event-id";
1354
+ const J = "text/event-stream", Kt = 1e3, ue = "last-event-id";
1355
1355
  function Yt(r, t) {
1356
- var { signal: e, headers: n, onopen: i, onmessage: o, onclose: s, onerror: c, openWhenHidden: u, fetch: a } = t, l = Kt(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
1356
+ var { signal: e, headers: n, onopen: i, onmessage: o, onclose: s, onerror: c, openWhenHidden: u, fetch: a } = t, l = Bt(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
1357
1357
  return new Promise((v, b) => {
1358
1358
  const f = Object.assign({}, n);
1359
- f.accept || (f.accept = X);
1359
+ f.accept || (f.accept = J);
1360
1360
  let y;
1361
1361
  function h() {
1362
1362
  y.abort(), document.hidden || H();
1363
1363
  }
1364
1364
  u || document.addEventListener("visibilitychange", h);
1365
- let S = Bt, w = 0;
1365
+ let g = Kt, w = 0;
1366
1366
  function x() {
1367
1367
  document.removeEventListener("visibilitychange", h), window.clearTimeout(w), y.abort();
1368
1368
  }
@@ -1378,12 +1378,12 @@ function Yt(r, t) {
1378
1378
  await ke(j), await Gt(j.body, Ft(Ht((I) => {
1379
1379
  I ? f[ue] = I : delete f[ue];
1380
1380
  }, (I) => {
1381
- S = I;
1381
+ g = I;
1382
1382
  }, o))), s == null || s(), x(), v();
1383
1383
  } catch (j) {
1384
1384
  if (!y.signal.aborted)
1385
1385
  try {
1386
- const I = (V = c == null ? void 0 : c(j)) !== null && V !== void 0 ? V : S;
1386
+ const I = (V = c == null ? void 0 : c(j)) !== null && V !== void 0 ? V : g;
1387
1387
  window.clearTimeout(w), w = window.setTimeout(H, I);
1388
1388
  } catch (I) {
1389
1389
  x(), b(I);
@@ -1395,12 +1395,12 @@ function Yt(r, t) {
1395
1395
  }
1396
1396
  function qt(r) {
1397
1397
  const t = r.headers.get("content-type");
1398
- if (!(t != null && t.startsWith(X)))
1399
- throw new Error(`Expected content-type to be ${X}, Actual: ${t}`);
1398
+ if (!(t != null && t.startsWith(J)))
1399
+ throw new Error(`Expected content-type to be ${J}, Actual: ${t}`);
1400
1400
  }
1401
1401
  function Wt(r) {
1402
1402
  const { endpoint: t, apiKey: e, payload: n, debugMode: i } = r;
1403
- return new g((o) => {
1403
+ return new S((o) => {
1404
1404
  const s = new AbortController(), c = {
1405
1405
  "Content-Type": "application/json"
1406
1406
  };
@@ -1435,7 +1435,7 @@ function Wt(r) {
1435
1435
  };
1436
1436
  });
1437
1437
  }
1438
- class Xt {
1438
+ class Jt {
1439
1439
  constructor() {
1440
1440
  m(this, "listeners", {});
1441
1441
  }
@@ -1460,14 +1460,13 @@ class zt {
1460
1460
  constructor(t) {
1461
1461
  m(this, "apiKey");
1462
1462
  m(this, "endpoint");
1463
- m(this, "botProviderEndpoint");
1464
1463
  m(this, "debugMode");
1465
1464
  m(this, "destroy$", new Q());
1466
- m(this, "sseEmitter", new Xt());
1465
+ m(this, "sseEmitter", new Jt());
1467
1466
  m(this, "transformSsePayload");
1468
1467
  if (!t.endpoint && !t.botProviderEndpoint)
1469
1468
  throw new Error("Either endpoint or botProviderEndpoint must be provided");
1470
- if (this.apiKey = t.apiKey, this.debugMode = t.debugMode, this.transformSsePayload = t.transformSsePayload, this.botProviderEndpoint = t.botProviderEndpoint, !t.endpoint && t.botProviderEndpoint) {
1469
+ if (this.apiKey = t.apiKey, this.debugMode = t.debugMode, this.transformSsePayload = t.transformSsePayload, !t.endpoint && t.botProviderEndpoint) {
1471
1470
  const e = t.botProviderEndpoint.replace(/\/+$/, "");
1472
1471
  this.endpoint = `${e}/message/sse`;
1473
1472
  } else t.endpoint && (this.endpoint = t.endpoint, this.debugMode && console.warn(
@@ -1529,9 +1528,9 @@ class zt {
1529
1528
  debugMode: this.debugMode,
1530
1529
  payload: ((i = this.transformSsePayload) == null ? void 0 : i.call(this, t)) ?? t
1531
1530
  }).pipe(
1532
- Rt((o) => mt(o).pipe(Dt((e == null ? void 0 : e.delayTime) ?? 50))),
1531
+ Rt((o) => mt(o).pipe(Ut((e == null ? void 0 : e.delayTime) ?? 50))),
1533
1532
  Nt(this.destroy$),
1534
- Ut(3)
1533
+ $t(3)
1535
1534
  ).subscribe({
1536
1535
  next: (o) => {
1537
1536
  var s;
@@ -1550,50 +1549,6 @@ class zt {
1550
1549
  close() {
1551
1550
  this.destroy$.next(), this.destroy$.complete();
1552
1551
  }
1553
- /**
1554
- * 上傳檔案到 Blob API
1555
- * 根據 API 文件:/generic/ns/{namespace}/bot-provider/{bot_provider_name}/blob
1556
- */
1557
- async uploadFile(t, e) {
1558
- const n = this.deriveBlobEndpoint();
1559
- if (!n)
1560
- throw new Error("Unable to derive blob endpoint. Please provide botProviderEndpoint in config.");
1561
- const i = new FormData();
1562
- i.append("file", t), i.append("customChannelId", e);
1563
- const o = {};
1564
- this.apiKey && (o["X-API-KEY"] = this.apiKey);
1565
- try {
1566
- const s = await fetch(n, {
1567
- method: "POST",
1568
- headers: o,
1569
- body: i
1570
- });
1571
- if (!s.ok)
1572
- throw new Error(`Upload failed: ${s.status} ${s.statusText}`);
1573
- const c = await s.json();
1574
- return this.debugMode && console.log("[AsgardServiceClient] File upload response:", c), c;
1575
- } catch (s) {
1576
- throw console.error("[AsgardServiceClient] File upload error:", s), s;
1577
- }
1578
- }
1579
- /**
1580
- * 從 botProviderEndpoint 衍生 Blob API endpoint
1581
- */
1582
- deriveBlobEndpoint() {
1583
- if (!this.botProviderEndpoint && !this.endpoint)
1584
- return null;
1585
- let t = this.botProviderEndpoint;
1586
- if (!t && this.endpoint && (t = this.endpoint.replace("/message/sse", "")), !t)
1587
- return null;
1588
- if (t = t.replace(/\/+$/, ""), !t.includes("/generic/")) {
1589
- const e = t.match(/^(https?:\/\/[^\/]+)(\/.*)/);
1590
- if (e) {
1591
- const [, n, i] = e;
1592
- t = `${n}/generic${i}`;
1593
- }
1594
- }
1595
- return `${t}/blob`;
1596
- }
1597
1552
  }
1598
1553
  class Le {
1599
1554
  constructor(t) {
@@ -1619,7 +1574,7 @@ class Le {
1619
1574
  }
1620
1575
  }
1621
1576
  subscribe() {
1622
- this.statesSubscription = Ct([
1577
+ this.statesSubscription = Pt([
1623
1578
  this.isConnecting$,
1624
1579
  this.conversation$
1625
1580
  ]).pipe(
@@ -1651,7 +1606,7 @@ class Le {
1651
1606
  resetChannel(t, e) {
1652
1607
  return this.fetchSse(
1653
1608
  {
1654
- action: B.RESET_CHANNEL,
1609
+ action: K.RESET_CHANNEL,
1655
1610
  customChannelId: this.customChannelId,
1656
1611
  customMessageId: this.customMessageId,
1657
1612
  text: (t == null ? void 0 : t.text) || "",
@@ -1667,18 +1622,15 @@ class Le {
1667
1622
  type: "user",
1668
1623
  messageId: i,
1669
1624
  text: n,
1670
- blobIds: t.blobIds,
1671
1625
  time: /* @__PURE__ */ new Date()
1672
1626
  })
1673
1627
  ), this.fetchSse(
1674
1628
  {
1675
- action: B.NONE,
1629
+ action: K.NONE,
1676
1630
  customChannelId: this.customChannelId,
1677
1631
  customMessageId: i,
1678
1632
  payload: t == null ? void 0 : t.payload,
1679
- text: n,
1680
- blobIds: t == null ? void 0 : t.blobIds
1681
- // 新增:支援 blobIds
1633
+ text: n
1682
1634
  },
1683
1635
  e
1684
1636
  );
@@ -1688,14 +1640,14 @@ class Le {
1688
1640
  this.isConnecting$.complete(), this.conversation$.complete(), (t = this.statesSubscription) == null || t.unsubscribe();
1689
1641
  }
1690
1642
  }
1691
- class T {
1643
+ class C {
1692
1644
  constructor({ messages: t }) {
1693
1645
  m(this, "messages", null);
1694
1646
  this.messages = t;
1695
1647
  }
1696
1648
  pushMessage(t) {
1697
1649
  const e = new Map(this.messages);
1698
- return e.set(t.messageId, t), new T({ messages: e });
1650
+ return e.set(t.messageId, t), new C({ messages: e });
1699
1651
  }
1700
1652
  onMessage(t) {
1701
1653
  switch (t.eventType) {
@@ -1727,7 +1679,7 @@ class T {
1727
1679
  messageId: e.messageId,
1728
1680
  message: e,
1729
1681
  time: /* @__PURE__ */ new Date()
1730
- }), new T({ messages: n });
1682
+ }), new C({ messages: n });
1731
1683
  }
1732
1684
  onMessageDelta(t) {
1733
1685
  const e = t.fact.messageDelta.message, n = new Map(this.messages), i = n.get(e.messageId);
@@ -1741,7 +1693,7 @@ class T {
1741
1693
  messageId: e.messageId,
1742
1694
  message: e,
1743
1695
  time: /* @__PURE__ */ new Date()
1744
- }), new T({ messages: n });
1696
+ }), new C({ messages: n });
1745
1697
  }
1746
1698
  onMessageComplete(t) {
1747
1699
  const e = t.fact.messageComplete.message, n = new Map(this.messages);
@@ -1753,7 +1705,7 @@ class T {
1753
1705
  messageId: e.messageId,
1754
1706
  message: e,
1755
1707
  time: /* @__PURE__ */ new Date()
1756
- }), new T({ messages: n });
1708
+ }), new C({ messages: n });
1757
1709
  }
1758
1710
  onMessageError(t) {
1759
1711
  const e = crypto.randomUUID(), n = t.fact.runError.error, i = new Map(this.messages);
@@ -1763,15 +1715,15 @@ class T {
1763
1715
  messageId: e,
1764
1716
  error: n,
1765
1717
  time: /* @__PURE__ */ new Date()
1766
- }), new T({ messages: i });
1718
+ }), new C({ messages: i });
1767
1719
  }
1768
1720
  }
1769
1721
  export {
1770
1722
  zt as AsgardServiceClient,
1771
1723
  Le as Channel,
1772
- T as Conversation,
1724
+ C as Conversation,
1773
1725
  d as EventType,
1774
- B as FetchSseAction,
1775
- De as MessageTemplateType
1726
+ K as FetchSseAction,
1727
+ Ue as MessageTemplateType
1776
1728
  };
1777
1729
  //# sourceMappingURL=index.mjs.map