@foxden-app/foxclaw 0.2.3 → 0.2.4

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 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 serve
41
+ foxclaw start
42
42
  ```
43
43
 
44
44
  pnpm 用户可以使用:
@@ -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 serve
51
+ foxclaw start
52
52
  ```
53
53
 
54
- 运行 `doctor` 或 `serve` 前先编辑 `.env`。私聊模式的最小配置:
54
+ 运行 `doctor` 或 `start` 前先编辑 `.env`。私聊模式的最小配置:
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
  默认配置文件是 `~/.foxclaw/.env`。如果你想把配置放在别处,可以设置 `FOXCLAW_ENV=/path/to/.env`。
65
65
 
66
+ `foxclaw start` 会运行检查并安装或重启后台服务;这个命令是幂等的,升级后可以再执行一次。
67
+
66
68
  FoxClaw 只接受来自 `TG_ALLOWED_USER_ID` 的消息。把机器人放进群组并不会让每个群成员都能使用它。
67
69
 
68
70
  <details>
@@ -83,20 +85,25 @@ FoxClaw 只接受来自 `TG_ALLOWED_USER_ID` 的消息。把机器人放进群
83
85
 
84
86
  </details>
85
87
 
86
- ## 作为服务安装
88
+ ## 服务与调试
89
+
90
+ 推荐使用:
87
91
 
88
- Linux 用户级 systemd:
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
- macOS launchd:
103
+ 前台调试时可以直接运行:
97
104
 
98
105
  ```bash
99
- foxclaw install-launchd
106
+ foxclaw serve
100
107
  ```
101
108
 
102
109
  默认运行时文件存储在 `~/.foxclaw`:
@@ -118,14 +125,14 @@ FoxClaw 最初 fork 自 `Gan-Xing/telegram-codex-app-bridge`,并继续以 MIT
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 install-systemd
128
+ foxclaw start
122
129
  ```
123
130
 
124
131
  如果使用 launchd 安装,先卸载旧 plist(如存在):
125
132
 
126
133
  ```bash
127
134
  launchctl unload ~/Library/LaunchAgents/com.ganxing.telegram-codex-app-bridge.plist 2>/dev/null || true
128
- foxclaw install-launchd
135
+ foxclaw start
129
136
  ```
130
137
 
131
138
  旧运行时目录不会被自动读取。如果你想保留现有绑定、缓存线程列表、审批和状态数据,请手动复制一次。
@@ -134,7 +141,7 @@ foxclaw install-launchd
134
141
 
135
142
  1. 使用 `@BotFather` 创建机器人,并把 token 填入 `TG_BOT_TOKEN`。
136
143
  2. 获取你的 Telegram 数字用户 ID,并填入 `TG_ALLOWED_USER_ID`。
137
- 3. 使用 `foxclaw serve` 或服务安装器启动 FoxClaw。
144
+ 3. 使用 `foxclaw start` 启动 FoxClaw。
138
145
  4. 打开与机器人的私聊并发送 `/help`。
139
146
 
140
147
  可选的群组/话题配置:
@@ -243,7 +250,7 @@ foxclaw weixin-login
243
250
  ```bash
244
251
  foxclaw doctor
245
252
  foxclaw status
246
- foxclaw install-systemd
253
+ foxclaw start
247
254
  foxclaw uninstall-systemd
248
255
  ```
249
256
 
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 serve
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 serve
51
+ foxclaw start
52
52
  ```
53
53
 
54
- Edit `.env` before running `doctor` or `serve`. Minimum private-chat config:
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
- ## Installing As A Service
88
+ ## Service And Debugging
89
+
90
+ Recommended:
87
91
 
88
- Linux user systemd:
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
- macOS launchd:
103
+ For foreground debugging:
97
104
 
98
105
  ```bash
99
- foxclaw install-launchd
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 install-systemd
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 install-launchd
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 serve` or the service installer.
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 install-systemd
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 configuredCodexBin = process.env.CODEX_CLI_BIN;
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 in the foreground with foxclaw serve and ask me to send /help and /status to the Telegram bot.
48
- 8. Only after the foreground test works, install the background service:
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 and start foxclaw.service with foxclaw install-systemd.
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
- - Do not install the background service before the foreground Telegram test works.
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
- - Do not install the background service until foreground mode replies to `/help` and `/status`.
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 In The Foreground First
186
+ ## 9. Start FoxClaw
187
187
 
188
- Run FoxClaw directly before installing it as a background service:
188
+ Start or restart the background service:
189
189
 
190
190
  ```bash
191
- foxclaw serve
191
+ foxclaw start
192
192
  ```
193
193
 
194
- Leave this terminal open.
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
- Stop the foreground process with `Ctrl+C` after the bot works.
232
+ ## 10. Service Commands
233
233
 
234
- ## 10. Install As A Background Service
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
- launchd starts FoxClaw when you log in.
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
- systemctl --user restart foxclaw.service
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
- systemctl --user restart foxclaw.service
281
+ foxclaw start
291
282
  ```
@@ -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 install-systemd`. |
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
- systemctl --user restart foxclaw.service
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
- systemctl --user restart foxclaw.service
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 install-systemd
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 install-launchd
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 install-systemd
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",
3
+ "version": "0.2.4",
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",