@pikecode/api-key-manager 1.0.29 → 1.0.31
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 +1 -1
- package/src/commands/edit.js +2 -7
- package/src/commands/switch.js +5 -0
- package/src/config.js +18 -7
package/package.json
CHANGED
package/src/commands/edit.js
CHANGED
|
@@ -200,14 +200,9 @@ class ProviderEditor extends BaseCommand {
|
|
|
200
200
|
await this.configManager.addProvider(name, {
|
|
201
201
|
displayName: answers.displayName,
|
|
202
202
|
ideName: 'codex',
|
|
203
|
-
authMode: 'openai_api_key',
|
|
204
203
|
baseUrl: answers.baseUrl || null,
|
|
205
204
|
authToken: answers.authToken,
|
|
206
|
-
tokenType: null,
|
|
207
|
-
codexFiles: null,
|
|
208
205
|
launchArgs: existingProvider.launchArgs || [],
|
|
209
|
-
primaryModel: existingProvider.models?.primary || null,
|
|
210
|
-
smallFastModel: existingProvider.models?.smallFast || null,
|
|
211
206
|
setAsDefault: false
|
|
212
207
|
});
|
|
213
208
|
} else {
|
|
@@ -221,8 +216,8 @@ class ProviderEditor extends BaseCommand {
|
|
|
221
216
|
tokenType: answers.tokenType, // 仅在 authMode 为 'api_key' 时使用
|
|
222
217
|
launchArgs: answers.launchArgs,
|
|
223
218
|
// Retain original model settings unless we add editing for them
|
|
224
|
-
primaryModel: existingProvider.models
|
|
225
|
-
smallFastModel: existingProvider.models
|
|
219
|
+
primaryModel: existingProvider.models?.primary || null,
|
|
220
|
+
smallFastModel: existingProvider.models?.smallFast || null,
|
|
226
221
|
setAsDefault: false, // Don't change default status on edit
|
|
227
222
|
});
|
|
228
223
|
}
|
package/src/commands/switch.js
CHANGED
|
@@ -1491,6 +1491,11 @@ class EnvSwitcher extends BaseCommand {
|
|
|
1491
1491
|
}
|
|
1492
1492
|
provider.models.primary = answers.primaryModel || null;
|
|
1493
1493
|
provider.models.smallFast = answers.smallFastModel || null;
|
|
1494
|
+
} else {
|
|
1495
|
+
// 确保 Codex 配置不包含 Claude 特定字段
|
|
1496
|
+
provider.authMode = null;
|
|
1497
|
+
provider.tokenType = null;
|
|
1498
|
+
provider.models = null;
|
|
1494
1499
|
}
|
|
1495
1500
|
|
|
1496
1501
|
// 确保 ideName 不被改变
|
package/src/config.js
CHANGED
|
@@ -198,24 +198,35 @@ class ConfigManager {
|
|
|
198
198
|
async addProvider(name, providerConfig) {
|
|
199
199
|
await this.ensureLoaded();
|
|
200
200
|
|
|
201
|
+
const isCodex = providerConfig.ideName === 'codex';
|
|
202
|
+
|
|
201
203
|
this.config.providers[name] = {
|
|
202
204
|
name,
|
|
203
205
|
displayName: providerConfig.displayName || name,
|
|
204
|
-
ideName: providerConfig.ideName || 'claude',
|
|
206
|
+
ideName: providerConfig.ideName || 'claude',
|
|
205
207
|
baseUrl: providerConfig.baseUrl,
|
|
206
208
|
authToken: providerConfig.authToken,
|
|
207
|
-
authMode: providerConfig.authMode || 'api_key',
|
|
208
|
-
tokenType: providerConfig.tokenType || 'api_key', // 仅在 authMode 为 'api_key' 时使用
|
|
209
209
|
launchArgs: providerConfig.launchArgs || [],
|
|
210
|
-
models: {
|
|
211
|
-
primary: providerConfig.primaryModel || null,
|
|
212
|
-
smallFast: providerConfig.smallFastModel || null
|
|
213
|
-
},
|
|
214
210
|
createdAt: new Date().toISOString(),
|
|
215
211
|
lastUsed: new Date().toISOString(),
|
|
216
212
|
current: false
|
|
217
213
|
};
|
|
218
214
|
|
|
215
|
+
// Claude Code 特定字段
|
|
216
|
+
if (!isCodex) {
|
|
217
|
+
this.config.providers[name].authMode = providerConfig.authMode || 'api_key';
|
|
218
|
+
this.config.providers[name].tokenType = providerConfig.tokenType || 'api_key';
|
|
219
|
+
this.config.providers[name].models = {
|
|
220
|
+
primary: providerConfig.primaryModel || null,
|
|
221
|
+
smallFast: providerConfig.smallFastModel || null
|
|
222
|
+
};
|
|
223
|
+
} else {
|
|
224
|
+
// Codex 不需要这些字段,设置为 null 以保持向后兼容
|
|
225
|
+
this.config.providers[name].authMode = null;
|
|
226
|
+
this.config.providers[name].tokenType = null;
|
|
227
|
+
this.config.providers[name].models = null;
|
|
228
|
+
}
|
|
229
|
+
|
|
219
230
|
// 如果是第一个供应商或设置为默认,则设为当前供应商
|
|
220
231
|
if (Object.keys(this.config.providers).length === 1 || providerConfig.setAsDefault) {
|
|
221
232
|
// 重置所有供应商的current状态
|