@cloudbase/agent-react-ui 0.0.23

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 (109) hide show
  1. package/README.md +135 -0
  2. package/components.json +21 -0
  3. package/dist/index.css +4241 -0
  4. package/dist/index.css.map +1 -0
  5. package/dist/index.d.mts +59 -0
  6. package/dist/index.d.ts +59 -0
  7. package/dist/index.js +2169 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/index.mjs +2182 -0
  10. package/dist/index.mjs.map +1 -0
  11. package/example/.env.sample +2 -0
  12. package/example/App.tsx +368 -0
  13. package/example/app.css +1 -0
  14. package/example/index.html +12 -0
  15. package/example/main.tsx +9 -0
  16. package/example/vite.config.ts +34 -0
  17. package/package.json +75 -0
  18. package/postcss.config.cjs +3 -0
  19. package/src/components/ai-elements/agent.tsx +140 -0
  20. package/src/components/ai-elements/artifact.tsx +147 -0
  21. package/src/components/ai-elements/attachments.tsx +421 -0
  22. package/src/components/ai-elements/audio-player.tsx +228 -0
  23. package/src/components/ai-elements/canvas.tsx +22 -0
  24. package/src/components/ai-elements/chain-of-thought.tsx +228 -0
  25. package/src/components/ai-elements/checkpoint.tsx +71 -0
  26. package/src/components/ai-elements/code-block.tsx +532 -0
  27. package/src/components/ai-elements/commit.tsx +448 -0
  28. package/src/components/ai-elements/confirmation.tsx +176 -0
  29. package/src/components/ai-elements/connection.tsx +28 -0
  30. package/src/components/ai-elements/context.tsx +408 -0
  31. package/src/components/ai-elements/controls.tsx +18 -0
  32. package/src/components/ai-elements/conversation.tsx +100 -0
  33. package/src/components/ai-elements/edge.tsx +140 -0
  34. package/src/components/ai-elements/environment-variables.tsx +295 -0
  35. package/src/components/ai-elements/file-tree.tsx +258 -0
  36. package/src/components/ai-elements/image.tsx +24 -0
  37. package/src/components/ai-elements/inline-citation.tsx +287 -0
  38. package/src/components/ai-elements/message.tsx +336 -0
  39. package/src/components/ai-elements/mic-selector.tsx +370 -0
  40. package/src/components/ai-elements/model-selector.tsx +211 -0
  41. package/src/components/ai-elements/node.tsx +71 -0
  42. package/src/components/ai-elements/open-in-chat.tsx +365 -0
  43. package/src/components/ai-elements/package-info.tsx +233 -0
  44. package/src/components/ai-elements/panel.tsx +15 -0
  45. package/src/components/ai-elements/persona.tsx +270 -0
  46. package/src/components/ai-elements/plan.tsx +142 -0
  47. package/src/components/ai-elements/prompt-input.tsx +1263 -0
  48. package/src/components/ai-elements/queue.tsx +274 -0
  49. package/src/components/ai-elements/reasoning.tsx +193 -0
  50. package/src/components/ai-elements/sandbox.tsx +126 -0
  51. package/src/components/ai-elements/schema-display.tsx +458 -0
  52. package/src/components/ai-elements/shimmer.tsx +64 -0
  53. package/src/components/ai-elements/snippet.tsx +139 -0
  54. package/src/components/ai-elements/sources.tsx +77 -0
  55. package/src/components/ai-elements/speech-input.tsx +301 -0
  56. package/src/components/ai-elements/stack-trace.tsx +482 -0
  57. package/src/components/ai-elements/suggestion.tsx +53 -0
  58. package/src/components/ai-elements/task.tsx +87 -0
  59. package/src/components/ai-elements/terminal.tsx +261 -0
  60. package/src/components/ai-elements/test-results.tsx +485 -0
  61. package/src/components/ai-elements/tool.tsx +174 -0
  62. package/src/components/ai-elements/toolbar.tsx +16 -0
  63. package/src/components/ai-elements/transcription.tsx +124 -0
  64. package/src/components/ai-elements/voice-selector.tsx +479 -0
  65. package/src/components/ai-elements/web-preview.tsx +263 -0
  66. package/src/components/chat/Chat.tsx +178 -0
  67. package/src/components/chat/Input.tsx +98 -0
  68. package/src/components/chat/Message.tsx +276 -0
  69. package/src/components/chat/index.ts +2 -0
  70. package/src/components/index.ts +1 -0
  71. package/src/components/ui/accordion.tsx +64 -0
  72. package/src/components/ui/alert.tsx +66 -0
  73. package/src/components/ui/avatar.tsx +107 -0
  74. package/src/components/ui/badge.tsx +48 -0
  75. package/src/components/ui/button-group.tsx +83 -0
  76. package/src/components/ui/button.tsx +64 -0
  77. package/src/components/ui/card.tsx +92 -0
  78. package/src/components/ui/carousel.tsx +239 -0
  79. package/src/components/ui/collapsible.tsx +31 -0
  80. package/src/components/ui/command.tsx +184 -0
  81. package/src/components/ui/dialog.tsx +158 -0
  82. package/src/components/ui/dropdown-menu.tsx +257 -0
  83. package/src/components/ui/hover-card.tsx +42 -0
  84. package/src/components/ui/input-group.tsx +168 -0
  85. package/src/components/ui/input.tsx +21 -0
  86. package/src/components/ui/popover.tsx +87 -0
  87. package/src/components/ui/progress.tsx +31 -0
  88. package/src/components/ui/scroll-area.tsx +56 -0
  89. package/src/components/ui/select.tsx +190 -0
  90. package/src/components/ui/separator.tsx +28 -0
  91. package/src/components/ui/spinner.tsx +16 -0
  92. package/src/components/ui/switch.tsx +33 -0
  93. package/src/components/ui/tabs.tsx +91 -0
  94. package/src/components/ui/textarea.tsx +18 -0
  95. package/src/components/ui/tooltip.tsx +61 -0
  96. package/src/css/global.css +123 -0
  97. package/src/css/index.css +1 -0
  98. package/src/hooks/index.ts +1 -0
  99. package/src/hooks/use-copy-to-clipboard.ts +31 -0
  100. package/src/index.ts +4 -0
  101. package/src/lib/utils.ts +6 -0
  102. package/src/locales/context.ts +8 -0
  103. package/src/locales/hooks.ts +20 -0
  104. package/src/locales/index.ts +3 -0
  105. package/src/locales/langs/en.ts +17 -0
  106. package/src/locales/langs/index.ts +12 -0
  107. package/src/locales/langs/zh-cn.ts +18 -0
  108. package/tsconfig.json +21 -0
  109. package/tsup.config.ts +21 -0
