@runtypelabs/persona 3.9.1 → 3.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/index.cjs +46 -44
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +119 -0
  4. package/dist/index.d.ts +119 -0
  5. package/dist/index.global.js +67 -65
  6. package/dist/index.global.js.map +1 -1
  7. package/dist/index.js +46 -44
  8. package/dist/index.js.map +1 -1
  9. package/dist/theme-editor.cjs +828 -212
  10. package/dist/theme-editor.d.cts +128 -3
  11. package/dist/theme-editor.d.ts +128 -3
  12. package/dist/theme-editor.js +824 -212
  13. package/dist/theme-reference.cjs +1 -1
  14. package/dist/theme-reference.d.cts +8 -0
  15. package/dist/theme-reference.d.ts +8 -0
  16. package/dist/theme-reference.js +1 -1
  17. package/dist/widget.css +124 -0
  18. package/package.json +1 -1
  19. package/src/client.test.ts +312 -1
  20. package/src/client.ts +247 -24
  21. package/src/components/messages.ts +1 -1
  22. package/src/components/reasoning-bubble.ts +117 -28
  23. package/src/components/tool-bubble.ts +162 -28
  24. package/src/defaults.ts +13 -1
  25. package/src/styles/widget.css +124 -0
  26. package/src/theme-editor/index.ts +5 -0
  27. package/src/theme-editor/preview-utils.test.ts +58 -0
  28. package/src/theme-editor/preview-utils.ts +220 -4
  29. package/src/theme-editor/sections.test.ts +20 -0
  30. package/src/theme-editor/sections.ts +10 -0
  31. package/src/theme-reference.ts +8 -3
  32. package/src/tool-call-display-defaults.test.ts +23 -0
  33. package/src/types.ts +126 -0
  34. package/src/ui.scroll.test.ts +104 -0
  35. package/src/ui.tool-display.test.ts +204 -0
  36. package/src/ui.ts +103 -3
  37. package/src/utils/message-fingerprint.test.ts +17 -0
  38. package/src/utils/message-fingerprint.ts +13 -1
