@townco/ui 0.1.17 → 0.1.19

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 (214) hide show
  1. package/dist/core/hooks/use-chat-input.d.ts +17 -17
  2. package/dist/core/hooks/use-chat-input.js +55 -64
  3. package/dist/core/hooks/use-chat-messages.js +114 -121
  4. package/dist/core/hooks/use-chat-session.d.ts +1 -1
  5. package/dist/core/hooks/use-chat-session.js +80 -78
  6. package/dist/gui/components/Button.d.ts +7 -23
  7. package/dist/gui/components/Button.js +27 -40
  8. package/dist/gui/components/Card.d.ts +7 -26
  9. package/dist/gui/components/Card.js +8 -54
  10. package/dist/gui/components/ChatEmptyState.d.ts +18 -0
  11. package/dist/gui/components/ChatEmptyState.js +22 -0
  12. package/dist/gui/components/ChatInput.js +29 -1
  13. package/dist/gui/components/ChatLayout.js +2 -2
  14. package/dist/gui/components/ChatSecondaryPanel.d.ts +25 -14
  15. package/dist/gui/components/ChatSecondaryPanel.js +60 -115
  16. package/dist/gui/components/ChatStatus.d.ts +2 -4
  17. package/dist/gui/components/ChatStatus.js +34 -45
  18. package/dist/gui/components/Conversation.d.ts +14 -17
  19. package/dist/gui/components/Conversation.js +83 -143
  20. package/dist/gui/components/Dialog.d.ts +11 -57
  21. package/dist/gui/components/HeightTransition.d.ts +7 -12
  22. package/dist/gui/components/HeightTransition.js +77 -88
  23. package/dist/gui/components/Input.d.ts +6 -13
  24. package/dist/gui/components/Input.js +16 -27
  25. package/dist/gui/components/Label.d.ts +1 -7
  26. package/dist/gui/components/MarkdownRenderer.d.ts +4 -6
  27. package/dist/gui/components/MarkdownRenderer.js +81 -178
  28. package/dist/gui/components/Message.d.ts +1 -1
  29. package/dist/gui/components/MessageContent.d.ts +22 -29
  30. package/dist/gui/components/PanelTabsHeader.d.ts +17 -0
  31. package/dist/gui/components/PanelTabsHeader.js +31 -0
  32. package/dist/gui/components/Reasoning.d.ts +24 -30
  33. package/dist/gui/components/Reasoning.js +60 -187
  34. package/dist/gui/components/Response.d.ts +9 -11
  35. package/dist/gui/components/Response.js +90 -229
  36. package/dist/gui/components/Select.d.ts +10 -69
  37. package/dist/gui/components/Tabs.d.ts +4 -24
  38. package/dist/gui/components/Task.d.ts +24 -28
  39. package/dist/gui/components/Task.js +31 -164
  40. package/dist/gui/components/Textarea.d.ts +7 -15
  41. package/dist/gui/components/Textarea.js +46 -63
  42. package/dist/gui/components/ThinkingBlock.d.ts +10 -20
  43. package/dist/gui/components/ThinkingBlock.js +35 -134
  44. package/dist/gui/components/TodoList.d.ts +10 -12
  45. package/dist/gui/components/TodoList.js +7 -22
  46. package/dist/gui/components/TodoListItem.d.ts +6 -9
  47. package/dist/gui/components/TodoListItem.js +4 -18
  48. package/dist/gui/components/index.d.ts +2 -0
  49. package/dist/gui/components/index.js +2 -0
  50. package/dist/gui/lib/utils.js +1 -1
  51. package/dist/index.test.js +1 -0
  52. package/dist/sdk/client/acp-client.d.ts +76 -88
  53. package/dist/sdk/client/acp-client.js +217 -215
  54. package/dist/sdk/schemas/agent.d.ts +64 -111
  55. package/dist/sdk/schemas/agent.js +24 -24
  56. package/dist/sdk/schemas/message.d.ts +147 -245
  57. package/dist/sdk/schemas/message.js +40 -40
  58. package/dist/sdk/schemas/session.d.ts +6 -6
  59. package/dist/sdk/transports/http.d.ts +55 -55
  60. package/dist/sdk/transports/http.js +3 -3
  61. package/dist/sdk/transports/stdio.d.ts +20 -20
  62. package/dist/sdk/transports/types.d.ts +42 -42
  63. package/dist/sdk/transports/websocket.d.ts +12 -12
  64. package/dist/sdk/transports/websocket.js +46 -52
  65. package/dist/tui/components/ChatView.d.ts +2 -4
  66. package/dist/tui/components/GameOfLife.js +35 -64
  67. package/dist/tui/components/InputBox.d.ts +11 -18
  68. package/dist/tui/components/InputBox.js +10 -70
  69. package/dist/tui/components/ReadlineInput.d.ts +6 -12
  70. package/dist/tui/components/ReadlineInput.js +237 -252
  71. package/dist/tui/components/SingleSelect.d.ts +9 -15
  72. package/dist/tui/components/SingleSelect.js +43 -84
  73. package/dist/tui/components/StatusBar.d.ts +6 -11
  74. package/dist/tui/components/StatusBar.js +67 -102
  75. package/package.json +2 -2
  76. package/src/styles/global.css +64 -0
  77. package/dist/core/hooks/index.d.ts.map +0 -1
  78. package/dist/core/hooks/index.js.map +0 -1
  79. package/dist/core/hooks/use-chat-input.d.ts.map +0 -1
  80. package/dist/core/hooks/use-chat-input.js.map +0 -1
  81. package/dist/core/hooks/use-chat-messages.d.ts.map +0 -1
  82. package/dist/core/hooks/use-chat-messages.js.map +0 -1
  83. package/dist/core/hooks/use-chat-session.d.ts.map +0 -1
  84. package/dist/core/hooks/use-chat-session.js.map +0 -1
  85. package/dist/core/index.d.ts.map +0 -1
  86. package/dist/core/index.js.map +0 -1
  87. package/dist/core/schemas/chat.d.ts.map +0 -1
  88. package/dist/core/schemas/chat.js.map +0 -1
  89. package/dist/core/schemas/index.d.ts.map +0 -1
  90. package/dist/core/schemas/index.js.map +0 -1
  91. package/dist/core/store/chat-store.d.ts.map +0 -1
  92. package/dist/core/store/chat-store.js.map +0 -1
  93. package/dist/gui/components/Button.d.ts.map +0 -1
  94. package/dist/gui/components/Button.js.map +0 -1
  95. package/dist/gui/components/Card.d.ts.map +0 -1
  96. package/dist/gui/components/Card.js.map +0 -1
  97. package/dist/gui/components/ChatInput.d.ts.map +0 -1
  98. package/dist/gui/components/ChatInput.js.map +0 -1
  99. package/dist/gui/components/ChatInterface.d.ts +0 -12
  100. package/dist/gui/components/ChatInterface.d.ts.map +0 -1
  101. package/dist/gui/components/ChatInterface.js +0 -204
  102. package/dist/gui/components/ChatInterface.js.map +0 -1
  103. package/dist/gui/components/ChatPreview.d.ts +0 -12
  104. package/dist/gui/components/ChatPreview.d.ts.map +0 -1
  105. package/dist/gui/components/ChatPreview.js +0 -214
  106. package/dist/gui/components/ChatPreview.js.map +0 -1
  107. package/dist/gui/components/ChatSecondaryPanel.d.ts.map +0 -1
  108. package/dist/gui/components/ChatSecondaryPanel.js.map +0 -1
  109. package/dist/gui/components/ChatStatus.d.ts.map +0 -1
  110. package/dist/gui/components/ChatStatus.js.map +0 -1
  111. package/dist/gui/components/ChatView.d.ts +0 -8
  112. package/dist/gui/components/ChatView.d.ts.map +0 -1
  113. package/dist/gui/components/ChatView.js +0 -42
  114. package/dist/gui/components/ChatView.js.map +0 -1
  115. package/dist/gui/components/ConfigPanel.d.ts +0 -20
  116. package/dist/gui/components/ConfigPanel.d.ts.map +0 -1
  117. package/dist/gui/components/ConfigPanel.js +0 -225
  118. package/dist/gui/components/ConfigPanel.js.map +0 -1
  119. package/dist/gui/components/Conversation.d.ts.map +0 -1
  120. package/dist/gui/components/Conversation.js.map +0 -1
  121. package/dist/gui/components/Dialog.d.ts.map +0 -1
  122. package/dist/gui/components/Dialog.js.map +0 -1
  123. package/dist/gui/components/HeightTransition.d.ts.map +0 -1
  124. package/dist/gui/components/HeightTransition.js.map +0 -1
  125. package/dist/gui/components/Input.d.ts.map +0 -1
  126. package/dist/gui/components/Input.js.map +0 -1
  127. package/dist/gui/components/InputBox.d.ts +0 -21
  128. package/dist/gui/components/InputBox.d.ts.map +0 -1
  129. package/dist/gui/components/InputBox.js +0 -90
  130. package/dist/gui/components/InputBox.js.map +0 -1
  131. package/dist/gui/components/Label.d.ts.map +0 -1
  132. package/dist/gui/components/Label.js.map +0 -1
  133. package/dist/gui/components/MarkdownRenderer.d.ts.map +0 -1
  134. package/dist/gui/components/MarkdownRenderer.js.map +0 -1
  135. package/dist/gui/components/Message.d.ts.map +0 -1
  136. package/dist/gui/components/Message.js.map +0 -1
  137. package/dist/gui/components/MessageContent.d.ts.map +0 -1
  138. package/dist/gui/components/MessageContent.js.map +0 -1
  139. package/dist/gui/components/MessageList.d.ts.map +0 -1
  140. package/dist/gui/components/MessageList.js.map +0 -1
  141. package/dist/gui/components/PlaygroundLayout.d.ts +0 -14
  142. package/dist/gui/components/PlaygroundLayout.d.ts.map +0 -1
  143. package/dist/gui/components/PlaygroundLayout.js +0 -49
  144. package/dist/gui/components/PlaygroundLayout.js.map +0 -1
  145. package/dist/gui/components/Reasoning.d.ts.map +0 -1
  146. package/dist/gui/components/Reasoning.js.map +0 -1
  147. package/dist/gui/components/Response.d.ts.map +0 -1
  148. package/dist/gui/components/Response.js.map +0 -1
  149. package/dist/gui/components/Select.d.ts.map +0 -1
  150. package/dist/gui/components/Select.js.map +0 -1
  151. package/dist/gui/components/StatusBar.d.ts +0 -12
  152. package/dist/gui/components/StatusBar.d.ts.map +0 -1
  153. package/dist/gui/components/StatusBar.js +0 -58
  154. package/dist/gui/components/StatusBar.js.map +0 -1
  155. package/dist/gui/components/Tabs.d.ts.map +0 -1
  156. package/dist/gui/components/Tabs.js.map +0 -1
  157. package/dist/gui/components/Task.d.ts.map +0 -1
  158. package/dist/gui/components/Task.js.map +0 -1
  159. package/dist/gui/components/Textarea.d.ts.map +0 -1
  160. package/dist/gui/components/Textarea.js.map +0 -1
  161. package/dist/gui/components/ThinkingBlock.d.ts.map +0 -1
  162. package/dist/gui/components/ThinkingBlock.js.map +0 -1
  163. package/dist/gui/components/TodoList.d.ts.map +0 -1
  164. package/dist/gui/components/TodoList.js.map +0 -1
  165. package/dist/gui/components/TodoListItem.d.ts.map +0 -1
  166. package/dist/gui/components/TodoListItem.js.map +0 -1
  167. package/dist/gui/components/index.d.ts.map +0 -1
  168. package/dist/gui/components/index.js.map +0 -1
  169. package/dist/gui/index.d.ts.map +0 -1
  170. package/dist/gui/index.js.map +0 -1
  171. package/dist/gui/lib/utils.d.ts.map +0 -1
  172. package/dist/gui/lib/utils.js.map +0 -1
  173. package/dist/index.d.ts.map +0 -1
  174. package/dist/index.js.map +0 -1
  175. package/dist/sdk/client/acp-client.d.ts.map +0 -1
  176. package/dist/sdk/client/acp-client.js.map +0 -1
  177. package/dist/sdk/client/index.d.ts.map +0 -1
  178. package/dist/sdk/client/index.js.map +0 -1
  179. package/dist/sdk/index.d.ts.map +0 -1
  180. package/dist/sdk/index.js.map +0 -1
  181. package/dist/sdk/schemas/agent.d.ts.map +0 -1
  182. package/dist/sdk/schemas/agent.js.map +0 -1
  183. package/dist/sdk/schemas/index.d.ts.map +0 -1
  184. package/dist/sdk/schemas/index.js.map +0 -1
  185. package/dist/sdk/schemas/message.d.ts.map +0 -1
  186. package/dist/sdk/schemas/message.js.map +0 -1
  187. package/dist/sdk/schemas/session.d.ts.map +0 -1
  188. package/dist/sdk/schemas/session.js.map +0 -1
  189. package/dist/sdk/transports/http.d.ts.map +0 -1
  190. package/dist/sdk/transports/http.js.map +0 -1
  191. package/dist/sdk/transports/index.d.ts.map +0 -1
  192. package/dist/sdk/transports/index.js.map +0 -1
  193. package/dist/sdk/transports/stdio.d.ts.map +0 -1
  194. package/dist/sdk/transports/stdio.js.map +0 -1
  195. package/dist/sdk/transports/types.d.ts.map +0 -1
  196. package/dist/sdk/transports/types.js.map +0 -1
  197. package/dist/sdk/transports/websocket.d.ts.map +0 -1
  198. package/dist/sdk/transports/websocket.js.map +0 -1
  199. package/dist/tui/components/ChatView.d.ts.map +0 -1
  200. package/dist/tui/components/ChatView.js.map +0 -1
  201. package/dist/tui/components/GameOfLife.d.ts.map +0 -1
  202. package/dist/tui/components/GameOfLife.js.map +0 -1
  203. package/dist/tui/components/InputBox.d.ts.map +0 -1
  204. package/dist/tui/components/InputBox.js.map +0 -1
  205. package/dist/tui/components/MessageList.d.ts.map +0 -1
  206. package/dist/tui/components/MessageList.js.map +0 -1
  207. package/dist/tui/components/ReadlineInput.d.ts.map +0 -1
  208. package/dist/tui/components/ReadlineInput.js.map +0 -1
  209. package/dist/tui/components/StatusBar.d.ts.map +0 -1
  210. package/dist/tui/components/StatusBar.js.map +0 -1
  211. package/dist/tui/components/index.d.ts.map +0 -1
  212. package/dist/tui/components/index.js.map +0 -1
  213. package/dist/tui/index.d.ts.map +0 -1
  214. package/dist/tui/index.js.map +0 -1
