@agentiffai/design 1.3.11 → 1.3.13

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.
@@ -1,4 +1,4 @@
1
- export { A as Action, c as ActionVariant, d as Actions, a as ActionsLayout, b as ActionsProps, f as AgentState, e as AgentStateProps, q as AssistantMessage, m as AssistantMessageProps, i as Button, B as ButtonProps, g as ButtonSize, h as ButtonVariant, r as FileAttachment, n as FileAttachmentProps, j as Footer, F as FooterProps, k as Header, H as HeaderProps, l as Input, I as InputProps, M as Message, s as Messages, t as MessagesList, u as MessagesListContainer, v as MessagesListContent, o as MessagesListProps, p as MessagesProps, x as Response, R as ResponseProps, y as StreamErrorMessage, S as StreamErrorMessageProps, E as StreamStatusIndicator, D as StreamStatusIndicatorProps, C as StreamingText, z as StreamingTextProps, J as Suggestions, G as SuggestionsProps, w as UserMessage, U as UserMessageProps, K as Window, W as WindowProps } from '../Window-BcTRumpc.cjs';
1
+ export { A as Action, c as ActionVariant, d as Actions, a as ActionsLayout, b as ActionsProps, f as AgentState, e as AgentStateProps, q as AssistantMessage, m as AssistantMessageProps, i as Button, B as ButtonProps, g as ButtonSize, h as ButtonVariant, r as FileAttachment, n as FileAttachmentProps, j as Footer, F as FooterProps, k as Header, H as HeaderProps, l as Input, I as InputProps, M as Message, s as Messages, t as MessagesList, u as MessagesListContainer, v as MessagesListContent, o as MessagesListProps, p as MessagesProps, x as Response, R as ResponseProps, y as StreamErrorMessage, S as StreamErrorMessageProps, E as StreamStatusIndicator, D as StreamStatusIndicatorProps, C as StreamingText, z as StreamingTextProps, J as Suggestions, G as SuggestionsProps, w as UserMessage, U as UserMessageProps, K as Window, W as WindowProps } from '../Window-pJb3Z5_P.cjs';
2
2
  import { RenderMessageProps, AssistantMessageProps, InputProps, UserMessageProps } from '@copilotkit/react-ui';
3
3
  import * as React$1 from 'react';
4
4
  import React__default, { ReactNode } from 'react';
@@ -1,4 +1,4 @@
1
- export { A as Action, c as ActionVariant, d as Actions, a as ActionsLayout, b as ActionsProps, f as AgentState, e as AgentStateProps, q as AssistantMessage, m as AssistantMessageProps, i as Button, B as ButtonProps, g as ButtonSize, h as ButtonVariant, r as FileAttachment, n as FileAttachmentProps, j as Footer, F as FooterProps, k as Header, H as HeaderProps, l as Input, I as InputProps, M as Message, s as Messages, t as MessagesList, u as MessagesListContainer, v as MessagesListContent, o as MessagesListProps, p as MessagesProps, x as Response, R as ResponseProps, y as StreamErrorMessage, S as StreamErrorMessageProps, E as StreamStatusIndicator, D as StreamStatusIndicatorProps, C as StreamingText, z as StreamingTextProps, J as Suggestions, G as SuggestionsProps, w as UserMessage, U as UserMessageProps, K as Window, W as WindowProps } from '../Window-BcTRumpc.js';
1
+ export { A as Action, c as ActionVariant, d as Actions, a as ActionsLayout, b as ActionsProps, f as AgentState, e as AgentStateProps, q as AssistantMessage, m as AssistantMessageProps, i as Button, B as ButtonProps, g as ButtonSize, h as ButtonVariant, r as FileAttachment, n as FileAttachmentProps, j as Footer, F as FooterProps, k as Header, H as HeaderProps, l as Input, I as InputProps, M as Message, s as Messages, t as MessagesList, u as MessagesListContainer, v as MessagesListContent, o as MessagesListProps, p as MessagesProps, x as Response, R as ResponseProps, y as StreamErrorMessage, S as StreamErrorMessageProps, E as StreamStatusIndicator, D as StreamStatusIndicatorProps, C as StreamingText, z as StreamingTextProps, J as Suggestions, G as SuggestionsProps, w as UserMessage, U as UserMessageProps, K as Window, W as WindowProps } from '../Window-pJb3Z5_P.js';
2
2
  import { RenderMessageProps, AssistantMessageProps, InputProps, UserMessageProps } from '@copilotkit/react-ui';
3
3
  import * as React$1 from 'react';
4
4
  import React__default, { ReactNode } from 'react';
