yicoclaw 1.0.0
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/README.md +237 -0
- package/package.json +98 -0
package/README.md
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# AI Agent Workspace
|
|
2
|
+
|
|
3
|
+
AI 对话工作台,支持多模型切换、自定义模型管理、Markdown 渲染及技能管理。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- **多模型支持**:支持预置模型和自定义模型配置
|
|
8
|
+
- **流式对话**:实时流式输出,打字机效果
|
|
9
|
+
- **模型管理**:可视化配置自定义模型(API Key、地址等)
|
|
10
|
+
- **技能管理**:上传和管理技能包
|
|
11
|
+
- **用户认证**:基于用户名密码的登录系统
|
|
12
|
+
- **Markdown 渲染**:支持代码高亮、表格等 GFM 扩展
|
|
13
|
+
|
|
14
|
+
## 技术栈
|
|
15
|
+
|
|
16
|
+
- **Framework**: Next.js 16 (App Router)
|
|
17
|
+
- **Core**: React 19
|
|
18
|
+
- **Language**: TypeScript 5
|
|
19
|
+
- **UI 组件**: shadcn/ui (基于 Radix UI)
|
|
20
|
+
- **Styling**: Tailwind CSS 4
|
|
21
|
+
- **LLM SDK**: coze-coding-dev-sdk
|
|
22
|
+
|
|
23
|
+
## 快速开始
|
|
24
|
+
|
|
25
|
+
### 1. 安装依赖
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pnpm install
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 2. 启动开发服务器
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pnpm dev
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
服务将在 `http://localhost:5000` 上运行。
|
|
38
|
+
|
|
39
|
+
### 3. 访问应用
|
|
40
|
+
|
|
41
|
+
打开浏览器访问 `http://localhost:5000`
|
|
42
|
+
|
|
43
|
+
默认登录账号:
|
|
44
|
+
- 用户名:`admin`
|
|
45
|
+
- 密码:`admin123`
|
|
46
|
+
|
|
47
|
+
## CLI 命令行工具
|
|
48
|
+
|
|
49
|
+
### 安装
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# 从源码安装
|
|
53
|
+
cd packages/yicoclaw
|
|
54
|
+
pnpm install && pnpm build && npm link
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 命令
|
|
58
|
+
|
|
59
|
+
| 命令 | 描述 |
|
|
60
|
+
|------|------|
|
|
61
|
+
| `yicoclaw install` | 安装并配置 CLI |
|
|
62
|
+
| `yicoclaw install --port 1211` | 指定默认端口 |
|
|
63
|
+
| `yicoclaw install --skills /path` | 指定技能存放路径 |
|
|
64
|
+
| `yicoclaw install --yes` | 使用默认配置 |
|
|
65
|
+
| `yicoclaw start` | 启动服务 |
|
|
66
|
+
| `yicoclaw start --port 9527` | 指定端口启动 |
|
|
67
|
+
| `yicoclaw doctor` | 检查安装状态 |
|
|
68
|
+
|
|
69
|
+
### 配置文件
|
|
70
|
+
|
|
71
|
+
安装后,用户配置保存在 `~/.yicoclaw/config.json`:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"defaultPort": 1211,
|
|
76
|
+
"skillsPath": "/home/user/.yicoclaw/skills",
|
|
77
|
+
"installPath": "/path/to/project"
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## 配置说明
|
|
82
|
+
|
|
83
|
+
### config.json 结构
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"app": {
|
|
88
|
+
"name": "AI Agent Workspace",
|
|
89
|
+
"version": "1.0.0"
|
|
90
|
+
},
|
|
91
|
+
"auth": {
|
|
92
|
+
"enabled": true,
|
|
93
|
+
"users": [
|
|
94
|
+
{
|
|
95
|
+
"username": "admin",
|
|
96
|
+
"password": "admin123",
|
|
97
|
+
"role": "admin"
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
"sessionTimeout": 86400
|
|
101
|
+
},
|
|
102
|
+
"fileOperations": {
|
|
103
|
+
"enabled": true,
|
|
104
|
+
"allowedPaths": ["${COZE_WORKSPACE_PATH}", "/tmp"],
|
|
105
|
+
"maxFileSize": 10485760,
|
|
106
|
+
"allowedFileTypes": [".txt", ".md", ".json", ".js", ".ts"]
|
|
107
|
+
},
|
|
108
|
+
"skills": {
|
|
109
|
+
"enabled": true,
|
|
110
|
+
"skillsPath": "/workspace/projects/skills",
|
|
111
|
+
"allowedOperations": ["create", "read", "update", "delete"]
|
|
112
|
+
},
|
|
113
|
+
"modelSelection": {
|
|
114
|
+
"mode": "manual",
|
|
115
|
+
"defaultModel": "custom-glm-4-001",
|
|
116
|
+
"customModels": [
|
|
117
|
+
{
|
|
118
|
+
"id": "custom-glm-4-001",
|
|
119
|
+
"name": "GLM-4",
|
|
120
|
+
"modelName": "glm-4",
|
|
121
|
+
"apiKey": "your-api-key",
|
|
122
|
+
"baseUrl": "https://open.bigmodel.cn/api/paas/v4",
|
|
123
|
+
"description": "智谱大模型"
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### 添加自定义模型
|
|
131
|
+
|
|
132
|
+
在左侧菜单点击「模型管理」,添加自定义模型:
|
|
133
|
+
|
|
134
|
+
| 字段 | 说明 |
|
|
135
|
+
|------|------|
|
|
136
|
+
| 模型显示名称 | 界面中显示的名称 |
|
|
137
|
+
| OpenAI 模型名称 | API 调用的实际模型名 |
|
|
138
|
+
| API Key | 模型的 API 密钥 |
|
|
139
|
+
| API URL | API 基础地址 |
|
|
140
|
+
|
|
141
|
+
## API 接口
|
|
142
|
+
|
|
143
|
+
### 用户登录
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
POST /api/auth/login
|
|
147
|
+
Content-Type: application/json
|
|
148
|
+
|
|
149
|
+
{
|
|
150
|
+
"username": "admin",
|
|
151
|
+
"password": "admin123"
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### 流式聊天
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
POST /api/chat/stream
|
|
159
|
+
Content-Type: application/json
|
|
160
|
+
|
|
161
|
+
{
|
|
162
|
+
"message": "用户消息",
|
|
163
|
+
"modelId": "custom-glm-4-001",
|
|
164
|
+
"history": [
|
|
165
|
+
{ "role": "user", "content": "历史消息" },
|
|
166
|
+
{ "role": "assistant", "content": "历史回复" }
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 文件操作
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
POST /api/files
|
|
175
|
+
Content-Type: application/json
|
|
176
|
+
|
|
177
|
+
{
|
|
178
|
+
"action": "create|read|update|delete|list",
|
|
179
|
+
"filePath": "/path/to/file.txt",
|
|
180
|
+
"content": "文件内容"
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### 技能上传
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
POST /api/skills/upload
|
|
188
|
+
Content-Type: multipart/form-data
|
|
189
|
+
|
|
190
|
+
file: 技能包文件 (.zip, .tar.gz)
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## 开发指南
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# 开发模式
|
|
197
|
+
pnpm dev
|
|
198
|
+
|
|
199
|
+
# 构建生产版本
|
|
200
|
+
pnpm build
|
|
201
|
+
|
|
202
|
+
# 启动生产服务
|
|
203
|
+
pnpm start
|
|
204
|
+
|
|
205
|
+
# 代码检查
|
|
206
|
+
pnpm lint
|
|
207
|
+
pnpm ts-check
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## 项目结构
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
├── src/
|
|
214
|
+
│ ├── app/
|
|
215
|
+
│ │ ├── api/ # API 路由
|
|
216
|
+
│ │ ├── login/ # 登录页面
|
|
217
|
+
│ │ ├── page.tsx # 主页面
|
|
218
|
+
│ │ └── layout.tsx # 根布局
|
|
219
|
+
│ ├── components/ # 组件
|
|
220
|
+
│ │ ├── sidebar.tsx # 侧边栏
|
|
221
|
+
│ │ ├── chat-page.tsx # 对话页面
|
|
222
|
+
│ │ ├── models-page.tsx # 模型管理
|
|
223
|
+
│ │ └── skills-page.tsx # 技能管理
|
|
224
|
+
│ └── lib/ # 工具库
|
|
225
|
+
├── packages/
|
|
226
|
+
│ └── yicoclaw/ # CLI 工具
|
|
227
|
+
├── public/ # 静态资源
|
|
228
|
+
├── config.json # 配置文件
|
|
229
|
+
└── skills/ # 技能存储
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## 安全注意事项
|
|
233
|
+
|
|
234
|
+
1. **API Key 安全**:不要将包含真实 API Key 的 config.json 提交到版本控制
|
|
235
|
+
2. **文件操作权限**:配置 `allowedPaths` 限制可操作的目录
|
|
236
|
+
3. **文件类型限制**:配置 `allowedFileTypes` 限制可创建的文件类型
|
|
237
|
+
4. **文件大小限制**:配置 `maxFileSize` 防止创建过大文件
|
package/package.json
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "yicoclaw",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"build": "bash ./scripts/build.sh",
|
|
6
|
+
"dev": "bash ./scripts/dev.sh",
|
|
7
|
+
"preinstall": "npx only-allow pnpm",
|
|
8
|
+
"lint": "eslint",
|
|
9
|
+
"start": "bash ./scripts/start.sh",
|
|
10
|
+
"ts-check": "tsc -p tsconfig.json"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@aws-sdk/client-s3": "^3.958.0",
|
|
14
|
+
"@aws-sdk/lib-storage": "^3.958.0",
|
|
15
|
+
"@hookform/resolvers": "^5.2.2",
|
|
16
|
+
"@radix-ui/react-accordion": "^1.2.12",
|
|
17
|
+
"@radix-ui/react-alert-dialog": "^1.1.15",
|
|
18
|
+
"@radix-ui/react-aspect-ratio": "^1.1.8",
|
|
19
|
+
"@radix-ui/react-avatar": "^1.1.11",
|
|
20
|
+
"@radix-ui/react-checkbox": "^1.3.3",
|
|
21
|
+
"@radix-ui/react-collapsible": "^1.1.12",
|
|
22
|
+
"@radix-ui/react-context-menu": "^2.2.16",
|
|
23
|
+
"@radix-ui/react-dialog": "^1.1.15",
|
|
24
|
+
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
|
25
|
+
"@radix-ui/react-hover-card": "^1.1.15",
|
|
26
|
+
"@radix-ui/react-label": "^2.1.8",
|
|
27
|
+
"@radix-ui/react-menubar": "^1.1.16",
|
|
28
|
+
"@radix-ui/react-navigation-menu": "^1.2.14",
|
|
29
|
+
"@radix-ui/react-popover": "^1.1.15",
|
|
30
|
+
"@radix-ui/react-progress": "^1.1.8",
|
|
31
|
+
"@radix-ui/react-radio-group": "^1.3.8",
|
|
32
|
+
"@radix-ui/react-scroll-area": "^1.2.10",
|
|
33
|
+
"@radix-ui/react-select": "^2.2.6",
|
|
34
|
+
"@radix-ui/react-separator": "^1.1.8",
|
|
35
|
+
"@radix-ui/react-slider": "^1.3.6",
|
|
36
|
+
"@radix-ui/react-slot": "^1.2.4",
|
|
37
|
+
"@radix-ui/react-switch": "^1.2.6",
|
|
38
|
+
"@radix-ui/react-tabs": "^1.1.13",
|
|
39
|
+
"@radix-ui/react-toggle": "^1.1.10",
|
|
40
|
+
"@radix-ui/react-toggle-group": "^1.1.11",
|
|
41
|
+
"@radix-ui/react-tooltip": "^1.2.8",
|
|
42
|
+
"@supabase/supabase-js": "2.95.3",
|
|
43
|
+
"class-variance-authority": "^0.7.1",
|
|
44
|
+
"clsx": "^2.1.1",
|
|
45
|
+
"cmdk": "^1.1.1",
|
|
46
|
+
"coze-coding-dev-sdk": "^0.7.19",
|
|
47
|
+
"date-fns": "^4.1.0",
|
|
48
|
+
"dotenv": "^17.2.3",
|
|
49
|
+
"drizzle-kit": "^0.31.8",
|
|
50
|
+
"drizzle-orm": "^0.45.1",
|
|
51
|
+
"drizzle-zod": "^0.8.3",
|
|
52
|
+
"embla-carousel-react": "^8.6.0",
|
|
53
|
+
"gpt-tokenizer": "^3.4.0",
|
|
54
|
+
"input-otp": "^1.4.2",
|
|
55
|
+
"lucide-react": "^0.468.0",
|
|
56
|
+
"next": "16.1.1",
|
|
57
|
+
"next-themes": "^0.4.6",
|
|
58
|
+
"pg": "^8.16.3",
|
|
59
|
+
"react": "19.2.3",
|
|
60
|
+
"react-day-picker": "^9.13.0",
|
|
61
|
+
"react-dom": "19.2.3",
|
|
62
|
+
"react-hook-form": "^7.70.0",
|
|
63
|
+
"react-markdown": "^10.1.0",
|
|
64
|
+
"react-resizable-panels": "^4.2.0",
|
|
65
|
+
"recharts": "2.15.4",
|
|
66
|
+
"rehype-highlight": "^7.0.2",
|
|
67
|
+
"remark-gfm": "^4.0.1",
|
|
68
|
+
"sonner": "^2.0.7",
|
|
69
|
+
"tailwind-merge": "^2.6.0",
|
|
70
|
+
"tw-animate-css": "^1.4.0",
|
|
71
|
+
"vaul": "^1.1.2",
|
|
72
|
+
"zod": "^4.3.5"
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@react-dev-inspector/babel-plugin": "^2.0.1",
|
|
76
|
+
"@react-dev-inspector/middleware": "^2.0.1",
|
|
77
|
+
"@tailwindcss/postcss": "^4",
|
|
78
|
+
"@tailwindcss/typography": "^0.5.19",
|
|
79
|
+
"@types/node": "^20",
|
|
80
|
+
"@types/pg": "^8.16.0",
|
|
81
|
+
"@types/react": "^19",
|
|
82
|
+
"@types/react-dom": "^19",
|
|
83
|
+
"eslint": "^9",
|
|
84
|
+
"eslint-config-next": "16.1.1",
|
|
85
|
+
"only-allow": "^1.2.2",
|
|
86
|
+
"react-dev-inspector": "^2.0.1",
|
|
87
|
+
"shadcn": "latest",
|
|
88
|
+
"tailwindcss": "^4",
|
|
89
|
+
"tsup": "^8.3.5",
|
|
90
|
+
"tsx": "^4.19.2",
|
|
91
|
+
"typescript": "^5"
|
|
92
|
+
},
|
|
93
|
+
"packageManager": "pnpm@9.0.0",
|
|
94
|
+
"engines": {
|
|
95
|
+
"pnpm": ">=9.0.0"
|
|
96
|
+
},
|
|
97
|
+
"files": ["dist", "lib", "README.md"]
|
|
98
|
+
}
|