@asgard-js/core 0.3.25 → 0.3.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +697 -507
- package/dist/index.mjs.map +1 -1
- package/dist/lib/channel.d.ts +61 -6
- package/dist/lib/channel.d.ts.map +1 -1
- package/dist/lib/client.d.ts +23 -2
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/lib/conversation.d.ts +17 -5
- package/dist/lib/conversation.d.ts.map +1 -1
- package/dist/lib/create-sse-observable.d.ts.map +1 -1
- package/dist/lib/create-sse-observable.spec.d.ts +2 -0
- package/dist/lib/create-sse-observable.spec.d.ts.map +1 -0
- package/dist/lib/stop-generation.spec.d.ts +2 -0
- package/dist/lib/stop-generation.spec.d.ts.map +1 -0
- package/dist/types/channel-busy-error.d.ts +16 -0
- package/dist/types/channel-busy-error.d.ts.map +1 -0
- package/dist/types/channel.d.ts +51 -0
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/client.d.ts +10 -1
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/http-error.d.ts +8 -1
- package/dist/types/http-error.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,25 +1,45 @@
|
|
|
1
1
|
class w extends Error {
|
|
2
2
|
status;
|
|
3
3
|
statusText;
|
|
4
|
+
/**
|
|
5
|
+
* The decoded error payload, when the response carried one.
|
|
6
|
+
*
|
|
7
|
+
* Consumers branch on this — `asgard-ai-data-insight-web` reads `reason_code` off it to raise its
|
|
8
|
+
* credit-limit dialog on a `429` — so **always pass it when constructing from a real response**,
|
|
9
|
+
* even though the parameter is optional.
|
|
10
|
+
*/
|
|
4
11
|
body;
|
|
12
|
+
// `body` is optional because every construction site derives it from a response whose text or JSON
|
|
13
|
+
// may fail to parse, yielding `undefined` or `null`. An absent body is therefore a normal outcome
|
|
14
|
+
// rather than a caller mistake, and a test raising a status-only error need not pass a filler value.
|
|
5
15
|
constructor(t, e, r) {
|
|
6
16
|
super(`HTTP ${t}: ${e}`), this.name = "HttpError", this.status = t, this.statusText = e, this.body = r;
|
|
7
17
|
}
|
|
8
18
|
}
|
|
9
|
-
function
|
|
19
|
+
function An(n) {
|
|
10
20
|
return n instanceof w;
|
|
11
21
|
}
|
|
12
|
-
|
|
13
|
-
|
|
22
|
+
class ye extends Error {
|
|
23
|
+
/** Which run is holding the channel. */
|
|
24
|
+
runKind;
|
|
25
|
+
constructor(t) {
|
|
26
|
+
super(`Cannot send a message while a "${t}" run is in flight on this channel.`), this.name = "ChannelBusyError", this.runKind = t;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function Pn(n) {
|
|
30
|
+
return n instanceof ye;
|
|
31
|
+
}
|
|
32
|
+
var $ = /* @__PURE__ */ ((n) => (n.RESET_CHANNEL = "RESET_CHANNEL", n.NONE = "NONE", n.RESPONSE_TOOL_CALL_CONSENT = "RESPONSE_TOOL_CALL_CONSENT", n.NUDGE = "NUDGE", n))($ || {}), l = /* @__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.SANDBOX_LAUNCH = "asgard.sandbox.launch", n.SANDBOX_READY = "asgard.sandbox.ready", n.DONE = "asgard.run.done", n.ERROR = "asgard.run.error", n))(l || {}), Ye = /* @__PURE__ */ ((n) => (n.ALLOW_ONCE = "ALLOW_ONCE", n.ALLOW_ALWAYS = "ALLOW_ALWAYS", n.DENY_ONCE = "DENY_ONCE", n))(Ye || {}), We = /* @__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))(We || {});
|
|
33
|
+
async function Xe(n, t) {
|
|
14
34
|
const e = n.getReader();
|
|
15
35
|
let r;
|
|
16
36
|
for (; !(r = await e.read()).done; )
|
|
17
37
|
t(r.value);
|
|
18
38
|
}
|
|
19
|
-
function
|
|
39
|
+
function Ve(n) {
|
|
20
40
|
let t, e, r, s = !1;
|
|
21
41
|
return function(i) {
|
|
22
|
-
t === void 0 ? (t = i, e = 0, r = -1) : t =
|
|
42
|
+
t === void 0 ? (t = i, e = 0, r = -1) : t = Je(t, i);
|
|
23
43
|
const a = t.length;
|
|
24
44
|
let c = 0;
|
|
25
45
|
for (; e < a; ) {
|
|
@@ -43,12 +63,12 @@ function Xe(n) {
|
|
|
43
63
|
c === a ? t = void 0 : c !== 0 && (t = t.subarray(c), e -= c);
|
|
44
64
|
};
|
|
45
65
|
}
|
|
46
|
-
function
|
|
47
|
-
let r =
|
|
66
|
+
function ze(n, t, e) {
|
|
67
|
+
let r = ae();
|
|
48
68
|
const s = new TextDecoder();
|
|
49
69
|
return function(i, a) {
|
|
50
70
|
if (i.length === 0)
|
|
51
|
-
e?.(r), r =
|
|
71
|
+
e?.(r), r = ae();
|
|
52
72
|
else if (a > 0) {
|
|
53
73
|
const c = s.decode(i.subarray(0, a)), u = a + (i[a + 1] === 32 ? 2 : 1), h = s.decode(i.subarray(u));
|
|
54
74
|
switch (c) {
|
|
@@ -70,11 +90,11 @@ function Ve(n, t, e) {
|
|
|
70
90
|
}
|
|
71
91
|
};
|
|
72
92
|
}
|
|
73
|
-
function
|
|
93
|
+
function Je(n, t) {
|
|
74
94
|
const e = new Uint8Array(n.length + t.length);
|
|
75
95
|
return e.set(n), e.set(t, n.length), e;
|
|
76
96
|
}
|
|
77
|
-
function
|
|
97
|
+
function ae() {
|
|
78
98
|
return {
|
|
79
99
|
data: "",
|
|
80
100
|
event: "",
|
|
@@ -82,7 +102,7 @@ function ie() {
|
|
|
82
102
|
retry: void 0
|
|
83
103
|
};
|
|
84
104
|
}
|
|
85
|
-
var
|
|
105
|
+
var Qe = function(n, t) {
|
|
86
106
|
var e = {};
|
|
87
107
|
for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && t.indexOf(r) < 0 && (e[r] = n[r]);
|
|
88
108
|
if (n != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -90,70 +110,70 @@ var ze = function(n, t) {
|
|
|
90
110
|
t.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[s]) && (e[r[s]] = n[r[s]]);
|
|
91
111
|
return e;
|
|
92
112
|
};
|
|
93
|
-
const
|
|
94
|
-
function
|
|
95
|
-
var { signal: e, headers: r, onopen: s, onmessage: o, onclose: i, onerror: a, openWhenHidden: c, fetch: u } = t, h =
|
|
113
|
+
const Z = "text/event-stream", Ze = 1e3, ce = "last-event-id";
|
|
114
|
+
function Se(n, t) {
|
|
115
|
+
var { signal: e, headers: r, onopen: s, onmessage: o, onclose: i, onerror: a, openWhenHidden: c, fetch: u } = t, h = Qe(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
96
116
|
return new Promise((m, b) => {
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
let
|
|
100
|
-
function
|
|
101
|
-
|
|
117
|
+
const d = Object.assign({}, r);
|
|
118
|
+
d.accept || (d.accept = Z);
|
|
119
|
+
let p;
|
|
120
|
+
function f() {
|
|
121
|
+
p.abort(), document.hidden || X();
|
|
102
122
|
}
|
|
103
|
-
c || document.addEventListener("visibilitychange",
|
|
104
|
-
let
|
|
105
|
-
function
|
|
106
|
-
document.removeEventListener("visibilitychange",
|
|
123
|
+
c || document.addEventListener("visibilitychange", f);
|
|
124
|
+
let _ = Ze, E = 0;
|
|
125
|
+
function L() {
|
|
126
|
+
document.removeEventListener("visibilitychange", f), window.clearTimeout(E), p.abort();
|
|
107
127
|
}
|
|
108
128
|
e?.addEventListener("abort", () => {
|
|
109
|
-
|
|
129
|
+
L(), m();
|
|
110
130
|
});
|
|
111
|
-
const
|
|
112
|
-
async function
|
|
113
|
-
var
|
|
114
|
-
|
|
131
|
+
const Ke = u ?? window.fetch, qe = s ?? et;
|
|
132
|
+
async function X() {
|
|
133
|
+
var V;
|
|
134
|
+
p = new AbortController();
|
|
115
135
|
try {
|
|
116
|
-
const
|
|
117
|
-
await
|
|
118
|
-
x ?
|
|
136
|
+
const H = await Ke(n, Object.assign(Object.assign({}, h), { headers: d, signal: p.signal }));
|
|
137
|
+
await qe(H), await Xe(H.body, Ve(ze((x) => {
|
|
138
|
+
x ? d[ce] = x : delete d[ce];
|
|
119
139
|
}, (x) => {
|
|
120
|
-
|
|
121
|
-
}, o))), i?.(),
|
|
122
|
-
} catch (
|
|
123
|
-
if (!
|
|
140
|
+
_ = x;
|
|
141
|
+
}, o))), i?.(), L(), m();
|
|
142
|
+
} catch (H) {
|
|
143
|
+
if (!p.signal.aborted)
|
|
124
144
|
try {
|
|
125
|
-
const x = (
|
|
126
|
-
window.clearTimeout(E), E = window.setTimeout(
|
|
145
|
+
const x = (V = a?.(H)) !== null && V !== void 0 ? V : _;
|
|
146
|
+
window.clearTimeout(E), E = window.setTimeout(X, x);
|
|
127
147
|
} catch (x) {
|
|
128
|
-
|
|
148
|
+
L(), b(x);
|
|
129
149
|
}
|
|
130
150
|
}
|
|
131
151
|
}
|
|
132
|
-
|
|
152
|
+
X();
|
|
133
153
|
});
|
|
134
154
|
}
|
|
135
|
-
function
|
|
155
|
+
function et(n) {
|
|
136
156
|
const t = n.headers.get("content-type");
|
|
137
|
-
if (!t?.startsWith(
|
|
138
|
-
throw new Error(`Expected content-type to be ${
|
|
157
|
+
if (!t?.startsWith(Z))
|
|
158
|
+
throw new Error(`Expected content-type to be ${Z}, Actual: ${t}`);
|
|
139
159
|
}
|
|
140
|
-
var
|
|
141
|
-
return
|
|
160
|
+
var ee = function(n, t) {
|
|
161
|
+
return ee = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
|
|
142
162
|
e.__proto__ = r;
|
|
143
163
|
} || function(e, r) {
|
|
144
164
|
for (var s in r) Object.prototype.hasOwnProperty.call(r, s) && (e[s] = r[s]);
|
|
145
|
-
},
|
|
165
|
+
}, ee(n, t);
|
|
146
166
|
};
|
|
147
167
|
function T(n, t) {
|
|
148
168
|
if (typeof t != "function" && t !== null)
|
|
149
169
|
throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
|
|
150
|
-
|
|
170
|
+
ee(n, t);
|
|
151
171
|
function e() {
|
|
152
172
|
this.constructor = n;
|
|
153
173
|
}
|
|
154
174
|
n.prototype = t === null ? Object.create(t) : (e.prototype = t.prototype, new e());
|
|
155
175
|
}
|
|
156
|
-
function
|
|
176
|
+
function tt(n, t, e, r) {
|
|
157
177
|
function s(o) {
|
|
158
178
|
return o instanceof e ? o : new e(function(i) {
|
|
159
179
|
i(o);
|
|
@@ -180,7 +200,7 @@ function Ze(n, t, e, r) {
|
|
|
180
200
|
u((r = r.apply(n, t || [])).next());
|
|
181
201
|
});
|
|
182
202
|
}
|
|
183
|
-
function
|
|
203
|
+
function we(n, t) {
|
|
184
204
|
var e = { label: 0, sent: function() {
|
|
185
205
|
if (o[0] & 1) throw o[1];
|
|
186
206
|
return o[1];
|
|
@@ -240,7 +260,7 @@ function ye(n, t) {
|
|
|
240
260
|
return { value: u[0] ? u[1] : void 0, done: !0 };
|
|
241
261
|
}
|
|
242
262
|
}
|
|
243
|
-
function
|
|
263
|
+
function R(n) {
|
|
244
264
|
var t = typeof Symbol == "function" && Symbol.iterator, e = t && n[t], r = 0;
|
|
245
265
|
if (e) return e.call(n);
|
|
246
266
|
if (n && typeof n.length == "number") return {
|
|
@@ -267,56 +287,56 @@ function D(n, t) {
|
|
|
267
287
|
}
|
|
268
288
|
return o;
|
|
269
289
|
}
|
|
270
|
-
function
|
|
290
|
+
function F(n, t, e) {
|
|
271
291
|
if (e || arguments.length === 2) for (var r = 0, s = t.length, o; r < s; r++)
|
|
272
292
|
(o || !(r in t)) && (o || (o = Array.prototype.slice.call(t, 0, r)), o[r] = t[r]);
|
|
273
293
|
return n.concat(o || Array.prototype.slice.call(t));
|
|
274
294
|
}
|
|
275
|
-
function
|
|
276
|
-
return this instanceof
|
|
295
|
+
function k(n) {
|
|
296
|
+
return this instanceof k ? (this.v = n, this) : new k(n);
|
|
277
297
|
}
|
|
278
|
-
function
|
|
298
|
+
function nt(n, t, e) {
|
|
279
299
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
280
300
|
var r = e.apply(n, t || []), s, o = [];
|
|
281
301
|
return s = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), a("next"), a("throw"), a("return", i), s[Symbol.asyncIterator] = function() {
|
|
282
302
|
return this;
|
|
283
303
|
}, s;
|
|
284
|
-
function i(
|
|
285
|
-
return function(
|
|
286
|
-
return Promise.resolve(
|
|
304
|
+
function i(d) {
|
|
305
|
+
return function(p) {
|
|
306
|
+
return Promise.resolve(p).then(d, m);
|
|
287
307
|
};
|
|
288
308
|
}
|
|
289
|
-
function a(
|
|
290
|
-
r[
|
|
291
|
-
return new Promise(function(
|
|
292
|
-
o.push([
|
|
309
|
+
function a(d, p) {
|
|
310
|
+
r[d] && (s[d] = function(f) {
|
|
311
|
+
return new Promise(function(_, E) {
|
|
312
|
+
o.push([d, f, _, E]) > 1 || c(d, f);
|
|
293
313
|
});
|
|
294
|
-
},
|
|
314
|
+
}, p && (s[d] = p(s[d])));
|
|
295
315
|
}
|
|
296
|
-
function c(
|
|
316
|
+
function c(d, p) {
|
|
297
317
|
try {
|
|
298
|
-
u(r[
|
|
299
|
-
} catch (
|
|
300
|
-
b(o[0][3],
|
|
318
|
+
u(r[d](p));
|
|
319
|
+
} catch (f) {
|
|
320
|
+
b(o[0][3], f);
|
|
301
321
|
}
|
|
302
322
|
}
|
|
303
|
-
function u(
|
|
304
|
-
|
|
323
|
+
function u(d) {
|
|
324
|
+
d.value instanceof k ? Promise.resolve(d.value.v).then(h, m) : b(o[0][2], d);
|
|
305
325
|
}
|
|
306
|
-
function h(
|
|
307
|
-
c("next",
|
|
326
|
+
function h(d) {
|
|
327
|
+
c("next", d);
|
|
308
328
|
}
|
|
309
|
-
function m(
|
|
310
|
-
c("throw",
|
|
329
|
+
function m(d) {
|
|
330
|
+
c("throw", d);
|
|
311
331
|
}
|
|
312
|
-
function b(
|
|
313
|
-
|
|
332
|
+
function b(d, p) {
|
|
333
|
+
d(p), o.shift(), o.length && c(o[0][0], o[0][1]);
|
|
314
334
|
}
|
|
315
335
|
}
|
|
316
|
-
function
|
|
336
|
+
function rt(n) {
|
|
317
337
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
318
338
|
var t = n[Symbol.asyncIterator], e;
|
|
319
|
-
return t ? t.call(n) : (n = typeof
|
|
339
|
+
return t ? t.call(n) : (n = typeof R == "function" ? R(n) : n[Symbol.iterator](), e = {}, r("next"), r("throw"), r("return"), e[Symbol.asyncIterator] = function() {
|
|
320
340
|
return this;
|
|
321
341
|
}, e);
|
|
322
342
|
function r(o) {
|
|
@@ -335,13 +355,13 @@ function tt(n) {
|
|
|
335
355
|
function g(n) {
|
|
336
356
|
return typeof n == "function";
|
|
337
357
|
}
|
|
338
|
-
function
|
|
358
|
+
function Ee(n) {
|
|
339
359
|
var t = function(r) {
|
|
340
360
|
Error.call(r), r.stack = new Error().stack;
|
|
341
361
|
}, e = n(t);
|
|
342
362
|
return e.prototype = Object.create(Error.prototype), e.prototype.constructor = e, e;
|
|
343
363
|
}
|
|
344
|
-
var z =
|
|
364
|
+
var z = Ee(function(n) {
|
|
345
365
|
return function(e) {
|
|
346
366
|
n(this), this.message = e ? e.length + ` errors occurred during unsubscription:
|
|
347
367
|
` + e.map(function(r, s) {
|
|
@@ -356,7 +376,7 @@ function q(n, t) {
|
|
|
356
376
|
0 <= e && n.splice(e, 1);
|
|
357
377
|
}
|
|
358
378
|
}
|
|
359
|
-
var
|
|
379
|
+
var j = (function() {
|
|
360
380
|
function n(t) {
|
|
361
381
|
this.initialTeardown = t, this.closed = !1, this._parentage = null, this._finalizers = null;
|
|
362
382
|
}
|
|
@@ -368,12 +388,12 @@ var R = (function() {
|
|
|
368
388
|
if (i)
|
|
369
389
|
if (this._parentage = null, Array.isArray(i))
|
|
370
390
|
try {
|
|
371
|
-
for (var a =
|
|
391
|
+
for (var a = R(i), c = a.next(); !c.done; c = a.next()) {
|
|
372
392
|
var u = c.value;
|
|
373
393
|
u.remove(this);
|
|
374
394
|
}
|
|
375
|
-
} catch (
|
|
376
|
-
t = { error:
|
|
395
|
+
} catch (f) {
|
|
396
|
+
t = { error: f };
|
|
377
397
|
} finally {
|
|
378
398
|
try {
|
|
379
399
|
c && !c.done && (e = a.return) && e.call(a);
|
|
@@ -387,26 +407,26 @@ var R = (function() {
|
|
|
387
407
|
if (g(h))
|
|
388
408
|
try {
|
|
389
409
|
h();
|
|
390
|
-
} catch (
|
|
391
|
-
o =
|
|
410
|
+
} catch (f) {
|
|
411
|
+
o = f instanceof z ? f.errors : [f];
|
|
392
412
|
}
|
|
393
413
|
var m = this._finalizers;
|
|
394
414
|
if (m) {
|
|
395
415
|
this._finalizers = null;
|
|
396
416
|
try {
|
|
397
|
-
for (var b =
|
|
398
|
-
var
|
|
417
|
+
for (var b = R(m), d = b.next(); !d.done; d = b.next()) {
|
|
418
|
+
var p = d.value;
|
|
399
419
|
try {
|
|
400
|
-
|
|
401
|
-
} catch (
|
|
402
|
-
o = o ?? [],
|
|
420
|
+
ue(p);
|
|
421
|
+
} catch (f) {
|
|
422
|
+
o = o ?? [], f instanceof z ? o = F(F([], D(o)), D(f.errors)) : o.push(f);
|
|
403
423
|
}
|
|
404
424
|
}
|
|
405
|
-
} catch (
|
|
406
|
-
r = { error:
|
|
425
|
+
} catch (f) {
|
|
426
|
+
r = { error: f };
|
|
407
427
|
} finally {
|
|
408
428
|
try {
|
|
409
|
-
|
|
429
|
+
d && !d.done && (s = b.return) && s.call(b);
|
|
410
430
|
} finally {
|
|
411
431
|
if (r) throw r.error;
|
|
412
432
|
}
|
|
@@ -419,7 +439,7 @@ var R = (function() {
|
|
|
419
439
|
var e;
|
|
420
440
|
if (t && t !== this)
|
|
421
441
|
if (this.closed)
|
|
422
|
-
|
|
442
|
+
ue(t);
|
|
423
443
|
else {
|
|
424
444
|
if (t instanceof n) {
|
|
425
445
|
if (t.closed || t._hasParent(this))
|
|
@@ -444,44 +464,44 @@ var R = (function() {
|
|
|
444
464
|
var t = new n();
|
|
445
465
|
return t.closed = !0, t;
|
|
446
466
|
})(), n;
|
|
447
|
-
})(),
|
|
448
|
-
function
|
|
449
|
-
return n instanceof
|
|
467
|
+
})(), Ie = j.EMPTY;
|
|
468
|
+
function Te(n) {
|
|
469
|
+
return n instanceof j || n && "closed" in n && g(n.remove) && g(n.add) && g(n.unsubscribe);
|
|
450
470
|
}
|
|
451
|
-
function
|
|
471
|
+
function ue(n) {
|
|
452
472
|
g(n) ? n() : n.unsubscribe();
|
|
453
473
|
}
|
|
454
|
-
var
|
|
474
|
+
var st = {
|
|
455
475
|
Promise: void 0
|
|
456
|
-
},
|
|
476
|
+
}, ot = {
|
|
457
477
|
setTimeout: function(n, t) {
|
|
458
478
|
for (var e = [], r = 2; r < arguments.length; r++)
|
|
459
479
|
e[r - 2] = arguments[r];
|
|
460
|
-
return setTimeout.apply(void 0,
|
|
480
|
+
return setTimeout.apply(void 0, F([n, t], D(e)));
|
|
461
481
|
},
|
|
462
482
|
clearTimeout: function(n) {
|
|
463
483
|
return clearTimeout(n);
|
|
464
484
|
},
|
|
465
485
|
delegate: void 0
|
|
466
486
|
};
|
|
467
|
-
function
|
|
468
|
-
|
|
487
|
+
function xe(n) {
|
|
488
|
+
ot.setTimeout(function() {
|
|
469
489
|
throw n;
|
|
470
490
|
});
|
|
471
491
|
}
|
|
472
|
-
function
|
|
492
|
+
function te() {
|
|
473
493
|
}
|
|
474
|
-
function
|
|
494
|
+
function G(n) {
|
|
475
495
|
n();
|
|
476
496
|
}
|
|
477
|
-
var
|
|
497
|
+
var re = (function(n) {
|
|
478
498
|
T(t, n);
|
|
479
499
|
function t(e) {
|
|
480
500
|
var r = n.call(this) || this;
|
|
481
|
-
return r.isStopped = !1, e ? (r.destination = e,
|
|
501
|
+
return r.isStopped = !1, e ? (r.destination = e, Te(e) && e.add(r)) : r.destination = ct, r;
|
|
482
502
|
}
|
|
483
503
|
return t.create = function(e, r, s) {
|
|
484
|
-
return new
|
|
504
|
+
return new ne(e, r, s);
|
|
485
505
|
}, t.prototype.next = function(e) {
|
|
486
506
|
this.isStopped || this._next(e);
|
|
487
507
|
}, t.prototype.error = function(e) {
|
|
@@ -505,7 +525,7 @@ var ne = (function(n) {
|
|
|
505
525
|
this.unsubscribe();
|
|
506
526
|
}
|
|
507
527
|
}, t;
|
|
508
|
-
})(
|
|
528
|
+
})(j), it = (function() {
|
|
509
529
|
function n(t) {
|
|
510
530
|
this.partialObserver = t;
|
|
511
531
|
}
|
|
@@ -515,7 +535,7 @@ var ne = (function(n) {
|
|
|
515
535
|
try {
|
|
516
536
|
e.next(t);
|
|
517
537
|
} catch (r) {
|
|
518
|
-
|
|
538
|
+
B(r);
|
|
519
539
|
}
|
|
520
540
|
}, n.prototype.error = function(t) {
|
|
521
541
|
var e = this.partialObserver;
|
|
@@ -523,20 +543,20 @@ var ne = (function(n) {
|
|
|
523
543
|
try {
|
|
524
544
|
e.error(t);
|
|
525
545
|
} catch (r) {
|
|
526
|
-
|
|
546
|
+
B(r);
|
|
527
547
|
}
|
|
528
548
|
else
|
|
529
|
-
|
|
549
|
+
B(t);
|
|
530
550
|
}, n.prototype.complete = function() {
|
|
531
551
|
var t = this.partialObserver;
|
|
532
552
|
if (t.complete)
|
|
533
553
|
try {
|
|
534
554
|
t.complete();
|
|
535
555
|
} catch (e) {
|
|
536
|
-
|
|
556
|
+
B(e);
|
|
537
557
|
}
|
|
538
558
|
}, n;
|
|
539
|
-
})(),
|
|
559
|
+
})(), ne = (function(n) {
|
|
540
560
|
T(t, n);
|
|
541
561
|
function t(e, r, s) {
|
|
542
562
|
var o = n.call(this) || this, i;
|
|
@@ -544,29 +564,29 @@ var ne = (function(n) {
|
|
|
544
564
|
next: e ?? void 0,
|
|
545
565
|
error: r ?? void 0,
|
|
546
566
|
complete: s ?? void 0
|
|
547
|
-
} : i = e, o.destination = new
|
|
567
|
+
} : i = e, o.destination = new it(i), o;
|
|
548
568
|
}
|
|
549
569
|
return t;
|
|
550
|
-
})(
|
|
551
|
-
function
|
|
552
|
-
|
|
570
|
+
})(re);
|
|
571
|
+
function B(n) {
|
|
572
|
+
xe(n);
|
|
553
573
|
}
|
|
554
|
-
function
|
|
574
|
+
function at(n) {
|
|
555
575
|
throw n;
|
|
556
576
|
}
|
|
557
|
-
var
|
|
577
|
+
var ct = {
|
|
558
578
|
closed: !0,
|
|
559
|
-
next:
|
|
560
|
-
error:
|
|
561
|
-
complete:
|
|
562
|
-
},
|
|
579
|
+
next: te,
|
|
580
|
+
error: at,
|
|
581
|
+
complete: te
|
|
582
|
+
}, se = (function() {
|
|
563
583
|
return typeof Symbol == "function" && Symbol.observable || "@@observable";
|
|
564
584
|
})();
|
|
565
|
-
function
|
|
585
|
+
function W(n) {
|
|
566
586
|
return n;
|
|
567
587
|
}
|
|
568
|
-
function
|
|
569
|
-
return n.length === 0 ?
|
|
588
|
+
function ut(n) {
|
|
589
|
+
return n.length === 0 ? W : n.length === 1 ? n[0] : function(e) {
|
|
570
590
|
return n.reduce(function(r, s) {
|
|
571
591
|
return s(r);
|
|
572
592
|
}, e);
|
|
@@ -580,8 +600,8 @@ var S = (function() {
|
|
|
580
600
|
var e = new n();
|
|
581
601
|
return e.source = this, e.operator = t, e;
|
|
582
602
|
}, n.prototype.subscribe = function(t, e, r) {
|
|
583
|
-
var s = this, o =
|
|
584
|
-
return
|
|
603
|
+
var s = this, o = dt(t) ? t : new ne(t, e, r);
|
|
604
|
+
return G(function() {
|
|
585
605
|
var i = s, a = i.operator, c = i.source;
|
|
586
606
|
o.add(a ? a.call(o, c) : c ? s._subscribe(o) : s._trySubscribe(o));
|
|
587
607
|
}), o;
|
|
@@ -593,8 +613,8 @@ var S = (function() {
|
|
|
593
613
|
}
|
|
594
614
|
}, n.prototype.forEach = function(t, e) {
|
|
595
615
|
var r = this;
|
|
596
|
-
return e =
|
|
597
|
-
var i = new
|
|
616
|
+
return e = le(e), new e(function(s, o) {
|
|
617
|
+
var i = new ne({
|
|
598
618
|
next: function(a) {
|
|
599
619
|
try {
|
|
600
620
|
t(a);
|
|
@@ -610,15 +630,15 @@ var S = (function() {
|
|
|
610
630
|
}, n.prototype._subscribe = function(t) {
|
|
611
631
|
var e;
|
|
612
632
|
return (e = this.source) === null || e === void 0 ? void 0 : e.subscribe(t);
|
|
613
|
-
}, n.prototype[
|
|
633
|
+
}, n.prototype[se] = function() {
|
|
614
634
|
return this;
|
|
615
635
|
}, n.prototype.pipe = function() {
|
|
616
636
|
for (var t = [], e = 0; e < arguments.length; e++)
|
|
617
637
|
t[e] = arguments[e];
|
|
618
|
-
return
|
|
638
|
+
return ut(t)(this);
|
|
619
639
|
}, n.prototype.toPromise = function(t) {
|
|
620
640
|
var e = this;
|
|
621
|
-
return t =
|
|
641
|
+
return t = le(t), new t(function(r, s) {
|
|
622
642
|
var o;
|
|
623
643
|
e.subscribe(function(i) {
|
|
624
644
|
return o = i;
|
|
@@ -632,22 +652,22 @@ var S = (function() {
|
|
|
632
652
|
return new n(t);
|
|
633
653
|
}, n;
|
|
634
654
|
})();
|
|
635
|
-
function
|
|
655
|
+
function le(n) {
|
|
636
656
|
var t;
|
|
637
|
-
return (t = n ??
|
|
657
|
+
return (t = n ?? st.Promise) !== null && t !== void 0 ? t : Promise;
|
|
638
658
|
}
|
|
639
|
-
function
|
|
659
|
+
function lt(n) {
|
|
640
660
|
return n && g(n.next) && g(n.error) && g(n.complete);
|
|
641
661
|
}
|
|
642
|
-
function
|
|
643
|
-
return n && n instanceof
|
|
662
|
+
function dt(n) {
|
|
663
|
+
return n && n instanceof re || lt(n) && Te(n);
|
|
644
664
|
}
|
|
645
|
-
function
|
|
665
|
+
function ht(n) {
|
|
646
666
|
return g(n?.lift);
|
|
647
667
|
}
|
|
648
|
-
function
|
|
668
|
+
function P(n) {
|
|
649
669
|
return function(t) {
|
|
650
|
-
if (
|
|
670
|
+
if (ht(t))
|
|
651
671
|
return t.lift(function(e) {
|
|
652
672
|
try {
|
|
653
673
|
return n(e, this);
|
|
@@ -658,10 +678,10 @@ function A(n) {
|
|
|
658
678
|
throw new TypeError("Unable to lift unknown Observable type");
|
|
659
679
|
};
|
|
660
680
|
}
|
|
661
|
-
function
|
|
662
|
-
return new
|
|
681
|
+
function A(n, t, e, r, s) {
|
|
682
|
+
return new ft(n, t, e, r, s);
|
|
663
683
|
}
|
|
664
|
-
var
|
|
684
|
+
var ft = (function(n) {
|
|
665
685
|
T(t, n);
|
|
666
686
|
function t(e, r, s, o, i, a) {
|
|
667
687
|
var c = n.call(this, e) || this;
|
|
@@ -696,30 +716,30 @@ var dt = (function(n) {
|
|
|
696
716
|
n.prototype.unsubscribe.call(this), !r && ((e = this.onFinalize) === null || e === void 0 || e.call(this));
|
|
697
717
|
}
|
|
698
718
|
}, t;
|
|
699
|
-
})(
|
|
719
|
+
})(re), pt = Ee(function(n) {
|
|
700
720
|
return function() {
|
|
701
721
|
n(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
|
|
702
722
|
};
|
|
703
|
-
}),
|
|
723
|
+
}), oe = (function(n) {
|
|
704
724
|
T(t, n);
|
|
705
725
|
function t() {
|
|
706
726
|
var e = n.call(this) || this;
|
|
707
727
|
return e.closed = !1, e.currentObservers = null, e.observers = [], e.isStopped = !1, e.hasError = !1, e.thrownError = null, e;
|
|
708
728
|
}
|
|
709
729
|
return t.prototype.lift = function(e) {
|
|
710
|
-
var r = new
|
|
730
|
+
var r = new de(this, this);
|
|
711
731
|
return r.operator = e, r;
|
|
712
732
|
}, t.prototype._throwIfClosed = function() {
|
|
713
733
|
if (this.closed)
|
|
714
|
-
throw new
|
|
734
|
+
throw new pt();
|
|
715
735
|
}, t.prototype.next = function(e) {
|
|
716
736
|
var r = this;
|
|
717
|
-
|
|
737
|
+
G(function() {
|
|
718
738
|
var s, o;
|
|
719
739
|
if (r._throwIfClosed(), !r.isStopped) {
|
|
720
740
|
r.currentObservers || (r.currentObservers = Array.from(r.observers));
|
|
721
741
|
try {
|
|
722
|
-
for (var i =
|
|
742
|
+
for (var i = R(r.currentObservers), a = i.next(); !a.done; a = i.next()) {
|
|
723
743
|
var c = a.value;
|
|
724
744
|
c.next(e);
|
|
725
745
|
}
|
|
@@ -736,7 +756,7 @@ var dt = (function(n) {
|
|
|
736
756
|
});
|
|
737
757
|
}, t.prototype.error = function(e) {
|
|
738
758
|
var r = this;
|
|
739
|
-
|
|
759
|
+
G(function() {
|
|
740
760
|
if (r._throwIfClosed(), !r.isStopped) {
|
|
741
761
|
r.hasError = r.isStopped = !0, r.thrownError = e;
|
|
742
762
|
for (var s = r.observers; s.length; )
|
|
@@ -745,7 +765,7 @@ var dt = (function(n) {
|
|
|
745
765
|
});
|
|
746
766
|
}, t.prototype.complete = function() {
|
|
747
767
|
var e = this;
|
|
748
|
-
|
|
768
|
+
G(function() {
|
|
749
769
|
if (e._throwIfClosed(), !e.isStopped) {
|
|
750
770
|
e.isStopped = !0;
|
|
751
771
|
for (var r = e.observers; r.length; )
|
|
@@ -767,7 +787,7 @@ var dt = (function(n) {
|
|
|
767
787
|
return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
|
|
768
788
|
}, t.prototype._innerSubscribe = function(e) {
|
|
769
789
|
var r = this, s = this, o = s.hasError, i = s.isStopped, a = s.observers;
|
|
770
|
-
return o || i ?
|
|
790
|
+
return o || i ? Ie : (this.currentObservers = null, a.push(e), new j(function() {
|
|
771
791
|
r.currentObservers = null, q(a, e);
|
|
772
792
|
}));
|
|
773
793
|
}, t.prototype._checkFinalizedStatuses = function(e) {
|
|
@@ -777,9 +797,9 @@ var dt = (function(n) {
|
|
|
777
797
|
var e = new S();
|
|
778
798
|
return e.source = this, e;
|
|
779
799
|
}, t.create = function(e, r) {
|
|
780
|
-
return new
|
|
800
|
+
return new de(e, r);
|
|
781
801
|
}, t;
|
|
782
|
-
})(S),
|
|
802
|
+
})(S), de = (function(n) {
|
|
783
803
|
T(t, n);
|
|
784
804
|
function t(e, r) {
|
|
785
805
|
var s = n.call(this) || this;
|
|
@@ -796,9 +816,9 @@ var dt = (function(n) {
|
|
|
796
816
|
(r = (e = this.destination) === null || e === void 0 ? void 0 : e.complete) === null || r === void 0 || r.call(e);
|
|
797
817
|
}, t.prototype._subscribe = function(e) {
|
|
798
818
|
var r, s;
|
|
799
|
-
return (s = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(e)) !== null && s !== void 0 ? s :
|
|
819
|
+
return (s = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(e)) !== null && s !== void 0 ? s : Ie;
|
|
800
820
|
}, t;
|
|
801
|
-
})(
|
|
821
|
+
})(oe), C = (function(n) {
|
|
802
822
|
T(t, n);
|
|
803
823
|
function t(e) {
|
|
804
824
|
var r = n.call(this) || this;
|
|
@@ -821,11 +841,11 @@ var dt = (function(n) {
|
|
|
821
841
|
}, t.prototype.next = function(e) {
|
|
822
842
|
n.prototype.next.call(this, this._value = e);
|
|
823
843
|
}, t;
|
|
824
|
-
})(
|
|
844
|
+
})(oe), mt = {
|
|
825
845
|
now: function() {
|
|
826
846
|
return Date.now();
|
|
827
847
|
}
|
|
828
|
-
},
|
|
848
|
+
}, gt = (function(n) {
|
|
829
849
|
T(t, n);
|
|
830
850
|
function t(e, r) {
|
|
831
851
|
return n.call(this) || this;
|
|
@@ -833,17 +853,17 @@ var dt = (function(n) {
|
|
|
833
853
|
return t.prototype.schedule = function(e, r) {
|
|
834
854
|
return this;
|
|
835
855
|
}, t;
|
|
836
|
-
})(
|
|
856
|
+
})(j), he = {
|
|
837
857
|
setInterval: function(n, t) {
|
|
838
858
|
for (var e = [], r = 2; r < arguments.length; r++)
|
|
839
859
|
e[r - 2] = arguments[r];
|
|
840
|
-
return setInterval.apply(void 0,
|
|
860
|
+
return setInterval.apply(void 0, F([n, t], D(e)));
|
|
841
861
|
},
|
|
842
862
|
clearInterval: function(n) {
|
|
843
863
|
return clearInterval(n);
|
|
844
864
|
},
|
|
845
865
|
delegate: void 0
|
|
846
|
-
},
|
|
866
|
+
}, bt = (function(n) {
|
|
847
867
|
T(t, n);
|
|
848
868
|
function t(e, r) {
|
|
849
869
|
var s = n.call(this, e, r) || this;
|
|
@@ -857,11 +877,11 @@ var dt = (function(n) {
|
|
|
857
877
|
var o = this.id, i = this.scheduler;
|
|
858
878
|
return o != null && (this.id = this.recycleAsyncId(i, o, r)), this.pending = !0, this.delay = r, this.id = (s = this.id) !== null && s !== void 0 ? s : this.requestAsyncId(i, this.id, r), this;
|
|
859
879
|
}, t.prototype.requestAsyncId = function(e, r, s) {
|
|
860
|
-
return s === void 0 && (s = 0),
|
|
880
|
+
return s === void 0 && (s = 0), he.setInterval(e.flush.bind(e, this), s);
|
|
861
881
|
}, t.prototype.recycleAsyncId = function(e, r, s) {
|
|
862
882
|
if (s === void 0 && (s = 0), s != null && this.delay === s && this.pending === !1)
|
|
863
883
|
return r;
|
|
864
|
-
r != null &&
|
|
884
|
+
r != null && he.clearInterval(r);
|
|
865
885
|
}, t.prototype.execute = function(e, r) {
|
|
866
886
|
if (this.closed)
|
|
867
887
|
return new Error("executing a cancelled action");
|
|
@@ -885,17 +905,17 @@ var dt = (function(n) {
|
|
|
885
905
|
this.work = this.state = this.scheduler = null, this.pending = !1, q(o, this), r != null && (this.id = this.recycleAsyncId(s, r, null)), this.delay = null, n.prototype.unsubscribe.call(this);
|
|
886
906
|
}
|
|
887
907
|
}, t;
|
|
888
|
-
})(
|
|
908
|
+
})(gt), fe = (function() {
|
|
889
909
|
function n(t, e) {
|
|
890
910
|
e === void 0 && (e = n.now), this.schedulerActionCtor = t, this.now = e;
|
|
891
911
|
}
|
|
892
912
|
return n.prototype.schedule = function(t, e, r) {
|
|
893
913
|
return e === void 0 && (e = 0), new this.schedulerActionCtor(this, t).schedule(r, e);
|
|
894
|
-
}, n.now =
|
|
895
|
-
})(),
|
|
914
|
+
}, n.now = mt.now, n;
|
|
915
|
+
})(), vt = (function(n) {
|
|
896
916
|
T(t, n);
|
|
897
917
|
function t(e, r) {
|
|
898
|
-
r === void 0 && (r =
|
|
918
|
+
r === void 0 && (r = fe.now);
|
|
899
919
|
var s = n.call(this, e, r) || this;
|
|
900
920
|
return s.actions = [], s._active = !1, s;
|
|
901
921
|
}
|
|
@@ -917,60 +937,60 @@ var dt = (function(n) {
|
|
|
917
937
|
throw s;
|
|
918
938
|
}
|
|
919
939
|
}, t;
|
|
920
|
-
})(
|
|
940
|
+
})(fe), Ce = new vt(bt), yt = Ce, St = new S(function(n) {
|
|
921
941
|
return n.complete();
|
|
922
942
|
});
|
|
923
|
-
function
|
|
943
|
+
function Oe(n) {
|
|
924
944
|
return n && g(n.schedule);
|
|
925
945
|
}
|
|
926
|
-
function
|
|
946
|
+
function Ae(n) {
|
|
927
947
|
return n[n.length - 1];
|
|
928
948
|
}
|
|
929
|
-
function
|
|
930
|
-
return g(
|
|
949
|
+
function wt(n) {
|
|
950
|
+
return g(Ae(n)) ? n.pop() : void 0;
|
|
931
951
|
}
|
|
932
|
-
function
|
|
933
|
-
return
|
|
952
|
+
function Pe(n) {
|
|
953
|
+
return Oe(Ae(n)) ? n.pop() : void 0;
|
|
934
954
|
}
|
|
935
|
-
var
|
|
955
|
+
var _e = (function(n) {
|
|
936
956
|
return n && typeof n.length == "number" && typeof n != "function";
|
|
937
957
|
});
|
|
938
958
|
function Le(n) {
|
|
939
959
|
return g(n?.then);
|
|
940
960
|
}
|
|
941
|
-
function
|
|
942
|
-
return g(n[
|
|
961
|
+
function Ue(n) {
|
|
962
|
+
return g(n[se]);
|
|
943
963
|
}
|
|
944
|
-
function
|
|
964
|
+
function Me(n) {
|
|
945
965
|
return Symbol.asyncIterator && g(n?.[Symbol.asyncIterator]);
|
|
946
966
|
}
|
|
947
|
-
function
|
|
967
|
+
function ke(n) {
|
|
948
968
|
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.");
|
|
949
969
|
}
|
|
950
|
-
function
|
|
970
|
+
function Et() {
|
|
951
971
|
return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
|
|
952
972
|
}
|
|
953
|
-
var
|
|
954
|
-
function ke(n) {
|
|
955
|
-
return g(n?.[Me]);
|
|
956
|
-
}
|
|
973
|
+
var Re = Et();
|
|
957
974
|
function Ne(n) {
|
|
958
|
-
return
|
|
975
|
+
return g(n?.[Re]);
|
|
976
|
+
}
|
|
977
|
+
function je(n) {
|
|
978
|
+
return nt(this, arguments, function() {
|
|
959
979
|
var e, r, s, o;
|
|
960
|
-
return
|
|
980
|
+
return we(this, function(i) {
|
|
961
981
|
switch (i.label) {
|
|
962
982
|
case 0:
|
|
963
983
|
e = n.getReader(), i.label = 1;
|
|
964
984
|
case 1:
|
|
965
985
|
i.trys.push([1, , 9, 10]), i.label = 2;
|
|
966
986
|
case 2:
|
|
967
|
-
return [4,
|
|
987
|
+
return [4, k(e.read())];
|
|
968
988
|
case 3:
|
|
969
|
-
return r = i.sent(), s = r.value, o = r.done, o ? [4,
|
|
989
|
+
return r = i.sent(), s = r.value, o = r.done, o ? [4, k(void 0)] : [3, 5];
|
|
970
990
|
case 4:
|
|
971
991
|
return [2, i.sent()];
|
|
972
992
|
case 5:
|
|
973
|
-
return [4,
|
|
993
|
+
return [4, k(s)];
|
|
974
994
|
case 6:
|
|
975
995
|
return [4, i.sent()];
|
|
976
996
|
case 7:
|
|
@@ -985,57 +1005,57 @@ function Ne(n) {
|
|
|
985
1005
|
});
|
|
986
1006
|
});
|
|
987
1007
|
}
|
|
988
|
-
function
|
|
1008
|
+
function $e(n) {
|
|
989
1009
|
return g(n?.getReader);
|
|
990
1010
|
}
|
|
991
1011
|
function U(n) {
|
|
992
1012
|
if (n instanceof S)
|
|
993
1013
|
return n;
|
|
994
1014
|
if (n != null) {
|
|
995
|
-
if (
|
|
996
|
-
return wt(n);
|
|
997
|
-
if (Ae(n))
|
|
998
|
-
return Et(n);
|
|
999
|
-
if (Le(n))
|
|
1015
|
+
if (Ue(n))
|
|
1000
1016
|
return It(n);
|
|
1001
|
-
if (
|
|
1002
|
-
return $e(n);
|
|
1003
|
-
if (ke(n))
|
|
1017
|
+
if (_e(n))
|
|
1004
1018
|
return Tt(n);
|
|
1005
|
-
if (
|
|
1019
|
+
if (Le(n))
|
|
1006
1020
|
return xt(n);
|
|
1021
|
+
if (Me(n))
|
|
1022
|
+
return De(n);
|
|
1023
|
+
if (Ne(n))
|
|
1024
|
+
return Ct(n);
|
|
1025
|
+
if ($e(n))
|
|
1026
|
+
return Ot(n);
|
|
1007
1027
|
}
|
|
1008
|
-
throw
|
|
1028
|
+
throw ke(n);
|
|
1009
1029
|
}
|
|
1010
|
-
function
|
|
1030
|
+
function It(n) {
|
|
1011
1031
|
return new S(function(t) {
|
|
1012
|
-
var e = n[
|
|
1032
|
+
var e = n[se]();
|
|
1013
1033
|
if (g(e.subscribe))
|
|
1014
1034
|
return e.subscribe(t);
|
|
1015
1035
|
throw new TypeError("Provided object does not correctly implement Symbol.observable");
|
|
1016
1036
|
});
|
|
1017
1037
|
}
|
|
1018
|
-
function
|
|
1038
|
+
function Tt(n) {
|
|
1019
1039
|
return new S(function(t) {
|
|
1020
1040
|
for (var e = 0; e < n.length && !t.closed; e++)
|
|
1021
1041
|
t.next(n[e]);
|
|
1022
1042
|
t.complete();
|
|
1023
1043
|
});
|
|
1024
1044
|
}
|
|
1025
|
-
function
|
|
1045
|
+
function xt(n) {
|
|
1026
1046
|
return new S(function(t) {
|
|
1027
1047
|
n.then(function(e) {
|
|
1028
1048
|
t.closed || (t.next(e), t.complete());
|
|
1029
1049
|
}, function(e) {
|
|
1030
1050
|
return t.error(e);
|
|
1031
|
-
}).then(null,
|
|
1051
|
+
}).then(null, xe);
|
|
1032
1052
|
});
|
|
1033
1053
|
}
|
|
1034
|
-
function
|
|
1054
|
+
function Ct(n) {
|
|
1035
1055
|
return new S(function(t) {
|
|
1036
1056
|
var e, r;
|
|
1037
1057
|
try {
|
|
1038
|
-
for (var s =
|
|
1058
|
+
for (var s = R(n), o = s.next(); !o.done; o = s.next()) {
|
|
1039
1059
|
var i = o.value;
|
|
1040
1060
|
if (t.next(i), t.closed)
|
|
1041
1061
|
return;
|
|
@@ -1052,24 +1072,24 @@ function Tt(n) {
|
|
|
1052
1072
|
t.complete();
|
|
1053
1073
|
});
|
|
1054
1074
|
}
|
|
1055
|
-
function
|
|
1075
|
+
function De(n) {
|
|
1056
1076
|
return new S(function(t) {
|
|
1057
|
-
|
|
1077
|
+
At(n, t).catch(function(e) {
|
|
1058
1078
|
return t.error(e);
|
|
1059
1079
|
});
|
|
1060
1080
|
});
|
|
1061
1081
|
}
|
|
1062
|
-
function
|
|
1063
|
-
return
|
|
1082
|
+
function Ot(n) {
|
|
1083
|
+
return De(je(n));
|
|
1064
1084
|
}
|
|
1065
|
-
function
|
|
1085
|
+
function At(n, t) {
|
|
1066
1086
|
var e, r, s, o;
|
|
1067
|
-
return
|
|
1087
|
+
return tt(this, void 0, void 0, function() {
|
|
1068
1088
|
var i, a;
|
|
1069
|
-
return
|
|
1089
|
+
return we(this, function(c) {
|
|
1070
1090
|
switch (c.label) {
|
|
1071
1091
|
case 0:
|
|
1072
|
-
c.trys.push([0, 5, 6, 11]), e =
|
|
1092
|
+
c.trys.push([0, 5, 6, 11]), e = rt(n), c.label = 1;
|
|
1073
1093
|
case 1:
|
|
1074
1094
|
return [4, e.next()];
|
|
1075
1095
|
case 2:
|
|
@@ -1100,7 +1120,7 @@ function Ct(n, t) {
|
|
|
1100
1120
|
});
|
|
1101
1121
|
});
|
|
1102
1122
|
}
|
|
1103
|
-
function
|
|
1123
|
+
function O(n, t, e, r, s) {
|
|
1104
1124
|
r === void 0 && (r = 0), s === void 0 && (s = !1);
|
|
1105
1125
|
var o = t.schedule(function() {
|
|
1106
1126
|
e(), s ? n.add(this.schedule(null, r)) : this.unsubscribe();
|
|
@@ -1108,35 +1128,35 @@ function C(n, t, e, r, s) {
|
|
|
1108
1128
|
if (n.add(o), !s)
|
|
1109
1129
|
return o;
|
|
1110
1130
|
}
|
|
1111
|
-
function
|
|
1112
|
-
return t === void 0 && (t = 0),
|
|
1113
|
-
e.subscribe(
|
|
1114
|
-
return
|
|
1131
|
+
function Fe(n, t) {
|
|
1132
|
+
return t === void 0 && (t = 0), P(function(e, r) {
|
|
1133
|
+
e.subscribe(A(r, function(s) {
|
|
1134
|
+
return O(r, n, function() {
|
|
1115
1135
|
return r.next(s);
|
|
1116
1136
|
}, t);
|
|
1117
1137
|
}, function() {
|
|
1118
|
-
return
|
|
1138
|
+
return O(r, n, function() {
|
|
1119
1139
|
return r.complete();
|
|
1120
1140
|
}, t);
|
|
1121
1141
|
}, function(s) {
|
|
1122
|
-
return
|
|
1142
|
+
return O(r, n, function() {
|
|
1123
1143
|
return r.error(s);
|
|
1124
1144
|
}, t);
|
|
1125
1145
|
}));
|
|
1126
1146
|
});
|
|
1127
1147
|
}
|
|
1128
|
-
function
|
|
1129
|
-
return t === void 0 && (t = 0),
|
|
1148
|
+
function He(n, t) {
|
|
1149
|
+
return t === void 0 && (t = 0), P(function(e, r) {
|
|
1130
1150
|
r.add(n.schedule(function() {
|
|
1131
1151
|
return e.subscribe(r);
|
|
1132
1152
|
}, t));
|
|
1133
1153
|
});
|
|
1134
1154
|
}
|
|
1135
|
-
function
|
|
1136
|
-
return U(n).pipe(
|
|
1155
|
+
function Pt(n, t) {
|
|
1156
|
+
return U(n).pipe(He(t), Fe(t));
|
|
1137
1157
|
}
|
|
1138
|
-
function
|
|
1139
|
-
return U(n).pipe(
|
|
1158
|
+
function _t(n, t) {
|
|
1159
|
+
return U(n).pipe(He(t), Fe(t));
|
|
1140
1160
|
}
|
|
1141
1161
|
function Lt(n, t) {
|
|
1142
1162
|
return new S(function(e) {
|
|
@@ -1146,11 +1166,11 @@ function Lt(n, t) {
|
|
|
1146
1166
|
});
|
|
1147
1167
|
});
|
|
1148
1168
|
}
|
|
1149
|
-
function
|
|
1169
|
+
function Ut(n, t) {
|
|
1150
1170
|
return new S(function(e) {
|
|
1151
1171
|
var r;
|
|
1152
|
-
return
|
|
1153
|
-
r = n[
|
|
1172
|
+
return O(e, t, function() {
|
|
1173
|
+
r = n[Re](), O(e, t, function() {
|
|
1154
1174
|
var s, o, i;
|
|
1155
1175
|
try {
|
|
1156
1176
|
s = r.next(), o = s.value, i = s.done;
|
|
@@ -1165,13 +1185,13 @@ function _t(n, t) {
|
|
|
1165
1185
|
};
|
|
1166
1186
|
});
|
|
1167
1187
|
}
|
|
1168
|
-
function
|
|
1188
|
+
function Be(n, t) {
|
|
1169
1189
|
if (!n)
|
|
1170
1190
|
throw new Error("Iterable cannot be null");
|
|
1171
1191
|
return new S(function(e) {
|
|
1172
|
-
|
|
1192
|
+
O(e, t, function() {
|
|
1173
1193
|
var r = n[Symbol.asyncIterator]();
|
|
1174
|
-
|
|
1194
|
+
O(e, t, function() {
|
|
1175
1195
|
r.next().then(function(s) {
|
|
1176
1196
|
s.done ? e.complete() : e.next(s.value);
|
|
1177
1197
|
});
|
|
@@ -1179,63 +1199,63 @@ function He(n, t) {
|
|
|
1179
1199
|
});
|
|
1180
1200
|
});
|
|
1181
1201
|
}
|
|
1182
|
-
function
|
|
1183
|
-
return
|
|
1202
|
+
function Mt(n, t) {
|
|
1203
|
+
return Be(je(n), t);
|
|
1184
1204
|
}
|
|
1185
|
-
function
|
|
1205
|
+
function kt(n, t) {
|
|
1186
1206
|
if (n != null) {
|
|
1207
|
+
if (Ue(n))
|
|
1208
|
+
return Pt(n, t);
|
|
1187
1209
|
if (_e(n))
|
|
1188
|
-
return Ot(n, t);
|
|
1189
|
-
if (Ae(n))
|
|
1190
1210
|
return Lt(n, t);
|
|
1191
1211
|
if (Le(n))
|
|
1192
|
-
return At(n, t);
|
|
1193
|
-
if (Pe(n))
|
|
1194
|
-
return He(n, t);
|
|
1195
|
-
if (ke(n))
|
|
1196
1212
|
return _t(n, t);
|
|
1197
|
-
if (
|
|
1198
|
-
return
|
|
1213
|
+
if (Me(n))
|
|
1214
|
+
return Be(n, t);
|
|
1215
|
+
if (Ne(n))
|
|
1216
|
+
return Ut(n, t);
|
|
1217
|
+
if ($e(n))
|
|
1218
|
+
return Mt(n, t);
|
|
1199
1219
|
}
|
|
1200
|
-
throw
|
|
1220
|
+
throw ke(n);
|
|
1201
1221
|
}
|
|
1202
|
-
function
|
|
1203
|
-
return t ?
|
|
1222
|
+
function ie(n, t) {
|
|
1223
|
+
return t ? kt(n, t) : U(n);
|
|
1204
1224
|
}
|
|
1205
|
-
function
|
|
1225
|
+
function Rt() {
|
|
1206
1226
|
for (var n = [], t = 0; t < arguments.length; t++)
|
|
1207
1227
|
n[t] = arguments[t];
|
|
1208
|
-
var e =
|
|
1209
|
-
return
|
|
1228
|
+
var e = Pe(n);
|
|
1229
|
+
return ie(n, e);
|
|
1210
1230
|
}
|
|
1211
|
-
function
|
|
1231
|
+
function Nt(n) {
|
|
1212
1232
|
return n instanceof Date && !isNaN(n);
|
|
1213
1233
|
}
|
|
1214
1234
|
function N(n, t) {
|
|
1215
|
-
return
|
|
1235
|
+
return P(function(e, r) {
|
|
1216
1236
|
var s = 0;
|
|
1217
|
-
e.subscribe(
|
|
1237
|
+
e.subscribe(A(r, function(o) {
|
|
1218
1238
|
r.next(n.call(t, o, s++));
|
|
1219
1239
|
}));
|
|
1220
1240
|
});
|
|
1221
1241
|
}
|
|
1222
|
-
var
|
|
1223
|
-
function
|
|
1224
|
-
return
|
|
1242
|
+
var jt = Array.isArray;
|
|
1243
|
+
function $t(n, t) {
|
|
1244
|
+
return jt(t) ? n.apply(void 0, F([], D(t))) : n(t);
|
|
1225
1245
|
}
|
|
1226
|
-
function
|
|
1246
|
+
function Dt(n) {
|
|
1227
1247
|
return N(function(t) {
|
|
1228
|
-
return
|
|
1248
|
+
return $t(n, t);
|
|
1229
1249
|
});
|
|
1230
1250
|
}
|
|
1231
|
-
var
|
|
1232
|
-
function
|
|
1251
|
+
var Ft = Array.isArray, Ht = Object.getPrototypeOf, Bt = Object.prototype, Gt = Object.keys;
|
|
1252
|
+
function Kt(n) {
|
|
1233
1253
|
if (n.length === 1) {
|
|
1234
1254
|
var t = n[0];
|
|
1235
|
-
if (
|
|
1255
|
+
if (Ft(t))
|
|
1236
1256
|
return { args: t, keys: null };
|
|
1237
|
-
if (
|
|
1238
|
-
var e =
|
|
1257
|
+
if (qt(t)) {
|
|
1258
|
+
var e = Gt(t);
|
|
1239
1259
|
return {
|
|
1240
1260
|
args: e.map(function(r) {
|
|
1241
1261
|
return t[r];
|
|
@@ -1246,33 +1266,33 @@ function Gt(n) {
|
|
|
1246
1266
|
}
|
|
1247
1267
|
return { args: n, keys: null };
|
|
1248
1268
|
}
|
|
1249
|
-
function
|
|
1250
|
-
return n && typeof n == "object" &&
|
|
1269
|
+
function qt(n) {
|
|
1270
|
+
return n && typeof n == "object" && Ht(n) === Bt;
|
|
1251
1271
|
}
|
|
1252
|
-
function
|
|
1272
|
+
function Yt(n, t) {
|
|
1253
1273
|
return n.reduce(function(e, r, s) {
|
|
1254
1274
|
return e[r] = t[s], e;
|
|
1255
1275
|
}, {});
|
|
1256
1276
|
}
|
|
1257
|
-
function
|
|
1277
|
+
function Wt() {
|
|
1258
1278
|
for (var n = [], t = 0; t < arguments.length; t++)
|
|
1259
1279
|
n[t] = arguments[t];
|
|
1260
|
-
var e =
|
|
1280
|
+
var e = Pe(n), r = wt(n), s = Kt(n), o = s.args, i = s.keys;
|
|
1261
1281
|
if (o.length === 0)
|
|
1262
|
-
return
|
|
1263
|
-
var a = new S(
|
|
1264
|
-
return
|
|
1265
|
-
} :
|
|
1266
|
-
return r ? a.pipe(
|
|
1267
|
-
}
|
|
1268
|
-
function
|
|
1269
|
-
return e === void 0 && (e =
|
|
1270
|
-
|
|
1282
|
+
return ie([], e);
|
|
1283
|
+
var a = new S(Xt(o, e, i ? function(c) {
|
|
1284
|
+
return Yt(i, c);
|
|
1285
|
+
} : W));
|
|
1286
|
+
return r ? a.pipe(Dt(r)) : a;
|
|
1287
|
+
}
|
|
1288
|
+
function Xt(n, t, e) {
|
|
1289
|
+
return e === void 0 && (e = W), function(r) {
|
|
1290
|
+
pe(t, function() {
|
|
1271
1291
|
for (var s = n.length, o = new Array(s), i = s, a = s, c = function(h) {
|
|
1272
|
-
|
|
1273
|
-
var m =
|
|
1274
|
-
m.subscribe(
|
|
1275
|
-
o[h] =
|
|
1292
|
+
pe(t, function() {
|
|
1293
|
+
var m = ie(n[h], t), b = !1;
|
|
1294
|
+
m.subscribe(A(r, function(d) {
|
|
1295
|
+
o[h] = d, b || (b = !0, a--), a || r.next(e(o.slice()));
|
|
1276
1296
|
}, function() {
|
|
1277
1297
|
--i || r.complete();
|
|
1278
1298
|
}));
|
|
@@ -1282,37 +1302,37 @@ function Yt(n, t, e) {
|
|
|
1282
1302
|
}, r);
|
|
1283
1303
|
};
|
|
1284
1304
|
}
|
|
1285
|
-
function
|
|
1286
|
-
n ?
|
|
1305
|
+
function pe(n, t, e) {
|
|
1306
|
+
n ? O(e, n, t) : t();
|
|
1287
1307
|
}
|
|
1288
|
-
function
|
|
1308
|
+
function Vt(n, t, e, r, s, o, i, a) {
|
|
1289
1309
|
var c = [], u = 0, h = 0, m = !1, b = function() {
|
|
1290
1310
|
m && !c.length && !u && t.complete();
|
|
1291
|
-
},
|
|
1292
|
-
return u < r ? f
|
|
1293
|
-
},
|
|
1311
|
+
}, d = function(f) {
|
|
1312
|
+
return u < r ? p(f) : c.push(f);
|
|
1313
|
+
}, p = function(f) {
|
|
1294
1314
|
u++;
|
|
1295
|
-
var
|
|
1296
|
-
U(e(
|
|
1315
|
+
var _ = !1;
|
|
1316
|
+
U(e(f, h++)).subscribe(A(t, function(E) {
|
|
1297
1317
|
t.next(E);
|
|
1298
1318
|
}, function() {
|
|
1299
|
-
|
|
1319
|
+
_ = !0;
|
|
1300
1320
|
}, void 0, function() {
|
|
1301
|
-
if (
|
|
1321
|
+
if (_)
|
|
1302
1322
|
try {
|
|
1303
1323
|
u--;
|
|
1304
1324
|
for (var E = function() {
|
|
1305
|
-
var
|
|
1306
|
-
i ||
|
|
1325
|
+
var L = c.shift();
|
|
1326
|
+
i || p(L);
|
|
1307
1327
|
}; c.length && u < r; )
|
|
1308
1328
|
E();
|
|
1309
1329
|
b();
|
|
1310
|
-
} catch (
|
|
1311
|
-
t.error(
|
|
1330
|
+
} catch (L) {
|
|
1331
|
+
t.error(L);
|
|
1312
1332
|
}
|
|
1313
1333
|
}));
|
|
1314
1334
|
};
|
|
1315
|
-
return n.subscribe(
|
|
1335
|
+
return n.subscribe(A(t, d, function() {
|
|
1316
1336
|
m = !0, b();
|
|
1317
1337
|
})), function() {
|
|
1318
1338
|
};
|
|
@@ -1322,15 +1342,15 @@ function Y(n, t, e) {
|
|
|
1322
1342
|
return N(function(o, i) {
|
|
1323
1343
|
return t(r, o, s, i);
|
|
1324
1344
|
})(U(n(r, s)));
|
|
1325
|
-
}, e) : (typeof t == "number" && (e = t),
|
|
1326
|
-
return
|
|
1345
|
+
}, e) : (typeof t == "number" && (e = t), P(function(r, s) {
|
|
1346
|
+
return Vt(r, s, n, e);
|
|
1327
1347
|
}));
|
|
1328
1348
|
}
|
|
1329
|
-
function
|
|
1330
|
-
n === void 0 && (n = 0), e === void 0 && (e =
|
|
1349
|
+
function zt(n, t, e) {
|
|
1350
|
+
n === void 0 && (n = 0), e === void 0 && (e = yt);
|
|
1331
1351
|
var r = -1;
|
|
1332
|
-
return t != null && (
|
|
1333
|
-
var o =
|
|
1352
|
+
return t != null && (Oe(t) ? e = t : r = t), new S(function(s) {
|
|
1353
|
+
var o = Nt(n) ? +n - e.now() : n;
|
|
1334
1354
|
o < 0 && (o = 0);
|
|
1335
1355
|
var i = 0;
|
|
1336
1356
|
return e.schedule(function() {
|
|
@@ -1338,50 +1358,50 @@ function Vt(n, t, e) {
|
|
|
1338
1358
|
}, o);
|
|
1339
1359
|
});
|
|
1340
1360
|
}
|
|
1341
|
-
function
|
|
1361
|
+
function Jt(n, t) {
|
|
1342
1362
|
return g(t) ? Y(n, t, 1) : Y(n, 1);
|
|
1343
1363
|
}
|
|
1344
|
-
function
|
|
1364
|
+
function Qt(n) {
|
|
1345
1365
|
return n <= 0 ? function() {
|
|
1346
|
-
return
|
|
1347
|
-
} :
|
|
1366
|
+
return St;
|
|
1367
|
+
} : P(function(t, e) {
|
|
1348
1368
|
var r = 0;
|
|
1349
|
-
t.subscribe(
|
|
1369
|
+
t.subscribe(A(e, function(s) {
|
|
1350
1370
|
++r <= n && (e.next(s), n <= r && e.complete());
|
|
1351
1371
|
}));
|
|
1352
1372
|
});
|
|
1353
1373
|
}
|
|
1354
|
-
function
|
|
1374
|
+
function Zt(n) {
|
|
1355
1375
|
return N(function() {
|
|
1356
1376
|
return n;
|
|
1357
1377
|
});
|
|
1358
1378
|
}
|
|
1359
|
-
function
|
|
1379
|
+
function en(n, t) {
|
|
1360
1380
|
return Y(function(e, r) {
|
|
1361
|
-
return U(n(e, r)).pipe(
|
|
1381
|
+
return U(n(e, r)).pipe(Qt(1), Zt(e));
|
|
1362
1382
|
});
|
|
1363
1383
|
}
|
|
1364
|
-
function
|
|
1365
|
-
t === void 0 && (t =
|
|
1366
|
-
var e =
|
|
1367
|
-
return
|
|
1384
|
+
function tn(n, t) {
|
|
1385
|
+
t === void 0 && (t = Ce);
|
|
1386
|
+
var e = zt(n, t);
|
|
1387
|
+
return en(function() {
|
|
1368
1388
|
return e;
|
|
1369
1389
|
});
|
|
1370
1390
|
}
|
|
1371
|
-
function
|
|
1372
|
-
return t === void 0 && (t =
|
|
1391
|
+
function M(n, t) {
|
|
1392
|
+
return t === void 0 && (t = W), n = n ?? nn, P(function(e, r) {
|
|
1373
1393
|
var s, o = !0;
|
|
1374
|
-
e.subscribe(
|
|
1394
|
+
e.subscribe(A(r, function(i) {
|
|
1375
1395
|
var a = t(i);
|
|
1376
1396
|
(o || !n(s, a)) && (o = !1, s = a, r.next(i));
|
|
1377
1397
|
}));
|
|
1378
1398
|
});
|
|
1379
1399
|
}
|
|
1380
|
-
function
|
|
1400
|
+
function nn(n, t) {
|
|
1381
1401
|
return n === t;
|
|
1382
1402
|
}
|
|
1383
|
-
function
|
|
1384
|
-
return
|
|
1403
|
+
function rn(n) {
|
|
1404
|
+
return P(function(t, e) {
|
|
1385
1405
|
try {
|
|
1386
1406
|
t.subscribe(e);
|
|
1387
1407
|
} finally {
|
|
@@ -1389,27 +1409,27 @@ function tn(n) {
|
|
|
1389
1409
|
}
|
|
1390
1410
|
});
|
|
1391
1411
|
}
|
|
1392
|
-
function
|
|
1393
|
-
return
|
|
1394
|
-
U(n).subscribe(
|
|
1412
|
+
function sn(n) {
|
|
1413
|
+
return P(function(t, e) {
|
|
1414
|
+
U(n).subscribe(A(e, function() {
|
|
1395
1415
|
return e.complete();
|
|
1396
|
-
},
|
|
1416
|
+
}, te)), !e.closed && t.subscribe(e);
|
|
1397
1417
|
});
|
|
1398
1418
|
}
|
|
1399
|
-
function
|
|
1419
|
+
function me(n) {
|
|
1400
1420
|
const { endpoint: t, apiKey: e, payload: r, debugMode: s, customHeaders: o } = n, i = n.method ?? "POST";
|
|
1401
1421
|
return new S((a) => {
|
|
1402
1422
|
const c = new AbortController();
|
|
1403
|
-
let u, h = !1;
|
|
1404
|
-
const
|
|
1423
|
+
let u, h = !1, m = !1;
|
|
1424
|
+
const b = {
|
|
1405
1425
|
"Content-Type": "application/json",
|
|
1406
1426
|
...o
|
|
1407
1427
|
};
|
|
1408
|
-
e && (
|
|
1409
|
-
const
|
|
1410
|
-
return s &&
|
|
1428
|
+
e && (b["X-API-KEY"] = e);
|
|
1429
|
+
const d = new URL(t);
|
|
1430
|
+
return s && d.searchParams.set("is_debug", "true"), Se(d.toString(), {
|
|
1411
1431
|
method: i,
|
|
1412
|
-
headers:
|
|
1432
|
+
headers: b,
|
|
1413
1433
|
body: i === "POST" && r ? JSON.stringify(r) : void 0,
|
|
1414
1434
|
signal: c.signal,
|
|
1415
1435
|
/**
|
|
@@ -1417,41 +1437,42 @@ function pe(n) {
|
|
|
1417
1437
|
* https://github.com/Azure/fetch-event-source/issues/17#issuecomment-1525904929
|
|
1418
1438
|
*/
|
|
1419
1439
|
openWhenHidden: !0,
|
|
1420
|
-
onopen: async (
|
|
1421
|
-
if (
|
|
1422
|
-
u =
|
|
1440
|
+
onopen: async (p) => {
|
|
1441
|
+
if (p.ok)
|
|
1442
|
+
u = p.headers.get("X-Trace-Id") ?? void 0;
|
|
1423
1443
|
else {
|
|
1424
1444
|
let f;
|
|
1425
1445
|
try {
|
|
1426
|
-
f = await
|
|
1446
|
+
f = await p.json();
|
|
1427
1447
|
} catch {
|
|
1428
1448
|
try {
|
|
1429
|
-
f = await
|
|
1449
|
+
f = await p.text();
|
|
1430
1450
|
} catch {
|
|
1431
1451
|
f = null;
|
|
1432
1452
|
}
|
|
1433
1453
|
}
|
|
1434
|
-
a.error(new w(
|
|
1454
|
+
a.error(new w(p.status, p.statusText, f)), c.abort();
|
|
1435
1455
|
}
|
|
1436
1456
|
},
|
|
1437
|
-
onmessage: (
|
|
1438
|
-
|
|
1439
|
-
const f = JSON.parse(
|
|
1457
|
+
onmessage: (p) => {
|
|
1458
|
+
p.id && (h = !0);
|
|
1459
|
+
const f = JSON.parse(p.data);
|
|
1440
1460
|
u ? f.traceId = u : f.requestId && (f.traceId = f.requestId, u || (u = f.requestId)), a.next(f);
|
|
1441
1461
|
},
|
|
1442
1462
|
onclose: () => {
|
|
1443
1463
|
a.complete();
|
|
1444
1464
|
},
|
|
1445
|
-
onerror: (
|
|
1465
|
+
onerror: (p) => {
|
|
1466
|
+
if (m) throw p;
|
|
1446
1467
|
if (!h)
|
|
1447
|
-
throw a.error(
|
|
1468
|
+
throw a.error(p), c.abort(), p;
|
|
1448
1469
|
}
|
|
1449
1470
|
}), () => {
|
|
1450
|
-
c.abort();
|
|
1471
|
+
m = !0, c.abort();
|
|
1451
1472
|
};
|
|
1452
1473
|
});
|
|
1453
1474
|
}
|
|
1454
|
-
class
|
|
1475
|
+
class on {
|
|
1455
1476
|
listeners = {};
|
|
1456
1477
|
on(t, e) {
|
|
1457
1478
|
this.listeners = Object.assign({}, this.listeners, {
|
|
@@ -1470,17 +1491,17 @@ class rn {
|
|
|
1470
1491
|
this.listeners[t] && this.listeners[t].forEach((r) => r(...e));
|
|
1471
1492
|
}
|
|
1472
1493
|
}
|
|
1473
|
-
class
|
|
1494
|
+
class _n {
|
|
1474
1495
|
apiKey;
|
|
1475
1496
|
endpoint;
|
|
1476
1497
|
botProviderEndpoint;
|
|
1477
1498
|
debugMode;
|
|
1478
|
-
destroy$ = new
|
|
1499
|
+
destroy$ = new oe();
|
|
1479
1500
|
closed = !1;
|
|
1480
1501
|
detached = !1;
|
|
1481
1502
|
detachTimer;
|
|
1482
1503
|
inFlight = 0;
|
|
1483
|
-
sseEmitter = new
|
|
1504
|
+
sseEmitter = new on();
|
|
1484
1505
|
transformSsePayload;
|
|
1485
1506
|
customHeaders;
|
|
1486
1507
|
constructor(t) {
|
|
@@ -1501,39 +1522,39 @@ class xn {
|
|
|
1501
1522
|
}
|
|
1502
1523
|
handleEvent(t) {
|
|
1503
1524
|
switch (t.eventType) {
|
|
1504
|
-
case
|
|
1505
|
-
this.sseEmitter.emit(
|
|
1525
|
+
case l.INIT:
|
|
1526
|
+
this.sseEmitter.emit(l.INIT, t);
|
|
1506
1527
|
break;
|
|
1507
|
-
case
|
|
1508
|
-
case
|
|
1509
|
-
this.sseEmitter.emit(
|
|
1528
|
+
case l.PROCESS_START:
|
|
1529
|
+
case l.PROCESS_COMPLETE:
|
|
1530
|
+
this.sseEmitter.emit(l.PROCESS, t);
|
|
1510
1531
|
break;
|
|
1511
|
-
case
|
|
1512
|
-
case
|
|
1513
|
-
case
|
|
1514
|
-
this.sseEmitter.emit(
|
|
1532
|
+
case l.MESSAGE_START:
|
|
1533
|
+
case l.MESSAGE_DELTA:
|
|
1534
|
+
case l.MESSAGE_COMPLETE:
|
|
1535
|
+
this.sseEmitter.emit(l.MESSAGE, t);
|
|
1515
1536
|
break;
|
|
1516
|
-
case
|
|
1517
|
-
case
|
|
1518
|
-
this.sseEmitter.emit(
|
|
1537
|
+
case l.TOOL_CALL_START:
|
|
1538
|
+
case l.TOOL_CALL_COMPLETE:
|
|
1539
|
+
this.sseEmitter.emit(l.TOOL_CALL, t);
|
|
1519
1540
|
break;
|
|
1520
|
-
case
|
|
1541
|
+
case l.TOOL_CALL_CONSENT:
|
|
1521
1542
|
this.sseEmitter.emit(
|
|
1522
|
-
|
|
1543
|
+
l.TOOL_CALL_CONSENT,
|
|
1523
1544
|
t
|
|
1524
1545
|
);
|
|
1525
1546
|
break;
|
|
1526
|
-
case
|
|
1527
|
-
this.sseEmitter.emit(
|
|
1547
|
+
case l.DONE:
|
|
1548
|
+
this.sseEmitter.emit(l.DONE, t);
|
|
1528
1549
|
break;
|
|
1529
|
-
case
|
|
1530
|
-
this.sseEmitter.emit(
|
|
1550
|
+
case l.ERROR:
|
|
1551
|
+
this.sseEmitter.emit(l.ERROR, t);
|
|
1531
1552
|
break;
|
|
1532
1553
|
}
|
|
1533
1554
|
}
|
|
1534
1555
|
fetchSse(t, e) {
|
|
1535
1556
|
return e?.onSseStart?.(), this.inFlight += 1, this.runSse(
|
|
1536
|
-
|
|
1557
|
+
me({
|
|
1537
1558
|
apiKey: this.apiKey,
|
|
1538
1559
|
endpoint: this.endpoint,
|
|
1539
1560
|
debugMode: this.debugMode,
|
|
@@ -1552,7 +1573,7 @@ class xn {
|
|
|
1552
1573
|
e?.onSseStart?.(), this.inFlight += 1;
|
|
1553
1574
|
const r = new URL(this.endpoint);
|
|
1554
1575
|
return r.searchParams.set("custom_channel_id", t), this.runSse(
|
|
1555
|
-
|
|
1576
|
+
me({
|
|
1556
1577
|
apiKey: this.apiKey,
|
|
1557
1578
|
endpoint: r.toString(),
|
|
1558
1579
|
debugMode: this.debugMode,
|
|
@@ -1602,16 +1623,47 @@ class xn {
|
|
|
1602
1623
|
}))
|
|
1603
1624
|
};
|
|
1604
1625
|
}
|
|
1626
|
+
deriveSuspendEndpoint() {
|
|
1627
|
+
const t = this.getBaseEndpoint();
|
|
1628
|
+
return t ? `${t}/message/suspend` : null;
|
|
1629
|
+
}
|
|
1630
|
+
/**
|
|
1631
|
+
* Ask the backend to suspend this channel's background run (F-023 AC1):
|
|
1632
|
+
* `POST {base}/message/suspend?custom_channel_id=…`. The six downstream relays expose this at the
|
|
1633
|
+
* exact same shape as `GET {base}/message/sse`, so it is derived identically with no per-backend case.
|
|
1634
|
+
*
|
|
1635
|
+
* `custom_channel_id` is always sent — some backends take the channel from the path and ignore it,
|
|
1636
|
+
* others require it, and sending it is correct for both (same rule as the GET rejoin).
|
|
1637
|
+
*
|
|
1638
|
+
* **Resolving means "accepted", not "stopped".** The run winds down on the server and declares itself
|
|
1639
|
+
* finished through the terminal event on the already-open SSE stream (the same event a normal run
|
|
1640
|
+
* ends with), so callers must keep that stream connected and wait for it.
|
|
1641
|
+
*
|
|
1642
|
+
* Success is **any 2xx** — relays variously answer `204 No Content` or `200` with an envelope, so no
|
|
1643
|
+
* single status is hardcoded. `404` means the channel was never created, i.e. there is nothing to
|
|
1644
|
+
* stop, which is a success rather than an error. Every other non-2xx throws {@link HttpError}.
|
|
1645
|
+
*/
|
|
1646
|
+
async suspendChannel(t, e) {
|
|
1647
|
+
const r = this.deriveSuspendEndpoint();
|
|
1648
|
+
if (!r)
|
|
1649
|
+
throw new Error("Unable to derive channel suspend endpoint. Please provide botProviderEndpoint in config.");
|
|
1650
|
+
const s = new URL(r);
|
|
1651
|
+
s.searchParams.set("custom_channel_id", t), e?.requestId && s.searchParams.set("request_id", e.requestId), e?.force && s.searchParams.set("force", "true");
|
|
1652
|
+
const o = await fetch(s.toString(), { method: "POST", headers: this.apiHeaders() });
|
|
1653
|
+
if (!(o.ok || o.status === 404))
|
|
1654
|
+
throw new w(o.status, o.statusText, await o.text().catch(() => {
|
|
1655
|
+
}));
|
|
1656
|
+
}
|
|
1605
1657
|
runSse(t, e) {
|
|
1606
1658
|
return t.pipe(
|
|
1607
1659
|
// No RxJS-level retry: re-subscribing would re-POST and the backend would re-dispatch a duplicate
|
|
1608
1660
|
// run. Mid-stream resume is the library's job (native Last-Event-ID reconnect in
|
|
1609
1661
|
// create-sse-observable); a no-cursor failure surfaces via `error` below.
|
|
1610
|
-
|
|
1611
|
-
|
|
1662
|
+
Jt((r) => Rt(r).pipe(tn(e?.delayTime ?? 50))),
|
|
1663
|
+
sn(this.destroy$),
|
|
1612
1664
|
// Settle the run accounting on every termination path — complete, error, AND a user-initiated
|
|
1613
1665
|
// unsubscribe (stop-generation aborts the connection without a terminal event).
|
|
1614
|
-
|
|
1666
|
+
rn(() => this.onRunSettled())
|
|
1615
1667
|
).subscribe({
|
|
1616
1668
|
next: (r) => {
|
|
1617
1669
|
this.detached || (e?.onSseMessage?.(r), this.handleEvent(r));
|
|
@@ -1738,7 +1790,8 @@ class xn {
|
|
|
1738
1790
|
throw new Error("Unable to derive sandbox fs endpoint. Please provide botProviderEndpoint in config.");
|
|
1739
1791
|
return `${e}/sandbox/${encodeURIComponent(t)}/fs`;
|
|
1740
1792
|
}
|
|
1741
|
-
|
|
1793
|
+
/** The shared auth / custom headers for the client's plain-JSON REST calls (no SSE). */
|
|
1794
|
+
apiHeaders() {
|
|
1742
1795
|
const t = { ...this.customHeaders };
|
|
1743
1796
|
return this.apiKey && (t["X-API-KEY"] = this.apiKey), t;
|
|
1744
1797
|
}
|
|
@@ -1749,7 +1802,7 @@ class xn {
|
|
|
1749
1802
|
async sandboxFsList(t, e) {
|
|
1750
1803
|
const r = new URL(`${this.deriveSandboxFsEndpoint(t)}/list`);
|
|
1751
1804
|
r.searchParams.set("path", e);
|
|
1752
|
-
const s = await fetch(r.toString(), { method: "GET", headers: this.
|
|
1805
|
+
const s = await fetch(r.toString(), { method: "GET", headers: this.apiHeaders() });
|
|
1753
1806
|
if (!s.ok)
|
|
1754
1807
|
throw new w(s.status, s.statusText, await s.text().catch(() => {
|
|
1755
1808
|
}));
|
|
@@ -1763,7 +1816,7 @@ class xn {
|
|
|
1763
1816
|
async sandboxFsRead(t, e, r) {
|
|
1764
1817
|
const s = new URL(`${this.deriveSandboxFsEndpoint(t)}/file`);
|
|
1765
1818
|
s.searchParams.set("path", e), r?.offsetBytes != null && s.searchParams.set("offset_bytes", String(r.offsetBytes)), r?.limitBytes != null && s.searchParams.set("limit_bytes", String(r.limitBytes));
|
|
1766
|
-
const o = await fetch(s.toString(), { method: "GET", headers: this.
|
|
1819
|
+
const o = await fetch(s.toString(), { method: "GET", headers: this.apiHeaders() });
|
|
1767
1820
|
if (!o.ok)
|
|
1768
1821
|
throw new w(o.status, o.statusText, await o.text().catch(() => {
|
|
1769
1822
|
}));
|
|
@@ -1783,7 +1836,7 @@ class xn {
|
|
|
1783
1836
|
o.searchParams.set("path", e), s?.mode != null && o.searchParams.set("mode", String(s.mode)), s?.createOnly && o.searchParams.set("create_only", "true");
|
|
1784
1837
|
const i = new FormData();
|
|
1785
1838
|
i.append("file", r instanceof Blob ? r : new Blob([r]));
|
|
1786
|
-
const a = await fetch(o.toString(), { method: "PUT", headers: this.
|
|
1839
|
+
const a = await fetch(o.toString(), { method: "PUT", headers: this.apiHeaders(), body: i });
|
|
1787
1840
|
if (!a.ok)
|
|
1788
1841
|
throw new w(a.status, a.statusText, await a.text().catch(() => {
|
|
1789
1842
|
}));
|
|
@@ -1794,7 +1847,7 @@ class xn {
|
|
|
1794
1847
|
async sandboxFsRequest(t, e, r, s) {
|
|
1795
1848
|
const o = new URL(`${this.deriveSandboxFsEndpoint(t)}/${e}`);
|
|
1796
1849
|
Object.entries(s).forEach(([a, c]) => o.searchParams.set(a, c));
|
|
1797
|
-
const i = await fetch(o.toString(), { method: r, headers: this.
|
|
1850
|
+
const i = await fetch(o.toString(), { method: r, headers: this.apiHeaders() });
|
|
1798
1851
|
if (!i.ok)
|
|
1799
1852
|
throw new w(i.status, i.statusText, await i.text().catch(() => {
|
|
1800
1853
|
}));
|
|
@@ -1804,7 +1857,7 @@ class xn {
|
|
|
1804
1857
|
async sandboxFsStat(t, e) {
|
|
1805
1858
|
const r = new URL(`${this.deriveSandboxFsEndpoint(t)}/stat`);
|
|
1806
1859
|
r.searchParams.set("path", e);
|
|
1807
|
-
const s = await fetch(r.toString(), { method: "GET", headers: this.
|
|
1860
|
+
const s = await fetch(r.toString(), { method: "GET", headers: this.apiHeaders() });
|
|
1808
1861
|
if (!s.ok)
|
|
1809
1862
|
throw new w(s.status, s.statusText, await s.text().catch(() => {
|
|
1810
1863
|
}));
|
|
@@ -1851,8 +1904,8 @@ class xn {
|
|
|
1851
1904
|
const r = new URL(`${this.deriveSandboxFsEndpoint(t)}/watch`);
|
|
1852
1905
|
return r.searchParams.set("path", e), new S((s) => {
|
|
1853
1906
|
const o = new AbortController();
|
|
1854
|
-
return
|
|
1855
|
-
headers: this.
|
|
1907
|
+
return Se(r.toString(), {
|
|
1908
|
+
headers: this.apiHeaders(),
|
|
1856
1909
|
signal: o.signal,
|
|
1857
1910
|
openWhenHidden: !0,
|
|
1858
1911
|
onopen: async (i) => {
|
|
@@ -1891,29 +1944,29 @@ class xn {
|
|
|
1891
1944
|
const y = [];
|
|
1892
1945
|
for (let n = 0; n < 256; ++n)
|
|
1893
1946
|
y.push((n + 256).toString(16).slice(1));
|
|
1894
|
-
function
|
|
1947
|
+
function an(n, t = 0) {
|
|
1895
1948
|
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();
|
|
1896
1949
|
}
|
|
1897
1950
|
let J;
|
|
1898
|
-
const
|
|
1899
|
-
function
|
|
1951
|
+
const cn = new Uint8Array(16);
|
|
1952
|
+
function un() {
|
|
1900
1953
|
if (!J) {
|
|
1901
1954
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
1902
1955
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
1903
1956
|
J = crypto.getRandomValues.bind(crypto);
|
|
1904
1957
|
}
|
|
1905
|
-
return J(
|
|
1958
|
+
return J(cn);
|
|
1906
1959
|
}
|
|
1907
|
-
const
|
|
1908
|
-
function
|
|
1960
|
+
const ln = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), ge = { randomUUID: ln };
|
|
1961
|
+
function dn(n, t, e) {
|
|
1909
1962
|
n = n || {};
|
|
1910
|
-
const r = n.random ?? n.rng?.() ??
|
|
1963
|
+
const r = n.random ?? n.rng?.() ?? un();
|
|
1911
1964
|
if (r.length < 16)
|
|
1912
1965
|
throw new Error("Random bytes length must be >= 16");
|
|
1913
|
-
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128,
|
|
1966
|
+
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, an(r);
|
|
1914
1967
|
}
|
|
1915
|
-
function
|
|
1916
|
-
return
|
|
1968
|
+
function Ge(n, t, e) {
|
|
1969
|
+
return ge.randomUUID && !n ? ge.randomUUID() : dn(n);
|
|
1917
1970
|
}
|
|
1918
1971
|
class v {
|
|
1919
1972
|
messages = null;
|
|
@@ -1929,47 +1982,61 @@ class v {
|
|
|
1929
1982
|
return this.pendingConsent ? new v({ messages: this.messages, pendingConsent: null }) : this;
|
|
1930
1983
|
}
|
|
1931
1984
|
/**
|
|
1932
|
-
* Converge
|
|
1933
|
-
*
|
|
1934
|
-
*
|
|
1935
|
-
*
|
|
1936
|
-
*
|
|
1985
|
+
* Converge everything the aborted run left mid-flight (F-020 AC10, F-023). A stopped run sends no
|
|
1986
|
+
* closing frame for whatever was in progress, so without this those messages advertise activity that
|
|
1987
|
+
* has ceased — and they persist in the transcript that way:
|
|
1988
|
+
*
|
|
1989
|
+
* - a tool-call with `isComplete === false` gets no `tool_call.complete`, and would render as
|
|
1990
|
+
* `running` forever, so it converges to `cancelled`;
|
|
1991
|
+
* - a thinking block with `isThinking === true` gets no `message.thinking.complete`, and would keep
|
|
1992
|
+
* its highlighted "Thinking…" state forever, so it converges to the settled state.
|
|
1993
|
+
*
|
|
1994
|
+
* Content is preserved either way — never rolled back. Already-settled messages and every other
|
|
1995
|
+
* message type are untouched, and the same instance is returned when nothing was in flight.
|
|
1937
1996
|
*/
|
|
1938
|
-
|
|
1997
|
+
settleInFlightMessages() {
|
|
1939
1998
|
if (!this.messages) return this;
|
|
1940
1999
|
let t = !1;
|
|
1941
2000
|
const e = new Map(this.messages);
|
|
1942
2001
|
for (const [r, s] of e)
|
|
1943
|
-
s.type === "tool-call" && !s.isComplete && (e.set(r, { ...s, isComplete: !0, isCancelled: !0 }), t = !0);
|
|
2002
|
+
s.type === "tool-call" && !s.isComplete && (e.set(r, { ...s, isComplete: !0, isCancelled: !0 }), t = !0), s.type === "thinking" && s.isThinking && (e.set(r, { ...s, isThinking: !1 }), t = !0);
|
|
1944
2003
|
return t ? new v({ messages: e, pendingConsent: this.pendingConsent }) : this;
|
|
1945
2004
|
}
|
|
2005
|
+
/**
|
|
2006
|
+
* @deprecated Renamed to {@link settleInFlightMessages} in 0.3.27 — it settles in-flight thinking
|
|
2007
|
+
* blocks as well as tool-calls, which the old name no longer described. Behaviour is unchanged;
|
|
2008
|
+
* this alias will be removed in a future major version.
|
|
2009
|
+
*/
|
|
2010
|
+
cancelInFlightToolCalls() {
|
|
2011
|
+
return this.settleInFlightMessages();
|
|
2012
|
+
}
|
|
1946
2013
|
onMessage(t) {
|
|
1947
2014
|
switch (t.eventType) {
|
|
1948
|
-
case
|
|
2015
|
+
case l.MESSAGE_START:
|
|
1949
2016
|
return this.onMessageStart(t);
|
|
1950
|
-
case
|
|
2017
|
+
case l.MESSAGE_DELTA:
|
|
1951
2018
|
return this.onMessageDelta(t);
|
|
1952
|
-
case
|
|
2019
|
+
case l.MESSAGE_COMPLETE:
|
|
1953
2020
|
return this.onMessageComplete(t);
|
|
1954
|
-
case
|
|
2021
|
+
case l.MESSAGE_USER:
|
|
1955
2022
|
return this.onMessageUser(t);
|
|
1956
|
-
case
|
|
2023
|
+
case l.MESSAGE_THINKING_START:
|
|
1957
2024
|
return this.onThinkingStart(t);
|
|
1958
|
-
case
|
|
2025
|
+
case l.MESSAGE_THINKING_DELTA:
|
|
1959
2026
|
return this.onThinkingDelta(t);
|
|
1960
|
-
case
|
|
2027
|
+
case l.MESSAGE_THINKING_COMPLETE:
|
|
1961
2028
|
return this.onThinkingComplete(t);
|
|
1962
|
-
case
|
|
2029
|
+
case l.TOOL_CALL_START:
|
|
1963
2030
|
return this.onToolCallStart(t);
|
|
1964
|
-
case
|
|
2031
|
+
case l.TOOL_CALL_COMPLETE:
|
|
1965
2032
|
return this.onToolCallComplete(t);
|
|
1966
|
-
case
|
|
2033
|
+
case l.TOOL_CALL_CONSENT:
|
|
1967
2034
|
return this.onToolCallConsent(t);
|
|
1968
|
-
case
|
|
2035
|
+
case l.SUBAGENT_START:
|
|
1969
2036
|
return this.onSubagentStart(t);
|
|
1970
|
-
case
|
|
2037
|
+
case l.SUBAGENT_COMPLETE:
|
|
1971
2038
|
return this.onSubagentComplete(t);
|
|
1972
|
-
case
|
|
2039
|
+
case l.ERROR:
|
|
1973
2040
|
return this.onMessageError(t);
|
|
1974
2041
|
default:
|
|
1975
2042
|
return this;
|
|
@@ -1998,7 +2065,7 @@ class v {
|
|
|
1998
2065
|
const r = new Map(this.messages);
|
|
1999
2066
|
return r.set(e.messageId, {
|
|
2000
2067
|
type: "bot",
|
|
2001
|
-
eventType:
|
|
2068
|
+
eventType: l.MESSAGE_START,
|
|
2002
2069
|
isTyping: !0,
|
|
2003
2070
|
typingText: "",
|
|
2004
2071
|
messageId: e.messageId,
|
|
@@ -2016,7 +2083,7 @@ class v {
|
|
|
2016
2083
|
const s = r?.type === "bot" ? r : void 0, o = new Map(this.messages);
|
|
2017
2084
|
return o.set(e.messageId, {
|
|
2018
2085
|
type: "bot",
|
|
2019
|
-
eventType:
|
|
2086
|
+
eventType: l.MESSAGE_DELTA,
|
|
2020
2087
|
isTyping: !0,
|
|
2021
2088
|
typingText: `${s?.typingText ?? ""}${e.text}`,
|
|
2022
2089
|
messageId: e.messageId,
|
|
@@ -2032,7 +2099,7 @@ class v {
|
|
|
2032
2099
|
const r = new Map(this.messages), s = r.get(e.messageId);
|
|
2033
2100
|
return r.set(e.messageId, {
|
|
2034
2101
|
type: "bot",
|
|
2035
|
-
eventType:
|
|
2102
|
+
eventType: l.MESSAGE_COMPLETE,
|
|
2036
2103
|
isTyping: !1,
|
|
2037
2104
|
typingText: null,
|
|
2038
2105
|
messageId: e.messageId,
|
|
@@ -2102,10 +2169,10 @@ class v {
|
|
|
2102
2169
|
return s.set(e.messageId, o), new v({ messages: s, pendingConsent: this.pendingConsent });
|
|
2103
2170
|
}
|
|
2104
2171
|
onMessageError(t) {
|
|
2105
|
-
const e =
|
|
2172
|
+
const e = Ge(), r = t.fact.runError.error, s = new Map(this.messages);
|
|
2106
2173
|
return s.set(e, {
|
|
2107
2174
|
type: "error",
|
|
2108
|
-
eventType:
|
|
2175
|
+
eventType: l.ERROR,
|
|
2109
2176
|
messageId: e,
|
|
2110
2177
|
error: r,
|
|
2111
2178
|
time: /* @__PURE__ */ new Date(),
|
|
@@ -2115,7 +2182,7 @@ class v {
|
|
|
2115
2182
|
onToolCallStart(t) {
|
|
2116
2183
|
const e = t.fact.toolCallStart, r = new Map(this.messages), s = `${e.processId}-${e.callSeq}`, o = {
|
|
2117
2184
|
type: "tool-call",
|
|
2118
|
-
eventType:
|
|
2185
|
+
eventType: l.TOOL_CALL_START,
|
|
2119
2186
|
messageId: s,
|
|
2120
2187
|
processId: e.processId,
|
|
2121
2188
|
callSeq: e.callSeq,
|
|
@@ -2136,7 +2203,7 @@ class v {
|
|
|
2136
2203
|
if (o?.type === "tool-call") {
|
|
2137
2204
|
const i = {
|
|
2138
2205
|
...o,
|
|
2139
|
-
eventType:
|
|
2206
|
+
eventType: l.TOOL_CALL_COMPLETE,
|
|
2140
2207
|
result: e.toolCallResult,
|
|
2141
2208
|
isError: e.isError,
|
|
2142
2209
|
sidecar: e.toolUseResultSidecar,
|
|
@@ -2181,22 +2248,22 @@ class v {
|
|
|
2181
2248
|
return r.set(s, o), new v({ messages: r, pendingConsent: this.pendingConsent });
|
|
2182
2249
|
}
|
|
2183
2250
|
}
|
|
2184
|
-
const
|
|
2185
|
-
function
|
|
2186
|
-
return n.toolsetName === "" &&
|
|
2251
|
+
const hn = /* @__PURE__ */ new Set(["TaskCreate", "TaskUpdate"]);
|
|
2252
|
+
function fn(n) {
|
|
2253
|
+
return n.toolsetName === "" && hn.has(n.toolName);
|
|
2187
2254
|
}
|
|
2188
|
-
function
|
|
2255
|
+
function be(n) {
|
|
2189
2256
|
return typeof n == "object" && n !== null ? n : void 0;
|
|
2190
2257
|
}
|
|
2191
2258
|
function I(n) {
|
|
2192
2259
|
return typeof n == "string" ? n : void 0;
|
|
2193
2260
|
}
|
|
2194
|
-
function
|
|
2261
|
+
function pn(n) {
|
|
2195
2262
|
const t = [], e = /* @__PURE__ */ new Map();
|
|
2196
2263
|
for (const r of n) {
|
|
2197
2264
|
const s = r.parameter ?? {}, o = r.sidecar ?? {};
|
|
2198
2265
|
if (r.toolName === "TaskCreate") {
|
|
2199
|
-
const i =
|
|
2266
|
+
const i = be(o.task), a = I(i?.id);
|
|
2200
2267
|
if (!a) continue;
|
|
2201
2268
|
e.has(a) || t.push(a), e.set(a, {
|
|
2202
2269
|
id: a,
|
|
@@ -2207,7 +2274,7 @@ function hn(n) {
|
|
|
2207
2274
|
// initial status = pending (keep existing on repeat)
|
|
2208
2275
|
});
|
|
2209
2276
|
} else if (r.toolName === "TaskUpdate") {
|
|
2210
|
-
const i =
|
|
2277
|
+
const i = be(o.statusChange), a = I(s.taskId) || I(o.taskId), c = I(i?.to) || I(s.status);
|
|
2211
2278
|
if (!a || !c) continue;
|
|
2212
2279
|
const u = e.get(a);
|
|
2213
2280
|
u && e.set(a, { ...u, status: c });
|
|
@@ -2215,13 +2282,13 @@ function hn(n) {
|
|
|
2215
2282
|
}
|
|
2216
2283
|
return t.map((r) => e.get(r));
|
|
2217
2284
|
}
|
|
2218
|
-
function
|
|
2285
|
+
function mn(n) {
|
|
2219
2286
|
return n.toolsetName === "" && n.toolName === "Agent";
|
|
2220
2287
|
}
|
|
2221
|
-
function
|
|
2288
|
+
function gn(n) {
|
|
2222
2289
|
return !!n;
|
|
2223
2290
|
}
|
|
2224
|
-
function
|
|
2291
|
+
function bn(n) {
|
|
2225
2292
|
const t = [], e = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), s = (o) => (e.has(o) || (t.push(o), e.set(o, { status: "running" }), r.set(o, /* @__PURE__ */ new Map())), e.get(o));
|
|
2226
2293
|
for (const o of n)
|
|
2227
2294
|
switch (o.kind) {
|
|
@@ -2262,21 +2329,21 @@ function mn(n) {
|
|
|
2262
2329
|
tools: Array.from(r.get(o).values())
|
|
2263
2330
|
}));
|
|
2264
2331
|
}
|
|
2265
|
-
function
|
|
2332
|
+
function vn(n) {
|
|
2266
2333
|
return typeof n == "string" ? n : void 0;
|
|
2267
2334
|
}
|
|
2268
|
-
function
|
|
2335
|
+
function yn(n) {
|
|
2269
2336
|
const t = [];
|
|
2270
2337
|
for (const e of n) {
|
|
2271
|
-
if (e.type === "tool-call" &&
|
|
2338
|
+
if (e.type === "tool-call" && mn(e)) {
|
|
2272
2339
|
t.push({
|
|
2273
2340
|
kind: "agentStart",
|
|
2274
2341
|
toolUseId: e.toolUseId ?? e.messageId,
|
|
2275
|
-
description:
|
|
2342
|
+
description: vn(e.parameter.description)
|
|
2276
2343
|
});
|
|
2277
2344
|
continue;
|
|
2278
2345
|
}
|
|
2279
|
-
if (e.type === "tool-call" &&
|
|
2346
|
+
if (e.type === "tool-call" && gn(e.parentToolUseId)) {
|
|
2280
2347
|
const r = e.toolUseId ?? e.messageId;
|
|
2281
2348
|
t.push({
|
|
2282
2349
|
kind: "toolStart",
|
|
@@ -2313,37 +2380,37 @@ function bn(n) {
|
|
|
2313
2380
|
}
|
|
2314
2381
|
return t;
|
|
2315
2382
|
}
|
|
2316
|
-
function
|
|
2383
|
+
function Sn(n) {
|
|
2317
2384
|
const t = Array.from(n.messages?.values() ?? []).filter(
|
|
2318
|
-
(e) => e.type === "tool-call" && e.isComplete &&
|
|
2385
|
+
(e) => e.type === "tool-call" && e.isComplete && fn(e)
|
|
2319
2386
|
);
|
|
2320
|
-
return
|
|
2387
|
+
return pn(t);
|
|
2321
2388
|
}
|
|
2322
|
-
function
|
|
2323
|
-
return
|
|
2389
|
+
function wn(n) {
|
|
2390
|
+
return bn(yn(Array.from(n.messages?.values() ?? [])));
|
|
2324
2391
|
}
|
|
2325
|
-
function
|
|
2392
|
+
function En(n, t) {
|
|
2326
2393
|
return n === t ? !0 : n.length !== t.length ? !1 : n.every((e, r) => {
|
|
2327
2394
|
const s = t[r];
|
|
2328
2395
|
return e.id === s.id && e.status === s.status && e.subject === s.subject && e.activeForm === s.activeForm && e.description === s.description;
|
|
2329
2396
|
});
|
|
2330
2397
|
}
|
|
2331
|
-
function
|
|
2398
|
+
function In(n, t) {
|
|
2332
2399
|
return n.length !== t.length ? !1 : n.every((e, r) => {
|
|
2333
2400
|
const s = t[r];
|
|
2334
2401
|
return e.toolName === s.toolName && e.toolsetName === s.toolsetName && e.status === s.status && e.reason === s.reason;
|
|
2335
2402
|
});
|
|
2336
2403
|
}
|
|
2337
|
-
function
|
|
2404
|
+
function Tn(n, t) {
|
|
2338
2405
|
return n === t ? !0 : n.length !== t.length ? !1 : n.every((e, r) => {
|
|
2339
2406
|
const s = t[r];
|
|
2340
|
-
return e.parentToolUseId === s.parentToolUseId && e.status === s.status && e.subagentType === s.subagentType && e.description === s.description && e.summary === s.summary &&
|
|
2407
|
+
return e.parentToolUseId === s.parentToolUseId && e.status === s.status && e.subagentType === s.subagentType && e.description === s.description && e.summary === s.summary && In(e.tools, s.tools);
|
|
2341
2408
|
});
|
|
2342
2409
|
}
|
|
2343
|
-
function
|
|
2344
|
-
const t = new
|
|
2345
|
-
return r.add(n.pipe(N(
|
|
2346
|
-
n.pipe(N(
|
|
2410
|
+
function xn(n) {
|
|
2411
|
+
const t = new C([]), e = new C([]), r = new j();
|
|
2412
|
+
return r.add(n.pipe(N(Sn), M(En)).subscribe(t)), r.add(
|
|
2413
|
+
n.pipe(N(wn), M(Tn)).subscribe(e)
|
|
2347
2414
|
), {
|
|
2348
2415
|
tasks$: t.asObservable(),
|
|
2349
2416
|
subagents$: e.asObservable(),
|
|
@@ -2352,18 +2419,26 @@ function In(n) {
|
|
|
2352
2419
|
teardown: () => r.unsubscribe()
|
|
2353
2420
|
};
|
|
2354
2421
|
}
|
|
2355
|
-
function
|
|
2422
|
+
function ve(n) {
|
|
2356
2423
|
const t = /* @__PURE__ */ new Map();
|
|
2357
2424
|
for (const e of n) t.set(e.sandboxName, e);
|
|
2358
2425
|
return [...t.values()].sort(
|
|
2359
2426
|
(e, r) => (e.sandboxBlueprintName || e.sandboxName).localeCompare(r.sandboxBlueprintName || r.sandboxName)
|
|
2360
2427
|
);
|
|
2361
2428
|
}
|
|
2429
|
+
const Q = { kind: null, stopPhase: "idle" }, Cn = 1e4;
|
|
2430
|
+
function On(n, t) {
|
|
2431
|
+
return n.kind === t.kind && n.stopPhase === t.stopPhase && n.requestId === t.requestId;
|
|
2432
|
+
}
|
|
2362
2433
|
class K {
|
|
2363
2434
|
client;
|
|
2364
2435
|
customChannelId;
|
|
2365
2436
|
customMessageId;
|
|
2437
|
+
// Join-time run state from `GET /channel/metadata` (F-023 AC9): decides whether a rejoin is tailing a
|
|
2438
|
+
// live run (`restore`) or replaying a finished transcript (`replay`).
|
|
2439
|
+
joinRunState;
|
|
2366
2440
|
isConnecting$;
|
|
2441
|
+
runStatusSubject;
|
|
2367
2442
|
conversation$;
|
|
2368
2443
|
channelTitleSubject;
|
|
2369
2444
|
sandboxPhaseSubject;
|
|
@@ -2384,24 +2459,33 @@ class K {
|
|
|
2384
2459
|
sandboxPhase$;
|
|
2385
2460
|
/** Reactive live-sandbox list store (F-019): authoritative from `/channel/metadata`, per-slice; replay-safe. */
|
|
2386
2461
|
launchedSandboxes$;
|
|
2462
|
+
/** Reactive run identity + stop lifecycle store (F-023): who holds the connection, and is a stop pending. */
|
|
2463
|
+
runStatus$;
|
|
2387
2464
|
currentUserMessageId;
|
|
2388
2465
|
// The most-recently-sent user message id. Unlike currentUserMessageId (which
|
|
2389
2466
|
// is cleared once a traceId is attached), this is kept across the SSE
|
|
2390
2467
|
// lifecycle so RESPONSE_TOOL_CALL_CONSENT — fired after run.done — can echo
|
|
2391
2468
|
// back the message id the bot is waiting on.
|
|
2392
2469
|
lastSentMessageId;
|
|
2393
|
-
// The in-flight SSE run's subscription. Held so
|
|
2394
|
-
//
|
|
2395
|
-
// every terminal (complete / error)
|
|
2470
|
+
// The in-flight SSE run's subscription. Held so the connection can be aborted locally (unsubscribe →
|
|
2471
|
+
// create-sse-observable teardown → AbortController.abort()) on close, on channel switch, and on the
|
|
2472
|
+
// legacy stop fallback. Cleared on every terminal (complete / error).
|
|
2473
|
+
//
|
|
2474
|
+
// NOTE (F-023): a user-initiated stop no longer unsubscribes this. Runs execute in the background on
|
|
2475
|
+
// the server, so cutting the stream would only stop *watching* — the stop is requested through
|
|
2476
|
+
// `client.suspendChannel()` and declared by this same stream's terminal event.
|
|
2396
2477
|
currentRun;
|
|
2478
|
+
// Armed when a stop is accepted; fires after FORCE_STOP_TIMEOUT_MS to offer force-stop (F-023 AC7).
|
|
2479
|
+
// Cleared on terminal, on suspend failure, and in close() (§1.5).
|
|
2480
|
+
forceStopTimer;
|
|
2397
2481
|
constructor(t) {
|
|
2398
2482
|
if (!t.client)
|
|
2399
2483
|
throw new Error("client must be required");
|
|
2400
2484
|
if (!t.customChannelId)
|
|
2401
2485
|
throw new Error("customChannelId must be required");
|
|
2402
|
-
this.client = t.client, this.customChannelId = t.customChannelId, this.customMessageId = t.customMessageId, this.isConnecting$ = new
|
|
2403
|
-
|
|
2404
|
-
), this.derivedStores =
|
|
2486
|
+
this.client = t.client, this.customChannelId = t.customChannelId, this.customMessageId = t.customMessageId, this.joinRunState = t.runState ?? "IDLE", this.isConnecting$ = new C(!1), this.runStatusSubject = new C(Q), this.conversation$ = new C(t.conversation), this.channelTitleSubject = new C(t.channelTitle ?? null), this.sandboxPhaseSubject = new C("idle"), this.launchedSandboxesSubject = new C(
|
|
2487
|
+
ve(t.launchedSandboxes ?? [])
|
|
2488
|
+
), this.derivedStores = xn(this.conversation$), this.tasks$ = this.derivedStores.tasks$, this.subagents$ = this.derivedStores.subagents$, this.channelTitle$ = this.channelTitleSubject.pipe(M()), this.sandboxPhase$ = this.sandboxPhaseSubject.pipe(M()), this.launchedSandboxes$ = this.launchedSandboxesSubject.pipe(M()), this.runStatus$ = this.runStatusSubject.pipe(M(On)), this.statesObserver = t.statesObserver;
|
|
2405
2489
|
}
|
|
2406
2490
|
/** Current Task Check List snapshot (F-013) — for framework-agnostic `getSnapshot()` bridging. */
|
|
2407
2491
|
getTasks() {
|
|
@@ -2423,6 +2507,10 @@ class K {
|
|
|
2423
2507
|
getLaunchedSandboxes() {
|
|
2424
2508
|
return this.launchedSandboxesSubject.value;
|
|
2425
2509
|
}
|
|
2510
|
+
/** Current run identity + stop lifecycle snapshot (F-023) — for framework-agnostic `getSnapshot()` bridging. */
|
|
2511
|
+
getRunStatus() {
|
|
2512
|
+
return this.runStatusSubject.value;
|
|
2513
|
+
}
|
|
2426
2514
|
/** Names hinted by `sandbox.launch` but not yet confirmed live by metadata (F-019) — "starting" placeholders. */
|
|
2427
2515
|
getPendingLaunches() {
|
|
2428
2516
|
return this.pendingLaunches;
|
|
@@ -2433,7 +2521,7 @@ class K {
|
|
|
2433
2521
|
* launch whose name now appears (promoted to live). metadata (heartbeat-backed) is the sole authority.
|
|
2434
2522
|
*/
|
|
2435
2523
|
applyLaunchedSandboxes(t) {
|
|
2436
|
-
const e =
|
|
2524
|
+
const e = ve(t);
|
|
2437
2525
|
this.pendingLaunches = this.pendingLaunches.filter((r) => !e.some((s) => s.sandboxName === r)), this.launchedSandboxesSubject.next(e);
|
|
2438
2526
|
}
|
|
2439
2527
|
/**
|
|
@@ -2494,24 +2582,37 @@ class K {
|
|
|
2494
2582
|
}
|
|
2495
2583
|
}
|
|
2496
2584
|
subscribe() {
|
|
2497
|
-
this.statesSubscription =
|
|
2585
|
+
this.statesSubscription = Wt([
|
|
2498
2586
|
this.isConnecting$,
|
|
2499
2587
|
this.conversation$,
|
|
2500
2588
|
this.derivedStores.tasks$,
|
|
2501
2589
|
this.derivedStores.subagents$,
|
|
2502
2590
|
this.channelTitle$,
|
|
2503
2591
|
this.sandboxPhase$,
|
|
2504
|
-
this.launchedSandboxes
|
|
2592
|
+
this.launchedSandboxes$,
|
|
2593
|
+
this.runStatus$
|
|
2505
2594
|
]).pipe(
|
|
2506
|
-
N(
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2595
|
+
N(
|
|
2596
|
+
([
|
|
2597
|
+
t,
|
|
2598
|
+
e,
|
|
2599
|
+
r,
|
|
2600
|
+
s,
|
|
2601
|
+
o,
|
|
2602
|
+
i,
|
|
2603
|
+
a,
|
|
2604
|
+
c
|
|
2605
|
+
]) => ({
|
|
2606
|
+
isConnecting: t,
|
|
2607
|
+
conversation: e,
|
|
2608
|
+
tasks: r,
|
|
2609
|
+
subagents: s,
|
|
2610
|
+
channelTitle: o,
|
|
2611
|
+
sandboxPhase: i,
|
|
2612
|
+
launchedSandboxes: a,
|
|
2613
|
+
runStatus: c
|
|
2614
|
+
})
|
|
2615
|
+
)
|
|
2515
2616
|
).subscribe(this.statesObserver);
|
|
2516
2617
|
}
|
|
2517
2618
|
/**
|
|
@@ -2535,14 +2636,14 @@ class K {
|
|
|
2535
2636
|
*/
|
|
2536
2637
|
updateSandboxPhase(t) {
|
|
2537
2638
|
switch (t) {
|
|
2538
|
-
case
|
|
2639
|
+
case l.SANDBOX_LAUNCH:
|
|
2539
2640
|
this.sandboxPhaseSubject.next("launching");
|
|
2540
2641
|
break;
|
|
2541
|
-
case
|
|
2642
|
+
case l.SANDBOX_READY:
|
|
2542
2643
|
this.sandboxPhaseSubject.next("ready");
|
|
2543
2644
|
break;
|
|
2544
|
-
case
|
|
2545
|
-
case
|
|
2645
|
+
case l.INIT:
|
|
2646
|
+
case l.ERROR:
|
|
2546
2647
|
this.sandboxPhaseSubject.next("idle");
|
|
2547
2648
|
break;
|
|
2548
2649
|
}
|
|
@@ -2556,9 +2657,9 @@ class K {
|
|
|
2556
2657
|
return {
|
|
2557
2658
|
onSseStart: t?.onSseStart,
|
|
2558
2659
|
onSseMessage: (s) => {
|
|
2559
|
-
if (t?.onSseMessage?.(s), s.eventType ===
|
|
2660
|
+
if (t?.onSseMessage?.(s), this.captureRequestId(s.requestId), s.eventType === l.CHANNEL_TITLE_UPDATE && this.channelTitleSubject.next(
|
|
2560
2661
|
s.fact.channelTitleUpdate.title
|
|
2561
|
-
), this.updateSandboxPhase(s.eventType), s.eventType ===
|
|
2662
|
+
), this.updateSandboxPhase(s.eventType), s.eventType === l.SANDBOX_LAUNCH && this.noteSandboxLaunch(s.fact.sandboxLaunch.sandboxName), this.currentUserMessageId && s.traceId) {
|
|
2562
2663
|
const o = new Map(this.conversation$.value.messages), i = o.get(this.currentUserMessageId);
|
|
2563
2664
|
i && i.type === "user" && (o.set(this.currentUserMessageId, {
|
|
2564
2665
|
...i,
|
|
@@ -2568,16 +2669,33 @@ class K {
|
|
|
2568
2669
|
this.conversation$.next(this.conversation$.value.onMessage(s));
|
|
2569
2670
|
},
|
|
2570
2671
|
onSseError: (s) => {
|
|
2571
|
-
t?.onSseError?.(s), this.
|
|
2672
|
+
t?.onSseError?.(s), this.settleRun(), r(s);
|
|
2572
2673
|
},
|
|
2573
2674
|
onSseCompleted: () => {
|
|
2574
|
-
t?.onSseCompleted?.(), this.
|
|
2675
|
+
t?.onSseCompleted?.(), this.settleRun(), e();
|
|
2575
2676
|
}
|
|
2576
2677
|
};
|
|
2577
2678
|
}
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2679
|
+
/**
|
|
2680
|
+
* The terminal of a run, whichever way it ended. For a stop in flight this is the moment the backend
|
|
2681
|
+
* declares the run actually finished (F-023 AC3) — the same event a normal run ends with — so it is
|
|
2682
|
+
* the only place `stopping` is released back to "waiting for input".
|
|
2683
|
+
*/
|
|
2684
|
+
settleRun() {
|
|
2685
|
+
const t = this.runStatusSubject.value.stopPhase !== "idle";
|
|
2686
|
+
this.clearForceStopTimer(), this.isConnecting$.next(!1), this.runStatusSubject.next(Q), this.currentUserMessageId = void 0, this.currentRun = void 0, t && this.conversation$.next(this.conversation$.value.settleInFlightMessages());
|
|
2687
|
+
}
|
|
2688
|
+
/** Record the backend run id from the first frame that carries one; later frames must not overwrite it. */
|
|
2689
|
+
captureRequestId(t) {
|
|
2690
|
+
const e = this.runStatusSubject.value;
|
|
2691
|
+
!t || e.requestId || !e.kind || this.runStatusSubject.next({ ...e, requestId: t });
|
|
2692
|
+
}
|
|
2693
|
+
clearForceStopTimer() {
|
|
2694
|
+
this.forceStopTimer && (clearTimeout(this.forceStopTimer), this.forceStopTimer = void 0);
|
|
2695
|
+
}
|
|
2696
|
+
fetchSse(t, e, r) {
|
|
2697
|
+
return new Promise((s, o) => {
|
|
2698
|
+
this.isConnecting$.next(!0), this.runStatusSubject.next({ kind: t, stopPhase: "idle" }), this.currentRun = this.client.fetchSse(e, this.buildRunHandlers(r, s, o));
|
|
2581
2699
|
});
|
|
2582
2700
|
}
|
|
2583
2701
|
/**
|
|
@@ -2592,11 +2710,15 @@ class K {
|
|
|
2592
2710
|
e();
|
|
2593
2711
|
return;
|
|
2594
2712
|
}
|
|
2595
|
-
this.isConnecting$.next(!0), this.
|
|
2713
|
+
this.isConnecting$.next(!0), this.runStatusSubject.next({
|
|
2714
|
+
kind: this.joinRunState === "RUNNING" ? "restore" : "replay",
|
|
2715
|
+
stopPhase: "idle"
|
|
2716
|
+
}), this.currentRun = this.client.rejoinSse(this.customChannelId, this.buildRunHandlers(t, e, r));
|
|
2596
2717
|
});
|
|
2597
2718
|
}
|
|
2598
2719
|
resetChannel(t, e) {
|
|
2599
2720
|
return this.fetchSse(
|
|
2721
|
+
"reset",
|
|
2600
2722
|
{
|
|
2601
2723
|
action: $.RESET_CHANNEL,
|
|
2602
2724
|
customChannelId: this.customChannelId,
|
|
@@ -2608,24 +2730,27 @@ class K {
|
|
|
2608
2730
|
);
|
|
2609
2731
|
}
|
|
2610
2732
|
sendMessage(t, e) {
|
|
2611
|
-
const r =
|
|
2612
|
-
|
|
2733
|
+
const r = this.runStatusSubject.value.kind;
|
|
2734
|
+
if (r) return Promise.reject(new ye(r));
|
|
2735
|
+
const s = t.text.trim(), o = t.customMessageId ?? Ge();
|
|
2736
|
+
return this.currentUserMessageId = o, this.lastSentMessageId = o, this.conversation$.next(
|
|
2613
2737
|
this.conversation$.value.pushMessage({
|
|
2614
2738
|
type: "user",
|
|
2615
|
-
messageId:
|
|
2616
|
-
text:
|
|
2739
|
+
messageId: o,
|
|
2740
|
+
text: s,
|
|
2617
2741
|
blobIds: t.blobIds,
|
|
2618
2742
|
filePreviewUrls: t.filePreviewUrls,
|
|
2619
2743
|
documentNames: t.documentNames,
|
|
2620
2744
|
time: /* @__PURE__ */ new Date()
|
|
2621
2745
|
})
|
|
2622
2746
|
), this.fetchSse(
|
|
2747
|
+
"user",
|
|
2623
2748
|
{
|
|
2624
2749
|
action: $.NONE,
|
|
2625
2750
|
customChannelId: this.customChannelId,
|
|
2626
|
-
customMessageId:
|
|
2751
|
+
customMessageId: o,
|
|
2627
2752
|
payload: this.resolvePayload(t?.payload),
|
|
2628
|
-
text:
|
|
2753
|
+
text: s,
|
|
2629
2754
|
blobIds: t?.blobIds
|
|
2630
2755
|
},
|
|
2631
2756
|
e
|
|
@@ -2633,6 +2758,7 @@ class K {
|
|
|
2633
2758
|
}
|
|
2634
2759
|
replyToolCallConsents(t, e, r) {
|
|
2635
2760
|
return this.conversation$.next(this.conversation$.value.clearPendingConsent()), this.fetchSse(
|
|
2761
|
+
"user",
|
|
2636
2762
|
{
|
|
2637
2763
|
action: $.RESPONSE_TOOL_CALL_CONSENT,
|
|
2638
2764
|
customChannelId: this.customChannelId,
|
|
@@ -2652,6 +2778,7 @@ class K {
|
|
|
2652
2778
|
*/
|
|
2653
2779
|
nudge(t) {
|
|
2654
2780
|
return this.fetchSse(
|
|
2781
|
+
"nudge",
|
|
2655
2782
|
{
|
|
2656
2783
|
action: $.NUDGE,
|
|
2657
2784
|
customChannelId: this.customChannelId,
|
|
@@ -2662,19 +2789,80 @@ class K {
|
|
|
2662
2789
|
);
|
|
2663
2790
|
}
|
|
2664
2791
|
/**
|
|
2665
|
-
* User-initiated stop-generation
|
|
2666
|
-
*
|
|
2667
|
-
*
|
|
2668
|
-
*
|
|
2792
|
+
* User-initiated stop-generation (F-023).
|
|
2793
|
+
*
|
|
2794
|
+
* Runs execute in the **background on the server**, so aborting the local SSE connection would only
|
|
2795
|
+
* stop *watching*: the agent would keep running, keep spending tokens and keep writing the
|
|
2796
|
+
* transcript. Instead this asks the backend to suspend the run and **keeps the stream open**, because
|
|
2797
|
+
* the stop is declared by that stream's terminal event — the same event a normal run ends with.
|
|
2798
|
+
*
|
|
2799
|
+
* The call is therefore asynchronous in two stages:
|
|
2800
|
+
* 1. resolving here means the backend **accepted** the request, not that the run has stopped;
|
|
2801
|
+
* 2. `isConnecting` / `runStatus` only return to idle when the terminal event arrives (AC3).
|
|
2802
|
+
*
|
|
2803
|
+
* While waiting, `runStatus.stopPhase` is `stopping` and every send entrance must stay gated (AC5).
|
|
2804
|
+
* If the terminal event has not arrived within {@link FORCE_STOP_TIMEOUT_MS} the phase becomes
|
|
2805
|
+
* `force-stoppable`, and calling again with `{ force: true }` tells the backend to give up on the run
|
|
2806
|
+
* rather than let it wind down (AC7).
|
|
2807
|
+
*
|
|
2808
|
+
* No-ops (resolving) when nothing is running, when the run is not the user's own — a `RESET_CHANNEL`
|
|
2809
|
+
* welcome, a transcript replay or an invisible nudge must never be stopped (AC8) — or when a stop is
|
|
2810
|
+
* already pending and this is not a force.
|
|
2811
|
+
*
|
|
2812
|
+
* **Rejects** when the suspend request fails (network error, or a non-2xx that is not `404`). The
|
|
2813
|
+
* stop phase is rolled back to `idle` first, so the caller can retry and the UI can never be stuck in
|
|
2814
|
+
* `stopping` (AC4).
|
|
2815
|
+
*
|
|
2816
|
+
* A client that predates the suspend endpoint (a custom `IAsgardServiceClient`) falls back to the old
|
|
2817
|
+
* local-abort behavior, so existing integrations keep working.
|
|
2818
|
+
*/
|
|
2819
|
+
async stopGeneration(t) {
|
|
2820
|
+
const e = this.runStatusSubject.value;
|
|
2821
|
+
if (!(!this.currentRun || e.kind !== "user") && !(e.stopPhase !== "idle" && !t?.force)) {
|
|
2822
|
+
if (!this.client.suspendChannel) {
|
|
2823
|
+
this.abortConnection();
|
|
2824
|
+
return;
|
|
2825
|
+
}
|
|
2826
|
+
this.clearForceStopTimer(), this.runStatusSubject.next({ ...e, stopPhase: "stopping" });
|
|
2827
|
+
try {
|
|
2828
|
+
await this.client.suspendChannel(this.customChannelId, {
|
|
2829
|
+
requestId: e.requestId,
|
|
2830
|
+
force: t?.force
|
|
2831
|
+
});
|
|
2832
|
+
} catch (r) {
|
|
2833
|
+
throw this.clearForceStopTimer(), this.runStatusSubject.next({ ...this.runStatusSubject.value, stopPhase: "idle" }), r;
|
|
2834
|
+
}
|
|
2835
|
+
this.armForceStopTimer();
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
/**
|
|
2839
|
+
* Escalate to `force-stoppable` once an accepted stop has waited too long for the terminal event
|
|
2840
|
+
* (F-023 AC7 / UC-044) — the escape hatch for an agent that never winds down. Re-armed on a force
|
|
2841
|
+
* retry, so a second timeout offers the same way out again.
|
|
2842
|
+
*/
|
|
2843
|
+
armForceStopTimer() {
|
|
2844
|
+
this.clearForceStopTimer(), this.forceStopTimer = setTimeout(() => {
|
|
2845
|
+
this.forceStopTimer = void 0;
|
|
2846
|
+
const t = this.runStatusSubject.value;
|
|
2847
|
+
t.stopPhase === "stopping" && this.runStatusSubject.next({ ...t, stopPhase: "force-stoppable" });
|
|
2848
|
+
}, Cn);
|
|
2849
|
+
}
|
|
2850
|
+
/**
|
|
2851
|
+
* Cut the local SSE connection without telling the backend. This is *not* stop-generation (see
|
|
2852
|
+
* {@link stopGeneration}) — the server-side run keeps going. Used when there is nothing to stop
|
|
2853
|
+
* remotely: a client without suspend support, and channel teardown.
|
|
2854
|
+
*
|
|
2855
|
+
* The deliberate abort must never be read as a transport failure — `create-sse-observable` marks the
|
|
2856
|
+
* stream disposed so no reconnect is attempted (F-023 AC10).
|
|
2669
2857
|
*/
|
|
2670
|
-
|
|
2671
|
-
this.currentRun && (this.currentRun.unsubscribe(), this.currentRun = void 0, this.isConnecting$.next(!1), this.currentUserMessageId = void 0, this.conversation$.next(this.conversation$.value.
|
|
2858
|
+
abortConnection() {
|
|
2859
|
+
this.currentRun && (this.currentRun.unsubscribe(), this.clearForceStopTimer(), this.currentRun = void 0, this.isConnecting$.next(!1), this.runStatusSubject.next(Q), this.currentUserMessageId = void 0, this.conversation$.next(this.conversation$.value.settleInFlightMessages()));
|
|
2672
2860
|
}
|
|
2673
2861
|
close() {
|
|
2674
|
-
this.currentRun?.unsubscribe(), this.currentRun = void 0, this.isConnecting$.complete(), this.conversation$.complete(), this.channelTitleSubject.complete(), this.sandboxPhaseSubject.complete(), this.launchedSandboxesSubject.complete(), this.derivedStores.teardown(), this.statesSubscription?.unsubscribe();
|
|
2862
|
+
this.currentRun?.unsubscribe(), this.currentRun = void 0, this.clearForceStopTimer(), this.isConnecting$.complete(), this.runStatusSubject.complete(), this.conversation$.complete(), this.channelTitleSubject.complete(), this.sandboxPhaseSubject.complete(), this.launchedSandboxesSubject.complete(), this.derivedStores.teardown(), this.statesSubscription?.unsubscribe();
|
|
2675
2863
|
}
|
|
2676
2864
|
}
|
|
2677
|
-
function
|
|
2865
|
+
function Ln(n) {
|
|
2678
2866
|
const t = /^sandbox:\/\/([^/]+)\/([^?#]+)(?:\?([^#]*))?/.exec(n.trim());
|
|
2679
2867
|
if (!t) return null;
|
|
2680
2868
|
const e = decodeURIComponent(t[1]), r = t[2], s = new URLSearchParams(t[3] ?? "");
|
|
@@ -2686,27 +2874,29 @@ function Cn(n) {
|
|
|
2686
2874
|
return null;
|
|
2687
2875
|
}
|
|
2688
2876
|
export {
|
|
2689
|
-
|
|
2877
|
+
_n as AsgardServiceClient,
|
|
2690
2878
|
K as Channel,
|
|
2879
|
+
ye as ChannelBusyError,
|
|
2691
2880
|
v as Conversation,
|
|
2692
|
-
|
|
2881
|
+
l as EventType,
|
|
2693
2882
|
$ as FetchSseAction,
|
|
2694
2883
|
w as HttpError,
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2884
|
+
We as MessageTemplateType,
|
|
2885
|
+
Ye as ToolCallConsentResult,
|
|
2886
|
+
yn as conversationToSubagentEvents,
|
|
2887
|
+
xn as createDerivedStores,
|
|
2888
|
+
wn as deriveSubagents,
|
|
2889
|
+
Sn as deriveTasks,
|
|
2890
|
+
mn as isAgentTool,
|
|
2891
|
+
Pn as isChannelBusyError,
|
|
2892
|
+
An as isHttpError,
|
|
2893
|
+
gn as isSubagentChildTool,
|
|
2894
|
+
fn as isTaskTool,
|
|
2895
|
+
ve as reconcileLaunched,
|
|
2896
|
+
bn as reduceSubagents,
|
|
2897
|
+
pn as reduceTaskEvents,
|
|
2898
|
+
Ln as resolveSandboxUri,
|
|
2899
|
+
Tn as subagentsEqual,
|
|
2900
|
+
En as tasksEqual
|
|
2711
2901
|
};
|
|
2712
2902
|
//# sourceMappingURL=index.mjs.map
|