@foxden-app/foxclaw 0.2.7 → 0.3.1

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,461 @@
1
+ # FoxClaw User Manual
2
+
3
+ FoxClaw wraps your local Codex into a phone-controllable service. Telegram or Weixin provides the chat surface, FoxClaw handles auth, thread binding, approvals, setup panels, and account switching, and your local `codex app-server` performs the actual coding work.
4
+
5
+ Typical flow:
6
+
7
+ ```text
8
+ Telegram/Weixin on your phone
9
+ -> FoxClaw bot
10
+ -> local FoxClaw service
11
+ -> codex app-server
12
+ -> DEFAULT_CWD or the current thread cwd
13
+ ```
14
+
15
+ Your code, shell access, Codex auth, and runtime state stay on the host machine. For a first install, use Telegram private chat before configuring groups, topics, or Weixin.
16
+
17
+ ## 1. Full Setup
18
+
19
+ ### 1.1 Install Node.js 24
20
+
21
+ FoxClaw requires Node.js 24. Check first:
22
+
23
+ ```bash
24
+ node -v
25
+ ```
26
+
27
+ If this is not `v24...`, install Node 24 with `nvm`:
28
+
29
+ ```bash
30
+ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
31
+ export NVM_DIR="$HOME/.nvm"
32
+ [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
33
+ nvm install 24
34
+ nvm use 24
35
+ node -v
36
+ ```
37
+
38
+ ### 1.2 Install And Log In To Codex
39
+
40
+ FoxClaw does not create a Codex account. It uses the Codex CLI already logged in on this machine.
41
+
42
+ ```bash
43
+ npm install -g @openai/codex
44
+ codex login
45
+ codex --version
46
+ ```
47
+
48
+ `codex --version` only proves the command exists. To verify auth, start Codex and run a tiny request:
49
+
50
+ ```bash
51
+ codex
52
+ ```
53
+
54
+ Then type:
55
+
56
+ ```text
57
+ Say ready and exit.
58
+ ```
59
+
60
+ If Codex answers normally, FoxClaw has a working execution backend.
61
+
62
+ ### 1.3 Create A Telegram Bot
63
+
64
+ 1. Open Telegram.
65
+ 2. Search for `@BotFather`.
66
+ 3. Send `/newbot`.
67
+ 4. Follow the prompts to choose a bot name and username.
68
+ 5. Copy the bot token. It looks like `123456789:AA...`.
69
+
70
+ Keep this token private. Anyone with the token can control the bot.
71
+
72
+ ### 1.4 Get Your Numeric Telegram User ID
73
+
74
+ FoxClaw only responds to the user configured in `TG_ALLOWED_USER_ID`.
75
+
76
+ 1. Open Telegram.
77
+ 2. Search for `@userinfobot`.
78
+ 3. Send any message or press Start.
79
+ 4. Copy the numeric `Id`.
80
+
81
+ Use the number, not your `@username`.
82
+
83
+ ### 1.5 Install FoxClaw
84
+
85
+ If you use pnpm for global packages:
86
+
87
+ ```bash
88
+ pnpm add -g @foxden-app/foxclaw
89
+ foxclaw init
90
+ ```
91
+
92
+ If you use npm:
93
+
94
+ ```bash
95
+ npm install -g @foxden-app/foxclaw
96
+ foxclaw init
97
+ ```
98
+
99
+ Both install the same published npm package. Use one global package manager consistently on a machine to avoid multiple versions in PATH.
100
+
101
+ ### 1.6 Fill In The Config
102
+
103
+ The default config file is `~/.foxclaw/.env`:
104
+
105
+ ```bash
106
+ $EDITOR ~/.foxclaw/.env
107
+ ```
108
+
109
+ Minimum private-chat config:
110
+
111
+ ```dotenv
112
+ TG_BOT_TOKEN=123456789:replace_with_your_bot_token
113
+ TG_ALLOWED_USER_ID=123456789
114
+ TG_ALLOWED_CHAT_ID=
115
+ TG_ALLOWED_TOPIC_ID=
116
+ DEFAULT_CWD=/absolute/path/to/workspace
117
+ DEFAULT_APPROVAL_POLICY=on-request
118
+ DEFAULT_SANDBOX_MODE=workspace-write
119
+ ```
120
+
121
+ Fields:
122
+
123
+ - `TG_BOT_TOKEN`: the token from `@BotFather`.
124
+ - `TG_ALLOWED_USER_ID`: your numeric Telegram user id.
125
+ - `TG_ALLOWED_CHAT_ID`: leave empty for the first private-chat setup.
126
+ - `TG_ALLOWED_TOPIC_ID`: leave empty unless binding a Telegram topic.
127
+ - `DEFAULT_CWD`: the default directory where Codex works; it must exist.
128
+ - `DEFAULT_APPROVAL_POLICY`: `on-request` is a good first value.
129
+ - `DEFAULT_SANDBOX_MODE`: `workspace-write` is a good first value.
130
+
131
+ ### 1.7 Check And Start
132
+
133
+ ```bash
134
+ foxclaw doctor
135
+ foxclaw start
136
+ foxclaw status
137
+ ```
138
+
139
+ Linux service logs:
140
+
141
+ ```bash
142
+ systemctl --user status foxclaw.service
143
+ journalctl --user -u foxclaw.service -f
144
+ ```
145
+
146
+ On macOS, `foxclaw start` manages launchd. For foreground debugging, stop the background service and run:
147
+
148
+ ```bash
149
+ foxclaw stop
150
+ foxclaw serve
151
+ ```
152
+
153
+ ### 1.8 First Telegram Test
154
+
155
+ Open a private chat with your bot and send:
156
+
157
+ ```text
158
+ /help
159
+ ```
160
+
161
+ ```text
162
+ /status
163
+ ```
164
+
165
+ ```text
166
+ /setup
167
+ ```
168
+
169
+ Then send a normal request:
170
+
171
+ ```text
172
+ List files in DEFAULT_CWD.
173
+ ```
174
+
175
+ If Codex replies, the basic path is working.
176
+
177
+ ## 2. Groups And Topics
178
+
179
+ Private chat is the safest first mode. Configure a group or topic only after private chat works.
180
+
181
+ ```dotenv
182
+ TG_ALLOWED_CHAT_ID=-1001234567890
183
+ TG_ALLOWED_TOPIC_ID=42
184
+ ```
185
+
186
+ - Leave `TG_ALLOWED_CHAT_ID` empty for private chat only.
187
+ - Set only `TG_ALLOWED_CHAT_ID` to allow one group as the default conversation scope.
188
+ - Set both values to bind one topic.
189
+ - Private chat still works for `TG_ALLOWED_USER_ID` when a group is configured.
190
+
191
+ Find group or topic IDs:
192
+
193
+ 1. Stop FoxClaw.
194
+ 2. Send a message in the target group or topic.
195
+ 3. Open:
196
+
197
+ ```text
198
+ https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates
199
+ ```
200
+
201
+ 4. Use `message.chat.id` as `TG_ALLOWED_CHAT_ID`.
202
+ 5. Use `message.message_thread_id` as `TG_ALLOWED_TOPIC_ID`.
203
+
204
+ If FoxClaw is still running, it may consume the update before you inspect it.
205
+
206
+ For group messages:
207
+
208
+ - Add the bot to the group.
209
+ - Disable privacy mode in `@BotFather`.
210
+ - Promote the bot to administrator.
211
+ - Test with a plain natural-language message, not only `/status@botname`.
212
+
213
+ ## 3. Commands
214
+
215
+ ### 3.1 `/help`
216
+
217
+ `/help` returns the available command list. The top entries are pinned:
218
+
219
+ ```text
220
+ /help
221
+ /setup
222
+ /status
223
+ /threads [query]
224
+ /auth
225
+ ```
226
+
227
+ Later commands are sorted by recent usage. Plain text, photos, and files continue the currently bound thread; if no thread is bound, FoxClaw creates one.
228
+
229
+ ### 3.2 `/status`, `/account`, `/quota`
230
+
231
+ - `/status`: FoxClaw, app-server, current thread binding, model, access, and Codex usage summary.
232
+ - `/account`: current Codex account.
233
+ - `/quota`: Codex usage and quota window.
234
+
235
+ ### 3.3 `/config`, `/requirements`, `/provider`
236
+
237
+ - `/config`: reads the Codex config summary for the bound thread cwd or `DEFAULT_CWD`, including `model`, `approval_policy`, `sandbox_mode`, and `service_tier`.
238
+ - `/requirements`: shows app-server constraints such as allowed approval, sandbox, and web search modes.
239
+ - `/provider`: shows the current Codex provider summary.
240
+
241
+ These are useful when the phone-side model, permission, or provider behavior does not match what you expected.
242
+
243
+ ## 4. The `/setup` Panel
244
+
245
+ `/setup` is one of the main mobile panels. Settings are scoped to the chat, so private chat, group, and topic can use different settings.
246
+
247
+ It controls:
248
+
249
+ - Model: server default, or a model returned by app-server.
250
+ - Reasoning effort: for example `low`, `medium`, `high`, or `xhigh`, depending on model support.
251
+ - Fast tier: available when supported by the selected model.
252
+ - Access: `read-only`, `default`, or `full-access`.
253
+ - Mode: `Agent` or `Plan`.
254
+ - Active turn behavior: steer the current turn, or queue the message for the next turn.
255
+
256
+ Telegram renders the HTML and buttons. This text block approximates the real panel:
257
+
258
+ ```text
259
+ Session preferences
260
+ Current: gpt-5.5 · high · fast=off · default · Agent · Steer current turn
261
+ Focus: Model
262
+
263
+ Model: gpt-5.5
264
+ Effort: high
265
+ Fast: off
266
+ Access: Default (on-request / workspace-write)
267
+ Mode: Agent
268
+ Active turn: Steer current turn
269
+
270
+ [Auto] [gpt-5.5]
271
+ [low] [medium] [high]
272
+ [⚡ Fast on] [Fast off]
273
+ [👁️ Read-only] [🛡️ Default] [🔓 Full access]
274
+ [Agent] [📝 Plan]
275
+ [Steer current turn] [Queue next turn]
276
+ ```
277
+
278
+ Command aliases:
279
+
280
+ - `/model <model|default>`: switch model.
281
+ - `/effort <effort|default>`: switch reasoning effort.
282
+ - `/permissions [read-only|default|full-access]`: switch access preset.
283
+ - `/mode [default|plan]`: switch Agent/Plan.
284
+ - `/active <steer|queue>`: control how new messages behave during an active turn.
285
+
286
+ ## 5. Threads And Watch
287
+
288
+ FoxClaw chats are bound to Codex threads. Once you open a thread from your phone, normal messages continue that thread.
289
+
290
+ Common commands:
291
+
292
+ - `/threads [query]`: list recent threads, optionally filtered by keyword.
293
+ - `/threads archived [query]`: list archived threads.
294
+ - `/open <n>`: open item n from the latest `/threads` list and bind this chat.
295
+ - `/new [cwd]`: create a new thread in a cwd, or in the default cwd.
296
+ - `/where`: show the current thread, cwd, and settings.
297
+ - `/rename <name>`: rename the current thread.
298
+ - `/archive`: archive the current thread.
299
+ - `/interrupt`: interrupt the current running turn.
300
+
301
+ Threads panel approximation:
302
+
303
+ ```text
304
+ Recent threads
305
+ Tap a button below to open or manage a thread.
306
+ Showing 1-5
307
+ Current: fix auth rotation
308
+ ~/Projects/foxclaw | 3 minutes ago | idle
309
+
310
+ [🧵 1. fix auth rotation]
311
+ [✏️] [👀] [🗑️] [➕]
312
+
313
+ [🧵 2. polish README copy]
314
+ [✏️] [👀] [🗑️] [➕]
315
+
316
+ [➕ New]
317
+ [➡️ Next]
318
+ [🗄️ Archived]
319
+ ```
320
+
321
+ ### `/watch`
322
+
323
+ `/watch` observes a thread even if the task was started elsewhere. A common workflow is starting a long Codex CLI task at your desk, then watching it from your phone.
324
+
325
+ Usage:
326
+
327
+ - `/watch`: watch the currently bound thread.
328
+ - `/watch <n>`: watch item n from the latest `/threads` list.
329
+ - `/unwatch`: stop watching.
330
+
331
+ Watch mode mirrors live turn progress and approval requests. The watching chat is read-only for normal prompts during the observed turn. Send `/unwatch` before starting a new prompt from that chat, or wait for the turn to finish.
332
+
333
+ ## 6. Codex Login And Auth Rotation
334
+
335
+ This is a key FoxClaw feature. Codex auth is usually stored at `~/.codex/auth.json`. FoxClaw stores multiple accounts as candidate files and switches which candidate the active `auth.json` points to.
336
+
337
+ ### 6.1 File Format
338
+
339
+ Candidate files live in the Codex auth directory, usually `~/.codex/`. If `CODEX_AUTH_DIR` is set, FoxClaw uses that directory.
340
+
341
+ Recommended layout:
342
+
343
+ ```text
344
+ ~/.codex/
345
+ auth.json -> /home/alice/.codex/auth.json_personal
346
+ auth.json_personal
347
+ auth.json_team
348
+ auth.json_plus_trial
349
+ ```
350
+
351
+ FoxClaw recognizes candidate names in these forms:
352
+
353
+ - `auth.json_<name>`
354
+ - `auth.json.<name>`
355
+ - `auth.json-<name>`
356
+
357
+ `auth.json` is what Codex currently uses. When switching accounts, FoxClaw points `auth.json` at one candidate. Candidate contents are Codex-generated JSON; FoxClaw treats those private fields as opaque and you should not hand-write them.
358
+
359
+ If you already have a working `auth.json`, you can save it as a candidate:
360
+
361
+ ```bash
362
+ cp -L ~/.codex/auth.json ~/.codex/auth.json_personal
363
+ ```
364
+
365
+ The safer path is adding candidates from the phone with `/auth add <name>`.
366
+
367
+ ### 6.2 Login Commands
368
+
369
+ - `/login_device`: starts ChatGPT device login for the current `auth.json`. FoxClaw sends a login URL, short code, login id, and cancel command.
370
+ - `/login_cancel [id]`: cancels an in-progress device login.
371
+ - `/logout confirm`: logs out the current Codex account.
372
+ - `/auth add <name>`: adds a candidate account. For example, `/auth add work` creates `auth.json_work` and starts device login.
373
+
374
+ `/auth add <name>` flow:
375
+
376
+ 1. FoxClaw prepares `auth.json_<name>`.
377
+ 2. It temporarily points `auth.json` at that candidate.
378
+ 3. It restarts app-server so Codex writes into the new candidate.
379
+ 4. It sends the login URL and short code.
380
+ 5. You complete login in the browser.
381
+ 6. The candidate appears in `/auth`.
382
+
383
+ If the login is cancelled or fails, FoxClaw tries to restore the previous auth target and remove the unfinished candidate.
384
+
385
+ ### 6.3 The `/auth` Panel
386
+
387
+ `/auth` lists candidate accounts, the current account, and the auth directory. It also provides buttons for switching, disabling, login, and reload.
388
+
389
+ Approximation:
390
+
391
+ ```text
392
+ Codex auth
393
+ Current: auth.json_personal
394
+ Auth dir: /home/alice/.codex
395
+ Candidates: 2
396
+ 1. auth.json_personal * [enabled]
397
+ 2. auth.json_team [enabled]
398
+
399
+ [✅ auth.json_personal] [✅]
400
+ [🔐 auth.json_team] [✅]
401
+ [🛡️ Access] [🔑 Login]
402
+ [🔄 Reload auth]
403
+ ```
404
+
405
+ The right-side `✅` / `⏸️` button shows the current state. Tapping it toggles enabled/disabled, and the refreshed list shows the new state.
406
+
407
+ Equivalent commands:
408
+
409
+ - `/auth` or `/auth list`: show candidates.
410
+ - `/auth use <n>`: switch to candidate n and restart app-server.
411
+ - `/auth enable <n>`: let candidate n participate in auto-rotation.
412
+ - `/auth disable <n>`: skip candidate n during auto-rotation.
413
+ - `/auth reload` or `/auth_reload`: restart app-server and reload the current `auth.json`.
414
+
415
+ If active turns, pending approvals, pending user inputs, or MCP elicitations exist, FoxClaw refuses manual auth switching to avoid changing accounts mid-request.
416
+
417
+ ### 6.4 How Auto-Rotation Works
418
+
419
+ When Codex reports a usage limit, missing login, expired auth, or similar auth error, FoxClaw tries to rotate automatically:
420
+
421
+ 1. Record the failed candidate.
422
+ 2. Select the next enabled candidate that has not already failed in this retry cycle.
423
+ 3. Point `auth.json` at that candidate.
424
+ 4. Restart `codex app-server` so the new auth is loaded.
425
+ 5. Retry the failed request with the new account.
426
+
427
+ Disabled candidates are skipped. If no candidate is available, FoxClaw reports the error back to the phone and stops retrying.
428
+
429
+ Example account layout:
430
+
431
+ ```text
432
+ auth.json_personal # primary account
433
+ auth.json_team # Team or work account
434
+ auth.json_plus_trial # trial account
435
+ auth.json_backup # backup account, enable or disable as needed
436
+ ```
437
+
438
+ ## 7. Daily Workflow
439
+
440
+ 1. Enter the project directory on your computer and make sure Codex works.
441
+ 2. From your phone, send `/new /home/alice/Projects/app`, or use `/threads` to open an existing thread.
442
+ 3. Use `/setup` to choose model, effort, access, and Agent/Plan mode.
443
+ 4. Send a task, for example: `Fix the failing test and run the related test suite.`
444
+ 5. Step away from the computer and watch progress on your phone.
445
+ 6. Approve or deny command and file-change requests from Telegram.
446
+ 7. To observe a task started from Codex CLI, use `/threads`, then tap `👀` or send `/watch <n>`.
447
+ 8. When quota is hit, let `/auth` candidates auto-rotate, or switch manually with `/auth use <n>`.
448
+
449
+ ## 8. Safety
450
+
451
+ - Do not share `TG_BOT_TOKEN`, `~/.codex/auth.json*`, or `.env`.
452
+ - Do not use `/`, `/home`, `/Users`, or your whole home directory as the first `DEFAULT_CWD`.
453
+ - When unsure, use `/permissions read-only` or select `Read-only` in `/setup`.
454
+ - Group mode still only accepts `TG_ALLOWED_USER_ID`, but use trusted groups.
455
+ - Multi-account files are Codex login credentials. Treat backups and sync tools accordingly.
456
+
457
+ ## 9. More Reading
458
+
459
+ - [Beginner Install Guide](./install-for-beginners.md)
460
+ - [Agent-Assisted Install](./agent-assisted-install.md)
461
+ - [Troubleshooting](./troubleshooting.md)
@@ -257,13 +257,13 @@ foxclaw status
257
257
  修改 `.env` 后重启:
