@asgard-js/core 0.0.44-canary.2 → 0.0.44-canary.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -17
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +167 -119
- package/dist/index.mjs.map +1 -1
- package/dist/lib/channel.d.ts +3 -1
- package/dist/lib/channel.d.ts.map +1 -1
- package/dist/lib/client.d.ts +11 -1
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/types/blob.d.ts +22 -0
- package/dist/types/blob.d.ts.map +1 -0
- package/dist/types/channel.d.ts +2 -0
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/client.d.ts +3 -0
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var je = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var m = (r, t, e) =>
|
|
4
|
-
var
|
|
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 || {}), 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
|
|
20
|
+
function De(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
|
|
140
|
-
return this instanceof
|
|
139
|
+
function C(r) {
|
|
140
|
+
return this instanceof C ? (this.v = r, this) : new C(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(
|
|
156
|
-
o.push([f, h,
|
|
155
|
+
return new Promise(function(S, w) {
|
|
156
|
+
o.push([f, h, S, 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
|
|
168
|
+
f.value instanceof C ? 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
|
|
208
|
+
var K = 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 B = le(function(r) {
|
|
|
214
214
|
`) : "", this.name = "UnsubscriptionError", this.errors = e;
|
|
215
215
|
};
|
|
216
216
|
});
|
|
217
|
-
function
|
|
217
|
+
function D(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
|
|
255
|
+
o = h instanceof K ? 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
|
|
266
|
+
o = o ?? [], h instanceof K ? 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
|
|
280
|
+
throw new K(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) &&
|
|
303
|
+
e === t ? this._parentage = null : Array.isArray(e) && D(e, t);
|
|
304
304
|
}, r.prototype.remove = function(t) {
|
|
305
305
|
var e = this._finalizers;
|
|
306
|
-
e &&
|
|
306
|
+
e && D(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;
|
|
@@ -338,11 +338,11 @@ function q() {
|
|
|
338
338
|
function U(r) {
|
|
339
339
|
r();
|
|
340
340
|
}
|
|
341
|
-
var
|
|
341
|
+
var J = (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 =
|
|
345
|
+
return n.isStopped = !1, e ? (n.destination = e, he(e) && e.add(n)) : n.destination = Be, 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 X = (function(r) {
|
|
|
379
379
|
try {
|
|
380
380
|
e.next(t);
|
|
381
381
|
} catch (n) {
|
|
382
|
-
|
|
382
|
+
$(n);
|
|
383
383
|
}
|
|
384
384
|
}, r.prototype.error = function(t) {
|
|
385
385
|
var e = this.partialObserver;
|
|
@@ -387,17 +387,17 @@ var X = (function(r) {
|
|
|
387
387
|
try {
|
|
388
388
|
e.error(t);
|
|
389
389
|
} catch (n) {
|
|
390
|
-
|
|
390
|
+
$(n);
|
|
391
391
|
}
|
|
392
392
|
else
|
|
393
|
-
|
|
393
|
+
$(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
|
-
|
|
400
|
+
$(e);
|
|
401
401
|
}
|
|
402
402
|
}, r;
|
|
403
403
|
})(), W = (function(r) {
|
|
@@ -411,17 +411,17 @@ var X = (function(r) {
|
|
|
411
411
|
} : s = e, o.destination = new Ve(s), o;
|
|
412
412
|
}
|
|
413
413
|
return t;
|
|
414
|
-
})(
|
|
415
|
-
function
|
|
414
|
+
})(J);
|
|
415
|
+
function $(r) {
|
|
416
416
|
de(r);
|
|
417
417
|
}
|
|
418
|
-
function
|
|
418
|
+
function Ke(r) {
|
|
419
419
|
throw r;
|
|
420
420
|
}
|
|
421
|
-
var
|
|
421
|
+
var Be = {
|
|
422
422
|
closed: !0,
|
|
423
423
|
next: q,
|
|
424
|
-
error:
|
|
424
|
+
error: Ke,
|
|
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
|
|
439
|
+
var g = (function() {
|
|
440
440
|
function r(t) {
|
|
441
441
|
t && (this._subscribe = t);
|
|
442
442
|
}
|
|
@@ -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
|
|
507
|
+
return r && r instanceof J || qe(r) && he(r);
|
|
508
508
|
}
|
|
509
|
-
function
|
|
509
|
+
function Xe(r) {
|
|
510
510
|
return p(r == null ? void 0 : r.lift);
|
|
511
511
|
}
|
|
512
|
-
function
|
|
512
|
+
function P(r) {
|
|
513
513
|
return function(t) {
|
|
514
|
-
if (
|
|
514
|
+
if (Xe(t))
|
|
515
515
|
return t.lift(function(e) {
|
|
516
516
|
try {
|
|
517
517
|
return r(e, this);
|
|
@@ -523,9 +523,9 @@ function T(r) {
|
|
|
523
523
|
};
|
|
524
524
|
}
|
|
525
525
|
function E(r, t, e, n, i) {
|
|
526
|
-
return new
|
|
526
|
+
return new Je(r, t, e, n, i);
|
|
527
527
|
}
|
|
528
|
-
var
|
|
528
|
+
var Je = (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 Xe = (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
|
-
})(
|
|
563
|
+
})(J), ze = le(function(r) {
|
|
564
564
|
return function() {
|
|
565
565
|
r(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
|
|
566
566
|
};
|
|
@@ -632,18 +632,18 @@ var Xe = (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,
|
|
635
|
+
n.currentObservers = null, D(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
|
|
641
|
+
var e = new g();
|
|
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
|
-
})(
|
|
646
|
+
})(g), 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 Xe = (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,
|
|
749
|
+
this.work = this.state = this.scheduler = null, this.pending = !1, D(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 Xe = (function(r) {
|
|
|
781
781
|
throw i;
|
|
782
782
|
}
|
|
783
783
|
}, t;
|
|
784
|
-
})(oe), ve = new tt(et), rt = ve, nt = new
|
|
784
|
+
})(oe), ve = new tt(et), rt = ve, nt = new g(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
|
|
802
|
+
function ge(r) {
|
|
803
803
|
return p(r == null ? void 0 : r.then);
|
|
804
804
|
}
|
|
805
|
-
function
|
|
805
|
+
function Se(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,
|
|
831
|
+
return [4, C(e.read())];
|
|
832
832
|
case 3:
|
|
833
|
-
return n = s.sent(), i = n.value, o = n.done, o ? [4,
|
|
833
|
+
return n = s.sent(), i = n.value, o = n.done, o ? [4, C(void 0)] : [3, 5];
|
|
834
834
|
case 4:
|
|
835
835
|
return [2, s.sent()];
|
|
836
836
|
case 5:
|
|
837
|
-
return [4,
|
|
837
|
+
return [4, C(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
|
|
856
|
+
if (r instanceof g)
|
|
857
857
|
return r;
|
|
858
858
|
if (r != null) {
|
|
859
|
-
if (
|
|
859
|
+
if (Se(r))
|
|
860
860
|
return st(r);
|
|
861
861
|
if (me(r))
|
|
862
862
|
return at(r);
|
|
863
|
-
if (
|
|
863
|
+
if (ge(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
|
|
875
|
+
return new g(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
|
|
883
|
+
return new g(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
|
|
890
|
+
return new g(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
|
|
899
|
+
return new g(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
|
|
920
|
+
return new g(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
|
|
931
|
+
return De(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
|
|
976
|
-
return t === void 0 && (t = 0),
|
|
975
|
+
function Pe(r, t) {
|
|
976
|
+
return t === void 0 && (t = 0), P(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 Te(r, t) {
|
|
|
989
989
|
}));
|
|
990
990
|
});
|
|
991
991
|
}
|
|
992
|
-
function
|
|
993
|
-
return t === void 0 && (t = 0),
|
|
992
|
+
function Te(r, t) {
|
|
993
|
+
return t === void 0 && (t = 0), P(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(
|
|
1000
|
+
return _(r).pipe(Te(t), Pe(t));
|
|
1001
1001
|
}
|
|
1002
1002
|
function dt(r, t) {
|
|
1003
|
-
return _(r).pipe(
|
|
1003
|
+
return _(r).pipe(Te(t), Pe(t));
|
|
1004
1004
|
}
|
|
1005
1005
|
function vt(r, t) {
|
|
1006
|
-
return new
|
|
1006
|
+
return new g(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
|
|
1014
|
+
return new g(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
|
|
1032
|
+
function Ce(r, t) {
|
|
1033
1033
|
if (!r)
|
|
1034
1034
|
throw new Error("Iterable cannot be null");
|
|
1035
|
-
return new
|
|
1035
|
+
return new g(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 Pe(r, t) {
|
|
|
1044
1044
|
});
|
|
1045
1045
|
}
|
|
1046
1046
|
function pt(r, t) {
|
|
1047
|
-
return
|
|
1047
|
+
return Ce(Ae(r), t);
|
|
1048
1048
|
}
|
|
1049
1049
|
function bt(r, t) {
|
|
1050
1050
|
if (r != null) {
|
|
1051
|
-
if (
|
|
1051
|
+
if (Se(r))
|
|
1052
1052
|
return ht(r, t);
|
|
1053
1053
|
if (me(r))
|
|
1054
1054
|
return vt(r, t);
|
|
1055
|
-
if (
|
|
1055
|
+
if (ge(r))
|
|
1056
1056
|
return dt(r, t);
|
|
1057
1057
|
if (we(r))
|
|
1058
|
-
return
|
|
1058
|
+
return Ce(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
|
|
1075
|
+
function gt(r) {
|
|
1076
1076
|
return r instanceof Date && !isNaN(r);
|
|
1077
1077
|
}
|
|
1078
1078
|
function F(r, t) {
|
|
1079
|
-
return
|
|
1079
|
+
return P(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
|
|
1086
|
+
var St = Array.isArray;
|
|
1087
1087
|
function wt(r, t) {
|
|
1088
|
-
return
|
|
1088
|
+
return St(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 (
|
|
1101
|
+
if (Pt(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
|
|
1113
|
+
function Pt(r) {
|
|
1114
1114
|
return r && typeof r == "object" && It(r) === At;
|
|
1115
1115
|
}
|
|
1116
|
-
function
|
|
1116
|
+
function Tt(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
|
|
1121
|
+
function Ct() {
|
|
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
|
|
1128
|
-
return
|
|
1127
|
+
var c = new g(Mt(o, e, s ? function(u) {
|
|
1128
|
+
return Tt(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
|
|
1159
|
+
var S = !1;
|
|
1160
1160
|
_(e(h, l++)).subscribe(E(t, function(w) {
|
|
1161
1161
|
t.next(w);
|
|
1162
1162
|
}, function() {
|
|
1163
|
-
|
|
1163
|
+
S = !0;
|
|
1164
1164
|
}, void 0, function() {
|
|
1165
|
-
if (
|
|
1165
|
+
if (S)
|
|
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),
|
|
1189
|
+
}, e) : (typeof t == "number" && (e = t), P(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
|
|
1197
|
-
var o =
|
|
1196
|
+
return t != null && (ye(t) ? e = t : n = t), new g(function(i) {
|
|
1197
|
+
var o = gt(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
|
-
} :
|
|
1211
|
+
} : P(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,7 +1220,7 @@ function jt(r) {
|
|
|
1220
1220
|
return r;
|
|
1221
1221
|
});
|
|
1222
1222
|
}
|
|
1223
|
-
function
|
|
1223
|
+
function $t(r, t) {
|
|
1224
1224
|
return N(function(e, n) {
|
|
1225
1225
|
return _(r(e, n)).pipe(kt(1), jt(e));
|
|
1226
1226
|
});
|
|
@@ -1228,17 +1228,17 @@ function Dt(r, t) {
|
|
|
1228
1228
|
function Ut(r, t) {
|
|
1229
1229
|
t === void 0 && (t = ve);
|
|
1230
1230
|
var e = Me(r, t);
|
|
1231
|
-
return
|
|
1231
|
+
return $t(function() {
|
|
1232
1232
|
return e;
|
|
1233
1233
|
});
|
|
1234
1234
|
}
|
|
1235
|
-
function
|
|
1235
|
+
function Dt(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 :
|
|
1241
|
+
return n <= 0 ? G : P(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 $t(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)),
|
|
1253
|
-
|
|
1252
|
+
var h = typeof i == "number" ? Me(i) : _(i(f, a)), S = E(u, function() {
|
|
1253
|
+
S.unsubscribe(), y();
|
|
1254
1254
|
}, function() {
|
|
1255
1255
|
u.complete();
|
|
1256
1256
|
});
|
|
1257
|
-
h.subscribe(
|
|
1257
|
+
h.subscribe(S);
|
|
1258
1258
|
} else
|
|
1259
1259
|
y();
|
|
1260
1260
|
} else
|
|
@@ -1265,7 +1265,7 @@ function $t(r) {
|
|
|
1265
1265
|
});
|
|
1266
1266
|
}
|
|
1267
1267
|
function Nt(r) {
|
|
1268
|
-
return
|
|
1268
|
+
return P(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
|
|
1346
|
+
var Kt = 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 Bt = 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
|
|
1354
|
+
const X = "text/event-stream", Bt = 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 =
|
|
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"]);
|
|
1357
1357
|
return new Promise((v, b) => {
|
|
1358
1358
|
const f = Object.assign({}, n);
|
|
1359
|
-
f.accept || (f.accept =
|
|
1359
|
+
f.accept || (f.accept = X);
|
|
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
|
|
1365
|
+
let S = Bt, 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
|
-
|
|
1381
|
+
S = 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 :
|
|
1386
|
+
const I = (V = c == null ? void 0 : c(j)) !== null && V !== void 0 ? V : S;
|
|
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(
|
|
1399
|
-
throw new Error(`Expected content-type to be ${
|
|
1398
|
+
if (!(t != null && t.startsWith(X)))
|
|
1399
|
+
throw new Error(`Expected content-type to be ${X}, Actual: ${t}`);
|
|
1400
1400
|
}
|
|
1401
1401
|
function Wt(r) {
|
|
1402
1402
|
const { endpoint: t, apiKey: e, payload: n, debugMode: i } = r;
|
|
1403
|
-
return new
|
|
1403
|
+
return new g((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
|
|
1438
|
+
class Xt {
|
|
1439
1439
|
constructor() {
|
|
1440
1440
|
m(this, "listeners", {});
|
|
1441
1441
|
}
|
|
@@ -1460,13 +1460,14 @@ class zt {
|
|
|
1460
1460
|
constructor(t) {
|
|
1461
1461
|
m(this, "apiKey");
|
|
1462
1462
|
m(this, "endpoint");
|
|
1463
|
+
m(this, "botProviderEndpoint");
|
|
1463
1464
|
m(this, "debugMode");
|
|
1464
1465
|
m(this, "destroy$", new Q());
|
|
1465
|
-
m(this, "sseEmitter", new
|
|
1466
|
+
m(this, "sseEmitter", new Xt());
|
|
1466
1467
|
m(this, "transformSsePayload");
|
|
1467
1468
|
if (!t.endpoint && !t.botProviderEndpoint)
|
|
1468
1469
|
throw new Error("Either endpoint or botProviderEndpoint must be provided");
|
|
1469
|
-
if (this.apiKey = t.apiKey, this.debugMode = t.debugMode, this.transformSsePayload = t.transformSsePayload, !t.endpoint && t.botProviderEndpoint) {
|
|
1470
|
+
if (this.apiKey = t.apiKey, this.debugMode = t.debugMode, this.transformSsePayload = t.transformSsePayload, this.botProviderEndpoint = t.botProviderEndpoint, !t.endpoint && t.botProviderEndpoint) {
|
|
1470
1471
|
const e = t.botProviderEndpoint.replace(/\/+$/, "");
|
|
1471
1472
|
this.endpoint = `${e}/message/sse`;
|
|
1472
1473
|
} else t.endpoint && (this.endpoint = t.endpoint, this.debugMode && console.warn(
|
|
@@ -1530,7 +1531,7 @@ class zt {
|
|
|
1530
1531
|
}).pipe(
|
|
1531
1532
|
Rt((o) => mt(o).pipe(Ut((e == null ? void 0 : e.delayTime) ?? 50))),
|
|
1532
1533
|
Nt(this.destroy$),
|
|
1533
|
-
|
|
1534
|
+
Dt(3)
|
|
1534
1535
|
).subscribe({
|
|
1535
1536
|
next: (o) => {
|
|
1536
1537
|
var s;
|
|
@@ -1549,6 +1550,50 @@ class zt {
|
|
|
1549
1550
|
close() {
|
|
1550
1551
|
this.destroy$.next(), this.destroy$.complete();
|
|
1551
1552
|
}
|
|
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
|
+
}
|
|
1552
1597
|
}
|
|
1553
1598
|
class Le {
|
|
1554
1599
|
constructor(t) {
|
|
@@ -1574,7 +1619,7 @@ class Le {
|
|
|
1574
1619
|
}
|
|
1575
1620
|
}
|
|
1576
1621
|
subscribe() {
|
|
1577
|
-
this.statesSubscription =
|
|
1622
|
+
this.statesSubscription = Ct([
|
|
1578
1623
|
this.isConnecting$,
|
|
1579
1624
|
this.conversation$
|
|
1580
1625
|
]).pipe(
|
|
@@ -1606,7 +1651,7 @@ class Le {
|
|
|
1606
1651
|
resetChannel(t, e) {
|
|
1607
1652
|
return this.fetchSse(
|
|
1608
1653
|
{
|
|
1609
|
-
action:
|
|
1654
|
+
action: B.RESET_CHANNEL,
|
|
1610
1655
|
customChannelId: this.customChannelId,
|
|
1611
1656
|
customMessageId: this.customMessageId,
|
|
1612
1657
|
text: (t == null ? void 0 : t.text) || "",
|
|
@@ -1622,15 +1667,18 @@ class Le {
|
|
|
1622
1667
|
type: "user",
|
|
1623
1668
|
messageId: i,
|
|
1624
1669
|
text: n,
|
|
1670
|
+
blobIds: t.blobIds,
|
|
1671
|
+
filePreviewUrls: t.filePreviewUrls,
|
|
1625
1672
|
time: /* @__PURE__ */ new Date()
|
|
1626
1673
|
})
|
|
1627
1674
|
), this.fetchSse(
|
|
1628
1675
|
{
|
|
1629
|
-
action:
|
|
1676
|
+
action: B.NONE,
|
|
1630
1677
|
customChannelId: this.customChannelId,
|
|
1631
1678
|
customMessageId: i,
|
|
1632
1679
|
payload: t == null ? void 0 : t.payload,
|
|
1633
|
-
text: n
|
|
1680
|
+
text: n,
|
|
1681
|
+
blobIds: t == null ? void 0 : t.blobIds
|
|
1634
1682
|
},
|
|
1635
1683
|
e
|
|
1636
1684
|
);
|
|
@@ -1640,14 +1688,14 @@ class Le {
|
|
|
1640
1688
|
this.isConnecting$.complete(), this.conversation$.complete(), (t = this.statesSubscription) == null || t.unsubscribe();
|
|
1641
1689
|
}
|
|
1642
1690
|
}
|
|
1643
|
-
class
|
|
1691
|
+
class T {
|
|
1644
1692
|
constructor({ messages: t }) {
|
|
1645
1693
|
m(this, "messages", null);
|
|
1646
1694
|
this.messages = t;
|
|
1647
1695
|
}
|
|
1648
1696
|
pushMessage(t) {
|
|
1649
1697
|
const e = new Map(this.messages);
|
|
1650
|
-
return e.set(t.messageId, t), new
|
|
1698
|
+
return e.set(t.messageId, t), new T({ messages: e });
|
|
1651
1699
|
}
|
|
1652
1700
|
onMessage(t) {
|
|
1653
1701
|
switch (t.eventType) {
|
|
@@ -1679,7 +1727,7 @@ class C {
|
|
|
1679
1727
|
messageId: e.messageId,
|
|
1680
1728
|
message: e,
|
|
1681
1729
|
time: /* @__PURE__ */ new Date()
|
|
1682
|
-
}), new
|
|
1730
|
+
}), new T({ messages: n });
|
|
1683
1731
|
}
|
|
1684
1732
|
onMessageDelta(t) {
|
|
1685
1733
|
const e = t.fact.messageDelta.message, n = new Map(this.messages), i = n.get(e.messageId);
|
|
@@ -1693,7 +1741,7 @@ class C {
|
|
|
1693
1741
|
messageId: e.messageId,
|
|
1694
1742
|
message: e,
|
|
1695
1743
|
time: /* @__PURE__ */ new Date()
|
|
1696
|
-
}), new
|
|
1744
|
+
}), new T({ messages: n });
|
|
1697
1745
|
}
|
|
1698
1746
|
onMessageComplete(t) {
|
|
1699
1747
|
const e = t.fact.messageComplete.message, n = new Map(this.messages);
|
|
@@ -1705,7 +1753,7 @@ class C {
|
|
|
1705
1753
|
messageId: e.messageId,
|
|
1706
1754
|
message: e,
|
|
1707
1755
|
time: /* @__PURE__ */ new Date()
|
|
1708
|
-
}), new
|
|
1756
|
+
}), new T({ messages: n });
|
|
1709
1757
|
}
|
|
1710
1758
|
onMessageError(t) {
|
|
1711
1759
|
const e = crypto.randomUUID(), n = t.fact.runError.error, i = new Map(this.messages);
|
|
@@ -1715,15 +1763,15 @@ class C {
|
|
|
1715
1763
|
messageId: e,
|
|
1716
1764
|
error: n,
|
|
1717
1765
|
time: /* @__PURE__ */ new Date()
|
|
1718
|
-
}), new
|
|
1766
|
+
}), new T({ messages: i });
|
|
1719
1767
|
}
|
|
1720
1768
|
}
|
|
1721
1769
|
export {
|
|
1722
1770
|
zt as AsgardServiceClient,
|
|
1723
1771
|
Le as Channel,
|
|
1724
|
-
|
|
1772
|
+
T as Conversation,
|
|
1725
1773
|
d as EventType,
|
|
1726
|
-
|
|
1774
|
+
B as FetchSseAction,
|
|
1727
1775
|
Ue as MessageTemplateType
|
|
1728
1776
|
};
|
|
1729
1777
|
//# sourceMappingURL=index.mjs.map
|