fotric-claw 0.1.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/LICENSE +21 -0
- package/README.md +276 -0
- package/backend/.env.example +26 -0
- package/backend/nest-cli.json +8 -0
- package/backend/package-lock.json +13239 -0
- package/backend/package.json +82 -0
- package/backend/src/agent/agent.module.ts +10 -0
- package/backend/src/agent/agent.service.ts +210 -0
- package/backend/src/agent/index.ts +4 -0
- package/backend/src/agent/llm.factory.ts +20 -0
- package/backend/src/agent/tools/fetch.tool.ts +128 -0
- package/backend/src/agent/tools/file-read.tool.ts +99 -0
- package/backend/src/agent/tools/index.ts +55 -0
- package/backend/src/agent/tools/node-repl.tool.ts +82 -0
- package/backend/src/agent/tools/rag.tool.ts +192 -0
- package/backend/src/agent/tools/shell.tool.ts +65 -0
- package/backend/src/app.module.ts +26 -0
- package/backend/src/chat/chat.controller.ts +34 -0
- package/backend/src/chat/chat.module.ts +12 -0
- package/backend/src/chat/chat.service.ts +52 -0
- package/backend/src/chat/dto/chat.dto.ts +12 -0
- package/backend/src/chat/dto/index.ts +1 -0
- package/backend/src/chat/index.ts +4 -0
- package/backend/src/config/config.controller.ts +92 -0
- package/backend/src/config/config.module.ts +7 -0
- package/backend/src/config/constants.ts +56 -0
- package/backend/src/config/index.ts +3 -0
- package/backend/src/files/files.controller.ts +87 -0
- package/backend/src/files/files.module.ts +7 -0
- package/backend/src/files/index.ts +2 -0
- package/backend/src/main.ts +21 -0
- package/backend/src/memory/index.ts +3 -0
- package/backend/src/memory/memory.module.ts +10 -0
- package/backend/src/memory/memory.service.ts +329 -0
- package/backend/src/memory/memory.types.ts +38 -0
- package/backend/src/sessions/default.json +7 -0
- package/backend/src/sessions/index.ts +2 -0
- package/backend/src/sessions/main_session.json +40 -0
- package/backend/src/sessions/sessions.controller.ts +25 -0
- package/backend/src/sessions/sessions.module.ts +9 -0
- package/backend/src/sessions/test.json +16 -0
- package/backend/src/skills/browser_search/SKILL.md +81 -0
- package/backend/src/skills/get_weather/SKILL.md +72 -0
- package/backend/src/skills/index.ts +3 -0
- package/backend/src/skills/skill.types.ts +27 -0
- package/backend/src/skills/skills.module.ts +8 -0
- package/backend/src/skills/skills.service.ts +139 -0
- package/backend/src/skills/web_search/SKILL.md +76 -0
- package/backend/src/workspace/AGENTS.md +47 -0
- package/backend/src/workspace/IDENTITY.md +32 -0
- package/backend/src/workspace/MEMORY.md +15 -0
- package/backend/src/workspace/SOUL.md +29 -0
- package/backend/src/workspace/USER.md +8 -0
- package/backend/tsconfig.build.json +4 -0
- package/backend/tsconfig.json +26 -0
- package/bin/fotric-claw.js +281 -0
- package/frontend/next.config.js +14 -0
- package/frontend/package-lock.json +5700 -0
- package/frontend/package.json +33 -0
- package/frontend/postcss.config.js +6 -0
- package/frontend/src/app/globals.css +41 -0
- package/frontend/src/app/layout.tsx +22 -0
- package/frontend/src/app/page.tsx +405 -0
- package/frontend/src/lib/api.ts +157 -0
- package/frontend/src/lib/utils.ts +3 -0
- package/frontend/tailwind.config.js +32 -0
- package/frontend/tsconfig.json +26 -0
- package/knowledge/README.md +21 -0
- package/package.json +49 -0
- package/scripts/init-skills.ts +95 -0
- package/storage/.gitkeep +5 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 FOTRIC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
# FotricCalw 安装与配置指南
|
|
2
|
+
|
|
3
|
+
FotricCalw 是一个轻量级、透明的 AI Agent 系统,支持命令行安装和配置。
|
|
4
|
+
|
|
5
|
+
## 系统要求
|
|
6
|
+
|
|
7
|
+
- Node.js >= 18.0.0
|
|
8
|
+
- npm >= 9.0.0
|
|
9
|
+
|
|
10
|
+
## 安装方式
|
|
11
|
+
|
|
12
|
+
### 方式一:从 npm 安装(待开发)
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install -g fotric-claw
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
> 注:此方式暂不可用,请使用源码安装。
|
|
19
|
+
|
|
20
|
+
### 方式二:从源码安装
|
|
21
|
+
|
|
22
|
+
#### 步骤 1:克隆项目
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
git clone https://github.com/fotric/fotric-claw.git
|
|
26
|
+
cd fotric-claw
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
#### 步骤 2:安装依赖
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm run install:all
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
该命令会自动安装前端和后端的所有依赖。
|
|
36
|
+
|
|
37
|
+
也可以手动安装:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
cd backend && npm install
|
|
41
|
+
cd ../frontend && npm install
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
#### 步骤 3:配置环境变量
|
|
45
|
+
|
|
46
|
+
复制环境变量模板:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
cp backend/.env.example backend/.env
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
或使用命令行配置工具(配置将保存到 `backend/.env`):
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
node bin/fotric-claw.js config
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### 步骤 4:启动服务
|
|
59
|
+
|
|
60
|
+
**方式一:使用命令行工具(推荐)**
|
|
61
|
+
|
|
62
|
+
(由于方式一的命令行工具暂未开发,此处仅展示手动启动的方式)
|
|
63
|
+
```bash
|
|
64
|
+
fotric-claw start
|
|
65
|
+
```
|
|
66
|
+
使用该方案,等效于上述命令
|
|
67
|
+
```bash
|
|
68
|
+
node bin/fotric-claw.js start
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
该命令将自动启动后端和前端服务。
|
|
72
|
+
|
|
73
|
+
**方式二:手动启动**
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# 启动后端服务
|
|
77
|
+
npm run backend
|
|
78
|
+
|
|
79
|
+
# 在新终端窗口启动前端服务
|
|
80
|
+
npm run frontend
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
#### 步骤 5:访问应用
|
|
84
|
+
|
|
85
|
+
打开浏览器访问 http://localhost:3000
|
|
86
|
+
|
|
87
|
+
## 命令行配置
|
|
88
|
+
|
|
89
|
+
FotricCalw 提供了交互式命令行配置工具,方便用户设置 LLM API 参数。
|
|
90
|
+
|
|
91
|
+
### 查看帮助
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
fotric-claw help
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
输出:
|
|
98
|
+
```
|
|
99
|
+
FotricCalw CLI
|
|
100
|
+
|
|
101
|
+
Usage:
|
|
102
|
+
fotric-claw <command> [options]
|
|
103
|
+
|
|
104
|
+
Commands:
|
|
105
|
+
start Start backend and frontend services (dev mode)
|
|
106
|
+
start:prod Start backend and frontend services (production mode)
|
|
107
|
+
build Build backend and frontend for production
|
|
108
|
+
config Configure LLM API settings
|
|
109
|
+
help Show this help message
|
|
110
|
+
|
|
111
|
+
Examples:
|
|
112
|
+
fotric-claw start
|
|
113
|
+
fotric-claw start:prod
|
|
114
|
+
fotric-claw build
|
|
115
|
+
fotric-claw config
|
|
116
|
+
fotric-claw help
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### 配置 LLM API
|
|
120
|
+
|
|
121
|
+
运行配置命令:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
fotric-claw config
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
系统将显示当前配置并引导您输入新的配置值:
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
🔧 FotricCalw Configuration
|
|
131
|
+
|
|
132
|
+
Current configuration:
|
|
133
|
+
API Key: sk-a****bcd
|
|
134
|
+
API Base URL: https://api.openai.com/v1
|
|
135
|
+
Model Name: gpt-4o
|
|
136
|
+
|
|
137
|
+
Enter API Key (sk-abcd1234):
|
|
138
|
+
Enter API Base URL (https://api.openai.com/v1):
|
|
139
|
+
Enter Model Name (gpt-4o):
|
|
140
|
+
|
|
141
|
+
✅ Configuration saved to .env file
|
|
142
|
+
Please restart the server for changes to take effect.
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### 配置参数说明
|
|
146
|
+
|
|
147
|
+
| 参数 | 环境变量 | 说明 | 默认值 |
|
|
148
|
+
|------|----------|------|--------|
|
|
149
|
+
| API Key | `FOTRIC_API_KEY` | LLM API 密钥 | - |
|
|
150
|
+
| API Base URL | `FOTRIC_API_BASE_URL` | API 基础地址 | `https://api.openai.com/v1` |
|
|
151
|
+
| Model Name | `FOTRIC_MODEL_NAME` | 模型名称 | `gpt-4o` |
|
|
152
|
+
|
|
153
|
+
## 环境变量配置
|
|
154
|
+
|
|
155
|
+
除了使用命令行工具,您也可以直接编辑 `backend/.env` 文件:
|
|
156
|
+
|
|
157
|
+
```env
|
|
158
|
+
# 服务器配置
|
|
159
|
+
PORT=8002
|
|
160
|
+
NODE_ENV=development
|
|
161
|
+
|
|
162
|
+
# LLM API 配置(支持 OpenAI 兼容接口)
|
|
163
|
+
FOTRIC_API_KEY=your_api_key_here
|
|
164
|
+
FOTRIC_API_BASE_URL=https://api.openai.com/v1
|
|
165
|
+
FOTRIC_MODEL_NAME=gpt-4o
|
|
166
|
+
|
|
167
|
+
# 项目路径配置
|
|
168
|
+
FOTRIC_ROOT_DIR=./
|
|
169
|
+
FOTRIC_SKILLS_DIR=./src/skills
|
|
170
|
+
FOTRIC_WORKSPACE_DIR=./src/workspace
|
|
171
|
+
FOTRIC_SESSIONS_DIR=./src/sessions
|
|
172
|
+
FOTRIC_KNOWLEDGE_DIR=../knowledge
|
|
173
|
+
FOTRIC_STORAGE_DIR=../storage
|
|
174
|
+
|
|
175
|
+
# 内存配置
|
|
176
|
+
FOTRIC_MAX_MEMORY_CHARS=20000
|
|
177
|
+
FOTRIC_MAX_TOKENS=128000
|
|
178
|
+
|
|
179
|
+
# 工具配置
|
|
180
|
+
FOTRIC_SHELL_TIMEOUT=30000
|
|
181
|
+
FOTRIC_REPL_TIMEOUT=15000
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## 启动服务
|
|
185
|
+
|
|
186
|
+
### 开发模式
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# 启动后端服务
|
|
190
|
+
npm run backend
|
|
191
|
+
|
|
192
|
+
# 启动前端服务(新终端窗口)
|
|
193
|
+
npm run frontend
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### 生产模式
|
|
197
|
+
|
|
198
|
+
**方式一:使用命令行工具(推荐)**
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# 构建项目
|
|
202
|
+
fotric-claw build
|
|
203
|
+
|
|
204
|
+
# 启动生产服务
|
|
205
|
+
fotric-claw start:prod
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**方式二:手动操作**
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
# 构建项目
|
|
212
|
+
npm run build:backend
|
|
213
|
+
npm run build:frontend
|
|
214
|
+
|
|
215
|
+
# 启动后端
|
|
216
|
+
cd backend && npm run start:prod
|
|
217
|
+
|
|
218
|
+
# 启动前端
|
|
219
|
+
cd frontend && npm run start
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## 访问服务
|
|
223
|
+
|
|
224
|
+
启动成功后:
|
|
225
|
+
|
|
226
|
+
- **前端界面**: http://localhost:3000
|
|
227
|
+
- **后端 API**: http://localhost:8002
|
|
228
|
+
- **配置接口**: http://localhost:8002/api/config
|
|
229
|
+
|
|
230
|
+
## 常见问题
|
|
231
|
+
|
|
232
|
+
### 1. 端口被占用
|
|
233
|
+
|
|
234
|
+
如果默认端口被占用,可以修改 `backend/.env` 中的 `PORT` 配置:
|
|
235
|
+
|
|
236
|
+
```env
|
|
237
|
+
PORT=8003
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### 2. API Key 未配置
|
|
241
|
+
|
|
242
|
+
如果未配置 API Key,后端服务仍可启动,但 AI 对话功能将无法使用。请通过以下方式配置:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
fotric-claw config
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
或在前端界面的设置页面配置。
|
|
249
|
+
|
|
250
|
+
### 3. 使用其他 LLM 提供商
|
|
251
|
+
|
|
252
|
+
FotricCalw 支持所有 OpenAI 兼容的 API 接口,例如:
|
|
253
|
+
|
|
254
|
+
**Azure OpenAI:**
|
|
255
|
+
```env
|
|
256
|
+
FOTRIC_API_BASE_URL=https://your-resource.openai.azure.com/openai/deployments/your-deployment
|
|
257
|
+
FOTRIC_API_KEY=your-azure-key
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**国内 API 代理:**
|
|
261
|
+
```env
|
|
262
|
+
FOTRIC_API_BASE_URL=https://your-proxy.com/v1
|
|
263
|
+
FOTRIC_API_KEY=your-api-key
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
**本地部署模型:**
|
|
267
|
+
```env
|
|
268
|
+
FOTRIC_API_BASE_URL=http://localhost:11434/v1
|
|
269
|
+
FOTRIC_API_KEY=ollama
|
|
270
|
+
FOTRIC_MODEL_NAME=llama2
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## 技术支持
|
|
274
|
+
|
|
275
|
+
- GitHub: https://github.com/fotric/fotric-claw
|
|
276
|
+
- 官网: https://www.fotric.cn/
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# FotricCalw Backend Configuration
|
|
2
|
+
|
|
3
|
+
# Server
|
|
4
|
+
PORT=8002
|
|
5
|
+
NODE_ENV=development
|
|
6
|
+
|
|
7
|
+
# LLM API Configuration (支持 OpenAI 兼容接口)
|
|
8
|
+
FOTRIC_API_KEY=your_api_key_here
|
|
9
|
+
FOTRIC_API_BASE_URL=https://api.openai.com/v1
|
|
10
|
+
FOTRIC_MODEL_NAME=gpt-4o
|
|
11
|
+
|
|
12
|
+
# Project Paths
|
|
13
|
+
FOTRIC_ROOT_DIR=./
|
|
14
|
+
FOTRIC_SKILLS_DIR=./src/skills
|
|
15
|
+
FOTRIC_WORKSPACE_DIR=./src/workspace
|
|
16
|
+
FOTRIC_SESSIONS_DIR=./src/sessions
|
|
17
|
+
FOTRIC_KNOWLEDGE_DIR=../knowledge
|
|
18
|
+
FOTRIC_STORAGE_DIR=../storage
|
|
19
|
+
|
|
20
|
+
# Memory Configuration
|
|
21
|
+
FOTRIC_MAX_MEMORY_CHARS=20000
|
|
22
|
+
FOTRIC_MAX_TOKENS=128000
|
|
23
|
+
|
|
24
|
+
# Tool Configuration
|
|
25
|
+
FOTRIC_SHELL_TIMEOUT=30000
|
|
26
|
+
FOTRIC_REPL_TIMEOUT=15000
|