feihong-code 8.0.2 → 8.3.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/.github/dependabot.yml +1 -1
- package/.github/workflows/ci.yml +193 -193
- package/.github/workflows/release.yml +211 -203
- package/.github/workflows/swebench-real.yml +12 -1
- package/CHANGELOG.md +149 -135
- package/README.md +656 -656
- package/dist/cli/version.js +1 -1
- package/docs/API.md +827 -827
- package/docs//344/275/277/347/224/250/350/257/264/346/230/216/344/271/246-v8.0.1.md +146 -146
- package/docs//344/275/277/347/224/250/350/257/264/346/230/216/344/271/246.md +227 -227
- package/package.json +4 -3
package/docs/API.md
CHANGED
|
@@ -1,827 +1,827 @@
|
|
|
1
|
-
# 飞虹 Code API 文档
|
|
2
|
-
|
|
3
|
-
**版本**:v8.0.1
|
|
4
|
-
**基础 URL**:`http://localhost:8080`
|
|
5
|
-
**认证方式**:Bearer Token(FH_WEB_TOKEN)
|
|
6
|
-
**数据格式**:JSON
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## 目录
|
|
11
|
-
|
|
12
|
-
1. [认证方式](#认证方式)
|
|
13
|
-
2. [公开接口](#公开接口)
|
|
14
|
-
3. [受保护接口](#受保护接口)
|
|
15
|
-
4. [错误响应](#错误响应)
|
|
16
|
-
5. [数据模型](#数据模型)
|
|
17
|
-
6. [示例代码](#示例代码)
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## 认证方式
|
|
22
|
-
|
|
23
|
-
### 获取 Token
|
|
24
|
-
|
|
25
|
-
后端启动时自动生成 `FH_WEB_TOKEN`,输出在启动日志中:
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
[飞虹 Code] Web 控制台访问令牌 (FH_WEB_TOKEN): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
也可通过环境变量设置:
|
|
32
|
-
```bash
|
|
33
|
-
$env:FH_WEB_TOKEN = "your-secret-token"
|
|
34
|
-
node dist/cli/index.js serve
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### 使用 Token
|
|
38
|
-
|
|
39
|
-
所有受保护接口需在请求头中携带 Token:
|
|
40
|
-
|
|
41
|
-
```http
|
|
42
|
-
Authorization: Bearer <FH_WEB_TOKEN>
|
|
43
|
-
Content-Type: application/json
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### cURL 示例
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
curl -X GET http://localhost:8080/api/tasks \
|
|
50
|
-
-H "Authorization: Bearer <FH_WEB_TOKEN>"
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
## 公开接口
|
|
56
|
-
|
|
57
|
-
### 1. 健康检查
|
|
58
|
-
|
|
59
|
-
检查后端服务是否正常运行。
|
|
60
|
-
|
|
61
|
-
**请求**
|
|
62
|
-
```
|
|
63
|
-
GET /api/health
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
**响应** `200 OK`
|
|
67
|
-
```json
|
|
68
|
-
{
|
|
69
|
-
"ok": true,
|
|
70
|
-
"product": "飞虹 Code",
|
|
71
|
-
"version": "7.9.1",
|
|
72
|
-
"signature": "晋江市飞虹智科技企业管理有限公司 · 飞扬企源研发中心 · 负责人:吴赐虹",
|
|
73
|
-
"enterprise": true,
|
|
74
|
-
"lang": "zh",
|
|
75
|
-
"wechat": "disabled",
|
|
76
|
-
"feishu": "disabled",
|
|
77
|
-
"yuanbao": "disabled",
|
|
78
|
-
"time": "2026-09-03T03:22:41.905Z"
|
|
79
|
-
}
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
**字段说明**
|
|
83
|
-
|
|
84
|
-
| 字段 | 类型 | 说明 |
|
|
85
|
-
|------|------|------|
|
|
86
|
-
| ok | boolean | 服务是否正常 |
|
|
87
|
-
| product | string | 产品名称 |
|
|
88
|
-
| version | string | 当前版本号 |
|
|
89
|
-
| signature | string | 版权签名 |
|
|
90
|
-
| enterprise | boolean | 是否企业版 |
|
|
91
|
-
| lang | string | 语言 |
|
|
92
|
-
| wechat | string | 微信桥接状态(disabled/enabled) |
|
|
93
|
-
| feishu | string | 飞书桥接状态 |
|
|
94
|
-
| yuanbao | string | 元宝桥接状态 |
|
|
95
|
-
| time | string | 服务器时间(ISO 8601) |
|
|
96
|
-
|
|
97
|
-
**示例**
|
|
98
|
-
```bash
|
|
99
|
-
curl http://localhost:8080/api/health
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
---
|
|
103
|
-
|
|
104
|
-
## 受保护接口
|
|
105
|
-
|
|
106
|
-
> 以下接口均需携带 `Authorization: Bearer <FH_WEB_TOKEN>` 请求头。
|
|
107
|
-
|
|
108
|
-
### 2. 版本信息
|
|
109
|
-
|
|
110
|
-
获取详细的版本和构建信息。
|
|
111
|
-
|
|
112
|
-
**请求**
|
|
113
|
-
```
|
|
114
|
-
GET /api/version
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
**响应** `200 OK`
|
|
118
|
-
```json
|
|
119
|
-
{
|
|
120
|
-
"version": "7.9.1",
|
|
121
|
-
"buildTime": "2026-09-03T10:00:00.000Z",
|
|
122
|
-
"commit": "abc1234",
|
|
123
|
-
"nodeVersion": "v22.23.2",
|
|
124
|
-
"platform": "win32"
|
|
125
|
-
}
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
**错误响应** `401 Unauthorized`
|
|
129
|
-
```json
|
|
130
|
-
{
|
|
131
|
-
"error": "Unauthorized",
|
|
132
|
-
"code": 401
|
|
133
|
-
}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
### 3. 系统状态
|
|
139
|
-
|
|
140
|
-
获取当前系统运行状态。
|
|
141
|
-
|
|
142
|
-
**请求**
|
|
143
|
-
```
|
|
144
|
-
GET /api/status
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
**响应** `200 OK`
|
|
148
|
-
```json
|
|
149
|
-
{
|
|
150
|
-
"status": "running",
|
|
151
|
-
"uptime": 3600,
|
|
152
|
-
"memory": {
|
|
153
|
-
"rss": 238026752,
|
|
154
|
-
"heapTotal": 104857600,
|
|
155
|
-
"heapUsed": 62914560
|
|
156
|
-
},
|
|
157
|
-
"cpu": {
|
|
158
|
-
"usage": 5.2,
|
|
159
|
-
"cores": 8
|
|
160
|
-
},
|
|
161
|
-
"activeTasks": 3,
|
|
162
|
-
"queuedTasks": 0
|
|
163
|
-
}
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
---
|
|
167
|
-
|
|
168
|
-
### 4. 配置管理
|
|
169
|
-
|
|
170
|
-
获取或更新系统配置。
|
|
171
|
-
|
|
172
|
-
**获取配置**
|
|
173
|
-
```
|
|
174
|
-
GET /api/config
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
**更新配置**
|
|
178
|
-
```
|
|
179
|
-
POST /api/config
|
|
180
|
-
Content-Type: application/json
|
|
181
|
-
|
|
182
|
-
{
|
|
183
|
-
"model": "agnes-2.5-flash",
|
|
184
|
-
"apiBase": "https://api.agnes-ai.cn/v1",
|
|
185
|
-
"temperature": 0.7,
|
|
186
|
-
"maxTokens": 4096
|
|
187
|
-
}
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
**响应** `200 OK`
|
|
191
|
-
```json
|
|
192
|
-
{
|
|
193
|
-
"success": true,
|
|
194
|
-
"config": { ... }
|
|
195
|
-
}
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
---
|
|
199
|
-
|
|
200
|
-
### 5. 功能特性
|
|
201
|
-
|
|
202
|
-
获取可用功能特性列表。
|
|
203
|
-
|
|
204
|
-
**请求**
|
|
205
|
-
```
|
|
206
|
-
GET /api/features
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
**响应** `200 OK`
|
|
210
|
-
```json
|
|
211
|
-
{
|
|
212
|
-
"features": [
|
|
213
|
-
{ "id": "chat", "name": "AI 对话", "enabled": true },
|
|
214
|
-
{ "id": "games", "name": "游戏中心", "enabled": true },
|
|
215
|
-
{ "id": "creative", "name": "AI 创作", "enabled": true },
|
|
216
|
-
{ "id": "hermes", "name": "Hermes Agent", "enabled": true },
|
|
217
|
-
{ "id": "keyless", "name": "免密网络层", "enabled": true },
|
|
218
|
-
{ "id": "wechat", "name": "微信桥接", "enabled": false },
|
|
219
|
-
{ "id": "feishu", "name": "飞书桥接", "enabled": false }
|
|
220
|
-
]
|
|
221
|
-
}
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
---
|
|
225
|
-
|
|
226
|
-
### 6. 模型管理
|
|
227
|
-
|
|
228
|
-
获取可用模型列表。
|
|
229
|
-
|
|
230
|
-
**请求**
|
|
231
|
-
```
|
|
232
|
-
GET /api/models
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
**响应** `200 OK`
|
|
236
|
-
```json
|
|
237
|
-
{
|
|
238
|
-
"models": [
|
|
239
|
-
{
|
|
240
|
-
"id": "agnes-2.5-flash",
|
|
241
|
-
"name": "Agnes 2.5 Flash",
|
|
242
|
-
"provider": "agnes",
|
|
243
|
-
"apiBase": "https://api.agnes-ai.cn/v1",
|
|
244
|
-
"contextWindow": 128000,
|
|
245
|
-
"maxOutput": 8192,
|
|
246
|
-
"supportsStreaming": true,
|
|
247
|
-
"supportsVision": false
|
|
248
|
-
}
|
|
249
|
-
],
|
|
250
|
-
"defaultModel": "agnes-2.5-flash"
|
|
251
|
-
}
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
**添加模型**
|
|
255
|
-
```
|
|
256
|
-
POST /api/models
|
|
257
|
-
Content-Type: application/json
|
|
258
|
-
|
|
259
|
-
{
|
|
260
|
-
"id": "custom-model",
|
|
261
|
-
"name": "自定义模型",
|
|
262
|
-
"provider": "openai-compatible",
|
|
263
|
-
"apiBase": "https://api.example.com/v1",
|
|
264
|
-
"apiKey": "sk-xxx",
|
|
265
|
-
"contextWindow": 32000
|
|
266
|
-
}
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
---
|
|
270
|
-
|
|
271
|
-
### 7. 模型提供商
|
|
272
|
-
|
|
273
|
-
获取配置的模型提供商列表。
|
|
274
|
-
|
|
275
|
-
**请求**
|
|
276
|
-
```
|
|
277
|
-
GET /api/providers
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
**响应** `200 OK`
|
|
281
|
-
```json
|
|
282
|
-
{
|
|
283
|
-
"providers": [
|
|
284
|
-
{
|
|
285
|
-
"id": "agnes",
|
|
286
|
-
"name": "Agnes AI",
|
|
287
|
-
"apiBase": "https://api.agnes-ai.cn/v1",
|
|
288
|
-
"models": ["agnes-2.5-flash"],
|
|
289
|
-
"status": "connected"
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
"id": "siliconflow",
|
|
293
|
-
"name": "硅基流动",
|
|
294
|
-
"apiBase": "https://api.siliconflow.cn/v1",
|
|
295
|
-
"models": ["deepseek-ai/DeepSeek-OCR"],
|
|
296
|
-
"status": "connected"
|
|
297
|
-
}
|
|
298
|
-
]
|
|
299
|
-
}
|
|
300
|
-
```
|
|
301
|
-
|
|
302
|
-
---
|
|
303
|
-
|
|
304
|
-
### 8. Agent 管理
|
|
305
|
-
|
|
306
|
-
管理 AI Agent 实例。
|
|
307
|
-
|
|
308
|
-
**获取 Agent 列表**
|
|
309
|
-
```
|
|
310
|
-
GET /api/agents
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
**响应** `200 OK`
|
|
314
|
-
```json
|
|
315
|
-
{
|
|
316
|
-
"agents": [
|
|
317
|
-
{
|
|
318
|
-
"id": "agent-001",
|
|
319
|
-
"name": "代码助手",
|
|
320
|
-
"type": "solo",
|
|
321
|
-
"status": "idle",
|
|
322
|
-
"createdAt": "2026-09-01T10:00:00.000Z",
|
|
323
|
-
"lastActive": "2026-09-03T08:00:00.000Z"
|
|
324
|
-
}
|
|
325
|
-
],
|
|
326
|
-
"total": 5
|
|
327
|
-
}
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
**创建 Agent**
|
|
331
|
-
```
|
|
332
|
-
POST /api/agents
|
|
333
|
-
Content-Type: application/json
|
|
334
|
-
|
|
335
|
-
{
|
|
336
|
-
"name": "新 Agent",
|
|
337
|
-
"type": "solo",
|
|
338
|
-
"systemPrompt": "你是一个专业的代码助手",
|
|
339
|
-
"model": "agnes-2.5-flash"
|
|
340
|
-
}
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
**获取单个 Agent**
|
|
344
|
-
```
|
|
345
|
-
GET /api/agents/:id
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
**删除 Agent**
|
|
349
|
-
```
|
|
350
|
-
DELETE /api/agents/:id
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
---
|
|
354
|
-
|
|
355
|
-
### 9. 技能管理
|
|
356
|
-
|
|
357
|
-
管理可复用技能。
|
|
358
|
-
|
|
359
|
-
**获取技能列表**
|
|
360
|
-
```
|
|
361
|
-
GET /api/skills
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
**响应** `200 OK`
|
|
365
|
-
```json
|
|
366
|
-
{
|
|
367
|
-
"skills": [
|
|
368
|
-
{
|
|
369
|
-
"id": "skill-summarize",
|
|
370
|
-
"name": "内容摘要",
|
|
371
|
-
"description": "对长文本进行结构化摘要",
|
|
372
|
-
"trigger": "摘要|总结|概括",
|
|
373
|
-
"tags": ["文本处理", "效率"],
|
|
374
|
-
"useCount": 12,
|
|
375
|
-
"builtin": true,
|
|
376
|
-
"createdAt": "2026-09-01T00:00:00.000Z"
|
|
377
|
-
}
|
|
378
|
-
],
|
|
379
|
-
"total": 4
|
|
380
|
-
}
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
**安装技能**
|
|
384
|
-
```
|
|
385
|
-
POST /api/skills
|
|
386
|
-
Content-Type: application/json
|
|
387
|
-
|
|
388
|
-
{
|
|
389
|
-
"name": "新技能",
|
|
390
|
-
"description": "技能描述",
|
|
391
|
-
"trigger": "触发词",
|
|
392
|
-
"prompt": "提示词模板,{{content}}表示用户输入",
|
|
393
|
-
"tags": ["自定义"]
|
|
394
|
-
}
|
|
395
|
-
```
|
|
396
|
-
|
|
397
|
-
**删除技能**
|
|
398
|
-
```
|
|
399
|
-
DELETE /api/skills/:id
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
---
|
|
403
|
-
|
|
404
|
-
### 10. 工具列表
|
|
405
|
-
|
|
406
|
-
获取可用工具列表。
|
|
407
|
-
|
|
408
|
-
**请求**
|
|
409
|
-
```
|
|
410
|
-
GET /api/tools
|
|
411
|
-
```
|
|
412
|
-
|
|
413
|
-
**响应** `200 OK`
|
|
414
|
-
```json
|
|
415
|
-
{
|
|
416
|
-
"tools": [
|
|
417
|
-
{ "name": "web_search", "description": "网页搜索", "enabled": true },
|
|
418
|
-
{ "name": "file_read", "description": "文件读取", "enabled": true },
|
|
419
|
-
{ "name": "shell_exec", "description": "Shell 执行", "enabled": true },
|
|
420
|
-
{ "name": "browser", "description": "浏览器自动化", "enabled": true },
|
|
421
|
-
{ "name": "tts", "description": "文字转语音", "enabled": true }
|
|
422
|
-
],
|
|
423
|
-
"total": 8
|
|
424
|
-
}
|
|
425
|
-
```
|
|
426
|
-
|
|
427
|
-
---
|
|
428
|
-
|
|
429
|
-
### 11. 任务队列
|
|
430
|
-
|
|
431
|
-
管理异步任务队列。
|
|
432
|
-
|
|
433
|
-
**获取任务列表**
|
|
434
|
-
```
|
|
435
|
-
GET /api/tasks?status=pending&limit=20&offset=0
|
|
436
|
-
```
|
|
437
|
-
|
|
438
|
-
**查询参数**
|
|
439
|
-
|
|
440
|
-
| 参数 | 类型 | 说明 |
|
|
441
|
-
|------|------|------|
|
|
442
|
-
| status | string | 筛选状态(pending/running/completed/failed) |
|
|
443
|
-
| limit | number | 每页数量(默认20) |
|
|
444
|
-
| offset | number | 偏移量(默认0) |
|
|
445
|
-
|
|
446
|
-
**响应** `200 OK`
|
|
447
|
-
```json
|
|
448
|
-
{
|
|
449
|
-
"tasks": [
|
|
450
|
-
{
|
|
451
|
-
"id": "task-001",
|
|
452
|
-
"type": "chat",
|
|
453
|
-
"status": "completed",
|
|
454
|
-
"progress": 100,
|
|
455
|
-
"createdAt": "2026-09-03T10:00:00.000Z",
|
|
456
|
-
"completedAt": "2026-09-03T10:00:05.000Z",
|
|
457
|
-
"result": { "summary": "任务完成" }
|
|
458
|
-
}
|
|
459
|
-
],
|
|
460
|
-
"total": 98,
|
|
461
|
-
"pending": 0,
|
|
462
|
-
"running": 0
|
|
463
|
-
}
|
|
464
|
-
```
|
|
465
|
-
|
|
466
|
-
**创建任务**
|
|
467
|
-
```
|
|
468
|
-
POST /api/tasks
|
|
469
|
-
Content-Type: application/json
|
|
470
|
-
|
|
471
|
-
{
|
|
472
|
-
"type": "chat",
|
|
473
|
-
"input": "你好",
|
|
474
|
-
"model": "agnes-2.5-flash"
|
|
475
|
-
}
|
|
476
|
-
```
|
|
477
|
-
|
|
478
|
-
**获取任务状态**
|
|
479
|
-
```
|
|
480
|
-
GET /api/tasks/:id
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
**取消任务**
|
|
484
|
-
```
|
|
485
|
-
POST /api/tasks/:id/cancel
|
|
486
|
-
```
|
|
487
|
-
|
|
488
|
-
**删除任务**
|
|
489
|
-
```
|
|
490
|
-
DELETE /api/tasks/:id
|
|
491
|
-
```
|
|
492
|
-
|
|
493
|
-
---
|
|
494
|
-
|
|
495
|
-
### 12. 知识库
|
|
496
|
-
|
|
497
|
-
管理知识库文档。
|
|
498
|
-
|
|
499
|
-
**获取文档列表**
|
|
500
|
-
```
|
|
501
|
-
GET /api/knowledge
|
|
502
|
-
```
|
|
503
|
-
|
|
504
|
-
**响应** `200 OK`
|
|
505
|
-
```json
|
|
506
|
-
{
|
|
507
|
-
"documents": [
|
|
508
|
-
{
|
|
509
|
-
"id": "doc-001",
|
|
510
|
-
"title": "飞虹 Code 使用指南",
|
|
511
|
-
"type": "markdown",
|
|
512
|
-
"size": 10240,
|
|
513
|
-
"tags": ["指南", "使用"],
|
|
514
|
-
"createdAt": "2026-09-01T00:00:00.000Z"
|
|
515
|
-
}
|
|
516
|
-
],
|
|
517
|
-
"total": 14
|
|
518
|
-
}
|
|
519
|
-
```
|
|
520
|
-
|
|
521
|
-
**上传文档**
|
|
522
|
-
```
|
|
523
|
-
POST /api/knowledge
|
|
524
|
-
Content-Type: multipart/form-data
|
|
525
|
-
|
|
526
|
-
file: <文件>
|
|
527
|
-
title: 文档标题
|
|
528
|
-
tags: ["标签1","标签2"]
|
|
529
|
-
```
|
|
530
|
-
|
|
531
|
-
**搜索知识库**
|
|
532
|
-
```
|
|
533
|
-
GET /api/knowledge/search?q=关键词
|
|
534
|
-
```
|
|
535
|
-
|
|
536
|
-
**删除文档**
|
|
537
|
-
```
|
|
538
|
-
DELETE /api/knowledge/:id
|
|
539
|
-
```
|
|
540
|
-
|
|
541
|
-
---
|
|
542
|
-
|
|
543
|
-
### 13. 插件管理
|
|
544
|
-
|
|
545
|
-
管理系统插件。
|
|
546
|
-
|
|
547
|
-
**获取插件列表**
|
|
548
|
-
```
|
|
549
|
-
GET /api/plugins
|
|
550
|
-
```
|
|
551
|
-
|
|
552
|
-
**响应** `200 OK`
|
|
553
|
-
```json
|
|
554
|
-
{
|
|
555
|
-
"plugins": [
|
|
556
|
-
{
|
|
557
|
-
"id": "plugin-001",
|
|
558
|
-
"name": "示例插件",
|
|
559
|
-
"version": "1.0.0",
|
|
560
|
-
"description": "插件描述",
|
|
561
|
-
"enabled": true,
|
|
562
|
-
"installedAt": "2026-09-01T00:00:00.000Z"
|
|
563
|
-
}
|
|
564
|
-
],
|
|
565
|
-
"total": 0
|
|
566
|
-
}
|
|
567
|
-
```
|
|
568
|
-
|
|
569
|
-
**启用/禁用插件**
|
|
570
|
-
```
|
|
571
|
-
POST /api/plugins/:id/toggle
|
|
572
|
-
```
|
|
573
|
-
|
|
574
|
-
**卸载插件**
|
|
575
|
-
```
|
|
576
|
-
DELETE /api/plugins/:id
|
|
577
|
-
```
|
|
578
|
-
|
|
579
|
-
---
|
|
580
|
-
|
|
581
|
-
## 错误响应
|
|
582
|
-
|
|
583
|
-
### 错误格式
|
|
584
|
-
|
|
585
|
-
所有错误响应遵循统一格式:
|
|
586
|
-
|
|
587
|
-
```json
|
|
588
|
-
{
|
|
589
|
-
"error": "错误描述",
|
|
590
|
-
"code": 400,
|
|
591
|
-
"details": {}
|
|
592
|
-
}
|
|
593
|
-
```
|
|
594
|
-
|
|
595
|
-
### 常见错误码
|
|
596
|
-
|
|
597
|
-
| 状态码 | 说明 | 原因 |
|
|
598
|
-
|--------|------|------|
|
|
599
|
-
| 400 | Bad Request | 请求参数错误 |
|
|
600
|
-
| 401 | Unauthorized | 未携带或 Token 无效 |
|
|
601
|
-
| 403 | Forbidden | 无权限访问 |
|
|
602
|
-
| 404 | Not Found | 资源不存在 |
|
|
603
|
-
| 409 | Conflict | 资源冲突 |
|
|
604
|
-
| 429 | Too Many Requests | 请求频率超限 |
|
|
605
|
-
| 500 | Internal Server Error | 服务器内部错误 |
|
|
606
|
-
| 503 | Service Unavailable | 服务暂不可用 |
|
|
607
|
-
|
|
608
|
-
### 认证错误示例
|
|
609
|
-
|
|
610
|
-
```http
|
|
611
|
-
HTTP/1.1 401 Unauthorized
|
|
612
|
-
Content-Type: application/json
|
|
613
|
-
|
|
614
|
-
{
|
|
615
|
-
"error": "Unauthorized",
|
|
616
|
-
"code": 401
|
|
617
|
-
}
|
|
618
|
-
```
|
|
619
|
-
|
|
620
|
-
---
|
|
621
|
-
|
|
622
|
-
## 数据模型
|
|
623
|
-
|
|
624
|
-
### Health
|
|
625
|
-
|
|
626
|
-
```typescript
|
|
627
|
-
interface Health {
|
|
628
|
-
ok: boolean;
|
|
629
|
-
product: string;
|
|
630
|
-
version: string;
|
|
631
|
-
signature: string;
|
|
632
|
-
enterprise: boolean;
|
|
633
|
-
lang: string;
|
|
634
|
-
wechat: 'disabled' | 'enabled';
|
|
635
|
-
feishu: 'disabled' | 'enabled';
|
|
636
|
-
yuanbao: 'disabled' | 'enabled';
|
|
637
|
-
time: string; // ISO 8601
|
|
638
|
-
}
|
|
639
|
-
```
|
|
640
|
-
|
|
641
|
-
### Model
|
|
642
|
-
|
|
643
|
-
```typescript
|
|
644
|
-
interface Model {
|
|
645
|
-
id: string;
|
|
646
|
-
name: string;
|
|
647
|
-
provider: string;
|
|
648
|
-
apiBase: string;
|
|
649
|
-
contextWindow: number;
|
|
650
|
-
maxOutput: number;
|
|
651
|
-
supportsStreaming: boolean;
|
|
652
|
-
supportsVision: boolean;
|
|
653
|
-
}
|
|
654
|
-
```
|
|
655
|
-
|
|
656
|
-
### Skill
|
|
657
|
-
|
|
658
|
-
```typescript
|
|
659
|
-
interface Skill {
|
|
660
|
-
id: string;
|
|
661
|
-
name: string;
|
|
662
|
-
description: string;
|
|
663
|
-
trigger: string; // | 分隔多个触发词
|
|
664
|
-
prompt: string; // 支持 {{content}} {{变量}}
|
|
665
|
-
tools: string[];
|
|
666
|
-
tags: string[];
|
|
667
|
-
version: string;
|
|
668
|
-
useCount: number;
|
|
669
|
-
builtin?: boolean;
|
|
670
|
-
autoExtracted?: boolean;
|
|
671
|
-
llmExtracted?: boolean;
|
|
672
|
-
createdAt: string;
|
|
673
|
-
improvedAt?: string;
|
|
674
|
-
}
|
|
675
|
-
```
|
|
676
|
-
|
|
677
|
-
### Task
|
|
678
|
-
|
|
679
|
-
```typescript
|
|
680
|
-
interface Task {
|
|
681
|
-
id: string;
|
|
682
|
-
type: string;
|
|
683
|
-
status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
684
|
-
progress: number; // 0-100
|
|
685
|
-
input: any;
|
|
686
|
-
result?: any;
|
|
687
|
-
error?: string;
|
|
688
|
-
createdAt: string;
|
|
689
|
-
startedAt?: string;
|
|
690
|
-
completedAt?: string;
|
|
691
|
-
}
|
|
692
|
-
```
|
|
693
|
-
|
|
694
|
-
### Agent
|
|
695
|
-
|
|
696
|
-
```typescript
|
|
697
|
-
interface Agent {
|
|
698
|
-
id: string;
|
|
699
|
-
name: string;
|
|
700
|
-
type: 'solo' | 'orchestrator' | 'team';
|
|
701
|
-
status: 'idle' | 'running' | 'error';
|
|
702
|
-
systemPrompt?: string;
|
|
703
|
-
model?: string;
|
|
704
|
-
createdAt: string;
|
|
705
|
-
lastActive?: string;
|
|
706
|
-
}
|
|
707
|
-
```
|
|
708
|
-
|
|
709
|
-
---
|
|
710
|
-
|
|
711
|
-
## 示例代码
|
|
712
|
-
|
|
713
|
-
### Node.js 示例
|
|
714
|
-
|
|
715
|
-
```javascript
|
|
716
|
-
const BASE_URL = 'http://localhost:8080';
|
|
717
|
-
const TOKEN = 'your-fh-web-token';
|
|
718
|
-
|
|
719
|
-
async function api(path, options = {}) {
|
|
720
|
-
const res = await fetch(`${BASE_URL}${path}`, {
|
|
721
|
-
...options,
|
|
722
|
-
headers: {
|
|
723
|
-
'Content-Type': 'application/json',
|
|
724
|
-
'Authorization': `Bearer ${TOKEN}`,
|
|
725
|
-
...options.headers
|
|
726
|
-
}
|
|
727
|
-
});
|
|
728
|
-
if (!res.ok) throw new Error(`API Error: ${res.status}`);
|
|
729
|
-
return res.json();
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
// 健康检查(无需认证)
|
|
733
|
-
const health = await fetch(`${BASE_URL}/api/health`).then(r => r.json());
|
|
734
|
-
console.log('版本:', health.version);
|
|
735
|
-
|
|
736
|
-
// 获取任务列表(需认证)
|
|
737
|
-
const tasks = await api('/api/tasks?status=completed&limit=10');
|
|
738
|
-
console.log('任务数:', tasks.total);
|
|
739
|
-
|
|
740
|
-
// 创建任务
|
|
741
|
-
const newTask = await api('/api/tasks', {
|
|
742
|
-
method: 'POST',
|
|
743
|
-
body: JSON.stringify({ type: 'chat', input: '你好' })
|
|
744
|
-
});
|
|
745
|
-
console.log('任务ID:', newTask.id);
|
|
746
|
-
```
|
|
747
|
-
|
|
748
|
-
### Python 示例
|
|
749
|
-
|
|
750
|
-
```python
|
|
751
|
-
import requests
|
|
752
|
-
|
|
753
|
-
BASE_URL = 'http://localhost:8080'
|
|
754
|
-
TOKEN = 'your-fh-web-token'
|
|
755
|
-
HEADERS = {'Authorization': f'Bearer {TOKEN}'}
|
|
756
|
-
|
|
757
|
-
# 健康检查
|
|
758
|
-
health = requests.get(f'{BASE_URL}/api/health').json()
|
|
759
|
-
print(f"版本: {health['version']}")
|
|
760
|
-
|
|
761
|
-
# 获取模型列表
|
|
762
|
-
models = requests.get(f'{BASE_URL}/api/models', headers=HEADERS).json()
|
|
763
|
-
print(f"模型数: {len(models['models'])}")
|
|
764
|
-
|
|
765
|
-
# 创建技能
|
|
766
|
-
skill = requests.post(
|
|
767
|
-
f'{BASE_URL}/api/skills',
|
|
768
|
-
headers=HEADERS,
|
|
769
|
-
json={
|
|
770
|
-
'name': '代码优化',
|
|
771
|
-
'description': '优化代码性能和可读性',
|
|
772
|
-
'trigger': '优化代码|代码优化|性能优化',
|
|
773
|
-
'prompt': '请优化以下代码,提升性能和可读性:\n\n{{content}}'
|
|
774
|
-
}
|
|
775
|
-
).json()
|
|
776
|
-
print(f"技能ID: {skill.get('id')}")
|
|
777
|
-
```
|
|
778
|
-
|
|
779
|
-
### cURL 示例
|
|
780
|
-
|
|
781
|
-
```bash
|
|
782
|
-
# 健康检查
|
|
783
|
-
curl http://localhost:8080/api/health
|
|
784
|
-
|
|
785
|
-
# 获取任务列表
|
|
786
|
-
curl -X GET http://localhost:8080/api/tasks \
|
|
787
|
-
-H "Authorization: Bearer <TOKEN>"
|
|
788
|
-
|
|
789
|
-
# 创建任务
|
|
790
|
-
curl -X POST http://localhost:8080/api/tasks \
|
|
791
|
-
-H "Authorization: Bearer <TOKEN>" \
|
|
792
|
-
-H "Content-Type: application/json" \
|
|
793
|
-
-d '{"type":"chat","input":"你好"}'
|
|
794
|
-
|
|
795
|
-
# 安装技能
|
|
796
|
-
curl -X POST http://localhost:8080/api/skills \
|
|
797
|
-
-H "Authorization: Bearer <TOKEN>" \
|
|
798
|
-
-H "Content-Type: application/json" \
|
|
799
|
-
-d '{"name":"新技能","description":"描述","trigger":"触发词","prompt":"模板"}'
|
|
800
|
-
```
|
|
801
|
-
|
|
802
|
-
---
|
|
803
|
-
|
|
804
|
-
## 速率限制
|
|
805
|
-
|
|
806
|
-
| 接口类型 | 限制 |
|
|
807
|
-
|----------|------|
|
|
808
|
-
| 公开接口(/api/health) | 无限制 |
|
|
809
|
-
| 受保护接口 | 100 次/分钟 |
|
|
810
|
-
| 文件上传 | 10 次/分钟,单文件最大 50MB |
|
|
811
|
-
|
|
812
|
-
超出限制返回 `429 Too Many Requests`。
|
|
813
|
-
|
|
814
|
-
---
|
|
815
|
-
|
|
816
|
-
## 变更日志
|
|
817
|
-
|
|
818
|
-
| 版本 | 日期 | 变更 |
|
|
819
|
-
|------|------|------|
|
|
820
|
-
| v7.9.1 | 2026-09-03 | 新增 favicon/robots、LLM 辅助技能提炼、集成测试框架 |
|
|
821
|
-
| v7.9.0 | 2026-09-03 | Hermes Agent 完整框架(持久记忆+自演化技能+自动化调度+工具集) |
|
|
822
|
-
| v7.8.0 | 2026-09-02 | 免密网络层(Keyless Web Tier)+ Hermes 记忆基础 |
|
|
823
|
-
| v7.6.0 | 2026-08-30 | 基础版本,20个子系统 |
|
|
824
|
-
|
|
825
|
-
---
|
|
826
|
-
|
|
827
|
-
*本文档随版本更新而维护,最新版本以项目仓库 docs/ 目录为准。*
|
|
1
|
+
# 飞虹 Code API 文档
|
|
2
|
+
|
|
3
|
+
**版本**:v8.0.1
|
|
4
|
+
**基础 URL**:`http://localhost:8080`
|
|
5
|
+
**认证方式**:Bearer Token(FH_WEB_TOKEN)
|
|
6
|
+
**数据格式**:JSON
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 目录
|
|
11
|
+
|
|
12
|
+
1. [认证方式](#认证方式)
|
|
13
|
+
2. [公开接口](#公开接口)
|
|
14
|
+
3. [受保护接口](#受保护接口)
|
|
15
|
+
4. [错误响应](#错误响应)
|
|
16
|
+
5. [数据模型](#数据模型)
|
|
17
|
+
6. [示例代码](#示例代码)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 认证方式
|
|
22
|
+
|
|
23
|
+
### 获取 Token
|
|
24
|
+
|
|
25
|
+
后端启动时自动生成 `FH_WEB_TOKEN`,输出在启动日志中:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
[飞虹 Code] Web 控制台访问令牌 (FH_WEB_TOKEN): xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
也可通过环境变量设置:
|
|
32
|
+
```bash
|
|
33
|
+
$env:FH_WEB_TOKEN = "your-secret-token"
|
|
34
|
+
node dist/cli/index.js serve
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 使用 Token
|
|
38
|
+
|
|
39
|
+
所有受保护接口需在请求头中携带 Token:
|
|
40
|
+
|
|
41
|
+
```http
|
|
42
|
+
Authorization: Bearer <FH_WEB_TOKEN>
|
|
43
|
+
Content-Type: application/json
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### cURL 示例
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
curl -X GET http://localhost:8080/api/tasks \
|
|
50
|
+
-H "Authorization: Bearer <FH_WEB_TOKEN>"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 公开接口
|
|
56
|
+
|
|
57
|
+
### 1. 健康检查
|
|
58
|
+
|
|
59
|
+
检查后端服务是否正常运行。
|
|
60
|
+
|
|
61
|
+
**请求**
|
|
62
|
+
```
|
|
63
|
+
GET /api/health
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**响应** `200 OK`
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"ok": true,
|
|
70
|
+
"product": "飞虹 Code",
|
|
71
|
+
"version": "7.9.1",
|
|
72
|
+
"signature": "晋江市飞虹智科技企业管理有限公司 · 飞扬企源研发中心 · 负责人:吴赐虹",
|
|
73
|
+
"enterprise": true,
|
|
74
|
+
"lang": "zh",
|
|
75
|
+
"wechat": "disabled",
|
|
76
|
+
"feishu": "disabled",
|
|
77
|
+
"yuanbao": "disabled",
|
|
78
|
+
"time": "2026-09-03T03:22:41.905Z"
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**字段说明**
|
|
83
|
+
|
|
84
|
+
| 字段 | 类型 | 说明 |
|
|
85
|
+
|------|------|------|
|
|
86
|
+
| ok | boolean | 服务是否正常 |
|
|
87
|
+
| product | string | 产品名称 |
|
|
88
|
+
| version | string | 当前版本号 |
|
|
89
|
+
| signature | string | 版权签名 |
|
|
90
|
+
| enterprise | boolean | 是否企业版 |
|
|
91
|
+
| lang | string | 语言 |
|
|
92
|
+
| wechat | string | 微信桥接状态(disabled/enabled) |
|
|
93
|
+
| feishu | string | 飞书桥接状态 |
|
|
94
|
+
| yuanbao | string | 元宝桥接状态 |
|
|
95
|
+
| time | string | 服务器时间(ISO 8601) |
|
|
96
|
+
|
|
97
|
+
**示例**
|
|
98
|
+
```bash
|
|
99
|
+
curl http://localhost:8080/api/health
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 受保护接口
|
|
105
|
+
|
|
106
|
+
> 以下接口均需携带 `Authorization: Bearer <FH_WEB_TOKEN>` 请求头。
|
|
107
|
+
|
|
108
|
+
### 2. 版本信息
|
|
109
|
+
|
|
110
|
+
获取详细的版本和构建信息。
|
|
111
|
+
|
|
112
|
+
**请求**
|
|
113
|
+
```
|
|
114
|
+
GET /api/version
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**响应** `200 OK`
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"version": "7.9.1",
|
|
121
|
+
"buildTime": "2026-09-03T10:00:00.000Z",
|
|
122
|
+
"commit": "abc1234",
|
|
123
|
+
"nodeVersion": "v22.23.2",
|
|
124
|
+
"platform": "win32"
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**错误响应** `401 Unauthorized`
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"error": "Unauthorized",
|
|
132
|
+
"code": 401
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### 3. 系统状态
|
|
139
|
+
|
|
140
|
+
获取当前系统运行状态。
|
|
141
|
+
|
|
142
|
+
**请求**
|
|
143
|
+
```
|
|
144
|
+
GET /api/status
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**响应** `200 OK`
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
"status": "running",
|
|
151
|
+
"uptime": 3600,
|
|
152
|
+
"memory": {
|
|
153
|
+
"rss": 238026752,
|
|
154
|
+
"heapTotal": 104857600,
|
|
155
|
+
"heapUsed": 62914560
|
|
156
|
+
},
|
|
157
|
+
"cpu": {
|
|
158
|
+
"usage": 5.2,
|
|
159
|
+
"cores": 8
|
|
160
|
+
},
|
|
161
|
+
"activeTasks": 3,
|
|
162
|
+
"queuedTasks": 0
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
### 4. 配置管理
|
|
169
|
+
|
|
170
|
+
获取或更新系统配置。
|
|
171
|
+
|
|
172
|
+
**获取配置**
|
|
173
|
+
```
|
|
174
|
+
GET /api/config
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**更新配置**
|
|
178
|
+
```
|
|
179
|
+
POST /api/config
|
|
180
|
+
Content-Type: application/json
|
|
181
|
+
|
|
182
|
+
{
|
|
183
|
+
"model": "agnes-2.5-flash",
|
|
184
|
+
"apiBase": "https://api.agnes-ai.cn/v1",
|
|
185
|
+
"temperature": 0.7,
|
|
186
|
+
"maxTokens": 4096
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**响应** `200 OK`
|
|
191
|
+
```json
|
|
192
|
+
{
|
|
193
|
+
"success": true,
|
|
194
|
+
"config": { ... }
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
### 5. 功能特性
|
|
201
|
+
|
|
202
|
+
获取可用功能特性列表。
|
|
203
|
+
|
|
204
|
+
**请求**
|
|
205
|
+
```
|
|
206
|
+
GET /api/features
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**响应** `200 OK`
|
|
210
|
+
```json
|
|
211
|
+
{
|
|
212
|
+
"features": [
|
|
213
|
+
{ "id": "chat", "name": "AI 对话", "enabled": true },
|
|
214
|
+
{ "id": "games", "name": "游戏中心", "enabled": true },
|
|
215
|
+
{ "id": "creative", "name": "AI 创作", "enabled": true },
|
|
216
|
+
{ "id": "hermes", "name": "Hermes Agent", "enabled": true },
|
|
217
|
+
{ "id": "keyless", "name": "免密网络层", "enabled": true },
|
|
218
|
+
{ "id": "wechat", "name": "微信桥接", "enabled": false },
|
|
219
|
+
{ "id": "feishu", "name": "飞书桥接", "enabled": false }
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
### 6. 模型管理
|
|
227
|
+
|
|
228
|
+
获取可用模型列表。
|
|
229
|
+
|
|
230
|
+
**请求**
|
|
231
|
+
```
|
|
232
|
+
GET /api/models
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**响应** `200 OK`
|
|
236
|
+
```json
|
|
237
|
+
{
|
|
238
|
+
"models": [
|
|
239
|
+
{
|
|
240
|
+
"id": "agnes-2.5-flash",
|
|
241
|
+
"name": "Agnes 2.5 Flash",
|
|
242
|
+
"provider": "agnes",
|
|
243
|
+
"apiBase": "https://api.agnes-ai.cn/v1",
|
|
244
|
+
"contextWindow": 128000,
|
|
245
|
+
"maxOutput": 8192,
|
|
246
|
+
"supportsStreaming": true,
|
|
247
|
+
"supportsVision": false
|
|
248
|
+
}
|
|
249
|
+
],
|
|
250
|
+
"defaultModel": "agnes-2.5-flash"
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**添加模型**
|
|
255
|
+
```
|
|
256
|
+
POST /api/models
|
|
257
|
+
Content-Type: application/json
|
|
258
|
+
|
|
259
|
+
{
|
|
260
|
+
"id": "custom-model",
|
|
261
|
+
"name": "自定义模型",
|
|
262
|
+
"provider": "openai-compatible",
|
|
263
|
+
"apiBase": "https://api.example.com/v1",
|
|
264
|
+
"apiKey": "sk-xxx",
|
|
265
|
+
"contextWindow": 32000
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
### 7. 模型提供商
|
|
272
|
+
|
|
273
|
+
获取配置的模型提供商列表。
|
|
274
|
+
|
|
275
|
+
**请求**
|
|
276
|
+
```
|
|
277
|
+
GET /api/providers
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**响应** `200 OK`
|
|
281
|
+
```json
|
|
282
|
+
{
|
|
283
|
+
"providers": [
|
|
284
|
+
{
|
|
285
|
+
"id": "agnes",
|
|
286
|
+
"name": "Agnes AI",
|
|
287
|
+
"apiBase": "https://api.agnes-ai.cn/v1",
|
|
288
|
+
"models": ["agnes-2.5-flash"],
|
|
289
|
+
"status": "connected"
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
"id": "siliconflow",
|
|
293
|
+
"name": "硅基流动",
|
|
294
|
+
"apiBase": "https://api.siliconflow.cn/v1",
|
|
295
|
+
"models": ["deepseek-ai/DeepSeek-OCR"],
|
|
296
|
+
"status": "connected"
|
|
297
|
+
}
|
|
298
|
+
]
|
|
299
|
+
}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
### 8. Agent 管理
|
|
305
|
+
|
|
306
|
+
管理 AI Agent 实例。
|
|
307
|
+
|
|
308
|
+
**获取 Agent 列表**
|
|
309
|
+
```
|
|
310
|
+
GET /api/agents
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
**响应** `200 OK`
|
|
314
|
+
```json
|
|
315
|
+
{
|
|
316
|
+
"agents": [
|
|
317
|
+
{
|
|
318
|
+
"id": "agent-001",
|
|
319
|
+
"name": "代码助手",
|
|
320
|
+
"type": "solo",
|
|
321
|
+
"status": "idle",
|
|
322
|
+
"createdAt": "2026-09-01T10:00:00.000Z",
|
|
323
|
+
"lastActive": "2026-09-03T08:00:00.000Z"
|
|
324
|
+
}
|
|
325
|
+
],
|
|
326
|
+
"total": 5
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
**创建 Agent**
|
|
331
|
+
```
|
|
332
|
+
POST /api/agents
|
|
333
|
+
Content-Type: application/json
|
|
334
|
+
|
|
335
|
+
{
|
|
336
|
+
"name": "新 Agent",
|
|
337
|
+
"type": "solo",
|
|
338
|
+
"systemPrompt": "你是一个专业的代码助手",
|
|
339
|
+
"model": "agnes-2.5-flash"
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
**获取单个 Agent**
|
|
344
|
+
```
|
|
345
|
+
GET /api/agents/:id
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
**删除 Agent**
|
|
349
|
+
```
|
|
350
|
+
DELETE /api/agents/:id
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
### 9. 技能管理
|
|
356
|
+
|
|
357
|
+
管理可复用技能。
|
|
358
|
+
|
|
359
|
+
**获取技能列表**
|
|
360
|
+
```
|
|
361
|
+
GET /api/skills
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
**响应** `200 OK`
|
|
365
|
+
```json
|
|
366
|
+
{
|
|
367
|
+
"skills": [
|
|
368
|
+
{
|
|
369
|
+
"id": "skill-summarize",
|
|
370
|
+
"name": "内容摘要",
|
|
371
|
+
"description": "对长文本进行结构化摘要",
|
|
372
|
+
"trigger": "摘要|总结|概括",
|
|
373
|
+
"tags": ["文本处理", "效率"],
|
|
374
|
+
"useCount": 12,
|
|
375
|
+
"builtin": true,
|
|
376
|
+
"createdAt": "2026-09-01T00:00:00.000Z"
|
|
377
|
+
}
|
|
378
|
+
],
|
|
379
|
+
"total": 4
|
|
380
|
+
}
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
**安装技能**
|
|
384
|
+
```
|
|
385
|
+
POST /api/skills
|
|
386
|
+
Content-Type: application/json
|
|
387
|
+
|
|
388
|
+
{
|
|
389
|
+
"name": "新技能",
|
|
390
|
+
"description": "技能描述",
|
|
391
|
+
"trigger": "触发词",
|
|
392
|
+
"prompt": "提示词模板,{{content}}表示用户输入",
|
|
393
|
+
"tags": ["自定义"]
|
|
394
|
+
}
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
**删除技能**
|
|
398
|
+
```
|
|
399
|
+
DELETE /api/skills/:id
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
|
|
404
|
+
### 10. 工具列表
|
|
405
|
+
|
|
406
|
+
获取可用工具列表。
|
|
407
|
+
|
|
408
|
+
**请求**
|
|
409
|
+
```
|
|
410
|
+
GET /api/tools
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
**响应** `200 OK`
|
|
414
|
+
```json
|
|
415
|
+
{
|
|
416
|
+
"tools": [
|
|
417
|
+
{ "name": "web_search", "description": "网页搜索", "enabled": true },
|
|
418
|
+
{ "name": "file_read", "description": "文件读取", "enabled": true },
|
|
419
|
+
{ "name": "shell_exec", "description": "Shell 执行", "enabled": true },
|
|
420
|
+
{ "name": "browser", "description": "浏览器自动化", "enabled": true },
|
|
421
|
+
{ "name": "tts", "description": "文字转语音", "enabled": true }
|
|
422
|
+
],
|
|
423
|
+
"total": 8
|
|
424
|
+
}
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
---
|
|
428
|
+
|
|
429
|
+
### 11. 任务队列
|
|
430
|
+
|
|
431
|
+
管理异步任务队列。
|
|
432
|
+
|
|
433
|
+
**获取任务列表**
|
|
434
|
+
```
|
|
435
|
+
GET /api/tasks?status=pending&limit=20&offset=0
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
**查询参数**
|
|
439
|
+
|
|
440
|
+
| 参数 | 类型 | 说明 |
|
|
441
|
+
|------|------|------|
|
|
442
|
+
| status | string | 筛选状态(pending/running/completed/failed) |
|
|
443
|
+
| limit | number | 每页数量(默认20) |
|
|
444
|
+
| offset | number | 偏移量(默认0) |
|
|
445
|
+
|
|
446
|
+
**响应** `200 OK`
|
|
447
|
+
```json
|
|
448
|
+
{
|
|
449
|
+
"tasks": [
|
|
450
|
+
{
|
|
451
|
+
"id": "task-001",
|
|
452
|
+
"type": "chat",
|
|
453
|
+
"status": "completed",
|
|
454
|
+
"progress": 100,
|
|
455
|
+
"createdAt": "2026-09-03T10:00:00.000Z",
|
|
456
|
+
"completedAt": "2026-09-03T10:00:05.000Z",
|
|
457
|
+
"result": { "summary": "任务完成" }
|
|
458
|
+
}
|
|
459
|
+
],
|
|
460
|
+
"total": 98,
|
|
461
|
+
"pending": 0,
|
|
462
|
+
"running": 0
|
|
463
|
+
}
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
**创建任务**
|
|
467
|
+
```
|
|
468
|
+
POST /api/tasks
|
|
469
|
+
Content-Type: application/json
|
|
470
|
+
|
|
471
|
+
{
|
|
472
|
+
"type": "chat",
|
|
473
|
+
"input": "你好",
|
|
474
|
+
"model": "agnes-2.5-flash"
|
|
475
|
+
}
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
**获取任务状态**
|
|
479
|
+
```
|
|
480
|
+
GET /api/tasks/:id
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
**取消任务**
|
|
484
|
+
```
|
|
485
|
+
POST /api/tasks/:id/cancel
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
**删除任务**
|
|
489
|
+
```
|
|
490
|
+
DELETE /api/tasks/:id
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
---
|
|
494
|
+
|
|
495
|
+
### 12. 知识库
|
|
496
|
+
|
|
497
|
+
管理知识库文档。
|
|
498
|
+
|
|
499
|
+
**获取文档列表**
|
|
500
|
+
```
|
|
501
|
+
GET /api/knowledge
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
**响应** `200 OK`
|
|
505
|
+
```json
|
|
506
|
+
{
|
|
507
|
+
"documents": [
|
|
508
|
+
{
|
|
509
|
+
"id": "doc-001",
|
|
510
|
+
"title": "飞虹 Code 使用指南",
|
|
511
|
+
"type": "markdown",
|
|
512
|
+
"size": 10240,
|
|
513
|
+
"tags": ["指南", "使用"],
|
|
514
|
+
"createdAt": "2026-09-01T00:00:00.000Z"
|
|
515
|
+
}
|
|
516
|
+
],
|
|
517
|
+
"total": 14
|
|
518
|
+
}
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
**上传文档**
|
|
522
|
+
```
|
|
523
|
+
POST /api/knowledge
|
|
524
|
+
Content-Type: multipart/form-data
|
|
525
|
+
|
|
526
|
+
file: <文件>
|
|
527
|
+
title: 文档标题
|
|
528
|
+
tags: ["标签1","标签2"]
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
**搜索知识库**
|
|
532
|
+
```
|
|
533
|
+
GET /api/knowledge/search?q=关键词
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
**删除文档**
|
|
537
|
+
```
|
|
538
|
+
DELETE /api/knowledge/:id
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
---
|
|
542
|
+
|
|
543
|
+
### 13. 插件管理
|
|
544
|
+
|
|
545
|
+
管理系统插件。
|
|
546
|
+
|
|
547
|
+
**获取插件列表**
|
|
548
|
+
```
|
|
549
|
+
GET /api/plugins
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
**响应** `200 OK`
|
|
553
|
+
```json
|
|
554
|
+
{
|
|
555
|
+
"plugins": [
|
|
556
|
+
{
|
|
557
|
+
"id": "plugin-001",
|
|
558
|
+
"name": "示例插件",
|
|
559
|
+
"version": "1.0.0",
|
|
560
|
+
"description": "插件描述",
|
|
561
|
+
"enabled": true,
|
|
562
|
+
"installedAt": "2026-09-01T00:00:00.000Z"
|
|
563
|
+
}
|
|
564
|
+
],
|
|
565
|
+
"total": 0
|
|
566
|
+
}
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
**启用/禁用插件**
|
|
570
|
+
```
|
|
571
|
+
POST /api/plugins/:id/toggle
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
**卸载插件**
|
|
575
|
+
```
|
|
576
|
+
DELETE /api/plugins/:id
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
---
|
|
580
|
+
|
|
581
|
+
## 错误响应
|
|
582
|
+
|
|
583
|
+
### 错误格式
|
|
584
|
+
|
|
585
|
+
所有错误响应遵循统一格式:
|
|
586
|
+
|
|
587
|
+
```json
|
|
588
|
+
{
|
|
589
|
+
"error": "错误描述",
|
|
590
|
+
"code": 400,
|
|
591
|
+
"details": {}
|
|
592
|
+
}
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
### 常见错误码
|
|
596
|
+
|
|
597
|
+
| 状态码 | 说明 | 原因 |
|
|
598
|
+
|--------|------|------|
|
|
599
|
+
| 400 | Bad Request | 请求参数错误 |
|
|
600
|
+
| 401 | Unauthorized | 未携带或 Token 无效 |
|
|
601
|
+
| 403 | Forbidden | 无权限访问 |
|
|
602
|
+
| 404 | Not Found | 资源不存在 |
|
|
603
|
+
| 409 | Conflict | 资源冲突 |
|
|
604
|
+
| 429 | Too Many Requests | 请求频率超限 |
|
|
605
|
+
| 500 | Internal Server Error | 服务器内部错误 |
|
|
606
|
+
| 503 | Service Unavailable | 服务暂不可用 |
|
|
607
|
+
|
|
608
|
+
### 认证错误示例
|
|
609
|
+
|
|
610
|
+
```http
|
|
611
|
+
HTTP/1.1 401 Unauthorized
|
|
612
|
+
Content-Type: application/json
|
|
613
|
+
|
|
614
|
+
{
|
|
615
|
+
"error": "Unauthorized",
|
|
616
|
+
"code": 401
|
|
617
|
+
}
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
---
|
|
621
|
+
|
|
622
|
+
## 数据模型
|
|
623
|
+
|
|
624
|
+
### Health
|
|
625
|
+
|
|
626
|
+
```typescript
|
|
627
|
+
interface Health {
|
|
628
|
+
ok: boolean;
|
|
629
|
+
product: string;
|
|
630
|
+
version: string;
|
|
631
|
+
signature: string;
|
|
632
|
+
enterprise: boolean;
|
|
633
|
+
lang: string;
|
|
634
|
+
wechat: 'disabled' | 'enabled';
|
|
635
|
+
feishu: 'disabled' | 'enabled';
|
|
636
|
+
yuanbao: 'disabled' | 'enabled';
|
|
637
|
+
time: string; // ISO 8601
|
|
638
|
+
}
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
### Model
|
|
642
|
+
|
|
643
|
+
```typescript
|
|
644
|
+
interface Model {
|
|
645
|
+
id: string;
|
|
646
|
+
name: string;
|
|
647
|
+
provider: string;
|
|
648
|
+
apiBase: string;
|
|
649
|
+
contextWindow: number;
|
|
650
|
+
maxOutput: number;
|
|
651
|
+
supportsStreaming: boolean;
|
|
652
|
+
supportsVision: boolean;
|
|
653
|
+
}
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
### Skill
|
|
657
|
+
|
|
658
|
+
```typescript
|
|
659
|
+
interface Skill {
|
|
660
|
+
id: string;
|
|
661
|
+
name: string;
|
|
662
|
+
description: string;
|
|
663
|
+
trigger: string; // | 分隔多个触发词
|
|
664
|
+
prompt: string; // 支持 {{content}} {{变量}}
|
|
665
|
+
tools: string[];
|
|
666
|
+
tags: string[];
|
|
667
|
+
version: string;
|
|
668
|
+
useCount: number;
|
|
669
|
+
builtin?: boolean;
|
|
670
|
+
autoExtracted?: boolean;
|
|
671
|
+
llmExtracted?: boolean;
|
|
672
|
+
createdAt: string;
|
|
673
|
+
improvedAt?: string;
|
|
674
|
+
}
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
### Task
|
|
678
|
+
|
|
679
|
+
```typescript
|
|
680
|
+
interface Task {
|
|
681
|
+
id: string;
|
|
682
|
+
type: string;
|
|
683
|
+
status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
684
|
+
progress: number; // 0-100
|
|
685
|
+
input: any;
|
|
686
|
+
result?: any;
|
|
687
|
+
error?: string;
|
|
688
|
+
createdAt: string;
|
|
689
|
+
startedAt?: string;
|
|
690
|
+
completedAt?: string;
|
|
691
|
+
}
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
### Agent
|
|
695
|
+
|
|
696
|
+
```typescript
|
|
697
|
+
interface Agent {
|
|
698
|
+
id: string;
|
|
699
|
+
name: string;
|
|
700
|
+
type: 'solo' | 'orchestrator' | 'team';
|
|
701
|
+
status: 'idle' | 'running' | 'error';
|
|
702
|
+
systemPrompt?: string;
|
|
703
|
+
model?: string;
|
|
704
|
+
createdAt: string;
|
|
705
|
+
lastActive?: string;
|
|
706
|
+
}
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
---
|
|
710
|
+
|
|
711
|
+
## 示例代码
|
|
712
|
+
|
|
713
|
+
### Node.js 示例
|
|
714
|
+
|
|
715
|
+
```javascript
|
|
716
|
+
const BASE_URL = 'http://localhost:8080';
|
|
717
|
+
const TOKEN = 'your-fh-web-token';
|
|
718
|
+
|
|
719
|
+
async function api(path, options = {}) {
|
|
720
|
+
const res = await fetch(`${BASE_URL}${path}`, {
|
|
721
|
+
...options,
|
|
722
|
+
headers: {
|
|
723
|
+
'Content-Type': 'application/json',
|
|
724
|
+
'Authorization': `Bearer ${TOKEN}`,
|
|
725
|
+
...options.headers
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
if (!res.ok) throw new Error(`API Error: ${res.status}`);
|
|
729
|
+
return res.json();
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
// 健康检查(无需认证)
|
|
733
|
+
const health = await fetch(`${BASE_URL}/api/health`).then(r => r.json());
|
|
734
|
+
console.log('版本:', health.version);
|
|
735
|
+
|
|
736
|
+
// 获取任务列表(需认证)
|
|
737
|
+
const tasks = await api('/api/tasks?status=completed&limit=10');
|
|
738
|
+
console.log('任务数:', tasks.total);
|
|
739
|
+
|
|
740
|
+
// 创建任务
|
|
741
|
+
const newTask = await api('/api/tasks', {
|
|
742
|
+
method: 'POST',
|
|
743
|
+
body: JSON.stringify({ type: 'chat', input: '你好' })
|
|
744
|
+
});
|
|
745
|
+
console.log('任务ID:', newTask.id);
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
### Python 示例
|
|
749
|
+
|
|
750
|
+
```python
|
|
751
|
+
import requests
|
|
752
|
+
|
|
753
|
+
BASE_URL = 'http://localhost:8080'
|
|
754
|
+
TOKEN = 'your-fh-web-token'
|
|
755
|
+
HEADERS = {'Authorization': f'Bearer {TOKEN}'}
|
|
756
|
+
|
|
757
|
+
# 健康检查
|
|
758
|
+
health = requests.get(f'{BASE_URL}/api/health').json()
|
|
759
|
+
print(f"版本: {health['version']}")
|
|
760
|
+
|
|
761
|
+
# 获取模型列表
|
|
762
|
+
models = requests.get(f'{BASE_URL}/api/models', headers=HEADERS).json()
|
|
763
|
+
print(f"模型数: {len(models['models'])}")
|
|
764
|
+
|
|
765
|
+
# 创建技能
|
|
766
|
+
skill = requests.post(
|
|
767
|
+
f'{BASE_URL}/api/skills',
|
|
768
|
+
headers=HEADERS,
|
|
769
|
+
json={
|
|
770
|
+
'name': '代码优化',
|
|
771
|
+
'description': '优化代码性能和可读性',
|
|
772
|
+
'trigger': '优化代码|代码优化|性能优化',
|
|
773
|
+
'prompt': '请优化以下代码,提升性能和可读性:\n\n{{content}}'
|
|
774
|
+
}
|
|
775
|
+
).json()
|
|
776
|
+
print(f"技能ID: {skill.get('id')}")
|
|
777
|
+
```
|
|
778
|
+
|
|
779
|
+
### cURL 示例
|
|
780
|
+
|
|
781
|
+
```bash
|
|
782
|
+
# 健康检查
|
|
783
|
+
curl http://localhost:8080/api/health
|
|
784
|
+
|
|
785
|
+
# 获取任务列表
|
|
786
|
+
curl -X GET http://localhost:8080/api/tasks \
|
|
787
|
+
-H "Authorization: Bearer <TOKEN>"
|
|
788
|
+
|
|
789
|
+
# 创建任务
|
|
790
|
+
curl -X POST http://localhost:8080/api/tasks \
|
|
791
|
+
-H "Authorization: Bearer <TOKEN>" \
|
|
792
|
+
-H "Content-Type: application/json" \
|
|
793
|
+
-d '{"type":"chat","input":"你好"}'
|
|
794
|
+
|
|
795
|
+
# 安装技能
|
|
796
|
+
curl -X POST http://localhost:8080/api/skills \
|
|
797
|
+
-H "Authorization: Bearer <TOKEN>" \
|
|
798
|
+
-H "Content-Type: application/json" \
|
|
799
|
+
-d '{"name":"新技能","description":"描述","trigger":"触发词","prompt":"模板"}'
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
---
|
|
803
|
+
|
|
804
|
+
## 速率限制
|
|
805
|
+
|
|
806
|
+
| 接口类型 | 限制 |
|
|
807
|
+
|----------|------|
|
|
808
|
+
| 公开接口(/api/health) | 无限制 |
|
|
809
|
+
| 受保护接口 | 100 次/分钟 |
|
|
810
|
+
| 文件上传 | 10 次/分钟,单文件最大 50MB |
|
|
811
|
+
|
|
812
|
+
超出限制返回 `429 Too Many Requests`。
|
|
813
|
+
|
|
814
|
+
---
|
|
815
|
+
|
|
816
|
+
## 变更日志
|
|
817
|
+
|
|
818
|
+
| 版本 | 日期 | 变更 |
|
|
819
|
+
|------|------|------|
|
|
820
|
+
| v7.9.1 | 2026-09-03 | 新增 favicon/robots、LLM 辅助技能提炼、集成测试框架 |
|
|
821
|
+
| v7.9.0 | 2026-09-03 | Hermes Agent 完整框架(持久记忆+自演化技能+自动化调度+工具集) |
|
|
822
|
+
| v7.8.0 | 2026-09-02 | 免密网络层(Keyless Web Tier)+ Hermes 记忆基础 |
|
|
823
|
+
| v7.6.0 | 2026-08-30 | 基础版本,20个子系统 |
|
|
824
|
+
|
|
825
|
+
---
|
|
826
|
+
|
|
827
|
+
*本文档随版本更新而维护,最新版本以项目仓库 docs/ 目录为准。*
|