@runtypelabs/persona 3.9.2 → 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 -43
  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 -64
  6. package/dist/index.global.js.map +1 -1
  7. package/dist/index.js +46 -43
  8. package/dist/index.js.map +1 -1
  9. package/dist/theme-editor.cjs +826 -210
  10. package/dist/theme-editor.d.cts +128 -3
  11. package/dist/theme-editor.d.ts +128 -3
  12. package/dist/theme-editor.js +822 -210
  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 +161 -27
  24. package/src/defaults.ts +12 -0
  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
@@ -118,6 +118,18 @@ var DEFAULT_WIDGET_CONFIG = {
118
118
  enabled: true,
119
119
  iconName: "arrow-down",
120
120
  label: ""
121
+ },
122
+ toolCallDisplay: {
123
+ collapsedMode: "tool-call",
124
+ activePreview: false,
125
+ grouped: false,
126
+ previewMaxLines: 3,
127
+ expandable: true
128
+ },
129
+ reasoningDisplay: {
130
+ activePreview: false,
131
+ previewMaxLines: 3,
132
+ expandable: true
121
133
  }
122
134
  },
123
135
  suggestionChips: [
@@ -2597,6 +2609,16 @@ var debugSectionDef = {
2597
2609
  fields: [
2598
2610
  { id: "dev-reasoning", label: "Show Reasoning", description: "Display AI reasoning steps", type: "toggle", path: "features.showReasoning", defaultValue: false },
2599
2611
  { id: "dev-tool-calls", label: "Show Tool Calls", description: "Display tool call details", type: "toggle", path: "features.showToolCalls", defaultValue: false },
2612
+ { id: "dev-tool-collapsed-mode", label: "Tool Call Summary", description: "Choose what collapsed tool rows show by default", type: "select", path: "features.toolCallDisplay.collapsedMode", defaultValue: "tool-call", options: [{ value: "tool-call", label: "Tool Call" }, { value: "tool-name", label: "Tool Name" }, { value: "tool-preview", label: "Tool Preview" }] },
2613
+ { id: "dev-tool-active-preview", label: "Tool Preview While Active", description: "Show a lightweight preview in collapsed active tool rows", type: "toggle", path: "features.toolCallDisplay.activePreview", defaultValue: false },
2614
+ { id: "dev-tool-preview-lines", label: "Tool Preview Lines", type: "select", path: "features.toolCallDisplay.previewMaxLines", defaultValue: 3, options: [{ value: "1", label: "1" }, { value: "2", label: "2" }, { value: "3", label: "3" }, { value: "4", label: "4" }, { value: "5", label: "5" }], formatValue: (v) => String(v != null ? v : 3), parseValue: (v) => Number(v) },
2615
+ { id: "dev-tool-active-min-height", label: "Tool Active Min Height", description: "CSS min-height for collapsed active tool rows (e.g. 5rem)", type: "text", path: "features.toolCallDisplay.activeMinHeight", defaultValue: "" },
2616
+ { id: "dev-tool-expandable", label: "Tool Calls Expandable", description: "Allow expanding tool call rows to see full details", type: "toggle", path: "features.toolCallDisplay.expandable", defaultValue: true },
2617
+ { id: "dev-tool-grouped", label: "Group Sequential Tool Calls", description: "Render consecutive tool rows inside a grouped container", type: "toggle", path: "features.toolCallDisplay.grouped", defaultValue: false },
2618
+ { id: "dev-reasoning-expandable", label: "Reasoning Expandable", description: "Allow expanding reasoning rows to see full details", type: "toggle", path: "features.reasoningDisplay.expandable", defaultValue: true },
2619
+ { id: "dev-reasoning-active-preview", label: "Reasoning Preview While Active", description: "Show a lightweight preview in collapsed active reasoning rows", type: "toggle", path: "features.reasoningDisplay.activePreview", defaultValue: false },
2620
+ { id: "dev-reasoning-preview-lines", label: "Reasoning Preview Lines", type: "select", path: "features.reasoningDisplay.previewMaxLines", defaultValue: 3, options: [{ value: "1", label: "1" }, { value: "2", label: "2" }, { value: "3", label: "3" }, { value: "4", label: "4" }, { value: "5", label: "5" }], formatValue: (v) => String(v != null ? v : 3), parseValue: (v) => Number(v) },
2621
+ { id: "dev-reasoning-active-min-height", label: "Reasoning Active Min Height", description: "CSS min-height for collapsed active reasoning rows (e.g. 5rem)", type: "text", path: "features.reasoningDisplay.activeMinHeight", defaultValue: "" },
2600
2622
  { id: "dev-debug", label: "Debug Mode", description: "Show debug information", type: "toggle", path: "debug", defaultValue: false }
2601
2623
  ]
2602
2624
  };
@@ -3396,6 +3418,24 @@ function getParserFromType(parserType) {
3396
3418
  return createPlainTextParser;
3397
3419
  }
3398
3420
  }
