@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.cjs
CHANGED
|
@@ -73,20 +73,24 @@ __export(theme_editor_exports, {
|
|
|
73
73
|
ThemeEditorState: () => ThemeEditorState,
|
|
74
74
|
ZOOM_MAX: () => ZOOM_MAX,
|
|
75
75
|
ZOOM_MIN: () => ZOOM_MIN,
|
|
76
|
+
appendPreviewTranscriptEntry: () => appendPreviewTranscriptEntry,
|
|
76
77
|
applySceneConfig: () => applySceneConfig,
|
|
77
78
|
applyShellTheme: () => applyShellTheme,
|
|
78
79
|
buildPreviewConfig: () => buildPreviewConfig,
|
|
80
|
+
buildPreviewConfigWithMessages: () => buildPreviewConfigWithMessages,
|
|
79
81
|
buildShellCss: () => buildShellCss,
|
|
80
82
|
buildSrcdoc: () => buildSrcdoc,
|
|
81
83
|
convertFromPx: () => convertFromPx,
|
|
82
84
|
convertToPx: () => convertToPx,
|
|
83
85
|
createPreviewMessages: () => createPreviewMessages,
|
|
86
|
+
createPreviewTranscriptEntry: () => createPreviewTranscriptEntry,
|
|
84
87
|
createThemePreview: () => createThemePreview,
|
|
85
88
|
detectRoleAssignment: () => detectRoleAssignment,
|
|
86
89
|
escapeHtml: () => escapeHtml2,
|
|
87
90
|
findSection: () => findSection,
|
|
88
91
|
formatCssValue: () => formatCssValue,
|
|
89
92
|
generateColorScale: () => generateColorScale,
|
|
93
|
+
getPreviewTranscriptPresetLabel: () => getPreviewTranscriptPresetLabel,
|
|
90
94
|
getShellPalette: () => getShellPalette,
|
|
91
95
|
getThemeEditorPreset: () => getThemeEditorPreset,
|
|
92
96
|
hexToHsl: () => hexToHsl,
|
|
@@ -223,6 +227,18 @@ var DEFAULT_WIDGET_CONFIG = {
|
|
|
223
227
|
enabled: true,
|
|
224
228
|
iconName: "arrow-down",
|
|
225
229
|
label: ""
|
|
230
|
+
},
|
|
231
|
+
toolCallDisplay: {
|
|
232
|
+
collapsedMode: "tool-call",
|
|
233
|
+
activePreview: false,
|
|
234
|
+
grouped: false,
|
|
235
|
+
previewMaxLines: 3,
|
|
236
|
+
expandable: true
|
|
237
|
+
},
|
|
238
|
+
reasoningDisplay: {
|
|
239
|
+
activePreview: false,
|
|
240
|
+
previewMaxLines: 3,
|
|
241
|
+
expandable: true
|
|
226
242
|
}
|
|
227
243
|
},
|
|
228
244
|
suggestionChips: [
|
|
@@ -2702,6 +2718,16 @@ var debugSectionDef = {
|
|
|
2702
2718
|
fields: [
|
|
2703
2719
|
{ id: "dev-reasoning", label: "Show Reasoning", description: "Display AI reasoning steps", type: "toggle", path: "features.showReasoning", defaultValue: false },
|
|
2704
2720
|
{ id: "dev-tool-calls", label: "Show Tool Calls", description: "Display tool call details", type: "toggle", path: "features.showToolCalls", defaultValue: false },
|
|
2721
|
+
{ 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" }] },
|
|
2722
|
+
{ 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 },
|
|
2723
|
+
{ 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) },
|
|
2724
|
+
{ 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: "" },
|
|
2725
|
+
{ 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 },
|
|
2726
|
+
{ 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 },
|
|
2727
|
+
{ id: "dev-reasoning-expandable", label: "Reasoning Expandable", description: "Allow expanding reasoning rows to see full details", type: "toggle", path: "features.reasoningDisplay.expandable", defaultValue: true },
|
|
2728
|
+
{ 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 },
|
|
2729
|
+
{ 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) },
|
|
2730
|
+
{ 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: "" },
|
|
2705
2731
|
{ id: "dev-debug", label: "Debug Mode", description: "Show debug information", type: "toggle", path: "debug", defaultValue: false }
|
|
2706
2732
|
]
|
|
2707
2733
|
};
|
|
@@ -3501,6 +3527,24 @@ function getParserFromType(parserType) {
|
|
|
3501
3527
|
return createPlainTextParser;
|
|
3502
3528
|
}
|
|
3503
3529
|
}
|
|
3530
|
+
var looksStructured = (value) => value.startsWith("{") || value.startsWith("[") || value.startsWith("<");
|
|
3531
|
+
function preferFinalStructuredContent(rawBuffer, finalString) {
|
|
3532
|
+
if (!rawBuffer) return finalString;
|
|
3533
|
+
const rawTrimmed = rawBuffer.trim();
|
|
3534
|
+
const finalTrimmed = finalString.trim();
|
|
3535
|
+
if (rawTrimmed.length === 0) return finalString;
|
|
3536
|
+
if (finalTrimmed.length === 0) return rawBuffer;
|
|
3537
|
+
const rawLooksStructured = looksStructured(rawTrimmed);
|
|
3538
|
+
const finalLooksStructured = looksStructured(finalTrimmed);
|
|
3539
|
+
if (!finalLooksStructured) return rawBuffer;
|
|
3540
|
+
if (!rawLooksStructured) return finalString;
|
|
3541
|
+
if (finalTrimmed === rawTrimmed) return finalString;
|
|
3542
|
+
if (finalTrimmed.startsWith(rawTrimmed)) return finalString;
|
|
3543
|
+
const rawJsonText = extractTextFromJson(rawBuffer);
|
|
3544
|
+
const finalJsonText = extractTextFromJson(finalString);
|
|
3545
|
+
if (finalJsonText !== null && rawJsonText === null) return finalString;
|
|
3546
|
+
return rawBuffer;
|
|
3547
|
+
}
|
|
3504
3548
|
var AgentWidgetClient = class {
|
|
3505
3549
|
constructor(config = {}) {
|
|
3506
3550
|
this.config = config;
|
|
@@ -4219,7 +4263,7 @@ var AgentWidgetClient = class {
|
|
|
4219
4263
|
}
|
|
4220
4264
|
}
|
|
4221
4265
|
async streamResponse(body, onEvent, assistantMessageId) {
|
|
4222
|
-
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;
|
|
4266
|
+
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;
|
|
4223
4267
|
const reader = body.getReader();
|
|
4224
4268
|
const decoder = new TextDecoder();
|
|
4225
4269
|
let buffer = "";
|
|
@@ -4459,6 +4503,92 @@ var AgentWidgetClient = class {
|
|
|
4459
4503
|
};
|
|
4460
4504
|
const streamParsers = /* @__PURE__ */ new Map();
|
|
4461
4505
|
const rawContentBuffers = /* @__PURE__ */ new Map();
|
|
4506
|
+
const seqChunkBuffers = /* @__PURE__ */ new Map();
|
|
4507
|
+
const reasonSeqBuffers = /* @__PURE__ */ new Map();
|
|
4508
|
+
function insertSeqChunk(bufferMap, key, seq, text) {
|
|
4509
|
+
let buf = bufferMap.get(key);
|
|
4510
|
+
if (!buf) {
|
|
4511
|
+
buf = [];
|
|
4512
|
+
bufferMap.set(key, buf);
|
|
4513
|
+
}
|
|
4514
|
+
let lo = 0, hi = buf.length;
|
|
4515
|
+
while (lo < hi) {
|
|
4516
|
+
const mid = lo + hi >>> 1;
|
|
4517
|
+
if (buf[mid].seq < seq) lo = mid + 1;
|
|
4518
|
+
else hi = mid;
|
|
4519
|
+
}
|
|
4520
|
+
buf.splice(lo, 0, { seq, text });
|
|
4521
|
+
let result = "";
|
|
4522
|
+
for (let i = 0; i < buf.length; i++) result += buf[i].text;
|
|
4523
|
+
return result;
|
|
4524
|
+
}
|
|
4525
|
+
let lastSealedTextSegment = null;
|
|
4526
|
+
const reconcileSealedAssistantWithFinalResponse = (msg, finalContent) => {
|
|
4527
|
+
const finalString = ensureStringContent(finalContent);
|
|
4528
|
+
const rawBuffer = rawContentBuffers.get(msg.id);
|
|
4529
|
+
const contentToProcess = preferFinalStructuredContent(rawBuffer, finalString);
|
|
4530
|
+
msg.rawContent = contentToProcess;
|
|
4531
|
+
const parser = streamParsers.get(msg.id);
|
|
4532
|
+
const mergeIfBetter = (mergedDisplay) => {
|
|
4533
|
+
var _a2;
|
|
4534
|
+
const cur = (_a2 = msg.content) != null ? _a2 : "";
|
|
4535
|
+
if (mergedDisplay.trim() === "") return;
|
|
4536
|
+
if (cur.trim().length === 0 || mergedDisplay.startsWith(cur) || mergedDisplay.trimStart().startsWith(cur.trim())) {
|
|
4537
|
+
msg.content = mergedDisplay;
|
|
4538
|
+
}
|
|
4539
|
+
};
|
|
4540
|
+
const finalizeCleanup = () => {
|
|
4541
|
+
var _a2;
|
|
4542
|
+
if (parser) {
|
|
4543
|
+
const closeResult = (_a2 = parser.close) == null ? void 0 : _a2.call(parser);
|
|
4544
|
+
if (closeResult instanceof Promise) closeResult.catch(() => {
|
|
4545
|
+
});
|
|
4546
|
+
}
|
|
4547
|
+
streamParsers.delete(msg.id);
|
|
4548
|
+
rawContentBuffers.delete(msg.id);
|
|
4549
|
+
msg.streaming = false;
|
|
4550
|
+
emitMessage(msg);
|
|
4551
|
+
};
|
|
4552
|
+
if (!parser) {
|
|
4553
|
+
mergeIfBetter(finalString);
|
|
4554
|
+
finalizeCleanup();
|
|
4555
|
+
return;
|
|
4556
|
+
}
|
|
4557
|
+
const extractedFromJson = extractTextFromJson(contentToProcess);
|
|
4558
|
+
if (extractedFromJson !== null && extractedFromJson.trim() !== "") {
|
|
4559
|
+
mergeIfBetter(extractedFromJson);
|
|
4560
|
+
finalizeCleanup();
|
|
4561
|
+
return;
|
|
4562
|
+
}
|
|
4563
|
+
const bestDisplayText = (result) => {
|
|
4564
|
+
var _a2;
|
|
4565
|
+
const text = typeof result === "string" ? result : (_a2 = result == null ? void 0 : result.text) != null ? _a2 : null;
|
|
4566
|
+
if (text !== null && text.trim() !== "") return text;
|
|
4567
|
+
const extracted = parser.getExtractedText();
|
|
4568
|
+
if (extracted !== null && extracted.trim() !== "") return extracted;
|
|
4569
|
+
return finalString;
|
|
4570
|
+
};
|
|
4571
|
+
let parsedResult;
|
|
4572
|
+
try {
|
|
4573
|
+
parsedResult = parser.processChunk(contentToProcess);
|
|
4574
|
+
} catch {
|
|
4575
|
+
mergeIfBetter(finalString);
|
|
4576
|
+
finalizeCleanup();
|
|
4577
|
+
return;
|
|
4578
|
+
}
|
|
4579
|
+
if (parsedResult instanceof Promise) {
|
|
4580
|
+
parsedResult.then((result) => {
|
|
4581
|
+
mergeIfBetter(bestDisplayText(result));
|
|
4582
|
+
finalizeCleanup();
|
|
4583
|
+
}).catch(() => {
|
|
4584
|
+
mergeIfBetter(finalString);
|
|
4585
|
+
finalizeCleanup();
|
|
4586
|
+
});
|
|
4587
|
+
return;
|
|
4588
|
+
}
|
|
4589
|
+
mergeIfBetter(bestDisplayText(parsedResult));
|
|
4590
|
+
finalizeCleanup();
|
|
4591
|
+
};
|
|
4462
4592
|
let agentExecution = null;
|
|
4463
4593
|
const agentIterationMessages = /* @__PURE__ */ new Map();
|
|
4464
4594
|
const iterationDisplay = (_a = this.config.iterationDisplay) != null ? _a : "separate";
|
|
@@ -4532,7 +4662,13 @@ var AgentWidgetClient = class {
|
|
|
4532
4662
|
reasoningMessage.reasoning.startedAt = (_m = reasoningMessage.reasoning.startedAt) != null ? _m : resolveTimestamp((_l = payload.startedAt) != null ? _l : payload.timestamp);
|
|
4533
4663
|
const chunk = (_p = (_o = (_n = payload.reasoningText) != null ? _n : payload.text) != null ? _o : payload.delta) != null ? _p : "";
|
|
4534
4664
|
if (chunk && payload.hidden !== true) {
|
|
4535
|
-
|
|
4665
|
+
const reasonSeq = typeof payload.sequenceIndex === "number" ? payload.sequenceIndex : void 0;
|
|
4666
|
+
if (reasonSeq !== void 0) {
|
|
4667
|
+
const ordered = insertSeqChunk(reasonSeqBuffers, reasoningId, reasonSeq, String(chunk));
|
|
4668
|
+
reasoningMessage.reasoning.chunks = [ordered];
|
|
4669
|
+
} else {
|
|
4670
|
+
reasoningMessage.reasoning.chunks.push(String(chunk));
|
|
4671
|
+
}
|
|
4536
4672
|
}
|
|
4537
4673
|
reasoningMessage.reasoning.status = payload.done ? "complete" : "streaming";
|
|
4538
4674
|
if (payload.done) {
|
|
@@ -4544,6 +4680,7 @@ var AgentWidgetClient = class {
|
|
|
4544
4680
|
0,
|
|
4545
4681
|
((_s = reasoningMessage.reasoning.completedAt) != null ? _s : Date.now()) - start
|
|
4546
4682
|
);
|
|
4683
|
+
reasonSeqBuffers.delete(reasoningId);
|
|
4547
4684
|
}
|
|
4548
4685
|
reasoningMessage.streaming = reasoningMessage.reasoning.status !== "complete";
|
|
4549
4686
|
emitMessage(reasoningMessage);
|
|
@@ -4561,6 +4698,7 @@ var AgentWidgetClient = class {
|
|
|
4561
4698
|
((_x = reasoningMessage.reasoning.completedAt) != null ? _x : Date.now()) - start
|
|
4562
4699
|
);
|
|
4563
4700
|
reasoningMessage.streaming = false;
|
|
4701
|
+
reasonSeqBuffers.delete(reasoningId);
|
|
4564
4702
|
emitMessage(reasoningMessage);
|
|
4565
4703
|
}
|
|
4566
4704
|
const stepKey = getStepKey(payload);
|
|
@@ -4676,6 +4814,7 @@ var AgentWidgetClient = class {
|
|
|
4676
4814
|
if (prev) {
|
|
4677
4815
|
prev.streaming = false;
|
|
4678
4816
|
emitMessage(prev);
|
|
4817
|
+
lastSealedTextSegment = prev;
|
|
4679
4818
|
assistantMessage = null;
|
|
4680
4819
|
didSplitByPartId = true;
|
|
4681
4820
|
}
|
|
@@ -4688,6 +4827,7 @@ var AgentWidgetClient = class {
|
|
|
4688
4827
|
if (prev) {
|
|
4689
4828
|
prev.streaming = false;
|
|
4690
4829
|
emitMessage(prev);
|
|
4830
|
+
lastSealedTextSegment = prev;
|
|
4691
4831
|
assistantMessage = null;
|
|
4692
4832
|
didSplitByPartId = true;
|
|
4693
4833
|
}
|
|
@@ -4703,6 +4843,7 @@ var AgentWidgetClient = class {
|
|
|
4703
4843
|
if (prev) {
|
|
4704
4844
|
prev.streaming = false;
|
|
4705
4845
|
emitMessage(prev);
|
|
4846
|
+
lastSealedTextSegment = prev;
|
|
4706
4847
|
assistantMessage = null;
|
|
4707
4848
|
didSplitByPartId = true;
|
|
4708
4849
|
}
|
|
@@ -4716,8 +4857,14 @@ var AgentWidgetClient = class {
|
|
|
4716
4857
|
}
|
|
4717
4858
|
const chunk = (_ca = (_ba = (_aa = (_$ = payload.text) != null ? _$ : payload.delta) != null ? _aa : payload.content) != null ? _ba : payload.chunk) != null ? _ca : "";
|
|
4718
4859
|
if (chunk) {
|
|
4719
|
-
const
|
|
4720
|
-
|
|
4860
|
+
const chunkSeq = typeof payload.seq === "number" ? payload.seq : void 0;
|
|
4861
|
+
let accumulatedRaw;
|
|
4862
|
+
if (chunkSeq !== void 0) {
|
|
4863
|
+
accumulatedRaw = insertSeqChunk(seqChunkBuffers, assistant.id, chunkSeq, chunk);
|
|
4864
|
+
} else {
|
|
4865
|
+
const rawBuffer = (_da = rawContentBuffers.get(assistant.id)) != null ? _da : "";
|
|
4866
|
+
accumulatedRaw = rawBuffer + chunk;
|
|
4867
|
+
}
|
|
4721
4868
|
assistant.rawContent = accumulatedRaw;
|
|
4722
4869
|
if (!streamParsers.has(assistant.id)) {
|
|
4723
4870
|
streamParsers.set(assistant.id, this.createStreamParser());
|
|
@@ -4729,7 +4876,11 @@ var AgentWidgetClient = class {
|
|
|
4729
4876
|
}
|
|
4730
4877
|
const isPlainTextParser = parser.__isPlainTextParser === true;
|
|
4731
4878
|
if (isPlainTextParser) {
|
|
4732
|
-
|
|
4879
|
+
if (chunkSeq !== void 0) {
|
|
4880
|
+
assistant.content = accumulatedRaw;
|
|
4881
|
+
} else {
|
|
4882
|
+
assistant.content += chunk;
|
|
4883
|
+
}
|
|
4733
4884
|
rawContentBuffers.delete(assistant.id);
|
|
4734
4885
|
streamParsers.delete(assistant.id);
|
|
4735
4886
|
assistant.rawContent = void 0;
|
|
@@ -4742,15 +4893,16 @@ var AgentWidgetClient = class {
|
|
|
4742
4893
|
var _a2;
|
|
4743
4894
|
const text = typeof result === "string" ? result : (_a2 = result == null ? void 0 : result.text) != null ? _a2 : null;
|
|
4744
4895
|
if (text !== null && text.trim() !== "") {
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
currentAssistant.content = text;
|
|
4748
|
-
emitMessage(currentAssistant);
|
|
4749
|
-
}
|
|
4896
|
+
assistant.content = text;
|
|
4897
|
+
emitMessage(assistant);
|
|
4750
4898
|
} else if (!looksLikeJson && !accumulatedRaw.trim().startsWith("<")) {
|
|
4751
4899
|
const currentAssistant = assistantMessage;
|
|
4752
4900
|
if (currentAssistant && currentAssistant.id === assistant.id) {
|
|
4753
|
-
|
|
4901
|
+
if (chunkSeq !== void 0) {
|
|
4902
|
+
currentAssistant.content = accumulatedRaw;
|
|
4903
|
+
} else {
|
|
4904
|
+
currentAssistant.content += chunk;
|
|
4905
|
+
}
|
|
4754
4906
|
rawContentBuffers.delete(currentAssistant.id);
|
|
4755
4907
|
streamParsers.delete(currentAssistant.id);
|
|
4756
4908
|
currentAssistant.rawContent = void 0;
|
|
@@ -4758,7 +4910,11 @@ var AgentWidgetClient = class {
|
|
|
4758
4910
|
}
|
|
4759
4911
|
}
|
|
4760
4912
|
}).catch(() => {
|
|
4761
|
-
|
|
4913
|
+
if (chunkSeq !== void 0) {
|
|
4914
|
+
assistant.content = accumulatedRaw;
|
|
4915
|
+
} else {
|
|
4916
|
+
assistant.content += chunk;
|
|
4917
|
+
}
|
|
4762
4918
|
rawContentBuffers.delete(assistant.id);
|
|
4763
4919
|
streamParsers.delete(assistant.id);
|
|
4764
4920
|
assistant.rawContent = void 0;
|
|
@@ -4770,7 +4926,11 @@ var AgentWidgetClient = class {
|
|
|
4770
4926
|
assistant.content = text;
|
|
4771
4927
|
emitMessage(assistant);
|
|
4772
4928
|
} else if (!looksLikeJson && !accumulatedRaw.trim().startsWith("<")) {
|
|
4773
|
-
|
|
4929
|
+
if (chunkSeq !== void 0) {
|
|
4930
|
+
assistant.content = accumulatedRaw;
|
|
4931
|
+
} else {
|
|
4932
|
+
assistant.content += chunk;
|
|
4933
|
+
}
|
|
4774
4934
|
rawContentBuffers.delete(assistant.id);
|
|
4775
4935
|
streamParsers.delete(assistant.id);
|
|
4776
4936
|
assistant.rawContent = void 0;
|
|
@@ -4806,6 +4966,7 @@ var AgentWidgetClient = class {
|
|
|
4806
4966
|
currentAssistant.streaming = false;
|
|
4807
4967
|
streamParsers.delete(currentAssistant.id);
|
|
4808
4968
|
rawContentBuffers.delete(currentAssistant.id);
|
|
4969
|
+
seqChunkBuffers.delete(currentAssistant.id);
|
|
4809
4970
|
emitMessage(currentAssistant);
|
|
4810
4971
|
}
|
|
4811
4972
|
}
|
|
@@ -4831,6 +4992,7 @@ var AgentWidgetClient = class {
|
|
|
4831
4992
|
streamParsers.delete(assistant.id);
|
|
4832
4993
|
}
|
|
4833
4994
|
rawContentBuffers.delete(assistant.id);
|
|
4995
|
+
seqChunkBuffers.delete(assistant.id);
|
|
4834
4996
|
assistant.streaming = false;
|
|
4835
4997
|
emitMessage(assistant);
|
|
4836
4998
|
}
|
|
@@ -4847,14 +5009,26 @@ var AgentWidgetClient = class {
|
|
|
4847
5009
|
const msg = assistantMessage;
|
|
4848
5010
|
streamParsers.delete(msg.id);
|
|
4849
5011
|
rawContentBuffers.delete(msg.id);
|
|
5012
|
+
seqChunkBuffers.delete(msg.id);
|
|
4850
5013
|
if (msg.streaming !== false) {
|
|
4851
5014
|
msg.streaming = false;
|
|
4852
5015
|
emitMessage(msg);
|
|
4853
5016
|
}
|
|
4854
5017
|
}
|
|
5018
|
+
const splitFinalContent = (_ja = payload.result) == null ? void 0 : _ja.response;
|
|
5019
|
+
const sealedForReconcile = lastSealedTextSegment;
|
|
5020
|
+
if (sealedForReconcile) {
|
|
5021
|
+
if (splitFinalContent !== void 0 && splitFinalContent !== null) {
|
|
5022
|
+
reconcileSealedAssistantWithFinalResponse(sealedForReconcile, splitFinalContent);
|
|
5023
|
+
} else {
|
|
5024
|
+
streamParsers.delete(sealedForReconcile.id);
|
|
5025
|
+
rawContentBuffers.delete(sealedForReconcile.id);
|
|
5026
|
+
}
|
|
5027
|
+
}
|
|
5028
|
+
lastSealedTextSegment = null;
|
|
4855
5029
|
continue;
|
|
4856
5030
|
}
|
|
4857
|
-
const finalContent = (
|
|
5031
|
+
const finalContent = (_ka = payload.result) == null ? void 0 : _ka.response;
|
|
4858
5032
|
const assistant = ensureAssistantMessage();
|
|
4859
5033
|
if (finalContent !== void 0 && finalContent !== null) {
|
|
4860
5034
|
const parser = streamParsers.get(assistant.id);
|
|
@@ -4887,6 +5061,7 @@ var AgentWidgetClient = class {
|
|
|
4887
5061
|
currentAssistant.streaming = false;
|
|
4888
5062
|
streamParsers.delete(currentAssistant.id);
|
|
4889
5063
|
rawContentBuffers.delete(currentAssistant.id);
|
|
5064
|
+
seqChunkBuffers.delete(currentAssistant.id);
|
|
4890
5065
|
emitMessage(currentAssistant);
|
|
4891
5066
|
}
|
|
4892
5067
|
} else {
|
|
@@ -4901,12 +5076,13 @@ var AgentWidgetClient = class {
|
|
|
4901
5076
|
currentAssistant.streaming = false;
|
|
4902
5077
|
streamParsers.delete(currentAssistant.id);
|
|
4903
5078
|
rawContentBuffers.delete(currentAssistant.id);
|
|
5079
|
+
seqChunkBuffers.delete(currentAssistant.id);
|
|
4904
5080
|
emitMessage(currentAssistant);
|
|
4905
5081
|
}
|
|
4906
5082
|
}
|
|
4907
5083
|
});
|
|
4908
5084
|
} else {
|
|
4909
|
-
const text = typeof parsedResult === "string" ? parsedResult : (
|
|
5085
|
+
const text = typeof parsedResult === "string" ? parsedResult : (_la = parsedResult == null ? void 0 : parsedResult.text) != null ? _la : null;
|
|
4910
5086
|
if (text !== null && text.trim() !== "") {
|
|
4911
5087
|
assistant.content = text;
|
|
4912
5088
|
hasExtractedText = true;
|
|
@@ -4930,7 +5106,7 @@ var AgentWidgetClient = class {
|
|
|
4930
5106
|
assistant.content = ensureStringContent(finalContent);
|
|
4931
5107
|
}
|
|
4932
5108
|
if (parser) {
|
|
4933
|
-
const closeResult = (
|
|
5109
|
+
const closeResult = (_ma = parser.close) == null ? void 0 : _ma.call(parser);
|
|
4934
5110
|
if (closeResult instanceof Promise) {
|
|
4935
5111
|
closeResult.catch(() => {
|
|
4936
5112
|
});
|
|
@@ -4938,22 +5114,25 @@ var AgentWidgetClient = class {
|
|
|
4938
5114
|
}
|
|
4939
5115
|
streamParsers.delete(assistant.id);
|
|
4940
5116
|
rawContentBuffers.delete(assistant.id);
|
|
5117
|
+
seqChunkBuffers.delete(assistant.id);
|
|
4941
5118
|
assistant.streaming = false;
|
|
4942
5119
|
emitMessage(assistant);
|
|
4943
5120
|
}
|
|
4944
5121
|
} else {
|
|
4945
5122
|
streamParsers.delete(assistant.id);
|
|
4946
5123
|
rawContentBuffers.delete(assistant.id);
|
|
5124
|
+
seqChunkBuffers.delete(assistant.id);
|
|
4947
5125
|
assistant.streaming = false;
|
|
4948
5126
|
emitMessage(assistant);
|
|
4949
5127
|
}
|
|
4950
5128
|
} else if (payloadType === "flow_complete") {
|
|
4951
|
-
const finalContent = (
|
|
5129
|
+
const finalContent = (_na = payload.result) == null ? void 0 : _na.response;
|
|
4952
5130
|
if (didSplitByPartId) {
|
|
4953
5131
|
if (assistantMessage !== null) {
|
|
4954
5132
|
const msg = assistantMessage;
|
|
4955
5133
|
streamParsers.delete(msg.id);
|
|
4956
5134
|
rawContentBuffers.delete(msg.id);
|
|
5135
|
+
seqChunkBuffers.delete(msg.id);
|
|
4957
5136
|
if (msg.streaming !== false) {
|
|
4958
5137
|
msg.streaming = false;
|
|
4959
5138
|
emitMessage(msg);
|
|
@@ -4977,12 +5156,9 @@ var AgentWidgetClient = class {
|
|
|
4977
5156
|
var _a2;
|
|
4978
5157
|
const text = typeof result === "string" ? result : (_a2 = result == null ? void 0 : result.text) != null ? _a2 : null;
|
|
4979
5158
|
if (text !== null) {
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
currentAssistant.streaming = false;
|
|
4984
|
-
emitMessage(currentAssistant);
|
|
4985
|
-
}
|
|
5159
|
+
assistant.content = text;
|
|
5160
|
+
assistant.streaming = false;
|
|
5161
|
+
emitMessage(assistant);
|
|
4986
5162
|
}
|
|
4987
5163
|
});
|
|
4988
5164
|
}
|
|
@@ -4994,6 +5170,7 @@ var AgentWidgetClient = class {
|
|
|
4994
5170
|
}
|
|
4995
5171
|
streamParsers.delete(assistant.id);
|
|
4996
5172
|
rawContentBuffers.delete(assistant.id);
|
|
5173
|
+
seqChunkBuffers.delete(assistant.id);
|
|
4997
5174
|
const contentChanged = displayContent !== assistant.content;
|
|
4998
5175
|
const streamingChanged = assistant.streaming !== false;
|
|
4999
5176
|
if (contentChanged) {
|
|
@@ -5008,6 +5185,7 @@ var AgentWidgetClient = class {
|
|
|
5008
5185
|
const msg = assistantMessage;
|
|
5009
5186
|
streamParsers.delete(msg.id);
|
|
5010
5187
|
rawContentBuffers.delete(msg.id);
|
|
5188
|
+
seqChunkBuffers.delete(msg.id);
|
|
5011
5189
|
if (msg.streaming !== false) {
|
|
5012
5190
|
msg.streaming = false;
|
|
5013
5191
|
emitMessage(msg);
|
|
@@ -5018,11 +5196,11 @@ var AgentWidgetClient = class {
|
|
|
5018
5196
|
} else if (payloadType === "agent_start") {
|
|
5019
5197
|
agentExecution = {
|
|
5020
5198
|
executionId: payload.executionId,
|
|
5021
|
-
agentId: (
|
|
5022
|
-
agentName: (
|
|
5199
|
+
agentId: (_oa = payload.agentId) != null ? _oa : "virtual",
|
|
5200
|
+
agentName: (_pa = payload.agentName) != null ? _pa : "",
|
|
5023
5201
|
status: "running",
|
|
5024
5202
|
currentIteration: 0,
|
|
5025
|
-
maxTurns: (
|
|
5203
|
+
maxTurns: (_qa = payload.maxTurns) != null ? _qa : 1,
|
|
5026
5204
|
startedAt: resolveTimestamp(payload.startedAt)
|
|
5027
5205
|
};
|
|
5028
5206
|
} else if (payloadType === "agent_iteration_start") {
|
|
@@ -5042,7 +5220,7 @@ var AgentWidgetClient = class {
|
|
|
5042
5220
|
} else if (payloadType === "agent_turn_delta") {
|
|
5043
5221
|
if (payload.contentType === "text") {
|
|
5044
5222
|
const assistant = ensureAssistantMessage();
|
|
5045
|
-
assistant.content += (
|
|
5223
|
+
assistant.content += (_ra = payload.delta) != null ? _ra : "";
|
|
5046
5224
|
assistant.agentMetadata = {
|
|
5047
5225
|
executionId: payload.executionId,
|
|
5048
5226
|
iteration: payload.iteration,
|
|
@@ -5051,14 +5229,14 @@ var AgentWidgetClient = class {
|
|
|
5051
5229
|
};
|
|
5052
5230
|
emitMessage(assistant);
|
|
5053
5231
|
} else if (payload.contentType === "thinking") {
|
|
5054
|
-
const reasoningId = (
|
|
5232
|
+
const reasoningId = (_sa = payload.turnId) != null ? _sa : `agent-think-${payload.iteration}`;
|
|
5055
5233
|
const reasoningMessage = ensureReasoningMessage(reasoningId);
|
|
5056
|
-
reasoningMessage.reasoning = (
|
|
5234
|
+
reasoningMessage.reasoning = (_ta = reasoningMessage.reasoning) != null ? _ta : {
|
|
5057
5235
|
id: reasoningId,
|
|
5058
5236
|
status: "streaming",
|
|
5059
5237
|
chunks: []
|
|
5060
5238
|
};
|
|
5061
|
-
reasoningMessage.reasoning.chunks.push((
|
|
5239
|
+
reasoningMessage.reasoning.chunks.push((_ua = payload.delta) != null ? _ua : "");
|
|
5062
5240
|
reasoningMessage.agentMetadata = {
|
|
5063
5241
|
executionId: payload.executionId,
|
|
5064
5242
|
iteration: payload.iteration,
|
|
@@ -5066,12 +5244,12 @@ var AgentWidgetClient = class {
|
|
|
5066
5244
|
};
|
|
5067
5245
|
emitMessage(reasoningMessage);
|
|
5068
5246
|
} else if (payload.contentType === "tool_input") {
|
|
5069
|
-
const toolId = (
|
|
5247
|
+
const toolId = (_va = payload.toolCallId) != null ? _va : toolContext.lastId;
|
|
5070
5248
|
if (toolId) {
|
|
5071
5249
|
const toolMessage = toolMessages.get(toolId);
|
|
5072
5250
|
if (toolMessage == null ? void 0 : toolMessage.toolCall) {
|
|
5073
|
-
toolMessage.toolCall.chunks = (
|
|
5074
|
-
toolMessage.toolCall.chunks.push((
|
|
5251
|
+
toolMessage.toolCall.chunks = (_wa = toolMessage.toolCall.chunks) != null ? _wa : [];
|
|
5252
|
+
toolMessage.toolCall.chunks.push((_xa = payload.delta) != null ? _xa : "");
|
|
5075
5253
|
emitMessage(toolMessage);
|
|
5076
5254
|
}
|
|
5077
5255
|
}
|
|
@@ -5083,20 +5261,20 @@ var AgentWidgetClient = class {
|
|
|
5083
5261
|
if (reasoningMessage == null ? void 0 : reasoningMessage.reasoning) {
|
|
5084
5262
|
reasoningMessage.reasoning.status = "complete";
|
|
5085
5263
|
reasoningMessage.reasoning.completedAt = resolveTimestamp(payload.completedAt);
|
|
5086
|
-
const start = (
|
|
5264
|
+
const start = (_ya = reasoningMessage.reasoning.startedAt) != null ? _ya : Date.now();
|
|
5087
5265
|
reasoningMessage.reasoning.durationMs = Math.max(
|
|
5088
5266
|
0,
|
|
5089
|
-
((
|
|
5267
|
+
((_za = reasoningMessage.reasoning.completedAt) != null ? _za : Date.now()) - start
|
|
5090
5268
|
);
|
|
5091
5269
|
reasoningMessage.streaming = false;
|
|
5092
5270
|
emitMessage(reasoningMessage);
|
|
5093
5271
|
}
|
|
5094
5272
|
}
|
|
5095
5273
|
} else if (payloadType === "agent_tool_start") {
|
|
5096
|
-
const toolId = (
|
|
5274
|
+
const toolId = (_Aa = payload.toolCallId) != null ? _Aa : `agent-tool-${nextSequence()}`;
|
|
5097
5275
|
trackToolId(getToolCallKey(payload), toolId);
|
|
5098
5276
|
const toolMessage = ensureToolMessage(toolId);
|
|
5099
|
-
const tool = (
|
|
5277
|
+
const tool = (_Ba = toolMessage.toolCall) != null ? _Ba : {
|
|
5100
5278
|
id: toolId,
|
|
5101
5279
|
status: "pending",
|
|
5102
5280
|
name: void 0,
|
|
@@ -5108,12 +5286,12 @@ var AgentWidgetClient = class {
|
|
|
5108
5286
|
completedAt: void 0,
|
|
5109
5287
|
durationMs: void 0
|
|
5110
5288
|
};
|
|
5111
|
-
tool.name = (
|
|
5289
|
+
tool.name = (_Da = (_Ca = payload.toolName) != null ? _Ca : payload.name) != null ? _Da : tool.name;
|
|
5112
5290
|
tool.status = "running";
|
|
5113
5291
|
if (payload.parameters !== void 0) {
|
|
5114
5292
|
tool.args = payload.parameters;
|
|
5115
5293
|
}
|
|
5116
|
-
tool.startedAt = resolveTimestamp((
|
|
5294
|
+
tool.startedAt = resolveTimestamp((_Ea = payload.startedAt) != null ? _Ea : payload.timestamp);
|
|
5117
5295
|
toolMessage.toolCall = tool;
|
|
5118
5296
|
toolMessage.streaming = true;
|
|
5119
5297
|
toolMessage.agentMetadata = {
|
|
@@ -5122,21 +5300,21 @@ var AgentWidgetClient = class {
|
|
|
5122
5300
|
};
|
|
5123
5301
|
emitMessage(toolMessage);
|
|
5124
5302
|
} else if (payloadType === "agent_tool_delta") {
|
|
5125
|
-
const toolId = (
|
|
5303
|
+
const toolId = (_Fa = payload.toolCallId) != null ? _Fa : toolContext.lastId;
|
|
5126
5304
|
if (toolId) {
|
|
5127
|
-
const toolMessage = (
|
|
5305
|
+
const toolMessage = (_Ga = toolMessages.get(toolId)) != null ? _Ga : ensureToolMessage(toolId);
|
|
5128
5306
|
if (toolMessage.toolCall) {
|
|
5129
|
-
toolMessage.toolCall.chunks = (
|
|
5130
|
-
toolMessage.toolCall.chunks.push((
|
|
5307
|
+
toolMessage.toolCall.chunks = (_Ha = toolMessage.toolCall.chunks) != null ? _Ha : [];
|
|
5308
|
+
toolMessage.toolCall.chunks.push((_Ia = payload.delta) != null ? _Ia : "");
|
|
5131
5309
|
toolMessage.toolCall.status = "running";
|
|
5132
5310
|
toolMessage.streaming = true;
|
|
5133
5311
|
emitMessage(toolMessage);
|
|
5134
5312
|
}
|
|
5135
5313
|
}
|
|
5136
5314
|
} else if (payloadType === "agent_tool_complete") {
|
|
5137
|
-
const toolId = (
|
|
5315
|
+
const toolId = (_Ja = payload.toolCallId) != null ? _Ja : toolContext.lastId;
|
|
5138
5316
|
if (toolId) {
|
|
5139
|
-
const toolMessage = (
|
|
5317
|
+
const toolMessage = (_Ka = toolMessages.get(toolId)) != null ? _Ka : ensureToolMessage(toolId);
|
|
5140
5318
|
if (toolMessage.toolCall) {
|
|
5141
5319
|
toolMessage.toolCall.status = "complete";
|
|
5142
5320
|
if (payload.result !== void 0) {
|
|
@@ -5145,7 +5323,7 @@ var AgentWidgetClient = class {
|
|
|
5145
5323
|
if (typeof payload.executionTime === "number") {
|
|
5146
5324
|
toolMessage.toolCall.durationMs = payload.executionTime;
|
|
5147
5325
|
}
|
|
5148
|
-
toolMessage.toolCall.completedAt = resolveTimestamp((
|
|
5326
|
+
toolMessage.toolCall.completedAt = resolveTimestamp((_La = payload.completedAt) != null ? _La : payload.timestamp);
|
|
5149
5327
|
toolMessage.streaming = false;
|
|
5150
5328
|
emitMessage(toolMessage);
|
|
5151
5329
|
const callKey = getToolCallKey(payload);
|
|
@@ -5160,7 +5338,7 @@ var AgentWidgetClient = class {
|
|
|
5160
5338
|
const reflectionMessage = {
|
|
5161
5339
|
id: reflectionId,
|
|
5162
5340
|
role: "assistant",
|
|
5163
|
-
content: (
|
|
5341
|
+
content: (_Ma = payload.reflection) != null ? _Ma : "",
|
|
5164
5342
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5165
5343
|
streaming: false,
|
|
5166
5344
|
variant: "reasoning",
|
|
@@ -5168,7 +5346,7 @@ var AgentWidgetClient = class {
|
|
|
5168
5346
|
reasoning: {
|
|
5169
5347
|
id: reflectionId,
|
|
5170
5348
|
status: "complete",
|
|
5171
|
-
chunks: [(
|
|
5349
|
+
chunks: [(_Na = payload.reflection) != null ? _Na : ""]
|
|
5172
5350
|
},
|
|
5173
5351
|
agentMetadata: {
|
|
5174
5352
|
executionId: payload.executionId,
|
|
@@ -5189,7 +5367,7 @@ var AgentWidgetClient = class {
|
|
|
5189
5367
|
}
|
|
5190
5368
|
onEvent({ type: "status", status: "idle" });
|
|
5191
5369
|
} else if (payloadType === "agent_error") {
|
|
5192
|
-
const errorMessage = typeof payload.error === "string" ? payload.error : (
|
|
5370
|
+
const errorMessage = typeof payload.error === "string" ? payload.error : (_Pa = (_Oa = payload.error) == null ? void 0 : _Oa.message) != null ? _Pa : "Agent execution error";
|
|
5193
5371
|
if (payload.recoverable) {
|
|
5194
5372
|
if (typeof console !== "undefined") {
|
|
5195
5373
|
console.warn("[AgentWidget] Recoverable agent error:", errorMessage);
|
|
@@ -5202,7 +5380,7 @@ var AgentWidgetClient = class {
|
|
|
5202
5380
|
}
|
|
5203
5381
|
} else if (payloadType === "agent_ping") {
|
|
5204
5382
|
} else if (payloadType === "agent_approval_start") {
|
|
5205
|
-
const approvalId = (
|
|
5383
|
+
const approvalId = (_Qa = payload.approvalId) != null ? _Qa : `approval-${nextSequence()}`;
|
|
5206
5384
|
const approvalMessage = {
|
|
5207
5385
|
id: `approval-${approvalId}`,
|
|
5208
5386
|
role: "assistant",
|
|
@@ -5214,17 +5392,17 @@ var AgentWidgetClient = class {
|
|
|
5214
5392
|
approval: {
|
|
5215
5393
|
id: approvalId,
|
|
5216
5394
|
status: "pending",
|
|
5217
|
-
agentId: (
|
|
5218
|
-
executionId: (
|
|
5219
|
-
toolName: (
|
|
5395
|
+
agentId: (_Ra = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _Ra : "virtual",
|
|
5396
|
+
executionId: (_Ta = (_Sa = payload.executionId) != null ? _Sa : agentExecution == null ? void 0 : agentExecution.executionId) != null ? _Ta : "",
|
|
5397
|
+
toolName: (_Ua = payload.toolName) != null ? _Ua : "",
|
|
5220
5398
|
toolType: payload.toolType,
|
|
5221
|
-
description: (
|
|
5399
|
+
description: (_Wa = payload.description) != null ? _Wa : `Execute ${(_Va = payload.toolName) != null ? _Va : "tool"}`,
|
|
5222
5400
|
parameters: payload.parameters
|
|
5223
5401
|
}
|
|
5224
5402
|
};
|
|
5225
5403
|
emitMessage(approvalMessage);
|
|
5226
5404
|
} else if (payloadType === "step_await" && payload.awaitReason === "approval_required") {
|
|
5227
|
-
const approvalId = (
|
|
5405
|
+
const approvalId = (_Xa = payload.approvalId) != null ? _Xa : `approval-${nextSequence()}`;
|
|
5228
5406
|
const approvalMessage = {
|
|
5229
5407
|
id: `approval-${approvalId}`,
|
|
5230
5408
|
role: "assistant",
|
|
@@ -5236,11 +5414,11 @@ var AgentWidgetClient = class {
|
|
|
5236
5414
|
approval: {
|
|
5237
5415
|
id: approvalId,
|
|
5238
5416
|
status: "pending",
|
|
5239
|
-
agentId: (
|
|
5240
|
-
executionId: (
|
|
5241
|
-
toolName: (
|
|
5417
|
+
agentId: (_Ya = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _Ya : "virtual",
|
|
5418
|
+
executionId: (__a = (_Za = payload.executionId) != null ? _Za : agentExecution == null ? void 0 : agentExecution.executionId) != null ? __a : "",
|
|
5419
|
+
toolName: (_$a = payload.toolName) != null ? _$a : "",
|
|
5242
5420
|
toolType: payload.toolType,
|
|
5243
|
-
description: (
|
|
5421
|
+
description: (_bb = payload.description) != null ? _bb : `Execute ${(_ab = payload.toolName) != null ? _ab : "tool"}`,
|
|
5244
5422
|
parameters: payload.parameters
|
|
5245
5423
|
}
|
|
5246
5424
|
};
|
|
@@ -5259,11 +5437,11 @@ var AgentWidgetClient = class {
|
|
|
5259
5437
|
sequence: nextSequence(),
|
|
5260
5438
|
approval: {
|
|
5261
5439
|
id: approvalId,
|
|
5262
|
-
status: (
|
|
5263
|
-
agentId: (
|
|
5264
|
-
executionId: (
|
|
5265
|
-
toolName: (
|
|
5266
|
-
description: (
|
|
5440
|
+
status: (_cb = payload.decision) != null ? _cb : "approved",
|
|
5441
|
+
agentId: (_db = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _db : "virtual",
|
|
5442
|
+
executionId: (_fb = (_eb = payload.executionId) != null ? _eb : agentExecution == null ? void 0 : agentExecution.executionId) != null ? _fb : "",
|
|
5443
|
+
toolName: (_gb = payload.toolName) != null ? _gb : "",
|
|
5444
|
+
description: (_hb = payload.description) != null ? _hb : "",
|
|
5267
5445
|
resolvedAt: Date.now()
|
|
5268
5446
|
}
|
|
5269
5447
|
};
|
|
@@ -5301,7 +5479,7 @@ var AgentWidgetClient = class {
|
|
|
5301
5479
|
}
|
|
5302
5480
|
} else if (payloadType === "artifact_delta") {
|
|
5303
5481
|
const deltaId = String(payload.id);
|
|
5304
|
-
const deltaText = typeof payload.delta === "string" ? payload.delta : String((
|
|
5482
|
+
const deltaText = typeof payload.delta === "string" ? payload.delta : String((_ib = payload.delta) != null ? _ib : "");
|
|
5305
5483
|
onEvent({
|
|
5306
5484
|
type: "artifact_delta",
|
|
5307
5485
|
id: deltaId,
|
|
@@ -5324,7 +5502,7 @@ var AgentWidgetClient = class {
|
|
|
5324
5502
|
if (refMsg) {
|
|
5325
5503
|
refMsg.streaming = false;
|
|
5326
5504
|
try {
|
|
5327
|
-
const parsed = JSON.parse((
|
|
5505
|
+
const parsed = JSON.parse((_jb = refMsg.rawContent) != null ? _jb : "{}");
|
|
5328
5506
|
if (parsed.props) {
|
|
5329
5507
|
parsed.props.status = "complete";
|
|
5330
5508
|
const acc = artifactContent.get(artCompleteId);
|
|
@@ -5345,7 +5523,7 @@ var AgentWidgetClient = class {
|
|
|
5345
5523
|
if (!m || typeof m !== "object") {
|
|
5346
5524
|
continue;
|
|
5347
5525
|
}
|
|
5348
|
-
const id = String((
|
|
5526
|
+
const id = String((_kb = m.id) != null ? _kb : `msg-${nextSequence()}`);
|
|
5349
5527
|
const roleRaw = m.role;
|
|
5350
5528
|
const role = roleRaw === "user" ? "user" : roleRaw === "system" ? "system" : "assistant";
|
|
5351
5529
|
const msg = {
|
|
@@ -5364,7 +5542,7 @@ var AgentWidgetClient = class {
|
|
|
5364
5542
|
if (msg.rawContent) {
|
|
5365
5543
|
try {
|
|
5366
5544
|
const parsed = JSON.parse(msg.rawContent);
|
|
5367
|
-
const refArtId = (
|
|
5545
|
+
const refArtId = (_lb = parsed == null ? void 0 : parsed.props) == null ? void 0 : _lb.artifactId;
|
|
5368
5546
|
if (typeof refArtId === "string") {
|
|
5369
5547
|
artifactIdsWithCards.add(refArtId);
|
|
5370
5548
|
}
|
|
@@ -5375,6 +5553,7 @@ var AgentWidgetClient = class {
|
|
|
5375
5553
|
assistantMessageRef.current = null;
|
|
5376
5554
|
streamParsers.delete(id);
|
|
5377
5555
|
rawContentBuffers.delete(id);
|
|
5556
|
+
seqChunkBuffers.delete(id);
|
|
5378
5557
|
} else if (payloadType === "error" && payload.error) {
|
|
5379
5558
|
onEvent({
|
|
5380
5559
|
type: "error",
|
|
@@ -7797,7 +7976,7 @@ var morphMessages = (container, newContent, options = {}) => {
|
|
|
7797
7976
|
|
|
7798
7977
|
// src/utils/message-fingerprint.ts
|
|
7799
7978
|
function computeMessageFingerprint(message, configVersion) {
|
|
7800
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
7979
|
+
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;
|
|
7801
7980
|
return [
|
|
7802
7981
|
message.id,
|
|
7803
7982
|
message.role,
|
|
@@ -7809,8 +7988,11 @@ function computeMessageFingerprint(message, configVersion) {
|
|
|
7809
7988
|
(_i = (_h = message.llmContent) == null ? void 0 : _h.length) != null ? _i : 0,
|
|
7810
7989
|
(_k = (_j = message.approval) == null ? void 0 : _j.status) != null ? _k : "",
|
|
7811
7990
|
(_m = (_l = message.toolCall) == null ? void 0 : _l.status) != null ? _m : "",
|
|
7812
|
-
(_p = (_o = (_n = message.
|
|
7813
|
-
(_r = (_q = message.
|
|
7991
|
+
(_p = (_o = (_n = message.toolCall) == null ? void 0 : _n.chunks) == null ? void 0 : _o.length) != null ? _p : 0,
|
|
7992
|
+
(_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 : "",
|
|
7993
|
+
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,
|
|
7994
|
+
(_y = (_x = (_w = message.reasoning) == null ? void 0 : _w.chunks) == null ? void 0 : _x.length) != null ? _y : 0,
|
|
7995
|
+
(_A = (_z = message.contentParts) == null ? void 0 : _z.length) != null ? _A : 0,
|
|
7814
7996
|
configVersion
|
|
7815
7997
|
].join("\0");
|
|
7816
7998
|
}
|
|
@@ -9892,10 +10074,26 @@ var createStandardBubble = (message, transform, layoutConfig, actionsConfig, act
|
|
|
9892
10074
|
|
|
9893
10075
|
// src/components/reasoning-bubble.ts
|
|
9894
10076
|
var reasoningExpansionState = /* @__PURE__ */ new Set();
|
|
10077
|
+
var appendRenderedValue = (container, value) => {
|
|
10078
|
+
if (value == null) return false;
|
|
10079
|
+
if (typeof value === "string") {
|
|
10080
|
+
container.textContent = value;
|
|
10081
|
+
return true;
|
|
10082
|
+
}
|
|
10083
|
+
container.appendChild(value);
|
|
10084
|
+
return true;
|
|
10085
|
+
};
|
|
10086
|
+
var getReasoningPreviewText = (message, maxLines) => {
|
|
10087
|
+
var _a, _b;
|
|
10088
|
+
const text = (_b = (_a = message.reasoning) == null ? void 0 : _a.chunks.join("").trim()) != null ? _b : "";
|
|
10089
|
+
if (!text) return "";
|
|
10090
|
+
return text.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).slice(0, maxLines).join("\n");
|
|
10091
|
+
};
|
|
9895
10092
|
var updateReasoningBubbleUI = (messageId, bubble) => {
|
|
9896
10093
|
const expanded = reasoningExpansionState.has(messageId);
|
|
9897
10094
|
const header = bubble.querySelector('button[data-expand-header="true"]');
|
|
9898
10095
|
const content = bubble.querySelector(".persona-border-t");
|
|
10096
|
+
const preview = bubble.querySelector('[data-persona-collapsed-preview="reasoning"]');
|
|
9899
10097
|
if (!header || !content) return;
|
|
9900
10098
|
header.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
9901
10099
|
const headerMeta = header.querySelector(".persona-ml-auto");
|
|
@@ -9911,8 +10109,12 @@ var updateReasoningBubbleUI = (messageId, bubble) => {
|
|
|
9911
10109
|
}
|
|
9912
10110
|
}
|
|
9913
10111
|
content.style.display = expanded ? "" : "none";
|
|
10112
|
+
if (preview) {
|
|
10113
|
+
preview.style.display = expanded ? "none" : preview.textContent || preview.childNodes.length ? "" : "none";
|
|
10114
|
+
}
|
|
9914
10115
|
};
|
|
9915
|
-
var createReasoningBubble = (message) => {
|
|
10116
|
+
var createReasoningBubble = (message, config) => {
|
|
10117
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
9916
10118
|
const reasoning = message.reasoning;
|
|
9917
10119
|
const bubble = createElement(
|
|
9918
10120
|
"div",
|
|
@@ -9937,19 +10139,41 @@ var createReasoningBubble = (message) => {
|
|
|
9937
10139
|
if (!reasoning) {
|
|
9938
10140
|
return bubble;
|
|
9939
10141
|
}
|
|
9940
|
-
|
|
10142
|
+
const reasoningDisplayConfig = (_b = (_a = config == null ? void 0 : config.features) == null ? void 0 : _a.reasoningDisplay) != null ? _b : {};
|
|
10143
|
+
const expandable = reasoningDisplayConfig.expandable !== false;
|
|
10144
|
+
let expanded = expandable && reasoningExpansionState.has(message.id);
|
|
10145
|
+
const isActive = reasoning.status !== "complete";
|
|
10146
|
+
const previewText = getReasoningPreviewText(message, (_c = reasoningDisplayConfig.previewMaxLines) != null ? _c : 3);
|
|
9941
10147
|
const header = createElement(
|
|
9942
10148
|
"button",
|
|
9943
|
-
"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"
|
|
10149
|
+
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"
|
|
9944
10150
|
);
|
|
9945
10151
|
header.type = "button";
|
|
9946
|
-
|
|
9947
|
-
|
|
10152
|
+
if (expandable) {
|
|
10153
|
+
header.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
10154
|
+
header.setAttribute("data-expand-header", "true");
|
|
10155
|
+
}
|
|
9948
10156
|
header.setAttribute("data-bubble-type", "reasoning");
|
|
9949
10157
|
const headerContent = createElement("div", "persona-flex persona-flex-col persona-text-left");
|
|
9950
10158
|
const title = createElement("span", "persona-text-xs persona-text-persona-primary");
|
|
9951
|
-
|
|
9952
|
-
|
|
10159
|
+
const defaultSummary = "Thinking...";
|
|
10160
|
+
const customSummary = (_e = (_d = config == null ? void 0 : config.reasoning) == null ? void 0 : _d.renderCollapsedSummary) == null ? void 0 : _e.call(_d, {
|
|
10161
|
+
message,
|
|
10162
|
+
reasoning,
|
|
10163
|
+
defaultSummary,
|
|
10164
|
+
previewText,
|
|
10165
|
+
isActive,
|
|
10166
|
+
config: config != null ? config : {}
|
|
10167
|
+
});
|
|
10168
|
+
if (typeof customSummary === "string" && customSummary.trim()) {
|
|
10169
|
+
title.textContent = customSummary;
|
|
10170
|
+
headerContent.appendChild(title);
|
|
10171
|
+
} else if (customSummary instanceof HTMLElement) {
|
|
10172
|
+
headerContent.appendChild(customSummary);
|
|
10173
|
+
} else {
|
|
10174
|
+
title.textContent = defaultSummary;
|
|
10175
|
+
headerContent.appendChild(title);
|
|
10176
|
+
}
|
|
9953
10177
|
const status = createElement("span", "persona-text-xs persona-text-persona-primary");
|
|
9954
10178
|
status.textContent = describeReasonStatus(reasoning);
|
|
9955
10179
|
headerContent.appendChild(status);
|
|
@@ -9958,17 +10182,49 @@ var createReasoningBubble = (message) => {
|
|
|
9958
10182
|
} else {
|
|
9959
10183
|
title.style.display = "";
|
|
9960
10184
|
}
|
|
9961
|
-
|
|
9962
|
-
|
|
9963
|
-
|
|
9964
|
-
|
|
9965
|
-
|
|
10185
|
+
let toggleIcon = null;
|
|
10186
|
+
if (expandable) {
|
|
10187
|
+
toggleIcon = createElement("div", "persona-flex persona-items-center");
|
|
10188
|
+
const iconColor = "currentColor";
|
|
10189
|
+
const chevronIcon = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor, 2);
|
|
10190
|
+
if (chevronIcon) {
|
|
10191
|
+
toggleIcon.appendChild(chevronIcon);
|
|
10192
|
+
} else {
|
|
10193
|
+
toggleIcon.textContent = expanded ? "Hide" : "Show";
|
|
10194
|
+
}
|
|
10195
|
+
const headerMeta = createElement("div", "persona-flex persona-items-center persona-ml-auto");
|
|
10196
|
+
headerMeta.append(toggleIcon);
|
|
10197
|
+
header.append(headerContent, headerMeta);
|
|
9966
10198
|
} else {
|
|
9967
|
-
|
|
10199
|
+
header.append(headerContent);
|
|
10200
|
+
}
|
|
10201
|
+
const collapsedPreview = createElement(
|
|
10202
|
+
"div",
|
|
10203
|
+
"persona-px-4 persona-py-3 persona-text-xs persona-leading-snug persona-text-persona-muted"
|
|
10204
|
+
);
|
|
10205
|
+
collapsedPreview.setAttribute("data-persona-collapsed-preview", "reasoning");
|
|
10206
|
+
collapsedPreview.style.display = "none";
|
|
10207
|
+
collapsedPreview.style.whiteSpace = "pre-wrap";
|
|
10208
|
+
if (!expanded && isActive && reasoningDisplayConfig.activePreview && previewText) {
|
|
10209
|
+
const renderedPreview = (_g = (_f = config == null ? void 0 : config.reasoning) == null ? void 0 : _f.renderCollapsedPreview) == null ? void 0 : _g.call(_f, {
|
|
10210
|
+
message,
|
|
10211
|
+
reasoning,
|
|
10212
|
+
defaultPreview: previewText,
|
|
10213
|
+
isActive,
|
|
10214
|
+
config: config != null ? config : {}
|
|
10215
|
+
});
|
|
10216
|
+
if (!appendRenderedValue(collapsedPreview, renderedPreview)) {
|
|
10217
|
+
collapsedPreview.textContent = previewText;
|
|
10218
|
+
}
|
|
10219
|
+
collapsedPreview.style.display = "";
|
|
10220
|
+
}
|
|
10221
|
+
if (!expanded && isActive && reasoningDisplayConfig.activeMinHeight) {
|
|
10222
|
+
bubble.style.minHeight = reasoningDisplayConfig.activeMinHeight;
|
|
10223
|
+
}
|
|
10224
|
+
if (!expandable) {
|
|
10225
|
+
bubble.append(header, collapsedPreview);
|
|
10226
|
+
return bubble;
|
|
9968
10227
|
}
|
|
9969
|
-
const headerMeta = createElement("div", "persona-flex persona-items-center persona-ml-auto");
|
|
9970
|
-
headerMeta.append(toggleIcon);
|
|
9971
|
-
header.append(headerContent, headerMeta);
|
|
9972
10228
|
const content = createElement(
|
|
9973
10229
|
"div",
|
|
9974
10230
|
"persona-border-t persona-border-gray-200 persona-bg-gray-50 persona-px-4 persona-py-3"
|
|
@@ -9983,29 +10239,74 @@ var createReasoningBubble = (message) => {
|
|
|
9983
10239
|
content.appendChild(body);
|
|
9984
10240
|
const applyExpansionState = () => {
|
|
9985
10241
|
header.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
9986
|
-
toggleIcon
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
|
|
10242
|
+
if (toggleIcon) {
|
|
10243
|
+
toggleIcon.innerHTML = "";
|
|
10244
|
+
const iconColor = "currentColor";
|
|
10245
|
+
const chevronIcon = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor, 2);
|
|
10246
|
+
if (chevronIcon) {
|
|
10247
|
+
toggleIcon.appendChild(chevronIcon);
|
|
10248
|
+
} else {
|
|
10249
|
+
toggleIcon.textContent = expanded ? "Hide" : "Show";
|
|
10250
|
+
}
|
|
9993
10251
|
}
|
|
9994
10252
|
content.style.display = expanded ? "" : "none";
|
|
10253
|
+
collapsedPreview.style.display = expanded ? "none" : collapsedPreview.textContent || collapsedPreview.childNodes.length ? "" : "none";
|
|
9995
10254
|
};
|
|
9996
10255
|
applyExpansionState();
|
|
9997
|
-
bubble.append(header, content);
|
|
10256
|
+
bubble.append(header, collapsedPreview, content);
|
|
9998
10257
|
return bubble;
|
|
9999
10258
|
};
|
|
10000
10259
|
|
|
10001
10260
|
// src/components/tool-bubble.ts
|
|
10002
10261
|
var toolExpansionState = /* @__PURE__ */ new Set();
|
|
10262
|
+
var appendRenderedValue2 = (container, value) => {
|
|
10263
|
+
if (value == null) return false;
|
|
10264
|
+
if (typeof value === "string") {
|
|
10265
|
+
container.textContent = value;
|
|
10266
|
+
return true;
|
|
10267
|
+
}
|
|
10268
|
+
container.appendChild(value);
|
|
10269
|
+
return true;
|
|
10270
|
+
};
|
|
10271
|
+
var getToolPreviewText = (message, maxLines) => {
|
|
10272
|
+
var _a;
|
|
10273
|
+
const tool = message.toolCall;
|
|
10274
|
+
if (!tool) return "";
|
|
10275
|
+
const chunkText = ((_a = tool.chunks) != null ? _a : []).join("").trim();
|
|
10276
|
+
if (chunkText) {
|
|
10277
|
+
const lines = chunkText.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).slice(-maxLines);
|
|
10278
|
+
return lines.join("\n");
|
|
10279
|
+
}
|
|
10280
|
+
const argsText = formatUnknownValue(tool.args).trim();
|
|
10281
|
+
if (!argsText) return "";
|
|
10282
|
+
return argsText.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).slice(0, maxLines).join("\n");
|
|
10283
|
+
};
|
|
10284
|
+
var getToolSummaryText = (message, config) => {
|
|
10285
|
+
var _a, _b, _c, _d;
|
|
10286
|
+
const tool = message.toolCall;
|
|
10287
|
+
const toolDisplayConfig = (_a = config == null ? void 0 : config.features) == null ? void 0 : _a.toolCallDisplay;
|
|
10288
|
+
const collapsedMode = (_b = toolDisplayConfig == null ? void 0 : toolDisplayConfig.collapsedMode) != null ? _b : "tool-call";
|
|
10289
|
+
const previewText = getToolPreviewText(message, (_c = toolDisplayConfig == null ? void 0 : toolDisplayConfig.previewMaxLines) != null ? _c : 3);
|
|
10290
|
+
const defaultSummary = tool ? describeToolTitle(tool) : "";
|
|
10291
|
+
if (!tool) {
|
|
10292
|
+
return { summary: defaultSummary, previewText, isActive: false };
|
|
10293
|
+
}
|
|
10294
|
+
const isActive = tool.status !== "complete";
|
|
10295
|
+
let summary = defaultSummary;
|
|
10296
|
+
if (collapsedMode === "tool-name") {
|
|
10297
|
+
summary = ((_d = tool.name) == null ? void 0 : _d.trim()) || defaultSummary;
|
|
10298
|
+
} else if (collapsedMode === "tool-preview" && previewText) {
|
|
10299
|
+
summary = previewText;
|
|
10300
|
+
}
|
|
10301
|
+
return { summary, previewText, isActive };
|
|
10302
|
+
};
|
|
10003
10303
|
var updateToolBubbleUI = (messageId, bubble, config) => {
|
|
10004
10304
|
var _a;
|
|
10005
10305
|
const expanded = toolExpansionState.has(messageId);
|
|
10006
10306
|
const toolCallConfig = (_a = config == null ? void 0 : config.toolCall) != null ? _a : {};
|
|
10007
10307
|
const header = bubble.querySelector('button[data-expand-header="true"]');
|
|
10008
10308
|
const content = bubble.querySelector(".persona-border-t");
|
|
10309
|
+
const preview = bubble.querySelector('[data-persona-collapsed-preview="tool"]');
|
|
10009
10310
|
if (!header || !content) return;
|
|
10010
10311
|
header.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
10011
10312
|
const headerMeta = header.querySelector(".persona-ml-auto");
|
|
@@ -10021,9 +10322,12 @@ var updateToolBubbleUI = (messageId, bubble, config) => {
|
|
|
10021
10322
|
}
|
|
10022
10323
|
}
|
|
10023
10324
|
content.style.display = expanded ? "" : "none";
|
|
10325
|
+
if (preview) {
|
|
10326
|
+
preview.style.display = expanded ? "none" : preview.textContent || preview.childNodes.length ? "" : "none";
|
|
10327
|
+
}
|
|
10024
10328
|
};
|
|
10025
10329
|
var createToolBubble = (message, config) => {
|
|
10026
|
-
var _a;
|
|
10330
|
+
var _a, _b, _c, _d, _e, _f;
|
|
10027
10331
|
const tool = message.toolCall;
|
|
10028
10332
|
const toolCallConfig = (_a = config == null ? void 0 : config.toolCall) != null ? _a : {};
|
|
10029
10333
|
const bubble = createElement(
|
|
@@ -10061,14 +10365,19 @@ var createToolBubble = (message, config) => {
|
|
|
10061
10365
|
if (!tool) {
|
|
10062
10366
|
return bubble;
|
|
10063
10367
|
}
|
|
10064
|
-
|
|
10368
|
+
const toolDisplayConfig = (_c = (_b = config == null ? void 0 : config.features) == null ? void 0 : _b.toolCallDisplay) != null ? _c : {};
|
|
10369
|
+
const expandable = toolDisplayConfig.expandable !== false;
|
|
10370
|
+
let expanded = expandable && toolExpansionState.has(message.id);
|
|
10371
|
+
const { summary, previewText, isActive } = getToolSummaryText(message, config);
|
|
10065
10372
|
const header = createElement(
|
|
10066
10373
|
"button",
|
|
10067
|
-
"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"
|
|
10374
|
+
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"
|
|
10068
10375
|
);
|
|
10069
10376
|
header.type = "button";
|
|
10070
|
-
|
|
10071
|
-
|
|
10377
|
+
if (expandable) {
|
|
10378
|
+
header.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
10379
|
+
header.setAttribute("data-expand-header", "true");
|
|
10380
|
+
}
|
|
10072
10381
|
header.setAttribute("data-bubble-type", "tool");
|
|
10073
10382
|
if (toolCallConfig.headerBackgroundColor) {
|
|
10074
10383
|
header.style.backgroundColor = toolCallConfig.headerBackgroundColor;
|
|
@@ -10086,19 +10395,67 @@ var createToolBubble = (message, config) => {
|
|
|
10086
10395
|
if (toolCallConfig.headerTextColor) {
|
|
10087
10396
|
title.style.color = toolCallConfig.headerTextColor;
|
|
10088
10397
|
}
|
|
10089
|
-
|
|
10090
|
-
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
|
|
10398
|
+
const customSummary = (_e = toolCallConfig.renderCollapsedSummary) == null ? void 0 : _e.call(toolCallConfig, {
|
|
10399
|
+
message,
|
|
10400
|
+
toolCall: tool,
|
|
10401
|
+
defaultSummary: summary,
|
|
10402
|
+
previewText,
|
|
10403
|
+
collapsedMode: (_d = toolDisplayConfig.collapsedMode) != null ? _d : "tool-call",
|
|
10404
|
+
isActive,
|
|
10405
|
+
config: config != null ? config : {}
|
|
10406
|
+
});
|
|
10407
|
+
if (typeof customSummary === "string" && customSummary.trim()) {
|
|
10408
|
+
title.textContent = customSummary;
|
|
10409
|
+
headerContent.appendChild(title);
|
|
10410
|
+
} else if (customSummary instanceof HTMLElement) {
|
|
10411
|
+
headerContent.appendChild(customSummary);
|
|
10412
|
+
} else {
|
|
10413
|
+
title.textContent = summary;
|
|
10414
|
+
headerContent.appendChild(title);
|
|
10415
|
+
}
|
|
10416
|
+
let toggleIcon = null;
|
|
10417
|
+
if (expandable) {
|
|
10418
|
+
toggleIcon = createElement("div", "persona-flex persona-items-center");
|
|
10419
|
+
const iconColor = toolCallConfig.toggleTextColor || toolCallConfig.headerTextColor || "currentColor";
|
|
10420
|
+
const chevronIcon = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor, 2);
|
|
10421
|
+
if (chevronIcon) {
|
|
10422
|
+
toggleIcon.appendChild(chevronIcon);
|
|
10423
|
+
} else {
|
|
10424
|
+
toggleIcon.textContent = expanded ? "Hide" : "Show";
|
|
10425
|
+
}
|
|
10426
|
+
const headerMeta = createElement("div", "persona-flex persona-items-center persona-gap-2 persona-ml-auto");
|
|
10427
|
+
headerMeta.append(toggleIcon);
|
|
10428
|
+
header.append(headerContent, headerMeta);
|
|
10096
10429
|
} else {
|
|
10097
|
-
|
|
10430
|
+
header.append(headerContent);
|
|
10431
|
+
}
|
|
10432
|
+
const collapsedPreview = createElement(
|
|
10433
|
+
"div",
|
|
10434
|
+
"persona-px-4 persona-py-3 persona-text-xs persona-leading-snug persona-text-persona-muted"
|
|
10435
|
+
);
|
|
10436
|
+
collapsedPreview.setAttribute("data-persona-collapsed-preview", "tool");
|
|
10437
|
+
collapsedPreview.style.display = "none";
|
|
10438
|
+
collapsedPreview.style.whiteSpace = "pre-wrap";
|
|
10439
|
+
if (!expanded && isActive && toolDisplayConfig.activePreview && previewText) {
|
|
10440
|
+
const renderedPreview = (_f = toolCallConfig.renderCollapsedPreview) == null ? void 0 : _f.call(toolCallConfig, {
|
|
10441
|
+
message,
|
|
10442
|
+
toolCall: tool,
|
|
10443
|
+
defaultPreview: previewText,
|
|
10444
|
+
isActive,
|
|
10445
|
+
config: config != null ? config : {}
|
|
10446
|
+
});
|
|
10447
|
+
if (!appendRenderedValue2(collapsedPreview, renderedPreview)) {
|
|
10448
|
+
collapsedPreview.textContent = previewText;
|
|
10449
|
+
}
|
|
10450
|
+
collapsedPreview.style.display = "";
|
|
10451
|
+
}
|
|
10452
|
+
if (!expanded && isActive && toolDisplayConfig.activeMinHeight) {
|
|
10453
|
+
bubble.style.minHeight = toolDisplayConfig.activeMinHeight;
|
|
10454
|
+
}
|
|
10455
|
+
if (!expandable) {
|
|
10456
|
+
bubble.append(header, collapsedPreview);
|
|
10457
|
+
return bubble;
|
|
10098
10458
|
}
|
|
10099
|
-
const headerMeta = createElement("div", "persona-flex persona-items-center persona-gap-2 persona-ml-auto");
|
|
10100
|
-
headerMeta.append(toggleIcon);
|
|
10101
|
-
header.append(headerContent, headerMeta);
|
|
10102
10459
|
const content = createElement(
|
|
10103
10460
|
"div",
|
|
10104
10461
|
"persona-border-t persona-border-gray-200 persona-bg-gray-50 persona-space-y-3 persona-px-4 persona-py-3"
|
|
@@ -10228,18 +10585,21 @@ var createToolBubble = (message, config) => {
|
|
|
10228
10585
|
}
|
|
10229
10586
|
const applyToolExpansion = () => {
|
|
10230
10587
|
header.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
10231
|
-
toggleIcon
|
|
10232
|
-
|
|
10233
|
-
|
|
10234
|
-
|
|
10235
|
-
|
|
10236
|
-
|
|
10237
|
-
|
|
10588
|
+
if (toggleIcon) {
|
|
10589
|
+
toggleIcon.innerHTML = "";
|
|
10590
|
+
const iconColor = toolCallConfig.toggleTextColor || toolCallConfig.headerTextColor || "currentColor";
|
|
10591
|
+
const chevronIcon = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor, 2);
|
|
10592
|
+
if (chevronIcon) {
|
|
10593
|
+
toggleIcon.appendChild(chevronIcon);
|
|
10594
|
+
} else {
|
|
10595
|
+
toggleIcon.textContent = expanded ? "Hide" : "Show";
|
|
10596
|
+
}
|
|
10238
10597
|
}
|
|
10239
10598
|
content.style.display = expanded ? "" : "none";
|
|
10599
|
+
collapsedPreview.style.display = expanded ? "none" : collapsedPreview.textContent || collapsedPreview.childNodes.length ? "" : "none";
|
|
10240
10600
|
};
|
|
10241
10601
|
applyToolExpansion();
|
|
10242
|
-
bubble.append(header, content);
|
|
10602
|
+
bubble.append(header, collapsedPreview, content);
|
|
10243
10603
|
return bubble;
|
|
10244
10604
|
};
|
|
10245
10605
|
|
|
@@ -13046,6 +13406,15 @@ function getClipboardImageFiles(clipboardData) {
|
|
|
13046
13406
|
}
|
|
13047
13407
|
return imageFiles;
|
|
13048
13408
|
}
|
|
13409
|
+
function dataTransferHasFiles(dataTransfer) {
|
|
13410
|
+
if (!dataTransfer) return false;
|
|
13411
|
+
const types = dataTransfer.types;
|
|
13412
|
+
if (!types) return false;
|
|
13413
|
+
if (typeof types.contains === "function") {
|
|
13414
|
+
return types.contains("Files");
|
|
13415
|
+
}
|
|
13416
|
+
return Array.from(types).includes("Files");
|
|
13417
|
+
}
|
|
13049
13418
|
function normalizePersistStateConfig(config) {
|
|
13050
13419
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
13051
13420
|
if (!config) return null;
|
|
@@ -13137,8 +13506,36 @@ var buildPostprocessor = (cfg, actionManager, onResubmitRequested) => {
|
|
|
13137
13506
|
return sanitize ? sanitize(html) : html;
|
|
13138
13507
|
};
|
|
13139
13508
|
};
|
|
13509
|
+
function buildDropOverlay(dropCfg) {
|
|
13510
|
+
var _a, _b, _c, _d;
|
|
13511
|
+
const overlay = createElement("div", "persona-attachment-drop-overlay");
|
|
13512
|
+
if (dropCfg == null ? void 0 : dropCfg.background) overlay.style.setProperty("--persona-drop-overlay-bg", dropCfg.background);
|
|
13513
|
+
if ((dropCfg == null ? void 0 : dropCfg.backdropBlur) !== void 0) overlay.style.setProperty("--persona-drop-overlay-blur", dropCfg.backdropBlur);
|
|
13514
|
+
if (dropCfg == null ? void 0 : dropCfg.border) overlay.style.setProperty("--persona-drop-overlay-border", dropCfg.border);
|
|
13515
|
+
if (dropCfg == null ? void 0 : dropCfg.borderRadius) overlay.style.setProperty("--persona-drop-overlay-radius", dropCfg.borderRadius);
|
|
13516
|
+
if (dropCfg == null ? void 0 : dropCfg.inset) overlay.style.setProperty("--persona-drop-overlay-inset", dropCfg.inset);
|
|
13517
|
+
if (dropCfg == null ? void 0 : dropCfg.labelSize) overlay.style.setProperty("--persona-drop-overlay-label-size", dropCfg.labelSize);
|
|
13518
|
+
if (dropCfg == null ? void 0 : dropCfg.labelColor) overlay.style.setProperty("--persona-drop-overlay-label-color", dropCfg.labelColor);
|
|
13519
|
+
const iconName = (_a = dropCfg == null ? void 0 : dropCfg.iconName) != null ? _a : "upload";
|
|
13520
|
+
const iconSize = (_b = dropCfg == null ? void 0 : dropCfg.iconSize) != null ? _b : "48px";
|
|
13521
|
+
const iconColor = (_c = dropCfg == null ? void 0 : dropCfg.iconColor) != null ? _c : "rgba(59, 130, 246, 0.6)";
|
|
13522
|
+
const iconStrokeWidth = (_d = dropCfg == null ? void 0 : dropCfg.iconStrokeWidth) != null ? _d : 0.5;
|
|
13523
|
+
const iconSvg = renderLucideIcon(iconName, iconSize, iconColor, iconStrokeWidth);
|
|
13524
|
+
if (iconSvg) overlay.appendChild(iconSvg);
|
|
13525
|
+
if (dropCfg == null ? void 0 : dropCfg.label) {
|
|
13526
|
+
const labelEl = createElement("span", "persona-drop-overlay-label");
|
|
13527
|
+
labelEl.textContent = dropCfg.label;
|
|
13528
|
+
overlay.appendChild(labelEl);
|
|
13529
|
+
}
|
|
13530
|
+
return overlay;
|
|
13531
|
+
}
|
|
13140
13532
|
var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
13141
13533
|
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;
|
|
13534
|
+
if (mount == null) {
|
|
13535
|
+
throw new Error(
|
|
13536
|
+
'createAgentExperience: mount must be a non-null HTMLElement (e.g. pass document.getElementById("my-root") after the node exists).'
|
|
13537
|
+
);
|
|
13538
|
+
}
|
|
13142
13539
|
if (mount.id && !mount.getAttribute("data-persona-instance")) {
|
|
13143
13540
|
mount.setAttribute("data-persona-instance", mount.id);
|
|
13144
13541
|
}
|
|
@@ -13542,8 +13939,22 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
13542
13939
|
return composerElements.footer;
|
|
13543
13940
|
},
|
|
13544
13941
|
onSubmit: (text) => {
|
|
13545
|
-
|
|
13546
|
-
|
|
13942
|
+
var _a2;
|
|
13943
|
+
if (!session || session.isStreaming()) return;
|
|
13944
|
+
const value = text.trim();
|
|
13945
|
+
const hasAttachments = (_a2 = attachmentManager == null ? void 0 : attachmentManager.hasAttachments()) != null ? _a2 : false;
|
|
13946
|
+
if (!value && !hasAttachments) return;
|
|
13947
|
+
let contentParts;
|
|
13948
|
+
if (hasAttachments) {
|
|
13949
|
+
contentParts = [];
|
|
13950
|
+
contentParts.push(...attachmentManager.getContentParts());
|
|
13951
|
+
if (value) {
|
|
13952
|
+
contentParts.push(createTextPart(value));
|
|
13953
|
+
}
|
|
13954
|
+
}
|
|
13955
|
+
session.sendMessage(value, { contentParts });
|
|
13956
|
+
if (hasAttachments) {
|
|
13957
|
+
attachmentManager.clearAttachments();
|
|
13547
13958
|
}
|
|
13548
13959
|
},
|
|
13549
13960
|
streaming: false,
|
|
@@ -13622,6 +14033,9 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
13622
14033
|
attachmentManager == null ? void 0 : attachmentManager.handleFileSelect(target.files);
|
|
13623
14034
|
target.value = "";
|
|
13624
14035
|
});
|
|
14036
|
+
const dropCfg = config.attachments.dropOverlay;
|
|
14037
|
+
const overlay = buildDropOverlay(dropCfg);
|
|
14038
|
+
container.appendChild(overlay);
|
|
13625
14039
|
}
|
|
13626
14040
|
const renderSlots = () => {
|
|
13627
14041
|
var _a2, _b2;
|
|
@@ -14415,6 +14829,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14415
14829
|
let lastScrollTop = 0;
|
|
14416
14830
|
let scrollRAF = null;
|
|
14417
14831
|
let isAutoScrolling = false;
|
|
14832
|
+
let hasPendingAutoScroll = false;
|
|
14418
14833
|
const USER_SCROLL_THRESHOLD = 1;
|
|
14419
14834
|
const BOTTOM_THRESHOLD = 8;
|
|
14420
14835
|
const messageState = /* @__PURE__ */ new Map();
|
|
@@ -14507,6 +14922,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14507
14922
|
cancelAnimationFrame(scrollRAF);
|
|
14508
14923
|
scrollRAF = null;
|
|
14509
14924
|
}
|
|
14925
|
+
hasPendingAutoScroll = false;
|
|
14510
14926
|
cancelSmoothScroll();
|
|
14511
14927
|
};
|
|
14512
14928
|
const syncScrollToBottomButton = () => {
|
|
@@ -14536,9 +14952,14 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14536
14952
|
const scheduleAutoScroll = (force = false) => {
|
|
14537
14953
|
if (!autoFollow.isFollowing()) return;
|
|
14538
14954
|
if (!force && !isStreaming) return;
|
|
14539
|
-
|
|
14955
|
+
if (scrollRAF !== null) {
|
|
14956
|
+
cancelAnimationFrame(scrollRAF);
|
|
14957
|
+
scrollRAF = null;
|
|
14958
|
+
}
|
|
14959
|
+
hasPendingAutoScroll = true;
|
|
14540
14960
|
scrollRAF = requestAnimationFrame(() => {
|
|
14541
14961
|
scrollRAF = null;
|
|
14962
|
+
hasPendingAutoScroll = false;
|
|
14542
14963
|
if (!autoFollow.isFollowing()) return;
|
|
14543
14964
|
smoothScrollToBottom(getScrollableContainer(), force ? 220 : 140);
|
|
14544
14965
|
});
|
|
@@ -14612,7 +15033,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14612
15033
|
});
|
|
14613
15034
|
};
|
|
14614
15035
|
const renderMessagesWithPluginsImpl = (container2, messages, transform) => {
|
|
14615
|
-
var _a2, _b2, _c2, _d2;
|
|
15036
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
14616
15037
|
const tempContainer = document.createElement("div");
|
|
14617
15038
|
const getInlineLoadingIndicatorRenderer = () => {
|
|
14618
15039
|
var _a3;
|
|
@@ -14626,6 +15047,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14626
15047
|
return void 0;
|
|
14627
15048
|
};
|
|
14628
15049
|
const inlineLoadingRenderer = getInlineLoadingIndicatorRenderer();
|
|
15050
|
+
const appendRenderedValue3 = (containerEl, value) => {
|
|
15051
|
+
if (value == null) return false;
|
|
15052
|
+
if (typeof value === "string") {
|
|
15053
|
+
containerEl.textContent = value;
|
|
15054
|
+
return true;
|
|
15055
|
+
}
|
|
15056
|
+
containerEl.appendChild(value);
|
|
15057
|
+
return true;
|
|
15058
|
+
};
|
|
14629
15059
|
const activeMessageIds = /* @__PURE__ */ new Set();
|
|
14630
15060
|
messages.forEach((message) => {
|
|
14631
15061
|
var _a3, _b3;
|
|
@@ -14658,7 +15088,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14658
15088
|
if (!showReasoning) return;
|
|
14659
15089
|
bubble = matchingPlugin.renderReasoning({
|
|
14660
15090
|
message,
|
|
14661
|
-
defaultRenderer: () => createReasoningBubble(message),
|
|
15091
|
+
defaultRenderer: () => createReasoningBubble(message, config),
|
|
14662
15092
|
config
|
|
14663
15093
|
});
|
|
14664
15094
|
} else if (message.variant === "tool" && message.toolCall && matchingPlugin.renderToolCall) {
|
|
@@ -14764,7 +15194,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14764
15194
|
if (!bubble) {
|
|
14765
15195
|
if (message.variant === "reasoning" && message.reasoning) {
|
|
14766
15196
|
if (!showReasoning) return;
|
|
14767
|
-
bubble = createReasoningBubble(message);
|
|
15197
|
+
bubble = createReasoningBubble(message, config);
|
|
14768
15198
|
} else if (message.variant === "tool" && message.toolCall) {
|
|
14769
15199
|
if (!showToolCalls) return;
|
|
14770
15200
|
bubble = createToolBubble(message, config);
|
|
@@ -14817,6 +15247,68 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14817
15247
|
setCachedWrapper(messageCache, message.id, fingerprint, wrapper2);
|
|
14818
15248
|
tempContainer.appendChild(wrapper2);
|
|
14819
15249
|
});
|
|
15250
|
+
if ((_b2 = (_a2 = config.features) == null ? void 0 : _a2.toolCallDisplay) == null ? void 0 : _b2.grouped) {
|
|
15251
|
+
const toolGroups = [];
|
|
15252
|
+
let currentGroup = [];
|
|
15253
|
+
messages.forEach((message) => {
|
|
15254
|
+
if (message.variant === "tool" && message.toolCall && showToolCalls) {
|
|
15255
|
+
currentGroup.push(message);
|
|
15256
|
+
return;
|
|
15257
|
+
}
|
|
15258
|
+
if (currentGroup.length > 1) {
|
|
15259
|
+
toolGroups.push(currentGroup);
|
|
15260
|
+
}
|
|
15261
|
+
currentGroup = [];
|
|
15262
|
+
});
|
|
15263
|
+
if (currentGroup.length > 1) {
|
|
15264
|
+
toolGroups.push(currentGroup);
|
|
15265
|
+
}
|
|
15266
|
+
toolGroups.forEach((group, groupIndex) => {
|
|
15267
|
+
var _a3, _b3;
|
|
15268
|
+
const wrappers = group.map(
|
|
15269
|
+
(groupMessage) => Array.from(tempContainer.children).find(
|
|
15270
|
+
(child) => child instanceof HTMLElement && child.getAttribute("data-wrapper-id") === groupMessage.id
|
|
15271
|
+
)
|
|
15272
|
+
).filter((wrapper2) => Boolean(wrapper2));
|
|
15273
|
+
if (wrappers.length < 2) {
|
|
15274
|
+
return;
|
|
15275
|
+
}
|
|
15276
|
+
const groupWrapper = document.createElement("div");
|
|
15277
|
+
groupWrapper.className = "persona-flex";
|
|
15278
|
+
groupWrapper.id = `wrapper-tool-group-${groupIndex}-${group[0].id}`;
|
|
15279
|
+
groupWrapper.setAttribute("data-wrapper-id", `tool-group-${groupIndex}-${group[0].id}`);
|
|
15280
|
+
const groupContainer = document.createElement("div");
|
|
15281
|
+
groupContainer.className = "persona-tool-group persona-flex persona-w-full persona-flex-col persona-gap-2";
|
|
15282
|
+
groupContainer.setAttribute("data-persona-tool-group", "true");
|
|
15283
|
+
const summary = document.createElement("div");
|
|
15284
|
+
summary.className = "persona-tool-group-summary persona-text-xs persona-text-persona-muted";
|
|
15285
|
+
const defaultSummary = `Called ${group.length} tools`;
|
|
15286
|
+
const renderedSummary = (_b3 = (_a3 = config.toolCall) == null ? void 0 : _a3.renderGroupedSummary) == null ? void 0 : _b3.call(_a3, {
|
|
15287
|
+
messages: group,
|
|
15288
|
+
toolCalls: group.map((groupMessage) => groupMessage.toolCall).filter((toolCall) => Boolean(toolCall)),
|
|
15289
|
+
defaultSummary,
|
|
15290
|
+
config
|
|
15291
|
+
});
|
|
15292
|
+
if (!appendRenderedValue3(summary, renderedSummary)) {
|
|
15293
|
+
summary.textContent = defaultSummary;
|
|
15294
|
+
}
|
|
15295
|
+
const stack = document.createElement("div");
|
|
15296
|
+
stack.className = "persona-tool-group-stack persona-flex persona-flex-col";
|
|
15297
|
+
groupContainer.append(summary, stack);
|
|
15298
|
+
groupWrapper.appendChild(groupContainer);
|
|
15299
|
+
wrappers[0].before(groupWrapper);
|
|
15300
|
+
wrappers.forEach((wrapper2, wrapperIndex) => {
|
|
15301
|
+
const item = document.createElement("div");
|
|
15302
|
+
item.className = "persona-tool-group-item persona-relative";
|
|
15303
|
+
item.setAttribute("data-persona-tool-group-item", "true");
|
|
15304
|
+
if (wrapperIndex < wrappers.length - 1) {
|
|
15305
|
+
item.setAttribute("data-persona-tool-group-connector", "true");
|
|
15306
|
+
}
|
|
15307
|
+
item.appendChild(wrapper2);
|
|
15308
|
+
stack.appendChild(item);
|
|
15309
|
+
});
|
|
15310
|
+
});
|
|
15311
|
+
}
|
|
14820
15312
|
pruneCache(messageCache, activeMessageIds);
|
|
14821
15313
|
const hasStreamingAssistantMessage = messages.some(
|
|
14822
15314
|
(msg) => msg.role === "assistant" && msg.streaming
|
|
@@ -14835,7 +15327,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14835
15327
|
if (loadingPlugin == null ? void 0 : loadingPlugin.renderLoadingIndicator) {
|
|
14836
15328
|
typingIndicator = loadingPlugin.renderLoadingIndicator(loadingIndicatorContext);
|
|
14837
15329
|
}
|
|
14838
|
-
if (typingIndicator === null && ((
|
|
15330
|
+
if (typingIndicator === null && ((_c2 = config.loadingIndicator) == null ? void 0 : _c2.render)) {
|
|
14839
15331
|
typingIndicator = config.loadingIndicator.render(loadingIndicatorContext);
|
|
14840
15332
|
}
|
|
14841
15333
|
if (typingIndicator === null) {
|
|
@@ -14843,7 +15335,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14843
15335
|
}
|
|
14844
15336
|
if (typingIndicator) {
|
|
14845
15337
|
const typingBubble = document.createElement("div");
|
|
14846
|
-
const showBubble = ((
|
|
15338
|
+
const showBubble = ((_d2 = config.loadingIndicator) == null ? void 0 : _d2.showBubble) !== false;
|
|
14847
15339
|
typingBubble.className = showBubble ? [
|
|
14848
15340
|
"persona-max-w-[85%]",
|
|
14849
15341
|
"persona-rounded-2xl",
|
|
@@ -14884,12 +15376,12 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
14884
15376
|
if (idlePlugin == null ? void 0 : idlePlugin.renderIdleIndicator) {
|
|
14885
15377
|
idleIndicator = idlePlugin.renderIdleIndicator(idleIndicatorContext);
|
|
14886
15378
|
}
|
|
14887
|
-
if (idleIndicator === null && ((
|
|
15379
|
+
if (idleIndicator === null && ((_e2 = config.loadingIndicator) == null ? void 0 : _e2.renderIdle)) {
|
|
14888
15380
|
idleIndicator = config.loadingIndicator.renderIdle(idleIndicatorContext);
|
|
14889
15381
|
}
|
|
14890
15382
|
if (idleIndicator) {
|
|
14891
15383
|
const idleBubble = document.createElement("div");
|
|
14892
|
-
const showBubble = ((
|
|
15384
|
+
const showBubble = ((_f2 = config.loadingIndicator) == null ? void 0 : _f2.showBubble) !== false;
|
|
14893
15385
|
idleBubble.className = showBubble ? [
|
|
14894
15386
|
"persona-max-w-[85%]",
|
|
14895
15387
|
"persona-rounded-2xl",
|
|
@@ -15786,7 +16278,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
15786
16278
|
lastScrollTop,
|
|
15787
16279
|
nearBottom: isElementNearBottom(body, BOTTOM_THRESHOLD),
|
|
15788
16280
|
userScrollThreshold: USER_SCROLL_THRESHOLD,
|
|
15789
|
-
isAutoScrolling,
|
|
16281
|
+
isAutoScrolling: isAutoScrolling || hasPendingAutoScroll,
|
|
15790
16282
|
pauseOnUpwardScroll: true,
|
|
15791
16283
|
pauseWhenAwayFromBottom: false,
|
|
15792
16284
|
resumeRequiresDownwardScroll: true
|
|
@@ -15901,6 +16393,61 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
15901
16393
|
}
|
|
15902
16394
|
textarea == null ? void 0 : textarea.addEventListener("keydown", handleInputEnter);
|
|
15903
16395
|
textarea == null ? void 0 : textarea.addEventListener("paste", handleInputPaste);
|
|
16396
|
+
const ATTACHMENT_DROP_ACTIVE_CLASS = "persona-attachment-drop-active";
|
|
16397
|
+
let attachmentFileDragDepth = 0;
|
|
16398
|
+
const clearAttachmentDropVisual = () => {
|
|
16399
|
+
attachmentFileDragDepth = 0;
|
|
16400
|
+
container.classList.remove(ATTACHMENT_DROP_ACTIVE_CLASS);
|
|
16401
|
+
};
|
|
16402
|
+
const attachmentDropHandlingActive = () => {
|
|
16403
|
+
var _a2;
|
|
16404
|
+
return ((_a2 = config.attachments) == null ? void 0 : _a2.enabled) === true && attachmentManager !== null;
|
|
16405
|
+
};
|
|
16406
|
+
const handleAttachmentDragEnterCapture = (e) => {
|
|
16407
|
+
if (!dataTransferHasFiles(e.dataTransfer) || !attachmentDropHandlingActive()) return;
|
|
16408
|
+
attachmentFileDragDepth++;
|
|
16409
|
+
if (attachmentFileDragDepth === 1) {
|
|
16410
|
+
container.classList.add(ATTACHMENT_DROP_ACTIVE_CLASS);
|
|
16411
|
+
}
|
|
16412
|
+
};
|
|
16413
|
+
const handleAttachmentDragLeaveCapture = (e) => {
|
|
16414
|
+
if (!dataTransferHasFiles(e.dataTransfer) || !attachmentDropHandlingActive()) return;
|
|
16415
|
+
attachmentFileDragDepth--;
|
|
16416
|
+
if (attachmentFileDragDepth <= 0) {
|
|
16417
|
+
clearAttachmentDropVisual();
|
|
16418
|
+
}
|
|
16419
|
+
};
|
|
16420
|
+
const handleAttachmentDragOverCapture = (e) => {
|
|
16421
|
+
if (!dataTransferHasFiles(e.dataTransfer) || !attachmentDropHandlingActive()) return;
|
|
16422
|
+
e.preventDefault();
|
|
16423
|
+
e.dataTransfer.dropEffect = "copy";
|
|
16424
|
+
};
|
|
16425
|
+
const handleAttachmentDropCapture = (e) => {
|
|
16426
|
+
var _a2;
|
|
16427
|
+
if (!dataTransferHasFiles(e.dataTransfer) || !attachmentDropHandlingActive()) return;
|
|
16428
|
+
e.preventDefault();
|
|
16429
|
+
e.stopPropagation();
|
|
16430
|
+
clearAttachmentDropVisual();
|
|
16431
|
+
const files = Array.from((_a2 = e.dataTransfer.files) != null ? _a2 : []);
|
|
16432
|
+
if (files.length === 0) return;
|
|
16433
|
+
void attachmentManager.handleFiles(files);
|
|
16434
|
+
};
|
|
16435
|
+
const attachmentDropCapture = true;
|
|
16436
|
+
container.addEventListener("dragenter", handleAttachmentDragEnterCapture, attachmentDropCapture);
|
|
16437
|
+
container.addEventListener("dragleave", handleAttachmentDragLeaveCapture, attachmentDropCapture);
|
|
16438
|
+
mount.addEventListener("dragover", handleAttachmentDragOverCapture, attachmentDropCapture);
|
|
16439
|
+
mount.addEventListener("drop", handleAttachmentDropCapture, attachmentDropCapture);
|
|
16440
|
+
const ownerDoc = mount.ownerDocument;
|
|
16441
|
+
const handleDocDragOver = (e) => {
|
|
16442
|
+
if (!attachmentDropHandlingActive()) return;
|
|
16443
|
+
e.preventDefault();
|
|
16444
|
+
};
|
|
16445
|
+
const handleDocDrop = (e) => {
|
|
16446
|
+
if (!attachmentDropHandlingActive()) return;
|
|
16447
|
+
e.preventDefault();
|
|
16448
|
+
};
|
|
16449
|
+
ownerDoc.addEventListener("dragover", handleDocDragOver);
|
|
16450
|
+
ownerDoc.addEventListener("drop", handleDocDrop);
|
|
15904
16451
|
destroyCallbacks.push(() => {
|
|
15905
16452
|
if (composerForm) {
|
|
15906
16453
|
composerForm.removeEventListener("submit", handleSubmit);
|
|
@@ -15908,6 +16455,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
15908
16455
|
textarea == null ? void 0 : textarea.removeEventListener("keydown", handleInputEnter);
|
|
15909
16456
|
textarea == null ? void 0 : textarea.removeEventListener("paste", handleInputPaste);
|
|
15910
16457
|
});
|
|
16458
|
+
destroyCallbacks.push(() => {
|
|
16459
|
+
container.removeEventListener("dragenter", handleAttachmentDragEnterCapture, attachmentDropCapture);
|
|
16460
|
+
container.removeEventListener("dragleave", handleAttachmentDragLeaveCapture, attachmentDropCapture);
|
|
16461
|
+
mount.removeEventListener("dragover", handleAttachmentDragOverCapture, attachmentDropCapture);
|
|
16462
|
+
mount.removeEventListener("drop", handleAttachmentDropCapture, attachmentDropCapture);
|
|
16463
|
+
ownerDoc.removeEventListener("dragover", handleDocDragOver);
|
|
16464
|
+
ownerDoc.removeEventListener("drop", handleDocDrop);
|
|
16465
|
+
clearAttachmentDropVisual();
|
|
16466
|
+
});
|
|
15911
16467
|
destroyCallbacks.push(() => {
|
|
15912
16468
|
session.cancel();
|
|
15913
16469
|
});
|
|
@@ -15922,13 +16478,17 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
15922
16478
|
}
|
|
15923
16479
|
const controller = {
|
|
15924
16480
|
update(nextConfig) {
|
|
15925
|
-
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;
|
|
16481
|
+
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;
|
|
15926
16482
|
const previousToolCallConfig = config.toolCall;
|
|
15927
16483
|
const previousMessageActions = config.messageActions;
|
|
15928
16484
|
const previousLayoutMessages = (_a2 = config.layout) == null ? void 0 : _a2.messages;
|
|
15929
16485
|
const previousColorScheme = config.colorScheme;
|
|
15930
16486
|
const previousLoadingIndicator = config.loadingIndicator;
|
|
15931
16487
|
const previousIterationDisplay = config.iterationDisplay;
|
|
16488
|
+
const previousShowReasoning = (_b2 = config.features) == null ? void 0 : _b2.showReasoning;
|
|
16489
|
+
const previousShowToolCalls = (_c2 = config.features) == null ? void 0 : _c2.showToolCalls;
|
|
16490
|
+
const previousToolCallDisplay = (_d2 = config.features) == null ? void 0 : _d2.toolCallDisplay;
|
|
16491
|
+
const previousReasoningDisplay = (_e2 = config.features) == null ? void 0 : _e2.reasoningDisplay;
|
|
15932
16492
|
config = { ...config, ...nextConfig };
|
|
15933
16493
|
applyFullHeightStyles();
|
|
15934
16494
|
applyThemeVariables(mount, config);
|
|
@@ -15941,15 +16501,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
15941
16501
|
const newPlugins = pluginRegistry.getForInstance(config.plugins);
|
|
15942
16502
|
plugins.length = 0;
|
|
15943
16503
|
plugins.push(...newPlugins);
|
|
15944
|
-
launcherEnabled = (
|
|
15945
|
-
autoExpand = (
|
|
15946
|
-
showReasoning = (
|
|
15947
|
-
showToolCalls = (
|
|
15948
|
-
scrollToBottomFeature = (
|
|
16504
|
+
launcherEnabled = (_g2 = (_f2 = config.launcher) == null ? void 0 : _f2.enabled) != null ? _g2 : true;
|
|
16505
|
+
autoExpand = (_i2 = (_h2 = config.launcher) == null ? void 0 : _h2.autoExpand) != null ? _i2 : false;
|
|
16506
|
+
showReasoning = (_k2 = (_j2 = config.features) == null ? void 0 : _j2.showReasoning) != null ? _k2 : true;
|
|
16507
|
+
showToolCalls = (_m2 = (_l2 = config.features) == null ? void 0 : _l2.showToolCalls) != null ? _m2 : true;
|
|
16508
|
+
scrollToBottomFeature = (_o2 = (_n2 = config.features) == null ? void 0 : _n2.scrollToBottom) != null ? _o2 : {};
|
|
15949
16509
|
renderScrollToBottomButton();
|
|
15950
16510
|
syncScrollToBottomButton();
|
|
15951
16511
|
const prevShowEventStreamToggle = showEventStreamToggle;
|
|
15952
|
-
showEventStreamToggle = (
|
|
16512
|
+
showEventStreamToggle = (_q2 = (_p2 = config.features) == null ? void 0 : _p2.showEventStreamToggle) != null ? _q2 : false;
|
|
15953
16513
|
if (showEventStreamToggle && !prevShowEventStreamToggle) {
|
|
15954
16514
|
if (!eventStreamBuffer) {
|
|
15955
16515
|
eventStreamStore = new EventStreamStore(eventStreamDbName);
|
|
@@ -15966,7 +16526,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
15966
16526
|
});
|
|
15967
16527
|
}
|
|
15968
16528
|
if (!eventStreamToggleBtn && header) {
|
|
15969
|
-
const dynEsClassNames = (
|
|
16529
|
+
const dynEsClassNames = (_s2 = (_r2 = config.features) == null ? void 0 : _r2.eventStream) == null ? void 0 : _s2.classNames;
|
|
15970
16530
|
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 : "");
|
|
15971
16531
|
eventStreamToggleBtn = createElement("button", dynToggleBtnClasses);
|
|
15972
16532
|
eventStreamToggleBtn.style.width = "28px";
|
|
@@ -16004,15 +16564,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16004
16564
|
eventStreamBuffer = null;
|
|
16005
16565
|
eventStreamStore = null;
|
|
16006
16566
|
}
|
|
16007
|
-
if (((
|
|
16567
|
+
if (((_t2 = config.launcher) == null ? void 0 : _t2.enabled) === false && launcherButtonInstance) {
|
|
16008
16568
|
launcherButtonInstance.destroy();
|
|
16009
16569
|
launcherButtonInstance = null;
|
|
16010
16570
|
}
|
|
16011
|
-
if (((
|
|
16571
|
+
if (((_u2 = config.launcher) == null ? void 0 : _u2.enabled) === false && customLauncherElement) {
|
|
16012
16572
|
customLauncherElement.remove();
|
|
16013
16573
|
customLauncherElement = null;
|
|
16014
16574
|
}
|
|
16015
|
-
if (((
|
|
16575
|
+
if (((_v2 = config.launcher) == null ? void 0 : _v2.enabled) !== false && !launcherButtonInstance && !customLauncherElement) {
|
|
16016
16576
|
const launcherPlugin = plugins.find((p) => p.renderLauncher);
|
|
16017
16577
|
if (launcherPlugin == null ? void 0 : launcherPlugin.renderLauncher) {
|
|
16018
16578
|
const customLauncher = launcherPlugin.renderLauncher({
|
|
@@ -16036,13 +16596,13 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16036
16596
|
if (launcherButtonInstance) {
|
|
16037
16597
|
launcherButtonInstance.update(config);
|
|
16038
16598
|
}
|
|
16039
|
-
if (headerTitle && ((
|
|
16599
|
+
if (headerTitle && ((_w2 = config.launcher) == null ? void 0 : _w2.title) !== void 0) {
|
|
16040
16600
|
headerTitle.textContent = config.launcher.title;
|
|
16041
16601
|
}
|
|
16042
|
-
if (headerSubtitle && ((
|
|
16602
|
+
if (headerSubtitle && ((_x2 = config.launcher) == null ? void 0 : _x2.subtitle) !== void 0) {
|
|
16043
16603
|
headerSubtitle.textContent = config.launcher.subtitle;
|
|
16044
16604
|
}
|
|
16045
|
-
const headerLayoutConfig = (
|
|
16605
|
+
const headerLayoutConfig = (_y2 = config.layout) == null ? void 0 : _y2.header;
|
|
16046
16606
|
const headerLayoutChanged = (headerLayoutConfig == null ? void 0 : headerLayoutConfig.layout) !== prevHeaderLayout;
|
|
16047
16607
|
if (headerLayoutChanged && header) {
|
|
16048
16608
|
const newHeaderElements = headerLayoutConfig ? buildHeaderWithLayout(config, headerLayoutConfig, {
|
|
@@ -16088,11 +16648,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16088
16648
|
}
|
|
16089
16649
|
}
|
|
16090
16650
|
}
|
|
16091
|
-
const showHeader = ((
|
|
16651
|
+
const showHeader = ((_z2 = config.layout) == null ? void 0 : _z2.showHeader) !== false;
|
|
16092
16652
|
if (header) {
|
|
16093
16653
|
header.style.display = showHeader ? "" : "none";
|
|
16094
16654
|
}
|
|
16095
|
-
const showFooter = ((
|
|
16655
|
+
const showFooter = ((_A2 = config.layout) == null ? void 0 : _A2.showFooter) !== false;
|
|
16096
16656
|
if (footer) {
|
|
16097
16657
|
footer.style.display = showFooter ? "" : "none";
|
|
16098
16658
|
}
|
|
@@ -16116,20 +16676,21 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16116
16676
|
refreshCloseButton();
|
|
16117
16677
|
const toolCallConfigChanged = JSON.stringify(nextConfig.toolCall) !== JSON.stringify(previousToolCallConfig);
|
|
16118
16678
|
const messageActionsChanged = JSON.stringify(config.messageActions) !== JSON.stringify(previousMessageActions);
|
|
16119
|
-
const layoutMessagesChanged = JSON.stringify((
|
|
16120
|
-
const loadingIndicatorChanged = ((
|
|
16679
|
+
const layoutMessagesChanged = JSON.stringify((_B2 = config.layout) == null ? void 0 : _B2.messages) !== JSON.stringify(previousLayoutMessages);
|
|
16680
|
+
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);
|
|
16121
16681
|
const iterationDisplayChanged = config.iterationDisplay !== previousIterationDisplay;
|
|
16122
|
-
const
|
|
16682
|
+
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);
|
|
16683
|
+
const messagesConfigChanged = toolCallConfigChanged || messageActionsChanged || layoutMessagesChanged || loadingIndicatorChanged || iterationDisplayChanged || featuresChanged;
|
|
16123
16684
|
if (messagesConfigChanged && session) {
|
|
16124
16685
|
configVersion++;
|
|
16125
16686
|
renderMessagesWithPlugins(messagesWrapper, session.getMessages(), postprocess);
|
|
16126
16687
|
}
|
|
16127
|
-
const launcher = (
|
|
16128
|
-
const headerIconHidden = (
|
|
16129
|
-
const layoutShowIcon = (
|
|
16688
|
+
const launcher = (_L2 = config.launcher) != null ? _L2 : {};
|
|
16689
|
+
const headerIconHidden = (_M2 = launcher.headerIconHidden) != null ? _M2 : false;
|
|
16690
|
+
const layoutShowIcon = (_O = (_N2 = config.layout) == null ? void 0 : _N2.header) == null ? void 0 : _O.showIcon;
|
|
16130
16691
|
const shouldHideIcon = headerIconHidden || layoutShowIcon === false;
|
|
16131
16692
|
const headerIconName = launcher.headerIconName;
|
|
16132
|
-
const headerIconSize = (
|
|
16693
|
+
const headerIconSize = (_P = launcher.headerIconSize) != null ? _P : "48px";
|
|
16133
16694
|
if (iconHolder) {
|
|
16134
16695
|
const headerEl = container.querySelector(".persona-border-b-persona-divider");
|
|
16135
16696
|
const headerCopy = headerEl == null ? void 0 : headerEl.querySelector(".persona-flex-col");
|
|
@@ -16156,7 +16717,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16156
16717
|
if (iconSvg) {
|
|
16157
16718
|
iconHolder.replaceChildren(iconSvg);
|
|
16158
16719
|
} else {
|
|
16159
|
-
iconHolder.textContent = (
|
|
16720
|
+
iconHolder.textContent = (_Q = launcher.agentIconText) != null ? _Q : "\u{1F4AC}";
|
|
16160
16721
|
}
|
|
16161
16722
|
} else if (launcher.iconUrl) {
|
|
16162
16723
|
const img2 = iconHolder.querySelector("img");
|
|
@@ -16179,7 +16740,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16179
16740
|
if (existingSvg || existingImg) {
|
|
16180
16741
|
iconHolder.replaceChildren();
|
|
16181
16742
|
}
|
|
16182
|
-
iconHolder.textContent = (
|
|
16743
|
+
iconHolder.textContent = (_R = launcher.agentIconText) != null ? _R : "\u{1F4AC}";
|
|
16183
16744
|
}
|
|
16184
16745
|
const img = iconHolder.querySelector("img");
|
|
16185
16746
|
if (img) {
|
|
@@ -16188,8 +16749,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16188
16749
|
}
|
|
16189
16750
|
}
|
|
16190
16751
|
}
|
|
16191
|
-
const layoutShowTitle = (
|
|
16192
|
-
const layoutShowSubtitle = (
|
|
16752
|
+
const layoutShowTitle = (_T = (_S = config.layout) == null ? void 0 : _S.header) == null ? void 0 : _T.showTitle;
|
|
16753
|
+
const layoutShowSubtitle = (_V = (_U = config.layout) == null ? void 0 : _U.header) == null ? void 0 : _V.showSubtitle;
|
|
16193
16754
|
if (headerTitle) {
|
|
16194
16755
|
headerTitle.style.display = layoutShowTitle === false ? "none" : "";
|
|
16195
16756
|
}
|
|
@@ -16197,14 +16758,14 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16197
16758
|
headerSubtitle.style.display = layoutShowSubtitle === false ? "none" : "";
|
|
16198
16759
|
}
|
|
16199
16760
|
if (closeButton) {
|
|
16200
|
-
const layoutShowCloseButton = (
|
|
16761
|
+
const layoutShowCloseButton = (_X = (_W = config.layout) == null ? void 0 : _W.header) == null ? void 0 : _X.showCloseButton;
|
|
16201
16762
|
if (layoutShowCloseButton === false) {
|
|
16202
16763
|
closeButton.style.display = "none";
|
|
16203
16764
|
} else {
|
|
16204
16765
|
closeButton.style.display = "";
|
|
16205
16766
|
}
|
|
16206
|
-
const closeButtonSize = (
|
|
16207
|
-
const closeButtonPlacement = (
|
|
16767
|
+
const closeButtonSize = (_Y = launcher.closeButtonSize) != null ? _Y : "32px";
|
|
16768
|
+
const closeButtonPlacement = (_Z = launcher.closeButtonPlacement) != null ? _Z : "inline";
|
|
16208
16769
|
closeButton.style.height = closeButtonSize;
|
|
16209
16770
|
closeButton.style.width = closeButtonSize;
|
|
16210
16771
|
const { closeButtonWrapper } = panelElements;
|
|
@@ -16217,8 +16778,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16217
16778
|
container.style.position = "relative";
|
|
16218
16779
|
container.appendChild(closeButtonWrapper);
|
|
16219
16780
|
} else {
|
|
16220
|
-
const clearChatPlacement = (
|
|
16221
|
-
const clearChatEnabled = (
|
|
16781
|
+
const clearChatPlacement = (_$ = (__ = launcher.clearChat) == null ? void 0 : __.placement) != null ? _$ : "inline";
|
|
16782
|
+
const clearChatEnabled = (_ba = (_aa = launcher.clearChat) == null ? void 0 : _aa.enabled) != null ? _ba : true;
|
|
16222
16783
|
closeButtonWrapper.className = clearChatEnabled && clearChatPlacement === "inline" ? "" : "persona-ml-auto";
|
|
16223
16784
|
const header2 = container.querySelector(".persona-border-b-persona-divider");
|
|
16224
16785
|
if (header2) {
|
|
@@ -16264,8 +16825,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16264
16825
|
closeButton.style.paddingTop = "";
|
|
16265
16826
|
closeButton.style.paddingBottom = "";
|
|
16266
16827
|
}
|
|
16267
|
-
const closeButtonIconName = (
|
|
16268
|
-
const closeButtonIconText = (
|
|
16828
|
+
const closeButtonIconName = (_ca = launcher.closeButtonIconName) != null ? _ca : "x";
|
|
16829
|
+
const closeButtonIconText = (_da = launcher.closeButtonIconText) != null ? _da : "\xD7";
|
|
16269
16830
|
closeButton.innerHTML = "";
|
|
16270
16831
|
const iconSvg = renderLucideIcon(closeButtonIconName, "20px", "currentColor", 2);
|
|
16271
16832
|
if (iconSvg) {
|
|
@@ -16273,8 +16834,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16273
16834
|
} else {
|
|
16274
16835
|
closeButton.textContent = closeButtonIconText;
|
|
16275
16836
|
}
|
|
16276
|
-
const closeButtonTooltipText = (
|
|
16277
|
-
const closeButtonShowTooltip = (
|
|
16837
|
+
const closeButtonTooltipText = (_ea = launcher.closeButtonTooltipText) != null ? _ea : "Close chat";
|
|
16838
|
+
const closeButtonShowTooltip = (_fa = launcher.closeButtonShowTooltip) != null ? _fa : true;
|
|
16278
16839
|
closeButton.setAttribute("aria-label", closeButtonTooltipText);
|
|
16279
16840
|
if (closeButtonWrapper) {
|
|
16280
16841
|
if (closeButtonWrapper._cleanupTooltip) {
|
|
@@ -16331,11 +16892,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16331
16892
|
}
|
|
16332
16893
|
const { clearChatButton, clearChatButtonWrapper } = panelElements;
|
|
16333
16894
|
if (clearChatButton) {
|
|
16334
|
-
const clearChatConfig = (
|
|
16335
|
-
const clearChatEnabled = (
|
|
16336
|
-
const layoutShowClearChat = (
|
|
16895
|
+
const clearChatConfig = (_ga = launcher.clearChat) != null ? _ga : {};
|
|
16896
|
+
const clearChatEnabled = (_ha = clearChatConfig.enabled) != null ? _ha : true;
|
|
16897
|
+
const layoutShowClearChat = (_ja = (_ia = config.layout) == null ? void 0 : _ia.header) == null ? void 0 : _ja.showClearChat;
|
|
16337
16898
|
const shouldShowClearChat = layoutShowClearChat !== void 0 ? layoutShowClearChat : clearChatEnabled;
|
|
16338
|
-
const clearChatPlacement = (
|
|
16899
|
+
const clearChatPlacement = (_ka = clearChatConfig.placement) != null ? _ka : "inline";
|
|
16339
16900
|
if (clearChatButtonWrapper) {
|
|
16340
16901
|
clearChatButtonWrapper.style.display = shouldShowClearChat ? "" : "none";
|
|
16341
16902
|
const { closeButtonWrapper } = panelElements;
|
|
@@ -16377,11 +16938,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16377
16938
|
}
|
|
16378
16939
|
}
|
|
16379
16940
|
if (shouldShowClearChat) {
|
|
16380
|
-
const clearChatSize = (
|
|
16941
|
+
const clearChatSize = (_la = clearChatConfig.size) != null ? _la : "32px";
|
|
16381
16942
|
clearChatButton.style.height = clearChatSize;
|
|
16382
16943
|
clearChatButton.style.width = clearChatSize;
|
|
16383
|
-
const clearChatIconName = (
|
|
16384
|
-
const clearChatIconColor = (
|
|
16944
|
+
const clearChatIconName = (_ma = clearChatConfig.iconName) != null ? _ma : "refresh-cw";
|
|
16945
|
+
const clearChatIconColor = (_na = clearChatConfig.iconColor) != null ? _na : "";
|
|
16385
16946
|
clearChatButton.style.color = clearChatIconColor || HEADER_THEME_CSS.actionIconColor;
|
|
16386
16947
|
clearChatButton.innerHTML = "";
|
|
16387
16948
|
const iconSvg = renderLucideIcon(clearChatIconName, "20px", "currentColor", 2);
|
|
@@ -16425,8 +16986,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16425
16986
|
clearChatButton.style.paddingTop = "";
|
|
16426
16987
|
clearChatButton.style.paddingBottom = "";
|
|
16427
16988
|
}
|
|
16428
|
-
const clearChatTooltipText = (
|
|
16429
|
-
const clearChatShowTooltip = (
|
|
16989
|
+
const clearChatTooltipText = (_oa = clearChatConfig.tooltipText) != null ? _oa : "Clear chat";
|
|
16990
|
+
const clearChatShowTooltip = (_pa = clearChatConfig.showTooltip) != null ? _pa : true;
|
|
16430
16991
|
clearChatButton.setAttribute("aria-label", clearChatTooltipText);
|
|
16431
16992
|
if (clearChatButtonWrapper) {
|
|
16432
16993
|
if (clearChatButtonWrapper._cleanupTooltip) {
|
|
@@ -16502,9 +17063,9 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16502
17063
|
suggestionsManager.render(config.suggestionChips, session, textarea, void 0, config.suggestionChipsConfig);
|
|
16503
17064
|
updateCopy();
|
|
16504
17065
|
setComposerDisabled(session.isStreaming());
|
|
16505
|
-
const voiceRecognitionEnabled = ((
|
|
17066
|
+
const voiceRecognitionEnabled = ((_qa = config.voiceRecognition) == null ? void 0 : _qa.enabled) === true;
|
|
16506
17067
|
const hasSpeechRecognition = typeof window !== "undefined" && (typeof window.webkitSpeechRecognition !== "undefined" || typeof window.SpeechRecognition !== "undefined");
|
|
16507
|
-
const hasRuntypeProvider = ((
|
|
17068
|
+
const hasRuntypeProvider = ((_sa = (_ra = config.voiceRecognition) == null ? void 0 : _ra.provider) == null ? void 0 : _sa.type) === "runtype";
|
|
16508
17069
|
const hasVoiceInput = hasSpeechRecognition || hasRuntypeProvider;
|
|
16509
17070
|
if (voiceRecognitionEnabled && hasVoiceInput) {
|
|
16510
17071
|
if (!micButton || !micButtonWrapper) {
|
|
@@ -16517,17 +17078,17 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16517
17078
|
micButton.disabled = session.isStreaming();
|
|
16518
17079
|
}
|
|
16519
17080
|
} else {
|
|
16520
|
-
const voiceConfig = (
|
|
16521
|
-
const sendButtonConfig2 = (
|
|
16522
|
-
const micIconName = (
|
|
16523
|
-
const buttonSize2 = (
|
|
16524
|
-
const micIconSize = (
|
|
17081
|
+
const voiceConfig = (_ta = config.voiceRecognition) != null ? _ta : {};
|
|
17082
|
+
const sendButtonConfig2 = (_ua = config.sendButton) != null ? _ua : {};
|
|
17083
|
+
const micIconName = (_va = voiceConfig.iconName) != null ? _va : "mic";
|
|
17084
|
+
const buttonSize2 = (_wa = sendButtonConfig2.size) != null ? _wa : "40px";
|
|
17085
|
+
const micIconSize = (_xa = voiceConfig.iconSize) != null ? _xa : buttonSize2;
|
|
16525
17086
|
const micIconSizeNum = parseFloat(micIconSize) || 24;
|
|
16526
17087
|
micButton.style.width = micIconSize;
|
|
16527
17088
|
micButton.style.height = micIconSize;
|
|
16528
17089
|
micButton.style.minWidth = micIconSize;
|
|
16529
17090
|
micButton.style.minHeight = micIconSize;
|
|
16530
|
-
const iconColor = (
|
|
17091
|
+
const iconColor = (_za = (_ya = voiceConfig.iconColor) != null ? _ya : sendButtonConfig2.textColor) != null ? _za : "currentColor";
|
|
16531
17092
|
micButton.innerHTML = "";
|
|
16532
17093
|
const micIconSvg = renderLucideIcon(micIconName, micIconSizeNum, iconColor, 2);
|
|
16533
17094
|
if (micIconSvg) {
|
|
@@ -16535,7 +17096,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16535
17096
|
} else {
|
|
16536
17097
|
micButton.textContent = "\u{1F3A4}";
|
|
16537
17098
|
}
|
|
16538
|
-
const backgroundColor2 = (
|
|
17099
|
+
const backgroundColor2 = (_Aa = voiceConfig.backgroundColor) != null ? _Aa : sendButtonConfig2.backgroundColor;
|
|
16539
17100
|
if (backgroundColor2) {
|
|
16540
17101
|
micButton.style.backgroundColor = backgroundColor2;
|
|
16541
17102
|
} else {
|
|
@@ -16573,8 +17134,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16573
17134
|
micButton.style.paddingBottom = "";
|
|
16574
17135
|
}
|
|
16575
17136
|
const tooltip2 = micButtonWrapper == null ? void 0 : micButtonWrapper.querySelector(".persona-send-button-tooltip");
|
|
16576
|
-
const tooltipText2 = (
|
|
16577
|
-
const showTooltip2 = (
|
|
17137
|
+
const tooltipText2 = (_Ba = voiceConfig.tooltipText) != null ? _Ba : "Start voice recognition";
|
|
17138
|
+
const showTooltip2 = (_Ca = voiceConfig.showTooltip) != null ? _Ca : false;
|
|
16578
17139
|
if (showTooltip2 && tooltipText2) {
|
|
16579
17140
|
if (!tooltip2) {
|
|
16580
17141
|
const newTooltip = document.createElement("div");
|
|
@@ -16594,19 +17155,19 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16594
17155
|
} else {
|
|
16595
17156
|
if (micButton && micButtonWrapper) {
|
|
16596
17157
|
micButtonWrapper.style.display = "none";
|
|
16597
|
-
if (((
|
|
17158
|
+
if (((_Ea = (_Da = config.voiceRecognition) == null ? void 0 : _Da.provider) == null ? void 0 : _Ea.type) === "runtype") {
|
|
16598
17159
|
if (session.isVoiceActive()) session.toggleVoice();
|
|
16599
17160
|
} else if (isRecording) {
|
|
16600
17161
|
stopVoiceRecognition();
|
|
16601
17162
|
}
|
|
16602
17163
|
}
|
|
16603
17164
|
}
|
|
16604
|
-
const attachmentsEnabled = ((
|
|
17165
|
+
const attachmentsEnabled = ((_Fa = config.attachments) == null ? void 0 : _Fa.enabled) === true;
|
|
16605
17166
|
if (attachmentsEnabled) {
|
|
16606
17167
|
if (!attachmentButtonWrapper || !attachmentButton) {
|
|
16607
|
-
const attachmentsConfig = (
|
|
16608
|
-
const sendButtonConfig2 = (
|
|
16609
|
-
const buttonSize2 = (
|
|
17168
|
+
const attachmentsConfig = (_Ga = config.attachments) != null ? _Ga : {};
|
|
17169
|
+
const sendButtonConfig2 = (_Ha = config.sendButton) != null ? _Ha : {};
|
|
17170
|
+
const buttonSize2 = (_Ia = sendButtonConfig2.size) != null ? _Ia : "40px";
|
|
16610
17171
|
if (!attachmentPreviewsContainer) {
|
|
16611
17172
|
attachmentPreviewsContainer = createElement("div", "persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2");
|
|
16612
17173
|
attachmentPreviewsContainer.style.display = "none";
|
|
@@ -16615,8 +17176,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16615
17176
|
if (!attachmentInput) {
|
|
16616
17177
|
attachmentInput = document.createElement("input");
|
|
16617
17178
|
attachmentInput.type = "file";
|
|
16618
|
-
attachmentInput.accept = ((
|
|
16619
|
-
attachmentInput.multiple = ((
|
|
17179
|
+
attachmentInput.accept = ((_Ja = attachmentsConfig.allowedTypes) != null ? _Ja : ALL_SUPPORTED_MIME_TYPES).join(",");
|
|
17180
|
+
attachmentInput.multiple = ((_Ka = attachmentsConfig.maxFiles) != null ? _Ka : 4) > 1;
|
|
16620
17181
|
attachmentInput.style.display = "none";
|
|
16621
17182
|
attachmentInput.setAttribute("aria-label", "Attach files");
|
|
16622
17183
|
composerForm.insertBefore(attachmentInput, textarea);
|
|
@@ -16627,8 +17188,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16627
17188
|
"persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-attachment-button"
|
|
16628
17189
|
);
|
|
16629
17190
|
attachmentButton.type = "button";
|
|
16630
|
-
attachmentButton.setAttribute("aria-label", (
|
|
16631
|
-
const attachIconName = (
|
|
17191
|
+
attachmentButton.setAttribute("aria-label", (_La = attachmentsConfig.buttonTooltipText) != null ? _La : "Attach file");
|
|
17192
|
+
const attachIconName = (_Ma = attachmentsConfig.buttonIconName) != null ? _Ma : "paperclip";
|
|
16632
17193
|
const attachIconSize = buttonSize2;
|
|
16633
17194
|
const buttonSizeNum = parseFloat(attachIconSize) || 40;
|
|
16634
17195
|
const attachIconSizeNum = Math.round(buttonSizeNum * 0.6);
|
|
@@ -16660,7 +17221,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16660
17221
|
attachmentInput == null ? void 0 : attachmentInput.click();
|
|
16661
17222
|
});
|
|
16662
17223
|
attachmentButtonWrapper.appendChild(attachmentButton);
|
|
16663
|
-
const attachTooltipText = (
|
|
17224
|
+
const attachTooltipText = (_Na = attachmentsConfig.buttonTooltipText) != null ? _Na : "Attach file";
|
|
16664
17225
|
const tooltip2 = createElement("div", "persona-send-button-tooltip");
|
|
16665
17226
|
tooltip2.textContent = attachTooltipText;
|
|
16666
17227
|
attachmentButtonWrapper.appendChild(tooltip2);
|
|
@@ -16675,12 +17236,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16675
17236
|
}
|
|
16676
17237
|
});
|
|
16677
17238
|
}
|
|
17239
|
+
if (!container.querySelector(".persona-attachment-drop-overlay")) {
|
|
17240
|
+
container.appendChild(buildDropOverlay(attachmentsConfig.dropOverlay));
|
|
17241
|
+
}
|
|
16678
17242
|
} else {
|
|
16679
17243
|
attachmentButtonWrapper.style.display = "";
|
|
16680
|
-
const attachmentsConfig = (
|
|
17244
|
+
const attachmentsConfig = (_Oa = config.attachments) != null ? _Oa : {};
|
|
16681
17245
|
if (attachmentInput) {
|
|
16682
|
-
attachmentInput.accept = ((
|
|
16683
|
-
attachmentInput.multiple = ((
|
|
17246
|
+
attachmentInput.accept = ((_Pa = attachmentsConfig.allowedTypes) != null ? _Pa : ALL_SUPPORTED_MIME_TYPES).join(",");
|
|
17247
|
+
attachmentInput.multiple = ((_Qa = attachmentsConfig.maxFiles) != null ? _Qa : 4) > 1;
|
|
16684
17248
|
}
|
|
16685
17249
|
if (attachmentManager) {
|
|
16686
17250
|
attachmentManager.updateConfig({
|
|
@@ -16697,14 +17261,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16697
17261
|
if (attachmentManager) {
|
|
16698
17262
|
attachmentManager.clearAttachments();
|
|
16699
17263
|
}
|
|
17264
|
+
(_Ra = container.querySelector(".persona-attachment-drop-overlay")) == null ? void 0 : _Ra.remove();
|
|
16700
17265
|
}
|
|
16701
|
-
const sendButtonConfig = (
|
|
16702
|
-
const useIcon = (
|
|
16703
|
-
const iconText = (
|
|
17266
|
+
const sendButtonConfig = (_Sa = config.sendButton) != null ? _Sa : {};
|
|
17267
|
+
const useIcon = (_Ta = sendButtonConfig.useIcon) != null ? _Ta : false;
|
|
17268
|
+
const iconText = (_Ua = sendButtonConfig.iconText) != null ? _Ua : "\u2191";
|
|
16704
17269
|
const iconName = sendButtonConfig.iconName;
|
|
16705
|
-
const tooltipText = (
|
|
16706
|
-
const showTooltip = (
|
|
16707
|
-
const buttonSize = (
|
|
17270
|
+
const tooltipText = (_Va = sendButtonConfig.tooltipText) != null ? _Va : "Send message";
|
|
17271
|
+
const showTooltip = (_Wa = sendButtonConfig.showTooltip) != null ? _Wa : false;
|
|
17272
|
+
const buttonSize = (_Xa = sendButtonConfig.size) != null ? _Xa : "40px";
|
|
16708
17273
|
const backgroundColor = sendButtonConfig.backgroundColor;
|
|
16709
17274
|
const textColor = sendButtonConfig.textColor;
|
|
16710
17275
|
if (useIcon) {
|
|
@@ -16741,7 +17306,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16741
17306
|
sendButton.classList.add("persona-bg-persona-primary");
|
|
16742
17307
|
}
|
|
16743
17308
|
} else {
|
|
16744
|
-
sendButton.textContent = (
|
|
17309
|
+
sendButton.textContent = (_Za = (_Ya = config.copy) == null ? void 0 : _Ya.sendButtonLabel) != null ? _Za : "Send";
|
|
16745
17310
|
sendButton.style.width = "";
|
|
16746
17311
|
sendButton.style.height = "";
|
|
16747
17312
|
sendButton.style.minWidth = "";
|
|
@@ -16801,7 +17366,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16801
17366
|
} else if (tooltip) {
|
|
16802
17367
|
tooltip.style.display = "none";
|
|
16803
17368
|
}
|
|
16804
|
-
const updatedContentMaxWidth = (
|
|
17369
|
+
const updatedContentMaxWidth = (__a = config.layout) == null ? void 0 : __a.contentMaxWidth;
|
|
16805
17370
|
if (updatedContentMaxWidth) {
|
|
16806
17371
|
messagesWrapper.style.maxWidth = updatedContentMaxWidth;
|
|
16807
17372
|
messagesWrapper.style.marginLeft = "auto";
|
|
@@ -16833,8 +17398,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
|
|
|
16833
17398
|
suggestions.style.marginRight = "";
|
|
16834
17399
|
}
|
|
16835
17400
|
}
|
|
16836
|
-
const statusIndicatorConfig = (
|
|
16837
|
-
const isVisible = (
|
|
17401
|
+
const statusIndicatorConfig = (_$a = config.statusIndicator) != null ? _$a : {};
|
|
17402
|
+
const isVisible = (_ab = statusIndicatorConfig.visible) != null ? _ab : true;
|
|
16838
17403
|
statusText.style.display = isVisible ? "" : "none";
|
|
16839
17404
|
if (session) {
|
|
16840
17405
|
const currentStatus = session.getStatus();
|
|
@@ -17890,7 +18455,166 @@ function buildSrcdoc(mountId, shellMode, docked, widgetCssPath) {
|
|
|
17890
18455
|
</body>
|
|
17891
18456
|
</html>`;
|
|
17892
18457
|
}
|
|
17893
|
-
|
|
18458
|
+
var PREVIEW_TRANSCRIPT_PRESET_LABELS = {
|
|
18459
|
+
"user-message": "User message",
|
|
18460
|
+
"assistant-message": "Assistant message",
|
|
18461
|
+
"reasoning-streaming": "Reasoning (streaming)",
|
|
18462
|
+
"reasoning-complete": "Reasoning (complete)",
|
|
18463
|
+
"tool-running": "Tool call (running)",
|
|
18464
|
+
"tool-complete": "Tool call (complete)"
|
|
18465
|
+
};
|
|
18466
|
+
function getPreviewTranscriptPresetLabel(preset) {
|
|
18467
|
+
return PREVIEW_TRANSCRIPT_PRESET_LABELS[preset];
|
|
18468
|
+
}
|
|
18469
|
+
function createPreviewTranscriptEntry(preset, index = 0) {
|
|
18470
|
+
const createdAt = new Date(Date.now() - Math.max(0, 60 - index) * 1e3).toISOString();
|
|
18471
|
+
const suffix = `${preset}-${index}`;
|
|
18472
|
+
switch (preset) {
|
|
18473
|
+
case "user-message":
|
|
18474
|
+
return {
|
|
18475
|
+
id: `preview-seq-user-${suffix}`,
|
|
18476
|
+
role: "user",
|
|
18477
|
+
content: "Can you continue with the next step?",
|
|
18478
|
+
createdAt
|
|
18479
|
+
};
|
|
18480
|
+
case "assistant-message":
|
|
18481
|
+
return {
|
|
18482
|
+
id: `preview-seq-assistant-${suffix}`,
|
|
18483
|
+
role: "assistant",
|
|
18484
|
+
content: "Absolutely. I can keep going and explain what happens next.",
|
|
18485
|
+
createdAt
|
|
18486
|
+
};
|
|
18487
|
+
case "reasoning-streaming":
|
|
18488
|
+
return {
|
|
18489
|
+
id: `preview-seq-reasoning-stream-${suffix}`,
|
|
18490
|
+
role: "assistant",
|
|
18491
|
+
content: "",
|
|
18492
|
+
createdAt,
|
|
18493
|
+
streaming: true,
|
|
18494
|
+
variant: "reasoning",
|
|
18495
|
+
reasoning: {
|
|
18496
|
+
id: `preview-reasoning-stream-${suffix}`,
|
|
18497
|
+
status: "streaming",
|
|
18498
|
+
chunks: ["Thinking through the next step in the workflow..."]
|
|
18499
|
+
}
|
|
18500
|
+
};
|
|
18501
|
+
case "reasoning-complete":
|
|
18502
|
+
return {
|
|
18503
|
+
id: `preview-seq-reasoning-complete-${suffix}`,
|
|
18504
|
+
role: "assistant",
|
|
18505
|
+
content: "",
|
|
18506
|
+
createdAt,
|
|
18507
|
+
streaming: false,
|
|
18508
|
+
variant: "reasoning",
|
|
18509
|
+
reasoning: {
|
|
18510
|
+
id: `preview-reasoning-complete-${suffix}`,
|
|
18511
|
+
status: "complete",
|
|
18512
|
+
chunks: ["Reviewed the requirements and finalized the reasoning output."],
|
|
18513
|
+
durationMs: 1200
|
|
18514
|
+
}
|
|
18515
|
+
};
|
|
18516
|
+
case "tool-complete":
|
|
18517
|
+
return {
|
|
18518
|
+
id: `preview-seq-tool-complete-${suffix}`,
|
|
18519
|
+
role: "assistant",
|
|
18520
|
+
content: "",
|
|
18521
|
+
createdAt,
|
|
18522
|
+
streaming: false,
|
|
18523
|
+
variant: "tool",
|
|
18524
|
+
toolCall: {
|
|
18525
|
+
id: `preview-tool-complete-${suffix}`,
|
|
18526
|
+
name: "Create build instructions",
|
|
18527
|
+
status: "complete",
|
|
18528
|
+
chunks: ["Prepared the build instructions and validated the inputs."],
|
|
18529
|
+
result: { ok: true },
|
|
18530
|
+
duration: 420
|
|
18531
|
+
}
|
|
18532
|
+
};
|
|
18533
|
+
case "tool-running":
|
|
18534
|
+
default:
|
|
18535
|
+
return {
|
|
18536
|
+
id: `preview-seq-tool-running-${suffix}`,
|
|
18537
|
+
role: "assistant",
|
|
18538
|
+
content: "",
|
|
18539
|
+
createdAt,
|
|
18540
|
+
streaming: true,
|
|
18541
|
+
variant: "tool",
|
|
18542
|
+
toolCall: {
|
|
18543
|
+
id: `preview-tool-running-${suffix}`,
|
|
18544
|
+
name: "Get platform documentation",
|
|
18545
|
+
status: "running",
|
|
18546
|
+
chunks: ["Fetching the relevant platform documentation..."]
|
|
18547
|
+
}
|
|
18548
|
+
};
|
|
18549
|
+
}
|
|
18550
|
+
}
|
|
18551
|
+
function appendPreviewTranscriptEntry(messages, preset) {
|
|
18552
|
+
return [...messages, createPreviewTranscriptEntry(preset, messages.length)];
|
|
18553
|
+
}
|
|
18554
|
+
var createAdvancedTranscriptPreviewMessages = () => [
|
|
18555
|
+
{
|
|
18556
|
+
id: "preview-adv-1",
|
|
18557
|
+
role: "user",
|
|
18558
|
+
content: "Can you create the product and gather the docs?",
|
|
18559
|
+
createdAt: new Date(Date.now() - 18e4).toISOString()
|
|
18560
|
+
},
|
|
18561
|
+
{
|
|
18562
|
+
id: "preview-adv-2",
|
|
18563
|
+
role: "assistant",
|
|
18564
|
+
content: "",
|
|
18565
|
+
createdAt: new Date(Date.now() - 15e4).toISOString(),
|
|
18566
|
+
streaming: true,
|
|
18567
|
+
variant: "reasoning",
|
|
18568
|
+
reasoning: {
|
|
18569
|
+
id: "preview-reasoning",
|
|
18570
|
+
status: "streaming",
|
|
18571
|
+
chunks: [
|
|
18572
|
+
"Now let me get the Persona embed documentation and builtin tools catalog."
|
|
18573
|
+
]
|
|
18574
|
+
}
|
|
18575
|
+
},
|
|
18576
|
+
{
|
|
18577
|
+
id: "preview-adv-3",
|
|
18578
|
+
role: "assistant",
|
|
18579
|
+
content: "",
|
|
18580
|
+
createdAt: new Date(Date.now() - 12e4).toISOString(),
|
|
18581
|
+
streaming: true,
|
|
18582
|
+
variant: "tool",
|
|
18583
|
+
toolCall: {
|
|
18584
|
+
id: "preview-tool-1",
|
|
18585
|
+
name: "Load tools",
|
|
18586
|
+
status: "running",
|
|
18587
|
+
chunks: ["Loaded tools, used Runtype integration"]
|
|
18588
|
+
}
|
|
18589
|
+
},
|
|
18590
|
+
{
|
|
18591
|
+
id: "preview-adv-4",
|
|
18592
|
+
role: "assistant",
|
|
18593
|
+
content: "",
|
|
18594
|
+
createdAt: new Date(Date.now() - 9e4).toISOString(),
|
|
18595
|
+
streaming: true,
|
|
18596
|
+
variant: "tool",
|
|
18597
|
+
toolCall: {
|
|
18598
|
+
id: "preview-tool-2",
|
|
18599
|
+
name: "Get platform documentation",
|
|
18600
|
+
status: "running",
|
|
18601
|
+
chunks: ["Get platform documentation"]
|
|
18602
|
+
}
|
|
18603
|
+
},
|
|
18604
|
+
{
|
|
18605
|
+
id: "preview-adv-5",
|
|
18606
|
+
role: "assistant",
|
|
18607
|
+
content: "I loaded the tools and fetched the docs. Next I can assemble the product details.",
|
|
18608
|
+
createdAt: new Date(Date.now() - 3e4).toISOString()
|
|
18609
|
+
}
|
|
18610
|
+
];
|
|
18611
|
+
var shouldSeedAdvancedTranscriptPreview = (config) => {
|
|
18612
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
18613
|
+
return Boolean(
|
|
18614
|
+
((_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)
|
|
18615
|
+
);
|
|
18616
|
+
};
|
|
18617
|
+
function createPreviewMessages(scene, config, appendedMessages = []) {
|
|
17894
18618
|
if (scene === "home") {
|
|
17895
18619
|
return [{ id: "preview-home-1", role: "assistant", content: "Hi there! How can we help today?", createdAt: (/* @__PURE__ */ new Date()).toISOString() }];
|
|
17896
18620
|
}
|
|
@@ -17903,20 +18627,24 @@ function createPreviewMessages(scene) {
|
|
|
17903
18627
|
{ id: "preview-art-2", role: "assistant", content: "Here\u2019s a project overview document for you.", createdAt: new Date(Date.now() - 6e4).toISOString() }
|
|
17904
18628
|
];
|
|
17905
18629
|
}
|
|
18630
|
+
if (scene === "conversation" && shouldSeedAdvancedTranscriptPreview(config)) {
|
|
18631
|
+
return [...createAdvancedTranscriptPreviewMessages(), ...appendedMessages];
|
|
18632
|
+
}
|
|
17906
18633
|
return [
|
|
17907
18634
|
{ id: "preview-conv-1", role: "assistant", content: "Hello! How can I help you today?", createdAt: new Date(Date.now() - 18e4).toISOString() },
|
|
17908
18635
|
{ id: "preview-conv-2", role: "user", content: "I want to customize the theme editor preview.", createdAt: new Date(Date.now() - 12e4).toISOString() },
|
|
17909
|
-
{ 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() }
|
|
18636
|
+
{ 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() },
|
|
18637
|
+
...appendedMessages
|
|
17910
18638
|
];
|
|
17911
18639
|
}
|
|
17912
|
-
function applySceneConfig(base, scene) {
|
|
18640
|
+
function applySceneConfig(base, scene, appendedMessages = []) {
|
|
17913
18641
|
var _a, _b;
|
|
17914
18642
|
const launcher = { ...base.launcher, enabled: true, autoExpand: scene !== "minimized" };
|
|
17915
18643
|
const config = {
|
|
17916
18644
|
...base,
|
|
17917
18645
|
launcher,
|
|
17918
18646
|
suggestionChips: scene === "home" ? ((_a = base.suggestionChips) == null ? void 0 : _a.length) ? base.suggestionChips : HOME_SUGGESTION_CHIPS : base.suggestionChips,
|
|
17919
|
-
initialMessages: createPreviewMessages(scene),
|
|
18647
|
+
initialMessages: createPreviewMessages(scene, base, appendedMessages),
|
|
17920
18648
|
storageAdapter: PREVIEW_STORAGE_ADAPTER
|
|
17921
18649
|
};
|
|
17922
18650
|
if (scene === "artifact") {
|
|
@@ -17925,6 +18653,19 @@ function applySceneConfig(base, scene) {
|
|
|
17925
18653
|
return config;
|
|
17926
18654
|
}
|
|
17927
18655
|
function buildPreviewConfig(options, shellModeOverride) {
|
|
18656
|
+
var _a, _b, _c, _d;
|
|
18657
|
+
const theme = options.theme ? createTheme(options.theme, { validate: false }) : createTheme();
|
|
18658
|
+
const scene = (_a = options.scene) != null ? _a : "conversation";
|
|
18659
|
+
const base = {
|
|
18660
|
+
...DEFAULT_WIDGET_CONFIG,
|
|
18661
|
+
...options.config,
|
|
18662
|
+
theme,
|
|
18663
|
+
darkTheme: options.darkTheme,
|
|
18664
|
+
colorScheme: (_c = shellModeOverride != null ? shellModeOverride : (_b = options.config) == null ? void 0 : _b.colorScheme) != null ? _c : "light"
|
|
18665
|
+
};
|
|
18666
|
+
return applySceneConfig(base, scene, (_d = options.appendedMessages) != null ? _d : []);
|
|
18667
|
+
}
|
|
18668
|
+
function buildPreviewConfigWithMessages(options, messages, shellModeOverride) {
|
|
17928
18669
|
var _a, _b, _c;
|
|
17929
18670
|
const theme = options.theme ? createTheme(options.theme, { validate: false }) : createTheme();
|
|
17930
18671
|
const scene = (_a = options.scene) != null ? _a : "conversation";
|
|
@@ -17935,7 +18676,7 @@ function buildPreviewConfig(options, shellModeOverride) {
|
|
|
17935
18676
|
darkTheme: options.darkTheme,
|
|
17936
18677
|
colorScheme: (_c = shellModeOverride != null ? shellModeOverride : (_b = options.config) == null ? void 0 : _b.colorScheme) != null ? _c : "light"
|
|
17937
18678
|
};
|
|
17938
|
-
return applySceneConfig(base, scene);
|
|
18679
|
+
return applySceneConfig(base, scene, messages);
|
|
17939
18680
|
}
|
|
17940
18681
|
|
|
17941
18682
|
// src/theme-editor/preview.ts
|
|
@@ -18253,20 +18994,24 @@ function createThemePreview(container, initialOptions) {
|
|
|
18253
18994
|
ThemeEditorState,
|
|
18254
18995
|
ZOOM_MAX,
|
|
18255
18996
|
ZOOM_MIN,
|
|
18997
|
+
appendPreviewTranscriptEntry,
|
|
18256
18998
|
applySceneConfig,
|
|
18257
18999
|
applyShellTheme,
|
|
18258
19000
|
buildPreviewConfig,
|
|
19001
|
+
buildPreviewConfigWithMessages,
|
|
18259
19002
|
buildShellCss,
|
|
18260
19003
|
buildSrcdoc,
|
|
18261
19004
|
convertFromPx,
|
|
18262
19005
|
convertToPx,
|
|
18263
19006
|
createPreviewMessages,
|
|
19007
|
+
createPreviewTranscriptEntry,
|
|
18264
19008
|
createThemePreview,
|
|
18265
19009
|
detectRoleAssignment,
|
|
18266
19010
|
escapeHtml,
|
|
18267
19011
|
findSection,
|
|
18268
19012
|
formatCssValue,
|
|
18269
19013
|
generateColorScale,
|
|
19014
|
+
getPreviewTranscriptPresetLabel,
|
|
18270
19015
|
getShellPalette,
|
|
18271
19016
|
getThemeEditorPreset,
|
|
18272
19017
|
hexToHsl,
|