@asgard-js/core 0.3.52 → 0.3.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +161 -140
- package/dist/index.mjs.map +1 -1
- package/dist/lib/channel.d.ts +2 -1
- package/dist/lib/channel.d.ts.map +1 -1
- package/dist/lib/conversation.d.ts +6 -0
- package/dist/lib/conversation.d.ts.map +1 -1
- package/dist/types/channel-awaiting-consent-error.d.ts +15 -7
- package/dist/types/channel-awaiting-consent-error.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ 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 Ln(n) {
|
|
20
20
|
return n instanceof w;
|
|
21
21
|
}
|
|
22
22
|
class Z extends Error {
|
|
@@ -26,18 +26,25 @@ class Z extends Error {
|
|
|
26
26
|
super(`Cannot send a message while a "${t}" run is in flight on this channel.`), this.name = "ChannelBusyError", this.runKind = t;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function _n(n) {
|
|
30
30
|
return n instanceof Z;
|
|
31
31
|
}
|
|
32
|
-
class
|
|
33
|
-
/**
|
|
32
|
+
class ee extends Error {
|
|
33
|
+
/**
|
|
34
|
+
* The paused batch's process id, as carried by the pending consent prompt.
|
|
35
|
+
*
|
|
36
|
+
* **Empty string on a rejoin.** A prompt recovered after a reload is reconstructed by the backend
|
|
37
|
+
* from its durable pause state, and that path deliberately leaves the process id blank (clients are
|
|
38
|
+
* meant to detect a consent pause from the prompt's presence, not from this id). Treat it as a
|
|
39
|
+
* diagnostic hint, never as a key.
|
|
40
|
+
*/
|
|
34
41
|
processId;
|
|
35
42
|
constructor(t) {
|
|
36
|
-
super("Cannot send
|
|
43
|
+
super("Cannot send this turn while the channel is awaiting a tool-call consent response."), this.name = "ChannelAwaitingConsentError", this.processId = t;
|
|
37
44
|
}
|
|
38
45
|
}
|
|
39
46
|
function Un(n) {
|
|
40
|
-
return n instanceof
|
|
47
|
+
return n instanceof ee;
|
|
41
48
|
}
|
|
42
49
|
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 || {}), Xe = /* @__PURE__ */ ((n) => (n.ALLOW_ONCE = "ALLOW_ONCE", n.ALLOW_ALWAYS = "ALLOW_ALWAYS", n.DENY_ONCE = "DENY_ONCE", n))(Xe || {}), Ve = /* @__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))(Ve || {});
|
|
43
50
|
async function ze(n, t) {
|
|
@@ -74,11 +81,11 @@ function Je(n) {
|
|
|
74
81
|
};
|
|
75
82
|
}
|
|
76
83
|
function Qe(n, t, e) {
|
|
77
|
-
let r =
|
|
84
|
+
let r = ue();
|
|
78
85
|
const s = new TextDecoder();
|
|
79
86
|
return function(i, a) {
|
|
80
87
|
if (i.length === 0)
|
|
81
|
-
e?.(r), r =
|
|
88
|
+
e?.(r), r = ue();
|
|
82
89
|
else if (a > 0) {
|
|
83
90
|
const c = s.decode(i.subarray(0, a)), u = a + (i[a + 1] === 32 ? 2 : 1), h = s.decode(i.subarray(u));
|
|
84
91
|
switch (c) {
|
|
@@ -104,7 +111,7 @@ function Ze(n, t) {
|
|
|
104
111
|
const e = new Uint8Array(n.length + t.length);
|
|
105
112
|
return e.set(n), e.set(t, n.length), e;
|
|
106
113
|
}
|
|
107
|
-
function
|
|
114
|
+
function ue() {
|
|
108
115
|
return {
|
|
109
116
|
data: "",
|
|
110
117
|
event: "",
|
|
@@ -120,23 +127,23 @@ var et = function(n, t) {
|
|
|
120
127
|
t.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[s]) && (e[r[s]] = n[r[s]]);
|
|
121
128
|
return e;
|
|
122
129
|
};
|
|
123
|
-
const
|
|
130
|
+
const te = "text/event-stream", tt = 1e3, le = "last-event-id";
|
|
124
131
|
function Ee(n, t) {
|
|
125
132
|
var { signal: e, headers: r, onopen: s, onmessage: o, onclose: i, onerror: a, openWhenHidden: c, fetch: u } = t, h = et(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
126
|
-
return new Promise((m,
|
|
133
|
+
return new Promise((m, v) => {
|
|
127
134
|
const d = Object.assign({}, r);
|
|
128
|
-
d.accept || (d.accept =
|
|
135
|
+
d.accept || (d.accept = te);
|
|
129
136
|
let p;
|
|
130
137
|
function f() {
|
|
131
138
|
p.abort(), document.hidden || X();
|
|
132
139
|
}
|
|
133
140
|
c || document.addEventListener("visibilitychange", f);
|
|
134
|
-
let
|
|
135
|
-
function
|
|
141
|
+
let L = tt, E = 0;
|
|
142
|
+
function _() {
|
|
136
143
|
document.removeEventListener("visibilitychange", f), window.clearTimeout(E), p.abort();
|
|
137
144
|
}
|
|
138
145
|
e?.addEventListener("abort", () => {
|
|
139
|
-
|
|
146
|
+
_(), m();
|
|
140
147
|
});
|
|
141
148
|
const Ye = u ?? window.fetch, We = s ?? nt;
|
|
142
149
|
async function X() {
|
|
@@ -145,17 +152,17 @@ function Ee(n, t) {
|
|
|
145
152
|
try {
|
|
146
153
|
const H = await Ye(n, Object.assign(Object.assign({}, h), { headers: d, signal: p.signal }));
|
|
147
154
|
await We(H), await ze(H.body, Je(Qe((C) => {
|
|
148
|
-
C ? d[
|
|
155
|
+
C ? d[le] = C : delete d[le];
|
|
149
156
|
}, (C) => {
|
|
150
|
-
|
|
151
|
-
}, o))), i?.(),
|
|
157
|
+
L = C;
|
|
158
|
+
}, o))), i?.(), _(), m();
|
|
152
159
|
} catch (H) {
|
|
153
160
|
if (!p.signal.aborted)
|
|
154
161
|
try {
|
|
155
|
-
const C = (V = a?.(H)) !== null && V !== void 0 ? V :
|
|
162
|
+
const C = (V = a?.(H)) !== null && V !== void 0 ? V : L;
|
|
156
163
|
window.clearTimeout(E), E = window.setTimeout(X, C);
|
|
157
164
|
} catch (C) {
|
|
158
|
-
|
|
165
|
+
_(), v(C);
|
|
159
166
|
}
|
|
160
167
|
}
|
|
161
168
|
}
|
|
@@ -164,20 +171,20 @@ function Ee(n, t) {
|
|
|
164
171
|
}
|
|
165
172
|
function nt(n) {
|
|
166
173
|
const t = n.headers.get("content-type");
|
|
167
|
-
if (!t?.startsWith(
|
|
168
|
-
throw new Error(`Expected content-type to be ${
|
|
174
|
+
if (!t?.startsWith(te))
|
|
175
|
+
throw new Error(`Expected content-type to be ${te}, Actual: ${t}`);
|
|
169
176
|
}
|
|
170
|
-
var
|
|
171
|
-
return
|
|
177
|
+
var ne = function(n, t) {
|
|
178
|
+
return ne = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
|
|
172
179
|
e.__proto__ = r;
|
|
173
180
|
} || function(e, r) {
|
|
174
181
|
for (var s in r) Object.prototype.hasOwnProperty.call(r, s) && (e[s] = r[s]);
|
|
175
|
-
},
|
|
182
|
+
}, ne(n, t);
|
|
176
183
|
};
|
|
177
184
|
function T(n, t) {
|
|
178
185
|
if (typeof t != "function" && t !== null)
|
|
179
186
|
throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
|
|
180
|
-
|
|
187
|
+
ne(n, t);
|
|
181
188
|
function e() {
|
|
182
189
|
this.constructor = n;
|
|
183
190
|
}
|
|
@@ -318,8 +325,8 @@ function st(n, t, e) {
|
|
|
318
325
|
}
|
|
319
326
|
function a(d, p) {
|
|
320
327
|
r[d] && (s[d] = function(f) {
|
|
321
|
-
return new Promise(function(
|
|
322
|
-
o.push([d, f,
|
|
328
|
+
return new Promise(function(L, E) {
|
|
329
|
+
o.push([d, f, L, E]) > 1 || c(d, f);
|
|
323
330
|
});
|
|
324
331
|
}, p && (s[d] = p(s[d])));
|
|
325
332
|
}
|
|
@@ -327,11 +334,11 @@ function st(n, t, e) {
|
|
|
327
334
|
try {
|
|
328
335
|
u(r[d](p));
|
|
329
336
|
} catch (f) {
|
|
330
|
-
|
|
337
|
+
v(o[0][3], f);
|
|
331
338
|
}
|
|
332
339
|
}
|
|
333
340
|
function u(d) {
|
|
334
|
-
d.value instanceof k ? Promise.resolve(d.value.v).then(h, m) :
|
|
341
|
+
d.value instanceof k ? Promise.resolve(d.value.v).then(h, m) : v(o[0][2], d);
|
|
335
342
|
}
|
|
336
343
|
function h(d) {
|
|
337
344
|
c("next", d);
|
|
@@ -339,7 +346,7 @@ function st(n, t, e) {
|
|
|
339
346
|
function m(d) {
|
|
340
347
|
c("throw", d);
|
|
341
348
|
}
|
|
342
|
-
function
|
|
349
|
+
function v(d, p) {
|
|
343
350
|
d(p), o.shift(), o.length && c(o[0][0], o[0][1]);
|
|
344
351
|
}
|
|
345
352
|
}
|
|
@@ -424,10 +431,10 @@ var j = (function() {
|
|
|
424
431
|
if (m) {
|
|
425
432
|
this._finalizers = null;
|
|
426
433
|
try {
|
|
427
|
-
for (var
|
|
434
|
+
for (var v = N(m), d = v.next(); !d.done; d = v.next()) {
|
|
428
435
|
var p = d.value;
|
|
429
436
|
try {
|
|
430
|
-
|
|
437
|
+
de(p);
|
|
431
438
|
} catch (f) {
|
|
432
439
|
o = o ?? [], f instanceof z ? o = F(F([], D(o)), D(f.errors)) : o.push(f);
|
|
433
440
|
}
|
|
@@ -436,7 +443,7 @@ var j = (function() {
|
|
|
436
443
|
r = { error: f };
|
|
437
444
|
} finally {
|
|
438
445
|
try {
|
|
439
|
-
d && !d.done && (s =
|
|
446
|
+
d && !d.done && (s = v.return) && s.call(v);
|
|
440
447
|
} finally {
|
|
441
448
|
if (r) throw r.error;
|
|
442
449
|
}
|
|
@@ -449,7 +456,7 @@ var j = (function() {
|
|
|
449
456
|
var e;
|
|
450
457
|
if (t && t !== this)
|
|
451
458
|
if (this.closed)
|
|
452
|
-
|
|
459
|
+
de(t);
|
|
453
460
|
else {
|
|
454
461
|
if (t instanceof n) {
|
|
455
462
|
if (t.closed || t._hasParent(this))
|
|
@@ -478,7 +485,7 @@ var j = (function() {
|
|
|
478
485
|
function xe(n) {
|
|
479
486
|
return n instanceof j || n && "closed" in n && g(n.remove) && g(n.add) && g(n.unsubscribe);
|
|
480
487
|
}
|
|
481
|
-
function
|
|
488
|
+
function de(n) {
|
|
482
489
|
g(n) ? n() : n.unsubscribe();
|
|
483
490
|
}
|
|
484
491
|
var it = {
|
|
@@ -499,19 +506,19 @@ function Oe(n) {
|
|
|
499
506
|
throw n;
|
|
500
507
|
});
|
|
501
508
|
}
|
|
502
|
-
function
|
|
509
|
+
function re() {
|
|
503
510
|
}
|
|
504
511
|
function G(n) {
|
|
505
512
|
n();
|
|
506
513
|
}
|
|
507
|
-
var
|
|
514
|
+
var oe = (function(n) {
|
|
508
515
|
T(t, n);
|
|
509
516
|
function t(e) {
|
|
510
517
|
var r = n.call(this) || this;
|
|
511
518
|
return r.isStopped = !1, e ? (r.destination = e, xe(e) && e.add(r)) : r.destination = lt, r;
|
|
512
519
|
}
|
|
513
520
|
return t.create = function(e, r, s) {
|
|
514
|
-
return new
|
|
521
|
+
return new se(e, r, s);
|
|
515
522
|
}, t.prototype.next = function(e) {
|
|
516
523
|
this.isStopped || this._next(e);
|
|
517
524
|
}, t.prototype.error = function(e) {
|
|
@@ -566,7 +573,7 @@ var se = (function(n) {
|
|
|
566
573
|
B(e);
|
|
567
574
|
}
|
|
568
575
|
}, n;
|
|
569
|
-
})(),
|
|
576
|
+
})(), se = (function(n) {
|
|
570
577
|
T(t, n);
|
|
571
578
|
function t(e, r, s) {
|
|
572
579
|
var o = n.call(this) || this, i;
|
|
@@ -577,7 +584,7 @@ var se = (function(n) {
|
|
|
577
584
|
} : i = e, o.destination = new ct(i), o;
|
|
578
585
|
}
|
|
579
586
|
return t;
|
|
580
|
-
})(
|
|
587
|
+
})(oe);
|
|
581
588
|
function B(n) {
|
|
582
589
|
Oe(n);
|
|
583
590
|
}
|
|
@@ -586,10 +593,10 @@ function ut(n) {
|
|
|
586
593
|
}
|
|
587
594
|
var lt = {
|
|
588
595
|
closed: !0,
|
|
589
|
-
next:
|
|
596
|
+
next: re,
|
|
590
597
|
error: ut,
|
|
591
|
-
complete:
|
|
592
|
-
},
|
|
598
|
+
complete: re
|
|
599
|
+
}, ie = (function() {
|
|
593
600
|
return typeof Symbol == "function" && Symbol.observable || "@@observable";
|
|
594
601
|
})();
|
|
595
602
|
function W(n) {
|
|
@@ -610,7 +617,7 @@ var S = (function() {
|
|
|
610
617
|
var e = new n();
|
|
611
618
|
return e.source = this, e.operator = t, e;
|
|
612
619
|
}, n.prototype.subscribe = function(t, e, r) {
|
|
613
|
-
var s = this, o = ft(t) ? t : new
|
|
620
|
+
var s = this, o = ft(t) ? t : new se(t, e, r);
|
|
614
621
|
return G(function() {
|
|
615
622
|
var i = s, a = i.operator, c = i.source;
|
|
616
623
|
o.add(a ? a.call(o, c) : c ? s._subscribe(o) : s._trySubscribe(o));
|
|
@@ -623,8 +630,8 @@ var S = (function() {
|
|
|
623
630
|
}
|
|
624
631
|
}, n.prototype.forEach = function(t, e) {
|
|
625
632
|
var r = this;
|
|
626
|
-
return e =
|
|
627
|
-
var i = new
|
|
633
|
+
return e = he(e), new e(function(s, o) {
|
|
634
|
+
var i = new se({
|
|
628
635
|
next: function(a) {
|
|
629
636
|
try {
|
|
630
637
|
t(a);
|
|
@@ -640,7 +647,7 @@ var S = (function() {
|
|
|
640
647
|
}, n.prototype._subscribe = function(t) {
|
|
641
648
|
var e;
|
|
642
649
|
return (e = this.source) === null || e === void 0 ? void 0 : e.subscribe(t);
|
|
643
|
-
}, n.prototype[
|
|
650
|
+
}, n.prototype[ie] = function() {
|
|
644
651
|
return this;
|
|
645
652
|
}, n.prototype.pipe = function() {
|
|
646
653
|
for (var t = [], e = 0; e < arguments.length; e++)
|
|
@@ -648,7 +655,7 @@ var S = (function() {
|
|
|
648
655
|
return dt(t)(this);
|
|
649
656
|
}, n.prototype.toPromise = function(t) {
|
|
650
657
|
var e = this;
|
|
651
|
-
return t =
|
|
658
|
+
return t = he(t), new t(function(r, s) {
|
|
652
659
|
var o;
|
|
653
660
|
e.subscribe(function(i) {
|
|
654
661
|
return o = i;
|
|
@@ -662,7 +669,7 @@ var S = (function() {
|
|
|
662
669
|
return new n(t);
|
|
663
670
|
}, n;
|
|
664
671
|
})();
|
|
665
|
-
function
|
|
672
|
+
function he(n) {
|
|
666
673
|
var t;
|
|
667
674
|
return (t = n ?? it.Promise) !== null && t !== void 0 ? t : Promise;
|
|
668
675
|
}
|
|
@@ -670,7 +677,7 @@ function ht(n) {
|
|
|
670
677
|
return n && g(n.next) && g(n.error) && g(n.complete);
|
|
671
678
|
}
|
|
672
679
|
function ft(n) {
|
|
673
|
-
return n && n instanceof
|
|
680
|
+
return n && n instanceof oe || ht(n) && xe(n);
|
|
674
681
|
}
|
|
675
682
|
function pt(n) {
|
|
676
683
|
return g(n?.lift);
|
|
@@ -726,18 +733,18 @@ var mt = (function(n) {
|
|
|
726
733
|
n.prototype.unsubscribe.call(this), !r && ((e = this.onFinalize) === null || e === void 0 || e.call(this));
|
|
727
734
|
}
|
|
728
735
|
}, t;
|
|
729
|
-
})(
|
|
736
|
+
})(oe), gt = Te(function(n) {
|
|
730
737
|
return function() {
|
|
731
738
|
n(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
|
|
732
739
|
};
|
|
733
|
-
}),
|
|
740
|
+
}), ae = (function(n) {
|
|
734
741
|
T(t, n);
|
|
735
742
|
function t() {
|
|
736
743
|
var e = n.call(this) || this;
|
|
737
744
|
return e.closed = !1, e.currentObservers = null, e.observers = [], e.isStopped = !1, e.hasError = !1, e.thrownError = null, e;
|
|
738
745
|
}
|
|
739
746
|
return t.prototype.lift = function(e) {
|
|
740
|
-
var r = new
|
|
747
|
+
var r = new fe(this, this);
|
|
741
748
|
return r.operator = e, r;
|
|
742
749
|
}, t.prototype._throwIfClosed = function() {
|
|
743
750
|
if (this.closed)
|
|
@@ -807,9 +814,9 @@ var mt = (function(n) {
|
|
|
807
814
|
var e = new S();
|
|
808
815
|
return e.source = this, e;
|
|
809
816
|
}, t.create = function(e, r) {
|
|
810
|
-
return new
|
|
817
|
+
return new fe(e, r);
|
|
811
818
|
}, t;
|
|
812
|
-
})(S),
|
|
819
|
+
})(S), fe = (function(n) {
|
|
813
820
|
T(t, n);
|
|
814
821
|
function t(e, r) {
|
|
815
822
|
var s = n.call(this) || this;
|
|
@@ -828,7 +835,7 @@ var mt = (function(n) {
|
|
|
828
835
|
var r, s;
|
|
829
836
|
return (s = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(e)) !== null && s !== void 0 ? s : Ce;
|
|
830
837
|
}, t;
|
|
831
|
-
})(
|
|
838
|
+
})(ae), x = (function(n) {
|
|
832
839
|
T(t, n);
|
|
833
840
|
function t(e) {
|
|
834
841
|
var r = n.call(this) || this;
|
|
@@ -851,7 +858,7 @@ var mt = (function(n) {
|
|
|
851
858
|
}, t.prototype.next = function(e) {
|
|
852
859
|
n.prototype.next.call(this, this._value = e);
|
|
853
860
|
}, t;
|
|
854
|
-
})(
|
|
861
|
+
})(ae), bt = {
|
|
855
862
|
now: function() {
|
|
856
863
|
return Date.now();
|
|
857
864
|
}
|
|
@@ -863,7 +870,7 @@ var mt = (function(n) {
|
|
|
863
870
|
return t.prototype.schedule = function(e, r) {
|
|
864
871
|
return this;
|
|
865
872
|
}, t;
|
|
866
|
-
})(j),
|
|
873
|
+
})(j), pe = {
|
|
867
874
|
setInterval: function(n, t) {
|
|
868
875
|
for (var e = [], r = 2; r < arguments.length; r++)
|
|
869
876
|
e[r - 2] = arguments[r];
|
|
@@ -887,11 +894,11 @@ var mt = (function(n) {
|
|
|
887
894
|
var o = this.id, i = this.scheduler;
|
|
888
895
|
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;
|
|
889
896
|
}, t.prototype.requestAsyncId = function(e, r, s) {
|
|
890
|
-
return s === void 0 && (s = 0),
|
|
897
|
+
return s === void 0 && (s = 0), pe.setInterval(e.flush.bind(e, this), s);
|
|
891
898
|
}, t.prototype.recycleAsyncId = function(e, r, s) {
|
|
892
899
|
if (s === void 0 && (s = 0), s != null && this.delay === s && this.pending === !1)
|
|
893
900
|
return r;
|
|
894
|
-
r != null &&
|
|
901
|
+
r != null && pe.clearInterval(r);
|
|
895
902
|
}, t.prototype.execute = function(e, r) {
|
|
896
903
|
if (this.closed)
|
|
897
904
|
return new Error("executing a cancelled action");
|
|
@@ -915,7 +922,7 @@ var mt = (function(n) {
|
|
|
915
922
|
this.work = this.state = this.scheduler = null, this.pending = !1, K(o, this), r != null && (this.id = this.recycleAsyncId(s, r, null)), this.delay = null, n.prototype.unsubscribe.call(this);
|
|
916
923
|
}
|
|
917
924
|
}, t;
|
|
918
|
-
})(vt),
|
|
925
|
+
})(vt), me = (function() {
|
|
919
926
|
function n(t, e) {
|
|
920
927
|
e === void 0 && (e = n.now), this.schedulerActionCtor = t, this.now = e;
|
|
921
928
|
}
|
|
@@ -925,7 +932,7 @@ var mt = (function(n) {
|
|
|
925
932
|
})(), St = (function(n) {
|
|
926
933
|
T(t, n);
|
|
927
934
|
function t(e, r) {
|
|
928
|
-
r === void 0 && (r =
|
|
935
|
+
r === void 0 && (r = me.now);
|
|
929
936
|
var s = n.call(this, e, r) || this;
|
|
930
937
|
return s.actions = [], s._active = !1, s;
|
|
931
938
|
}
|
|
@@ -947,20 +954,20 @@ var mt = (function(n) {
|
|
|
947
954
|
throw s;
|
|
948
955
|
}
|
|
949
956
|
}, t;
|
|
950
|
-
})(
|
|
957
|
+
})(me), Ae = new St(yt), wt = Ae, Et = new S(function(n) {
|
|
951
958
|
return n.complete();
|
|
952
959
|
});
|
|
953
960
|
function Pe(n) {
|
|
954
961
|
return n && g(n.schedule);
|
|
955
962
|
}
|
|
956
|
-
function
|
|
963
|
+
function Le(n) {
|
|
957
964
|
return n[n.length - 1];
|
|
958
965
|
}
|
|
959
966
|
function It(n) {
|
|
960
|
-
return g(
|
|
967
|
+
return g(Le(n)) ? n.pop() : void 0;
|
|
961
968
|
}
|
|
962
|
-
function
|
|
963
|
-
return Pe(
|
|
969
|
+
function _e(n) {
|
|
970
|
+
return Pe(Le(n)) ? n.pop() : void 0;
|
|
964
971
|
}
|
|
965
972
|
var Ue = (function(n) {
|
|
966
973
|
return n && typeof n.length == "number" && typeof n != "function";
|
|
@@ -969,7 +976,7 @@ function Me(n) {
|
|
|
969
976
|
return g(n?.then);
|
|
970
977
|
}
|
|
971
978
|
function ke(n) {
|
|
972
|
-
return g(n[
|
|
979
|
+
return g(n[ie]);
|
|
973
980
|
}
|
|
974
981
|
function Ne(n) {
|
|
975
982
|
return Symbol.asyncIterator && g(n?.[Symbol.asyncIterator]);
|
|
@@ -1039,7 +1046,7 @@ function U(n) {
|
|
|
1039
1046
|
}
|
|
1040
1047
|
function Ct(n) {
|
|
1041
1048
|
return new S(function(t) {
|
|
1042
|
-
var e = n[
|
|
1049
|
+
var e = n[ie]();
|
|
1043
1050
|
if (g(e.subscribe))
|
|
1044
1051
|
return e.subscribe(t);
|
|
1045
1052
|
throw new TypeError("Provided object does not correctly implement Symbol.observable");
|
|
@@ -1084,7 +1091,7 @@ function At(n) {
|
|
|
1084
1091
|
}
|
|
1085
1092
|
function He(n) {
|
|
1086
1093
|
return new S(function(t) {
|
|
1087
|
-
|
|
1094
|
+
Lt(n, t).catch(function(e) {
|
|
1088
1095
|
return t.error(e);
|
|
1089
1096
|
});
|
|
1090
1097
|
});
|
|
@@ -1092,7 +1099,7 @@ function He(n) {
|
|
|
1092
1099
|
function Pt(n) {
|
|
1093
1100
|
return He(De(n));
|
|
1094
1101
|
}
|
|
1095
|
-
function
|
|
1102
|
+
function Lt(n, t) {
|
|
1096
1103
|
var e, r, s, o;
|
|
1097
1104
|
return rt(this, void 0, void 0, function() {
|
|
1098
1105
|
var i, a;
|
|
@@ -1162,7 +1169,7 @@ function Ge(n, t) {
|
|
|
1162
1169
|
}, t));
|
|
1163
1170
|
});
|
|
1164
1171
|
}
|
|
1165
|
-
function
|
|
1172
|
+
function _t(n, t) {
|
|
1166
1173
|
return U(n).pipe(Ge(t), Be(t));
|
|
1167
1174
|
}
|
|
1168
1175
|
function Ut(n, t) {
|
|
@@ -1215,7 +1222,7 @@ function Nt(n, t) {
|
|
|
1215
1222
|
function Rt(n, t) {
|
|
1216
1223
|
if (n != null) {
|
|
1217
1224
|
if (ke(n))
|
|
1218
|
-
return
|
|
1225
|
+
return _t(n, t);
|
|
1219
1226
|
if (Ue(n))
|
|
1220
1227
|
return Mt(n, t);
|
|
1221
1228
|
if (Me(n))
|
|
@@ -1229,14 +1236,14 @@ function Rt(n, t) {
|
|
|
1229
1236
|
}
|
|
1230
1237
|
throw Re(n);
|
|
1231
1238
|
}
|
|
1232
|
-
function
|
|
1239
|
+
function ce(n, t) {
|
|
1233
1240
|
return t ? Rt(n, t) : U(n);
|
|
1234
1241
|
}
|
|
1235
1242
|
function jt() {
|
|
1236
1243
|
for (var n = [], t = 0; t < arguments.length; t++)
|
|
1237
1244
|
n[t] = arguments[t];
|
|
1238
|
-
var e =
|
|
1239
|
-
return
|
|
1245
|
+
var e = _e(n);
|
|
1246
|
+
return ce(n, e);
|
|
1240
1247
|
}
|
|
1241
1248
|
function $t(n) {
|
|
1242
1249
|
return n instanceof Date && !isNaN(n);
|
|
@@ -1287,9 +1294,9 @@ function Xt(n, t) {
|
|
|
1287
1294
|
function Vt() {
|
|
1288
1295
|
for (var n = [], t = 0; t < arguments.length; t++)
|
|
1289
1296
|
n[t] = arguments[t];
|
|
1290
|
-
var e =
|
|
1297
|
+
var e = _e(n), r = It(n), s = Yt(n), o = s.args, i = s.keys;
|
|
1291
1298
|
if (o.length === 0)
|
|
1292
|
-
return
|
|
1299
|
+
return ce([], e);
|
|
1293
1300
|
var a = new S(zt(o, e, i ? function(c) {
|
|
1294
1301
|
return Xt(i, c);
|
|
1295
1302
|
} : W));
|
|
@@ -1297,12 +1304,12 @@ function Vt() {
|
|
|
1297
1304
|
}
|
|
1298
1305
|
function zt(n, t, e) {
|
|
1299
1306
|
return e === void 0 && (e = W), function(r) {
|
|
1300
|
-
|
|
1307
|
+
ge(t, function() {
|
|
1301
1308
|
for (var s = n.length, o = new Array(s), i = s, a = s, c = function(h) {
|
|
1302
|
-
|
|
1303
|
-
var m =
|
|
1309
|
+
ge(t, function() {
|
|
1310
|
+
var m = ce(n[h], t), v = !1;
|
|
1304
1311
|
m.subscribe(A(r, function(d) {
|
|
1305
|
-
o[h] = d,
|
|
1312
|
+
o[h] = d, v || (v = !0, a--), a || r.next(e(o.slice()));
|
|
1306
1313
|
}, function() {
|
|
1307
1314
|
--i || r.complete();
|
|
1308
1315
|
}));
|
|
@@ -1312,38 +1319,38 @@ function zt(n, t, e) {
|
|
|
1312
1319
|
}, r);
|
|
1313
1320
|
};
|
|
1314
1321
|
}
|
|
1315
|
-
function
|
|
1322
|
+
function ge(n, t, e) {
|
|
1316
1323
|
n ? O(e, n, t) : t();
|
|
1317
1324
|
}
|
|
1318
1325
|
function Jt(n, t, e, r, s, o, i, a) {
|
|
1319
|
-
var c = [], u = 0, h = 0, m = !1,
|
|
1326
|
+
var c = [], u = 0, h = 0, m = !1, v = function() {
|
|
1320
1327
|
m && !c.length && !u && t.complete();
|
|
1321
1328
|
}, d = function(f) {
|
|
1322
1329
|
return u < r ? p(f) : c.push(f);
|
|
1323
1330
|
}, p = function(f) {
|
|
1324
1331
|
u++;
|
|
1325
|
-
var
|
|
1332
|
+
var L = !1;
|
|
1326
1333
|
U(e(f, h++)).subscribe(A(t, function(E) {
|
|
1327
1334
|
t.next(E);
|
|
1328
1335
|
}, function() {
|
|
1329
|
-
|
|
1336
|
+
L = !0;
|
|
1330
1337
|
}, void 0, function() {
|
|
1331
|
-
if (
|
|
1338
|
+
if (L)
|
|
1332
1339
|
try {
|
|
1333
1340
|
u--;
|
|
1334
1341
|
for (var E = function() {
|
|
1335
|
-
var
|
|
1336
|
-
i || p(
|
|
1342
|
+
var _ = c.shift();
|
|
1343
|
+
i || p(_);
|
|
1337
1344
|
}; c.length && u < r; )
|
|
1338
1345
|
E();
|
|
1339
|
-
|
|
1340
|
-
} catch (
|
|
1341
|
-
t.error(
|
|
1346
|
+
v();
|
|
1347
|
+
} catch (_) {
|
|
1348
|
+
t.error(_);
|
|
1342
1349
|
}
|
|
1343
1350
|
}));
|
|
1344
1351
|
};
|
|
1345
1352
|
return n.subscribe(A(t, d, function() {
|
|
1346
|
-
m = !0,
|
|
1353
|
+
m = !0, v();
|
|
1347
1354
|
})), function() {
|
|
1348
1355
|
};
|
|
1349
1356
|
}
|
|
@@ -1423,23 +1430,23 @@ function an(n) {
|
|
|
1423
1430
|
return P(function(t, e) {
|
|
1424
1431
|
U(n).subscribe(A(e, function() {
|
|
1425
1432
|
return e.complete();
|
|
1426
|
-
},
|
|
1433
|
+
}, re)), !e.closed && t.subscribe(e);
|
|
1427
1434
|
});
|
|
1428
1435
|
}
|
|
1429
|
-
function
|
|
1436
|
+
function be(n) {
|
|
1430
1437
|
const { endpoint: t, apiKey: e, payload: r, debugMode: s, customHeaders: o } = n, i = n.method ?? "POST";
|
|
1431
1438
|
return new S((a) => {
|
|
1432
1439
|
const c = new AbortController();
|
|
1433
1440
|
let u, h = !1, m = !1;
|
|
1434
|
-
const
|
|
1441
|
+
const v = {
|
|
1435
1442
|
"Content-Type": "application/json",
|
|
1436
1443
|
...o
|
|
1437
1444
|
};
|
|
1438
|
-
e && (
|
|
1445
|
+
e && (v["X-API-KEY"] = e);
|
|
1439
1446
|
const d = new URL(t);
|
|
1440
1447
|
return s && d.searchParams.set("is_debug", "true"), Ee(d.toString(), {
|
|
1441
1448
|
method: i,
|
|
1442
|
-
headers:
|
|
1449
|
+
headers: v,
|
|
1443
1450
|
body: i === "POST" && r ? JSON.stringify(r) : void 0,
|
|
1444
1451
|
signal: c.signal,
|
|
1445
1452
|
/**
|
|
@@ -1506,7 +1513,7 @@ class Mn {
|
|
|
1506
1513
|
endpoint;
|
|
1507
1514
|
botProviderEndpoint;
|
|
1508
1515
|
debugMode;
|
|
1509
|
-
destroy$ = new
|
|
1516
|
+
destroy$ = new ae();
|
|
1510
1517
|
closed = !1;
|
|
1511
1518
|
detached = !1;
|
|
1512
1519
|
detachTimer;
|
|
@@ -1564,7 +1571,7 @@ class Mn {
|
|
|
1564
1571
|
}
|
|
1565
1572
|
fetchSse(t, e) {
|
|
1566
1573
|
return e?.onSseStart?.(), this.inFlight += 1, this.runSse(
|
|
1567
|
-
|
|
1574
|
+
be({
|
|
1568
1575
|
apiKey: this.apiKey,
|
|
1569
1576
|
endpoint: this.endpoint,
|
|
1570
1577
|
debugMode: this.debugMode,
|
|
@@ -1583,7 +1590,7 @@ class Mn {
|
|
|
1583
1590
|
e?.onSseStart?.(), this.inFlight += 1;
|
|
1584
1591
|
const r = new URL(this.endpoint);
|
|
1585
1592
|
return r.searchParams.set("custom_channel_id", t), this.runSse(
|
|
1586
|
-
|
|
1593
|
+
be({
|
|
1587
1594
|
apiKey: this.apiKey,
|
|
1588
1595
|
endpoint: r.toString(),
|
|
1589
1596
|
debugMode: this.debugMode,
|
|
@@ -1967,7 +1974,7 @@ function dn() {
|
|
|
1967
1974
|
}
|
|
1968
1975
|
return J(ln);
|
|
1969
1976
|
}
|
|
1970
|
-
const hn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto),
|
|
1977
|
+
const hn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), ve = { randomUUID: hn };
|
|
1971
1978
|
function fn(n, t, e) {
|
|
1972
1979
|
n = n || {};
|
|
1973
1980
|
const r = n.random ?? n.rng?.() ?? dn();
|
|
@@ -1976,9 +1983,9 @@ function fn(n, t, e) {
|
|
|
1976
1983
|
return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, un(r);
|
|
1977
1984
|
}
|
|
1978
1985
|
function Ke(n, t, e) {
|
|
1979
|
-
return
|
|
1986
|
+
return ve.randomUUID && !n ? ve.randomUUID() : fn(n);
|
|
1980
1987
|
}
|
|
1981
|
-
class
|
|
1988
|
+
class b {
|
|
1982
1989
|
messages = null;
|
|
1983
1990
|
pendingConsent = null;
|
|
1984
1991
|
constructor({ messages: t, pendingConsent: e = null }) {
|
|
@@ -1986,10 +1993,18 @@ class v {
|
|
|
1986
1993
|
}
|
|
1987
1994
|
pushMessage(t) {
|
|
1988
1995
|
const e = new Map(this.messages);
|
|
1989
|
-
return e.set(t.messageId, t), new
|
|
1996
|
+
return e.set(t.messageId, t), new b({ messages: e, pendingConsent: this.pendingConsent });
|
|
1990
1997
|
}
|
|
1991
1998
|
clearPendingConsent() {
|
|
1992
|
-
return this.pendingConsent ? new
|
|
1999
|
+
return this.pendingConsent ? new b({ messages: this.messages, pendingConsent: null }) : this;
|
|
2000
|
+
}
|
|
2001
|
+
/**
|
|
2002
|
+
* Put a consent prompt back (#410) — the mirror of {@link clearPendingConsent}, used to undo the
|
|
2003
|
+
* optimistic clear when the reply never reaches the server. Yields to a prompt that arrived in the
|
|
2004
|
+
* meantime: that one is newer than the batch being restored.
|
|
2005
|
+
*/
|
|
2006
|
+
restorePendingConsent(t) {
|
|
2007
|
+
return this.pendingConsent ? this : new b({ messages: this.messages, pendingConsent: t });
|
|
1993
2008
|
}
|
|
1994
2009
|
/**
|
|
1995
2010
|
* Converge everything the aborted run left mid-flight (F-020 AC10, F-023). A stopped run sends no
|
|
@@ -2010,7 +2025,7 @@ class v {
|
|
|
2010
2025
|
const e = new Map(this.messages);
|
|
2011
2026
|
for (const [r, s] of e)
|
|
2012
2027
|
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);
|
|
2013
|
-
return t ? new
|
|
2028
|
+
return t ? new b({ messages: e, pendingConsent: this.pendingConsent }) : this;
|
|
2014
2029
|
}
|
|
2015
2030
|
/**
|
|
2016
2031
|
* @deprecated Renamed to {@link settleInFlightMessages} in 0.3.27 — it settles in-flight thinking
|
|
@@ -2092,7 +2107,7 @@ class v {
|
|
|
2092
2107
|
time: /* @__PURE__ */ new Date(),
|
|
2093
2108
|
traceId: t.traceId,
|
|
2094
2109
|
raw: ""
|
|
2095
|
-
}), new
|
|
2110
|
+
}), new b({ messages: r, pendingConsent: this.pendingConsent });
|
|
2096
2111
|
}
|
|
2097
2112
|
onMessageDelta(t) {
|
|
2098
2113
|
const e = t.fact.messageDelta.message;
|
|
@@ -2110,7 +2125,7 @@ class v {
|
|
|
2110
2125
|
time: /* @__PURE__ */ new Date(),
|
|
2111
2126
|
traceId: t.traceId ?? s?.traceId,
|
|
2112
2127
|
raw: s?.raw ?? ""
|
|
2113
|
-
}), new
|
|
2128
|
+
}), new b({ messages: o, pendingConsent: this.pendingConsent });
|
|
2114
2129
|
}
|
|
2115
2130
|
onMessageComplete(t) {
|
|
2116
2131
|
const e = t.fact.messageComplete.message;
|
|
@@ -2126,7 +2141,7 @@ class v {
|
|
|
2126
2141
|
time: /* @__PURE__ */ new Date(),
|
|
2127
2142
|
traceId: t.traceId ?? (s?.type === "bot" ? s.traceId : void 0),
|
|
2128
2143
|
raw: JSON.stringify(t)
|
|
2129
|
-
}), new
|
|
2144
|
+
}), new b({ messages: r, pendingConsent: this.pendingConsent });
|
|
2130
2145
|
}
|
|
2131
2146
|
onThinkingStart(t) {
|
|
2132
2147
|
const e = t.fact.messageThinkingStart.message;
|
|
@@ -2140,7 +2155,7 @@ class v {
|
|
|
2140
2155
|
time: /* @__PURE__ */ new Date(),
|
|
2141
2156
|
traceId: t.traceId
|
|
2142
2157
|
};
|
|
2143
|
-
return r.set(e.messageId, s), new
|
|
2158
|
+
return r.set(e.messageId, s), new b({ messages: r, pendingConsent: this.pendingConsent });
|
|
2144
2159
|
}
|
|
2145
2160
|
onThinkingDelta(t) {
|
|
2146
2161
|
const e = t.fact.messageThinkingDelta.message;
|
|
@@ -2155,7 +2170,7 @@ class v {
|
|
|
2155
2170
|
time: s?.time ?? /* @__PURE__ */ new Date(),
|
|
2156
2171
|
traceId: t.traceId ?? s?.traceId
|
|
2157
2172
|
};
|
|
2158
|
-
return o.set(e.messageId, i), new
|
|
2173
|
+
return o.set(e.messageId, i), new b({ messages: o, pendingConsent: this.pendingConsent });
|
|
2159
2174
|
}
|
|
2160
2175
|
onThinkingComplete(t) {
|
|
2161
2176
|
const e = t.fact.messageThinkingComplete.message;
|
|
@@ -2170,7 +2185,7 @@ class v {
|
|
|
2170
2185
|
time: s?.time ?? /* @__PURE__ */ new Date(),
|
|
2171
2186
|
traceId: t.traceId ?? s?.traceId
|
|
2172
2187
|
};
|
|
2173
|
-
return o.set(e.messageId, i), new
|
|
2188
|
+
return o.set(e.messageId, i), new b({ messages: o, pendingConsent: this.pendingConsent });
|
|
2174
2189
|
}
|
|
2175
2190
|
onMessageUser(t) {
|
|
2176
2191
|
const e = t.fact.messageUser;
|
|
@@ -2185,7 +2200,7 @@ class v {
|
|
|
2185
2200
|
time: /* @__PURE__ */ new Date(),
|
|
2186
2201
|
traceId: t.traceId
|
|
2187
2202
|
};
|
|
2188
|
-
return s.set(e.messageId, o), new
|
|
2203
|
+
return s.set(e.messageId, o), new b({ messages: s, pendingConsent: this.pendingConsent });
|
|
2189
2204
|
}
|
|
2190
2205
|
onMessageError(t) {
|
|
2191
2206
|
const e = Ke(), r = t.fact.runError.error, s = new Map(this.messages);
|
|
@@ -2196,7 +2211,7 @@ class v {
|
|
|
2196
2211
|
error: r,
|
|
2197
2212
|
time: /* @__PURE__ */ new Date(),
|
|
2198
2213
|
traceId: t.traceId
|
|
2199
|
-
}), new
|
|
2214
|
+
}), new b({ messages: s, pendingConsent: this.pendingConsent });
|
|
2200
2215
|
}
|
|
2201
2216
|
onToolCallStart(t) {
|
|
2202
2217
|
const e = t.fact.toolCallStart, r = new Map(this.messages), s = `${e.processId}-${e.callSeq}`;
|
|
@@ -2217,7 +2232,7 @@ class v {
|
|
|
2217
2232
|
time: /* @__PURE__ */ new Date(),
|
|
2218
2233
|
traceId: t.traceId
|
|
2219
2234
|
};
|
|
2220
|
-
return r.set(s, o), new
|
|
2235
|
+
return r.set(s, o), new b({ messages: r, pendingConsent: this.pendingConsent });
|
|
2221
2236
|
}
|
|
2222
2237
|
onToolCallComplete(t) {
|
|
2223
2238
|
const e = t.fact.toolCallComplete, r = new Map(this.messages), s = `${e.processId}-${e.callSeq}`, o = r.get(s);
|
|
@@ -2254,11 +2269,11 @@ class v {
|
|
|
2254
2269
|
};
|
|
2255
2270
|
r.set(s, i);
|
|
2256
2271
|
}
|
|
2257
|
-
return new
|
|
2272
|
+
return new b({ messages: r, pendingConsent: this.pendingConsent });
|
|
2258
2273
|
}
|
|
2259
2274
|
onToolCallConsent(t) {
|
|
2260
2275
|
const e = t.fact.toolCallConsent;
|
|
2261
|
-
return new
|
|
2276
|
+
return new b({ messages: this.messages, pendingConsent: e });
|
|
2262
2277
|
}
|
|
2263
2278
|
onSubagentStart(t) {
|
|
2264
2279
|
const e = t.fact.subagentStart, r = new Map(this.messages), s = `subagent:${e.parentToolUseId}:start`, o = {
|
|
@@ -2272,7 +2287,7 @@ class v {
|
|
|
2272
2287
|
time: /* @__PURE__ */ new Date(),
|
|
2273
2288
|
traceId: t.traceId
|
|
2274
2289
|
};
|
|
2275
|
-
return r.delete(s), r.set(s, o), new
|
|
2290
|
+
return r.delete(s), r.set(s, o), new b({ messages: r, pendingConsent: this.pendingConsent });
|
|
2276
2291
|
}
|
|
2277
2292
|
onSubagentComplete(t) {
|
|
2278
2293
|
const e = t.fact.subagentComplete, r = new Map(this.messages), s = `subagent:${e.parentToolUseId}:complete`, o = {
|
|
@@ -2287,14 +2302,14 @@ class v {
|
|
|
2287
2302
|
time: /* @__PURE__ */ new Date(),
|
|
2288
2303
|
traceId: t.traceId
|
|
2289
2304
|
};
|
|
2290
|
-
return r.delete(s), r.set(s, o), new
|
|
2305
|
+
return r.delete(s), r.set(s, o), new b({ messages: r, pendingConsent: this.pendingConsent });
|
|
2291
2306
|
}
|
|
2292
2307
|
}
|
|
2293
2308
|
const pn = /* @__PURE__ */ new Set(["TaskCreate", "TaskUpdate"]);
|
|
2294
2309
|
function mn(n) {
|
|
2295
2310
|
return n.toolsetName === "" && pn.has(n.toolName);
|
|
2296
2311
|
}
|
|
2297
|
-
function
|
|
2312
|
+
function ye(n) {
|
|
2298
2313
|
return typeof n == "object" && n !== null ? n : void 0;
|
|
2299
2314
|
}
|
|
2300
2315
|
function I(n) {
|
|
@@ -2305,7 +2320,7 @@ function gn(n) {
|
|
|
2305
2320
|
for (const r of n) {
|
|
2306
2321
|
const s = r.parameter ?? {}, o = r.sidecar ?? {};
|
|
2307
2322
|
if (r.toolName === "TaskCreate") {
|
|
2308
|
-
const i =
|
|
2323
|
+
const i = ye(o.task), a = I(i?.id);
|
|
2309
2324
|
if (!a) continue;
|
|
2310
2325
|
e.has(a) || t.push(a), e.set(a, {
|
|
2311
2326
|
id: a,
|
|
@@ -2316,7 +2331,7 @@ function gn(n) {
|
|
|
2316
2331
|
// initial status = pending (keep existing on repeat)
|
|
2317
2332
|
});
|
|
2318
2333
|
} else if (r.toolName === "TaskUpdate") {
|
|
2319
|
-
const i =
|
|
2334
|
+
const i = ye(o.statusChange), a = I(s.taskId) || I(o.taskId), c = I(i?.to) || I(s.status);
|
|
2320
2335
|
if (!a || !c) continue;
|
|
2321
2336
|
const u = e.get(a);
|
|
2322
2337
|
u && e.set(a, { ...u, status: c });
|
|
@@ -2330,7 +2345,7 @@ function bn(n) {
|
|
|
2330
2345
|
function vn(n) {
|
|
2331
2346
|
return !!n;
|
|
2332
2347
|
}
|
|
2333
|
-
function
|
|
2348
|
+
function Se(n) {
|
|
2334
2349
|
n.status !== "running" && (n.status = "running", n.summary = void 0);
|
|
2335
2350
|
}
|
|
2336
2351
|
function yn(n) {
|
|
@@ -2344,11 +2359,11 @@ function yn(n) {
|
|
|
2344
2359
|
}
|
|
2345
2360
|
case "subagentStart": {
|
|
2346
2361
|
const i = s(o.parentToolUseId);
|
|
2347
|
-
i.agentId = o.agentId ?? i.agentId, i.subagentType = o.subagentType ?? i.subagentType, i.description = o.description ?? i.description,
|
|
2362
|
+
i.agentId = o.agentId ?? i.agentId, i.subagentType = o.subagentType ?? i.subagentType, i.description = o.description ?? i.description, Se(i);
|
|
2348
2363
|
break;
|
|
2349
2364
|
}
|
|
2350
2365
|
case "toolStart": {
|
|
2351
|
-
|
|
2366
|
+
Se(s(o.parentToolUseId)), r.get(o.parentToolUseId).set(o.toolUseId, {
|
|
2352
2367
|
toolsetName: o.toolsetName,
|
|
2353
2368
|
toolName: o.toolName,
|
|
2354
2369
|
parameter: o.parameter ?? {},
|
|
@@ -2464,7 +2479,7 @@ function On(n) {
|
|
|
2464
2479
|
teardown: () => r.unsubscribe()
|
|
2465
2480
|
};
|
|
2466
2481
|
}
|
|
2467
|
-
function
|
|
2482
|
+
function we(n) {
|
|
2468
2483
|
const t = /* @__PURE__ */ new Map();
|
|
2469
2484
|
for (const e of n) t.set(e.sandboxName, e);
|
|
2470
2485
|
return [...t.values()].sort(
|
|
@@ -2529,7 +2544,7 @@ class q {
|
|
|
2529
2544
|
if (!t.customChannelId)
|
|
2530
2545
|
throw new Error("customChannelId must be required");
|
|
2531
2546
|
this.client = t.client, this.customChannelId = t.customChannelId, this.customMessageId = t.customMessageId, this.joinRunState = t.runState ?? "IDLE", this.isConnecting$ = new x(!1), this.runStatusSubject = new x(Q), this.conversation$ = new x(t.conversation), this.channelTitleSubject = new x(t.channelTitle ?? null), this.sandboxPhaseSubject = new x("idle"), this.launchedSandboxesSubject = new x(
|
|
2532
|
-
|
|
2547
|
+
we(t.launchedSandboxes ?? [])
|
|
2533
2548
|
), this.derivedStores = On(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(Pn)), this.statesObserver = t.statesObserver;
|
|
2534
2549
|
}
|
|
2535
2550
|
/** Current Task Check List snapshot (F-013) — for framework-agnostic `getSnapshot()` bridging. */
|
|
@@ -2566,7 +2581,7 @@ class q {
|
|
|
2566
2581
|
* launch whose name now appears (promoted to live). metadata (heartbeat-backed) is the sole authority.
|
|
2567
2582
|
*/
|
|
2568
2583
|
applyLaunchedSandboxes(t) {
|
|
2569
|
-
const e =
|
|
2584
|
+
const e = we(t);
|
|
2570
2585
|
this.pendingLaunches = this.pendingLaunches.filter((r) => !e.some((s) => s.sandboxName === r)), this.launchedSandboxesSubject.next(e);
|
|
2571
2586
|
}
|
|
2572
2587
|
/**
|
|
@@ -2710,7 +2725,7 @@ class q {
|
|
|
2710
2725
|
...i,
|
|
2711
2726
|
traceId: s.traceId
|
|
2712
2727
|
}), this.conversation$.next(
|
|
2713
|
-
new
|
|
2728
|
+
new b({ messages: o, pendingConsent: this.conversation$.value.pendingConsent })
|
|
2714
2729
|
)), this.currentUserMessageId = void 0;
|
|
2715
2730
|
}
|
|
2716
2731
|
this.conversation$.next(this.conversation$.value.onMessage(s));
|
|
@@ -2780,7 +2795,7 @@ class q {
|
|
|
2780
2795
|
const r = this.runStatusSubject.value.kind;
|
|
2781
2796
|
if (r) return Promise.reject(new Z(r));
|
|
2782
2797
|
const s = this.conversation$.value.pendingConsent;
|
|
2783
|
-
if (s) return Promise.reject(new
|
|
2798
|
+
if (s) return Promise.reject(new ee(s.processId));
|
|
2784
2799
|
const o = t.text.trim(), i = t.customMessageId ?? Ke();
|
|
2785
2800
|
return this.currentUserMessageId = i, this.lastSentMessageId = i, this.conversation$.next(
|
|
2786
2801
|
this.conversation$.value.pushMessage({
|
|
@@ -2806,6 +2821,7 @@ class q {
|
|
|
2806
2821
|
);
|
|
2807
2822
|
}
|
|
2808
2823
|
replyToolCallConsents(t, e, r) {
|
|
2824
|
+
const s = this.conversation$.value.pendingConsent;
|
|
2809
2825
|
return this.conversation$.next(this.conversation$.value.clearPendingConsent()), this.fetchSse(
|
|
2810
2826
|
"user",
|
|
2811
2827
|
{
|
|
@@ -2817,7 +2833,9 @@ class q {
|
|
|
2817
2833
|
toolCallConsents: t
|
|
2818
2834
|
},
|
|
2819
2835
|
e
|
|
2820
|
-
)
|
|
2836
|
+
).catch((o) => {
|
|
2837
|
+
throw s && this.conversation$.next(this.conversation$.value.restorePendingConsent(s)), o;
|
|
2838
|
+
});
|
|
2821
2839
|
}
|
|
2822
2840
|
/**
|
|
2823
2841
|
* Nudge an idle / recycled sandbox back to life (F-021 AC4). Sends an `action=NUDGE` turn with empty
|
|
@@ -2836,11 +2854,14 @@ class q {
|
|
|
2836
2854
|
* function to compute it at send time. In `@asgard-js/react` this is filled in automatically from
|
|
2837
2855
|
* `onBeforeSendMessage`.
|
|
2838
2856
|
*
|
|
2839
|
-
* Rejects with `ChannelBusyError` when a run already holds the channel,
|
|
2857
|
+
* Rejects with `ChannelBusyError` when a run already holds the channel, and with
|
|
2858
|
+
* `ChannelAwaitingConsentError` while a consent prompt is pending — exactly like `sendMessage`.
|
|
2840
2859
|
*/
|
|
2841
2860
|
nudge(t, e) {
|
|
2842
2861
|
const r = this.runStatusSubject.value.kind;
|
|
2843
|
-
|
|
2862
|
+
if (r) return Promise.reject(new Z(r));
|
|
2863
|
+
const s = this.conversation$.value.pendingConsent;
|
|
2864
|
+
return s ? Promise.reject(new ee(s.processId)) : this.fetchSse(
|
|
2844
2865
|
"nudge",
|
|
2845
2866
|
{
|
|
2846
2867
|
action: $.NUDGE,
|
|
@@ -2940,9 +2961,9 @@ function kn(n) {
|
|
|
2940
2961
|
export {
|
|
2941
2962
|
Mn as AsgardServiceClient,
|
|
2942
2963
|
q as Channel,
|
|
2943
|
-
|
|
2964
|
+
ee as ChannelAwaitingConsentError,
|
|
2944
2965
|
Z as ChannelBusyError,
|
|
2945
|
-
|
|
2966
|
+
b as Conversation,
|
|
2946
2967
|
l as EventType,
|
|
2947
2968
|
$ as FetchSseAction,
|
|
2948
2969
|
w as HttpError,
|
|
@@ -2954,11 +2975,11 @@ export {
|
|
|
2954
2975
|
En as deriveTasks,
|
|
2955
2976
|
bn as isAgentTool,
|
|
2956
2977
|
Un as isChannelAwaitingConsentError,
|
|
2957
|
-
|
|
2958
|
-
|
|
2978
|
+
_n as isChannelBusyError,
|
|
2979
|
+
Ln as isHttpError,
|
|
2959
2980
|
vn as isSubagentChildTool,
|
|
2960
2981
|
mn as isTaskTool,
|
|
2961
|
-
|
|
2982
|
+
we as reconcileLaunched,
|
|
2962
2983
|
yn as reduceSubagents,
|
|
2963
2984
|
gn as reduceTaskEvents,
|
|
2964
2985
|
kn as resolveSandboxUri,
|