3421
+ var looksStructured = (value) => value.startsWith("{") || value.startsWith("[") || value.startsWith("<");
3422
+ function preferFinalStructuredContent(rawBuffer, finalString) {
3423
+ if (!rawBuffer) return finalString;
3424
+ const rawTrimmed = rawBuffer.trim();
3425
+ const finalTrimmed = finalString.trim();
3426
+ if (rawTrimmed.length === 0) return finalString;
3427
+ if (finalTrimmed.length === 0) return rawBuffer;
3428
+ const rawLooksStructured = looksStructured(rawTrimmed);
3429
+ const finalLooksStructured = looksStructured(finalTrimmed);
3430
+ if (!finalLooksStructured) return rawBuffer;
3431
+ if (!rawLooksStructured) return finalString;
3432
+ if (finalTrimmed === rawTrimmed) return finalString;
3433
+ if (finalTrimmed.startsWith(rawTrimmed)) return finalString;
3434
+ const rawJsonText = extractTextFromJson(rawBuffer);
3435
+ const finalJsonText = extractTextFromJson(finalString);
3436
+ if (finalJsonText !== null && rawJsonText === null) return finalString;
3437
+ return rawBuffer;
3438
+ }
3399
3439
  var AgentWidgetClient = class {
3400
3440
  constructor(config = {}) {
3401
3441
  this.config = config;
@@ -4114,7 +4154,7 @@ var AgentWidgetClient = class {
4114
4154
  }
4115
4155
  }
4116
4156
  async streamResponse(body, onEvent, assistantMessageId) {
4117
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb;
4157
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb, _lb;
4118
4158
  const reader = body.getReader();
4119
4159
  const decoder = new TextDecoder();
4120
4160
  let buffer = "";
@@ -4354,6 +4394,92 @@ var AgentWidgetClient = class {
4354
4394
  };
4355
4395
  const streamParsers = /* @__PURE__ */ new Map();
4356
4396
  const rawContentBuffers = /* @__PURE__ */ new Map();
4397
+ const seqChunkBuffers = /* @__PURE__ */ new Map();
4398
+ const reasonSeqBuffers = /* @__PURE__ */ new Map();
4399
+ function insertSeqChunk(bufferMap, key, seq, text) {
4400
+ let buf = bufferMap.get(key);
4401
+ if (!buf) {
4402
+ buf = [];
4403
+ bufferMap.set(key, buf);
4404
+ }
4405
+ let lo = 0, hi = buf.length;
4406
+ while (lo < hi) {
4407
+ const mid = lo + hi >>> 1;
4408
+ if (buf[mid].seq < seq) lo = mid + 1;
4409
+ else hi = mid;
4410
+ }
4411
+ buf.splice(lo, 0, { seq, text });
4412
+ let result = "";
4413
+ for (let i = 0; i < buf.length; i++) result += buf[i].text;
4414
+ return result;
4415
+ }
4416
+ let lastSealedTextSegment = null;
4417
+ const reconcileSealedAssistantWithFinalResponse = (msg, finalContent) => {
4418
+ const finalString = ensureStringContent(finalContent);
4419
+ const rawBuffer = rawContentBuffers.get(msg.id);
4420
+ const contentToProcess = preferFinalStructuredContent(rawBuffer, finalString);
4421
+ msg.rawContent = contentToProcess;
4422
+ const parser = streamParsers.get(msg.id);
4423
+ const mergeIfBetter = (mergedDisplay) => {
4424
+ var _a2;
4425
+ const cur = (_a2 = msg.content) != null ? _a2 : "";
4426
+ if (mergedDisplay.trim() === "") return;
4427
+ if (cur.trim().length === 0 || mergedDisplay.startsWith(cur) || mergedDisplay.trimStart().startsWith(cur.trim())) {
4428
+ msg.content = mergedDisplay;
4429
+ }
4430
+ };
4431
+ const finalizeCleanup = () => {
4432
+ var _a2;
4433
+ if (parser) {
4434
+ const closeResult = (_a2 = parser.close) == null ? void 0 : _a2.call(parser);
4435
+ if (closeResult instanceof Promise) closeResult.catch(() => {
4436
+ });
4437
+ }
4438
+ streamParsers.delete(msg.id);
4439
+ rawContentBuffers.delete(msg.id);
4440
+ msg.streaming = false;
4441
+ emitMessage(msg);
4442
+ };
4443
+ if (!parser) {
4444
+ mergeIfBetter(finalString);
4445
+ finalizeCleanup();
4446
+ return;
4447
+ }
4448
+ const extractedFromJson = extractTextFromJson(contentToProcess);
4449
+ if (extractedFromJson !== null && extractedFromJson.trim() !== "") {
4450
+ mergeIfBetter(extractedFromJson);
4451
+ finalizeCleanup();
4452
+ return;
4453
+ }
4454
+ const bestDisplayText = (result) => {
4455
+ var _a2;
4456
+ const text = typeof result === "string" ? result : (_a2 = result == null ? void 0 : result.text) != null ? _a2 : null;
4457
+ if (text !== null && text.trim() !== "") return text;
4458
+ const extracted = parser.getExtractedText();
4459
+ if (extracted !== null && extracted.trim() !== "") return extracted;
4460
+ return finalString;
4461
+ };
4462
+ let parsedResult;
4463
+ try {
4464
+ parsedResult = parser.processChunk(contentToProcess);
4465
+ } catch {
4466
+ mergeIfBetter(finalString);
4467
+ finalizeCleanup();
4468
+ return;
4469
+ }
4470
+ if (parsedResult instanceof Promise) {
4471
+ parsedResult.then((result) => {
4472
+ mergeIfBetter(bestDisplayText(result));
4473
+ finalizeCleanup();
4474
+ }).catch(() => {
4475
+ mergeIfBetter(finalString);
4476
+ finalizeCleanup();
4477
+ });
4478
+ return;
4479
+ }
4480
+ mergeIfBetter(bestDisplayText(parsedResult));
4481
+ finalizeCleanup();
4482
+ };
4357
4483
  let agentExecution = null;
4358
4484
  const agentIterationMessages = /* @__PURE__ */ new Map();
4359
4485
  const iterationDisplay = (_a = this.config.iterationDisplay) != null ? _a : "separate";
@@ -4427,7 +4553,13 @@ var AgentWidgetClient = class {
4427
4553
  reasoningMessage.reasoning.startedAt = (_m = reasoningMessage.reasoning.startedAt) != null ? _m : resolveTimestamp((_l = payload.startedAt) != null ? _l : payload.timestamp);
4428
4554
  const chunk = (_p = (_o = (_n = payload.reasoningText) != null ? _n : payload.text) != null ? _o : payload.delta) != null ? _p : "";
4429
4555
  if (chunk && payload.hidden !== true) {
4430
- reasoningMessage.reasoning.chunks.push(String(chunk));
4556
+ const reasonSeq = typeof payload.sequenceIndex === "number" ? payload.sequenceIndex : void 0;
4557
+ if (reasonSeq !== void 0) {
4558
+ const ordered = insertSeqChunk(reasonSeqBuffers, reasoningId, reasonSeq, String(chunk));
4559
+ reasoningMessage.reasoning.chunks = [ordered];
4560
+ } else {
4561
+ reasoningMessage.reasoning.chunks.push(String(chunk));
4562
+ }
4431
4563
  }
4432
4564
  reasoningMessage.reasoning.status = payload.done ? "complete" : "streaming";
4433
4565
  if (payload.done) {
@@ -4439,6 +4571,7 @@ var AgentWidgetClient = class {
4439
4571
  0,
4440
4572
  ((_s = reasoningMessage.reasoning.completedAt) != null ? _s : Date.now()) - start
4441
4573
  );
4574
+ reasonSeqBuffers.delete(reasoningId);
4442
4575
  }
4443
4576
  reasoningMessage.streaming = reasoningMessage.reasoning.status !== "complete";
4444
4577
  emitMessage(reasoningMessage);
@@ -4456,6 +4589,7 @@ var AgentWidgetClient = class {
4456
4589
  ((_x = reasoningMessage.reasoning.completedAt) != null ? _x : Date.now()) - start
4457
4590
  );
4458
4591
  reasoningMessage.streaming = false;
4592
+ reasonSeqBuffers.delete(reasoningId);
4459
4593
  emitMessage(reasoningMessage);
4460
4594
  }
4461
4595
  const stepKey = getStepKey(payload);
@@ -4571,6 +4705,7 @@ var AgentWidgetClient = class {
4571
4705
  if (prev) {
4572
4706
  prev.streaming = false;
4573
4707
  emitMessage(prev);
4708
+ lastSealedTextSegment = prev;
4574
4709
  assistantMessage = null;
4575
4710
  didSplitByPartId = true;
4576
4711
  }
@@ -4583,6 +4718,7 @@ var AgentWidgetClient = class {
4583
4718
  if (prev) {
4584
4719
  prev.streaming = false;
4585
4720
  emitMessage(prev);
4721
+ lastSealedTextSegment = prev;
4586
4722
  assistantMessage = null;
4587
4723
  didSplitByPartId = true;
4588
4724
  }
@@ -4598,6 +4734,7 @@ var AgentWidgetClient = class {
4598
4734
  if (prev) {
4599
4735
  prev.streaming = false;
4600
4736
  emitMessage(prev);
4737
+ lastSealedTextSegment = prev;
4601
4738
  assistantMessage = null;
4602
4739
  didSplitByPartId = true;
4603
4740
  }
@@ -4611,8 +4748,14 @@ var AgentWidgetClient = class {
4611
4748
  }
4612
4749
  const chunk = (_ca = (_ba = (_aa = (_$ = payload.text) != null ? _$ : payload.delta) != null ? _aa : payload.content) != null ? _ba : payload.chunk) != null ? _ca : "";
4613
4750
  if (chunk) {
4614
- const rawBuffer = (_da = rawContentBuffers.get(assistant.id)) != null ? _da : "";
4615
- const accumulatedRaw = rawBuffer + chunk;
4751
+ const chunkSeq = typeof payload.seq === "number" ? payload.seq : void 0;
4752
+ let accumulatedRaw;
4753
+ if (chunkSeq !== void 0) {
4754
+ accumulatedRaw = insertSeqChunk(seqChunkBuffers, assistant.id, chunkSeq, chunk);
4755
+ } else {
4756
+ const rawBuffer = (_da = rawContentBuffers.get(assistant.id)) != null ? _da : "";
4757
+ accumulatedRaw = rawBuffer + chunk;
4758
+ }
4616
4759
  assistant.rawContent = accumulatedRaw;
4617
4760
  if (!streamParsers.has(assistant.id)) {
4618
4761
  streamParsers.set(assistant.id, this.createStreamParser());
@@ -4624,7 +4767,11 @@ var AgentWidgetClient = class {
4624
4767
  }
4625
4768
  const isPlainTextParser = parser.__isPlainTextParser === true;
4626
4769
  if (isPlainTextParser) {
4627
- assistant.content += chunk;
4770
+ if (chunkSeq !== void 0) {
4771
+ assistant.content = accumulatedRaw;
4772
+ } else {
4773
+ assistant.content += chunk;
4774
+ }
4628
4775
  rawContentBuffers.delete(assistant.id);
4629
4776
  streamParsers.delete(assistant.id);
4630
4777
  assistant.rawContent = void 0;
@@ -4637,15 +4784,16 @@ var AgentWidgetClient = class {
4637
4784
  var _a2;
4638
4785
  const text = typeof result === "string" ? result : (_a2 = result == null ? void 0 : result.text) != null ? _a2 : null;
4639
4786
  if (text !== null && text.trim() !== "") {
4640
- const currentAssistant = assistantMessage;
4641
- if (currentAssistant && currentAssistant.id === assistant.id) {
4642
- currentAssistant.content = text;
4643
- emitMessage(currentAssistant);
4644
- }
4787
+ assistant.content = text;
4788
+ emitMessage(assistant);
4645
4789
  } else if (!looksLikeJson && !accumulatedRaw.trim().startsWith("<")) {
4646
4790
  const currentAssistant = assistantMessage;
4647
4791
  if (currentAssistant && currentAssistant.id === assistant.id) {
4648
- currentAssistant.content += chunk;
4792
+ if (chunkSeq !== void 0) {
4793
+ currentAssistant.content = accumulatedRaw;
4794
+ } else {
4795
+ currentAssistant.content += chunk;
4796
+ }
4649
4797
  rawContentBuffers.delete(currentAssistant.id);
4650
4798
  streamParsers.delete(currentAssistant.id);
4651
4799
  currentAssistant.rawContent = void 0;
@@ -4653,7 +4801,11 @@ var AgentWidgetClient = class {
4653
4801
  }
4654
4802
  }
4655
4803
  }).catch(() => {
4656
- assistant.content += chunk;
4804
+ if (chunkSeq !== void 0) {
4805
+ assistant.content = accumulatedRaw;
4806
+ } else {
4807
+ assistant.content += chunk;
4808
+ }
4657
4809
  rawContentBuffers.delete(assistant.id);
4658
4810
  streamParsers.delete(assistant.id);
4659
4811
  assistant.rawContent = void 0;
@@ -4665,7 +4817,11 @@ var AgentWidgetClient = class {
4665
4817
  assistant.content = text;
4666
4818
  emitMessage(assistant);
4667
4819
  } else if (!looksLikeJson && !accumulatedRaw.trim().startsWith("<")) {
4668
- assistant.content += chunk;
4820
+ if (chunkSeq !== void 0) {
4821
+ assistant.content = accumulatedRaw;
4822
+ } else {
4823
+ assistant.content += chunk;
4824
+ }
4669
4825
  rawContentBuffers.delete(assistant.id);
4670
4826
  streamParsers.delete(assistant.id);
4671
4827
  assistant.rawContent = void 0;
@@ -4701,6 +4857,7 @@ var AgentWidgetClient = class {
4701
4857
  currentAssistant.streaming = false;
4702
4858
  streamParsers.delete(currentAssistant.id);
4703
4859
  rawContentBuffers.delete(currentAssistant.id);
4860
+ seqChunkBuffers.delete(currentAssistant.id);
4704
4861
  emitMessage(currentAssistant);
4705
4862
  }
4706
4863
  }
@@ -4726,6 +4883,7 @@ var AgentWidgetClient = class {
4726
4883
  streamParsers.delete(assistant.id);
4727
4884
  }
4728
4885
  rawContentBuffers.delete(assistant.id);
4886
+ seqChunkBuffers.delete(assistant.id);
4729
4887
  assistant.streaming = false;
4730
4888
  emitMessage(assistant);
4731
4889
  }
@@ -4742,14 +4900,26 @@ var AgentWidgetClient = class {
4742
4900
  const msg = assistantMessage;
4743
4901
  streamParsers.delete(msg.id);
4744
4902
  rawContentBuffers.delete(msg.id);
4903
+ seqChunkBuffers.delete(msg.id);
4745
4904
  if (msg.streaming !== false) {
4746
4905
  msg.streaming = false;
4747
4906
  emitMessage(msg);
4748
4907
  }
4749
4908
  }
4909
+ const splitFinalContent = (_ja = payload.result) == null ? void 0 : _ja.response;
4910
+ const sealedForReconcile = lastSealedTextSegment;
4911
+ if (sealedForReconcile) {
4912
+ if (splitFinalContent !== void 0 && splitFinalContent !== null) {
4913
+ reconcileSealedAssistantWithFinalResponse(sealedForReconcile, splitFinalContent);
4914
+ } else {
4915
+ streamParsers.delete(sealedForReconcile.id);
4916
+ rawContentBuffers.delete(sealedForReconcile.id);
4917
+ }
4918
+ }
4919
+ lastSealedTextSegment = null;
4750
4920
  continue;
4751
4921
  }
4752
- const finalContent = (_ja = payload.result) == null ? void 0 : _ja.response;
4922
+ const finalContent = (_ka = payload.result) == null ? void 0 : _ka.response;
4753
4923
  const assistant = ensureAssistantMessage();
4754
4924
  if (finalContent !== void 0 && finalContent !== null) {
4755
4925
  const parser = streamParsers.get(assistant.id);
@@ -4782,6 +4952,7 @@ var AgentWidgetClient = class {
4782
4952
  currentAssistant.streaming = false;
4783
4953
  streamParsers.delete(currentAssistant.id);
4784
4954
  rawContentBuffers.delete(currentAssistant.id);
4955
+ seqChunkBuffers.delete(currentAssistant.id);
4785
4956
  emitMessage(currentAssistant);
4786
4957
  }
4787
4958
  } else {
@@ -4796,12 +4967,13 @@ var AgentWidgetClient = class {
4796
4967
  currentAssistant.streaming = false;
4797
4968
  streamParsers.delete(currentAssistant.id);
4798
4969
  rawContentBuffers.delete(currentAssistant.id);
4970
+ seqChunkBuffers.delete(currentAssistant.id);
4799
4971
  emitMessage(currentAssistant);
4800
4972
  }
4801
4973
  }
4802
4974
  });
4803
4975
  } else {
4804
- const text = typeof parsedResult === "string" ? parsedResult : (_ka = parsedResult == null ? void 0 : parsedResult.text) != null ? _ka : null;
4976
+ const text = typeof parsedResult === "string" ? parsedResult : (_la = parsedResult == null ? void 0 : parsedResult.text) != null ? _la : null;
4805
4977
  if (text !== null && text.trim() !== "") {
4806
4978
  assistant.content = text;
4807
4979
  hasExtractedText = true;
@@ -4825,7 +4997,7 @@ var AgentWidgetClient = class {
4825
4997
  assistant.content = ensureStringContent(finalContent);
4826
4998
  }
4827
4999
  if (parser) {
4828
- const closeResult = (_la = parser.close) == null ? void 0 : _la.call(parser);
5000
+ const closeResult = (_ma = parser.close) == null ? void 0 : _ma.call(parser);
4829
5001
  if (closeResult instanceof Promise) {
4830
5002
  closeResult.catch(() => {
4831
5003
  });
@@ -4833,22 +5005,25 @@ var AgentWidgetClient = class {
4833
5005
  }
4834
5006
  streamParsers.delete(assistant.id);
4835
5007
  rawContentBuffers.delete(assistant.id);
5008
+ seqChunkBuffers.delete(assistant.id);
4836
5009
  assistant.streaming = false;
4837
5010
  emitMessage(assistant);
4838
5011
  }
4839
5012
  } else {
4840
5013
  streamParsers.delete(assistant.id);
4841
5014
  rawContentBuffers.delete(assistant.id);
5015
+ seqChunkBuffers.delete(assistant.id);
4842
5016
  assistant.streaming = false;
4843
5017
  emitMessage(assistant);
4844
5018
  }
4845
5019
  } else if (payloadType === "flow_complete") {
4846
- const finalContent = (_ma = payload.result) == null ? void 0 : _ma.response;
5020
+ const finalContent = (_na = payload.result) == null ? void 0 : _na.response;
4847
5021
  if (didSplitByPartId) {
4848
5022
  if (assistantMessage !== null) {
4849
5023
  const msg = assistantMessage;
4850
5024
  streamParsers.delete(msg.id);
4851
5025
  rawContentBuffers.delete(msg.id);
5026
+ seqChunkBuffers.delete(msg.id);
4852
5027
  if (msg.streaming !== false) {
4853
5028
  msg.streaming = false;
4854
5029
  emitMessage(msg);
@@ -4872,12 +5047,9 @@ var AgentWidgetClient = class {
4872
5047
  var _a2;
4873
5048
  const text = typeof result === "string" ? result : (_a2 = result == null ? void 0 : result.text) != null ? _a2 : null;
4874
5049
  if (text !== null) {
4875
- const currentAssistant = assistantMessage;
4876
- if (currentAssistant && currentAssistant.id === assistant.id) {
4877
- currentAssistant.content = text;
4878
- currentAssistant.streaming = false;
4879
- emitMessage(currentAssistant);
4880
- }
5050
+ assistant.content = text;
5051
+ assistant.streaming = false;
5052
+ emitMessage(assistant);
4881
5053
  }
4882
5054
  });
4883
5055
  }
@@ -4889,6 +5061,7 @@ var AgentWidgetClient = class {
4889
5061
  }
4890
5062
  streamParsers.delete(assistant.id);
4891
5063
  rawContentBuffers.delete(assistant.id);
5064
+ seqChunkBuffers.delete(assistant.id);
4892
5065
  const contentChanged = displayContent !== assistant.content;
4893
5066
  const streamingChanged = assistant.streaming !== false;
4894
5067
  if (contentChanged) {
@@ -4903,6 +5076,7 @@ var AgentWidgetClient = class {
4903
5076
  const msg = assistantMessage;
4904
5077
  streamParsers.delete(msg.id);
4905
5078
  rawContentBuffers.delete(msg.id);
5079
+ seqChunkBuffers.delete(msg.id);
4906
5080
  if (msg.streaming !== false) {
4907
5081
  msg.streaming = false;
4908
5082
  emitMessage(msg);
@@ -4913,11 +5087,11 @@ var AgentWidgetClient = class {
4913
5087
  } else if (payloadType === "agent_start") {
4914
5088
  agentExecution = {
4915
5089
  executionId: payload.executionId,
4916
- agentId: (_na = payload.agentId) != null ? _na : "virtual",
4917
- agentName: (_oa = payload.agentName) != null ? _oa : "",
5090
+ agentId: (_oa = payload.agentId) != null ? _oa : "virtual",
5091
+ agentName: (_pa = payload.agentName) != null ? _pa : "",
4918
5092
  status: "running",
4919
5093
  currentIteration: 0,
4920
- maxTurns: (_pa = payload.maxTurns) != null ? _pa : 1,
5094
+ maxTurns: (_qa = payload.maxTurns) != null ? _qa : 1,
4921
5095
  startedAt: resolveTimestamp(payload.startedAt)
4922
5096
  };
4923
5097
  } else if (payloadType === "agent_iteration_start") {
@@ -4937,7 +5111,7 @@ var AgentWidgetClient = class {
4937
5111
  } else if (payloadType === "agent_turn_delta") {
4938
5112
  if (payload.contentType === "text") {
4939
5113
  const assistant = ensureAssistantMessage();
4940
- assistant.content += (_qa = payload.delta) != null ? _qa : "";
5114
+ assistant.content += (_ra = payload.delta) != null ? _ra : "";
4941
5115
  assistant.agentMetadata = {
4942
5116
  executionId: payload.executionId,
4943
5117
  iteration: payload.iteration,
@@ -4946,14 +5120,14 @@ var AgentWidgetClient = class {
4946
5120
  };
4947
5121
  emitMessage(assistant);
4948
5122
  } else if (payload.contentType === "thinking") {
4949
- const reasoningId = (_ra = payload.turnId) != null ? _ra : `agent-think-${payload.iteration}`;
5123
+ const reasoningId = (_sa = payload.turnId) != null ? _sa : `agent-think-${payload.iteration}`;
4950
5124
  const reasoningMessage = ensureReasoningMessage(reasoningId);
4951
- reasoningMessage.reasoning = (_sa = reasoningMessage.reasoning) != null ? _sa : {
5125
+ reasoningMessage.reasoning = (_ta = reasoningMessage.reasoning) != null ? _ta : {
4952
5126
  id: reasoningId,
4953
5127
  status: "streaming",
4954
5128
  chunks: []
4955
5129
  };
4956
- reasoningMessage.reasoning.chunks.push((_ta = payload.delta) != null ? _ta : "");
5130
+ reasoningMessage.reasoning.chunks.push((_ua = payload.delta) != null ? _ua : "");
4957
5131
  reasoningMessage.agentMetadata = {
4958
5132
  executionId: payload.executionId,
4959
5133
  iteration: payload.iteration,
@@ -4961,12 +5135,12 @@ var AgentWidgetClient = class {
4961
5135
  };
4962
5136
  emitMessage(reasoningMessage);
4963
5137
  } else if (payload.contentType === "tool_input") {
4964
- const toolId = (_ua = payload.toolCallId) != null ? _ua : toolContext.lastId;
5138
+ const toolId = (_va = payload.toolCallId) != null ? _va : toolContext.lastId;
4965
5139
  if (toolId) {
4966
5140
  const toolMessage = toolMessages.get(toolId);
4967
5141
  if (toolMessage == null ? void 0 : toolMessage.toolCall) {
4968
- toolMessage.toolCall.chunks = (_va = toolMessage.toolCall.chunks) != null ? _va : [];
4969
- toolMessage.toolCall.chunks.push((_wa = payload.delta) != null ? _wa : "");
5142
+ toolMessage.toolCall.chunks = (_wa = toolMessage.toolCall.chunks) != null ? _wa : [];
5143
+ toolMessage.toolCall.chunks.push((_xa = payload.delta) != null ? _xa : "");
4970
5144
  emitMessage(toolMessage);
4971
5145
  }
4972
5146
  }
@@ -4978,20 +5152,20 @@ var AgentWidgetClient = class {
4978
5152
  if (reasoningMessage == null ? void 0 : reasoningMessage.reasoning) {
4979
5153
  reasoningMessage.reasoning.status = "complete";
4980
5154
  reasoningMessage.reasoning.completedAt = resolveTimestamp(payload.completedAt);
4981
- const start = (_xa = reasoningMessage.reasoning.startedAt) != null ? _xa : Date.now();
5155
+ const start = (_ya = reasoningMessage.reasoning.startedAt) != null ? _ya : Date.now();
4982
5156
  reasoningMessage.reasoning.durationMs = Math.max(
4983
5157
  0,
4984
- ((_ya = reasoningMessage.reasoning.completedAt) != null ? _ya : Date.now()) - start
5158
+ ((_za = reasoningMessage.reasoning.completedAt) != null ? _za : Date.now()) - start
4985
5159
  );
4986
5160
  reasoningMessage.streaming = false;
4987
5161
  emitMessage(reasoningMessage);
4988
5162
  }
4989
5163
  }
4990
5164
  } else if (payloadType === "agent_tool_start") {
4991
- const toolId = (_za = payload.toolCallId) != null ? _za : `agent-tool-${nextSequence()}`;
5165
+ const toolId = (_Aa = payload.toolCallId) != null ? _Aa : `agent-tool-${nextSequence()}`;
4992
5166
  trackToolId(getToolCallKey(payload), toolId);
4993
5167
  const toolMessage = ensureToolMessage(toolId);
4994
- const tool = (_Aa = toolMessage.toolCall) != null ? _Aa : {
5168
+ const tool = (_Ba = toolMessage.toolCall) != null ? _Ba : {
4995
5169
  id: toolId,
4996
5170
  status: "pending",
4997
5171
  name: void 0,
@@ -5003,12 +5177,12 @@ var AgentWidgetClient = class {
5003
5177
  completedAt: void 0,
5004
5178
  durationMs: void 0
5005
5179
  };
5006
- tool.name = (_Ca = (_Ba = payload.toolName) != null ? _Ba : payload.name) != null ? _Ca : tool.name;
5180
+ tool.name = (_Da = (_Ca = payload.toolName) != null ? _Ca : payload.name) != null ? _Da : tool.name;
5007
5181
  tool.status = "running";
5008
5182
  if (payload.parameters !== void 0) {
5009
5183
  tool.args = payload.parameters;
5010
5184
  }
5011
- tool.startedAt = resolveTimestamp((_Da = payload.startedAt) != null ? _Da : payload.timestamp);
5185
+ tool.startedAt = resolveTimestamp((_Ea = payload.startedAt) != null ? _Ea : payload.timestamp);
5012
5186
  toolMessage.toolCall = tool;
5013
5187
  toolMessage.streaming = true;
5014
5188
  toolMessage.agentMetadata = {
@@ -5017,21 +5191,21 @@ var AgentWidgetClient = class {
5017
5191
  };
5018
5192
  emitMessage(toolMessage);
5019
5193
  } else if (payloadType === "agent_tool_delta") {
5020
- const toolId = (_Ea = payload.toolCallId) != null ? _Ea : toolContext.lastId;
5194
+ const toolId = (_Fa = payload.toolCallId) != null ? _Fa : toolContext.lastId;
5021
5195
  if (toolId) {
5022
- const toolMessage = (_Fa = toolMessages.get(toolId)) != null ? _Fa : ensureToolMessage(toolId);
5196
+ const toolMessage = (_Ga = toolMessages.get(toolId)) != null ? _Ga : ensureToolMessage(toolId);
5023
5197
  if (toolMessage.toolCall) {
5024
- toolMessage.toolCall.chunks = (_Ga = toolMessage.toolCall.chunks) != null ? _Ga : [];
5025
- toolMessage.toolCall.chunks.push((_Ha = payload.delta) != null ? _Ha : "");
5198
+ toolMessage.toolCall.chunks = (_Ha = toolMessage.toolCall.chunks) != null ? _Ha : [];
5199
+ toolMessage.toolCall.chunks.push((_Ia = payload.delta) != null ? _Ia : "");
5026
5200
  toolMessage.toolCall.status = "running";
5027
5201
  toolMessage.streaming = true;
5028
5202
  emitMessage(toolMessage);
5029
5203
  }
5030
5204
  }
5031
5205
  } else if (payloadType === "agent_tool_complete") {
5032
- const toolId = (_Ia = payload.toolCallId) != null ? _Ia : toolContext.lastId;
5206
+ const toolId = (_Ja = payload.toolCallId) != null ? _Ja : toolContext.lastId;
5033
5207
  if (toolId) {
5034
- const toolMessage = (_Ja = toolMessages.get(toolId)) != null ? _Ja : ensureToolMessage(toolId);
5208
+ const toolMessage = (_Ka = toolMessages.get(toolId)) != null ? _Ka : ensureToolMessage(toolId);
5035
5209
  if (toolMessage.toolCall) {
5036
5210
  toolMessage.toolCall.status = "complete";
5037
5211
  if (payload.result !== void 0) {
@@ -5040,7 +5214,7 @@ var AgentWidgetClient = class {
5040
5214
  if (typeof payload.executionTime === "number") {
5041
5215
  toolMessage.toolCall.durationMs = payload.executionTime;
5042
5216
  }
5043
- toolMessage.toolCall.completedAt = resolveTimestamp((_Ka = payload.completedAt) != null ? _Ka : payload.timestamp);
5217
+ toolMessage.toolCall.completedAt = resolveTimestamp((_La = payload.completedAt) != null ? _La : payload.timestamp);
5044
5218
  toolMessage.streaming = false;
5045
5219
  emitMessage(toolMessage);
5046
5220
  const callKey = getToolCallKey(payload);
@@ -5055,7 +5229,7 @@ var AgentWidgetClient = class {
5055
5229
  const reflectionMessage = {
5056
5230
  id: reflectionId,
5057
5231
  role: "assistant",
5058
- content: (_La = payload.reflection) != null ? _La : "",
5232
+ content: (_Ma = payload.reflection) != null ? _Ma : "",
5059
5233
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
5060
5234
  streaming: false,
5061
5235
  variant: "reasoning",
@@ -5063,7 +5237,7 @@ var AgentWidgetClient = class {
5063
5237
  reasoning: {
5064
5238
  id: reflectionId,
5065
5239
  status: "complete",
5066
- chunks: [(_Ma = payload.reflection) != null ? _Ma : ""]
5240
+ chunks: [(_Na = payload.reflection) != null ? _Na : ""]
5067
5241
  },
5068
5242
  agentMetadata: {
5069
5243
  executionId: payload.executionId,
@@ -5084,7 +5258,7 @@ var AgentWidgetClient = class {
5084
5258
  }
5085
5259
  onEvent({ type: "status", status: "idle" });
5086
5260
  } else if (payloadType === "agent_error") {
5087
- const errorMessage = typeof payload.error === "string" ? payload.error : (_Oa = (_Na = payload.error) == null ? void 0 : _Na.message) != null ? _Oa : "Agent execution error";
5261
+ const errorMessage = typeof payload.error === "string" ? payload.error : (_Pa = (_Oa = payload.error) == null ? void 0 : _Oa.message) != null ? _Pa : "Agent execution error";
5088
5262
  if (payload.recoverable) {
5089
5263
  if (typeof console !== "undefined") {
5090
5264
  console.warn("[AgentWidget] Recoverable agent error:", errorMessage);
@@ -5097,7 +5271,7 @@ var AgentWidgetClient = class {
5097
5271
  }
5098
5272
  } else if (payloadType === "agent_ping") {
5099
5273
  } else if (payloadType === "agent_approval_start") {
5100
- const approvalId = (_Pa = payload.approvalId) != null ? _Pa : `approval-${nextSequence()}`;
5274
+ const approvalId = (_Qa = payload.approvalId) != null ? _Qa : `approval-${nextSequence()}`;
5101
5275
  const approvalMessage = {
5102
5276
  id: `approval-${approvalId}`,
5103
5277
  role: "assistant",
@@ -5109,17 +5283,17 @@ var AgentWidgetClient = class {
5109
5283
  approval: {
5110
5284
  id: approvalId,
5111
5285
  status: "pending",
5112
- agentId: (_Qa = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _Qa : "virtual",
5113
- executionId: (_Sa = (_Ra = payload.executionId) != null ? _Ra : agentExecution == null ? void 0 : agentExecution.executionId) != null ? _Sa : "",
5114
- toolName: (_Ta = payload.toolName) != null ? _Ta : "",
5286
+ agentId: (_Ra = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _Ra : "virtual",
5287
+ executionId: (_Ta = (_Sa = payload.executionId) != null ? _Sa : agentExecution == null ? void 0 : agentExecution.executionId) != null ? _Ta : "",
5288
+ toolName: (_Ua = payload.toolName) != null ? _Ua : "",
5115
5289
  toolType: payload.toolType,
5116
- description: (_Va = payload.description) != null ? _Va : `Execute ${(_Ua = payload.toolName) != null ? _Ua : "tool"}`,
5290
+ description: (_Wa = payload.description) != null ? _Wa : `Execute ${(_Va = payload.toolName) != null ? _Va : "tool"}`,
5117
5291
  parameters: payload.parameters
5118
5292
  }
5119
5293
  };
5120
5294
  emitMessage(approvalMessage);
5121
5295
  } else if (payloadType === "step_await" && payload.awaitReason === "approval_required") {
5122
- const approvalId = (_Wa = payload.approvalId) != null ? _Wa : `approval-${nextSequence()}`;
5296
+ const approvalId = (_Xa = payload.approvalId) != null ? _Xa : `approval-${nextSequence()}`;
5123
5297
  const approvalMessage = {
5124
5298
  id: `approval-${approvalId}`,
5125
5299
  role: "assistant",
@@ -5131,11 +5305,11 @@ var AgentWidgetClient = class {
5131
5305
  approval: {
5132
5306
  id: approvalId,
5133
5307
  status: "pending",
5134
- agentId: (_Xa = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _Xa : "virtual",
5135
- executionId: (_Za = (_Ya = payload.executionId) != null ? _Ya : agentExecution == null ? void 0 : agentExecution.executionId) != null ? _Za : "",
5136
- toolName: (__a = payload.toolName) != null ? __a : "",
5308
+ agentId: (_Ya = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _Ya : "virtual",
5309
+ executionId: (__a = (_Za = payload.executionId) != null ? _Za : agentExecution == null ? void 0 : agentExecution.executionId) != null ? __a : "",
5310
+ toolName: (_$a = payload.toolName) != null ? _$a : "",
5137
5311
  toolType: payload.toolType,
5138
- description: (_ab = payload.description) != null ? _ab : `Execute ${(_$a = payload.toolName) != null ? _$a : "tool"}`,
5312
+ description: (_bb = payload.description) != null ? _bb : `Execute ${(_ab = payload.toolName) != null ? _ab : "tool"}`,
5139
5313
  parameters: payload.parameters
5140
5314
  }
5141
5315
  };
@@ -5154,11 +5328,11 @@ var AgentWidgetClient = class {
5154
5328
  sequence: nextSequence(),
5155
5329
  approval: {
5156
5330
  id: approvalId,
5157
- status: (_bb = payload.decision) != null ? _bb : "approved",
5158
- agentId: (_cb = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _cb : "virtual",
5159
- executionId: (_eb = (_db = payload.executionId) != null ? _db : agentExecution == null ? void 0 : agentExecution.executionId) != null ? _eb : "",
5160
- toolName: (_fb = payload.toolName) != null ? _fb : "",
5161
- description: (_gb = payload.description) != null ? _gb : "",
5331
+ status: (_cb = payload.decision) != null ? _cb : "approved",
5332
+ agentId: (_db = agentExecution == null ? void 0 : agentExecution.agentId) != null ? _db : "virtual",
5333
+ executionId: (_fb = (_eb = payload.executionId) != null ? _eb : agentExecution == null ? void 0 : agentExecution.executionId) != null ? _fb : "",
5334
+ toolName: (_gb = payload.toolName) != null ? _gb : "",
5335
+ description: (_hb = payload.description) != null ? _hb : "",
5162
5336
  resolvedAt: Date.now()
5163
5337
  }
5164
5338
  };
@@ -5196,7 +5370,7 @@ var AgentWidgetClient = class {
5196
5370
  }
5197
5371
  } else if (payloadType === "artifact_delta") {
5198
5372
  const deltaId = String(payload.id);
5199
- const deltaText = typeof payload.delta === "string" ? payload.delta : String((_hb = payload.delta) != null ? _hb : "");
5373
+ const deltaText = typeof payload.delta === "string" ? payload.delta : String((_ib = payload.delta) != null ? _ib : "");
5200
5374
  onEvent({
5201
5375
  type: "artifact_delta",
5202
5376
  id: deltaId,
@@ -5219,7 +5393,7 @@ var AgentWidgetClient = class {
5219
5393
  if (refMsg) {
5220
5394
  refMsg.streaming = false;
5221
5395
  try {
5222
- const parsed = JSON.parse((_ib = refMsg.rawContent) != null ? _ib : "{}");
5396
+ const parsed = JSON.parse((_jb = refMsg.rawContent) != null ? _jb : "{}");
5223
5397
  if (parsed.props) {
5224
5398
  parsed.props.status = "complete";
5225
5399
  const acc = artifactContent.get(artCompleteId);
@@ -5240,7 +5414,7 @@ var AgentWidgetClient = class {
5240
5414
  if (!m || typeof m !== "object") {
5241
5415
  continue;
5242
5416
  }
5243
- const id = String((_jb = m.id) != null ? _jb : `msg-${nextSequence()}`);
5417
+ const id = String((_kb = m.id) != null ? _kb : `msg-${nextSequence()}`);
5244
5418
  const roleRaw = m.role;
5245
5419
  const role = roleRaw === "user" ? "user" : roleRaw === "system" ? "system" : "assistant";
5246
5420
  const msg = {
@@ -5259,7 +5433,7 @@ var AgentWidgetClient = class {
5259
5433
  if (msg.rawContent) {
5260
5434
  try {
5261
5435
  const parsed = JSON.parse(msg.rawContent);
5262
- const refArtId = (_kb = parsed == null ? void 0 : parsed.props) == null ? void 0 : _kb.artifactId;
5436
+ const refArtId = (_lb = parsed == null ? void 0 : parsed.props) == null ? void 0 : _lb.artifactId;
5263
5437
  if (typeof refArtId === "string") {
5264
5438
  artifactIdsWithCards.add(refArtId);
5265
5439
  }
@@ -5270,6 +5444,7 @@ var AgentWidgetClient = class {
5270
5444
  assistantMessageRef.current = null;
5271
5445
  streamParsers.delete(id);
5272
5446
  rawContentBuffers.delete(id);
5447
+ seqChunkBuffers.delete(id);
5273
5448
  } else if (payloadType === "error" && payload.error) {
5274
5449
  onEvent({
5275
5450
  type: "error",
@@ -7692,7 +7867,7 @@ var morphMessages = (container, newContent, options = {}) => {
7692
7867
 
7693
7868
  // src/utils/message-fingerprint.ts
7694
7869
  function computeMessageFingerprint(message, configVersion) {
7695
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
7870
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A;
7696
7871
  return [
7697
7872
  message.id,
7698
7873
  message.role,
@@ -7704,8 +7879,11 @@ function computeMessageFingerprint(message, configVersion) {
7704
7879
  (_i = (_h = message.llmContent) == null ? void 0 : _h.length) != null ? _i : 0,
7705
7880
  (_k = (_j = message.approval) == null ? void 0 : _j.status) != null ? _k : "",
7706
7881
  (_m = (_l = message.toolCall) == null ? void 0 : _l.status) != null ? _m : "",
7707
- (_p = (_o = (_n = message.reasoning) == null ? void 0 : _n.chunks) == null ? void 0 : _o.length) != null ? _p : 0,
7708
- (_r = (_q = message.contentParts) == null ? void 0 : _q.length) != null ? _r : 0,
7882
+ (_p = (_o = (_n = message.toolCall) == null ? void 0 : _n.chunks) == null ? void 0 : _o.length) != null ? _p : 0,
7883
+ (_t = (_s = (_r = (_q = message.toolCall) == null ? void 0 : _q.chunks) == null ? void 0 : _r[message.toolCall.chunks.length - 1]) == null ? void 0 : _s.slice(-32)) != null ? _t : "",
7884
+ typeof ((_u = message.toolCall) == null ? void 0 : _u.args) === "string" ? message.toolCall.args.length : ((_v = message.toolCall) == null ? void 0 : _v.args) ? JSON.stringify(message.toolCall.args).length : 0,
7885
+ (_y = (_x = (_w = message.reasoning) == null ? void 0 : _w.chunks) == null ? void 0 : _x.length) != null ? _y : 0,
7886
+ (_A = (_z = message.contentParts) == null ? void 0 : _z.length) != null ? _A : 0,
7709
7887
  configVersion
7710
7888
  ].join("\0");
7711
7889
  }
@@ -9787,10 +9965,26 @@ var createStandardBubble = (message, transform, layoutConfig, actionsConfig, act
9787
9965
 
9788
9966
  // src/components/reasoning-bubble.ts
9789
9967
  var reasoningExpansionState = /* @__PURE__ */ new Set();
9968
+ var appendRenderedValue = (container, value) => {
9969
+ if (value == null) return false;
9970
+ if (typeof value === "string") {
9971
+ container.textContent = value;
9972
+ return true;
9973
+ }
9974
+ container.appendChild(value);
9975
+ return true;
9976
+ };
9977
+ var getReasoningPreviewText = (message, maxLines) => {
9978
+ var _a, _b;
9979
+ const text = (_b = (_a = message.reasoning) == null ? void 0 : _a.chunks.join("").trim()) != null ? _b : "";
9980
+ if (!text) return "";
9981
+ return text.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).slice(0, maxLines).join("\n");
9982
+ };
9790
9983
  var updateReasoningBubbleUI = (messageId, bubble) => {
9791
9984
  const expanded = reasoningExpansionState.has(messageId);
9792
9985
  const header = bubble.querySelector('button[data-expand-header="true"]');
9793
9986
  const content = bubble.querySelector(".persona-border-t");
9987
+ const preview = bubble.querySelector('[data-persona-collapsed-preview="reasoning"]');
9794
9988
  if (!header || !content) return;
9795
9989
  header.setAttribute("aria-expanded", expanded ? "true" : "false");
9796
9990
  const headerMeta = header.querySelector(".persona-ml-auto");
@@ -9806,8 +10000,12 @@ var updateReasoningBubbleUI = (messageId, bubble) => {
9806
10000
  }
9807
10001
  }
9808
10002
  content.style.display = expanded ? "" : "none";
10003
+ if (preview) {
10004
+ preview.style.display = expanded ? "none" : preview.textContent || preview.childNodes.length ? "" : "none";
10005
+ }
9809
10006
  };
9810
- var createReasoningBubble = (message) => {
10007
+ var createReasoningBubble = (message, config) => {
10008
+ var _a, _b, _c, _d, _e, _f, _g;
9811
10009
  const reasoning = message.reasoning;
9812
10010
  const bubble = createElement(
9813
10011
  "div",
@@ -9832,19 +10030,41 @@ var createReasoningBubble = (message) => {
9832
10030
  if (!reasoning) {
9833
10031
  return bubble;
9834
10032
  }
9835
- let expanded = reasoningExpansionState.has(message.id);
10033
+ const reasoningDisplayConfig = (_b = (_a = config == null ? void 0 : config.features) == null ? void 0 : _a.reasoningDisplay) != null ? _b : {};
10034
+ const expandable = reasoningDisplayConfig.expandable !== false;
10035
+ let expanded = expandable && reasoningExpansionState.has(message.id);
10036
+ const isActive = reasoning.status !== "complete";
10037
+ const previewText = getReasoningPreviewText(message, (_c = reasoningDisplayConfig.previewMaxLines) != null ? _c : 3);
9836
10038
  const header = createElement(
9837
10039
  "button",
9838
- "persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-pointer persona-border-none"
10040
+ expandable ? "persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-pointer persona-border-none" : "persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-default persona-border-none"
9839
10041
  );
9840
10042
  header.type = "button";
9841
- header.setAttribute("aria-expanded", expanded ? "true" : "false");
9842
- header.setAttribute("data-expand-header", "true");
10043
+ if (expandable) {
10044
+ header.setAttribute("aria-expanded", expanded ? "true" : "false");
10045
+ header.setAttribute("data-expand-header", "true");
10046
+ }
9843
10047
  header.setAttribute("data-bubble-type", "reasoning");
9844
10048
  const headerContent = createElement("div", "persona-flex persona-flex-col persona-text-left");
9845
10049
  const title = createElement("span", "persona-text-xs persona-text-persona-primary");
9846
- title.textContent = "Thinking...";
9847
- headerContent.appendChild(title);
10050
+ const defaultSummary = "Thinking...";
10051
+ const customSummary = (_e = (_d = config == null ? void 0 : config.reasoning) == null ? void 0 : _d.renderCollapsedSummary) == null ? void 0 : _e.call(_d, {
10052
+ message,
10053
+ reasoning,
10054
+ defaultSummary,
10055
+ previewText,
10056
+ isActive,
10057
+ config: config != null ? config : {}
10058
+ });
10059
+ if (typeof customSummary === "string" && customSummary.trim()) {
10060
+ title.textContent = customSummary;
10061
+ headerContent.appendChild(title);
10062
+ } else if (customSummary instanceof HTMLElement) {
10063
+ headerContent.appendChild(customSummary);
10064
+ } else {
10065
+ title.textContent = defaultSummary;
10066
+ headerContent.appendChild(title);
10067
+ }
9848
10068
  const status = createElement("span", "persona-text-xs persona-text-persona-primary");
9849
10069
  status.textContent = describeReasonStatus(reasoning);
9850
10070
  headerContent.appendChild(status);
@@ -9853,17 +10073,49 @@ var createReasoningBubble = (message) => {
9853
10073
  } else {
9854
10074
  title.style.display = "";
9855
10075
  }
9856
- const toggleIcon = createElement("div", "persona-flex persona-items-center");
9857
- const iconColor = "currentColor";
9858
- const chevronIcon = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor, 2);
9859
- if (chevronIcon) {
9860
- toggleIcon.appendChild(chevronIcon);
10076
+ let toggleIcon = null;
10077
+ if (expandable) {
10078
+ toggleIcon = createElement("div", "persona-flex persona-items-center");
10079
+ const iconColor = "currentColor";
10080
+ const chevronIcon = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor, 2);
10081
+ if (chevronIcon) {
10082
+ toggleIcon.appendChild(chevronIcon);
10083
+ } else {
10084
+ toggleIcon.textContent = expanded ? "Hide" : "Show";
10085
+ }
10086
+ const headerMeta = createElement("div", "persona-flex persona-items-center persona-ml-auto");
10087
+ headerMeta.append(toggleIcon);
10088
+ header.append(headerContent, headerMeta);
9861
10089
  } else {
9862
- toggleIcon.textContent = expanded ? "Hide" : "Show";
10090
+ header.append(headerContent);
10091
+ }
10092
+ const collapsedPreview = createElement(
10093
+ "div",
10094
+ "persona-px-4 persona-py-3 persona-text-xs persona-leading-snug persona-text-persona-muted"
10095
+ );
10096
+ collapsedPreview.setAttribute("data-persona-collapsed-preview", "reasoning");
10097
+ collapsedPreview.style.display = "none";
10098
+ collapsedPreview.style.whiteSpace = "pre-wrap";
10099
+ if (!expanded && isActive && reasoningDisplayConfig.activePreview && previewText) {
10100
+ const renderedPreview = (_g = (_f = config == null ? void 0 : config.reasoning) == null ? void 0 : _f.renderCollapsedPreview) == null ? void 0 : _g.call(_f, {
10101
+ message,
10102
+ reasoning,
10103
+ defaultPreview: previewText,
10104
+ isActive,
10105
+ config: config != null ? config : {}
10106
+ });
10107
+ if (!appendRenderedValue(collapsedPreview, renderedPreview)) {
10108
+ collapsedPreview.textContent = previewText;
10109
+ }
10110
+ collapsedPreview.style.display = "";
10111
+ }
10112
+ if (!expanded && isActive && reasoningDisplayConfig.activeMinHeight) {
10113
+ bubble.style.minHeight = reasoningDisplayConfig.activeMinHeight;
10114
+ }
10115
+ if (!expandable) {
10116
+ bubble.append(header, collapsedPreview);
10117
+ return bubble;
9863
10118
  }
9864
- const headerMeta = createElement("div", "persona-flex persona-items-center persona-ml-auto");
9865
- headerMeta.append(toggleIcon);
9866
- header.append(headerContent, headerMeta);
9867
10119
  const content = createElement(
9868
10120
  "div",
9869
10121
  "persona-border-t persona-border-gray-200 persona-bg-gray-50 persona-px-4 persona-py-3"
@@ -9878,29 +10130,74 @@ var createReasoningBubble = (message) => {
9878
10130
  content.appendChild(body);
9879
10131
  const applyExpansionState = () => {
9880
10132
  header.setAttribute("aria-expanded", expanded ? "true" : "false");
9881
- toggleIcon.innerHTML = "";
9882
- const iconColor2 = "currentColor";
9883
- const chevronIcon2 = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor2, 2);
9884
- if (chevronIcon2) {
9885
- toggleIcon.appendChild(chevronIcon2);
9886
- } else {
9887
- toggleIcon.textContent = expanded ? "Hide" : "Show";
10133
+ if (toggleIcon) {
10134
+ toggleIcon.innerHTML = "";
10135
+ const iconColor = "currentColor";
10136
+ const chevronIcon = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor, 2);
10137
+ if (chevronIcon) {
10138
+ toggleIcon.appendChild(chevronIcon);
10139
+ } else {
10140
+ toggleIcon.textContent = expanded ? "Hide" : "Show";
10141
+ }
9888
10142
  }
9889
10143
  content.style.display = expanded ? "" : "none";
10144
+ collapsedPreview.style.display = expanded ? "none" : collapsedPreview.textContent || collapsedPreview.childNodes.length ? "" : "none";
9890
10145
  };
9891
10146
  applyExpansionState();
9892
- bubble.append(header, content);
10147
+ bubble.append(header, collapsedPreview, content);
9893
10148
  return bubble;
9894
10149
  };
9895
10150
 
9896
10151
  // src/components/tool-bubble.ts
9897
10152
  var toolExpansionState = /* @__PURE__ */ new Set();
10153
+ var appendRenderedValue2 = (container, value) => {
10154
+ if (value == null) return false;
10155
+ if (typeof value === "string") {
10156
+ container.textContent = value;
10157
+ return true;
10158
+ }
10159
+ container.appendChild(value);
10160
+ return true;
10161
+ };
10162
+ var getToolPreviewText = (message, maxLines) => {
10163
+ var _a;
10164
+ const tool = message.toolCall;
10165
+ if (!tool) return "";
10166
+ const chunkText = ((_a = tool.chunks) != null ? _a : []).join("").trim();
10167
+ if (chunkText) {
10168
+ const lines = chunkText.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).slice(-maxLines);
10169
+ return lines.join("\n");
10170
+ }
10171
+ const argsText = formatUnknownValue(tool.args).trim();
10172
+ if (!argsText) return "";
10173
+ return argsText.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).slice(0, maxLines).join("\n");
10174
+ };
10175
+ var getToolSummaryText = (message, config) => {
10176
+ var _a, _b, _c, _d;
10177
+ const tool = message.toolCall;
10178
+ const toolDisplayConfig = (_a = config == null ? void 0 : config.features) == null ? void 0 : _a.toolCallDisplay;
10179
+ const collapsedMode = (_b = toolDisplayConfig == null ? void 0 : toolDisplayConfig.collapsedMode) != null ? _b : "tool-call";
10180
+ const previewText = getToolPreviewText(message, (_c = toolDisplayConfig == null ? void 0 : toolDisplayConfig.previewMaxLines) != null ? _c : 3);
10181
+ const defaultSummary = tool ? describeToolTitle(tool) : "";
10182
+ if (!tool) {
10183
+ return { summary: defaultSummary, previewText, isActive: false };
10184
+ }
10185
+ const isActive = tool.status !== "complete";
10186
+ let summary = defaultSummary;
10187
+ if (collapsedMode === "tool-name") {
10188
+ summary = ((_d = tool.name) == null ? void 0 : _d.trim()) || defaultSummary;
10189
+ } else if (collapsedMode === "tool-preview" && previewText) {
10190
+ summary = previewText;
10191
+ }
10192
+ return { summary, previewText, isActive };
10193
+ };
9898
10194
  var updateToolBubbleUI = (messageId, bubble, config) => {
9899
10195
  var _a;
9900
10196
  const expanded = toolExpansionState.has(messageId);
9901
10197
  const toolCallConfig = (_a = config == null ? void 0 : config.toolCall) != null ? _a : {};
9902
10198
  const header = bubble.querySelector('button[data-expand-header="true"]');
9903
10199
  const content = bubble.querySelector(".persona-border-t");
10200
+ const preview = bubble.querySelector('[data-persona-collapsed-preview="tool"]');
9904
10201
  if (!header || !content) return;
9905
10202
  header.setAttribute("aria-expanded", expanded ? "true" : "false");
9906
10203
  const headerMeta = header.querySelector(".persona-ml-auto");
@@ -9916,9 +10213,12 @@ var updateToolBubbleUI = (messageId, bubble, config) => {
9916
10213
  }
9917
10214
  }
9918
10215
  content.style.display = expanded ? "" : "none";
10216
+ if (preview) {
10217
+ preview.style.display = expanded ? "none" : preview.textContent || preview.childNodes.length ? "" : "none";
10218
+ }
9919
10219
  };
9920
10220
  var createToolBubble = (message, config) => {
9921
- var _a;
10221
+ var _a, _b, _c, _d, _e, _f;
9922
10222
  const tool = message.toolCall;
9923
10223
  const toolCallConfig = (_a = config == null ? void 0 : config.toolCall) != null ? _a : {};
9924
10224
  const bubble = createElement(
@@ -9956,14 +10256,19 @@ var createToolBubble = (message, config) => {
9956
10256
  if (!tool) {
9957
10257
  return bubble;
9958
10258
  }
9959
- let expanded = toolExpansionState.has(message.id);
10259
+ const toolDisplayConfig = (_c = (_b = config == null ? void 0 : config.features) == null ? void 0 : _b.toolCallDisplay) != null ? _c : {};
10260
+ const expandable = toolDisplayConfig.expandable !== false;
10261
+ let expanded = expandable && toolExpansionState.has(message.id);
10262
+ const { summary, previewText, isActive } = getToolSummaryText(message, config);
9960
10263
  const header = createElement(
9961
10264
  "button",
9962
- "persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-pointer persona-border-none"
10265
+ expandable ? "persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-pointer persona-border-none" : "persona-flex persona-w-full persona-items-center persona-justify-between persona-gap-3 persona-bg-transparent persona-px-4 persona-py-3 persona-text-left persona-cursor-default persona-border-none"
9963
10266
  );
9964
10267
  header.type = "button";
9965
- header.setAttribute("aria-expanded", expanded ? "true" : "false");
9966
- header.setAttribute("data-expand-header", "true");
10268
+ if (expandable) {
10269
+ header.setAttribute("aria-expanded", expanded ? "true" : "false");
10270
+ header.setAttribute("data-expand-header", "true");
10271
+ }
9967
10272
  header.setAttribute("data-bubble-type", "tool");
9968
10273
  if (toolCallConfig.headerBackgroundColor) {
9969
10274
  header.style.backgroundColor = toolCallConfig.headerBackgroundColor;
@@ -9981,19 +10286,67 @@ var createToolBubble = (message, config) => {
9981
10286
  if (toolCallConfig.headerTextColor) {
9982
10287
  title.style.color = toolCallConfig.headerTextColor;
9983
10288
  }
9984
- title.textContent = describeToolTitle(tool);
9985
- headerContent.appendChild(title);
9986
- const toggleIcon = createElement("div", "persona-flex persona-items-center");
9987
- const iconColor = toolCallConfig.toggleTextColor || toolCallConfig.headerTextColor || "currentColor";
9988
- const chevronIcon = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor, 2);
9989
- if (chevronIcon) {
9990
- toggleIcon.appendChild(chevronIcon);
10289
+ const customSummary = (_e = toolCallConfig.renderCollapsedSummary) == null ? void 0 : _e.call(toolCallConfig, {
10290
+ message,
10291
+ toolCall: tool,
10292
+ defaultSummary: summary,
10293
+ previewText,
10294
+ collapsedMode: (_d = toolDisplayConfig.collapsedMode) != null ? _d : "tool-call",
10295
+ isActive,
10296
+ config: config != null ? config : {}
10297
+ });
10298
+ if (typeof customSummary === "string" && customSummary.trim()) {
10299
+ title.textContent = customSummary;
10300
+ headerContent.appendChild(title);
10301
+ } else if (customSummary instanceof HTMLElement) {
10302
+ headerContent.appendChild(customSummary);
9991
10303
  } else {
9992
- toggleIcon.textContent = expanded ? "Hide" : "Show";
10304
+ title.textContent = summary;
10305
+ headerContent.appendChild(title);
10306
+ }
10307
+ let toggleIcon = null;
10308
+ if (expandable) {
10309
+ toggleIcon = createElement("div", "persona-flex persona-items-center");
10310
+ const iconColor = toolCallConfig.toggleTextColor || toolCallConfig.headerTextColor || "currentColor";
10311
+ const chevronIcon = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor, 2);
10312
+ if (chevronIcon) {
10313
+ toggleIcon.appendChild(chevronIcon);
10314
+ } else {
10315
+ toggleIcon.textContent = expanded ? "Hide" : "Show";
10316
+ }
10317
+ const headerMeta = createElement("div", "persona-flex persona-items-center persona-gap-2 persona-ml-auto");
10318
+ headerMeta.append(toggleIcon);
10319
+ header.append(headerContent, headerMeta);
10320
+ } else {
10321
+ header.append(headerContent);
10322
+ }
10323
+ const collapsedPreview = createElement(
10324
+ "div",
10325
+ "persona-px-4 persona-py-3 persona-text-xs persona-leading-snug persona-text-persona-muted"
10326
+ );
10327
+ collapsedPreview.setAttribute("data-persona-collapsed-preview", "tool");
10328
+ collapsedPreview.style.display = "none";
10329
+ collapsedPreview.style.whiteSpace = "pre-wrap";
10330
+ if (!expanded && isActive && toolDisplayConfig.activePreview && previewText) {
10331
+ const renderedPreview = (_f = toolCallConfig.renderCollapsedPreview) == null ? void 0 : _f.call(toolCallConfig, {
10332
+ message,
10333
+ toolCall: tool,
10334
+ defaultPreview: previewText,
10335
+ isActive,
10336
+ config: config != null ? config : {}
10337
+ });
10338
+ if (!appendRenderedValue2(collapsedPreview, renderedPreview)) {
10339
+ collapsedPreview.textContent = previewText;
10340
+ }
10341
+ collapsedPreview.style.display = "";
10342
+ }
10343
+ if (!expanded && isActive && toolDisplayConfig.activeMinHeight) {
10344
+ bubble.style.minHeight = toolDisplayConfig.activeMinHeight;
10345
+ }
10346
+ if (!expandable) {
10347
+ bubble.append(header, collapsedPreview);
10348
+ return bubble;
9993
10349
  }
9994
- const headerMeta = createElement("div", "persona-flex persona-items-center persona-gap-2 persona-ml-auto");
9995
- headerMeta.append(toggleIcon);
9996
- header.append(headerContent, headerMeta);
9997
10350
  const content = createElement(
9998
10351
  "div",
9999
10352
  "persona-border-t persona-border-gray-200 persona-bg-gray-50 persona-space-y-3 persona-px-4 persona-py-3"
@@ -10123,18 +10476,21 @@ var createToolBubble = (message, config) => {
10123
10476
  }
10124
10477
  const applyToolExpansion = () => {
10125
10478
  header.setAttribute("aria-expanded", expanded ? "true" : "false");
10126
- toggleIcon.innerHTML = "";
10127
- const iconColor2 = toolCallConfig.toggleTextColor || toolCallConfig.headerTextColor || "currentColor";
10128
- const chevronIcon2 = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor2, 2);
10129
- if (chevronIcon2) {
10130
- toggleIcon.appendChild(chevronIcon2);
10131
- } else {
10132
- toggleIcon.textContent = expanded ? "Hide" : "Show";
10479
+ if (toggleIcon) {
10480
+ toggleIcon.innerHTML = "";
10481
+ const iconColor = toolCallConfig.toggleTextColor || toolCallConfig.headerTextColor || "currentColor";
10482
+ const chevronIcon = renderLucideIcon(expanded ? "chevron-up" : "chevron-down", 16, iconColor, 2);
10483
+ if (chevronIcon) {
10484
+ toggleIcon.appendChild(chevronIcon);
10485
+ } else {
10486
+ toggleIcon.textContent = expanded ? "Hide" : "Show";
10487
+ }
10133
10488
  }
10134
10489
  content.style.display = expanded ? "" : "none";
10490
+ collapsedPreview.style.display = expanded ? "none" : collapsedPreview.textContent || collapsedPreview.childNodes.length ? "" : "none";
10135
10491
  };
10136
10492
  applyToolExpansion();
10137
- bubble.append(header, content);
10493
+ bubble.append(header, collapsedPreview, content);
10138
10494
  return bubble;
10139
10495
  };
10140
10496
 
@@ -14507,7 +14863,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14507
14863
  });
14508
14864
  };
14509
14865
  const renderMessagesWithPluginsImpl = (container2, messages, transform) => {
14510
- var _a2, _b2, _c2, _d2;
14866
+ var _a2, _b2, _c2, _d2, _e2, _f2;
14511
14867
  const tempContainer = document.createElement("div");
14512
14868
  const getInlineLoadingIndicatorRenderer = () => {
14513
14869
  var _a3;
@@ -14521,6 +14877,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14521
14877
  return void 0;
14522
14878
  };
14523
14879
  const inlineLoadingRenderer = getInlineLoadingIndicatorRenderer();
14880
+ const appendRenderedValue3 = (containerEl, value) => {
14881
+ if (value == null) return false;
14882
+ if (typeof value === "string") {
14883
+ containerEl.textContent = value;
14884
+ return true;
14885
+ }
14886
+ containerEl.appendChild(value);
14887
+ return true;
14888
+ };
14524
14889
  const activeMessageIds = /* @__PURE__ */ new Set();
14525
14890
  messages.forEach((message) => {
14526
14891
  var _a3, _b3;
@@ -14553,7 +14918,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14553
14918
  if (!showReasoning) return;
14554
14919
  bubble = matchingPlugin.renderReasoning({
14555
14920
  message,
14556
- defaultRenderer: () => createReasoningBubble(message),
14921
+ defaultRenderer: () => createReasoningBubble(message, config),
14557
14922
  config
14558
14923
  });
14559
14924
  } else if (message.variant === "tool" && message.toolCall && matchingPlugin.renderToolCall) {
@@ -14659,7 +15024,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14659
15024
  if (!bubble) {
14660
15025
  if (message.variant === "reasoning" && message.reasoning) {
14661
15026
  if (!showReasoning) return;
14662
- bubble = createReasoningBubble(message);
15027
+ bubble = createReasoningBubble(message, config);
14663
15028
  } else if (message.variant === "tool" && message.toolCall) {
14664
15029
  if (!showToolCalls) return;
14665
15030
  bubble = createToolBubble(message, config);
@@ -14712,6 +15077,68 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14712
15077
  setCachedWrapper(messageCache, message.id, fingerprint, wrapper2);
14713
15078
  tempContainer.appendChild(wrapper2);
14714
15079
  });
15080
+ if ((_b2 = (_a2 = config.features) == null ? void 0 : _a2.toolCallDisplay) == null ? void 0 : _b2.grouped) {
15081
+ const toolGroups = [];
15082
+ let currentGroup = [];
15083
+ messages.forEach((message) => {
15084
+ if (message.variant === "tool" && message.toolCall && showToolCalls) {
15085
+ currentGroup.push(message);
15086
+ return;
15087
+ }
15088
+ if (currentGroup.length > 1) {
15089
+ toolGroups.push(currentGroup);
15090
+ }
15091
+ currentGroup = [];
15092
+ });
15093
+ if (currentGroup.length > 1) {
15094
+ toolGroups.push(currentGroup);
15095
+ }
15096
+ toolGroups.forEach((group, groupIndex) => {
15097
+ var _a3, _b3;
15098
+ const wrappers = group.map(
15099
+ (groupMessage) => Array.from(tempContainer.children).find(
15100
+ (child) => child instanceof HTMLElement && child.getAttribute("data-wrapper-id") === groupMessage.id
15101
+ )
15102
+ ).filter((wrapper2) => Boolean(wrapper2));
15103
+ if (wrappers.length < 2) {
15104
+ return;
15105
+ }
15106
+ const groupWrapper = document.createElement("div");
15107
+ groupWrapper.className = "persona-flex";
15108
+ groupWrapper.id = `wrapper-tool-group-${groupIndex}-${group[0].id}`;
15109
+ groupWrapper.setAttribute("data-wrapper-id", `tool-group-${groupIndex}-${group[0].id}`);
15110
+ const groupContainer = document.createElement("div");
15111
+ groupContainer.className = "persona-tool-group persona-flex persona-w-full persona-flex-col persona-gap-2";
15112
+ groupContainer.setAttribute("data-persona-tool-group", "true");
15113
+ const summary = document.createElement("div");
15114
+ summary.className = "persona-tool-group-summary persona-text-xs persona-text-persona-muted";
15115
+ const defaultSummary = `Called ${group.length} tools`;
15116
+ const renderedSummary = (_b3 = (_a3 = config.toolCall) == null ? void 0 : _a3.renderGroupedSummary) == null ? void 0 : _b3.call(_a3, {
15117
+ messages: group,
15118
+ toolCalls: group.map((groupMessage) => groupMessage.toolCall).filter((toolCall) => Boolean(toolCall)),
15119
+ defaultSummary,
15120
+ config
15121
+ });
15122
+ if (!appendRenderedValue3(summary, renderedSummary)) {
15123
+ summary.textContent = defaultSummary;
15124
+ }
15125
+ const stack = document.createElement("div");
15126
+ stack.className = "persona-tool-group-stack persona-flex persona-flex-col";
15127
+ groupContainer.append(summary, stack);
15128
+ groupWrapper.appendChild(groupContainer);
15129
+ wrappers[0].before(groupWrapper);
15130
+ wrappers.forEach((wrapper2, wrapperIndex) => {
15131
+ const item = document.createElement("div");
15132
+ item.className = "persona-tool-group-item persona-relative";
15133
+ item.setAttribute("data-persona-tool-group-item", "true");
15134
+ if (wrapperIndex < wrappers.length - 1) {
15135
+ item.setAttribute("data-persona-tool-group-connector", "true");
15136
+ }
15137
+ item.appendChild(wrapper2);
15138
+ stack.appendChild(item);
15139
+ });
15140
+ });
15141
+ }
14715
15142
  pruneCache(messageCache, activeMessageIds);
14716
15143
  const hasStreamingAssistantMessage = messages.some(
14717
15144
  (msg) => msg.role === "assistant" && msg.streaming
@@ -14730,7 +15157,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14730
15157
  if (loadingPlugin == null ? void 0 : loadingPlugin.renderLoadingIndicator) {
14731
15158
  typingIndicator = loadingPlugin.renderLoadingIndicator(loadingIndicatorContext);
14732
15159
  }
14733
- if (typingIndicator === null && ((_a2 = config.loadingIndicator) == null ? void 0 : _a2.render)) {
15160
+ if (typingIndicator === null && ((_c2 = config.loadingIndicator) == null ? void 0 : _c2.render)) {
14734
15161
  typingIndicator = config.loadingIndicator.render(loadingIndicatorContext);
14735
15162
  }
14736
15163
  if (typingIndicator === null) {
@@ -14738,7 +15165,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14738
15165
  }
14739
15166
  if (typingIndicator) {
14740
15167
  const typingBubble = document.createElement("div");
14741
- const showBubble = ((_b2 = config.loadingIndicator) == null ? void 0 : _b2.showBubble) !== false;
15168
+ const showBubble = ((_d2 = config.loadingIndicator) == null ? void 0 : _d2.showBubble) !== false;
14742
15169
  typingBubble.className = showBubble ? [
14743
15170
  "persona-max-w-[85%]",
14744
15171
  "persona-rounded-2xl",
@@ -14779,12 +15206,12 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14779
15206
  if (idlePlugin == null ? void 0 : idlePlugin.renderIdleIndicator) {
14780
15207
  idleIndicator = idlePlugin.renderIdleIndicator(idleIndicatorContext);
14781
15208
  }
14782
- if (idleIndicator === null && ((_c2 = config.loadingIndicator) == null ? void 0 : _c2.renderIdle)) {
15209
+ if (idleIndicator === null && ((_e2 = config.loadingIndicator) == null ? void 0 : _e2.renderIdle)) {
14783
15210
  idleIndicator = config.loadingIndicator.renderIdle(idleIndicatorContext);
14784
15211
  }
14785
15212
  if (idleIndicator) {
14786
15213
  const idleBubble = document.createElement("div");
14787
- const showBubble = ((_d2 = config.loadingIndicator) == null ? void 0 : _d2.showBubble) !== false;
15214
+ const showBubble = ((_f2 = config.loadingIndicator) == null ? void 0 : _f2.showBubble) !== false;
14788
15215
  idleBubble.className = showBubble ? [
14789
15216
  "persona-max-w-[85%]",
14790
15217
  "persona-rounded-2xl",
@@ -15817,13 +16244,17 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15817
16244
  }
15818
16245
  const controller = {
15819
16246
  update(nextConfig) {
15820
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2, _s2, _t2, _u2, _v2, _w2, _x2, _y2, _z2, _A2, _B2, _C2, _D2, _E2, _F2, _G2, _H2, _I2, _J2, _K2, _L2, _M2, _N2, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra;
16247
+ 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;
15821
16248
  const previousToolCallConfig = config.toolCall;
15822
16249
  const previousMessageActions = config.messageActions;
15823
16250
  const previousLayoutMessages = (_a2 = config.layout) == null ? void 0 : _a2.messages;
15824
16251
  const previousColorScheme = config.colorScheme;
15825
16252
  const previousLoadingIndicator = config.loadingIndicator;
15826
16253
  const previousIterationDisplay = config.iterationDisplay;
16254
+ const previousShowReasoning = (_b2 = config.features) == null ? void 0 : _b2.showReasoning;
16255
+ const previousShowToolCalls = (_c2 = config.features) == null ? void 0 : _c2.showToolCalls;
16256
+ const previousToolCallDisplay = (_d2 = config.features) == null ? void 0 : _d2.toolCallDisplay;
16257
+ const previousReasoningDisplay = (_e2 = config.features) == null ? void 0 : _e2.reasoningDisplay;
15827
16258
  config = { ...config, ...nextConfig };
15828
16259
  applyFullHeightStyles();
15829
16260
  applyThemeVariables(mount, config);
@@ -15836,15 +16267,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15836
16267
  const newPlugins = pluginRegistry.getForInstance(config.plugins);
15837
16268
  plugins.length = 0;
15838
16269
  plugins.push(...newPlugins);
15839
- launcherEnabled = (_c2 = (_b2 = config.launcher) == null ? void 0 : _b2.enabled) != null ? _c2 : true;
15840
- autoExpand = (_e2 = (_d2 = config.launcher) == null ? void 0 : _d2.autoExpand) != null ? _e2 : false;
15841
- showReasoning = (_g2 = (_f2 = config.features) == null ? void 0 : _f2.showReasoning) != null ? _g2 : true;
15842
- showToolCalls = (_i2 = (_h2 = config.features) == null ? void 0 : _h2.showToolCalls) != null ? _i2 : true;
15843
- scrollToBottomFeature = (_k2 = (_j2 = config.features) == null ? void 0 : _j2.scrollToBottom) != null ? _k2 : {};
16270
+ launcherEnabled = (_g2 = (_f2 = config.launcher) == null ? void 0 : _f2.enabled) != null ? _g2 : true;
16271
+ autoExpand = (_i2 = (_h2 = config.launcher) == null ? void 0 : _h2.autoExpand) != null ? _i2 : false;
16272
+ showReasoning = (_k2 = (_j2 = config.features) == null ? void 0 : _j2.showReasoning) != null ? _k2 : true;
16273
+ showToolCalls = (_m2 = (_l2 = config.features) == null ? void 0 : _l2.showToolCalls) != null ? _m2 : true;
16274
+ scrollToBottomFeature = (_o2 = (_n2 = config.features) == null ? void 0 : _n2.scrollToBottom) != null ? _o2 : {};
15844
16275
  renderScrollToBottomButton();
15845
16276
  syncScrollToBottomButton();
15846
16277
  const prevShowEventStreamToggle = showEventStreamToggle;
15847
- showEventStreamToggle = (_m2 = (_l2 = config.features) == null ? void 0 : _l2.showEventStreamToggle) != null ? _m2 : false;
16278
+ showEventStreamToggle = (_q2 = (_p2 = config.features) == null ? void 0 : _p2.showEventStreamToggle) != null ? _q2 : false;
15848
16279
  if (showEventStreamToggle && !prevShowEventStreamToggle) {
15849
16280
  if (!eventStreamBuffer) {
15850
16281
  eventStreamStore = new EventStreamStore(eventStreamDbName);
@@ -15861,7 +16292,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15861
16292
  });
15862
16293
  }
15863
16294
  if (!eventStreamToggleBtn && header) {
15864
- const dynEsClassNames = (_o2 = (_n2 = config.features) == null ? void 0 : _n2.eventStream) == null ? void 0 : _o2.classNames;
16295
+ const dynEsClassNames = (_s2 = (_r2 = config.features) == null ? void 0 : _r2.eventStream) == null ? void 0 : _s2.classNames;
15865
16296
  const dynToggleBtnClasses = "persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-opacity-80 persona-cursor-pointer persona-border-none persona-bg-transparent persona-p-1" + ((dynEsClassNames == null ? void 0 : dynEsClassNames.toggleButton) ? " " + dynEsClassNames.toggleButton : "");
15866
16297
  eventStreamToggleBtn = createElement("button", dynToggleBtnClasses);
15867
16298
  eventStreamToggleBtn.style.width = "28px";
@@ -15899,15 +16330,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15899
16330
  eventStreamBuffer = null;
15900
16331
  eventStreamStore = null;
15901
16332
  }
15902
- if (((_p2 = config.launcher) == null ? void 0 : _p2.enabled) === false && launcherButtonInstance) {
16333
+ if (((_t2 = config.launcher) == null ? void 0 : _t2.enabled) === false && launcherButtonInstance) {
15903
16334
  launcherButtonInstance.destroy();
15904
16335
  launcherButtonInstance = null;
15905
16336
  }
15906
- if (((_q2 = config.launcher) == null ? void 0 : _q2.enabled) === false && customLauncherElement) {
16337
+ if (((_u2 = config.launcher) == null ? void 0 : _u2.enabled) === false && customLauncherElement) {
15907
16338
  customLauncherElement.remove();
15908
16339
  customLauncherElement = null;
15909
16340
  }
15910
- if (((_r2 = config.launcher) == null ? void 0 : _r2.enabled) !== false && !launcherButtonInstance && !customLauncherElement) {
16341
+ if (((_v2 = config.launcher) == null ? void 0 : _v2.enabled) !== false && !launcherButtonInstance && !customLauncherElement) {
15911
16342
  const launcherPlugin = plugins.find((p) => p.renderLauncher);
15912
16343
  if (launcherPlugin == null ? void 0 : launcherPlugin.renderLauncher) {
15913
16344
  const customLauncher = launcherPlugin.renderLauncher({
@@ -15931,13 +16362,13 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15931
16362
  if (launcherButtonInstance) {
15932
16363
  launcherButtonInstance.update(config);
15933
16364
  }
15934
- if (headerTitle && ((_s2 = config.launcher) == null ? void 0 : _s2.title) !== void 0) {
16365
+ if (headerTitle && ((_w2 = config.launcher) == null ? void 0 : _w2.title) !== void 0) {
15935
16366
  headerTitle.textContent = config.launcher.title;
15936
16367
  }
15937
- if (headerSubtitle && ((_t2 = config.launcher) == null ? void 0 : _t2.subtitle) !== void 0) {
16368
+ if (headerSubtitle && ((_x2 = config.launcher) == null ? void 0 : _x2.subtitle) !== void 0) {
15938
16369
  headerSubtitle.textContent = config.launcher.subtitle;
15939
16370
  }
15940
- const headerLayoutConfig = (_u2 = config.layout) == null ? void 0 : _u2.header;
16371
+ const headerLayoutConfig = (_y2 = config.layout) == null ? void 0 : _y2.header;
15941
16372
  const headerLayoutChanged = (headerLayoutConfig == null ? void 0 : headerLayoutConfig.layout) !== prevHeaderLayout;
15942
16373
  if (headerLayoutChanged && header) {
15943
16374
  const newHeaderElements = headerLayoutConfig ? buildHeaderWithLayout(config, headerLayoutConfig, {
@@ -15983,11 +16414,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15983
16414
  }
15984
16415
  }
15985
16416
  }
15986
- const showHeader = ((_v2 = config.layout) == null ? void 0 : _v2.showHeader) !== false;
16417
+ const showHeader = ((_z2 = config.layout) == null ? void 0 : _z2.showHeader) !== false;
15987
16418
  if (header) {
15988
16419
  header.style.display = showHeader ? "" : "none";
15989
16420
  }
15990
- const showFooter = ((_w2 = config.layout) == null ? void 0 : _w2.showFooter) !== false;
16421
+ const showFooter = ((_A2 = config.layout) == null ? void 0 : _A2.showFooter) !== false;
15991
16422
  if (footer) {
15992
16423
  footer.style.display = showFooter ? "" : "none";
15993
16424
  }
@@ -16011,20 +16442,21 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16011
16442
  refreshCloseButton();
16012
16443
  const toolCallConfigChanged = JSON.stringify(nextConfig.toolCall) !== JSON.stringify(previousToolCallConfig);
16013
16444
  const messageActionsChanged = JSON.stringify(config.messageActions) !== JSON.stringify(previousMessageActions);
16014
- const layoutMessagesChanged = JSON.stringify((_x2 = config.layout) == null ? void 0 : _x2.messages) !== JSON.stringify(previousLayoutMessages);
16015
- 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);
16445
+ const layoutMessagesChanged = JSON.stringify((_B2 = config.layout) == null ? void 0 : _B2.messages) !== JSON.stringify(previousLayoutMessages);
16446
+ const loadingIndicatorChanged = ((_C2 = config.loadingIndicator) == null ? void 0 : _C2.render) !== (previousLoadingIndicator == null ? void 0 : previousLoadingIndicator.render) || ((_D2 = config.loadingIndicator) == null ? void 0 : _D2.renderIdle) !== (previousLoadingIndicator == null ? void 0 : previousLoadingIndicator.renderIdle) || ((_E2 = config.loadingIndicator) == null ? void 0 : _E2.showBubble) !== (previousLoadingIndicator == null ? void 0 : previousLoadingIndicator.showBubble);
16016
16447
  const iterationDisplayChanged = config.iterationDisplay !== previousIterationDisplay;
16017
- const messagesConfigChanged = toolCallConfigChanged || messageActionsChanged || layoutMessagesChanged || loadingIndicatorChanged || iterationDisplayChanged;
16448
+ 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);
16449
+ const messagesConfigChanged = toolCallConfigChanged || messageActionsChanged || layoutMessagesChanged || loadingIndicatorChanged || iterationDisplayChanged || featuresChanged;
16018
16450
  if (messagesConfigChanged && session) {
16019
16451
  configVersion++;
16020
16452
  renderMessagesWithPlugins(messagesWrapper, session.getMessages(), postprocess);
16021
16453
  }
16022
- const launcher = (_B2 = config.launcher) != null ? _B2 : {};
16023
- const headerIconHidden = (_C2 = launcher.headerIconHidden) != null ? _C2 : false;
16024
- const layoutShowIcon = (_E2 = (_D2 = config.layout) == null ? void 0 : _D2.header) == null ? void 0 : _E2.showIcon;
16454
+ const launcher = (_L2 = config.launcher) != null ? _L2 : {};
16455
+ const headerIconHidden = (_M2 = launcher.headerIconHidden) != null ? _M2 : false;
16456
+ const layoutShowIcon = (_O = (_N2 = config.layout) == null ? void 0 : _N2.header) == null ? void 0 : _O.showIcon;
16025
16457
  const shouldHideIcon = headerIconHidden || layoutShowIcon === false;
16026
16458
  const headerIconName = launcher.headerIconName;
16027
- const headerIconSize = (_F2 = launcher.headerIconSize) != null ? _F2 : "48px";
16459
+ const headerIconSize = (_P = launcher.headerIconSize) != null ? _P : "48px";
16028
16460
  if (iconHolder) {
16029
16461
  const headerEl = container.querySelector(".persona-border-b-persona-divider");
16030
16462
  const headerCopy = headerEl == null ? void 0 : headerEl.querySelector(".persona-flex-col");
@@ -16051,7 +16483,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16051
16483
  if (iconSvg) {
16052
16484
  iconHolder.replaceChildren(iconSvg);
16053
16485
  } else {
16054
- iconHolder.textContent = (_G2 = launcher.agentIconText) != null ? _G2 : "\u{1F4AC}";
16486
+ iconHolder.textContent = (_Q = launcher.agentIconText) != null ? _Q : "\u{1F4AC}";
16055
16487
  }
16056
16488
  } else if (launcher.iconUrl) {
16057
16489
  const img2 = iconHolder.querySelector("img");
@@ -16074,7 +16506,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16074
16506
  if (existingSvg || existingImg) {
16075
16507
  iconHolder.replaceChildren();
16076
16508
  }
16077
- iconHolder.textContent = (_H2 = launcher.agentIconText) != null ? _H2 : "\u{1F4AC}";
16509
+ iconHolder.textContent = (_R = launcher.agentIconText) != null ? _R : "\u{1F4AC}";
16078
16510
  }
16079
16511
  const img = iconHolder.querySelector("img");
16080
16512
  if (img) {
@@ -16083,8 +16515,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16083
16515
  }
16084
16516
  }
16085
16517
  }
16086
- const layoutShowTitle = (_J2 = (_I2 = config.layout) == null ? void 0 : _I2.header) == null ? void 0 : _J2.showTitle;
16087
- const layoutShowSubtitle = (_L2 = (_K2 = config.layout) == null ? void 0 : _K2.header) == null ? void 0 : _L2.showSubtitle;
16518
+ const layoutShowTitle = (_T = (_S = config.layout) == null ? void 0 : _S.header) == null ? void 0 : _T.showTitle;
16519
+ const layoutShowSubtitle = (_V = (_U = config.layout) == null ? void 0 : _U.header) == null ? void 0 : _V.showSubtitle;
16088
16520
  if (headerTitle) {
16089
16521
  headerTitle.style.display = layoutShowTitle === false ? "none" : "";
16090
16522
  }
@@ -16092,14 +16524,14 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16092
16524
  headerSubtitle.style.display = layoutShowSubtitle === false ? "none" : "";
16093
16525
  }
16094
16526
  if (closeButton) {
16095
- const layoutShowCloseButton = (_N2 = (_M2 = config.layout) == null ? void 0 : _M2.header) == null ? void 0 : _N2.showCloseButton;
16527
+ const layoutShowCloseButton = (_X = (_W = config.layout) == null ? void 0 : _W.header) == null ? void 0 : _X.showCloseButton;
16096
16528
  if (layoutShowCloseButton === false) {
16097
16529
  closeButton.style.display = "none";
16098
16530
  } else {
16099
16531
  closeButton.style.display = "";
16100
16532
  }
16101
- const closeButtonSize = (_O = launcher.closeButtonSize) != null ? _O : "32px";
16102
- const closeButtonPlacement = (_P = launcher.closeButtonPlacement) != null ? _P : "inline";
16533
+ const closeButtonSize = (_Y = launcher.closeButtonSize) != null ? _Y : "32px";
16534
+ const closeButtonPlacement = (_Z = launcher.closeButtonPlacement) != null ? _Z : "inline";
16103
16535
  closeButton.style.height = closeButtonSize;
16104
16536
  closeButton.style.width = closeButtonSize;
16105
16537
  const { closeButtonWrapper } = panelElements;
@@ -16112,8 +16544,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16112
16544
  container.style.position = "relative";
16113
16545
  container.appendChild(closeButtonWrapper);
16114
16546
  } else {
16115
- const clearChatPlacement = (_R = (_Q = launcher.clearChat) == null ? void 0 : _Q.placement) != null ? _R : "inline";
16116
- const clearChatEnabled = (_T = (_S = launcher.clearChat) == null ? void 0 : _S.enabled) != null ? _T : true;
16547
+ const clearChatPlacement = (_$ = (__ = launcher.clearChat) == null ? void 0 : __.placement) != null ? _$ : "inline";
16548
+ const clearChatEnabled = (_ba = (_aa = launcher.clearChat) == null ? void 0 : _aa.enabled) != null ? _ba : true;
16117
16549
  closeButtonWrapper.className = clearChatEnabled && clearChatPlacement === "inline" ? "" : "persona-ml-auto";
16118
16550
  const header2 = container.querySelector(".persona-border-b-persona-divider");
16119
16551
  if (header2) {
@@ -16159,8 +16591,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16159
16591
  closeButton.style.paddingTop = "";
16160
16592
  closeButton.style.paddingBottom = "";
16161
16593
  }
16162
- const closeButtonIconName = (_U = launcher.closeButtonIconName) != null ? _U : "x";
16163
- const closeButtonIconText = (_V = launcher.closeButtonIconText) != null ? _V : "\xD7";
16594
+ const closeButtonIconName = (_ca = launcher.closeButtonIconName) != null ? _ca : "x";
16595
+ const closeButtonIconText = (_da = launcher.closeButtonIconText) != null ? _da : "\xD7";
16164
16596
  closeButton.innerHTML = "";
16165
16597
  const iconSvg = renderLucideIcon(closeButtonIconName, "20px", "currentColor", 2);
16166
16598
  if (iconSvg) {
@@ -16168,8 +16600,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16168
16600
  } else {
16169
16601
  closeButton.textContent = closeButtonIconText;
16170
16602
  }
16171
- const closeButtonTooltipText = (_W = launcher.closeButtonTooltipText) != null ? _W : "Close chat";
16172
- const closeButtonShowTooltip = (_X = launcher.closeButtonShowTooltip) != null ? _X : true;
16603
+ const closeButtonTooltipText = (_ea = launcher.closeButtonTooltipText) != null ? _ea : "Close chat";
16604
+ const closeButtonShowTooltip = (_fa = launcher.closeButtonShowTooltip) != null ? _fa : true;
16173
16605
  closeButton.setAttribute("aria-label", closeButtonTooltipText);
16174
16606
  if (closeButtonWrapper) {
16175
16607
  if (closeButtonWrapper._cleanupTooltip) {
@@ -16226,11 +16658,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16226
16658
  }
16227
16659
  const { clearChatButton, clearChatButtonWrapper } = panelElements;
16228
16660
  if (clearChatButton) {
16229
- const clearChatConfig = (_Y = launcher.clearChat) != null ? _Y : {};
16230
- const clearChatEnabled = (_Z = clearChatConfig.enabled) != null ? _Z : true;
16231
- const layoutShowClearChat = (_$ = (__ = config.layout) == null ? void 0 : __.header) == null ? void 0 : _$.showClearChat;
16661
+ const clearChatConfig = (_ga = launcher.clearChat) != null ? _ga : {};
16662
+ const clearChatEnabled = (_ha = clearChatConfig.enabled) != null ? _ha : true;
16663
+ const layoutShowClearChat = (_ja = (_ia = config.layout) == null ? void 0 : _ia.header) == null ? void 0 : _ja.showClearChat;
16232
16664
  const shouldShowClearChat = layoutShowClearChat !== void 0 ? layoutShowClearChat : clearChatEnabled;
16233
- const clearChatPlacement = (_aa = clearChatConfig.placement) != null ? _aa : "inline";
16665
+ const clearChatPlacement = (_ka = clearChatConfig.placement) != null ? _ka : "inline";
16234
16666
  if (clearChatButtonWrapper) {
16235
16667
  clearChatButtonWrapper.style.display = shouldShowClearChat ? "" : "none";
16236
16668
  const { closeButtonWrapper } = panelElements;
@@ -16272,11 +16704,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16272
16704
  }
16273
16705
  }
16274
16706
  if (shouldShowClearChat) {
16275
- const clearChatSize = (_ba = clearChatConfig.size) != null ? _ba : "32px";
16707
+ const clearChatSize = (_la = clearChatConfig.size) != null ? _la : "32px";
16276
16708
  clearChatButton.style.height = clearChatSize;
16277
16709
  clearChatButton.style.width = clearChatSize;
16278
- const clearChatIconName = (_ca = clearChatConfig.iconName) != null ? _ca : "refresh-cw";
16279
- const clearChatIconColor = (_da = clearChatConfig.iconColor) != null ? _da : "";
16710
+ const clearChatIconName = (_ma = clearChatConfig.iconName) != null ? _ma : "refresh-cw";
16711
+ const clearChatIconColor = (_na = clearChatConfig.iconColor) != null ? _na : "";
16280
16712
  clearChatButton.style.color = clearChatIconColor || HEADER_THEME_CSS.actionIconColor;
16281
16713
  clearChatButton.innerHTML = "";
16282
16714
  const iconSvg = renderLucideIcon(clearChatIconName, "20px", "currentColor", 2);
@@ -16320,8 +16752,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16320
16752
  clearChatButton.style.paddingTop = "";
16321
16753
  clearChatButton.style.paddingBottom = "";
16322
16754
  }
16323
- const clearChatTooltipText = (_ea = clearChatConfig.tooltipText) != null ? _ea : "Clear chat";
16324
- const clearChatShowTooltip = (_fa = clearChatConfig.showTooltip) != null ? _fa : true;
16755
+ const clearChatTooltipText = (_oa = clearChatConfig.tooltipText) != null ? _oa : "Clear chat";
16756
+ const clearChatShowTooltip = (_pa = clearChatConfig.showTooltip) != null ? _pa : true;
16325
16757
  clearChatButton.setAttribute("aria-label", clearChatTooltipText);
16326
16758
  if (clearChatButtonWrapper) {
16327
16759
  if (clearChatButtonWrapper._cleanupTooltip) {
@@ -16397,9 +16829,9 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16397
16829
  suggestionsManager.render(config.suggestionChips, session, textarea, void 0, config.suggestionChipsConfig);
16398
16830
  updateCopy();
16399
16831
  setComposerDisabled(session.isStreaming());
16400
- const voiceRecognitionEnabled = ((_ga = config.voiceRecognition) == null ? void 0 : _ga.enabled) === true;
16832
+ const voiceRecognitionEnabled = ((_qa = config.voiceRecognition) == null ? void 0 : _qa.enabled) === true;
16401
16833
  const hasSpeechRecognition = typeof window !== "undefined" && (typeof window.webkitSpeechRecognition !== "undefined" || typeof window.SpeechRecognition !== "undefined");
16402
- const hasRuntypeProvider = ((_ia = (_ha = config.voiceRecognition) == null ? void 0 : _ha.provider) == null ? void 0 : _ia.type) === "runtype";
16834
+ const hasRuntypeProvider = ((_sa = (_ra = config.voiceRecognition) == null ? void 0 : _ra.provider) == null ? void 0 : _sa.type) === "runtype";
16403
16835
  const hasVoiceInput = hasSpeechRecognition || hasRuntypeProvider;
16404
16836
  if (voiceRecognitionEnabled && hasVoiceInput) {
16405
16837
  if (!micButton || !micButtonWrapper) {
@@ -16412,17 +16844,17 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16412
16844
  micButton.disabled = session.isStreaming();
16413
16845
  }
16414
16846
  } else {
16415
- const voiceConfig = (_ja = config.voiceRecognition) != null ? _ja : {};
16416
- const sendButtonConfig2 = (_ka = config.sendButton) != null ? _ka : {};
16417
- const micIconName = (_la = voiceConfig.iconName) != null ? _la : "mic";
16418
- const buttonSize2 = (_ma = sendButtonConfig2.size) != null ? _ma : "40px";
16419
- const micIconSize = (_na = voiceConfig.iconSize) != null ? _na : buttonSize2;
16847
+ const voiceConfig = (_ta = config.voiceRecognition) != null ? _ta : {};
16848
+ const sendButtonConfig2 = (_ua = config.sendButton) != null ? _ua : {};
16849
+ const micIconName = (_va = voiceConfig.iconName) != null ? _va : "mic";
16850
+ const buttonSize2 = (_wa = sendButtonConfig2.size) != null ? _wa : "40px";
16851
+ const micIconSize = (_xa = voiceConfig.iconSize) != null ? _xa : buttonSize2;
16420
16852
  const micIconSizeNum = parseFloat(micIconSize) || 24;
16421
16853
  micButton.style.width = micIconSize;
16422
16854
  micButton.style.height = micIconSize;
16423
16855
  micButton.style.minWidth = micIconSize;
16424
16856
  micButton.style.minHeight = micIconSize;
16425
- const iconColor = (_pa = (_oa = voiceConfig.iconColor) != null ? _oa : sendButtonConfig2.textColor) != null ? _pa : "currentColor";
16857
+ const iconColor = (_za = (_ya = voiceConfig.iconColor) != null ? _ya : sendButtonConfig2.textColor) != null ? _za : "currentColor";
16426
16858
  micButton.innerHTML = "";
16427
16859
  const micIconSvg = renderLucideIcon(micIconName, micIconSizeNum, iconColor, 2);
16428
16860
  if (micIconSvg) {
@@ -16430,7 +16862,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16430
16862
  } else {
16431
16863
  micButton.textContent = "\u{1F3A4}";
16432
16864
  }
16433
- const backgroundColor2 = (_qa = voiceConfig.backgroundColor) != null ? _qa : sendButtonConfig2.backgroundColor;
16865
+ const backgroundColor2 = (_Aa = voiceConfig.backgroundColor) != null ? _Aa : sendButtonConfig2.backgroundColor;
16434
16866
  if (backgroundColor2) {
16435
16867
  micButton.style.backgroundColor = backgroundColor2;
16436
16868
  } else {
@@ -16468,8 +16900,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16468
16900
  micButton.style.paddingBottom = "";
16469
16901
  }
16470
16902
  const tooltip2 = micButtonWrapper == null ? void 0 : micButtonWrapper.querySelector(".persona-send-button-tooltip");
16471
- const tooltipText2 = (_ra = voiceConfig.tooltipText) != null ? _ra : "Start voice recognition";
16472
- const showTooltip2 = (_sa = voiceConfig.showTooltip) != null ? _sa : false;
16903
+ const tooltipText2 = (_Ba = voiceConfig.tooltipText) != null ? _Ba : "Start voice recognition";
16904
+ const showTooltip2 = (_Ca = voiceConfig.showTooltip) != null ? _Ca : false;
16473
16905
  if (showTooltip2 && tooltipText2) {
16474
16906
  if (!tooltip2) {
16475
16907
  const newTooltip = document.createElement("div");
@@ -16489,19 +16921,19 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16489
16921
  } else {
16490
16922
  if (micButton && micButtonWrapper) {
16491
16923
  micButtonWrapper.style.display = "none";
16492
- if (((_ua = (_ta = config.voiceRecognition) == null ? void 0 : _ta.provider) == null ? void 0 : _ua.type) === "runtype") {
16924
+ if (((_Ea = (_Da = config.voiceRecognition) == null ? void 0 : _Da.provider) == null ? void 0 : _Ea.type) === "runtype") {
16493
16925
  if (session.isVoiceActive()) session.toggleVoice();
16494
16926
  } else if (isRecording) {
16495
16927
  stopVoiceRecognition();
16496
16928
  }
16497
16929
  }
16498
16930
  }
16499
- const attachmentsEnabled = ((_va = config.attachments) == null ? void 0 : _va.enabled) === true;
16931
+ const attachmentsEnabled = ((_Fa = config.attachments) == null ? void 0 : _Fa.enabled) === true;
16500
16932
  if (attachmentsEnabled) {
16501
16933
  if (!attachmentButtonWrapper || !attachmentButton) {
16502
- const attachmentsConfig = (_wa = config.attachments) != null ? _wa : {};
16503
- const sendButtonConfig2 = (_xa = config.sendButton) != null ? _xa : {};
16504
- const buttonSize2 = (_ya = sendButtonConfig2.size) != null ? _ya : "40px";
16934
+ const attachmentsConfig = (_Ga = config.attachments) != null ? _Ga : {};
16935
+ const sendButtonConfig2 = (_Ha = config.sendButton) != null ? _Ha : {};
16936
+ const buttonSize2 = (_Ia = sendButtonConfig2.size) != null ? _Ia : "40px";
16505
16937
  if (!attachmentPreviewsContainer) {
16506
16938
  attachmentPreviewsContainer = createElement("div", "persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2");
16507
16939
  attachmentPreviewsContainer.style.display = "none";
@@ -16510,8 +16942,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16510
16942
  if (!attachmentInput) {
16511
16943
  attachmentInput = document.createElement("input");
16512
16944
  attachmentInput.type = "file";
16513
- attachmentInput.accept = ((_za = attachmentsConfig.allowedTypes) != null ? _za : ALL_SUPPORTED_MIME_TYPES).join(",");
16514
- attachmentInput.multiple = ((_Aa = attachmentsConfig.maxFiles) != null ? _Aa : 4) > 1;
16945
+ attachmentInput.accept = ((_Ja = attachmentsConfig.allowedTypes) != null ? _Ja : ALL_SUPPORTED_MIME_TYPES).join(",");
16946
+ attachmentInput.multiple = ((_Ka = attachmentsConfig.maxFiles) != null ? _Ka : 4) > 1;
16515
16947
  attachmentInput.style.display = "none";
16516
16948
  attachmentInput.setAttribute("aria-label", "Attach files");
16517
16949
  composerForm.insertBefore(attachmentInput, textarea);
@@ -16522,8 +16954,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16522
16954
  "persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-attachment-button"
16523
16955
  );
16524
16956
  attachmentButton.type = "button";
16525
- attachmentButton.setAttribute("aria-label", (_Ba = attachmentsConfig.buttonTooltipText) != null ? _Ba : "Attach file");
16526
- const attachIconName = (_Ca = attachmentsConfig.buttonIconName) != null ? _Ca : "paperclip";
16957
+ attachmentButton.setAttribute("aria-label", (_La = attachmentsConfig.buttonTooltipText) != null ? _La : "Attach file");
16958
+ const attachIconName = (_Ma = attachmentsConfig.buttonIconName) != null ? _Ma : "paperclip";
16527
16959
  const attachIconSize = buttonSize2;
16528
16960
  const buttonSizeNum = parseFloat(attachIconSize) || 40;
16529
16961
  const attachIconSizeNum = Math.round(buttonSizeNum * 0.6);
@@ -16555,7 +16987,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16555
16987
  attachmentInput == null ? void 0 : attachmentInput.click();
16556
16988
  });
16557
16989
  attachmentButtonWrapper.appendChild(attachmentButton);
16558
- const attachTooltipText = (_Da = attachmentsConfig.buttonTooltipText) != null ? _Da : "Attach file";
16990
+ const attachTooltipText = (_Na = attachmentsConfig.buttonTooltipText) != null ? _Na : "Attach file";
16559
16991
  const tooltip2 = createElement("div", "persona-send-button-tooltip");
16560
16992
  tooltip2.textContent = attachTooltipText;
16561
16993
  attachmentButtonWrapper.appendChild(tooltip2);
@@ -16572,10 +17004,10 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16572
17004
  }
16573
17005
  } else {
16574
17006
  attachmentButtonWrapper.style.display = "";
16575
- const attachmentsConfig = (_Ea = config.attachments) != null ? _Ea : {};
17007
+ const attachmentsConfig = (_Oa = config.attachments) != null ? _Oa : {};
16576
17008
  if (attachmentInput) {
16577
- attachmentInput.accept = ((_Fa = attachmentsConfig.allowedTypes) != null ? _Fa : ALL_SUPPORTED_MIME_TYPES).join(",");
16578
- attachmentInput.multiple = ((_Ga = attachmentsConfig.maxFiles) != null ? _Ga : 4) > 1;
17009
+ attachmentInput.accept = ((_Pa = attachmentsConfig.allowedTypes) != null ? _Pa : ALL_SUPPORTED_MIME_TYPES).join(",");
17010
+ attachmentInput.multiple = ((_Qa = attachmentsConfig.maxFiles) != null ? _Qa : 4) > 1;
16579
17011
  }
16580
17012
  if (attachmentManager) {
16581
17013
  attachmentManager.updateConfig({
@@ -16593,13 +17025,13 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16593
17025
  attachmentManager.clearAttachments();
16594
17026
  }
16595
17027
  }
16596
- const sendButtonConfig = (_Ha = config.sendButton) != null ? _Ha : {};
16597
- const useIcon = (_Ia = sendButtonConfig.useIcon) != null ? _Ia : false;
16598
- const iconText = (_Ja = sendButtonConfig.iconText) != null ? _Ja : "\u2191";
17028
+ const sendButtonConfig = (_Ra = config.sendButton) != null ? _Ra : {};
17029
+ const useIcon = (_Sa = sendButtonConfig.useIcon) != null ? _Sa : false;
17030
+ const iconText = (_Ta = sendButtonConfig.iconText) != null ? _Ta : "\u2191";
16599
17031
  const iconName = sendButtonConfig.iconName;
16600
- const tooltipText = (_Ka = sendButtonConfig.tooltipText) != null ? _Ka : "Send message";
16601
- const showTooltip = (_La = sendButtonConfig.showTooltip) != null ? _La : false;
16602
- const buttonSize = (_Ma = sendButtonConfig.size) != null ? _Ma : "40px";
17032
+ const tooltipText = (_Ua = sendButtonConfig.tooltipText) != null ? _Ua : "Send message";
17033
+ const showTooltip = (_Va = sendButtonConfig.showTooltip) != null ? _Va : false;
17034
+ const buttonSize = (_Wa = sendButtonConfig.size) != null ? _Wa : "40px";
16603
17035
  const backgroundColor = sendButtonConfig.backgroundColor;
16604
17036
  const textColor = sendButtonConfig.textColor;
16605
17037
  if (useIcon) {
@@ -16636,7 +17068,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16636
17068
  sendButton.classList.add("persona-bg-persona-primary");
16637
17069
  }
16638
17070
  } else {
16639
- sendButton.textContent = (_Oa = (_Na = config.copy) == null ? void 0 : _Na.sendButtonLabel) != null ? _Oa : "Send";
17071
+ sendButton.textContent = (_Ya = (_Xa = config.copy) == null ? void 0 : _Xa.sendButtonLabel) != null ? _Ya : "Send";
16640
17072
  sendButton.style.width = "";
16641
17073
  sendButton.style.height = "";
16642
17074
  sendButton.style.minWidth = "";
@@ -16696,7 +17128,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16696
17128
  } else if (tooltip) {
16697
17129
  tooltip.style.display = "none";
16698
17130
  }
16699
- const updatedContentMaxWidth = (_Pa = config.layout) == null ? void 0 : _Pa.contentMaxWidth;
17131
+ const updatedContentMaxWidth = (_Za = config.layout) == null ? void 0 : _Za.contentMaxWidth;
16700
17132
  if (updatedContentMaxWidth) {
16701
17133
  messagesWrapper.style.maxWidth = updatedContentMaxWidth;
16702
17134
  messagesWrapper.style.marginLeft = "auto";
@@ -16728,8 +17160,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16728
17160
  suggestions.style.marginRight = "";
16729
17161
  }
16730
17162
  }
16731
- const statusIndicatorConfig = (_Qa = config.statusIndicator) != null ? _Qa : {};
16732
- const isVisible = (_Ra = statusIndicatorConfig.visible) != null ? _Ra : true;
17163
+ const statusIndicatorConfig = (__a = config.statusIndicator) != null ? __a : {};
17164
+ const isVisible = (_$a = statusIndicatorConfig.visible) != null ? _$a : true;
16733
17165
  statusText.style.display = isVisible ? "" : "none";
16734
17166
  if (session) {
16735
17167
  const currentStatus = session.getStatus();
@@ -17785,7 +18217,166 @@ function buildSrcdoc(mountId, shellMode, docked, widgetCssPath) {
17785
18217
  </body>
17786
18218
  </html>`;
17787
18219
  }
17788
- function createPreviewMessages(scene) {
18220
+ var PREVIEW_TRANSCRIPT_PRESET_LABELS = {
18221
+ "user-message": "User message",
18222
+ "assistant-message": "Assistant message",
18223
+ "reasoning-streaming": "Reasoning (streaming)",
18224
+ "reasoning-complete": "Reasoning (complete)",
18225
+ "tool-running": "Tool call (running)",
18226
+ "tool-complete": "Tool call (complete)"
18227
+ };
18228
+ function getPreviewTranscriptPresetLabel(preset) {
18229
+ return PREVIEW_TRANSCRIPT_PRESET_LABELS[preset];
18230
+ }
18231
+ function createPreviewTranscriptEntry(preset, index = 0) {
18232
+ const createdAt = new Date(Date.now() - Math.max(0, 60 - index) * 1e3).toISOString();
18233
+ const suffix = `${preset}-${index}`;
18234
+ switch (preset) {
18235
+ case "user-message":
18236
+ return {
18237
+ id: `preview-seq-user-${suffix}`,
18238
+ role: "user",
18239
+ content: "Can you continue with the next step?",
18240
+ createdAt
18241
+ };
18242
+ case "assistant-message":
18243
+ return {
18244
+ id: `preview-seq-assistant-${suffix}`,
18245
+ role: "assistant",
18246
+ content: "Absolutely. I can keep going and explain what happens next.",
18247
+ createdAt
18248
+ };
18249
+ case "reasoning-streaming":
18250
+ return {
18251
+ id: `preview-seq-reasoning-stream-${suffix}`,
18252
+ role: "assistant",
18253
+ content: "",
18254
+ createdAt,
18255
+ streaming: true,
18256
+ variant: "reasoning",
18257
+ reasoning: {
18258
+ id: `preview-reasoning-stream-${suffix}`,
18259
+ status: "streaming",
18260
+ chunks: ["Thinking through the next step in the workflow..."]
18261
+ }
18262
+ };
18263
+ case "reasoning-complete":
18264
+ return {
18265
+ id: `preview-seq-reasoning-complete-${suffix}`,
18266
+ role: "assistant",
18267
+ content: "",
18268
+ createdAt,
18269
+ streaming: false,
18270
+ variant: "reasoning",
18271
+ reasoning: {
18272
+ id: `preview-reasoning-complete-${suffix}`,
18273
+ status: "complete",
18274
+ chunks: ["Reviewed the requirements and finalized the reasoning output."],
18275
+ durationMs: 1200
18276
+ }
18277
+ };
18278
+ case "tool-complete":
18279
+ return {
18280
+ id: `preview-seq-tool-complete-${suffix}`,
18281
+ role: "assistant",
18282
+ content: "",
18283
+ createdAt,
18284
+ streaming: false,
18285
+ variant: "tool",
18286
+ toolCall: {
18287
+ id: `preview-tool-complete-${suffix}`,
18288
+ name: "Create build instructions",
18289
+ status: "complete",
18290
+ chunks: ["Prepared the build instructions and validated the inputs."],
18291
+ result: { ok: true },
18292
+ duration: 420
18293
+ }
18294
+ };
18295
+ case "tool-running":
18296
+ default:
18297
+ return {
18298
+ id: `preview-seq-tool-running-${suffix}`,
18299
+ role: "assistant",
18300
+ content: "",
18301
+ createdAt,
18302
+ streaming: true,
18303
+ variant: "tool",
18304
+ toolCall: {
18305
+ id: `preview-tool-running-${suffix}`,
18306
+ name: "Get platform documentation",
18307
+ status: "running",
18308
+ chunks: ["Fetching the relevant platform documentation..."]
18309
+ }
18310
+ };
18311
+ }
18312
+ }
18313
+ function appendPreviewTranscriptEntry(messages, preset) {
18314
+ return [...messages, createPreviewTranscriptEntry(preset, messages.length)];
18315
+ }
18316
+ var createAdvancedTranscriptPreviewMessages = () => [
18317
+ {
18318
+ id: "preview-adv-1",
18319
+ role: "user",
18320
+ content: "Can you create the product and gather the docs?",
18321
+ createdAt: new Date(Date.now() - 18e4).toISOString()
18322
+ },
18323
+ {
18324
+ id: "preview-adv-2",
18325
+ role: "assistant",
18326
+ content: "",
18327
+ createdAt: new Date(Date.now() - 15e4).toISOString(),
18328
+ streaming: true,
18329
+ variant: "reasoning",
18330
+ reasoning: {
18331
+ id: "preview-reasoning",
18332
+ status: "streaming",
18333
+ chunks: [
18334
+ "Now let me get the Persona embed documentation and builtin tools catalog."
18335
+ ]
18336
+ }
18337
+ },
18338
+ {
18339
+ id: "preview-adv-3",
18340
+ role: "assistant",
18341
+ content: "",
18342
+ createdAt: new Date(Date.now() - 12e4).toISOString(),
18343
+ streaming: true,
18344
+ variant: "tool",
18345
+ toolCall: {
18346
+ id: "preview-tool-1",
18347
+ name: "Load tools",
18348
+ status: "running",
18349
+ chunks: ["Loaded tools, used Runtype integration"]
18350
+ }
18351
+ },
18352
+ {
18353
+ id: "preview-adv-4",
18354
+ role: "assistant",
18355
+ content: "",
18356
+ createdAt: new Date(Date.now() - 9e4).toISOString(),
18357
+ streaming: true,
18358
+ variant: "tool",
18359
+ toolCall: {
18360
+ id: "preview-tool-2",
18361
+ name: "Get platform documentation",
18362
+ status: "running",
18363
+ chunks: ["Get platform documentation"]
18364
+ }
18365
+ },
18366
+ {
18367
+ id: "preview-adv-5",
18368
+ role: "assistant",
18369
+ content: "I loaded the tools and fetched the docs. Next I can assemble the product details.",
18370
+ createdAt: new Date(Date.now() - 3e4).toISOString()
18371
+ }
18372
+ ];
18373
+ var shouldSeedAdvancedTranscriptPreview = (config) => {
18374
+ var _a, _b, _c, _d, _e, _f, _g, _h;
18375
+ return Boolean(
18376
+ ((_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)
18377
+ );
18378
+ };
18379
+ function createPreviewMessages(scene, config, appendedMessages = []) {
17789
18380
  if (scene === "home") {
17790
18381
  return [{ id: "preview-home-1", role: "assistant", content: "Hi there! How can we help today?", createdAt: (/* @__PURE__ */ new Date()).toISOString() }];
17791
18382
  }
@@ -17798,20 +18389,24 @@ function createPreviewMessages(scene) {
17798
18389
  { id: "preview-art-2", role: "assistant", content: "Here\u2019s a project overview document for you.", createdAt: new Date(Date.now() - 6e4).toISOString() }
17799
18390
  ];
17800
18391
  }
18392
+ if (scene === "conversation" && shouldSeedAdvancedTranscriptPreview(config)) {
18393
+ return [...createAdvancedTranscriptPreviewMessages(), ...appendedMessages];
18394
+ }
17801
18395
  return [
17802
18396
  { id: "preview-conv-1", role: "assistant", content: "Hello! How can I help you today?", createdAt: new Date(Date.now() - 18e4).toISOString() },
17803
18397
  { id: "preview-conv-2", role: "user", content: "I want to customize the theme editor preview.", createdAt: new Date(Date.now() - 12e4).toISOString() },
17804
- { id: "preview-conv-3", role: "assistant", content: "Absolutely. Check out the [getting started guide](https://example.com) to see what\u2019s possible, then adjust colors and tokens to match your brand.", createdAt: new Date(Date.now() - 6e4).toISOString() }
18398
+ { 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() },
18399
+ ...appendedMessages
17805
18400
  ];
17806
18401
  }
17807
- function applySceneConfig(base, scene) {
18402
+ function applySceneConfig(base, scene, appendedMessages = []) {
17808
18403
  var _a, _b;
17809
18404
  const launcher = { ...base.launcher, enabled: true, autoExpand: scene !== "minimized" };
17810
18405
  const config = {
17811
18406
  ...base,
17812
18407
  launcher,
17813
18408
  suggestionChips: scene === "home" ? ((_a = base.suggestionChips) == null ? void 0 : _a.length) ? base.suggestionChips : HOME_SUGGESTION_CHIPS : base.suggestionChips,
17814
- initialMessages: createPreviewMessages(scene),
18409
+ initialMessages: createPreviewMessages(scene, base, appendedMessages),
17815
18410
  storageAdapter: PREVIEW_STORAGE_ADAPTER
17816
18411
  };
17817
18412
  if (scene === "artifact") {
@@ -17820,6 +18415,19 @@ function applySceneConfig(base, scene) {
17820
18415
  return config;
17821
18416
  }
17822
18417
  function buildPreviewConfig(options, shellModeOverride) {
18418
+ var _a, _b, _c, _d;
18419
+ const theme = options.theme ? createTheme(options.theme, { validate: false }) : createTheme();
18420
+ const scene = (_a = options.scene) != null ? _a : "conversation";
18421
+ const base = {
18422
+ ...DEFAULT_WIDGET_CONFIG,
18423
+ ...options.config,
18424
+ theme,
18425
+ darkTheme: options.darkTheme,
18426
+ colorScheme: (_c = shellModeOverride != null ? shellModeOverride : (_b = options.config) == null ? void 0 : _b.colorScheme) != null ? _c : "light"
18427
+ };
18428
+ return applySceneConfig(base, scene, (_d = options.appendedMessages) != null ? _d : []);
18429
+ }
18430
+ function buildPreviewConfigWithMessages(options, messages, shellModeOverride) {
17823
18431
  var _a, _b, _c;
17824
18432
  const theme = options.theme ? createTheme(options.theme, { validate: false }) : createTheme();
17825
18433
  const scene = (_a = options.scene) != null ? _a : "conversation";
@@ -17830,7 +18438,7 @@ function buildPreviewConfig(options, shellModeOverride) {
17830
18438
  darkTheme: options.darkTheme,
17831
18439
  colorScheme: (_c = shellModeOverride != null ? shellModeOverride : (_b = options.config) == null ? void 0 : _b.colorScheme) != null ? _c : "light"
17832
18440
  };
17833
- return applySceneConfig(base, scene);
18441
+ return applySceneConfig(base, scene, messages);
17834
18442
  }
17835
18443
 
17836
18444
  // src/theme-editor/preview.ts
@@ -18147,20 +18755,24 @@ export {
18147
18755
  ThemeEditorState,
18148
18756
  ZOOM_MAX,
18149
18757
  ZOOM_MIN,
18758
+ appendPreviewTranscriptEntry,
18150
18759
  applySceneConfig,
18151
18760
  applyShellTheme,
18152
18761
  buildPreviewConfig,
18762
+ buildPreviewConfigWithMessages,
18153
18763
  buildShellCss,
18154
18764
  buildSrcdoc,
18155
18765
  convertFromPx,
18156
18766
  convertToPx,
18157
18767
  createPreviewMessages,
18768
+ createPreviewTranscriptEntry,
18158
18769
  createThemePreview,
18159
18770
  detectRoleAssignment,
18160
18771
  escapeHtml2 as escapeHtml,
18161
18772
  findSection,
18162
18773
  formatCssValue,
18163
18774
  generateColorScale,
18775
+ getPreviewTranscriptPresetLabel,
18164
18776
  getShellPalette,
18165
18777
  getThemeEditorPreset,
18166
18778
  hexToHsl,