@foxden-app/foxclaw 0.2.6 → 0.2.7

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.
@@ -0,0 +1,295 @@
1
+ # 新手安装指南
2
+
3
+ 这份指南面向第一次安装 FoxClaw 的用户。你只需要能打开终端、复制命令、编辑一个配置文件,不需要提前熟悉 Node.js、Telegram bot 或 Codex CLI。
4
+
5
+ FoxClaw 跑在你的电脑上。手机发消息给 Telegram bot,bot 把消息交给 FoxClaw,FoxClaw 再控制本机 Codex。整个过程不需要公网服务器。
6
+
7
+ 如果这台电脑上已经有 Codex、OpenClaw、QwenPaw、Hermes、OpenCode、Kimi CLI 这类能跑 shell 的 agent,优先看 [Agent 辅助安装](./agent-assisted-install.md)。
8
+
9
+ 开始前先记住:
10
+
11
+ - 第一次先用 Telegram 私聊,不要先配群组。
12
+ - 不要把 bot token 发给不信任的人。
13
+ - 第一次不要把 `/`、`/Users`、`/home` 或整个 home 目录设为 `DEFAULT_CWD`。
14
+ - 日常启动用 `foxclaw start`,前台模式只用于排障。
15
+
16
+ ## 1. 准备
17
+
18
+ 你需要:
19
+
20
+ - 一台可以持续开机的 macOS 或 Linux 电脑
21
+ - 一个 Telegram 账号
22
+ - 一个已可使用的 Codex 账号
23
+ - 一个 Codex 可以工作的目录,例如 `~/Projects` 或 `~/Desktop`
24
+ - 第一次安装大约 10-20 分钟
25
+
26
+ ## 2. 安装 Node.js 24
27
+
28
+ FoxClaw 需要 Node.js 24,因为它使用 Node 内置 SQLite 运行时。
29
+
30
+ 如果已经安装 Node 24,这条命令会输出 `v24...`:
31
+
32
+ ```bash
33
+ node -v
34
+ ```
35
+
36
+ 如果不是 Node 24,推荐用 `nvm` 安装:
37
+
38
+ ```bash
39
+ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
40
+ export NVM_DIR="$HOME/.nvm"
41
+ [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
42
+ nvm install 24
43
+ nvm use 24
44
+ node -v
45
+ npm -v
46
+ ```
47
+
48
+ 如果 `node -v` 仍然显示旧版本,关闭终端,重新打开后运行:
49
+
50
+ ```bash
51
+ nvm use 24
52
+ ```
53
+
54
+ ## 3. 安装并登录 Codex
55
+
56
+ FoxClaw 不创建 Codex 账号,它使用这台电脑上已经登录的 Codex CLI。
57
+
58
+ 如果还没有安装 Codex CLI:
59
+
60
+ ```bash
61
+ npm install -g @openai/codex
62
+ ```
63
+
64
+ 如果遇到 `EACCES`、`EPERM` 或 `permission denied`,不要反复加 `sudo` 硬装,先看 [故障排查](./troubleshooting.md)。
65
+
66
+ 登录 Codex:
67
+
68
+ ```bash
69
+ codex login
70
+ ```
71
+
72
+ 检查命令是否存在:
73
+
74
+ ```bash
75
+ codex --version
76
+ ```
77
+
78
+ `codex --version` 只能证明命令存在。要确认认证可用,直接启动 Codex 并发一个小请求:
79
+
80
+ ```bash
81
+ codex
82
+ ```
83
+
84
+ 然后输入:
85
+
86
+ ```text
87
+ Say ready and exit.
88
+ ```
89
+
90
+ 如果你的 CLI 支持 `codex login status`,也可以用它辅助检查;真正可靠的验证是 Codex 能正常回答一个普通请求。
91
+
92
+ ## 4. 创建 Telegram Bot
93
+
94
+ 1. 打开 Telegram。
95
+ 2. 搜索 `@BotFather`。
96
+ 3. 发送 `/newbot`。
97
+ 4. 按提示选择 bot 名称。
98
+ 5. 复制 bot token,它看起来像 `123456789:AA...`。
99
+
100
+ 请保存好这个 token。拿到 token 的人可以控制这个 bot。
101
+
102
+ ## 5. 获取 Telegram 数字用户 ID
103
+
104
+ FoxClaw 只接受一个已配置用户的消息。
105
+
106
+ 最简单的方式:
107
+
108
+ 1. 打开 Telegram。
109
+ 2. 搜索 `@userinfobot`。
110
+ 3. 给它发任意消息或点击 Start。
111
+ 4. 复制数字 `Id`。
112
+
113
+ 请使用数字 ID,不要填 `@username`。
114
+
115
+ ## 6. 安装 FoxClaw
116
+
117
+ 用 npm 安装发布包:
118
+
119
+ ```bash
120
+ npm install -g @foxden-app/foxclaw
121
+ foxclaw init
122
+ ```
123
+
124
+ 这会创建默认配置文件 `~/.foxclaw/.env`。
125
+
126
+ 如果你用 pnpm:
127
+
128
+ ```bash
129
+ pnpm add -g @foxden-app/foxclaw
130
+ foxclaw init
131
+ ```
132
+
133
+ ## 7. 填写 `.env`
134
+
135
+ 用简单编辑器打开配置:
136
+
137
+ ```bash
138
+ nano ~/.foxclaw/.env
139
+ ```
140
+
141
+ 第一次私聊模式只需要重点填写这些值:
142
+
143
+ ```dotenv
144
+ TG_BOT_TOKEN=123456789:replace_with_your_bot_token
145
+ TG_ALLOWED_USER_ID=123456789
146
+ TG_ALLOWED_CHAT_ID=
147
+ TG_ALLOWED_TOPIC_ID=
148
+ DEFAULT_CWD=/absolute/path/to/a/folder
149
+ DEFAULT_APPROVAL_POLICY=on-request
150
+ DEFAULT_SANDBOX_MODE=workspace-write
151
+ ```
152
+
153
+ `TG_ALLOWED_CHAT_ID=` 和 `TG_ALLOWED_TOPIC_ID=` 第一次保持为空,不要删掉这两行;留空表示私聊模式。
154
+
155
+ `DEFAULT_CWD` 必须是真实存在的目录,例如:
156
+
157
+ ```dotenv
158
+ DEFAULT_CWD=/Users/alice/Desktop
159
+ DEFAULT_CWD=/home/alice/projects
160
+ ```
161
+
162
+ 在 `nano` 中按 `Ctrl+O`、回车、`Ctrl+X` 保存退出。
163
+
164
+ ## 8. 运行检查
165
+
166
+ 执行:
167
+
168
+ ```bash
169
+ foxclaw doctor
170
+ ```
171
+
172
+ 理想情况下会看到:
173
+
174
+ ```text
175
+ [OK] node >= 24
176
+ [OK] codex cli available
177
+ [OK] telegram bot token configured
178
+ [OK] telegram allowed user configured
179
+ [OK] default cwd exists
180
+ ```
181
+
182
+ 如果看到 `[FAIL]`,先看 [故障排查](./troubleshooting.md)。
183
+
184
+ ## 9. 启动 FoxClaw
185
+
186
+ 启动或重启后台服务:
187
+
188
+ ```bash
189
+ foxclaw start
190
+ ```
191
+
192
+ 这个命令可以重复执行。它会跑检查,并按当前系统安装或重启后台服务。
193
+
194
+ 打开你的 Telegram bot,先发:
195
+
196
+ ```text
197
+ /help
198
+ ```
199
+
200
+ 如果 bot 回复了,再发:
201
+
202
+ ```text
203
+ /status
204
+ ```
205
+
206
+ 然后试一个普通请求:
207
+
208
+ ```text
209
+ List the files in the current working directory.
210
+ ```
211
+
212
+ 还可以试:
213
+
214
+ ```text
215
+ /setup
216
+ ```
217
+
218
+ ```text
219
+ List files in DEFAULT_CWD.
220
+ ```
221
+
222
+ ```text
223
+ Create a short README-style summary of this folder.
224
+ ```
225
+
226
+ ```text
227
+ /interrupt
228
+ ```
229
+
230
+ ## 10. 服务命令
231
+
232
+ Linux 上 `foxclaw start` 管理用户级 systemd 服务。查看状态:
233
+
234
+ ```bash
235
+ systemctl --user status foxclaw.service
236
+ journalctl --user -u foxclaw.service -f
237
+ ```
238
+
239
+ 如果希望重启后未登录也能启动用户服务:
240
+
241
+ ```bash
242
+ loginctl enable-linger "$USER"
243
+ ```
244
+
245
+ macOS 上 `foxclaw start` 管理 launchd,并在你登录后启动 FoxClaw。
246
+
247
+ 前台调试时,先停后台服务,再运行 `foxclaw serve`。
248
+
249
+ ## 11. 日常维护
250
+
251
+ 查看状态:
252
+
253
+ ```bash
254
+ foxclaw status
255
+ ```
256
+
257
+ 修改 `.env` 后重启:
258
+
259
+ ```bash
260
+ foxclaw start
261
+ ```
262
+
263
+ 停止 Linux 服务:
264
+
265
+ ```bash
266
+ systemctl --user stop foxclaw.service
267
+ ```
268
+
269
+ 卸载 Linux 服务:
270
+
271
+ ```bash
272
+ foxclaw uninstall-systemd
273
+ ```
274
+
275
+ 以后升级 FoxClaw:
276
+
277
+ ```bash
278
+ npm install -g @foxden-app/foxclaw@latest
279
+ foxclaw start
280
+ ```
281
+
282
+ ## 从旧项目名迁移
283
+
284
+ 如果这台机器仍在运行 `telegram-codex-app-bridge`,迁移一次即可:
285
+
286
+ ```bash
287
+ systemctl --user disable --now telegram-codex-app-bridge.service 2>/dev/null || true
288
+ test -e ~/.foxclaw || cp -a ~/.telegram-codex-app-bridge ~/.foxclaw
289
+ npm install -g @foxden-app/foxclaw@latest
290
+ foxclaw init
291
+ foxclaw doctor
292
+ foxclaw start
293
+ ```
294
+
295
+ 如果 `~/.foxclaw/.env` 已经存在,`foxclaw init` 不会覆盖它。
@@ -0,0 +1,222 @@
1
+ # 故障排查
2
+
3
+ 先从这两条命令开始:
4
+
5
+ ```bash
6
+ foxclaw doctor
7
+ foxclaw status
8
+ ```
9
+
10
+ 如果 FoxClaw 是 Linux 用户级服务,再看:
11
+
12
+ ```bash
13
+ systemctl --user status foxclaw.service
14
+ journalctl --user -u foxclaw.service -f
15
+ ```
16
+
17
+ ## Doctor 检查失败
18
+
19
+ | 现象 | 含义 | 处理方式 |
20
+ | --- | --- | --- |
21
+ | `[FAIL] node >= 24` | 当前 shell 使用的是旧版 Node.js。 | 运行 `nvm install 24 && nvm use 24`,再重新执行 `foxclaw doctor`。如果服务仍用旧 Node,从 Node 24 的 shell 里重新执行 `foxclaw start`。 |
22
+ | `[FAIL] codex cli available` | `codex` 命令不在 PATH 里。 | 安装 Codex CLI 或修正 PATH,再确认 `codex --version` 可用。 |
23
+ | `[FAIL] telegram bot token configured` | `.env` 里缺少 `TG_BOT_TOKEN`。 | 从 `@BotFather` 复制 token,填入 `.env`。 |
24
+ | `[FAIL] telegram allowed user configured` | `.env` 里缺少 `TG_ALLOWED_USER_ID`。 | 从 `@userinfobot` 获取数字 ID,填入 `.env`。 |
25
+ | `[FAIL] default cwd exists` | `DEFAULT_CWD` 指向不存在的目录。 | 创建该目录,或把 `DEFAULT_CWD` 改成一个真实存在的绝对路径。 |
26
+
27
+ ## Node 或 npm 不存在
28
+
29
+ 如果看到 `node: command not found` 或 `npm: command not found`,用 `nvm` 安装 Node.js 24:
30
+
31
+ ```bash
32
+ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
33
+ export NVM_DIR="$HOME/.nvm"
34
+ [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
35
+ nvm install 24
36
+ nvm use 24
37
+ node -v
38
+ npm -v
39
+ ```
40
+
41
+ 如果仍然失败,关闭终端,重新打开后运行:
42
+
43
+ ```bash
44
+ nvm use 24
45
+ ```
46
+
47
+ ## npm 权限错误
48
+
49
+ 如果 `npm install -g @openai/codex` 或 `npm install -g @foxden-app/foxclaw` 报 `EACCES`、`EPERM`、`permission denied`,说明当前全局 npm 目录不可写。
50
+
51
+ 推荐处理方式是通过 `nvm` 使用用户级 Node,然后重新安装:
52
+
53
+ ```bash
54
+ nvm install 24
55
+ nvm use 24
56
+ npm install -g @openai/codex
57
+ npm install -g @foxden-app/foxclaw
58
+ ```
59
+
60
+ 除非你很清楚本机 Node 的安装方式,否则不要直接混用 `sudo npm install -g ...`。`sudo`、系统 Node 和 `nvm` 混在一起,常见结果是 PATH 断掉或服务启动时找不到命令。
61
+
62
+ 如果 `codex` 已安装但 FoxClaw 找不到它,先定位二进制:
63
+
64
+ ```bash
65
+ command -v codex
66
+ ```
67
+
68
+ 然后把绝对路径写进 `.env`:
69
+
70
+ ```dotenv
71
+ CODEX_CLI_BIN=/absolute/path/to/codex
72
+ ```
73
+
74
+ ## Bot 没有回复
75
+
76
+ 按顺序检查:
77
+
78
+ 1. 确认 FoxClaw 正在运行:
79
+
80
+ ```bash
81
+ foxclaw status
82
+ ```
83
+
84
+ 2. 先用私聊测试。直接打开 bot 发:
85
+
86
+ ```text
87
+ /help
88
+ ```
89
+
90
+ 3. 确认 `TG_ALLOWED_USER_ID` 是你的 Telegram 数字 ID,不是 `@username`。
91
+
92
+ 4. 确认 `.env` 里的 bot token 属于你正在聊天的 bot。
93
+
94
+ 5. 修改 `.env` 后重启:
95
+
96
+ ```bash
97
+ foxclaw start
98
+ ```
99
+
100
+ 如果正在前台运行,先 `Ctrl+C` 停止,再重新运行 `foxclaw serve`。
101
+
102
+ ## 群组消息不生效
103
+
104
+ 私聊模式最简单。群组或话题模式请检查:
105
+
106
+ 1. 已把 bot 加入目标群组。
107
+ 2. 已在 `@BotFather` 里关闭 bot 的 `privacy mode`。
108
+ 3. 已把 bot 提升为群管理员。
109
+ 4. 如果是加群后才关闭隐私模式,先把 bot 踢出群再重新加入。
110
+ 5. 已配置 `TG_ALLOWED_CHAT_ID`,必要时也配置 `TG_ALLOWED_TOPIC_ID`。
111
+
112
+ `/status@botname` 这种显式命令有时会在隐私模式下仍然可用,所以验证群组配置时请用普通自然语言消息测试。
113
+
114
+ ## 获取群组或话题 ID
115
+
116
+ 1. 停掉 FoxClaw。
117
+ 2. 在目标群组或话题里发一条新消息。
118
+ 3. 浏览器打开:
119
+
120
+ ```text
121
+ https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates
122
+ ```
123
+
124
+ 4. 用 `message.chat.id` 作为 `TG_ALLOWED_CHAT_ID`。
125
+ 5. 用 `message.message_thread_id` 作为 `TG_ALLOWED_TOPIC_ID`。
126
+
127
+ 如果 FoxClaw 还在运行,它可能会先消费这条 update,导致你在浏览器里看不到。
128
+
129
+ ## Telegram polling 冲突
130
+
131
+ 如果 Telegram 报 conflict,或者同一个 bot 行为异常,通常是两个进程在轮询同一个 bot token。
132
+
133
+ 检查新旧服务:
134
+
135
+ ```bash
136
+ systemctl --user is-active foxclaw.service
137
+ systemctl --user is-active telegram-codex-app-bridge.service 2>/dev/null || true
138
+ ```
139
+
140
+ 停掉旧服务:
141
+
142
+ ```bash
143
+ systemctl --user disable --now telegram-codex-app-bridge.service
144
+ ```
145
+
146
+ 然后重启 FoxClaw:
147
+
148
+ ```bash
149
+ foxclaw start
150
+ ```
151
+
152
+ ## Codex 或 app-server 异常
153
+
154
+ FoxClaw 需要本机 Codex 已登录。先检查命令:
155
+
156
+ ```bash
157
+ codex --version
158
+ ```
159
+
160
+ 如果没有登录:
161
+
162
+ ```bash
163
+ codex login
164
+ ```
165
+
166
+ `codex --version` 只证明命令存在。要验证认证真的可用,运行:
167
+
168
+ ```bash
169
+ codex
170
+ ```
171
+
172
+ 然后输入:
173
+
174
+ ```text
175
+ Say ready and exit.
176
+ ```
177
+
178
+ 如果你的 CLI 支持 `codex login status`,也可以一起看;但普通请求能成功回答才是最直接的验证。
179
+
180
+ FoxClaw app-server 日志默认在:
181
+
182
+ ```bash
183
+ tail -f ~/.foxclaw/logs/codex-app-server.log
184
+ ```
185
+
186
+ Bridge 日志默认在:
187
+
188
+ ```bash
189
+ tail -f ~/.foxclaw/logs/service.log
190
+ ```
191
+
192
+ ## 服务用了错误的 Node 版本
193
+
194
+ systemd 安装脚本会记录当时 PATH 里的 `node`。如果你从 Node 22 或更旧版本的 shell 里安装过服务,请从 Node 24 的 shell 重新安装:
195
+
196
+ ```bash
197
+ nvm use 24
198
+ foxclaw start
199
+ systemctl --user status foxclaw.service
200
+ ```
201
+
202
+ 状态输出里应该能看到 Node 24 的路径。
203
+
204
+ ## 重启后是否会自动运行
205
+
206
+ Linux 用户级 systemd:
207
+
208
+ ```bash
209
+ systemctl --user is-enabled foxclaw.service
210
+ ```
211
+
212
+ `enabled` 表示会随用户会话启动。如果希望机器重启后未登录也启动用户服务:
213
+
214
+ ```bash
215
+ loginctl enable-linger "$USER"
216
+ ```
217
+
218
+ macOS 上,运行过下面命令后,FoxClaw 会在你登录时由 launchd 启动:
219
+
220
+ ```bash
221
+ foxclaw start
222
+ ```
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@foxden-app/foxclaw",
3
- "version": "0.2.6", "description": "Foxden local execution claw for controlling Codex from trusted chat interfaces.",
3
+ "version": "0.2.7",
4
+ "description": "Foxden local execution claw for controlling Codex from trusted chat interfaces.",
4
5
  "type": "module",
5
6
  "main": "dist/main.js",
6
7
  "bin": {
package/scripts/doctor.sh CHANGED
File without changes
File without changes
package/scripts/status.sh CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
4
- node "$ROOT_DIR/dist/main.js" status
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
4
+ node "$ROOT_DIR/dist/main.js" status
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
4
- node "$ROOT_DIR/dist/main.js" install-systemd
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
4
+ node "$ROOT_DIR/dist/main.js" install-systemd
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
4
- node "$ROOT_DIR/dist/main.js" uninstall-systemd
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
4
+ node "$ROOT_DIR/dist/main.js" uninstall-systemd