Skip to content

Commit c377b03

Browse files
committed
Add link to Chinese documentation
1 parent 41ee7b2 commit c377b03

2 files changed

Lines changed: 197 additions & 0 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# welinker
22

3+
中文文档: [docs/README.zh-CN.md](docs/README.zh-CN.md)
4+
35
Rust implementation of a WeChat iLink to AI Agent bridge, based on the architecture in `../weclaw`.
46

57
## Features

docs/README.zh-CN.md

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
# welinker 中文文档
2+
3+
welinker 是一个用 Rust 实现的 WeChat iLink 到 AI Agent 的桥接工具。它可以通过微信扫码登录,监听已保存账号的消息,并把消息路由到本地或 HTTP 形式的 AI Agent。
4+
5+
## 功能概览
6+
7+
- 通过 iLink 扫码登录微信账号。
8+
- 对已保存账号进行长轮询消息监听。
9+
- 支持 ACP、CLI、OpenAI 兼容 HTTP Agent 路由。
10+
- 内置聊天命令:`/info``/help``/new``/clear``/cwd``/agent message`
11+
- 内置别名:`/cc``/cx``/oc``/zc``/cs``/km``/gm``/ocd``/pi``/cp``/dr``/if``/kr``/qw``/hm``/hh`
12+
- 支持通过 CLI 和 `POST /api/send` 发送文本与媒体消息。
13+
- 内置 WebUI,可查看账号状态、手动发送消息、调整配置。
14+
- 配置 `save_dir` 后可保存收到的图片、语音、文件和视频。
15+
- 支持多账号列表、移除账号、指定账号发送消息。
16+
- 支持后台进程命令:`start``status``stop``restart`
17+
18+
运行时文件默认保存在 `~/.welinker`
19+
20+
- `~/.welinker/config.json`
21+
- `~/.welinker/accounts/*.json`
22+
- `~/.welinker/welinker.log`
23+
- `~/.welinker/welinker.pid`
24+
25+
## 安装
26+
27+
构建依赖:
28+
29+
- Rust/Cargo
30+
- Node.js/npm,用于构建内置 WebUI
31+
32+
从当前源码目录安装:
33+
34+
```bash
35+
./install.sh
36+
```
37+
38+
默认安装位置是 `~/.local/bin/welinker`。如需指定安装前缀:
39+
40+
```bash
41+
./install.sh --prefix /usr/local
42+
```
43+
44+
使用 Homebrew 辅助本地安装:
45+
46+
```bash
47+
scripts/install-homebrew.sh
48+
```
49+
50+
该脚本会安装缺失的 `rust``node` formula,然后把 `welinker` 安装到 `$(brew --prefix)/bin`
51+
52+
也可以从本仓库的 Homebrew formula 安装:
53+
54+
```bash
55+
brew install --HEAD ./Formula/welinker.rb
56+
```
57+
58+
## 快速开始
59+
60+
开发环境中可以直接使用 `cargo run`
61+
62+
```bash
63+
cargo run -- login
64+
cargo run -- start --foreground
65+
```
66+
67+
安装后可以直接使用 `welinker`
68+
69+
```bash
70+
welinker login
71+
welinker start --foreground
72+
```
73+
74+
首次启动时,如果本地没有已保存的微信账号,`start` 会自动进入登录流程。`start` 还会检测常见本地 Agent,并把检测到的配置写入 `~/.welinker/config.json`
75+
76+
前台运行或后台服务启动后,可打开 WebUI:
77+
78+
```text
79+
http://127.0.0.1:18011/
80+
```
81+
82+
如果只想打开 WebUI 和本地 Agent 聊天,不触发微信扫码登录:
83+
84+
```bash
85+
welinker start --foreground --web-only
86+
```
87+
88+
注意:发送微信消息仍然需要至少一个已登录账号。
89+
90+
## 常用命令
91+
92+
```bash
93+
welinker login
94+
welinker start --foreground
95+
welinker start --foreground --web-only
96+
welinker start
97+
welinker status
98+
welinker stop
99+
welinker restart
100+
welinker version
101+
welinker send --to "user_id@im.wechat" --text "hello"
102+
welinker send --account "bot_id@im.bot" --to "user_id@im.wechat" --text "hello"
103+
welinker accounts list
104+
welinker accounts remove "bot_id@im.bot"
105+
```
106+
107+
开发时也可以把上面的 `welinker` 替换成 `cargo run --`
108+
109+
## 配置
110+
111+
主配置文件位于 `~/.welinker/config.json`。示例:
112+
113+
```json
114+
{
115+
"api_addr": "127.0.0.1:18011",
116+
"save_dir": "/Users/me/WeChat",
117+
"route_tag": "optional-sk-route-tag",
118+
"default_agent": "gemini",
119+
"agents": {}
120+
}
121+
```
122+
123+
可用环境变量覆盖:
124+
125+
- `WELINKER_API_ADDR`
126+
- `WELINKER_SAVE_DIR`
127+
- `WELINKER_ROUTE_TAG`
128+
- `WELINKER_DEFAULT_AGENT`
129+
- `WELINKER_HERMES_HTTP_URL`
130+
- `WELINKER_HERMES_HTTP_KEY`
131+
- `WELINKER_HERMES_HTTP_MODEL`
132+
- `WELINKER_ALLOW_REMOTE_API=1` 允许把 `api_addr` 绑定到非本机回环地址。
133+
134+
通过 WebUI 保存的配置会立即写入磁盘。默认 Agent、别名、API 地址、保存目录等运行时配置不会热重载,修改后需要重启 welinker 才会生效。
135+
136+
## HTTP API
137+
138+
内置 API 服务默认监听 `127.0.0.1:18011`
139+
140+
- `GET /api/status`
141+
- `GET /api/accounts`
142+
- `POST /api/send`,多账号登录时可传入 `account_id`
143+
- `POST /api/chat`,不经过微信登录,直接向本地配置的 Agent 发送消息。
144+
- `GET /api/config`,读取 `~/.welinker/config.json`
145+
- `PUT /api/config`,校验并保存完整配置 JSON。
146+
147+
`PUT /api/config` 成功后会返回:
148+
149+
```json
150+
{
151+
"reload_required": true
152+
}
153+
```
154+
155+
## 安全说明
156+
157+
`GET /api/config``PUT /api/config``POST /api/chat` 会暴露敏感的本地能力:配置文件可能包含 Agent API key,聊天接口也可以调用本地 Agent。因此 API 服务默认拒绝绑定到非回环地址。
158+
159+
安全默认配置:
160+
161+
```json
162+
{
163+
"api_addr": "127.0.0.1:18011"
164+
}
165+
```
166+
167+
如确需在局域网或远程环境访问,需要显式开启:
168+
169+
```bash
170+
WELINKER_ALLOW_REMOTE_API=1 welinker start --foreground --api-addr 0.0.0.0:18011
171+
```
172+
173+
只应在可信网络或自有访问控制之后使用远程绑定。
174+
175+
## 排错
176+
177+
后台模式日志位于:
178+
179+
```text
180+
~/.welinker/welinker.log
181+
```
182+
183+
如果端口已被占用或 API 服务绑定失败,前台模式会在 tracing 日志中输出错误;后台模式会写入 `~/.welinker/welinker.log`,常见日志格式如下:
184+
185+
```text
186+
api server stopped error=...
187+
```
188+
189+
如果保存 WebUI 配置或本地聊天失败,先检查 API 是否仍在运行:
190+
191+
```bash
192+
welinker status
193+
```
194+
195+
然后确认 `api_addr` 是否仍为本机可访问地址,并在修改运行时配置后重启 welinker。

0 commit comments

Comments
 (0)