@foxden-app/foxclaw 0.3.17 → 0.3.19
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/.env.example +5 -2
- package/README.md +14 -4
- package/README_EN.md +14 -4
- package/dist/auth/mirror.d.ts +25 -0
- package/dist/auth/mirror.js +199 -0
- package/dist/codex_app/client.d.ts +2 -1
- package/dist/codex_app/client.js +10 -2
- package/dist/codex_app/local_usage.d.ts +7 -6
- package/dist/codex_app/local_usage.js +55 -66
- package/dist/config.d.ts +7 -0
- package/dist/config.js +18 -1
- package/dist/controller/controller.d.ts +14 -2
- package/dist/controller/controller.js +110 -34
- package/dist/core/bridge_scope.d.ts +5 -2
- package/dist/core/bridge_scope.js +7 -3
- package/dist/i18n.d.ts +4 -4
- package/dist/i18n.js +4 -4
- package/dist/main.js +144 -9
- package/dist/store/database.d.ts +4 -2
- package/dist/store/database.js +42 -6
- package/dist/telegram/addressing.d.ts +1 -0
- package/dist/telegram/addressing.js +3 -0
- package/dist/telegram/gateway.d.ts +4 -1
- package/dist/telegram/gateway.js +23 -5
- package/dist/types.d.ts +7 -0
- package/dist/update.d.ts +5 -0
- package/dist/update.js +93 -5
- package/docs/agent-assisted-install.md +4 -4
- package/docs/install-for-beginners.md +3 -3
- package/docs/troubleshooting.md +1 -1
- package/docs/user-manual.md +11 -11
- package/docs/zh/agent-assisted-install.md +4 -4
- package/docs/zh/foxclaw-skill.md +1 -1
- package/docs/zh/install-for-beginners.md +3 -3
- package/docs/zh/troubleshooting.md +1 -1
- package/docs/zh/user-manual.md +11 -11
- package/package.json +1 -1
- package/skills/foxclaw/SKILL.md +26 -19
- package/skills/foxclaw/references/telegram-setup.md +5 -4
- package/skills/foxclaw/scripts/bootstrap_host.py +11 -8
- package/skills/foxclaw/scripts/bootstrap_remote.py +8 -4
- package/skills/npm-publish/SKILL.md +3 -0
package/dist/update.js
CHANGED
|
@@ -3,6 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import process from 'node:process';
|
|
4
4
|
import { spawn, spawnSync } from 'node:child_process';
|
|
5
5
|
const PACKAGE_SPEC = '@foxden-app/foxclaw@latest';
|
|
6
|
+
const CODEX_PACKAGE_SPEC = '@openai/codex@latest';
|
|
6
7
|
const UPDATE_STATUS_FILENAME = 'self-update.json';
|
|
7
8
|
export function selfUpdateStatusPath(statusPath) {
|
|
8
9
|
return path.join(path.dirname(statusPath), UPDATE_STATUS_FILENAME);
|
|
@@ -33,6 +34,7 @@ export function resolveSelfUpdateInstaller(entryPoint, nodePath = process.execPa
|
|
|
33
34
|
command: pnpmCommand,
|
|
34
35
|
installArgs: ['add', '--global', PACKAGE_SPEC],
|
|
35
36
|
rootArgs: ['root', '--global'],
|
|
37
|
+
pnpmHome,
|
|
36
38
|
};
|
|
37
39
|
}
|
|
38
40
|
const npmCommandName = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
@@ -43,6 +45,7 @@ export function resolveSelfUpdateInstaller(entryPoint, nodePath = process.execPa
|
|
|
43
45
|
command: npmCommand,
|
|
44
46
|
installArgs: ['exec', '--yes', '--package=pnpm@latest', '--', 'pnpm', 'add', '--global', PACKAGE_SPEC],
|
|
45
47
|
rootArgs: ['exec', '--yes', '--package=pnpm@latest', '--', 'pnpm', 'root', '--global'],
|
|
48
|
+
pnpmHome,
|
|
46
49
|
};
|
|
47
50
|
}
|
|
48
51
|
const adjacentNpm = path.join(path.dirname(nodePath), process.platform === 'win32' ? 'npm.cmd' : 'npm');
|
|
@@ -53,6 +56,65 @@ export function resolveSelfUpdateInstaller(entryPoint, nodePath = process.execPa
|
|
|
53
56
|
rootArgs: ['root', '--global'],
|
|
54
57
|
};
|
|
55
58
|
}
|
|
59
|
+
export function resolveCodexUpdateInstaller(codexCliBin, nodePath = process.execPath, exists = fs.existsSync, env = process.env, realpath = fs.realpathSync, readText = (target) => fs.readFileSync(target, 'utf8')) {
|
|
60
|
+
const resolved = resolveManagedCodexEntryPoint(codexCliBin, realpath, readText);
|
|
61
|
+
if (!resolved)
|
|
62
|
+
return null;
|
|
63
|
+
const normalized = resolved.replace(/\\/g, '/');
|
|
64
|
+
const pnpmManaged = normalized.includes('/global/') && normalized.includes('/.pnpm/@openai+codex@');
|
|
65
|
+
const npmManaged = normalized.includes('/lib/node_modules/@openai/codex/')
|
|
66
|
+
|| normalized.includes('/npm/node_modules/@openai/codex/');
|
|
67
|
+
if (!pnpmManaged && !npmManaged) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
const installer = resolveSelfUpdateInstaller(resolved, nodePath, exists, env);
|
|
71
|
+
return {
|
|
72
|
+
...installer,
|
|
73
|
+
installArgs: installer.installArgs.map((argument) => (argument === PACKAGE_SPEC ? CODEX_PACKAGE_SPEC : argument)),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function resolveManagedCodexEntryPoint(codexCliBin, realpath, readText) {
|
|
77
|
+
const pending = [codexCliBin];
|
|
78
|
+
const visited = new Set();
|
|
79
|
+
while (pending.length > 0 && visited.size < 4) {
|
|
80
|
+
const candidate = pending.shift();
|
|
81
|
+
let resolved = candidate;
|
|
82
|
+
try {
|
|
83
|
+
resolved = realpath(candidate);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
// Wrapper inspection below can still reveal its managed target.
|
|
87
|
+
}
|
|
88
|
+
if (visited.has(resolved))
|
|
89
|
+
continue;
|
|
90
|
+
visited.add(resolved);
|
|
91
|
+
const normalized = resolved.replace(/\\/g, '/');
|
|
92
|
+
if (isManagedCodexPackagePath(normalized)) {
|
|
93
|
+
return resolved;
|
|
94
|
+
}
|
|
95
|
+
let contents = '';
|
|
96
|
+
try {
|
|
97
|
+
contents = readText(resolved);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const embeddedPackageRoot = contents.match(/\/[^\s"']*\/global\/[^\s"']*\/\.pnpm\/@openai\+codex@[^\s"']*\/node_modules\/@openai\/codex/)?.[0];
|
|
103
|
+
if (embeddedPackageRoot) {
|
|
104
|
+
return path.join(embeddedPackageRoot, 'bin', 'codex.js');
|
|
105
|
+
}
|
|
106
|
+
const wrappedExecutable = contents.match(/\bexec\s+"([^"]*codex[^"]*)"/)?.[1];
|
|
107
|
+
if (wrappedExecutable) {
|
|
108
|
+
pending.push(wrappedExecutable);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
function isManagedCodexPackagePath(normalized) {
|
|
114
|
+
return (normalized.includes('/global/') && normalized.includes('/.pnpm/@openai+codex@'))
|
|
115
|
+
|| normalized.includes('/lib/node_modules/@openai/codex/')
|
|
116
|
+
|| normalized.includes('/npm/node_modules/@openai/codex/');
|
|
117
|
+
}
|
|
56
118
|
export function readSelfUpdateStatus(statusFile) {
|
|
57
119
|
try {
|
|
58
120
|
const parsed = JSON.parse(fs.readFileSync(statusFile, 'utf8'));
|
|
@@ -69,6 +131,7 @@ export function readSelfUpdateStatus(statusFile) {
|
|
|
69
131
|
locale: parsed.locale,
|
|
70
132
|
fromVersion: parsed.fromVersion,
|
|
71
133
|
toVersion: typeof parsed.toVersion === 'string' ? parsed.toVersion : null,
|
|
134
|
+
...(typeof parsed.codexUpdate === 'string' ? { codexUpdate: parsed.codexUpdate } : {}),
|
|
72
135
|
error: typeof parsed.error === 'string' ? parsed.error : null,
|
|
73
136
|
updatedAt: parsed.updatedAt,
|
|
74
137
|
};
|
|
@@ -97,6 +160,7 @@ export function createSelfUpdateRuntime(options) {
|
|
|
97
160
|
locale,
|
|
98
161
|
fromVersion: options.version,
|
|
99
162
|
toVersion: null,
|
|
163
|
+
codexUpdate: null,
|
|
100
164
|
error: null,
|
|
101
165
|
updatedAt: new Date().toISOString(),
|
|
102
166
|
});
|
|
@@ -106,7 +170,7 @@ export function createSelfUpdateRuntime(options) {
|
|
|
106
170
|
const child = spawn(options.nodePath, [options.entryPoint, 'update', '--notification-file', statusFile], {
|
|
107
171
|
detached: true,
|
|
108
172
|
stdio: ['ignore', logFd, logFd],
|
|
109
|
-
env: process.env,
|
|
173
|
+
env: options.codexCliBin ? { ...process.env, CODEX_CLI_BIN: options.codexCliBin } : process.env,
|
|
110
174
|
});
|
|
111
175
|
child.unref();
|
|
112
176
|
}
|
|
@@ -117,6 +181,7 @@ export function createSelfUpdateRuntime(options) {
|
|
|
117
181
|
locale,
|
|
118
182
|
fromVersion: options.version,
|
|
119
183
|
toVersion: null,
|
|
184
|
+
codexUpdate: null,
|
|
120
185
|
error: formatError(error),
|
|
121
186
|
updatedAt: new Date().toISOString(),
|
|
122
187
|
});
|
|
@@ -137,7 +202,10 @@ export function createSelfUpdateRuntime(options) {
|
|
|
137
202
|
export function performSelfUpdate(options) {
|
|
138
203
|
const env = options.env ?? process.env;
|
|
139
204
|
let toVersion = null;
|
|
205
|
+
let codexUpdate = null;
|
|
140
206
|
try {
|
|
207
|
+
codexUpdate = updateManagedCodexCli(options.codexCliBin ?? env.CODEX_CLI_BIN ?? '', options.nodePath, env);
|
|
208
|
+
console.log(`[UPDATE] ${codexUpdate}`);
|
|
141
209
|
const installer = resolveSelfUpdateInstaller(options.entryPoint, options.nodePath, fs.existsSync, env);
|
|
142
210
|
const installerEnv = buildInstallerEnv(options.entryPoint, installer, env);
|
|
143
211
|
console.log(`[UPDATE] Installing ${PACKAGE_SPEC} with ${installer.manager}...`);
|
|
@@ -146,7 +214,7 @@ export function performSelfUpdate(options) {
|
|
|
146
214
|
toVersion = readInstalledPackageVersion(updatedEntryPoint);
|
|
147
215
|
console.log('[UPDATE] Running checks and restarting the FoxClaw service...');
|
|
148
216
|
runInherited(options.nodePath, [updatedEntryPoint, 'start'], installerEnv);
|
|
149
|
-
completeNotification(options.notificationFile, 'succeeded', toVersion, null);
|
|
217
|
+
completeNotification(options.notificationFile, 'succeeded', toVersion, codexUpdate, null);
|
|
150
218
|
console.log(`[OK] FoxClaw updated and restarted: ${options.version} -> ${toVersion}`);
|
|
151
219
|
return {
|
|
152
220
|
ok: true,
|
|
@@ -157,7 +225,7 @@ export function performSelfUpdate(options) {
|
|
|
157
225
|
}
|
|
158
226
|
catch (error) {
|
|
159
227
|
const message = formatError(error);
|
|
160
|
-
completeNotification(options.notificationFile, 'failed', toVersion, message);
|
|
228
|
+
completeNotification(options.notificationFile, 'failed', toVersion, codexUpdate, message);
|
|
161
229
|
console.error(`[FAIL] FoxClaw update failed: ${message}`);
|
|
162
230
|
return {
|
|
163
231
|
ok: false,
|
|
@@ -167,6 +235,23 @@ export function performSelfUpdate(options) {
|
|
|
167
235
|
};
|
|
168
236
|
}
|
|
169
237
|
}
|
|
238
|
+
function updateManagedCodexCli(codexCliBin, nodePath, env) {
|
|
239
|
+
if (!codexCliBin) {
|
|
240
|
+
return 'Codex CLI update skipped: CODEX_CLI_BIN is not configured.';
|
|
241
|
+
}
|
|
242
|
+
const installer = resolveCodexUpdateInstaller(codexCliBin, nodePath, fs.existsSync, env);
|
|
243
|
+
if (!installer) {
|
|
244
|
+
return 'Codex CLI update skipped: configured installation is not a recognized global npm/pnpm package.';
|
|
245
|
+
}
|
|
246
|
+
try {
|
|
247
|
+
const installerEnv = buildInstallerEnv(fs.realpathSync(codexCliBin), installer, env);
|
|
248
|
+
runInherited(installer.command, installer.installArgs, installerEnv);
|
|
249
|
+
return `Codex CLI updated with ${installer.manager}.`;
|
|
250
|
+
}
|
|
251
|
+
catch (error) {
|
|
252
|
+
return `Codex CLI update failed without blocking FoxClaw update: ${formatError(error)}`;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
170
255
|
function executableCandidates(commandName, nodePath, env, preferred = []) {
|
|
171
256
|
return [
|
|
172
257
|
...preferred,
|
|
@@ -175,7 +260,9 @@ function executableCandidates(commandName, nodePath, env, preferred = []) {
|
|
|
175
260
|
].filter((candidate, index, all) => candidate && all.indexOf(candidate) === index);
|
|
176
261
|
}
|
|
177
262
|
function buildInstallerEnv(entryPoint, installer, env) {
|
|
178
|
-
const pnpmHome = installer.manager === 'pnpm'
|
|
263
|
+
const pnpmHome = installer.manager === 'pnpm'
|
|
264
|
+
? installer.pnpmHome ?? inferPnpmHomeFromEntryPoint(entryPoint)
|
|
265
|
+
: null;
|
|
179
266
|
if (!pnpmHome) {
|
|
180
267
|
return env;
|
|
181
268
|
}
|
|
@@ -230,7 +317,7 @@ function readInstalledPackageVersion(updatedEntryPoint) {
|
|
|
230
317
|
return 'unknown';
|
|
231
318
|
}
|
|
232
319
|
}
|
|
233
|
-
function completeNotification(notificationFile, state, toVersion, error) {
|
|
320
|
+
function completeNotification(notificationFile, state, toVersion, codexUpdate, error) {
|
|
234
321
|
if (!notificationFile) {
|
|
235
322
|
return;
|
|
236
323
|
}
|
|
@@ -242,6 +329,7 @@ function completeNotification(notificationFile, state, toVersion, error) {
|
|
|
242
329
|
...pending,
|
|
243
330
|
state,
|
|
244
331
|
toVersion,
|
|
332
|
+
codexUpdate,
|
|
245
333
|
error,
|
|
246
334
|
updatedAt: new Date().toISOString(),
|
|
247
335
|
});
|
|
@@ -8,7 +8,7 @@ This works well with Codex, OpenClaw, QwenPaw, Hermes, OpenCode, Kimi CLI, or an
|
|
|
8
8
|
|
|
9
9
|
Prepare these values before asking the agent:
|
|
10
10
|
|
|
11
|
-
- `
|
|
11
|
+
- `TG_BOT_TOKENS`: one or more comma-separated Telegram bot tokens from `@BotFather`
|
|
12
12
|
- `TG_ALLOWED_USER_ID`: your numeric Telegram user id
|
|
13
13
|
- `DEFAULT_CWD`: the folder where Codex should work
|
|
14
14
|
|
|
@@ -33,7 +33,7 @@ Published package:
|
|
|
33
33
|
Use private Telegram chat first. Do not configure group/topic mode unless I explicitly provide TG_ALLOWED_CHAT_ID or TG_ALLOWED_TOPIC_ID.
|
|
34
34
|
|
|
35
35
|
Here are the required values:
|
|
36
|
-
|
|
36
|
+
TG_BOT_TOKENS=<paste one token, or comma-separated tokens here>
|
|
37
37
|
TG_ALLOWED_USER_ID=<paste numeric Telegram user id here>
|
|
38
38
|
DEFAULT_CWD=<paste absolute working directory here>
|
|
39
39
|
|
|
@@ -49,13 +49,13 @@ Tasks:
|
|
|
49
49
|
9. Verify the final state:
|
|
50
50
|
- foxclaw.service is active/enabled on Linux
|
|
51
51
|
- foxclaw status works
|
|
52
|
-
10. Report the commands used, the final status, and the log command I should use if something stops working. Redact
|
|
52
|
+
10. Report the commands used, the final status, and the log command I should use if something stops working. Redact TG_BOT_TOKENS and never print the full token or full .env content.
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
## Safety Notes
|
|
56
56
|
|
|
57
57
|
- Do not paste bot tokens into public issue trackers or public chat logs.
|
|
58
58
|
- Do not commit `.env`.
|
|
59
|
-
- When reporting results, redact `TG_BOT_TOKEN`.
|
|
59
|
+
- When reporting results, redact `TG_BOT_TOKENS` and legacy `TG_BOT_TOKEN`.
|
|
60
60
|
- Do not use `/` or your whole home directory as `DEFAULT_CWD` for a first install.
|
|
61
61
|
- Use `foxclaw start` for normal service startup. Use foreground `foxclaw serve` only when troubleshooting.
|
|
@@ -143,7 +143,7 @@ nano ~/.foxclaw/.env
|
|
|
143
143
|
For a first private-chat install, fill only the important values:
|
|
144
144
|
|
|
145
145
|
```dotenv
|
|
146
|
-
|
|
146
|
+
TG_BOT_TOKENS=123456789:replace_with_your_bot_token
|
|
147
147
|
TG_ALLOWED_USER_ID=123456789
|
|
148
148
|
TG_ALLOWED_CHAT_ID=
|
|
149
149
|
TG_ALLOWED_TOPIC_ID=
|
|
@@ -176,7 +176,7 @@ You want to see:
|
|
|
176
176
|
```text
|
|
177
177
|
[OK] node >= 24
|
|
178
178
|
[OK] codex cli available
|
|
179
|
-
[OK] telegram bot token configured
|
|
179
|
+
[OK] telegram bot token(s) configured
|
|
180
180
|
[OK] telegram allowed user configured
|
|
181
181
|
[OK] default cwd exists
|
|
182
182
|
```
|
|
@@ -280,7 +280,7 @@ Update FoxClaw later:
|
|
|
280
280
|
foxclaw update
|
|
281
281
|
```
|
|
282
282
|
|
|
283
|
-
You can also send `/update` in an authorized Telegram chat. When no
|
|
283
|
+
You can also send `/update` in an authorized Telegram chat. When every bot is idle with no approval or question active, it attempts to update an npm/pnpm-managed Codex CLI, upgrades FoxClaw, checks, restarts the service, and reports the result after restart.
|
|
284
284
|
|
|
285
285
|
## Next Step
|
|
286
286
|
|
package/docs/troubleshooting.md
CHANGED
|
@@ -20,7 +20,7 @@ journalctl --user -u foxclaw.service -f
|
|
|
20
20
|
| --- | --- | --- |
|
|
21
21
|
| `[FAIL] node >= 24` | Your current shell is using an older Node.js. | Install or activate Node.js 24+ by any method, 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
|
-
| `[FAIL] telegram bot token configured` | `TG_BOT_TOKEN` is
|
|
23
|
+
| `[FAIL] telegram bot token(s) configured` | Neither `TG_BOT_TOKENS` nor legacy `TG_BOT_TOKEN` is present in `.env`. | Put one or more comma-separated `@BotFather` tokens in `TG_BOT_TOKENS`. |
|
|
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`. |
|
|
25
25
|
| `[FAIL] default cwd exists` | `DEFAULT_CWD` points to a folder that does not exist. | Create the folder or change `DEFAULT_CWD` to an existing absolute path. |
|
|
26
26
|
|
package/docs/user-manual.md
CHANGED
|
@@ -100,7 +100,7 @@ Both install the same published npm package. Use one global package manager cons
|
|
|
100
100
|
|
|
101
101
|
### 1.6 Fill In The Config
|
|
102
102
|
|
|
103
|
-
`foxclaw init` creates the default config file at `~/.foxclaw/.env` and prompts for
|
|
103
|
+
`foxclaw init` creates the default config file at `~/.foxclaw/.env` and prompts for one or more comma-separated Telegram bot tokens, your numeric Telegram user id, and the default workspace. If the current shell has proxy variables such as `HTTP_PROXY`, `HTTPS_PROXY`, or `ALL_PROXY`, it also asks whether to save them into the FoxClaw config. When `HTTP_PROXY` or `HTTPS_PROXY` is configured, FoxClaw passes it to systemd/launchd explicitly and enables Node's env proxy support. Press Enter on any field to skip it, then edit manually if needed:
|
|
104
104
|
|
|
105
105
|
```bash
|
|
106
106
|
$EDITOR ~/.foxclaw/.env
|
|
@@ -109,7 +109,7 @@ $EDITOR ~/.foxclaw/.env
|
|
|
109
109
|
Minimum private-chat config:
|
|
110
110
|
|
|
111
111
|
```dotenv
|
|
112
|
-
|
|
112
|
+
TG_BOT_TOKENS=123456789:replace_with_your_bot_token
|
|
113
113
|
TG_ALLOWED_USER_ID=123456789
|
|
114
114
|
TG_ALLOWED_CHAT_ID=
|
|
115
115
|
TG_ALLOWED_TOPIC_ID=
|
|
@@ -120,7 +120,7 @@ DEFAULT_SANDBOX_MODE=workspace-write
|
|
|
120
120
|
|
|
121
121
|
Fields:
|
|
122
122
|
|
|
123
|
-
- `
|
|
123
|
+
- `TG_BOT_TOKENS`: one or more `@BotFather` tokens separated by commas. The legacy single-bot `TG_BOT_TOKEN` setting remains compatible.
|
|
124
124
|
- `TG_ALLOWED_USER_ID`: your numeric Telegram user id.
|
|
125
125
|
- `TG_ALLOWED_CHAT_ID`: leave empty for the first private-chat setup.
|
|
126
126
|
- `TG_ALLOWED_TOPIC_ID`: leave empty unless binding a Telegram topic.
|
|
@@ -136,7 +136,7 @@ foxclaw start
|
|
|
136
136
|
foxclaw status
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
-
For later upgrades, run `foxclaw update`. It uses the npm or pnpm installation method currently managing FoxClaw,
|
|
139
|
+
For later upgrades, run `foxclaw update`. It uses the npm or pnpm installation method currently managing FoxClaw, attempts to update a globally npm/pnpm-managed Codex CLI, runs checks, and restarts the background service.
|
|
140
140
|
|
|
141
141
|
Linux service logs:
|
|
142
142
|
|
|
@@ -230,10 +230,10 @@ Later commands are sorted by recent usage. Plain text, photos, and files continu
|
|
|
230
230
|
|
|
231
231
|
### 3.2 `/status`, `/account`, `/quota`, `/update`
|
|
232
232
|
|
|
233
|
-
- `/status`: FoxClaw, app-server, current thread binding, model, access, and Codex usage summary. Local session, token, and
|
|
233
|
+
- `/status`: FoxClaw, app-server, current thread binding, model, access, and Codex usage summary. Local session, token, and visible-reply-throughput metrics use a background-generated historical snapshot instead of scanning large logs during the request; throughput is computed end-to-end for completed turns, excluding reasoning tokens while including waiting and tool execution time.
|
|
234
234
|
- `/account`: current Codex account.
|
|
235
235
|
- `/quota`: Codex usage and quota window.
|
|
236
|
-
- `/update`: upgrade FoxClaw, run checks, and restart the service; it refuses while a turn, approval, or question
|
|
236
|
+
- `/update`: upgrade FoxClaw, attempt to update an npm/pnpm-managed Codex CLI, run checks, and restart the service; it refuses while any bot runtime has a turn, approval, or question active, then reports the result after restart.
|
|
237
237
|
|
|
238
238
|
### 3.3 `/config`, `/requirements`, `/provider`
|
|
239
239
|
|
|
@@ -335,11 +335,11 @@ Watch mode mirrors live turn progress and approval requests. The watching chat i
|
|
|
335
335
|
|
|
336
336
|
## 6. Codex Login And Auth Rotation
|
|
337
337
|
|
|
338
|
-
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.
|
|
338
|
+
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. In `TG_BOT_TOKENS` mode, each bot has an isolated Codex home, app-server, and current candidate, so bots can run and switch accounts independently; validated login/refresh credentials are safely mirrored between bot homes.
|
|
339
339
|
|
|
340
340
|
### 6.1 File Format
|
|
341
341
|
|
|
342
|
-
|
|
342
|
+
In single-bot compatibility mode, candidate files live in the Codex auth directory, usually `~/.codex/`. If `CODEX_AUTH_DIR` is set, FoxClaw uses that directory. Multi-bot mode treats that directory as its candidate source and stores isolated bot copies under `~/.foxclaw/codex/telegram/bot<id>/home/`.
|
|
343
343
|
|
|
344
344
|
Recommended layout:
|
|
345
345
|
|
|
@@ -357,7 +357,7 @@ FoxClaw recognizes candidate names in these forms:
|
|
|
357
357
|
- `auth.json.<name>`
|
|
358
358
|
- `auth.json-<name>`
|
|
359
359
|
|
|
360
|
-
`auth.json` is what Codex currently uses. When switching accounts, FoxClaw points `auth.json` at one candidate. Candidate contents are Codex-generated JSON
|
|
360
|
+
`auth.json` is what Codex currently uses. When switching accounts, FoxClaw points `auth.json` at one candidate. Candidate contents are Codex-generated JSON and should not be hand-written. In multi-bot mode, FoxClaw mirrors a candidate only when its account identity matches and its refresh timestamp is newer, preventing a same-name candidate from overwriting a different account.
|
|
361
361
|
|
|
362
362
|
If you already have a working `auth.json`, you can save it as a candidate:
|
|
363
363
|
|
|
@@ -416,7 +416,7 @@ Equivalent commands:
|
|
|
416
416
|
- `/auth disable <n>`: skip candidate n during auto-rotation.
|
|
417
417
|
- `/auth reload` or `/auth_reload`: restart app-server and reload the current `auth.json`.
|
|
418
418
|
|
|
419
|
-
If active turns, pending approvals, pending user inputs, or MCP elicitations
|
|
419
|
+
If the requesting bot runtime has active turns, pending approvals, pending user inputs, or MCP elicitations, FoxClaw refuses manual auth switching to avoid changing accounts mid-request; another idle bot is unaffected.
|
|
420
420
|
|
|
421
421
|
### 6.4 How Auto-Rotation Works
|
|
422
422
|
|
|
@@ -452,7 +452,7 @@ auth.json_backup # backup account, enable or disable as needed
|
|
|
452
452
|
|
|
453
453
|
## 8. Safety
|
|
454
454
|
|
|
455
|
-
- Do not share `TG_BOT_TOKEN`, `~/.codex/auth.json*`, or `.env`.
|
|
455
|
+
- Do not share `TG_BOT_TOKENS`, `TG_BOT_TOKEN`, `~/.codex/auth.json*`, or `.env`.
|
|
456
456
|
- Do not use `/`, `/home`, `/Users`, or your whole home directory as the first `DEFAULT_CWD`.
|
|
457
457
|
- When unsure, use `/permissions read-only` or select `Read-only` in `/setup`.
|
|
458
458
|
- Group mode still only accepts `TG_ALLOWED_USER_ID`, but use trusted groups.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
先准备这几个值:
|
|
10
10
|
|
|
11
|
-
- `
|
|
11
|
+
- `TG_BOT_TOKENS`:从 `@BotFather` 拿到的一个或多个 Telegram bot token,多项用逗号分隔
|
|
12
12
|
- `TG_ALLOWED_USER_ID`:你的 Telegram 数字用户 ID
|
|
13
13
|
- `DEFAULT_CWD`:希望 Codex 默认工作的目录
|
|
14
14
|
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
先使用 Telegram 私聊模式。除非我明确提供 TG_ALLOWED_CHAT_ID 或 TG_ALLOWED_TOPIC_ID,否则不要配置群组/话题模式。
|
|
33
33
|
|
|
34
34
|
必需配置:
|
|
35
|
-
|
|
35
|
+
TG_BOT_TOKENS=<粘贴一个 token,或多个逗号分隔 token>
|
|
36
36
|
TG_ALLOWED_USER_ID=<把 Telegram 数字用户 ID 粘贴在这里>
|
|
37
37
|
DEFAULT_CWD=<把绝对工作目录粘贴在这里>
|
|
38
38
|
|
|
@@ -48,13 +48,13 @@ DEFAULT_CWD=<把绝对工作目录粘贴在这里>
|
|
|
48
48
|
9. 验证最终状态:
|
|
49
49
|
- Linux 上 foxclaw.service 处于 active/enabled
|
|
50
50
|
- foxclaw status 可以正常输出
|
|
51
|
-
10. 汇报执行过的命令、最终状态和后续看日志的命令。请隐藏
|
|
51
|
+
10. 汇报执行过的命令、最终状态和后续看日志的命令。请隐藏 TG_BOT_TOKENS,不要打印完整 token 或完整 .env。
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
## 安全注意事项
|
|
55
55
|
|
|
56
56
|
- 不要把 bot token 粘贴到公开 issue、公开聊天或代码仓库。
|
|
57
57
|
- 不要提交 `.env`。
|
|
58
|
-
- 汇报结果时隐藏 `TG_BOT_TOKEN`。
|
|
58
|
+
- 汇报结果时隐藏 `TG_BOT_TOKENS` 和兼容变量 `TG_BOT_TOKEN`。
|
|
59
59
|
- 第一次安装不要把 `/`、整个 `/Users`、整个 `/home` 或完整 home 目录设为 `DEFAULT_CWD`。
|
|
60
60
|
- 日常启动用 `foxclaw start`;只有排障时才用前台模式 `foxclaw serve`。
|
package/docs/zh/foxclaw-skill.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
## 基本流程
|
|
12
12
|
|
|
13
|
-
1. 准备 `
|
|
13
|
+
1. 准备 `TG_BOT_TOKENS`(一个或多个逗号分隔的 bot token)、`TG_ALLOWED_USER_ID` 和 `DEFAULT_CWD`。
|
|
14
14
|
2. 让 Codex 使用 `skills/foxclaw`。
|
|
15
15
|
3. 如果是远程机器,提供 SSH 目标。
|
|
16
16
|
4. 让 Codex 执行安装、写配置、跑 `foxclaw doctor`。
|
|
@@ -141,7 +141,7 @@ nano ~/.foxclaw/.env
|
|
|
141
141
|
第一次私聊模式只需要重点填写这些值:
|
|
142
142
|
|
|
143
143
|
```dotenv
|
|
144
|
-
|
|
144
|
+
TG_BOT_TOKENS=123456789:replace_with_your_bot_token
|
|
145
145
|
TG_ALLOWED_USER_ID=123456789
|
|
146
146
|
TG_ALLOWED_CHAT_ID=
|
|
147
147
|
TG_ALLOWED_TOPIC_ID=
|
|
@@ -174,7 +174,7 @@ foxclaw doctor
|
|
|
174
174
|
```text
|
|
175
175
|
[OK] node >= 24
|
|
176
176
|
[OK] codex cli available
|
|
177
|
-
[OK] telegram bot token configured
|
|
177
|
+
[OK] telegram bot token(s) configured
|
|
178
178
|
[OK] telegram allowed user configured
|
|
179
179
|
[OK] default cwd exists
|
|
180
180
|
```
|
|
@@ -278,7 +278,7 @@ foxclaw uninstall-systemd
|
|
|
278
278
|
foxclaw update
|
|
279
279
|
```
|
|
280
280
|
|
|
281
|
-
也可以在已授权的 Telegram 私聊里发送 `/update
|
|
281
|
+
也可以在已授权的 Telegram 私聊里发送 `/update`。它会在所有 bot 都没有运行中回复、审批或待确认问题时,尝试升级 npm/pnpm 安装的 Codex CLI,完成 FoxClaw 升级、自检和服务重启,并在重启后回报结果。
|
|
282
282
|
|
|
283
283
|
如果 `~/.foxclaw/.env` 已经存在,`foxclaw init` 会先询问是否更新 Telegram 和工作目录相关字段,其它配置保持不变。
|
|
284
284
|
|
|
@@ -20,7 +20,7 @@ journalctl --user -u foxclaw.service -f
|
|
|
20
20
|
| --- | --- | --- |
|
|
21
21
|
| `[FAIL] node >= 24` | 当前 shell 使用的是旧版 Node.js。 | 先用任意方式安装或切换到 Node.js 24+,再重新执行 `foxclaw doctor`。如果服务仍用旧 Node,从 Node 24+ 的 shell 里重新执行 `foxclaw start`。 |
|
|
22
22
|
| `[FAIL] codex cli available` | `codex` 命令不在 PATH 里。 | 安装 Codex CLI 或修正 PATH,再确认 `codex --version` 可用。 |
|
|
23
|
-
| `[FAIL] telegram bot token configured` | `.env`
|
|
23
|
+
| `[FAIL] telegram bot token(s) configured` | `.env` 里没有 `TG_BOT_TOKENS`,也没有兼容变量 `TG_BOT_TOKEN`。 | 从 `@BotFather` 复制一个或多个 token,用逗号分隔填入 `TG_BOT_TOKENS`。 |
|
|
24
24
|
| `[FAIL] telegram allowed user configured` | `.env` 里缺少 `TG_ALLOWED_USER_ID`。 | 从 `@userinfobot` 获取数字 ID,填入 `.env`。 |
|
|
25
25
|
| `[FAIL] default cwd exists` | `DEFAULT_CWD` 指向不存在的目录。 | 创建该目录,或把 `DEFAULT_CWD` 改成一个真实存在的绝对路径。 |
|
|
26
26
|
|
package/docs/zh/user-manual.md
CHANGED
|
@@ -100,7 +100,7 @@ foxclaw init
|
|
|
100
100
|
|
|
101
101
|
### 1.6 填写配置
|
|
102
102
|
|
|
103
|
-
`foxclaw init` 会创建默认配置文件 `~/.foxclaw/.env
|
|
103
|
+
`foxclaw init` 会创建默认配置文件 `~/.foxclaw/.env`,并提示填写一个或多个 Telegram bot token(逗号分隔)、Telegram 数字用户 ID 和默认工作目录。如果当前 shell 里有 `HTTP_PROXY`、`HTTPS_PROXY`、`ALL_PROXY` 等代理变量,它也会询问是否写入 FoxClaw 配置。配置了 `HTTP_PROXY` 或 `HTTPS_PROXY` 后,FoxClaw 会在安装服务时显式传给 systemd/launchd,并启用 Node 的 env proxy。任何一项都可以直接回车跳过,之后再手动编辑:
|
|
104
104
|
|
|
105
105
|
```bash
|
|
106
106
|
$EDITOR ~/.foxclaw/.env
|
|
@@ -109,7 +109,7 @@ $EDITOR ~/.foxclaw/.env
|
|
|
109
109
|
第一次私聊模式的最小配置:
|
|
110
110
|
|
|
111
111
|
```dotenv
|
|
112
|
-
|
|
112
|
+
TG_BOT_TOKENS=123456789:replace_with_your_bot_token
|
|
113
113
|
TG_ALLOWED_USER_ID=123456789
|
|
114
114
|
TG_ALLOWED_CHAT_ID=
|
|
115
115
|
TG_ALLOWED_TOPIC_ID=
|
|
@@ -120,7 +120,7 @@ DEFAULT_SANDBOX_MODE=workspace-write
|
|
|
120
120
|
|
|
121
121
|
字段说明:
|
|
122
122
|
|
|
123
|
-
- `
|
|
123
|
+
- `TG_BOT_TOKENS`:从 `@BotFather` 拿到的一个或多个 bot token,多项用英文逗号分隔。旧版单 bot 配置 `TG_BOT_TOKEN` 仍兼容。
|
|
124
124
|
- `TG_ALLOWED_USER_ID`:你的 Telegram 数字用户 ID。
|
|
125
125
|
- `TG_ALLOWED_CHAT_ID`:第一次保持为空,表示私聊模式。
|
|
126
126
|
- `TG_ALLOWED_TOPIC_ID`:第一次保持为空,表示不绑定 Telegram 话题。
|
|
@@ -136,7 +136,7 @@ foxclaw start
|
|
|
136
136
|
foxclaw status
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
-
后续升级只需运行 `foxclaw update`;它会使用当前安装 FoxClaw 的 npm 或 pnpm
|
|
139
|
+
后续升级只需运行 `foxclaw update`;它会使用当前安装 FoxClaw 的 npm 或 pnpm,尝试同时升级由 npm/pnpm 全局安装的 Codex CLI,然后执行自检并重启后台服务。
|
|
140
140
|
|
|
141
141
|
Linux 查看服务日志:
|
|
142
142
|
|
|
@@ -230,10 +230,10 @@ TG_ALLOWED_TOPIC_ID=42
|
|
|
230
230
|
|
|
231
231
|
### 3.2 `/status`、`/account`、`/quota`、`/update`
|
|
232
232
|
|
|
233
|
-
- `/status`:查看 FoxClaw、app-server、当前绑定线程、模型、权限和 Codex 用量摘要。本地 session/Token
|
|
233
|
+
- `/status`:查看 FoxClaw、app-server、当前绑定线程、模型、权限和 Codex 用量摘要。本地 session/Token/可见答复吞吐使用后台生成的历史快照,避免状态查询现场扫描大量日志;答复吞吐按完成轮次端到端耗时计算,排除推理 token,但包含等待与工具执行时间。
|
|
234
234
|
- `/account`:查看当前 Codex 登录账号。
|
|
235
235
|
- `/quota`:查看 Codex 用量和额度窗口。
|
|
236
|
-
- `/update`:升级 FoxClaw
|
|
236
|
+
- `/update`:升级 FoxClaw,并尝试升级 npm/pnpm 安装的 Codex CLI,然后自检和重启服务;任意 bot runtime 有运行中回复、审批或待确认问题时都会拒绝执行,重启后会回报结果。
|
|
237
237
|
|
|
238
238
|
### 3.3 `/config`、`/requirements`、`/provider`
|
|
239
239
|
|
|
@@ -335,11 +335,11 @@ FoxClaw 的聊天是“绑定线程”的。你在手机上打开某个 Codex
|
|
|
335
335
|
|
|
336
336
|
## 6. Codex 登录和 auth 轮转
|
|
337
337
|
|
|
338
|
-
这是 FoxClaw 的特色功能。Codex 的登录状态通常保存在 `~/.codex/auth.json`。FoxClaw 把多个账号保存成候选文件,并通过切换 `auth.json`
|
|
338
|
+
这是 FoxClaw 的特色功能。Codex 的登录状态通常保存在 `~/.codex/auth.json`。FoxClaw 把多个账号保存成候选文件,并通过切换 `auth.json` 指向哪个候选来换号。启用 `TG_BOT_TOKENS` 多 bot 模式后,每个 bot 使用独立 Codex home、独立 app-server 和独立当前候选,因此可以并行运行、单独切号;已验证的登录/刷新凭据会安全镜像到其他 bot home。
|
|
339
339
|
|
|
340
340
|
### 6.1 文件格式
|
|
341
341
|
|
|
342
|
-
|
|
342
|
+
单 bot 兼容模式的候选文件放在 Codex auth 目录,默认是 `~/.codex/`。如果你设置了 `CODEX_AUTH_DIR`,则使用那个目录。多 bot 模式以这个目录作为候选源,并在 `~/.foxclaw/codex/telegram/bot<id>/home/` 下为每个 bot 保存隔离副本。
|
|
343
343
|
|
|
344
344
|
推荐命名:
|
|
345
345
|
|
|
@@ -357,7 +357,7 @@ FoxClaw 识别这些候选文件名:
|
|
|
357
357
|
- `auth.json.<name>`
|
|
358
358
|
- `auth.json-<name>`
|
|
359
359
|
|
|
360
|
-
`auth.json` 是 Codex 当前使用的文件。切换账号时,FoxClaw 会把 `auth.json` 指向某个候选文件。候选文件内容是 Codex CLI 生成的 JSON
|
|
360
|
+
`auth.json` 是 Codex 当前使用的文件。切换账号时,FoxClaw 会把 `auth.json` 指向某个候选文件。候选文件内容是 Codex CLI 生成的 JSON,不建议手写这些字段。多 bot 镜像只在能校验同一账号标识且刷新时间更新时复制候选,避免同名候选意外覆盖成另一个账号。
|
|
361
361
|
|
|
362
362
|
如果你已经有一个可用的 `auth.json`,可以先备份成候选:
|
|
363
363
|
|
|
@@ -416,7 +416,7 @@ Candidates: 2
|
|
|
416
416
|
- `/auth disable <n>`:禁用第 n 个候选,自动轮转会跳过它。
|
|
417
417
|
- `/auth reload` 或 `/auth_reload`:重启 app-server,重新加载当前 `auth.json`。
|
|
418
418
|
|
|
419
|
-
切换 auth
|
|
419
|
+
切换 auth 时,如果当前 bot runtime 还有活跃 turn、待审批、待用户输入或 MCP elicitation,FoxClaw 会先拒绝切换,避免中途换号破坏正在进行的请求;另一个空闲 bot 不受影响。
|
|
420
420
|
|
|
421
421
|
### 6.4 自动轮转如何工作
|
|
422
422
|
|
|
@@ -452,7 +452,7 @@ auth.json_backup # 备用账号,可按需 enable/disable
|
|
|
452
452
|
|
|
453
453
|
## 8. 安全建议
|
|
454
454
|
|
|
455
|
-
- 不要把 `TG_BOT_TOKEN`、`~/.codex/auth.json*` 或 `.env` 发给别人。
|
|
455
|
+
- 不要把 `TG_BOT_TOKENS`、`TG_BOT_TOKEN`、`~/.codex/auth.json*` 或 `.env` 发给别人。
|
|
456
456
|
- 第一次不要把 `DEFAULT_CWD` 设成 `/`、`/home`、`/Users` 或整个 home。
|
|
457
457
|
- 不确定权限时,用 `/permissions read-only` 或 `/setup` 选 `Read-only`。
|
|
458
458
|
- 群组模式只允许配置的 `TG_ALLOWED_USER_ID` 操作,但仍建议只放进可信群。
|