@townco/ui 0.1.0 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/hooks/use-chat-input.d.ts +17 -17
- package/dist/core/hooks/use-chat-input.js +64 -55
- package/dist/core/hooks/use-chat-messages.d.ts +11 -11
- package/dist/core/hooks/use-chat-messages.js +121 -114
- package/dist/core/hooks/use-chat-session.d.ts +5 -5
- package/dist/core/hooks/use-chat-session.js +78 -80
- package/dist/core/hooks/use-media-query.d.ts +5 -5
- package/dist/core/hooks/use-media-query.js +38 -38
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/schemas/chat.d.ts +83 -56
- package/dist/core/schemas/chat.js +27 -25
- package/dist/core/store/chat-store.d.ts +28 -22
- package/dist/core/store/chat-store.js +59 -50
- package/dist/gui/components/Button.d.ts +23 -7
- package/dist/gui/components/Button.js +40 -27
- package/dist/gui/components/Card.d.ts +26 -7
- package/dist/gui/components/Card.js +54 -8
- package/dist/gui/components/ChatHeader.d.ts +58 -31
- package/dist/gui/components/ChatHeader.js +171 -66
- package/dist/gui/components/ChatInput.d.ts +58 -36
- package/dist/gui/components/ChatInput.js +191 -121
- package/dist/gui/components/ChatInterface.d.ts +9 -6
- package/dist/gui/components/ChatInterface.js +162 -90
- package/dist/gui/components/ChatLayout.d.ts +71 -41
- package/dist/gui/components/ChatLayout.js +214 -87
- package/dist/gui/components/ChatPanelTabContent.d.ts +18 -9
- package/dist/gui/components/ChatPanelTabContent.js +88 -10
- package/dist/gui/components/ChatPreview.d.ts +9 -6
- package/dist/gui/components/ChatPreview.js +212 -162
- package/dist/gui/components/ChatSecondaryPanel.d.ts +14 -11
- package/dist/gui/components/ChatSecondaryPanel.js +115 -38
- package/dist/gui/components/ChatSidebar.d.ts +26 -13
- package/dist/gui/components/ChatSidebar.js +48 -14
- package/dist/gui/components/ChatStatus.d.ts +4 -2
- package/dist/gui/components/ChatStatus.js +45 -34
- package/dist/gui/components/ChatView.d.ts +5 -3
- package/dist/gui/components/ChatView.js +38 -9
- package/dist/gui/components/ConfigPanel.d.ts +16 -12
- package/dist/gui/components/ConfigPanel.js +218 -41
- package/dist/gui/components/Conversation.d.ts +17 -14
- package/dist/gui/components/Conversation.js +143 -83
- package/dist/gui/components/Dialog.d.ts +57 -11
- package/dist/gui/components/Dialog.js +84 -8
- package/dist/gui/components/DropdownMenu.d.ts +101 -20
- package/dist/gui/components/DropdownMenu.js +161 -14
- package/dist/gui/components/HeightTransition.d.ts +12 -7
- package/dist/gui/components/HeightTransition.js +88 -77
- package/dist/gui/components/Input.d.ts +13 -6
- package/dist/gui/components/Input.js +27 -16
- package/dist/gui/components/InputBox.d.ts +19 -12
- package/dist/gui/components/InputBox.js +86 -14
- package/dist/gui/components/Label.d.ts +7 -1
- package/dist/gui/components/Label.js +12 -2
- package/dist/gui/components/MarkdownRenderer.d.ts +6 -4
- package/dist/gui/components/MarkdownRenderer.js +178 -81
- package/dist/gui/components/Message.d.ts +25 -18
- package/dist/gui/components/Message.js +44 -23
- package/dist/gui/components/MessageContent.d.ts +29 -22
- package/dist/gui/components/MessageContent.js +157 -85
- package/dist/gui/components/PlaygroundLayout.d.ts +9 -5
- package/dist/gui/components/PlaygroundLayout.js +43 -12
- package/dist/gui/components/Reasoning.d.ts +30 -24
- package/dist/gui/components/Reasoning.js +187 -60
- package/dist/gui/components/Response.d.ts +11 -9
- package/dist/gui/components/Response.js +229 -90
- package/dist/gui/components/Select.d.ts +69 -10
- package/dist/gui/components/Select.js +118 -12
- package/dist/gui/components/Sonner.d.ts +3 -1
- package/dist/gui/components/Sonner.js +29 -18
- package/dist/gui/components/StatusBar.d.ts +9 -5
- package/dist/gui/components/StatusBar.js +56 -9
- package/dist/gui/components/Tabs.d.ts +24 -4
- package/dist/gui/components/Tabs.js +32 -4
- package/dist/gui/components/Task.d.ts +28 -24
- package/dist/gui/components/Task.js +164 -31
- package/dist/gui/components/Textarea.d.ts +15 -7
- package/dist/gui/components/Textarea.js +63 -46
- package/dist/gui/components/ThinkingBlock.d.ts +20 -10
- package/dist/gui/components/ThinkingBlock.js +134 -35
- package/dist/gui/components/TodoList.d.ts +12 -10
- package/dist/gui/components/TodoList.js +22 -7
- package/dist/gui/components/TodoListItem.d.ts +9 -6
- package/dist/gui/components/TodoListItem.js +18 -4
- package/dist/gui/components/index.d.ts +59 -8
- package/dist/gui/components/index.js +42 -8
- package/dist/gui/lib/utils.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.test.js +0 -1
- package/dist/sdk/client/acp-client.d.ts +88 -76
- package/dist/sdk/client/acp-client.js +215 -217
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/schemas/agent.d.ts +111 -64
- package/dist/sdk/schemas/agent.js +24 -24
- package/dist/sdk/schemas/message.d.ts +245 -147
- package/dist/sdk/schemas/message.js +40 -40
- package/dist/sdk/schemas/session.d.ts +219 -135
- package/dist/sdk/schemas/session.js +27 -27
- package/dist/sdk/transports/http.d.ts +55 -55
- package/dist/sdk/transports/http.js +472 -469
- package/dist/sdk/transports/stdio.d.ts +20 -20
- package/dist/sdk/transports/stdio.js +289 -286
- package/dist/sdk/transports/types.d.ts +42 -42
- package/dist/sdk/transports/websocket.d.ts +12 -12
- package/dist/sdk/transports/websocket.js +52 -46
- package/dist/tui/components/ChatView.d.ts +4 -2
- package/dist/tui/components/ChatView.js +51 -18
- package/dist/tui/components/GameOfLife.js +64 -35
- package/dist/tui/components/InputBox.d.ts +18 -11
- package/dist/tui/components/InputBox.js +70 -10
- package/dist/tui/components/MessageList.d.ts +4 -2
- package/dist/tui/components/MessageList.js +37 -10
- package/dist/tui/components/MultiSelect.d.ts +15 -9
- package/dist/tui/components/MultiSelect.js +116 -69
- package/dist/tui/components/ReadlineInput.d.ts +12 -6
- package/dist/tui/components/ReadlineInput.js +252 -237
- package/dist/tui/components/SingleSelect.d.ts +15 -9
- package/dist/tui/components/SingleSelect.js +84 -43
- package/dist/tui/components/StatusBar.d.ts +11 -6
- package/dist/tui/components/StatusBar.js +102 -67
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/package.json +2 -3
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
3
2
|
import * as React from "react";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
import { cn } from "../lib/utils.js";
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
const Label = React.forwardRef(({ className, ...props }, ref) =>
|
|
7
|
+
_jsx(LabelPrimitive.Root, {
|
|
8
|
+
ref: ref,
|
|
9
|
+
className: cn(
|
|
10
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
11
|
+
className,
|
|
12
|
+
),
|
|
13
|
+
...props,
|
|
14
|
+
}),
|
|
15
|
+
);
|
|
6
16
|
Label.displayName = LabelPrimitive.Root.displayName;
|
|
7
17
|
export { Label };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
interface MarkdownRendererProps {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
content: string;
|
|
3
|
+
className?: string;
|
|
4
4
|
}
|
|
5
|
-
export declare function MarkdownRenderer({
|
|
6
|
-
|
|
5
|
+
export declare function MarkdownRenderer({
|
|
6
|
+
content,
|
|
7
|
+
className,
|
|
8
|
+
}: MarkdownRendererProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -2,85 +2,182 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import ReactMarkdown from "react-markdown";
|
|
3
3
|
import remarkGfm from "remark-gfm";
|
|
4
4
|
import { cn } from "../lib/utils.js";
|
|
5
|
-
export function MarkdownRenderer({ content, className
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
5
|
+
export function MarkdownRenderer({ content, className }) {
|
|
6
|
+
if (!content) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const components = {
|
|
10
|
+
// Table styling
|
|
11
|
+
table: ({ node, ...props }) =>
|
|
12
|
+
_jsx("div", {
|
|
13
|
+
className: "overflow-x-auto my-4",
|
|
14
|
+
children: _jsx("table", {
|
|
15
|
+
className:
|
|
16
|
+
"min-w-full border-collapse border border-border rounded-md",
|
|
17
|
+
...props,
|
|
18
|
+
}),
|
|
19
|
+
}),
|
|
20
|
+
thead: ({ node, ...props }) =>
|
|
21
|
+
_jsx("thead", { className: "bg-card border-b border-border", ...props }),
|
|
22
|
+
tbody: ({ node, ...props }) => _jsx("tbody", { ...props }),
|
|
23
|
+
tr: ({ node, ...props }) =>
|
|
24
|
+
_jsx("tr", {
|
|
25
|
+
className: "border-b border-border hover:bg-card transition-colors",
|
|
26
|
+
...props,
|
|
27
|
+
}),
|
|
28
|
+
th: ({ node, ...props }) =>
|
|
29
|
+
_jsx("th", {
|
|
30
|
+
className:
|
|
31
|
+
"px-4 py-2 text-left font-semibold text-foreground border-r border-border last:border-r-0",
|
|
32
|
+
...props,
|
|
33
|
+
}),
|
|
34
|
+
td: ({ node, ...props }) =>
|
|
35
|
+
_jsx("td", {
|
|
36
|
+
className:
|
|
37
|
+
"px-4 py-2 text-foreground border-r border-border last:border-r-0",
|
|
38
|
+
...props,
|
|
39
|
+
}),
|
|
40
|
+
// Task list styling
|
|
41
|
+
input: ({ node, checked, ...props }) => {
|
|
42
|
+
if (props.type === "checkbox") {
|
|
43
|
+
return _jsx("input", {
|
|
44
|
+
type: "checkbox",
|
|
45
|
+
checked: checked || false,
|
|
46
|
+
disabled: true,
|
|
47
|
+
readOnly: true,
|
|
48
|
+
className: "mr-2 w-4 h-4 accent-[primary] cursor-not-allowed",
|
|
49
|
+
...props,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return _jsx("input", { ...props });
|
|
53
|
+
},
|
|
54
|
+
// Code block styling
|
|
55
|
+
code: ({ node, ...props }) => {
|
|
56
|
+
const inline = !props.className?.includes("language-");
|
|
57
|
+
if (inline) {
|
|
58
|
+
return _jsx("code", {
|
|
59
|
+
className:
|
|
60
|
+
"px-1.5 py-0.5 bg-card border border-border rounded text-sm font-mono text-foreground",
|
|
61
|
+
...props,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return _jsx("code", {
|
|
65
|
+
className:
|
|
66
|
+
"block p-4 bg-card border border-border rounded-md overflow-x-auto text-sm font-mono text-foreground",
|
|
67
|
+
...props,
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
pre: ({ node, ...props }) => _jsx("pre", { className: "my-4", ...props }),
|
|
71
|
+
// Heading styling
|
|
72
|
+
h1: ({ node, ...props }) =>
|
|
73
|
+
_jsx("h1", {
|
|
74
|
+
className: "text-2xl font-bold mt-6 mb-4 text-foreground",
|
|
75
|
+
...props,
|
|
76
|
+
}),
|
|
77
|
+
h2: ({ node, ...props }) =>
|
|
78
|
+
_jsx("h2", {
|
|
79
|
+
className: "text-xl font-semibold mt-5 mb-3 text-foreground",
|
|
80
|
+
...props,
|
|
81
|
+
}),
|
|
82
|
+
h3: ({ node, ...props }) =>
|
|
83
|
+
_jsx("h3", {
|
|
84
|
+
className: "text-lg font-semibold mt-4 mb-2 text-foreground",
|
|
85
|
+
...props,
|
|
86
|
+
}),
|
|
87
|
+
// List styling
|
|
88
|
+
ul: ({ node, ...props }) => {
|
|
89
|
+
// Check if this is a task list by looking for checkbox inputs in children
|
|
90
|
+
const isTaskList = node?.children?.some(
|
|
91
|
+
(child) =>
|
|
92
|
+
typeof child === "object" &&
|
|
93
|
+
child !== null &&
|
|
94
|
+
"type" in child &&
|
|
95
|
+
child.type === "element" &&
|
|
96
|
+
"tagName" in child &&
|
|
97
|
+
child.tagName === "li" &&
|
|
98
|
+
"children" in child &&
|
|
99
|
+
Array.isArray(child.children) &&
|
|
100
|
+
child.children.some(
|
|
101
|
+
(grandChild) =>
|
|
102
|
+
typeof grandChild === "object" &&
|
|
103
|
+
grandChild !== null &&
|
|
104
|
+
"type" in grandChild &&
|
|
105
|
+
grandChild.type === "element" &&
|
|
106
|
+
"tagName" in grandChild &&
|
|
107
|
+
grandChild.tagName === "input" &&
|
|
108
|
+
"properties" in grandChild &&
|
|
109
|
+
typeof grandChild.properties === "object" &&
|
|
110
|
+
grandChild.properties !== null &&
|
|
111
|
+
"type" in grandChild.properties &&
|
|
112
|
+
grandChild.properties.type === "checkbox",
|
|
113
|
+
),
|
|
114
|
+
);
|
|
115
|
+
return _jsx("ul", {
|
|
116
|
+
className: cn(
|
|
117
|
+
"my-2 space-y-1 text-foreground",
|
|
118
|
+
isTaskList ? "list-none space-y-2" : "list-disc list-inside",
|
|
119
|
+
),
|
|
120
|
+
...props,
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
ol: ({ node, ...props }) =>
|
|
124
|
+
_jsx("ol", {
|
|
125
|
+
className: "list-decimal list-inside my-2 space-y-1 text-foreground",
|
|
126
|
+
...props,
|
|
127
|
+
}),
|
|
128
|
+
// List item styling
|
|
129
|
+
li: ({ node, ...props }) => {
|
|
130
|
+
// Check if this li contains a checkbox (task list item)
|
|
131
|
+
const isTaskListItem = node?.children?.some(
|
|
132
|
+
(child) =>
|
|
133
|
+
typeof child === "object" &&
|
|
134
|
+
child !== null &&
|
|
135
|
+
"type" in child &&
|
|
136
|
+
child.type === "element" &&
|
|
137
|
+
"tagName" in child &&
|
|
138
|
+
child.tagName === "input" &&
|
|
139
|
+
"properties" in child &&
|
|
140
|
+
typeof child.properties === "object" &&
|
|
141
|
+
child.properties !== null &&
|
|
142
|
+
"type" in child.properties &&
|
|
143
|
+
child.properties.type === "checkbox",
|
|
144
|
+
);
|
|
145
|
+
return _jsx("li", {
|
|
146
|
+
className: cn("flex items-start", isTaskListItem ? "gap-2" : "ml-2"),
|
|
147
|
+
...props,
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
// Link styling
|
|
151
|
+
a: ({ node, ...props }) =>
|
|
152
|
+
_jsx("a", {
|
|
153
|
+
className: "text-primary hover:underline",
|
|
154
|
+
target: "_blank",
|
|
155
|
+
rel: "noopener noreferrer",
|
|
156
|
+
...props,
|
|
157
|
+
}),
|
|
158
|
+
// Paragraph styling
|
|
159
|
+
p: ({ node, ...props }) =>
|
|
160
|
+
_jsx("p", {
|
|
161
|
+
className: "my-2 text-foreground leading-relaxed",
|
|
162
|
+
...props,
|
|
163
|
+
}),
|
|
164
|
+
// Blockquote styling
|
|
165
|
+
blockquote: ({ node, ...props }) =>
|
|
166
|
+
_jsx("blockquote", {
|
|
167
|
+
className:
|
|
168
|
+
"border-l-4 border-[primary] pl-4 italic my-4 text-foreground bg-card py-2",
|
|
169
|
+
...props,
|
|
170
|
+
}),
|
|
171
|
+
};
|
|
172
|
+
return _jsx("div", {
|
|
173
|
+
className: cn(
|
|
174
|
+
"markdown-content prose prose-sm max-w-none dark:prose-invert",
|
|
175
|
+
className,
|
|
176
|
+
),
|
|
177
|
+
children: _jsx(ReactMarkdown, {
|
|
178
|
+
remarkPlugins: [remarkGfm],
|
|
179
|
+
components: components,
|
|
180
|
+
children: content,
|
|
181
|
+
}),
|
|
182
|
+
});
|
|
86
183
|
}
|
|
@@ -5,22 +5,29 @@ import type { DisplayMessage } from "./MessageList.js";
|
|
|
5
5
|
* Message wrapper component inspired by shadcn.io/ai
|
|
6
6
|
* Provides role-based layout and styling for chat messages
|
|
7
7
|
*/
|
|
8
|
-
declare const messageVariants: (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
declare const messageVariants: (
|
|
9
|
+
props?:
|
|
10
|
+
| ({
|
|
11
|
+
role?: "user" | "assistant" | "system" | null | undefined;
|
|
12
|
+
layout?: "default" | "full" | "compact" | null | undefined;
|
|
13
|
+
} & import("class-variance-authority/types").ClassProp)
|
|
14
|
+
| undefined,
|
|
15
|
+
) => string;
|
|
16
|
+
export interface MessageProps
|
|
17
|
+
extends React.HTMLAttributes<HTMLDivElement>,
|
|
18
|
+
VariantProps<typeof messageVariants> {
|
|
19
|
+
/**
|
|
20
|
+
* Message object for smart rendering (optional)
|
|
21
|
+
* When provided, automatically extracts role and id
|
|
22
|
+
*/
|
|
23
|
+
message?: DisplayMessage;
|
|
24
|
+
/** Message role - determines alignment and styling (fallback if message not provided) */
|
|
25
|
+
role?: "user" | "assistant" | "system";
|
|
26
|
+
/** Optional layout override */
|
|
27
|
+
layout?: "default" | "full" | "compact";
|
|
28
|
+
/** Optional message ID for accessibility (fallback if message not provided) */
|
|
29
|
+
messageId?: string;
|
|
24
30
|
}
|
|
25
|
-
export declare const Message: React.ForwardRefExoticComponent<
|
|
26
|
-
|
|
31
|
+
export declare const Message: React.ForwardRefExoticComponent<
|
|
32
|
+
MessageProps & React.RefAttributes<HTMLDivElement>
|
|
33
|
+
>;
|
|
@@ -1,33 +1,54 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
1
|
import { cva } from "class-variance-authority";
|
|
3
2
|
import * as React from "react";
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
import { cn } from "../lib/utils.js";
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* Message wrapper component inspired by shadcn.io/ai
|
|
7
8
|
* Provides role-based layout and styling for chat messages
|
|
8
9
|
*/
|
|
9
10
|
const messageVariants = cva("flex animate-fadeIn", {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
27
|
-
export const Message = React.forwardRef(({ message, role: roleProp, layout, className, children, messageId: messageIdProp, ...props }, ref) => {
|
|
28
|
-
// Extract role and messageId from message if provided
|
|
29
|
-
const role = message ? message.role : roleProp || "assistant";
|
|
30
|
-
const messageId = message ? message.id : messageIdProp;
|
|
31
|
-
return (_jsx("article", { ref: ref, "aria-label": `${role} message`, "data-message-id": messageId, className: cn(messageVariants({ role, layout }), className), ...props, children: children }));
|
|
11
|
+
variants: {
|
|
12
|
+
role: {
|
|
13
|
+
user: "max-w-[80%] self-end ml-auto",
|
|
14
|
+
assistant: "self-start mr-auto",
|
|
15
|
+
system: "self-start mr-auto max-w-full",
|
|
16
|
+
},
|
|
17
|
+
layout: {
|
|
18
|
+
default: "",
|
|
19
|
+
full: "max-w-full",
|
|
20
|
+
compact: "max-w-[90%]",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
role: "assistant",
|
|
25
|
+
layout: "default",
|
|
26
|
+
},
|
|
32
27
|
});
|
|
28
|
+
export const Message = React.forwardRef(
|
|
29
|
+
(
|
|
30
|
+
{
|
|
31
|
+
message,
|
|
32
|
+
role: roleProp,
|
|
33
|
+
layout,
|
|
34
|
+
className,
|
|
35
|
+
children,
|
|
36
|
+
messageId: messageIdProp,
|
|
37
|
+
...props
|
|
38
|
+
},
|
|
39
|
+
ref,
|
|
40
|
+
) => {
|
|
41
|
+
// Extract role and messageId from message if provided
|
|
42
|
+
const role = message ? message.role : roleProp || "assistant";
|
|
43
|
+
const messageId = message ? message.id : messageIdProp;
|
|
44
|
+
return _jsx("article", {
|
|
45
|
+
ref: ref,
|
|
46
|
+
"aria-label": `${role} message`,
|
|
47
|
+
"data-message-id": messageId,
|
|
48
|
+
className: cn(messageVariants({ role, layout }), className),
|
|
49
|
+
...props,
|
|
50
|
+
children: children,
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
);
|
|
33
54
|
Message.displayName = "Message";
|
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
import { type VariantProps } from "class-variance-authority";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import type { DisplayMessage } from "./MessageList.js";
|
|
4
|
-
declare const messageContentVariants: (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
4
|
+
declare const messageContentVariants: (
|
|
5
|
+
props?:
|
|
6
|
+
| ({
|
|
7
|
+
role?: "user" | "assistant" | "system" | null | undefined;
|
|
8
|
+
variant?: "default" | "outline" | "ghost" | null | undefined;
|
|
9
|
+
} & import("class-variance-authority/types").ClassProp)
|
|
10
|
+
| undefined,
|
|
11
|
+
) => string;
|
|
12
|
+
export interface MessageContentProps
|
|
13
|
+
extends Omit<React.HTMLAttributes<HTMLDivElement>, "children">,
|
|
14
|
+
VariantProps<typeof messageContentVariants> {
|
|
15
|
+
/** Message role - determines styling */
|
|
16
|
+
role?: "user" | "assistant" | "system";
|
|
17
|
+
/** Visual variant */
|
|
18
|
+
variant?: "default" | "outline" | "ghost";
|
|
19
|
+
/** Whether the message is currently streaming */
|
|
20
|
+
isStreaming?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Message object for smart rendering (optional)
|
|
23
|
+
* When provided, automatically renders thinking, waiting, and content
|
|
24
|
+
*/
|
|
25
|
+
message?: DisplayMessage;
|
|
26
|
+
/** Display style for thinking/reasoning blocks (when using smart rendering) */
|
|
27
|
+
thinkingDisplayStyle?: "collapsible" | "inline";
|
|
28
|
+
/** Custom content (overrides smart rendering) */
|
|
29
|
+
children?: React.ReactNode;
|
|
24
30
|
}
|
|
25
|
-
export declare const MessageContent: React.ForwardRefExoticComponent<
|
|
26
|
-
|
|
31
|
+
export declare const MessageContent: React.ForwardRefExoticComponent<
|
|
32
|
+
MessageContentProps & React.RefAttributes<HTMLDivElement>
|
|
33
|
+
>;
|