@runtypelabs/persona 3.15.1 → 3.16.0
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 +46 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.global.js +61 -61
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +46 -46
- package/dist/index.js.map +1 -1
- package/dist/theme-editor.cjs +169 -64
- package/dist/theme-editor.d.cts +11 -0
- package/dist/theme-editor.d.ts +11 -0
- package/dist/theme-editor.js +169 -64
- package/package.json +1 -1
- package/src/client.ts +169 -2
- package/src/components/header-builder.ts +18 -7
- package/src/components/header-layouts.ts +3 -1
- package/src/defaults.ts +6 -0
- package/src/types.ts +11 -0
- package/src/ui.ts +4 -2
package/dist/theme-editor.cjs
CHANGED
|
@@ -154,6 +154,12 @@ var DEFAULT_WIDGET_CONFIG = {
|
|
|
154
154
|
agentIconSize: "40px",
|
|
155
155
|
headerIconSize: "40px",
|
|
156
156
|
closeButtonSize: "32px",
|
|
157
|
+
// Zero out browser-default <button> padding so the icon gets the full
|
|
158
|
+
// 32x32 content box, matching clearChat.paddingX/Y below. Without this,
|
|
159
|
+
// UA stylesheets add ~1-2px vertical and ~6px horizontal padding that
|
|
160
|
+
// eats into the border-box width and shrinks the rendered icon.
|
|
161
|
+
closeButtonPaddingX: "0px",
|
|
162
|
+
closeButtonPaddingY: "0px",
|
|
157
163
|
callToActionIconName: "arrow-up-right",
|
|
158
164
|
callToActionIconText: "",
|
|
159
165
|
callToActionIconSize: "32px",
|
|
@@ -4456,6 +4462,8 @@ var AgentWidgetClient = class {
|
|
|
4456
4462
|
let didSplitByPartId = false;
|
|
4457
4463
|
const reasoningMessages = /* @__PURE__ */ new Map();
|
|
4458
4464
|
const toolMessages = /* @__PURE__ */ new Map();
|
|
4465
|
+
const nestedStepMessages = /* @__PURE__ */ new Map();
|
|
4466
|
+
const nestedPartIdByStep = /* @__PURE__ */ new Map();
|
|
4459
4467
|
const reasoningContext = {
|
|
4460
4468
|
lastId: null,
|
|
4461
4469
|
byStep: /* @__PURE__ */ new Map()
|
|
@@ -4464,6 +4472,31 @@ var AgentWidgetClient = class {
|
|
|
4464
4472
|
lastId: null,
|
|
4465
4473
|
byCall: /* @__PURE__ */ new Map()
|
|
4466
4474
|
};
|
|
4475
|
+
const getNestedStepKey = (toolId, stepId, partId = "") => `${toolId}::${stepId}::${partId}`;
|
|
4476
|
+
const getNestedStepPrefix = (toolId, stepId) => `${toolId}::${stepId}::`;
|
|
4477
|
+
const ensureNestedStepMessage = (toolId, stepId, partId, executionId) => {
|
|
4478
|
+
const key = getNestedStepKey(toolId, stepId, partId);
|
|
4479
|
+
const existing = nestedStepMessages.get(key);
|
|
4480
|
+
if (existing) return existing;
|
|
4481
|
+
const idSuffix = partId ? `-${partId}` : "";
|
|
4482
|
+
const message = {
|
|
4483
|
+
id: `nested-${toolId}-${stepId}${idSuffix}`,
|
|
4484
|
+
role: "assistant",
|
|
4485
|
+
content: "",
|
|
4486
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4487
|
+
streaming: true,
|
|
4488
|
+
sequence: nextSequence(),
|
|
4489
|
+
...partId ? { partId } : {},
|
|
4490
|
+
agentMetadata: {
|
|
4491
|
+
executionId,
|
|
4492
|
+
parentToolId: toolId,
|
|
4493
|
+
parentStepId: stepId
|
|
4494
|
+
}
|
|
4495
|
+
};
|
|
4496
|
+
nestedStepMessages.set(key, message);
|
|
4497
|
+
emitMessage(message);
|
|
4498
|
+
return message;
|
|
4499
|
+
};
|
|
4467
4500
|
const normalizeKey = (value) => {
|
|
4468
4501
|
if (value === null || value === void 0) return null;
|
|
4469
4502
|
try {
|
|
@@ -4773,7 +4806,7 @@ var AgentWidgetClient = class {
|
|
|
4773
4806
|
const agentIterationMessages = /* @__PURE__ */ new Map();
|
|
4774
4807
|
const iterationDisplay = (_a = this.config.iterationDisplay) != null ? _a : "separate";
|
|
4775
4808
|
drainReadyQueue = () => {
|
|
4776
|
-
var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb;
|
|
4809
|
+
var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb, _lb, _mb, _nb, _ob, _pb, _qb, _rb, _sb, _tb, _ub;
|
|
4777
4810
|
for (let i = 0; i < seqReadyQueue.length; i++) {
|
|
4778
4811
|
const payloadType = seqReadyQueue[i].payloadType;
|
|
4779
4812
|
const payload = seqReadyQueue[i].payload;
|
|
@@ -4946,6 +4979,9 @@ var AgentWidgetClient = class {
|
|
|
4946
4979
|
toolContext.byCall.delete(callKey);
|
|
4947
4980
|
}
|
|
4948
4981
|
} else if (payloadType === "text_start") {
|
|
4982
|
+
if ((_X = payload.toolContext) == null ? void 0 : _X.toolId) {
|
|
4983
|
+
continue;
|
|
4984
|
+
}
|
|
4949
4985
|
const incomingPartId = payload.partId;
|
|
4950
4986
|
if (incomingPartId !== void 0 && partIdState.current !== null && incomingPartId !== partIdState.current) {
|
|
4951
4987
|
const prev = assistantMessage;
|
|
@@ -4961,6 +4997,9 @@ var AgentWidgetClient = class {
|
|
|
4961
4997
|
partIdState.current = incomingPartId;
|
|
4962
4998
|
}
|
|
4963
4999
|
} else if (payloadType === "text_end") {
|
|
5000
|
+
if ((_Y = payload.toolContext) == null ? void 0 : _Y.toolId) {
|
|
5001
|
+
continue;
|
|
5002
|
+
}
|
|
4964
5003
|
const prev = assistantMessage;
|
|
4965
5004
|
if (prev) {
|
|
4966
5005
|
prev.streaming = false;
|
|
@@ -4975,6 +5014,48 @@ var AgentWidgetClient = class {
|
|
|
4975
5014
|
if (stepType === "tool" || executionType === "context") {
|
|
4976
5015
|
continue;
|
|
4977
5016
|
}
|
|
5017
|
+
const nestedToolCtx = payload.toolContext;
|
|
5018
|
+
if (nestedToolCtx == null ? void 0 : nestedToolCtx.toolId) {
|
|
5019
|
+
const nestedStepId = String(
|
|
5020
|
+
(__ = (_Z = payload.id) != null ? _Z : nestedToolCtx.stepId) != null ? __ : `step-${nextSequence()}`
|
|
5021
|
+
);
|
|
5022
|
+
const incomingPartId2 = payload.partId !== void 0 && payload.partId !== null ? String(payload.partId) : "";
|
|
5023
|
+
const stepScopeKey = `${nestedToolCtx.toolId}::${nestedStepId}`;
|
|
5024
|
+
const prevPartId = nestedPartIdByStep.get(stepScopeKey);
|
|
5025
|
+
if (incomingPartId2 !== "" && prevPartId !== void 0 && prevPartId !== "" && prevPartId !== incomingPartId2) {
|
|
5026
|
+
const prev = nestedStepMessages.get(
|
|
5027
|
+
getNestedStepKey(
|
|
5028
|
+
nestedToolCtx.toolId,
|
|
5029
|
+
nestedStepId,
|
|
5030
|
+
prevPartId
|
|
5031
|
+
)
|
|
5032
|
+
);
|
|
5033
|
+
if (prev && prev.streaming !== false) {
|
|
5034
|
+
prev.streaming = false;
|
|
5035
|
+
emitMessage(prev);
|
|
5036
|
+
}
|
|
5037
|
+
}
|
|
5038
|
+
if (incomingPartId2 !== "") {
|
|
5039
|
+
nestedPartIdByStep.set(stepScopeKey, incomingPartId2);
|
|
5040
|
+
}
|
|
5041
|
+
const nestedMsg = ensureNestedStepMessage(
|
|
5042
|
+
nestedToolCtx.toolId,
|
|
5043
|
+
nestedStepId,
|
|
5044
|
+
incomingPartId2,
|
|
5045
|
+
nestedToolCtx.executionId
|
|
5046
|
+
);
|
|
5047
|
+
const nestedChunk = (_ca = (_ba = (_aa = (_$ = payload.text) != null ? _$ : payload.delta) != null ? _aa : payload.content) != null ? _ba : payload.chunk) != null ? _ca : "";
|
|
5048
|
+
if (nestedChunk) {
|
|
5049
|
+
nestedMsg.content += String(nestedChunk);
|
|
5050
|
+
nestedMsg.streaming = true;
|
|
5051
|
+
emitMessage(nestedMsg);
|
|
5052
|
+
}
|
|
5053
|
+
if (payload.isComplete) {
|
|
5054
|
+
nestedMsg.streaming = false;
|
|
5055
|
+
emitMessage(nestedMsg);
|
|
5056
|
+
}
|
|
5057
|
+
continue;
|
|
5058
|
+
}
|
|
4978
5059
|
const incomingPartId = payload.partId;
|
|
4979
5060
|
if (incomingPartId !== void 0 && partIdState.current !== null && incomingPartId !== partIdState.current) {
|
|
4980
5061
|
const prev = assistantMessage;
|
|
@@ -4989,18 +5070,18 @@ var AgentWidgetClient = class {
|
|
|
4989
5070
|
if (incomingPartId !== void 0) {
|
|
4990
5071
|
partIdState.current = incomingPartId;
|
|
4991
5072
|
}
|
|
4992
|
-
const assistant = incomingPartId !== void 0 ? (
|
|
5073
|
+
const assistant = incomingPartId !== void 0 ? (_da = assistantMessagesByPartId.get(incomingPartId)) != null ? _da : ensureAssistantMessage() : ensureAssistantMessage();
|
|
4993
5074
|
if (incomingPartId !== void 0) {
|
|
4994
5075
|
if (!assistant.partId) {
|
|
4995
5076
|
assistant.partId = incomingPartId;
|
|
4996
5077
|
}
|
|
4997
5078
|
assistantMessagesByPartId.set(incomingPartId, assistant);
|
|
4998
5079
|
}
|
|
4999
|
-
const chunk = (
|
|
5080
|
+
const chunk = (_ha = (_ga = (_fa = (_ea = payload.text) != null ? _ea : payload.delta) != null ? _fa : payload.content) != null ? _ga : payload.chunk) != null ? _ha : "";
|
|
5000
5081
|
if (chunk) {
|
|
5001
5082
|
const chunkSeq = typeof payload.seq === "number" ? payload.seq : void 0;
|
|
5002
5083
|
const chunkBufferKey = incomingPartId != null ? incomingPartId : assistant.id;
|
|
5003
|
-
const accumulatedRaw = chunkSeq !== void 0 ? insertOrderedChunk(chunkBufferKey, chunkSeq, String(chunk)) : ((
|
|
5084
|
+
const accumulatedRaw = chunkSeq !== void 0 ? insertOrderedChunk(chunkBufferKey, chunkSeq, String(chunk)) : ((_ia = rawContentBuffers.get(assistant.id)) != null ? _ia : "") + chunk;
|
|
5004
5085
|
assistant.rawContent = accumulatedRaw;
|
|
5005
5086
|
if (!streamParsers.has(assistant.id)) {
|
|
5006
5087
|
streamParsers.set(assistant.id, this.createStreamParser());
|
|
@@ -5046,7 +5127,7 @@ var AgentWidgetClient = class {
|
|
|
5046
5127
|
emitMessage(assistant);
|
|
5047
5128
|
});
|
|
5048
5129
|
} else {
|
|
5049
|
-
const text = typeof parsedResult === "string" ? parsedResult : (
|
|
5130
|
+
const text = typeof parsedResult === "string" ? parsedResult : (_ja = parsedResult == null ? void 0 : parsedResult.text) != null ? _ja : null;
|
|
5050
5131
|
if (text !== null && text.trim() !== "") {
|
|
5051
5132
|
assistant.content = text;
|
|
5052
5133
|
emitMessage(assistant);
|
|
@@ -5060,7 +5141,7 @@ var AgentWidgetClient = class {
|
|
|
5060
5141
|
}
|
|
5061
5142
|
}
|
|
5062
5143
|
if (payload.isComplete) {
|
|
5063
|
-
const finalContent = (
|
|
5144
|
+
const finalContent = (_la = (_ka = payload.result) == null ? void 0 : _ka.response) != null ? _la : assistant.content;
|
|
5064
5145
|
if (finalContent) {
|
|
5065
5146
|
const rawBuffer = rawContentBuffers.get(assistant.id);
|
|
5066
5147
|
const contentToProcess = rawBuffer != null ? rawBuffer : ensureStringContent(finalContent);
|
|
@@ -5092,7 +5173,7 @@ var AgentWidgetClient = class {
|
|
|
5092
5173
|
}
|
|
5093
5174
|
});
|
|
5094
5175
|
} else {
|
|
5095
|
-
extractedText = typeof parsedResult === "string" ? parsedResult : (
|
|
5176
|
+
extractedText = typeof parsedResult === "string" ? parsedResult : (_ma = parsedResult == null ? void 0 : parsedResult.text) != null ? _ma : null;
|
|
5096
5177
|
}
|
|
5097
5178
|
}
|
|
5098
5179
|
}
|
|
@@ -5104,7 +5185,7 @@ var AgentWidgetClient = class {
|
|
|
5104
5185
|
}
|
|
5105
5186
|
const parserToClose = streamParsers.get(assistant.id);
|
|
5106
5187
|
if (parserToClose) {
|
|
5107
|
-
const closeResult = (
|
|
5188
|
+
const closeResult = (_na = parserToClose.close) == null ? void 0 : _na.call(parserToClose);
|
|
5108
5189
|
if (closeResult instanceof Promise) {
|
|
5109
5190
|
closeResult.catch(() => {
|
|
5110
5191
|
});
|
|
@@ -5123,6 +5204,28 @@ var AgentWidgetClient = class {
|
|
|
5123
5204
|
if (stepType === "tool" || executionType === "context") {
|
|
5124
5205
|
continue;
|
|
5125
5206
|
}
|
|
5207
|
+
const nestedCompleteCtx = payload.toolContext;
|
|
5208
|
+
if (nestedCompleteCtx == null ? void 0 : nestedCompleteCtx.toolId) {
|
|
5209
|
+
const nestedStepId = String(
|
|
5210
|
+
(_pa = (_oa = payload.id) != null ? _oa : nestedCompleteCtx.stepId) != null ? _pa : ""
|
|
5211
|
+
);
|
|
5212
|
+
if (nestedStepId) {
|
|
5213
|
+
const prefix = getNestedStepPrefix(
|
|
5214
|
+
nestedCompleteCtx.toolId,
|
|
5215
|
+
nestedStepId
|
|
5216
|
+
);
|
|
5217
|
+
for (const [key, msg] of nestedStepMessages) {
|
|
5218
|
+
if (key.startsWith(prefix) && msg.streaming !== false) {
|
|
5219
|
+
msg.streaming = false;
|
|
5220
|
+
emitMessage(msg);
|
|
5221
|
+
}
|
|
5222
|
+
}
|
|
5223
|
+
nestedPartIdByStep.delete(
|
|
5224
|
+
`${nestedCompleteCtx.toolId}::${nestedStepId}`
|
|
5225
|
+
);
|
|
5226
|
+
}
|
|
5227
|
+
continue;
|
|
5228
|
+
}
|
|
5126
5229
|
if (didSplitByPartId) {
|
|
5127
5230
|
if (assistantMessage !== null) {
|
|
5128
5231
|
const msg = assistantMessage;
|
|
@@ -5133,7 +5236,7 @@ var AgentWidgetClient = class {
|
|
|
5133
5236
|
emitMessage(msg);
|
|
5134
5237
|
}
|
|
5135
5238
|
}
|
|
5136
|
-
const splitFinalContent = (
|
|
5239
|
+
const splitFinalContent = (_qa = payload.result) == null ? void 0 : _qa.response;
|
|
5137
5240
|
const sealedForReconcile = lastSealedTextSegment;
|
|
5138
5241
|
if (sealedForReconcile) {
|
|
5139
5242
|
if (splitFinalContent !== void 0 && splitFinalContent !== null) {
|
|
@@ -5146,7 +5249,7 @@ var AgentWidgetClient = class {
|
|
|
5146
5249
|
lastSealedTextSegment = null;
|
|
5147
5250
|
continue;
|
|
5148
5251
|
}
|
|
5149
|
-
const finalContent = (
|
|
5252
|
+
const finalContent = (_ra = payload.result) == null ? void 0 : _ra.response;
|
|
5150
5253
|
const assistant = ensureAssistantMessage();
|
|
5151
5254
|
if (finalContent !== void 0 && finalContent !== null) {
|
|
5152
5255
|
const parser = streamParsers.get(assistant.id);
|
|
@@ -5198,7 +5301,7 @@ var AgentWidgetClient = class {
|
|
|
5198
5301
|
}
|
|
5199
5302
|
});
|
|
5200
5303
|
} else {
|
|
5201
|
-
const text = typeof parsedResult === "string" ? parsedResult : (
|
|
5304
|
+
const text = typeof parsedResult === "string" ? parsedResult : (_sa = parsedResult == null ? void 0 : parsedResult.text) != null ? _sa : null;
|
|
5202
5305
|
if (text !== null && text.trim() !== "") {
|
|
5203
5306
|
assistant.content = text;
|
|
5204
5307
|
hasExtractedText = true;
|
|
@@ -5222,7 +5325,7 @@ var AgentWidgetClient = class {
|
|
|
5222
5325
|
assistant.content = ensureStringContent(finalContent);
|
|
5223
5326
|
}
|
|
5224
5327
|
if (parser) {
|
|
5225
|
-
const closeResult = (
|
|
5328
|
+
const closeResult = (_ta = parser.close) == null ? void 0 : _ta.call(parser);
|
|
5226
5329
|
if (closeResult instanceof Promise) {
|
|
5227
5330
|
closeResult.catch(() => {
|
|
5228
5331
|
});
|
|
@@ -5240,7 +5343,7 @@ var AgentWidgetClient = class {
|
|
|
5240
5343
|
emitMessage(assistant);
|
|
5241
5344
|
}
|
|
5242
5345
|
} else if (payloadType === "flow_complete") {
|
|
5243
|
-
const finalContent = (
|
|
5346
|
+
const finalContent = (_ua = payload.result) == null ? void 0 : _ua.response;
|
|
5244
5347
|
if (didSplitByPartId) {
|
|
5245
5348
|
if (assistantMessage !== null) {
|
|
5246
5349
|
const msg = assistantMessage;
|
|
@@ -5307,11 +5410,11 @@ var AgentWidgetClient = class {
|
|
|
5307
5410
|
} else if (payloadType === "agent_start") {
|
|
5308
5411
|
agentExecution = {
|
|
5309
5412
|
executionId: payload.executionId,
|
|
5310
|
-
agentId: (
|
|
5311
|
-
agentName: (
|
|
5413
|
+
agentId: (_va = payload.agentId) != null ? _va : "virtual",
|
|
5414
|
+
agentName: (_wa = payload.agentName) != null ? _wa : "",
|
|
5312
5415
|
status: "running",
|
|
5313
5416
|
currentIteration: 0,
|
|
5314
|
-
maxTurns: (
|
|
5417
|
+
maxTurns: (_xa = payload.maxTurns) != null ? _xa : 1,
|
|
5315
5418
|
startedAt: resolveTimestamp(payload.startedAt)
|
|
5316
5419
|
};
|
|
5317
5420
|
} else if (payloadType === "agent_iteration_start") {
|
|
@@ -5331,7 +5434,7 @@ var AgentWidgetClient = class {
|
|
|
5331
5434
|
} else if (payloadType === "agent_turn_delta") {
|
|
5332
5435
|
if (payload.contentType === "text") {
|
|
5333
5436
|
const assistant = ensureAssistantMessage();
|
|
5334
|
-
assistant.content += (
|
|
5437
|
+
assistant.content += (_ya = payload.delta) != null ? _ya : "";
|
|
5335
5438
|
assistant.agentMetadata = {
|
|
5336
5439
|
executionId: payload.executionId,
|
|
5337
5440
|
iteration: payload.iteration,
|
|
@@ -5340,14 +5443,14 @@ var AgentWidgetClient = class {
|
|
|
5340
5443
|
};
|
|
5341
5444
|
emitMessage(assistant);
|
|
5342
5445
|
} else if (payload.contentType === "thinking") {
|
|
5343
|
-
const reasoningId = (
|
|
5446
|
+
const reasoningId = (_za = payload.turnId) != null ? _za : `agent-think-${payload.iteration}`;
|
|
5344
5447
|
const reasoningMessage = ensureReasoningMessage(reasoningId);
|
|
5345
|
-
reasoningMessage.reasoning = (
|
|
5448
|
+
reasoningMessage.reasoning = (_Aa = reasoningMessage.reasoning) != null ? _Aa : {
|
|
5346
5449
|
id: reasoningId,
|
|
5347
5450
|
status: "streaming",
|
|
5348
5451
|
chunks: []
|
|
5349
5452
|
};
|
|
5350
|
-
reasoningMessage.reasoning.chunks.push((
|
|
5453
|
+
reasoningMessage.reasoning.chunks.push((_Ba = payload.delta) != null ? _Ba : "");
|
|
5351
5454
|
reasoningMessage.agentMetadata = {
|
|
5352
5455
|
executionId: payload.executionId,
|
|
5353
5456
|
iteration: payload.iteration,
|
|
@@ -5355,12 +5458,12 @@ var AgentWidgetClient = class {
|
|
|
5355
5458
|
};
|
|
5356
5459
|
emitMessage(reasoningMessage);
|
|
5357
5460
|
} else if (payload.contentType === "tool_input") {
|
|
5358
|
-
const toolId = (
|
|
5461
|
+
const toolId = (_Ca = payload.toolCallId) != null ? _Ca : toolContext.lastId;
|
|
5359
5462
|
if (toolId) {
|
|
5360
5463
|
const toolMessage = toolMessages.get(toolId);
|
|
5361
5464
|
if (toolMessage == null ? void 0 : toolMessage.toolCall) {
|
|
5362
|
-
toolMessage.toolCall.chunks = (
|
|
5363
|
-
toolMessage.toolCall.chunks.push((
|
|
5465
|
+
toolMessage.toolCall.chunks = (_Da = toolMessage.toolCall.chunks) != null ? _Da : [];
|
|
5466
|
+
toolMessage.toolCall.chunks.push((_Ea = payload.delta) != null ? _Ea : "");
|
|
5364
5467
|
emitMessage(toolMessage);
|
|
5365
5468
|
}
|
|
5366
5469
|
}
|
|
@@ -5372,20 +5475,20 @@ var AgentWidgetClient = class {
|
|
|
5372
5475
|
if (reasoningMessage == null ? void 0 : reasoningMessage.reasoning) {
|
|
5373
5476
|
reasoningMessage.reasoning.status = "complete";
|
|
5374
5477
|
reasoningMessage.reasoning.completedAt = resolveTimestamp(payload.completedAt);
|
|
5375
|
-
const start = (
|
|
5478
|
+
const start = (_Fa = reasoningMessage.reasoning.startedAt) != null ? _Fa : Date.now();
|
|
5376
5479
|
reasoningMessage.reasoning.durationMs = Math.max(
|
|
5377
5480
|
0,
|
|
5378
|
-
((
|
|
5481
|
+
((_Ga = reasoningMessage.reasoning.completedAt) != null ? _Ga : Date.now()) - start
|
|
5379
5482
|
);
|
|
5380
5483
|
reasoningMessage.streaming = false;
|
|
5381
5484
|
emitMessage(reasoningMessage);
|
|
5382
5485
|
}
|
|
5383
5486
|
}
|
|
5384
5487
|
} else if (payloadType === "agent_tool_start") {
|
|
5385
|
-
const toolId = (
|
|
5488
|
+
const toolId = (_Ha = payload.toolCallId) != null ? _Ha : `agent-tool-${nextSequence()}`;
|
|
5386
5489
|
trackToolId(getToolCallKey(payload), toolId);
|
|
5387
5490
|
const toolMessage = ensureToolMessage(toolId);
|
|
5388
|
-
const tool = (
|
|
5491
|
+
const tool = (_Ia = toolMessage.toolCall) != null ? _Ia : {
|
|
5389
5492
|
id: toolId,
|
|
5390
5493
|
status: "pending",
|
|
5391
5494
|
name: void 0,
|
|
@@ -5397,12 +5500,12 @@ var AgentWidgetClient = class {
|
|
|
5397
5500
|
completedAt: void 0,
|
|
5398
5501
|
durationMs: void 0
|
|
5399
5502
|
};
|
|
5400
|
-
tool.name = (
|
|
5503
|
+
tool.name = (_Ka = (_Ja = payload.toolName) != null ? _Ja : payload.name) != null ? _Ka : tool.name;
|
|
5401
5504
|
tool.status = "running";
|
|
5402
5505
|
if (payload.parameters !== void 0) {
|
|
5403
5506
|
tool.args = payload.parameters;
|
|
5404
5507
|
}
|
|
5405
|
-
tool.startedAt = resolveTimestamp((
|
|
5508
|
+
tool.startedAt = resolveTimestamp((_La = payload.startedAt) != null ? _La : payload.timestamp);
|
|
5406
5509
|
toolMessage.toolCall = tool;
|
|
5407
5510
|
toolMessage.streaming = true;
|
|
5408
5511
|
toolMessage.agentMetadata = {
|
|
@@ -5411,21 +5514,21 @@ var AgentWidgetClient = class {
|
|
|
5411
5514
|
};
|
|
5412
5515
|
emitMessage(toolMessage);
|
|
5413
5516
|
} else if (payloadType === "agent_tool_delta") {
|
|
5414
|
-
const toolId = (
|
|
5517
|
+
const toolId = (_Ma = payload.toolCallId) != null ? _Ma : toolContext.lastId;
|
|
5415
5518
|
if (toolId) {
|
|
5416
|
-
const toolMessage = (
|
|
5519
|
+
const toolMessage = (_Na = toolMessages.get(toolId)) != null ? _Na : ensureToolMessage(toolId);
|
|
5417
5520
|
if (toolMessage.toolCall) {
|
|
5418
|
-
toolMessage.toolCall.chunks = (
|
|
5419
|
-
toolMessage.toolCall.chunks.push((
|
|
5521
|
+
toolMessage.toolCall.chunks = (_Oa = toolMessage.toolCall.chunks) != null ? _Oa : [];
|
|
5522
|
+
toolMessage.toolCall.chunks.push((_Pa = payload.delta) != null ? _Pa : "");
|
|
5420
5523
|
toolMessage.toolCall.status = "running";
|
|
5421
5524
|
toolMessage.streaming = true;
|
|
5422
5525
|
emitMessage(toolMessage);
|
|
5423
5526
|
}
|
|
5424
5527
|
}
|
|
5425
5528
|
} else if (payloadType === "agent_tool_complete") {
|
|
5426
|
-
const toolId = (
|
|
5529
|
+
const toolId = (_Qa = payload.toolCallId) != null ? _Qa : toolContext.lastId;
|
|
5427
5530
|
if (toolId) {
|
|
5428
|
-
const toolMessage = (
|
|
5531
|
+
const toolMessage = (_Ra = toolMessages.get(toolId)) != null ? _Ra : ensureToolMessage(toolId);
|
|
5429
5532
|
if (toolMessage.toolCall) {
|
|
5430
5533
|
toolMessage.toolCall.status = "complete";
|
|
5431
5534
|
if (payload.result !== void 0) {
|
|
@@ -5434,7 +5537,7 @@ var AgentWidgetClient = class {
|
|
|
5434
5537
|
if (typeof payload.executionTime === "number") {
|
|
5435
5538
|
toolMessage.toolCall.durationMs = payload.executionTime;
|
|
5436
5539
|
}
|
|
5437
|
-
toolMessage.toolCall.completedAt = resolveTimestamp((
|
|
5540
|
+
toolMessage.toolCall.completedAt = resolveTimestamp((_Sa = payload.completedAt) != null ? _Sa : payload.timestamp);
|
|
5438
5541
|
toolMessage.streaming = false;
|
|
5439
5542
|
emitMessage(toolMessage);
|
|
5440
5543
|
const callKey = getToolCallKey(payload);
|
|
@@ -5449,7 +5552,7 @@ var AgentWidgetClient = class {
|
|
|
5449
5552
|
const reflectionMessage = {
|
|
5450
5553
|
id: reflectionId,
|
|
5451
5554
|
role: "assistant",
|
|
5452
|
-
content: (
|
|
5555
|
+
content: (_Ta = payload.reflection) != null ? _Ta : "",
|
|
5453
5556
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5454
5557
|
streaming: false,
|
|
5455
5558
|
variant: "reasoning",
|
|
@@ -5457,7 +5560,7 @@ var AgentWidgetClient = class {
|
|
|
5457
5560
|
reasoning: {
|
|
5458
5561
|
id: reflectionId,
|
|
5459
5562
|
status: "complete",
|
|
5460
|
-
chunks: [(
|
|
5563
|
+
chunks: [(_Ua = payload.reflection) != null ? _Ua : ""]
|
|
5461
5564
|
},
|
|
5462
5565
|
agentMetadata: {
|
|
5463
5566
|
executionId: payload.executionId,
|
|
@@ -5478,7 +5581,7 @@ var AgentWidgetClient = class {
|
|
|
5478
5581
|
}
|
|
5479
5582
|
onEvent({ type: "status", status: "idle" });
|
|
5480
5583
|
} else if (payloadType === "agent_error") {
|
|
5481
|
-
const errorMessage = typeof payload.error === "string" ? payload.error : (
|
|
5584
|
+
const errorMessage = typeof payload.error === "string" ? payload.error : (_Wa = (_Va = payload.error) == null ? void 0 : _Va.message) != null ? _Wa : "Agent execution error";
|
|
5482
5585
|
if (payload.recoverable) {
|
|
5483
5586
|
if (typeof console !== "undefined") {
|
|
5484
5587
|
console.warn("[AgentWidget] Recoverable agent error:", errorMessage);
|
|
@@ -5491,7 +5594,7 @@ var AgentWidgetClient = class {
|
|
|
5491
5594
|
}
|
|
5492
5595
|
} else if (payloadType === "agent_ping") {
|
|
5493
5596
|
} else if (payloadType === "agent_approval_start") {
|
|
5494
|
-
const approvalId = (
|
|
5597
|
+
const approvalId = (_Xa = payload.approvalId) != null ? _Xa : `approval-${nextSequence()}`;
|
|
5495
5598
|
const approvalMessage = {
|
|
5496
5599
|
id: `approval-${approvalId}`,
|
|
5497
5600
|
role: "assistant",
|
|
@@ -5503,17 +5606,17 @@ var AgentWidgetClient = class {
|
|
|
5503
5606
|
approval: {
|
|
5504
5607
|
id: approvalId,
|
|
5505
5608
|
status: "pending",
|
|
5506
|
-
agentId: (
|
|
5507
|
-
executionId: (
|
|
5508
|
-
toolName: (
|
|
5609
|
+
agentId: (_Ya = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _Ya : "virtual",
|
|
5610
|
+
executionId: (__a = (_Za = payload.executionId) != null ? _Za : agentExecution == null ? void 0 : agentExecution.executionId) != null ? __a : "",
|
|
5611
|
+
toolName: (_$a = payload.toolName) != null ? _$a : "",
|
|
5509
5612
|
toolType: payload.toolType,
|
|
5510
|
-
description: (
|
|
5613
|
+
description: (_bb = payload.description) != null ? _bb : `Execute ${(_ab = payload.toolName) != null ? _ab : "tool"}`,
|
|
5511
5614
|
parameters: payload.parameters
|
|
5512
5615
|
}
|
|
5513
5616
|
};
|
|
5514
5617
|
emitMessage(approvalMessage);
|
|
5515
5618
|
} else if (payloadType === "step_await" && payload.awaitReason === "approval_required") {
|
|
5516
|
-
const approvalId = (
|
|
5619
|
+
const approvalId = (_cb = payload.approvalId) != null ? _cb : `approval-${nextSequence()}`;
|
|
5517
5620
|
const approvalMessage = {
|
|
5518
5621
|
id: `approval-${approvalId}`,
|
|
5519
5622
|
role: "assistant",
|
|
@@ -5525,11 +5628,11 @@ var AgentWidgetClient = class {
|
|
|
5525
5628
|
approval: {
|
|
5526
5629
|
id: approvalId,
|
|
5527
5630
|
status: "pending",
|
|
5528
|
-
agentId: (
|
|
5529
|
-
executionId: (
|
|
5530
|
-
toolName: (
|
|
5631
|
+
agentId: (_db = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _db : "virtual",
|
|
5632
|
+
executionId: (_fb = (_eb = payload.executionId) != null ? _eb : agentExecution == null ? void 0 : agentExecution.executionId) != null ? _fb : "",
|
|
5633
|
+
toolName: (_gb = payload.toolName) != null ? _gb : "",
|
|
5531
5634
|
toolType: payload.toolType,
|
|
5532
|
-
description: (
|
|
5635
|
+
description: (_ib = payload.description) != null ? _ib : `Execute ${(_hb = payload.toolName) != null ? _hb : "tool"}`,
|
|
5533
5636
|
parameters: payload.parameters
|
|
5534
5637
|
}
|
|
5535
5638
|
};
|
|
@@ -5548,11 +5651,11 @@ var AgentWidgetClient = class {
|
|
|
5548
5651
|
sequence: nextSequence(),
|
|
5549
5652
|
approval: {
|
|
5550
5653
|
id: approvalId,
|
|
5551
|
-
status: (
|
|
5552
|
-
agentId: (
|
|
5553
|
-
executionId: (
|
|
5554
|
-
toolName: (
|
|
5555
|
-
description: (
|
|
5654
|
+
status: (_jb = payload.decision) != null ? _jb : "approved",
|
|
5655
|
+
agentId: (_kb = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _kb : "virtual",
|
|
5656
|
+
executionId: (_mb = (_lb = payload.executionId) != null ? _lb : agentExecution == null ? void 0 : agentExecution.executionId) != null ? _mb : "",
|
|
5657
|
+
toolName: (_nb = payload.toolName) != null ? _nb : "",
|
|
5658
|
+
description: (_ob = payload.description) != null ? _ob : "",
|
|
5556
5659
|
resolvedAt: Date.now()
|
|
5557
5660
|
}
|
|
5558
5661
|
};
|
|
@@ -5590,7 +5693,7 @@ var AgentWidgetClient = class {
|
|
|
5590
5693
|
}
|
|
5591
5694
|
} else if (payloadType === "artifact_delta") {
|
|
5592
5695
|
const deltaId = String(payload.id);
|
|
5593
|
-
const deltaText = typeof payload.delta === "string" ? payload.delta : String((
|
|
5696
|
+
const deltaText = typeof payload.delta === "string" ? payload.delta : String((_pb = payload.delta) != null ? _pb : "");
|
|
5594
5697
|
onEvent({
|
|
5595
5698
|
type: "artifact_delta",
|
|
5596
5699
|
id: deltaId,
|
|
@@ -5613,7 +5716,7 @@ var AgentWidgetClient = class {
|
|
|
5613
5716
|
if (refMsg) {
|
|
5614
5717
|
refMsg.streaming = false;
|
|
5615
5718
|
try {
|
|
5616
|
-
const parsed = JSON.parse((
|
|
5719
|
+
const parsed = JSON.parse((_qb = refMsg.rawContent) != null ? _qb : "{}");
|
|
5617
5720
|
if (parsed.props) {
|
|
5618
5721
|
parsed.props.status = "complete";
|
|
5619
5722
|
const acc = artifactContent.get(artCompleteId);
|
|
@@ -5634,7 +5737,7 @@ var AgentWidgetClient = class {
|
|
|
5634
5737
|
if (!m || typeof m !== "object") {
|
|
5635
5738
|
continue;
|
|
5636
5739
|
}
|
|
5637
|
-
const id = String((
|
|
5740
|
+
const id = String((_rb = m.id) != null ? _rb : `msg-${nextSequence()}`);
|
|
5638
5741
|
const roleRaw = m.role;
|
|
5639
5742
|
const role = roleRaw === "user" ? "user" : roleRaw === "system" ? "system" : "assistant";
|
|
5640
5743
|
const msg = {
|
|
@@ -5653,7 +5756,7 @@ var AgentWidgetClient = class {
|
|
|
5653
5756
|
if (msg.rawContent) {
|
|
5654
5757
|
try {
|
|
5655
5758
|
const parsed = JSON.parse(msg.rawContent);
|
|
5656
|
-
const refArtId = (
|
|
5759
|
+
const refArtId = (_sb = parsed == null ? void 0 : parsed.props) == null ? void 0 : _sb.artifactId;
|
|
5657
5760
|
if (typeof refArtId === "string") {
|
|
5658
5761
|
artifactIdsWithCards.add(refArtId);
|
|
5659
5762
|
}
|
|
@@ -5669,7 +5772,7 @@ var AgentWidgetClient = class {
|
|
|
5669
5772
|
if (payload.error instanceof Error) {
|
|
5670
5773
|
resolvedError = payload.error;
|
|
5671
5774
|
} else if (payloadType === "dispatch_error") {
|
|
5672
|
-
const msg = (
|
|
5775
|
+
const msg = (_tb = payload.message) != null ? _tb : payload.error;
|
|
5673
5776
|
if (msg != null && msg !== "") {
|
|
5674
5777
|
resolvedError = new Error(String(msg));
|
|
5675
5778
|
}
|
|
@@ -5678,7 +5781,7 @@ var AgentWidgetClient = class {
|
|
|
5678
5781
|
if (typeof e === "string" && e !== "") {
|
|
5679
5782
|
resolvedError = new Error(e);
|
|
5680
5783
|
} else if (e != null && typeof e === "object" && "message" in e) {
|
|
5681
|
-
resolvedError = new Error(String((
|
|
5784
|
+
resolvedError = new Error(String((_ub = e.message) != null ? _ub : e));
|
|
5682
5785
|
}
|
|
5683
5786
|
} else if (payloadType === "error" && payload.error != null && payload.error !== "") {
|
|
5684
5787
|
resolvedError = new Error(String(payload.error));
|
|
@@ -8654,6 +8757,7 @@ var buildHeader = (context) => {
|
|
|
8654
8757
|
clearChatButton.style.color = clearChatIconColor || HEADER_THEME_CSS.actionIconColor;
|
|
8655
8758
|
const iconSvg = renderLucideIcon(clearChatIconName, "20px", "currentColor", 1);
|
|
8656
8759
|
if (iconSvg) {
|
|
8760
|
+
iconSvg.style.display = "block";
|
|
8657
8761
|
clearChatButton.appendChild(iconSvg);
|
|
8658
8762
|
}
|
|
8659
8763
|
if (clearChatBgColor) {
|
|
@@ -8737,7 +8841,7 @@ var buildHeader = (context) => {
|
|
|
8737
8841
|
}
|
|
8738
8842
|
const closeButtonWrapper = createElement(
|
|
8739
8843
|
"div",
|
|
8740
|
-
closeButtonPlacement === "top-right" ? "persona-absolute persona-top-4 persona-right-4 persona-z-50" : clearChatEnabled && clearChatPlacement === "inline" ? "" : "persona-ml-auto"
|
|
8844
|
+
closeButtonPlacement === "top-right" ? "persona-absolute persona-top-4 persona-right-4 persona-z-50" : clearChatEnabled && clearChatPlacement === "inline" ? "persona-relative persona-inline-flex persona-items-center persona-justify-center" : "persona-relative persona-ml-auto persona-inline-flex persona-items-center persona-justify-center"
|
|
8741
8845
|
);
|
|
8742
8846
|
const closeButton = createElement(
|
|
8743
8847
|
"button",
|
|
@@ -8753,8 +8857,9 @@ var buildHeader = (context) => {
|
|
|
8753
8857
|
const closeButtonIconName = (_E = launcher.closeButtonIconName) != null ? _E : "x";
|
|
8754
8858
|
const closeButtonIconText = (_F = launcher.closeButtonIconText) != null ? _F : "\xD7";
|
|
8755
8859
|
closeButton.style.color = launcher.closeButtonColor || HEADER_THEME_CSS.actionIconColor;
|
|
8756
|
-
const closeIconSvg = renderLucideIcon(closeButtonIconName, "
|
|
8860
|
+
const closeIconSvg = renderLucideIcon(closeButtonIconName, "28px", "currentColor", 1);
|
|
8757
8861
|
if (closeIconSvg) {
|
|
8862
|
+
closeIconSvg.style.display = "block";
|
|
8758
8863
|
closeButton.appendChild(closeIconSvg);
|
|
8759
8864
|
} else {
|
|
8760
8865
|
closeButton.textContent = closeButtonIconText;
|
|
@@ -9282,7 +9387,7 @@ var buildMinimalHeader = (context) => {
|
|
|
9282
9387
|
closeButton.style.display = showClose ? "" : "none";
|
|
9283
9388
|
closeButton.style.color = launcher.closeButtonColor || HEADER_THEME_CSS.actionIconColor;
|
|
9284
9389
|
const closeButtonIconName = (_i = launcher.closeButtonIconName) != null ? _i : "x";
|
|
9285
|
-
const closeIconSvg = renderLucideIcon(closeButtonIconName, "
|
|
9390
|
+
const closeIconSvg = renderLucideIcon(closeButtonIconName, "28px", "currentColor", 1);
|
|
9286
9391
|
if (closeIconSvg) {
|
|
9287
9392
|
closeButton.appendChild(closeIconSvg);
|
|
9288
9393
|
} else {
|
|
@@ -17271,7 +17376,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
17271
17376
|
const closeButtonIconName = (_ca = launcher.closeButtonIconName) != null ? _ca : "x";
|
|
17272
17377
|
const closeButtonIconText = (_da = launcher.closeButtonIconText) != null ? _da : "\xD7";
|
|
17273
17378
|
closeButton.innerHTML = "";
|
|
17274
|
-
const iconSvg = renderLucideIcon(closeButtonIconName, "
|
|
17379
|
+
const iconSvg = renderLucideIcon(closeButtonIconName, "28px", "currentColor", 1);
|
|
17275
17380
|
if (iconSvg) {
|
|
17276
17381
|
closeButton.appendChild(iconSvg);
|
|
17277
17382
|
} else {
|
package/dist/theme-editor.d.cts
CHANGED
|
@@ -767,6 +767,17 @@ type AgentMessageMetadata = {
|
|
|
767
767
|
iteration?: number;
|
|
768
768
|
turnId?: string;
|
|
769
769
|
agentName?: string;
|
|
770
|
+
/**
|
|
771
|
+
* When this message was produced by a step inside a nested flow executed
|
|
772
|
+
* as a tool, identifies the parent tool call id. Enables renderers to
|
|
773
|
+
* visually group or indent nested-flow output under its parent tool.
|
|
774
|
+
*/
|
|
775
|
+
parentToolId?: string;
|
|
776
|
+
/**
|
|
777
|
+
* Nested flow step id that produced this message (e.g. a `send-stream`
|
|
778
|
+
* or `prompt` step inside the nested flow). Stable key for that step.
|
|
779
|
+
*/
|
|
780
|
+
parentStepId?: string;
|
|
770
781
|
};
|
|
771
782
|
type AgentWidgetRequestMiddlewareContext = {
|
|
772
783
|
payload: AgentWidgetRequestPayload;
|
package/dist/theme-editor.d.ts
CHANGED
|
@@ -767,6 +767,17 @@ type AgentMessageMetadata = {
|
|
|
767
767
|
iteration?: number;
|
|
768
768
|
turnId?: string;
|
|
769
769
|
agentName?: string;
|
|
770
|
+
/**
|
|
771
|
+
* When this message was produced by a step inside a nested flow executed
|
|
772
|
+
* as a tool, identifies the parent tool call id. Enables renderers to
|
|
773
|
+
* visually group or indent nested-flow output under its parent tool.
|
|
774
|
+
*/
|
|
775
|
+
parentToolId?: string;
|
|
776
|
+
/**
|
|
777
|
+
* Nested flow step id that produced this message (e.g. a `send-stream`
|
|
778
|
+
* or `prompt` step inside the nested flow). Stable key for that step.
|
|
779
|
+
*/
|
|
780
|
+
parentStepId?: string;
|
|
770
781
|
};
|
|
771
782
|
type AgentWidgetRequestMiddlewareContext = {
|
|
772
783
|
payload: AgentWidgetRequestPayload;
|