@tokenaut/opentoken 1.4.12 → 1.4.13

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/tools/codex.js +23 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenaut/opentoken",
3
- "version": "1.4.12",
3
+ "version": "1.4.13",
4
4
  "description": "OpenToken 一键接入 AI 模型 · https://docs.opentoken.io/",
5
5
  "main": "src/cli.js",
6
6
  "bin": {
@@ -343,6 +343,29 @@ async function test() {
343
343
  return;
344
344
  }
345
345
 
346
+ const OPENTOKEN_URLS = ['https://cn2.gw.opentoken.io', 'https://gw.opentoken.io'];
347
+ const baseUrlClean = config.baseUrl.replace(/\/+$/, '').replace(/\/v1$/, '');
348
+ const isOpenTokenUrl = OPENTOKEN_URLS.some((u) => baseUrlClean === u);
349
+
350
+ if (!isOpenTokenUrl) {
351
+ console.log('');
352
+ console.log(chalk.yellow(' ⚠ 当前调用地址不是 opentoken 的地址,是否继续检查?'));
353
+ console.log(chalk.gray(' 当前 URL : ') + config.baseUrl);
354
+ console.log('');
355
+ const { confirm } = await inquirer.prompt([
356
+ {
357
+ type: 'input',
358
+ name: 'confirm',
359
+ message: ' 继续测试?(y/n)',
360
+ default: 'n',
361
+ },
362
+ ]);
363
+ if (confirm.toLowerCase() !== 'y') {
364
+ console.log(chalk.gray(' 已取消测试'));
365
+ return;
366
+ }
367
+ }
368
+
346
369
  console.log('');
347
370
  console.log(chalk.bold(chalk.cyan('正在测试 Codex 连接...')));
348
371
  console.log(chalk.gray(' Base URL : ') + config.baseUrl);