yingclaw 2.5.13 → 2.5.17
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 +3 -1
- package/bin/cli.js +2 -1
- package/lib/config.js +8 -4
- package/lib/gateway.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -103,13 +103,15 @@ claw setup # 兼容旧命令:config + code
|
|
|
103
103
|
|
|
104
104
|
```
|
|
105
105
|
ANTHROPIC_BASE_URL
|
|
106
|
-
ANTHROPIC_AUTH_TOKEN
|
|
106
|
+
ANTHROPIC_AUTH_TOKEN
|
|
107
107
|
ANTHROPIC_MODEL
|
|
108
108
|
ANTHROPIC_DEFAULT_OPUS_MODEL / SONNET_MODEL / HAIKU_MODEL
|
|
109
109
|
CLAUDE_CODE_SUBAGENT_MODEL
|
|
110
110
|
CLAUDE_CODE_EFFORT_LEVEL
|
|
111
111
|
```
|
|
112
112
|
|
|
113
|
+
新版只写入 `ANTHROPIC_AUTH_TOKEN`,并会清除旧版遗留的 `ANTHROPIC_API_KEY`,避免 Claude Code 同时检测到 token 和 API key 后报 `Auth conflict`。
|
|
114
|
+
|
|
113
115
|
**桌面接入**(`claw desktop`)默认写入本机 Gateway:
|
|
114
116
|
|
|
115
117
|
- macOS / Windows:写入 `Claude-3p/configLibrary/` 中的 yingclaw entry
|
package/bin/cli.js
CHANGED
|
@@ -17,6 +17,7 @@ const {
|
|
|
17
17
|
buildClaudeEnv,
|
|
18
18
|
PROVIDERS,
|
|
19
19
|
CLAUDE_ENV_KEYS,
|
|
20
|
+
CLEAR_CLAUDE_ENV_KEYS,
|
|
20
21
|
} = require('../lib/config');
|
|
21
22
|
const { execSync, spawn, spawnSync } = require('child_process');
|
|
22
23
|
const pkg = require('../package.json');
|
|
@@ -567,7 +568,7 @@ program
|
|
|
567
568
|
const resetNote = isWin
|
|
568
569
|
? '注:当前终端的环境变量还在内存中,重新打开 PowerShell / CMD 后才彻底清除'
|
|
569
570
|
: '注:当前终端的环境变量还在内存中,重开终端后生效,或在当前终端执行:';
|
|
570
|
-
const unsetCmd = isWin ? null : `unset ${
|
|
571
|
+
const unsetCmd = isWin ? null : `unset ${CLEAR_CLAUDE_ENV_KEYS.join(' ')}`;
|
|
571
572
|
console.log(boxen(
|
|
572
573
|
chalk.bold('已清除以下位置中的 Claude Code 终端环境变量:\n\n') +
|
|
573
574
|
cleared.map(f => chalk.cyan(' • ' + f)).join('\n') +
|
package/lib/config.js
CHANGED
|
@@ -8,7 +8,6 @@ const WINDOWS_ENV_LABEL = 'Windows 用户环境变量';
|
|
|
8
8
|
const CLAUDE_ENV_KEYS = [
|
|
9
9
|
'ANTHROPIC_BASE_URL',
|
|
10
10
|
'ANTHROPIC_AUTH_TOKEN',
|
|
11
|
-
'ANTHROPIC_API_KEY',
|
|
12
11
|
'ANTHROPIC_MODEL',
|
|
13
12
|
'ANTHROPIC_DEFAULT_OPUS_MODEL',
|
|
14
13
|
'ANTHROPIC_DEFAULT_SONNET_MODEL',
|
|
@@ -16,6 +15,10 @@ const CLAUDE_ENV_KEYS = [
|
|
|
16
15
|
'CLAUDE_CODE_SUBAGENT_MODEL',
|
|
17
16
|
'CLAUDE_CODE_EFFORT_LEVEL',
|
|
18
17
|
];
|
|
18
|
+
const LEGACY_CLAUDE_ENV_KEYS = [
|
|
19
|
+
'ANTHROPIC_API_KEY',
|
|
20
|
+
];
|
|
21
|
+
const CLEAR_CLAUDE_ENV_KEYS = [...new Set([...CLAUDE_ENV_KEYS, ...LEGACY_CLAUDE_ENV_KEYS])];
|
|
19
22
|
|
|
20
23
|
const PROVIDERS = {
|
|
21
24
|
deepseek: {
|
|
@@ -266,7 +269,6 @@ function buildClaudeEnv({ provider, baseUrl, apiKey, model, fastModel }) {
|
|
|
266
269
|
return {
|
|
267
270
|
ANTHROPIC_BASE_URL: baseUrl,
|
|
268
271
|
ANTHROPIC_AUTH_TOKEN: apiKey,
|
|
269
|
-
ANTHROPIC_API_KEY: apiKey,
|
|
270
272
|
ANTHROPIC_MODEL: model,
|
|
271
273
|
ANTHROPIC_DEFAULT_OPUS_MODEL: model,
|
|
272
274
|
ANTHROPIC_DEFAULT_SONNET_MODEL: model,
|
|
@@ -284,7 +286,7 @@ function buildWindowsSetEnvCommands(env) {
|
|
|
284
286
|
}
|
|
285
287
|
|
|
286
288
|
function buildWindowsClearEnvCommands() {
|
|
287
|
-
return
|
|
289
|
+
return CLEAR_CLAUDE_ENV_KEYS.map((key) => ({
|
|
288
290
|
command: 'reg',
|
|
289
291
|
args: ['delete', 'HKCU\\Environment', '/V', key, '/F'],
|
|
290
292
|
}));
|
|
@@ -325,6 +327,7 @@ async function validateKey(config, options = {}) {
|
|
|
325
327
|
'content-type': 'application/json',
|
|
326
328
|
authorization: `Bearer ${config.apiKey}`,
|
|
327
329
|
'x-api-key': config.apiKey,
|
|
330
|
+
'api-key': config.apiKey,
|
|
328
331
|
'anthropic-version': '2023-06-01',
|
|
329
332
|
},
|
|
330
333
|
body: JSON.stringify({
|
|
@@ -354,7 +357,6 @@ function buildEnvBlock(baseUrl, apiKey, model, fastModel) {
|
|
|
354
357
|
'# clawai-start',
|
|
355
358
|
`export ANTHROPIC_BASE_URL=${shellQuote(env.ANTHROPIC_BASE_URL)}`,
|
|
356
359
|
`export ANTHROPIC_AUTH_TOKEN=${shellQuote(env.ANTHROPIC_AUTH_TOKEN)}`,
|
|
357
|
-
`export ANTHROPIC_API_KEY=${shellQuote(env.ANTHROPIC_API_KEY)}`,
|
|
358
360
|
`export ANTHROPIC_MODEL=${shellQuote(env.ANTHROPIC_MODEL)}`,
|
|
359
361
|
`export ANTHROPIC_DEFAULT_OPUS_MODEL=${shellQuote(env.ANTHROPIC_DEFAULT_OPUS_MODEL)}`,
|
|
360
362
|
`export ANTHROPIC_DEFAULT_SONNET_MODEL=${shellQuote(env.ANTHROPIC_DEFAULT_SONNET_MODEL)}`,
|
|
@@ -372,6 +374,7 @@ function writeEnvToZshrc(baseUrl, apiKey, model, fastModel, options = {}) {
|
|
|
372
374
|
if (platform === 'win32') {
|
|
373
375
|
const provider = providerKeyFromBaseUrl(baseUrl);
|
|
374
376
|
const env = buildClaudeEnv({ provider, baseUrl, apiKey, model, fastModel });
|
|
377
|
+
runWindowsEnvCommands(buildWindowsClearEnvCommands(), options.runner || spawnSync, { ignoreErrors: true });
|
|
375
378
|
runWindowsEnvCommands(buildWindowsSetEnvCommands(env), options.runner || spawnSync);
|
|
376
379
|
return { result: 'updated', file: WINDOWS_ENV_LABEL };
|
|
377
380
|
}
|
|
@@ -467,4 +470,5 @@ module.exports = {
|
|
|
467
470
|
PROVIDERS,
|
|
468
471
|
CONFIG_FILE,
|
|
469
472
|
CLAUDE_ENV_KEYS,
|
|
473
|
+
CLEAR_CLAUDE_ENV_KEYS,
|
|
470
474
|
};
|
package/lib/gateway.js
CHANGED
|
@@ -209,6 +209,7 @@ async function proxyMessages(req, res, config) {
|
|
|
209
209
|
accept: body.stream ? 'text/event-stream' : 'application/json',
|
|
210
210
|
authorization: `Bearer ${config.apiKey}`,
|
|
211
211
|
'x-api-key': config.apiKey,
|
|
212
|
+
'api-key': config.apiKey,
|
|
212
213
|
'anthropic-version': '2023-06-01',
|
|
213
214
|
},
|
|
214
215
|
body: JSON.stringify(body),
|