Skip to content

Commit b12852d

Browse files
committed
docs: 修正服务器架构说明和连接方式
1 parent 7b6dcaf commit b12852d

1 file changed

Lines changed: 44 additions & 54 deletions

File tree

开发备忘录.md

Lines changed: 44 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -7,75 +7,65 @@
77

88
## ✅ AI 全代理模式 + 版本自动检查(2026-04-01,v1.5.4)
99

10-
### 背景
10+
### 架构(已确认正确)
1111

12-
引擎打包成 exe 后没有 `.env` 文件,`TP_AI_API_KEY` 未配置 → AI 诊断功能不可用。同时也需要一个机制让后端切换 AI 模型而不要求用户更新插件。
12+
**两台服务器,职责不同:**
1313

14-
### 架构设计
14+
| 服务器 | IP | 域名 | 用途 |
15+
|--------|-----|------|------|
16+
| xinzaoai.com | 115.159.71.197 | xinzaoai.com | 官网 + 文件下载(engine.exe, vsix) |
17+
| TestPilot AI | 82.157.97.179 | testpilot.xinzaoai.com | Python FastAPI 引擎 + AI 代理 |
1518

16-
```
17-
用户引擎(exe)
18-
有 TP_AI_API_KEY → 直连豆包(开发模式,本地.env)
19-
无 TP_AI_API_KEY → ProxyAIClient → xinzaoai.com/api/ai/proxy → 豆包
20-
↑ 后端改 TP_ARK_MODEL/TP_ARK_API_KEY 即可切换模型,无需用户更新
21-
```
19+
**SSH 连接方式:**
20+
```bash
21+
# TestPilot AI 服务器(主服务器)
22+
ssh -i "D:\Projects\TestPilotAI\key\TestPilotAi.pem" ubuntu@82.157.97.179
2223

23-
### 修改文件
24+
# xinzaoai.com 官网服务器(仅用于上传下载文件)
25+
scp -i "D:\Projects\xinzao\key\xinzao_ai.pem" ... ubuntu@115.159.71.197:/var/www/xinzao/downloads/
26+
```
2427

25-
**引擎端:**
26-
- `src/core/ai_client.py`:末尾新增 `ProxyAIClient` 类,接口与 `AIClient` 完全相同
27-
- 代理地址:`https://xinzaoai.com/api/ai/proxy`
28-
- 鉴权:`X-Engine-Secret: testpilot-engine-secret-2026`
29-
- `src/app.py`:无 `TP_AI_API_KEY` 时自动使用 `ProxyAIClient`
28+
**服务器关键路径(82.157.97.179):**
29+
- 应用目录:`/opt/testpilot/app/`
30+
- 环境变量:`/opt/testpilot/app/.env`
31+
- 日志:`/opt/testpilot/logs/`
32+
- systemd 服务名:`testpilot-api.service`
33+
- 重启命令:`sudo systemctl restart testpilot-api`
3034

31-
**服务器端(`xinzao/server/index.js`):**
32-
- `bodyParser.json({ limit: '10mb' })`:支持截图 base64 大请求体
33-
- `GET /api/version/check`:返回 `{ latest, minimum, model, changelog }`
34-
- `POST /api/ai/proxy`:验证 `X-Engine-Secret` → 转发到豆包 → 返回 OpenAI 格式响应
35-
- 环境变量:`TP_ARK_API_KEY``TP_ARK_BASE_URL``TP_ARK_MODEL``TP_ENGINE_SECRET`
35+
### 系统架构
3636

37-
**插件端(`extension/src/engineManager.ts`):**
38-
- `_checkVersion()` 方法:启动时异步调 `/api/version/check`
39-
- 低于 `minimum` → 弹出模态强制更新提示
40-
- 低于 `latest` → 弱提示,用户可选择忽略
37+
```
38+
用户引擎(本地 exe)
39+
有 TP_AI_API_KEY → 直连豆包(开发模式)
40+
无 TP_AI_API_KEY → ProxyAIClient
41+
42+
testpilot.xinzaoai.com/api/v1/ai/proxy
43+
↓(服务器有 API Key)
44+
豆包 AI(方舟平台)
45+
```
4146

42-
### 服务器部署待做
47+
**切换 AI 模型**:SSH 改 `/opt/testpilot/app/.env``TP_AI_MODEL`,重启服务,用户无感知。
4348

44-
SSH 被 fail2ban 临时封锁,手动解封后执行:
49+
### 修改文件
4550

46-
```bash
47-
# 1. 上传 server/index.js
48-
scp -i "D:\Projects\xinzao\key\xinzao_ai.pem" D:\Projects\xinzao\server\index.js ubuntu@115.159.71.197:/home/ubuntu/xinzao/server/
49-
50-
# 2. 设置服务器环境变量
51-
ssh ubuntu@115.159.71.197
52-
cat >> /home/ubuntu/xinzao/server/.env << 'EOF'
53-
TP_ARK_API_KEY=98c755a5-2ae7-47b1-8904-a990482cfab2
54-
TP_ARK_BASE_URL=https://ark.cn-beijing.volces.com/api/v3
55-
TP_ARK_MODEL=doubao-seed-1-8-251228
56-
TP_ENGINE_SECRET=testpilot-engine-secret-2026
57-
EOF
58-
59-
# 3. 重启服务
60-
pm2 restart xinzao-server # 或 node index.js
61-
62-
# 4. 上传新 VSIX
63-
scp testpilot-ai-1.5.4.vsix ubuntu@115.159.71.197:/var/www/xinzao/downloads/
64-
```
51+
- `src/api/routes.py`:新增 `GET /version/check``POST /ai/proxy` 路由
52+
- `src/core/ai_client.py`:新增 `ProxyAIClient`,代理地址 `testpilot.xinzaoai.com/api/v1/ai/proxy`
53+
- `src/app.py`:无 Key 时自动使用 `ProxyAIClient`
54+
- `extension/src/engineManager.ts`:启动时调版本检查,强制/弱提示更新
6555

66-
### 版本管理说明
56+
### 线上端点(已验证 HTTP 200)
6757

68-
服务器 `index.js` 里的两个常量控制版本策略:
69-
```javascript
70-
const TP_LATEST_VERSION = '1.5.4'; // 弱提示更新
71-
const TP_MINIMUM_VERSION = '1.5.0'; // 低于此版本强制更新
72-
```
73-
**切换 AI 模型**:只需 SSH 改服务器 `.env``TP_ARK_MODEL`,重启服务,用户无感知。
58+
| 端点 | URL |
59+
|------|-----|
60+
| 版本检查 | `https://testpilot.xinzaoai.com/api/v1/version/check` |
61+
| AI 代理 | `https://testpilot.xinzaoai.com/api/v1/ai/proxy` |
62+
| 引擎下载(Windows) | `https://xinzaoai.com/downloads/testpilot-engine-windows.exe` |
63+
| 插件下载 | `https://xinzaoai.com/downloads/testpilot-ai-1.5.4.vsix` |
7464

7565
### Git 信息
7666

77-
- Commit: `4b82bc6` — "feat: AI全代理模式 + 版本自动检查(v1.5.4)"
78-
- Tag: `v1.5.4`
67+
- v1.5.4 commit: `7b6dcaf`
68+
- Tag: `v1.5.4`(含版本检查 + AI 代理)
7969

8070
---
8171

0 commit comments

Comments
 (0)