@foxden-app/foxclaw 0.2.3 → 0.2.5
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/README.md +97 -88
- package/README_EN.md +19 -12
- package/dist/config.js +1 -1
- package/dist/main.js +58 -37
- package/docs/agent-assisted-install.md +4 -6
- package/docs/install-for-beginners.md +11 -20
- package/docs/troubleshooting.md +6 -6
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -2,56 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
# FoxClaw
|
|
4
4
|
|
|
5
|
-
FoxClaw 是 Foxden agents
|
|
5
|
+
FoxClaw 是 Foxden agents 的本地执行爪——跑在你自己电脑上,让你通过 Telegram 或微信远程操控本机的 Codex。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
不需要公网服务器。FoxClaw 在本地和 `codex app-server` 通信,审批在你电脑上完成,结果推送回手机。
|
|
8
8
|
|
|
9
9
|
## 从这里开始
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
11
|
+
- 手头有 Codex、OpenClaw、QwenPaw、Hermes、OpenCode、Kimi CLI 之类能跑 shell 的 agent?推荐走 [Agent 辅助安装](./docs/agent-assisted-install.md)。
|
|
12
|
+
- 对 Node、Telegram 机器人、Codex CLI 不太熟?看 [新手安装指南](./docs/install-for-beginners.md)。
|
|
13
|
+
- Git、Node、`.env` 都玩得转?直接往下看快速设置。
|
|
14
|
+
- 卡住了?看 [故障排查](./docs/troubleshooting.md)。
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
FoxClaw 适合这些场景:
|
|
17
17
|
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
18
|
+
- 在手机上用 Codex,但不想把电脑暴露到公网
|
|
19
|
+
- 代码、shell、认证、审批、运行数据全部留在本机
|
|
20
|
+
- 只允许一个受信任的 Telegram 用户远程操作
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
最低要求:一个 Telegram bot token、你的 Telegram 数字用户 ID、Node.js 24、一份已登录的 `codex` CLI。首次安装大约 10–20 分钟。
|
|
23
23
|
|
|
24
|
-
30
|
|
24
|
+
**30 秒体验**:启动 FoxClaw 后,给你的 Telegram 机器人发一句 `List files in DEFAULT_CWD`。Codex 会在本地检查那个目录,然后把结果发回 Telegram。
|
|
25
25
|
|
|
26
26
|
## 环境要求
|
|
27
27
|
|
|
28
|
-
- macOS 或 Linux
|
|
29
|
-
-
|
|
28
|
+
- macOS 或 Linux,`codex` CLI 可用
|
|
29
|
+
- Codex 已完成登录认证
|
|
30
30
|
- Node.js 24+
|
|
31
|
-
-
|
|
31
|
+
- 一个 `@BotFather` 创建的 Telegram bot token
|
|
32
32
|
- 你的 Telegram 数字用户 ID
|
|
33
33
|
|
|
34
|
-
##
|
|
34
|
+
## 快速设置
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
37
|
npm install -g @foxden-app/foxclaw
|
|
38
38
|
foxclaw init
|
|
39
39
|
$EDITOR ~/.foxclaw/.env
|
|
40
40
|
foxclaw doctor
|
|
41
|
-
foxclaw
|
|
41
|
+
foxclaw start
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
pnpm
|
|
44
|
+
pnpm 用户:
|
|
45
45
|
|
|
46
46
|
```bash
|
|
47
47
|
pnpm add -g @foxden-app/foxclaw
|
|
48
48
|
foxclaw init
|
|
49
49
|
$EDITOR ~/.foxclaw/.env
|
|
50
50
|
foxclaw doctor
|
|
51
|
-
foxclaw
|
|
51
|
+
foxclaw start
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
跑 `doctor` 或 `start` 之前先把 `.env` 填好。私聊模式最小配置:
|
|
55
55
|
|
|
56
56
|
```dotenv
|
|
57
57
|
TG_BOT_TOKEN=123456:telegram-token
|
|
@@ -61,114 +61,123 @@ DEFAULT_APPROVAL_POLICY=on-request
|
|
|
61
61
|
DEFAULT_SANDBOX_MODE=workspace-write
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
配置文件默认在 `~/.foxclaw/.env`。想放别处的话设 `FOXCLAW_ENV=/path/to/.env`。
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
`foxclaw start` 会自动检查环境并安装/重启后台服务,幂等操作,升级后再跑一次就行。
|
|
67
|
+
|
|
68
|
+
FoxClaw 只响应 `TG_ALLOWED_USER_ID` 的消息——把机器人拉进群不代表群里所有人都能用。
|
|
67
69
|
|
|
68
70
|
<details>
|
|
69
|
-
<summary>FoxClaw
|
|
70
|
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
73
|
-
-
|
|
74
|
-
-
|
|
75
|
-
-
|
|
76
|
-
- Codex
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
- Skills、MCP、hooks、plugins、apps、feature flags、config、requirements
|
|
81
|
-
-
|
|
82
|
-
-
|
|
71
|
+
<summary>FoxClaw 能做什么</summary>
|
|
72
|
+
|
|
73
|
+
- 单个 Telegram 用户通过私聊、群组、话题控制
|
|
74
|
+
- 可选微信/iLink 通道,复用同一套桥接核心
|
|
75
|
+
- `/threads`、`/open`、`/new`、`/where`、`/interrupt`——稳定的聊天-线程绑定
|
|
76
|
+
- 手机上管理线程生命周期:重命名、归档、取消归档、fork、回滚、compact、review、diff
|
|
77
|
+
- 每个聊天独立的设置面板:模型、reasoning effort、Fast tier、access preset、Agent/Plan 模式、active-turn 行为
|
|
78
|
+
- Codex 账户管理:`/account`、`/quota`、`/login_device`、`/login_cancel`、`/auth add <name>`、`/logout confirm`
|
|
79
|
+
- 触发用量限制时自动在本地 `auth.json_*` 之间切换认证
|
|
80
|
+
- 命令、文件变更、细粒度权限审批的内联按钮
|
|
81
|
+
- MCP elicitation 卡片——工具在 turn 中提出结构化问题时展示
|
|
82
|
+
- Skills、MCP、hooks、plugins、apps、feature flags、config、requirements、provider diagnostics
|
|
83
|
+
- SQLite 持久化:绑定、offset、审批、待处理提示、审计日志
|
|
84
|
+
- 单实例进程锁,防止同一 bot token 重复 polling
|
|
83
85
|
|
|
84
86
|
</details>
|
|
85
87
|
|
|
86
|
-
##
|
|
88
|
+
## 服务与调试
|
|
89
|
+
|
|
90
|
+
推荐方式:
|
|
87
91
|
|
|
88
|
-
|
|
92
|
+
```bash
|
|
93
|
+
foxclaw start
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Linux 上会安装/重启用户级 systemd 服务,macOS 上安装/重载 launchd。查看状态:
|
|
89
97
|
|
|
90
98
|
```bash
|
|
91
|
-
foxclaw install-systemd
|
|
92
99
|
systemctl --user status foxclaw.service
|
|
93
100
|
journalctl --user -u foxclaw.service -f
|
|
94
101
|
```
|
|
95
102
|
|
|
96
|
-
|
|
103
|
+
需要前台调试时:
|
|
97
104
|
|
|
98
105
|
```bash
|
|
99
|
-
foxclaw
|
|
106
|
+
foxclaw serve
|
|
100
107
|
```
|
|
101
108
|
|
|
102
|
-
|
|
109
|
+
运行时文件默认在 `~/.foxclaw`:
|
|
103
110
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
111
|
+
| 用途 | 路径 |
|
|
112
|
+
|------|------|
|
|
113
|
+
| 数据库 | `~/.foxclaw/data/bridge.sqlite` |
|
|
114
|
+
| Bridge 日志 | `~/.foxclaw/logs/service.log` |
|
|
115
|
+
| 状态 | `~/.foxclaw/runtime/status.json` |
|
|
116
|
+
| App-server 状态 | `~/.foxclaw/runtime/codex-app-server.json` |
|
|
117
|
+
| App-server 日志 | `~/.foxclaw/logs/codex-app-server.log` |
|
|
109
118
|
|
|
110
|
-
|
|
119
|
+
可通过 `STORE_PATH`、`LOCK_PATH`、`CODEX_APP_SERVER_STATE_PATH`、`CODEX_APP_SERVER_LOG_PATH` 覆盖。
|
|
111
120
|
|
|
112
121
|
## 从 telegram-codex-app-bridge 迁移
|
|
113
122
|
|
|
114
|
-
FoxClaw 最初 fork 自 `Gan-Xing/telegram-codex-app-bridge
|
|
123
|
+
FoxClaw 最初 fork 自 `Gan-Xing/telegram-codex-app-bridge`,继续以 MIT License 分发。
|
|
115
124
|
|
|
116
|
-
|
|
125
|
+
升级已有安装:
|
|
117
126
|
|
|
118
127
|
```bash
|
|
119
128
|
systemctl --user disable --now telegram-codex-app-bridge.service 2>/dev/null || true
|
|
120
129
|
test -e ~/.foxclaw || cp -a ~/.telegram-codex-app-bridge ~/.foxclaw
|
|
121
|
-
foxclaw
|
|
130
|
+
foxclaw start
|
|
122
131
|
```
|
|
123
132
|
|
|
124
|
-
|
|
133
|
+
macOS launchd 用户先卸载旧 plist:
|
|
125
134
|
|
|
126
135
|
```bash
|
|
127
136
|
launchctl unload ~/Library/LaunchAgents/com.ganxing.telegram-codex-app-bridge.plist 2>/dev/null || true
|
|
128
|
-
foxclaw
|
|
137
|
+
foxclaw start
|
|
129
138
|
```
|
|
130
139
|
|
|
131
|
-
|
|
140
|
+
旧目录不会被自动读取。如果要保留已有的绑定、线程缓存、审批和状态数据,手动复制一次即可。
|
|
132
141
|
|
|
133
142
|
## Telegram 设置
|
|
134
143
|
|
|
135
|
-
1.
|
|
136
|
-
2.
|
|
137
|
-
3.
|
|
138
|
-
4.
|
|
144
|
+
1. 用 `@BotFather` 创建机器人,token 填入 `TG_BOT_TOKEN`。
|
|
145
|
+
2. 拿到你的 Telegram 数字用户 ID,填入 `TG_ALLOWED_USER_ID`。
|
|
146
|
+
3. `foxclaw start` 启动。
|
|
147
|
+
4. 打开和机器人的私聊,发 `/help`。
|
|
139
148
|
|
|
140
|
-
|
|
149
|
+
可选——群组/话题配置:
|
|
141
150
|
|
|
142
151
|
```dotenv
|
|
143
152
|
TG_ALLOWED_CHAT_ID=-1001234567890
|
|
144
153
|
TG_ALLOWED_TOPIC_ID=42
|
|
145
154
|
```
|
|
146
155
|
|
|
147
|
-
-
|
|
148
|
-
-
|
|
149
|
-
-
|
|
150
|
-
-
|
|
156
|
+
- `TG_ALLOWED_CHAT_ID` 留空 → 纯私聊模式。
|
|
157
|
+
- 只填 `TG_ALLOWED_CHAT_ID` → 允许一个群组作为默认会话范围。
|
|
158
|
+
- 两个都填 → 绑定到某个话题。
|
|
159
|
+
- 配了群组后,`TG_ALLOWED_USER_ID` 的私聊依然可用。
|
|
151
160
|
|
|
152
|
-
|
|
161
|
+
**怎么找群组和话题 ID:**
|
|
153
162
|
|
|
154
|
-
1.
|
|
155
|
-
2.
|
|
156
|
-
3.
|
|
157
|
-
4.
|
|
158
|
-
5.
|
|
163
|
+
1. 先停掉 FoxClaw。
|
|
164
|
+
2. 在目标群组/话题里发一条消息。
|
|
165
|
+
3. 浏览器打开 `https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates`。
|
|
166
|
+
4. 找 `message.chat.id` → 填 `TG_ALLOWED_CHAT_ID`。
|
|
167
|
+
5. 找 `message.message_thread_id` → 填 `TG_ALLOWED_TOPIC_ID`。
|
|
159
168
|
|
|
160
|
-
如果 FoxClaw
|
|
169
|
+
> 如果 FoxClaw 还在跑,它可能会先把这条 update 消费掉,所以要先停。
|
|
161
170
|
|
|
162
171
|
## Telegram 群组检查清单
|
|
163
172
|
|
|
164
|
-
|
|
173
|
+
要让机器人在群组/超级群里收到普通消息:
|
|
165
174
|
|
|
166
|
-
1.
|
|
167
|
-
2. 在 `@BotFather`
|
|
168
|
-
3.
|
|
169
|
-
4.
|
|
175
|
+
1. 把机器人加进目标群组。
|
|
176
|
+
2. 在 `@BotFather` 里关掉 `privacy mode`。
|
|
177
|
+
3. 把机器人设为群管理员。
|
|
178
|
+
4. 如果是加群之后才改的隐私模式,把机器人踢出去再重新加。
|
|
170
179
|
|
|
171
|
-
|
|
180
|
+
> 注意:即使 privacy mode 挡住了普通消息,`/status@botname` 这种显式命令可能还是能用的。所以验证群组设置时,请用一条普通文本消息测试。
|
|
172
181
|
|
|
173
182
|
## Codex App-Server 生命周期
|
|
174
183
|
|
|
@@ -183,14 +192,14 @@ CODEX_APP_SYNC_ON_OPEN=true
|
|
|
183
192
|
CODEX_APP_SYNC_ON_TURN_COMPLETE=false
|
|
184
193
|
```
|
|
185
194
|
|
|
186
|
-
FoxClaw 会把 `codex app-server`
|
|
195
|
+
FoxClaw 会把 `codex app-server` 作为 detached 子进程启动,记录其 pid 和端口。重启时如果进程还活着就直接重连,否则拉起新进程。`/auth_reload` 和认证切换会重启 app-server 以重新加载 `auth.json`。
|
|
187
196
|
|
|
188
|
-
|
|
197
|
+
一般不需要手动固定 app-server 端口。
|
|
189
198
|
|
|
190
199
|
## 命令
|
|
191
200
|
|
|
192
201
|
- `/help`
|
|
193
|
-
- `/setup`
|
|
202
|
+
- `/setup` — 统一设置面板
|
|
194
203
|
- `/fast <on|off|toggle>`
|
|
195
204
|
- `/active <steer|queue>`
|
|
196
205
|
- `/status`、`/account`、`/quota`
|
|
@@ -208,45 +217,45 @@ FoxClaw 会把 `codex app-server` 启动为一个由 bridge 管理的 detached
|
|
|
208
217
|
- `/skills [query]`、`/skill <name>`、`/skill_enable <name>`、`/skill_disable <name>`
|
|
209
218
|
- `/loaded`、`/hooks`、`/plugins [query]`、`/apps [reload]`、`/features`、`/config`、`/requirements`、`/provider`
|
|
210
219
|
- `/mcp`、`/mcp_reload`、`/mcp_login <server>`、`/mcp_resource <server> <uri>`
|
|
211
|
-
- `/models`、`/model`、`/effort`、`/permissions`、`/access`、`/mode`、`/plan
|
|
220
|
+
- `/models`、`/model`、`/effort`、`/permissions`、`/access`、`/mode`、`/plan`、`/agent`
|
|
212
221
|
- `/reveal`、`/where`、`/interrupt`
|
|
213
222
|
|
|
214
|
-
|
|
223
|
+
直接发文本会送到当前线程;没有绑定线程时自动创建新线程。
|
|
215
224
|
|
|
216
225
|
## 微信/iLink
|
|
217
226
|
|
|
218
|
-
|
|
227
|
+
微信支持默认关闭,需要手动开启:
|
|
219
228
|
|
|
220
229
|
```dotenv
|
|
221
230
|
WX_ENABLED=true
|
|
222
231
|
WX_ALLOWED_ILINK_USER_IDS=
|
|
223
232
|
```
|
|
224
233
|
|
|
225
|
-
|
|
234
|
+
构建完成后跑一次二维码登录:
|
|
226
235
|
|
|
227
236
|
```bash
|
|
228
237
|
foxclaw weixin-login
|
|
229
238
|
```
|
|
230
239
|
|
|
231
|
-
|
|
240
|
+
微信运行时文件在 `~/.foxclaw/weixin`。
|
|
232
241
|
|
|
233
242
|
## Codex Skill
|
|
234
243
|
|
|
235
|
-
|
|
244
|
+
仓库自带一个 Codex skill:[`skills/foxclaw`](./skills/foxclaw)。用它可以让 Codex 通过 SSH 在本机或远程 Mac 上 bootstrap FoxClaw——写 `.env`、构建、跑 doctor、装 launchd、引导首次消息验证,一条龙。
|
|
236
245
|
|
|
237
246
|
## 故障排查
|
|
238
247
|
|
|
239
|
-
`doctor`
|
|
248
|
+
`doctor` 报错、Telegram 没回复、服务日志看不懂、重启行为异常、迁移出问题——都看 [故障排查](./docs/troubleshooting.md)。
|
|
240
249
|
|
|
241
250
|
## 运维命令
|
|
242
251
|
|
|
243
252
|
```bash
|
|
244
253
|
foxclaw doctor
|
|
245
254
|
foxclaw status
|
|
246
|
-
foxclaw
|
|
255
|
+
foxclaw start
|
|
247
256
|
foxclaw uninstall-systemd
|
|
248
257
|
```
|
|
249
258
|
|
|
250
259
|
## 贡献
|
|
251
260
|
|
|
252
|
-
|
|
261
|
+
欢迎到 [GitHub](https://github.com/foxden-app/foxclaw) 提 issue 和 PR。
|
package/README_EN.md
CHANGED
|
@@ -38,7 +38,7 @@ npm install -g @foxden-app/foxclaw
|
|
|
38
38
|
foxclaw init
|
|
39
39
|
$EDITOR ~/.foxclaw/.env
|
|
40
40
|
foxclaw doctor
|
|
41
|
-
foxclaw
|
|
41
|
+
foxclaw start
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
pnpm users can use:
|
|
@@ -48,10 +48,10 @@ pnpm add -g @foxden-app/foxclaw
|
|
|
48
48
|
foxclaw init
|
|
49
49
|
$EDITOR ~/.foxclaw/.env
|
|
50
50
|
foxclaw doctor
|
|
51
|
-
foxclaw
|
|
51
|
+
foxclaw start
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
Edit `.env` before running `doctor` or `
|
|
54
|
+
Edit `.env` before running `doctor` or `start`. Minimum private-chat config:
|
|
55
55
|
|
|
56
56
|
```dotenv
|
|
57
57
|
TG_BOT_TOKEN=123456:telegram-token
|
|
@@ -63,6 +63,8 @@ DEFAULT_SANDBOX_MODE=workspace-write
|
|
|
63
63
|
|
|
64
64
|
The default config file is `~/.foxclaw/.env`. Set `FOXCLAW_ENV=/path/to/.env` if you want to keep it somewhere else.
|
|
65
65
|
|
|
66
|
+
`foxclaw start` runs checks and installs or restarts the background service. It is idempotent, so run it again after upgrading.
|
|
67
|
+
|
|
66
68
|
FoxClaw accepts messages only from `TG_ALLOWED_USER_ID`. Putting the bot in a group does not make it available to every group member.
|
|
67
69
|
|
|
68
70
|
<details>
|
|
@@ -83,20 +85,25 @@ FoxClaw accepts messages only from `TG_ALLOWED_USER_ID`. Putting the bot in a gr
|
|
|
83
85
|
|
|
84
86
|
</details>
|
|
85
87
|
|
|
86
|
-
##
|
|
88
|
+
## Service And Debugging
|
|
89
|
+
|
|
90
|
+
Recommended:
|
|
87
91
|
|
|
88
|
-
|
|
92
|
+
```bash
|
|
93
|
+
foxclaw start
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
It installs or restarts the Linux user systemd service, or loads/reloads launchd on macOS. To inspect Linux service state:
|
|
89
97
|
|
|
90
98
|
```bash
|
|
91
|
-
foxclaw install-systemd
|
|
92
99
|
systemctl --user status foxclaw.service
|
|
93
100
|
journalctl --user -u foxclaw.service -f
|
|
94
101
|
```
|
|
95
102
|
|
|
96
|
-
|
|
103
|
+
For foreground debugging:
|
|
97
104
|
|
|
98
105
|
```bash
|
|
99
|
-
foxclaw
|
|
106
|
+
foxclaw serve
|
|
100
107
|
```
|
|
101
108
|
|
|
102
109
|
Default runtime files are stored under `~/.foxclaw`:
|
|
@@ -118,14 +125,14 @@ When upgrading an existing local install:
|
|
|
118
125
|
```bash
|
|
119
126
|
systemctl --user disable --now telegram-codex-app-bridge.service 2>/dev/null || true
|
|
120
127
|
test -e ~/.foxclaw || cp -a ~/.telegram-codex-app-bridge ~/.foxclaw
|
|
121
|
-
foxclaw
|
|
128
|
+
foxclaw start
|
|
122
129
|
```
|
|
123
130
|
|
|
124
131
|
For launchd installs, unload the old plist if present:
|
|
125
132
|
|
|
126
133
|
```bash
|
|
127
134
|
launchctl unload ~/Library/LaunchAgents/com.ganxing.telegram-codex-app-bridge.plist 2>/dev/null || true
|
|
128
|
-
foxclaw
|
|
135
|
+
foxclaw start
|
|
129
136
|
```
|
|
130
137
|
|
|
131
138
|
The old runtime directory is not read automatically. Copy it once if you want to keep existing bindings, cached thread lists, approvals, and status data.
|
|
@@ -134,7 +141,7 @@ The old runtime directory is not read automatically. Copy it once if you want to
|
|
|
134
141
|
|
|
135
142
|
1. Create a bot with `@BotFather` and copy the token into `TG_BOT_TOKEN`.
|
|
136
143
|
2. Get your Telegram numeric user id and place it into `TG_ALLOWED_USER_ID`.
|
|
137
|
-
3. Start FoxClaw with `foxclaw
|
|
144
|
+
3. Start FoxClaw with `foxclaw start`.
|
|
138
145
|
4. Open a private chat with the bot and send `/help`.
|
|
139
146
|
|
|
140
147
|
Optional group/topic config:
|
|
@@ -243,7 +250,7 @@ See [Troubleshooting](./docs/troubleshooting.md) for `doctor` failures, Telegram
|
|
|
243
250
|
```bash
|
|
244
251
|
foxclaw doctor
|
|
245
252
|
foxclaw status
|
|
246
|
-
foxclaw
|
|
253
|
+
foxclaw start
|
|
247
254
|
foxclaw uninstall-systemd
|
|
248
255
|
```
|
|
249
256
|
|
package/dist/config.js
CHANGED
|
@@ -18,7 +18,7 @@ export function loadEnv() {
|
|
|
18
18
|
envLoaded = true;
|
|
19
19
|
const explicitPath = process.env.FOXCLAW_ENV?.trim();
|
|
20
20
|
if (explicitPath) {
|
|
21
|
-
dotenv.config({ path: explicitPath });
|
|
21
|
+
dotenv.config({ path: explicitPath, override: true });
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
const cwdEnvPath = path.join(process.cwd(), '.env');
|
package/dist/main.js
CHANGED
|
@@ -21,6 +21,11 @@ async function main() {
|
|
|
21
21
|
installSystemd();
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
+
if (command === 'start') {
|
|
25
|
+
requireNode24(command);
|
|
26
|
+
startService();
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
24
29
|
if (command === 'uninstall-systemd') {
|
|
25
30
|
uninstallSystemd();
|
|
26
31
|
return;
|
|
@@ -40,43 +45,7 @@ async function main() {
|
|
|
40
45
|
return;
|
|
41
46
|
}
|
|
42
47
|
if (command === 'doctor') {
|
|
43
|
-
const
|
|
44
|
-
const checks = [
|
|
45
|
-
['node >= 24', Number(process.versions.node.split('.')[0]) >= 24],
|
|
46
|
-
['codex cli available', hasConfiguredCodexBin(configuredCodexBin) || hasCommand('codex')],
|
|
47
|
-
['telegram bot token configured', Boolean(process.env.TG_BOT_TOKEN)],
|
|
48
|
-
['telegram allowed user configured', Boolean(process.env.TG_ALLOWED_USER_ID)],
|
|
49
|
-
];
|
|
50
|
-
if (process.env.WX_ENABLED === 'true' || process.env.WX_ENABLED === '1') {
|
|
51
|
-
const accountsDir = process.env.WEIXIN_ACCOUNTS_DIR || path.join(APP_HOME, 'weixin', 'accounts');
|
|
52
|
-
let hasAccounts = false;
|
|
53
|
-
try {
|
|
54
|
-
if (fs.existsSync(accountsDir)) {
|
|
55
|
-
hasAccounts = fs.readdirSync(accountsDir).some((n) => n.endsWith('.json'));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
catch {
|
|
59
|
-
hasAccounts = false;
|
|
60
|
-
}
|
|
61
|
-
checks.push(['WX_ENABLED: Weixin account JSON present', hasAccounts]);
|
|
62
|
-
checks.push(['WX_ALLOWED_ILINK_USER_IDS set (recommended)', Boolean(process.env.WX_ALLOWED_ILINK_USER_IDS?.trim())]);
|
|
63
|
-
}
|
|
64
|
-
let failed = false;
|
|
65
|
-
for (const [name, ok] of checks) {
|
|
66
|
-
console.log(`${ok ? '[OK]' : '[FAIL]'} ${name}`);
|
|
67
|
-
if (!ok)
|
|
68
|
-
failed = true;
|
|
69
|
-
}
|
|
70
|
-
try {
|
|
71
|
-
const cwd = process.env.DEFAULT_CWD || process.cwd();
|
|
72
|
-
fs.accessSync(cwd);
|
|
73
|
-
console.log(`[OK] default cwd exists: ${cwd}`);
|
|
74
|
-
}
|
|
75
|
-
catch {
|
|
76
|
-
const cwd = process.env.DEFAULT_CWD || process.cwd();
|
|
77
|
-
console.log(`[FAIL] default cwd missing: ${cwd}`);
|
|
78
|
-
failed = true;
|
|
79
|
-
}
|
|
48
|
+
const failed = !runDoctorChecks();
|
|
80
49
|
process.exit(failed ? 1 : 0);
|
|
81
50
|
}
|
|
82
51
|
if (command === 'weixin-login') {
|
|
@@ -177,6 +146,58 @@ function initConfig() {
|
|
|
177
146
|
console.log(`Created ${envPath}`);
|
|
178
147
|
console.log('Edit it, then run: foxclaw doctor');
|
|
179
148
|
}
|
|
149
|
+
function startService() {
|
|
150
|
+
if (!runDoctorChecks()) {
|
|
151
|
+
console.error('');
|
|
152
|
+
console.error('Fix the failed checks above, then run: foxclaw start');
|
|
153
|
+
process.exit(1);
|
|
154
|
+
}
|
|
155
|
+
if (process.platform === 'darwin') {
|
|
156
|
+
installLaunchd();
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
installSystemd();
|
|
160
|
+
}
|
|
161
|
+
function runDoctorChecks() {
|
|
162
|
+
const configuredCodexBin = process.env.CODEX_CLI_BIN;
|
|
163
|
+
const checks = [
|
|
164
|
+
['node >= 24', Number(process.versions.node.split('.')[0]) >= 24],
|
|
165
|
+
['codex cli available', hasConfiguredCodexBin(configuredCodexBin) || hasCommand('codex')],
|
|
166
|
+
['telegram bot token configured', Boolean(process.env.TG_BOT_TOKEN)],
|
|
167
|
+
['telegram allowed user configured', Boolean(process.env.TG_ALLOWED_USER_ID)],
|
|
168
|
+
];
|
|
169
|
+
if (process.env.WX_ENABLED === 'true' || process.env.WX_ENABLED === '1') {
|
|
170
|
+
const accountsDir = process.env.WEIXIN_ACCOUNTS_DIR || path.join(APP_HOME, 'weixin', 'accounts');
|
|
171
|
+
let hasAccounts = false;
|
|
172
|
+
try {
|
|
173
|
+
if (fs.existsSync(accountsDir)) {
|
|
174
|
+
hasAccounts = fs.readdirSync(accountsDir).some((n) => n.endsWith('.json'));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
hasAccounts = false;
|
|
179
|
+
}
|
|
180
|
+
checks.push(['WX_ENABLED: Weixin account JSON present', hasAccounts]);
|
|
181
|
+
checks.push(['WX_ALLOWED_ILINK_USER_IDS set (recommended)', Boolean(process.env.WX_ALLOWED_ILINK_USER_IDS?.trim())]);
|
|
182
|
+
}
|
|
183
|
+
let passed = true;
|
|
184
|
+
for (const [name, ok] of checks) {
|
|
185
|
+
console.log(`${ok ? '[OK]' : '[FAIL]'} ${name}`);
|
|
186
|
+
if (!ok)
|
|
187
|
+
passed = false;
|
|
188
|
+
}
|
|
189
|
+
try {
|
|
190
|
+
const cwd = process.env.DEFAULT_CWD || process.cwd();
|
|
191
|
+
fs.accessSync(cwd);
|
|
192
|
+
console.log(`[OK] default cwd exists: ${cwd}`);
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
const cwd = process.env.DEFAULT_CWD || process.cwd();
|
|
196
|
+
console.log(`[FAIL] default cwd missing: ${cwd}`);
|
|
197
|
+
passed = false;
|
|
198
|
+
}
|
|
199
|
+
return passed;
|
|
200
|
+
}
|
|
180
201
|
function installSystemd() {
|
|
181
202
|
if (!hasCommand('systemctl')) {
|
|
182
203
|
console.error('systemctl not found (need systemd)');
|
|
@@ -44,10 +44,8 @@ Tasks:
|
|
|
44
44
|
4. Install or update FoxClaw with npm install -g @foxden-app/foxclaw@latest.
|
|
45
45
|
5. Run foxclaw init, then write ~/.foxclaw/.env. Never print or commit the bot token.
|
|
46
46
|
6. Run foxclaw doctor.
|
|
47
|
-
7. Start FoxClaw
|
|
48
|
-
8.
|
|
49
|
-
- Linux: foxclaw install-systemd
|
|
50
|
-
- macOS: foxclaw install-launchd
|
|
47
|
+
7. Start FoxClaw with foxclaw start.
|
|
48
|
+
8. Ask me to send /help and /status to the Telegram bot.
|
|
51
49
|
9. Verify the final state:
|
|
52
50
|
- foxclaw.service is active/enabled on Linux
|
|
53
51
|
- old telegram-codex-app-bridge.service is inactive/disabled if present
|
|
@@ -72,7 +70,7 @@ Please:
|
|
|
72
70
|
4. Install or update FoxClaw with npm install -g @foxden-app/foxclaw@latest.
|
|
73
71
|
5. Run foxclaw init if ~/.foxclaw/.env does not exist, then verify ~/.foxclaw/.env.
|
|
74
72
|
6. Run foxclaw doctor.
|
|
75
|
-
7. Install
|
|
73
|
+
7. Install or restart the FoxClaw service with foxclaw start.
|
|
76
74
|
8. Verify foxclaw.service is active and telegram-codex-app-bridge.service is inactive/disabled.
|
|
77
75
|
9. Report final status and any blockers. Redact TG_BOT_TOKEN and never print the full token or full .env content.
|
|
78
76
|
```
|
|
@@ -83,4 +81,4 @@ Please:
|
|
|
83
81
|
- Do not commit `.env`.
|
|
84
82
|
- When reporting results, redact `TG_BOT_TOKEN`.
|
|
85
83
|
- Do not use `/` or your whole home directory as `DEFAULT_CWD` for a first install.
|
|
86
|
-
-
|
|
84
|
+
- Use `foxclaw start` for normal service startup. Use foreground `foxclaw serve` only when troubleshooting.
|
|
@@ -11,7 +11,7 @@ Before you start:
|
|
|
11
11
|
- Do not configure a Telegram group first. Use private chat first.
|
|
12
12
|
- Do not send your bot token to anyone you do not trust.
|
|
13
13
|
- Do not use `/`, `/Users`, `/home`, or your whole home directory as `DEFAULT_CWD` for the first install.
|
|
14
|
-
-
|
|
14
|
+
- Use `foxclaw start` for normal startup. Use foreground mode only when troubleshooting.
|
|
15
15
|
|
|
16
16
|
## 1. Prepare
|
|
17
17
|
|
|
@@ -183,15 +183,15 @@ You want to see:
|
|
|
183
183
|
|
|
184
184
|
If you see `[FAIL]`, stop and check [Troubleshooting](./troubleshooting.md).
|
|
185
185
|
|
|
186
|
-
## 9. Start
|
|
186
|
+
## 9. Start FoxClaw
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
Start or restart the background service:
|
|
189
189
|
|
|
190
190
|
```bash
|
|
191
|
-
foxclaw
|
|
191
|
+
foxclaw start
|
|
192
192
|
```
|
|
193
193
|
|
|
194
|
-
|
|
194
|
+
This command is safe to run again. It runs the same checks as `doctor`, then installs or restarts the service for your platform.
|
|
195
195
|
|
|
196
196
|
Now open your Telegram bot and send:
|
|
197
197
|
|
|
@@ -229,16 +229,11 @@ Create a short README-style summary of this folder.
|
|
|
229
229
|
/interrupt
|
|
230
230
|
```
|
|
231
231
|
|
|
232
|
-
|
|
232
|
+
## 10. Service Commands
|
|
233
233
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
Only do this after foreground mode works.
|
|
237
|
-
|
|
238
|
-
On Linux with systemd:
|
|
234
|
+
On Linux, `foxclaw start` manages a user-level systemd service. Check it with:
|
|
239
235
|
|
|
240
236
|
```bash
|
|
241
|
-
foxclaw install-systemd
|
|
242
237
|
systemctl --user status foxclaw.service
|
|
243
238
|
journalctl --user -u foxclaw.service -f
|
|
244
239
|
```
|
|
@@ -249,13 +244,9 @@ The service starts again when your user session starts. If you need it to start
|
|
|
249
244
|
loginctl enable-linger "$USER"
|
|
250
245
|
```
|
|
251
246
|
|
|
252
|
-
On macOS
|
|
253
|
-
|
|
254
|
-
```bash
|
|
255
|
-
foxclaw install-launchd
|
|
256
|
-
```
|
|
247
|
+
On macOS, `foxclaw start` manages launchd and starts FoxClaw when you log in.
|
|
257
248
|
|
|
258
|
-
|
|
249
|
+
For foreground debugging, stop the service first and then run `foxclaw serve`.
|
|
259
250
|
|
|
260
251
|
## 11. Day-To-Day Commands
|
|
261
252
|
|
|
@@ -268,7 +259,7 @@ foxclaw status
|
|
|
268
259
|
Restart Linux service after changing `.env`:
|
|
269
260
|
|
|
270
261
|
```bash
|
|
271
|
-
|
|
262
|
+
foxclaw start
|
|
272
263
|
```
|
|
273
264
|
|
|
274
265
|
Stop Linux service:
|
|
@@ -287,5 +278,5 @@ Update FoxClaw later:
|
|
|
287
278
|
|
|
288
279
|
```bash
|
|
289
280
|
npm install -g @foxden-app/foxclaw@latest
|
|
290
|
-
|
|
281
|
+
foxclaw start
|
|
291
282
|
```
|
package/docs/troubleshooting.md
CHANGED
|
@@ -18,7 +18,7 @@ journalctl --user -u foxclaw.service -f
|
|
|
18
18
|
|
|
19
19
|
| Symptom | Meaning | Fix |
|
|
20
20
|
| --- | --- | --- |
|
|
21
|
-
| `[FAIL] node >= 24` | Your current shell is using an older Node.js. | Run `nvm install 24 && nvm use 24`, then rerun `foxclaw doctor`. If the service uses old Node, reinstall it from a Node 24 shell with `foxclaw
|
|
21
|
+
| `[FAIL] node >= 24` | Your current shell is using an older Node.js. | Run `nvm install 24 && nvm use 24`, then rerun `foxclaw doctor`. If the service uses old Node, reinstall it from a Node 24 shell with `foxclaw start`. |
|
|
22
22
|
| `[FAIL] codex cli available` | The `codex` command is not in PATH. | Install Codex CLI or fix PATH, then confirm `codex --version` works. |
|
|
23
23
|
| `[FAIL] telegram bot token configured` | `TG_BOT_TOKEN` is missing from `.env`. | Copy the token from `@BotFather` into `.env`. |
|
|
24
24
|
| `[FAIL] telegram allowed user configured` | `TG_ALLOWED_USER_ID` is missing from `.env`. | Get your numeric id from `@userinfobot` and add it to `.env`. |
|
|
@@ -93,7 +93,7 @@ Check these in order:
|
|
|
93
93
|
5. Restart after changing `.env`:
|
|
94
94
|
|
|
95
95
|
```bash
|
|
96
|
-
|
|
96
|
+
foxclaw start
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
If running foreground mode, stop with `Ctrl+C` and run `foxclaw serve` again.
|
|
@@ -145,7 +145,7 @@ systemctl --user disable --now telegram-codex-app-bridge.service
|
|
|
145
145
|
Then restart FoxClaw:
|
|
146
146
|
|
|
147
147
|
```bash
|
|
148
|
-
|
|
148
|
+
foxclaw start
|
|
149
149
|
```
|
|
150
150
|
|
|
151
151
|
## Codex Or App-Server Fails
|
|
@@ -194,7 +194,7 @@ The systemd installer captures the `node` binary from your current PATH. If you
|
|
|
194
194
|
|
|
195
195
|
```bash
|
|
196
196
|
nvm use 24
|
|
197
|
-
foxclaw
|
|
197
|
+
foxclaw start
|
|
198
198
|
systemctl --user status foxclaw.service
|
|
199
199
|
```
|
|
200
200
|
|
|
@@ -217,7 +217,7 @@ loginctl enable-linger "$USER"
|
|
|
217
217
|
macOS launchd starts FoxClaw when you log in after running:
|
|
218
218
|
|
|
219
219
|
```bash
|
|
220
|
-
foxclaw
|
|
220
|
+
foxclaw start
|
|
221
221
|
```
|
|
222
222
|
|
|
223
223
|
## Migrating From The Old Project Name
|
|
@@ -230,7 +230,7 @@ test -e ~/.foxclaw || cp -a ~/.telegram-codex-app-bridge ~/.foxclaw
|
|
|
230
230
|
npm install -g @foxden-app/foxclaw@latest
|
|
231
231
|
foxclaw init
|
|
232
232
|
foxclaw doctor
|
|
233
|
-
foxclaw
|
|
233
|
+
foxclaw start
|
|
234
234
|
```
|
|
235
235
|
|
|
236
236
|
If `~/.foxclaw/.env` already exists, `foxclaw init` leaves it untouched.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foxden-app/foxclaw",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Foxden local execution claw for controlling Codex from trusted chat interfaces.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"build": "npm run clean && tsc -p tsconfig.build.json",
|
|
38
38
|
"dev": "tsx src/main.ts serve",
|
|
39
39
|
"serve": "node dist/main.js serve",
|
|
40
|
+
"start-service": "node dist/main.js start",
|
|
40
41
|
"weixin-login": "node dist/main.js weixin-login",
|
|
41
42
|
"status": "node dist/main.js status",
|
|
42
43
|
"doctor": "node dist/main.js doctor",
|