@asgard-js/core 0.3.37 → 0.3.39
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 +73 -41
- package/dist/index.mjs.map +1 -1
- package/dist/lib/conversation.d.ts +7 -0
- package/dist/lib/conversation.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -128,13 +128,13 @@ function Se(n, t) {
|
|
|
128
128
|
e?.addEventListener("abort", () => {
|
|
129
129
|
L(), m();
|
|
130
130
|
});
|
|
131
|
-
const
|
|
131
|
+
const qe = u ?? window.fetch, Ke = s ?? et;
|
|
132
132
|
async function X() {
|
|
133
133
|
var V;
|
|
134
134
|
p = new AbortController();
|
|
135
135
|
try {
|
|
136
|
-
const H = await
|
|
137
|
-
await
|
|
136
|
+
const H = await qe(n, Object.assign(Object.assign({}, h), { headers: d, signal: p.signal }));
|
|
137
|
+
await Ke(H), await Xe(H.body, Ve(ze((x) => {
|
|
138
138
|
x ? d[ue] = x : delete d[ue];
|
|
139
139
|
}, (x) => {
|
|
140
140
|
_ = x;
|
|
@@ -260,7 +260,7 @@ function we(n, t) {
|
|
|
260
260
|
return { value: u[0] ? u[1] : void 0, done: !0 };
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
|
-
function
|
|
263
|
+
function N(n) {
|
|
264
264
|
var t = typeof Symbol == "function" && Symbol.iterator, e = t && n[t], r = 0;
|
|
265
265
|
if (e) return e.call(n);
|
|
266
266
|
if (n && typeof n.length == "number") return {
|
|
@@ -336,7 +336,7 @@ function nt(n, t, e) {
|
|
|
336
336
|
function rt(n) {
|
|
337
337
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
338
338
|
var t = n[Symbol.asyncIterator], e;
|
|
339
|
-
return t ? t.call(n) : (n = typeof
|
|
339
|
+
return t ? t.call(n) : (n = typeof N == "function" ? N(n) : n[Symbol.iterator](), e = {}, r("next"), r("throw"), r("return"), e[Symbol.asyncIterator] = function() {
|
|
340
340
|
return this;
|
|
341
341
|
}, e);
|
|
342
342
|
function r(o) {
|
|
@@ -370,7 +370,7 @@ var z = Ee(function(n) {
|
|
|
370
370
|
`) : "", this.name = "UnsubscriptionError", this.errors = e;
|
|
371
371
|
};
|
|
372
372
|
});
|
|
373
|
-
function
|
|
373
|
+
function K(n, t) {
|
|
374
374
|
if (n) {
|
|
375
375
|
var e = n.indexOf(t);
|
|
376
376
|
0 <= e && n.splice(e, 1);
|
|
@@ -388,7 +388,7 @@ var j = (function() {
|
|
|
388
388
|
if (i)
|
|
389
389
|
if (this._parentage = null, Array.isArray(i))
|
|
390
390
|
try {
|
|
391
|
-
for (var a =
|
|
391
|
+
for (var a = N(i), c = a.next(); !c.done; c = a.next()) {
|
|
392
392
|
var u = c.value;
|
|
393
393
|
u.remove(this);
|
|
394
394
|
}
|
|
@@ -414,7 +414,7 @@ var j = (function() {
|
|
|
414
414
|
if (m) {
|
|
415
415
|
this._finalizers = null;
|
|
416
416
|
try {
|
|
417
|
-
for (var b =
|
|
417
|
+
for (var b = N(m), d = b.next(); !d.done; d = b.next()) {
|
|
418
418
|
var p = d.value;
|
|
419
419
|
try {
|
|
420
420
|
le(p);
|
|
@@ -456,10 +456,10 @@ var j = (function() {
|
|
|
456
456
|
this._parentage = Array.isArray(e) ? (e.push(t), e) : e ? [e, t] : t;
|
|
457
457
|
}, n.prototype._removeParent = function(t) {
|
|
458
458
|
var e = this._parentage;
|
|
459
|
-
e === t ? this._parentage = null : Array.isArray(e) &&
|
|
459
|
+
e === t ? this._parentage = null : Array.isArray(e) && K(e, t);
|
|
460
460
|
}, n.prototype.remove = function(t) {
|
|
461
461
|
var e = this._finalizers;
|
|
462
|
-
e &&
|
|
462
|
+
e && K(e, t), t instanceof n && t._removeParent(this);
|
|
463
463
|
}, n.EMPTY = (function() {
|
|
464
464
|
var t = new n();
|
|
465
465
|
return t.closed = !0, t;
|
|
@@ -739,7 +739,7 @@ var ft = (function(n) {
|
|
|
739
739
|
if (r._throwIfClosed(), !r.isStopped) {
|
|
740
740
|
r.currentObservers || (r.currentObservers = Array.from(r.observers));
|
|
741
741
|
try {
|
|
742
|
-
for (var i =
|
|
742
|
+
for (var i = N(r.currentObservers), a = i.next(); !a.done; a = i.next()) {
|
|
743
743
|
var c = a.value;
|
|
744
744
|
c.next(e);
|
|
745
745
|
}
|
|
@@ -788,7 +788,7 @@ var ft = (function(n) {
|
|
|
788
788
|
}, t.prototype._innerSubscribe = function(e) {
|
|
789
789
|
var r = this, s = this, o = s.hasError, i = s.isStopped, a = s.observers;
|
|
790
790
|
return o || i ? Ie : (this.currentObservers = null, a.push(e), new j(function() {
|
|
791
|
-
r.currentObservers = null,
|
|
791
|
+
r.currentObservers = null, K(a, e);
|
|
792
792
|
}));
|
|
793
793
|
}, t.prototype._checkFinalizedStatuses = function(e) {
|
|
794
794
|
var r = this, s = r.hasError, o = r.thrownError, i = r.isStopped;
|
|
@@ -902,7 +902,7 @@ var ft = (function(n) {
|
|
|
902
902
|
}, t.prototype.unsubscribe = function() {
|
|
903
903
|
if (!this.closed) {
|
|
904
904
|
var e = this, r = e.id, s = e.scheduler, o = s.actions;
|
|
905
|
-
this.work = this.state = this.scheduler = null, this.pending = !1,
|
|
905
|
+
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);
|
|
906
906
|
}
|
|
907
907
|
}, t;
|
|
908
908
|
})(gt), pe = (function() {
|
|
@@ -970,9 +970,9 @@ function ke(n) {
|
|
|
970
970
|
function Et() {
|
|
971
971
|
return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
|
|
972
972
|
}
|
|
973
|
-
var
|
|
974
|
-
function
|
|
975
|
-
return g(n?.[
|
|
973
|
+
var Ne = Et();
|
|
974
|
+
function Re(n) {
|
|
975
|
+
return g(n?.[Ne]);
|
|
976
976
|
}
|
|
977
977
|
function je(n) {
|
|
978
978
|
return nt(this, arguments, function() {
|
|
@@ -1020,7 +1020,7 @@ function U(n) {
|
|
|
1020
1020
|
return xt(n);
|
|
1021
1021
|
if (Me(n))
|
|
1022
1022
|
return De(n);
|
|
1023
|
-
if (
|
|
1023
|
+
if (Re(n))
|
|
1024
1024
|
return Ct(n);
|
|
1025
1025
|
if ($e(n))
|
|
1026
1026
|
return Ot(n);
|
|
@@ -1055,7 +1055,7 @@ function Ct(n) {
|
|
|
1055
1055
|
return new S(function(t) {
|
|
1056
1056
|
var e, r;
|
|
1057
1057
|
try {
|
|
1058
|
-
for (var s =
|
|
1058
|
+
for (var s = N(n), o = s.next(); !o.done; o = s.next()) {
|
|
1059
1059
|
var i = o.value;
|
|
1060
1060
|
if (t.next(i), t.closed)
|
|
1061
1061
|
return;
|
|
@@ -1170,7 +1170,7 @@ function Ut(n, t) {
|
|
|
1170
1170
|
return new S(function(e) {
|
|
1171
1171
|
var r;
|
|
1172
1172
|
return O(e, t, function() {
|
|
1173
|
-
r = n[
|
|
1173
|
+
r = n[Ne](), O(e, t, function() {
|
|
1174
1174
|
var s, o, i;
|
|
1175
1175
|
try {
|
|
1176
1176
|
s = r.next(), o = s.value, i = s.done;
|
|
@@ -1212,7 +1212,7 @@ function kt(n, t) {
|
|
|
1212
1212
|
return _t(n, t);
|
|
1213
1213
|
if (Me(n))
|
|
1214
1214
|
return Be(n, t);
|
|
1215
|
-
if (
|
|
1215
|
+
if (Re(n))
|
|
1216
1216
|
return Ut(n, t);
|
|
1217
1217
|
if ($e(n))
|
|
1218
1218
|
return Mt(n, t);
|
|
@@ -1222,16 +1222,16 @@ function kt(n, t) {
|
|
|
1222
1222
|
function ae(n, t) {
|
|
1223
1223
|
return t ? kt(n, t) : U(n);
|
|
1224
1224
|
}
|
|
1225
|
-
function
|
|
1225
|
+
function Nt() {
|
|
1226
1226
|
for (var n = [], t = 0; t < arguments.length; t++)
|
|
1227
1227
|
n[t] = arguments[t];
|
|
1228
1228
|
var e = Pe(n);
|
|
1229
1229
|
return ae(n, e);
|
|
1230
1230
|
}
|
|
1231
|
-
function
|
|
1231
|
+
function Rt(n) {
|
|
1232
1232
|
return n instanceof Date && !isNaN(n);
|
|
1233
1233
|
}
|
|
1234
|
-
function
|
|
1234
|
+
function R(n, t) {
|
|
1235
1235
|
return P(function(e, r) {
|
|
1236
1236
|
var s = 0;
|
|
1237
1237
|
e.subscribe(A(r, function(o) {
|
|
@@ -1244,17 +1244,17 @@ function $t(n, t) {
|
|
|
1244
1244
|
return jt(t) ? n.apply(void 0, F([], D(t))) : n(t);
|
|
1245
1245
|
}
|
|
1246
1246
|
function Dt(n) {
|
|
1247
|
-
return
|
|
1247
|
+
return R(function(t) {
|
|
1248
1248
|
return $t(n, t);
|
|
1249
1249
|
});
|
|
1250
1250
|
}
|
|
1251
1251
|
var Ft = Array.isArray, Ht = Object.getPrototypeOf, Bt = Object.prototype, Gt = Object.keys;
|
|
1252
|
-
function
|
|
1252
|
+
function qt(n) {
|
|
1253
1253
|
if (n.length === 1) {
|
|
1254
1254
|
var t = n[0];
|
|
1255
1255
|
if (Ft(t))
|
|
1256
1256
|
return { args: t, keys: null };
|
|
1257
|
-
if (
|
|
1257
|
+
if (Kt(t)) {
|
|
1258
1258
|
var e = Gt(t);
|
|
1259
1259
|
return {
|
|
1260
1260
|
args: e.map(function(r) {
|
|
@@ -1266,7 +1266,7 @@ function Kt(n) {
|
|
|
1266
1266
|
}
|
|
1267
1267
|
return { args: n, keys: null };
|
|
1268
1268
|
}
|
|
1269
|
-
function
|
|
1269
|
+
function Kt(n) {
|
|
1270
1270
|
return n && typeof n == "object" && Ht(n) === Bt;
|
|
1271
1271
|
}
|
|
1272
1272
|
function Yt(n, t) {
|
|
@@ -1277,7 +1277,7 @@ function Yt(n, t) {
|
|
|
1277
1277
|
function Wt() {
|
|
1278
1278
|
for (var n = [], t = 0; t < arguments.length; t++)
|
|
1279
1279
|
n[t] = arguments[t];
|
|
1280
|
-
var e = Pe(n), r = wt(n), s =
|
|
1280
|
+
var e = Pe(n), r = wt(n), s = qt(n), o = s.args, i = s.keys;
|
|
1281
1281
|
if (o.length === 0)
|
|
1282
1282
|
return ae([], e);
|
|
1283
1283
|
var a = new S(Xt(o, e, i ? function(c) {
|
|
@@ -1339,7 +1339,7 @@ function Vt(n, t, e, r, s, o, i, a) {
|
|
|
1339
1339
|
}
|
|
1340
1340
|
function Y(n, t, e) {
|
|
1341
1341
|
return e === void 0 && (e = 1 / 0), g(t) ? Y(function(r, s) {
|
|
1342
|
-
return
|
|
1342
|
+
return R(function(o, i) {
|
|
1343
1343
|
return t(r, o, s, i);
|
|
1344
1344
|
})(U(n(r, s)));
|
|
1345
1345
|
}, e) : (typeof t == "number" && (e = t), P(function(r, s) {
|
|
@@ -1350,7 +1350,7 @@ function zt(n, t, e) {
|
|
|
1350
1350
|
n === void 0 && (n = 0), e === void 0 && (e = yt);
|
|
1351
1351
|
var r = -1;
|
|
1352
1352
|
return t != null && (Oe(t) ? e = t : r = t), new S(function(s) {
|
|
1353
|
-
var o =
|
|
1353
|
+
var o = Rt(n) ? +n - e.now() : n;
|
|
1354
1354
|
o < 0 && (o = 0);
|
|
1355
1355
|
var i = 0;
|
|
1356
1356
|
return e.schedule(function() {
|
|
@@ -1372,7 +1372,7 @@ function Qt(n) {
|
|
|
1372
1372
|
});
|
|
1373
1373
|
}
|
|
1374
1374
|
function Zt(n) {
|
|
1375
|
-
return
|
|
1375
|
+
return R(function() {
|
|
1376
1376
|
return n;
|
|
1377
1377
|
});
|
|
1378
1378
|
}
|
|
@@ -1659,7 +1659,7 @@ class _n {
|
|
|
1659
1659
|
// No RxJS-level retry: re-subscribing would re-POST and the backend would re-dispatch a duplicate
|
|
1660
1660
|
// run. Mid-stream resume is the library's job (native Last-Event-ID reconnect in
|
|
1661
1661
|
// create-sse-observable); a no-cursor failure surfaces via `error` below.
|
|
1662
|
-
Jt((r) =>
|
|
1662
|
+
Jt((r) => Nt(r).pipe(tn(e?.delayTime ?? 50))),
|
|
1663
1663
|
sn(this.destroy$),
|
|
1664
1664
|
// Settle the run accounting on every termination path — complete, error, AND a user-initiated
|
|
1665
1665
|
// unsubscribe (stop-generation aborts the connection without a terminal event).
|
|
@@ -2058,6 +2058,15 @@ class v {
|
|
|
2058
2058
|
isTerminalThinking(t) {
|
|
2059
2059
|
return t?.type === "thinking" && !t.isThinking;
|
|
2060
2060
|
}
|
|
2061
|
+
/**
|
|
2062
|
+
* A tool-call is terminal once it has completed (`isComplete === true`), whether that came from a
|
|
2063
|
+
* live `tool_call.complete` or from one materialized on GET rejoin. Same policy as the bot and
|
|
2064
|
+
* thinking guards (F-011): a late / out-of-order `tool_call.start` must not roll it back to
|
|
2065
|
+
* running, which would also drop the result and hide it from the Task list.
|
|
2066
|
+
*/
|
|
2067
|
+
isTerminalToolCall(t) {
|
|
2068
|
+
return t?.type === "tool-call" && t.isComplete === !0;
|
|
2069
|
+
}
|
|
2061
2070
|
onMessageStart(t) {
|
|
2062
2071
|
const e = t.fact.messageStart.message;
|
|
2063
2072
|
if (e.parentToolUseId) return this;
|
|
@@ -2180,7 +2189,9 @@ class v {
|
|
|
2180
2189
|
}), new v({ messages: s, pendingConsent: this.pendingConsent });
|
|
2181
2190
|
}
|
|
2182
2191
|
onToolCallStart(t) {
|
|
2183
|
-
const e = t.fact.toolCallStart, r = new Map(this.messages), s = `${e.processId}-${e.callSeq}
|
|
2192
|
+
const e = t.fact.toolCallStart, r = new Map(this.messages), s = `${e.processId}-${e.callSeq}`;
|
|
2193
|
+
if (this.isTerminalToolCall(this.messages?.get(s))) return this;
|
|
2194
|
+
const o = {
|
|
2184
2195
|
type: "tool-call",
|
|
2185
2196
|
eventType: l.TOOL_CALL_START,
|
|
2186
2197
|
messageId: s,
|
|
@@ -2211,6 +2222,27 @@ class v {
|
|
|
2211
2222
|
traceId: t.traceId ?? o.traceId
|
|
2212
2223
|
};
|
|
2213
2224
|
r.set(s, i);
|
|
2225
|
+
} else {
|
|
2226
|
+
const i = {
|
|
2227
|
+
type: "tool-call",
|
|
2228
|
+
eventType: l.TOOL_CALL_COMPLETE,
|
|
2229
|
+
messageId: s,
|
|
2230
|
+
processId: e.processId,
|
|
2231
|
+
callSeq: e.callSeq,
|
|
2232
|
+
toolName: e.toolCall.toolName,
|
|
2233
|
+
reason: e.toolCall.reason,
|
|
2234
|
+
toolsetName: e.toolCall.toolsetName,
|
|
2235
|
+
parameter: e.toolCall.parameter,
|
|
2236
|
+
toolUseId: e.toolUseId,
|
|
2237
|
+
parentToolUseId: e.parentToolUseId,
|
|
2238
|
+
result: e.toolCallResult,
|
|
2239
|
+
isError: e.isError,
|
|
2240
|
+
sidecar: e.toolUseResultSidecar,
|
|
2241
|
+
isComplete: !0,
|
|
2242
|
+
time: /* @__PURE__ */ new Date(),
|
|
2243
|
+
traceId: t.traceId
|
|
2244
|
+
};
|
|
2245
|
+
r.set(s, i);
|
|
2214
2246
|
}
|
|
2215
2247
|
return new v({ messages: r, pendingConsent: this.pendingConsent });
|
|
2216
2248
|
}
|
|
@@ -2409,8 +2441,8 @@ function Tn(n, t) {
|
|
|
2409
2441
|
}
|
|
2410
2442
|
function xn(n) {
|
|
2411
2443
|
const t = new C([]), e = new C([]), r = new j();
|
|
2412
|
-
return r.add(n.pipe(
|
|
2413
|
-
n.pipe(
|
|
2444
|
+
return r.add(n.pipe(R(Sn), M(En)).subscribe(t)), r.add(
|
|
2445
|
+
n.pipe(R(wn), M(Tn)).subscribe(e)
|
|
2414
2446
|
), {
|
|
2415
2447
|
tasks$: t.asObservable(),
|
|
2416
2448
|
subagents$: e.asObservable(),
|
|
@@ -2430,7 +2462,7 @@ const Q = { kind: null, stopPhase: "idle" }, Cn = 1e4;
|
|
|
2430
2462
|
function On(n, t) {
|
|
2431
2463
|
return n.kind === t.kind && n.stopPhase === t.stopPhase && n.requestId === t.requestId;
|
|
2432
2464
|
}
|
|
2433
|
-
class
|
|
2465
|
+
class q {
|
|
2434
2466
|
client;
|
|
2435
2467
|
customChannelId;
|
|
2436
2468
|
customMessageId;
|
|
@@ -2555,11 +2587,11 @@ class K {
|
|
|
2555
2587
|
this.channelTitleSubject.next(t);
|
|
2556
2588
|
}
|
|
2557
2589
|
static create(t) {
|
|
2558
|
-
const e = new
|
|
2590
|
+
const e = new q(t);
|
|
2559
2591
|
return e.subscribe(), e;
|
|
2560
2592
|
}
|
|
2561
2593
|
static async reset(t, e, r, s) {
|
|
2562
|
-
const o = new
|
|
2594
|
+
const o = new q(t);
|
|
2563
2595
|
try {
|
|
2564
2596
|
return o.subscribe(), s?.(o), await o.resetChannel(e, r), o;
|
|
2565
2597
|
} catch (i) {
|
|
@@ -2574,7 +2606,7 @@ class K {
|
|
|
2574
2606
|
* "join an existing channel and wipe its history" data-loss bug.
|
|
2575
2607
|
*/
|
|
2576
2608
|
static async restore(t, e, r) {
|
|
2577
|
-
const s = new
|
|
2609
|
+
const s = new q(t);
|
|
2578
2610
|
try {
|
|
2579
2611
|
return s.subscribe(), r?.(s), await s.rejoinChannel(e), s;
|
|
2580
2612
|
} catch (o) {
|
|
@@ -2592,7 +2624,7 @@ class K {
|
|
|
2592
2624
|
this.launchedSandboxes$,
|
|
2593
2625
|
this.runStatus$
|
|
2594
2626
|
]).pipe(
|
|
2595
|
-
|
|
2627
|
+
R(
|
|
2596
2628
|
([
|
|
2597
2629
|
t,
|
|
2598
2630
|
e,
|
|
@@ -2890,7 +2922,7 @@ function Ln(n) {
|
|
|
2890
2922
|
}
|
|
2891
2923
|
export {
|
|
2892
2924
|
_n as AsgardServiceClient,
|
|
2893
|
-
|
|
2925
|
+
q as Channel,
|
|
2894
2926
|
Z as ChannelBusyError,
|
|
2895
2927
|
v as Conversation,
|
|
2896
2928
|
l as EventType,
|