@@ -1,197 +1,70 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
2
  import { cva } from "class-variance-authority";
2
3
  import { ChevronDown } from "lucide-react";
3
4
  import * as React from "react";
4
5
  import { useEffect, useState } from "react";
5
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  import { cn } from "../lib/utils.js";
7
-
8
7
  /**
9
8
  * Reasoning component inspired by shadcn.io/ai
10
9
  * Displays AI thinking/reasoning process with auto-collapse support
11
10
  */
12
- const reasoningContainerVariants = cva(
13
- "mb-3 rounded-lg bg-card border border-border transition-all",
14
- {
15
- variants: {
16
- variant: {
17
- default: "opacity-70",
18
- subtle: "opacity-50",
19
- prominent: "opacity-90 shadow-sm",
20
- },
21
- },
22
- defaultVariants: {
23
- variant: "default",
24
- },
25
- },
26
- );
27
- const reasoningIconVariants = cva(
28
- "w-4 h-4 text-foreground opacity-60 transition-transform duration-200",
29
- {
30
- variants: {
31
- expanded: {
32
- true: "rotate-180",
33
- false: "",
34
- },
35
- },
36
- defaultVariants: {
37
- expanded: false,
38
- },
39
- },
40
- );
41
- export const Reasoning = React.forwardRef(
42
- (
43
- {
44
- content,
45
- isStreaming = false,
46
- mode = "collapsible",
47
- defaultExpanded = false,
48
- autoExpand = false,
49
- autoCollapse = true,
50
- autoCollapseDelay = 2000,
51
- label = "Thinking",
52
- variant,
53
- className,
54
- },
55
- ref,
56
- ) => {
57
- const [isExpanded, setIsExpanded] = useState(
58
- mode === "inline" ? true : defaultExpanded,
59
- );
60
- const [shouldAutoCollapse, setShouldAutoCollapse] = useState(false);
61
- // Handle auto-collapse after streaming completes
62
- useEffect(() => {
63
- if (autoCollapse && !isStreaming && content && mode === "collapsible") {
64
- const timer = setTimeout(() => {
65
- setShouldAutoCollapse(true);
66
- setIsExpanded(false);
67
- }, autoCollapseDelay);
68
- return () => clearTimeout(timer);
69
- }
70
- return undefined;
71
- }, [isStreaming, content, autoCollapse, autoCollapseDelay, mode]);
72
- // Auto-expand when streaming starts (only if autoExpand is enabled)
73
- useEffect(() => {
74
- if (
75
- autoExpand &&
76
- isStreaming &&
77
- mode === "collapsible" &&
78
- !shouldAutoCollapse
79
- ) {
80
- setIsExpanded(true);
81
- }
82
- }, [autoExpand, isStreaming, mode, shouldAutoCollapse]);
83
- if (!content && !isStreaming) {
84
- return null;
85
- }
86
- // Inline mode - always visible
87
- if (mode === "inline") {
88
- return _jsxs("div", {
89
- ref: ref,
90
- className: cn(
91
- reasoningContainerVariants({ variant }),
92
- "p-3",
93
- className,
94
- ),
95
- children: [
96
- _jsxs("div", {
97
- className: "flex items-start gap-2 mb-2",
98
- children: [
99
- _jsx("span", {
100
- className:
101
- "text-xs font-medium text-foreground opacity-60 uppercase tracking-wide",
102
- children: label,
103
- }),
104
- isStreaming &&
105
- _jsx("span", {
106
- className:
107
- "inline-block w-2 h-2 bg-primary rounded-full animate-pulse",
108
- }),
109
- ],
110
- }),
111
- _jsxs("div", {
112
- className:
113
- "text-sm italic text-foreground opacity-80 leading-relaxed whitespace-pre-wrap",
114
- children: [
115
- content,
116
- isStreaming &&
117
- content &&
118
- _jsx("span", {
119
- className: "inline-block animate-typing text-primary",
120
- children: "...",
121
- }),
122
- ],
123
- }),
124
- ],
125
- });
126
- }
127
- // Collapsible mode
128
- return _jsxs("div", {
129
- ref: ref,
130
- className: cn("mb-3", className),
131
- children: [
132
- _jsxs("button", {
133
- type: "button",
134
- onClick: () => {
135
- setIsExpanded(!isExpanded);
136
- setShouldAutoCollapse(false); // Disable auto-collapse on manual interaction
137
- },
138
- className:
139
- "w-full flex items-center justify-between p-2.5 rounded-lg bg-card border border-border hover:bg-card/80 hover:shadow-sm transition-all text-left",
140
- "aria-expanded": isExpanded,
141
- "aria-label": `${isExpanded ? "Collapse" : "Expand"} reasoning`,
142
- children: [
143
- _jsxs("div", {
144
- className: "flex items-center gap-2 flex-1 min-w-0",
145
- children: [
146
- _jsx("span", {
147
- className:
148
- "text-xs font-medium text-foreground opacity-60 uppercase tracking-wide shrink-0",
149
- children: label,
150
- }),
151
- isStreaming &&
152
- _jsx("span", {
153
- className:
154
- "inline-block w-2 h-2 bg-primary rounded-full animate-pulse shrink-0",
155
- }),
156
- !isExpanded &&
157
- content &&
158
- _jsxs("span", {
159
- className: "text-xs text-foreground opacity-50 truncate",
160
- children: [
161
- content.substring(0, 60),
162
- content.length > 60 && "...",
163
- ],
164
- }),
165
- ],
166
- }),
167
- _jsx(ChevronDown, {
168
- className: reasoningIconVariants({ expanded: isExpanded }),
169
- "aria-hidden": "true",
170
- }),
171
- ],
172
- }),
173
- isExpanded &&
174
- _jsx("div", {
175
- className: cn(
176
- reasoningContainerVariants({ variant }),
177
- "mt-2 p-3 animate-fadeIn",
178
- ),
179
- children: _jsxs("div", {
180
- className:
181
- "text-sm italic text-foreground opacity-80 leading-relaxed whitespace-pre-wrap",
182
- children: [
183
- content,
184
- isStreaming &&
185
- content &&
186
- _jsx("span", {
187
- className: "inline-block animate-typing text-primary",
188
- children: "...",
189
- }),
190
- ],
191
- }),
192
- }),
193
- ],
194
- });
195
- },
196
- );
11
+ const reasoningContainerVariants = cva("mb-3 rounded-lg bg-card border border-border transition-all", {
12
+ variants: {
13
+ variant: {
14
+ default: "opacity-70",
15
+ subtle: "opacity-50",
16
+ prominent: "opacity-90 shadow-sm",
17
+ },
18
+ },
19
+ defaultVariants: {
20
+ variant: "default",
21
+ },
22
+ });
23
+ const reasoningIconVariants = cva("w-4 h-4 text-foreground opacity-60 transition-transform duration-200", {
24
+ variants: {
25
+ expanded: {
26
+ true: "rotate-180",
27
+ false: "",
28
+ },
29
+ },
30
+ defaultVariants: {
31
+ expanded: false,
32
+ },
33
+ });
34
+ export const Reasoning = React.forwardRef(({ content, isStreaming = false, mode = "collapsible", defaultExpanded = false, autoExpand = false, autoCollapse = true, autoCollapseDelay = 2000, label = "Thinking", variant, className, }, ref) => {
35
+ const [isExpanded, setIsExpanded] = useState(mode === "inline" ? true : defaultExpanded);
36
+ const [shouldAutoCollapse, setShouldAutoCollapse] = useState(false);
37
+ // Handle auto-collapse after streaming completes
38
+ useEffect(() => {
39
+ if (autoCollapse && !isStreaming && content && mode === "collapsible") {
40
+ const timer = setTimeout(() => {
41
+ setShouldAutoCollapse(true);
42
+ setIsExpanded(false);
43
+ }, autoCollapseDelay);
44
+ return () => clearTimeout(timer);
45
+ }
46
+ return undefined;
47
+ }, [isStreaming, content, autoCollapse, autoCollapseDelay, mode]);
48
+ // Auto-expand when streaming starts (only if autoExpand is enabled)
49
+ useEffect(() => {
50
+ if (autoExpand &&
51
+ isStreaming &&
52
+ mode === "collapsible" &&
53
+ !shouldAutoCollapse) {
54
+ setIsExpanded(true);
55
+ }
56
+ }, [autoExpand, isStreaming, mode, shouldAutoCollapse]);
57
+ if (!content && !isStreaming) {
58
+ return null;
59
+ }
60
+ // Inline mode - always visible
61
+ if (mode === "inline") {
62
+ return (_jsxs("div", { ref: ref, className: cn(reasoningContainerVariants({ variant }), "p-3", className), children: [_jsxs("div", { className: "flex items-start gap-2 mb-2", children: [_jsx("span", { className: "text-xs font-medium text-foreground opacity-60 uppercase tracking-wide", children: label }), isStreaming && (_jsx("span", { className: "inline-block w-2 h-2 bg-primary rounded-full animate-pulse" }))] }), _jsxs("div", { className: "text-sm italic text-foreground opacity-80 leading-relaxed whitespace-pre-wrap", children: [content, isStreaming && content && (_jsx("span", { className: "inline-block animate-typing text-primary", children: "..." }))] })] }));
63
+ }
64
+ // Collapsible mode
65
+ return (_jsxs("div", { ref: ref, className: cn("mb-3", className), children: [_jsxs("button", { type: "button", onClick: () => {
66
+ setIsExpanded(!isExpanded);
67
+ setShouldAutoCollapse(false); // Disable auto-collapse on manual interaction
68
+ }, className: "w-full flex items-center justify-between p-2.5 rounded-lg bg-card border border-border hover:bg-card/80 hover:shadow-sm transition-all text-left", "aria-expanded": isExpanded, "aria-label": `${isExpanded ? "Collapse" : "Expand"} reasoning`, children: [_jsxs("div", { className: "flex items-center gap-2 flex-1 min-w-0", children: [_jsx("span", { className: "text-xs font-medium text-foreground opacity-60 uppercase tracking-wide shrink-0", children: label }), isStreaming && (_jsx("span", { className: "inline-block w-2 h-2 bg-primary rounded-full animate-pulse shrink-0" })), !isExpanded && content && (_jsxs("span", { className: "text-xs text-foreground opacity-50 truncate", children: [content.substring(0, 60), content.length > 60 && "..."] }))] }), _jsx(ChevronDown, { className: reasoningIconVariants({ expanded: isExpanded }), "aria-hidden": "true" })] }), isExpanded && (_jsx("div", { className: cn(reasoningContainerVariants({ variant }), "mt-2 p-3 animate-fadeIn"), children: _jsxs("div", { className: "text-sm italic text-foreground opacity-80 leading-relaxed whitespace-pre-wrap", children: [content, isStreaming && content && (_jsx("span", { className: "inline-block animate-typing text-primary", children: "..." }))] }) }))] }));
69
+ });
197
70
  Reasoning.displayName = "Reasoning";
