@asgard-js/core 0.3.6 → 0.3.8
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 +420 -380
- 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/lib/conversation.d.ts +8 -0
- package/dist/lib/conversation.d.ts.map +1 -1
- package/dist/types/channel.d.ts +6 -0
- package/dist/types/channel.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
|
-
} catch (
|
|
39
|
-
|
|
38
|
+
} catch (g) {
|
|
39
|
+
o(g);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
function u(h) {
|
|
43
43
|
try {
|
|
44
44
|
c(r.throw(h));
|
|
45
|
-
} catch (
|
|
46
|
-
|
|
45
|
+
} catch (g) {
|
|
46
|
+
o(g);
|
|
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
|
-
return Promise.resolve(f).then(l,
|
|
158
|
+
return Promise.resolve(f).then(l, g);
|
|
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,20 +169,20 @@ 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,
|
|
176
|
+
l.value instanceof L ? Promise.resolve(l.value.v).then(h, g) : v(i[0][2], l);
|
|
177
177
|
}
|
|
178
178
|
function h(l) {
|
|
179
179
|
u("next", l);
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function g(l) {
|
|
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,20 +191,20 @@ 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
|
-
function
|
|
207
|
+
function m(n) {
|
|
208
208
|
return typeof n == "function";
|
|
209
209
|
}
|
|
210
210
|
function ye(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,24 +254,24 @@ var U = (function() {
|
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
else
|
|
257
|
-
|
|
257
|
+
o.remove(this);
|
|
258
258
|
var h = this.initialTeardown;
|
|
259
|
-
if (
|
|
259
|
+
if (m(h))
|
|
260
260
|
try {
|
|
261
261
|
h();
|
|
262
262
|
} catch (p) {
|
|
263
|
-
|
|
263
|
+
i = p instanceof W ? p.errors : [p];
|
|
264
264
|
}
|
|
265
|
-
var
|
|
266
|
-
if (
|
|
265
|
+
var g = this._finalizers;
|
|
266
|
+
if (g) {
|
|
267
267
|
this._finalizers = null;
|
|
268
268
|
try {
|
|
269
|
-
for (var v = k(
|
|
269
|
+
for (var v = k(g), 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))
|
|
@@ -318,10 +318,10 @@ var U = (function() {
|
|
|
318
318
|
})(), n;
|
|
319
319
|
})(), be = U.EMPTY;
|
|
320
320
|
function Se(n) {
|
|
321
|
-
return n instanceof U || n && "closed" in n &&
|
|
321
|
+
return n instanceof U || n && "closed" in n && m(n.remove) && m(n.add) && m(n.unsubscribe);
|
|
322
322
|
}
|
|
323
|
-
function
|
|
324
|
-
|
|
323
|
+
function oe(n) {
|
|
324
|
+
m(n) ? n() : n.unsubscribe();
|
|
325
325
|
}
|
|
326
326
|
var Ye = {
|
|
327
327
|
Promise: void 0
|
|
@@ -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
|
|
414
|
+
var i = n.call(this) || this, o;
|
|
415
|
+
return m(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) {
|
|
@@ -509,15 +509,15 @@ function ae(n) {
|
|
|
509
509
|
return (t = n ?? Ye.Promise) !== null && t !== void 0 ? t : Promise;
|
|
510
510
|
}
|
|
511
511
|
function Ze(n) {
|
|
512
|
-
return n &&
|
|
512
|
+
return n && m(n.next) && m(n.error) && m(n.complete);
|
|
513
513
|
}
|
|
514
514
|
function et(n) {
|
|
515
515
|
return n && n instanceof ne || Ze(n) && Se(n);
|
|
516
516
|
}
|
|
517
517
|
function tt(n) {
|
|
518
|
-
return
|
|
518
|
+
return m(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,17 +789,17 @@ 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) {
|
|
796
|
-
return n &&
|
|
796
|
+
return n && m(n.schedule);
|
|
797
797
|
}
|
|
798
798
|
function Te(n) {
|
|
799
799
|
return n[n.length - 1];
|
|
800
800
|
}
|
|
801
801
|
function lt(n) {
|
|
802
|
-
return
|
|
802
|
+
return m(Te(n)) ? n.pop() : void 0;
|
|
803
803
|
}
|
|
804
804
|
function Ce(n) {
|
|
805
805
|
return we(Te(n)) ? n.pop() : void 0;
|
|
@@ -808,13 +808,13 @@ var Oe = (function(n) {
|
|
|
808
808
|
return n && typeof n.length == "number" && typeof n != "function";
|
|
809
809
|
});
|
|
810
810
|
function Ae(n) {
|
|
811
|
-
return
|
|
811
|
+
return m(n?.then);
|
|
812
812
|
}
|
|
813
813
|
function _e(n) {
|
|
814
|
-
return
|
|
814
|
+
return m(n[re]);
|
|
815
815
|
}
|
|
816
816
|
function Me(n) {
|
|
817
|
-
return Symbol.asyncIterator &&
|
|
817
|
+
return Symbol.asyncIterator && m(n?.[Symbol.asyncIterator]);
|
|
818
818
|
}
|
|
819
819
|
function xe(n) {
|
|
820
820
|
return new TypeError("You provided " + (n !== null && typeof n == "object" ? "an invalid object" : "'" + n + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
|
|
@@ -824,29 +824,29 @@ function dt() {
|
|
|
824
824
|
}
|
|
825
825
|
var Le = dt();
|
|
826
826
|
function ke(n) {
|
|
827
|
-
return
|
|
827
|
+
return m(n?.[Le]);
|
|
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:
|
|
@@ -858,7 +858,7 @@ function Pe(n) {
|
|
|
858
858
|
});
|
|
859
859
|
}
|
|
860
860
|
function Ue(n) {
|
|
861
|
-
return
|
|
861
|
+
return m(n?.getReader);
|
|
862
862
|
}
|
|
863
863
|
function x(n) {
|
|
864
864
|
if (n instanceof S)
|
|
@@ -873,16 +873,16 @@ function x(n) {
|
|
|
873
873
|
if (Me(n))
|
|
874
874
|
return Ne(n);
|
|
875
875
|
if (ke(n))
|
|
876
|
-
return mt(n);
|
|
877
|
-
if (Ue(n))
|
|
878
876
|
return gt(n);
|
|
877
|
+
if (Ue(n))
|
|
878
|
+
return mt(n);
|
|
879
879
|
}
|
|
880
880
|
throw xe(n);
|
|
881
881
|
}
|
|
882
882
|
function ht(n) {
|
|
883
883
|
return new S(function(t) {
|
|
884
884
|
var e = n[re]();
|
|
885
|
-
if (
|
|
885
|
+
if (m(e.subscribe))
|
|
886
886
|
return e.subscribe(t);
|
|
887
887
|
throw new TypeError("Provided object does not correctly implement Symbol.observable");
|
|
888
888
|
});
|
|
@@ -903,20 +903,20 @@ function pt(n) {
|
|
|
903
903
|
}).then(null, Ie);
|
|
904
904
|
});
|
|
905
905
|
}
|
|
906
|
-
function
|
|
906
|
+
function gt(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
|
}
|
|
@@ -931,13 +931,13 @@ function Ne(n) {
|
|
|
931
931
|
});
|
|
932
932
|
});
|
|
933
933
|
}
|
|
934
|
-
function
|
|
934
|
+
function mt(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,17 +1023,17 @@ 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
|
-
return
|
|
1036
|
+
return m(r?.return) && r.return();
|
|
1037
1037
|
};
|
|
1038
1038
|
});
|
|
1039
1039
|
}
|
|
@@ -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
|
|
1146
|
-
|
|
1147
|
-
|
|
1145
|
+
var g = ie(n[h], t), v = !1;
|
|
1146
|
+
g.subscribe(O(r, function(l) {
|
|
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,44 +1157,44 @@ 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,
|
|
1161
|
-
var u = [], c = 0, h = 0,
|
|
1162
|
-
|
|
1160
|
+
function jt(n, t, e, r, s, i, o, a) {
|
|
1161
|
+
var u = [], c = 0, h = 0, g = !1, v = function() {
|
|
1162
|
+
g && !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
|
};
|
|
1187
1187
|
return n.subscribe(O(t, l, function() {
|
|
1188
|
-
|
|
1188
|
+
g = !0, v();
|
|
1189
1189
|
})), function() {
|
|
1190
1190
|
};
|
|
1191
1191
|
}
|
|
1192
1192
|
function B(n, t, e) {
|
|
1193
|
-
return e === void 0 && (e = 1 / 0),
|
|
1194
|
-
return P(function(
|
|
1195
|
-
return t(r,
|
|
1193
|
+
return e === void 0 && (e = 1 / 0), m(t) ? B(function(r, s) {
|
|
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,21 +1202,21 @@ 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) {
|
|
1214
|
-
return
|
|
1214
|
+
return m(t) ? B(n, t, 1) : B(n, 1);
|
|
1215
1215
|
}
|
|
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 + `
|
|
@@ -1312,14 +1321,14 @@ function Xt(n, t, e) {
|
|
|
1312
1321
|
n(r.id = h);
|
|
1313
1322
|
break;
|
|
1314
1323
|
case "retry":
|
|
1315
|
-
const
|
|
1316
|
-
isNaN(
|
|
1324
|
+
const g = parseInt(h, 10);
|
|
1325
|
+
isNaN(g) || t(r.retry = g);
|
|
1317
1326
|
break;
|
|
1318
1327
|
}
|
|
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,10 +1348,10 @@ 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:
|
|
1345
|
-
return new Promise((
|
|
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"]);
|
|
1354
|
+
return new Promise((g, v) => {
|
|
1346
1355
|
const l = Object.assign({}, r);
|
|
1347
1356
|
l.accept || (l.accept = ee);
|
|
1348
1357
|
let f;
|
|
@@ -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(), g();
|
|
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(), g();
|
|
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
|
-
const
|
|
1403
|
+
const g = {
|
|
1395
1404
|
"Content-Type": "application/json",
|
|
1396
|
-
...
|
|
1405
|
+
...i
|
|
1397
1406
|
};
|
|
1398
|
-
e && (
|
|
1407
|
+
e && (g["X-API-KEY"] = e);
|
|
1399
1408
|
const v = new URL(t);
|
|
1400
|
-
return s && v.searchParams.set("is_debug", "true"),
|
|
1401
|
-
method:
|
|
1402
|
-
headers:
|
|
1403
|
-
body:
|
|
1409
|
+
return s && v.searchParams.set("is_debug", "true"), en(v.toString(), {
|
|
1410
|
+
method: o,
|
|
1411
|
+
headers: g,
|
|
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}`);
|
|
@@ -1700,34 +1712,34 @@ class wn {
|
|
|
1700
1712
|
return !t && this.endpoint && (t = this.endpoint.replace("/message/sse", "")), t ? t.replace(/\/+$/, "") : null;
|
|
1701
1713
|
}
|
|
1702
1714
|
}
|
|
1703
|
-
const
|
|
1715
|
+
const b = [];
|
|
1704
1716
|
for (let n = 0; n < 256; ++n)
|
|
1705
|
-
|
|
1706
|
-
function
|
|
1707
|
-
return (
|
|
1717
|
+
b.push((n + 256).toString(16).slice(1));
|
|
1718
|
+
function rn(n, t = 0) {
|
|
1719
|
+
return (b[n[t + 0]] + b[n[t + 1]] + b[n[t + 2]] + b[n[t + 3]] + "-" + b[n[t + 4]] + b[n[t + 5]] + "-" + b[n[t + 6]] + b[n[t + 7]] + "-" + b[n[t + 8]] + b[n[t + 9]] + "-" + b[n[t + 10]] + b[n[t + 11]] + b[n[t + 12]] + b[n[t + 13]] + b[n[t + 14]] + b[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), ge = { 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
|
|
1740
|
+
return ge.randomUUID && !n ? ge.randomUUID() : cn(n);
|
|
1729
1741
|
}
|
|
1730
|
-
class
|
|
1742
|
+
class y {
|
|
1731
1743
|
messages = null;
|
|
1732
1744
|
pendingConsent = null;
|
|
1733
1745
|
constructor({ messages: t, pendingConsent: e = null }) {
|
|
@@ -1735,10 +1747,25 @@ class b {
|
|
|
1735
1747
|
}
|
|
1736
1748
|
pushMessage(t) {
|
|
1737
1749
|
const e = new Map(this.messages);
|
|
1738
|
-
return e.set(t.messageId, t), new
|
|
1750
|
+
return e.set(t.messageId, t), new y({ messages: e, pendingConsent: this.pendingConsent });
|
|
1739
1751
|
}
|
|
1740
1752
|
clearPendingConsent() {
|
|
1741
|
-
return this.pendingConsent ? new
|
|
1753
|
+
return this.pendingConsent ? new y({ messages: this.messages, pendingConsent: null }) : this;
|
|
1754
|
+
}
|
|
1755
|
+
/**
|
|
1756
|
+
* Converge every still-running tool-call to `cancelled` (F-020 AC10). Called when a user-initiated
|
|
1757
|
+
* stop-generation aborts the run: an in-flight tool-call (`isComplete === false`) would otherwise
|
|
1758
|
+
* linger as `running` forever, since its `tool_call.complete` frame never arrives. Already-settled
|
|
1759
|
+
* calls and non-tool-call messages are left untouched; content is preserved (never rolled back).
|
|
1760
|
+
* Returns the same instance when nothing is in flight.
|
|
1761
|
+
*/
|
|
1762
|
+
cancelInFlightToolCalls() {
|
|
1763
|
+
if (!this.messages) return this;
|
|
1764
|
+
let t = !1;
|
|
1765
|
+
const e = new Map(this.messages);
|
|
1766
|
+
for (const [r, s] of e)
|
|
1767
|
+
s.type === "tool-call" && !s.isComplete && (e.set(r, { ...s, isComplete: !0, isCancelled: !0 }), t = !0);
|
|
1768
|
+
return t ? new y({ messages: e, pendingConsent: this.pendingConsent }) : this;
|
|
1742
1769
|
}
|
|
1743
1770
|
onMessage(t) {
|
|
1744
1771
|
switch (t.eventType) {
|
|
@@ -1802,13 +1829,13 @@ class b {
|
|
|
1802
1829
|
time: /* @__PURE__ */ new Date(),
|
|
1803
1830
|
traceId: t.traceId,
|
|
1804
1831
|
raw: ""
|
|
1805
|
-
}), new
|
|
1832
|
+
}), new y({ messages: r, pendingConsent: this.pendingConsent });
|
|
1806
1833
|
}
|
|
1807
1834
|
onMessageDelta(t) {
|
|
1808
1835
|
const e = t.fact.messageDelta.message, r = this.messages?.get(e.messageId);
|
|
1809
1836
|
if (this.isTerminalBot(r)) return this;
|
|
1810
|
-
const s = r?.type === "bot" ? r : void 0,
|
|
1811
|
-
return
|
|
1837
|
+
const s = r?.type === "bot" ? r : void 0, i = new Map(this.messages);
|
|
1838
|
+
return i.set(e.messageId, {
|
|
1812
1839
|
type: "bot",
|
|
1813
1840
|
eventType: d.MESSAGE_DELTA,
|
|
1814
1841
|
isTyping: !0,
|
|
@@ -1818,7 +1845,7 @@ class b {
|
|
|
1818
1845
|
time: /* @__PURE__ */ new Date(),
|
|
1819
1846
|
traceId: t.traceId ?? s?.traceId,
|
|
1820
1847
|
raw: s?.raw ?? ""
|
|
1821
|
-
}), new
|
|
1848
|
+
}), new y({ messages: i, pendingConsent: this.pendingConsent });
|
|
1822
1849
|
}
|
|
1823
1850
|
onMessageComplete(t) {
|
|
1824
1851
|
const e = t.fact.messageComplete.message, r = new Map(this.messages), s = r.get(e.messageId);
|
|
@@ -1832,7 +1859,7 @@ class b {
|
|
|
1832
1859
|
time: /* @__PURE__ */ new Date(),
|
|
1833
1860
|
traceId: t.traceId ?? (s?.type === "bot" ? s.traceId : void 0),
|
|
1834
1861
|
raw: JSON.stringify(t)
|
|
1835
|
-
}), new
|
|
1862
|
+
}), new y({ messages: r, pendingConsent: this.pendingConsent });
|
|
1836
1863
|
}
|
|
1837
1864
|
onThinkingStart(t) {
|
|
1838
1865
|
const e = t.fact.messageThinkingStart.message;
|
|
@@ -1845,12 +1872,12 @@ class b {
|
|
|
1845
1872
|
time: /* @__PURE__ */ new Date(),
|
|
1846
1873
|
traceId: t.traceId
|
|
1847
1874
|
};
|
|
1848
|
-
return r.set(e.messageId, s), new
|
|
1875
|
+
return r.set(e.messageId, s), new y({ messages: r, pendingConsent: this.pendingConsent });
|
|
1849
1876
|
}
|
|
1850
1877
|
onThinkingDelta(t) {
|
|
1851
1878
|
const e = t.fact.messageThinkingDelta.message, r = this.messages?.get(e.messageId);
|
|
1852
1879
|
if (this.isTerminalThinking(r)) return this;
|
|
1853
|
-
const s = r?.type === "thinking" ? r : void 0,
|
|
1880
|
+
const s = r?.type === "thinking" ? r : void 0, i = new Map(this.messages), o = {
|
|
1854
1881
|
type: "thinking",
|
|
1855
1882
|
messageId: e.messageId,
|
|
1856
1883
|
text: `${s?.text ?? ""}${e.text}`,
|
|
@@ -1858,10 +1885,10 @@ class b {
|
|
|
1858
1885
|
time: s?.time ?? /* @__PURE__ */ new Date(),
|
|
1859
1886
|
traceId: t.traceId ?? s?.traceId
|
|
1860
1887
|
};
|
|
1861
|
-
return
|
|
1888
|
+
return i.set(e.messageId, o), new y({ messages: i, pendingConsent: this.pendingConsent });
|
|
1862
1889
|
}
|
|
1863
1890
|
onThinkingComplete(t) {
|
|
1864
|
-
const e = t.fact.messageThinkingComplete.message, r = this.messages?.get(e.messageId), s = r?.type === "thinking" ? r : void 0,
|
|
1891
|
+
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
1892
|
type: "thinking",
|
|
1866
1893
|
messageId: e.messageId,
|
|
1867
1894
|
// Self-sufficient (F-011): the complete frame carries the full reasoning, so a complete-only
|
|
@@ -1871,12 +1898,12 @@ class b {
|
|
|
1871
1898
|
time: s?.time ?? /* @__PURE__ */ new Date(),
|
|
1872
1899
|
traceId: t.traceId ?? s?.traceId
|
|
1873
1900
|
};
|
|
1874
|
-
return
|
|
1901
|
+
return i.set(e.messageId, o), new y({ messages: i, pendingConsent: this.pendingConsent });
|
|
1875
1902
|
}
|
|
1876
1903
|
onMessageUser(t) {
|
|
1877
1904
|
const e = t.fact.messageUser;
|
|
1878
1905
|
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),
|
|
1906
|
+
const s = new Map(this.messages), i = {
|
|
1880
1907
|
type: "user",
|
|
1881
1908
|
messageId: e.messageId,
|
|
1882
1909
|
text: e.text,
|
|
@@ -1886,7 +1913,7 @@ class b {
|
|
|
1886
1913
|
time: /* @__PURE__ */ new Date(),
|
|
1887
1914
|
traceId: t.traceId
|
|
1888
1915
|
};
|
|
1889
|
-
return s.set(e.messageId,
|
|
1916
|
+
return s.set(e.messageId, i), new y({ messages: s, pendingConsent: this.pendingConsent });
|
|
1890
1917
|
}
|
|
1891
1918
|
onMessageError(t) {
|
|
1892
1919
|
const e = De(), r = t.fact.runError.error, s = new Map(this.messages);
|
|
@@ -1897,10 +1924,10 @@ class b {
|
|
|
1897
1924
|
error: r,
|
|
1898
1925
|
time: /* @__PURE__ */ new Date(),
|
|
1899
1926
|
traceId: t.traceId
|
|
1900
|
-
}), new
|
|
1927
|
+
}), new y({ messages: s, pendingConsent: this.pendingConsent });
|
|
1901
1928
|
}
|
|
1902
1929
|
onToolCallStart(t) {
|
|
1903
|
-
const e = t.fact.toolCallStart, r = new Map(this.messages), s = `${e.processId}-${e.callSeq}`,
|
|
1930
|
+
const e = t.fact.toolCallStart, r = new Map(this.messages), s = `${e.processId}-${e.callSeq}`, i = {
|
|
1904
1931
|
type: "tool-call",
|
|
1905
1932
|
eventType: d.TOOL_CALL_START,
|
|
1906
1933
|
messageId: s,
|
|
@@ -1916,30 +1943,30 @@ class b {
|
|
|
1916
1943
|
time: /* @__PURE__ */ new Date(),
|
|
1917
1944
|
traceId: t.traceId
|
|
1918
1945
|
};
|
|
1919
|
-
return r.set(s,
|
|
1946
|
+
return r.set(s, i), new y({ messages: r, pendingConsent: this.pendingConsent });
|
|
1920
1947
|
}
|
|
1921
1948
|
onToolCallComplete(t) {
|
|
1922
|
-
const e = t.fact.toolCallComplete, r = new Map(this.messages), s = `${e.processId}-${e.callSeq}`,
|
|
1923
|
-
if (
|
|
1924
|
-
const
|
|
1925
|
-
...
|
|
1949
|
+
const e = t.fact.toolCallComplete, r = new Map(this.messages), s = `${e.processId}-${e.callSeq}`, i = r.get(s);
|
|
1950
|
+
if (i?.type === "tool-call") {
|
|
1951
|
+
const o = {
|
|
1952
|
+
...i,
|
|
1926
1953
|
eventType: d.TOOL_CALL_COMPLETE,
|
|
1927
1954
|
result: e.toolCallResult,
|
|
1928
1955
|
isError: e.isError,
|
|
1929
1956
|
sidecar: e.toolUseResultSidecar,
|
|
1930
1957
|
isComplete: !0,
|
|
1931
|
-
traceId: t.traceId ??
|
|
1958
|
+
traceId: t.traceId ?? i.traceId
|
|
1932
1959
|
};
|
|
1933
|
-
r.set(s,
|
|
1960
|
+
r.set(s, o);
|
|
1934
1961
|
}
|
|
1935
|
-
return new
|
|
1962
|
+
return new y({ messages: r, pendingConsent: this.pendingConsent });
|
|
1936
1963
|
}
|
|
1937
1964
|
onToolCallConsent(t) {
|
|
1938
1965
|
const e = t.fact.toolCallConsent;
|
|
1939
|
-
return new
|
|
1966
|
+
return new y({ messages: this.messages, pendingConsent: e });
|
|
1940
1967
|
}
|
|
1941
1968
|
onSubagentStart(t) {
|
|
1942
|
-
const e = t.fact.subagentStart, r = new Map(this.messages), s = `subagent:${e.parentToolUseId}:start`,
|
|
1969
|
+
const e = t.fact.subagentStart, r = new Map(this.messages), s = `subagent:${e.parentToolUseId}:start`, i = {
|
|
1943
1970
|
type: "subagent",
|
|
1944
1971
|
messageId: s,
|
|
1945
1972
|
kind: "start",
|
|
@@ -1950,10 +1977,10 @@ class b {
|
|
|
1950
1977
|
time: /* @__PURE__ */ new Date(),
|
|
1951
1978
|
traceId: t.traceId
|
|
1952
1979
|
};
|
|
1953
|
-
return r.set(s,
|
|
1980
|
+
return r.set(s, i), new y({ messages: r, pendingConsent: this.pendingConsent });
|
|
1954
1981
|
}
|
|
1955
1982
|
onSubagentComplete(t) {
|
|
1956
|
-
const e = t.fact.subagentComplete, r = new Map(this.messages), s = `subagent:${e.parentToolUseId}:complete`,
|
|
1983
|
+
const e = t.fact.subagentComplete, r = new Map(this.messages), s = `subagent:${e.parentToolUseId}:complete`, i = {
|
|
1957
1984
|
type: "subagent",
|
|
1958
1985
|
messageId: s,
|
|
1959
1986
|
kind: "complete",
|
|
@@ -1965,36 +1992,36 @@ class b {
|
|
|
1965
1992
|
time: /* @__PURE__ */ new Date(),
|
|
1966
1993
|
traceId: t.traceId
|
|
1967
1994
|
};
|
|
1968
|
-
return r.set(s,
|
|
1995
|
+
return r.set(s, i), new y({ messages: r, pendingConsent: this.pendingConsent });
|
|
1969
1996
|
}
|
|
1970
1997
|
}
|
|
1971
|
-
const
|
|
1972
|
-
function
|
|
1973
|
-
return n.toolsetName === "" &&
|
|
1998
|
+
const un = /* @__PURE__ */ new Set(["TaskCreate", "TaskUpdate"]);
|
|
1999
|
+
function ln(n) {
|
|
2000
|
+
return n.toolsetName === "" && un.has(n.toolName);
|
|
1974
2001
|
}
|
|
1975
|
-
function
|
|
2002
|
+
function me(n) {
|
|
1976
2003
|
return typeof n == "object" && n !== null ? n : void 0;
|
|
1977
2004
|
}
|
|
1978
2005
|
function E(n) {
|
|
1979
2006
|
return typeof n == "string" ? n : void 0;
|
|
1980
2007
|
}
|
|
1981
|
-
function
|
|
2008
|
+
function dn(n) {
|
|
1982
2009
|
const t = [], e = /* @__PURE__ */ new Map();
|
|
1983
2010
|
for (const r of n) {
|
|
1984
|
-
const s = r.parameter ?? {},
|
|
2011
|
+
const s = r.parameter ?? {}, i = r.sidecar ?? {};
|
|
1985
2012
|
if (r.toolName === "TaskCreate") {
|
|
1986
|
-
const
|
|
2013
|
+
const o = me(i.task), a = E(o?.id);
|
|
1987
2014
|
if (!a) continue;
|
|
1988
2015
|
e.has(a) || t.push(a), e.set(a, {
|
|
1989
2016
|
id: a,
|
|
1990
|
-
subject: E(s.subject) || E(
|
|
2017
|
+
subject: E(s.subject) || E(o?.subject) || "",
|
|
1991
2018
|
activeForm: E(s.activeForm),
|
|
1992
2019
|
description: E(s.description),
|
|
1993
2020
|
status: e.get(a)?.status ?? "pending"
|
|
1994
2021
|
// initial status = pending (keep existing on repeat)
|
|
1995
2022
|
});
|
|
1996
2023
|
} else if (r.toolName === "TaskUpdate") {
|
|
1997
|
-
const
|
|
2024
|
+
const o = me(i.statusChange), a = E(s.taskId) || E(i.taskId), u = E(o?.to) || E(s.status);
|
|
1998
2025
|
if (!a || !u) continue;
|
|
1999
2026
|
const c = e.get(a);
|
|
2000
2027
|
c && e.set(a, { ...c, status: u });
|
|
@@ -2002,68 +2029,68 @@ function ln(n) {
|
|
|
2002
2029
|
}
|
|
2003
2030
|
return t.map((r) => e.get(r));
|
|
2004
2031
|
}
|
|
2005
|
-
function
|
|
2032
|
+
function hn(n) {
|
|
2006
2033
|
return n.toolsetName === "" && n.toolName === "Agent";
|
|
2007
2034
|
}
|
|
2008
|
-
function
|
|
2035
|
+
function fn(n) {
|
|
2009
2036
|
return !!n;
|
|
2010
2037
|
}
|
|
2011
|
-
function
|
|
2012
|
-
const t = [], e = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), s = (
|
|
2013
|
-
for (const
|
|
2014
|
-
switch (
|
|
2038
|
+
function pn(n) {
|
|
2039
|
+
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));
|
|
2040
|
+
for (const i of n)
|
|
2041
|
+
switch (i.kind) {
|
|
2015
2042
|
case "agentStart": {
|
|
2016
|
-
const
|
|
2017
|
-
|
|
2043
|
+
const o = s(i.toolUseId);
|
|
2044
|
+
i.description && !o.description && (o.description = i.description);
|
|
2018
2045
|
break;
|
|
2019
2046
|
}
|
|
2020
2047
|
case "subagentStart": {
|
|
2021
|
-
const
|
|
2022
|
-
|
|
2048
|
+
const o = s(i.parentToolUseId);
|
|
2049
|
+
o.agentId = i.agentId ?? o.agentId, o.subagentType = i.subagentType ?? o.subagentType, o.description = i.description ?? o.description;
|
|
2023
2050
|
break;
|
|
2024
2051
|
}
|
|
2025
2052
|
case "toolStart": {
|
|
2026
|
-
s(
|
|
2027
|
-
toolsetName:
|
|
2028
|
-
toolName:
|
|
2029
|
-
parameter:
|
|
2030
|
-
reason:
|
|
2053
|
+
s(i.parentToolUseId), r.get(i.parentToolUseId).set(i.toolUseId, {
|
|
2054
|
+
toolsetName: i.toolsetName,
|
|
2055
|
+
toolName: i.toolName,
|
|
2056
|
+
parameter: i.parameter ?? {},
|
|
2057
|
+
reason: i.reason,
|
|
2031
2058
|
status: "running"
|
|
2032
2059
|
});
|
|
2033
2060
|
break;
|
|
2034
2061
|
}
|
|
2035
2062
|
case "toolComplete": {
|
|
2036
|
-
const
|
|
2037
|
-
|
|
2063
|
+
const o = r.get(i.parentToolUseId)?.get(i.toolUseId);
|
|
2064
|
+
o && (o.status = i.isError ? "error" : "completed");
|
|
2038
2065
|
break;
|
|
2039
2066
|
}
|
|
2040
2067
|
case "subagentComplete": {
|
|
2041
|
-
const
|
|
2042
|
-
|
|
2068
|
+
const o = s(i.parentToolUseId);
|
|
2069
|
+
o.status = i.status, o.summary = i.summary;
|
|
2043
2070
|
break;
|
|
2044
2071
|
}
|
|
2045
2072
|
}
|
|
2046
|
-
return t.map((
|
|
2047
|
-
parentToolUseId:
|
|
2048
|
-
...e.get(
|
|
2049
|
-
tools: Array.from(r.get(
|
|
2073
|
+
return t.map((i) => ({
|
|
2074
|
+
parentToolUseId: i,
|
|
2075
|
+
...e.get(i),
|
|
2076
|
+
tools: Array.from(r.get(i).values())
|
|
2050
2077
|
}));
|
|
2051
2078
|
}
|
|
2052
|
-
function
|
|
2079
|
+
function gn(n) {
|
|
2053
2080
|
return typeof n == "string" ? n : void 0;
|
|
2054
2081
|
}
|
|
2055
2082
|
function mn(n) {
|
|
2056
2083
|
const t = [];
|
|
2057
2084
|
for (const e of n) {
|
|
2058
|
-
if (e.type === "tool-call" &&
|
|
2085
|
+
if (e.type === "tool-call" && hn(e)) {
|
|
2059
2086
|
t.push({
|
|
2060
2087
|
kind: "agentStart",
|
|
2061
2088
|
toolUseId: e.toolUseId ?? e.messageId,
|
|
2062
|
-
description:
|
|
2089
|
+
description: gn(e.parameter.description)
|
|
2063
2090
|
});
|
|
2064
2091
|
continue;
|
|
2065
2092
|
}
|
|
2066
|
-
if (e.type === "tool-call" &&
|
|
2093
|
+
if (e.type === "tool-call" && fn(e.parentToolUseId)) {
|
|
2067
2094
|
const r = e.toolUseId ?? e.messageId;
|
|
2068
2095
|
t.push({
|
|
2069
2096
|
kind: "toolStart",
|
|
@@ -2100,37 +2127,37 @@ function mn(n) {
|
|
|
2100
2127
|
}
|
|
2101
2128
|
return t;
|
|
2102
2129
|
}
|
|
2103
|
-
function
|
|
2130
|
+
function vn(n) {
|
|
2104
2131
|
const t = Array.from(n.messages?.values() ?? []).filter(
|
|
2105
|
-
(e) => e.type === "tool-call" && e.isComplete &&
|
|
2132
|
+
(e) => e.type === "tool-call" && e.isComplete && ln(e)
|
|
2106
2133
|
);
|
|
2107
|
-
return
|
|
2134
|
+
return dn(t);
|
|
2108
2135
|
}
|
|
2109
|
-
function
|
|
2110
|
-
return
|
|
2136
|
+
function yn(n) {
|
|
2137
|
+
return pn(mn(Array.from(n.messages?.values() ?? [])));
|
|
2111
2138
|
}
|
|
2112
|
-
function
|
|
2139
|
+
function bn(n, t) {
|
|
2113
2140
|
return n === t ? !0 : n.length !== t.length ? !1 : n.every((e, r) => {
|
|
2114
2141
|
const s = t[r];
|
|
2115
2142
|
return e.id === s.id && e.status === s.status && e.subject === s.subject && e.activeForm === s.activeForm && e.description === s.description;
|
|
2116
2143
|
});
|
|
2117
2144
|
}
|
|
2118
|
-
function
|
|
2145
|
+
function Sn(n, t) {
|
|
2119
2146
|
return n.length !== t.length ? !1 : n.every((e, r) => {
|
|
2120
2147
|
const s = t[r];
|
|
2121
2148
|
return e.toolName === s.toolName && e.toolsetName === s.toolsetName && e.status === s.status && e.reason === s.reason;
|
|
2122
2149
|
});
|
|
2123
2150
|
}
|
|
2124
|
-
function
|
|
2151
|
+
function In(n, t) {
|
|
2125
2152
|
return n === t ? !0 : n.length !== t.length ? !1 : n.every((e, r) => {
|
|
2126
2153
|
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 &&
|
|
2154
|
+
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
2155
|
});
|
|
2129
2156
|
}
|
|
2130
|
-
function
|
|
2157
|
+
function En(n) {
|
|
2131
2158
|
const t = new N([]), e = new N([]), r = new U();
|
|
2132
|
-
return r.add(n.pipe(P(
|
|
2133
|
-
n.pipe(P(
|
|
2159
|
+
return r.add(n.pipe(P(vn), Z(bn)).subscribe(t)), r.add(
|
|
2160
|
+
n.pipe(P(yn), Z(In)).subscribe(e)
|
|
2134
2161
|
), {
|
|
2135
2162
|
tasks$: t.asObservable(),
|
|
2136
2163
|
subagents$: e.asObservable(),
|
|
@@ -2161,12 +2188,16 @@ class K {
|
|
|
2161
2188
|
// lifecycle so RESPONSE_TOOL_CALL_CONSENT — fired after run.done — can echo
|
|
2162
2189
|
// back the message id the bot is waiting on.
|
|
2163
2190
|
lastSentMessageId;
|
|
2191
|
+
// The in-flight SSE run's subscription. Held so a user-initiated stop-generation can abort the
|
|
2192
|
+
// connection (unsubscribe → create-sse-observable teardown → AbortController.abort()). Cleared on
|
|
2193
|
+
// every terminal (complete / error) and on stop.
|
|
2194
|
+
currentRun;
|
|
2164
2195
|
constructor(t) {
|
|
2165
2196
|
if (!t.client)
|
|
2166
2197
|
throw new Error("client must be required");
|
|
2167
2198
|
if (!t.customChannelId)
|
|
2168
2199
|
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 =
|
|
2200
|
+
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
2201
|
}
|
|
2171
2202
|
/** Current Task Check List snapshot (F-013) — for framework-agnostic `getSnapshot()` bridging. */
|
|
2172
2203
|
getTasks() {
|
|
@@ -2189,11 +2220,11 @@ class K {
|
|
|
2189
2220
|
return e.subscribe(), e;
|
|
2190
2221
|
}
|
|
2191
2222
|
static async reset(t, e, r, s) {
|
|
2192
|
-
const
|
|
2223
|
+
const i = new K(t);
|
|
2193
2224
|
try {
|
|
2194
|
-
return
|
|
2195
|
-
} catch (
|
|
2196
|
-
throw
|
|
2225
|
+
return i.subscribe(), s?.(i), await i.resetChannel(e, r), i;
|
|
2226
|
+
} catch (o) {
|
|
2227
|
+
throw i.close(), o;
|
|
2197
2228
|
}
|
|
2198
2229
|
}
|
|
2199
2230
|
/**
|
|
@@ -2207,8 +2238,8 @@ class K {
|
|
|
2207
2238
|
const s = new K(t);
|
|
2208
2239
|
try {
|
|
2209
2240
|
return s.subscribe(), r?.(s), await s.rejoinChannel(e), s;
|
|
2210
|
-
} catch (
|
|
2211
|
-
throw s.close(),
|
|
2241
|
+
} catch (i) {
|
|
2242
|
+
throw s.close(), i;
|
|
2212
2243
|
}
|
|
2213
2244
|
}
|
|
2214
2245
|
subscribe() {
|
|
@@ -2219,12 +2250,12 @@ class K {
|
|
|
2219
2250
|
this.derivedStores.subagents$,
|
|
2220
2251
|
this.channelTitle$
|
|
2221
2252
|
]).pipe(
|
|
2222
|
-
P(([t, e, r, s,
|
|
2253
|
+
P(([t, e, r, s, i]) => ({
|
|
2223
2254
|
isConnecting: t,
|
|
2224
2255
|
conversation: e,
|
|
2225
2256
|
tasks: r,
|
|
2226
2257
|
subagents: s,
|
|
2227
|
-
channelTitle:
|
|
2258
|
+
channelTitle: i
|
|
2228
2259
|
}))
|
|
2229
2260
|
).subscribe(this.statesObserver);
|
|
2230
2261
|
}
|
|
@@ -2254,25 +2285,25 @@ class K {
|
|
|
2254
2285
|
if (t?.onSseMessage?.(s), s.eventType === d.CHANNEL_TITLE_UPDATE && this.channelTitleSubject.next(
|
|
2255
2286
|
s.fact.channelTitleUpdate.title
|
|
2256
2287
|
), this.currentUserMessageId && s.traceId) {
|
|
2257
|
-
const
|
|
2258
|
-
|
|
2259
|
-
...
|
|
2288
|
+
const i = new Map(this.conversation$.value.messages), o = i.get(this.currentUserMessageId);
|
|
2289
|
+
o && o.type === "user" && (i.set(this.currentUserMessageId, {
|
|
2290
|
+
...o,
|
|
2260
2291
|
traceId: s.traceId
|
|
2261
|
-
}), this.conversation$.next(new
|
|
2292
|
+
}), this.conversation$.next(new y({ messages: i }))), this.currentUserMessageId = void 0;
|
|
2262
2293
|
}
|
|
2263
2294
|
this.conversation$.next(this.conversation$.value.onMessage(s));
|
|
2264
2295
|
},
|
|
2265
2296
|
onSseError: (s) => {
|
|
2266
|
-
t?.onSseError?.(s), this.isConnecting$.next(!1), this.currentUserMessageId = void 0, r(s);
|
|
2297
|
+
t?.onSseError?.(s), this.isConnecting$.next(!1), this.currentUserMessageId = void 0, this.currentRun = void 0, r(s);
|
|
2267
2298
|
},
|
|
2268
2299
|
onSseCompleted: () => {
|
|
2269
|
-
t?.onSseCompleted?.(), this.isConnecting$.next(!1), this.currentUserMessageId = void 0, e();
|
|
2300
|
+
t?.onSseCompleted?.(), this.isConnecting$.next(!1), this.currentUserMessageId = void 0, this.currentRun = void 0, e();
|
|
2270
2301
|
}
|
|
2271
2302
|
};
|
|
2272
2303
|
}
|
|
2273
2304
|
fetchSse(t, e) {
|
|
2274
2305
|
return new Promise((r, s) => {
|
|
2275
|
-
this.isConnecting$.next(!0), this.client.fetchSse(t, this.buildRunHandlers(e, r, s));
|
|
2306
|
+
this.isConnecting$.next(!0), this.currentRun = this.client.fetchSse(t, this.buildRunHandlers(e, r, s));
|
|
2276
2307
|
});
|
|
2277
2308
|
}
|
|
2278
2309
|
/**
|
|
@@ -2287,7 +2318,7 @@ class K {
|
|
|
2287
2318
|
e();
|
|
2288
2319
|
return;
|
|
2289
2320
|
}
|
|
2290
|
-
this.isConnecting$.next(!0), this.client.rejoinSse(this.customChannelId, this.buildRunHandlers(t, e, r));
|
|
2321
|
+
this.isConnecting$.next(!0), this.currentRun = this.client.rejoinSse(this.customChannelId, this.buildRunHandlers(t, e, r));
|
|
2291
2322
|
});
|
|
2292
2323
|
}
|
|
2293
2324
|
resetChannel(t, e) {
|
|
@@ -2339,30 +2370,39 @@ class K {
|
|
|
2339
2370
|
e
|
|
2340
2371
|
);
|
|
2341
2372
|
}
|
|
2373
|
+
/**
|
|
2374
|
+
* User-initiated stop-generation: abort the in-flight SSE run (if any) and release the input.
|
|
2375
|
+
* Unsubscribing tears down the SSE observable → AbortController.abort() cuts the HTTP stream. The
|
|
2376
|
+
* partial assistant message already received stays in the conversation (frozen, not deleted). A no-op
|
|
2377
|
+
* when nothing is running.
|
|
2378
|
+
*/
|
|
2379
|
+
stopGeneration() {
|
|
2380
|
+
this.currentRun && (this.currentRun.unsubscribe(), this.currentRun = void 0, this.isConnecting$.next(!1), this.currentUserMessageId = void 0, this.conversation$.next(this.conversation$.value.cancelInFlightToolCalls()));
|
|
2381
|
+
}
|
|
2342
2382
|
close() {
|
|
2343
|
-
this.isConnecting$.complete(), this.conversation$.complete(), this.channelTitleSubject.complete(), this.derivedStores.teardown(), this.statesSubscription?.unsubscribe();
|
|
2383
|
+
this.currentRun?.unsubscribe(), this.currentRun = void 0, this.isConnecting$.complete(), this.conversation$.complete(), this.channelTitleSubject.complete(), this.derivedStores.teardown(), this.statesSubscription?.unsubscribe();
|
|
2344
2384
|
}
|
|
2345
2385
|
}
|
|
2346
2386
|
export {
|
|
2347
|
-
|
|
2387
|
+
Tn as AsgardServiceClient,
|
|
2348
2388
|
K as Channel,
|
|
2349
|
-
|
|
2389
|
+
y as Conversation,
|
|
2350
2390
|
d as EventType,
|
|
2351
2391
|
H as FetchSseAction,
|
|
2352
2392
|
te as HttpError,
|
|
2353
2393
|
Fe as MessageTemplateType,
|
|
2354
2394
|
Ke as ToolCallConsentResult,
|
|
2355
2395
|
mn as conversationToSubagentEvents,
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2396
|
+
En as createDerivedStores,
|
|
2397
|
+
yn as deriveSubagents,
|
|
2398
|
+
vn as deriveTasks,
|
|
2399
|
+
hn as isAgentTool,
|
|
2400
|
+
wn as isHttpError,
|
|
2401
|
+
fn as isSubagentChildTool,
|
|
2402
|
+
ln as isTaskTool,
|
|
2403
|
+
pn as reduceSubagents,
|
|
2404
|
+
dn as reduceTaskEvents,
|
|
2405
|
+
In as subagentsEqual,
|
|
2406
|
+
bn as tasksEqual
|
|
2367
2407
|
};
|
|
2368
2408
|
//# sourceMappingURL=index.mjs.map
|