258
258
 
259
259
  ```bash
260
- foxclaw start
260
+ foxclaw restart
261
261
  ```
262
262
 
263
- 停止 Linux 服务:
263
+ 停止服务:
264
264
 
265
265
  ```bash
266
- systemctl --user stop foxclaw.service
266
+ foxclaw stop
267
267
  ```
268
268
 
269
269
  卸载 Linux 服务:
@@ -293,3 +293,7 @@ foxclaw start
293
293
  ```
294
294
 
295
295
  如果 `~/.foxclaw/.env` 已经存在,`foxclaw init` 不会覆盖它。
296
+
297
+ ## 下一步
298
+
299
+ 安装跑通后,继续看 [用户手册](./user-manual.md),里面系统说明了 `/help`、`/setup`、`/threads`、`/watch`、`/auth`、Codex 登录和多账号轮转。
@@ -94,7 +94,7 @@ CODEX_CLI_BIN=/absolute/path/to/codex
94
94
  5. 修改 `.env` 后重启:
95
95
 
96
96
  ```bash
97
- foxclaw start
97
+ foxclaw restart
98
98
  ```
99
99
 
100
100
  如果正在前台运行,先 `Ctrl+C` 停止,再重新运行 `foxclaw serve`。
@@ -146,7 +146,7 @@ systemctl --user disable --now telegram-codex-app-bridge.service
146
146
  然后重启 FoxClaw:
147
147
 
148
148
  ```bash
149
- foxclaw start
149
+ foxclaw restart
150
150
  ```
151
151
 
152
152
  ## Codex 或 app-server 异常