@@ -4,15 +4,13 @@ import * as React from "react";
4
4
  * Streaming-optimized markdown renderer for AI-generated content
5
5
  */
6
6
  export interface ResponseProps extends React.HTMLAttributes<HTMLDivElement> {
7
- /** The markdown content to render */
8
- content: string;
9
- /** Whether the content is currently streaming */
10
- isStreaming?: boolean;
11
- /** Show empty state when no content */
12
- showEmpty?: boolean;
13
- /** Custom empty state message */
14
- emptyMessage?: string;
7
+ /** The markdown content to render */
8
+ content: string;
9
+ /** Whether the content is currently streaming */
10
+ isStreaming?: boolean;
11
+ /** Show empty state when no content */
12
+ showEmpty?: boolean;
13
+ /** Custom empty state message */
14
+ emptyMessage?: string;
15
15
  }
16
- export declare const Response: React.ForwardRefExoticComponent<
17
- ResponseProps & React.RefAttributes<HTMLDivElement>
18
- >;
16
+ export declare const Response: React.ForwardRefExoticComponent<ResponseProps & React.RefAttributes<HTMLDivElement>>;
@@ -1,234 +1,95 @@
1
- import * as React from "react";
2
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
3
  import ReactMarkdown from "react-markdown";
4
4
  import remarkGfm from "remark-gfm";