@@ -1,5 +1,5 @@
1
1
  import { useButton } from '@react-aria/button';
2
- import { memo, useRef, useEffect, useState, useMemo, useCallback } from 'react';
2
+ import { memo, useRef, useEffect, useMemo, useState, useCallback } from 'react';
3
3
  import styled8, { css, keyframes, createGlobalStyle } from 'styled-components';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
5
  import { useCopilotChat } from '@copilotkit/react-core';
@@ -104,7 +104,9 @@ var tokens = {
104
104
  fontWeight: {
105
105
  regular: 400,
106
106
  medium: 500,
107
- semibold: 600},
107
+ semibold: 600,
108
+ bold: 700
109
+ },
108
110
  lineHeight: {
109
111
  tight: 1.25,
110
112
  normal: 1.5}
@@ -822,6 +824,59 @@ function AssistantThinking({
822
824
  );
823
825
  }
824
826
  AssistantThinking.displayName = "AssistantThinking";
827
+ function parseMarkdown(text) {
828
+ if (!text) return [];
829
+ const elements = [];
830
+ let key = 0;
831
+ const paragraphs = text.split(/\n\n+/);
832
+ paragraphs.forEach((paragraph, pIndex) => {
833
+ if (pIndex > 0) {
834
+ elements.push(/* @__PURE__ */ jsx("br", {}, key++));
835
+ elements.push(/* @__PURE__ */ jsx("br", {}, key++));
836
+ }
837
+ const lines = paragraph.split("\n");
838
+ lines.forEach((line, lineIndex) => {
839
+ if (lineIndex > 0) {
840
+ elements.push(/* @__PURE__ */ jsx("br", {}, key++));
841
+ }
842
+ const parsed = parseInlineMarkdown(line, key);
843
+ elements.push(...parsed.elements);
844
+ key = parsed.nextKey;
845
+ });
846
+ });
847
+ return elements;
848
+ }
849
+ function parseInlineMarkdown(text, startKey) {
850
+ const elements = [];
851
+ let key = startKey;
852
+ const inlineRegex = /(\*\*(.+?)\*\*)|(\*(.+?)\*)|(`([^`]+)`)|(\[([^\]]+)\]\(([^)]+)\))/g;
853
+ let lastIndex = 0;
854
+ let match;
855
+ while ((match = inlineRegex.exec(text)) !== null) {
856
+ if (match.index > lastIndex) {
857
+ elements.push(text.slice(lastIndex, match.index));
858
+ }
859
+ if (match[1]) {
860
+ elements.push(/* @__PURE__ */ jsx("strong", { children: match[2] }, key++));
861
+ } else if (match[3]) {
862
+ elements.push(/* @__PURE__ */ jsx("em", { children: match[4] }, key++));
863
+ } else if (match[5]) {
864
+ elements.push(/* @__PURE__ */ jsx("code", { children: match[6] }, key++));
865
+ } else if (match[7]) {
866
+ elements.push(
867
+ /* @__PURE__ */ jsx("a", { href: match[9], target: "_blank", rel: "noopener noreferrer", children: match[8] }, key++)
868
+ );
869
+ }
870
+ lastIndex = match.index + match[0].length;
871
+ }
872
+ if (lastIndex < text.length) {
873
+ elements.push(text.slice(lastIndex));
874
+ }
875
+ if (elements.length === 0) {
876
+ elements.push(text);
877
+ }
878
+ return { elements, nextKey: key };
879
+ }
825
880
  var Container3 = styled8.div`
826
881
  font-family: ${(props) => props.$variant === "code" ? tokens.typography.fontFamily.monospace : tokens.typography.fontFamily.primary};
827
882
  white-space: pre-wrap;
@@ -830,6 +885,33 @@ var Container3 = styled8.div`
830
885
  /* Performance optimizations for streaming text */
831
886
  text-rendering: optimizeSpeed;
832
887
  contain: content;
888
+
889
+ /* Markdown element styles */
890
+ strong {
891
+ font-weight: ${tokens.typography.fontWeight.bold};
892
+ color: ${tokens.colors.text.primary};
893
+ }
894
+
895
+ em {
896
+ font-style: italic;
897
+ }
898
+
899
+ code {
900
+ font-family: ${tokens.typography.fontFamily.monospace};
901
+ background: ${tokens.colors.surface.overlay};
902
+ padding: 0.15em 0.4em;
903
+ border-radius: ${tokens.borderRadius.sm};
904
+ font-size: 0.9em;
905
+ }
906
+
907
+ a {
908
+ color: ${tokens.colors.primary};
909
+ text-decoration: none;
910
+
911
+ &:hover {
912
+ text-decoration: underline;
913
+ }
914
+ }
833
915
  `;
