@syntrologie/adapt-chatbot 2.8.0-canary.265 → 2.8.0-canary.267
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/ChatAssistantLit.js
CHANGED
|
@@ -1291,11 +1291,11 @@ ${c}` : c;
|
|
|
1291
1291
|
`, 1)[0], R2 = !d.trim(), f = 0;
|
|
1292
1292
|
if (this.options.pedantic ? (f = 2, c = d.trimStart()) : R2 ? f = t[1].length + 1 : (f = d.search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, c = d.slice(f), f += t[1].length), R2 && this.rules.other.blankLine.test(h) && (p += h + `
|
|
1293
1293
|
`, e = e.substring(h.length + 1), l = true), !l) {
|
|
1294
|
-
let S = this.rules.other.nextBulletRegex(f), V2 = this.rules.other.hrRegex(f), Y2 = this.rules.other.fencesBeginRegex(f), ee = this.rules.other.headingBeginRegex(f), xe2 = this.rules.other.htmlBeginRegex(f),
|
|
1294
|
+
let S = this.rules.other.nextBulletRegex(f), V2 = this.rules.other.hrRegex(f), Y2 = this.rules.other.fencesBeginRegex(f), ee = this.rules.other.headingBeginRegex(f), xe2 = this.rules.other.htmlBeginRegex(f), be = this.rules.other.blockquoteBeginRegex(f);
|
|
1295
1295
|
for (; e; ) {
|
|
1296
1296
|
let H2 = e.split(`
|
|
1297
1297
|
`, 1)[0], I2;
|
|
1298
|
-
if (h = H2, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "), I2 = h) : I2 = h.replace(this.rules.other.tabCharGlobal, " "), Y2.test(h) || ee.test(h) || xe2.test(h) ||
|
|
1298
|
+
if (h = H2, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "), I2 = h) : I2 = h.replace(this.rules.other.tabCharGlobal, " "), Y2.test(h) || ee.test(h) || xe2.test(h) || be.test(h) || S.test(h) || V2.test(h)) break;
|
|
1299
1299
|
if (I2.search(this.rules.other.nonSpaceChar) >= f || !h.trim()) c += `
|
|
1300
1300
|
` + I2.slice(f);
|
|
1301
1301
|
else {
|
|
@@ -3423,7 +3423,8 @@ var ContextSchema = z2.object({
|
|
|
3423
3423
|
var ToolSchema = z2.object({
|
|
3424
3424
|
name: z2.string(),
|
|
3425
3425
|
description: z2.string(),
|
|
3426
|
-
parameters: z2.any()
|
|
3426
|
+
parameters: z2.any(),
|
|
3427
|
+
metadata: z2.record(z2.any()).optional()
|
|
3427
3428
|
});
|
|
3428
3429
|
var RunAgentInputSchema = z2.object({
|
|
3429
3430
|
threadId: z2.string(),
|
|
@@ -3684,11 +3685,32 @@ var RunStartedEventSchema = BaseEventSchema.extend({
|
|
|
3684
3685
|
parentRunId: z2.string().optional(),
|
|
3685
3686
|
input: RunAgentInputSchema.optional()
|
|
3686
3687
|
});
|
|
3688
|
+
var InterruptSchema = z2.object({
|
|
3689
|
+
id: z2.string(),
|
|
3690
|
+
reason: z2.string(),
|
|
3691
|
+
message: z2.string().optional(),
|
|
3692
|
+
toolCallId: z2.string().optional(),
|
|
3693
|
+
responseSchema: z2.record(z2.any()).optional(),
|
|
3694
|
+
expiresAt: z2.string().optional(),
|
|
3695
|
+
metadata: z2.record(z2.any()).optional()
|
|
3696
|
+
});
|
|
3697
|
+
var RunFinishedSuccessOutcomeSchema = z2.object({
|
|
3698
|
+
type: z2.literal("success")
|
|
3699
|
+
}).strict();
|
|
3700
|
+
var RunFinishedInterruptOutcomeSchema = z2.object({
|
|
3701
|
+
type: z2.literal("interrupt"),
|
|
3702
|
+
interrupts: z2.array(InterruptSchema).min(1)
|
|
3703
|
+
}).strict();
|
|
3704
|
+
var RunFinishedOutcomeSchema = z2.discriminatedUnion("type", [
|
|
3705
|
+
RunFinishedSuccessOutcomeSchema,
|
|
3706
|
+
RunFinishedInterruptOutcomeSchema
|
|
3707
|
+
]);
|
|
3687
3708
|
var RunFinishedEventSchema = BaseEventSchema.extend({
|
|
3688
3709
|
type: z2.literal(EventType.RUN_FINISHED),
|
|
3689
3710
|
threadId: z2.string(),
|
|
3690
3711
|
runId: z2.string(),
|
|
3691
|
-
result: z2.any().optional()
|
|
3712
|
+
result: z2.any().optional(),
|
|
3713
|
+
outcome: RunFinishedOutcomeSchema.nullable().optional().transform((v2) => v2 ?? void 0)
|
|
3692
3714
|
});
|
|
3693
3715
|
var RunErrorEventSchema = BaseEventSchema.extend({
|
|
3694
3716
|
type: z2.literal(EventType.RUN_ERROR),
|
|
@@ -6764,11 +6786,18 @@ function getTextEncoding() {
|
|
|
6764
6786
|
if (globalThis[symbol] == void 0) {
|
|
6765
6787
|
const te2 = new globalThis.TextEncoder();
|
|
6766
6788
|
const td = new globalThis.TextDecoder();
|
|
6789
|
+
let tdStrict;
|
|
6767
6790
|
globalThis[symbol] = {
|
|
6768
6791
|
encodeUtf8(text2) {
|
|
6769
6792
|
return te2.encode(text2);
|
|
6770
6793
|
},
|
|
6771
|
-
decodeUtf8(bytes) {
|
|
6794
|
+
decodeUtf8(bytes, strict) {
|
|
6795
|
+
if (strict) {
|
|
6796
|
+
if (tdStrict === void 0) {
|
|
6797
|
+
tdStrict = new globalThis.TextDecoder("utf-8", { fatal: true });
|
|
6798
|
+
}
|
|
6799
|
+
return tdStrict.decode(bytes);
|
|
6800
|
+
}
|
|
6772
6801
|
return td.decode(bytes);
|
|
6773
6802
|
},
|
|
6774
6803
|
checkUtf8(text2) {
|
|
@@ -6894,7 +6923,7 @@ var BinaryWriter = class {
|
|
|
6894
6923
|
return this;
|
|
6895
6924
|
}
|
|
6896
6925
|
/**
|
|
6897
|
-
* Write a `bool` value, a
|
|
6926
|
+
* Write a `bool` value, a varint.
|
|
6898
6927
|
*/
|
|
6899
6928
|
bool(value) {
|
|
6900
6929
|
this.buf.push(value ? 1 : 0);
|
|
@@ -6960,7 +6989,7 @@ var BinaryWriter = class {
|
|
|
6960
6989
|
return this;
|
|
6961
6990
|
}
|
|
6962
6991
|
/**
|
|
6963
|
-
* Write a `
|
|
6992
|
+
* Write a `sfixed64` value, a signed, fixed-length 64-bit integer.
|
|
6964
6993
|
*/
|
|
6965
6994
|
sfixed64(value) {
|
|
6966
6995
|
let chunk = new Uint8Array(8), view = new DataView(chunk.buffer), tc = protoInt64.enc(value);
|
|
@@ -7013,12 +7042,21 @@ var BinaryReader = class {
|
|
|
7013
7042
|
this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
7014
7043
|
}
|
|
7015
7044
|
/**
|
|
7016
|
-
* Reads a tag - field number and wire type.
|
|
7045
|
+
* Reads a tag - field number and wire type. Tags are uint32 varints; values
|
|
7046
|
+
* that do not fit in uint32 are rejected.
|
|
7017
7047
|
*/
|
|
7018
7048
|
tag() {
|
|
7019
|
-
|
|
7020
|
-
|
|
7049
|
+
const start = this.pos;
|
|
7050
|
+
const tag = this.uint32();
|
|
7051
|
+
const bytesRead = this.pos - start;
|
|
7052
|
+
if (bytesRead > 5 || bytesRead == 5 && this.buf[this.pos - 1] > 15) {
|
|
7053
|
+
throw new Error("illegal tag: varint overflows uint32");
|
|
7054
|
+
}
|
|
7055
|
+
const fieldNo = tag >>> 3;
|
|
7056
|
+
const wireType = tag & 7;
|
|
7057
|
+
if (fieldNo <= 0 || wireType > 5) {
|
|
7021
7058
|
throw new Error("illegal tag: field no " + fieldNo + " wire type " + wireType);
|
|
7059
|
+
}
|
|
7022
7060
|
return [fieldNo, wireType];
|
|
7023
7061
|
}
|
|
7024
7062
|
/**
|
|
@@ -7157,10 +7195,11 @@ var BinaryReader = class {
|
|
|
7157
7195
|
return this.buf.subarray(start, start + len);
|
|
7158
7196
|
}
|
|
7159
7197
|
/**
|
|
7160
|
-
* Read a `string` field, length-delimited data converted to UTF-8 text.
|
|
7198
|
+
* Read a `string` field, length-delimited data converted to UTF-8 text. If
|
|
7199
|
+
* `strict` is true, throw on invalid UTF-8 instead of substituting U+FFFD.
|
|
7161
7200
|
*/
|
|
7162
|
-
string() {
|
|
7163
|
-
return this.decodeUtf8(this.bytes());
|
|
7201
|
+
string(strict) {
|
|
7202
|
+
return this.decodeUtf8(this.bytes(), strict);
|
|
7164
7203
|
}
|
|
7165
7204
|
};
|
|
7166
7205
|
function assertInt32(arg) {
|
|
@@ -9350,20 +9389,20 @@ function A2(e) {
|
|
|
9350
9389
|
return e;
|
|
9351
9390
|
}
|
|
9352
9391
|
async function j2(e, t, n, r) {
|
|
9353
|
-
let i =
|
|
9392
|
+
let i = typeof process < `u` && process.env !== void 0, a = i && false, o = i && false, s = O2(t), c = O2(n), l = s, u3 = c, d;
|
|
9354
9393
|
for (let t2 of e) try {
|
|
9355
|
-
|
|
9356
|
-
let e2 = await r(t2,
|
|
9394
|
+
o && (A2(l), A2(u3));
|
|
9395
|
+
let e2 = await r(t2, l, u3);
|
|
9357
9396
|
if (e2 === void 0) continue;
|
|
9358
|
-
if (e2.messages !== void 0 && e2.messages !==
|
|
9397
|
+
if (e2.messages !== void 0 && e2.messages !== l && (l = O2(e2.messages)), e2.state !== void 0 && e2.state !== u3 && (u3 = O2(e2.state)), d = e2.stopPropagation, d === true) break;
|
|
9359
9398
|
} catch (e2) {
|
|
9360
|
-
if (
|
|
9361
|
-
if (
|
|
9399
|
+
if (o && e2 instanceof TypeError) {
|
|
9400
|
+
if (a) throw e2;
|
|
9362
9401
|
console.error(`AG-UI: Subscriber attempted to mutate frozen inputs in-place. Return mutations via AgentStateMutation instead of mutating directly.`, e2);
|
|
9363
|
-
} else
|
|
9402
|
+
} else a || console.error(`Subscriber error:`, e2);
|
|
9364
9403
|
continue;
|
|
9365
9404
|
}
|
|
9366
|
-
return { ...
|
|
9405
|
+
return { ...l === s ? {} : { messages: o && Object.isFrozen(l) ? O2(l) : l }, ...u3 === c ? {} : { state: o && Object.isFrozen(u3) ? O2(u3) : u3 }, ...d === void 0 ? {} : { stopPropagation: d } };
|
|
9367
9406
|
}
|
|
9368
9407
|
function M2(e) {
|
|
9369
9408
|
if (!e) return { enabled: false, events: false, lifecycle: false, verbose: false };
|
|
@@ -9398,6 +9437,17 @@ var P2 = class {
|
|
|
9398
9437
|
function F2(e) {
|
|
9399
9438
|
return e.enabled ? new P2(e) : void 0;
|
|
9400
9439
|
}
|
|
9440
|
+
function ae2(e, t, n) {
|
|
9441
|
+
if (t) {
|
|
9442
|
+
let r2 = e.find((e2) => e2.id === t);
|
|
9443
|
+
if (r2?.role === `assistant`) return r2;
|
|
9444
|
+
r2 && console.warn(`TOOL_CALL_START: parentMessageId '${t}' matches a '${r2.role}' message, not assistant \u2014 falling back to toolCallId`);
|
|
9445
|
+
let i = { id: r2 ? n : t, role: `assistant`, toolCalls: [] };
|
|
9446
|
+
return e.push(i), i;
|
|
9447
|
+
}
|
|
9448
|
+
let r = { id: n, role: `assistant`, toolCalls: [] };
|
|
9449
|
+
return e.push(r), r;
|
|
9450
|
+
}
|
|
9401
9451
|
var I = (e, t, n, r, s) => {
|
|
9402
9452
|
let c = N2(s), l = O2(n.messages), u3 = O2(e.state), d = {}, f = (e2) => {
|
|
9403
9453
|
e2.messages !== void 0 && (l = e2.messages, d.messages = e2.messages), e2.state !== void 0 && (u3 = e2.state, d.state = e2.state);
|
|
@@ -9435,8 +9485,8 @@ var I = (e, t, n, r, s) => {
|
|
|
9435
9485
|
case EventType.TOOL_CALL_START: {
|
|
9436
9486
|
let i = await j2(r, l, u3, (r2, i2, a) => r2.onToolCallStartEvent?.({ event: t2, messages: i2, state: a, agent: n, input: e }));
|
|
9437
9487
|
if (f(i), i.stopPropagation !== true) {
|
|
9438
|
-
let { toolCallId: e2, toolCallName: n2, parentMessageId: r2 } = t2, i2;
|
|
9439
|
-
|
|
9488
|
+
let { toolCallId: e2, toolCallName: n2, parentMessageId: r2 } = t2, i2 = ae2(l, r2, e2);
|
|
9489
|
+
i2.toolCalls ?? (i2.toolCalls = []), i2.toolCalls.push({ id: e2, type: `function`, function: { name: n2, arguments: `` } }), f({ messages: l });
|
|
9440
9490
|
}
|
|
9441
9491
|
return p();
|
|
9442
9492
|
}
|
|
@@ -9493,7 +9543,7 @@ var I = (e, t, n, r, s) => {
|
|
|
9493
9543
|
if (f(i), i.stopPropagation !== true) {
|
|
9494
9544
|
let { delta: e2 } = t2;
|
|
9495
9545
|
try {
|
|
9496
|
-
u3 = applyPatch(u3, e2, true, false).newDocument, f({ state: u3 });
|
|
9546
|
+
u3 = fast_json_patch_default.applyPatch(u3, e2, true, false).newDocument, f({ state: u3 });
|
|
9497
9547
|
} catch (t3) {
|
|
9498
9548
|
let n2 = t3 instanceof Error ? t3.message : String(t3);
|
|
9499
9549
|
console.warn(`Failed to apply state patch:
|
|
@@ -9530,7 +9580,7 @@ Error: ${n2}`);
|
|
|
9530
9580
|
if (s2.role !== `activity`) return console.warn(`ACTIVITY_DELTA: Message '${i.messageId}' is not an activity message`), p();
|
|
9531
9581
|
let c2 = s2, d2 = await j2(r, l, u3, (t3, r2, a) => t3.onActivityDeltaEvent?.({ event: i, messages: r2, state: a, agent: n, input: e, activityMessage: c2 }));
|
|
9532
9582
|
if (f(d2), d2.stopPropagation !== true) try {
|
|
9533
|
-
let e2 = O2(c2.content ?? {}), t3 = applyPatch(e2, i.patch ?? [], true, false).newDocument;
|
|
9583
|
+
let e2 = O2(c2.content ?? {}), t3 = fast_json_patch_default.applyPatch(e2, i.patch ?? [], true, false).newDocument;
|
|
9534
9584
|
l[o2] = { ...c2, content: O2(t3), activityType: i.activityType }, f({ messages: l });
|
|
9535
9585
|
} catch (e2) {
|
|
9536
9586
|
let t3 = e2 instanceof Error ? e2.message : String(e2);
|
|
@@ -9831,26 +9881,26 @@ var H = (e, t) => {
|
|
|
9831
9881
|
} }), a.asObservable();
|
|
9832
9882
|
};
|
|
9833
9883
|
var U2 = E2.enum([`TextMessageStart`, `TextMessageContent`, `TextMessageEnd`, `ActionExecutionStart`, `ActionExecutionArgs`, `ActionExecutionEnd`, `ActionExecutionResult`, `AgentStateMessage`, `MetaEvent`, `RunStarted`, `RunFinished`, `RunError`, `NodeStarted`, `NodeFinished`]);
|
|
9834
|
-
var
|
|
9835
|
-
var
|
|
9836
|
-
var
|
|
9837
|
-
var
|
|
9838
|
-
var
|
|
9839
|
-
var
|
|
9840
|
-
var
|
|
9841
|
-
var
|
|
9842
|
-
var
|
|
9843
|
-
var
|
|
9844
|
-
var
|
|
9845
|
-
E2.discriminatedUnion(`type`, [
|
|
9846
|
-
var
|
|
9884
|
+
var oe2 = E2.enum([`LangGraphInterruptEvent`, `PredictState`, `Exit`]);
|
|
9885
|
+
var se2 = E2.object({ type: E2.literal(U2.enum.TextMessageStart), messageId: E2.string(), parentMessageId: E2.string().optional(), role: E2.string().optional() });
|
|
9886
|
+
var ce2 = E2.object({ type: E2.literal(U2.enum.TextMessageContent), messageId: E2.string(), content: E2.string() });
|
|
9887
|
+
var le2 = E2.object({ type: E2.literal(U2.enum.TextMessageEnd), messageId: E2.string() });
|
|
9888
|
+
var ue2 = E2.object({ type: E2.literal(U2.enum.ActionExecutionStart), actionExecutionId: E2.string(), actionName: E2.string(), parentMessageId: E2.string().optional() });
|
|
9889
|
+
var de2 = E2.object({ type: E2.literal(U2.enum.ActionExecutionArgs), actionExecutionId: E2.string(), args: E2.string() });
|
|
9890
|
+
var fe2 = E2.object({ type: E2.literal(U2.enum.ActionExecutionEnd), actionExecutionId: E2.string() });
|
|
9891
|
+
var pe2 = E2.object({ type: E2.literal(U2.enum.ActionExecutionResult), actionName: E2.string(), actionExecutionId: E2.string(), result: E2.string() });
|
|
9892
|
+
var me2 = E2.object({ type: E2.literal(U2.enum.AgentStateMessage), threadId: E2.string(), agentName: E2.string(), nodeName: E2.string(), runId: E2.string(), active: E2.boolean(), role: E2.string(), state: E2.string(), running: E2.boolean() });
|
|
9893
|
+
var he2 = E2.object({ type: E2.literal(U2.enum.MetaEvent), name: oe2, value: E2.any() });
|
|
9894
|
+
var ge2 = E2.object({ type: E2.literal(U2.enum.RunError), message: E2.string(), code: E2.string().optional() });
|
|
9895
|
+
E2.discriminatedUnion(`type`, [se2, ce2, le2, ue2, de2, fe2, pe2, me2, he2, ge2]), E2.object({ id: E2.string(), role: E2.string(), content: E2.string(), parentMessageId: E2.string().optional() }), E2.object({ id: E2.string(), name: E2.string(), arguments: E2.any(), parentMessageId: E2.string().optional() }), E2.object({ id: E2.string(), result: E2.any(), actionExecutionId: E2.string(), actionName: E2.string() });
|
|
9896
|
+
var _e2 = (e) => {
|
|
9847
9897
|
if (typeof e == `string`) return e;
|
|
9848
9898
|
if (!Array.isArray(e)) return;
|
|
9849
9899
|
let t = e.filter((e2) => e2.type === `text`).map((e2) => e2.text).filter((e2) => e2.length > 0);
|
|
9850
9900
|
if (t.length !== 0) return t.join(`
|
|
9851
9901
|
`);
|
|
9852
9902
|
};
|
|
9853
|
-
var
|
|
9903
|
+
var ve2 = (e, t, n) => (r) => {
|
|
9854
9904
|
let o = {}, s = true, c = true, l = ``, u3 = null, d = null, f = [], p = {}, m2 = (e2) => {
|
|
9855
9905
|
typeof e2 == `object` && e2 && (`messages` in e2 && delete e2.messages, o = e2);
|
|
9856
9906
|
};
|
|
@@ -9912,7 +9962,7 @@ var W2 = (e, t, n) => (r) => {
|
|
|
9912
9962
|
case EventType.STATE_SNAPSHOT:
|
|
9913
9963
|
return m2(r2.snapshot), [{ type: U2.enum.AgentStateMessage, threadId: e, agentName: n, nodeName: l, runId: t, running: s, role: `assistant`, state: JSON.stringify(o), active: c }];
|
|
9914
9964
|
case EventType.STATE_DELTA: {
|
|
9915
|
-
let i = r2, u4 = applyPatch(o, i.delta, true, false);
|
|
9965
|
+
let i = r2, u4 = fast_json_patch_default.applyPatch(o, i.delta, true, false);
|
|
9916
9966
|
return u4 ? (m2(u4.newDocument), [{ type: U2.enum.AgentStateMessage, threadId: e, agentName: n, nodeName: l, runId: t, running: s, role: `assistant`, state: JSON.stringify(o), active: c }]) : [];
|
|
9917
9967
|
}
|
|
9918
9968
|
case EventType.MESSAGES_SNAPSHOT:
|
|
@@ -9920,7 +9970,7 @@ var W2 = (e, t, n) => (r) => {
|
|
|
9920
9970
|
case EventType.RUN_STARTED:
|
|
9921
9971
|
return [];
|
|
9922
9972
|
case EventType.RUN_FINISHED:
|
|
9923
|
-
return u3 && (o.messages = u3), Object.keys(o).length === 0 ? [] : [{ type: U2.enum.AgentStateMessage, threadId: e, agentName: n, nodeName: l, runId: t, running: s, role: `assistant`, state: JSON.stringify({ ...o, ...u3 ? { messages:
|
|
9973
|
+
return u3 && (o.messages = u3), Object.keys(o).length === 0 ? [] : [{ type: U2.enum.AgentStateMessage, threadId: e, agentName: n, nodeName: l, runId: t, running: s, role: `assistant`, state: JSON.stringify({ ...o, ...u3 ? { messages: ye2(u3) } : {} }), active: false }];
|
|
9924
9974
|
case EventType.RUN_ERROR: {
|
|
9925
9975
|
let e2 = r2;
|
|
9926
9976
|
return [{ type: U2.enum.RunError, message: e2.message, code: e2.code }];
|
|
@@ -9934,10 +9984,10 @@ var W2 = (e, t, n) => (r) => {
|
|
|
9934
9984
|
}
|
|
9935
9985
|
}));
|
|
9936
9986
|
};
|
|
9937
|
-
function
|
|
9987
|
+
function ye2(e) {
|
|
9938
9988
|
let t = [];
|
|
9939
9989
|
for (let n of e) if (n.role === `assistant` || n.role === `user` || n.role === `system`) {
|
|
9940
|
-
let e2 =
|
|
9990
|
+
let e2 = _e2(n.content);
|
|
9941
9991
|
if (e2) {
|
|
9942
9992
|
let r = { id: n.id, role: n.role, content: e2 };
|
|
9943
9993
|
t.push(r);
|
|
@@ -9959,7 +10009,7 @@ function _e2(e) {
|
|
|
9959
10009
|
}
|
|
9960
10010
|
return t;
|
|
9961
10011
|
}
|
|
9962
|
-
var
|
|
10012
|
+
var W2 = (e) => (t) => {
|
|
9963
10013
|
let n = N2(e), r, a, o, s, c = () => {
|
|
9964
10014
|
if (!r || s !== `text`) throw Error(`No text message to close`);
|
|
9965
10015
|
let e2 = { type: EventType.TEXT_MESSAGE_END, messageId: r.messageId };
|
|
@@ -10053,9 +10103,9 @@ var G2 = (e) => (t) => {
|
|
|
10053
10103
|
f();
|
|
10054
10104
|
}));
|
|
10055
10105
|
};
|
|
10056
|
-
var
|
|
10106
|
+
var G2 = class {
|
|
10057
10107
|
runNext(e, t) {
|
|
10058
|
-
return t.run(e).pipe(
|
|
10108
|
+
return t.run(e).pipe(W2(false));
|
|
10059
10109
|
}
|
|
10060
10110
|
runNextWithState(e, t) {
|
|
10061
10111
|
let n = O2(e.messages || []), r = O2(e.state || {}), i = new ReplaySubject();
|
|
@@ -10064,7 +10114,7 @@ var K2 = class {
|
|
|
10064
10114
|
}), this.runNext(e, t).pipe(concatMap(async (e2) => (i.next(e2), await new Promise((e3) => setTimeout(e3, 0)), { event: e2, messages: O2(n), state: O2(r) })));
|
|
10065
10115
|
}
|
|
10066
10116
|
};
|
|
10067
|
-
var
|
|
10117
|
+
var K2 = class extends G2 {
|
|
10068
10118
|
constructor(e) {
|
|
10069
10119
|
super(), this.fn = e;
|
|
10070
10120
|
}
|
|
@@ -10072,7 +10122,7 @@ var q2 = class extends K2 {
|
|
|
10072
10122
|
return this.fn(e, t);
|
|
10073
10123
|
}
|
|
10074
10124
|
};
|
|
10075
|
-
function
|
|
10125
|
+
function xe(e) {
|
|
10076
10126
|
let t = e.content;
|
|
10077
10127
|
if (Array.isArray(t)) {
|
|
10078
10128
|
let n = t.filter((e2) => typeof e2 == `object` && !!e2 && `type` in e2 && e2.type === `text` && typeof e2.text == `string`).map((e2) => e2.text).join(``);
|
|
@@ -10080,57 +10130,79 @@ function ye2(e) {
|
|
|
10080
10130
|
}
|
|
10081
10131
|
return typeof t == `string` ? e : { ...e, content: `` };
|
|
10082
10132
|
}
|
|
10083
|
-
var
|
|
10133
|
+
var q2 = class extends G2 {
|
|
10084
10134
|
run(e, t) {
|
|
10085
|
-
let { parentRunId: n, ...r } = e, i = { ...r, messages: r.messages.map(
|
|
10135
|
+
let { parentRunId: n, ...r } = e, i = { ...r, messages: r.messages.map(xe) };
|
|
10086
10136
|
return this.runNext(i, t);
|
|
10087
10137
|
}
|
|
10088
10138
|
};
|
|
10089
|
-
var
|
|
10090
|
-
var
|
|
10091
|
-
var
|
|
10092
|
-
var
|
|
10093
|
-
var
|
|
10094
|
-
var
|
|
10139
|
+
var J2 = `THINKING_START`;
|
|
10140
|
+
var Y = `THINKING_END`;
|
|
10141
|
+
var X2 = `THINKING_TEXT_MESSAGE_START`;
|
|
10142
|
+
var Z2 = `THINKING_TEXT_MESSAGE_CONTENT`;
|
|
10143
|
+
var Se2 = `THINKING_TEXT_MESSAGE_END`;
|
|
10144
|
+
var Ce2 = class extends G2 {
|
|
10095
10145
|
constructor(...e) {
|
|
10096
10146
|
super(...e), this.currentReasoningId = null, this.currentMessageId = null;
|
|
10097
10147
|
}
|
|
10098
10148
|
warnAboutTransformation(e, t) {
|
|
10099
|
-
console.warn(`AG-UI is converting ${e} to ${t}. To remove this warning, upgrade your AG-UI integration package (e.g. @ag-ui/langgraph). To surpress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`);
|
|
10149
|
+
typeof process < `u` && process.env !== void 0 && void 0 || console.warn(`AG-UI is converting ${e} to ${t}. To remove this warning, upgrade your AG-UI integration package (e.g. @ag-ui/langgraph). To surpress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`);
|
|
10100
10150
|
}
|
|
10101
10151
|
run(e, t) {
|
|
10102
10152
|
return this.currentReasoningId = null, this.currentMessageId = null, this.runNext(e, t).pipe(map((e2) => this.transformEvent(e2)));
|
|
10103
10153
|
}
|
|
10104
10154
|
transformEvent(e) {
|
|
10105
10155
|
switch (e.type) {
|
|
10106
|
-
case
|
|
10156
|
+
case J2: {
|
|
10107
10157
|
this.currentReasoningId = k2();
|
|
10108
10158
|
let { title: t, ...n } = e;
|
|
10109
|
-
return this.warnAboutTransformation(
|
|
10159
|
+
return this.warnAboutTransformation(J2, EventType.REASONING_START), { ...n, type: EventType.REASONING_START, messageId: this.currentReasoningId };
|
|
10110
10160
|
}
|
|
10111
|
-
case
|
|
10112
|
-
return this.currentMessageId = k2(), this.warnAboutTransformation(
|
|
10113
|
-
case
|
|
10161
|
+
case X2:
|
|
10162
|
+
return this.currentMessageId = k2(), this.warnAboutTransformation(X2, EventType.REASONING_MESSAGE_START), { ...e, type: EventType.REASONING_MESSAGE_START, messageId: this.currentMessageId, role: `assistant` };
|
|
10163
|
+
case Z2: {
|
|
10114
10164
|
let { delta: t, ...n } = e;
|
|
10115
|
-
return this.warnAboutTransformation(
|
|
10165
|
+
return this.warnAboutTransformation(Z2, EventType.REASONING_MESSAGE_CONTENT), { ...n, type: EventType.REASONING_MESSAGE_CONTENT, messageId: this.currentMessageId ?? k2(), delta: t };
|
|
10116
10166
|
}
|
|
10117
|
-
case
|
|
10167
|
+
case Se2: {
|
|
10118
10168
|
let t = this.currentMessageId ?? k2();
|
|
10119
|
-
return this.warnAboutTransformation(
|
|
10169
|
+
return this.warnAboutTransformation(Se2, EventType.REASONING_MESSAGE_END), { ...e, type: EventType.REASONING_MESSAGE_END, messageId: t };
|
|
10120
10170
|
}
|
|
10121
|
-
case
|
|
10171
|
+
case Y: {
|
|
10122
10172
|
let t = this.currentReasoningId ?? k2();
|
|
10123
|
-
return this.warnAboutTransformation(
|
|
10173
|
+
return this.warnAboutTransformation(Y, EventType.REASONING_END), { ...e, type: EventType.REASONING_END, messageId: t };
|
|
10124
10174
|
}
|
|
10125
10175
|
default:
|
|
10126
10176
|
return e;
|
|
10127
10177
|
}
|
|
10128
10178
|
}
|
|
10129
10179
|
};
|
|
10130
|
-
|
|
10131
|
-
|
|
10180
|
+
function we2(e) {
|
|
10181
|
+
return e.startsWith(`image/`) ? `image` : e.startsWith(`audio/`) ? `audio` : e.startsWith(`video/`) ? `video` : `document`;
|
|
10182
|
+
}
|
|
10183
|
+
function Te2(e) {
|
|
10184
|
+
return typeof e == `object` && !!e && `type` in e && e.type === `binary` && `mimeType` in e && typeof e.mimeType == `string`;
|
|
10185
|
+
}
|
|
10186
|
+
function Ee2(e) {
|
|
10187
|
+
let t = we2(e.mimeType);
|
|
10188
|
+
return e.data ? { type: t, source: { type: `data`, value: e.data, mimeType: e.mimeType }, ...e.filename ? { metadata: { filename: e.filename } } : {} } : e.url ? { type: t, source: { type: `url`, value: e.url, mimeType: e.mimeType }, ...e.filename ? { metadata: { filename: e.filename } } : {} } : e;
|
|
10189
|
+
}
|
|
10190
|
+
function De2(e) {
|
|
10191
|
+
let t = e.content;
|
|
10192
|
+
if (!Array.isArray(t)) return e;
|
|
10193
|
+
let n = t.map((e2) => Te2(e2) ? Ee2(e2) : e2);
|
|
10194
|
+
return { ...e, content: n };
|
|
10195
|
+
}
|
|
10196
|
+
var Oe2 = class extends G2 {
|
|
10197
|
+
run(e, t) {
|
|
10198
|
+
let n = { ...e, messages: e.messages.map(De2) };
|
|
10199
|
+
return this.runNext(n, t);
|
|
10200
|
+
}
|
|
10201
|
+
};
|
|
10202
|
+
var ke2 = `0.0.53`;
|
|
10203
|
+
var Ae2 = class {
|
|
10132
10204
|
get maxVersion() {
|
|
10133
|
-
return
|
|
10205
|
+
return ke2;
|
|
10134
10206
|
}
|
|
10135
10207
|
get debug() {
|
|
10136
10208
|
return this._debug;
|
|
@@ -10145,7 +10217,7 @@ var Se2 = class {
|
|
|
10145
10217
|
typeof e == `boolean` ? this._debugLogger = e ? F2(M2(true)) : void 0 : this._debugLogger = e;
|
|
10146
10218
|
}
|
|
10147
10219
|
constructor({ agentId: t, description: n, threadId: r, initialMessages: i, initialState: a, debug: o } = {}) {
|
|
10148
|
-
this.subscribers = [], this.isRunning = false, this.middlewares = [], this.agentId = t, this.description = n ?? ``, this.threadId = r ?? v4_default(), this.messages = O2(i ?? []), this.state = O2(a ?? {}), this._debug = M2(o), this._debugLogger = F2(this._debug), compareVersions(this.maxVersion, `0.0.39`) <= 0 && this.middlewares.unshift(new
|
|
10220
|
+
this.subscribers = [], this.isRunning = false, this.middlewares = [], this.agentId = t, this.description = n ?? ``, this.threadId = r ?? v4_default(), this.messages = O2(i ?? []), this.state = O2(a ?? {}), this._debug = M2(o), this._debugLogger = F2(this._debug), compareVersions(this.maxVersion, `0.0.39`) <= 0 && this.middlewares.unshift(new q2()), compareVersions(this.maxVersion, `0.0.45`) <= 0 && this.middlewares.unshift(new Ce2()), compareVersions(this.maxVersion, `0.0.47`) <= 0 && this.middlewares.unshift(new Oe2());
|
|
10149
10221
|
}
|
|
10150
10222
|
subscribe(e) {
|
|
10151
10223
|
return this.subscribers.push(e), { unsubscribe: () => {
|
|
@@ -10153,7 +10225,7 @@ var Se2 = class {
|
|
|
10153
10225
|
} };
|
|
10154
10226
|
}
|
|
10155
10227
|
use(...e) {
|
|
10156
|
-
let t = e.map((e2) => typeof e2 == `function` ? new
|
|
10228
|
+
let t = e.map((e2) => typeof e2 == `function` ? new K2(e2) : e2);
|
|
10157
10229
|
return this.middlewares.push(...t), this;
|
|
10158
10230
|
}
|
|
10159
10231
|
async runAgent(t, n) {
|
|
@@ -10172,7 +10244,7 @@ var Se2 = class {
|
|
|
10172
10244
|
return e.messages;
|
|
10173
10245
|
}, get state() {
|
|
10174
10246
|
return e.state;
|
|
10175
|
-
} }), this).run(r),
|
|
10247
|
+
} }), this).run(r), W2(this.debugLogger), L2(this.debugLogger), (e) => e.pipe(takeUntil(this.activeRunDetach$)), (e) => this.apply(r, e, o), (e) => this.processApplyEvents(r, e, o), catchError((e) => (this.debugLogger?.lifecycle(`LIFECYCLE`, `Run errored:`, { agentId: this.agentId, error: e instanceof Error ? e.message : String(e) }), this.isRunning = false, this.onError(r, e, o))), finalize(() => {
|
|
10176
10248
|
this.debugLogger?.lifecycle(`LIFECYCLE`, `Run finished:`, { agentId: this.agentId, threadId: this.threadId }), this.isRunning = false, this.onFinalize(r, o), s?.(), s = void 0, this.activeRunCompletionPromise = void 0, this.activeRunDetach$ = void 0;
|
|
10177
10249
|
}))(of(null)));
|
|
10178
10250
|
let c = O2(this.messages).filter((e) => !a.has(e.id));
|
|
@@ -10194,7 +10266,7 @@ var Se2 = class {
|
|
|
10194
10266
|
let d;
|
|
10195
10267
|
this.activeRunCompletionPromise = new Promise((e) => {
|
|
10196
10268
|
d = e;
|
|
10197
|
-
}), await lastValueFrom(pipe(() => defer(() => this.connect(i)),
|
|
10269
|
+
}), await lastValueFrom(pipe(() => defer(() => this.connect(i)), W2(this.debugLogger), L2(this.debugLogger), (e) => e.pipe(takeUntil(this.activeRunDetach$)), (e) => this.apply(i, e, c), (e) => this.processApplyEvents(i, e, c), catchError((e) => (this.isRunning = false, e instanceof AGUIConnectNotImplementedError ? EMPTY : this.onError(i, e, c))), finalize(() => {
|
|
10198
10270
|
this.isRunning = false, this.onFinalize(i, c), d?.(), d = void 0, this.activeRunCompletionPromise = void 0, this.activeRunDetach$ = void 0;
|
|
10199
10271
|
}))(of(null)), { defaultValue: void 0 });
|
|
10200
10272
|
let f = O2(this.messages).filter((e) => !s.has(e.id));
|
|
@@ -10241,7 +10313,10 @@ var Se2 = class {
|
|
|
10241
10313
|
t2.onMessagesChanged?.({ messages: this.messages, state: this.state, agent: this, input: e });
|
|
10242
10314
|
})), i.state !== void 0 && (this.state = i.state, n.forEach((t2) => {
|
|
10243
10315
|
t2.onStateChanged?.({ state: this.state, messages: this.messages, agent: this, input: e });
|
|
10244
|
-
}))), i.stopPropagation !== true)
|
|
10316
|
+
}))), i.stopPropagation !== true) {
|
|
10317
|
+
let e2 = String(t);
|
|
10318
|
+
if (!(t.name === `AbortError` || t.message === `Fetch is aborted` || t.message === `signal is aborted without reason` || t.message === `component unmounted` || e2 === `component unmounted`)) throw console.error(`Agent execution failed:`, t), t;
|
|
10319
|
+
}
|
|
10245
10320
|
return {};
|
|
10246
10321
|
}));
|
|
10247
10322
|
}
|
|
@@ -10290,10 +10365,10 @@ var Se2 = class {
|
|
|
10290
10365
|
return e.messages;
|
|
10291
10366
|
}, get state() {
|
|
10292
10367
|
return e.state;
|
|
10293
|
-
} }), this).run(n)).pipe(
|
|
10368
|
+
} }), this).run(n)).pipe(W2(this.debugLogger), L2(this.debugLogger), ve2(this.threadId, n.runId, this.agentId), (e) => e.pipe(map((e2) => (this.debugLogger?.event(`LEGACY`, `Event:`, e2, { type: e2.type }), e2))));
|
|
10294
10369
|
}
|
|
10295
10370
|
};
|
|
10296
|
-
var
|
|
10371
|
+
var je2 = class extends Ae2 {
|
|
10297
10372
|
requestInit(e) {
|
|
10298
10373
|
return { method: `POST`, headers: { ...this.headers, "Content-Type": `application/json`, Accept: `text/event-stream` }, body: JSON.stringify(e), signal: this.abortController.signal };
|
|
10299
10374
|
}
|
|
@@ -10340,7 +10415,7 @@ var AgUiTransport = class {
|
|
|
10340
10415
|
}
|
|
10341
10416
|
connect(sessionId) {
|
|
10342
10417
|
const resolvedHeaders = typeof this._headers === "function" ? this._headers() : this._headers;
|
|
10343
|
-
this._agent = new
|
|
10418
|
+
this._agent = new je2({
|
|
10344
10419
|
url: this._url,
|
|
10345
10420
|
headers: resolvedHeaders,
|
|
10346
10421
|
threadId: this._threadId || void 0
|
|
@@ -11191,4 +11266,4 @@ fast-json-patch/module/duplex.mjs:
|
|
|
11191
11266
|
* MIT license
|
|
11192
11267
|
*)
|
|
11193
11268
|
*/
|
|
11194
|
-
//# sourceMappingURL=chunk-
|
|
11269
|
+
//# sourceMappingURL=chunk-XJQRG6VA.js.map
|