@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.js
CHANGED
|
@@ -45,6 +45,12 @@ var DEFAULT_WIDGET_CONFIG = {
|
|
|
45
45
|
agentIconSize: "40px",
|
|
46
46
|
headerIconSize: "40px",
|
|
47
47
|
closeButtonSize: "32px",
|
|
48
|
+
// Zero out browser-default <button> padding so the icon gets the full
|
|
49
|
+
// 32x32 content box, matching clearChat.paddingX/Y below. Without this,
|
|
50
|
+
// UA stylesheets add ~1-2px vertical and ~6px horizontal padding that
|
|
51
|
+
// eats into the border-box width and shrinks the rendered icon.
|
|
52
|
+
closeButtonPaddingX: "0px",
|
|
53
|
+
closeButtonPaddingY: "0px",
|
|
48
54
|
callToActionIconName: "arrow-up-right",
|
|
49
55
|
callToActionIconText: "",
|
|
50
56
|
callToActionIconSize: "32px",
|
|
@@ -4347,6 +4353,8 @@ var AgentWidgetClient = class {
|
|
|
4347
4353
|
let didSplitByPartId = false;
|
|
4348
4354
|
const reasoningMessages = /* @__PURE__ */ new Map();
|
|
4349
4355
|
const toolMessages = /* @__PURE__ */ new Map();
|
|
4356
|
+
const nestedStepMessages = /* @__PURE__ */ new Map();
|
|
4357
|
+
const nestedPartIdByStep = /* @__PURE__ */ new Map();
|
|
4350
4358
|
const reasoningContext = {
|
|
4351
4359
|
lastId: null,
|
|
4352
4360
|
byStep: /* @__PURE__ */ new Map()
|
|
@@ -4355,6 +4363,31 @@ var AgentWidgetClient = class {
|
|
|
4355
4363
|
lastId: null,
|
|
4356
4364
|
byCall: /* @__PURE__ */ new Map()
|
|
4357
4365
|
};
|
|
4366
|
+
const getNestedStepKey = (toolId, stepId, partId = "") => `${toolId}::${stepId}::${partId}`;
|
|
4367
|
+
const getNestedStepPrefix = (toolId, stepId) => `${toolId}::${stepId}::`;
|
|
4368
|
+
const ensureNestedStepMessage = (toolId, stepId, partId, executionId) => {
|
|
4369
|
+
const key = getNestedStepKey(toolId, stepId, partId);
|
|
4370
|
+
const existing = nestedStepMessages.get(key);
|
|
4371
|
+
if (existing) return existing;
|
|
4372
|
+
const idSuffix = partId ? `-${partId}` : "";
|
|
4373
|
+
const message = {
|
|
4374
|
+
id: `nested-${toolId}-${stepId}${idSuffix}`,
|
|
4375
|
+
role: "assistant",
|
|
4376
|
+
content: "",
|
|
4377
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4378
|
+
streaming: true,
|
|
4379
|
+
sequence: nextSequence(),
|
|
4380
|
+
...partId ? { partId } : {},
|
|
4381
|
+
agentMetadata: {
|
|
4382
|
+
executionId,
|
|
4383
|
+
parentToolId: toolId,
|
|
4384
|
+
parentStepId: stepId
|
|
4385
|
+
}
|
|
4386
|
+
};
|
|
4387
|
+
nestedStepMessages.set(key, message);
|
|
4388
|
+
emitMessage(message);
|
|
4389
|
+
return message;
|
|
4390
|
+
};
|
|
4358
4391
|
const normalizeKey = (value) => {
|
|
4359
4392
|
if (value === null || value === void 0) return null;
|
|
4360
4393
|
try {
|
|
@@ -4664,7 +4697,7 @@ var AgentWidgetClient = class {
|
|
|
4664
4697
|
const agentIterationMessages = /* @__PURE__ */ new Map();
|
|
4665
4698
|
const iterationDisplay = (_a = this.config.iterationDisplay) != null ? _a : "separate";
|
|
4666
4699
|
drainReadyQueue = () => {
|
|
4667
|
-
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;
|
|
4700
|
+
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;
|
|
4668
4701
|
for (let i = 0; i < seqReadyQueue.length; i++) {
|
|
4669
4702
|
const payloadType = seqReadyQueue[i].payloadType;
|
|
4670
4703
|
const payload = seqReadyQueue[i].payload;
|
|
@@ -4837,6 +4870,9 @@ var AgentWidgetClient = class {
|
|
|
4837
4870
|
toolContext.byCall.delete(callKey);
|
|
4838
4871
|
}
|
|
4839
4872
|
} else if (payloadType === "text_start") {
|
|
4873
|
+
if ((_X = payload.toolContext) == null ? void 0 : _X.toolId) {
|
|
4874
|
+
continue;
|
|
4875
|
+
}
|
|
4840
4876
|
const incomingPartId = payload.partId;
|
|
4841
4877
|
if (incomingPartId !== void 0 && partIdState.current !== null && incomingPartId !== partIdState.current) {
|
|
4842
4878
|
const prev = assistantMessage;
|
|
@@ -4852,6 +4888,9 @@ var AgentWidgetClient = class {
|
|
|
4852
4888
|
partIdState.current = incomingPartId;
|
|
4853
4889
|
}
|
|
4854
4890
|
} else if (payloadType === "text_end") {
|
|
4891
|
+
if ((_Y = payload.toolContext) == null ? void 0 : _Y.toolId) {
|
|
4892
|
+
continue;
|
|
4893
|
+
}
|
|
4855
4894
|
const prev = assistantMessage;
|
|
4856
4895
|
if (prev) {
|
|
4857
4896
|
prev.streaming = false;
|
|
@@ -4866,6 +4905,48 @@ var AgentWidgetClient = class {
|
|
|
4866
4905
|
if (stepType === "tool" || executionType === "context") {
|
|
4867
4906
|
continue;
|
|
4868
4907
|
}
|
|
4908
|
+
const nestedToolCtx = payload.toolContext;
|
|
4909
|
+
if (nestedToolCtx == null ? void 0 : nestedToolCtx.toolId) {
|
|
4910
|
+
const nestedStepId = String(
|
|
4911
|
+
(__ = (_Z = payload.id) != null ? _Z : nestedToolCtx.stepId) != null ? __ : `step-${nextSequence()}`
|
|
4912
|
+
);
|
|
4913
|
+
const incomingPartId2 = payload.partId !== void 0 && payload.partId !== null ? String(payload.partId) : "";
|
|
4914
|
+
const stepScopeKey = `${nestedToolCtx.toolId}::${nestedStepId}`;
|
|
4915
|
+
const prevPartId = nestedPartIdByStep.get(stepScopeKey);
|
|
4916
|
+
if (incomingPartId2 !== "" && prevPartId !== void 0 && prevPartId !== "" && prevPartId !== incomingPartId2) {
|
|
4917
|
+
const prev = nestedStepMessages.get(
|
|
4918
|
+
getNestedStepKey(
|
|
4919
|
+
nestedToolCtx.toolId,
|
|
4920
|
+
nestedStepId,
|
|
4921
|
+
prevPartId
|
|
4922
|
+
)
|
|
4923
|
+
);
|
|
4924
|
+
if (prev && prev.streaming !== false) {
|
|
4925
|
+
prev.streaming = false;
|
|
4926
|
+
emitMessage(prev);
|
|
4927
|
+
}
|
|
4928
|
+
}
|
|
4929
|
+
if (incomingPartId2 !== "") {
|
|
4930
|
+
nestedPartIdByStep.set(stepScopeKey, incomingPartId2);
|
|
4931
|
+
}
|
|
4932
|
+
const nestedMsg = ensureNestedStepMessage(
|
|
4933
|
+
nestedToolCtx.toolId,
|
|
4934
|
+
nestedStepId,
|
|
4935
|
+
incomingPartId2,
|
|
4936
|
+
nestedToolCtx.executionId
|
|
4937
|
+
);
|
|
4938
|
+
const nestedChunk = (_ca = (_ba = (_aa = (_$ = payload.text) != null ? _$ : payload.delta) != null ? _aa : payload.content) != null ? _ba : payload.chunk) != null ? _ca : "";
|
|
4939
|
+
if (nestedChunk) {
|
|
4940
|
+
nestedMsg.content += String(nestedChunk);
|
|
4941
|
+
nestedMsg.streaming = true;
|
|
4942
|
+
emitMessage(nestedMsg);
|
|
4943
|
+
}
|
|
4944
|
+
if (payload.isComplete) {
|
|
4945
|
+
nestedMsg.streaming = false;
|
|
4946
|
+
emitMessage(nestedMsg);
|
|
4947
|
+
}
|
|
4948
|
+
continue;
|
|
4949
|
+
}
|
|
4869
4950
|
const incomingPartId = payload.partId;
|
|
4870
4951
|
if (incomingPartId !== void 0 && partIdState.current !== null && incomingPartId !== partIdState.current) {
|
|
4871
4952
|
const prev = assistantMessage;
|
|
@@ -4880,18 +4961,18 @@ var AgentWidgetClient = class {
|
|
|
4880
4961
|
if (incomingPartId !== void 0) {
|
|
4881
4962
|
partIdState.current = incomingPartId;
|
|
4882
4963
|
}
|
|
4883
|
-
const assistant = incomingPartId !== void 0 ? (
|
|
4964
|
+
const assistant = incomingPartId !== void 0 ? (_da = assistantMessagesByPartId.get(incomingPartId)) != null ? _da : ensureAssistantMessage() : ensureAssistantMessage();
|
|
4884
4965
|
if (incomingPartId !== void 0) {
|
|
4885
4966
|
if (!assistant.partId) {
|
|
4886
4967
|
assistant.partId = incomingPartId;
|
|
4887
4968
|
}
|
|
4888
4969
|
assistantMessagesByPartId.set(incomingPartId, assistant);
|
|
4889
4970
|
}
|
|
4890
|
-
const chunk = (
|
|
4971
|
+
const chunk = (_ha = (_ga = (_fa = (_ea = payload.text) != null ? _ea : payload.delta) != null ? _fa : payload.content) != null ? _ga : payload.chunk) != null ? _ha : "";
|
|
4891
4972
|
if (chunk) {
|
|
4892
4973
|
const chunkSeq = typeof payload.seq === "number" ? payload.seq : void 0;
|
|
4893
4974
|
const chunkBufferKey = incomingPartId != null ? incomingPartId : assistant.id;
|
|
4894
|
-
const accumulatedRaw = chunkSeq !== void 0 ? insertOrderedChunk(chunkBufferKey, chunkSeq, String(chunk)) : ((
|
|
4975
|
+
const accumulatedRaw = chunkSeq !== void 0 ? insertOrderedChunk(chunkBufferKey, chunkSeq, String(chunk)) : ((_ia = rawContentBuffers.get(assistant.id)) != null ? _ia : "") + chunk;
|
|
4895
4976
|
assistant.rawContent = accumulatedRaw;
|
|
4896
4977
|
if (!streamParsers.has(assistant.id)) {
|
|
4897
4978
|
streamParsers.set(assistant.id, this.createStreamParser());
|
|
@@ -4937,7 +5018,7 @@ var AgentWidgetClient = class {
|
|
|
4937
5018
|
emitMessage(assistant);
|
|
4938
5019
|
});
|
|
4939
5020
|
} else {
|
|
4940
|
-
const text = typeof parsedResult === "string" ? parsedResult : (
|
|
5021
|
+
const text = typeof parsedResult === "string" ? parsedResult : (_ja = parsedResult == null ? void 0 : parsedResult.text) != null ? _ja : null;
|
|
4941
5022
|
if (text !== null && text.trim() !== "") {
|
|
4942
5023
|
assistant.content = text;
|
|
4943
5024
|
emitMessage(assistant);
|
|
@@ -4951,7 +5032,7 @@ var AgentWidgetClient = class {
|
|
|
4951
5032
|
}
|
|
4952
5033
|
}
|
|
4953
5034
|
if (payload.isComplete) {
|
|
4954
|
-
const finalContent = (
|
|
5035
|
+
const finalContent = (_la = (_ka = payload.result) == null ? void 0 : _ka.response) != null ? _la : assistant.content;
|
|
4955
5036
|
if (finalContent) {
|
|
4956
5037
|
const rawBuffer = rawContentBuffers.get(assistant.id);
|
|
4957
5038
|
const contentToProcess = rawBuffer != null ? rawBuffer : ensureStringContent(finalContent);
|
|
@@ -4983,7 +5064,7 @@ var AgentWidgetClient = class {
|
|
|
4983
5064
|
}
|
|
4984
5065
|
});
|
|
4985
5066
|
} else {
|
|
4986
|
-
extractedText = typeof parsedResult === "string" ? parsedResult : (
|
|
5067
|
+
extractedText = typeof parsedResult === "string" ? parsedResult : (_ma = parsedResult == null ? void 0 : parsedResult.text) != null ? _ma : null;
|
|
4987
5068
|
}
|
|
4988
5069
|
}
|
|
4989
5070
|
}
|
|
@@ -4995,7 +5076,7 @@ var AgentWidgetClient = class {
|
|
|
4995
5076
|
}
|
|
4996
5077
|
const parserToClose = streamParsers.get(assistant.id);
|
|
4997
5078
|
if (parserToClose) {
|
|
4998
|
-
const closeResult = (
|
|
5079
|
+
const closeResult = (_na = parserToClose.close) == null ? void 0 : _na.call(parserToClose);
|
|
4999
5080
|
if (closeResult instanceof Promise) {
|
|
5000
5081
|
closeResult.catch(() => {
|
|
5001
5082
|
});
|
|
@@ -5014,6 +5095,28 @@ var AgentWidgetClient = class {
|
|
|
5014
5095
|
if (stepType === "tool" || executionType === "context") {
|
|
5015
5096
|
continue;
|
|
5016
5097
|
}
|
|
5098
|
+
const nestedCompleteCtx = payload.toolContext;
|
|
5099
|
+
if (nestedCompleteCtx == null ? void 0 : nestedCompleteCtx.toolId) {
|
|
5100
|
+
const nestedStepId = String(
|
|
5101
|
+
(_pa = (_oa = payload.id) != null ? _oa : nestedCompleteCtx.stepId) != null ? _pa : ""
|
|
5102
|
+
);
|
|
5103
|
+
if (nestedStepId) {
|
|
5104
|
+
const prefix = getNestedStepPrefix(
|
|
5105
|
+
nestedCompleteCtx.toolId,
|
|
5106
|
+
nestedStepId
|
|
5107
|
+
);
|
|
5108
|
+
for (const [key, msg] of nestedStepMessages) {
|
|
5109
|
+
if (key.startsWith(prefix) && msg.streaming !== false) {
|
|
5110
|
+
msg.streaming = false;
|
|
5111
|
+
emitMessage(msg);
|
|
5112
|
+
}
|
|
5113
|
+
}
|
|
5114
|
+
nestedPartIdByStep.delete(
|
|
5115
|
+
`${nestedCompleteCtx.toolId}::${nestedStepId}`
|
|
5116
|
+
);
|
|
5117
|
+
}
|
|
5118
|
+
continue;
|
|
5119
|
+
}
|
|
5017
5120
|
if (didSplitByPartId) {
|
|
5018
5121
|
if (assistantMessage !== null) {
|
|
5019
5122
|
const msg = assistantMessage;
|
|
@@ -5024,7 +5127,7 @@ var AgentWidgetClient = class {
|
|
|
5024
5127
|
emitMessage(msg);
|
|
5025
5128
|
}
|
|
5026
5129
|
}
|
|
5027
|
-
const splitFinalContent = (
|
|
5130
|
+
const splitFinalContent = (_qa = payload.result) == null ? void 0 : _qa.response;
|
|
5028
5131
|
const sealedForReconcile = lastSealedTextSegment;
|
|
5029
5132
|
if (sealedForReconcile) {
|
|
5030
5133
|
if (splitFinalContent !== void 0 && splitFinalContent !== null) {
|
|
@@ -5037,7 +5140,7 @@ var AgentWidgetClient = class {
|
|
|
5037
5140
|
lastSealedTextSegment = null;
|
|
5038
5141
|
continue;
|
|
5039
5142
|
}
|
|
5040
|
-
const finalContent = (
|
|
5143
|
+
const finalContent = (_ra = payload.result) == null ? void 0 : _ra.response;
|
|
5041
5144
|
const assistant = ensureAssistantMessage();
|
|
5042
5145
|
if (finalContent !== void 0 && finalContent !== null) {
|
|
5043
5146
|
const parser = streamParsers.get(assistant.id);
|
|
@@ -5089,7 +5192,7 @@ var AgentWidgetClient = class {
|
|
|
5089
5192
|
}
|
|
5090
5193
|
});
|
|
5091
5194
|
} else {
|
|
5092
|
-
const text = typeof parsedResult === "string" ? parsedResult : (
|
|
5195
|
+
const text = typeof parsedResult === "string" ? parsedResult : (_sa = parsedResult == null ? void 0 : parsedResult.text) != null ? _sa : null;
|
|
5093
5196
|
if (text !== null && text.trim() !== "") {
|
|
5094
5197
|
assistant.content = text;
|
|
5095
5198
|
hasExtractedText = true;
|
|
@@ -5113,7 +5216,7 @@ var AgentWidgetClient = class {
|
|
|
5113
5216
|
assistant.content = ensureStringContent(finalContent);
|
|
5114
5217
|
}
|
|
5115
5218
|
if (parser) {
|
|
5116
|
-
const closeResult = (
|
|
5219
|
+
const closeResult = (_ta = parser.close) == null ? void 0 : _ta.call(parser);
|
|
5117
5220
|
if (closeResult instanceof Promise) {
|
|
5118
5221
|
closeResult.catch(() => {
|
|
5119
5222
|
});
|
|
@@ -5131,7 +5234,7 @@ var AgentWidgetClient = class {
|
|
|
5131
5234
|
emitMessage(assistant);
|
|
5132
5235
|
}
|
|
5133
5236
|
} else if (payloadType === "flow_complete") {
|
|
5134
|
-
const finalContent = (
|
|
5237
|
+
const finalContent = (_ua = payload.result) == null ? void 0 : _ua.response;
|
|
5135
5238
|
if (didSplitByPartId) {
|
|
5136
5239
|
if (assistantMessage !== null) {
|
|
5137
5240
|
const msg = assistantMessage;
|
|
@@ -5198,11 +5301,11 @@ var AgentWidgetClient = class {
|
|
|
5198
5301
|
} else if (payloadType === "agent_start") {
|
|
5199
5302
|
agentExecution = {
|
|
5200
5303
|
executionId: payload.executionId,
|
|
5201
|
-
agentId: (
|
|
5202
|
-
agentName: (
|
|
5304
|
+
agentId: (_va = payload.agentId) != null ? _va : "virtual",
|
|
5305
|
+
agentName: (_wa = payload.agentName) != null ? _wa : "",
|
|
5203
5306
|
status: "running",
|
|
5204
5307
|
currentIteration: 0,
|
|
5205
|
-
maxTurns: (
|
|
5308
|
+
maxTurns: (_xa = payload.maxTurns) != null ? _xa : 1,
|
|
5206
5309
|
startedAt: resolveTimestamp(payload.startedAt)
|
|
5207
5310
|
};
|
|
5208
5311
|
} else if (payloadType === "agent_iteration_start") {
|
|
@@ -5222,7 +5325,7 @@ var AgentWidgetClient = class {
|
|
|
5222
5325
|
} else if (payloadType === "agent_turn_delta") {
|
|
5223
5326
|
if (payload.contentType === "text") {
|
|
5224
5327
|
const assistant = ensureAssistantMessage();
|
|
5225
|
-
assistant.content += (
|
|
5328
|
+
assistant.content += (_ya = payload.delta) != null ? _ya : "";
|
|
5226
5329
|
assistant.agentMetadata = {
|
|
5227
5330
|
executionId: payload.executionId,
|
|
5228
5331
|
iteration: payload.iteration,
|
|
@@ -5231,14 +5334,14 @@ var AgentWidgetClient = class {
|
|
|
5231
5334
|
};
|
|
5232
5335
|
emitMessage(assistant);
|
|
5233
5336
|
} else if (payload.contentType === "thinking") {
|
|
5234
|
-
const reasoningId = (
|
|
5337
|
+
const reasoningId = (_za = payload.turnId) != null ? _za : `agent-think-${payload.iteration}`;
|
|
5235
5338
|
const reasoningMessage = ensureReasoningMessage(reasoningId);
|
|
5236
|
-
reasoningMessage.reasoning = (
|
|
5339
|
+
reasoningMessage.reasoning = (_Aa = reasoningMessage.reasoning) != null ? _Aa : {
|
|
5237
5340
|
id: reasoningId,
|
|
5238
5341
|
status: "streaming",
|
|
5239
5342
|
chunks: []
|
|
5240
5343
|
};
|
|
5241
|
-
reasoningMessage.reasoning.chunks.push((
|
|
5344
|
+
reasoningMessage.reasoning.chunks.push((_Ba = payload.delta) != null ? _Ba : "");
|
|
5242
5345
|
reasoningMessage.agentMetadata = {
|
|
5243
5346
|
executionId: payload.executionId,
|
|
5244
5347
|
iteration: payload.iteration,
|
|
@@ -5246,12 +5349,12 @@ var AgentWidgetClient = class {
|
|
|
5246
5349
|
};
|
|
5247
5350
|
emitMessage(reasoningMessage);
|
|
5248
5351
|
} else if (payload.contentType === "tool_input") {
|
|
5249
|
-
const toolId = (
|
|
5352
|
+
const toolId = (_Ca = payload.toolCallId) != null ? _Ca : toolContext.lastId;
|
|
5250
5353
|
if (toolId) {
|
|
5251
5354
|
const toolMessage = toolMessages.get(toolId);
|
|
5252
5355
|
if (toolMessage == null ? void 0 : toolMessage.toolCall) {
|
|
5253
|
-
toolMessage.toolCall.chunks = (
|
|
5254
|
-
toolMessage.toolCall.chunks.push((
|
|
5356
|
+
toolMessage.toolCall.chunks = (_Da = toolMessage.toolCall.chunks) != null ? _Da : [];
|
|
5357
|
+
toolMessage.toolCall.chunks.push((_Ea = payload.delta) != null ? _Ea : "");
|
|
5255
5358
|
emitMessage(toolMessage);
|
|
5256
5359
|
}
|
|
5257
5360
|
}
|
|
@@ -5263,20 +5366,20 @@ var AgentWidgetClient = class {
|
|
|
5263
5366
|
if (reasoningMessage == null ? void 0 : reasoningMessage.reasoning) {
|
|
5264
5367
|
reasoningMessage.reasoning.status = "complete";
|
|
5265
5368
|
reasoningMessage.reasoning.completedAt = resolveTimestamp(payload.completedAt);
|
|
5266
|
-
const start = (
|
|
5369
|
+
const start = (_Fa = reasoningMessage.reasoning.startedAt) != null ? _Fa : Date.now();
|
|
5267
5370
|
reasoningMessage.reasoning.durationMs = Math.max(
|
|
5268
5371
|
0,
|
|
5269
|
-
((
|
|
5372
|
+
((_Ga = reasoningMessage.reasoning.completedAt) != null ? _Ga : Date.now()) - start
|
|
5270
5373
|
);
|
|
5271
5374
|
reasoningMessage.streaming = false;
|
|
5272
5375
|
emitMessage(reasoningMessage);
|
|
5273
5376
|
}
|
|
5274
5377
|
}
|
|
5275
5378
|
} else if (payloadType === "agent_tool_start") {
|
|
5276
|
-
const toolId = (
|
|
5379
|
+
const toolId = (_Ha = payload.toolCallId) != null ? _Ha : `agent-tool-${nextSequence()}`;
|
|
5277
5380
|
trackToolId(getToolCallKey(payload), toolId);
|
|
5278
5381
|
const toolMessage = ensureToolMessage(toolId);
|
|
5279
|
-
const tool = (
|
|
5382
|
+
const tool = (_Ia = toolMessage.toolCall) != null ? _Ia : {
|
|
5280
5383
|
id: toolId,
|
|
5281
5384
|
status: "pending",
|
|
5282
5385
|
name: void 0,
|
|
@@ -5288,12 +5391,12 @@ var AgentWidgetClient = class {
|
|
|
5288
5391
|
completedAt: void 0,
|
|
5289
5392
|
durationMs: void 0
|
|
5290
5393
|
};
|
|
5291
|
-
tool.name = (
|
|
5394
|
+
tool.name = (_Ka = (_Ja = payload.toolName) != null ? _Ja : payload.name) != null ? _Ka : tool.name;
|
|
5292
5395
|
tool.status = "running";
|
|
5293
5396
|
if (payload.parameters !== void 0) {
|
|
5294
5397
|
tool.args = payload.parameters;
|
|
5295
5398
|
}
|
|
5296
|
-
tool.startedAt = resolveTimestamp((
|
|
5399
|
+
tool.startedAt = resolveTimestamp((_La = payload.startedAt) != null ? _La : payload.timestamp);
|
|
5297
5400
|
toolMessage.toolCall = tool;
|
|
5298
5401
|
toolMessage.streaming = true;
|
|
5299
5402
|
toolMessage.agentMetadata = {
|
|
@@ -5302,21 +5405,21 @@ var AgentWidgetClient = class {
|
|
|
5302
5405
|
};
|
|
5303
5406
|
emitMessage(toolMessage);
|
|
5304
5407
|
} else if (payloadType === "agent_tool_delta") {
|
|
5305
|
-
const toolId = (
|
|
5408
|
+
const toolId = (_Ma = payload.toolCallId) != null ? _Ma : toolContext.lastId;
|
|
5306
5409
|
if (toolId) {
|
|
5307
|
-
const toolMessage = (
|
|
5410
|
+
const toolMessage = (_Na = toolMessages.get(toolId)) != null ? _Na : ensureToolMessage(toolId);
|
|
5308
5411
|
if (toolMessage.toolCall) {
|
|
5309
|
-
toolMessage.toolCall.chunks = (
|
|
5310
|
-
toolMessage.toolCall.chunks.push((
|
|
5412
|
+
toolMessage.toolCall.chunks = (_Oa = toolMessage.toolCall.chunks) != null ? _Oa : [];
|
|
5413
|
+
toolMessage.toolCall.chunks.push((_Pa = payload.delta) != null ? _Pa : "");
|
|
5311
5414
|
toolMessage.toolCall.status = "running";
|
|
5312
5415
|
toolMessage.streaming = true;
|
|
5313
5416
|
emitMessage(toolMessage);
|
|
5314
5417
|
}
|
|
5315
5418
|
}
|
|
5316
5419
|
} else if (payloadType === "agent_tool_complete") {
|
|
5317
|
-
const toolId = (
|
|
5420
|
+
const toolId = (_Qa = payload.toolCallId) != null ? _Qa : toolContext.lastId;
|
|
5318
5421
|
if (toolId) {
|
|
5319
|
-
const toolMessage = (
|
|
5422
|
+
const toolMessage = (_Ra = toolMessages.get(toolId)) != null ? _Ra : ensureToolMessage(toolId);
|
|
5320
5423
|
if (toolMessage.toolCall) {
|
|
5321
5424
|
toolMessage.toolCall.status = "complete";
|
|
5322
5425
|
if (payload.result !== void 0) {
|
|
@@ -5325,7 +5428,7 @@ var AgentWidgetClient = class {
|
|
|
5325
5428
|
if (typeof payload.executionTime === "number") {
|
|
5326
5429
|
toolMessage.toolCall.durationMs = payload.executionTime;
|
|
5327
5430
|
}
|
|
5328
|
-
toolMessage.toolCall.completedAt = resolveTimestamp((
|
|
5431
|
+
toolMessage.toolCall.completedAt = resolveTimestamp((_Sa = payload.completedAt) != null ? _Sa : payload.timestamp);
|
|
5329
5432
|
toolMessage.streaming = false;
|
|
5330
5433
|
emitMessage(toolMessage);
|
|
5331
5434
|
const callKey = getToolCallKey(payload);
|
|
@@ -5340,7 +5443,7 @@ var AgentWidgetClient = class {
|
|
|
5340
5443
|
const reflectionMessage = {
|
|
5341
5444
|
id: reflectionId,
|
|
5342
5445
|
role: "assistant",
|
|
5343
|
-
content: (
|
|
5446
|
+
content: (_Ta = payload.reflection) != null ? _Ta : "",
|
|
5344
5447
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5345
5448
|
streaming: false,
|
|
5346
5449
|
variant: "reasoning",
|
|
@@ -5348,7 +5451,7 @@ var AgentWidgetClient = class {
|
|
|
5348
5451
|
reasoning: {
|
|
5349
5452
|
id: reflectionId,
|
|
5350
5453
|
status: "complete",
|
|
5351
|
-
chunks: [(
|
|
5454
|
+
chunks: [(_Ua = payload.reflection) != null ? _Ua : ""]
|
|
5352
5455
|
},
|
|
5353
5456
|
agentMetadata: {
|
|
5354
5457
|
executionId: payload.executionId,
|
|
@@ -5369,7 +5472,7 @@ var AgentWidgetClient = class {
|
|
|
5369
5472
|
}
|
|
5370
5473
|
onEvent({ type: "status", status: "idle" });
|
|
5371
5474
|
} else if (payloadType === "agent_error") {
|
|
5372
|
-
const errorMessage = typeof payload.error === "string" ? payload.error : (
|
|
5475
|
+
const errorMessage = typeof payload.error === "string" ? payload.error : (_Wa = (_Va = payload.error) == null ? void 0 : _Va.message) != null ? _Wa : "Agent execution error";
|
|
5373
5476
|
if (payload.recoverable) {
|
|
5374
5477
|
if (typeof console !== "undefined") {
|
|
5375
5478
|
console.warn("[AgentWidget] Recoverable agent error:", errorMessage);
|
|
@@ -5382,7 +5485,7 @@ var AgentWidgetClient = class {
|
|
|
5382
5485
|
}
|
|
5383
5486
|
} else if (payloadType === "agent_ping") {
|
|
5384
5487
|
} else if (payloadType === "agent_approval_start") {
|
|
5385
|
-
const approvalId = (
|
|
5488
|
+
const approvalId = (_Xa = payload.approvalId) != null ? _Xa : `approval-${nextSequence()}`;
|
|
5386
5489
|
const approvalMessage = {
|
|
5387
5490
|
id: `approval-${approvalId}`,
|
|
5388
5491
|
role: "assistant",
|
|
@@ -5394,17 +5497,17 @@ var AgentWidgetClient = class {
|
|
|
5394
5497
|
approval: {
|
|
5395
5498
|
id: approvalId,
|
|
5396
5499
|
status: "pending",
|
|
5397
|
-
agentId: (
|
|
5398
|
-
executionId: (
|
|
5399
|
-
toolName: (
|
|
5500
|
+
agentId: (_Ya = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _Ya : "virtual",
|
|
5501
|
+
executionId: (__a = (_Za = payload.executionId) != null ? _Za : agentExecution == null ? void 0 : agentExecution.executionId) != null ? __a : "",
|
|
5502
|
+
toolName: (_$a = payload.toolName) != null ? _$a : "",
|
|
5400
5503
|
toolType: payload.toolType,
|
|
5401
|
-
description: (
|
|
5504
|
+
description: (_bb = payload.description) != null ? _bb : `Execute ${(_ab = payload.toolName) != null ? _ab : "tool"}`,
|
|
5402
5505
|
parameters: payload.parameters
|
|
5403
5506
|
}
|
|
5404
5507
|
};
|
|
5405
5508
|
emitMessage(approvalMessage);
|
|
5406
5509
|
} else if (payloadType === "step_await" && payload.awaitReason === "approval_required") {
|
|
5407
|
-
const approvalId = (
|
|
5510
|
+
const approvalId = (_cb = payload.approvalId) != null ? _cb : `approval-${nextSequence()}`;
|
|
5408
5511
|
const approvalMessage = {
|
|
5409
5512
|
id: `approval-${approvalId}`,
|
|
5410
5513
|
role: "assistant",
|
|
@@ -5416,11 +5519,11 @@ var AgentWidgetClient = class {
|
|
|
5416
5519
|
approval: {
|
|
5417
5520
|
id: approvalId,
|
|
5418
5521
|
status: "pending",
|
|
5419
|
-
agentId: (
|
|
5420
|
-
executionId: (
|
|
5421
|
-
toolName: (
|
|
5522
|
+
agentId: (_db = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _db : "virtual",
|
|
5523
|
+
executionId: (_fb = (_eb = payload.executionId) != null ? _eb : agentExecution == null ? void 0 : agentExecution.executionId) != null ? _fb : "",
|
|
5524
|
+
toolName: (_gb = payload.toolName) != null ? _gb : "",
|
|
5422
5525
|
toolType: payload.toolType,
|
|
5423
|
-
description: (
|
|
5526
|
+
description: (_ib = payload.description) != null ? _ib : `Execute ${(_hb = payload.toolName) != null ? _hb : "tool"}`,
|
|
5424
5527
|
parameters: payload.parameters
|
|
5425
5528
|
}
|
|
5426
5529
|
};
|
|
@@ -5439,11 +5542,11 @@ var AgentWidgetClient = class {
|
|
|
5439
5542
|
sequence: nextSequence(),
|
|
5440
5543
|
approval: {
|
|
5441
5544
|
id: approvalId,
|
|
5442
|
-
status: (
|
|
5443
|
-
agentId: (
|
|
5444
|
-
executionId: (
|
|
5445
|
-
toolName: (
|
|
5446
|
-
description: (
|
|
5545
|
+
status: (_jb = payload.decision) != null ? _jb : "approved",
|
|
5546
|
+
agentId: (_kb = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _kb : "virtual",
|
|
5547
|
+
executionId: (_mb = (_lb = payload.executionId) != null ? _lb : agentExecution == null ? void 0 : agentExecution.executionId) != null ? _mb : "",
|
|
5548
|
+
toolName: (_nb = payload.toolName) != null ? _nb : "",
|
|
5549
|
+
description: (_ob = payload.description) != null ? _ob : "",
|
|
5447
5550
|
resolvedAt: Date.now()
|
|
5448
5551
|
}
|
|
5449
5552
|
};
|
|
@@ -5481,7 +5584,7 @@ var AgentWidgetClient = class {
|
|
|
5481
5584
|
}
|
|
5482
5585
|
} else if (payloadType === "artifact_delta") {
|
|
5483
5586
|
const deltaId = String(payload.id);
|
|
5484
|
-
const deltaText = typeof payload.delta === "string" ? payload.delta : String((
|
|
5587
|
+
const deltaText = typeof payload.delta === "string" ? payload.delta : String((_pb = payload.delta) != null ? _pb : "");
|
|
5485
5588
|
onEvent({
|
|
5486
5589
|
type: "artifact_delta",
|
|
5487
5590
|
id: deltaId,
|
|
@@ -5504,7 +5607,7 @@ var AgentWidgetClient = class {
|
|
|
5504
5607
|
if (refMsg) {
|
|
5505
5608
|
refMsg.streaming = false;
|
|
5506
5609
|
try {
|
|
5507
|
-
const parsed = JSON.parse((
|
|
5610
|
+
const parsed = JSON.parse((_qb = refMsg.rawContent) != null ? _qb : "{}");
|
|
5508
5611
|
if (parsed.props) {
|
|
5509
5612
|
parsed.props.status = "complete";
|
|
5510
5613
|
const acc = artifactContent.get(artCompleteId);
|
|
@@ -5525,7 +5628,7 @@ var AgentWidgetClient = class {
|
|
|
5525
5628
|
if (!m || typeof m !== "object") {
|
|
5526
5629
|
continue;
|
|
5527
5630
|
}
|
|
5528
|
-
const id = String((
|
|
5631
|
+
const id = String((_rb = m.id) != null ? _rb : `msg-${nextSequence()}`);
|
|
5529
5632
|
const roleRaw = m.role;
|
|
5530
5633
|
const role = roleRaw === "user" ? "user" : roleRaw === "system" ? "system" : "assistant";
|
|
5531
5634
|
const msg = {
|
|
@@ -5544,7 +5647,7 @@ var AgentWidgetClient = class {
|
|
|
5544
5647
|
if (msg.rawContent) {
|
|
5545
5648
|
try {
|
|
5546
5649
|
const parsed = JSON.parse(msg.rawContent);
|
|
5547
|
-
const refArtId = (
|
|
5650
|
+
const refArtId = (_sb = parsed == null ? void 0 : parsed.props) == null ? void 0 : _sb.artifactId;
|
|
5548
5651
|
if (typeof refArtId === "string") {
|
|
5549
5652
|
artifactIdsWithCards.add(refArtId);
|
|
5550
5653
|
}
|
|
@@ -5560,7 +5663,7 @@ var AgentWidgetClient = class {
|
|
|
5560
5663
|
if (payload.error instanceof Error) {
|
|
5561
5664
|
resolvedError = payload.error;
|
|
5562
5665
|
} else if (payloadType === "dispatch_error") {
|
|
5563
|
-
const msg = (
|
|
5666
|
+
const msg = (_tb = payload.message) != null ? _tb : payload.error;
|
|
5564
5667
|
if (msg != null && msg !== "") {
|
|
5565
5668
|
resolvedError = new Error(String(msg));
|
|
5566
5669
|
}
|
|
@@ -5569,7 +5672,7 @@ var AgentWidgetClient = class {
|
|
|
5569
5672
|
if (typeof e === "string" && e !== "") {
|
|
5570
5673
|
resolvedError = new Error(e);
|
|
5571
5674
|
} else if (e != null && typeof e === "object" && "message" in e) {
|
|
5572
|
-
resolvedError = new Error(String((
|
|
5675
|
+
resolvedError = new Error(String((_ub = e.message) != null ? _ub : e));
|
|
5573
5676
|
}
|
|
5574
5677
|
} else if (payloadType === "error" && payload.error != null && payload.error !== "") {
|
|
5575
5678
|
resolvedError = new Error(String(payload.error));
|
|
@@ -8545,6 +8648,7 @@ var buildHeader = (context) => {
|
|
|
8545
8648
|
clearChatButton.style.color = clearChatIconColor || HEADER_THEME_CSS.actionIconColor;
|
|
8546
8649
|
const iconSvg = renderLucideIcon(clearChatIconName, "20px", "currentColor", 1);
|
|
8547
8650
|
if (iconSvg) {
|
|
8651
|
+
iconSvg.style.display = "block";
|
|
8548
8652
|
clearChatButton.appendChild(iconSvg);
|
|
8549
8653
|
}
|
|
8550
8654
|
if (clearChatBgColor) {
|
|
@@ -8628,7 +8732,7 @@ var buildHeader = (context) => {
|
|
|
8628
8732
|
}
|
|
8629
8733
|
const closeButtonWrapper = createElement(
|
|
8630
8734
|
"div",
|
|
8631
|
-
closeButtonPlacement === "top-right" ? "persona-absolute persona-top-4 persona-right-4 persona-z-50" : clearChatEnabled && clearChatPlacement === "inline" ? "" : "persona-ml-auto"
|
|
8735
|
+
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"
|
|
8632
8736
|
);
|
|
8633
8737
|
const closeButton = createElement(
|
|
8634
8738
|
"button",
|
|
@@ -8644,8 +8748,9 @@ var buildHeader = (context) => {
|
|
|
8644
8748
|
const closeButtonIconName = (_E = launcher.closeButtonIconName) != null ? _E : "x";
|
|
8645
8749
|
const closeButtonIconText = (_F = launcher.closeButtonIconText) != null ? _F : "\xD7";
|
|
8646
8750
|
closeButton.style.color = launcher.closeButtonColor || HEADER_THEME_CSS.actionIconColor;
|
|
8647
|
-
const closeIconSvg = renderLucideIcon(closeButtonIconName, "
|
|
8751
|
+
const closeIconSvg = renderLucideIcon(closeButtonIconName, "28px", "currentColor", 1);
|
|
8648
8752
|
if (closeIconSvg) {
|
|
8753
|
+
closeIconSvg.style.display = "block";
|
|
8649
8754
|
closeButton.appendChild(closeIconSvg);
|
|
8650
8755
|
} else {
|
|
8651
8756
|
closeButton.textContent = closeButtonIconText;
|
|
@@ -9173,7 +9278,7 @@ var buildMinimalHeader = (context) => {
|
|
|
9173
9278
|
closeButton.style.display = showClose ? "" : "none";
|
|
9174
9279
|
closeButton.style.color = launcher.closeButtonColor || HEADER_THEME_CSS.actionIconColor;
|
|
9175
9280
|
const closeButtonIconName = (_i = launcher.closeButtonIconName) != null ? _i : "x";
|
|
9176
|
-
const closeIconSvg = renderLucideIcon(closeButtonIconName, "
|
|
9281
|
+
const closeIconSvg = renderLucideIcon(closeButtonIconName, "28px", "currentColor", 1);
|
|
9177
9282
|
if (closeIconSvg) {
|
|
9178
9283
|
closeButton.appendChild(closeIconSvg);
|
|
9179
9284
|
} else {
|
|
@@ -17162,7 +17267,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
17162
17267
|
const closeButtonIconName = (_ca = launcher.closeButtonIconName) != null ? _ca : "x";
|
|
17163
17268
|
const closeButtonIconText = (_da = launcher.closeButtonIconText) != null ? _da : "\xD7";
|
|
17164
17269
|
closeButton.innerHTML = "";
|
|
17165
|
-
const iconSvg = renderLucideIcon(closeButtonIconName, "
|
|
17270
|
+
const iconSvg = renderLucideIcon(closeButtonIconName, "28px", "currentColor", 1);
|
|
17166
17271
|
if (iconSvg) {
|
|
17167
17272
|
closeButton.appendChild(iconSvg);
|
|
17168
17273
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runtypelabs/persona",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.16.0",
|
|
4
4
|
"description": "Themeable, pluggable streaming agent widget for websites, in plain JS with support for voice input and reasoning / tool output.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|