@asgard-js/core 0.3.6 → 0.3.7
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.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 +355 -330
- package/dist/index.mjs.map +1 -1
- package/dist/lib/channel.d.ts +8 -0
- package/dist/lib/channel.d.ts.map +1 -1
- package/dist/lib/client.d.ts +3 -2
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/types/client.d.ts +7 -2
- package/dist/types/client.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ class te extends Error {
|
|
|
6
6
|
super(`HTTP ${t}: ${e}`), this.name = "HttpError", this.status = t, this.statusText = e, this.body = r;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function wn(n) {
|
|
10
10
|
return n instanceof te;
|
|
11
11
|
}
|
|
12
12
|
var H = /* @__PURE__ */ ((n) => (n.RESET_CHANNEL = "RESET_CHANNEL", n.NONE = "NONE", n.RESPONSE_TOOL_CALL_CONSENT = "RESPONSE_TOOL_CALL_CONSENT", n))(H || {}), d = /* @__PURE__ */ ((n) => (n.INIT = "asgard.run.init", n.PROCESS = "asgard.process", n.PROCESS_START = "asgard.process.start", n.PROCESS_COMPLETE = "asgard.process.complete", n.MESSAGE = "asgard.message", n.MESSAGE_START = "asgard.message.start", n.MESSAGE_DELTA = "asgard.message.delta", n.MESSAGE_COMPLETE = "asgard.message.complete", n.MESSAGE_USER = "asgard.message.user", n.MESSAGE_THINKING_START = "asgard.message.thinking.start", n.MESSAGE_THINKING_DELTA = "asgard.message.thinking.delta", n.MESSAGE_THINKING_COMPLETE = "asgard.message.thinking.complete", n.TOOL_CALL = "asgard.tool_call", n.TOOL_CALL_START = "asgard.tool_call.start", n.TOOL_CALL_COMPLETE = "asgard.tool_call.complete", n.TOOL_CALL_CONSENT = "asgard.tool_call.consent", n.SUBAGENT_START = "asgard.subagent.start", n.SUBAGENT_COMPLETE = "asgard.subagent.complete", n.CHANNEL_TITLE_UPDATE = "asgard.channel.title.update", n.DONE = "asgard.run.done", n.ERROR = "asgard.run.error", n))(d || {}), Ke = /* @__PURE__ */ ((n) => (n.ALLOW_ONCE = "ALLOW_ONCE", n.ALLOW_ALWAYS = "ALLOW_ALWAYS", n.DENY_ONCE = "DENY_ONCE", n))(Ke || {}), Fe = /* @__PURE__ */ ((n) => (n.TEXT = "TEXT", n.HINT = "HINT", n.BUTTON = "BUTTON", n.IMAGE = "IMAGE", n.VIDEO = "VIDEO", n.AUDIO = "AUDIO", n.LOCATION = "LOCATION", n.CAROUSEL = "CAROUSEL", n.CHART = "CHART", n.TABLE = "TABLE", n.ATTACHMENT = "ATTACHMENT", n))(Fe || {}), z = function(n, t) {
|
|
@@ -26,40 +26,40 @@ function w(n, t) {
|
|
|
26
26
|
n.prototype = t === null ? Object.create(t) : (e.prototype = t.prototype, new e());
|
|
27
27
|
}
|
|
28
28
|
function Be(n, t, e, r) {
|
|
29
|
-
function s(
|
|
30
|
-
return
|
|
31
|
-
i
|
|
29
|
+
function s(i) {
|
|
30
|
+
return i instanceof e ? i : new e(function(o) {
|
|
31
|
+
o(i);
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
-
return new (e || (e = Promise))(function(
|
|
34
|
+
return new (e || (e = Promise))(function(i, o) {
|
|
35
35
|
function a(h) {
|
|
36
36
|
try {
|
|
37
37
|
c(r.next(h));
|
|
38
38
|
} catch (m) {
|
|
39
|
-
|
|
39
|
+
o(m);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
function u(h) {
|
|
43
43
|
try {
|
|
44
44
|
c(r.throw(h));
|
|
45
45
|
} catch (m) {
|
|
46
|
-
|
|
46
|
+
o(m);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
function c(h) {
|
|
50
|
-
h.done ?
|
|
50
|
+
h.done ? i(h.value) : s(h.value).then(a, u);
|
|
51
51
|
}
|
|
52
52
|
c((r = r.apply(n, t || [])).next());
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
function ve(n, t) {
|
|
56
56
|
var e = { label: 0, sent: function() {
|
|
57
|
-
if (
|
|
58
|
-
return
|
|
59
|
-
}, trys: [], ops: [] }, r, s,
|
|
60
|
-
return
|
|
57
|
+
if (i[0] & 1) throw i[1];
|
|
58
|
+
return i[1];
|
|
59
|
+
}, trys: [], ops: [] }, r, s, i, o = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
|
|
60
|
+
return o.next = a(0), o.throw = a(1), o.return = a(2), typeof Symbol == "function" && (o[Symbol.iterator] = function() {
|
|
61
61
|
return this;
|
|
62
|
-
}),
|
|
62
|
+
}), o;
|
|
63
63
|
function a(c) {
|
|
64
64
|
return function(h) {
|
|
65
65
|
return u([c, h]);
|
|
@@ -67,12 +67,12 @@ function ve(n, t) {
|
|
|
67
67
|
}
|
|
68
68
|
function u(c) {
|
|
69
69
|
if (r) throw new TypeError("Generator is already executing.");
|
|
70
|
-
for (;
|
|
71
|
-
if (r = 1, s && (
|
|
72
|
-
switch (s = 0,
|
|
70
|
+
for (; o && (o = 0, c[0] && (e = 0)), e; ) try {
|
|
71
|
+
if (r = 1, s && (i = c[0] & 2 ? s.return : c[0] ? s.throw || ((i = s.return) && i.call(s), 0) : s.next) && !(i = i.call(s, c[1])).done) return i;
|
|
72
|
+
switch (s = 0, i && (c = [c[0] & 2, i.value]), c[0]) {
|
|
73
73
|
case 0:
|
|
74
74
|
case 1:
|
|
75
|
-
|
|
75
|
+
i = c;
|
|
76
76
|
break;
|
|
77
77
|
case 4:
|
|
78
78
|
return e.label++, { value: c[1], done: !1 };
|
|
@@ -83,30 +83,30 @@ function ve(n, t) {
|
|
|
83
83
|
c = e.ops.pop(), e.trys.pop();
|
|
84
84
|
continue;
|
|
85
85
|
default:
|
|
86
|
-
if (
|
|
86
|
+
if (i = e.trys, !(i = i.length > 0 && i[i.length - 1]) && (c[0] === 6 || c[0] === 2)) {
|
|
87
87
|
e = 0;
|
|
88
88
|
continue;
|
|
89
89
|
}
|
|
90
|
-
if (c[0] === 3 && (!
|
|
90
|
+
if (c[0] === 3 && (!i || c[1] > i[0] && c[1] < i[3])) {
|
|
91
91
|
e.label = c[1];
|
|
92
92
|
break;
|
|
93
93
|
}
|
|
94
|
-
if (c[0] === 6 && e.label <
|
|
95
|
-
e.label =
|
|
94
|
+
if (c[0] === 6 && e.label < i[1]) {
|
|
95
|
+
e.label = i[1], i = c;
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
98
|
-
if (
|
|
99
|
-
e.label =
|
|
98
|
+
if (i && e.label < i[2]) {
|
|
99
|
+
e.label = i[2], e.ops.push(c);
|
|
100
100
|
break;
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
i[2] && e.ops.pop(), e.trys.pop();
|
|
103
103
|
continue;
|
|
104
104
|
}
|
|
105
105
|
c = t.call(n, e);
|
|
106
106
|
} catch (h) {
|
|
107
107
|
c = [6, h], s = 0;
|
|
108
108
|
} finally {
|
|
109
|
-
r =
|
|
109
|
+
r = i = 0;
|
|
110
110
|
}
|
|
111
111
|
if (c[0] & 5) throw c[1];
|
|
112
112
|
return { value: c[0] ? c[1] : void 0, done: !0 };
|
|
@@ -125,43 +125,43 @@ function k(n) {
|
|
|
125
125
|
function R(n, t) {
|
|
126
126
|
var e = typeof Symbol == "function" && n[Symbol.iterator];
|
|
127
127
|
if (!e) return n;
|
|
128
|
-
var r = e.call(n), s,
|
|
128
|
+
var r = e.call(n), s, i = [], o;
|
|
129
129
|
try {
|
|
130
|
-
for (; (t === void 0 || t-- > 0) && !(s = r.next()).done; )
|
|
130
|
+
for (; (t === void 0 || t-- > 0) && !(s = r.next()).done; ) i.push(s.value);
|
|
131
131
|
} catch (a) {
|
|
132
|
-
|
|
132
|
+
o = { error: a };
|
|
133
133
|
} finally {
|
|
134
134
|
try {
|
|
135
135
|
s && !s.done && (e = r.return) && e.call(r);
|
|
136
136
|
} finally {
|
|
137
|
-
if (
|
|
137
|
+
if (o) throw o.error;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
return
|
|
140
|
+
return i;
|
|
141
141
|
}
|
|
142
142
|
function $(n, t, e) {
|
|
143
|
-
if (e || arguments.length === 2) for (var r = 0, s = t.length,
|
|
144
|
-
(
|
|
145
|
-
return n.concat(
|
|
143
|
+
if (e || arguments.length === 2) for (var r = 0, s = t.length, i; r < s; r++)
|
|
144
|
+
(i || !(r in t)) && (i || (i = Array.prototype.slice.call(t, 0, r)), i[r] = t[r]);
|
|
145
|
+
return n.concat(i || Array.prototype.slice.call(t));
|
|
146
146
|
}
|
|
147
147
|
function L(n) {
|
|
148
148
|
return this instanceof L ? (this.v = n, this) : new L(n);
|
|
149
149
|
}
|
|
150
150
|
function qe(n, t, e) {
|
|
151
151
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
152
|
-
var r = e.apply(n, t || []), s,
|
|
153
|
-
return s = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), a("next"), a("throw"), a("return",
|
|
152
|
+
var r = e.apply(n, t || []), s, i = [];
|
|
153
|
+
return s = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), a("next"), a("throw"), a("return", o), s[Symbol.asyncIterator] = function() {
|
|
154
154
|
return this;
|
|
155
155
|
}, s;
|
|
156
|
-
function
|
|
156
|
+
function o(l) {
|
|
157
157
|
return function(f) {
|
|
158
158
|
return Promise.resolve(f).then(l, m);
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
161
|
function a(l, f) {
|
|
162
162
|
r[l] && (s[l] = function(p) {
|
|
163
|
-
return new Promise(function(
|
|
164
|
-
|
|
163
|
+
return new Promise(function(_, I) {
|
|
164
|
+
i.push([l, p, _, I]) > 1 || u(l, p);
|
|
165
165
|
});
|
|
166
166
|
}, f && (s[l] = f(s[l])));
|
|
167
167
|
}
|
|
@@ -169,11 +169,11 @@ function qe(n, t, e) {
|
|
|
169
169
|
try {
|
|
170
170
|
c(r[l](f));
|
|
171
171
|
} catch (p) {
|
|
172
|
-
v(
|
|
172
|
+
v(i[0][3], p);
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
function c(l) {
|
|
176
|
-
l.value instanceof L ? Promise.resolve(l.value.v).then(h, m) : v(
|
|
176
|
+
l.value instanceof L ? Promise.resolve(l.value.v).then(h, m) : v(i[0][2], l);
|
|
177
177
|
}
|
|
178
178
|
function h(l) {
|
|
179
179
|
u("next", l);
|
|
@@ -182,7 +182,7 @@ function qe(n, t, e) {
|
|
|
182
182
|
u("throw", l);
|
|
183
183
|
}
|
|
184
184
|
function v(l, f) {
|
|
185
|
-
l(f),
|
|
185
|
+
l(f), i.shift(), i.length && u(i[0][0], i[0][1]);
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
function Ve(n) {
|
|
@@ -191,17 +191,17 @@ function Ve(n) {
|
|
|
191
191
|
return t ? t.call(n) : (n = typeof k == "function" ? k(n) : n[Symbol.iterator](), e = {}, r("next"), r("throw"), r("return"), e[Symbol.asyncIterator] = function() {
|
|
192
192
|
return this;
|
|
193
193
|
}, e);
|
|
194
|
-
function r(
|
|
195
|
-
e[
|
|
194
|
+
function r(i) {
|
|
195
|
+
e[i] = n[i] && function(o) {
|
|
196
196
|
return new Promise(function(a, u) {
|
|
197
|
-
|
|
197
|
+
o = n[i](o), s(a, u, o.done, o.value);
|
|
198
198
|
});
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
|
-
function s(
|
|
201
|
+
function s(i, o, a, u) {
|
|
202
202
|
Promise.resolve(u).then(function(c) {
|
|
203
|
-
|
|
204
|
-
},
|
|
203
|
+
i({ value: c, done: a });
|
|
204
|
+
}, o);
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
function g(n) {
|
|
@@ -233,14 +233,14 @@ var U = (function() {
|
|
|
233
233
|
this.initialTeardown = t, this.closed = !1, this._parentage = null, this._finalizers = null;
|
|
234
234
|
}
|
|
235
235
|
return n.prototype.unsubscribe = function() {
|
|
236
|
-
var t, e, r, s,
|
|
236
|
+
var t, e, r, s, i;
|
|
237
237
|
if (!this.closed) {
|
|
238
238
|
this.closed = !0;
|
|
239
|
-
var
|
|
240
|
-
if (
|
|
241
|
-
if (this._parentage = null, Array.isArray(
|
|
239
|
+
var o = this._parentage;
|
|
240
|
+
if (o)
|
|
241
|
+
if (this._parentage = null, Array.isArray(o))
|
|
242
242
|
try {
|
|
243
|
-
for (var a = k(
|
|
243
|
+
for (var a = k(o), u = a.next(); !u.done; u = a.next()) {
|
|
244
244
|
var c = u.value;
|
|
245
245
|
c.remove(this);
|
|
246
246
|
}
|
|
@@ -254,13 +254,13 @@ var U = (function() {
|
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
else
|
|
257
|
-
|
|
257
|
+
o.remove(this);
|
|
258
258
|
var h = this.initialTeardown;
|
|
259
259
|
if (g(h))
|
|
260
260
|
try {
|
|
261
261
|
h();
|
|
262
262
|
} catch (p) {
|
|
263
|
-
|
|
263
|
+
i = p instanceof W ? p.errors : [p];
|
|
264
264
|
}
|
|
265
265
|
var m = this._finalizers;
|
|
266
266
|
if (m) {
|
|
@@ -269,9 +269,9 @@ var U = (function() {
|
|
|
269
269
|
for (var v = k(m), l = v.next(); !l.done; l = v.next()) {
|
|
270
270
|
var f = l.value;
|
|
271
271
|
try {
|
|
272
|
-
|
|
272
|
+
oe(f);
|
|
273
273
|
} catch (p) {
|
|
274
|
-
|
|
274
|
+
i = i ?? [], p instanceof W ? i = $($([], R(i)), R(p.errors)) : i.push(p);
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
277
|
} catch (p) {
|
|
@@ -284,14 +284,14 @@ var U = (function() {
|
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
if (
|
|
288
|
-
throw new W(
|
|
287
|
+
if (i)
|
|
288
|
+
throw new W(i);
|
|
289
289
|
}
|
|
290
290
|
}, n.prototype.add = function(t) {
|
|
291
291
|
var e;
|
|
292
292
|
if (t && t !== this)
|
|
293
293
|
if (this.closed)
|
|
294
|
-
|
|
294
|
+
oe(t);
|
|
295
295
|
else {
|
|
296
296
|
if (t instanceof n) {
|
|
297
297
|
if (t.closed || t._hasParent(this))
|
|
@@ -320,7 +320,7 @@ var U = (function() {
|
|
|
320
320
|
function Se(n) {
|
|
321
321
|
return n instanceof U || n && "closed" in n && g(n.remove) && g(n.add) && g(n.unsubscribe);
|
|
322
322
|
}
|
|
323
|
-
function
|
|
323
|
+
function oe(n) {
|
|
324
324
|
g(n) ? n() : n.unsubscribe();
|
|
325
325
|
}
|
|
326
326
|
var Ye = {
|
|
@@ -411,12 +411,12 @@ var ne = (function(n) {
|
|
|
411
411
|
})(), Q = (function(n) {
|
|
412
412
|
w(t, n);
|
|
413
413
|
function t(e, r, s) {
|
|
414
|
-
var
|
|
415
|
-
return g(e) || !e ?
|
|
414
|
+
var i = n.call(this) || this, o;
|
|
415
|
+
return g(e) || !e ? o = {
|
|
416
416
|
next: e ?? void 0,
|
|
417
417
|
error: r ?? void 0,
|
|
418
418
|
complete: s ?? void 0
|
|
419
|
-
} :
|
|
419
|
+
} : o = e, i.destination = new Xe(o), i;
|
|
420
420
|
}
|
|
421
421
|
return t;
|
|
422
422
|
})(ne);
|
|
@@ -452,11 +452,11 @@ var S = (function() {
|
|
|
452
452
|
var e = new n();
|
|
453
453
|
return e.source = this, e.operator = t, e;
|
|
454
454
|
}, n.prototype.subscribe = function(t, e, r) {
|
|
455
|
-
var s = this,
|
|
455
|
+
var s = this, i = et(t) ? t : new Q(t, e, r);
|
|
456
456
|
return G(function() {
|
|
457
|
-
var
|
|
458
|
-
|
|
459
|
-
}),
|
|
457
|
+
var o = s, a = o.operator, u = o.source;
|
|
458
|
+
i.add(a ? a.call(i, u) : u ? s._subscribe(i) : s._trySubscribe(i));
|
|
459
|
+
}), i;
|
|
460
460
|
}, n.prototype._trySubscribe = function(t) {
|
|
461
461
|
try {
|
|
462
462
|
return this._subscribe(t);
|
|
@@ -465,19 +465,19 @@ var S = (function() {
|
|
|
465
465
|
}
|
|
466
466
|
}, n.prototype.forEach = function(t, e) {
|
|
467
467
|
var r = this;
|
|
468
|
-
return e = ae(e), new e(function(s,
|
|
469
|
-
var
|
|
468
|
+
return e = ae(e), new e(function(s, i) {
|
|
469
|
+
var o = new Q({
|
|
470
470
|
next: function(a) {
|
|
471
471
|
try {
|
|
472
472
|
t(a);
|
|
473
473
|
} catch (u) {
|
|
474
|
-
|
|
474
|
+
i(u), o.unsubscribe();
|
|
475
475
|
}
|
|
476
476
|
},
|
|
477
|
-
error:
|
|
477
|
+
error: i,
|
|
478
478
|
complete: s
|
|
479
479
|
});
|
|
480
|
-
r.subscribe(
|
|
480
|
+
r.subscribe(o);
|
|
481
481
|
});
|
|
482
482
|
}, n.prototype._subscribe = function(t) {
|
|
483
483
|
var e;
|
|
@@ -491,13 +491,13 @@ var S = (function() {
|
|
|
491
491
|
}, n.prototype.toPromise = function(t) {
|
|
492
492
|
var e = this;
|
|
493
493
|
return t = ae(t), new t(function(r, s) {
|
|
494
|
-
var
|
|
495
|
-
e.subscribe(function(
|
|
496
|
-
return
|
|
497
|
-
}, function(
|
|
498
|
-
return s(
|
|
494
|
+
var i;
|
|
495
|
+
e.subscribe(function(o) {
|
|
496
|
+
return i = o;
|
|
497
|
+
}, function(o) {
|
|
498
|
+
return s(o);
|
|
499
499
|
}, function() {
|
|
500
|
-
return r(
|
|
500
|
+
return r(i);
|
|
501
501
|
});
|
|
502
502
|
});
|
|
503
503
|
}, n.create = function(t) {
|
|
@@ -517,7 +517,7 @@ function et(n) {
|
|
|
517
517
|
function tt(n) {
|
|
518
518
|
return g(n?.lift);
|
|
519
519
|
}
|
|
520
|
-
function
|
|
520
|
+
function A(n) {
|
|
521
521
|
return function(t) {
|
|
522
522
|
if (tt(t))
|
|
523
523
|
return t.lift(function(e) {
|
|
@@ -535,17 +535,17 @@ function O(n, t, e, r, s) {
|
|
|
535
535
|
}
|
|
536
536
|
var nt = (function(n) {
|
|
537
537
|
w(t, n);
|
|
538
|
-
function t(e, r, s,
|
|
538
|
+
function t(e, r, s, i, o, a) {
|
|
539
539
|
var u = n.call(this, e) || this;
|
|
540
|
-
return u.onFinalize =
|
|
540
|
+
return u.onFinalize = o, u.shouldUnsubscribe = a, u._next = r ? function(c) {
|
|
541
541
|
try {
|
|
542
542
|
r(c);
|
|
543
543
|
} catch (h) {
|
|
544
544
|
e.error(h);
|
|
545
545
|
}
|
|
546
|
-
} : n.prototype._next, u._error =
|
|
546
|
+
} : n.prototype._next, u._error = i ? function(c) {
|
|
547
547
|
try {
|
|
548
|
-
|
|
548
|
+
i(c);
|
|
549
549
|
} catch (h) {
|
|
550
550
|
e.error(h);
|
|
551
551
|
} finally {
|
|
@@ -587,11 +587,11 @@ var nt = (function(n) {
|
|
|
587
587
|
}, t.prototype.next = function(e) {
|
|
588
588
|
var r = this;
|
|
589
589
|
G(function() {
|
|
590
|
-
var s,
|
|
590
|
+
var s, i;
|
|
591
591
|
if (r._throwIfClosed(), !r.isStopped) {
|
|
592
592
|
r.currentObservers || (r.currentObservers = Array.from(r.observers));
|
|
593
593
|
try {
|
|
594
|
-
for (var
|
|
594
|
+
for (var o = k(r.currentObservers), a = o.next(); !a.done; a = o.next()) {
|
|
595
595
|
var u = a.value;
|
|
596
596
|
u.next(e);
|
|
597
597
|
}
|
|
@@ -599,7 +599,7 @@ var nt = (function(n) {
|
|
|
599
599
|
s = { error: c };
|
|
600
600
|
} finally {
|
|
601
601
|
try {
|
|
602
|
-
a && !a.done && (
|
|
602
|
+
a && !a.done && (i = o.return) && i.call(o);
|
|
603
603
|
} finally {
|
|
604
604
|
if (s) throw s.error;
|
|
605
605
|
}
|
|
@@ -638,13 +638,13 @@ var nt = (function(n) {
|
|
|
638
638
|
}, t.prototype._subscribe = function(e) {
|
|
639
639
|
return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
|
|
640
640
|
}, t.prototype._innerSubscribe = function(e) {
|
|
641
|
-
var r = this, s = this,
|
|
642
|
-
return
|
|
641
|
+
var r = this, s = this, i = s.hasError, o = s.isStopped, a = s.observers;
|
|
642
|
+
return i || o ? be : (this.currentObservers = null, a.push(e), new U(function() {
|
|
643
643
|
r.currentObservers = null, F(a, e);
|
|
644
644
|
}));
|
|
645
645
|
}, t.prototype._checkFinalizedStatuses = function(e) {
|
|
646
|
-
var r = this, s = r.hasError,
|
|
647
|
-
s ? e.error(
|
|
646
|
+
var r = this, s = r.hasError, i = r.thrownError, o = r.isStopped;
|
|
647
|
+
s ? e.error(i) : o && e.complete();
|
|
648
648
|
}, t.prototype.asObservable = function() {
|
|
649
649
|
var e = new S();
|
|
650
650
|
return e.source = this, e;
|
|
@@ -686,10 +686,10 @@ var nt = (function(n) {
|
|
|
686
686
|
var r = n.prototype._subscribe.call(this, e);
|
|
687
687
|
return !r.closed && e.next(this._value), r;
|
|
688
688
|
}, t.prototype.getValue = function() {
|
|
689
|
-
var e = this, r = e.hasError, s = e.thrownError,
|
|
689
|
+
var e = this, r = e.hasError, s = e.thrownError, i = e._value;
|
|
690
690
|
if (r)
|
|
691
691
|
throw s;
|
|
692
|
-
return this._throwIfClosed(),
|
|
692
|
+
return this._throwIfClosed(), i;
|
|
693
693
|
}, t.prototype.next = function(e) {
|
|
694
694
|
n.prototype.next.call(this, this._value = e);
|
|
695
695
|
}, t;
|
|
@@ -697,7 +697,7 @@ var nt = (function(n) {
|
|
|
697
697
|
now: function() {
|
|
698
698
|
return Date.now();
|
|
699
699
|
}
|
|
700
|
-
},
|
|
700
|
+
}, it = (function(n) {
|
|
701
701
|
w(t, n);
|
|
702
702
|
function t(e, r) {
|
|
703
703
|
return n.call(this) || this;
|
|
@@ -715,7 +715,7 @@ var nt = (function(n) {
|
|
|
715
715
|
return clearInterval(n);
|
|
716
716
|
},
|
|
717
717
|
delegate: void 0
|
|
718
|
-
},
|
|
718
|
+
}, ot = (function(n) {
|
|
719
719
|
w(t, n);
|
|
720
720
|
function t(e, r) {
|
|
721
721
|
var s = n.call(this, e, r) || this;
|
|
@@ -726,8 +726,8 @@ var nt = (function(n) {
|
|
|
726
726
|
if (r === void 0 && (r = 0), this.closed)
|
|
727
727
|
return this;
|
|
728
728
|
this.state = e;
|
|
729
|
-
var
|
|
730
|
-
return
|
|
729
|
+
var i = this.id, o = this.scheduler;
|
|
730
|
+
return i != null && (this.id = this.recycleAsyncId(o, i, r)), this.pending = !0, this.delay = r, this.id = (s = this.id) !== null && s !== void 0 ? s : this.requestAsyncId(o, this.id, r), this;
|
|
731
731
|
}, t.prototype.requestAsyncId = function(e, r, s) {
|
|
732
732
|
return s === void 0 && (s = 0), ue.setInterval(e.flush.bind(e, this), s);
|
|
733
733
|
}, t.prototype.recycleAsyncId = function(e, r, s) {
|
|
@@ -743,21 +743,21 @@ var nt = (function(n) {
|
|
|
743
743
|
return s;
|
|
744
744
|
this.pending === !1 && this.id != null && (this.id = this.recycleAsyncId(this.scheduler, this.id, null));
|
|
745
745
|
}, t.prototype._execute = function(e, r) {
|
|
746
|
-
var s = !1,
|
|
746
|
+
var s = !1, i;
|
|
747
747
|
try {
|
|
748
748
|
this.work(e);
|
|
749
|
-
} catch (
|
|
750
|
-
s = !0,
|
|
749
|
+
} catch (o) {
|
|
750
|
+
s = !0, i = o || new Error("Scheduled action threw falsy error");
|
|
751
751
|
}
|
|
752
752
|
if (s)
|
|
753
|
-
return this.unsubscribe(),
|
|
753
|
+
return this.unsubscribe(), i;
|
|
754
754
|
}, t.prototype.unsubscribe = function() {
|
|
755
755
|
if (!this.closed) {
|
|
756
|
-
var e = this, r = e.id, s = e.scheduler,
|
|
757
|
-
this.work = this.state = this.scheduler = null, this.pending = !1, F(
|
|
756
|
+
var e = this, r = e.id, s = e.scheduler, i = s.actions;
|
|
757
|
+
this.work = this.state = this.scheduler = null, this.pending = !1, F(i, this), r != null && (this.id = this.recycleAsyncId(s, r, null)), this.delay = null, n.prototype.unsubscribe.call(this);
|
|
758
758
|
}
|
|
759
759
|
}, t;
|
|
760
|
-
})(
|
|
760
|
+
})(it), le = (function() {
|
|
761
761
|
function n(t, e) {
|
|
762
762
|
e === void 0 && (e = n.now), this.schedulerActionCtor = t, this.now = e;
|
|
763
763
|
}
|
|
@@ -789,7 +789,7 @@ var nt = (function(n) {
|
|
|
789
789
|
throw s;
|
|
790
790
|
}
|
|
791
791
|
}, t;
|
|
792
|
-
})(le), Ee = new at(
|
|
792
|
+
})(le), Ee = new at(ot), ct = Ee, ut = new S(function(n) {
|
|
793
793
|
return n.complete();
|
|
794
794
|
});
|
|
795
795
|
function we(n) {
|
|
@@ -828,25 +828,25 @@ function ke(n) {
|
|
|
828
828
|
}
|
|
829
829
|
function Pe(n) {
|
|
830
830
|
return qe(this, arguments, function() {
|
|
831
|
-
var e, r, s,
|
|
832
|
-
return ve(this, function(
|
|
833
|
-
switch (
|
|
831
|
+
var e, r, s, i;
|
|
832
|
+
return ve(this, function(o) {
|
|
833
|
+
switch (o.label) {
|
|
834
834
|
case 0:
|
|
835
|
-
e = n.getReader(),
|
|
835
|
+
e = n.getReader(), o.label = 1;
|
|
836
836
|
case 1:
|
|
837
|
-
|
|
837
|
+
o.trys.push([1, , 9, 10]), o.label = 2;
|
|
838
838
|
case 2:
|
|
839
839
|
return [4, L(e.read())];
|
|
840
840
|
case 3:
|
|
841
|
-
return r =
|
|
841
|
+
return r = o.sent(), s = r.value, i = r.done, i ? [4, L(void 0)] : [3, 5];
|
|
842
842
|
case 4:
|
|
843
|
-
return [2,
|
|
843
|
+
return [2, o.sent()];
|
|
844
844
|
case 5:
|
|
845
845
|
return [4, L(s)];
|
|
846
846
|
case 6:
|
|
847
|
-
return [4,
|
|
847
|
+
return [4, o.sent()];
|
|
848
848
|
case 7:
|
|
849
|
-
return
|
|
849
|
+
return o.sent(), [3, 2];
|
|
850
850
|
case 8:
|
|
851
851
|
return [3, 10];
|
|
852
852
|
case 9:
|
|
@@ -907,16 +907,16 @@ function mt(n) {
|
|
|
907
907
|
return new S(function(t) {
|
|
908
908
|
var e, r;
|
|
909
909
|
try {
|
|
910
|
-
for (var s = k(n),
|
|
911
|
-
var
|
|
912
|
-
if (t.next(
|
|
910
|
+
for (var s = k(n), i = s.next(); !i.done; i = s.next()) {
|
|
911
|
+
var o = i.value;
|
|
912
|
+
if (t.next(o), t.closed)
|
|
913
913
|
return;
|
|
914
914
|
}
|
|
915
915
|
} catch (a) {
|
|
916
916
|
e = { error: a };
|
|
917
917
|
} finally {
|
|
918
918
|
try {
|
|
919
|
-
|
|
919
|
+
i && !i.done && (r = s.return) && r.call(s);
|
|
920
920
|
} finally {
|
|
921
921
|
if (e) throw e.error;
|
|
922
922
|
}
|
|
@@ -935,9 +935,9 @@ function gt(n) {
|
|
|
935
935
|
return Ne(Pe(n));
|
|
936
936
|
}
|
|
937
937
|
function vt(n, t) {
|
|
938
|
-
var e, r, s,
|
|
938
|
+
var e, r, s, i;
|
|
939
939
|
return Be(this, void 0, void 0, function() {
|
|
940
|
-
var
|
|
940
|
+
var o, a;
|
|
941
941
|
return ve(this, function(u) {
|
|
942
942
|
switch (u.label) {
|
|
943
943
|
case 0:
|
|
@@ -946,7 +946,7 @@ function vt(n, t) {
|
|
|
946
946
|
return [4, e.next()];
|
|
947
947
|
case 2:
|
|
948
948
|
if (r = u.sent(), !!r.done) return [3, 4];
|
|
949
|
-
if (
|
|
949
|
+
if (o = r.value, t.next(o), t.closed)
|
|
950
950
|
return [2];
|
|
951
951
|
u.label = 3;
|
|
952
952
|
case 3:
|
|
@@ -956,7 +956,7 @@ function vt(n, t) {
|
|
|
956
956
|
case 5:
|
|
957
957
|
return a = u.sent(), s = { error: a }, [3, 11];
|
|
958
958
|
case 6:
|
|
959
|
-
return u.trys.push([6, , 9, 10]), r && !r.done && (
|
|
959
|
+
return u.trys.push([6, , 9, 10]), r && !r.done && (i = e.return) ? [4, i.call(e)] : [3, 8];
|
|
960
960
|
case 7:
|
|
961
961
|
u.sent(), u.label = 8;
|
|
962
962
|
case 8:
|
|
@@ -974,14 +974,14 @@ function vt(n, t) {
|
|
|
974
974
|
}
|
|
975
975
|
function C(n, t, e, r, s) {
|
|
976
976
|
r === void 0 && (r = 0), s === void 0 && (s = !1);
|
|
977
|
-
var
|
|
977
|
+
var i = t.schedule(function() {
|
|
978
978
|
e(), s ? n.add(this.schedule(null, r)) : this.unsubscribe();
|
|
979
979
|
}, r);
|
|
980
|
-
if (n.add(
|
|
981
|
-
return
|
|
980
|
+
if (n.add(i), !s)
|
|
981
|
+
return i;
|
|
982
982
|
}
|
|
983
983
|
function Re(n, t) {
|
|
984
|
-
return t === void 0 && (t = 0),
|
|
984
|
+
return t === void 0 && (t = 0), A(function(e, r) {
|
|
985
985
|
e.subscribe(O(r, function(s) {
|
|
986
986
|
return C(r, n, function() {
|
|
987
987
|
return r.next(s);
|
|
@@ -998,7 +998,7 @@ function Re(n, t) {
|
|
|
998
998
|
});
|
|
999
999
|
}
|
|
1000
1000
|
function $e(n, t) {
|
|
1001
|
-
return t === void 0 && (t = 0),
|
|
1001
|
+
return t === void 0 && (t = 0), A(function(e, r) {
|
|
1002
1002
|
r.add(n.schedule(function() {
|
|
1003
1003
|
return e.subscribe(r);
|
|
1004
1004
|
}, t));
|
|
@@ -1023,14 +1023,14 @@ function It(n, t) {
|
|
|
1023
1023
|
var r;
|
|
1024
1024
|
return C(e, t, function() {
|
|
1025
1025
|
r = n[Le](), C(e, t, function() {
|
|
1026
|
-
var s,
|
|
1026
|
+
var s, i, o;
|
|
1027
1027
|
try {
|
|
1028
|
-
s = r.next(),
|
|
1028
|
+
s = r.next(), i = s.value, o = s.done;
|
|
1029
1029
|
} catch (a) {
|
|
1030
1030
|
e.error(a);
|
|
1031
1031
|
return;
|
|
1032
1032
|
}
|
|
1033
|
-
|
|
1033
|
+
o ? e.complete() : e.next(i);
|
|
1034
1034
|
}, 0, !0);
|
|
1035
1035
|
}), function() {
|
|
1036
1036
|
return g(r?.return) && r.return();
|
|
@@ -1071,23 +1071,23 @@ function wt(n, t) {
|
|
|
1071
1071
|
}
|
|
1072
1072
|
throw xe(n);
|
|
1073
1073
|
}
|
|
1074
|
-
function
|
|
1074
|
+
function ie(n, t) {
|
|
1075
1075
|
return t ? wt(n, t) : x(n);
|
|
1076
1076
|
}
|
|
1077
1077
|
function Tt() {
|
|
1078
1078
|
for (var n = [], t = 0; t < arguments.length; t++)
|
|
1079
1079
|
n[t] = arguments[t];
|
|
1080
1080
|
var e = Ce(n);
|
|
1081
|
-
return
|
|
1081
|
+
return ie(n, e);
|
|
1082
1082
|
}
|
|
1083
1083
|
function Ct(n) {
|
|
1084
1084
|
return n instanceof Date && !isNaN(n);
|
|
1085
1085
|
}
|
|
1086
1086
|
function P(n, t) {
|
|
1087
|
-
return
|
|
1087
|
+
return A(function(e, r) {
|
|
1088
1088
|
var s = 0;
|
|
1089
|
-
e.subscribe(O(r, function(
|
|
1090
|
-
r.next(n.call(t,
|
|
1089
|
+
e.subscribe(O(r, function(i) {
|
|
1090
|
+
r.next(n.call(t, i, s++));
|
|
1091
1091
|
}));
|
|
1092
1092
|
});
|
|
1093
1093
|
}
|
|
@@ -1129,24 +1129,24 @@ function Nt(n, t) {
|
|
|
1129
1129
|
function Rt() {
|
|
1130
1130
|
for (var n = [], t = 0; t < arguments.length; t++)
|
|
1131
1131
|
n[t] = arguments[t];
|
|
1132
|
-
var e = Ce(n), r = lt(n), s = Pt(n),
|
|
1133
|
-
if (
|
|
1134
|
-
return
|
|
1135
|
-
var a = new S($t(
|
|
1136
|
-
return Nt(
|
|
1132
|
+
var e = Ce(n), r = lt(n), s = Pt(n), i = s.args, o = s.keys;
|
|
1133
|
+
if (i.length === 0)
|
|
1134
|
+
return ie([], e);
|
|
1135
|
+
var a = new S($t(i, e, o ? function(u) {
|
|
1136
|
+
return Nt(o, u);
|
|
1137
1137
|
} : q));
|
|
1138
1138
|
return r ? a.pipe(_t(r)) : a;
|
|
1139
1139
|
}
|
|
1140
1140
|
function $t(n, t, e) {
|
|
1141
1141
|
return e === void 0 && (e = q), function(r) {
|
|
1142
1142
|
de(t, function() {
|
|
1143
|
-
for (var s = n.length,
|
|
1143
|
+
for (var s = n.length, i = new Array(s), o = s, a = s, u = function(h) {
|
|
1144
1144
|
de(t, function() {
|
|
1145
|
-
var m =
|
|
1145
|
+
var m = ie(n[h], t), v = !1;
|
|
1146
1146
|
m.subscribe(O(r, function(l) {
|
|
1147
|
-
|
|
1147
|
+
i[h] = l, v || (v = !0, a--), a || r.next(e(i.slice()));
|
|
1148
1148
|
}, function() {
|
|
1149
|
-
--
|
|
1149
|
+
--o || r.complete();
|
|
1150
1150
|
}));
|
|
1151
1151
|
}, r);
|
|
1152
1152
|
}, c = 0; c < s; c++)
|
|
@@ -1157,30 +1157,30 @@ function $t(n, t, e) {
|
|
|
1157
1157
|
function de(n, t, e) {
|
|
1158
1158
|
n ? C(e, n, t) : t();
|
|
1159
1159
|
}
|
|
1160
|
-
function jt(n, t, e, r, s,
|
|
1160
|
+
function jt(n, t, e, r, s, i, o, a) {
|
|
1161
1161
|
var u = [], c = 0, h = 0, m = !1, v = function() {
|
|
1162
1162
|
m && !u.length && !c && t.complete();
|
|
1163
1163
|
}, l = function(p) {
|
|
1164
1164
|
return c < r ? f(p) : u.push(p);
|
|
1165
1165
|
}, f = function(p) {
|
|
1166
1166
|
c++;
|
|
1167
|
-
var
|
|
1167
|
+
var _ = !1;
|
|
1168
1168
|
x(e(p, h++)).subscribe(O(t, function(I) {
|
|
1169
1169
|
t.next(I);
|
|
1170
1170
|
}, function() {
|
|
1171
|
-
|
|
1171
|
+
_ = !0;
|
|
1172
1172
|
}, void 0, function() {
|
|
1173
|
-
if (
|
|
1173
|
+
if (_)
|
|
1174
1174
|
try {
|
|
1175
1175
|
c--;
|
|
1176
1176
|
for (var I = function() {
|
|
1177
|
-
var
|
|
1178
|
-
|
|
1177
|
+
var M = u.shift();
|
|
1178
|
+
o || f(M);
|
|
1179
1179
|
}; u.length && c < r; )
|
|
1180
1180
|
I();
|
|
1181
1181
|
v();
|
|
1182
|
-
} catch (
|
|
1183
|
-
t.error(
|
|
1182
|
+
} catch (M) {
|
|
1183
|
+
t.error(M);
|
|
1184
1184
|
}
|
|
1185
1185
|
}));
|
|
1186
1186
|
};
|
|
@@ -1191,10 +1191,10 @@ function jt(n, t, e, r, s, o, i, a) {
|
|
|
1191
1191
|
}
|
|
1192
1192
|
function B(n, t, e) {
|
|
1193
1193
|
return e === void 0 && (e = 1 / 0), g(t) ? B(function(r, s) {
|
|
1194
|
-
return P(function(
|
|
1195
|
-
return t(r,
|
|
1194
|
+
return P(function(i, o) {
|
|
1195
|
+
return t(r, i, s, o);
|
|
1196
1196
|
})(x(n(r, s)));
|
|
1197
|
-
}, e) : (typeof t == "number" && (e = t),
|
|
1197
|
+
}, e) : (typeof t == "number" && (e = t), A(function(r, s) {
|
|
1198
1198
|
return jt(r, s, n, e);
|
|
1199
1199
|
}));
|
|
1200
1200
|
}
|
|
@@ -1202,12 +1202,12 @@ function Dt(n, t, e) {
|
|
|
1202
1202
|
n === void 0 && (n = 0), e === void 0 && (e = ct);
|
|
1203
1203
|
var r = -1;
|
|
1204
1204
|
return t != null && (we(t) ? e = t : r = t), new S(function(s) {
|
|
1205
|
-
var
|
|
1206
|
-
|
|
1207
|
-
var
|
|
1205
|
+
var i = Ct(n) ? +n - e.now() : n;
|
|
1206
|
+
i < 0 && (i = 0);
|
|
1207
|
+
var o = 0;
|
|
1208
1208
|
return e.schedule(function() {
|
|
1209
|
-
s.closed || (s.next(
|
|
1210
|
-
},
|
|
1209
|
+
s.closed || (s.next(o++), 0 <= r ? this.schedule(void 0, r) : s.complete());
|
|
1210
|
+
}, i);
|
|
1211
1211
|
});
|
|
1212
1212
|
}
|
|
1213
1213
|
function Ht(n, t) {
|
|
@@ -1216,7 +1216,7 @@ function Ht(n, t) {
|
|
|
1216
1216
|
function Gt(n) {
|
|
1217
1217
|
return n <= 0 ? function() {
|
|
1218
1218
|
return ut;
|
|
1219
|
-
} :
|
|
1219
|
+
} : A(function(t, e) {
|
|
1220
1220
|
var r = 0;
|
|
1221
1221
|
t.subscribe(O(e, function(s) {
|
|
1222
1222
|
++r <= n && (e.next(s), n <= r && e.complete());
|
|
@@ -1241,11 +1241,11 @@ function Bt(n, t) {
|
|
|
1241
1241
|
});
|
|
1242
1242
|
}
|
|
1243
1243
|
function Z(n, t) {
|
|
1244
|
-
return t === void 0 && (t = q), n = n ?? qt,
|
|
1245
|
-
var s,
|
|
1246
|
-
e.subscribe(O(r, function(
|
|
1247
|
-
var a = t(
|
|
1248
|
-
(
|
|
1244
|
+
return t === void 0 && (t = q), n = n ?? qt, A(function(e, r) {
|
|
1245
|
+
var s, i = !0;
|
|
1246
|
+
e.subscribe(O(r, function(o) {
|
|
1247
|
+
var a = t(o);
|
|
1248
|
+
(i || !n(s, a)) && (i = !1, s = a, r.next(o));
|
|
1249
1249
|
}));
|
|
1250
1250
|
});
|
|
1251
1251
|
}
|
|
@@ -1253,22 +1253,31 @@ function qt(n, t) {
|
|
|
1253
1253
|
return n === t;
|
|
1254
1254
|
}
|
|
1255
1255
|
function Vt(n) {
|
|
1256
|
-
return
|
|
1256
|
+
return A(function(t, e) {
|
|
1257
|
+
try {
|
|
1258
|
+
t.subscribe(e);
|
|
1259
|
+
} finally {
|
|
1260
|
+
e.add(n);
|
|
1261
|
+
}
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1264
|
+
function Yt(n) {
|
|
1265
|
+
return A(function(t, e) {
|
|
1257
1266
|
x(n).subscribe(O(e, function() {
|
|
1258
1267
|
return e.complete();
|
|
1259
1268
|
}, J)), !e.closed && t.subscribe(e);
|
|
1260
1269
|
});
|
|
1261
1270
|
}
|
|
1262
|
-
async function
|
|
1271
|
+
async function Wt(n, t) {
|
|
1263
1272
|
const e = n.getReader();
|
|
1264
1273
|
let r;
|
|
1265
1274
|
for (; !(r = await e.read()).done; )
|
|
1266
1275
|
t(r.value);
|
|
1267
1276
|
}
|
|
1268
|
-
function
|
|
1277
|
+
function Xt(n) {
|
|
1269
1278
|
let t, e, r, s = !1;
|
|
1270
|
-
return function(
|
|
1271
|
-
t === void 0 ? (t =
|
|
1279
|
+
return function(o) {
|
|
1280
|
+
t === void 0 ? (t = o, e = 0, r = -1) : t = Jt(t, o);
|
|
1272
1281
|
const a = t.length;
|
|
1273
1282
|
let u = 0;
|
|
1274
1283
|
for (; e < a; ) {
|
|
@@ -1292,14 +1301,14 @@ function Wt(n) {
|
|
|
1292
1301
|
u === a ? t = void 0 : u !== 0 && (t = t.subarray(u), e -= u);
|
|
1293
1302
|
};
|
|
1294
1303
|
}
|
|
1295
|
-
function
|
|
1304
|
+
function zt(n, t, e) {
|
|
1296
1305
|
let r = he();
|
|
1297
1306
|
const s = new TextDecoder();
|
|
1298
|
-
return function(
|
|
1299
|
-
if (
|
|
1307
|
+
return function(o, a) {
|
|
1308
|
+
if (o.length === 0)
|
|
1300
1309
|
e?.(r), r = he();
|
|
1301
1310
|
else if (a > 0) {
|
|
1302
|
-
const u = s.decode(
|
|
1311
|
+
const u = s.decode(o.subarray(0, a)), c = a + (o[a + 1] === 32 ? 2 : 1), h = s.decode(o.subarray(c));
|
|
1303
1312
|
switch (u) {
|
|
1304
1313
|
case "data":
|
|
1305
1314
|
r.data = r.data ? r.data + `
|
|
@@ -1319,7 +1328,7 @@ function Xt(n, t, e) {
|
|
|
1319
1328
|
}
|
|
1320
1329
|
};
|
|
1321
1330
|
}
|
|
1322
|
-
function
|
|
1331
|
+
function Jt(n, t) {
|
|
1323
1332
|
const e = new Uint8Array(n.length + t.length);
|
|
1324
1333
|
return e.set(n), e.set(t, n.length), e;
|
|
1325
1334
|
}
|
|
@@ -1331,7 +1340,7 @@ function he() {
|
|
|
1331
1340
|
retry: void 0
|
|
1332
1341
|
};
|
|
1333
1342
|
}
|
|
1334
|
-
var
|
|
1343
|
+
var Qt = function(n, t) {
|
|
1335
1344
|
var e = {};
|
|
1336
1345
|
for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && t.indexOf(r) < 0 && (e[r] = n[r]);
|
|
1337
1346
|
if (n != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -1339,9 +1348,9 @@ var Jt = function(n, t) {
|
|
|
1339
1348
|
t.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[s]) && (e[r[s]] = n[r[s]]);
|
|
1340
1349
|
return e;
|
|
1341
1350
|
};
|
|
1342
|
-
const ee = "text/event-stream",
|
|
1343
|
-
function
|
|
1344
|
-
var { signal: e, headers: r, onopen: s, onmessage:
|
|
1351
|
+
const ee = "text/event-stream", Zt = 1e3, fe = "last-event-id";
|
|
1352
|
+
function en(n, t) {
|
|
1353
|
+
var { signal: e, headers: r, onopen: s, onmessage: i, onclose: o, onerror: a, openWhenHidden: u, fetch: c } = t, h = Qt(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
1345
1354
|
return new Promise((m, v) => {
|
|
1346
1355
|
const l = Object.assign({}, r);
|
|
1347
1356
|
l.accept || (l.accept = ee);
|
|
@@ -1350,57 +1359,57 @@ function Zt(n, t) {
|
|
|
1350
1359
|
f.abort(), document.hidden || V();
|
|
1351
1360
|
}
|
|
1352
1361
|
u || document.addEventListener("visibilitychange", p);
|
|
1353
|
-
let
|
|
1354
|
-
function
|
|
1362
|
+
let _ = Zt, I = 0;
|
|
1363
|
+
function M() {
|
|
1355
1364
|
document.removeEventListener("visibilitychange", p), window.clearTimeout(I), f.abort();
|
|
1356
1365
|
}
|
|
1357
1366
|
e?.addEventListener("abort", () => {
|
|
1358
|
-
|
|
1367
|
+
M(), m();
|
|
1359
1368
|
});
|
|
1360
|
-
const He = c ?? window.fetch, Ge = s ??
|
|
1369
|
+
const He = c ?? window.fetch, Ge = s ?? tn;
|
|
1361
1370
|
async function V() {
|
|
1362
1371
|
var Y;
|
|
1363
1372
|
f = new AbortController();
|
|
1364
1373
|
try {
|
|
1365
1374
|
const j = await He(n, Object.assign(Object.assign({}, h), { headers: l, signal: f.signal }));
|
|
1366
|
-
await Ge(j), await
|
|
1375
|
+
await Ge(j), await Wt(j.body, Xt(zt((T) => {
|
|
1367
1376
|
T ? l[fe] = T : delete l[fe];
|
|
1368
1377
|
}, (T) => {
|
|
1369
|
-
|
|
1370
|
-
},
|
|
1378
|
+
_ = T;
|
|
1379
|
+
}, i))), o?.(), M(), m();
|
|
1371
1380
|
} catch (j) {
|
|
1372
1381
|
if (!f.signal.aborted)
|
|
1373
1382
|
try {
|
|
1374
|
-
const T = (Y = a?.(j)) !== null && Y !== void 0 ? Y :
|
|
1383
|
+
const T = (Y = a?.(j)) !== null && Y !== void 0 ? Y : _;
|
|
1375
1384
|
window.clearTimeout(I), I = window.setTimeout(V, T);
|
|
1376
1385
|
} catch (T) {
|
|
1377
|
-
|
|
1386
|
+
M(), v(T);
|
|
1378
1387
|
}
|
|
1379
1388
|
}
|
|
1380
1389
|
}
|
|
1381
1390
|
V();
|
|
1382
1391
|
});
|
|
1383
1392
|
}
|
|
1384
|
-
function
|
|
1393
|
+
function tn(n) {
|
|
1385
1394
|
const t = n.headers.get("content-type");
|
|
1386
1395
|
if (!t?.startsWith(ee))
|
|
1387
1396
|
throw new Error(`Expected content-type to be ${ee}, Actual: ${t}`);
|
|
1388
1397
|
}
|
|
1389
1398
|
function pe(n) {
|
|
1390
|
-
const { endpoint: t, apiKey: e, payload: r, debugMode: s, customHeaders:
|
|
1399
|
+
const { endpoint: t, apiKey: e, payload: r, debugMode: s, customHeaders: i } = n, o = n.method ?? "POST";
|
|
1391
1400
|
return new S((a) => {
|
|
1392
1401
|
const u = new AbortController();
|
|
1393
1402
|
let c, h = !1;
|
|
1394
1403
|
const m = {
|
|
1395
1404
|
"Content-Type": "application/json",
|
|
1396
|
-
...
|
|
1405
|
+
...i
|
|
1397
1406
|
};
|
|
1398
1407
|
e && (m["X-API-KEY"] = e);
|
|
1399
1408
|
const v = new URL(t);
|
|
1400
|
-
return s && v.searchParams.set("is_debug", "true"),
|
|
1401
|
-
method:
|
|
1409
|
+
return s && v.searchParams.set("is_debug", "true"), en(v.toString(), {
|
|
1410
|
+
method: o,
|
|
1402
1411
|
headers: m,
|
|
1403
|
-
body:
|
|
1412
|
+
body: o === "POST" && r ? JSON.stringify(r) : void 0,
|
|
1404
1413
|
signal: u.signal,
|
|
1405
1414
|
/**
|
|
1406
1415
|
* Allow SSE to work when the page is hidden.
|
|
@@ -1441,7 +1450,7 @@ function pe(n) {
|
|
|
1441
1450
|
};
|
|
1442
1451
|
});
|
|
1443
1452
|
}
|
|
1444
|
-
class
|
|
1453
|
+
class nn {
|
|
1445
1454
|
listeners = {};
|
|
1446
1455
|
on(t, e) {
|
|
1447
1456
|
this.listeners = Object.assign({}, this.listeners, {
|
|
@@ -1460,7 +1469,7 @@ class tn {
|
|
|
1460
1469
|
this.listeners[t] && this.listeners[t].forEach((r) => r(...e));
|
|
1461
1470
|
}
|
|
1462
1471
|
}
|
|
1463
|
-
class
|
|
1472
|
+
class Tn {
|
|
1464
1473
|
apiKey;
|
|
1465
1474
|
endpoint;
|
|
1466
1475
|
botProviderEndpoint;
|
|
@@ -1470,7 +1479,7 @@ class wn {
|
|
|
1470
1479
|
detached = !1;
|
|
1471
1480
|
detachTimer;
|
|
1472
1481
|
inFlight = 0;
|
|
1473
|
-
sseEmitter = new
|
|
1482
|
+
sseEmitter = new nn();
|
|
1474
1483
|
transformSsePayload;
|
|
1475
1484
|
customHeaders;
|
|
1476
1485
|
constructor(t) {
|
|
@@ -1522,7 +1531,7 @@ class wn {
|
|
|
1522
1531
|
}
|
|
1523
1532
|
}
|
|
1524
1533
|
fetchSse(t, e) {
|
|
1525
|
-
e?.onSseStart?.(), this.inFlight += 1, this.runSse(
|
|
1534
|
+
return e?.onSseStart?.(), this.inFlight += 1, this.runSse(
|
|
1526
1535
|
pe({
|
|
1527
1536
|
apiKey: this.apiKey,
|
|
1528
1537
|
endpoint: this.endpoint,
|
|
@@ -1541,7 +1550,7 @@ class wn {
|
|
|
1541
1550
|
rejoinSse(t, e) {
|
|
1542
1551
|
e?.onSseStart?.(), this.inFlight += 1;
|
|
1543
1552
|
const r = new URL(this.endpoint);
|
|
1544
|
-
r.searchParams.set("custom_channel_id", t), this.runSse(
|
|
1553
|
+
return r.searchParams.set("custom_channel_id", t), this.runSse(
|
|
1545
1554
|
pe({
|
|
1546
1555
|
apiKey: this.apiKey,
|
|
1547
1556
|
endpoint: r.toString(),
|
|
@@ -1570,13 +1579,13 @@ class wn {
|
|
|
1570
1579
|
r.searchParams.set("custom_channel_id", t);
|
|
1571
1580
|
const s = { ...this.customHeaders };
|
|
1572
1581
|
this.apiKey && (s["X-API-KEY"] = this.apiKey);
|
|
1573
|
-
const
|
|
1574
|
-
if (
|
|
1582
|
+
const i = await fetch(r.toString(), { method: "GET", headers: s });
|
|
1583
|
+
if (i.status === 404)
|
|
1575
1584
|
return null;
|
|
1576
|
-
if (!
|
|
1577
|
-
throw new te(
|
|
1585
|
+
if (!i.ok)
|
|
1586
|
+
throw new te(i.status, i.statusText, await i.text().catch(() => {
|
|
1578
1587
|
}));
|
|
1579
|
-
const
|
|
1588
|
+
const o = await i.json(), a = o.data ?? o;
|
|
1580
1589
|
return {
|
|
1581
1590
|
title: a.title ?? null,
|
|
1582
1591
|
runState: a.runState ?? "IDLE",
|
|
@@ -1584,21 +1593,24 @@ class wn {
|
|
|
1584
1593
|
};
|
|
1585
1594
|
}
|
|
1586
1595
|
runSse(t, e) {
|
|
1587
|
-
t.pipe(
|
|
1596
|
+
return t.pipe(
|
|
1588
1597
|
// No RxJS-level retry: re-subscribing would re-POST and the backend would re-dispatch a duplicate
|
|
1589
1598
|
// run. Mid-stream resume is the library's job (native Last-Event-ID reconnect in
|
|
1590
1599
|
// create-sse-observable); a no-cursor failure surfaces via `error` below.
|
|
1591
1600
|
Ht((r) => Tt(r).pipe(Bt(e?.delayTime ?? 50))),
|
|
1592
|
-
|
|
1601
|
+
Yt(this.destroy$),
|
|
1602
|
+
// Settle the run accounting on every termination path — complete, error, AND a user-initiated
|
|
1603
|
+
// unsubscribe (stop-generation aborts the connection without a terminal event).
|
|
1604
|
+
Vt(() => this.onRunSettled())
|
|
1593
1605
|
).subscribe({
|
|
1594
1606
|
next: (r) => {
|
|
1595
1607
|
this.detached || (e?.onSseMessage?.(r), this.handleEvent(r));
|
|
1596
1608
|
},
|
|
1597
1609
|
error: (r) => {
|
|
1598
|
-
this.detached || e?.onSseError?.(r)
|
|
1610
|
+
this.detached || e?.onSseError?.(r);
|
|
1599
1611
|
},
|
|
1600
1612
|
complete: () => {
|
|
1601
|
-
this.detached || e?.onSseCompleted?.()
|
|
1613
|
+
this.detached || e?.onSseCompleted?.();
|
|
1602
1614
|
}
|
|
1603
1615
|
});
|
|
1604
1616
|
}
|
|
@@ -1641,22 +1653,22 @@ class wn {
|
|
|
1641
1653
|
throw new Error("Unable to derive blob endpoint. Please provide botProviderEndpoint in config.");
|
|
1642
1654
|
const s = new FormData();
|
|
1643
1655
|
s.append("file", t), s.append("customChannelId", e);
|
|
1644
|
-
const
|
|
1656
|
+
const i = {
|
|
1645
1657
|
...this.customHeaders
|
|
1646
1658
|
};
|
|
1647
|
-
this.apiKey && (
|
|
1659
|
+
this.apiKey && (i["X-API-KEY"] = this.apiKey);
|
|
1648
1660
|
try {
|
|
1649
|
-
const
|
|
1661
|
+
const o = await fetch(r, {
|
|
1650
1662
|
method: "POST",
|
|
1651
|
-
headers:
|
|
1663
|
+
headers: i,
|
|
1652
1664
|
body: s
|
|
1653
1665
|
});
|
|
1654
|
-
if (!
|
|
1655
|
-
throw new Error(`Upload failed: ${
|
|
1656
|
-
const a = await
|
|
1666
|
+
if (!o.ok)
|
|
1667
|
+
throw new Error(`Upload failed: ${o.status} ${o.statusText}`);
|
|
1668
|
+
const a = await o.json();
|
|
1657
1669
|
return this.debugMode && console.log("[AsgardServiceClient] File upload response:", a), a;
|
|
1658
|
-
} catch (
|
|
1659
|
-
throw console.error("[AsgardServiceClient] File upload error:",
|
|
1670
|
+
} catch (o) {
|
|
1671
|
+
throw console.error("[AsgardServiceClient] File upload error:", o), o;
|
|
1660
1672
|
}
|
|
1661
1673
|
}
|
|
1662
1674
|
/**
|
|
@@ -1667,14 +1679,14 @@ class wn {
|
|
|
1667
1679
|
const r = this.getBaseEndpoint();
|
|
1668
1680
|
if (!r)
|
|
1669
1681
|
throw new Error("Unable to derive channel-home download endpoint. Please provide botProviderEndpoint in config.");
|
|
1670
|
-
const s = `custom_channel_id=${encodeURIComponent(e)}&relative_path=${encodeURIComponent(t)}`,
|
|
1682
|
+
const s = `custom_channel_id=${encodeURIComponent(e)}&relative_path=${encodeURIComponent(t)}`, i = `${r}/channel-home/download?${s}`, o = {
|
|
1671
1683
|
...this.customHeaders
|
|
1672
1684
|
};
|
|
1673
|
-
this.apiKey && (
|
|
1685
|
+
this.apiKey && (o["X-API-KEY"] = this.apiKey);
|
|
1674
1686
|
try {
|
|
1675
|
-
const a = await fetch(
|
|
1687
|
+
const a = await fetch(i, {
|
|
1676
1688
|
method: "GET",
|
|
1677
|
-
headers:
|
|
1689
|
+
headers: o
|
|
1678
1690
|
});
|
|
1679
1691
|
if (!a.ok)
|
|
1680
1692
|
throw new Error(`Channel Home download failed: ${a.status} ${a.statusText}`);
|
|
@@ -1703,29 +1715,29 @@ class wn {
|
|
|
1703
1715
|
const y = [];
|
|
1704
1716
|
for (let n = 0; n < 256; ++n)
|
|
1705
1717
|
y.push((n + 256).toString(16).slice(1));
|
|
1706
|
-
function
|
|
1718
|
+
function rn(n, t = 0) {
|
|
1707
1719
|
return (y[n[t + 0]] + y[n[t + 1]] + y[n[t + 2]] + y[n[t + 3]] + "-" + y[n[t + 4]] + y[n[t + 5]] + "-" + y[n[t + 6]] + y[n[t + 7]] + "-" + y[n[t + 8]] + y[n[t + 9]] + "-" + y[n[t + 10]] + y[n[t + 11]] + y[n[t + 12]] + y[n[t + 13]] + y[n[t + 14]] + y[n[t + 15]]).toLowerCase();
|
|
1708
1720
|
}
|
|
1709
1721
|
let X;
|
|
1710
|
-
const
|
|
1711
|
-
function
|
|
1722
|
+
const sn = new Uint8Array(16);
|
|
1723
|
+
function on() {
|
|
1712
1724
|
if (!X) {
|
|
1713
1725
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
1714
1726
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
1715
1727
|
X = crypto.getRandomValues.bind(crypto);
|
|
1716
1728
|
}
|
|
1717
|
-
return X(
|
|
1729
|
+
return X(sn);
|
|
1718
1730
|
}
|
|
1719
|
-
const
|
|
1720
|
-
function
|
|
1731
|
+
const an = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), me = { randomUUID: an };
|
|
1732
|
+
function cn(n, t, e) {
|
|
1721
1733
|
n = n || {};
|
|
1722
|
-
const r = n.random ?? n.rng?.() ??
|
|
1734
|
+
const r = n.random ?? n.rng?.() ?? on();
|
|
1723
1735
|
if (r.length < 16)
|
|
1724
1736
|
throw new Error("Random bytes length must be >= 16");
|
|
1725
|
-
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128,
|
|
1737
|
+
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, rn(r);
|
|
1726
1738
|
}
|
|
1727
1739
|
function De(n, t, e) {
|
|
1728
|
-
return me.randomUUID && !n ? me.randomUUID() :
|
|
1740
|
+
return me.randomUUID && !n ? me.randomUUID() : cn(n);
|
|
1729
1741
|
}
|
|
1730
1742
|
class b {
|
|
1731
1743
|
messages = null;
|
|
@@ -1807,8 +1819,8 @@ class b {
|
|
|
1807
1819
|
onMessageDelta(t) {
|
|
1808
1820
|
const e = t.fact.messageDelta.message, r = this.messages?.get(e.messageId);
|
|
1809
1821
|
if (this.isTerminalBot(r)) return this;
|
|
1810
|
-
const s = r?.type === "bot" ? r : void 0,
|
|
1811
|
-
return
|
|
1822
|
+
const s = r?.type === "bot" ? r : void 0, i = new Map(this.messages);
|
|
1823
|
+
return i.set(e.messageId, {
|
|
1812
1824
|
type: "bot",
|
|
1813
1825
|
eventType: d.MESSAGE_DELTA,
|
|
1814
1826
|
isTyping: !0,
|
|
@@ -1818,7 +1830,7 @@ class b {
|
|
|
1818
1830
|
time: /* @__PURE__ */ new Date(),
|
|
1819
1831
|
traceId: t.traceId ?? s?.traceId,
|
|
1820
1832
|
raw: s?.raw ?? ""
|
|
1821
|
-
}), new b({ messages:
|
|
1833
|
+
}), new b({ messages: i, pendingConsent: this.pendingConsent });
|
|
1822
1834
|
}
|
|
1823
1835
|
onMessageComplete(t) {
|
|
1824
1836
|
const e = t.fact.messageComplete.message, r = new Map(this.messages), s = r.get(e.messageId);
|
|
@@ -1850,7 +1862,7 @@ class b {
|
|
|
1850
1862
|
onThinkingDelta(t) {
|
|
1851
1863
|
const e = t.fact.messageThinkingDelta.message, r = this.messages?.get(e.messageId);
|
|
1852
1864
|
if (this.isTerminalThinking(r)) return this;
|
|
1853
|
-
const s = r?.type === "thinking" ? r : void 0,
|
|
1865
|
+
const s = r?.type === "thinking" ? r : void 0, i = new Map(this.messages), o = {
|
|
1854
1866
|
type: "thinking",
|
|
1855
1867
|
messageId: e.messageId,
|
|
1856
1868
|
text: `${s?.text ?? ""}${e.text}`,
|
|
@@ -1858,10 +1870,10 @@ class b {
|
|
|
1858
1870
|
time: s?.time ?? /* @__PURE__ */ new Date(),
|
|
1859
1871
|
traceId: t.traceId ?? s?.traceId
|
|
1860
1872
|
};
|
|
1861
|
-
return
|
|
1873
|
+
return i.set(e.messageId, o), new b({ messages: i, pendingConsent: this.pendingConsent });
|
|
1862
1874
|
}
|
|
1863
1875
|
onThinkingComplete(t) {
|
|
1864
|
-
const e = t.fact.messageThinkingComplete.message, r = this.messages?.get(e.messageId), s = r?.type === "thinking" ? r : void 0,
|
|
1876
|
+
const e = t.fact.messageThinkingComplete.message, r = this.messages?.get(e.messageId), s = r?.type === "thinking" ? r : void 0, i = new Map(this.messages), o = {
|
|
1865
1877
|
type: "thinking",
|
|
1866
1878
|
messageId: e.messageId,
|
|
1867
1879
|
// Self-sufficient (F-011): the complete frame carries the full reasoning, so a complete-only
|
|
@@ -1871,12 +1883,12 @@ class b {
|
|
|
1871
1883
|
time: s?.time ?? /* @__PURE__ */ new Date(),
|
|
1872
1884
|
traceId: t.traceId ?? s?.traceId
|
|
1873
1885
|
};
|
|
1874
|
-
return
|
|
1886
|
+
return i.set(e.messageId, o), new b({ messages: i, pendingConsent: this.pendingConsent });
|
|
1875
1887
|
}
|
|
1876
1888
|
onMessageUser(t) {
|
|
1877
1889
|
const e = t.fact.messageUser;
|
|
1878
1890
|
if ((this.messages?.get(e.messageId) ?? (e.customMessageId ? this.messages?.get(e.customMessageId) : void 0))?.type === "user") return this;
|
|
1879
|
-
const s = new Map(this.messages),
|
|
1891
|
+
const s = new Map(this.messages), i = {
|
|
1880
1892
|
type: "user",
|
|
1881
1893
|
messageId: e.messageId,
|
|
1882
1894
|
text: e.text,
|
|
@@ -1886,7 +1898,7 @@ class b {
|
|
|
1886
1898
|
time: /* @__PURE__ */ new Date(),
|
|
1887
1899
|
traceId: t.traceId
|
|
1888
1900
|
};
|
|
1889
|
-
return s.set(e.messageId,
|
|
1901
|
+
return s.set(e.messageId, i), new b({ messages: s, pendingConsent: this.pendingConsent });
|
|
1890
1902
|
}
|
|
1891
1903
|
onMessageError(t) {
|
|
1892
1904
|
const e = De(), r = t.fact.runError.error, s = new Map(this.messages);
|
|
@@ -1900,7 +1912,7 @@ class b {
|
|
|
1900
1912
|
}), new b({ messages: s, pendingConsent: this.pendingConsent });
|
|
1901
1913
|
}
|
|
1902
1914
|
onToolCallStart(t) {
|
|
1903
|
-
const e = t.fact.toolCallStart, r = new Map(this.messages), s = `${e.processId}-${e.callSeq}`,
|
|
1915
|
+
const e = t.fact.toolCallStart, r = new Map(this.messages), s = `${e.processId}-${e.callSeq}`, i = {
|
|
1904
1916
|
type: "tool-call",
|
|
1905
1917
|
eventType: d.TOOL_CALL_START,
|
|
1906
1918
|
messageId: s,
|
|
@@ -1916,21 +1928,21 @@ class b {
|
|
|
1916
1928
|
time: /* @__PURE__ */ new Date(),
|
|
1917
1929
|
traceId: t.traceId
|
|
1918
1930
|
};
|
|
1919
|
-
return r.set(s,
|
|
1931
|
+
return r.set(s, i), new b({ messages: r, pendingConsent: this.pendingConsent });
|
|
1920
1932
|
}
|
|
1921
1933
|
onToolCallComplete(t) {
|
|
1922
|
-
const e = t.fact.toolCallComplete, r = new Map(this.messages), s = `${e.processId}-${e.callSeq}`,
|
|
1923
|
-
if (
|
|
1924
|
-
const
|
|
1925
|
-
...
|
|
1934
|
+
const e = t.fact.toolCallComplete, r = new Map(this.messages), s = `${e.processId}-${e.callSeq}`, i = r.get(s);
|
|
1935
|
+
if (i?.type === "tool-call") {
|
|
1936
|
+
const o = {
|
|
1937
|
+
...i,
|
|
1926
1938
|
eventType: d.TOOL_CALL_COMPLETE,
|
|
1927
1939
|
result: e.toolCallResult,
|
|
1928
1940
|
isError: e.isError,
|
|
1929
1941
|
sidecar: e.toolUseResultSidecar,
|
|
1930
1942
|
isComplete: !0,
|
|
1931
|
-
traceId: t.traceId ??
|
|
1943
|
+
traceId: t.traceId ?? i.traceId
|
|
1932
1944
|
};
|
|
1933
|
-
r.set(s,
|
|
1945
|
+
r.set(s, o);
|
|
1934
1946
|
}
|
|
1935
1947
|
return new b({ messages: r, pendingConsent: this.pendingConsent });
|
|
1936
1948
|
}
|
|
@@ -1939,7 +1951,7 @@ class b {
|
|
|
1939
1951
|
return new b({ messages: this.messages, pendingConsent: e });
|
|
1940
1952
|
}
|
|
1941
1953
|
onSubagentStart(t) {
|
|
1942
|
-
const e = t.fact.subagentStart, r = new Map(this.messages), s = `subagent:${e.parentToolUseId}:start`,
|
|
1954
|
+
const e = t.fact.subagentStart, r = new Map(this.messages), s = `subagent:${e.parentToolUseId}:start`, i = {
|
|
1943
1955
|
type: "subagent",
|
|
1944
1956
|
messageId: s,
|
|
1945
1957
|
kind: "start",
|
|
@@ -1950,10 +1962,10 @@ class b {
|
|
|
1950
1962
|
time: /* @__PURE__ */ new Date(),
|
|
1951
1963
|
traceId: t.traceId
|
|
1952
1964
|
};
|
|
1953
|
-
return r.set(s,
|
|
1965
|
+
return r.set(s, i), new b({ messages: r, pendingConsent: this.pendingConsent });
|
|
1954
1966
|
}
|
|
1955
1967
|
onSubagentComplete(t) {
|
|
1956
|
-
const e = t.fact.subagentComplete, r = new Map(this.messages), s = `subagent:${e.parentToolUseId}:complete`,
|
|
1968
|
+
const e = t.fact.subagentComplete, r = new Map(this.messages), s = `subagent:${e.parentToolUseId}:complete`, i = {
|
|
1957
1969
|
type: "subagent",
|
|
1958
1970
|
messageId: s,
|
|
1959
1971
|
kind: "complete",
|
|
@@ -1965,12 +1977,12 @@ class b {
|
|
|
1965
1977
|
time: /* @__PURE__ */ new Date(),
|
|
1966
1978
|
traceId: t.traceId
|
|
1967
1979
|
};
|
|
1968
|
-
return r.set(s,
|
|
1980
|
+
return r.set(s, i), new b({ messages: r, pendingConsent: this.pendingConsent });
|
|
1969
1981
|
}
|
|
1970
1982
|
}
|
|
1971
|
-
const
|
|
1972
|
-
function
|
|
1973
|
-
return n.toolsetName === "" &&
|
|
1983
|
+
const un = /* @__PURE__ */ new Set(["TaskCreate", "TaskUpdate"]);
|
|
1984
|
+
function ln(n) {
|
|
1985
|
+
return n.toolsetName === "" && un.has(n.toolName);
|
|
1974
1986
|
}
|
|
1975
1987
|
function ge(n) {
|
|
1976
1988
|
return typeof n == "object" && n !== null ? n : void 0;
|
|
@@ -1978,23 +1990,23 @@ function ge(n) {
|
|
|
1978
1990
|
function E(n) {
|
|
1979
1991
|
return typeof n == "string" ? n : void 0;
|
|
1980
1992
|
}
|
|
1981
|
-
function
|
|
1993
|
+
function dn(n) {
|
|
1982
1994
|
const t = [], e = /* @__PURE__ */ new Map();
|
|
1983
1995
|
for (const r of n) {
|
|
1984
|
-
const s = r.parameter ?? {},
|
|
1996
|
+
const s = r.parameter ?? {}, i = r.sidecar ?? {};
|
|
1985
1997
|
if (r.toolName === "TaskCreate") {
|
|
1986
|
-
const
|
|
1998
|
+
const o = ge(i.task), a = E(o?.id);
|
|
1987
1999
|
if (!a) continue;
|
|
1988
2000
|
e.has(a) || t.push(a), e.set(a, {
|
|
1989
2001
|
id: a,
|
|
1990
|
-
subject: E(s.subject) || E(
|
|
2002
|
+
subject: E(s.subject) || E(o?.subject) || "",
|
|
1991
2003
|
activeForm: E(s.activeForm),
|
|
1992
2004
|
description: E(s.description),
|
|
1993
2005
|
status: e.get(a)?.status ?? "pending"
|
|
1994
2006
|
// initial status = pending (keep existing on repeat)
|
|
1995
2007
|
});
|
|
1996
2008
|
} else if (r.toolName === "TaskUpdate") {
|
|
1997
|
-
const
|
|
2009
|
+
const o = ge(i.statusChange), a = E(s.taskId) || E(i.taskId), u = E(o?.to) || E(s.status);
|
|
1998
2010
|
if (!a || !u) continue;
|
|
1999
2011
|
const c = e.get(a);
|
|
2000
2012
|
c && e.set(a, { ...c, status: u });
|
|
@@ -2002,68 +2014,68 @@ function ln(n) {
|
|
|
2002
2014
|
}
|
|
2003
2015
|
return t.map((r) => e.get(r));
|
|
2004
2016
|
}
|
|
2005
|
-
function
|
|
2017
|
+
function hn(n) {
|
|
2006
2018
|
return n.toolsetName === "" && n.toolName === "Agent";
|
|
2007
2019
|
}
|
|
2008
|
-
function
|
|
2020
|
+
function fn(n) {
|
|
2009
2021
|
return !!n;
|
|
2010
2022
|
}
|
|
2011
|
-
function
|
|
2012
|
-
const t = [], e = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), s = (
|
|
2013
|
-
for (const
|
|
2014
|
-
switch (
|
|
2023
|
+
function pn(n) {
|
|
2024
|
+
const t = [], e = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), s = (i) => (e.has(i) || (t.push(i), e.set(i, { status: "running" }), r.set(i, /* @__PURE__ */ new Map())), e.get(i));
|
|
2025
|
+
for (const i of n)
|
|
2026
|
+
switch (i.kind) {
|
|
2015
2027
|
case "agentStart": {
|
|
2016
|
-
const
|
|
2017
|
-
|
|
2028
|
+
const o = s(i.toolUseId);
|
|
2029
|
+
i.description && !o.description && (o.description = i.description);
|
|
2018
2030
|
break;
|
|
2019
2031
|
}
|
|
2020
2032
|
case "subagentStart": {
|
|
2021
|
-
const
|
|
2022
|
-
|
|
2033
|
+
const o = s(i.parentToolUseId);
|
|
2034
|
+
o.agentId = i.agentId ?? o.agentId, o.subagentType = i.subagentType ?? o.subagentType, o.description = i.description ?? o.description;
|
|
2023
2035
|
break;
|
|
2024
2036
|
}
|
|
2025
2037
|
case "toolStart": {
|
|
2026
|
-
s(
|
|
2027
|
-
toolsetName:
|
|
2028
|
-
toolName:
|
|
2029
|
-
parameter:
|
|
2030
|
-
reason:
|
|
2038
|
+
s(i.parentToolUseId), r.get(i.parentToolUseId).set(i.toolUseId, {
|
|
2039
|
+
toolsetName: i.toolsetName,
|
|
2040
|
+
toolName: i.toolName,
|
|
2041
|
+
parameter: i.parameter ?? {},
|
|
2042
|
+
reason: i.reason,
|
|
2031
2043
|
status: "running"
|
|
2032
2044
|
});
|
|
2033
2045
|
break;
|
|
2034
2046
|
}
|
|
2035
2047
|
case "toolComplete": {
|
|
2036
|
-
const
|
|
2037
|
-
|
|
2048
|
+
const o = r.get(i.parentToolUseId)?.get(i.toolUseId);
|
|
2049
|
+
o && (o.status = i.isError ? "error" : "completed");
|
|
2038
2050
|
break;
|
|
2039
2051
|
}
|
|
2040
2052
|
case "subagentComplete": {
|
|
2041
|
-
const
|
|
2042
|
-
|
|
2053
|
+
const o = s(i.parentToolUseId);
|
|
2054
|
+
o.status = i.status, o.summary = i.summary;
|
|
2043
2055
|
break;
|
|
2044
2056
|
}
|
|
2045
2057
|
}
|
|
2046
|
-
return t.map((
|
|
2047
|
-
parentToolUseId:
|
|
2048
|
-
...e.get(
|
|
2049
|
-
tools: Array.from(r.get(
|
|
2058
|
+
return t.map((i) => ({
|
|
2059
|
+
parentToolUseId: i,
|
|
2060
|
+
...e.get(i),
|
|
2061
|
+
tools: Array.from(r.get(i).values())
|
|
2050
2062
|
}));
|
|
2051
2063
|
}
|
|
2052
|
-
function
|
|
2064
|
+
function mn(n) {
|
|
2053
2065
|
return typeof n == "string" ? n : void 0;
|
|
2054
2066
|
}
|
|
2055
|
-
function
|
|
2067
|
+
function gn(n) {
|
|
2056
2068
|
const t = [];
|
|
2057
2069
|
for (const e of n) {
|
|
2058
|
-
if (e.type === "tool-call" &&
|
|
2070
|
+
if (e.type === "tool-call" && hn(e)) {
|
|
2059
2071
|
t.push({
|
|
2060
2072
|
kind: "agentStart",
|
|
2061
2073
|
toolUseId: e.toolUseId ?? e.messageId,
|
|
2062
|
-
description:
|
|
2074
|
+
description: mn(e.parameter.description)
|
|
2063
2075
|
});
|
|
2064
2076
|
continue;
|
|
2065
2077
|
}
|
|
2066
|
-
if (e.type === "tool-call" &&
|
|
2078
|
+
if (e.type === "tool-call" && fn(e.parentToolUseId)) {
|
|
2067
2079
|
const r = e.toolUseId ?? e.messageId;
|
|
2068
2080
|
t.push({
|
|
2069
2081
|
kind: "toolStart",
|
|
@@ -2100,37 +2112,37 @@ function mn(n) {
|
|
|
2100
2112
|
}
|
|
2101
2113
|
return t;
|
|
2102
2114
|
}
|
|
2103
|
-
function
|
|
2115
|
+
function vn(n) {
|
|
2104
2116
|
const t = Array.from(n.messages?.values() ?? []).filter(
|
|
2105
|
-
(e) => e.type === "tool-call" && e.isComplete &&
|
|
2117
|
+
(e) => e.type === "tool-call" && e.isComplete && ln(e)
|
|
2106
2118
|
);
|
|
2107
|
-
return
|
|
2119
|
+
return dn(t);
|
|
2108
2120
|
}
|
|
2109
|
-
function
|
|
2110
|
-
return
|
|
2121
|
+
function yn(n) {
|
|
2122
|
+
return pn(gn(Array.from(n.messages?.values() ?? [])));
|
|
2111
2123
|
}
|
|
2112
|
-
function
|
|
2124
|
+
function bn(n, t) {
|
|
2113
2125
|
return n === t ? !0 : n.length !== t.length ? !1 : n.every((e, r) => {
|
|
2114
2126
|
const s = t[r];
|
|
2115
2127
|
return e.id === s.id && e.status === s.status && e.subject === s.subject && e.activeForm === s.activeForm && e.description === s.description;
|
|
2116
2128
|
});
|
|
2117
2129
|
}
|
|
2118
|
-
function
|
|
2130
|
+
function Sn(n, t) {
|
|
2119
2131
|
return n.length !== t.length ? !1 : n.every((e, r) => {
|
|
2120
2132
|
const s = t[r];
|
|
2121
2133
|
return e.toolName === s.toolName && e.toolsetName === s.toolsetName && e.status === s.status && e.reason === s.reason;
|
|
2122
2134
|
});
|
|
2123
2135
|
}
|
|
2124
|
-
function
|
|
2136
|
+
function In(n, t) {
|
|
2125
2137
|
return n === t ? !0 : n.length !== t.length ? !1 : n.every((e, r) => {
|
|
2126
2138
|
const s = t[r];
|
|
2127
|
-
return e.parentToolUseId === s.parentToolUseId && e.status === s.status && e.subagentType === s.subagentType && e.description === s.description && e.summary === s.summary &&
|
|
2139
|
+
return e.parentToolUseId === s.parentToolUseId && e.status === s.status && e.subagentType === s.subagentType && e.description === s.description && e.summary === s.summary && Sn(e.tools, s.tools);
|
|
2128
2140
|
});
|
|
2129
2141
|
}
|
|
2130
|
-
function
|
|
2142
|
+
function En(n) {
|
|
2131
2143
|
const t = new N([]), e = new N([]), r = new U();
|
|
2132
|
-
return r.add(n.pipe(P(
|
|
2133
|
-
n.pipe(P(
|
|
2144
|
+
return r.add(n.pipe(P(vn), Z(bn)).subscribe(t)), r.add(
|
|
2145
|
+
n.pipe(P(yn), Z(In)).subscribe(e)
|
|
2134
2146
|
), {
|
|
2135
2147
|
tasks$: t.asObservable(),
|
|
2136
2148
|
subagents$: e.asObservable(),
|
|
@@ -2161,12 +2173,16 @@ class K {
|
|
|
2161
2173
|
// lifecycle so RESPONSE_TOOL_CALL_CONSENT — fired after run.done — can echo
|
|
2162
2174
|
// back the message id the bot is waiting on.
|
|
2163
2175
|
lastSentMessageId;
|
|
2176
|
+
// The in-flight SSE run's subscription. Held so a user-initiated stop-generation can abort the
|
|
2177
|
+
// connection (unsubscribe → create-sse-observable teardown → AbortController.abort()). Cleared on
|
|
2178
|
+
// every terminal (complete / error) and on stop.
|
|
2179
|
+
currentRun;
|
|
2164
2180
|
constructor(t) {
|
|
2165
2181
|
if (!t.client)
|
|
2166
2182
|
throw new Error("client must be required");
|
|
2167
2183
|
if (!t.customChannelId)
|
|
2168
2184
|
throw new Error("customChannelId must be required");
|
|
2169
|
-
this.client = t.client, this.customChannelId = t.customChannelId, this.customMessageId = t.customMessageId, this.isConnecting$ = new N(!1), this.conversation$ = new N(t.conversation), this.channelTitleSubject = new N(t.channelTitle ?? null), this.derivedStores =
|
|
2185
|
+
this.client = t.client, this.customChannelId = t.customChannelId, this.customMessageId = t.customMessageId, this.isConnecting$ = new N(!1), this.conversation$ = new N(t.conversation), this.channelTitleSubject = new N(t.channelTitle ?? null), this.derivedStores = En(this.conversation$), this.tasks$ = this.derivedStores.tasks$, this.subagents$ = this.derivedStores.subagents$, this.channelTitle$ = this.channelTitleSubject.pipe(Z()), this.statesObserver = t.statesObserver;
|
|
2170
2186
|
}
|
|
2171
2187
|
/** Current Task Check List snapshot (F-013) — for framework-agnostic `getSnapshot()` bridging. */
|
|
2172
2188
|
getTasks() {
|
|
@@ -2189,11 +2205,11 @@ class K {
|
|
|
2189
2205
|
return e.subscribe(), e;
|
|
2190
2206
|
}
|
|
2191
2207
|
static async reset(t, e, r, s) {
|
|
2192
|
-
const
|
|
2208
|
+
const i = new K(t);
|
|
2193
2209
|
try {
|
|
2194
|
-
return
|
|
2195
|
-
} catch (
|
|
2196
|
-
throw
|
|
2210
|
+
return i.subscribe(), s?.(i), await i.resetChannel(e, r), i;
|
|
2211
|
+
} catch (o) {
|
|
2212
|
+
throw i.close(), o;
|
|
2197
2213
|
}
|
|
2198
2214
|
}
|
|
2199
2215
|
/**
|
|
@@ -2207,8 +2223,8 @@ class K {
|
|
|
2207
2223
|
const s = new K(t);
|
|
2208
2224
|
try {
|
|
2209
2225
|
return s.subscribe(), r?.(s), await s.rejoinChannel(e), s;
|
|
2210
|
-
} catch (
|
|
2211
|
-
throw s.close(),
|
|
2226
|
+
} catch (i) {
|
|
2227
|
+
throw s.close(), i;
|
|
2212
2228
|
}
|
|
2213
2229
|
}
|
|
2214
2230
|
subscribe() {
|
|
@@ -2219,12 +2235,12 @@ class K {
|
|
|
2219
2235
|
this.derivedStores.subagents$,
|
|
2220
2236
|
this.channelTitle$
|
|
2221
2237
|
]).pipe(
|
|
2222
|
-
P(([t, e, r, s,
|
|
2238
|
+
P(([t, e, r, s, i]) => ({
|
|
2223
2239
|
isConnecting: t,
|
|
2224
2240
|
conversation: e,
|
|
2225
2241
|
tasks: r,
|
|
2226
2242
|
subagents: s,
|
|
2227
|
-
channelTitle:
|
|
2243
|
+
channelTitle: i
|
|
2228
2244
|
}))
|
|
2229
2245
|
).subscribe(this.statesObserver);
|
|
2230
2246
|
}
|
|
@@ -2254,25 +2270,25 @@ class K {
|
|
|
2254
2270
|
if (t?.onSseMessage?.(s), s.eventType === d.CHANNEL_TITLE_UPDATE && this.channelTitleSubject.next(
|
|
2255
2271
|
s.fact.channelTitleUpdate.title
|
|
2256
2272
|
), this.currentUserMessageId && s.traceId) {
|
|
2257
|
-
const
|
|
2258
|
-
|
|
2259
|
-
...
|
|
2273
|
+
const i = new Map(this.conversation$.value.messages), o = i.get(this.currentUserMessageId);
|
|
2274
|
+
o && o.type === "user" && (i.set(this.currentUserMessageId, {
|
|
2275
|
+
...o,
|
|
2260
2276
|
traceId: s.traceId
|
|
2261
|
-
}), this.conversation$.next(new b({ messages:
|
|
2277
|
+
}), this.conversation$.next(new b({ messages: i }))), this.currentUserMessageId = void 0;
|
|
2262
2278
|
}
|
|
2263
2279
|
this.conversation$.next(this.conversation$.value.onMessage(s));
|
|
2264
2280
|
},
|
|
2265
2281
|
onSseError: (s) => {
|
|
2266
|
-
t?.onSseError?.(s), this.isConnecting$.next(!1), this.currentUserMessageId = void 0, r(s);
|
|
2282
|
+
t?.onSseError?.(s), this.isConnecting$.next(!1), this.currentUserMessageId = void 0, this.currentRun = void 0, r(s);
|
|
2267
2283
|
},
|
|
2268
2284
|
onSseCompleted: () => {
|
|
2269
|
-
t?.onSseCompleted?.(), this.isConnecting$.next(!1), this.currentUserMessageId = void 0, e();
|
|
2285
|
+
t?.onSseCompleted?.(), this.isConnecting$.next(!1), this.currentUserMessageId = void 0, this.currentRun = void 0, e();
|
|
2270
2286
|
}
|
|
2271
2287
|
};
|
|
2272
2288
|
}
|
|
2273
2289
|
fetchSse(t, e) {
|
|
2274
2290
|
return new Promise((r, s) => {
|
|
2275
|
-
this.isConnecting$.next(!0), this.client.fetchSse(t, this.buildRunHandlers(e, r, s));
|
|
2291
|
+
this.isConnecting$.next(!0), this.currentRun = this.client.fetchSse(t, this.buildRunHandlers(e, r, s));
|
|
2276
2292
|
});
|
|
2277
2293
|
}
|
|
2278
2294
|
/**
|
|
@@ -2287,7 +2303,7 @@ class K {
|
|
|
2287
2303
|
e();
|
|
2288
2304
|
return;
|
|
2289
2305
|
}
|
|
2290
|
-
this.isConnecting$.next(!0), this.client.rejoinSse(this.customChannelId, this.buildRunHandlers(t, e, r));
|
|
2306
|
+
this.isConnecting$.next(!0), this.currentRun = this.client.rejoinSse(this.customChannelId, this.buildRunHandlers(t, e, r));
|
|
2291
2307
|
});
|
|
2292
2308
|
}
|
|
2293
2309
|
resetChannel(t, e) {
|
|
@@ -2339,12 +2355,21 @@ class K {
|
|
|
2339
2355
|
e
|
|
2340
2356
|
);
|
|
2341
2357
|
}
|
|
2358
|
+
/**
|
|
2359
|
+
* User-initiated stop-generation: abort the in-flight SSE run (if any) and release the input.
|
|
2360
|
+
* Unsubscribing tears down the SSE observable → AbortController.abort() cuts the HTTP stream. The
|
|
2361
|
+
* partial assistant message already received stays in the conversation (frozen, not deleted). A no-op
|
|
2362
|
+
* when nothing is running.
|
|
2363
|
+
*/
|
|
2364
|
+
stopGeneration() {
|
|
2365
|
+
this.currentRun && (this.currentRun.unsubscribe(), this.currentRun = void 0, this.isConnecting$.next(!1), this.currentUserMessageId = void 0);
|
|
2366
|
+
}
|
|
2342
2367
|
close() {
|
|
2343
|
-
this.isConnecting$.complete(), this.conversation$.complete(), this.channelTitleSubject.complete(), this.derivedStores.teardown(), this.statesSubscription?.unsubscribe();
|
|
2368
|
+
this.currentRun?.unsubscribe(), this.currentRun = void 0, this.isConnecting$.complete(), this.conversation$.complete(), this.channelTitleSubject.complete(), this.derivedStores.teardown(), this.statesSubscription?.unsubscribe();
|
|
2344
2369
|
}
|
|
2345
2370
|
}
|
|
2346
2371
|
export {
|
|
2347
|
-
|
|
2372
|
+
Tn as AsgardServiceClient,
|
|
2348
2373
|
K as Channel,
|
|
2349
2374
|
b as Conversation,
|
|
2350
2375
|
d as EventType,
|
|
@@ -2352,17 +2377,17 @@ export {
|
|
|
2352
2377
|
te as HttpError,
|
|
2353
2378
|
Fe as MessageTemplateType,
|
|
2354
2379
|
Ke as ToolCallConsentResult,
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2380
|
+
gn as conversationToSubagentEvents,
|
|
2381
|
+
En as createDerivedStores,
|
|
2382
|
+
yn as deriveSubagents,
|
|
2383
|
+
vn as deriveTasks,
|
|
2384
|
+
hn as isAgentTool,
|
|
2385
|
+
wn as isHttpError,
|
|
2386
|
+
fn as isSubagentChildTool,
|
|
2387
|
+
ln as isTaskTool,
|
|
2388
|
+
pn as reduceSubagents,
|
|
2389
|
+
dn as reduceTaskEvents,
|
|
2390
|
+
In as subagentsEqual,
|
|
2391
|
+
bn as tasksEqual
|
|
2367
2392
|
};
|
|
2368
2393
|
//# sourceMappingURL=index.mjs.map
|