@tokenaut/opentoken 1.4.7 → 1.4.8

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
@@ -5,7 +5,6 @@
5
5
  ## 安装
6
6
 
7
7
  ```bash
8
- npx @tokenaut/opentoken
9
8
  npm install -g @tokenaut/opentoken
10
9
  ```
11
10
 
@@ -25,7 +24,7 @@ npm install -g @tokenaut/opentoken
25
24
  | 应用 | 子命令(别名) | 配置文件 |
26
25
  |------|----------------|----------|
27
26
  | **Claude Code** | `cc`、`claude` | `~/.claude/settings.json`(环境变量:`ANTHROPIC_AUTH_TOKEN`、`ANTHROPIC_BASE_URL`、`ANTHROPIC_MODEL`) |
28
- | **Claude Desktop** | `claude_desktop`、`cd` | `~/Library/Application Support/Claude-3p/configLibrary/*.json`(`inferenceGatewayApiKey`、`inferenceGatewayBaseUrl`) |
27
+ | **Claude Desktop** | `claude_desktop`、`cdp` | `~/Library/Application Support/Claude-3p/configLibrary/*.json`(`inferenceGatewayApiKey`、`inferenceGatewayBaseUrl`) |
29
28
  | **Atomcode** | `atomcode`、`ac` | `~/.atomcode/config.toml` |
30
29
  | **OpenClaw** | `openclaw`、`oc` | `~/.openclaw/openclaw.json`(合并写入 Opentoken:`models.providers.opentoken`、`agents.defaults.model.primary` 等) |
31
30
  | **Hermes** | `hermes`、`hm` | `~/.hermes/config.yaml`(`model.provider`、`model.base_url`、`model.default`)与 `~/.hermes/.env`(`OPENTOKEN_API_KEY`) |
@@ -70,15 +69,15 @@ opentoken cc -k sk-xxx -u https://gw.opentoken.io -m claude-opus-4-5
70
69
 
71
70
  ```bash
72
71
  opentoken claude_desktop --key <api_key>
73
- opentoken cd --url <base_url>
74
- opentoken cd -k <api_key> -u <base_url>
72
+ opentoken cdp --url <base_url>
73
+ opentoken cdp -k <api_key> -u <base_url>
75
74
  ```
76
75
 
77
76
  示例:
78
77
 
79
78
  ```bash
80
- opentoken cd -k sk-xxx
81
- opentoken cd -k sk-xxx -u https://gw.opentoken.io
79
+ opentoken cdp -k sk-xxx
80
+ opentoken cdp -k sk-xxx -u https://gw.opentoken.io
82
81
  ```
83
82
 
84
83
  ### Atomcode
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenaut/opentoken",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
4
4
  "description": "OpenToken 一键接入 AI 模型 · https://docs.opentoken.io/",
5
5
  "main": "src/cli.js",
