@asgard-js/core 0.3.26 → 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 +687 -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/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -16,20 +16,30 @@ class w extends Error {
|
|
|
16
16
|
super(`HTTP ${t}: ${e}`), this.name = "HttpError", this.status = t, this.statusText = e, this.body = r;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function An(n) {
|
|
20
20
|
return n instanceof w;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
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) {
|
|
24
34
|
const e = n.getReader();
|
|
25
35
|
let r;
|
|
26
36
|
for (; !(r = await e.read()).done; )
|
|
27
37
|
t(r.value);
|
|
28
38
|
}
|
|
29
|
-
function
|
|
39
|
+
function Ve(n) {
|
|
30
40
|
let t, e, r, s = !1;
|
|
31
41
|
return function(i) {
|
|
32
|
-
t === void 0 ? (t = i, e = 0, r = -1) : t =
|
|
42
|
+
t === void 0 ? (t = i, e = 0, r = -1) : t = Je(t, i);
|
|
33
43
|
const a = t.length;
|
|
34
44
|
let c = 0;
|
|
35
45
|
for (; e < a; ) {
|
|
@@ -53,12 +63,12 @@ function Xe(n) {
|
|
|
53
63
|
c === a ? t = void 0 : c !== 0 && (t = t.subarray(c), e -= c);
|
|
54
64
|
};
|
|
55
65
|
}
|
|
56
|
-
function
|
|
57
|
-
let r =
|
|
66
|
+
function ze(n, t, e) {
|
|
67
|
+
let r = ae();
|
|
58
68
|
const s = new TextDecoder();
|
|
59
69
|
return function(i, a) {
|
|
60
70
|
if (i.length === 0)
|
|
61
|
-
e?.(r), r =
|
|
71
|
+
e?.(r), r = ae();
|
|
62
72
|
else if (a > 0) {
|
|
63
73
|
const c = s.decode(i.subarray(0, a)), u = a + (i[a + 1] === 32 ? 2 : 1), h = s.decode(i.subarray(u));
|
|
64
74
|
switch (c) {
|
|
@@ -80,11 +90,11 @@ function Ve(n, t, e) {
|
|
|
80
90
|
}
|
|
81
91
|
};
|
|
82
92
|
}
|
|
83
|
-
function
|
|
93
|
+
function Je(n, t) {
|
|
84
94
|
const e = new Uint8Array(n.length + t.length);
|
|
85
95
|
return e.set(n), e.set(t, n.length), e;
|
|
86
96
|
}
|
|
87
|
-
function
|
|
97
|
+
function ae() {
|
|
88
98
|
return {
|
|
89
99
|
data: "",
|
|
90
100
|
event: "",
|
|
@@ -92,7 +102,7 @@ function ie() {
|
|
|
92
102
|
retry: void 0
|
|
93
103
|
};
|
|
94
104
|
}
|
|
95
|
-
var
|
|
105
|
+
var Qe = function(n, t) {
|
|
96
106
|
var e = {};
|
|
97
107
|
for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && t.indexOf(r) < 0 && (e[r] = n[r]);
|
|
98
108
|
if (n != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -100,70 +110,70 @@ var ze = function(n, t) {
|
|
|
100
110
|
t.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[s]) && (e[r[s]] = n[r[s]]);
|
|
101
111
|
return e;
|
|
102
112
|
};
|
|
103
|
-
const
|
|
104
|
-
function
|
|
105
|
-
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"]);
|
|
106
116
|
return new Promise((m, b) => {
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
let
|
|
110
|
-
function
|
|
111
|
-
|
|
117
|
+
const d = Object.assign({}, r);
|
|
118
|
+
d.accept || (d.accept = Z);
|
|
119
|
+
let p;
|
|
120
|
+
function f() {
|
|
121
|
+
p.abort(), document.hidden || X();
|
|
112
122
|
}
|
|
113
|
-
c || document.addEventListener("visibilitychange",
|
|
114
|
-
let
|
|
115
|
-
function
|
|
116
|
-
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();
|
|
117
127
|
}
|
|
118
128
|
e?.addEventListener("abort", () => {
|
|
119
|
-
|
|
129
|
+
L(), m();
|
|
120
130
|
});
|
|
121
|
-
const
|
|
122
|
-
async function
|
|
123
|
-
var
|
|
124
|
-
|
|
131
|
+
const Ke = u ?? window.fetch, qe = s ?? et;
|
|
132
|
+
async function X() {
|
|
133
|
+
var V;
|
|
134
|
+
p = new AbortController();
|
|
125
135
|
try {
|
|
126
|
-
const
|
|
127
|
-
await
|
|
128
|
-
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];
|
|
129
139
|
}, (x) => {
|
|
130
|
-
|
|
131
|
-
}, o))), i?.(),
|
|
132
|
-
} catch (
|
|
133
|
-
if (!
|
|
140
|
+
_ = x;
|
|
141
|
+
}, o))), i?.(), L(), m();
|
|
142
|
+
} catch (H) {
|
|
143
|
+
if (!p.signal.aborted)
|
|
134
144
|
try {
|
|
135
|
-
const x = (
|
|
136
|
-
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);
|
|
137
147
|
} catch (x) {
|
|
138
|
-
|
|
148
|
+
L(), b(x);
|
|
139
149
|
}
|
|
140
150
|
}
|
|
141
151
|
}
|
|
142
|
-
|
|
152
|
+
X();
|
|
143
153
|
});
|
|
144
154
|
}
|
|
145
|
-
function
|
|
155
|
+
function et(n) {
|
|
146
156
|
const t = n.headers.get("content-type");
|
|
147
|
-
if (!t?.startsWith(
|
|
148
|
-
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}`);
|
|
149
159
|
}
|
|
150
|
-
var
|
|
151
|
-
return
|
|
160
|
+
var ee = function(n, t) {
|
|
161
|
+
return ee = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
|
|
152
162
|
e.__proto__ = r;
|
|
153
163
|
} || function(e, r) {
|
|
154
164
|
for (var s in r) Object.prototype.hasOwnProperty.call(r, s) && (e[s] = r[s]);
|
|
155
|
-
},
|
|
165
|
+
}, ee(n, t);
|
|
156
166
|
};
|
|
157
167
|
function T(n, t) {
|
|
158
168
|
if (typeof t != "function" && t !== null)
|
|
159
169
|
throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
|
|
160
|
-
|
|
170
|
+
ee(n, t);
|
|
161
171
|
function e() {
|
|
162
172
|
this.constructor = n;
|
|
163
173
|
}
|
|
164
174
|
n.prototype = t === null ? Object.create(t) : (e.prototype = t.prototype, new e());
|
|
165
175
|
}
|
|
166
|
-
function
|
|
176
|
+
function tt(n, t, e, r) {
|
|
167
177
|
function s(o) {
|
|
168
178
|
return o instanceof e ? o : new e(function(i) {
|
|
169
179
|
i(o);
|
|
@@ -190,7 +200,7 @@ function Ze(n, t, e, r) {
|
|
|
190
200
|
u((r = r.apply(n, t || [])).next());
|
|
191
201
|
});
|
|
192
202
|
}
|
|
193
|
-
function
|
|
203
|
+
function we(n, t) {
|
|
194
204
|
var e = { label: 0, sent: function() {
|
|
195
205
|
if (o[0] & 1) throw o[1];
|
|
196
206
|
return o[1];
|
|
@@ -250,7 +260,7 @@ function ye(n, t) {
|
|
|
250
260
|
return { value: u[0] ? u[1] : void 0, done: !0 };
|
|
251
261
|
}
|
|
252
262
|
}
|
|
253
|
-
function
|
|
263
|
+
function R(n) {
|
|
254
264
|
var t = typeof Symbol == "function" && Symbol.iterator, e = t && n[t], r = 0;
|
|
255
265
|
if (e) return e.call(n);
|
|
256
266
|
if (n && typeof n.length == "number") return {
|
|
@@ -277,56 +287,56 @@ function D(n, t) {
|
|
|
277
287
|
}
|
|
278
288
|
return o;
|
|
279
289
|
}
|
|
280
|
-
function
|
|
290
|
+
function F(n, t, e) {
|
|
281
291
|
if (e || arguments.length === 2) for (var r = 0, s = t.length, o; r < s; r++)
|
|
282
292
|
(o || !(r in t)) && (o || (o = Array.prototype.slice.call(t, 0, r)), o[r] = t[r]);
|
|
283
293
|
return n.concat(o || Array.prototype.slice.call(t));
|
|
284
294
|
}
|
|
285
|
-
function
|
|
286
|
-
return this instanceof
|
|
295
|
+
function k(n) {
|
|
296
|
+
return this instanceof k ? (this.v = n, this) : new k(n);
|
|
287
297
|
}
|
|
288
|
-
function
|
|
298
|
+
function nt(n, t, e) {
|
|
289
299
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
290
300
|
var r = e.apply(n, t || []), s, o = [];
|
|
291
301
|
return s = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), a("next"), a("throw"), a("return", i), s[Symbol.asyncIterator] = function() {
|
|
292
302
|
return this;
|
|
293
303
|
}, s;
|
|
294
|
-
function i(
|
|
295
|
-
return function(
|
|
296
|
-
return Promise.resolve(
|
|
304
|
+
function i(d) {
|
|
305
|
+
return function(p) {
|
|
306
|
+
return Promise.resolve(p).then(d, m);
|
|
297
307
|
};
|
|
298
308
|
}
|
|
299
|
-
function a(
|
|
300
|
-
r[
|
|
301
|
-
return new Promise(function(
|
|
302
|
-
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);
|
|
303
313
|
});
|
|
304
|
-
},
|
|
314
|
+
}, p && (s[d] = p(s[d])));
|
|
305
315
|
}
|
|
306
|
-
function c(
|
|
316
|
+
function c(d, p) {
|
|
307
317
|
try {
|
|
308
|
-
u(r[
|
|
309
|
-
} catch (
|
|
310
|
-
b(o[0][3],
|
|
318
|
+
u(r[d](p));
|
|
319
|
+
} catch (f) {
|
|
320
|
+
b(o[0][3], f);
|
|
311
321
|
}
|
|
312
322
|
}
|
|
313
|
-
function u(
|
|
314
|
-
|
|
323
|
+
function u(d) {
|
|
324
|
+
d.value instanceof k ? Promise.resolve(d.value.v).then(h, m) : b(o[0][2], d);
|
|
315
325
|
}
|
|
316
|
-
function h(
|
|
317
|
-
c("next",
|
|
326
|
+
function h(d) {
|
|
327
|
+
c("next", d);
|
|
318
328
|
}
|
|
319
|
-
function m(
|
|
320
|
-
c("throw",
|
|
329
|
+
function m(d) {
|
|
330
|
+
c("throw", d);
|
|
321
331
|
}
|
|
322
|
-
function b(
|
|
323
|
-
|
|
332
|
+
function b(d, p) {
|
|
333
|
+
d(p), o.shift(), o.length && c(o[0][0], o[0][1]);
|
|
324
334
|
}
|
|
325
335
|
}
|
|
326
|
-
function
|
|
336
|
+
function rt(n) {
|
|
327
337
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
328
338
|
var t = n[Symbol.asyncIterator], e;
|
|
329
|
-
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() {
|
|
330
340
|
return this;
|
|
331
341
|
}, e);
|
|
332
342
|
function r(o) {
|
|
@@ -345,13 +355,13 @@ function tt(n) {
|
|
|
345
355
|
function g(n) {
|
|
346
356
|
return typeof n == "function";
|
|
347
357
|
}
|
|
348
|
-
function
|
|
358
|
+
function Ee(n) {
|
|
349
359
|
var t = function(r) {
|
|
350
360
|
Error.call(r), r.stack = new Error().stack;
|
|
351
361
|
}, e = n(t);
|
|
352
362
|
return e.prototype = Object.create(Error.prototype), e.prototype.constructor = e, e;
|
|
353
363
|
}
|
|
354
|
-
var z =
|
|
364
|
+
var z = Ee(function(n) {
|
|
355
365
|
return function(e) {
|
|
356
366
|
n(this), this.message = e ? e.length + ` errors occurred during unsubscription:
|
|
357
367
|
` + e.map(function(r, s) {
|
|
@@ -366,7 +376,7 @@ function q(n, t) {
|
|
|
366
376
|
0 <= e && n.splice(e, 1);
|
|
367
377
|
}
|
|
368
378
|
}
|
|
369
|
-
var
|
|
379
|
+
var j = (function() {
|
|
370
380
|
function n(t) {
|
|
371
381
|
this.initialTeardown = t, this.closed = !1, this._parentage = null, this._finalizers = null;
|
|
372
382
|
}
|
|
@@ -378,12 +388,12 @@ var R = (function() {
|
|
|
378
388
|
if (i)
|
|
379
389
|
if (this._parentage = null, Array.isArray(i))
|
|
380
390
|
try {
|
|
381
|
-
for (var a =
|
|
391
|
+
for (var a = R(i), c = a.next(); !c.done; c = a.next()) {
|
|
382
392
|
var u = c.value;
|
|
383
393
|
u.remove(this);
|
|
384
394
|
}
|
|
385
|
-
} catch (
|
|
386
|
-
t = { error:
|
|
395
|
+
} catch (f) {
|
|
396
|
+
t = { error: f };
|
|
387
397
|
} finally {
|
|
388
398
|
try {
|
|
389
399
|
c && !c.done && (e = a.return) && e.call(a);
|
|
@@ -397,26 +407,26 @@ var R = (function() {
|
|
|
397
407
|
if (g(h))
|
|
398
408
|
try {
|
|
399
409
|
h();
|
|
400
|
-
} catch (
|
|
401
|
-
o =
|
|
410
|
+
} catch (f) {
|
|
411
|
+
o = f instanceof z ? f.errors : [f];
|
|
402
412
|
}
|
|
403
413
|
var m = this._finalizers;
|
|
404
414
|
if (m) {
|
|
405
415
|
this._finalizers = null;
|
|
406
416
|
try {
|
|
407
|
-
for (var b =
|
|
408
|
-
var
|
|
417
|
+
for (var b = R(m), d = b.next(); !d.done; d = b.next()) {
|
|
418
|
+
var p = d.value;
|
|
409
419
|
try {
|
|
410
|
-
|
|
411
|
-
} catch (
|
|
412
|
-
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);
|
|
413
423
|
}
|
|
414
424
|
}
|
|
415
|
-
} catch (
|
|
416
|
-
r = { error:
|
|
425
|
+
} catch (f) {
|
|
426
|
+
r = { error: f };
|
|
417
427
|
} finally {
|
|
418
428
|
try {
|
|
419
|
-
|
|
429
|
+
d && !d.done && (s = b.return) && s.call(b);
|
|
420
430
|
} finally {
|
|
421
431
|
if (r) throw r.error;
|
|
422
432
|
}
|
|
@@ -429,7 +439,7 @@ var R = (function() {
|
|
|
429
439
|
var e;
|
|
430
440
|
if (t && t !== this)
|
|
431
441
|
if (this.closed)
|
|
432
|
-
|
|
442
|
+
ue(t);
|
|
433
443
|
else {
|
|
434
444
|
if (t instanceof n) {
|
|
435
445
|
if (t.closed || t._hasParent(this))
|
|
@@ -454,44 +464,44 @@ var R = (function() {
|
|
|
454
464
|
var t = new n();
|
|
455
465
|
return t.closed = !0, t;
|
|
456
466
|
})(), n;
|
|
457
|
-
})(),
|
|
458
|
-
function
|
|
459
|
-
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);
|
|
460
470
|
}
|
|
461
|
-
function
|
|
471
|
+
function ue(n) {
|
|
462
472
|
g(n) ? n() : n.unsubscribe();
|
|
463
473
|
}
|
|
464
|
-
var
|
|
474
|
+
var st = {
|
|
465
475
|
Promise: void 0
|
|
466
|
-
},
|
|
476
|
+
}, ot = {
|
|
467
477
|
setTimeout: function(n, t) {
|
|
468
478
|
for (var e = [], r = 2; r < arguments.length; r++)
|
|
469
479
|
e[r - 2] = arguments[r];
|
|
470
|
-
return setTimeout.apply(void 0,
|
|
480
|
+
return setTimeout.apply(void 0, F([n, t], D(e)));
|
|
471
481
|
},
|
|
472
482
|
clearTimeout: function(n) {
|
|
473
483
|
return clearTimeout(n);
|
|
474
484
|
},
|
|
475
485
|
delegate: void 0
|
|
476
486
|
};
|
|
477
|
-
function
|
|
478
|
-
|
|
487
|
+
function xe(n) {
|
|
488
|
+
ot.setTimeout(function() {
|
|
479
489
|
throw n;
|
|
480
490
|
});
|
|
481
491
|
}
|
|
482
|
-
function
|
|
492
|
+
function te() {
|
|
483
493
|
}
|
|
484
|
-
function
|
|
494
|
+
function G(n) {
|
|
485
495
|
n();
|
|
486
496
|
}
|
|
487
|
-
var
|
|
497
|
+
var re = (function(n) {
|
|
488
498
|
T(t, n);
|
|
489
499
|
function t(e) {
|
|
490
500
|
var r = n.call(this) || this;
|
|
491
|
-
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;
|
|
492
502
|
}
|
|
493
503
|
return t.create = function(e, r, s) {
|
|
494
|
-
return new
|
|
504
|
+
return new ne(e, r, s);
|
|
495
505
|
}, t.prototype.next = function(e) {
|
|
496
506
|
this.isStopped || this._next(e);
|
|
497
507
|
}, t.prototype.error = function(e) {
|
|
@@ -515,7 +525,7 @@ var ne = (function(n) {
|
|
|
515
525
|
this.unsubscribe();
|
|
516
526
|
}
|
|
517
527
|
}, t;
|
|
518
|
-
})(
|
|
528
|
+
})(j), it = (function() {
|
|
519
529
|
function n(t) {
|
|
520
530
|
this.partialObserver = t;
|
|
521
531
|
}
|
|
@@ -525,7 +535,7 @@ var ne = (function(n) {
|
|
|
525
535
|
try {
|
|
526
536
|
e.next(t);
|
|
527
537
|
} catch (r) {
|
|
528
|
-
|
|
538
|
+
B(r);
|
|
529
539
|
}
|
|
530
540
|
}, n.prototype.error = function(t) {
|
|
531
541
|
var e = this.partialObserver;
|
|
@@ -533,20 +543,20 @@ var ne = (function(n) {
|
|
|
533
543
|
try {
|
|
534
544
|
e.error(t);
|
|
535
545
|
} catch (r) {
|
|
536
|
-
|
|
546
|
+
B(r);
|
|
537
547
|
}
|
|
538
548
|
else
|
|
539
|
-
|
|
549
|
+
B(t);
|
|
540
550
|
}, n.prototype.complete = function() {
|
|
541
551
|
var t = this.partialObserver;
|
|
542
552
|
if (t.complete)
|
|
543
553
|
try {
|
|
544
554
|
t.complete();
|
|
545
555
|
} catch (e) {
|
|
546
|
-
|
|
556
|
+
B(e);
|
|
547
557
|
}
|
|
548
558
|
}, n;
|
|
549
|
-
})(),
|
|
559
|
+
})(), ne = (function(n) {
|
|
550
560
|
T(t, n);
|
|
551
561
|
function t(e, r, s) {
|
|
552
562
|
var o = n.call(this) || this, i;
|
|
@@ -554,29 +564,29 @@ var ne = (function(n) {
|
|
|
554
564
|
next: e ?? void 0,
|
|
555
565
|
error: r ?? void 0,
|
|
556
566
|
complete: s ?? void 0
|
|
557
|
-
} : i = e, o.destination = new
|
|
567
|
+
} : i = e, o.destination = new it(i), o;
|
|
558
568
|
}
|
|
559
569
|
return t;
|
|
560
|
-
})(
|
|
561
|
-
function
|
|
562
|
-
|
|
570
|
+
})(re);
|
|
571
|
+
function B(n) {
|
|
572
|
+
xe(n);
|
|
563
573
|
}
|
|
564
|
-
function
|
|
574
|
+
function at(n) {
|
|
565
575
|
throw n;
|
|
566
576
|
}
|
|
567
|
-
var
|
|
577
|
+
var ct = {
|
|
568
578
|
closed: !0,
|
|
569
|
-
next:
|
|
570
|
-
error:
|
|
571
|
-
complete:
|
|
572
|
-
},
|
|
579
|
+
next: te,
|
|
580
|
+
error: at,
|
|
581
|
+
complete: te
|
|
582
|
+
}, se = (function() {
|
|
573
583
|
return typeof Symbol == "function" && Symbol.observable || "@@observable";
|
|
574
584
|
})();
|
|
575
|
-
function
|
|
585
|
+
function W(n) {
|
|
576
586
|
return n;
|
|
577
587
|
}
|
|
578
|
-
function
|
|
579
|
-
return n.length === 0 ?
|
|
588
|
+
function ut(n) {
|
|
589
|
+
return n.length === 0 ? W : n.length === 1 ? n[0] : function(e) {
|
|
580
590
|
return n.reduce(function(r, s) {
|
|
581
591
|
return s(r);
|
|
582
592
|
}, e);
|
|
@@ -590,8 +600,8 @@ var S = (function() {
|
|
|
590
600
|
var e = new n();
|
|
591
601
|
return e.source = this, e.operator = t, e;
|
|
592
602
|
}, n.prototype.subscribe = function(t, e, r) {
|
|
593
|
-
var s = this, o =
|
|
594
|
-
return
|
|
603
|
+
var s = this, o = dt(t) ? t : new ne(t, e, r);
|
|
604
|
+
return G(function() {
|
|
595
605
|
var i = s, a = i.operator, c = i.source;
|
|
596
606
|
o.add(a ? a.call(o, c) : c ? s._subscribe(o) : s._trySubscribe(o));
|
|
597
607
|
}), o;
|
|
@@ -603,8 +613,8 @@ var S = (function() {
|
|
|
603
613
|
}
|
|
604
614
|
}, n.prototype.forEach = function(t, e) {
|
|
605
615
|
var r = this;
|
|
606
|
-
return e =
|
|
607
|
-
var i = new
|
|
616
|
+
return e = le(e), new e(function(s, o) {
|
|
617
|
+
var i = new ne({
|
|
608
618
|
next: function(a) {
|
|
609
619
|
try {
|
|
610
620
|
t(a);
|
|
@@ -620,15 +630,15 @@ var S = (function() {
|
|
|
620
630
|
}, n.prototype._subscribe = function(t) {
|
|
621
631
|
var e;
|
|
622
632
|
return (e = this.source) === null || e === void 0 ? void 0 : e.subscribe(t);
|
|
623
|
-
}, n.prototype[
|
|
633
|
+
}, n.prototype[se] = function() {
|
|
624
634
|
return this;
|
|
625
635
|
}, n.prototype.pipe = function() {
|
|
626
636
|
for (var t = [], e = 0; e < arguments.length; e++)
|
|
627
637
|
t[e] = arguments[e];
|
|
628
|
-
return
|
|
638
|
+
return ut(t)(this);
|
|
629
639
|
}, n.prototype.toPromise = function(t) {
|
|
630
640
|
var e = this;
|
|
631
|
-
return t =
|
|
641
|
+
return t = le(t), new t(function(r, s) {
|
|
632
642
|
var o;
|
|
633
643
|
e.subscribe(function(i) {
|
|
634
644
|
return o = i;
|
|
@@ -642,22 +652,22 @@ var S = (function() {
|
|
|
642
652
|
return new n(t);
|
|
643
653
|
}, n;
|
|
644
654
|
})();
|
|
645
|
-
function
|
|
655
|
+
function le(n) {
|
|
646
656
|
var t;
|
|
647
|
-
return (t = n ??
|
|
657
|
+
return (t = n ?? st.Promise) !== null && t !== void 0 ? t : Promise;
|
|
648
658
|
}
|
|
649
|
-
function
|
|
659
|
+
function lt(n) {
|
|
650
660
|
return n && g(n.next) && g(n.error) && g(n.complete);
|
|
651
661
|
}
|
|
652
|
-
function
|
|
653
|
-
return n && n instanceof
|
|
662
|
+
function dt(n) {
|
|
663
|
+
return n && n instanceof re || lt(n) && Te(n);
|
|
654
664
|
}
|
|
655
|
-
function
|
|
665
|
+
function ht(n) {
|
|
656
666
|
return g(n?.lift);
|
|
657
667
|
}
|
|
658
|
-
function
|
|
668
|
+
function P(n) {
|
|
659
669
|
return function(t) {
|
|
660
|
-
if (
|
|
670
|
+
if (ht(t))
|
|
661
671
|
return t.lift(function(e) {
|
|
662
672
|
try {
|
|
663
673
|
return n(e, this);
|
|
@@ -668,10 +678,10 @@ function A(n) {
|
|
|
668
678
|
throw new TypeError("Unable to lift unknown Observable type");
|
|
669
679
|
};
|
|
670
680
|
}
|
|
671
|
-
function
|
|
672
|
-
return new
|
|
681
|
+
function A(n, t, e, r, s) {
|
|
682
|
+
return new ft(n, t, e, r, s);
|
|
673
683
|
}
|
|
674
|
-
var
|
|
684
|
+
var ft = (function(n) {
|
|
675
685
|
T(t, n);
|
|
676
686
|
function t(e, r, s, o, i, a) {
|
|
677
687
|
var c = n.call(this, e) || this;
|
|
@@ -706,30 +716,30 @@ var dt = (function(n) {
|
|
|
706
716
|
n.prototype.unsubscribe.call(this), !r && ((e = this.onFinalize) === null || e === void 0 || e.call(this));
|
|
707
717
|
}
|
|
708
718
|
}, t;
|
|
709
|
-
})(
|
|
719
|
+
})(re), pt = Ee(function(n) {
|
|
710
720
|
return function() {
|
|
711
721
|
n(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
|
|
712
722
|
};
|
|
713
|
-
}),
|
|
723
|
+
}), oe = (function(n) {
|
|
714
724
|
T(t, n);
|
|
715
725
|
function t() {
|
|
716
726
|
var e = n.call(this) || this;
|
|
717
727
|
return e.closed = !1, e.currentObservers = null, e.observers = [], e.isStopped = !1, e.hasError = !1, e.thrownError = null, e;
|
|
718
728
|
}
|
|
719
729
|
return t.prototype.lift = function(e) {
|
|
720
|
-
var r = new
|
|
730
|
+
var r = new de(this, this);
|
|
721
731
|
return r.operator = e, r;
|
|
722
732
|
}, t.prototype._throwIfClosed = function() {
|
|
723
733
|
if (this.closed)
|
|
724
|
-
throw new
|
|
734
|
+
throw new pt();
|
|
725
735
|
}, t.prototype.next = function(e) {
|
|
726
736
|
var r = this;
|
|
727
|
-
|
|
737
|
+
G(function() {
|
|
728
738
|
var s, o;
|
|
729
739
|
if (r._throwIfClosed(), !r.isStopped) {
|
|
730
740
|
r.currentObservers || (r.currentObservers = Array.from(r.observers));
|
|
731
741
|
try {
|
|
732
|
-
for (var i =
|
|
742
|
+
for (var i = R(r.currentObservers), a = i.next(); !a.done; a = i.next()) {
|
|
733
743
|
var c = a.value;
|
|
734
744
|
c.next(e);
|
|
735
745
|
}
|
|
@@ -746,7 +756,7 @@ var dt = (function(n) {
|
|
|
746
756
|
});
|
|
747
757
|
}, t.prototype.error = function(e) {
|
|
748
758
|
var r = this;
|
|
749
|
-
|
|
759
|
+
G(function() {
|
|
750
760
|
if (r._throwIfClosed(), !r.isStopped) {
|
|
751
761
|
r.hasError = r.isStopped = !0, r.thrownError = e;
|
|
752
762
|
for (var s = r.observers; s.length; )
|
|
@@ -755,7 +765,7 @@ var dt = (function(n) {
|
|
|
755
765
|
});
|
|
756
766
|
}, t.prototype.complete = function() {
|
|
757
767
|
var e = this;
|
|
758
|
-
|
|
768
|
+
G(function() {
|
|
759
769
|
if (e._throwIfClosed(), !e.isStopped) {
|
|
760
770
|
e.isStopped = !0;
|
|
761
771
|
for (var r = e.observers; r.length; )
|
|
@@ -777,7 +787,7 @@ var dt = (function(n) {
|
|
|
777
787
|
return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
|
|
778
788
|
}, t.prototype._innerSubscribe = function(e) {
|
|
779
789
|
var r = this, s = this, o = s.hasError, i = s.isStopped, a = s.observers;
|
|
780
|
-
return o || i ?
|
|
790
|
+
return o || i ? Ie : (this.currentObservers = null, a.push(e), new j(function() {
|
|
781
791
|
r.currentObservers = null, q(a, e);
|
|
782
792
|
}));
|
|
783
793
|
}, t.prototype._checkFinalizedStatuses = function(e) {
|
|
@@ -787,9 +797,9 @@ var dt = (function(n) {
|
|
|
787
797
|
var e = new S();
|
|
788
798
|
return e.source = this, e;
|
|
789
799
|
}, t.create = function(e, r) {
|
|
790
|
-
return new
|
|
800
|
+
return new de(e, r);
|
|
791
801
|
}, t;
|
|
792
|
-
})(S),
|
|
802
|
+
})(S), de = (function(n) {
|
|
793
803
|
T(t, n);
|
|
794
804
|
function t(e, r) {
|
|
795
805
|
var s = n.call(this) || this;
|
|
@@ -806,9 +816,9 @@ var dt = (function(n) {
|
|
|
806
816
|
(r = (e = this.destination) === null || e === void 0 ? void 0 : e.complete) === null || r === void 0 || r.call(e);
|
|
807
817
|
}, t.prototype._subscribe = function(e) {
|
|
808
818
|
var r, s;
|
|
809
|
-
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;
|
|
810
820
|
}, t;
|
|
811
|
-
})(
|
|
821
|
+
})(oe), C = (function(n) {
|
|
812
822
|
T(t, n);
|
|
813
823
|
function t(e) {
|
|
814
824
|
var r = n.call(this) || this;
|
|
@@ -831,11 +841,11 @@ var dt = (function(n) {
|
|
|
831
841
|
}, t.prototype.next = function(e) {
|
|
832
842
|
n.prototype.next.call(this, this._value = e);
|
|
833
843
|
}, t;
|
|
834
|
-
})(
|
|
844
|
+
})(oe), mt = {
|
|
835
845
|
now: function() {
|
|
836
846
|
return Date.now();
|
|
837
847
|
}
|
|
838
|
-
},
|
|
848
|
+
}, gt = (function(n) {
|
|
839
849
|
T(t, n);
|
|
840
850
|
function t(e, r) {
|
|
841
851
|
return n.call(this) || this;
|
|
@@ -843,17 +853,17 @@ var dt = (function(n) {
|
|
|
843
853
|
return t.prototype.schedule = function(e, r) {
|
|
844
854
|
return this;
|
|
845
855
|
}, t;
|
|
846
|
-
})(
|
|
856
|
+
})(j), he = {
|
|
847
857
|
setInterval: function(n, t) {
|
|
848
858
|
for (var e = [], r = 2; r < arguments.length; r++)
|
|
849
859
|
e[r - 2] = arguments[r];
|
|
850
|
-
return setInterval.apply(void 0,
|
|
860
|
+
return setInterval.apply(void 0, F([n, t], D(e)));
|
|
851
861
|
},
|
|
852
862
|
clearInterval: function(n) {
|
|
853
863
|
return clearInterval(n);
|
|
854
864
|
},
|
|
855
865
|
delegate: void 0
|
|
856
|
-
},
|
|
866
|
+
}, bt = (function(n) {
|
|
857
867
|
T(t, n);
|
|
858
868
|
function t(e, r) {
|
|
859
869
|
var s = n.call(this, e, r) || this;
|
|
@@ -867,11 +877,11 @@ var dt = (function(n) {
|
|
|
867
877
|
var o = this.id, i = this.scheduler;
|
|
868
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;
|
|
869
879
|
}, t.prototype.requestAsyncId = function(e, r, s) {
|
|
870
|
-
return s === void 0 && (s = 0),
|
|
880
|
+
return s === void 0 && (s = 0), he.setInterval(e.flush.bind(e, this), s);
|
|
871
881
|
}, t.prototype.recycleAsyncId = function(e, r, s) {
|
|
872
882
|
if (s === void 0 && (s = 0), s != null && this.delay === s && this.pending === !1)
|
|
873
883
|
return r;
|
|
874
|
-
r != null &&
|
|
884
|
+
r != null && he.clearInterval(r);
|
|
875
885
|
}, t.prototype.execute = function(e, r) {
|
|
876
886
|
if (this.closed)
|
|
877
887
|
return new Error("executing a cancelled action");
|
|
@@ -895,17 +905,17 @@ var dt = (function(n) {
|
|
|
895
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);
|
|
896
906
|
}
|
|
897
907
|
}, t;
|
|
898
|
-
})(
|
|
908
|
+
})(gt), fe = (function() {
|
|
899
909
|
function n(t, e) {
|
|
900
910
|
e === void 0 && (e = n.now), this.schedulerActionCtor = t, this.now = e;
|
|
901
911
|
}
|
|
902
912
|
return n.prototype.schedule = function(t, e, r) {
|
|
903
913
|
return e === void 0 && (e = 0), new this.schedulerActionCtor(this, t).schedule(r, e);
|
|
904
|
-
}, n.now =
|
|
905
|
-
})(),
|
|
914
|
+
}, n.now = mt.now, n;
|
|
915
|
+
})(), vt = (function(n) {
|
|
906
916
|
T(t, n);
|
|
907
917
|
function t(e, r) {
|
|
908
|
-
r === void 0 && (r =
|
|
918
|
+
r === void 0 && (r = fe.now);
|
|
909
919
|
var s = n.call(this, e, r) || this;
|
|
910
920
|
return s.actions = [], s._active = !1, s;
|
|
911
921
|
}
|
|
@@ -927,60 +937,60 @@ var dt = (function(n) {
|
|
|
927
937
|
throw s;
|
|
928
938
|
}
|
|
929
939
|
}, t;
|
|
930
|
-
})(
|
|
940
|
+
})(fe), Ce = new vt(bt), yt = Ce, St = new S(function(n) {
|
|
931
941
|
return n.complete();
|
|
932
942
|
});
|
|
933
|
-
function
|
|
943
|
+
function Oe(n) {
|
|
934
944
|
return n && g(n.schedule);
|
|
935
945
|
}
|
|
936
|
-
function
|
|
946
|
+
function Ae(n) {
|
|
937
947
|
return n[n.length - 1];
|
|
938
948
|
}
|
|
939
|
-
function
|
|
940
|
-
return g(
|
|
949
|
+
function wt(n) {
|
|
950
|
+
return g(Ae(n)) ? n.pop() : void 0;
|
|
941
951
|
}
|
|
942
|
-
function
|
|
943
|
-
return
|
|
952
|
+
function Pe(n) {
|
|
953
|
+
return Oe(Ae(n)) ? n.pop() : void 0;
|
|
944
954
|
}
|
|
945
|
-
var
|
|
955
|
+
var _e = (function(n) {
|
|
946
956
|
return n && typeof n.length == "number" && typeof n != "function";
|
|
947
957
|
});
|
|
948
958
|
function Le(n) {
|
|
949
959
|
return g(n?.then);
|
|
950
960
|
}
|
|
951
|
-
function
|
|
952
|
-
return g(n[
|
|
961
|
+
function Ue(n) {
|
|
962
|
+
return g(n[se]);
|
|
953
963
|
}
|
|
954
|
-
function
|
|
964
|
+
function Me(n) {
|
|
955
965
|
return Symbol.asyncIterator && g(n?.[Symbol.asyncIterator]);
|
|
956
966
|
}
|
|
957
|
-
function
|
|
967
|
+
function ke(n) {
|
|
958
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.");
|
|
959
969
|
}
|
|
960
|
-
function
|
|
970
|
+
function Et() {
|
|
961
971
|
return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
|
|
962
972
|
}
|
|
963
|
-
var
|
|
964
|
-
function ke(n) {
|
|
965
|
-
return g(n?.[Me]);
|
|
966
|
-
}
|
|
973
|
+
var Re = Et();
|
|
967
974
|
function Ne(n) {
|
|
968
|
-
return
|
|
975
|
+
return g(n?.[Re]);
|
|
976
|
+
}
|
|
977
|
+
function je(n) {
|
|
978
|
+
return nt(this, arguments, function() {
|
|
969
979
|
var e, r, s, o;
|
|
970
|
-
return
|
|
980
|
+
return we(this, function(i) {
|
|
971
981
|
switch (i.label) {
|
|
972
982
|
case 0:
|
|
973
983
|
e = n.getReader(), i.label = 1;
|
|
974
984
|
case 1:
|
|
975
985
|
i.trys.push([1, , 9, 10]), i.label = 2;
|
|
976
986
|
case 2:
|
|
977
|
-
return [4,
|
|
987
|
+
return [4, k(e.read())];
|
|
978
988
|
case 3:
|
|
979
|
-
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];
|
|
980
990
|
case 4:
|
|
981
991
|
return [2, i.sent()];
|
|
982
992
|
case 5:
|
|
983
|
-
return [4,
|
|
993
|
+
return [4, k(s)];
|
|
984
994
|
case 6:
|
|
985
995
|
return [4, i.sent()];
|
|
986
996
|
case 7:
|
|
@@ -995,57 +1005,57 @@ function Ne(n) {
|
|
|
995
1005
|
});
|
|
996
1006
|
});
|
|
997
1007
|
}
|
|
998
|
-
function
|
|
1008
|
+
function $e(n) {
|
|
999
1009
|
return g(n?.getReader);
|
|
1000
1010
|
}
|
|
1001
1011
|
function U(n) {
|
|
1002
1012
|
if (n instanceof S)
|
|
1003
1013
|
return n;
|
|
1004
1014
|
if (n != null) {
|
|
1005
|
-
if (
|
|
1006
|
-
return wt(n);
|
|
1007
|
-
if (Ae(n))
|
|
1008
|
-
return Et(n);
|
|
1009
|
-
if (Le(n))
|
|
1015
|
+
if (Ue(n))
|
|
1010
1016
|
return It(n);
|
|
1011
|
-
if (
|
|
1012
|
-
return $e(n);
|
|
1013
|
-
if (ke(n))
|
|
1017
|
+
if (_e(n))
|
|
1014
1018
|
return Tt(n);
|
|
1015
|
-
if (
|
|
1019
|
+
if (Le(n))
|
|
1016
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);
|
|
1017
1027
|
}
|
|
1018
|
-
throw
|
|
1028
|
+
throw ke(n);
|
|
1019
1029
|
}
|
|
1020
|
-
function
|
|
1030
|
+
function It(n) {
|
|
1021
1031
|
return new S(function(t) {
|
|
1022
|
-
var e = n[
|
|
1032
|
+
var e = n[se]();
|
|
1023
1033
|
if (g(e.subscribe))
|
|
1024
1034
|
return e.subscribe(t);
|
|
1025
1035
|
throw new TypeError("Provided object does not correctly implement Symbol.observable");
|
|
1026
1036
|
});
|
|
1027
1037
|
}
|
|
1028
|
-
function
|
|
1038
|
+
function Tt(n) {
|
|
1029
1039
|
return new S(function(t) {
|
|
1030
1040
|
for (var e = 0; e < n.length && !t.closed; e++)
|
|
1031
1041
|
t.next(n[e]);
|
|
1032
1042
|
t.complete();
|
|
1033
1043
|
});
|
|
1034
1044
|
}
|
|
1035
|
-
function
|
|
1045
|
+
function xt(n) {
|
|
1036
1046
|
return new S(function(t) {
|
|
1037
1047
|
n.then(function(e) {
|
|
1038
1048
|
t.closed || (t.next(e), t.complete());
|
|
1039
1049
|
}, function(e) {
|
|
1040
1050
|
return t.error(e);
|
|
1041
|
-
}).then(null,
|
|
1051
|
+
}).then(null, xe);
|
|
1042
1052
|
});
|
|
1043
1053
|
}
|
|
1044
|
-
function
|
|
1054
|
+
function Ct(n) {
|
|
1045
1055
|
return new S(function(t) {
|
|
1046
1056
|
var e, r;
|
|
1047
1057
|
try {
|
|
1048
|
-
for (var s =
|
|
1058
|
+
for (var s = R(n), o = s.next(); !o.done; o = s.next()) {
|
|
1049
1059
|
var i = o.value;
|
|
1050
1060
|
if (t.next(i), t.closed)
|
|
1051
1061
|
return;
|
|
@@ -1062,24 +1072,24 @@ function Tt(n) {
|
|
|
1062
1072
|
t.complete();
|
|
1063
1073
|
});
|
|
1064
1074
|
}
|
|
1065
|
-
function
|
|
1075
|
+
function De(n) {
|
|
1066
1076
|
return new S(function(t) {
|
|
1067
|
-
|
|
1077
|
+
At(n, t).catch(function(e) {
|
|
1068
1078
|
return t.error(e);
|
|
1069
1079
|
});
|
|
1070
1080
|
});
|
|
1071
1081
|
}
|
|
1072
|
-
function
|
|
1073
|
-
return
|
|
1082
|
+
function Ot(n) {
|
|
1083
|
+
return De(je(n));
|
|
1074
1084
|
}
|
|
1075
|
-
function
|
|
1085
|
+
function At(n, t) {
|
|
1076
1086
|
var e, r, s, o;
|
|
1077
|
-
return
|
|
1087
|
+
return tt(this, void 0, void 0, function() {
|
|
1078
1088
|
var i, a;
|
|
1079
|
-
return
|
|
1089
|
+
return we(this, function(c) {
|
|
1080
1090
|
switch (c.label) {
|
|
1081
1091
|
case 0:
|
|
1082
|
-
c.trys.push([0, 5, 6, 11]), e =
|
|
1092
|
+
c.trys.push([0, 5, 6, 11]), e = rt(n), c.label = 1;
|
|
1083
1093
|
case 1:
|
|
1084
1094
|
return [4, e.next()];
|
|
1085
1095
|
case 2:
|
|
@@ -1110,7 +1120,7 @@ function Ct(n, t) {
|
|
|
1110
1120
|
});
|
|
1111
1121
|
});
|
|
1112
1122
|
}
|
|
1113
|
-
function
|
|
1123
|
+
function O(n, t, e, r, s) {
|
|
1114
1124
|
r === void 0 && (r = 0), s === void 0 && (s = !1);
|
|
1115
1125
|
var o = t.schedule(function() {
|
|
1116
1126
|
e(), s ? n.add(this.schedule(null, r)) : this.unsubscribe();
|
|
@@ -1118,35 +1128,35 @@ function C(n, t, e, r, s) {
|
|
|
1118
1128
|
if (n.add(o), !s)
|
|
1119
1129
|
return o;
|
|
1120
1130
|
}
|
|
1121
|
-
function
|
|
1122
|
-
return t === void 0 && (t = 0),
|
|
1123
|
-
e.subscribe(
|
|
1124
|
-
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() {
|
|
1125
1135
|
return r.next(s);
|
|
1126
1136
|
}, t);
|
|
1127
1137
|
}, function() {
|
|
1128
|
-
return
|
|
1138
|
+
return O(r, n, function() {
|
|
1129
1139
|
return r.complete();
|
|
1130
1140
|
}, t);
|
|
1131
1141
|
}, function(s) {
|
|
1132
|
-
return
|
|
1142
|
+
return O(r, n, function() {
|
|
1133
1143
|
return r.error(s);
|
|
1134
1144
|
}, t);
|
|
1135
1145
|
}));
|
|
1136
1146
|
});
|
|
1137
1147
|
}
|
|
1138
|
-
function
|
|
1139
|
-
return t === void 0 && (t = 0),
|
|
1148
|
+
function He(n, t) {
|
|
1149
|
+
return t === void 0 && (t = 0), P(function(e, r) {
|
|
1140
1150
|
r.add(n.schedule(function() {
|
|
1141
1151
|
return e.subscribe(r);
|
|
1142
1152
|
}, t));
|
|
1143
1153
|
});
|
|
1144
1154
|
}
|
|
1145
|
-
function
|
|
1146
|
-
return U(n).pipe(
|
|
1155
|
+
function Pt(n, t) {
|
|
1156
|
+
return U(n).pipe(He(t), Fe(t));
|
|
1147
1157
|
}
|
|
1148
|
-
function
|
|
1149
|
-
return U(n).pipe(
|
|
1158
|
+
function _t(n, t) {
|
|
1159
|
+
return U(n).pipe(He(t), Fe(t));
|
|
1150
1160
|
}
|
|
1151
1161
|
function Lt(n, t) {
|
|
1152
1162
|
return new S(function(e) {
|
|
@@ -1156,11 +1166,11 @@ function Lt(n, t) {
|
|
|
1156
1166
|
});
|
|
1157
1167
|
});
|
|
1158
1168
|
}
|
|
1159
|
-
function
|
|
1169
|
+
function Ut(n, t) {
|
|
1160
1170
|
return new S(function(e) {
|
|
1161
1171
|
var r;
|
|
1162
|
-
return
|
|
1163
|
-
r = n[
|
|
1172
|
+
return O(e, t, function() {
|
|
1173
|
+
r = n[Re](), O(e, t, function() {
|
|
1164
1174
|
var s, o, i;
|
|
1165
1175
|
try {
|
|
1166
1176
|
s = r.next(), o = s.value, i = s.done;
|
|
@@ -1175,13 +1185,13 @@ function _t(n, t) {
|
|
|
1175
1185
|
};
|
|
1176
1186
|
});
|
|
1177
1187
|
}
|
|
1178
|
-
function
|
|
1188
|
+
function Be(n, t) {
|
|
1179
1189
|
if (!n)
|
|
1180
1190
|
throw new Error("Iterable cannot be null");
|
|
1181
1191
|
return new S(function(e) {
|
|
1182
|
-
|
|
1192
|
+
O(e, t, function() {
|
|
1183
1193
|
var r = n[Symbol.asyncIterator]();
|
|
1184
|
-
|
|
1194
|
+
O(e, t, function() {
|
|
1185
1195
|
r.next().then(function(s) {
|
|
1186
1196
|
s.done ? e.complete() : e.next(s.value);
|
|
1187
1197
|
});
|
|
@@ -1189,63 +1199,63 @@ function He(n, t) {
|
|
|
1189
1199
|
});
|
|
1190
1200
|
});
|
|
1191
1201
|
}
|
|
1192
|
-
function
|
|
1193
|
-
return
|
|
1202
|
+
function Mt(n, t) {
|
|
1203
|
+
return Be(je(n), t);
|
|
1194
1204
|
}
|
|
1195
|
-
function
|
|
1205
|
+
function kt(n, t) {
|
|
1196
1206
|
if (n != null) {
|
|
1207
|
+
if (Ue(n))
|
|
1208
|
+
return Pt(n, t);
|
|
1197
1209
|
if (_e(n))
|
|
1198
|
-
return Ot(n, t);
|
|
1199
|
-
if (Ae(n))
|
|
1200
1210
|
return Lt(n, t);
|
|
1201
1211
|
if (Le(n))
|
|
1202
|
-
return At(n, t);
|
|
1203
|
-
if (Pe(n))
|
|
1204
|
-
return He(n, t);
|
|
1205
|
-
if (ke(n))
|
|
1206
1212
|
return _t(n, t);
|
|
1207
|
-
if (
|
|
1208
|
-
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);
|
|
1209
1219
|
}
|
|
1210
|
-
throw
|
|
1220
|
+
throw ke(n);
|
|
1211
1221
|
}
|
|
1212
|
-
function
|
|
1213
|
-
return t ?
|
|
1222
|
+
function ie(n, t) {
|
|
1223
|
+
return t ? kt(n, t) : U(n);
|
|
1214
1224
|
}
|
|
1215
|
-
function
|
|
1225
|
+
function Rt() {
|
|
1216
1226
|
for (var n = [], t = 0; t < arguments.length; t++)
|
|
1217
1227
|
n[t] = arguments[t];
|
|
1218
|
-
var e =
|
|
1219
|
-
return
|
|
1228
|
+
var e = Pe(n);
|
|
1229
|
+
return ie(n, e);
|
|
1220
1230
|
}
|
|
1221
|
-
function
|
|
1231
|
+
function Nt(n) {
|
|
1222
1232
|
return n instanceof Date && !isNaN(n);
|
|
1223
1233
|
}
|
|
1224
1234
|
function N(n, t) {
|
|
1225
|
-
return
|
|
1235
|
+
return P(function(e, r) {
|
|
1226
1236
|
var s = 0;
|
|
1227
|
-
e.subscribe(
|
|
1237
|
+
e.subscribe(A(r, function(o) {
|
|
1228
1238
|
r.next(n.call(t, o, s++));
|
|
1229
1239
|
}));
|
|
1230
1240
|
});
|
|
1231
1241
|
}
|
|
1232
|
-
var
|
|
1233
|
-
function
|
|
1234
|
-
return
|
|
1242
|
+
var jt = Array.isArray;
|
|
1243
|
+
function $t(n, t) {
|
|
1244
|
+
return jt(t) ? n.apply(void 0, F([], D(t))) : n(t);
|
|
1235
1245
|
}
|
|
1236
|
-
function
|
|
1246
|
+
function Dt(n) {
|
|
1237
1247
|
return N(function(t) {
|
|
1238
|
-
return
|
|
1248
|
+
return $t(n, t);
|
|
1239
1249
|
});
|
|
1240
1250
|
}
|
|
1241
|
-
var
|
|
1242
|
-
function
|
|
1251
|
+
var Ft = Array.isArray, Ht = Object.getPrototypeOf, Bt = Object.prototype, Gt = Object.keys;
|
|
1252
|
+
function Kt(n) {
|
|
1243
1253
|
if (n.length === 1) {
|
|
1244
1254
|
var t = n[0];
|
|
1245
|
-
if (
|
|
1255
|
+
if (Ft(t))
|
|
1246
1256
|
return { args: t, keys: null };
|
|
1247
|
-
if (
|
|
1248
|
-
var e =
|
|
1257
|
+
if (qt(t)) {
|
|
1258
|
+
var e = Gt(t);
|
|
1249
1259
|
return {
|
|
1250
1260
|
args: e.map(function(r) {
|
|
1251
1261
|
return t[r];
|
|
@@ -1256,33 +1266,33 @@ function Gt(n) {
|
|
|
1256
1266
|
}
|
|
1257
1267
|
return { args: n, keys: null };
|
|
1258
1268
|
}
|
|
1259
|
-
function
|
|
1260
|
-
return n && typeof n == "object" &&
|
|
1269
|
+
function qt(n) {
|
|
1270
|
+
return n && typeof n == "object" && Ht(n) === Bt;
|
|
1261
1271
|
}
|
|
1262
|
-
function
|
|
1272
|
+
function Yt(n, t) {
|
|
1263
1273
|
return n.reduce(function(e, r, s) {
|
|
1264
1274
|
return e[r] = t[s], e;
|
|
1265
1275
|
}, {});
|
|
1266
1276
|
}
|
|
1267
|
-
function
|
|
1277
|
+
function Wt() {
|
|
1268
1278
|
for (var n = [], t = 0; t < arguments.length; t++)
|
|
1269
1279
|
n[t] = arguments[t];
|
|
1270
|
-
var e =
|
|
1280
|
+
var e = Pe(n), r = wt(n), s = Kt(n), o = s.args, i = s.keys;
|
|
1271
1281
|
if (o.length === 0)
|
|
1272
|
-
return
|
|
1273
|
-
var a = new S(
|
|
1274
|
-
return
|
|
1275
|
-
} :
|
|
1276
|
-
return r ? a.pipe(
|
|
1277
|
-
}
|
|
1278
|
-
function
|
|
1279
|
-
return e === void 0 && (e =
|
|
1280
|
-
|
|
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() {
|
|
1281
1291
|
for (var s = n.length, o = new Array(s), i = s, a = s, c = function(h) {
|
|
1282
|
-
|
|
1283
|
-
var m =
|
|
1284
|
-
m.subscribe(
|
|
1285
|
-
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()));
|
|
1286
1296
|
}, function() {
|
|
1287
1297
|
--i || r.complete();
|
|
1288
1298
|
}));
|
|
@@ -1292,37 +1302,37 @@ function Yt(n, t, e) {
|
|
|
1292
1302
|
}, r);
|
|
1293
1303
|
};
|
|
1294
1304
|
}
|
|
1295
|
-
function
|
|
1296
|
-
n ?
|
|
1305
|
+
function pe(n, t, e) {
|
|
1306
|
+
n ? O(e, n, t) : t();
|
|
1297
1307
|
}
|
|
1298
|
-
function
|
|
1308
|
+
function Vt(n, t, e, r, s, o, i, a) {
|
|
1299
1309
|
var c = [], u = 0, h = 0, m = !1, b = function() {
|
|
1300
1310
|
m && !c.length && !u && t.complete();
|
|
1301
|
-
},
|
|
1302
|
-
return u < r ? f
|
|
1303
|
-
},
|
|
1311
|
+
}, d = function(f) {
|
|
1312
|
+
return u < r ? p(f) : c.push(f);
|
|
1313
|
+
}, p = function(f) {
|
|
1304
1314
|
u++;
|
|
1305
|
-
var
|
|
1306
|
-
U(e(
|
|
1315
|
+
var _ = !1;
|
|
1316
|
+
U(e(f, h++)).subscribe(A(t, function(E) {
|
|
1307
1317
|
t.next(E);
|
|
1308
1318
|
}, function() {
|
|
1309
|
-
|
|
1319
|
+
_ = !0;
|
|
1310
1320
|
}, void 0, function() {
|
|
1311
|
-
if (
|
|
1321
|
+
if (_)
|
|
1312
1322
|
try {
|
|
1313
1323
|
u--;
|
|
1314
1324
|
for (var E = function() {
|
|
1315
|
-
var
|
|
1316
|
-
i ||
|
|
1325
|
+
var L = c.shift();
|
|
1326
|
+
i || p(L);
|
|
1317
1327
|
}; c.length && u < r; )
|
|
1318
1328
|
E();
|
|
1319
1329
|
b();
|
|
1320
|
-
} catch (
|
|
1321
|
-
t.error(
|
|
1330
|
+
} catch (L) {
|
|
1331
|
+
t.error(L);
|
|
1322
1332
|
}
|
|
1323
1333
|
}));
|
|
1324
1334
|
};
|
|
1325
|
-
return n.subscribe(
|
|
1335
|
+
return n.subscribe(A(t, d, function() {
|
|
1326
1336
|
m = !0, b();
|
|
1327
1337
|
})), function() {
|
|
1328
1338
|
};
|
|
@@ -1332,15 +1342,15 @@ function Y(n, t, e) {
|
|
|
1332
1342
|
return N(function(o, i) {
|
|
1333
1343
|
return t(r, o, s, i);
|
|
1334
1344
|
})(U(n(r, s)));
|
|
1335
|
-
}, e) : (typeof t == "number" && (e = t),
|
|
1336
|
-
return
|
|
1345
|
+
}, e) : (typeof t == "number" && (e = t), P(function(r, s) {
|
|
1346
|
+
return Vt(r, s, n, e);
|
|
1337
1347
|
}));
|
|
1338
1348
|
}
|
|
1339
|
-
function
|
|
1340
|
-
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);
|
|
1341
1351
|
var r = -1;
|
|
1342
|
-
return t != null && (
|
|
1343
|
-
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;
|
|
1344
1354
|
o < 0 && (o = 0);
|
|
1345
1355
|
var i = 0;
|
|
1346
1356
|
return e.schedule(function() {
|
|
@@ -1348,50 +1358,50 @@ function Vt(n, t, e) {
|
|
|
1348
1358
|
}, o);
|
|
1349
1359
|
});
|
|
1350
1360
|
}
|
|
1351
|
-
function
|
|
1361
|
+
function Jt(n, t) {
|
|
1352
1362
|
return g(t) ? Y(n, t, 1) : Y(n, 1);
|
|
1353
1363
|
}
|
|
1354
|
-
function
|
|
1364
|
+
function Qt(n) {
|
|
1355
1365
|
return n <= 0 ? function() {
|
|
1356
|
-
return
|
|
1357
|
-
} :
|
|
1366
|
+
return St;
|
|
1367
|
+
} : P(function(t, e) {
|
|
1358
1368
|
var r = 0;
|
|
1359
|
-
t.subscribe(
|
|
1369
|
+
t.subscribe(A(e, function(s) {
|
|
1360
1370
|
++r <= n && (e.next(s), n <= r && e.complete());
|
|
1361
1371
|
}));
|
|
1362
1372
|
});
|
|
1363
1373
|
}
|
|
1364
|
-
function
|
|
1374
|
+
function Zt(n) {
|
|
1365
1375
|
return N(function() {
|
|
1366
1376
|
return n;
|
|
1367
1377
|
});
|
|
1368
1378
|
}
|
|
1369
|
-
function
|
|
1379
|
+
function en(n, t) {
|
|
1370
1380
|
return Y(function(e, r) {
|
|
1371
|
-
return U(n(e, r)).pipe(
|
|
1381
|
+
return U(n(e, r)).pipe(Qt(1), Zt(e));
|
|
1372
1382
|
});
|
|
1373
1383
|
}
|
|
1374
|
-
function
|
|
1375
|
-
t === void 0 && (t =
|
|
1376
|
-
var e =
|
|
1377
|
-
return
|
|
1384
|
+
function tn(n, t) {
|
|
1385
|
+
t === void 0 && (t = Ce);
|
|
1386
|
+
var e = zt(n, t);
|
|
1387
|
+
return en(function() {
|
|
1378
1388
|
return e;
|
|
1379
1389
|
});
|
|
1380
1390
|
}
|
|
1381
|
-
function
|
|
1382
|
-
return t === void 0 && (t =
|
|
1391
|
+
function M(n, t) {
|
|
1392
|
+
return t === void 0 && (t = W), n = n ?? nn, P(function(e, r) {
|
|
1383
1393
|
var s, o = !0;
|
|
1384
|
-
e.subscribe(
|
|
1394
|
+
e.subscribe(A(r, function(i) {
|
|
1385
1395
|
var a = t(i);
|
|
1386
1396
|
(o || !n(s, a)) && (o = !1, s = a, r.next(i));
|
|
1387
1397
|
}));
|
|
1388
1398
|
});
|
|
1389
1399
|
}
|
|
1390
|
-
function
|
|
1400
|
+
function nn(n, t) {
|
|
1391
1401
|
return n === t;
|
|
1392
1402
|
}
|
|
1393
|
-
function
|
|
1394
|
-
return
|
|
1403
|
+
function rn(n) {
|
|
1404
|
+
return P(function(t, e) {
|
|
1395
1405
|
try {
|
|
1396
1406
|
t.subscribe(e);
|
|
1397
1407
|
} finally {
|
|
@@ -1399,27 +1409,27 @@ function tn(n) {
|
|
|
1399
1409
|
}
|
|
1400
1410
|
});
|
|
1401
1411
|
}
|
|
1402
|
-
function
|
|
1403
|
-
return
|
|
1404
|
-
U(n).subscribe(
|
|
1412
|
+
function sn(n) {
|
|
1413
|
+
return P(function(t, e) {
|
|
1414
|
+
U(n).subscribe(A(e, function() {
|
|
1405
1415
|
return e.complete();
|
|
1406
|
-
},
|
|
1416
|
+
}, te)), !e.closed && t.subscribe(e);
|
|
1407
1417
|
});
|
|
1408
1418
|
}
|
|
1409
|
-
function
|
|
1419
|
+
function me(n) {
|
|
1410
1420
|
const { endpoint: t, apiKey: e, payload: r, debugMode: s, customHeaders: o } = n, i = n.method ?? "POST";
|
|
1411
1421
|
return new S((a) => {
|
|
1412
1422
|
const c = new AbortController();
|
|
1413
|
-
let u, h = !1;
|
|
1414
|
-
const
|
|
1423
|
+
let u, h = !1, m = !1;
|
|
1424
|
+
const b = {
|
|
1415
1425
|
"Content-Type": "application/json",
|
|
1416
1426
|
...o
|
|
1417
1427
|
};
|
|
1418
|
-
e && (
|
|
1419
|
-
const
|
|
1420
|
-
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(), {
|
|
1421
1431
|
method: i,
|
|
1422
|
-
headers:
|
|
1432
|
+
headers: b,
|
|
1423
1433
|
body: i === "POST" && r ? JSON.stringify(r) : void 0,
|
|
1424
1434
|
signal: c.signal,
|
|
1425
1435
|
/**
|
|
@@ -1427,41 +1437,42 @@ function pe(n) {
|
|
|
1427
1437
|
* https://github.com/Azure/fetch-event-source/issues/17#issuecomment-1525904929
|
|
1428
1438
|
*/
|
|
1429
1439
|
openWhenHidden: !0,
|
|
1430
|
-
onopen: async (
|
|
1431
|
-
if (
|
|
1432
|
-
u =
|
|
1440
|
+
onopen: async (p) => {
|
|
1441
|
+
if (p.ok)
|
|
1442
|
+
u = p.headers.get("X-Trace-Id") ?? void 0;
|
|
1433
1443
|
else {
|
|
1434
1444
|
let f;
|
|
1435
1445
|
try {
|
|
1436
|
-
f = await
|
|
1446
|
+
f = await p.json();
|
|
1437
1447
|
} catch {
|
|
1438
1448
|
try {
|
|
1439
|
-
f = await
|
|
1449
|
+
f = await p.text();
|
|
1440
1450
|
} catch {
|
|
1441
1451
|
f = null;
|
|
1442
1452
|
}
|
|
1443
1453
|
}
|
|
1444
|
-
a.error(new w(
|
|
1454
|
+
a.error(new w(p.status, p.statusText, f)), c.abort();
|
|
1445
1455
|
}
|
|
1446
1456
|
},
|
|
1447
|
-
onmessage: (
|
|
1448
|
-
|
|
1449
|
-
const f = JSON.parse(
|
|
1457
|
+
onmessage: (p) => {
|
|
1458
|
+
p.id && (h = !0);
|
|
1459
|
+
const f = JSON.parse(p.data);
|
|
1450
1460
|
u ? f.traceId = u : f.requestId && (f.traceId = f.requestId, u || (u = f.requestId)), a.next(f);
|
|
1451
1461
|
},
|
|
1452
1462
|
onclose: () => {
|
|
1453
1463
|
a.complete();
|
|
1454
1464
|
},
|
|
1455
|
-
onerror: (
|
|
1465
|
+
onerror: (p) => {
|
|
1466
|
+
if (m) throw p;
|
|
1456
1467
|
if (!h)
|
|
1457
|
-
throw a.error(
|
|
1468
|
+
throw a.error(p), c.abort(), p;
|
|
1458
1469
|
}
|
|
1459
1470
|
}), () => {
|
|
1460
|
-
c.abort();
|
|
1471
|
+
m = !0, c.abort();
|
|
1461
1472
|
};
|
|
1462
1473
|
});
|
|
1463
1474
|
}
|
|
1464
|
-
class
|
|
1475
|
+
class on {
|
|
1465
1476
|
listeners = {};
|
|
1466
1477
|
on(t, e) {
|
|
1467
1478
|
this.listeners = Object.assign({}, this.listeners, {
|
|
@@ -1480,17 +1491,17 @@ class rn {
|
|
|
1480
1491
|
this.listeners[t] && this.listeners[t].forEach((r) => r(...e));
|
|
1481
1492
|
}
|
|
1482
1493
|
}
|
|
1483
|
-
class
|
|
1494
|
+
class _n {
|
|
1484
1495
|
apiKey;
|
|
1485
1496
|
endpoint;
|
|
1486
1497
|
botProviderEndpoint;
|
|
1487
1498
|
debugMode;
|
|
1488
|
-
destroy$ = new
|
|
1499
|
+
destroy$ = new oe();
|
|
1489
1500
|
closed = !1;
|
|
1490
1501
|
detached = !1;
|
|
1491
1502
|
detachTimer;
|
|
1492
1503
|
inFlight = 0;
|
|
1493
|
-
sseEmitter = new
|
|
1504
|
+
sseEmitter = new on();
|
|
1494
1505
|
transformSsePayload;
|
|
1495
1506
|
customHeaders;
|
|
1496
1507
|
constructor(t) {
|
|
@@ -1511,39 +1522,39 @@ class xn {
|
|
|
1511
1522
|
}
|
|
1512
1523
|
handleEvent(t) {
|
|
1513
1524
|
switch (t.eventType) {
|
|
1514
|
-
case
|
|
1515
|
-
this.sseEmitter.emit(
|
|
1525
|
+
case l.INIT:
|
|
1526
|
+
this.sseEmitter.emit(l.INIT, t);
|
|
1516
1527
|
break;
|
|
1517
|
-
case
|
|
1518
|
-
case
|
|
1519
|
-
this.sseEmitter.emit(
|
|
1528
|
+
case l.PROCESS_START:
|
|
1529
|
+
case l.PROCESS_COMPLETE:
|
|
1530
|
+
this.sseEmitter.emit(l.PROCESS, t);
|
|
1520
1531
|
break;
|
|
1521
|
-
case
|
|
1522
|
-
case
|
|
1523
|
-
case
|
|
1524
|
-
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);
|
|
1525
1536
|
break;
|
|
1526
|
-
case
|
|
1527
|
-
case
|
|
1528
|
-
this.sseEmitter.emit(
|
|
1537
|
+
case l.TOOL_CALL_START:
|
|
1538
|
+
case l.TOOL_CALL_COMPLETE:
|
|
1539
|
+
this.sseEmitter.emit(l.TOOL_CALL, t);
|
|
1529
1540
|
break;
|
|
1530
|
-
case
|
|
1541
|
+
case l.TOOL_CALL_CONSENT:
|
|
1531
1542
|
this.sseEmitter.emit(
|
|
1532
|
-
|
|
1543
|
+
l.TOOL_CALL_CONSENT,
|
|
1533
1544
|
t
|
|
1534
1545
|
);
|
|
1535
1546
|
break;
|
|
1536
|
-
case
|
|
1537
|
-
this.sseEmitter.emit(
|
|
1547
|
+
case l.DONE:
|
|
1548
|
+
this.sseEmitter.emit(l.DONE, t);
|
|
1538
1549
|
break;
|
|
1539
|
-
case
|
|
1540
|
-
this.sseEmitter.emit(
|
|
1550
|
+
case l.ERROR:
|
|
1551
|
+
this.sseEmitter.emit(l.ERROR, t);
|
|
1541
1552
|
break;
|
|
1542
1553
|
}
|
|
1543
1554
|
}
|
|
1544
1555
|
fetchSse(t, e) {
|
|
1545
1556
|
return e?.onSseStart?.(), this.inFlight += 1, this.runSse(
|
|
1546
|
-
|
|
1557
|
+
me({
|
|
1547
1558
|
apiKey: this.apiKey,
|
|
1548
1559
|
endpoint: this.endpoint,
|
|
1549
1560
|
debugMode: this.debugMode,
|
|
@@ -1562,7 +1573,7 @@ class xn {
|
|
|
1562
1573
|
e?.onSseStart?.(), this.inFlight += 1;
|
|
1563
1574
|
const r = new URL(this.endpoint);
|
|
1564
1575
|
return r.searchParams.set("custom_channel_id", t), this.runSse(
|
|
1565
|
-
|
|
1576
|
+
me({
|
|
1566
1577
|
apiKey: this.apiKey,
|
|
1567
1578
|
endpoint: r.toString(),
|
|
1568
1579
|
debugMode: this.debugMode,
|
|
@@ -1612,16 +1623,47 @@ class xn {
|
|
|
1612
1623
|
}))
|
|
1613
1624
|
};
|
|
1614
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
|
+
}
|
|
1615
1657
|
runSse(t, e) {
|
|
1616
1658
|
return t.pipe(
|
|
1617
1659
|
// No RxJS-level retry: re-subscribing would re-POST and the backend would re-dispatch a duplicate
|
|
1618
1660
|
// run. Mid-stream resume is the library's job (native Last-Event-ID reconnect in
|
|
1619
1661
|
// create-sse-observable); a no-cursor failure surfaces via `error` below.
|
|
1620
|
-
|
|
1621
|
-
|
|
1662
|
+
Jt((r) => Rt(r).pipe(tn(e?.delayTime ?? 50))),
|
|
1663
|
+
sn(this.destroy$),
|
|
1622
1664
|
// Settle the run accounting on every termination path — complete, error, AND a user-initiated
|
|
1623
1665
|
// unsubscribe (stop-generation aborts the connection without a terminal event).
|
|
1624
|
-
|
|
1666
|
+
rn(() => this.onRunSettled())
|
|
1625
1667
|
).subscribe({
|
|
1626
1668
|
next: (r) => {
|
|
1627
1669
|
this.detached || (e?.onSseMessage?.(r), this.handleEvent(r));
|
|
@@ -1748,7 +1790,8 @@ class xn {
|
|
|
1748
1790
|
throw new Error("Unable to derive sandbox fs endpoint. Please provide botProviderEndpoint in config.");
|
|
1749
1791
|
return `${e}/sandbox/${encodeURIComponent(t)}/fs`;
|
|
1750
1792
|
}
|
|
1751
|
-
|
|
1793
|
+
/** The shared auth / custom headers for the client's plain-JSON REST calls (no SSE). */
|
|
1794
|
+
apiHeaders() {
|
|
1752
1795
|
const t = { ...this.customHeaders };
|
|
1753
1796
|
return this.apiKey && (t["X-API-KEY"] = this.apiKey), t;
|
|
1754
1797
|
}
|
|
@@ -1759,7 +1802,7 @@ class xn {
|
|
|
1759
1802
|
async sandboxFsList(t, e) {
|
|
1760
1803
|
const r = new URL(`${this.deriveSandboxFsEndpoint(t)}/list`);
|
|
1761
1804
|
r.searchParams.set("path", e);
|
|
1762
|
-
const s = await fetch(r.toString(), { method: "GET", headers: this.
|
|
1805
|
+
const s = await fetch(r.toString(), { method: "GET", headers: this.apiHeaders() });
|
|
1763
1806
|
if (!s.ok)
|
|
1764
1807
|
throw new w(s.status, s.statusText, await s.text().catch(() => {
|
|
1765
1808
|
}));
|
|
@@ -1773,7 +1816,7 @@ class xn {
|
|
|
1773
1816
|
async sandboxFsRead(t, e, r) {
|
|
1774
1817
|
const s = new URL(`${this.deriveSandboxFsEndpoint(t)}/file`);
|
|
1775
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));
|
|
1776
|
-
const o = await fetch(s.toString(), { method: "GET", headers: this.
|
|
1819
|
+
const o = await fetch(s.toString(), { method: "GET", headers: this.apiHeaders() });
|
|
1777
1820
|
if (!o.ok)
|
|
1778
1821
|
throw new w(o.status, o.statusText, await o.text().catch(() => {
|
|
1779
1822
|
}));
|
|
@@ -1793,7 +1836,7 @@ class xn {
|
|
|
1793
1836
|
o.searchParams.set("path", e), s?.mode != null && o.searchParams.set("mode", String(s.mode)), s?.createOnly && o.searchParams.set("create_only", "true");
|
|
1794
1837
|
const i = new FormData();
|
|
1795
1838
|
i.append("file", r instanceof Blob ? r : new Blob([r]));
|
|
1796
|
-
const a = await fetch(o.toString(), { method: "PUT", headers: this.
|
|
1839
|
+
const a = await fetch(o.toString(), { method: "PUT", headers: this.apiHeaders(), body: i });
|
|
1797
1840
|
if (!a.ok)
|
|
1798
1841
|
throw new w(a.status, a.statusText, await a.text().catch(() => {
|
|
1799
1842
|
}));
|
|
@@ -1804,7 +1847,7 @@ class xn {
|
|
|
1804
1847
|
async sandboxFsRequest(t, e, r, s) {
|
|
1805
1848
|
const o = new URL(`${this.deriveSandboxFsEndpoint(t)}/${e}`);
|
|
1806
1849
|
Object.entries(s).forEach(([a, c]) => o.searchParams.set(a, c));
|
|
1807
|
-
const i = await fetch(o.toString(), { method: r, headers: this.
|
|
1850
|
+
const i = await fetch(o.toString(), { method: r, headers: this.apiHeaders() });
|
|
1808
1851
|
if (!i.ok)
|
|
1809
1852
|
throw new w(i.status, i.statusText, await i.text().catch(() => {
|
|
1810
1853
|
}));
|
|
@@ -1814,7 +1857,7 @@ class xn {
|
|
|
1814
1857
|
async sandboxFsStat(t, e) {
|
|
1815
1858
|
const r = new URL(`${this.deriveSandboxFsEndpoint(t)}/stat`);
|
|
1816
1859
|
r.searchParams.set("path", e);
|
|
1817
|
-
const s = await fetch(r.toString(), { method: "GET", headers: this.
|
|
1860
|
+
const s = await fetch(r.toString(), { method: "GET", headers: this.apiHeaders() });
|
|
1818
1861
|
if (!s.ok)
|
|
1819
1862
|
throw new w(s.status, s.statusText, await s.text().catch(() => {
|
|
1820
1863
|
}));
|
|
@@ -1861,8 +1904,8 @@ class xn {
|
|
|
1861
1904
|
const r = new URL(`${this.deriveSandboxFsEndpoint(t)}/watch`);
|
|
1862
1905
|
return r.searchParams.set("path", e), new S((s) => {
|
|
1863
1906
|
const o = new AbortController();
|
|
1864
|
-
return
|
|
1865
|
-
headers: this.
|
|
1907
|
+
return Se(r.toString(), {
|
|
1908
|
+
headers: this.apiHeaders(),
|
|
1866
1909
|
signal: o.signal,
|
|
1867
1910
|
openWhenHidden: !0,
|
|
1868
1911
|
onopen: async (i) => {
|
|
@@ -1901,29 +1944,29 @@ class xn {
|
|
|
1901
1944
|
const y = [];
|
|
1902
1945
|
for (let n = 0; n < 256; ++n)
|
|
1903
1946
|
y.push((n + 256).toString(16).slice(1));
|
|
1904
|
-
function
|
|
1947
|
+
function an(n, t = 0) {
|
|
1905
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();
|
|
1906
1949
|
}
|
|
1907
1950
|
let J;
|
|
1908
|
-
const
|
|
1909
|
-
function
|
|
1951
|
+
const cn = new Uint8Array(16);
|
|
1952
|
+
function un() {
|
|
1910
1953
|
if (!J) {
|
|
1911
1954
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
1912
1955
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
1913
1956
|
J = crypto.getRandomValues.bind(crypto);
|
|
1914
1957
|
}
|
|
1915
|
-
return J(
|
|
1958
|
+
return J(cn);
|
|
1916
1959
|
}
|
|
1917
|
-
const
|
|
1918
|
-
function
|
|
1960
|
+
const ln = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), ge = { randomUUID: ln };
|
|
1961
|
+
function dn(n, t, e) {
|
|
1919
1962
|
n = n || {};
|
|
1920
|
-
const r = n.random ?? n.rng?.() ??
|
|
1963
|
+
const r = n.random ?? n.rng?.() ?? un();
|
|
1921
1964
|
if (r.length < 16)
|
|
1922
1965
|
throw new Error("Random bytes length must be >= 16");
|
|
1923
|
-
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);
|
|
1924
1967
|
}
|
|
1925
|
-
function
|
|
1926
|
-
return
|
|
1968
|
+
function Ge(n, t, e) {
|
|
1969
|
+
return ge.randomUUID && !n ? ge.randomUUID() : dn(n);
|
|
1927
1970
|
}
|
|
1928
1971
|
class v {
|
|
1929
1972
|
messages = null;
|
|
@@ -1939,47 +1982,61 @@ class v {
|
|
|
1939
1982
|
return this.pendingConsent ? new v({ messages: this.messages, pendingConsent: null }) : this;
|
|
1940
1983
|
}
|
|
1941
1984
|
/**
|
|
1942
|
-
* Converge
|
|
1943
|
-
*
|
|
1944
|
-
*
|
|
1945
|
-
*
|
|
1946
|
-
*
|
|
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.
|
|
1947
1996
|
*/
|
|
1948
|
-
|
|
1997
|
+
settleInFlightMessages() {
|
|
1949
1998
|
if (!this.messages) return this;
|
|
1950
1999
|
let t = !1;
|
|
1951
2000
|
const e = new Map(this.messages);
|
|
1952
2001
|
for (const [r, s] of e)
|
|
1953
|
-
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);
|
|
1954
2003
|
return t ? new v({ messages: e, pendingConsent: this.pendingConsent }) : this;
|
|
1955
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
|
+
}
|
|
1956
2013
|
onMessage(t) {
|
|
1957
2014
|
switch (t.eventType) {
|
|
1958
|
-
case
|
|
2015
|
+
case l.MESSAGE_START:
|
|
1959
2016
|
return this.onMessageStart(t);
|
|
1960
|
-
case
|
|
2017
|
+
case l.MESSAGE_DELTA:
|
|
1961
2018
|
return this.onMessageDelta(t);
|
|
1962
|
-
case
|
|
2019
|
+
case l.MESSAGE_COMPLETE:
|
|
1963
2020
|
return this.onMessageComplete(t);
|
|
1964
|
-
case
|
|
2021
|
+
case l.MESSAGE_USER:
|
|
1965
2022
|
return this.onMessageUser(t);
|
|
1966
|
-
case
|
|
2023
|
+
case l.MESSAGE_THINKING_START:
|
|
1967
2024
|
return this.onThinkingStart(t);
|
|
1968
|
-
case
|
|
2025
|
+
case l.MESSAGE_THINKING_DELTA:
|
|
1969
2026
|
return this.onThinkingDelta(t);
|
|
1970
|
-
case
|
|
2027
|
+
case l.MESSAGE_THINKING_COMPLETE:
|
|
1971
2028
|
return this.onThinkingComplete(t);
|
|
1972
|
-
case
|
|
2029
|
+
case l.TOOL_CALL_START:
|
|
1973
2030
|
return this.onToolCallStart(t);
|
|
1974
|
-
case
|
|
2031
|
+
case l.TOOL_CALL_COMPLETE:
|
|
1975
2032
|
return this.onToolCallComplete(t);
|
|
1976
|
-
case
|
|
2033
|
+
case l.TOOL_CALL_CONSENT:
|
|
1977
2034
|
return this.onToolCallConsent(t);
|
|
1978
|
-
case
|
|
2035
|
+
case l.SUBAGENT_START:
|
|
1979
2036
|
return this.onSubagentStart(t);
|
|
1980
|
-
case
|
|
2037
|
+
case l.SUBAGENT_COMPLETE:
|
|
1981
2038
|
return this.onSubagentComplete(t);
|
|
1982
|
-
case
|
|
2039
|
+
case l.ERROR:
|
|
1983
2040
|
return this.onMessageError(t);
|
|
1984
2041
|
default:
|
|
1985
2042
|
return this;
|
|
@@ -2008,7 +2065,7 @@ class v {
|
|
|
2008
2065
|
const r = new Map(this.messages);
|
|
2009
2066
|
return r.set(e.messageId, {
|
|
2010
2067
|
type: "bot",
|
|
2011
|
-
eventType:
|
|
2068
|
+
eventType: l.MESSAGE_START,
|
|
2012
2069
|
isTyping: !0,
|
|
2013
2070
|
typingText: "",
|
|
2014
2071
|
messageId: e.messageId,
|
|
@@ -2026,7 +2083,7 @@ class v {
|
|
|
2026
2083
|
const s = r?.type === "bot" ? r : void 0, o = new Map(this.messages);
|
|
2027
2084
|
return o.set(e.messageId, {
|
|
2028
2085
|
type: "bot",
|
|
2029
|
-
eventType:
|
|
2086
|
+
eventType: l.MESSAGE_DELTA,
|
|
2030
2087
|
isTyping: !0,
|
|
2031
2088
|
typingText: `${s?.typingText ?? ""}${e.text}`,
|
|
2032
2089
|
messageId: e.messageId,
|
|
@@ -2042,7 +2099,7 @@ class v {
|
|
|
2042
2099
|
const r = new Map(this.messages), s = r.get(e.messageId);
|
|
2043
2100
|
return r.set(e.messageId, {
|
|
2044
2101
|
type: "bot",
|
|
2045
|
-
eventType:
|
|
2102
|
+
eventType: l.MESSAGE_COMPLETE,
|
|
2046
2103
|
isTyping: !1,
|
|
2047
2104
|
typingText: null,
|
|
2048
2105
|
messageId: e.messageId,
|
|
@@ -2112,10 +2169,10 @@ class v {
|
|
|
2112
2169
|
return s.set(e.messageId, o), new v({ messages: s, pendingConsent: this.pendingConsent });
|
|
2113
2170
|
}
|
|
2114
2171
|
onMessageError(t) {
|
|
2115
|
-
const e =
|
|
2172
|
+
const e = Ge(), r = t.fact.runError.error, s = new Map(this.messages);
|
|
2116
2173
|
return s.set(e, {
|
|
2117
2174
|
type: "error",
|
|
2118
|
-
eventType:
|
|
2175
|
+
eventType: l.ERROR,
|
|
2119
2176
|
messageId: e,
|
|
2120
2177
|
error: r,
|
|
2121
2178
|
time: /* @__PURE__ */ new Date(),
|
|
@@ -2125,7 +2182,7 @@ class v {
|
|
|
2125
2182
|
onToolCallStart(t) {
|
|
2126
2183
|
const e = t.fact.toolCallStart, r = new Map(this.messages), s = `${e.processId}-${e.callSeq}`, o = {
|
|
2127
2184
|
type: "tool-call",
|
|
2128
|
-
eventType:
|
|
2185
|
+
eventType: l.TOOL_CALL_START,
|
|
2129
2186
|
messageId: s,
|
|
2130
2187
|
processId: e.processId,
|
|
2131
2188
|
callSeq: e.callSeq,
|
|
@@ -2146,7 +2203,7 @@ class v {
|
|
|
2146
2203
|
if (o?.type === "tool-call") {
|
|
2147
2204
|
const i = {
|
|
2148
2205
|
...o,
|
|
2149
|
-
eventType:
|
|
2206
|
+
eventType: l.TOOL_CALL_COMPLETE,
|
|
2150
2207
|
result: e.toolCallResult,
|
|
2151
2208
|
isError: e.isError,
|
|
2152
2209
|
sidecar: e.toolUseResultSidecar,
|
|
@@ -2191,22 +2248,22 @@ class v {
|
|
|
2191
2248
|
return r.set(s, o), new v({ messages: r, pendingConsent: this.pendingConsent });
|
|
2192
2249
|
}
|
|
2193
2250
|
}
|
|
2194
|
-
const
|
|
2195
|
-
function
|
|
2196
|
-
return n.toolsetName === "" &&
|
|
2251
|
+
const hn = /* @__PURE__ */ new Set(["TaskCreate", "TaskUpdate"]);
|
|
2252
|
+
function fn(n) {
|
|
2253
|
+
return n.toolsetName === "" && hn.has(n.toolName);
|
|
2197
2254
|
}
|
|
2198
|
-
function
|
|
2255
|
+
function be(n) {
|
|
2199
2256
|
return typeof n == "object" && n !== null ? n : void 0;
|
|
2200
2257
|
}
|
|
2201
2258
|
function I(n) {
|
|
2202
2259
|
return typeof n == "string" ? n : void 0;
|
|
2203
2260
|
}
|
|
2204
|
-
function
|
|
2261
|
+
function pn(n) {
|
|
2205
2262
|
const t = [], e = /* @__PURE__ */ new Map();
|
|
2206
2263
|
for (const r of n) {
|
|
2207
2264
|
const s = r.parameter ?? {}, o = r.sidecar ?? {};
|
|
2208
2265
|
if (r.toolName === "TaskCreate") {
|
|
2209
|
-
const i =
|
|
2266
|
+
const i = be(o.task), a = I(i?.id);
|
|
2210
2267
|
if (!a) continue;
|
|
2211
2268
|
e.has(a) || t.push(a), e.set(a, {
|
|
2212
2269
|
id: a,
|
|
@@ -2217,7 +2274,7 @@ function hn(n) {
|
|
|
2217
2274
|
// initial status = pending (keep existing on repeat)
|
|
2218
2275
|
});
|
|
2219
2276
|
} else if (r.toolName === "TaskUpdate") {
|
|
2220
|
-
const i =
|
|
2277
|
+
const i = be(o.statusChange), a = I(s.taskId) || I(o.taskId), c = I(i?.to) || I(s.status);
|
|
2221
2278
|
if (!a || !c) continue;
|
|
2222
2279
|
const u = e.get(a);
|
|
2223
2280
|
u && e.set(a, { ...u, status: c });
|
|
@@ -2225,13 +2282,13 @@ function hn(n) {
|
|
|
2225
2282
|
}
|
|
2226
2283
|
return t.map((r) => e.get(r));
|
|
2227
2284
|
}
|
|
2228
|
-
function
|
|
2285
|
+
function mn(n) {
|
|
2229
2286
|
return n.toolsetName === "" && n.toolName === "Agent";
|
|
2230
2287
|
}
|
|
2231
|
-
function
|
|
2288
|
+
function gn(n) {
|
|
2232
2289
|
return !!n;
|
|
2233
2290
|
}
|
|
2234
|
-
function
|
|
2291
|
+
function bn(n) {
|
|
2235
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));
|
|
2236
2293
|
for (const o of n)
|
|
2237
2294
|
switch (o.kind) {
|
|
@@ -2272,21 +2329,21 @@ function mn(n) {
|
|
|
2272
2329
|
tools: Array.from(r.get(o).values())
|
|
2273
2330
|
}));
|
|
2274
2331
|
}
|
|
2275
|
-
function
|
|
2332
|
+
function vn(n) {
|
|
2276
2333
|
return typeof n == "string" ? n : void 0;
|
|
2277
2334
|
}
|
|
2278
|
-
function
|
|
2335
|
+
function yn(n) {
|
|
2279
2336
|
const t = [];
|
|
2280
2337
|
for (const e of n) {
|
|
2281
|
-
if (e.type === "tool-call" &&
|
|
2338
|
+
if (e.type === "tool-call" && mn(e)) {
|
|
2282
2339
|
t.push({
|
|
2283
2340
|
kind: "agentStart",
|
|
2284
2341
|
toolUseId: e.toolUseId ?? e.messageId,
|
|
2285
|
-
description:
|
|
2342
|
+
description: vn(e.parameter.description)
|
|
2286
2343
|
});
|
|
2287
2344
|
continue;
|
|
2288
2345
|
}
|
|
2289
|
-
if (e.type === "tool-call" &&
|
|
2346
|
+
if (e.type === "tool-call" && gn(e.parentToolUseId)) {
|
|
2290
2347
|
const r = e.toolUseId ?? e.messageId;
|
|
2291
2348
|
t.push({
|
|
2292
2349
|
kind: "toolStart",
|
|
@@ -2323,37 +2380,37 @@ function bn(n) {
|
|
|
2323
2380
|
}
|
|
2324
2381
|
return t;
|
|
2325
2382
|
}
|
|
2326
|
-
function
|
|
2383
|
+
function Sn(n) {
|
|
2327
2384
|
const t = Array.from(n.messages?.values() ?? []).filter(
|
|
2328
|
-
(e) => e.type === "tool-call" && e.isComplete &&
|
|
2385
|
+
(e) => e.type === "tool-call" && e.isComplete && fn(e)
|
|
2329
2386
|
);
|
|
2330
|
-
return
|
|
2387
|
+
return pn(t);
|
|
2331
2388
|
}
|
|
2332
|
-
function
|
|
2333
|
-
return
|
|
2389
|
+
function wn(n) {
|
|
2390
|
+
return bn(yn(Array.from(n.messages?.values() ?? [])));
|
|
2334
2391
|
}
|
|
2335
|
-
function
|
|
2392
|
+
function En(n, t) {
|
|
2336
2393
|
return n === t ? !0 : n.length !== t.length ? !1 : n.every((e, r) => {
|
|
2337
2394
|
const s = t[r];
|
|
2338
2395
|
return e.id === s.id && e.status === s.status && e.subject === s.subject && e.activeForm === s.activeForm && e.description === s.description;
|
|
2339
2396
|
});
|
|
2340
2397
|
}
|
|
2341
|
-
function
|
|
2398
|
+
function In(n, t) {
|
|
2342
2399
|
return n.length !== t.length ? !1 : n.every((e, r) => {
|
|
2343
2400
|
const s = t[r];
|
|
2344
2401
|
return e.toolName === s.toolName && e.toolsetName === s.toolsetName && e.status === s.status && e.reason === s.reason;
|
|
2345
2402
|
});
|
|
2346
2403
|
}
|
|
2347
|
-
function
|
|
2404
|
+
function Tn(n, t) {
|
|
2348
2405
|
return n === t ? !0 : n.length !== t.length ? !1 : n.every((e, r) => {
|
|
2349
2406
|
const s = t[r];
|
|
2350
|
-
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);
|
|
2351
2408
|
});
|
|
2352
2409
|
}
|
|
2353
|
-
function
|
|
2354
|
-
const t = new
|
|
2355
|
-
return r.add(n.pipe(N(
|
|
2356
|
-
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)
|
|
2357
2414
|
), {
|
|
2358
2415
|
tasks$: t.asObservable(),
|
|
2359
2416
|
subagents$: e.asObservable(),
|
|
@@ -2362,18 +2419,26 @@ function In(n) {
|
|
|
2362
2419
|
teardown: () => r.unsubscribe()
|
|
2363
2420
|
};
|
|
2364
2421
|
}
|
|
2365
|
-
function
|
|
2422
|
+
function ve(n) {
|
|
2366
2423
|
const t = /* @__PURE__ */ new Map();
|
|
2367
2424
|
for (const e of n) t.set(e.sandboxName, e);
|
|
2368
2425
|
return [...t.values()].sort(
|
|
2369
2426
|
(e, r) => (e.sandboxBlueprintName || e.sandboxName).localeCompare(r.sandboxBlueprintName || r.sandboxName)
|
|
2370
2427
|
);
|
|
2371
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
|
+
}
|
|
2372
2433
|
class K {
|
|
2373
2434
|
client;
|
|
2374
2435
|
customChannelId;
|
|
2375
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;
|
|
2376
2440
|
isConnecting$;
|
|
2441
|
+
runStatusSubject;
|
|
2377
2442
|
conversation$;
|
|
2378
2443
|
channelTitleSubject;
|
|
2379
2444
|
sandboxPhaseSubject;
|
|
@@ -2394,24 +2459,33 @@ class K {
|
|
|
2394
2459
|
sandboxPhase$;
|
|
2395
2460
|
/** Reactive live-sandbox list store (F-019): authoritative from `/channel/metadata`, per-slice; replay-safe. */
|
|
2396
2461
|
launchedSandboxes$;
|
|
2462
|
+
/** Reactive run identity + stop lifecycle store (F-023): who holds the connection, and is a stop pending. */
|
|
2463
|
+
runStatus$;
|
|
2397
2464
|
currentUserMessageId;
|
|
2398
2465
|
// The most-recently-sent user message id. Unlike currentUserMessageId (which
|
|
2399
2466
|
// is cleared once a traceId is attached), this is kept across the SSE
|
|
2400
2467
|
// lifecycle so RESPONSE_TOOL_CALL_CONSENT — fired after run.done — can echo
|
|
2401
2468
|
// back the message id the bot is waiting on.
|
|
2402
2469
|
lastSentMessageId;
|
|
2403
|
-
// The in-flight SSE run's subscription. Held so
|
|
2404
|
-
//
|
|
2405
|
-
// 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.
|
|
2406
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;
|
|
2407
2481
|
constructor(t) {
|
|
2408
2482
|
if (!t.client)
|
|
2409
2483
|
throw new Error("client must be required");
|
|
2410
2484
|
if (!t.customChannelId)
|
|
2411
2485
|
throw new Error("customChannelId must be required");
|
|
2412
|
-
this.client = t.client, this.customChannelId = t.customChannelId, this.customMessageId = t.customMessageId, this.isConnecting$ = new
|
|
2413
|
-
|
|
2414
|
-
), 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;
|
|
2415
2489
|
}
|
|
2416
2490
|
/** Current Task Check List snapshot (F-013) — for framework-agnostic `getSnapshot()` bridging. */
|
|
2417
2491
|
getTasks() {
|
|
@@ -2433,6 +2507,10 @@ class K {
|
|
|
2433
2507
|
getLaunchedSandboxes() {
|
|
2434
2508
|
return this.launchedSandboxesSubject.value;
|
|
2435
2509
|
}
|
|
2510
|
+
/** Current run identity + stop lifecycle snapshot (F-023) — for framework-agnostic `getSnapshot()` bridging. */
|
|
2511
|
+
getRunStatus() {
|
|
2512
|
+
return this.runStatusSubject.value;
|
|
2513
|
+
}
|
|
2436
2514
|
/** Names hinted by `sandbox.launch` but not yet confirmed live by metadata (F-019) — "starting" placeholders. */
|
|
2437
2515
|
getPendingLaunches() {
|
|
2438
2516
|
return this.pendingLaunches;
|
|
@@ -2443,7 +2521,7 @@ class K {
|
|
|
2443
2521
|
* launch whose name now appears (promoted to live). metadata (heartbeat-backed) is the sole authority.
|
|
2444
2522
|
*/
|
|
2445
2523
|
applyLaunchedSandboxes(t) {
|
|
2446
|
-
const e =
|
|
2524
|
+
const e = ve(t);
|
|
2447
2525
|
this.pendingLaunches = this.pendingLaunches.filter((r) => !e.some((s) => s.sandboxName === r)), this.launchedSandboxesSubject.next(e);
|
|
2448
2526
|
}
|
|
2449
2527
|
/**
|
|
@@ -2504,24 +2582,37 @@ class K {
|
|
|
2504
2582
|
}
|
|
2505
2583
|
}
|
|
2506
2584
|
subscribe() {
|
|
2507
|
-
this.statesSubscription =
|
|
2585
|
+
this.statesSubscription = Wt([
|
|
2508
2586
|
this.isConnecting$,
|
|
2509
2587
|
this.conversation$,
|
|
2510
2588
|
this.derivedStores.tasks$,
|
|
2511
2589
|
this.derivedStores.subagents$,
|
|
2512
2590
|
this.channelTitle$,
|
|
2513
2591
|
this.sandboxPhase$,
|
|
2514
|
-
this.launchedSandboxes
|
|
2592
|
+
this.launchedSandboxes$,
|
|
2593
|
+
this.runStatus$
|
|
2515
2594
|
]).pipe(
|
|
2516
|
-
N(
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
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
|
+
)
|
|
2525
2616
|
).subscribe(this.statesObserver);
|
|
2526
2617
|
}
|
|
2527
2618
|
/**
|
|
@@ -2545,14 +2636,14 @@ class K {
|
|
|
2545
2636
|
*/
|
|
2546
2637
|
updateSandboxPhase(t) {
|
|
2547
2638
|
switch (t) {
|
|
2548
|
-
case
|
|
2639
|
+
case l.SANDBOX_LAUNCH:
|
|
2549
2640
|
this.sandboxPhaseSubject.next("launching");
|
|
2550
2641
|
break;
|
|
2551
|
-
case
|
|
2642
|
+
case l.SANDBOX_READY:
|
|
2552
2643
|
this.sandboxPhaseSubject.next("ready");
|
|
2553
2644
|
break;
|
|
2554
|
-
case
|
|
2555
|
-
case
|
|
2645
|
+
case l.INIT:
|
|
2646
|
+
case l.ERROR:
|
|
2556
2647
|
this.sandboxPhaseSubject.next("idle");
|
|
2557
2648
|
break;
|
|
2558
2649
|
}
|
|
@@ -2566,9 +2657,9 @@ class K {
|
|
|
2566
2657
|
return {
|
|
2567
2658
|
onSseStart: t?.onSseStart,
|
|
2568
2659
|
onSseMessage: (s) => {
|
|
2569
|
-
if (t?.onSseMessage?.(s), s.eventType ===
|
|
2660
|
+
if (t?.onSseMessage?.(s), this.captureRequestId(s.requestId), s.eventType === l.CHANNEL_TITLE_UPDATE && this.channelTitleSubject.next(
|
|
2570
2661
|
s.fact.channelTitleUpdate.title
|
|
2571
|
-
), 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) {
|
|
2572
2663
|
const o = new Map(this.conversation$.value.messages), i = o.get(this.currentUserMessageId);
|
|
2573
2664
|
i && i.type === "user" && (o.set(this.currentUserMessageId, {
|
|
2574
2665
|
...i,
|
|
@@ -2578,16 +2669,33 @@ class K {
|
|
|
2578
2669
|
this.conversation$.next(this.conversation$.value.onMessage(s));
|
|
2579
2670
|
},
|
|
2580
2671
|
onSseError: (s) => {
|
|
2581
|
-
t?.onSseError?.(s), this.
|
|
2672
|
+
t?.onSseError?.(s), this.settleRun(), r(s);
|
|
2582
2673
|
},
|
|
2583
2674
|
onSseCompleted: () => {
|
|
2584
|
-
t?.onSseCompleted?.(), this.
|
|
2675
|
+
t?.onSseCompleted?.(), this.settleRun(), e();
|
|
2585
2676
|
}
|
|
2586
2677
|
};
|
|
2587
2678
|
}
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
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));
|
|
2591
2699
|
});
|
|
2592
2700
|
}
|
|
2593
2701
|
/**
|
|
@@ -2602,11 +2710,15 @@ class K {
|
|
|
2602
2710
|
e();
|
|
2603
2711
|
return;
|
|
2604
2712
|
}
|
|
2605
|
-
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));
|
|
2606
2717
|
});
|
|
2607
2718
|
}
|
|
2608
2719
|
resetChannel(t, e) {
|
|
2609
2720
|
return this.fetchSse(
|
|
2721
|
+
"reset",
|
|
2610
2722
|
{
|
|
2611
2723
|
action: $.RESET_CHANNEL,
|
|
2612
2724
|
customChannelId: this.customChannelId,
|
|
@@ -2618,24 +2730,27 @@ class K {
|
|
|
2618
2730
|
);
|
|
2619
2731
|
}
|
|
2620
2732
|
sendMessage(t, e) {
|
|
2621
|
-
const r =
|
|
2622
|
-
|
|
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(
|
|
2623
2737
|
this.conversation$.value.pushMessage({
|
|
2624
2738
|
type: "user",
|
|
2625
|
-
messageId:
|
|
2626
|
-
text:
|
|
2739
|
+
messageId: o,
|
|
2740
|
+
text: s,
|
|
2627
2741
|
blobIds: t.blobIds,
|
|
2628
2742
|
filePreviewUrls: t.filePreviewUrls,
|
|
2629
2743
|
documentNames: t.documentNames,
|
|
2630
2744
|
time: /* @__PURE__ */ new Date()
|
|
2631
2745
|
})
|
|
2632
2746
|
), this.fetchSse(
|
|
2747
|
+
"user",
|
|
2633
2748
|
{
|
|
2634
2749
|
action: $.NONE,
|
|
2635
2750
|
customChannelId: this.customChannelId,
|
|
2636
|
-
customMessageId:
|
|
2751
|
+
customMessageId: o,
|
|
2637
2752
|
payload: this.resolvePayload(t?.payload),
|
|
2638
|
-
text:
|
|
2753
|
+
text: s,
|
|
2639
2754
|
blobIds: t?.blobIds
|
|
2640
2755
|
},
|
|
2641
2756
|
e
|
|
@@ -2643,6 +2758,7 @@ class K {
|
|
|
2643
2758
|
}
|
|
2644
2759
|
replyToolCallConsents(t, e, r) {
|
|
2645
2760
|
return this.conversation$.next(this.conversation$.value.clearPendingConsent()), this.fetchSse(
|
|
2761
|
+
"user",
|
|
2646
2762
|
{
|
|
2647
2763
|
action: $.RESPONSE_TOOL_CALL_CONSENT,
|
|
2648
2764
|
customChannelId: this.customChannelId,
|
|
@@ -2662,6 +2778,7 @@ class K {
|
|
|
2662
2778
|
*/
|
|
2663
2779
|
nudge(t) {
|
|
2664
2780
|
return this.fetchSse(
|
|
2781
|
+
"nudge",
|
|
2665
2782
|
{
|
|
2666
2783
|
action: $.NUDGE,
|
|
2667
2784
|
customChannelId: this.customChannelId,
|
|
@@ -2672,19 +2789,80 @@ class K {
|
|
|
2672
2789
|
);
|
|
2673
2790
|
}
|
|
2674
2791
|
/**
|
|
2675
|
-
* User-initiated stop-generation
|
|
2676
|
-
*
|
|
2677
|
-
*
|
|
2678
|
-
*
|
|
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).
|
|
2679
2857
|
*/
|
|
2680
|
-
|
|
2681
|
-
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()));
|
|
2682
2860
|
}
|
|
2683
2861
|
close() {
|
|
2684
|
-
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();
|
|
2685
2863
|
}
|
|
2686
2864
|
}
|
|
2687
|
-
function
|
|
2865
|
+
function Ln(n) {
|
|
2688
2866
|
const t = /^sandbox:\/\/([^/]+)\/([^?#]+)(?:\?([^#]*))?/.exec(n.trim());
|
|
2689
2867
|
if (!t) return null;
|
|
2690
2868
|
const e = decodeURIComponent(t[1]), r = t[2], s = new URLSearchParams(t[3] ?? "");
|
|
@@ -2696,27 +2874,29 @@ function Cn(n) {
|
|
|
2696
2874
|
return null;
|
|
2697
2875
|
}
|
|
2698
2876
|
export {
|
|
2699
|
-
|
|
2877
|
+
_n as AsgardServiceClient,
|
|
2700
2878
|
K as Channel,
|
|
2879
|
+
ye as ChannelBusyError,
|
|
2701
2880
|
v as Conversation,
|
|
2702
|
-
|
|
2881
|
+
l as EventType,
|
|
2703
2882
|
$ as FetchSseAction,
|
|
2704
2883
|
w as HttpError,
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
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
|
|
2721
2901
|
};
|
|
2722
2902
|
//# sourceMappingURL=index.mjs.map
|