@@ -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,
@@ -124,7 +128,7 @@ function deepMerge(base, override) {
124
128
  var DEFAULT_FLOATING_LAUNCHER_WIDTH = "min(440px, calc(100vw - 24px))";
125
129
  var DEFAULT_FLOATING_LAUNCHER_MAX_WIDTH = "440px";
126
130
  var DEFAULT_WIDGET_CONFIG = {
127
- apiUrl: "http://localhost:43111/api/chat/dispatch",
131
+ apiUrl: "https://api.runtype.com/api/chat/dispatch",
128
132
  // Client token mode defaults (optional, only used when clientToken is set)
129
133
  clientToken: void 0,
130
134
  theme: void 0,
@@ -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
- reasoningMessage.reasoning.chunks.push(String(chunk));
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 rawBuffer = (_da = rawContentBuffers.get(assistant.id)) != null ? _da : "";
4720
- const accumulatedRaw = rawBuffer + chunk;
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
- assistant.content += chunk;
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
- const currentAssistant = assistantMessage;
4746
- if (currentAssistant && currentAssistant.id === assistant.id) {
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
- currentAssistant.content += chunk;
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
- assistant.content += chunk;
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
- assistant.content += chunk;
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 = (_ja = payload.result) == null ? void 0 : _ja.response;
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 : (_ka = parsedResult == null ? void 0 : parsedResult.text) != null ? _ka : null;
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 = (_la = parser.close) == null ? void 0 : _la.call(parser);
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 = (_ma = payload.result) == null ? void 0 : _ma.response;
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
- const currentAssistant = assistantMessage;
4981
- if (currentAssistant && currentAssistant.id === assistant.id) {
4982
- currentAssistant.content = text;
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: (_na = payload.agentId) != null ? _na : "virtual",
5022
- agentName: (_oa = payload.agentName) != null ? _oa : "",
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: (_pa = payload.maxTurns) != null ? _pa : 1,
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 += (_qa = payload.delta) != null ? _qa : "";
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 = (_ra = payload.turnId) != null ? _ra : `agent-think-${payload.iteration}`;
5232
+ const reasoningId = (_sa = payload.turnId) != null ? _sa : `agent-think-${payload.iteration}`;
5055
5233
  const reasoningMessage = ensureReasoningMessage(reasoningId);
5056
- reasoningMessage.reasoning = (_sa = reasoningMessage.reasoning) != null ? _sa : {
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((_ta = payload.delta) != null ? _ta : "");
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 = (_ua = payload.toolCallId) != null ? _ua : toolContext.lastId;
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 = (_va = toolMessage.toolCall.chunks) != null ? _va : [];
5074
- toolMessage.toolCall.chunks.push((_wa = payload.delta) != null ? _wa : "");
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 = (_xa = reasoningMessage.reasoning.startedAt) != null ? _xa : Date.now();
5264
+ const start = (_ya = reasoningMessage.reasoning.startedAt) != null ? _ya : Date.now();
5087
5265
  reasoningMessage.reasoning.durationMs = Math.max(
5088
5266
  0,
5089
- ((_ya = reasoningMessage.reasoning.completedAt) != null ? _ya : Date.now()) - start
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 = (_za = payload.toolCallId) != null ? _za : `agent-tool-${nextSequence()}`;
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 = (_Aa = toolMessage.toolCall) != null ? _Aa : {
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 = (_Ca = (_Ba = payload.toolName) != null ? _Ba : payload.name) != null ? _Ca : 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((_Da = payload.startedAt) != null ? _Da : payload.timestamp);
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 = (_Ea = payload.toolCallId) != null ? _Ea : toolContext.lastId;
5303
+ const toolId = (_Fa = payload.toolCallId) != null ? _Fa : toolContext.lastId;
5126
5304
  if (toolId) {
5127
- const toolMessage = (_Fa = toolMessages.get(toolId)) != null ? _Fa : ensureToolMessage(toolId);
5305
+ const toolMessage = (_Ga = toolMessages.get(toolId)) != null ? _Ga : ensureToolMessage(toolId);
5128
5306
  if (toolMessage.toolCall) {
5129
- toolMessage.toolCall.chunks = (_Ga = toolMessage.toolCall.chunks) != null ? _Ga : [];
5130
- toolMessage.toolCall.chunks.push((_Ha = payload.delta) != null ? _Ha : "");
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 = (_Ia = payload.toolCallId) != null ? _Ia : toolContext.lastId;
5315
+ const toolId = (_Ja = payload.toolCallId) != null ? _Ja : toolContext.lastId;
5138
5316
  if (toolId) {
5139
- const toolMessage = (_Ja = toolMessages.get(toolId)) != null ? _Ja : ensureToolMessage(toolId);
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((_Ka = payload.completedAt) != null ? _Ka : payload.timestamp);
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: (_La = payload.reflection) != null ? _La : "",
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: [(_Ma = payload.reflection) != null ? _Ma : ""]
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 : (_Oa = (_Na = payload.error) == null ? void 0 : _Na.message) != null ? _Oa : "Agent execution 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 = (_Pa = payload.approvalId) != null ? _Pa : `approval-${nextSequence()}`;
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: (_Qa = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _Qa : "virtual",
5218
- executionId: (_Sa = (_Ra = payload.executionId) != null ? _Ra : agentExecution == null ? void 0 : agentExecution.executionId) != null ? _Sa : "",
5219
- toolName: (_Ta = payload.toolName) != null ? _Ta : "",
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: (_Va = payload.description) != null ? _Va : `Execute ${(_Ua = payload.toolName) != null ? _Ua : "tool"}`,
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 = (_Wa = payload.approvalId) != null ? _Wa : `approval-${nextSequence()}`;
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: (_Xa = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _Xa : "virtual",
5240
- executionId: (_Za = (_Ya = payload.executionId) != null ? _Ya : agentExecution == null ? void 0 : agentExecution.executionId) != null ? _Za : "",
5241
- toolName: (__a = payload.toolName) != null ? __a : "",
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: (_ab = payload.description) != null ? _ab : `Execute ${(_$a = payload.toolName) != null ? _$a : "tool"}`,
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: (_bb = payload.decision) != null ? _bb : "approved",
5263
- agentId: (_cb = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _cb : "virtual",
5264
- executionId: (_eb = (_db = payload.executionId) != null ? _db : agentExecution == null ? void 0 : agentExecution.executionId) != null ? _eb : "",
5265
- toolName: (_fb = payload.toolName) != null ? _fb : "",
5266
- description: (_gb = payload.description) != null ? _gb : "",
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((_hb = payload.delta) != null ? _hb : "");
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((_ib = refMsg.rawContent) != null ? _ib : "{}");
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((_jb = m.id) != null ? _jb : `msg-${nextSequence()}`);
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 = (_kb = parsed == null ? void 0 : parsed.props) == null ? void 0 : _kb.artifactId;
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.reasoning) == null ? void 0 : _n.chunks) == null ? void 0 : _o.length) != null ? _p : 0,
7813
- (_r = (_q = message.contentParts) == null ? void 0 : _q.length) != null ? _r : 0,
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
- let expanded = reasoningExpansionState.has(message.id);
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
- header.setAttribute("aria-expanded", expanded ? "true" : "false");
9947
- header.setAttribute("data-expand-header", "true");
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
- title.textContent = "Thinking...";
9952
- headerContent.appendChild(title);
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
- const toggleIcon = createElement("div", "persona-flex persona-items-center");
9962
- const iconColor = "currentColor";
9963
- const chevronIcon = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor, 2);
9964
- if (chevronIcon) {
9965
- toggleIcon.appendChild(chevronIcon);
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
- toggleIcon.textContent = expanded ? "Hide" : "Show";
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.innerHTML = "";
9987
- const iconColor2 = "currentColor";
9988
- const chevronIcon2 = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor2, 2);
9989
- if (chevronIcon2) {
9990
- toggleIcon.appendChild(chevronIcon2);
9991
- } else {
9992
- toggleIcon.textContent = expanded ? "Hide" : "Show";
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
- let expanded = toolExpansionState.has(message.id);
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
- header.setAttribute("aria-expanded", expanded ? "true" : "false");
10071
- header.setAttribute("data-expand-header", "true");
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
- title.textContent = describeToolTitle(tool);
10090
- headerContent.appendChild(title);
10091
- const toggleIcon = createElement("div", "persona-flex persona-items-center");
10092
- const iconColor = toolCallConfig.toggleTextColor || toolCallConfig.headerTextColor || "currentColor";
10093
- const chevronIcon = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor, 2);
10094
- if (chevronIcon) {
10095
- toggleIcon.appendChild(chevronIcon);
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);
10096
10412
  } else {
10097
- toggleIcon.textContent = expanded ? "Hide" : "Show";
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);
10429
+ } else {
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"
@@ -10182,7 +10539,7 @@ var createToolBubble = (message, config) => {
10182
10539
  if (toolCallConfig.codeBlockTextColor) {
10183
10540
  logsPre.style.color = toolCallConfig.codeBlockTextColor;
10184
10541
  }
10185
- logsPre.textContent = tool.chunks.join("\n");
10542
+ logsPre.textContent = tool.chunks.join("");
10186
10543
  logsBlock.append(logsLabel, logsPre);
10187
10544
  content.appendChild(logsBlock);
10188
10545
  }
@@ -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.innerHTML = "";
10232
- const iconColor2 = toolCallConfig.toggleTextColor || toolCallConfig.headerTextColor || "currentColor";
10233
- const chevronIcon2 = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor2, 2);
10234
- if (chevronIcon2) {
10235
- toggleIcon.appendChild(chevronIcon2);
10236
- } else {
10237
- toggleIcon.textContent = expanded ? "Hide" : "Show";
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
 
@@ -14612,7 +14972,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14612
14972
  });
14613
14973
  };
14614
14974
  const renderMessagesWithPluginsImpl = (container2, messages, transform) => {
14615
- var _a2, _b2, _c2, _d2;
14975
+ var _a2, _b2, _c2, _d2, _e2, _f2;
14616
14976
  const tempContainer = document.createElement("div");
14617
14977
  const getInlineLoadingIndicatorRenderer = () => {
14618
14978
  var _a3;
@@ -14626,6 +14986,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14626
14986
  return void 0;
14627
14987
  };
14628
14988
  const inlineLoadingRenderer = getInlineLoadingIndicatorRenderer();
14989
+ const appendRenderedValue3 = (containerEl, value) => {
14990
+ if (value == null) return false;
14991
+ if (typeof value === "string") {
14992
+ containerEl.textContent = value;
14993
+ return true;
14994
+ }
14995
+ containerEl.appendChild(value);
14996
+ return true;
14997
+ };
14629
14998
  const activeMessageIds = /* @__PURE__ */ new Set();
14630
14999
  messages.forEach((message) => {
14631
15000
  var _a3, _b3;
@@ -14658,7 +15027,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14658
15027
  if (!showReasoning) return;
14659
15028
  bubble = matchingPlugin.renderReasoning({
14660
15029
  message,
14661
- defaultRenderer: () => createReasoningBubble(message),
15030
+ defaultRenderer: () => createReasoningBubble(message, config),
14662
15031
  config
14663
15032
  });
14664
15033
  } else if (message.variant === "tool" && message.toolCall && matchingPlugin.renderToolCall) {
@@ -14764,7 +15133,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14764
15133
  if (!bubble) {
14765
15134
  if (message.variant === "reasoning" && message.reasoning) {
14766
15135
  if (!showReasoning) return;
14767
- bubble = createReasoningBubble(message);
15136
+ bubble = createReasoningBubble(message, config);
14768
15137
  } else if (message.variant === "tool" && message.toolCall) {
14769
15138
  if (!showToolCalls) return;
14770
15139
  bubble = createToolBubble(message, config);
@@ -14817,6 +15186,68 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14817
15186
  setCachedWrapper(messageCache, message.id, fingerprint, wrapper2);
14818
15187
  tempContainer.appendChild(wrapper2);
14819
15188
  });
15189
+ if ((_b2 = (_a2 = config.features) == null ? void 0 : _a2.toolCallDisplay) == null ? void 0 : _b2.grouped) {
15190
+ const toolGroups = [];
15191
+ let currentGroup = [];
15192
+ messages.forEach((message) => {
15193
+ if (message.variant === "tool" && message.toolCall && showToolCalls) {
15194
+ currentGroup.push(message);
15195
+ return;
15196
+ }
15197
+ if (currentGroup.length > 1) {
15198
+ toolGroups.push(currentGroup);
15199
+ }
15200
+ currentGroup = [];
15201
+ });
15202
+ if (currentGroup.length > 1) {
15203
+ toolGroups.push(currentGroup);
15204
+ }
15205
+ toolGroups.forEach((group, groupIndex) => {
15206
+ var _a3, _b3;
15207
+ const wrappers = group.map(
15208
+ (groupMessage) => Array.from(tempContainer.children).find(
15209
+ (child) => child instanceof HTMLElement && child.getAttribute("data-wrapper-id") === groupMessage.id
15210
+ )
15211
+ ).filter((wrapper2) => Boolean(wrapper2));
15212
+ if (wrappers.length < 2) {
15213
+ return;
15214
+ }
15215
+ const groupWrapper = document.createElement("div");
15216
+ groupWrapper.className = "persona-flex";
15217
+ groupWrapper.id = `wrapper-tool-group-${groupIndex}-${group[0].id}`;
15218
+ groupWrapper.setAttribute("data-wrapper-id", `tool-group-${groupIndex}-${group[0].id}`);
15219
+ const groupContainer = document.createElement("div");
15220
+ groupContainer.className = "persona-tool-group persona-flex persona-w-full persona-flex-col persona-gap-2";
15221
+ groupContainer.setAttribute("data-persona-tool-group", "true");
15222
+ const summary = document.createElement("div");
15223
+ summary.className = "persona-tool-group-summary persona-text-xs persona-text-persona-muted";
15224
+ const defaultSummary = `Called ${group.length} tools`;
15225
+ const renderedSummary = (_b3 = (_a3 = config.toolCall) == null ? void 0 : _a3.renderGroupedSummary) == null ? void 0 : _b3.call(_a3, {
15226
+ messages: group,
15227
+ toolCalls: group.map((groupMessage) => groupMessage.toolCall).filter((toolCall) => Boolean(toolCall)),
15228
+ defaultSummary,
15229
+ config
15230
+ });
15231
+ if (!appendRenderedValue3(summary, renderedSummary)) {
15232
+ summary.textContent = defaultSummary;
15233
+ }
15234
+ const stack = document.createElement("div");
15235
+ stack.className = "persona-tool-group-stack persona-flex persona-flex-col";
15236
+ groupContainer.append(summary, stack);
15237
+ groupWrapper.appendChild(groupContainer);
15238
+ wrappers[0].before(groupWrapper);
15239
+ wrappers.forEach((wrapper2, wrapperIndex) => {
15240
+ const item = document.createElement("div");
15241
+ item.className = "persona-tool-group-item persona-relative";
15242
+ item.setAttribute("data-persona-tool-group-item", "true");
15243
+ if (wrapperIndex < wrappers.length - 1) {
15244
+ item.setAttribute("data-persona-tool-group-connector", "true");
15245
+ }
15246
+ item.appendChild(wrapper2);
15247
+ stack.appendChild(item);
15248
+ });
15249
+ });
15250
+ }
14820
15251
  pruneCache(messageCache, activeMessageIds);
14821
15252
  const hasStreamingAssistantMessage = messages.some(
14822
15253
  (msg) => msg.role === "assistant" && msg.streaming
@@ -14835,7 +15266,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14835
15266
  if (loadingPlugin == null ? void 0 : loadingPlugin.renderLoadingIndicator) {
14836
15267
  typingIndicator = loadingPlugin.renderLoadingIndicator(loadingIndicatorContext);
14837
15268
  }
14838
- if (typingIndicator === null && ((_a2 = config.loadingIndicator) == null ? void 0 : _a2.render)) {
15269
+ if (typingIndicator === null && ((_c2 = config.loadingIndicator) == null ? void 0 : _c2.render)) {
14839
15270
  typingIndicator = config.loadingIndicator.render(loadingIndicatorContext);
14840
15271
  }
14841
15272
  if (typingIndicator === null) {
@@ -14843,7 +15274,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14843
15274
  }
14844
15275
  if (typingIndicator) {
14845
15276
  const typingBubble = document.createElement("div");
14846
- const showBubble = ((_b2 = config.loadingIndicator) == null ? void 0 : _b2.showBubble) !== false;
15277
+ const showBubble = ((_d2 = config.loadingIndicator) == null ? void 0 : _d2.showBubble) !== false;
14847
15278
  typingBubble.className = showBubble ? [
14848
15279
  "persona-max-w-[85%]",
14849
15280
  "persona-rounded-2xl",
@@ -14884,12 +15315,12 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14884
15315
  if (idlePlugin == null ? void 0 : idlePlugin.renderIdleIndicator) {
14885
15316
  idleIndicator = idlePlugin.renderIdleIndicator(idleIndicatorContext);
14886
15317
  }
14887
- if (idleIndicator === null && ((_c2 = config.loadingIndicator) == null ? void 0 : _c2.renderIdle)) {
15318
+ if (idleIndicator === null && ((_e2 = config.loadingIndicator) == null ? void 0 : _e2.renderIdle)) {
14888
15319
  idleIndicator = config.loadingIndicator.renderIdle(idleIndicatorContext);
14889
15320
  }
14890
15321
  if (idleIndicator) {
14891
15322
  const idleBubble = document.createElement("div");
14892
- const showBubble = ((_d2 = config.loadingIndicator) == null ? void 0 : _d2.showBubble) !== false;
15323
+ const showBubble = ((_f2 = config.loadingIndicator) == null ? void 0 : _f2.showBubble) !== false;
14893
15324
  idleBubble.className = showBubble ? [
14894
15325
  "persona-max-w-[85%]",
14895
15326
  "persona-rounded-2xl",
@@ -15922,13 +16353,17 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15922
16353
  }
15923
16354
  const controller = {
15924
16355
  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;
16356
+ 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;
15926
16357
  const previousToolCallConfig = config.toolCall;
15927
16358
  const previousMessageActions = config.messageActions;
15928
16359
  const previousLayoutMessages = (_a2 = config.layout) == null ? void 0 : _a2.messages;
15929
16360
  const previousColorScheme = config.colorScheme;
15930
16361
  const previousLoadingIndicator = config.loadingIndicator;
15931
16362
  const previousIterationDisplay = config.iterationDisplay;
16363
+ const previousShowReasoning = (_b2 = config.features) == null ? void 0 : _b2.showReasoning;
16364
+ const previousShowToolCalls = (_c2 = config.features) == null ? void 0 : _c2.showToolCalls;
16365
+ const previousToolCallDisplay = (_d2 = config.features) == null ? void 0 : _d2.toolCallDisplay;
16366
+ const previousReasoningDisplay = (_e2 = config.features) == null ? void 0 : _e2.reasoningDisplay;
15932
16367
  config = { ...config, ...nextConfig };
15933
16368
  applyFullHeightStyles();
15934
16369
  applyThemeVariables(mount, config);
@@ -15941,15 +16376,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15941
16376
  const newPlugins = pluginRegistry.getForInstance(config.plugins);
15942
16377
  plugins.length = 0;
15943
16378
  plugins.push(...newPlugins);
15944
- launcherEnabled = (_c2 = (_b2 = config.launcher) == null ? void 0 : _b2.enabled) != null ? _c2 : true;
15945
- autoExpand = (_e2 = (_d2 = config.launcher) == null ? void 0 : _d2.autoExpand) != null ? _e2 : false;
15946
- showReasoning = (_g2 = (_f2 = config.features) == null ? void 0 : _f2.showReasoning) != null ? _g2 : true;
15947
- showToolCalls = (_i2 = (_h2 = config.features) == null ? void 0 : _h2.showToolCalls) != null ? _i2 : true;
15948
- scrollToBottomFeature = (_k2 = (_j2 = config.features) == null ? void 0 : _j2.scrollToBottom) != null ? _k2 : {};
16379
+ launcherEnabled = (_g2 = (_f2 = config.launcher) == null ? void 0 : _f2.enabled) != null ? _g2 : true;
16380
+ autoExpand = (_i2 = (_h2 = config.launcher) == null ? void 0 : _h2.autoExpand) != null ? _i2 : false;
16381
+ showReasoning = (_k2 = (_j2 = config.features) == null ? void 0 : _j2.showReasoning) != null ? _k2 : true;
16382
+ showToolCalls = (_m2 = (_l2 = config.features) == null ? void 0 : _l2.showToolCalls) != null ? _m2 : true;
16383
+ scrollToBottomFeature = (_o2 = (_n2 = config.features) == null ? void 0 : _n2.scrollToBottom) != null ? _o2 : {};
15949
16384
  renderScrollToBottomButton();
15950
16385
  syncScrollToBottomButton();
15951
16386
  const prevShowEventStreamToggle = showEventStreamToggle;
15952
- showEventStreamToggle = (_m2 = (_l2 = config.features) == null ? void 0 : _l2.showEventStreamToggle) != null ? _m2 : false;
16387
+ showEventStreamToggle = (_q2 = (_p2 = config.features) == null ? void 0 : _p2.showEventStreamToggle) != null ? _q2 : false;
15953
16388
  if (showEventStreamToggle && !prevShowEventStreamToggle) {
15954
16389
  if (!eventStreamBuffer) {
15955
16390
  eventStreamStore = new EventStreamStore(eventStreamDbName);
@@ -15966,7 +16401,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15966
16401
  });
15967
16402
  }
15968
16403
  if (!eventStreamToggleBtn && header) {
15969
- const dynEsClassNames = (_o2 = (_n2 = config.features) == null ? void 0 : _n2.eventStream) == null ? void 0 : _o2.classNames;
16404
+ const dynEsClassNames = (_s2 = (_r2 = config.features) == null ? void 0 : _r2.eventStream) == null ? void 0 : _s2.classNames;
15970
16405
  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
16406
  eventStreamToggleBtn = createElement("button", dynToggleBtnClasses);
15972
16407
  eventStreamToggleBtn.style.width = "28px";
@@ -16004,15 +16439,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16004
16439
  eventStreamBuffer = null;
16005
16440
  eventStreamStore = null;
16006
16441
  }
16007
- if (((_p2 = config.launcher) == null ? void 0 : _p2.enabled) === false && launcherButtonInstance) {
16442
+ if (((_t2 = config.launcher) == null ? void 0 : _t2.enabled) === false && launcherButtonInstance) {
16008
16443
  launcherButtonInstance.destroy();
16009
16444
  launcherButtonInstance = null;
16010
16445
  }
16011
- if (((_q2 = config.launcher) == null ? void 0 : _q2.enabled) === false && customLauncherElement) {
16446
+ if (((_u2 = config.launcher) == null ? void 0 : _u2.enabled) === false && customLauncherElement) {
16012
16447
  customLauncherElement.remove();
16013
16448
  customLauncherElement = null;
16014
16449
  }
16015
- if (((_r2 = config.launcher) == null ? void 0 : _r2.enabled) !== false && !launcherButtonInstance && !customLauncherElement) {
16450
+ if (((_v2 = config.launcher) == null ? void 0 : _v2.enabled) !== false && !launcherButtonInstance && !customLauncherElement) {
16016
16451
  const launcherPlugin = plugins.find((p) => p.renderLauncher);
16017
16452
  if (launcherPlugin == null ? void 0 : launcherPlugin.renderLauncher) {
16018
16453
  const customLauncher = launcherPlugin.renderLauncher({
@@ -16036,13 +16471,13 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16036
16471
  if (launcherButtonInstance) {
16037
16472
  launcherButtonInstance.update(config);
16038
16473
  }
16039
- if (headerTitle && ((_s2 = config.launcher) == null ? void 0 : _s2.title) !== void 0) {
16474
+ if (headerTitle && ((_w2 = config.launcher) == null ? void 0 : _w2.title) !== void 0) {
16040
16475
  headerTitle.textContent = config.launcher.title;
16041
16476
  }
16042
- if (headerSubtitle && ((_t2 = config.launcher) == null ? void 0 : _t2.subtitle) !== void 0) {
16477
+ if (headerSubtitle && ((_x2 = config.launcher) == null ? void 0 : _x2.subtitle) !== void 0) {
16043
16478
  headerSubtitle.textContent = config.launcher.subtitle;
16044
16479
  }
16045
- const headerLayoutConfig = (_u2 = config.layout) == null ? void 0 : _u2.header;
16480
+ const headerLayoutConfig = (_y2 = config.layout) == null ? void 0 : _y2.header;
16046
16481
  const headerLayoutChanged = (headerLayoutConfig == null ? void 0 : headerLayoutConfig.layout) !== prevHeaderLayout;
16047
16482
  if (headerLayoutChanged && header) {
16048
16483
  const newHeaderElements = headerLayoutConfig ? buildHeaderWithLayout(config, headerLayoutConfig, {
@@ -16088,11 +16523,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16088
16523
  }
16089
16524
  }
16090
16525
  }
16091
- const showHeader = ((_v2 = config.layout) == null ? void 0 : _v2.showHeader) !== false;
16526
+ const showHeader = ((_z2 = config.layout) == null ? void 0 : _z2.showHeader) !== false;
16092
16527
  if (header) {
16093
16528
  header.style.display = showHeader ? "" : "none";
16094
16529
  }
16095
- const showFooter = ((_w2 = config.layout) == null ? void 0 : _w2.showFooter) !== false;
16530
+ const showFooter = ((_A2 = config.layout) == null ? void 0 : _A2.showFooter) !== false;
16096
16531
  if (footer) {
16097
16532
  footer.style.display = showFooter ? "" : "none";
16098
16533
  }
@@ -16116,20 +16551,21 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16116
16551
  refreshCloseButton();
16117
16552
  const toolCallConfigChanged = JSON.stringify(nextConfig.toolCall) !== JSON.stringify(previousToolCallConfig);
16118
16553
  const messageActionsChanged = JSON.stringify(config.messageActions) !== JSON.stringify(previousMessageActions);
16119
- const layoutMessagesChanged = JSON.stringify((_x2 = config.layout) == null ? void 0 : _x2.messages) !== JSON.stringify(previousLayoutMessages);
16120
- const loadingIndicatorChanged = ((_y2 = config.loadingIndicator) == null ? void 0 : _y2.render) !== (previousLoadingIndicator == null ? void 0 : previousLoadingIndicator.render) || ((_z2 = config.loadingIndicator) == null ? void 0 : _z2.renderIdle) !== (previousLoadingIndicator == null ? void 0 : previousLoadingIndicator.renderIdle) || ((_A2 = config.loadingIndicator) == null ? void 0 : _A2.showBubble) !== (previousLoadingIndicator == null ? void 0 : previousLoadingIndicator.showBubble);
16554
+ const layoutMessagesChanged = JSON.stringify((_B2 = config.layout) == null ? void 0 : _B2.messages) !== JSON.stringify(previousLayoutMessages);
16555
+ 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
16556
  const iterationDisplayChanged = config.iterationDisplay !== previousIterationDisplay;
16122
- const messagesConfigChanged = toolCallConfigChanged || messageActionsChanged || layoutMessagesChanged || loadingIndicatorChanged || iterationDisplayChanged;
16557
+ 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);
16558
+ const messagesConfigChanged = toolCallConfigChanged || messageActionsChanged || layoutMessagesChanged || loadingIndicatorChanged || iterationDisplayChanged || featuresChanged;
16123
16559
  if (messagesConfigChanged && session) {
16124
16560
  configVersion++;
16125
16561
  renderMessagesWithPlugins(messagesWrapper, session.getMessages(), postprocess);
16126
16562
  }
16127
- const launcher = (_B2 = config.launcher) != null ? _B2 : {};
16128
- const headerIconHidden = (_C2 = launcher.headerIconHidden) != null ? _C2 : false;
16129
- const layoutShowIcon = (_E2 = (_D2 = config.layout) == null ? void 0 : _D2.header) == null ? void 0 : _E2.showIcon;
16563
+ const launcher = (_L2 = config.launcher) != null ? _L2 : {};
16564
+ const headerIconHidden = (_M2 = launcher.headerIconHidden) != null ? _M2 : false;
16565
+ const layoutShowIcon = (_O = (_N2 = config.layout) == null ? void 0 : _N2.header) == null ? void 0 : _O.showIcon;
16130
16566
  const shouldHideIcon = headerIconHidden || layoutShowIcon === false;
16131
16567
  const headerIconName = launcher.headerIconName;
16132
- const headerIconSize = (_F2 = launcher.headerIconSize) != null ? _F2 : "48px";
16568
+ const headerIconSize = (_P = launcher.headerIconSize) != null ? _P : "48px";
16133
16569
  if (iconHolder) {
16134
16570
  const headerEl = container.querySelector(".persona-border-b-persona-divider");
16135
16571
  const headerCopy = headerEl == null ? void 0 : headerEl.querySelector(".persona-flex-col");
@@ -16156,7 +16592,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16156
16592
  if (iconSvg) {
16157
16593
  iconHolder.replaceChildren(iconSvg);
16158
16594
  } else {
16159
- iconHolder.textContent = (_G2 = launcher.agentIconText) != null ? _G2 : "\u{1F4AC}";
16595
+ iconHolder.textContent = (_Q = launcher.agentIconText) != null ? _Q : "\u{1F4AC}";
16160
16596
  }
16161
16597
  } else if (launcher.iconUrl) {
16162
16598
  const img2 = iconHolder.querySelector("img");
@@ -16179,7 +16615,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16179
16615
  if (existingSvg || existingImg) {
16180
16616
  iconHolder.replaceChildren();
16181
16617
  }
16182
- iconHolder.textContent = (_H2 = launcher.agentIconText) != null ? _H2 : "\u{1F4AC}";
16618
+ iconHolder.textContent = (_R = launcher.agentIconText) != null ? _R : "\u{1F4AC}";
16183
16619
  }
16184
16620
  const img = iconHolder.querySelector("img");
16185
16621
  if (img) {
@@ -16188,8 +16624,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16188
16624
  }
16189
16625
  }
16190
16626
  }
16191
- const layoutShowTitle = (_J2 = (_I2 = config.layout) == null ? void 0 : _I2.header) == null ? void 0 : _J2.showTitle;
16192
- const layoutShowSubtitle = (_L2 = (_K2 = config.layout) == null ? void 0 : _K2.header) == null ? void 0 : _L2.showSubtitle;
16627
+ const layoutShowTitle = (_T = (_S = config.layout) == null ? void 0 : _S.header) == null ? void 0 : _T.showTitle;
16628
+ const layoutShowSubtitle = (_V = (_U = config.layout) == null ? void 0 : _U.header) == null ? void 0 : _V.showSubtitle;
16193
16629
  if (headerTitle) {
16194
16630
  headerTitle.style.display = layoutShowTitle === false ? "none" : "";
16195
16631
  }
@@ -16197,14 +16633,14 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16197
16633
  headerSubtitle.style.display = layoutShowSubtitle === false ? "none" : "";
16198
16634
  }
16199
16635
  if (closeButton) {
16200
- const layoutShowCloseButton = (_N2 = (_M2 = config.layout) == null ? void 0 : _M2.header) == null ? void 0 : _N2.showCloseButton;
16636
+ const layoutShowCloseButton = (_X = (_W = config.layout) == null ? void 0 : _W.header) == null ? void 0 : _X.showCloseButton;
16201
16637
  if (layoutShowCloseButton === false) {
16202
16638
  closeButton.style.display = "none";
16203
16639
  } else {
16204
16640
  closeButton.style.display = "";
16205
16641
  }
16206
- const closeButtonSize = (_O = launcher.closeButtonSize) != null ? _O : "32px";
16207
- const closeButtonPlacement = (_P = launcher.closeButtonPlacement) != null ? _P : "inline";
16642
+ const closeButtonSize = (_Y = launcher.closeButtonSize) != null ? _Y : "32px";
16643
+ const closeButtonPlacement = (_Z = launcher.closeButtonPlacement) != null ? _Z : "inline";
16208
16644
  closeButton.style.height = closeButtonSize;
16209
16645
  closeButton.style.width = closeButtonSize;
16210
16646
  const { closeButtonWrapper } = panelElements;
@@ -16217,8 +16653,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16217
16653
  container.style.position = "relative";
16218
16654
  container.appendChild(closeButtonWrapper);
16219
16655
  } else {
16220
- const clearChatPlacement = (_R = (_Q = launcher.clearChat) == null ? void 0 : _Q.placement) != null ? _R : "inline";
16221
- const clearChatEnabled = (_T = (_S = launcher.clearChat) == null ? void 0 : _S.enabled) != null ? _T : true;
16656
+ const clearChatPlacement = (_$ = (__ = launcher.clearChat) == null ? void 0 : __.placement) != null ? _$ : "inline";
16657
+ const clearChatEnabled = (_ba = (_aa = launcher.clearChat) == null ? void 0 : _aa.enabled) != null ? _ba : true;
16222
16658
  closeButtonWrapper.className = clearChatEnabled && clearChatPlacement === "inline" ? "" : "persona-ml-auto";
16223
16659
  const header2 = container.querySelector(".persona-border-b-persona-divider");
16224
16660
  if (header2) {
@@ -16264,8 +16700,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16264
16700
  closeButton.style.paddingTop = "";
16265
16701
  closeButton.style.paddingBottom = "";
16266
16702
  }
16267
- const closeButtonIconName = (_U = launcher.closeButtonIconName) != null ? _U : "x";
16268
- const closeButtonIconText = (_V = launcher.closeButtonIconText) != null ? _V : "\xD7";
16703
+ const closeButtonIconName = (_ca = launcher.closeButtonIconName) != null ? _ca : "x";
16704
+ const closeButtonIconText = (_da = launcher.closeButtonIconText) != null ? _da : "\xD7";
16269
16705
  closeButton.innerHTML = "";
16270
16706
  const iconSvg = renderLucideIcon(closeButtonIconName, "20px", "currentColor", 2);
16271
16707
  if (iconSvg) {
@@ -16273,8 +16709,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16273
16709
  } else {
16274
16710
  closeButton.textContent = closeButtonIconText;
16275
16711
  }
16276
- const closeButtonTooltipText = (_W = launcher.closeButtonTooltipText) != null ? _W : "Close chat";
16277
- const closeButtonShowTooltip = (_X = launcher.closeButtonShowTooltip) != null ? _X : true;
16712
+ const closeButtonTooltipText = (_ea = launcher.closeButtonTooltipText) != null ? _ea : "Close chat";
16713
+ const closeButtonShowTooltip = (_fa = launcher.closeButtonShowTooltip) != null ? _fa : true;
16278
16714
  closeButton.setAttribute("aria-label", closeButtonTooltipText);
16279
16715
  if (closeButtonWrapper) {
16280
16716
  if (closeButtonWrapper._cleanupTooltip) {
@@ -16331,11 +16767,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16331
16767
  }
16332
16768
  const { clearChatButton, clearChatButtonWrapper } = panelElements;
16333
16769
  if (clearChatButton) {
16334
- const clearChatConfig = (_Y = launcher.clearChat) != null ? _Y : {};
16335
- const clearChatEnabled = (_Z = clearChatConfig.enabled) != null ? _Z : true;
16336
- const layoutShowClearChat = (_$ = (__ = config.layout) == null ? void 0 : __.header) == null ? void 0 : _$.showClearChat;
16770
+ const clearChatConfig = (_ga = launcher.clearChat) != null ? _ga : {};
16771
+ const clearChatEnabled = (_ha = clearChatConfig.enabled) != null ? _ha : true;
16772
+ const layoutShowClearChat = (_ja = (_ia = config.layout) == null ? void 0 : _ia.header) == null ? void 0 : _ja.showClearChat;
16337
16773
  const shouldShowClearChat = layoutShowClearChat !== void 0 ? layoutShowClearChat : clearChatEnabled;
16338
- const clearChatPlacement = (_aa = clearChatConfig.placement) != null ? _aa : "inline";
16774
+ const clearChatPlacement = (_ka = clearChatConfig.placement) != null ? _ka : "inline";
16339
16775
  if (clearChatButtonWrapper) {
16340
16776
  clearChatButtonWrapper.style.display = shouldShowClearChat ? "" : "none";
16341
16777
  const { closeButtonWrapper } = panelElements;
@@ -16377,11 +16813,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16377
16813
  }
16378
16814
  }
16379
16815
  if (shouldShowClearChat) {
16380
- const clearChatSize = (_ba = clearChatConfig.size) != null ? _ba : "32px";
16816
+ const clearChatSize = (_la = clearChatConfig.size) != null ? _la : "32px";
16381
16817
  clearChatButton.style.height = clearChatSize;
16382
16818
  clearChatButton.style.width = clearChatSize;
16383
- const clearChatIconName = (_ca = clearChatConfig.iconName) != null ? _ca : "refresh-cw";
16384
- const clearChatIconColor = (_da = clearChatConfig.iconColor) != null ? _da : "";
16819
+ const clearChatIconName = (_ma = clearChatConfig.iconName) != null ? _ma : "refresh-cw";
16820
+ const clearChatIconColor = (_na = clearChatConfig.iconColor) != null ? _na : "";
16385
16821
  clearChatButton.style.color = clearChatIconColor || HEADER_THEME_CSS.actionIconColor;
16386
16822
  clearChatButton.innerHTML = "";
16387
16823
  const iconSvg = renderLucideIcon(clearChatIconName, "20px", "currentColor", 2);
@@ -16425,8 +16861,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16425
16861
  clearChatButton.style.paddingTop = "";
16426
16862
  clearChatButton.style.paddingBottom = "";
16427
16863
  }
16428
- const clearChatTooltipText = (_ea = clearChatConfig.tooltipText) != null ? _ea : "Clear chat";
16429
- const clearChatShowTooltip = (_fa = clearChatConfig.showTooltip) != null ? _fa : true;
16864
+ const clearChatTooltipText = (_oa = clearChatConfig.tooltipText) != null ? _oa : "Clear chat";
16865
+ const clearChatShowTooltip = (_pa = clearChatConfig.showTooltip) != null ? _pa : true;
16430
16866
  clearChatButton.setAttribute("aria-label", clearChatTooltipText);
16431
16867
  if (clearChatButtonWrapper) {
16432
16868
  if (clearChatButtonWrapper._cleanupTooltip) {
@@ -16502,9 +16938,9 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16502
16938
  suggestionsManager.render(config.suggestionChips, session, textarea, void 0, config.suggestionChipsConfig);
16503
16939
  updateCopy();
16504
16940
  setComposerDisabled(session.isStreaming());
16505
- const voiceRecognitionEnabled = ((_ga = config.voiceRecognition) == null ? void 0 : _ga.enabled) === true;
16941
+ const voiceRecognitionEnabled = ((_qa = config.voiceRecognition) == null ? void 0 : _qa.enabled) === true;
16506
16942
  const hasSpeechRecognition = typeof window !== "undefined" && (typeof window.webkitSpeechRecognition !== "undefined" || typeof window.SpeechRecognition !== "undefined");
16507
- const hasRuntypeProvider = ((_ia = (_ha = config.voiceRecognition) == null ? void 0 : _ha.provider) == null ? void 0 : _ia.type) === "runtype";
16943
+ const hasRuntypeProvider = ((_sa = (_ra = config.voiceRecognition) == null ? void 0 : _ra.provider) == null ? void 0 : _sa.type) === "runtype";
16508
16944
  const hasVoiceInput = hasSpeechRecognition || hasRuntypeProvider;
16509
16945
  if (voiceRecognitionEnabled && hasVoiceInput) {
16510
16946
  if (!micButton || !micButtonWrapper) {
@@ -16517,17 +16953,17 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16517
16953
  micButton.disabled = session.isStreaming();
16518
16954
  }
16519
16955
  } else {
16520
- const voiceConfig = (_ja = config.voiceRecognition) != null ? _ja : {};
16521
- const sendButtonConfig2 = (_ka = config.sendButton) != null ? _ka : {};
16522
- const micIconName = (_la = voiceConfig.iconName) != null ? _la : "mic";
16523
- const buttonSize2 = (_ma = sendButtonConfig2.size) != null ? _ma : "40px";
16524
- const micIconSize = (_na = voiceConfig.iconSize) != null ? _na : buttonSize2;
16956
+ const voiceConfig = (_ta = config.voiceRecognition) != null ? _ta : {};
16957
+ const sendButtonConfig2 = (_ua = config.sendButton) != null ? _ua : {};
16958
+ const micIconName = (_va = voiceConfig.iconName) != null ? _va : "mic";
16959
+ const buttonSize2 = (_wa = sendButtonConfig2.size) != null ? _wa : "40px";
16960
+ const micIconSize = (_xa = voiceConfig.iconSize) != null ? _xa : buttonSize2;
16525
16961
  const micIconSizeNum = parseFloat(micIconSize) || 24;
16526
16962
  micButton.style.width = micIconSize;
16527
16963
  micButton.style.height = micIconSize;
16528
16964
  micButton.style.minWidth = micIconSize;
16529
16965
  micButton.style.minHeight = micIconSize;
16530
- const iconColor = (_pa = (_oa = voiceConfig.iconColor) != null ? _oa : sendButtonConfig2.textColor) != null ? _pa : "currentColor";
16966
+ const iconColor = (_za = (_ya = voiceConfig.iconColor) != null ? _ya : sendButtonConfig2.textColor) != null ? _za : "currentColor";
16531
16967
  micButton.innerHTML = "";
16532
16968
  const micIconSvg = renderLucideIcon(micIconName, micIconSizeNum, iconColor, 2);
16533
16969
  if (micIconSvg) {
@@ -16535,7 +16971,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16535
16971
  } else {
16536
16972
  micButton.textContent = "\u{1F3A4}";
16537
16973
  }
16538
- const backgroundColor2 = (_qa = voiceConfig.backgroundColor) != null ? _qa : sendButtonConfig2.backgroundColor;
16974
+ const backgroundColor2 = (_Aa = voiceConfig.backgroundColor) != null ? _Aa : sendButtonConfig2.backgroundColor;
16539
16975
  if (backgroundColor2) {
16540
16976
  micButton.style.backgroundColor = backgroundColor2;
16541
16977
  } else {
@@ -16573,8 +17009,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16573
17009
  micButton.style.paddingBottom = "";
16574
17010
  }
16575
17011
  const tooltip2 = micButtonWrapper == null ? void 0 : micButtonWrapper.querySelector(".persona-send-button-tooltip");
16576
- const tooltipText2 = (_ra = voiceConfig.tooltipText) != null ? _ra : "Start voice recognition";
16577
- const showTooltip2 = (_sa = voiceConfig.showTooltip) != null ? _sa : false;
17012
+ const tooltipText2 = (_Ba = voiceConfig.tooltipText) != null ? _Ba : "Start voice recognition";
17013
+ const showTooltip2 = (_Ca = voiceConfig.showTooltip) != null ? _Ca : false;
16578
17014
  if (showTooltip2 && tooltipText2) {
16579
17015
  if (!tooltip2) {
16580
17016
  const newTooltip = document.createElement("div");
@@ -16594,19 +17030,19 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16594
17030
  } else {
16595
17031
  if (micButton && micButtonWrapper) {
16596
17032
  micButtonWrapper.style.display = "none";
16597
- if (((_ua = (_ta = config.voiceRecognition) == null ? void 0 : _ta.provider) == null ? void 0 : _ua.type) === "runtype") {
17033
+ if (((_Ea = (_Da = config.voiceRecognition) == null ? void 0 : _Da.provider) == null ? void 0 : _Ea.type) === "runtype") {
16598
17034
  if (session.isVoiceActive()) session.toggleVoice();
16599
17035
  } else if (isRecording) {
16600
17036
  stopVoiceRecognition();
16601
17037
  }
16602
17038
  }
16603
17039
  }
16604
- const attachmentsEnabled = ((_va = config.attachments) == null ? void 0 : _va.enabled) === true;
17040
+ const attachmentsEnabled = ((_Fa = config.attachments) == null ? void 0 : _Fa.enabled) === true;
16605
17041
  if (attachmentsEnabled) {
16606
17042
  if (!attachmentButtonWrapper || !attachmentButton) {
16607
- const attachmentsConfig = (_wa = config.attachments) != null ? _wa : {};
16608
- const sendButtonConfig2 = (_xa = config.sendButton) != null ? _xa : {};
16609
- const buttonSize2 = (_ya = sendButtonConfig2.size) != null ? _ya : "40px";
17043
+ const attachmentsConfig = (_Ga = config.attachments) != null ? _Ga : {};
17044
+ const sendButtonConfig2 = (_Ha = config.sendButton) != null ? _Ha : {};
17045
+ const buttonSize2 = (_Ia = sendButtonConfig2.size) != null ? _Ia : "40px";
16610
17046
  if (!attachmentPreviewsContainer) {
16611
17047
  attachmentPreviewsContainer = createElement("div", "persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2");
16612
17048
  attachmentPreviewsContainer.style.display = "none";
@@ -16615,8 +17051,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16615
17051
  if (!attachmentInput) {
16616
17052
  attachmentInput = document.createElement("input");
16617
17053
  attachmentInput.type = "file";
16618
- attachmentInput.accept = ((_za = attachmentsConfig.allowedTypes) != null ? _za : ALL_SUPPORTED_MIME_TYPES).join(",");
16619
- attachmentInput.multiple = ((_Aa = attachmentsConfig.maxFiles) != null ? _Aa : 4) > 1;
17054
+ attachmentInput.accept = ((_Ja = attachmentsConfig.allowedTypes) != null ? _Ja : ALL_SUPPORTED_MIME_TYPES).join(",");
17055
+ attachmentInput.multiple = ((_Ka = attachmentsConfig.maxFiles) != null ? _Ka : 4) > 1;
16620
17056
  attachmentInput.style.display = "none";
16621
17057
  attachmentInput.setAttribute("aria-label", "Attach files");
16622
17058
  composerForm.insertBefore(attachmentInput, textarea);
@@ -16627,8 +17063,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16627
17063
  "persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-attachment-button"
16628
17064
  );
16629
17065
  attachmentButton.type = "button";
16630
- attachmentButton.setAttribute("aria-label", (_Ba = attachmentsConfig.buttonTooltipText) != null ? _Ba : "Attach file");
16631
- const attachIconName = (_Ca = attachmentsConfig.buttonIconName) != null ? _Ca : "paperclip";
17066
+ attachmentButton.setAttribute("aria-label", (_La = attachmentsConfig.buttonTooltipText) != null ? _La : "Attach file");
17067
+ const attachIconName = (_Ma = attachmentsConfig.buttonIconName) != null ? _Ma : "paperclip";
16632
17068
  const attachIconSize = buttonSize2;
16633
17069
  const buttonSizeNum = parseFloat(attachIconSize) || 40;
16634
17070
  const attachIconSizeNum = Math.round(buttonSizeNum * 0.6);
@@ -16660,7 +17096,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16660
17096
  attachmentInput == null ? void 0 : attachmentInput.click();
16661
17097
  });
16662
17098
  attachmentButtonWrapper.appendChild(attachmentButton);
16663
- const attachTooltipText = (_Da = attachmentsConfig.buttonTooltipText) != null ? _Da : "Attach file";
17099
+ const attachTooltipText = (_Na = attachmentsConfig.buttonTooltipText) != null ? _Na : "Attach file";
16664
17100
  const tooltip2 = createElement("div", "persona-send-button-tooltip");
16665
17101
  tooltip2.textContent = attachTooltipText;
16666
17102
  attachmentButtonWrapper.appendChild(tooltip2);
@@ -16677,10 +17113,10 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16677
17113
  }
16678
17114
  } else {
16679
17115
  attachmentButtonWrapper.style.display = "";
16680
- const attachmentsConfig = (_Ea = config.attachments) != null ? _Ea : {};
17116
+ const attachmentsConfig = (_Oa = config.attachments) != null ? _Oa : {};
16681
17117
  if (attachmentInput) {
16682
- attachmentInput.accept = ((_Fa = attachmentsConfig.allowedTypes) != null ? _Fa : ALL_SUPPORTED_MIME_TYPES).join(",");
16683
- attachmentInput.multiple = ((_Ga = attachmentsConfig.maxFiles) != null ? _Ga : 4) > 1;
17118
+ attachmentInput.accept = ((_Pa = attachmentsConfig.allowedTypes) != null ? _Pa : ALL_SUPPORTED_MIME_TYPES).join(",");
17119
+ attachmentInput.multiple = ((_Qa = attachmentsConfig.maxFiles) != null ? _Qa : 4) > 1;
16684
17120
  }
16685
17121
  if (attachmentManager) {
16686
17122
  attachmentManager.updateConfig({
@@ -16698,13 +17134,13 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16698
17134
  attachmentManager.clearAttachments();
16699
17135
  }
16700
17136
  }
16701
- const sendButtonConfig = (_Ha = config.sendButton) != null ? _Ha : {};
16702
- const useIcon = (_Ia = sendButtonConfig.useIcon) != null ? _Ia : false;
16703
- const iconText = (_Ja = sendButtonConfig.iconText) != null ? _Ja : "\u2191";
17137
+ const sendButtonConfig = (_Ra = config.sendButton) != null ? _Ra : {};
17138
+ const useIcon = (_Sa = sendButtonConfig.useIcon) != null ? _Sa : false;
17139
+ const iconText = (_Ta = sendButtonConfig.iconText) != null ? _Ta : "\u2191";
16704
17140
  const iconName = sendButtonConfig.iconName;
16705
- const tooltipText = (_Ka = sendButtonConfig.tooltipText) != null ? _Ka : "Send message";
16706
- const showTooltip = (_La = sendButtonConfig.showTooltip) != null ? _La : false;
16707
- const buttonSize = (_Ma = sendButtonConfig.size) != null ? _Ma : "40px";
17141
+ const tooltipText = (_Ua = sendButtonConfig.tooltipText) != null ? _Ua : "Send message";
17142
+ const showTooltip = (_Va = sendButtonConfig.showTooltip) != null ? _Va : false;
17143
+ const buttonSize = (_Wa = sendButtonConfig.size) != null ? _Wa : "40px";
16708
17144
  const backgroundColor = sendButtonConfig.backgroundColor;
16709
17145
  const textColor = sendButtonConfig.textColor;
16710
17146
  if (useIcon) {
@@ -16741,7 +17177,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16741
17177
  sendButton.classList.add("persona-bg-persona-primary");
16742
17178
  }
16743
17179
  } else {
16744
- sendButton.textContent = (_Oa = (_Na = config.copy) == null ? void 0 : _Na.sendButtonLabel) != null ? _Oa : "Send";
17180
+ sendButton.textContent = (_Ya = (_Xa = config.copy) == null ? void 0 : _Xa.sendButtonLabel) != null ? _Ya : "Send";
16745
17181
  sendButton.style.width = "";
16746
17182
  sendButton.style.height = "";
16747
17183
  sendButton.style.minWidth = "";
@@ -16801,7 +17237,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16801
17237
  } else if (tooltip) {
16802
17238
  tooltip.style.display = "none";
16803
17239
  }
16804
- const updatedContentMaxWidth = (_Pa = config.layout) == null ? void 0 : _Pa.contentMaxWidth;
17240
+ const updatedContentMaxWidth = (_Za = config.layout) == null ? void 0 : _Za.contentMaxWidth;
16805
17241
  if (updatedContentMaxWidth) {
16806
17242
  messagesWrapper.style.maxWidth = updatedContentMaxWidth;
16807
17243
  messagesWrapper.style.marginLeft = "auto";
@@ -16833,8 +17269,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16833
17269
  suggestions.style.marginRight = "";
16834
17270
  }
16835
17271
  }
16836
- const statusIndicatorConfig = (_Qa = config.statusIndicator) != null ? _Qa : {};
16837
- const isVisible = (_Ra = statusIndicatorConfig.visible) != null ? _Ra : true;
17272
+ const statusIndicatorConfig = (__a = config.statusIndicator) != null ? __a : {};
17273
+ const isVisible = (_$a = statusIndicatorConfig.visible) != null ? _$a : true;
16838
17274
  statusText.style.display = isVisible ? "" : "none";
16839
17275
  if (session) {
16840
17276
  const currentStatus = session.getStatus();
@@ -17890,7 +18326,166 @@ function buildSrcdoc(mountId, shellMode, docked, widgetCssPath) {
17890
18326
  </body>
17891
18327
  </html>`;
17892
18328
  }
17893
- function createPreviewMessages(scene) {
18329
+ var PREVIEW_TRANSCRIPT_PRESET_LABELS = {
18330
+ "user-message": "User message",
18331
+ "assistant-message": "Assistant message",
18332
+ "reasoning-streaming": "Reasoning (streaming)",
18333
+ "reasoning-complete": "Reasoning (complete)",
18334
+ "tool-running": "Tool call (running)",
18335
+ "tool-complete": "Tool call (complete)"
18336
+ };
18337
+ function getPreviewTranscriptPresetLabel(preset) {
18338
+ return PREVIEW_TRANSCRIPT_PRESET_LABELS[preset];
18339
+ }
18340
+ function createPreviewTranscriptEntry(preset, index = 0) {
18341
+ const createdAt = new Date(Date.now() - Math.max(0, 60 - index) * 1e3).toISOString();
18342
+ const suffix = `${preset}-${index}`;
18343
+ switch (preset) {
18344
+ case "user-message":
18345
+ return {
18346
+ id: `preview-seq-user-${suffix}`,
18347
+ role: "user",
18348
+ content: "Can you continue with the next step?",
18349
+ createdAt
18350
+ };
18351
+ case "assistant-message":
18352
+ return {
18353
+ id: `preview-seq-assistant-${suffix}`,
18354
+ role: "assistant",
18355
+ content: "Absolutely. I can keep going and explain what happens next.",
18356
+ createdAt
18357
+ };
18358
+ case "reasoning-streaming":
18359
+ return {
18360
+ id: `preview-seq-reasoning-stream-${suffix}`,
18361
+ role: "assistant",
18362
+ content: "",
18363
+ createdAt,
18364
+ streaming: true,
18365
+ variant: "reasoning",
18366
+ reasoning: {
18367
+ id: `preview-reasoning-stream-${suffix}`,
18368
+ status: "streaming",
18369
+ chunks: ["Thinking through the next step in the workflow..."]
18370
+ }
18371
+ };
18372
+ case "reasoning-complete":
18373
+ return {
18374
+ id: `preview-seq-reasoning-complete-${suffix}`,
18375
+ role: "assistant",
18376
+ content: "",
18377
+ createdAt,
18378
+ streaming: false,
18379
+ variant: "reasoning",
18380
+ reasoning: {
18381
+ id: `preview-reasoning-complete-${suffix}`,
18382
+ status: "complete",
18383
+ chunks: ["Reviewed the requirements and finalized the reasoning output."],
18384
+ durationMs: 1200
18385
+ }
18386
+ };
18387
+ case "tool-complete":
18388
+ return {
18389
+ id: `preview-seq-tool-complete-${suffix}`,
18390
+ role: "assistant",
18391
+ content: "",
18392
+ createdAt,
18393
+ streaming: false,
18394
+ variant: "tool",
18395
+ toolCall: {
18396
+ id: `preview-tool-complete-${suffix}`,
18397
+ name: "Create build instructions",
18398
+ status: "complete",
18399
+ chunks: ["Prepared the build instructions and validated the inputs."],
18400
+ result: { ok: true },
18401
+ duration: 420
18402
+ }
18403
+ };
18404
+ case "tool-running":
18405
+ default:
18406
+ return {
18407
+ id: `preview-seq-tool-running-${suffix}`,
18408
+ role: "assistant",
18409
+ content: "",
18410
+ createdAt,
18411
+ streaming: true,
18412
+ variant: "tool",
18413
+ toolCall: {
18414
+ id: `preview-tool-running-${suffix}`,
18415
+ name: "Get platform documentation",
18416
+ status: "running",
18417
+ chunks: ["Fetching the relevant platform documentation..."]
18418
+ }
18419
+ };
18420
+ }
18421
+ }
18422
+ function appendPreviewTranscriptEntry(messages, preset) {
18423
+ return [...messages, createPreviewTranscriptEntry(preset, messages.length)];
18424
+ }
18425
+ var createAdvancedTranscriptPreviewMessages = () => [
18426
+ {
18427
+ id: "preview-adv-1",
18428
+ role: "user",
18429
+ content: "Can you create the product and gather the docs?",
18430
+ createdAt: new Date(Date.now() - 18e4).toISOString()
18431
+ },
18432
+ {
18433
+ id: "preview-adv-2",
18434
+ role: "assistant",
18435
+ content: "",
18436
+ createdAt: new Date(Date.now() - 15e4).toISOString(),
18437
+ streaming: true,
18438
+ variant: "reasoning",
18439
+ reasoning: {
18440
+ id: "preview-reasoning",
18441
+ status: "streaming",
18442
+ chunks: [
18443
+ "Now let me get the Persona embed documentation and builtin tools catalog."
18444
+ ]
18445
+ }
18446
+ },
18447
+ {
18448
+ id: "preview-adv-3",
18449
+ role: "assistant",
18450
+ content: "",
18451
+ createdAt: new Date(Date.now() - 12e4).toISOString(),
18452
+ streaming: true,
18453
+ variant: "tool",
18454
+ toolCall: {
18455
+ id: "preview-tool-1",
18456
+ name: "Load tools",
18457
+ status: "running",
18458
+ chunks: ["Loaded tools, used Runtype integration"]
18459
+ }
18460
+ },
18461
+ {
18462
+ id: "preview-adv-4",
18463
+ role: "assistant",
18464
+ content: "",
18465
+ createdAt: new Date(Date.now() - 9e4).toISOString(),
18466
+ streaming: true,
18467
+ variant: "tool",
18468
+ toolCall: {
18469
+ id: "preview-tool-2",
18470
+ name: "Get platform documentation",
18471
+ status: "running",
18472
+ chunks: ["Get platform documentation"]
18473
+ }
18474
+ },
18475
+ {
18476
+ id: "preview-adv-5",
18477
+ role: "assistant",
18478
+ content: "I loaded the tools and fetched the docs. Next I can assemble the product details.",
18479
+ createdAt: new Date(Date.now() - 3e4).toISOString()
18480
+ }
18481
+ ];
18482
+ var shouldSeedAdvancedTranscriptPreview = (config) => {
18483
+ var _a, _b, _c, _d, _e, _f, _g, _h;
18484
+ return Boolean(
18485
+ ((_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)
18486
+ );
18487
+ };
18488
+ function createPreviewMessages(scene, config, appendedMessages = []) {
17894
18489
  if (scene === "home") {
17895
18490
  return [{ id: "preview-home-1", role: "assistant", content: "Hi there! How can we help today?", createdAt: (/* @__PURE__ */ new Date()).toISOString() }];
17896
18491
  }
@@ -17903,20 +18498,24 @@ function createPreviewMessages(scene) {
17903
18498
  { id: "preview-art-2", role: "assistant", content: "Here\u2019s a project overview document for you.", createdAt: new Date(Date.now() - 6e4).toISOString() }
17904
18499
  ];
17905
18500
  }
18501
+ if (scene === "conversation" && shouldSeedAdvancedTranscriptPreview(config)) {
18502
+ return [...createAdvancedTranscriptPreviewMessages(), ...appendedMessages];
18503
+ }
17906
18504
  return [
17907
18505
  { id: "preview-conv-1", role: "assistant", content: "Hello! How can I help you today?", createdAt: new Date(Date.now() - 18e4).toISOString() },
17908
18506
  { 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() }
18507
+ { 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() },
18508
+ ...appendedMessages
17910
18509
  ];
17911
18510
  }
17912
- function applySceneConfig(base, scene) {
18511
+ function applySceneConfig(base, scene, appendedMessages = []) {
17913
18512
  var _a, _b;
17914
18513
  const launcher = { ...base.launcher, enabled: true, autoExpand: scene !== "minimized" };
17915
18514
  const config = {
17916
18515
  ...base,
17917
18516
  launcher,
17918
18517
  suggestionChips: scene === "home" ? ((_a = base.suggestionChips) == null ? void 0 : _a.length) ? base.suggestionChips : HOME_SUGGESTION_CHIPS : base.suggestionChips,
17919
- initialMessages: createPreviewMessages(scene),
18518
+ initialMessages: createPreviewMessages(scene, base, appendedMessages),
17920
18519
  storageAdapter: PREVIEW_STORAGE_ADAPTER
17921
18520
  };
17922
18521
  if (scene === "artifact") {
@@ -17925,6 +18524,19 @@ function applySceneConfig(base, scene) {
17925
18524
  return config;
17926
18525
  }
17927
18526
  function buildPreviewConfig(options, shellModeOverride) {
18527
+ var _a, _b, _c, _d;
18528
+ const theme = options.theme ? createTheme(options.theme, { validate: false }) : createTheme();
18529
+ const scene = (_a = options.scene) != null ? _a : "conversation";
18530
+ const base = {
18531
+ ...DEFAULT_WIDGET_CONFIG,
18532
+ ...options.config,
18533
+ theme,
18534
+ darkTheme: options.darkTheme,
18535
+ colorScheme: (_c = shellModeOverride != null ? shellModeOverride : (_b = options.config) == null ? void 0 : _b.colorScheme) != null ? _c : "light"
18536
+ };
18537
+ return applySceneConfig(base, scene, (_d = options.appendedMessages) != null ? _d : []);
18538
+ }
18539
+ function buildPreviewConfigWithMessages(options, messages, shellModeOverride) {
17928
18540
  var _a, _b, _c;
17929
18541
  const theme = options.theme ? createTheme(options.theme, { validate: false }) : createTheme();
17930
18542
  const scene = (_a = options.scene) != null ? _a : "conversation";
@@ -17935,7 +18547,7 @@ function buildPreviewConfig(options, shellModeOverride) {
17935
18547
  darkTheme: options.darkTheme,
17936
18548
  colorScheme: (_c = shellModeOverride != null ? shellModeOverride : (_b = options.config) == null ? void 0 : _b.colorScheme) != null ? _c : "light"
17937
18549
  };
17938
- return applySceneConfig(base, scene);
18550
+ return applySceneConfig(base, scene, messages);
17939
18551
  }
17940
18552
 
17941
18553
  // src/theme-editor/preview.ts
@@ -18253,20 +18865,24 @@ function createThemePreview(container, initialOptions) {
18253
18865
  ThemeEditorState,
18254
18866
  ZOOM_MAX,
18255
18867
  ZOOM_MIN,
18868
+ appendPreviewTranscriptEntry,
18256
18869
  applySceneConfig,
18257
18870
  applyShellTheme,
18258
18871
  buildPreviewConfig,
18872
+ buildPreviewConfigWithMessages,
18259
18873
  buildShellCss,
18260
18874
  buildSrcdoc,
18261
18875
  convertFromPx,
18262
18876
  convertToPx,
18263
18877
  createPreviewMessages,
18878
+ createPreviewTranscriptEntry,
18264
18879
  createThemePreview,
18265
18880
  detectRoleAssignment,
18266
18881
  escapeHtml,
18267
18882
  findSection,
18268
18883
  formatCssValue,
18269
18884
  generateColorScale,
18885
+ getPreviewTranscriptPresetLabel,
18270
18886
  getShellPalette,
18271
18887
  getThemeEditorPreset,
18272
18888
  hexToHsl,