@cloudbase/agent-react-ui 1.0.1-alpha.32

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 +123 -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,123 @@
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
+ ## `AgKitUIProps`
52
+
53
+ `AgKitUI` 提供以下常用属性:
54
+
55
+ ```tsx
56
+ interface AgKitUIProps {
57
+ className?: string;
58
+ containerClassName?: string;
59
+ messagesClassName?: string;
60
+ inputClassName?: string;
61
+ emptyTitleClassName?: string;
62
+ inputPlaceholder?: string;
63
+ suggestions?: string[];
64
+ onSuggestionClick?: (suggestion: string) => void;
65
+ locale?: LocaleCode;
66
+ }
67
+ ```
68
+
69
+ - `className`:聊天主体布局类名
70
+ - `containerClassName`:最外层容器类名
71
+ - `messagesClassName`:消息列表区域类名
72
+ - `inputClassName`:输入区容器类名
73
+ - `emptyTitleClassName`:空状态标题类名
74
+ - `inputPlaceholder`:输入框占位文本
75
+ - `suggestions`:空状态下显示的建议问题
76
+ - `onSuggestionClick`:点击建议问题时触发的回调
77
+ - `locale`:内置文案语言,当前支持 `zh-CN` 和 `en-US`
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
+ 内置语言类型通过 `LocaleCode` 导出,可直接用于业务代码中的类型标注:
99
+
100
+ ```tsx
101
+ import { type LocaleCode } from "@cloudbase/agent-react-ui";
102
+ ```
103
+
104
+ 默认语言为 `zh-CN`。
105
+
106
+ ## 使用说明
107
+
108
+ 接入时通常由 `@cloudbase/agent-react-core` 提供运行时能力,包括消息状态、发送逻辑、工具注册和传输层;`@cloudbase/agent-react-ui` 负责聊天界面展示。
109
+
110
+ 如果需要快速接入默认聊天窗口,通常只需完成运行时初始化后渲染 `AgKitUI` 即可。
111
+
112
+ ## 参考
113
+
114
+ 仓库内提供了可运行示例:
115
+
116
+ - [example/App.tsx](/Users/choyjiang/Workspace/AG-Kit/typescript-sdk/packages/ui/react-ui/example/App.tsx)
117
+
118
+ 示例覆盖了以下内容:
119
+
120
+ - `AgKit` 与 `AgKitUI` 的组合使用
121
+ - `CloudBaseTransport` 初始化
122
+ - `useClientTool` 注册客户端工具
123
+ - `useToolCall` 自定义工具渲染
@@ -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
+ }