6
6
  "bin": {
package/src/cli.js CHANGED
@@ -38,7 +38,7 @@ function isCodexCommand(tool) {
38
38
  }
39
39
 
40
40
  function isClaudeDesktopCommand(tool) {
41
- return tool === 'claude_desktop' || tool === 'cd';
41
+ return tool === 'claude_desktop' || tool === 'cdp';
42
42
  }
43
43
 
44
44
  function printVersion() {
@@ -92,17 +92,17 @@ function printHelp() {
92
92
  console.log(' opentoken cx -k <k> -u <u> -m <m> 一键设置 URL 与模型');
93
93
  console.log('');
94
94
  console.log(' opentoken claude_desktop 进入 Claude Desktop 配置(configLibrary/*.json)');
95
- console.log(' opentoken cd 同上(缩写)');
96
- console.log(' opentoken cd --key <apikey> 设置 API Key(inferenceGatewayApiKey)');
97
- console.log(' opentoken cd --url <baseurl> 设置 Base URL(inferenceGatewayBaseUrl)');
98
- console.log(' opentoken cd -k <k> -u <u> 一键设置 Key 与 URL');
95
+ console.log(' opentoken cdp 同上(缩写)');
96
+ console.log(' opentoken cdp --key <apikey> 设置 API Key(inferenceGatewayApiKey)');
97
+ console.log(' opentoken cdp --url <baseurl> 设置 Base URL(inferenceGatewayBaseUrl)');
98
+ console.log(' opentoken cdp -k <k> -u <u> 一键设置 Key 与 URL');
99
99
  console.log('');
100
100
  console.log(chalk.bold('快捷别名(--key / -k,--url / -u,--model / -m)'));
101
101
  console.log('');
102
102
  console.log(chalk.bold('示例:'));
103
103
  console.log(' opentoken cc -k sk-xxx');
104
104
  console.log(` opentoken cc -k sk-xxx -u ${DEFAULT_BASE_URL} -m claude-opus-4-5`);
105
- console.log(` opentoken cd -k sk-xxx -u ${DEFAULT_BASE_URL}`);
105
+ console.log(` opentoken cdp -k sk-xxx -u ${DEFAULT_BASE_URL}`);
106
106
  console.log('');
107
107
  console.log(chalk.bold('主菜单:'));
108
108
  console.log(' 1. 配置 Claude Code');
package/src/models.js CHANGED
@@ -30,6 +30,10 @@ const CODEX_AUTH_KEY = 'OPENAI_API_KEY';
30
30
 
31
31
  const CODEX_DEFAULT_MODEL = 'gpt-5.4';
32
32
 
33
+ const CLAUDE_DEFAULT_MODEL = 'claude-sonnet-4-6';
34
+
35
+ const GENERAL_DEFAULT_MODEL = 'gpt-5.4';
36
+
33
37
  const API_NODES = [
34
38
  {
35
39
  name: 'opentoken 默认节点 - https://gw.opentoken.io',
@@ -58,4 +62,6 @@ module.exports = {
58
62
  CODEX_PROVIDER_KEY,
59
63
  CODEX_AUTH_KEY,
60
64
  CODEX_DEFAULT_MODEL,
65
+ CLAUDE_DEFAULT_MODEL,
66
+ GENERAL_DEFAULT_MODEL,
61
67
  };
@@ -2,7 +2,7 @@
2
2
 
3
3
  const chalk = require('chalk');
4
4
  const inquirer = require('inquirer');
5
- const { DEFAULT_BASE_URL, ATOMCODE_OPENTOKEN_BASE_URL } = require('../models');
5
+ const { DEFAULT_BASE_URL, ATOMCODE_OPENTOKEN_BASE_URL, GENERAL_DEFAULT_MODEL } = require('../models');
6
6
  const { fetchModelsForBaseUrl } = require('../fetch-models');
7
7
  const {
8
8
  CONFIG_PATH,
@@ -235,6 +235,8 @@ function quickSet({ key, model }) {
235
235
  if (key) toWrite.apiKey = key;
236
236
  if (model) toWrite.model = model;
237
237
 
238
+ if (key && !model) toWrite.model = GENERAL_DEFAULT_MODEL;
239
+
238
240
  if (Object.keys(toWrite).length === 0) return false;
239
241
 
240
242
  applyAtomcodeConfig(toWrite);
@@ -242,7 +244,7 @@ function quickSet({ key, model }) {
242
244
  console.log('');
243
245
  console.log(chalk.bold(chalk.cyan('Atomcode 配置已更新:')));
244
246
  if (key) console.log(chalk.green(' ✓ API Key : ') + maskApiKey(key));
245
- if (model) console.log(chalk.green(' ✓ 模型 : ') + model);
247
+ console.log(chalk.green(' ✓ 模型 : ') + (toWrite.model || model));
246
248
  console.log(chalk.green(' ✓ Base URL : ') + ATOMCODE_OPENTOKEN_BASE_URL + chalk.gray('(固定)'));
247
249
  console.log(chalk.gray(' ' + CONFIG_PATH));
248
250
  console.log('');
@@ -2,7 +2,7 @@
2
2
 
3
3
  const chalk = require('chalk');
4
4
  const inquirer = require('inquirer');
5
- const { API_NODES, DEFAULT_BASE_URL } = require('../models');
5
+ const { API_NODES, DEFAULT_BASE_URL, CLAUDE_DEFAULT_MODEL } = require('../models');
6
6
  const { fetchModelsForBaseUrl } = require('../fetch-models');
7
7
  const { getCurrentConfig, applyConfig } = require('../config');
8
8
  const { printLogo } = require('../logo');
@@ -285,6 +285,9 @@ function quickSet({ key, url, model }) {
285
285
  if (url) toWrite.baseUrl = url;
286
286
  if (model) toWrite.model = model;
287
287
 
288
+ if (key && !url) toWrite.baseUrl = DEFAULT_BASE_URL;
289
+ if (key && !model) toWrite.model = CLAUDE_DEFAULT_MODEL;
290
+
288
291
  if (Object.keys(toWrite).length === 0) return false;
289
292
 
290
293
  applyConfig(toWrite);
@@ -292,8 +295,8 @@ function quickSet({ key, url, model }) {
292
295
  console.log('');
293
296
  console.log(chalk.bold(chalk.cyan('Claude Code 配置已更新:')));
294
297
  if (key) console.log(chalk.green(' ✓ API Key : ') + maskApiKey(key));
295
- if (url) console.log(chalk.green(' ✓ Base URL : ') + url);
296
- if (model) console.log(chalk.green(' ✓ 模型 : ') + model);
298
+ console.log(chalk.green(' ✓ Base URL : ') + (toWrite.baseUrl || url));
299
+ console.log(chalk.green(' ✓ 模型 : ') + (toWrite.model || model));
297
300
  console.log('');
298
301
 
299
302
  return true;
@@ -169,6 +169,8 @@ function quickSet({ key, url }) {
169
169
  if (key) toWrite.apiKey = key;
170
170
  if (url) toWrite.baseUrl = url;
171
171
 
172
+ if (key && !url) toWrite.baseUrl = DEFAULT_BASE_URL;
173
+
172
174
  if (Object.keys(toWrite).length === 0) return false;
173
175
 
174
176
  applyConfig(toWrite);
@@ -176,7 +178,7 @@ function quickSet({ key, url }) {
176
178
  console.log('');
177
179
  console.log(chalk.bold(chalk.cyan('Claude Desktop 配置已更新:')));
178
180
  if (key) console.log(chalk.green(' ✓ API Key : ') + maskApiKey(key));
179
- if (url) console.log(chalk.green(' ✓ Base URL : ') + url);
181
+ console.log(chalk.green(' ✓ Base URL : ') + (toWrite.baseUrl || url));
180
182
  console.log('');
181
183
 
182
184
  return true;
@@ -2,7 +2,7 @@
2
2
 
3
3
  const chalk = require('chalk');
4
4
  const inquirer = require('inquirer');
5
- const { CODEX_OPENTOKEN_BASE_URL, CODEX_AUTH_KEY } = require('../models');
5
+ const { CODEX_OPENTOKEN_BASE_URL, CODEX_AUTH_KEY, CODEX_DEFAULT_MODEL } = require('../models');
6
6
  const { fetchModelsForBaseUrl } = require('../fetch-models');
7
7
  const {
8
8
  CONFIG_PATH,
@@ -293,14 +293,16 @@ async function quickSet({ key, url, model }) {
293
293
  if (model) toWrite.model = model;
294
294
  if (key) toWrite.apiKey = key;
295
295
 
296
+ if (key && !url) toWrite.baseUrl = CODEX_OPENTOKEN_BASE_URL;
297
+ if (key && !model) toWrite.model = CODEX_DEFAULT_MODEL;
298
+
296
299
  if (key) {
297
- const listBase = url || getCurrentCodexConfig().baseUrl || CODEX_OPENTOKEN_BASE_URL;
300
+ const listBase = toWrite.baseUrl || url || getCurrentCodexConfig().baseUrl || CODEX_OPENTOKEN_BASE_URL;
298
301
  const fetched = await fetchModelsForBaseUrl(listBase, key, {
299
302
  requiredEndpointType: 'responses',
300
303
  });
301
304
  if (fetched.ok && fetched.models.length > 0) {
302
305
  toWrite.models = fetched.models;
303
- if (!toWrite.model) toWrite.model = fetched.models[0];
304
306
  }
305
307
  }
306
308
 
@@ -311,8 +313,8 @@ async function quickSet({ key, url, model }) {
311
313
  console.log('');
312
314
  console.log(chalk.bold(chalk.cyan('Codex 配置已更新:')));
313
315
  if (key) console.log(chalk.green(' ✓ API Key : ') + maskApiKey(key));
314
- if (url) console.log(chalk.green(' ✓ Base URL : ') + url);
315
- if (toWrite.model) console.log(chalk.green(' ✓ 模型 : ') + toWrite.model);
316
+ console.log(chalk.green(' ✓ Base URL : ') + (toWrite.baseUrl || url));
317
+ console.log(chalk.green(' ✓ 模型 : ') + toWrite.model);
316
318
  if (toWrite.models) {
317
319
  console.log(chalk.gray(' (包含 ' + toWrite.models.length + ' 个 responses 模型)'));
318
320
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  const chalk = require('chalk');
4
4
  const inquirer = require('inquirer');
5
- const { DEFAULT_BASE_URL, HERMES_OPENTOKEN_BASE_URL } = require('../models');
5
+ const { DEFAULT_BASE_URL, HERMES_OPENTOKEN_BASE_URL, GENERAL_DEFAULT_MODEL } = require('../models');
6
6
  const { fetchModelsForBaseUrl } = require('../fetch-models');
7
7
  const {
8
8
  CONFIG_YAML_PATH,
@@ -255,6 +255,8 @@ function quickSet({ key, model }) {
255
255
  if (key) toWrite.apiKey = key;
256
256
  if (model) toWrite.model = model;
257
257
 
258
+ if (key && !model) toWrite.model = GENERAL_DEFAULT_MODEL;
259
+
258
260
  if (Object.keys(toWrite).length === 0) return false;
259
261
 
260
262
  applyHermesConfig(toWrite);
@@ -262,7 +264,7 @@ function quickSet({ key, model }) {
262
264
  console.log('');
263
265
  console.log(chalk.bold(chalk.cyan('Hermes 配置已更新:')));
264
266
  if (key) console.log(chalk.green(' ✓ Opentoken API KEY(.env): ') + maskApiKey(key));
265
- if (model) console.log(chalk.green(' ✓ model.default : ') + model);
267
+ console.log(chalk.green(' ✓ model.default : ') + (toWrite.model || model));
266
268
  console.log(chalk.green(' ✓ provider / base_url : ') + 'custom · ' + HERMES_OPENTOKEN_BASE_URL);
267
269
  console.log(chalk.gray(' ' + CONFIG_YAML_PATH));
268
270
  console.log(chalk.gray(' ' + ENV_PATH));
@@ -2,7 +2,7 @@
2
2
 
3
3
  const chalk = require('chalk');
4
4
  const inquirer = require('inquirer');
5
- const { DEFAULT_BASE_URL, OPENCLAW_PROVIDER_KEY } = require('../models');
5
+ const { DEFAULT_BASE_URL, OPENCLAW_PROVIDER_KEY, GENERAL_DEFAULT_MODEL } = require('../models');
6
6
  const { fetchModelsForBaseUrl } = require('../fetch-models');
7
7
  const {
8
8
  OPENCLAW_JSON_PATH,
@@ -225,6 +225,8 @@ function quickSet({ key, model }) {
225
225
  if (key) toWrite.apiKey = key;
226
226
  if (model) toWrite.model = model;
227
227
 
228
+ if (key && !model) toWrite.model = GENERAL_DEFAULT_MODEL;
229
+
228
230
  if (Object.keys(toWrite).length === 0) return false;
229
231
 
230
232
  applyOpenclawConfig(toWrite);
@@ -232,9 +234,7 @@ function quickSet({ key, model }) {
232
234
  console.log('');
233
235
  console.log(chalk.bold(chalk.cyan('OpenClaw 配置已更新')));
234
236
  if (key) console.log(chalk.green(' ✓ API Key: ') + maskApiKey(key));
235
- if (model) {
236
- console.log(chalk.green(' ✓ 模型: ') + OPENCLAW_PROVIDER_KEY + '/' + model);
237
- }
237
+ console.log(chalk.green(' ✓ 模型: ') + OPENCLAW_PROVIDER_KEY + '/' + (toWrite.model || model));
238
238
  console.log(chalk.gray(' ' + OPENCLAW_JSON_PATH));
239
239
  console.log('');
240
240
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  const chalk = require('chalk');
4
4
  const inquirer = require('inquirer');
5
- const { DEFAULT_BASE_URL, OPENCODE_PROVIDER_KEY } = require('../models');
5
+ const { DEFAULT_BASE_URL, OPENCODE_PROVIDER_KEY, GENERAL_DEFAULT_MODEL } = require('../models');
6
6
  const { fetchModelsForBaseUrl } = require('../fetch-models');
7
7
  const {
8
8
  OPENCODE_JSON_PATH,
@@ -229,6 +229,8 @@ async function quickSet({ key, model }) {
229
229
  if (key) toWrite.apiKey = key;
230
230
  if (model) toWrite.model = model;
231
231
 
232
+ if (key && !model) toWrite.model = GENERAL_DEFAULT_MODEL;
233
+
232
234
  if (Object.keys(toWrite).length === 0) return false;
233
235
 
234
236
  if (key) {
@@ -243,9 +245,7 @@ async function quickSet({ key, model }) {
243
245
  console.log('');
244
246
  console.log(chalk.bold(chalk.cyan('OpenCode 配置已更新')));
245
247
  if (key) console.log(chalk.green(' ✓ API Key: ') + maskApiKey(key));
246
- if (model) {
247
- console.log(chalk.green(' ✓ 模型: ') + model);
248
- }
248
+ console.log(chalk.green(' ✓ 模型: ') + (toWrite.model || model));
249
249
  if (toWrite.models) {
250
250
  console.log(chalk.gray(' (包含 ' + toWrite.models.length + ' 个可用模型)'));
251
251
  }