@runtypelabs/persona 3.9.2 → 3.10.1
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 +45 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +148 -0
- package/dist/index.d.ts +148 -0
- package/dist/index.global.js +67 -64
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +45 -42
- package/dist/index.js.map +1 -1
- package/dist/theme-editor.cjs +959 -214
- package/dist/theme-editor.d.cts +157 -3
- package/dist/theme-editor.d.ts +157 -3
- package/dist/theme-editor.js +955 -214
- package/dist/theme-reference.cjs +1 -1
- package/dist/theme-reference.d.cts +8 -0
- package/dist/theme-reference.d.ts +8 -0
- package/dist/theme-reference.js +1 -1
- package/dist/widget.css +154 -0
- package/package.json +1 -1
- package/src/client.test.ts +312 -1
- package/src/client.ts +247 -24
- package/src/components/messages.ts +1 -1
- package/src/components/reasoning-bubble.ts +117 -28
- package/src/components/tool-bubble.ts +161 -27
- package/src/defaults.ts +12 -0
- package/src/styles/widget.css +154 -0
- package/src/theme-editor/index.ts +5 -0
- package/src/theme-editor/preview-utils.test.ts +58 -0
- package/src/theme-editor/preview-utils.ts +220 -4
- package/src/theme-editor/sections.test.ts +20 -0
- package/src/theme-editor/sections.ts +10 -0
- package/src/theme-reference.ts +8 -3
- package/src/tool-call-display-defaults.test.ts +23 -0
- package/src/types.ts +155 -0
- package/src/ui.attachments-drop.test.ts +188 -0
- package/src/ui.scroll.test.ts +150 -0
- package/src/ui.tool-display.test.ts +204 -0
- package/src/ui.ts +275 -7
- package/src/utils/message-fingerprint.test.ts +17 -0
- package/src/utils/message-fingerprint.ts +13 -1
package/dist/theme-editor.js
CHANGED
|
@@ -118,6 +118,18 @@ var DEFAULT_WIDGET_CONFIG = {
|
|
|
118
118
|
enabled: true,
|
|
119
119
|
iconName: "arrow-down",
|
|
120
120
|
label: ""
|
|
121
|
+
},
|
|
122
|
+
toolCallDisplay: {
|
|
123
|
+
collapsedMode: "tool-call",
|
|
124
|
+
activePreview: false,
|
|
125
|
+
grouped: false,
|
|
126
|
+
previewMaxLines: 3,
|
|
127
|
+
expandable: true
|
|
128
|
+
},
|
|
129
|
+
reasoningDisplay: {
|
|
130
|
+
activePreview: false,
|
|
131
|
+
previewMaxLines: 3,
|
|
132
|
+
expandable: true
|
|
121
133
|
}
|
|
122
134
|
},
|
|
123
135
|
suggestionChips: [
|
|
@@ -2597,6 +2609,16 @@ var debugSectionDef = {
|
|
|
2597
2609
|
fields: [
|
|
2598
2610
|
{ id: "dev-reasoning", label: "Show Reasoning", description: "Display AI reasoning steps", type: "toggle", path: "features.showReasoning", defaultValue: false },
|
|
2599
2611
|
{ id: "dev-tool-calls", label: "Show Tool Calls", description: "Display tool call details", type: "toggle", path: "features.showToolCalls", defaultValue: false },
|
|
2612
|
+
{ id: "dev-tool-collapsed-mode", label: "Tool Call Summary", description: "Choose what collapsed tool rows show by default", type: "select", path: "features.toolCallDisplay.collapsedMode", defaultValue: "tool-call", options: [{ value: "tool-call", label: "Tool Call" }, { value: "tool-name", label: "Tool Name" }, { value: "tool-preview", label: "Tool Preview" }] },
|
|
2613
|
+
{ id: "dev-tool-active-preview", label: "Tool Preview While Active", description: "Show a lightweight preview in collapsed active tool rows", type: "toggle", path: "features.toolCallDisplay.activePreview", defaultValue: false },
|
|
2614
|
+
{ id: "dev-tool-preview-lines", label: "Tool Preview Lines", type: "select", path: "features.toolCallDisplay.previewMaxLines", defaultValue: 3, options: [{ value: "1", label: "1" }, { value: "2", label: "2" }, { value: "3", label: "3" }, { value: "4", label: "4" }, { value: "5", label: "5" }], formatValue: (v) => String(v != null ? v : 3), parseValue: (v) => Number(v) },
|
|
2615
|
+
{ id: "dev-tool-active-min-height", label: "Tool Active Min Height", description: "CSS min-height for collapsed active tool rows (e.g. 5rem)", type: "text", path: "features.toolCallDisplay.activeMinHeight", defaultValue: "" },
|
|
2616
|
+
{ id: "dev-tool-expandable", label: "Tool Calls Expandable", description: "Allow expanding tool call rows to see full details", type: "toggle", path: "features.toolCallDisplay.expandable", defaultValue: true },
|
|
2617
|
+
{ id: "dev-tool-grouped", label: "Group Sequential Tool Calls", description: "Render consecutive tool rows inside a grouped container", type: "toggle", path: "features.toolCallDisplay.grouped", defaultValue: false },
|
|
2618
|
+
{ id: "dev-reasoning-expandable", label: "Reasoning Expandable", description: "Allow expanding reasoning rows to see full details", type: "toggle", path: "features.reasoningDisplay.expandable", defaultValue: true },
|
|
2619
|
+
{ id: "dev-reasoning-active-preview", label: "Reasoning Preview While Active", description: "Show a lightweight preview in collapsed active reasoning rows", type: "toggle", path: "features.reasoningDisplay.activePreview", defaultValue: false },
|
|
2620
|
+
{ id: "dev-reasoning-preview-lines", label: "Reasoning Preview Lines", type: "select", path: "features.reasoningDisplay.previewMaxLines", defaultValue: 3, options: [{ value: "1", label: "1" }, { value: "2", label: "2" }, { value: "3", label: "3" }, { value: "4", label: "4" }, { value: "5", label: "5" }], formatValue: (v) => String(v != null ? v : 3), parseValue: (v) => Number(v) },
|
|
2621
|
+
{ id: "dev-reasoning-active-min-height", label: "Reasoning Active Min Height", description: "CSS min-height for collapsed active reasoning rows (e.g. 5rem)", type: "text", path: "features.reasoningDisplay.activeMinHeight", defaultValue: "" },
|
|
2600
2622
|
{ id: "dev-debug", label: "Debug Mode", description: "Show debug information", type: "toggle", path: "debug", defaultValue: false }
|
|
2601
2623
|
]
|
|
2602
2624
|
};
|
|
@@ -3396,6 +3418,24 @@ function getParserFromType(parserType) {
|
|
|
3396
3418
|
return createPlainTextParser;
|
|
3397
3419
|
}
|
|
3398
3420
|
}
|
|
3421
|
+
var looksStructured = (value) => value.startsWith("{") || value.startsWith("[") || value.startsWith("<");
|
|
3422
|
+
function preferFinalStructuredContent(rawBuffer, finalString) {
|
|
3423
|
+
if (!rawBuffer) return finalString;
|
|
3424
|
+
const rawTrimmed = rawBuffer.trim();
|
|
3425
|
+
const finalTrimmed = finalString.trim();
|
|
3426
|
+
if (rawTrimmed.length === 0) return finalString;
|
|
3427
|
+
if (finalTrimmed.length === 0) return rawBuffer;
|
|
3428
|
+
const rawLooksStructured = looksStructured(rawTrimmed);
|
|
3429
|
+
const finalLooksStructured = looksStructured(finalTrimmed);
|
|
3430
|
+
if (!finalLooksStructured) return rawBuffer;
|
|
3431
|
+
if (!rawLooksStructured) return finalString;
|
|
3432
|
+
if (finalTrimmed === rawTrimmed) return finalString;
|
|
3433
|
+
if (finalTrimmed.startsWith(rawTrimmed)) return finalString;
|
|
3434
|
+
const rawJsonText = extractTextFromJson(rawBuffer);
|
|
3435
|
+
const finalJsonText = extractTextFromJson(finalString);
|
|
3436
|
+
if (finalJsonText !== null && rawJsonText === null) return finalString;
|
|
3437
|
+
return rawBuffer;
|
|
3438
|
+
}
|
|
3399
3439
|
var AgentWidgetClient = class {
|
|
3400
3440
|
constructor(config = {}) {
|
|
3401
3441
|
this.config = config;
|
|
@@ -4114,7 +4154,7 @@ var AgentWidgetClient = class {
|
|
|
4114
4154
|
}
|
|
4115
4155
|
}
|
|
4116
4156
|
async streamResponse(body, onEvent, assistantMessageId) {
|
|
4117
|
-
var _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, _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;
|
|
4157
|
+
var _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, _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;
|
|
4118
4158
|
const reader = body.getReader();
|
|
4119
4159
|
const decoder = new TextDecoder();
|
|
4120
4160
|
let buffer = "";
|
|
@@ -4354,6 +4394,92 @@ var AgentWidgetClient = class {
|
|
|
4354
4394
|
};
|
|
4355
4395
|
const streamParsers = /* @__PURE__ */ new Map();
|
|
4356
4396
|
const rawContentBuffers = /* @__PURE__ */ new Map();
|
|
4397
|
+
const seqChunkBuffers = /* @__PURE__ */ new Map();
|
|
4398
|
+
const reasonSeqBuffers = /* @__PURE__ */ new Map();
|
|
4399
|
+
function insertSeqChunk(bufferMap, key, seq, text) {
|
|
4400
|
+
let buf = bufferMap.get(key);
|
|
4401
|
+
if (!buf) {
|
|
4402
|
+
buf = [];
|
|
4403
|
+
bufferMap.set(key, buf);
|
|
4404
|
+
}
|
|
4405
|
+
let lo = 0, hi = buf.length;
|
|
4406
|
+
while (lo < hi) {
|
|
4407
|
+
const mid = lo + hi >>> 1;
|
|
4408
|
+
if (buf[mid].seq < seq) lo = mid + 1;
|
|
4409
|
+
else hi = mid;
|
|
4410
|
+
}
|
|
4411
|
+
buf.splice(lo, 0, { seq, text });
|
|
4412
|
+
let result = "";
|
|
4413
|
+
for (let i = 0; i < buf.length; i++) result += buf[i].text;
|
|
4414
|
+
return result;
|
|
4415
|
+
}
|
|
4416
|
+
let lastSealedTextSegment = null;
|
|
4417
|
+
const reconcileSealedAssistantWithFinalResponse = (msg, finalContent) => {
|
|
4418
|
+
const finalString = ensureStringContent(finalContent);
|
|
4419
|
+
const rawBuffer = rawContentBuffers.get(msg.id);
|
|
4420
|
+
const contentToProcess = preferFinalStructuredContent(rawBuffer, finalString);
|
|
4421
|
+
msg.rawContent = contentToProcess;
|
|
4422
|
+
const parser = streamParsers.get(msg.id);
|
|
4423
|
+
const mergeIfBetter = (mergedDisplay) => {
|
|
4424
|
+
var _a2;
|
|
4425
|
+
const cur = (_a2 = msg.content) != null ? _a2 : "";
|
|
4426
|
+
if (mergedDisplay.trim() === "") return;
|
|
4427
|
+
if (cur.trim().length === 0 || mergedDisplay.startsWith(cur) || mergedDisplay.trimStart().startsWith(cur.trim())) {
|
|
4428
|
+
msg.content = mergedDisplay;
|
|
4429
|
+
}
|
|
4430
|
+
};
|
|
4431
|
+
const finalizeCleanup = () => {
|
|
4432
|
+
var _a2;
|
|
4433
|
+
if (parser) {
|
|
4434
|
+
const closeResult = (_a2 = parser.close) == null ? void 0 : _a2.call(parser);
|
|
4435
|
+
if (closeResult instanceof Promise) closeResult.catch(() => {
|
|
4436
|
+
});
|
|
4437
|
+
}
|
|
4438
|
+
streamParsers.delete(msg.id);
|
|
4439
|
+
rawContentBuffers.delete(msg.id);
|
|
4440
|
+
msg.streaming = false;
|
|
4441
|
+
emitMessage(msg);
|
|
4442
|
+
};
|
|
4443
|
+
if (!parser) {
|
|
4444
|
+
mergeIfBetter(finalString);
|
|
4445
|
+
finalizeCleanup();
|
|
4446
|
+
return;
|
|
4447
|
+
}
|
|
4448
|
+
const extractedFromJson = extractTextFromJson(contentToProcess);
|
|
4449
|
+
if (extractedFromJson !== null && extractedFromJson.trim() !== "") {
|
|
4450
|
+
mergeIfBetter(extractedFromJson);
|
|
4451
|
+
finalizeCleanup();
|
|
4452
|
+
return;
|
|
4453
|
+
}
|
|
4454
|
+
const bestDisplayText = (result) => {
|
|
4455
|
+
var _a2;
|
|
4456
|
+
const text = typeof result === "string" ? result : (_a2 = result == null ? void 0 : result.text) != null ? _a2 : null;
|
|
4457
|
+
if (text !== null && text.trim() !== "") return text;
|
|
4458
|
+
const extracted = parser.getExtractedText();
|
|
4459
|
+
if (extracted !== null && extracted.trim() !== "") return extracted;
|
|
4460
|
+
return finalString;
|
|
4461
|
+
};
|
|
4462
|
+
let parsedResult;
|
|
4463
|
+
try {
|
|
4464
|
+
parsedResult = parser.processChunk(contentToProcess);
|
|
4465
|
+
} catch {
|
|
4466
|
+
mergeIfBetter(finalString);
|
|
4467
|
+
finalizeCleanup();
|
|
4468
|
+
return;
|
|
4469
|
+
}
|
|
4470
|
+
if (parsedResult instanceof Promise) {
|
|
4471
|
+
parsedResult.then((result) => {
|
|
4472
|
+
mergeIfBetter(bestDisplayText(result));
|
|
4473
|
+
finalizeCleanup();
|
|
4474
|
+
}).catch(() => {
|
|
4475
|
+
mergeIfBetter(finalString);
|
|
4476
|
+
finalizeCleanup();
|
|
4477
|
+
});
|
|
4478
|
+
return;
|
|
4479
|
+
}
|
|
4480
|
+
mergeIfBetter(bestDisplayText(parsedResult));
|
|
4481
|
+
finalizeCleanup();
|
|
4482
|
+
};
|
|
4357
4483
|
let agentExecution = null;
|
|
4358
4484
|
const agentIterationMessages = /* @__PURE__ */ new Map();
|
|
4359
4485
|
const iterationDisplay = (_a = this.config.iterationDisplay) != null ? _a : "separate";
|
|
@@ -4427,7 +4553,13 @@ var AgentWidgetClient = class {
|
|
|
4427
4553
|
reasoningMessage.reasoning.startedAt = (_m = reasoningMessage.reasoning.startedAt) != null ? _m : resolveTimestamp((_l = payload.startedAt) != null ? _l : payload.timestamp);
|
|
4428
4554
|
const chunk = (_p = (_o = (_n = payload.reasoningText) != null ? _n : payload.text) != null ? _o : payload.delta) != null ? _p : "";
|
|
4429
4555
|
if (chunk && payload.hidden !== true) {
|
|
4430
|
-
|
|
4556
|
+
const reasonSeq = typeof payload.sequenceIndex === "number" ? payload.sequenceIndex : void 0;
|
|
4557
|
+
if (reasonSeq !== void 0) {
|
|
4558
|
+
const ordered = insertSeqChunk(reasonSeqBuffers, reasoningId, reasonSeq, String(chunk));
|
|
4559
|
+
reasoningMessage.reasoning.chunks = [ordered];
|
|
4560
|
+
} else {
|
|
4561
|
+
reasoningMessage.reasoning.chunks.push(String(chunk));
|
|
4562
|
+
}
|
|
4431
4563
|
}
|
|
4432
4564
|
reasoningMessage.reasoning.status = payload.done ? "complete" : "streaming";
|
|
4433
4565
|
if (payload.done) {
|
|
@@ -4439,6 +4571,7 @@ var AgentWidgetClient = class {
|
|
|
4439
4571
|
0,
|
|
4440
4572
|
((_s = reasoningMessage.reasoning.completedAt) != null ? _s : Date.now()) - start
|
|
4441
4573
|
);
|
|
4574
|
+
reasonSeqBuffers.delete(reasoningId);
|
|
4442
4575
|
}
|
|
4443
4576
|
reasoningMessage.streaming = reasoningMessage.reasoning.status !== "complete";
|
|
4444
4577
|
emitMessage(reasoningMessage);
|
|
@@ -4456,6 +4589,7 @@ var AgentWidgetClient = class {
|
|
|
4456
4589
|
((_x = reasoningMessage.reasoning.completedAt) != null ? _x : Date.now()) - start
|
|
4457
4590
|
);
|
|
4458
4591
|
reasoningMessage.streaming = false;
|
|
4592
|
+
reasonSeqBuffers.delete(reasoningId);
|
|
4459
4593
|
emitMessage(reasoningMessage);
|
|
4460
4594
|
}
|
|
4461
4595
|
const stepKey = getStepKey(payload);
|
|
@@ -4571,6 +4705,7 @@ var AgentWidgetClient = class {
|
|
|
4571
4705
|
if (prev) {
|
|
4572
4706
|
prev.streaming = false;
|
|
4573
4707
|
emitMessage(prev);
|
|
4708
|
+
lastSealedTextSegment = prev;
|
|
4574
4709
|
assistantMessage = null;
|
|
4575
4710
|
didSplitByPartId = true;
|
|
4576
4711
|
}
|
|
@@ -4583,6 +4718,7 @@ var AgentWidgetClient = class {
|
|
|
4583
4718
|
if (prev) {
|
|
4584
4719
|
prev.streaming = false;
|
|
4585
4720
|
emitMessage(prev);
|
|
4721
|
+
lastSealedTextSegment = prev;
|
|
4586
4722
|
assistantMessage = null;
|
|
4587
4723
|
didSplitByPartId = true;
|
|
4588
4724
|
}
|
|
@@ -4598,6 +4734,7 @@ var AgentWidgetClient = class {
|
|
|
4598
4734
|
if (prev) {
|
|
4599
4735
|
prev.streaming = false;
|
|
4600
4736
|
emitMessage(prev);
|
|
4737
|
+
lastSealedTextSegment = prev;
|
|
4601
4738
|
assistantMessage = null;
|
|
4602
4739
|
didSplitByPartId = true;
|
|
4603
4740
|
}
|
|
@@ -4611,8 +4748,14 @@ var AgentWidgetClient = class {
|
|
|
4611
4748
|
}
|
|
4612
4749
|
const chunk = (_ca = (_ba = (_aa = (_$ = payload.text) != null ? _$ : payload.delta) != null ? _aa : payload.content) != null ? _ba : payload.chunk) != null ? _ca : "";
|
|
4613
4750
|
if (chunk) {
|
|
4614
|
-
const
|
|
4615
|
-
|
|
4751
|
+
const chunkSeq = typeof payload.seq === "number" ? payload.seq : void 0;
|
|
4752
|
+
let accumulatedRaw;
|
|
4753
|
+
if (chunkSeq !== void 0) {
|
|
4754
|
+
accumulatedRaw = insertSeqChunk(seqChunkBuffers, assistant.id, chunkSeq, chunk);
|
|
4755
|
+
} else {
|
|
4756
|
+
const rawBuffer = (_da = rawContentBuffers.get(assistant.id)) != null ? _da : "";
|
|
4757
|
+
accumulatedRaw = rawBuffer + chunk;
|
|
4758
|
+
}
|
|
4616
4759
|
assistant.rawContent = accumulatedRaw;
|
|
4617
4760
|
if (!streamParsers.has(assistant.id)) {
|
|
4618
4761
|
streamParsers.set(assistant.id, this.createStreamParser());
|
|
@@ -4624,7 +4767,11 @@ var AgentWidgetClient = class {
|
|
|
4624
4767
|
}
|
|
4625
4768
|
const isPlainTextParser = parser.__isPlainTextParser === true;
|
|
4626
4769
|
if (isPlainTextParser) {
|
|
4627
|
-
|
|
4770
|
+
if (chunkSeq !== void 0) {
|
|
4771
|
+
assistant.content = accumulatedRaw;
|
|
4772
|
+
} else {
|
|
4773
|
+
assistant.content += chunk;
|
|
4774
|
+
}
|
|
4628
4775
|
rawContentBuffers.delete(assistant.id);
|
|
4629
4776
|
streamParsers.delete(assistant.id);
|
|
4630
4777
|
assistant.rawContent = void 0;
|
|
@@ -4637,15 +4784,16 @@ var AgentWidgetClient = class {
|
|
|
4637
4784
|
var _a2;
|
|
4638
4785
|
const text = typeof result === "string" ? result : (_a2 = result == null ? void 0 : result.text) != null ? _a2 : null;
|
|
4639
4786
|
if (text !== null && text.trim() !== "") {
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
currentAssistant.content = text;
|
|
4643
|
-
emitMessage(currentAssistant);
|
|
4644
|
-
}
|
|
4787
|
+
assistant.content = text;
|
|
4788
|
+
emitMessage(assistant);
|
|
4645
4789
|
} else if (!looksLikeJson && !accumulatedRaw.trim().startsWith("<")) {
|
|
4646
4790
|
const currentAssistant = assistantMessage;
|
|
4647
4791
|
if (currentAssistant && currentAssistant.id === assistant.id) {
|
|
4648
|
-
|
|
4792
|
+
if (chunkSeq !== void 0) {
|
|
4793
|
+
currentAssistant.content = accumulatedRaw;
|
|
4794
|
+
} else {
|
|
4795
|
+
currentAssistant.content += chunk;
|
|
4796
|
+
}
|
|
4649
4797
|
rawContentBuffers.delete(currentAssistant.id);
|
|
4650
4798
|
streamParsers.delete(currentAssistant.id);
|
|
4651
4799
|
currentAssistant.rawContent = void 0;
|
|
@@ -4653,7 +4801,11 @@ var AgentWidgetClient = class {
|
|
|
4653
4801
|
}
|
|
4654
4802
|
}
|
|
4655
4803
|
}).catch(() => {
|
|
4656
|
-
|
|
4804
|
+
if (chunkSeq !== void 0) {
|
|
4805
|
+
assistant.content = accumulatedRaw;
|
|
4806
|
+
} else {
|
|
4807
|
+
assistant.content += chunk;
|
|
4808
|
+
}
|
|
4657
4809
|
rawContentBuffers.delete(assistant.id);
|
|
4658
4810
|
streamParsers.delete(assistant.id);
|
|
4659
4811
|
assistant.rawContent = void 0;
|
|
@@ -4665,7 +4817,11 @@ var AgentWidgetClient = class {
|
|
|
4665
4817
|
assistant.content = text;
|
|
4666
4818
|
emitMessage(assistant);
|
|
4667
4819
|
} else if (!looksLikeJson && !accumulatedRaw.trim().startsWith("<")) {
|
|
4668
|
-
|
|
4820
|
+
if (chunkSeq !== void 0) {
|
|
4821
|
+
assistant.content = accumulatedRaw;
|
|
4822
|
+
} else {
|
|
4823
|
+
assistant.content += chunk;
|
|
4824
|
+
}
|
|
4669
4825
|
rawContentBuffers.delete(assistant.id);
|
|
4670
4826
|
streamParsers.delete(assistant.id);
|
|
4671
4827
|
assistant.rawContent = void 0;
|
|
@@ -4701,6 +4857,7 @@ var AgentWidgetClient = class {
|
|
|
4701
4857
|
currentAssistant.streaming = false;
|
|
4702
4858
|
streamParsers.delete(currentAssistant.id);
|
|
4703
4859
|
rawContentBuffers.delete(currentAssistant.id);
|
|
4860
|
+
seqChunkBuffers.delete(currentAssistant.id);
|
|
4704
4861
|
emitMessage(currentAssistant);
|
|
4705
4862
|
}
|
|
4706
4863
|
}
|
|
@@ -4726,6 +4883,7 @@ var AgentWidgetClient = class {
|
|
|
4726
4883
|
streamParsers.delete(assistant.id);
|
|
4727
4884
|
}
|
|
4728
4885
|
rawContentBuffers.delete(assistant.id);
|
|
4886
|
+
seqChunkBuffers.delete(assistant.id);
|
|
4729
4887
|
assistant.streaming = false;
|
|
4730
4888
|
emitMessage(assistant);
|
|
4731
4889
|
}
|
|
@@ -4742,14 +4900,26 @@ var AgentWidgetClient = class {
|
|
|
4742
4900
|
const msg = assistantMessage;
|
|
4743
4901
|
streamParsers.delete(msg.id);
|
|
4744
4902
|
rawContentBuffers.delete(msg.id);
|
|
4903
|
+
seqChunkBuffers.delete(msg.id);
|
|
4745
4904
|
if (msg.streaming !== false) {
|
|
4746
4905
|
msg.streaming = false;
|
|
4747
4906
|
emitMessage(msg);
|
|
4748
4907
|
}
|
|
4749
4908
|
}
|
|
4909
|
+
const splitFinalContent = (_ja = payload.result) == null ? void 0 : _ja.response;
|
|
4910
|
+
const sealedForReconcile = lastSealedTextSegment;
|
|
4911
|
+
if (sealedForReconcile) {
|
|
4912
|
+
if (splitFinalContent !== void 0 && splitFinalContent !== null) {
|
|
4913
|
+
reconcileSealedAssistantWithFinalResponse(sealedForReconcile, splitFinalContent);
|
|
4914
|
+
} else {
|
|
4915
|
+
streamParsers.delete(sealedForReconcile.id);
|
|
4916
|
+
rawContentBuffers.delete(sealedForReconcile.id);
|
|
4917
|
+
}
|
|
4918
|
+
}
|
|
4919
|
+
lastSealedTextSegment = null;
|
|
4750
4920
|
continue;
|
|
4751
4921
|
}
|
|
4752
|
-
const finalContent = (
|
|
4922
|
+
const finalContent = (_ka = payload.result) == null ? void 0 : _ka.response;
|
|
4753
4923
|
const assistant = ensureAssistantMessage();
|
|
4754
4924
|
if (finalContent !== void 0 && finalContent !== null) {
|
|
4755
4925
|
const parser = streamParsers.get(assistant.id);
|
|
@@ -4782,6 +4952,7 @@ var AgentWidgetClient = class {
|
|
|
4782
4952
|
currentAssistant.streaming = false;
|
|
4783
4953
|
streamParsers.delete(currentAssistant.id);
|
|
4784
4954
|
rawContentBuffers.delete(currentAssistant.id);
|
|
4955
|
+
seqChunkBuffers.delete(currentAssistant.id);
|
|
4785
4956
|
emitMessage(currentAssistant);
|
|
4786
4957
|
}
|
|
4787
4958
|
} else {
|
|
@@ -4796,12 +4967,13 @@ var AgentWidgetClient = class {
|
|
|
4796
4967
|
currentAssistant.streaming = false;
|
|
4797
4968
|
streamParsers.delete(currentAssistant.id);
|
|
4798
4969
|
rawContentBuffers.delete(currentAssistant.id);
|
|
4970
|
+
seqChunkBuffers.delete(currentAssistant.id);
|
|
4799
4971
|
emitMessage(currentAssistant);
|
|
4800
4972
|
}
|
|
4801
4973
|
}
|
|
4802
4974
|
});
|
|
4803
4975
|
} else {
|
|
4804
|
-
const text = typeof parsedResult === "string" ? parsedResult : (
|
|
4976
|
+
const text = typeof parsedResult === "string" ? parsedResult : (_la = parsedResult == null ? void 0 : parsedResult.text) != null ? _la : null;
|
|
4805
4977
|
if (text !== null && text.trim() !== "") {
|
|
4806
4978
|
assistant.content = text;
|
|
4807
4979
|
hasExtractedText = true;
|
|
@@ -4825,7 +4997,7 @@ var AgentWidgetClient = class {
|
|
|
4825
4997
|
assistant.content = ensureStringContent(finalContent);
|
|
4826
4998
|
}
|
|
4827
4999
|
if (parser) {
|
|
4828
|
-
const closeResult = (
|
|
5000
|
+
const closeResult = (_ma = parser.close) == null ? void 0 : _ma.call(parser);
|
|
4829
5001
|
if (closeResult instanceof Promise) {
|
|
4830
5002
|
closeResult.catch(() => {
|
|
4831
5003
|
});
|
|
@@ -4833,22 +5005,25 @@ var AgentWidgetClient = class {
|
|
|
4833
5005
|
}
|
|
4834
5006
|
streamParsers.delete(assistant.id);
|
|
4835
5007
|
rawContentBuffers.delete(assistant.id);
|
|
5008
|
+
seqChunkBuffers.delete(assistant.id);
|
|
4836
5009
|
assistant.streaming = false;
|
|
4837
5010
|
emitMessage(assistant);
|
|
4838
5011
|
}
|
|
4839
5012
|
} else {
|
|
4840
5013
|
streamParsers.delete(assistant.id);
|
|
4841
5014
|
rawContentBuffers.delete(assistant.id);
|
|
5015
|
+
seqChunkBuffers.delete(assistant.id);
|
|
4842
5016
|
assistant.streaming = false;
|
|
4843
5017
|
emitMessage(assistant);
|
|
4844
5018
|
}
|
|
4845
5019
|
} else if (payloadType === "flow_complete") {
|
|
4846
|
-
const finalContent = (
|
|
5020
|
+
const finalContent = (_na = payload.result) == null ? void 0 : _na.response;
|
|
4847
5021
|
if (didSplitByPartId) {
|
|
4848
5022
|
if (assistantMessage !== null) {
|
|
4849
5023
|
const msg = assistantMessage;
|
|
4850
5024
|
streamParsers.delete(msg.id);
|
|
4851
5025
|
rawContentBuffers.delete(msg.id);
|
|
5026
|
+
seqChunkBuffers.delete(msg.id);
|
|
4852
5027
|
if (msg.streaming !== false) {
|
|
4853
5028
|
msg.streaming = false;
|
|
4854
5029
|
emitMessage(msg);
|
|
@@ -4872,12 +5047,9 @@ var AgentWidgetClient = class {
|
|
|
4872
5047
|
var _a2;
|
|
4873
5048
|
const text = typeof result === "string" ? result : (_a2 = result == null ? void 0 : result.text) != null ? _a2 : null;
|
|
4874
5049
|
if (text !== null) {
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
currentAssistant.streaming = false;
|
|
4879
|
-
emitMessage(currentAssistant);
|
|
4880
|
-
}
|
|
5050
|
+
assistant.content = text;
|
|
5051
|
+
assistant.streaming = false;
|
|
5052
|
+
emitMessage(assistant);
|
|
4881
5053
|
}
|
|
4882
5054
|
});
|
|
4883
5055
|
}
|
|
@@ -4889,6 +5061,7 @@ var AgentWidgetClient = class {
|
|
|
4889
5061
|
}
|
|
4890
5062
|
streamParsers.delete(assistant.id);
|
|
4891
5063
|
rawContentBuffers.delete(assistant.id);
|
|
5064
|
+
seqChunkBuffers.delete(assistant.id);
|
|
4892
5065
|
const contentChanged = displayContent !== assistant.content;
|
|
4893
5066
|
const streamingChanged = assistant.streaming !== false;
|
|
4894
5067
|
if (contentChanged) {
|
|
@@ -4903,6 +5076,7 @@ var AgentWidgetClient = class {
|
|
|
4903
5076
|
const msg = assistantMessage;
|
|
4904
5077
|
streamParsers.delete(msg.id);
|
|
4905
5078
|
rawContentBuffers.delete(msg.id);
|
|
5079
|
+
seqChunkBuffers.delete(msg.id);
|
|
4906
5080
|
if (msg.streaming !== false) {
|
|
4907
5081
|
msg.streaming = false;
|
|
4908
5082
|
emitMessage(msg);
|
|
@@ -4913,11 +5087,11 @@ var AgentWidgetClient = class {
|
|
|
4913
5087
|
} else if (payloadType === "agent_start") {
|
|
4914
5088
|
agentExecution = {
|
|
4915
5089
|
executionId: payload.executionId,
|
|
4916
|
-
agentId: (
|
|
4917
|
-
agentName: (
|
|
5090
|
+
agentId: (_oa = payload.agentId) != null ? _oa : "virtual",
|
|
5091
|
+
agentName: (_pa = payload.agentName) != null ? _pa : "",
|
|
4918
5092
|
status: "running",
|
|
4919
5093
|
currentIteration: 0,
|
|
4920
|
-
maxTurns: (
|
|
5094
|
+
maxTurns: (_qa = payload.maxTurns) != null ? _qa : 1,
|
|
4921
5095
|
startedAt: resolveTimestamp(payload.startedAt)
|
|
4922
5096
|
};
|
|
4923
5097
|
} else if (payloadType === "agent_iteration_start") {
|
|
@@ -4937,7 +5111,7 @@ var AgentWidgetClient = class {
|
|
|
4937
5111
|
} else if (payloadType === "agent_turn_delta") {
|
|
4938
5112
|
if (payload.contentType === "text") {
|
|
4939
5113
|
const assistant = ensureAssistantMessage();
|
|
4940
|
-
assistant.content += (
|
|
5114
|
+
assistant.content += (_ra = payload.delta) != null ? _ra : "";
|
|
4941
5115
|
assistant.agentMetadata = {
|
|
4942
5116
|
executionId: payload.executionId,
|
|
4943
5117
|
iteration: payload.iteration,
|
|
@@ -4946,14 +5120,14 @@ var AgentWidgetClient = class {
|
|
|
4946
5120
|
};
|
|
4947
5121
|
emitMessage(assistant);
|
|
4948
5122
|
} else if (payload.contentType === "thinking") {
|
|
4949
|
-
const reasoningId = (
|
|
5123
|
+
const reasoningId = (_sa = payload.turnId) != null ? _sa : `agent-think-${payload.iteration}`;
|
|
4950
5124
|
const reasoningMessage = ensureReasoningMessage(reasoningId);
|
|
4951
|
-
reasoningMessage.reasoning = (
|
|
5125
|
+
reasoningMessage.reasoning = (_ta = reasoningMessage.reasoning) != null ? _ta : {
|
|
4952
5126
|
id: reasoningId,
|
|
4953
5127
|
status: "streaming",
|
|
4954
5128
|
chunks: []
|
|
4955
5129
|
};
|
|
4956
|
-
reasoningMessage.reasoning.chunks.push((
|
|
5130
|
+
reasoningMessage.reasoning.chunks.push((_ua = payload.delta) != null ? _ua : "");
|
|
4957
5131
|
reasoningMessage.agentMetadata = {
|
|
4958
5132
|
executionId: payload.executionId,
|
|
4959
5133
|
iteration: payload.iteration,
|
|
@@ -4961,12 +5135,12 @@ var AgentWidgetClient = class {
|
|
|
4961
5135
|
};
|
|
4962
5136
|
emitMessage(reasoningMessage);
|
|
4963
5137
|
} else if (payload.contentType === "tool_input") {
|
|
4964
|
-
const toolId = (
|
|
5138
|
+
const toolId = (_va = payload.toolCallId) != null ? _va : toolContext.lastId;
|
|
4965
5139
|
if (toolId) {
|
|
4966
5140
|
const toolMessage = toolMessages.get(toolId);
|
|
4967
5141
|
if (toolMessage == null ? void 0 : toolMessage.toolCall) {
|
|
4968
|
-
toolMessage.toolCall.chunks = (
|
|
4969
|
-
toolMessage.toolCall.chunks.push((
|
|
5142
|
+
toolMessage.toolCall.chunks = (_wa = toolMessage.toolCall.chunks) != null ? _wa : [];
|
|
5143
|
+
toolMessage.toolCall.chunks.push((_xa = payload.delta) != null ? _xa : "");
|
|
4970
5144
|
emitMessage(toolMessage);
|
|
4971
5145
|
}
|
|
4972
5146
|
}
|
|
@@ -4978,20 +5152,20 @@ var AgentWidgetClient = class {
|
|
|
4978
5152
|
if (reasoningMessage == null ? void 0 : reasoningMessage.reasoning) {
|
|
4979
5153
|
reasoningMessage.reasoning.status = "complete";
|
|
4980
5154
|
reasoningMessage.reasoning.completedAt = resolveTimestamp(payload.completedAt);
|
|
4981
|
-
const start = (
|
|
5155
|
+
const start = (_ya = reasoningMessage.reasoning.startedAt) != null ? _ya : Date.now();
|
|
4982
5156
|
reasoningMessage.reasoning.durationMs = Math.max(
|
|
4983
5157
|
0,
|
|
4984
|
-
((
|
|
5158
|
+
((_za = reasoningMessage.reasoning.completedAt) != null ? _za : Date.now()) - start
|
|
4985
5159
|
);
|
|
4986
5160
|
reasoningMessage.streaming = false;
|
|
4987
5161
|
emitMessage(reasoningMessage);
|
|
4988
5162
|
}
|
|
4989
5163
|
}
|
|
4990
5164
|
} else if (payloadType === "agent_tool_start") {
|
|
4991
|
-
const toolId = (
|
|
5165
|
+
const toolId = (_Aa = payload.toolCallId) != null ? _Aa : `agent-tool-${nextSequence()}`;
|
|
4992
5166
|
trackToolId(getToolCallKey(payload), toolId);
|
|
4993
5167
|
const toolMessage = ensureToolMessage(toolId);
|
|
4994
|
-
const tool = (
|
|
5168
|
+
const tool = (_Ba = toolMessage.toolCall) != null ? _Ba : {
|
|
4995
5169
|
id: toolId,
|
|
4996
5170
|
status: "pending",
|
|
4997
5171
|
name: void 0,
|
|
@@ -5003,12 +5177,12 @@ var AgentWidgetClient = class {
|
|
|
5003
5177
|
completedAt: void 0,
|
|
5004
5178
|
durationMs: void 0
|
|
5005
5179
|
};
|
|
5006
|
-
tool.name = (
|
|
5180
|
+
tool.name = (_Da = (_Ca = payload.toolName) != null ? _Ca : payload.name) != null ? _Da : tool.name;
|
|
5007
5181
|
tool.status = "running";
|
|
5008
5182
|
if (payload.parameters !== void 0) {
|
|
5009
5183
|
tool.args = payload.parameters;
|
|
5010
5184
|
}
|
|
5011
|
-
tool.startedAt = resolveTimestamp((
|
|
5185
|
+
tool.startedAt = resolveTimestamp((_Ea = payload.startedAt) != null ? _Ea : payload.timestamp);
|
|
5012
5186
|
toolMessage.toolCall = tool;
|
|
5013
5187
|
toolMessage.streaming = true;
|
|
5014
5188
|
toolMessage.agentMetadata = {
|
|
@@ -5017,21 +5191,21 @@ var AgentWidgetClient = class {
|
|
|
5017
5191
|
};
|
|
5018
5192
|
emitMessage(toolMessage);
|
|
5019
5193
|
} else if (payloadType === "agent_tool_delta") {
|
|
5020
|
-
const toolId = (
|
|
5194
|
+
const toolId = (_Fa = payload.toolCallId) != null ? _Fa : toolContext.lastId;
|
|
5021
5195
|
if (toolId) {
|
|
5022
|
-
const toolMessage = (
|
|
5196
|
+
const toolMessage = (_Ga = toolMessages.get(toolId)) != null ? _Ga : ensureToolMessage(toolId);
|
|
5023
5197
|
if (toolMessage.toolCall) {
|
|
5024
|
-
toolMessage.toolCall.chunks = (
|
|
5025
|
-
toolMessage.toolCall.chunks.push((
|
|
5198
|
+
toolMessage.toolCall.chunks = (_Ha = toolMessage.toolCall.chunks) != null ? _Ha : [];
|
|
5199
|
+
toolMessage.toolCall.chunks.push((_Ia = payload.delta) != null ? _Ia : "");
|
|
5026
5200
|
toolMessage.toolCall.status = "running";
|
|
5027
5201
|
toolMessage.streaming = true;
|
|
5028
5202
|
emitMessage(toolMessage);
|
|
5029
5203
|
}
|
|
5030
5204
|
}
|
|
5031
5205
|
} else if (payloadType === "agent_tool_complete") {
|
|
5032
|
-
const toolId = (
|
|
5206
|
+
const toolId = (_Ja = payload.toolCallId) != null ? _Ja : toolContext.lastId;
|
|
5033
5207
|
if (toolId) {
|
|
5034
|
-
const toolMessage = (
|
|
5208
|
+
const toolMessage = (_Ka = toolMessages.get(toolId)) != null ? _Ka : ensureToolMessage(toolId);
|
|
5035
5209
|
if (toolMessage.toolCall) {
|
|
5036
5210
|
toolMessage.toolCall.status = "complete";
|
|
5037
5211
|
if (payload.result !== void 0) {
|
|
@@ -5040,7 +5214,7 @@ var AgentWidgetClient = class {
|
|
|
5040
5214
|
if (typeof payload.executionTime === "number") {
|
|
5041
5215
|
toolMessage.toolCall.durationMs = payload.executionTime;
|
|
5042
5216
|
}
|
|
5043
|
-
toolMessage.toolCall.completedAt = resolveTimestamp((
|
|
5217
|
+
toolMessage.toolCall.completedAt = resolveTimestamp((_La = payload.completedAt) != null ? _La : payload.timestamp);
|
|
5044
5218
|
toolMessage.streaming = false;
|
|
5045
5219
|
emitMessage(toolMessage);
|
|
5046
5220
|
const callKey = getToolCallKey(payload);
|
|
@@ -5055,7 +5229,7 @@ var AgentWidgetClient = class {
|
|
|
5055
5229
|
const reflectionMessage = {
|
|
5056
5230
|
id: reflectionId,
|
|
5057
5231
|
role: "assistant",
|
|
5058
|
-
content: (
|
|
5232
|
+
content: (_Ma = payload.reflection) != null ? _Ma : "",
|
|
5059
5233
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5060
5234
|
streaming: false,
|
|
5061
5235
|
variant: "reasoning",
|
|
@@ -5063,7 +5237,7 @@ var AgentWidgetClient = class {
|
|
|
5063
5237
|
reasoning: {
|
|
5064
5238
|
id: reflectionId,
|
|
5065
5239
|
status: "complete",
|
|
5066
|
-
chunks: [(
|
|
5240
|
+
chunks: [(_Na = payload.reflection) != null ? _Na : ""]
|
|
5067
5241
|
},
|
|
5068
5242
|
agentMetadata: {
|
|
5069
5243
|
executionId: payload.executionId,
|
|
@@ -5084,7 +5258,7 @@ var AgentWidgetClient = class {
|
|
|
5084
5258
|
}
|
|
5085
5259
|
onEvent({ type: "status", status: "idle" });
|
|
5086
5260
|
} else if (payloadType === "agent_error") {
|
|
5087
|
-
const errorMessage = typeof payload.error === "string" ? payload.error : (
|
|
5261
|
+
const errorMessage = typeof payload.error === "string" ? payload.error : (_Pa = (_Oa = payload.error) == null ? void 0 : _Oa.message) != null ? _Pa : "Agent execution error";
|
|
5088
5262
|
if (payload.recoverable) {
|
|
5089
5263
|
if (typeof console !== "undefined") {
|
|
5090
5264
|
console.warn("[AgentWidget] Recoverable agent error:", errorMessage);
|
|
@@ -5097,7 +5271,7 @@ var AgentWidgetClient = class {
|
|
|
5097
5271
|
}
|
|
5098
5272
|
} else if (payloadType === "agent_ping") {
|
|
5099
5273
|
} else if (payloadType === "agent_approval_start") {
|
|
5100
|
-
const approvalId = (
|
|
5274
|
+
const approvalId = (_Qa = payload.approvalId) != null ? _Qa : `approval-${nextSequence()}`;
|
|
5101
5275
|
const approvalMessage = {
|
|
5102
5276
|
id: `approval-${approvalId}`,
|
|
5103
5277
|
role: "assistant",
|
|
@@ -5109,17 +5283,17 @@ var AgentWidgetClient = class {
|
|
|
5109
5283
|
approval: {
|
|
5110
5284
|
id: approvalId,
|
|
5111
5285
|
status: "pending",
|
|
5112
|
-
agentId: (
|
|
5113
|
-
executionId: (
|
|
5114
|
-
toolName: (
|
|
5286
|
+
agentId: (_Ra = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _Ra : "virtual",
|
|
5287
|
+
executionId: (_Ta = (_Sa = payload.executionId) != null ? _Sa : agentExecution == null ? void 0 : agentExecution.executionId) != null ? _Ta : "",
|
|
5288
|
+
toolName: (_Ua = payload.toolName) != null ? _Ua : "",
|
|
5115
5289
|
toolType: payload.toolType,
|
|
5116
|
-
description: (
|
|
5290
|
+
description: (_Wa = payload.description) != null ? _Wa : `Execute ${(_Va = payload.toolName) != null ? _Va : "tool"}`,
|
|
5117
5291
|
parameters: payload.parameters
|
|
5118
5292
|
}
|
|
5119
5293
|
};
|
|
5120
5294
|
emitMessage(approvalMessage);
|
|
5121
5295
|
} else if (payloadType === "step_await" && payload.awaitReason === "approval_required") {
|
|
5122
|
-
const approvalId = (
|
|
5296
|
+
const approvalId = (_Xa = payload.approvalId) != null ? _Xa : `approval-${nextSequence()}`;
|
|
5123
5297
|
const approvalMessage = {
|
|
5124
5298
|
id: `approval-${approvalId}`,
|
|
5125
5299
|
role: "assistant",
|
|
@@ -5131,11 +5305,11 @@ var AgentWidgetClient = class {
|
|
|
5131
5305
|
approval: {
|
|
5132
5306
|
id: approvalId,
|
|
5133
5307
|
status: "pending",
|
|
5134
|
-
agentId: (
|
|
5135
|
-
executionId: (
|
|
5136
|
-
toolName: (
|
|
5308
|
+
agentId: (_Ya = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _Ya : "virtual",
|
|
5309
|
+
executionId: (__a = (_Za = payload.executionId) != null ? _Za : agentExecution == null ? void 0 : agentExecution.executionId) != null ? __a : "",
|
|
5310
|
+
toolName: (_$a = payload.toolName) != null ? _$a : "",
|
|
5137
5311
|
toolType: payload.toolType,
|
|
5138
|
-
description: (
|
|
5312
|
+
description: (_bb = payload.description) != null ? _bb : `Execute ${(_ab = payload.toolName) != null ? _ab : "tool"}`,
|
|
5139
5313
|
parameters: payload.parameters
|
|
5140
5314
|
}
|
|
5141
5315
|
};
|
|
@@ -5154,11 +5328,11 @@ var AgentWidgetClient = class {
|
|
|
5154
5328
|
sequence: nextSequence(),
|
|
5155
5329
|
approval: {
|
|
5156
5330
|
id: approvalId,
|
|
5157
|
-
status: (
|
|
5158
|
-
agentId: (
|
|
5159
|
-
executionId: (
|
|
5160
|
-
toolName: (
|
|
5161
|
-
description: (
|
|
5331
|
+
status: (_cb = payload.decision) != null ? _cb : "approved",
|
|
5332
|
+
agentId: (_db = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _db : "virtual",
|
|
5333
|
+
executionId: (_fb = (_eb = payload.executionId) != null ? _eb : agentExecution == null ? void 0 : agentExecution.executionId) != null ? _fb : "",
|
|
5334
|
+
toolName: (_gb = payload.toolName) != null ? _gb : "",
|
|
5335
|
+
description: (_hb = payload.description) != null ? _hb : "",
|
|
5162
5336
|
resolvedAt: Date.now()
|
|
5163
5337
|
}
|
|
5164
5338
|
};
|
|
@@ -5196,7 +5370,7 @@ var AgentWidgetClient = class {
|
|
|
5196
5370
|
}
|
|
5197
5371
|
} else if (payloadType === "artifact_delta") {
|
|
5198
5372
|
const deltaId = String(payload.id);
|
|
5199
|
-
const deltaText = typeof payload.delta === "string" ? payload.delta : String((
|
|
5373
|
+
const deltaText = typeof payload.delta === "string" ? payload.delta : String((_ib = payload.delta) != null ? _ib : "");
|
|
5200
5374
|
onEvent({
|
|
5201
5375
|
type: "artifact_delta",
|
|
5202
5376
|
id: deltaId,
|
|
@@ -5219,7 +5393,7 @@ var AgentWidgetClient = class {
|
|
|
5219
5393
|
if (refMsg) {
|
|
5220
5394
|
refMsg.streaming = false;
|
|
5221
5395
|
try {
|
|
5222
|
-
const parsed = JSON.parse((
|
|
5396
|
+
const parsed = JSON.parse((_jb = refMsg.rawContent) != null ? _jb : "{}");
|
|
5223
5397
|
if (parsed.props) {
|
|
5224
5398
|
parsed.props.status = "complete";
|
|
5225
5399
|
const acc = artifactContent.get(artCompleteId);
|
|
@@ -5240,7 +5414,7 @@ var AgentWidgetClient = class {
|
|
|
5240
5414
|
if (!m || typeof m !== "object") {
|
|
5241
5415
|
continue;
|
|
5242
5416
|
}
|
|
5243
|
-
const id = String((
|
|
5417
|
+
const id = String((_kb = m.id) != null ? _kb : `msg-${nextSequence()}`);
|
|
5244
5418
|
const roleRaw = m.role;
|
|
5245
5419
|
const role = roleRaw === "user" ? "user" : roleRaw === "system" ? "system" : "assistant";
|
|
5246
5420
|
const msg = {
|
|
@@ -5259,7 +5433,7 @@ var AgentWidgetClient = class {
|
|
|
5259
5433
|
if (msg.rawContent) {
|
|
5260
5434
|
try {
|
|
5261
5435
|
const parsed = JSON.parse(msg.rawContent);
|
|
5262
|
-
const refArtId = (
|
|
5436
|
+
const refArtId = (_lb = parsed == null ? void 0 : parsed.props) == null ? void 0 : _lb.artifactId;
|
|
5263
5437
|
if (typeof refArtId === "string") {
|
|
5264
5438
|
artifactIdsWithCards.add(refArtId);
|
|
5265
5439
|
}
|
|
@@ -5270,6 +5444,7 @@ var AgentWidgetClient = class {
|
|
|
5270
5444
|
assistantMessageRef.current = null;
|
|
5271
5445
|
streamParsers.delete(id);
|
|
5272
5446
|
rawContentBuffers.delete(id);
|
|
5447
|
+
seqChunkBuffers.delete(id);
|
|
5273
5448
|
} else if (payloadType === "error" && payload.error) {
|
|
5274
5449
|
onEvent({
|
|
5275
5450
|
type: "error",
|
|
@@ -7692,7 +7867,7 @@ var morphMessages = (container, newContent, options = {}) => {
|
|
|
7692
7867
|
|
|
7693
7868
|
// src/utils/message-fingerprint.ts
|
|
7694
7869
|
function computeMessageFingerprint(message, configVersion) {
|
|
7695
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
7870
|
+
var _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, _A;
|
|
7696
7871
|
return [
|
|
7697
7872
|
message.id,
|
|
7698
7873
|
message.role,
|
|
@@ -7704,8 +7879,11 @@ function computeMessageFingerprint(message, configVersion) {
|
|
|
7704
7879
|
(_i = (_h = message.llmContent) == null ? void 0 : _h.length) != null ? _i : 0,
|
|
7705
7880
|
(_k = (_j = message.approval) == null ? void 0 : _j.status) != null ? _k : "",
|
|
7706
7881
|
(_m = (_l = message.toolCall) == null ? void 0 : _l.status) != null ? _m : "",
|
|
7707
|
-
(_p = (_o = (_n = message.
|
|
7708
|
-
(_r = (_q = message.
|
|
7882
|
+
(_p = (_o = (_n = message.toolCall) == null ? void 0 : _n.chunks) == null ? void 0 : _o.length) != null ? _p : 0,
|
|
7883
|
+
(_t = (_s = (_r = (_q = message.toolCall) == null ? void 0 : _q.chunks) == null ? void 0 : _r[message.toolCall.chunks.length - 1]) == null ? void 0 : _s.slice(-32)) != null ? _t : "",
|
|
7884
|
+
typeof ((_u = message.toolCall) == null ? void 0 : _u.args) === "string" ? message.toolCall.args.length : ((_v = message.toolCall) == null ? void 0 : _v.args) ? JSON.stringify(message.toolCall.args).length : 0,
|
|
7885
|
+
(_y = (_x = (_w = message.reasoning) == null ? void 0 : _w.chunks) == null ? void 0 : _x.length) != null ? _y : 0,
|
|
7886
|
+
(_A = (_z = message.contentParts) == null ? void 0 : _z.length) != null ? _A : 0,
|
|
7709
7887
|
configVersion
|
|
7710
7888
|
].join("\0");
|
|
7711
7889
|
}
|
|
@@ -9787,10 +9965,26 @@ var createStandardBubble = (message, transform, layoutConfig, actionsConfig, act
|
|
|
9787
9965
|
|
|
9788
9966
|
// src/components/reasoning-bubble.ts
|
|
9789
9967
|
var reasoningExpansionState = /* @__PURE__ */ new Set();
|
|
9968
|
+
var appendRenderedValue = (container, value) => {
|
|
9969
|
+
if (value == null) return false;
|
|
9970
|
+
if (typeof value === "string") {
|
|
9971
|
+
container.textContent = value;
|
|
9972
|
+
return true;
|
|
9973
|
+
}
|
|
9974
|
+
container.appendChild(value);
|
|
9975
|
+
return true;
|
|
9976
|
+
};
|
|
9977
|
+
var getReasoningPreviewText = (message, maxLines) => {
|
|
9978
|
+
var _a, _b;
|
|
9979
|
+
const text = (_b = (_a = message.reasoning) == null ? void 0 : _a.chunks.join("").trim()) != null ? _b : "";
|
|
9980
|
+
if (!text) return "";
|
|
9981
|
+
return text.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).slice(0, maxLines).join("\n");
|
|
9982
|
+
};
|
|
9790
9983
|
var updateReasoningBubbleUI = (messageId, bubble) => {
|
|
9791
9984
|
const expanded = reasoningExpansionState.has(messageId);
|
|
9792
9985
|
const header = bubble.querySelector('button[data-expand-header="true"]');
|
|
9793
9986
|
const content = bubble.querySelector(".persona-border-t");
|
|
9987
|
+
const preview = bubble.querySelector('[data-persona-collapsed-preview="reasoning"]');
|
|
9794
9988
|
if (!header || !content) return;
|
|
9795
9989
|
header.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
9796
9990
|
const headerMeta = header.querySelector(".persona-ml-auto");
|
|
@@ -9806,8 +10000,12 @@ var updateReasoningBubbleUI = (messageId, bubble) => {
|
|
|
9806
10000
|
}
|
|
9807
10001
|
}
|
|
9808
10002
|
content.style.display = expanded ? "" : "none";
|
|
10003
|
+
if (preview) {
|
|
10004
|
+
preview.style.display = expanded ? "none" : preview.textContent || preview.childNodes.length ? "" : "none";
|
|
10005
|
+
}
|
|
9809
10006
|
};
|
|
9810
|
-
var createReasoningBubble = (message) => {
|
|
10007
|
+
var createReasoningBubble = (message, config) => {
|
|
10008
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
9811
10009
|
const reasoning = message.reasoning;
|
|
9812
10010
|
const bubble = createElement(
|
|
9813
10011
|
"div",
|
|
@@ -9832,19 +10030,41 @@ var createReasoningBubble = (message) => {
|
|
|
9832
10030
|
if (!reasoning) {
|
|
9833
10031
|
return bubble;
|
|
9834
10032
|
}
|
|
9835
|
-
|
|
10033
|
+
const reasoningDisplayConfig = (_b = (_a = config == null ? void 0 : config.features) == null ? void 0 : _a.reasoningDisplay) != null ? _b : {};
|
|
10034
|
+
const expandable = reasoningDisplayConfig.expandable !== false;
|
|
10035
|
+
let expanded = expandable && reasoningExpansionState.has(message.id);
|
|
10036
|
+
const isActive = reasoning.status !== "complete";
|
|
10037
|
+
const previewText = getReasoningPreviewText(message, (_c = reasoningDisplayConfig.previewMaxLines) != null ? _c : 3);
|
|
9836
10038
|
const header = createElement(
|
|
9837
10039
|
"button",
|
|
9838
|
-
"persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-pointer persona-border-none"
|
|
10040
|
+
expandable ? "persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-pointer persona-border-none" : "persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-default persona-border-none"
|
|
9839
10041
|
);
|
|
9840
10042
|
header.type = "button";
|
|
9841
|
-
|
|
9842
|
-
|
|
10043
|
+
if (expandable) {
|
|
10044
|
+
header.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
10045
|
+
header.setAttribute("data-expand-header", "true");
|
|
10046
|
+
}
|
|
9843
10047
|
header.setAttribute("data-bubble-type", "reasoning");
|
|
9844
10048
|
const headerContent = createElement("div", "persona-flex persona-flex-col persona-text-left");
|
|
9845
10049
|
const title = createElement("span", "persona-text-xs persona-text-persona-primary");
|
|
9846
|
-
|
|
9847
|
-
|
|
10050
|
+
const defaultSummary = "Thinking...";
|
|
10051
|
+
const customSummary = (_e = (_d = config == null ? void 0 : config.reasoning) == null ? void 0 : _d.renderCollapsedSummary) == null ? void 0 : _e.call(_d, {
|
|
10052
|
+
message,
|
|
10053
|
+
reasoning,
|
|
10054
|
+
defaultSummary,
|
|
10055
|
+
previewText,
|
|
10056
|
+
isActive,
|
|
10057
|
+
config: config != null ? config : {}
|
|
10058
|
+
});
|
|
10059
|
+
if (typeof customSummary === "string" && customSummary.trim()) {
|
|
10060
|
+
title.textContent = customSummary;
|
|
10061
|
+
headerContent.appendChild(title);
|
|
10062
|
+
} else if (customSummary instanceof HTMLElement) {
|
|
10063
|
+
headerContent.appendChild(customSummary);
|
|
10064
|
+
} else {
|
|
10065
|
+
title.textContent = defaultSummary;
|
|
10066
|
+
headerContent.appendChild(title);
|
|
10067
|
+
}
|
|
9848
10068
|
const status = createElement("span", "persona-text-xs persona-text-persona-primary");
|
|
9849
10069
|
status.textContent = describeReasonStatus(reasoning);
|
|
9850
10070
|
headerContent.appendChild(status);
|
|
@@ -9853,17 +10073,49 @@ var createReasoningBubble = (message) => {
|
|
|
9853
10073
|
} else {
|
|
9854
10074
|
title.style.display = "";
|
|
9855
10075
|
}
|
|
9856
|
-
|
|
9857
|
-
|
|
9858
|
-
|
|
9859
|
-
|
|
9860
|
-
|
|
10076
|
+
let toggleIcon = null;
|
|
10077
|
+
if (expandable) {
|
|
10078
|
+
toggleIcon = createElement("div", "persona-flex persona-items-center");
|
|
10079
|
+
const iconColor = "currentColor";
|
|
10080
|
+
const chevronIcon = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor, 2);
|
|
10081
|
+
if (chevronIcon) {
|
|
10082
|
+
toggleIcon.appendChild(chevronIcon);
|
|
10083
|
+
} else {
|
|
10084
|
+
toggleIcon.textContent = expanded ? "Hide" : "Show";
|
|
10085
|
+
}
|
|
10086
|
+
const headerMeta = createElement("div", "persona-flex persona-items-center persona-ml-auto");
|
|
10087
|
+
headerMeta.append(toggleIcon);
|
|
10088
|
+
header.append(headerContent, headerMeta);
|
|
9861
10089
|
} else {
|
|
9862
|
-
|
|
10090
|
+
header.append(headerContent);
|
|
10091
|
+
}
|
|
10092
|
+
const collapsedPreview = createElement(
|
|
10093
|
+
"div",
|
|
10094
|
+
"persona-px-4 persona-py-3 persona-text-xs persona-leading-snug persona-text-persona-muted"
|
|
10095
|
+
);
|
|
10096
|
+
collapsedPreview.setAttribute("data-persona-collapsed-preview", "reasoning");
|
|
10097
|
+
collapsedPreview.style.display = "none";
|
|
10098
|
+
collapsedPreview.style.whiteSpace = "pre-wrap";
|
|
10099
|
+
if (!expanded && isActive && reasoningDisplayConfig.activePreview && previewText) {
|
|
10100
|
+
const renderedPreview = (_g = (_f = config == null ? void 0 : config.reasoning) == null ? void 0 : _f.renderCollapsedPreview) == null ? void 0 : _g.call(_f, {
|
|
10101
|
+
message,
|
|
10102
|
+
reasoning,
|
|
10103
|
+
defaultPreview: previewText,
|
|
10104
|
+
isActive,
|
|
10105
|
+
config: config != null ? config : {}
|
|
10106
|
+
});
|
|
10107
|
+
if (!appendRenderedValue(collapsedPreview, renderedPreview)) {
|
|
10108
|
+
collapsedPreview.textContent = previewText;
|
|
10109
|
+
}
|
|
10110
|
+
collapsedPreview.style.display = "";
|
|
10111
|
+
}
|
|
10112
|
+
if (!expanded && isActive && reasoningDisplayConfig.activeMinHeight) {
|
|
10113
|
+
bubble.style.minHeight = reasoningDisplayConfig.activeMinHeight;
|
|
10114
|
+
}
|
|
10115
|
+
if (!expandable) {
|
|
10116
|
+
bubble.append(header, collapsedPreview);
|
|
10117
|
+
return bubble;
|
|
9863
10118
|
}
|
|
9864
|
-
const headerMeta = createElement("div", "persona-flex persona-items-center persona-ml-auto");
|
|
9865
|
-
headerMeta.append(toggleIcon);
|
|
9866
|
-
header.append(headerContent, headerMeta);
|
|
9867
10119
|
const content = createElement(
|
|
9868
10120
|
"div",
|
|
9869
10121
|
"persona-border-t persona-border-gray-200 persona-bg-gray-50 persona-px-4 persona-py-3"
|
|
@@ -9878,29 +10130,74 @@ var createReasoningBubble = (message) => {
|
|
|
9878
10130
|
content.appendChild(body);
|
|
9879
10131
|
const applyExpansionState = () => {
|
|
9880
10132
|
header.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
9881
|
-
toggleIcon
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9887
|
-
|
|
10133
|
+
if (toggleIcon) {
|
|
10134
|
+
toggleIcon.innerHTML = "";
|
|
10135
|
+
const iconColor = "currentColor";
|
|
10136
|
+
const chevronIcon = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor, 2);
|
|
10137
|
+
if (chevronIcon) {
|
|
10138
|
+
toggleIcon.appendChild(chevronIcon);
|
|
10139
|
+
} else {
|
|
10140
|
+
toggleIcon.textContent = expanded ? "Hide" : "Show";
|
|
10141
|
+
}
|
|
9888
10142
|
}
|
|
9889
10143
|
content.style.display = expanded ? "" : "none";
|
|
10144
|
+
collapsedPreview.style.display = expanded ? "none" : collapsedPreview.textContent || collapsedPreview.childNodes.length ? "" : "none";
|
|
9890
10145
|
};
|
|
9891
10146
|
applyExpansionState();
|
|
9892
|
-
bubble.append(header, content);
|
|
10147
|
+
bubble.append(header, collapsedPreview, content);
|
|
9893
10148
|
return bubble;
|
|
9894
10149
|
};
|
|
9895
10150
|
|
|
9896
10151
|
// src/components/tool-bubble.ts
|
|
9897
10152
|
var toolExpansionState = /* @__PURE__ */ new Set();
|
|
10153
|
+
var appendRenderedValue2 = (container, value) => {
|
|
10154
|
+
if (value == null) return false;
|
|
10155
|
+
if (typeof value === "string") {
|
|
10156
|
+
container.textContent = value;
|
|
10157
|
+
return true;
|
|
10158
|
+
}
|
|
10159
|
+
container.appendChild(value);
|
|
10160
|
+
return true;
|
|
10161
|
+
};
|
|
10162
|
+
var getToolPreviewText = (message, maxLines) => {
|
|
10163
|
+
var _a;
|
|
10164
|
+
const tool = message.toolCall;
|
|
10165
|
+
if (!tool) return "";
|
|
10166
|
+
const chunkText = ((_a = tool.chunks) != null ? _a : []).join("").trim();
|
|
10167
|
+
if (chunkText) {
|
|
10168
|
+
const lines = chunkText.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).slice(-maxLines);
|
|
10169
|
+
return lines.join("\n");
|
|
10170
|
+
}
|
|
10171
|
+
const argsText = formatUnknownValue(tool.args).trim();
|
|
10172
|
+
if (!argsText) return "";
|
|
10173
|
+
return argsText.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).slice(0, maxLines).join("\n");
|
|
10174
|
+
};
|
|
10175
|
+
var getToolSummaryText = (message, config) => {
|
|
10176
|
+
var _a, _b, _c, _d;
|
|
10177
|
+
const tool = message.toolCall;
|
|
10178
|
+
const toolDisplayConfig = (_a = config == null ? void 0 : config.features) == null ? void 0 : _a.toolCallDisplay;
|
|
10179
|
+
const collapsedMode = (_b = toolDisplayConfig == null ? void 0 : toolDisplayConfig.collapsedMode) != null ? _b : "tool-call";
|
|
10180
|
+
const previewText = getToolPreviewText(message, (_c = toolDisplayConfig == null ? void 0 : toolDisplayConfig.previewMaxLines) != null ? _c : 3);
|
|
10181
|
+
const defaultSummary = tool ? describeToolTitle(tool) : "";
|
|
10182
|
+
if (!tool) {
|
|
10183
|
+
return { summary: defaultSummary, previewText, isActive: false };
|
|
10184
|
+
}
|
|
10185
|
+
const isActive = tool.status !== "complete";
|
|
10186
|
+
let summary = defaultSummary;
|
|
10187
|
+
if (collapsedMode === "tool-name") {
|
|
10188
|
+
summary = ((_d = tool.name) == null ? void 0 : _d.trim()) || defaultSummary;
|
|
10189
|
+
} else if (collapsedMode === "tool-preview" && previewText) {
|
|
10190
|
+
summary = previewText;
|
|
10191
|
+
}
|
|
10192
|
+
return { summary, previewText, isActive };
|
|
10193
|
+
};
|
|
9898
10194
|
var updateToolBubbleUI = (messageId, bubble, config) => {
|
|
9899
10195
|
var _a;
|
|
9900
10196
|
const expanded = toolExpansionState.has(messageId);
|
|
9901
10197
|
const toolCallConfig = (_a = config == null ? void 0 : config.toolCall) != null ? _a : {};
|
|
9902
10198
|
const header = bubble.querySelector('button[data-expand-header="true"]');
|
|
9903
10199
|
const content = bubble.querySelector(".persona-border-t");
|
|
10200
|
+
const preview = bubble.querySelector('[data-persona-collapsed-preview="tool"]');
|
|
9904
10201
|
if (!header || !content) return;
|
|
9905
10202
|
header.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
9906
10203
|
const headerMeta = header.querySelector(".persona-ml-auto");
|
|
@@ -9916,9 +10213,12 @@ var updateToolBubbleUI = (messageId, bubble, config) => {
|
|
|
9916
10213
|
}
|
|
9917
10214
|
}
|
|
9918
10215
|
content.style.display = expanded ? "" : "none";
|
|
10216
|
+
if (preview) {
|
|
10217
|
+
preview.style.display = expanded ? "none" : preview.textContent || preview.childNodes.length ? "" : "none";
|
|
10218
|
+
}
|
|
9919
10219
|
};
|
|
9920
10220
|
var createToolBubble = (message, config) => {
|
|
9921
|
-
var _a;
|
|
10221
|
+
var _a, _b, _c, _d, _e, _f;
|
|
9922
10222
|
const tool = message.toolCall;
|
|
9923
10223
|
const toolCallConfig = (_a = config == null ? void 0 : config.toolCall) != null ? _a : {};
|
|
9924
10224
|
const bubble = createElement(
|
|
@@ -9956,14 +10256,19 @@ var createToolBubble = (message, config) => {
|
|
|
9956
10256
|
if (!tool) {
|
|
9957
10257
|
return bubble;
|
|
9958
10258
|
}
|
|
9959
|
-
|
|
10259
|
+
const toolDisplayConfig = (_c = (_b = config == null ? void 0 : config.features) == null ? void 0 : _b.toolCallDisplay) != null ? _c : {};
|
|
10260
|
+
const expandable = toolDisplayConfig.expandable !== false;
|
|
10261
|
+
let expanded = expandable && toolExpansionState.has(message.id);
|
|
10262
|
+
const { summary, previewText, isActive } = getToolSummaryText(message, config);
|
|
9960
10263
|
const header = createElement(
|
|
9961
10264
|
"button",
|
|
9962
|
-
"persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-pointer persona-border-none"
|
|
10265
|
+
expandable ? "persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-pointer persona-border-none" : "persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-default persona-border-none"
|
|
9963
10266
|
);
|
|
9964
10267
|
header.type = "button";
|
|
9965
|
-
|
|
9966
|
-
|
|
10268
|
+
if (expandable) {
|
|
10269
|
+
header.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
10270
|
+
header.setAttribute("data-expand-header", "true");
|
|
10271
|
+
}
|
|
9967
10272
|
header.setAttribute("data-bubble-type", "tool");
|
|
9968
10273
|
if (toolCallConfig.headerBackgroundColor) {
|
|
9969
10274
|
header.style.backgroundColor = toolCallConfig.headerBackgroundColor;
|
|
@@ -9981,19 +10286,67 @@ var createToolBubble = (message, config) => {
|
|
|
9981
10286
|
if (toolCallConfig.headerTextColor) {
|
|
9982
10287
|
title.style.color = toolCallConfig.headerTextColor;
|
|
9983
10288
|
}
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
|
|
10289
|
+
const customSummary = (_e = toolCallConfig.renderCollapsedSummary) == null ? void 0 : _e.call(toolCallConfig, {
|
|
10290
|
+
message,
|
|
10291
|
+
toolCall: tool,
|
|
10292
|
+
defaultSummary: summary,
|
|
10293
|
+
previewText,
|
|
10294
|
+
collapsedMode: (_d = toolDisplayConfig.collapsedMode) != null ? _d : "tool-call",
|
|
10295
|
+
isActive,
|
|
10296
|
+
config: config != null ? config : {}
|
|
10297
|
+
});
|
|
10298
|
+
if (typeof customSummary === "string" && customSummary.trim()) {
|
|
10299
|
+
title.textContent = customSummary;
|
|
10300
|
+
headerContent.appendChild(title);
|
|
10301
|
+
} else if (customSummary instanceof HTMLElement) {
|
|
10302
|
+
headerContent.appendChild(customSummary);
|
|
10303
|
+
} else {
|
|
10304
|
+
title.textContent = summary;
|
|
10305
|
+
headerContent.appendChild(title);
|
|
10306
|
+
}
|
|
10307
|
+
let toggleIcon = null;
|
|
10308
|
+
if (expandable) {
|
|
10309
|
+
toggleIcon = createElement("div", "persona-flex persona-items-center");
|
|
10310
|
+
const iconColor = toolCallConfig.toggleTextColor || toolCallConfig.headerTextColor || "currentColor";
|
|
10311
|
+
const chevronIcon = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor, 2);
|
|
10312
|
+
if (chevronIcon) {
|
|
10313
|
+
toggleIcon.appendChild(chevronIcon);
|
|
10314
|
+
} else {
|
|
10315
|
+
toggleIcon.textContent = expanded ? "Hide" : "Show";
|
|
10316
|
+
}
|
|
10317
|
+
const headerMeta = createElement("div", "persona-flex persona-items-center persona-gap-2 persona-ml-auto");
|
|
10318
|
+
headerMeta.append(toggleIcon);
|
|
10319
|
+
header.append(headerContent, headerMeta);
|
|
9991
10320
|
} else {
|
|
9992
|
-
|
|
10321
|
+
header.append(headerContent);
|
|
10322
|
+
}
|
|
10323
|
+
const collapsedPreview = createElement(
|
|
10324
|
+
"div",
|
|
10325
|
+
"persona-px-4 persona-py-3 persona-text-xs persona-leading-snug persona-text-persona-muted"
|
|
10326
|
+
);
|
|
10327
|
+
collapsedPreview.setAttribute("data-persona-collapsed-preview", "tool");
|
|
10328
|
+
collapsedPreview.style.display = "none";
|
|
10329
|
+
collapsedPreview.style.whiteSpace = "pre-wrap";
|
|
10330
|
+
if (!expanded && isActive && toolDisplayConfig.activePreview && previewText) {
|
|
10331
|
+
const renderedPreview = (_f = toolCallConfig.renderCollapsedPreview) == null ? void 0 : _f.call(toolCallConfig, {
|
|
10332
|
+
message,
|
|
10333
|
+
toolCall: tool,
|
|
10334
|
+
defaultPreview: previewText,
|
|
10335
|
+
isActive,
|
|
10336
|
+
config: config != null ? config : {}
|
|
10337
|
+
});
|
|
10338
|
+
if (!appendRenderedValue2(collapsedPreview, renderedPreview)) {
|
|
10339
|
+
collapsedPreview.textContent = previewText;
|
|
10340
|
+
}
|
|
10341
|
+
collapsedPreview.style.display = "";
|
|
10342
|
+
}
|
|
10343
|
+
if (!expanded && isActive && toolDisplayConfig.activeMinHeight) {
|
|
10344
|
+
bubble.style.minHeight = toolDisplayConfig.activeMinHeight;
|
|
10345
|
+
}
|
|
10346
|
+
if (!expandable) {
|
|
10347
|
+
bubble.append(header, collapsedPreview);
|
|
10348
|
+
return bubble;
|
|
9993
10349
|
}
|
|
9994
|
-
const headerMeta = createElement("div", "persona-flex persona-items-center persona-gap-2 persona-ml-auto");
|
|
9995
|
-
headerMeta.append(toggleIcon);
|
|
9996
|
-
header.append(headerContent, headerMeta);
|
|
9997
10350
|
const content = createElement(
|
|
9998
10351
|
"div",
|
|
9999
10352
|
"persona-border-t persona-border-gray-200 persona-bg-gray-50 persona-space-y-3 persona-px-4 persona-py-3"
|
|
@@ -10123,18 +10476,21 @@ var createToolBubble = (message, config) => {
|
|
|
10123
10476
|
}
|
|
10124
10477
|
const applyToolExpansion = () => {
|
|
10125
10478
|
header.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
10126
|
-
toggleIcon
|
|
10127
|
-
|
|
10128
|
-
|
|
10129
|
-
|
|
10130
|
-
|
|
10131
|
-
|
|
10132
|
-
|
|
10479
|
+
if (toggleIcon) {
|
|
10480
|
+
toggleIcon.innerHTML = "";
|
|
10481
|
+
const iconColor = toolCallConfig.toggleTextColor || toolCallConfig.headerTextColor || "currentColor";
|
|
10482
|
+
const chevronIcon = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor, 2);
|
|
10483
|
+
if (chevronIcon) {
|
|
10484
|
+
toggleIcon.appendChild(chevronIcon);
|
|
10485
|
+
} else {
|
|
10486
|
+
toggleIcon.textContent = expanded ? "Hide" : "Show";
|
|
10487
|
+
}
|
|
10133
10488
|
}
|
|
10134
10489
|
content.style.display = expanded ? "" : "none";
|
|
10490
|
+
collapsedPreview.style.display = expanded ? "none" : collapsedPreview.textContent || collapsedPreview.childNodes.length ? "" : "none";
|
|
10135
10491
|
};
|
|
10136
10492
|
applyToolExpansion();
|
|
10137
|
-
bubble.append(header, content);
|
|
10493
|
+
bubble.append(header, collapsedPreview, content);
|
|
10138
10494
|
return bubble;
|
|
10139
10495
|
};
|
|
10140
10496
|
|
|
@@ -12941,6 +13297,15 @@ function getClipboardImageFiles(clipboardData) {
|
|
|
12941
13297
|
}
|
|
12942
13298
|
return imageFiles;
|
|
12943
13299
|
}
|
|
13300
|
+
function dataTransferHasFiles(dataTransfer) {
|
|
13301
|
+
if (!dataTransfer) return false;
|
|
13302
|
+
const types = dataTransfer.types;
|
|
13303
|
+
if (!types) return false;
|
|
13304
|
+
if (typeof types.contains === "function") {
|
|
13305
|
+
return types.contains("Files");
|
|
13306
|
+
}
|
|
13307
|
+
return Array.from(types).includes("Files");
|
|
13308
|
+
}
|
|
12944
13309
|
function normalizePersistStateConfig(config) {
|
|
12945
13310
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
12946
13311
|
if (!config) return null;
|
|
@@ -13032,8 +13397,36 @@ var buildPostprocessor = (cfg, actionManager, onResubmitRequested) => {
|
|
|
13032
13397
|
return sanitize ? sanitize(html) : html;
|
|
13033
13398
|
};
|
|
13034
13399
|
};
|
|
13400
|
+
function buildDropOverlay(dropCfg) {
|
|
13401
|
+
var _a, _b, _c, _d;
|
|
13402
|
+
const overlay = createElement("div", "persona-attachment-drop-overlay");
|
|
13403
|
+
if (dropCfg == null ? void 0 : dropCfg.background) overlay.style.setProperty("--persona-drop-overlay-bg", dropCfg.background);
|
|
13404
|
+
if ((dropCfg == null ? void 0 : dropCfg.backdropBlur) !== void 0) overlay.style.setProperty("--persona-drop-overlay-blur", dropCfg.backdropBlur);
|
|
13405
|
+
if (dropCfg == null ? void 0 : dropCfg.border) overlay.style.setProperty("--persona-drop-overlay-border", dropCfg.border);
|
|
13406
|
+
if (dropCfg == null ? void 0 : dropCfg.borderRadius) overlay.style.setProperty("--persona-drop-overlay-radius", dropCfg.borderRadius);
|
|
13407
|
+
if (dropCfg == null ? void 0 : dropCfg.inset) overlay.style.setProperty("--persona-drop-overlay-inset", dropCfg.inset);
|
|
13408
|
+
if (dropCfg == null ? void 0 : dropCfg.labelSize) overlay.style.setProperty("--persona-drop-overlay-label-size", dropCfg.labelSize);
|
|
13409
|
+
if (dropCfg == null ? void 0 : dropCfg.labelColor) overlay.style.setProperty("--persona-drop-overlay-label-color", dropCfg.labelColor);
|
|
13410
|
+
const iconName = (_a = dropCfg == null ? void 0 : dropCfg.iconName) != null ? _a : "upload";
|
|
13411
|
+
const iconSize = (_b = dropCfg == null ? void 0 : dropCfg.iconSize) != null ? _b : "48px";
|
|
13412
|
+
const iconColor = (_c = dropCfg == null ? void 0 : dropCfg.iconColor) != null ? _c : "rgba(59, 130, 246, 0.6)";
|
|
13413
|
+
const iconStrokeWidth = (_d = dropCfg == null ? void 0 : dropCfg.iconStrokeWidth) != null ? _d : 0.5;
|
|
13414
|
+
const iconSvg = renderLucideIcon(iconName, iconSize, iconColor, iconStrokeWidth);
|
|
13415
|
+
if (iconSvg) overlay.appendChild(iconSvg);
|
|
13416
|
+
if (dropCfg == null ? void 0 : dropCfg.label) {
|
|
13417
|
+
const labelEl = createElement("span", "persona-drop-overlay-label");
|
|
13418
|
+
labelEl.textContent = dropCfg.label;
|
|
13419
|
+
overlay.appendChild(labelEl);
|
|
13420
|
+
}
|
|
13421
|
+
return overlay;
|
|
13422
|
+
}
|
|
13035
13423
|
var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
13036
13424
|
var _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, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N;
|
|
13425
|
+
if (mount == null) {
|
|
13426
|
+
throw new Error(
|
|
13427
|
+
'createAgentExperience: mount must be a non-null HTMLElement (e.g. pass document.getElementById("my-root") after the node exists).'
|
|
13428
|
+
);
|
|
13429
|
+
}
|
|
13037
13430
|
if (mount.id && !mount.getAttribute("data-persona-instance")) {
|
|
13038
13431
|
mount.setAttribute("data-persona-instance", mount.id);
|
|
13039
13432
|
}
|
|
@@ -13437,8 +13830,22 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
13437
13830
|
return composerElements.footer;
|
|
13438
13831
|
},
|
|
13439
13832
|
onSubmit: (text) => {
|
|
13440
|
-
|
|
13441
|
-
|
|
13833
|
+
var _a2;
|
|
13834
|
+
if (!session || session.isStreaming()) return;
|
|
13835
|
+
const value = text.trim();
|
|
13836
|
+
const hasAttachments = (_a2 = attachmentManager == null ? void 0 : attachmentManager.hasAttachments()) != null ? _a2 : false;
|
|
13837
|
+
if (!value && !hasAttachments) return;
|
|
13838
|
+
let contentParts;
|
|
13839
|
+
if (hasAttachments) {
|
|
13840
|
+
contentParts = [];
|
|
13841
|
+
contentParts.push(...attachmentManager.getContentParts());
|
|
13842
|
+
if (value) {
|
|
13843
|
+
contentParts.push(createTextPart(value));
|
|
13844
|
+
}
|
|
13845
|
+
}
|
|
13846
|
+
session.sendMessage(value, { contentParts });
|
|
13847
|
+
if (hasAttachments) {
|
|
13848
|
+
attachmentManager.clearAttachments();
|
|
13442
13849
|
}
|
|
13443
13850
|
},
|
|
13444
13851
|
streaming: false,
|
|
@@ -13517,6 +13924,9 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
13517
13924
|
attachmentManager == null ? void 0 : attachmentManager.handleFileSelect(target.files);
|
|
13518
13925
|
target.value = "";
|
|
13519
13926
|
});
|
|
13927
|
+
const dropCfg = config.attachments.dropOverlay;
|
|
13928
|
+
const overlay = buildDropOverlay(dropCfg);
|
|
13929
|
+
container.appendChild(overlay);
|
|
13520
13930
|
}
|
|
13521
13931
|
const renderSlots = () => {
|
|
13522
13932
|
var _a2, _b2;
|
|
@@ -14310,6 +14720,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14310
14720
|
let lastScrollTop = 0;
|
|
14311
14721
|
let scrollRAF = null;
|
|
14312
14722
|
let isAutoScrolling = false;
|
|
14723
|
+
let hasPendingAutoScroll = false;
|
|
14313
14724
|
const USER_SCROLL_THRESHOLD = 1;
|
|
14314
14725
|
const BOTTOM_THRESHOLD = 8;
|
|
14315
14726
|
const messageState = /* @__PURE__ */ new Map();
|
|
@@ -14402,6 +14813,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14402
14813
|
cancelAnimationFrame(scrollRAF);
|
|
14403
14814
|
scrollRAF = null;
|
|
14404
14815
|
}
|
|
14816
|
+
hasPendingAutoScroll = false;
|
|
14405
14817
|
cancelSmoothScroll();
|
|
14406
14818
|
};
|
|
14407
14819
|
const syncScrollToBottomButton = () => {
|
|
@@ -14431,9 +14843,14 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14431
14843
|
const scheduleAutoScroll = (force = false) => {
|
|
14432
14844
|
if (!autoFollow.isFollowing()) return;
|
|
14433
14845
|
if (!force && !isStreaming) return;
|
|
14434
|
-
|
|
14846
|
+
if (scrollRAF !== null) {
|
|
14847
|
+
cancelAnimationFrame(scrollRAF);
|
|
14848
|
+
scrollRAF = null;
|
|
14849
|
+
}
|
|
14850
|
+
hasPendingAutoScroll = true;
|
|
14435
14851
|
scrollRAF = requestAnimationFrame(() => {
|
|
14436
14852
|
scrollRAF = null;
|
|
14853
|
+
hasPendingAutoScroll = false;
|
|
14437
14854
|
if (!autoFollow.isFollowing()) return;
|
|
14438
14855
|
smoothScrollToBottom(getScrollableContainer(), force ? 220 : 140);
|
|
14439
14856
|
});
|
|
@@ -14507,7 +14924,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14507
14924
|
});
|
|
14508
14925
|
};
|
|
14509
14926
|
const renderMessagesWithPluginsImpl = (container2, messages, transform) => {
|
|
14510
|
-
var _a2, _b2, _c2, _d2;
|
|
14927
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
14511
14928
|
const tempContainer = document.createElement("div");
|
|
14512
14929
|
const getInlineLoadingIndicatorRenderer = () => {
|
|
14513
14930
|
var _a3;
|
|
@@ -14521,6 +14938,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14521
14938
|
return void 0;
|
|
14522
14939
|
};
|
|
14523
14940
|
const inlineLoadingRenderer = getInlineLoadingIndicatorRenderer();
|
|
14941
|
+
const appendRenderedValue3 = (containerEl, value) => {
|
|
14942
|
+
if (value == null) return false;
|
|
14943
|
+
if (typeof value === "string") {
|
|
14944
|
+
containerEl.textContent = value;
|
|
14945
|
+
return true;
|
|
14946
|
+
}
|
|
14947
|
+
containerEl.appendChild(value);
|
|
14948
|
+
return true;
|
|
14949
|
+
};
|
|
14524
14950
|
const activeMessageIds = /* @__PURE__ */ new Set();
|
|
14525
14951
|
messages.forEach((message) => {
|
|
14526
14952
|
var _a3, _b3;
|
|
@@ -14553,7 +14979,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14553
14979
|
if (!showReasoning) return;
|
|
14554
14980
|
bubble = matchingPlugin.renderReasoning({
|
|
14555
14981
|
message,
|
|
14556
|
-
defaultRenderer: () => createReasoningBubble(message),
|
|
14982
|
+
defaultRenderer: () => createReasoningBubble(message, config),
|
|
14557
14983
|
config
|
|
14558
14984
|
});
|
|
14559
14985
|
} else if (message.variant === "tool" && message.toolCall && matchingPlugin.renderToolCall) {
|
|
@@ -14659,7 +15085,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14659
15085
|
if (!bubble) {
|
|
14660
15086
|
if (message.variant === "reasoning" && message.reasoning) {
|
|
14661
15087
|
if (!showReasoning) return;
|
|
14662
|
-
bubble = createReasoningBubble(message);
|
|
15088
|
+
bubble = createReasoningBubble(message, config);
|
|
14663
15089
|
} else if (message.variant === "tool" && message.toolCall) {
|
|
14664
15090
|
if (!showToolCalls) return;
|
|
14665
15091
|
bubble = createToolBubble(message, config);
|
|
@@ -14712,6 +15138,68 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14712
15138
|
setCachedWrapper(messageCache, message.id, fingerprint, wrapper2);
|
|
14713
15139
|
tempContainer.appendChild(wrapper2);
|
|
14714
15140
|
});
|
|
15141
|
+
if ((_b2 = (_a2 = config.features) == null ? void 0 : _a2.toolCallDisplay) == null ? void 0 : _b2.grouped) {
|
|
15142
|
+
const toolGroups = [];
|
|
15143
|
+
let currentGroup = [];
|
|
15144
|
+
messages.forEach((message) => {
|
|
15145
|
+
if (message.variant === "tool" && message.toolCall && showToolCalls) {
|
|
15146
|
+
currentGroup.push(message);
|
|
15147
|
+
return;
|
|
15148
|
+
}
|
|
15149
|
+
if (currentGroup.length > 1) {
|
|
15150
|
+
toolGroups.push(currentGroup);
|
|
15151
|
+
}
|
|
15152
|
+
currentGroup = [];
|
|
15153
|
+
});
|
|
15154
|
+
if (currentGroup.length > 1) {
|
|
15155
|
+
toolGroups.push(currentGroup);
|
|
15156
|
+
}
|
|
15157
|
+
toolGroups.forEach((group, groupIndex) => {
|
|
15158
|
+
var _a3, _b3;
|
|
15159
|
+
const wrappers = group.map(
|
|
15160
|
+
(groupMessage) => Array.from(tempContainer.children).find(
|
|
15161
|
+
(child) => child instanceof HTMLElement && child.getAttribute("data-wrapper-id") === groupMessage.id
|
|
15162
|
+
)
|
|
15163
|
+
).filter((wrapper2) => Boolean(wrapper2));
|
|
15164
|
+
if (wrappers.length < 2) {
|
|
15165
|
+
return;
|
|
15166
|
+
}
|
|
15167
|
+
const groupWrapper = document.createElement("div");
|
|
15168
|
+
groupWrapper.className = "persona-flex";
|
|
15169
|
+
groupWrapper.id = `wrapper-tool-group-${groupIndex}-${group[0].id}`;
|
|
15170
|
+
groupWrapper.setAttribute("data-wrapper-id", `tool-group-${groupIndex}-${group[0].id}`);
|
|
15171
|
+
const groupContainer = document.createElement("div");
|
|
15172
|
+
groupContainer.className = "persona-tool-group persona-flex persona-w-full persona-flex-col persona-gap-2";
|
|
15173
|
+
groupContainer.setAttribute("data-persona-tool-group", "true");
|
|
15174
|
+
const summary = document.createElement("div");
|
|
15175
|
+
summary.className = "persona-tool-group-summary persona-text-xs persona-text-persona-muted";
|
|
15176
|
+
const defaultSummary = `Called ${group.length} tools`;
|
|
15177
|
+
const renderedSummary = (_b3 = (_a3 = config.toolCall) == null ? void 0 : _a3.renderGroupedSummary) == null ? void 0 : _b3.call(_a3, {
|
|
15178
|
+
messages: group,
|
|
15179
|
+
toolCalls: group.map((groupMessage) => groupMessage.toolCall).filter((toolCall) => Boolean(toolCall)),
|
|
15180
|
+
defaultSummary,
|
|
15181
|
+
config
|
|
15182
|
+
});
|
|
15183
|
+
if (!appendRenderedValue3(summary, renderedSummary)) {
|
|
15184
|
+
summary.textContent = defaultSummary;
|
|
15185
|
+
}
|
|
15186
|
+
const stack = document.createElement("div");
|
|
15187
|
+
stack.className = "persona-tool-group-stack persona-flex persona-flex-col";
|
|
15188
|
+
groupContainer.append(summary, stack);
|
|
15189
|
+
groupWrapper.appendChild(groupContainer);
|
|
15190
|
+
wrappers[0].before(groupWrapper);
|
|
15191
|
+
wrappers.forEach((wrapper2, wrapperIndex) => {
|
|
15192
|
+
const item = document.createElement("div");
|
|
15193
|
+
item.className = "persona-tool-group-item persona-relative";
|
|
15194
|
+
item.setAttribute("data-persona-tool-group-item", "true");
|
|
15195
|
+
if (wrapperIndex < wrappers.length - 1) {
|
|
15196
|
+
item.setAttribute("data-persona-tool-group-connector", "true");
|
|
15197
|
+
}
|
|
15198
|
+
item.appendChild(wrapper2);
|
|
15199
|
+
stack.appendChild(item);
|
|
15200
|
+
});
|
|
15201
|
+
});
|
|
15202
|
+
}
|
|
14715
15203
|
pruneCache(messageCache, activeMessageIds);
|
|
14716
15204
|
const hasStreamingAssistantMessage = messages.some(
|
|
14717
15205
|
(msg) => msg.role === "assistant" && msg.streaming
|
|
@@ -14730,7 +15218,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14730
15218
|
if (loadingPlugin == null ? void 0 : loadingPlugin.renderLoadingIndicator) {
|
|
14731
15219
|
typingIndicator = loadingPlugin.renderLoadingIndicator(loadingIndicatorContext);
|
|
14732
15220
|
}
|
|
14733
|
-
if (typingIndicator === null && ((
|
|
15221
|
+
if (typingIndicator === null && ((_c2 = config.loadingIndicator) == null ? void 0 : _c2.render)) {
|
|
14734
15222
|
typingIndicator = config.loadingIndicator.render(loadingIndicatorContext);
|
|
14735
15223
|
}
|
|
14736
15224
|
if (typingIndicator === null) {
|
|
@@ -14738,7 +15226,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14738
15226
|
}
|
|
14739
15227
|
if (typingIndicator) {
|
|
14740
15228
|
const typingBubble = document.createElement("div");
|
|
14741
|
-
const showBubble = ((
|
|
15229
|
+
const showBubble = ((_d2 = config.loadingIndicator) == null ? void 0 : _d2.showBubble) !== false;
|
|
14742
15230
|
typingBubble.className = showBubble ? [
|
|
14743
15231
|
"persona-max-w-[85%]",
|
|
14744
15232
|
"persona-rounded-2xl",
|
|
@@ -14779,12 +15267,12 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14779
15267
|
if (idlePlugin == null ? void 0 : idlePlugin.renderIdleIndicator) {
|
|
14780
15268
|
idleIndicator = idlePlugin.renderIdleIndicator(idleIndicatorContext);
|
|
14781
15269
|
}
|
|
14782
|
-
if (idleIndicator === null && ((
|
|
15270
|
+
if (idleIndicator === null && ((_e2 = config.loadingIndicator) == null ? void 0 : _e2.renderIdle)) {
|
|
14783
15271
|
idleIndicator = config.loadingIndicator.renderIdle(idleIndicatorContext);
|
|
14784
15272
|
}
|
|
14785
15273
|
if (idleIndicator) {
|
|
14786
15274
|
const idleBubble = document.createElement("div");
|
|
14787
|
-
const showBubble = ((
|
|
15275
|
+
const showBubble = ((_f2 = config.loadingIndicator) == null ? void 0 : _f2.showBubble) !== false;
|
|
14788
15276
|
idleBubble.className = showBubble ? [
|
|
14789
15277
|
"persona-max-w-[85%]",
|
|
14790
15278
|
"persona-rounded-2xl",
|
|
@@ -15681,7 +16169,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
15681
16169
|
lastScrollTop,
|
|
15682
16170
|
nearBottom: isElementNearBottom(body, BOTTOM_THRESHOLD),
|
|
15683
16171
|
userScrollThreshold: USER_SCROLL_THRESHOLD,
|
|
15684
|
-
isAutoScrolling,
|
|
16172
|
+
isAutoScrolling: isAutoScrolling || hasPendingAutoScroll,
|
|
15685
16173
|
pauseOnUpwardScroll: true,
|
|
15686
16174
|
pauseWhenAwayFromBottom: false,
|
|
15687
16175
|
resumeRequiresDownwardScroll: true
|
|
@@ -15796,6 +16284,61 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
15796
16284
|
}
|
|
15797
16285
|
textarea == null ? void 0 : textarea.addEventListener("keydown", handleInputEnter);
|
|
15798
16286
|
textarea == null ? void 0 : textarea.addEventListener("paste", handleInputPaste);
|
|
16287
|
+
const ATTACHMENT_DROP_ACTIVE_CLASS = "persona-attachment-drop-active";
|
|
16288
|
+
let attachmentFileDragDepth = 0;
|
|
16289
|
+
const clearAttachmentDropVisual = () => {
|
|
16290
|
+
attachmentFileDragDepth = 0;
|
|
16291
|
+
container.classList.remove(ATTACHMENT_DROP_ACTIVE_CLASS);
|
|
16292
|
+
};
|
|
16293
|
+
const attachmentDropHandlingActive = () => {
|
|
16294
|
+
var _a2;
|
|
16295
|
+
return ((_a2 = config.attachments) == null ? void 0 : _a2.enabled) === true && attachmentManager !== null;
|
|
16296
|
+
};
|
|
16297
|
+
const handleAttachmentDragEnterCapture = (e) => {
|
|
16298
|
+
if (!dataTransferHasFiles(e.dataTransfer) || !attachmentDropHandlingActive()) return;
|
|
16299
|
+
attachmentFileDragDepth++;
|
|
16300
|
+
if (attachmentFileDragDepth === 1) {
|
|
16301
|
+
container.classList.add(ATTACHMENT_DROP_ACTIVE_CLASS);
|
|
16302
|
+
}
|
|
16303
|
+
};
|
|
16304
|
+
const handleAttachmentDragLeaveCapture = (e) => {
|
|
16305
|
+
if (!dataTransferHasFiles(e.dataTransfer) || !attachmentDropHandlingActive()) return;
|
|
16306
|
+
attachmentFileDragDepth--;
|
|
16307
|
+
if (attachmentFileDragDepth <= 0) {
|
|
16308
|
+
clearAttachmentDropVisual();
|
|
16309
|
+
}
|
|
16310
|
+
};
|
|
16311
|
+
const handleAttachmentDragOverCapture = (e) => {
|
|
16312
|
+
if (!dataTransferHasFiles(e.dataTransfer) || !attachmentDropHandlingActive()) return;
|
|
16313
|
+
e.preventDefault();
|
|
16314
|
+
e.dataTransfer.dropEffect = "copy";
|
|
16315
|
+
};
|
|
16316
|
+
const handleAttachmentDropCapture = (e) => {
|
|
16317
|
+
var _a2;
|
|
16318
|
+
if (!dataTransferHasFiles(e.dataTransfer) || !attachmentDropHandlingActive()) return;
|
|
16319
|
+
e.preventDefault();
|
|
16320
|
+
e.stopPropagation();
|
|
16321
|
+
clearAttachmentDropVisual();
|
|
16322
|
+
const files = Array.from((_a2 = e.dataTransfer.files) != null ? _a2 : []);
|
|
16323
|
+
if (files.length === 0) return;
|
|
16324
|
+
void attachmentManager.handleFiles(files);
|
|
16325
|
+
};
|
|
16326
|
+
const attachmentDropCapture = true;
|
|
16327
|
+
container.addEventListener("dragenter", handleAttachmentDragEnterCapture, attachmentDropCapture);
|
|
16328
|
+
container.addEventListener("dragleave", handleAttachmentDragLeaveCapture, attachmentDropCapture);
|
|
16329
|
+
mount.addEventListener("dragover", handleAttachmentDragOverCapture, attachmentDropCapture);
|
|
16330
|
+
mount.addEventListener("drop", handleAttachmentDropCapture, attachmentDropCapture);
|
|
16331
|
+
const ownerDoc = mount.ownerDocument;
|
|
16332
|
+
const handleDocDragOver = (e) => {
|
|
16333
|
+
if (!attachmentDropHandlingActive()) return;
|
|
16334
|
+
e.preventDefault();
|
|
16335
|
+
};
|
|
16336
|
+
const handleDocDrop = (e) => {
|
|
16337
|
+
if (!attachmentDropHandlingActive()) return;
|
|
16338
|
+
e.preventDefault();
|
|
16339
|
+
};
|
|
16340
|
+
ownerDoc.addEventListener("dragover", handleDocDragOver);
|
|
16341
|
+
ownerDoc.addEventListener("drop", handleDocDrop);
|
|
15799
16342
|
destroyCallbacks.push(() => {
|
|
15800
16343
|
if (composerForm) {
|
|
15801
16344
|
composerForm.removeEventListener("submit", handleSubmit);
|
|
@@ -15803,6 +16346,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
15803
16346
|
textarea == null ? void 0 : textarea.removeEventListener("keydown", handleInputEnter);
|
|
15804
16347
|
textarea == null ? void 0 : textarea.removeEventListener("paste", handleInputPaste);
|
|
15805
16348
|
});
|
|
16349
|
+
destroyCallbacks.push(() => {
|
|
16350
|
+
container.removeEventListener("dragenter", handleAttachmentDragEnterCapture, attachmentDropCapture);
|
|
16351
|
+
container.removeEventListener("dragleave", handleAttachmentDragLeaveCapture, attachmentDropCapture);
|
|
16352
|
+
mount.removeEventListener("dragover", handleAttachmentDragOverCapture, attachmentDropCapture);
|
|
16353
|
+
mount.removeEventListener("drop", handleAttachmentDropCapture, attachmentDropCapture);
|
|
16354
|
+
ownerDoc.removeEventListener("dragover", handleDocDragOver);
|
|
16355
|
+
ownerDoc.removeEventListener("drop", handleDocDrop);
|
|
16356
|
+
clearAttachmentDropVisual();
|
|
16357
|
+
});
|
|
15806
16358
|
destroyCallbacks.push(() => {
|
|
15807
16359
|
session.cancel();
|
|
15808
16360
|
});
|
|
@@ -15817,13 +16369,17 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
15817
16369
|
}
|
|
15818
16370
|
const controller = {
|
|
15819
16371
|
update(nextConfig) {
|
|
15820
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2, _s2, _t2, _u2, _v2, _w2, _x2, _y2, _z2, _A2, _B2, _C2, _D2, _E2, _F2, _G2, _H2, _I2, _J2, _K2, _L2, _M2, _N2, _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;
|
|
16372
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2, _s2, _t2, _u2, _v2, _w2, _x2, _y2, _z2, _A2, _B2, _C2, _D2, _E2, _F2, _G2, _H2, _I2, _J2, _K2, _L2, _M2, _N2, _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;
|
|
15821
16373
|
const previousToolCallConfig = config.toolCall;
|
|
15822
16374
|
const previousMessageActions = config.messageActions;
|
|
15823
16375
|
const previousLayoutMessages = (_a2 = config.layout) == null ? void 0 : _a2.messages;
|
|
15824
16376
|
const previousColorScheme = config.colorScheme;
|
|
15825
16377
|
const previousLoadingIndicator = config.loadingIndicator;
|
|
15826
16378
|
const previousIterationDisplay = config.iterationDisplay;
|
|
16379
|
+
const previousShowReasoning = (_b2 = config.features) == null ? void 0 : _b2.showReasoning;
|
|
16380
|
+
const previousShowToolCalls = (_c2 = config.features) == null ? void 0 : _c2.showToolCalls;
|
|
16381
|
+
const previousToolCallDisplay = (_d2 = config.features) == null ? void 0 : _d2.toolCallDisplay;
|
|
16382
|
+
const previousReasoningDisplay = (_e2 = config.features) == null ? void 0 : _e2.reasoningDisplay;
|
|
15827
16383
|
config = { ...config, ...nextConfig };
|
|
15828
16384
|
applyFullHeightStyles();
|
|
15829
16385
|
applyThemeVariables(mount, config);
|
|
@@ -15836,15 +16392,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
15836
16392
|
const newPlugins = pluginRegistry.getForInstance(config.plugins);
|
|
15837
16393
|
plugins.length = 0;
|
|
15838
16394
|
plugins.push(...newPlugins);
|
|
15839
|
-
launcherEnabled = (
|
|
15840
|
-
autoExpand = (
|
|
15841
|
-
showReasoning = (
|
|
15842
|
-
showToolCalls = (
|
|
15843
|
-
scrollToBottomFeature = (
|
|
16395
|
+
launcherEnabled = (_g2 = (_f2 = config.launcher) == null ? void 0 : _f2.enabled) != null ? _g2 : true;
|
|
16396
|
+
autoExpand = (_i2 = (_h2 = config.launcher) == null ? void 0 : _h2.autoExpand) != null ? _i2 : false;
|
|
16397
|
+
showReasoning = (_k2 = (_j2 = config.features) == null ? void 0 : _j2.showReasoning) != null ? _k2 : true;
|
|
16398
|
+
showToolCalls = (_m2 = (_l2 = config.features) == null ? void 0 : _l2.showToolCalls) != null ? _m2 : true;
|
|
16399
|
+
scrollToBottomFeature = (_o2 = (_n2 = config.features) == null ? void 0 : _n2.scrollToBottom) != null ? _o2 : {};
|
|
15844
16400
|
renderScrollToBottomButton();
|
|
15845
16401
|
syncScrollToBottomButton();
|
|
15846
16402
|
const prevShowEventStreamToggle = showEventStreamToggle;
|
|
15847
|
-
showEventStreamToggle = (
|
|
16403
|
+
showEventStreamToggle = (_q2 = (_p2 = config.features) == null ? void 0 : _p2.showEventStreamToggle) != null ? _q2 : false;
|
|
15848
16404
|
if (showEventStreamToggle && !prevShowEventStreamToggle) {
|
|
15849
16405
|
if (!eventStreamBuffer) {
|
|
15850
16406
|
eventStreamStore = new EventStreamStore(eventStreamDbName);
|
|
@@ -15861,7 +16417,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
15861
16417
|
});
|
|
15862
16418
|
}
|
|
15863
16419
|
if (!eventStreamToggleBtn && header) {
|
|
15864
|
-
const dynEsClassNames = (
|
|
16420
|
+
const dynEsClassNames = (_s2 = (_r2 = config.features) == null ? void 0 : _r2.eventStream) == null ? void 0 : _s2.classNames;
|
|
15865
16421
|
const dynToggleBtnClasses = "persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-opacity-80 persona-cursor-pointer persona-border-none persona-bg-transparent persona-p-1" + ((dynEsClassNames == null ? void 0 : dynEsClassNames.toggleButton) ? " " + dynEsClassNames.toggleButton : "");
|
|
15866
16422
|
eventStreamToggleBtn = createElement("button", dynToggleBtnClasses);
|
|
15867
16423
|
eventStreamToggleBtn.style.width = "28px";
|
|
@@ -15899,15 +16455,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
15899
16455
|
eventStreamBuffer = null;
|
|
15900
16456
|
eventStreamStore = null;
|
|
15901
16457
|
}
|
|
15902
|
-
if (((
|
|
16458
|
+
if (((_t2 = config.launcher) == null ? void 0 : _t2.enabled) === false && launcherButtonInstance) {
|
|
15903
16459
|
launcherButtonInstance.destroy();
|
|
15904
16460
|
launcherButtonInstance = null;
|
|
15905
16461
|
}
|
|
15906
|
-
if (((
|
|
16462
|
+
if (((_u2 = config.launcher) == null ? void 0 : _u2.enabled) === false && customLauncherElement) {
|
|
15907
16463
|
customLauncherElement.remove();
|
|
15908
16464
|
customLauncherElement = null;
|
|
15909
16465
|
}
|
|
15910
|
-
if (((
|
|
16466
|
+
if (((_v2 = config.launcher) == null ? void 0 : _v2.enabled) !== false && !launcherButtonInstance && !customLauncherElement) {
|
|
15911
16467
|
const launcherPlugin = plugins.find((p) => p.renderLauncher);
|
|
15912
16468
|
if (launcherPlugin == null ? void 0 : launcherPlugin.renderLauncher) {
|
|
15913
16469
|
const customLauncher = launcherPlugin.renderLauncher({
|
|
@@ -15931,13 +16487,13 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
15931
16487
|
if (launcherButtonInstance) {
|
|
15932
16488
|
launcherButtonInstance.update(config);
|
|
15933
16489
|
}
|
|
15934
|
-
if (headerTitle && ((
|
|
16490
|
+
if (headerTitle && ((_w2 = config.launcher) == null ? void 0 : _w2.title) !== void 0) {
|
|
15935
16491
|
headerTitle.textContent = config.launcher.title;
|
|
15936
16492
|
}
|
|
15937
|
-
if (headerSubtitle && ((
|
|
16493
|
+
if (headerSubtitle && ((_x2 = config.launcher) == null ? void 0 : _x2.subtitle) !== void 0) {
|
|
15938
16494
|
headerSubtitle.textContent = config.launcher.subtitle;
|
|
15939
16495
|
}
|
|
15940
|
-
const headerLayoutConfig = (
|
|
16496
|
+
const headerLayoutConfig = (_y2 = config.layout) == null ? void 0 : _y2.header;
|
|
15941
16497
|
const headerLayoutChanged = (headerLayoutConfig == null ? void 0 : headerLayoutConfig.layout) !== prevHeaderLayout;
|
|
15942
16498
|
if (headerLayoutChanged && header) {
|
|
15943
16499
|
const newHeaderElements = headerLayoutConfig ? buildHeaderWithLayout(config, headerLayoutConfig, {
|
|
@@ -15983,11 +16539,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
15983
16539
|
}
|
|
15984
16540
|
}
|
|
15985
16541
|
}
|
|
15986
|
-
const showHeader = ((
|
|
16542
|
+
const showHeader = ((_z2 = config.layout) == null ? void 0 : _z2.showHeader) !== false;
|
|
15987
16543
|
if (header) {
|
|
15988
16544
|
header.style.display = showHeader ? "" : "none";
|
|
15989
16545
|
}
|
|
15990
|
-
const showFooter = ((
|
|
16546
|
+
const showFooter = ((_A2 = config.layout) == null ? void 0 : _A2.showFooter) !== false;
|
|
15991
16547
|
if (footer) {
|
|
15992
16548
|
footer.style.display = showFooter ? "" : "none";
|
|
15993
16549
|
}
|
|
@@ -16011,20 +16567,21 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16011
16567
|
refreshCloseButton();
|
|
16012
16568
|
const toolCallConfigChanged = JSON.stringify(nextConfig.toolCall) !== JSON.stringify(previousToolCallConfig);
|
|
16013
16569
|
const messageActionsChanged = JSON.stringify(config.messageActions) !== JSON.stringify(previousMessageActions);
|
|
16014
|
-
const layoutMessagesChanged = JSON.stringify((
|
|
16015
|
-
const loadingIndicatorChanged = ((
|
|
16570
|
+
const layoutMessagesChanged = JSON.stringify((_B2 = config.layout) == null ? void 0 : _B2.messages) !== JSON.stringify(previousLayoutMessages);
|
|
16571
|
+
const loadingIndicatorChanged = ((_C2 = config.loadingIndicator) == null ? void 0 : _C2.render) !== (previousLoadingIndicator == null ? void 0 : previousLoadingIndicator.render) || ((_D2 = config.loadingIndicator) == null ? void 0 : _D2.renderIdle) !== (previousLoadingIndicator == null ? void 0 : previousLoadingIndicator.renderIdle) || ((_E2 = config.loadingIndicator) == null ? void 0 : _E2.showBubble) !== (previousLoadingIndicator == null ? void 0 : previousLoadingIndicator.showBubble);
|
|
16016
16572
|
const iterationDisplayChanged = config.iterationDisplay !== previousIterationDisplay;
|
|
16017
|
-
const
|
|
16573
|
+
const featuresChanged = ((_G2 = (_F2 = config.features) == null ? void 0 : _F2.showReasoning) != null ? _G2 : true) !== (previousShowReasoning != null ? previousShowReasoning : true) || ((_I2 = (_H2 = config.features) == null ? void 0 : _H2.showToolCalls) != null ? _I2 : true) !== (previousShowToolCalls != null ? previousShowToolCalls : true) || JSON.stringify((_J2 = config.features) == null ? void 0 : _J2.toolCallDisplay) !== JSON.stringify(previousToolCallDisplay) || JSON.stringify((_K2 = config.features) == null ? void 0 : _K2.reasoningDisplay) !== JSON.stringify(previousReasoningDisplay);
|
|
16574
|
+
const messagesConfigChanged = toolCallConfigChanged || messageActionsChanged || layoutMessagesChanged || loadingIndicatorChanged || iterationDisplayChanged || featuresChanged;
|
|
16018
16575
|
if (messagesConfigChanged && session) {
|
|
16019
16576
|
configVersion++;
|
|
16020
16577
|
renderMessagesWithPlugins(messagesWrapper, session.getMessages(), postprocess);
|
|
16021
16578
|
}
|
|
16022
|
-
const launcher = (
|
|
16023
|
-
const headerIconHidden = (
|
|
16024
|
-
const layoutShowIcon = (
|
|
16579
|
+
const launcher = (_L2 = config.launcher) != null ? _L2 : {};
|
|
16580
|
+
const headerIconHidden = (_M2 = launcher.headerIconHidden) != null ? _M2 : false;
|
|
16581
|
+
const layoutShowIcon = (_O = (_N2 = config.layout) == null ? void 0 : _N2.header) == null ? void 0 : _O.showIcon;
|
|
16025
16582
|
const shouldHideIcon = headerIconHidden || layoutShowIcon === false;
|
|
16026
16583
|
const headerIconName = launcher.headerIconName;
|
|
16027
|
-
const headerIconSize = (
|
|
16584
|
+
const headerIconSize = (_P = launcher.headerIconSize) != null ? _P : "48px";
|
|
16028
16585
|
if (iconHolder) {
|
|
16029
16586
|
const headerEl = container.querySelector(".persona-border-b-persona-divider");
|
|
16030
16587
|
const headerCopy = headerEl == null ? void 0 : headerEl.querySelector(".persona-flex-col");
|
|
@@ -16051,7 +16608,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16051
16608
|
if (iconSvg) {
|
|
16052
16609
|
iconHolder.replaceChildren(iconSvg);
|
|
16053
16610
|
} else {
|
|
16054
|
-
iconHolder.textContent = (
|
|
16611
|
+
iconHolder.textContent = (_Q = launcher.agentIconText) != null ? _Q : "\u{1F4AC}";
|
|
16055
16612
|
}
|
|
16056
16613
|
} else if (launcher.iconUrl) {
|
|
16057
16614
|
const img2 = iconHolder.querySelector("img");
|
|
@@ -16074,7 +16631,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16074
16631
|
if (existingSvg || existingImg) {
|
|
16075
16632
|
iconHolder.replaceChildren();
|
|
16076
16633
|
}
|
|
16077
|
-
iconHolder.textContent = (
|
|
16634
|
+
iconHolder.textContent = (_R = launcher.agentIconText) != null ? _R : "\u{1F4AC}";
|
|
16078
16635
|
}
|
|
16079
16636
|
const img = iconHolder.querySelector("img");
|
|
16080
16637
|
if (img) {
|
|
@@ -16083,8 +16640,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16083
16640
|
}
|
|
16084
16641
|
}
|
|
16085
16642
|
}
|
|
16086
|
-
const layoutShowTitle = (
|
|
16087
|
-
const layoutShowSubtitle = (
|
|
16643
|
+
const layoutShowTitle = (_T = (_S = config.layout) == null ? void 0 : _S.header) == null ? void 0 : _T.showTitle;
|
|
16644
|
+
const layoutShowSubtitle = (_V = (_U = config.layout) == null ? void 0 : _U.header) == null ? void 0 : _V.showSubtitle;
|
|
16088
16645
|
if (headerTitle) {
|
|
16089
16646
|
headerTitle.style.display = layoutShowTitle === false ? "none" : "";
|
|
16090
16647
|
}
|
|
@@ -16092,14 +16649,14 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16092
16649
|
headerSubtitle.style.display = layoutShowSubtitle === false ? "none" : "";
|
|
16093
16650
|
}
|
|
16094
16651
|
if (closeButton) {
|
|
16095
|
-
const layoutShowCloseButton = (
|
|
16652
|
+
const layoutShowCloseButton = (_X = (_W = config.layout) == null ? void 0 : _W.header) == null ? void 0 : _X.showCloseButton;
|
|
16096
16653
|
if (layoutShowCloseButton === false) {
|
|
16097
16654
|
closeButton.style.display = "none";
|
|
16098
16655
|
} else {
|
|
16099
16656
|
closeButton.style.display = "";
|
|
16100
16657
|
}
|
|
16101
|
-
const closeButtonSize = (
|
|
16102
|
-
const closeButtonPlacement = (
|
|
16658
|
+
const closeButtonSize = (_Y = launcher.closeButtonSize) != null ? _Y : "32px";
|
|
16659
|
+
const closeButtonPlacement = (_Z = launcher.closeButtonPlacement) != null ? _Z : "inline";
|
|
16103
16660
|
closeButton.style.height = closeButtonSize;
|
|
16104
16661
|
closeButton.style.width = closeButtonSize;
|
|
16105
16662
|
const { closeButtonWrapper } = panelElements;
|
|
@@ -16112,8 +16669,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16112
16669
|
container.style.position = "relative";
|
|
16113
16670
|
container.appendChild(closeButtonWrapper);
|
|
16114
16671
|
} else {
|
|
16115
|
-
const clearChatPlacement = (
|
|
16116
|
-
const clearChatEnabled = (
|
|
16672
|
+
const clearChatPlacement = (_$ = (__ = launcher.clearChat) == null ? void 0 : __.placement) != null ? _$ : "inline";
|
|
16673
|
+
const clearChatEnabled = (_ba = (_aa = launcher.clearChat) == null ? void 0 : _aa.enabled) != null ? _ba : true;
|
|
16117
16674
|
closeButtonWrapper.className = clearChatEnabled && clearChatPlacement === "inline" ? "" : "persona-ml-auto";
|
|
16118
16675
|
const header2 = container.querySelector(".persona-border-b-persona-divider");
|
|
16119
16676
|
if (header2) {
|
|
@@ -16159,8 +16716,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16159
16716
|
closeButton.style.paddingTop = "";
|
|
16160
16717
|
closeButton.style.paddingBottom = "";
|
|
16161
16718
|
}
|
|
16162
|
-
const closeButtonIconName = (
|
|
16163
|
-
const closeButtonIconText = (
|
|
16719
|
+
const closeButtonIconName = (_ca = launcher.closeButtonIconName) != null ? _ca : "x";
|
|
16720
|
+
const closeButtonIconText = (_da = launcher.closeButtonIconText) != null ? _da : "\xD7";
|
|
16164
16721
|
closeButton.innerHTML = "";
|
|
16165
16722
|
const iconSvg = renderLucideIcon(closeButtonIconName, "20px", "currentColor", 2);
|
|
16166
16723
|
if (iconSvg) {
|
|
@@ -16168,8 +16725,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16168
16725
|
} else {
|
|
16169
16726
|
closeButton.textContent = closeButtonIconText;
|
|
16170
16727
|
}
|
|
16171
|
-
const closeButtonTooltipText = (
|
|
16172
|
-
const closeButtonShowTooltip = (
|
|
16728
|
+
const closeButtonTooltipText = (_ea = launcher.closeButtonTooltipText) != null ? _ea : "Close chat";
|
|
16729
|
+
const closeButtonShowTooltip = (_fa = launcher.closeButtonShowTooltip) != null ? _fa : true;
|
|
16173
16730
|
closeButton.setAttribute("aria-label", closeButtonTooltipText);
|
|
16174
16731
|
if (closeButtonWrapper) {
|
|
16175
16732
|
if (closeButtonWrapper._cleanupTooltip) {
|
|
@@ -16226,11 +16783,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16226
16783
|
}
|
|
16227
16784
|
const { clearChatButton, clearChatButtonWrapper } = panelElements;
|
|
16228
16785
|
if (clearChatButton) {
|
|
16229
|
-
const clearChatConfig = (
|
|
16230
|
-
const clearChatEnabled = (
|
|
16231
|
-
const layoutShowClearChat = (
|
|
16786
|
+
const clearChatConfig = (_ga = launcher.clearChat) != null ? _ga : {};
|
|
16787
|
+
const clearChatEnabled = (_ha = clearChatConfig.enabled) != null ? _ha : true;
|
|
16788
|
+
const layoutShowClearChat = (_ja = (_ia = config.layout) == null ? void 0 : _ia.header) == null ? void 0 : _ja.showClearChat;
|
|
16232
16789
|
const shouldShowClearChat = layoutShowClearChat !== void 0 ? layoutShowClearChat : clearChatEnabled;
|
|
16233
|
-
const clearChatPlacement = (
|
|
16790
|
+
const clearChatPlacement = (_ka = clearChatConfig.placement) != null ? _ka : "inline";
|
|
16234
16791
|
if (clearChatButtonWrapper) {
|
|
16235
16792
|
clearChatButtonWrapper.style.display = shouldShowClearChat ? "" : "none";
|
|
16236
16793
|
const { closeButtonWrapper } = panelElements;
|
|
@@ -16272,11 +16829,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16272
16829
|
}
|
|
16273
16830
|
}
|
|
16274
16831
|
if (shouldShowClearChat) {
|
|
16275
|
-
const clearChatSize = (
|
|
16832
|
+
const clearChatSize = (_la = clearChatConfig.size) != null ? _la : "32px";
|
|
16276
16833
|
clearChatButton.style.height = clearChatSize;
|
|
16277
16834
|
clearChatButton.style.width = clearChatSize;
|
|
16278
|
-
const clearChatIconName = (
|
|
16279
|
-
const clearChatIconColor = (
|
|
16835
|
+
const clearChatIconName = (_ma = clearChatConfig.iconName) != null ? _ma : "refresh-cw";
|
|
16836
|
+
const clearChatIconColor = (_na = clearChatConfig.iconColor) != null ? _na : "";
|
|
16280
16837
|
clearChatButton.style.color = clearChatIconColor || HEADER_THEME_CSS.actionIconColor;
|
|
16281
16838
|
clearChatButton.innerHTML = "";
|
|
16282
16839
|
const iconSvg = renderLucideIcon(clearChatIconName, "20px", "currentColor", 2);
|
|
@@ -16320,8 +16877,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16320
16877
|
clearChatButton.style.paddingTop = "";
|
|
16321
16878
|
clearChatButton.style.paddingBottom = "";
|
|
16322
16879
|
}
|
|
16323
|
-
const clearChatTooltipText = (
|
|
16324
|
-
const clearChatShowTooltip = (
|
|
16880
|
+
const clearChatTooltipText = (_oa = clearChatConfig.tooltipText) != null ? _oa : "Clear chat";
|
|
16881
|
+
const clearChatShowTooltip = (_pa = clearChatConfig.showTooltip) != null ? _pa : true;
|
|
16325
16882
|
clearChatButton.setAttribute("aria-label", clearChatTooltipText);
|
|
16326
16883
|
if (clearChatButtonWrapper) {
|
|
16327
16884
|
if (clearChatButtonWrapper._cleanupTooltip) {
|
|
@@ -16397,9 +16954,9 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16397
16954
|
suggestionsManager.render(config.suggestionChips, session, textarea, void 0, config.suggestionChipsConfig);
|
|
16398
16955
|
updateCopy();
|
|
16399
16956
|
setComposerDisabled(session.isStreaming());
|
|
16400
|
-
const voiceRecognitionEnabled = ((
|
|
16957
|
+
const voiceRecognitionEnabled = ((_qa = config.voiceRecognition) == null ? void 0 : _qa.enabled) === true;
|
|
16401
16958
|
const hasSpeechRecognition = typeof window !== "undefined" && (typeof window.webkitSpeechRecognition !== "undefined" || typeof window.SpeechRecognition !== "undefined");
|
|
16402
|
-
const hasRuntypeProvider = ((
|
|
16959
|
+
const hasRuntypeProvider = ((_sa = (_ra = config.voiceRecognition) == null ? void 0 : _ra.provider) == null ? void 0 : _sa.type) === "runtype";
|
|
16403
16960
|
const hasVoiceInput = hasSpeechRecognition || hasRuntypeProvider;
|
|
16404
16961
|
if (voiceRecognitionEnabled && hasVoiceInput) {
|
|
16405
16962
|
if (!micButton || !micButtonWrapper) {
|
|
@@ -16412,17 +16969,17 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16412
16969
|
micButton.disabled = session.isStreaming();
|
|
16413
16970
|
}
|
|
16414
16971
|
} else {
|
|
16415
|
-
const voiceConfig = (
|
|
16416
|
-
const sendButtonConfig2 = (
|
|
16417
|
-
const micIconName = (
|
|
16418
|
-
const buttonSize2 = (
|
|
16419
|
-
const micIconSize = (
|
|
16972
|
+
const voiceConfig = (_ta = config.voiceRecognition) != null ? _ta : {};
|
|
16973
|
+
const sendButtonConfig2 = (_ua = config.sendButton) != null ? _ua : {};
|
|
16974
|
+
const micIconName = (_va = voiceConfig.iconName) != null ? _va : "mic";
|
|
16975
|
+
const buttonSize2 = (_wa = sendButtonConfig2.size) != null ? _wa : "40px";
|
|
16976
|
+
const micIconSize = (_xa = voiceConfig.iconSize) != null ? _xa : buttonSize2;
|
|
16420
16977
|
const micIconSizeNum = parseFloat(micIconSize) || 24;
|
|
16421
16978
|
micButton.style.width = micIconSize;
|
|
16422
16979
|
micButton.style.height = micIconSize;
|
|
16423
16980
|
micButton.style.minWidth = micIconSize;
|
|
16424
16981
|
micButton.style.minHeight = micIconSize;
|
|
16425
|
-
const iconColor = (
|
|
16982
|
+
const iconColor = (_za = (_ya = voiceConfig.iconColor) != null ? _ya : sendButtonConfig2.textColor) != null ? _za : "currentColor";
|
|
16426
16983
|
micButton.innerHTML = "";
|
|
16427
16984
|
const micIconSvg = renderLucideIcon(micIconName, micIconSizeNum, iconColor, 2);
|
|
16428
16985
|
if (micIconSvg) {
|
|
@@ -16430,7 +16987,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16430
16987
|
} else {
|
|
16431
16988
|
micButton.textContent = "\u{1F3A4}";
|
|
16432
16989
|
}
|
|
16433
|
-
const backgroundColor2 = (
|
|
16990
|
+
const backgroundColor2 = (_Aa = voiceConfig.backgroundColor) != null ? _Aa : sendButtonConfig2.backgroundColor;
|
|
16434
16991
|
if (backgroundColor2) {
|
|
16435
16992
|
micButton.style.backgroundColor = backgroundColor2;
|
|
16436
16993
|
} else {
|
|
@@ -16468,8 +17025,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16468
17025
|
micButton.style.paddingBottom = "";
|
|
16469
17026
|
}
|
|
16470
17027
|
const tooltip2 = micButtonWrapper == null ? void 0 : micButtonWrapper.querySelector(".persona-send-button-tooltip");
|
|
16471
|
-
const tooltipText2 = (
|
|
16472
|
-
const showTooltip2 = (
|
|
17028
|
+
const tooltipText2 = (_Ba = voiceConfig.tooltipText) != null ? _Ba : "Start voice recognition";
|
|
17029
|
+
const showTooltip2 = (_Ca = voiceConfig.showTooltip) != null ? _Ca : false;
|
|
16473
17030
|
if (showTooltip2 && tooltipText2) {
|
|
16474
17031
|
if (!tooltip2) {
|
|
16475
17032
|
const newTooltip = document.createElement("div");
|
|
@@ -16489,19 +17046,19 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16489
17046
|
} else {
|
|
16490
17047
|
if (micButton && micButtonWrapper) {
|
|
16491
17048
|
micButtonWrapper.style.display = "none";
|
|
16492
|
-
if (((
|
|
17049
|
+
if (((_Ea = (_Da = config.voiceRecognition) == null ? void 0 : _Da.provider) == null ? void 0 : _Ea.type) === "runtype") {
|
|
16493
17050
|
if (session.isVoiceActive()) session.toggleVoice();
|
|
16494
17051
|
} else if (isRecording) {
|
|
16495
17052
|
stopVoiceRecognition();
|
|
16496
17053
|
}
|
|
16497
17054
|
}
|
|
16498
17055
|
}
|
|
16499
|
-
const attachmentsEnabled = ((
|
|
17056
|
+
const attachmentsEnabled = ((_Fa = config.attachments) == null ? void 0 : _Fa.enabled) === true;
|
|
16500
17057
|
if (attachmentsEnabled) {
|
|
16501
17058
|
if (!attachmentButtonWrapper || !attachmentButton) {
|
|
16502
|
-
const attachmentsConfig = (
|
|
16503
|
-
const sendButtonConfig2 = (
|
|
16504
|
-
const buttonSize2 = (
|
|
17059
|
+
const attachmentsConfig = (_Ga = config.attachments) != null ? _Ga : {};
|
|
17060
|
+
const sendButtonConfig2 = (_Ha = config.sendButton) != null ? _Ha : {};
|
|
17061
|
+
const buttonSize2 = (_Ia = sendButtonConfig2.size) != null ? _Ia : "40px";
|
|
16505
17062
|
if (!attachmentPreviewsContainer) {
|
|
16506
17063
|
attachmentPreviewsContainer = createElement("div", "persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2");
|
|
16507
17064
|
attachmentPreviewsContainer.style.display = "none";
|
|
@@ -16510,8 +17067,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16510
17067
|
if (!attachmentInput) {
|
|
16511
17068
|
attachmentInput = document.createElement("input");
|
|
16512
17069
|
attachmentInput.type = "file";
|
|
16513
|
-
attachmentInput.accept = ((
|
|
16514
|
-
attachmentInput.multiple = ((
|
|
17070
|
+
attachmentInput.accept = ((_Ja = attachmentsConfig.allowedTypes) != null ? _Ja : ALL_SUPPORTED_MIME_TYPES).join(",");
|
|
17071
|
+
attachmentInput.multiple = ((_Ka = attachmentsConfig.maxFiles) != null ? _Ka : 4) > 1;
|
|
16515
17072
|
attachmentInput.style.display = "none";
|
|
16516
17073
|
attachmentInput.setAttribute("aria-label", "Attach files");
|
|
16517
17074
|
composerForm.insertBefore(attachmentInput, textarea);
|
|
@@ -16522,8 +17079,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16522
17079
|
"persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-attachment-button"
|
|
16523
17080
|
);
|
|
16524
17081
|
attachmentButton.type = "button";
|
|
16525
|
-
attachmentButton.setAttribute("aria-label", (
|
|
16526
|
-
const attachIconName = (
|
|
17082
|
+
attachmentButton.setAttribute("aria-label", (_La = attachmentsConfig.buttonTooltipText) != null ? _La : "Attach file");
|
|
17083
|
+
const attachIconName = (_Ma = attachmentsConfig.buttonIconName) != null ? _Ma : "paperclip";
|
|
16527
17084
|
const attachIconSize = buttonSize2;
|
|
16528
17085
|
const buttonSizeNum = parseFloat(attachIconSize) || 40;
|
|
16529
17086
|
const attachIconSizeNum = Math.round(buttonSizeNum * 0.6);
|
|
@@ -16555,7 +17112,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16555
17112
|
attachmentInput == null ? void 0 : attachmentInput.click();
|
|
16556
17113
|
});
|
|
16557
17114
|
attachmentButtonWrapper.appendChild(attachmentButton);
|
|
16558
|
-
const attachTooltipText = (
|
|
17115
|
+
const attachTooltipText = (_Na = attachmentsConfig.buttonTooltipText) != null ? _Na : "Attach file";
|
|
16559
17116
|
const tooltip2 = createElement("div", "persona-send-button-tooltip");
|
|
16560
17117
|
tooltip2.textContent = attachTooltipText;
|
|
16561
17118
|
attachmentButtonWrapper.appendChild(tooltip2);
|
|
@@ -16570,12 +17127,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16570
17127
|
}
|
|
16571
17128
|
});
|
|
16572
17129
|
}
|
|
17130
|
+
if (!container.querySelector(".persona-attachment-drop-overlay")) {
|
|
17131
|
+
container.appendChild(buildDropOverlay(attachmentsConfig.dropOverlay));
|
|
17132
|
+
}
|
|
16573
17133
|
} else {
|
|
16574
17134
|
attachmentButtonWrapper.style.display = "";
|
|
16575
|
-
const attachmentsConfig = (
|
|
17135
|
+
const attachmentsConfig = (_Oa = config.attachments) != null ? _Oa : {};
|
|
16576
17136
|
if (attachmentInput) {
|
|
16577
|
-
attachmentInput.accept = ((
|
|
16578
|
-
attachmentInput.multiple = ((
|
|
17137
|
+
attachmentInput.accept = ((_Pa = attachmentsConfig.allowedTypes) != null ? _Pa : ALL_SUPPORTED_MIME_TYPES).join(",");
|
|
17138
|
+
attachmentInput.multiple = ((_Qa = attachmentsConfig.maxFiles) != null ? _Qa : 4) > 1;
|
|
16579
17139
|
}
|
|
16580
17140
|
if (attachmentManager) {
|
|
16581
17141
|
attachmentManager.updateConfig({
|
|
@@ -16592,14 +17152,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16592
17152
|
if (attachmentManager) {
|
|
16593
17153
|
attachmentManager.clearAttachments();
|
|
16594
17154
|
}
|
|
17155
|
+
(_Ra = container.querySelector(".persona-attachment-drop-overlay")) == null ? void 0 : _Ra.remove();
|
|
16595
17156
|
}
|
|
16596
|
-
const sendButtonConfig = (
|
|
16597
|
-
const useIcon = (
|
|
16598
|
-
const iconText = (
|
|
17157
|
+
const sendButtonConfig = (_Sa = config.sendButton) != null ? _Sa : {};
|
|
17158
|
+
const useIcon = (_Ta = sendButtonConfig.useIcon) != null ? _Ta : false;
|
|
17159
|
+
const iconText = (_Ua = sendButtonConfig.iconText) != null ? _Ua : "\u2191";
|
|
16599
17160
|
const iconName = sendButtonConfig.iconName;
|
|
16600
|
-
const tooltipText = (
|
|
16601
|
-
const showTooltip = (
|
|
16602
|
-
const buttonSize = (
|
|
17161
|
+
const tooltipText = (_Va = sendButtonConfig.tooltipText) != null ? _Va : "Send message";
|
|
17162
|
+
const showTooltip = (_Wa = sendButtonConfig.showTooltip) != null ? _Wa : false;
|
|
17163
|
+
const buttonSize = (_Xa = sendButtonConfig.size) != null ? _Xa : "40px";
|
|
16603
17164
|
const backgroundColor = sendButtonConfig.backgroundColor;
|
|
16604
17165
|
const textColor = sendButtonConfig.textColor;
|
|
16605
17166
|
if (useIcon) {
|
|
@@ -16636,7 +17197,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16636
17197
|
sendButton.classList.add("persona-bg-persona-primary");
|
|
16637
17198
|
}
|
|
16638
17199
|
} else {
|
|
16639
|
-
sendButton.textContent = (
|
|
17200
|
+
sendButton.textContent = (_Za = (_Ya = config.copy) == null ? void 0 : _Ya.sendButtonLabel) != null ? _Za : "Send";
|
|
16640
17201
|
sendButton.style.width = "";
|
|
16641
17202
|
sendButton.style.height = "";
|
|
16642
17203
|
sendButton.style.minWidth = "";
|
|
@@ -16696,7 +17257,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16696
17257
|
} else if (tooltip) {
|
|
16697
17258
|
tooltip.style.display = "none";
|
|
16698
17259
|
}
|
|
16699
|
-
const updatedContentMaxWidth = (
|
|
17260
|
+
const updatedContentMaxWidth = (__a = config.layout) == null ? void 0 : __a.contentMaxWidth;
|
|
16700
17261
|
if (updatedContentMaxWidth) {
|
|
16701
17262
|
messagesWrapper.style.maxWidth = updatedContentMaxWidth;
|
|
16702
17263
|
messagesWrapper.style.marginLeft = "auto";
|
|
@@ -16728,8 +17289,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16728
17289
|
suggestions.style.marginRight = "";
|
|
16729
17290
|
}
|
|
16730
17291
|
}
|
|
16731
|
-
const statusIndicatorConfig = (
|
|
16732
|
-
const isVisible = (
|
|
17292
|
+
const statusIndicatorConfig = (_$a = config.statusIndicator) != null ? _$a : {};
|
|
17293
|
+
const isVisible = (_ab = statusIndicatorConfig.visible) != null ? _ab : true;
|
|
16733
17294
|
statusText.style.display = isVisible ? "" : "none";
|
|
16734
17295
|
if (session) {
|
|
16735
17296
|
const currentStatus = session.getStatus();
|
|
@@ -17785,7 +18346,166 @@ function buildSrcdoc(mountId, shellMode, docked, widgetCssPath) {
|
|
|
17785
18346
|
</body>
|
|
17786
18347
|
</html>`;
|
|
17787
18348
|
}
|
|
17788
|
-
|
|
18349
|
+
var PREVIEW_TRANSCRIPT_PRESET_LABELS = {
|
|
18350
|
+
"user-message": "User message",
|
|
18351
|
+
"assistant-message": "Assistant message",
|
|
18352
|
+
"reasoning-streaming": "Reasoning (streaming)",
|
|
18353
|
+
"reasoning-complete": "Reasoning (complete)",
|
|
18354
|
+
"tool-running": "Tool call (running)",
|
|
18355
|
+
"tool-complete": "Tool call (complete)"
|
|
18356
|
+
};
|
|
18357
|
+
function getPreviewTranscriptPresetLabel(preset) {
|
|
18358
|
+
return PREVIEW_TRANSCRIPT_PRESET_LABELS[preset];
|
|
18359
|
+
}
|
|
18360
|
+
function createPreviewTranscriptEntry(preset, index = 0) {
|
|
18361
|
+
const createdAt = new Date(Date.now() - Math.max(0, 60 - index) * 1e3).toISOString();
|
|
18362
|
+
const suffix = `${preset}-${index}`;
|
|
18363
|
+
switch (preset) {
|
|
18364
|
+
case "user-message":
|
|
18365
|
+
return {
|
|
18366
|
+
id: `preview-seq-user-${suffix}`,
|
|
18367
|
+
role: "user",
|
|
18368
|
+
content: "Can you continue with the next step?",
|
|
18369
|
+
createdAt
|
|
18370
|
+
};
|
|
18371
|
+
case "assistant-message":
|
|
18372
|
+
return {
|
|
18373
|
+
id: `preview-seq-assistant-${suffix}`,
|
|
18374
|
+
role: "assistant",
|
|
18375
|
+
content: "Absolutely. I can keep going and explain what happens next.",
|
|
18376
|
+
createdAt
|
|
18377
|
+
};
|
|
18378
|
+
case "reasoning-streaming":
|
|
18379
|
+
return {
|
|
18380
|
+
id: `preview-seq-reasoning-stream-${suffix}`,
|
|
18381
|
+
role: "assistant",
|
|
18382
|
+
content: "",
|
|
18383
|
+
createdAt,
|
|
18384
|
+
streaming: true,
|
|
18385
|
+
variant: "reasoning",
|
|
18386
|
+
reasoning: {
|
|
18387
|
+
id: `preview-reasoning-stream-${suffix}`,
|
|
18388
|
+
status: "streaming",
|
|
18389
|
+
chunks: ["Thinking through the next step in the workflow..."]
|
|
18390
|
+
}
|
|
18391
|
+
};
|
|
18392
|
+
case "reasoning-complete":
|
|
18393
|
+
return {
|
|
18394
|
+
id: `preview-seq-reasoning-complete-${suffix}`,
|
|
18395
|
+
role: "assistant",
|
|
18396
|
+
content: "",
|
|
18397
|
+
createdAt,
|
|
18398
|
+
streaming: false,
|
|
18399
|
+
variant: "reasoning",
|
|
18400
|
+
reasoning: {
|
|
18401
|
+
id: `preview-reasoning-complete-${suffix}`,
|
|
18402
|
+
status: "complete",
|
|
18403
|
+
chunks: ["Reviewed the requirements and finalized the reasoning output."],
|
|
18404
|
+
durationMs: 1200
|
|
18405
|
+
}
|
|
18406
|
+
};
|
|
18407
|
+
case "tool-complete":
|
|
18408
|
+
return {
|
|
18409
|
+
id: `preview-seq-tool-complete-${suffix}`,
|
|
18410
|
+
role: "assistant",
|
|
18411
|
+
content: "",
|
|
18412
|
+
createdAt,
|
|
18413
|
+
streaming: false,
|
|
18414
|
+
variant: "tool",
|
|
18415
|
+
toolCall: {
|
|
18416
|
+
id: `preview-tool-complete-${suffix}`,
|
|
18417
|
+
name: "Create build instructions",
|
|
18418
|
+
status: "complete",
|
|
18419
|
+
chunks: ["Prepared the build instructions and validated the inputs."],
|
|
18420
|
+
result: { ok: true },
|
|
18421
|
+
duration: 420
|
|
18422
|
+
}
|
|
18423
|
+
};
|
|
18424
|
+
case "tool-running":
|
|
18425
|
+
default:
|
|
18426
|
+
return {
|
|
18427
|
+
id: `preview-seq-tool-running-${suffix}`,
|
|
18428
|
+
role: "assistant",
|
|
18429
|
+
content: "",
|
|
18430
|
+
createdAt,
|
|
18431
|
+
streaming: true,
|
|
18432
|
+
variant: "tool",
|
|
18433
|
+
toolCall: {
|
|
18434
|
+
id: `preview-tool-running-${suffix}`,
|
|
18435
|
+
name: "Get platform documentation",
|
|
18436
|
+
status: "running",
|
|
18437
|
+
chunks: ["Fetching the relevant platform documentation..."]
|
|
18438
|
+
}
|
|
18439
|
+
};
|
|
18440
|
+
}
|
|
18441
|
+
}
|
|
18442
|
+
function appendPreviewTranscriptEntry(messages, preset) {
|
|
18443
|
+
return [...messages, createPreviewTranscriptEntry(preset, messages.length)];
|
|
18444
|
+
}
|
|
18445
|
+
var createAdvancedTranscriptPreviewMessages = () => [
|
|
18446
|
+
{
|
|
18447
|
+
id: "preview-adv-1",
|
|
18448
|
+
role: "user",
|
|
18449
|
+
content: "Can you create the product and gather the docs?",
|
|
18450
|
+
createdAt: new Date(Date.now() - 18e4).toISOString()
|
|
18451
|
+
},
|
|
18452
|
+
{
|
|
18453
|
+
id: "preview-adv-2",
|
|
18454
|
+
role: "assistant",
|
|
18455
|
+
content: "",
|
|
18456
|
+
createdAt: new Date(Date.now() - 15e4).toISOString(),
|
|
18457
|
+
streaming: true,
|
|
18458
|
+
variant: "reasoning",
|
|
18459
|
+
reasoning: {
|
|
18460
|
+
id: "preview-reasoning",
|
|
18461
|
+
status: "streaming",
|
|
18462
|
+
chunks: [
|
|
18463
|
+
"Now let me get the Persona embed documentation and builtin tools catalog."
|
|
18464
|
+
]
|
|
18465
|
+
}
|
|
18466
|
+
},
|
|
18467
|
+
{
|
|
18468
|
+
id: "preview-adv-3",
|
|
18469
|
+
role: "assistant",
|
|
18470
|
+
content: "",
|
|
18471
|
+
createdAt: new Date(Date.now() - 12e4).toISOString(),
|
|
18472
|
+
streaming: true,
|
|
18473
|
+
variant: "tool",
|
|
18474
|
+
toolCall: {
|
|
18475
|
+
id: "preview-tool-1",
|
|
18476
|
+
name: "Load tools",
|
|
18477
|
+
status: "running",
|
|
18478
|
+
chunks: ["Loaded tools, used Runtype integration"]
|
|
18479
|
+
}
|
|
18480
|
+
},
|
|
18481
|
+
{
|
|
18482
|
+
id: "preview-adv-4",
|
|
18483
|
+
role: "assistant",
|
|
18484
|
+
content: "",
|
|
18485
|
+
createdAt: new Date(Date.now() - 9e4).toISOString(),
|
|
18486
|
+
streaming: true,
|
|
18487
|
+
variant: "tool",
|
|
18488
|
+
toolCall: {
|
|
18489
|
+
id: "preview-tool-2",
|
|
18490
|
+
name: "Get platform documentation",
|
|
18491
|
+
status: "running",
|
|
18492
|
+
chunks: ["Get platform documentation"]
|
|
18493
|
+
}
|
|
18494
|
+
},
|
|
18495
|
+
{
|
|
18496
|
+
id: "preview-adv-5",
|
|
18497
|
+
role: "assistant",
|
|
18498
|
+
content: "I loaded the tools and fetched the docs. Next I can assemble the product details.",
|
|
18499
|
+
createdAt: new Date(Date.now() - 3e4).toISOString()
|
|
18500
|
+
}
|
|
18501
|
+
];
|
|
18502
|
+
var shouldSeedAdvancedTranscriptPreview = (config) => {
|
|
18503
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
18504
|
+
return Boolean(
|
|
18505
|
+
((_b = (_a = config == null ? void 0 : config.features) == null ? void 0 : _a.toolCallDisplay) == null ? void 0 : _b.activePreview) || ((_d = (_c = config == null ? void 0 : config.features) == null ? void 0 : _c.toolCallDisplay) == null ? void 0 : _d.grouped) || ((_f = (_e = config == null ? void 0 : config.features) == null ? void 0 : _e.toolCallDisplay) == null ? void 0 : _f.collapsedMode) && config.features.toolCallDisplay.collapsedMode !== "tool-call" || ((_h = (_g = config == null ? void 0 : config.features) == null ? void 0 : _g.reasoningDisplay) == null ? void 0 : _h.activePreview)
|
|
18506
|
+
);
|
|
18507
|
+
};
|
|
18508
|
+
function createPreviewMessages(scene, config, appendedMessages = []) {
|
|
17789
18509
|
if (scene === "home") {
|
|
17790
18510
|
return [{ id: "preview-home-1", role: "assistant", content: "Hi there! How can we help today?", createdAt: (/* @__PURE__ */ new Date()).toISOString() }];
|
|
17791
18511
|
}
|
|
@@ -17798,20 +18518,24 @@ function createPreviewMessages(scene) {
|
|
|
17798
18518
|
{ id: "preview-art-2", role: "assistant", content: "Here\u2019s a project overview document for you.", createdAt: new Date(Date.now() - 6e4).toISOString() }
|
|
17799
18519
|
];
|
|
17800
18520
|
}
|
|
18521
|
+
if (scene === "conversation" && shouldSeedAdvancedTranscriptPreview(config)) {
|
|
18522
|
+
return [...createAdvancedTranscriptPreviewMessages(), ...appendedMessages];
|
|
18523
|
+
}
|
|
17801
18524
|
return [
|
|
17802
18525
|
{ id: "preview-conv-1", role: "assistant", content: "Hello! How can I help you today?", createdAt: new Date(Date.now() - 18e4).toISOString() },
|
|
17803
18526
|
{ id: "preview-conv-2", role: "user", content: "I want to customize the theme editor preview.", createdAt: new Date(Date.now() - 12e4).toISOString() },
|
|
17804
|
-
{ id: "preview-conv-3", role: "assistant", content: "Absolutely. Check out the [getting started guide](https://example.com) to see what\u2019s possible, then adjust colors and tokens to match your brand.", createdAt: new Date(Date.now() - 6e4).toISOString() }
|
|
18527
|
+
{ id: "preview-conv-3", role: "assistant", content: "Absolutely. Check out the [getting started guide](https://example.com) to see what\u2019s possible, then adjust colors and tokens to match your brand.", createdAt: new Date(Date.now() - 6e4).toISOString() },
|
|
18528
|
+
...appendedMessages
|
|
17805
18529
|
];
|
|
17806
18530
|
}
|
|
17807
|
-
function applySceneConfig(base, scene) {
|
|
18531
|
+
function applySceneConfig(base, scene, appendedMessages = []) {
|
|
17808
18532
|
var _a, _b;
|
|
17809
18533
|
const launcher = { ...base.launcher, enabled: true, autoExpand: scene !== "minimized" };
|
|
17810
18534
|
const config = {
|
|
17811
18535
|
...base,
|
|
17812
18536
|
launcher,
|
|
17813
18537
|
suggestionChips: scene === "home" ? ((_a = base.suggestionChips) == null ? void 0 : _a.length) ? base.suggestionChips : HOME_SUGGESTION_CHIPS : base.suggestionChips,
|
|
17814
|
-
initialMessages: createPreviewMessages(scene),
|
|
18538
|
+
initialMessages: createPreviewMessages(scene, base, appendedMessages),
|
|
17815
18539
|
storageAdapter: PREVIEW_STORAGE_ADAPTER
|
|
17816
18540
|
};
|
|
17817
18541
|
if (scene === "artifact") {
|
|
@@ -17820,6 +18544,19 @@ function applySceneConfig(base, scene) {
|
|
|
17820
18544
|
return config;
|
|
17821
18545
|
}
|
|
17822
18546
|
function buildPreviewConfig(options, shellModeOverride) {
|
|
18547
|
+
var _a, _b, _c, _d;
|
|
18548
|
+
const theme = options.theme ? createTheme(options.theme, { validate: false }) : createTheme();
|
|
18549
|
+
const scene = (_a = options.scene) != null ? _a : "conversation";
|
|
18550
|
+
const base = {
|
|
18551
|
+
...DEFAULT_WIDGET_CONFIG,
|
|
18552
|
+
...options.config,
|
|
18553
|
+
theme,
|
|
18554
|
+
darkTheme: options.darkTheme,
|
|
18555
|
+
colorScheme: (_c = shellModeOverride != null ? shellModeOverride : (_b = options.config) == null ? void 0 : _b.colorScheme) != null ? _c : "light"
|
|
18556
|
+
};
|
|
18557
|
+
return applySceneConfig(base, scene, (_d = options.appendedMessages) != null ? _d : []);
|
|
18558
|
+
}
|
|
18559
|
+
function buildPreviewConfigWithMessages(options, messages, shellModeOverride) {
|
|
17823
18560
|
var _a, _b, _c;
|
|
17824
18561
|
const theme = options.theme ? createTheme(options.theme, { validate: false }) : createTheme();
|
|
17825
18562
|
const scene = (_a = options.scene) != null ? _a : "conversation";
|
|
@@ -17830,7 +18567,7 @@ function buildPreviewConfig(options, shellModeOverride) {
|
|
|
17830
18567
|
darkTheme: options.darkTheme,
|
|
17831
18568
|
colorScheme: (_c = shellModeOverride != null ? shellModeOverride : (_b = options.config) == null ? void 0 : _b.colorScheme) != null ? _c : "light"
|
|
17832
18569
|
};
|
|
17833
|
-
return applySceneConfig(base, scene);
|
|
18570
|
+
return applySceneConfig(base, scene, messages);
|
|
17834
18571
|
}
|
|
17835
18572
|
|
|
17836
18573
|
// src/theme-editor/preview.ts
|
|
@@ -18147,20 +18884,24 @@ export {
|
|
|
18147
18884
|
ThemeEditorState,
|
|
18148
18885
|
ZOOM_MAX,
|
|
18149
18886
|
ZOOM_MIN,
|
|
18887
|
+
appendPreviewTranscriptEntry,
|
|
18150
18888
|
applySceneConfig,
|
|
18151
18889
|
applyShellTheme,
|
|
18152
18890
|
buildPreviewConfig,
|
|
18891
|
+
buildPreviewConfigWithMessages,
|
|
18153
18892
|
buildShellCss,
|
|
18154
18893
|
buildSrcdoc,
|
|
18155
18894
|
convertFromPx,
|
|
18156
18895
|
convertToPx,
|
|
18157
18896
|
createPreviewMessages,
|
|
18897
|
+
createPreviewTranscriptEntry,
|
|
18158
18898
|
createThemePreview,
|
|
18159
18899
|
detectRoleAssignment,
|
|
18160
18900
|
escapeHtml2 as escapeHtml,
|
|
18161
18901
|
findSection,
|
|
18162
18902
|
formatCssValue,
|
|
18163
18903
|
generateColorScale,
|
|
18904
|
+
getPreviewTranscriptPresetLabel,
|
|
18164
18905
|
getShellPalette,
|
|
18165
18906
|
getThemeEditorPreset,
|
|
18166
18907
|
hexToHsl,
|