package/README.md ADDED
@@ -0,0 +1,135 @@
1
+ # @cloudbase/agent-react-ui
2
+
3
+ `@cloudbase/agent-react-ui` 提供可直接接入项目的 React 聊天界面组件,适用于希望快速完成 AG-Kit 聊天窗口搭建的场景。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install @cloudbase/agent-react-core @cloudbase/agent-react-ui
9
+ ```
10
+
11
+ ## 样式引入
12
+
13
+ 包入口已经包含样式导入:
14
+
15
+ ```ts
16
+ import "./css/index.css";
17
+ ```
18
+
19
+ 在常规的 React 构建环境中,直接使用组件即可。如果需要手动引入构建后的样式文件,可以使用:
20
+
21
+ ```ts
22
+ import "@cloudbase/agent-react-ui/styles.css";
23
+ ```
24
+
25
+ ## 快速开始
26
+
27
+ `AgKitUI` 依赖 `@cloudbase/agent-react-core` 提供的运行时上下文,因此需要与 `AgKit` 一起使用。
28
+
29
+ ```tsx
30
+ import cloudbase from "@cloudbase/js-sdk";
31
+ import { AgKit, CloudBaseTransport } from "@cloudbase/agent-react-core";
32
+ import { AgKitUI } from "@cloudbase/agent-react-ui";
33
+
34
+ const app = cloudbase.init({ env: "your-env-id" });
35
+ const transport = new CloudBaseTransport({
36
+ app,
37
+ agentId: "your-agent-id",
38
+ });
39
+
40
+ export function App() {
41
+ return (
42
+ <AgKit transport={transport}>
43
+ <div style={{ height: "600px" }}>
44
+ <AgKitUI />
45
+ </div>
46
+ </AgKit>
47
+ );
48
+ }
49
+ ```
50
+
51
+ ---
52
+
53
+ ## API 参考
54
+
55
+ ### `AgKitUI`
56
+
57
+ 核心聊天界面组件,内置了完整的消息渲染、工具调用展示、输入框和国际化支持。
58
+
59
+ #### `AgKitUIProps`
60
+
61
+ | 选项 | 必填 | 类型 | 说明 |
62
+ | --- | --- | --- | --- |
63
+ | `className` | 否 | `string` | 聊天主体布局类名 |
64
+ | `containerClassName` | 否 | `string` | 最外层根容器类名 |
65
+ | `messagesClassName` | 否 | `string` | 消息列表区域类名 |
66
+ | `inputClassName` | 否 | `string` | 输入框包裹层类名 |
67
+ | `emptyTitleClassName` | 否 | `string` | 空状态标题类名 |
68
+ | `inputPlaceholder` | 否 | `string` | 输入框占位文本,未提供时使用 locale 默认值 |
69
+ | `suggestions` | 否 | `string[]` | 聊天为空时显示的建议问题列表 |
70
+ | `locale` | 否 | `LocaleCode` | 内置 UI 文案语言,默认 `"zh-CN"` |
71
+ | `onSuggestionClick` | 否 | `(suggestion: string) => void` | 点击建议问题时触发的回调 |
72
+
73
+ #### 示例:基础用法
74
+
75
+ ```tsx
76
+ <AgKitUI />
77
+ ```
78
+
79
+ #### 示例:自定义建议与语言
80
+
81
+ ```tsx
82
+ <AgKitUI
83
+ locale="zh-CN"
84
+ inputPlaceholder="输入你的问题"
85
+ suggestions={[
86
+ "帮我总结今天的工作",
87
+ "生成一份周报模板",
88
+ "解释这个接口的用途",
89
+ ]}
90
+ onSuggestionClick={(value) => {
91
+ console.log("clicked suggestion:", value);
92
+ }}
93
+ />
94
+ ```
95
+
96
+ #### 示例:自定义样式
97
+
98
+ ```tsx
99
+ <AgKitUI
100
+ containerClassName="my-chat-container"
101
+ messagesClassName="my-messages"
102
+ inputClassName="my-input"
103
+ emptyTitleClassName="my-empty-title"
104
+ />
105
+ ```
106
+
107
+ ---
108
+
109
+ ### `LocaleCode`
110
+
111
+ 内置语言类型,用于指定 `AgKitUI` 的 UI 文案语言。
112
+
113
+ ```ts
114
+ type LocaleCode = "zh-CN" | "en-US";
115
+ ```
116
+
117
+ | 值 | 说明 |
118
+ | --- | --- |
119
+ | `"zh-CN"` | 简体中文(默认) |
120
+ | `"en-US"` | 英语 |
121
+
122
+ 可直接用于业务代码中的类型标注:
123
+
124
+ ```tsx
125
+ import { type LocaleCode } from "@cloudbase/agent-react-ui";
126
+ ```
127
+
128
+ ---
129
+
130
+ ## 使用说明
131
+
132
+ 接入时通常由 `@cloudbase/agent-react-core` 提供运行时能力,包括消息状态、发送逻辑、工具注册和传输层;`@cloudbase/agent-react-ui` 负责聊天界面展示。
133
+
134
+ 如果需要快速接入默认聊天窗口,通常只需完成运行时初始化后渲染 `AgKitUI` 即可。
135
+
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema.json",
3
+ "style": "new-york",
4
+ "rsc": false,
5
+ "tsx": true,
6
+ "tailwind": {
7
+ "config": "",
8
+ "css": "src/styles/globals.css",
9
+ "baseColor": "neutral",
10
+ "cssVariables": true,
11
+ "prefix": ""
12
+ },
13
+ "aliases": {
14
+ "components": "@/components",
15
+ "utils": "@/lib/utils",
16
+ "ui": "@/components/ui",
17
+ "lib": "@/lib",
18
+ "hooks": "@/hooks"
19
+ },
20
+ "iconLibrary": "lucide"
21
+ }