834
916
  var Cursor = styled8.span`
835
917
  display: inline-block;
@@ -874,8 +956,14 @@ var StreamingTextBase = ({
874
956
  wasStreamingRef.current = isStreaming;
875
957
  }, [isStreaming, onStreamComplete]);
876
958
  const showCursor = isStreaming && cursor;
959
+ const renderedContent = useMemo(() => {
960
+ if (variant === "markdown") {
961
+ return parseMarkdown(content);
962
+ }
963
+ return content;
964
+ }, [content, variant]);
877
965
  return /* @__PURE__ */ jsxs(Container3, { $variant: variant, className, children: [
878
- content,
966
+ renderedContent,
879
967
  showCursor && /* @__PURE__ */ jsx(Cursor, {})
880
968
  ] });
881
969
  };
@@ -1307,20 +1395,30 @@ var AssistantMessageAdapterBase = ({
1307
1395
  // markdownTagRenderers,
1308
1396
  // ImageRenderer,
1309
1397
  }) => {
1310
- if (isLoading || isGenerating && !message?.content) {
1311
- return /* @__PURE__ */ jsx(AssistantThinking, { message: "Thinking..." });
1312
- }
1398
+ const lastGenerativeUIRef = useRef(null);
1313
1399
  const rawContent = message?.content || "";
1314
1400
  const content = stripToolCallMarkers(rawContent);
1315
1401
  let generativeUIOutput = null;
1316
1402
  const msgWithUI = message;
1317
1403
  if (msgWithUI && typeof msgWithUI.generativeUI === "function") {
1318
1404
  try {
1319
- generativeUIOutput = msgWithUI.generativeUI();
1405
+ const newOutput = msgWithUI.generativeUI();
1406
+ if (newOutput !== null && newOutput !== void 0) {
1407
+ generativeUIOutput = newOutput;
1408
+ lastGenerativeUIRef.current = newOutput;
1409
+ }
1320
1410
  } catch (e) {
1321
1411
  console.warn("[AssistantMessageAdapter] Error rendering generativeUI:", e);
1322
1412
  }
1323
1413
  }
1414
+ if (!generativeUIOutput && lastGenerativeUIRef.current) {
1415
+ generativeUIOutput = lastGenerativeUIRef.current;
1416
+ }
1417
+ const hasGenerativeUI = generativeUIOutput !== null;
1418
+ const showThinking = (isLoading || isGenerating && !content) && !hasGenerativeUI;
1419
+ if (showThinking) {
1420
+ return /* @__PURE__ */ jsx(AssistantThinking, { message: "Thinking..." });
1421
+ }
1324
1422
  const attachments = [];
1325
1423
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1326
1424
  generativeUIOutput && /* @__PURE__ */ jsx(GenerativeUIContainer, { children: generativeUIOutput }),
@@ -1339,35 +1437,39 @@ var AssistantMessageAdapterBase = ({
1339
1437
  };
1340
1438
  var AssistantMessageAdapter = memo(AssistantMessageAdapterBase);
1341
1439
  AssistantMessageAdapter.displayName = "AssistantMessageAdapter";
1342
- function createAssistantMessageAdapter(ThinkingIndicator, ToolCallsComponent) {
1440
+ function createAssistantMessageAdapter(ThinkingIndicator, _ToolCallsComponent) {
1343
1441
  const CustomAssistantMessageAdapter = ({
1344
1442
  message,
1345
1443
  isLoading,
1346
- isGenerating,
1347
- isCurrentMessage
1444
+ isGenerating
1445
+ // isCurrentMessage and ToolCallsComponent are no longer used but kept for backwards compat
1348
1446
  }) => {
1349
- const showThinking = isLoading || isGenerating && !message?.content;
1350
- const shouldShowToolCalls = isCurrentMessage && ToolCallsComponent;
1447
+ const lastGenerativeUIRef = useRef(null);
1351
1448
  const rawContent = message?.content || "";
1352
1449
  const content = stripToolCallMarkers(rawContent);
1353
1450
  let generativeUIOutput = null;
1354
1451
  const msgWithUI = message;
1355
1452
  if (msgWithUI && typeof msgWithUI.generativeUI === "function") {
1356
1453
  try {
1357
- generativeUIOutput = msgWithUI.generativeUI();
1454
+ const newOutput = msgWithUI.generativeUI();
1455
+ if (newOutput !== null && newOutput !== void 0) {
1456
+ generativeUIOutput = newOutput;
1457
+ lastGenerativeUIRef.current = newOutput;
1458
+ }
1358
1459
  } catch (e) {
1359
1460
  console.warn("[AssistantMessageAdapter] Error rendering generativeUI:", e);
1360
1461
  }
1361
1462
  }
1463
+ if (!generativeUIOutput && lastGenerativeUIRef.current) {
1464
+ generativeUIOutput = lastGenerativeUIRef.current;
1465
+ }
1362
1466
  const attachments = [];
1467
+ const hasGenerativeUI = generativeUIOutput !== null;
1468
+ const showThinking = (isLoading || isGenerating && !content) && !hasGenerativeUI;
1363
1469
  if (showThinking) {
1364
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1365
- ThinkingIndicator ? /* @__PURE__ */ jsx(ThinkingIndicator, { isLoading, isGenerating }) : /* @__PURE__ */ jsx(AssistantThinking, { message: "Thinking..." }),
1366
- shouldShowToolCalls && /* @__PURE__ */ jsx(ToolCallsComponent, {})
1367
- ] });
1470
+ return /* @__PURE__ */ jsx(Fragment, { children: ThinkingIndicator ? /* @__PURE__ */ jsx(ThinkingIndicator, { isLoading, isGenerating }) : /* @__PURE__ */ jsx(AssistantThinking, { message: "Thinking..." }) });
1368
1471
  }
1369
1472
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1370
- shouldShowToolCalls && /* @__PURE__ */ jsx(ToolCallsComponent, {}),
1371
1473
  generativeUIOutput && /* @__PURE__ */ jsx(GenerativeUIContainer, { children: generativeUIOutput }),
1372
1474
  content && /* @__PURE__ */ jsx(
1373
1475
  AssistantMessage,
@@ -1385,16 +1487,15 @@ function createAssistantMessageAdapter(ThinkingIndicator, ToolCallsComponent) {
1385
1487
  CustomAssistantMessageAdapter.displayName = "CustomAssistantMessageAdapter";
1386
1488
  return memo(CustomAssistantMessageAdapter);
1387
1489
  }
1388
- function createAssistantMessageAdapterWithErrorReporting(onReportIssue, ThinkingIndicator, ToolCallsComponent) {
1490
+ function createAssistantMessageAdapterWithErrorReporting(onReportIssue, ThinkingIndicator, _ToolCallsComponent) {
1389
1491
  const ErrorReportingAssistantMessageAdapter = ({
1390
1492
  message,
1391
1493
  isLoading,
1392
- isGenerating,
1393
- isCurrentMessage
1494
+ isGenerating
1495
+ // isCurrentMessage and ToolCallsComponent are no longer used but kept for backwards compat
1394
1496
  }) => {
1497
+ const lastGenerativeUIRef = useRef(null);
1395
1498
  const { visibleMessages } = useCopilotChat();
1396
- const showThinking = isLoading || isGenerating && !message?.content;
1397
- const shouldShowToolCalls = isCurrentMessage && ToolCallsComponent;
1398
1499
  const rawContent = message?.content || "";
1399
1500
  const content = stripToolCallMarkers(rawContent);
1400
1501
  const errorContext = useMemo(() => detectErrorInMessage(content), [content]);
@@ -1442,20 +1543,25 @@ function createAssistantMessageAdapterWithErrorReporting(onReportIssue, Thinking
1442
1543
  const msgWithUI = message;
1443
1544
  if (msgWithUI && typeof msgWithUI.generativeUI === "function") {
1444
1545
  try {
1445
- generativeUIOutput = msgWithUI.generativeUI();
1546
+ const newOutput = msgWithUI.generativeUI();
1547
+ if (newOutput !== null && newOutput !== void 0) {
1548
+ generativeUIOutput = newOutput;
1549
+ lastGenerativeUIRef.current = newOutput;
1550
+ }
1446
1551
  } catch (e) {
1447
1552
  console.warn("[AssistantMessageAdapter] Error rendering generativeUI:", e);
1448
1553
  }
1449
1554
  }
1555
+ if (!generativeUIOutput && lastGenerativeUIRef.current) {
1556
+ generativeUIOutput = lastGenerativeUIRef.current;
1557
+ }
1450
1558
  const attachments = [];
1559
+ const hasGenerativeUI = generativeUIOutput !== null;
1560
+ const showThinking = (isLoading || isGenerating && !content) && !hasGenerativeUI;
1451
1561
  if (showThinking) {
1452
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1453
- ThinkingIndicator ? /* @__PURE__ */ jsx(ThinkingIndicator, { isLoading, isGenerating }) : /* @__PURE__ */ jsx(AssistantThinking, { message: "Thinking..." }),
1454
- shouldShowToolCalls && /* @__PURE__ */ jsx(ToolCallsComponent, {})
1455
- ] });
1562
+ return /* @__PURE__ */ jsx(Fragment, { children: ThinkingIndicator ? /* @__PURE__ */ jsx(ThinkingIndicator, { isLoading, isGenerating }) : /* @__PURE__ */ jsx(AssistantThinking, { message: "Thinking..." }) });
1456
1563
  }
1457
1564
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1458
- shouldShowToolCalls && /* @__PURE__ */ jsx(ToolCallsComponent, {}),
1459
1565
  generativeUIOutput && /* @__PURE__ */ jsx(GenerativeUIContainer, { children: generativeUIOutput }),
1460
1566
  content && /* @__PURE__ */ jsx(
1461
1567
  AssistantMessage,
@@ -3084,7 +3190,7 @@ function CustomCopilotSidebar2({
3084
3190
  [disabled, disabledReason, onSetOpen]
3085
3191
  );
3086
3192
  const AssistantMessageAdapterMemo = useMemo(
3087
- () => onReportIssue ? createAssistantMessageAdapterWithErrorReporting(onReportIssue, ThinkingIndicator, ToolCallsComponent) : ThinkingIndicator || ToolCallsComponent ? createAssistantMessageAdapter(ThinkingIndicator, ToolCallsComponent) : AssistantMessageAdapter,
3193
+ () => onReportIssue ? createAssistantMessageAdapterWithErrorReporting(onReportIssue, ThinkingIndicator) : ThinkingIndicator || ToolCallsComponent ? createAssistantMessageAdapter(ThinkingIndicator) : AssistantMessageAdapter,
3088
3194
  [ThinkingIndicator, ToolCallsComponent, onReportIssue]
3089
3195
  );
3090
3196
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -3640,27 +3746,6 @@ var ActionsContainer3 = styled8.div`
3640
3746
  gap: ${tokens.spacing.xs};
