@foxden-app/foxclaw 0.5.31 → 0.5.33
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/CHANGELOG.md +22 -0
- package/README.md +9 -1
- package/README_EN.md +8 -0
- package/dist/channels/bridge_messaging_router.d.ts +2 -0
- package/dist/channels/bridge_messaging_router.js +12 -0
- package/dist/channels/telegram/telegram_messaging_port.d.ts +2 -0
- package/dist/channels/telegram/telegram_messaging_port.js +9 -0
- package/dist/controller/controller.d.ts +3 -0
- package/dist/controller/controller.js +124 -13
- package/dist/controller/presentation.js +1 -6
- package/dist/i18n.d.ts +2 -0
- package/dist/i18n.js +3 -0
- package/dist/launchd.d.ts +18 -0
- package/dist/launchd.js +75 -0
- package/dist/main.js +78 -58
- package/dist/telegram/gateway.d.ts +10 -0
- package/dist/telegram/gateway.js +34 -0
- package/dist/telegram/html.d.ts +8 -0
- package/dist/telegram/html.js +31 -0
- package/dist/telegram/rich.d.ts +13 -0
- package/dist/telegram/rich.js +12 -0
- package/docs/agent-assisted-install.md +1 -0
- package/docs/install-for-beginners.md +13 -2
- package/docs/telegram-rich-messages.md +99 -0
- package/docs/troubleshooting.md +32 -2
- package/docs/user-manual.md +12 -1
- package/docs/zh/agent-assisted-install.md +1 -0
- package/docs/zh/install-for-beginners.md +12 -1
- package/docs/zh/telegram-rich-messages.md +125 -0
- package/docs/zh/troubleshooting.md +32 -2
- package/docs/zh/user-manual.md +12 -1
- package/package.json +2 -1
- package/skills/foxclaw/SKILL.md +2 -2
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Telegram Rich Message 适配专项检查
|
|
2
|
+
|
|
3
|
+
检查日期:2026-06-16。依据:Telegram Bot API Rich Messages 文档,尤其是 `RichMessage`、`sendRichMessage`、`sendRichMessageDraft` 与 Rich Message Formatting Options。
|
|
4
|
+
|
|
5
|
+
官方入口:
|
|
6
|
+
|
|
7
|
+
- https://core.telegram.org/bots/api#rich-message-formatting-options
|
|
8
|
+
- https://core.telegram.org/bots/api#sendrichmessage
|
|
9
|
+
- https://core.telegram.org/bots/api#sendrichmessagedraft
|
|
10
|
+
|
|
11
|
+
## 结论
|
|
12
|
+
|
|
13
|
+
FoxClaw 有明确收益,并已开始把 RichMessage 用在适合看效果、可安全回退的 Telegram 功能面。
|
|
14
|
+
|
|
15
|
+
现在的策略是:Telegram 优先尝试 `sendRichMessage`,失败时回退到既有 Telegram HTML;微信继续使用 HTML/plain 回退。Bot API 10.1 的 Rich Message 先用于可观察的诊断和结构化长文本,再逐步扩展到状态、auth/quota 和 AI draft streaming。
|
|
16
|
+
|
|
17
|
+
本次已先落地低风险增强:
|
|
18
|
+
|
|
19
|
+
- 新增 `src/telegram/html.ts`,统一 Telegram HTML 转义和常用标签生成。
|
|
20
|
+
- 新增 `src/telegram/rich.ts`,并在 `TelegramGateway` / `TelegramMessagingPort` / `BridgeMessagingRouter` 接入 `sendRichMessage` / rich HTML 发送链路。
|
|
21
|
+
- 新增 `/rich` 诊断命令,用来在真实 Telegram 客户端查看 heading、table、details、pre/code、list 的 RichMessage 效果。
|
|
22
|
+
- `/diff` 改为优先发送 RichMessage:标题用 heading,diff 内容放入 details + pre/code;rich 发送失败时回退到 HTML 加粗标题和可展开引用块。
|
|
23
|
+
- 现有 CLI 观察消息和归档工具批次状态复用同一套 HTML helper。
|
|
24
|
+
|
|
25
|
+
## 官方能力摘录
|
|
26
|
+
|
|
27
|
+
Bot API 10.1 新增 Rich Messages:
|
|
28
|
+
|
|
29
|
+
- `RichText*`:bold、italic、underline、strikethrough、spoiler、code、marked、math、url、email、phone、mention、hashtag、bot command、anchor/reference 等。
|
|
30
|
+
- `RichBlock*`:paragraph、heading、pre、footer、divider、math block、anchor、list、blockquote、pullquote、collage、slideshow、table、details、map、photo/video/audio/animation/voice、thinking。
|
|
31
|
+
- `sendRichMessage`:发送完整 rich message。
|
|
32
|
+
- `sendRichMessageDraft`:在私聊里流式发送临时 rich draft;draft 是短暂预览,最终仍要用 `sendRichMessage` 发送完整消息。
|
|
33
|
+
- `editMessageText` 新增 `rich_message` 参数,可编辑 rich message。
|
|
34
|
+
|
|
35
|
+
Rich Message HTML 还支持 `<details>`、`<table>`、`<pre><code class="language-...">`、`<ul>/<ol>`、`<hr/>`、`<tg-math-block>`、`<tg-thinking>` 等标签。`RichBlockThinking` 只能用于 `sendRichMessageDraft`。
|
|
36
|
+
|
|
37
|
+
## FoxClaw 现状
|
|
38
|
+
|
|
39
|
+
当前 Telegram 发送层:
|
|
40
|
+
|
|
41
|
+
- `src/telegram/gateway.ts`:`sendMessage`、`sendHtmlMessage`、`sendRichMessage`、`editMessage`、`editHtmlMessage`、`editRichMessage` 已接入;HTML 普通消息使用 `parse_mode=HTML`,rich 消息使用 `rich_message.html`。
|
|
42
|
+
- `src/channels/telegram/telegram_messaging_port.ts`:对 controller 暴露 plain/html/rich-html send/edit 和 `sendDraft`。
|
|
43
|
+
- `src/telegram/rendering.ts`:默认 `segmented_stream`;`draft_stream` 仍是旧 `sendMessageDraft` 文本 draft。
|
|
44
|
+
- `src/controller/controller.ts`:状态卡、审批、工具批次、diff、auth、MCP、插件、文件等功能面都在这里汇总发送。
|
|
45
|
+
- `src/controller/presentation.ts`:`/threads`、`/setup`、模型/权限面板已经使用 Telegram HTML。
|
|
46
|
+
|
|
47
|
+
已经使用的格式能力:
|
|
48
|
+
|
|
49
|
+
- `/threads`、`/setup` 等面板:加粗、code、HTML escape。
|
|
50
|
+
- CLI 观察消息:`<pre>`。
|
|
51
|
+
- 归档工具批次状态:`<blockquote expandable>`。
|
|
52
|
+
- 本次增强后的 `/diff`:加粗标题和可展开引用块。
|
|
53
|
+
|
|
54
|
+
已经接入:
|
|
55
|
+
|
|
56
|
+
- `sendRichMessage`:Telegram rich HTML 发送链路。
|
|
57
|
+
- `/rich`:RichMessage demo。
|
|
58
|
+
- `/diff`:RichMessage details + diff pre/code,失败回退 HTML。
|
|
59
|
+
|
|
60
|
+
尚未接入:
|
|
61
|
+
|
|
62
|
+
- Rich table/status 面板、auth/quota 表格、MCP resource details、rich draft streaming。
|
|
63
|
+
- `sendRichMessageDraft` 的 thinking block 和最终 rich message 持久化。
|
|
64
|
+
|
|
65
|
+
## 功能面盘点
|
|
66
|
+
|
|
67
|
+
| 功能面 | 现状 | 可用 rich 能力 | 建议 |
|
|
68
|
+
| --- | --- | --- | --- |
|
|
69
|
+
| 活动 turn 状态卡 | 普通短文本,频繁编辑 | heading、list、thinking draft | 保持普通状态卡稳定;私聊 draft streaming 后续用 `RichBlockThinking` |
|
|
70
|
+
| Codex streaming 回复 | 分段纯文本为主 | rich draft、paragraph、pre、details | 先不默认切;需要 feature flag 和失败回退 |
|
|
71
|
+
| 归档工具批次 | 已用 expandable blockquote | details、pre、list | 短期维持 HTML;后续 rich details 展开命令、文件、搜索结果 |
|
|
72
|
+
| `/diff` | 已优先 RichMessage,失败回退 HTML | pre language、details | 已落地 |
|
|
73
|
+
| 审批请求 | 多行纯文本 + inline keyboard | code、pre、spoiler、details | 命令、路径、patch 适合 code/pre/details;敏感参数可 spoiler |
|
|
74
|
+
| `/status` / runtime 摘要 | 纯文本列表 | table、heading、footer | 多 bot、多 auth、多 quota 适合 rich table |
|
|
75
|
+
| `/auth` / `/quota` | 紧凑纯文本 + 按钮 | table、marked、spoiler | quota 窗口适合 table;异常候选用 marked;隐藏敏感候选信息需谨慎 |
|
|
76
|
+
| `/threads` / `/setup` | 已用 HTML 面板 | heading、list、anchor | 现状够用;rich message 价值中等 |
|
|
77
|
+
| MCP resource / plugin skill | 纯文本长内容 | details、pre、anchor/reference | schema、resource 文本可放 details/pre,引用可用 anchor/reference |
|
|
78
|
+
| 说明类消息 / help | 纯文本 | heading、list、code | 可转 rich list,但优先级低 |
|
|
79
|
+
| 媒体附件反馈 | 纯文本摘要 | collage/slideshow/photo/video caption | 只在需要回显媒体结果时考虑,当前不是主路径 |
|
|
80
|
+
|
|
81
|
+
## 落地路线
|
|
82
|
+
|
|
83
|
+
### Phase 1:HTML 兼容增强
|
|
84
|
+
|
|
85
|
+
目标:不改变 Bot API 主方法,先改善现有客户端体验。
|
|
86
|
+
|
|
87
|
+
- 统一 Telegram HTML helper,禁止散落手写转义。
|
|
88
|
+
- 长内容默认折叠:diff、工具日志、MCP resource、插件 skill 内容。
|
|
89
|
+
- 命令、路径、模型、候选名使用 `<code>`。
|
|
90
|
+
- 对可能包含 secret/token 的诊断内容使用 `<tg-spoiler>` 或直接不展示。
|
|
91
|
+
|
|
92
|
+
已完成:HTML helper、`/diff` 折叠、现有 CLI/工具归档复用 helper。
|
|
93
|
+
|
|
94
|
+
### Phase 2:Rich Message builder
|
|
95
|
+
|
|
96
|
+
目标:让 rich message 作为可回退能力存在,而不是替换全部消息。
|
|
97
|
+
|
|
98
|
+
已完成:
|
|
99
|
+
|
|
100
|
+
- 新增 `src/telegram/rich.ts`,定义 `InputRichMessage` 的最小 HTML 输入。
|
|
101
|
+
- `TelegramGateway` 增加 `sendRichMessage`、`editRichMessage`、`sendRichMessageDraft`。
|
|
102
|
+
- `TelegramMessagingPort` 和 `BridgeMessagingRouter` 增加 rich HTML send/edit;微信 scope 自动用 fallback HTML。
|
|
103
|
+
- `/rich` 和 `/diff` 先使用 rich 发送,失败回退到 HTML。
|
|
104
|
+
|
|
105
|
+
下一步:
|
|
106
|
+
|
|
107
|
+
- 把 `/status`、`/auth`、`/quota`、MCP resource 等结构消息迁移到 rich table/details。
|
|
108
|
+
- 按真实客户端表现决定是否加入全局配置开关。
|
|
109
|
+
|
|
110
|
+
### Phase 3:Rich draft streaming
|
|
111
|
+
|
|
112
|
+
目标:私聊里的 AI 生成过程更自然。
|
|
113
|
+
|
|
114
|
+
- 仅对 Telegram 私聊启用;群组、topic 默认继续走现有 segmented stream。
|
|
115
|
+
- draft 中使用 `RichBlockThinking` 表示思考中,已生成文本用 paragraph/pre/details。
|
|
116
|
+
- 生成完成后调用 `sendRichMessage` 发送完整消息,不能只依赖 ephemeral draft。
|
|
117
|
+
- 保留旧 `sendMessageDraft` 和 plain segmented stream 回退。
|
|
118
|
+
|
|
119
|
+
## 风险和注意点
|
|
120
|
+
|
|
121
|
+
- Rich Messages 是 2026-06-11 Bot API 10.1 新能力,客户端兼容性需要通过 `/rich` 和 `/diff` 实测。
|
|
122
|
+
- `sendRichMessageDraft` 只面向用户私聊;FoxClaw 的群组、topic、多 bot 场景必须保留旧路径。
|
|
123
|
+
- Rich media block 需要 bot 具备对应发送权限,且媒体 URL/上传处理比文本复杂,暂不作为第一阶段目标。
|
|
124
|
+
- 自动实体识别可能把路径、邮箱、URL、命令误识别;rich builder 应按消息类型决定是否设置 `skip_entity_detection`。
|
|
125
|
+
- HTML/rich 格式必须集中 escape,不能让 Codex 输出或 shell 输出直接拼进标签。
|
|
@@ -14,6 +14,13 @@ systemctl --user status foxclaw.service
|
|
|
14
14
|
journalctl --user -u foxclaw.service -f
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
如果 FoxClaw 是 macOS launchd 服务,再看:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
launchctl print "gui/$(id -u)/app.foxden.foxclaw"
|
|
21
|
+
tail -f ~/.foxclaw/logs/launchd.err.log ~/.foxclaw/logs/service.log
|
|
22
|
+
```
|
|
23
|
+
|
|
17
24
|
## Doctor 检查失败
|
|
18
25
|
|
|
19
26
|
| 现象 | 含义 | 处理方式 |
|
|
@@ -137,6 +144,13 @@ systemctl --user is-active foxclaw.service
|
|
|
137
144
|
pgrep -af foxclaw
|
|
138
145
|
```
|
|
139
146
|
|
|
147
|
+
macOS 上用:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
launchctl print "gui/$(id -u)/app.foxden.foxclaw"
|
|
151
|
+
pgrep -af foxclaw
|
|
152
|
+
```
|
|
153
|
+
|
|
140
154
|
停掉多余进程或服务后,重启 FoxClaw:
|
|
141
155
|
|
|
142
156
|
```bash
|
|
@@ -201,12 +215,18 @@ tail -f ~/.foxclaw/logs/codex-app-server-bot<id>.log
|
|
|
201
215
|
|
|
202
216
|
如果 Telegram 里看到 `ChatGPT backend 403 Forbidden`,或者 app-server 日志里出现 `Unable to load site`、`cf-ray`、`chatgpt.com/backend-api`,通常不是 `auth.json` 文件坏了,而是服务进程访问 ChatGPT 后端时没有走正确网络。
|
|
203
217
|
|
|
204
|
-
常见原因是:你在 shell 里配置了代理,或者项目 `.env` 里有代理,但 systemd/launchd 服务实际读的是另一个 env
|
|
218
|
+
常见原因是:你在 shell 里配置了代理,或者项目 `.env` 里有代理,但 systemd/launchd 服务实际读的是另一个 env 文件。Linux 先看服务用的是哪个 env:
|
|
205
219
|
|
|
206
220
|
```bash
|
|
207
221
|
systemctl --user cat foxclaw.service
|
|
208
222
|
```
|
|
209
223
|
|
|
224
|
+
macOS 看 launchd plist 里的 `FOXCLAW_ENV`:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
plutil -p ~/Library/LaunchAgents/app.foxden.foxclaw.plist | grep FOXCLAW_ENV -A1
|
|
228
|
+
```
|
|
229
|
+
|
|
210
230
|
`foxclaw init` 会检测当前 shell 里的代理环境变量,并询问是否保存到 FoxClaw `.env`。如果你跳过了这一步,`foxclaw doctor` 会在发现“shell 有代理,但 FoxClaw env 没有代理”时给出 `[WARN]`。
|
|
211
231
|
|
|
212
232
|
确认 `Environment=FOXCLAW_ENV=...` 指向的文件里有你的代理配置,例如:
|
|
@@ -244,6 +264,8 @@ FoxClaw 会把 proxychains 写进主 service,并清理旧的 FoxClaw `ExecStar
|
|
|
244
264
|
|
|
245
265
|
systemd 安装脚本会记录当时正在运行的 Node 绝对路径,不依赖 systemd 去加载 `nvm.sh` 或其它 shell 初始化脚本。无论你用 nvm、fnm、asdf、mise、Volta、Homebrew 还是系统 Node,原则都是:从 Node 24+ 的 shell 里执行 `foxclaw start`,服务之后就固定使用这个 Node 24+ 路径。
|
|
246
266
|
|
|
267
|
+
macOS launchd 也是同样原则:plist 会记录执行 `foxclaw start` 时的 Node 绝对路径,不依赖登录 shell 初始化脚本。
|
|
268
|
+
|
|
247
269
|
如果你从 Node 22 或更旧版本的 shell 里安装过服务,请从 Node 24+ 的 shell 重新安装。nvm 用户示例:
|
|
248
270
|
|
|
249
271
|
```bash
|
|
@@ -252,7 +274,15 @@ foxclaw start
|
|
|
252
274
|
systemctl --user status foxclaw.service
|
|
253
275
|
```
|
|
254
276
|
|
|
255
|
-
|
|
277
|
+
macOS 用户示例:
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
nvm use 24
|
|
281
|
+
foxclaw start
|
|
282
|
+
launchctl print "gui/$(id -u)/app.foxden.foxclaw"
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
状态输出里应该能看到 Node 24+ 的路径。`foxclaw doctor` 也会检查已安装 systemd/launchd 服务里的 Node 路径,如果发现路径不存在或版本低于 24,会提示重新运行 `foxclaw start`。
|
|
256
286
|
|
|
257
287
|
## 重启后是否会自动运行
|
|
258
288
|
|
package/docs/zh/user-manual.md
CHANGED
|
@@ -145,7 +145,14 @@ systemctl --user status foxclaw.service
|
|
|
145
145
|
journalctl --user -u foxclaw.service -f
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
-
macOS 上 `foxclaw start` 会管理 launchd
|
|
148
|
+
macOS 上 `foxclaw start` 会管理 launchd。查看 launchd 状态和启动日志:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
launchctl print "gui/$(id -u)/app.foxden.foxclaw"
|
|
152
|
+
tail -f ~/.foxclaw/logs/launchd.err.log ~/.foxclaw/logs/service.log
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
前台排障时,先停后台服务,再运行:
|
|
149
156
|
|
|
150
157
|
```bash
|
|
151
158
|
foxclaw stop
|
|
@@ -258,6 +265,10 @@ TG_ALLOWED_TOPIC_ID=42
|
|
|
258
265
|
|
|
259
266
|
Telegram 会把 HTML 和按钮渲染出来。这里用等宽框模拟实际面板:
|
|
260
267
|
|
|
268
|
+
Telegram Rich Message 能力的专项盘点和后续接入路线见 [Telegram Rich Message 适配专项检查](./telegram-rich-messages.md)。当前默认通道仍优先使用兼容性更稳的 Telegram HTML。
|
|
269
|
+
|
|
270
|
+
可以发送 `/rich` 在当前 Telegram 客户端查看 RichMessage demo。`/diff` 也会优先用 RichMessage 展示 details 和 diff code block,失败时自动回退到 Telegram HTML。
|
|
271
|
+
|
|
261
272
|
```text
|
|
262
273
|
会话偏好
|
|
263
274
|
当前:gpt-5.5 · high · fast=off · default · Agent · Steer current turn
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foxden-app/foxclaw",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.33",
|
|
4
4
|
"description": "Foxden local execution claw for controlling Codex from trusted chat interfaces.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"install-systemd": "node dist/main.js install-systemd",
|
|
49
49
|
"uninstall-systemd": "node dist/main.js uninstall-systemd",
|
|
50
50
|
"install-launchd": "node dist/main.js install-launchd",
|
|
51
|
+
"uninstall-launchd": "node dist/main.js uninstall-launchd",
|
|
51
52
|
"typecheck": "tsc --noEmit",
|
|
52
53
|
"lint": "eslint .",
|
|
53
54
|
"test": "node --test --import tsx $(find src -name '*.test.ts' -print)",
|
package/skills/foxclaw/SKILL.md
CHANGED
|
@@ -144,8 +144,8 @@ Use `--no-start` by default when preparing a second Mac before a unique bot toke
|
|
|
144
144
|
|
|
145
145
|
After either bootstrap path:
|
|
146
146
|
|
|
147
|
-
1. Run `node dist/main.js doctor` in the installed bridge repo.
|
|
148
|
-
2. If launchd was installed, run `node dist/main.js status
|
|
147
|
+
1. Run `node dist/main.js doctor` in the installed bridge repo.
|
|
148
|
+
2. If launchd was installed, run `node dist/main.js status`, `launchctl print "gui/$(id -u)/app.foxden.foxclaw"`, and inspect `~/.foxclaw/logs/launchd.err.log` if either status check fails.
|
|
149
149
|
3. Check `codex login status`. If authentication is missing, stop and tell the user exactly how to log in.
|
|
150
150
|
4. If the bridge is expected to answer in a Telegram group, confirm:
|
|
151
151
|
- `privacy mode` is disabled
|