@pikecode/api-key-manager 2.0.4 → 2.0.5
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/package.json
CHANGED
|
@@ -38,6 +38,20 @@ async function promptProviderInfo(adder) {
|
|
|
38
38
|
validate: input => {
|
|
39
39
|
const err = validator.validateName(input);
|
|
40
40
|
return err || true;
|
|
41
|
+
},
|
|
42
|
+
when: answers => {
|
|
43
|
+
// 如果选择了官方登录,直接用 "openai-official",不需要输入名称
|
|
44
|
+
if ((answers.ideName || adder.presetIdeName) === 'codex' && answers.authMode === 'chatgpt_login') {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
},
|
|
49
|
+
default: answers => {
|
|
50
|
+
// 官方登录模式下返回默认名称
|
|
51
|
+
if ((answers.ideName || adder.presetIdeName) === 'codex' && answers.authMode === 'chatgpt_login') {
|
|
52
|
+
return 'openai-official';
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
41
55
|
}
|
|
42
56
|
},
|
|
43
57
|
{
|
|
@@ -86,7 +100,13 @@ async function promptProviderInfo(adder) {
|
|
|
86
100
|
{ name: UI_MESSAGES.AUTH_MODE_CODEX_CHATGPT_LOGIN, value: 'chatgpt_login' }
|
|
87
101
|
],
|
|
88
102
|
default: 'api_key',
|
|
89
|
-
when: answers =>
|
|
103
|
+
when: answers => {
|
|
104
|
+
const isCodex = (answers.ideName || adder.presetIdeName) === 'codex';
|
|
105
|
+
if (!isCodex) return false;
|
|
106
|
+
// 如果已经有官方配置了,就用 api_key 模式,不提示选择
|
|
107
|
+
const hasOfficialConfig = adder.configManager.getProvider('openai-official');
|
|
108
|
+
return !hasOfficialConfig;
|
|
109
|
+
}
|
|
90
110
|
},
|
|
91
111
|
{
|
|
92
112
|
type: 'input',
|
|
@@ -57,7 +57,7 @@ async function saveProvider(adder, answers) {
|
|
|
57
57
|
|
|
58
58
|
// 如果是首个 Codex 配置,自动创建官方登录配置
|
|
59
59
|
if (answers.ideName === 'codex') {
|
|
60
|
-
const existingCodexProviders =
|
|
60
|
+
const existingCodexProviders = adder.configManager.listProviders()
|
|
61
61
|
.filter(p => p.ideName === 'codex');
|
|
62
62
|
|
|
63
63
|
// 只有当刚才添加的是第一个 Codex 配置,且没有官方配置时才创建
|
package/src/commands/add.js
CHANGED
|
@@ -66,8 +66,17 @@ class ProviderAdder extends BaseCommand {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
if (answers.ideName === 'codex') {
|
|
69
|
-
// authMode 由用户在 prompts
|
|
70
|
-
//
|
|
69
|
+
// authMode 由用户在 prompts 中选择,没有官方配置时才提示
|
|
70
|
+
// 如果已有官方配置,默认为 api_key
|
|
71
|
+
if (!answers.authMode) {
|
|
72
|
+
answers.authMode = 'api_key';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 官方登录模式下自动设置名称为 openai-official
|
|
76
|
+
if (answers.authMode === 'chatgpt_login' && !answers.name) {
|
|
77
|
+
answers.name = 'openai-official';
|
|
78
|
+
}
|
|
79
|
+
|
|
71
80
|
answers.codexFiles = null;
|
|
72
81
|
|
|
73
82
|
// Codex 启动参数配置
|