3641
3747
  flex-wrap: wrap;
3642
3748
  `;
3643
- var StreamingIndicator2 = styled8.span`
3644
- display: inline-block;
3645
- width: ${tokens.spacing.xs};
3646
- height: ${tokens.spacing.xs};
3647
- margin-left: ${tokens.spacing.xs};
3648
- background-color: ${tokens.colors.text.tertiary};
3649
- border-radius: ${tokens.borderRadius.full};
3650
- animation: pulse 1.5s ease-in-out infinite;
3651
-
3652
- @keyframes pulse {
3653
- 0%,
3654
- 100% {
3655
- opacity: 0.3;
3656
- transform: scale(0.8);
3657
- }
3658
- 50% {
3659
- opacity: 1;
3660
- transform: scale(1.2);
3661
- }
3662
- }
3663
- `;
3664
3749
  var Avatar3 = styled8.img`
3665
3750
  width: ${tokens.spacing.xl};
3666
3751
  height: ${tokens.spacing.xl};
@@ -3676,15 +3761,21 @@ var UserMessage2 = ({
3676
3761
  avatarUrl,
3677
3762
  username,
3678
3763
  isStreaming = false,
3679
- actions = []
3764
+ actions = [],
3765
+ enableMarkdown = true
3680
3766
  }) => {
3681
3767
  return /* @__PURE__ */ jsxs(StyledUserMessage2, { className, children: [
3682
3768
  /* @__PURE__ */ jsxs(MessageBubble, { children: [
3683
3769
  username && /* @__PURE__ */ jsx("strong", { children: username }),
3684
- /* @__PURE__ */ jsxs(MessageContent2, { children: [
3685
- content,
3686
- isStreaming && /* @__PURE__ */ jsx(StreamingIndicator2, {})
3687
- ] }),
3770
+ /* @__PURE__ */ jsx(MessageContent2, { children: /* @__PURE__ */ jsx(
3771
+ StreamingText2,
3772
+ {
3773
+ content,
3774
+ isStreaming,
3775
+ variant: enableMarkdown ? "markdown" : "default",
3776
+ cursor: false
3777
+ }
3778
+ ) }),
3688
3779
  timestamp && /* @__PURE__ */ jsx(MessageTime2, { children: timestamp }),
3689
3780
  actions.length > 0 && /* @__PURE__ */ jsx(ActionsContainer3, { children: actions.map((action, index) => /* @__PURE__ */ jsxs(ActionButton3, { onClick: action.onClick, children: [
3690
3781
  action.icon,