5
5
  import { cn } from "../lib/utils.js";
6
- export const Response = React.forwardRef(
7
- (
8
- {
9
- content,
10
- isStreaming = false,
11
- showEmpty = true,
12
- emptyMessage = "",
13
- className,
14
- ...props
15
- },
16
- ref,
17
- ) => {
18
- // Show empty state during streaming if no content yet
19
- if (!content && isStreaming && showEmpty) {
20
- return _jsx("div", {
21
- ref: ref,
22
- className: cn("opacity-70 italic text-sm", className),
23
- ...props,
24
- children: emptyMessage,
25
- });
26
- }
27
- if (!content) {
28
- return null;
29
- }
30
- const components = {
31
- // Table styling
32
- table: ({ node, ...props }) =>
33
- _jsx("div", {
34
- className: "overflow-x-auto my-4",
35
- children: _jsx("table", {
36
- className:
37
- "min-w-full border-collapse border border-border rounded-md",
38
- ...props,
39
- }),
40
- }),
41
- thead: ({ node, ...props }) =>
42
- _jsx("thead", {
43
- className: "bg-card border-b border-border",
44
- ...props,
45
- }),
46
- tbody: ({ node, ...props }) => _jsx("tbody", { ...props }),
47
- tr: ({ node, ...props }) =>
48
- _jsx("tr", {
49
- className: "border-b border-border hover:bg-card transition-colors",
50
- ...props,
51
- }),
52
- th: ({ node, ...props }) =>
53
- _jsx("th", {
54
- className:
55
- "px-4 py-2 text-left font-semibold text-foreground border-r border-border last:border-r-0",
56
- ...props,
57
- }),
58
- td: ({ node, ...props }) =>
59
- _jsx("td", {
60
- className:
61
- "px-4 py-2 text-foreground border-r border-border last:border-r-0",
62
- ...props,
63
- }),
64
- // Task list styling
65
- input: ({ node, checked, ...props }) => {
66
- if (props.type === "checkbox") {
67
- return _jsx("input", {
68
- type: "checkbox",
69
- checked: checked || false,
70
- disabled: true,
71
- readOnly: true,
72
- className: "mr-2 w-4 h-4 accent-[primary] cursor-not-allowed",
73
- ...props,
74
- });
75
- }
76
- return _jsx("input", { ...props });
77
- },
78
- // Code block styling with enhanced shadows
79
- code: ({ node, ...props }) => {
80
- const inline = !props.className?.includes("language-");
81
- if (inline) {
82
- return _jsx("code", {
83
- className:
84
- "px-1.5 py-0.5 bg-card border border-border rounded text-sm font-mono text-foreground",
85
- ...props,
86
- });
87
- }
88
- return _jsx("code", {
89
- className:
90
- "block p-4 bg-card border border-border rounded-md overflow-x-auto text-sm font-mono text-foreground shadow-sm",
91
- ...props,
92
- });
93
- },
94
- pre: ({ node, ...props }) =>
95
- _jsx("pre", { className: "my-4 rounded-lg", ...props }),
96
- // Heading styling with improved hierarchy
97
- h1: ({ node, ...props }) =>
98
- _jsx("h1", {
99
- className:
100
- "text-2xl font-bold mt-6 mb-4 text-foreground border-b border-border pb-2",
101
- ...props,
102
- }),
103
- h2: ({ node, ...props }) =>
104
- _jsx("h2", {
105
- className:
106
- "text-xl font-semibold mt-5 mb-3 text-foreground border-b border-border/50 pb-1.5",
107
- ...props,
108
- }),
109
- h3: ({ node, ...props }) =>
110
- _jsx("h3", {
111
- className: "text-lg font-semibold mt-4 mb-2 text-foreground",
112
- ...props,
113
- }),
114
- h4: ({ node, ...props }) =>
115
- _jsx("h4", {
116
- className: "text-base font-semibold mt-3 mb-2 text-foreground",
117
- ...props,
118
- }),
119
- // List styling
120
- ul: ({ node, ...props }) => {
121
- // Check if this is a task list by looking for checkbox inputs in children
122
- const isTaskList = node?.children?.some(
123
- (child) =>
124
- typeof child === "object" &&
125
- child !== null &&
126
- "type" in child &&
127
- child.type === "element" &&
128
- "tagName" in child &&
129
- child.tagName === "li" &&
130
- "children" in child &&
131
- Array.isArray(child.children) &&
132
- child.children.some(
133
- (grandChild) =>
134
- typeof grandChild === "object" &&
135
- grandChild !== null &&
136
- "type" in grandChild &&
137
- grandChild.type === "element" &&
138
- "tagName" in grandChild &&
139
- grandChild.tagName === "input" &&
140
- "properties" in grandChild &&
141
- typeof grandChild.properties === "object" &&
142
- grandChild.properties !== null &&
143
- "type" in grandChild.properties &&
144
- grandChild.properties.type === "checkbox",
145
- ),
146
- );
147
- return _jsx("ul", {
148
- className: cn(
149
- "my-2 space-y-1 text-foreground",
150
- isTaskList ? "list-none space-y-2" : "list-disc list-inside",
151
- ),
152
- ...props,
153
- });
154
- },
155
- ol: ({ node, ...props }) =>
156
- _jsx("ol", {
157
- className: "list-decimal list-inside my-2 space-y-1 text-foreground",
158
- ...props,
159
- }),
160
- // List item styling
161
- li: ({ node, ...props }) => {
162
- // Check if this li contains a checkbox (task list item)
163
- const isTaskListItem = node?.children?.some(
164
- (child) =>
165
- typeof child === "object" &&
166
- child !== null &&
167
- "type" in child &&
168
- child.type === "element" &&
169
- "tagName" in child &&
170
- child.tagName === "input" &&
171
- "properties" in child &&
172
- typeof child.properties === "object" &&
173
- child.properties !== null &&
174
- "type" in child.properties &&
175
- child.properties.type === "checkbox",
176
- );
177
- return _jsx("li", {
178
- className: cn("flex items-start", isTaskListItem ? "gap-2" : "ml-2"),
179
- ...props,
180
- });
181
- },
182
- // Link styling with hover effect
183
- a: ({ node, ...props }) =>
184
- _jsx("a", {
185
- className:
186
- "text-primary hover:underline decoration-2 underline-offset-2 transition-all",
187
- target: "_blank",
188
- rel: "noopener noreferrer",
189
- ...props,
190
- }),
191
- // Paragraph styling
192
- p: ({ node, ...props }) =>
193
- _jsx("p", {
194
- className: "my-2 text-foreground leading-relaxed",
195
- ...props,
196
- }),
197
- // Blockquote styling with enhanced visual
198
- blockquote: ({ node, ...props }) =>
199
- _jsx("blockquote", {
200
- className:
201
- "border-l-4 border-[primary] pl-4 italic my-4 text-foreground bg-card py-2 rounded-r-md shadow-sm",
202
- ...props,
203
- }),
204
- // Horizontal rule
205
- hr: ({ node, ...props }) =>
206
- _jsx("hr", {
207
- className: "my-6 border-t border-border opacity-50",
208
- ...props,
209
- }),
210
- };
211
- return _jsxs("div", {
212
- ref: ref,
213
- className: cn(
214
- "markdown-content prose prose-sm max-w-none dark:prose-invert",
215
- className,
216
- ),
217
- ...props,
218
- children: [
219
- _jsx(ReactMarkdown, {
220
- remarkPlugins: [remarkGfm],
221
- components: components,
222
- children: content,
223
- }),
224
- isStreaming &&
225
- content &&
226
- _jsx("span", {
227
- className: "inline-block ml-1 animate-typing text-primary",
228
- children: "...",
229
- }),
230
- ],
231
- });
232
- },
233
- );
6
+ export const Response = React.forwardRef(({ content, isStreaming = false, showEmpty = true, emptyMessage = "", className, ...props }, ref) => {
7
+ // Show empty state during streaming if no content yet
8
+ if (!content && isStreaming && showEmpty) {
9
+ return (_jsx("div", { ref: ref, className: cn("opacity-70 italic text-sm", className), ...props, children: emptyMessage }));
10
+ }
11
+ if (!content) {
12
+ return null;
13
+ }
14
+ const components = {
15
+ // Table styling
16
+ table: ({ node, ...props }) => (_jsx("div", { className: "overflow-x-auto my-4", children: _jsx("table", { className: "min-w-full border-collapse border border-border rounded-md", ...props }) })),
17
+ thead: ({ node, ...props }) => (_jsx("thead", { className: "bg-card border-b border-border", ...props })),
18
+ tbody: ({ node, ...props }) => _jsx("tbody", { ...props }),
19
+ tr: ({ node, ...props }) => (_jsx("tr", { className: "border-b border-border hover:bg-card transition-colors", ...props })),
20
+ th: ({ node, ...props }) => (_jsx("th", { className: "px-4 py-2 text-left font-semibold text-foreground border-r border-border last:border-r-0", ...props })),
21
+ td: ({ node, ...props }) => (_jsx("td", { className: "px-4 py-2 text-foreground border-r border-border last:border-r-0", ...props })),
22
+ // Task list styling
23
+ input: ({ node, checked, ...props }) => {
24
+ if (props.type === "checkbox") {
25
+ return (_jsx("input", { type: "checkbox", checked: checked || false, disabled: true, readOnly: true, className: "mr-2 w-4 h-4 accent-[primary] cursor-not-allowed", ...props }));
26
+ }
27
+ return _jsx("input", { ...props });
28
+ },
29
+ // Code block styling with enhanced shadows
30
+ code: ({ node, ...props }) => {
31
+ const inline = !props.className?.includes("language-");
32
+ if (inline) {
33
+ return (_jsx("code", { className: "px-1.5 py-0.5 bg-card border border-border rounded text-sm font-mono text-foreground", ...props }));
34
+ }
35
+ return (_jsx("code", { className: "block p-4 bg-card border border-border rounded-md overflow-x-auto text-sm font-mono text-foreground shadow-sm", ...props }));
36
+ },
37
+ pre: ({ node, ...props }) => (_jsx("pre", { className: "my-4 rounded-lg", ...props })),
38
+ // Heading styling with improved hierarchy
39
+ h1: ({ node, ...props }) => (_jsx("h1", { className: "text-2xl font-bold mt-6 mb-4 text-foreground border-b border-border pb-2", ...props })),
40
+ h2: ({ node, ...props }) => (_jsx("h2", { className: "text-xl font-semibold mt-5 mb-3 text-foreground border-b border-border/50 pb-1.5", ...props })),
41
+ h3: ({ node, ...props }) => (_jsx("h3", { className: "text-lg font-semibold mt-4 mb-2 text-foreground", ...props })),
42
+ h4: ({ node, ...props }) => (_jsx("h4", { className: "text-base font-semibold mt-3 mb-2 text-foreground", ...props })),
43
+ // List styling
44
+ ul: ({ node, ...props }) => {
45
+ // Check if this is a task list by looking for checkbox inputs in children
46
+ const isTaskList = node?.children?.some((child) => typeof child === "object" &&
47
+ child !== null &&
48
+ "type" in child &&
49
+ child.type === "element" &&
50
+ "tagName" in child &&
51
+ child.tagName === "li" &&
52
+ "children" in child &&
53
+ Array.isArray(child.children) &&
54
+ child.children.some((grandChild) => typeof grandChild === "object" &&
55
+ grandChild !== null &&
56
+ "type" in grandChild &&
57
+ grandChild.type === "element" &&
58
+ "tagName" in grandChild &&
59
+ grandChild.tagName === "input" &&
60
+ "properties" in grandChild &&
61
+ typeof grandChild.properties === "object" &&
62
+ grandChild.properties !== null &&
63
+ "type" in grandChild.properties &&
64
+ grandChild.properties.type === "checkbox"));
65
+ return (_jsx("ul", { className: cn("my-2 space-y-1 text-foreground", isTaskList ? "list-none space-y-2" : "list-disc list-inside"), ...props }));
66
+ },
67
+ ol: ({ node, ...props }) => (_jsx("ol", { className: "list-decimal list-inside my-2 space-y-1 text-foreground", ...props })),
68
+ // List item styling
69
+ li: ({ node, ...props }) => {
70
+ // Check if this li contains a checkbox (task list item)
71
+ const isTaskListItem = node?.children?.some((child) => typeof child === "object" &&
72
+ child !== null &&
73
+ "type" in child &&
74
+ child.type === "element" &&
75
+ "tagName" in child &&
76
+ child.tagName === "input" &&
77
+ "properties" in child &&
78
+ typeof child.properties === "object" &&
79
+ child.properties !== null &&
80
+ "type" in child.properties &&
81
+ child.properties.type === "checkbox");
82
+ return (_jsx("li", { className: cn("flex items-start", isTaskListItem ? "gap-2" : "ml-2"), ...props }));
83
+ },
84
+ // Link styling with hover effect
85
+ a: ({ node, ...props }) => (_jsx("a", { className: "text-primary hover:underline decoration-2 underline-offset-2 transition-all", target: "_blank", rel: "noopener noreferrer", ...props })),
86
+ // Paragraph styling
87
+ p: ({ node, ...props }) => (_jsx("p", { className: "my-2 text-foreground leading-relaxed", ...props })),
88
+ // Blockquote styling with enhanced visual
89
+ blockquote: ({ node, ...props }) => (_jsx("blockquote", { className: "border-l-4 border-[primary] pl-4 italic my-4 text-foreground bg-card py-2 rounded-r-md shadow-sm", ...props })),
90
+ // Horizontal rule
91
+ hr: ({ node, ...props }) => (_jsx("hr", { className: "my-6 border-t border-border opacity-50", ...props })),
92
+ };
93
+ return (_jsxs("div", { ref: ref, className: cn("markdown-content prose prose-sm max-w-none dark:prose-invert", className), ...props, children: [_jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], components: components, children: content }), isStreaming && content && (_jsx("span", { className: "inline-block ml-1 animate-typing text-primary", children: "..." }))] }));
94
+ });
234
95
  Response.displayName = "Response";