@21st-sdk/react 0.1.3 → 0.1.4
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/LICENSE +1 -1
- package/README.md +20 -20
- package/dist/index.cjs +17 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -36
- package/dist/index.d.ts +48 -36
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/docs/02-getting-started.md +8 -8
- package/docs/04-react-ui.md +13 -13
- package/docs/05-nextjs.md +15 -15
- package/docs/06-node-sdk.md +8 -8
- package/docs/07-cli.md +1 -1
- package/docs/08-custom-tools.md +2 -2
- package/package.json +4 -4
- package/src/an-agent-chat.tsx +6 -3
- package/src/components/input/context-items.tsx +2 -2
- package/src/components/input/model-selector.tsx +3 -3
- package/src/components/input-bar.tsx +2 -2
- package/src/create-an-chat.ts +7 -4
- package/src/index.ts +11 -5
- package/src/models.ts +11 -6
- package/src/theme-config.ts +9 -6
- package/src/theme.ts +2 -2
- package/src/tools/tool-router.ts +3 -3
- package/src/types.ts +23 -15
package/src/types.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type React from "react"
|
|
2
2
|
import type { UIMessage, ChatStatus } from "ai"
|
|
3
3
|
|
|
4
|
-
/** Theme JSON generated by the
|
|
5
|
-
export interface
|
|
4
|
+
/** Theme JSON generated by the playground */
|
|
5
|
+
export interface ChatTheme {
|
|
6
6
|
theme: Record<string, string>
|
|
7
7
|
light: Record<string, string>
|
|
8
8
|
dark: Record<string, string>
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/** Per-element CSS class overrides */
|
|
12
|
-
export interface
|
|
12
|
+
export interface ChatClassNames {
|
|
13
13
|
root: string
|
|
14
14
|
messageList: string
|
|
15
15
|
userMessage: string
|
|
@@ -28,7 +28,7 @@ export interface AnClassNames {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/** Component slot overrides */
|
|
31
|
-
export interface
|
|
31
|
+
export interface ChatSlots {
|
|
32
32
|
InputBar: React.ComponentType<any>
|
|
33
33
|
UserMessage: React.ComponentType<any>
|
|
34
34
|
AssistantMessage: React.ComponentType<any>
|
|
@@ -36,8 +36,8 @@ export interface AnSlots {
|
|
|
36
36
|
MessageActions: React.ComponentType<any>
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
/** Props for
|
|
40
|
-
export interface
|
|
39
|
+
/** Props for createAgentChat() */
|
|
40
|
+
export interface CreateAgentChatOptions {
|
|
41
41
|
agent: string
|
|
42
42
|
/** Provide either tokenUrl (simple) or getToken (full control) */
|
|
43
43
|
tokenUrl?: string
|
|
@@ -54,10 +54,10 @@ export interface CreateAnChatOptions {
|
|
|
54
54
|
*
|
|
55
55
|
* @example
|
|
56
56
|
* // Per-user sandbox
|
|
57
|
-
*
|
|
57
|
+
* createAgentChat({ agent: "my-agent", tokenUrl: "/api/an/token", sandboxId: `user-${userId}` })
|
|
58
58
|
*
|
|
59
59
|
* // Continue existing sandbox
|
|
60
|
-
*
|
|
60
|
+
* createAgentChat({ agent: "my-agent", tokenUrl: "/api/an/token", sandboxId: sandbox.id })
|
|
61
61
|
*/
|
|
62
62
|
sandboxId?: string
|
|
63
63
|
/**
|
|
@@ -78,25 +78,25 @@ export interface CustomToolRendererProps {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/** A model option for the model selector */
|
|
81
|
-
export interface
|
|
81
|
+
export interface ModelOption {
|
|
82
82
|
id: string
|
|
83
83
|
name: string
|
|
84
84
|
version?: string
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
/** Props for the <
|
|
88
|
-
export interface
|
|
87
|
+
/** Props for the <AgentChat> drop-in component */
|
|
88
|
+
export interface AgentChatProps {
|
|
89
89
|
messages: UIMessage[]
|
|
90
90
|
onSend: (message: { role: "user"; content: string }) => void
|
|
91
91
|
status: ChatStatus
|
|
92
92
|
onStop: () => void
|
|
93
93
|
error?: Error
|
|
94
94
|
|
|
95
|
-
theme?:
|
|
95
|
+
theme?: ChatTheme
|
|
96
96
|
colorMode?: "light" | "dark" | "auto"
|
|
97
97
|
|
|
98
|
-
classNames?: Partial<
|
|
99
|
-
slots?: Partial<
|
|
98
|
+
classNames?: Partial<ChatClassNames>
|
|
99
|
+
slots?: Partial<ChatSlots>
|
|
100
100
|
toolRenderers?: Record<string, React.ComponentType<CustomToolRendererProps>>
|
|
101
101
|
|
|
102
102
|
/** Show window chrome header (traffic lights + agent indicator) */
|
|
@@ -104,7 +104,7 @@ export interface AnAgentChatProps {
|
|
|
104
104
|
|
|
105
105
|
/** Model selector configuration */
|
|
106
106
|
modelSelector?: {
|
|
107
|
-
models:
|
|
107
|
+
models: ModelOption[]
|
|
108
108
|
activeModelId?: string
|
|
109
109
|
onModelChange?: (id: string) => void
|
|
110
110
|
display?: "popover" | "badge"
|
|
@@ -133,3 +133,11 @@ export interface AnAgentChatProps {
|
|
|
133
133
|
className?: string
|
|
134
134
|
style?: React.CSSProperties
|
|
135
135
|
}
|
|
136
|
+
|
|
137
|
+
// Legacy type aliases kept for compatibility.
|
|
138
|
+
export type AnTheme = ChatTheme
|
|
139
|
+
export type AnClassNames = ChatClassNames
|
|
140
|
+
export type AnSlots = ChatSlots
|
|
141
|
+
export type CreateAnChatOptions = CreateAgentChatOptions
|
|
142
|
+
export type AnModelOption = ModelOption
|
|
143
|
+
export type AnAgentChatProps = AgentChatProps
|