@pikecode/api-key-manager 1.3.3 → 1.3.4
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/switch.js +55 -222
- package/src/utils/provider-status-checker.js +8 -22
package/package.json
CHANGED
package/src/commands/switch.js
CHANGED
|
@@ -90,12 +90,6 @@ class EnvSwitcher extends BaseCommand {
|
|
|
90
90
|
]));
|
|
91
91
|
console.log();
|
|
92
92
|
|
|
93
|
-
// 设置 ESC 键监听
|
|
94
|
-
const escListener = this.createESCListener(() => {
|
|
95
|
-
Logger.info('返回供应商选择');
|
|
96
|
-
this.showProviderSelection();
|
|
97
|
-
}, '返回供应商选择');
|
|
98
|
-
|
|
99
93
|
// 显示启动参数选择界面
|
|
100
94
|
const choices = [
|
|
101
95
|
{
|
|
@@ -108,17 +102,17 @@ class EnvSwitcher extends BaseCommand {
|
|
|
108
102
|
|
|
109
103
|
let answers;
|
|
110
104
|
try {
|
|
111
|
-
answers = await this.
|
|
105
|
+
answers = await this.promptWithESC(choices, '返回供应商选择', () => {
|
|
106
|
+
Logger.info('返回供应商选择');
|
|
107
|
+
this.showProviderSelection();
|
|
108
|
+
});
|
|
112
109
|
} catch (error) {
|
|
113
|
-
this.removeESCListener(escListener);
|
|
114
110
|
if (this.isEscCancelled(error)) {
|
|
115
111
|
return;
|
|
116
112
|
}
|
|
117
113
|
throw error;
|
|
118
114
|
}
|
|
119
115
|
|
|
120
|
-
this.removeESCListener(escListener);
|
|
121
|
-
|
|
122
116
|
// 检查互斥参数
|
|
123
117
|
const conflictError = LaunchArgsHelper.validateArgsConflict(answers.selectedArgs, availableArgs);
|
|
124
118
|
if (conflictError) {
|
|
@@ -288,15 +282,7 @@ class EnvSwitcher extends BaseCommand {
|
|
|
288
282
|
const filterSuffix = this.filter === 'codex' ? ' (Codex CLI)' : (this.filter === 'claude' ? ' (Claude Code)' : '');
|
|
289
283
|
const promptMessage = `请选择要切换的供应商${filterSuffix} (总计 ${providers.length} 个):`;
|
|
290
284
|
|
|
291
|
-
|
|
292
|
-
const escListener = this.createESCListener(() => {
|
|
293
|
-
Logger.info('退出程序');
|
|
294
|
-
this.showExitScreen();
|
|
295
|
-
this.destroy();
|
|
296
|
-
process.exit(0);
|
|
297
|
-
}, '退出程序');
|
|
298
|
-
|
|
299
|
-
const answer = await this.prompt([
|
|
285
|
+
const answer = await this.promptWithESC([
|
|
300
286
|
{
|
|
301
287
|
type: 'list',
|
|
302
288
|
name: 'provider',
|
|
@@ -305,7 +291,12 @@ class EnvSwitcher extends BaseCommand {
|
|
|
305
291
|
default: defaultChoice,
|
|
306
292
|
pageSize: this._getPageSize(choices.length)
|
|
307
293
|
}
|
|
308
|
-
])
|
|
294
|
+
], '退出程序', () => {
|
|
295
|
+
Logger.info('退出程序');
|
|
296
|
+
this.showExitScreen();
|
|
297
|
+
this.destroy();
|
|
298
|
+
process.exit(0);
|
|
299
|
+
});
|
|
309
300
|
|
|
310
301
|
if (answer.provider === '__OPEN_CONFIG__') {
|
|
311
302
|
await this.openConfigFile();
|
|
@@ -390,15 +381,9 @@ class EnvSwitcher extends BaseCommand {
|
|
|
390
381
|
{ name: `${UIHelper.icons.back} 返回主菜单`, value: 'back' }
|
|
391
382
|
];
|
|
392
383
|
|
|
393
|
-
// 设置 ESC 键监听
|
|
394
|
-
const escListener = this.createESCListener(() => {
|
|
395
|
-
Logger.info('返回供应商选择');
|
|
396
|
-
this.showProviderSelection();
|
|
397
|
-
}, '返回供应商选择');
|
|
398
|
-
|
|
399
384
|
let answer;
|
|
400
385
|
try {
|
|
401
|
-
answer = await this.
|
|
386
|
+
answer = await this.promptWithESC([
|
|
402
387
|
{
|
|
403
388
|
type: 'list',
|
|
404
389
|
name: 'setting',
|
|
@@ -406,24 +391,20 @@ class EnvSwitcher extends BaseCommand {
|
|
|
406
391
|
choices,
|
|
407
392
|
pageSize: 8
|
|
408
393
|
}
|
|
409
|
-
])
|
|
394
|
+
], '返回供应商选择', () => {
|
|
395
|
+
Logger.info('返回供应商选择');
|
|
396
|
+
this.showProviderSelection();
|
|
397
|
+
});
|
|
410
398
|
} catch (error) {
|
|
411
|
-
this.removeESCListener(escListener);
|
|
412
399
|
if (this.isEscCancelled(error)) {
|
|
413
400
|
return;
|
|
414
401
|
}
|
|
415
402
|
throw error;
|
|
416
403
|
}
|
|
417
404
|
|
|
418
|
-
this.removeESCListener(escListener);
|
|
419
|
-
|
|
420
405
|
switch (answer.setting) {
|
|
421
406
|
case 'search':
|
|
422
407
|
return await this.showSearchProvider();
|
|
423
|
-
case 'batch':
|
|
424
|
-
return await this.showBatchEdit();
|
|
425
|
-
case 'global':
|
|
426
|
-
return await this.showGlobalSettings();
|
|
427
408
|
case 'stats':
|
|
428
409
|
return await this.showStatistics();
|
|
429
410
|
case 'back':
|
|
@@ -431,84 +412,6 @@ class EnvSwitcher extends BaseCommand {
|
|
|
431
412
|
}
|
|
432
413
|
}
|
|
433
414
|
|
|
434
|
-
async showBatchEdit() {
|
|
435
|
-
this.clearScreen();
|
|
436
|
-
console.log(UIHelper.createTitle('批量编辑', UIHelper.icons.edit));
|
|
437
|
-
console.log();
|
|
438
|
-
console.log(UIHelper.createTooltip('此功能正在开发中...'));
|
|
439
|
-
console.log();
|
|
440
|
-
console.log(UIHelper.createHintLine([
|
|
441
|
-
['Enter', '返回上一页'],
|
|
442
|
-
['ESC', '返回快速设置']
|
|
443
|
-
]));
|
|
444
|
-
console.log();
|
|
445
|
-
|
|
446
|
-
// 设置 ESC 键监听
|
|
447
|
-
const escListener = this.createESCListener(() => {
|
|
448
|
-
Logger.info('返回快速设置');
|
|
449
|
-
this.showQuickSettings();
|
|
450
|
-
}, '返回快速设置');
|
|
451
|
-
|
|
452
|
-
try {
|
|
453
|
-
await this.prompt([
|
|
454
|
-
{
|
|
455
|
-
type: 'input',
|
|
456
|
-
name: 'continue',
|
|
457
|
-
message: '按回车键返回...'
|
|
458
|
-
}
|
|
459
|
-
]);
|
|
460
|
-
} catch (error) {
|
|
461
|
-
this.removeESCListener(escListener);
|
|
462
|
-
if (this.isEscCancelled(error)) {
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
|
-
throw error;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
this.removeESCListener(escListener);
|
|
469
|
-
|
|
470
|
-
return await this.showQuickSettings();
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
async showGlobalSettings() {
|
|
474
|
-
this.clearScreen();
|
|
475
|
-
console.log(UIHelper.createTitle('全局设置', UIHelper.icons.settings));
|
|
476
|
-
console.log();
|
|
477
|
-
console.log(UIHelper.createTooltip('此功能正在开发中...'));
|
|
478
|
-
console.log();
|
|
479
|
-
console.log(UIHelper.createHintLine([
|
|
480
|
-
['Enter', '返回上一页'],
|
|
481
|
-
['ESC', '返回快速设置']
|
|
482
|
-
]));
|
|
483
|
-
console.log();
|
|
484
|
-
|
|
485
|
-
// 设置 ESC 键监听
|
|
486
|
-
const escListener = this.createESCListener(() => {
|
|
487
|
-
Logger.info('返回快速设置');
|
|
488
|
-
this.showQuickSettings();
|
|
489
|
-
}, '返回快速设置');
|
|
490
|
-
|
|
491
|
-
try {
|
|
492
|
-
await this.prompt([
|
|
493
|
-
{
|
|
494
|
-
type: 'input',
|
|
495
|
-
name: 'continue',
|
|
496
|
-
message: '按回车键返回...'
|
|
497
|
-
}
|
|
498
|
-
]);
|
|
499
|
-
} catch (error) {
|
|
500
|
-
this.removeESCListener(escListener);
|
|
501
|
-
if (this.isEscCancelled(error)) {
|
|
502
|
-
return;
|
|
503
|
-
}
|
|
504
|
-
throw error;
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
this.removeESCListener(escListener);
|
|
508
|
-
|
|
509
|
-
return await this.showQuickSettings();
|
|
510
|
-
}
|
|
511
|
-
|
|
512
415
|
async showSearchProvider() {
|
|
513
416
|
this.clearScreen();
|
|
514
417
|
console.log(UIHelper.createHintLine([
|
|
@@ -517,32 +420,26 @@ class EnvSwitcher extends BaseCommand {
|
|
|
517
420
|
]));
|
|
518
421
|
console.log(UIHelper.createTooltip('示例: claude、demo 或供应商别名'));
|
|
519
422
|
console.log();
|
|
520
|
-
// 设置 ESC 键监听
|
|
521
|
-
const escListener = this.createESCListener(() => {
|
|
522
|
-
Logger.info('返回快速设置');
|
|
523
|
-
this.showQuickSettings();
|
|
524
|
-
}, '返回快速设置');
|
|
525
|
-
|
|
526
423
|
let answer;
|
|
527
424
|
try {
|
|
528
|
-
answer = await this.
|
|
425
|
+
answer = await this.promptWithESC([
|
|
529
426
|
{
|
|
530
427
|
type: 'input',
|
|
531
428
|
name: 'search',
|
|
532
429
|
message: '输入供应商名称搜索:',
|
|
533
430
|
validate: input => input.trim() !== '' || '请输入搜索内容'
|
|
534
431
|
}
|
|
535
|
-
])
|
|
432
|
+
], '返回快速设置', () => {
|
|
433
|
+
Logger.info('返回快速设置');
|
|
434
|
+
this.showQuickSettings();
|
|
435
|
+
});
|
|
536
436
|
} catch (error) {
|
|
537
|
-
this.removeESCListener(escListener);
|
|
538
437
|
if (this.isEscCancelled(error)) {
|
|
539
438
|
return;
|
|
540
439
|
}
|
|
541
440
|
throw error;
|
|
542
441
|
}
|
|
543
442
|
|
|
544
|
-
this.removeESCListener(escListener);
|
|
545
|
-
|
|
546
443
|
await this.configManager.load();
|
|
547
444
|
const providers = this.configManager.listProviders();
|
|
548
445
|
const searchResults = providers.filter(p =>
|
|
@@ -572,22 +469,9 @@ class EnvSwitcher extends BaseCommand {
|
|
|
572
469
|
const currentProvider = searchResults.find(p => p.current);
|
|
573
470
|
const defaultChoice = currentProvider ? currentProvider.name : searchResults[0]?.name;
|
|
574
471
|
|
|
575
|
-
// 设置 ESC 键监听
|
|
576
|
-
const escListener2 = this.createESCListener(() => {
|
|
577
|
-
Logger.info('返回快速设置');
|
|
578
|
-
this.showQuickSettings();
|
|
579
|
-
}, '返回快速设置');
|
|
580
|
-
|
|
581
|
-
console.log();
|
|
582
|
-
console.log(UIHelper.createHintLine([
|
|
583
|
-
['↑ / ↓', '选择结果'],
|
|
584
|
-
['Enter', '查看详情'],
|
|
585
|
-
['ESC', '返回快速设置']
|
|
586
|
-
]));
|
|
587
|
-
|
|
588
472
|
let result;
|
|
589
473
|
try {
|
|
590
|
-
result = await this.
|
|
474
|
+
result = await this.promptWithESC([
|
|
591
475
|
{
|
|
592
476
|
type: 'list',
|
|
593
477
|
name: 'provider',
|
|
@@ -596,17 +480,17 @@ class EnvSwitcher extends BaseCommand {
|
|
|
596
480
|
default: defaultChoice,
|
|
597
481
|
pageSize: 10
|
|
598
482
|
}
|
|
599
|
-
])
|
|
483
|
+
], '返回快速设置', () => {
|
|
484
|
+
Logger.info('返回快速设置');
|
|
485
|
+
this.showQuickSettings();
|
|
486
|
+
});
|
|
600
487
|
} catch (error) {
|
|
601
|
-
this.removeESCListener(escListener2);
|
|
602
488
|
if (this.isEscCancelled(error)) {
|
|
603
489
|
return;
|
|
604
490
|
}
|
|
605
491
|
throw error;
|
|
606
492
|
}
|
|
607
493
|
|
|
608
|
-
this.removeESCListener(escListener2);
|
|
609
|
-
|
|
610
494
|
if (result.provider === 'back') {
|
|
611
495
|
return await this.showQuickSettings();
|
|
612
496
|
}
|
|
@@ -637,30 +521,25 @@ class EnvSwitcher extends BaseCommand {
|
|
|
637
521
|
|
|
638
522
|
console.log(UIHelper.createTable(['项目', '数据'], stats));
|
|
639
523
|
console.log();
|
|
640
|
-
// 设置 ESC 键监听
|
|
641
|
-
const escListener = this.createESCListener(() => {
|
|
642
|
-
Logger.info('返回快速设置');
|
|
643
|
-
this.showQuickSettings();
|
|
644
|
-
}, '返回快速设置');
|
|
645
|
-
|
|
646
524
|
try {
|
|
647
|
-
await this.
|
|
525
|
+
await this.promptWithESC([
|
|
648
526
|
{
|
|
649
527
|
type: 'list',
|
|
650
528
|
name: 'action',
|
|
651
529
|
message: '操作:',
|
|
652
530
|
choices: [{ name: `${UIHelper.icons.back} 返回`, value: 'back' }]
|
|
653
531
|
}
|
|
654
|
-
])
|
|
532
|
+
], '返回快速设置', () => {
|
|
533
|
+
Logger.info('返回快速设置');
|
|
534
|
+
this.showQuickSettings();
|
|
535
|
+
});
|
|
655
536
|
} catch (error) {
|
|
656
|
-
this.removeESCListener(escListener);
|
|
657
537
|
if (this.isEscCancelled(error)) {
|
|
658
538
|
return;
|
|
659
539
|
}
|
|
660
540
|
throw error;
|
|
661
541
|
}
|
|
662
542
|
|
|
663
|
-
this.removeESCListener(escListener);
|
|
664
543
|
return await this.showQuickSettings();
|
|
665
544
|
}
|
|
666
545
|
|
|
@@ -709,35 +588,25 @@ class EnvSwitcher extends BaseCommand {
|
|
|
709
588
|
console.log();
|
|
710
589
|
});
|
|
711
590
|
|
|
712
|
-
const escListener = this.createESCListener(() => {
|
|
713
|
-
Logger.info('返回主菜单');
|
|
714
|
-
this.showProviderSelection();
|
|
715
|
-
}, '返回主菜单');
|
|
716
|
-
|
|
717
|
-
console.log(UIHelper.createHintLine([
|
|
718
|
-
['Enter', '返回主菜单'],
|
|
719
|
-
['ESC', '返回主菜单']
|
|
720
|
-
]));
|
|
721
|
-
console.log();
|
|
722
|
-
|
|
723
591
|
try {
|
|
724
|
-
await this.
|
|
592
|
+
await this.promptWithESC([
|
|
725
593
|
{
|
|
726
594
|
type: 'list',
|
|
727
595
|
name: 'action',
|
|
728
596
|
message: '操作:',
|
|
729
597
|
choices: [{ name: `${UIHelper.icons.back} 返回主菜单`, value: 'back' }]
|
|
730
598
|
}
|
|
731
|
-
])
|
|
599
|
+
], '返回主菜单', () => {
|
|
600
|
+
Logger.info('返回主菜单');
|
|
601
|
+
this.showProviderSelection();
|
|
602
|
+
});
|
|
732
603
|
} catch (error) {
|
|
733
|
-
this.removeESCListener(escListener);
|
|
734
604
|
if (this.isEscCancelled(error)) {
|
|
735
605
|
return;
|
|
736
606
|
}
|
|
737
607
|
throw error;
|
|
738
608
|
}
|
|
739
609
|
|
|
740
|
-
this.removeESCListener(escListener);
|
|
741
610
|
return await this.showProviderSelection();
|
|
742
611
|
}
|
|
743
612
|
|
|
@@ -774,14 +643,9 @@ class EnvSwitcher extends BaseCommand {
|
|
|
774
643
|
}
|
|
775
644
|
|
|
776
645
|
// 设置 ESC 键监听
|
|
777
|
-
escListener = this.createESCListener(() => {
|
|
778
|
-
Logger.info('返回供应商选择');
|
|
779
|
-
this.showProviderSelection();
|
|
780
|
-
}, '返回供应商选择');
|
|
781
|
-
|
|
782
646
|
let answer;
|
|
783
647
|
try {
|
|
784
|
-
answer = await this.
|
|
648
|
+
answer = await this.promptWithESC([
|
|
785
649
|
{
|
|
786
650
|
type: 'list',
|
|
787
651
|
name: 'action',
|
|
@@ -789,7 +653,10 @@ class EnvSwitcher extends BaseCommand {
|
|
|
789
653
|
choices,
|
|
790
654
|
pageSize: this._getPageSize(choices.length)
|
|
791
655
|
}
|
|
792
|
-
])
|
|
656
|
+
], '返回供应商选择', () => {
|
|
657
|
+
Logger.info('返回供应商选择');
|
|
658
|
+
this.showProviderSelection();
|
|
659
|
+
});
|
|
793
660
|
} catch (error) {
|
|
794
661
|
if (this.isEscCancelled(error)) {
|
|
795
662
|
return;
|
|
@@ -797,8 +664,6 @@ class EnvSwitcher extends BaseCommand {
|
|
|
797
664
|
throw error;
|
|
798
665
|
}
|
|
799
666
|
|
|
800
|
-
this.removeESCListener(escListener);
|
|
801
|
-
|
|
802
667
|
this._cancelStatusRefresh();
|
|
803
668
|
|
|
804
669
|
const result = await this.handleManageAction(answer.action);
|
|
@@ -1029,24 +894,20 @@ class EnvSwitcher extends BaseCommand {
|
|
|
1029
894
|
console.log();
|
|
1030
895
|
}
|
|
1031
896
|
|
|
1032
|
-
// 设置 ESC 键监听
|
|
1033
|
-
escListener = this.createESCListener(() => {
|
|
1034
|
-
Logger.info('返回管理列表');
|
|
1035
|
-
this.showManageMenu();
|
|
1036
|
-
}, '返回管理列表');
|
|
1037
|
-
|
|
1038
897
|
let answer;
|
|
1039
898
|
try {
|
|
1040
|
-
answer = await this.
|
|
899
|
+
answer = await this.promptWithESC([
|
|
1041
900
|
{
|
|
1042
901
|
type: 'list',
|
|
1043
902
|
name: 'action',
|
|
1044
903
|
message: '选择操作:',
|
|
1045
904
|
choices: ProviderDetailsHelper.buildActionChoices(UIHelper.icons)
|
|
1046
905
|
}
|
|
1047
|
-
])
|
|
906
|
+
], '返回管理列表', () => {
|
|
907
|
+
Logger.info('返回管理列表');
|
|
908
|
+
this.showManageMenu();
|
|
909
|
+
});
|
|
1048
910
|
} catch (error) {
|
|
1049
|
-
this.removeESCListener(escListener);
|
|
1050
911
|
if (this.isEscCancelled(error)) {
|
|
1051
912
|
return;
|
|
1052
913
|
}
|
|
@@ -1055,32 +916,21 @@ class EnvSwitcher extends BaseCommand {
|
|
|
1055
916
|
|
|
1056
917
|
switch (answer.action) {
|
|
1057
918
|
case 'back':
|
|
1058
|
-
// 移除 ESC 键监听
|
|
1059
|
-
this.removeESCListener(escListener);
|
|
1060
919
|
return await this.showManageMenu();
|
|
1061
920
|
case 'edit':
|
|
1062
|
-
// 移除 ESC 键监听
|
|
1063
|
-
this.removeESCListener(escListener);
|
|
1064
921
|
return await this.editProvider(providerName);
|
|
1065
922
|
case 'remove':
|
|
1066
|
-
// 移除 ESC 键监听
|
|
1067
|
-
this.removeESCListener(escListener);
|
|
1068
923
|
return await this.removeProvider(providerName);
|
|
1069
924
|
case 'launch':
|
|
1070
|
-
// 移除 ESC 键监听
|
|
1071
|
-
this.removeESCListener(escListener);
|
|
1072
925
|
return await this.showLaunchArgsSelection(providerName);
|
|
1073
926
|
}
|
|
1074
927
|
|
|
1075
928
|
} catch (error) {
|
|
1076
|
-
// 移除 ESC 键监听
|
|
1077
|
-
this.removeESCListener(escListener);
|
|
1078
929
|
await this.handleError(error, '显示供应商详情');
|
|
1079
930
|
}
|
|
1080
931
|
}
|
|
1081
932
|
|
|
1082
933
|
async editProvider(providerName) {
|
|
1083
|
-
let escListener;
|
|
1084
934
|
try {
|
|
1085
935
|
await this.configManager.load();
|
|
1086
936
|
let provider = this.configManager.getProvider(providerName);
|
|
@@ -1091,21 +941,17 @@ class EnvSwitcher extends BaseCommand {
|
|
|
1091
941
|
return await this.showManageMenu();
|
|
1092
942
|
}
|
|
1093
943
|
|
|
1094
|
-
// 设置 ESC 键监听
|
|
1095
|
-
escListener = this.createESCListener(() => {
|
|
1096
|
-
Logger.info('取消编辑供应商');
|
|
1097
|
-
this.showManageMenu();
|
|
1098
|
-
}, '取消编辑');
|
|
1099
|
-
|
|
1100
944
|
// 根据 IDE 类型构建不同的问卷
|
|
1101
945
|
const isCodex = provider.ideName === 'codex';
|
|
1102
946
|
const questions = ProviderEditQuestionsHelper.buildQuestions(provider, validator);
|
|
1103
947
|
|
|
1104
948
|
let answers;
|
|
1105
949
|
try {
|
|
1106
|
-
answers = await this.
|
|
950
|
+
answers = await this.promptWithESC(questions, '取消编辑', () => {
|
|
951
|
+
Logger.info('取消编辑供应商');
|
|
952
|
+
this.showManageMenu();
|
|
953
|
+
});
|
|
1107
954
|
} catch (error) {
|
|
1108
|
-
this.removeESCListener(escListener);
|
|
1109
955
|
if (this.isEscCancelled(error)) {
|
|
1110
956
|
return;
|
|
1111
957
|
}
|
|
@@ -1168,20 +1014,15 @@ class EnvSwitcher extends BaseCommand {
|
|
|
1168
1014
|
await this.configManager.save();
|
|
1169
1015
|
Logger.success(`供应商 '${newName}' 已更新`);
|
|
1170
1016
|
|
|
1171
|
-
// 移除 ESC 键监听
|
|
1172
|
-
this.removeESCListener(escListener);
|
|
1173
1017
|
return await this.showManageMenu();
|
|
1174
1018
|
|
|
1175
1019
|
} catch (error) {
|
|
1176
|
-
// 移除 ESC 键监听
|
|
1177
|
-
this.removeESCListener(escListener);
|
|
1178
1020
|
Logger.error(`编辑供应商失败: ${error.message}`);
|
|
1179
1021
|
throw error;
|
|
1180
1022
|
}
|
|
1181
1023
|
}
|
|
1182
1024
|
|
|
1183
1025
|
async removeProvider(providerName) {
|
|
1184
|
-
let escListener;
|
|
1185
1026
|
try {
|
|
1186
1027
|
await this.configManager.load();
|
|
1187
1028
|
const provider = this.configManager.getProvider(providerName);
|
|
@@ -1192,24 +1033,20 @@ class EnvSwitcher extends BaseCommand {
|
|
|
1192
1033
|
return await this.showManageMenu();
|
|
1193
1034
|
}
|
|
1194
1035
|
|
|
1195
|
-
// 设置 ESC 键监听
|
|
1196
|
-
escListener = this.createESCListener(() => {
|
|
1197
|
-
Logger.info('取消删除供应商');
|
|
1198
|
-
this.showManageMenu();
|
|
1199
|
-
}, '取消删除');
|
|
1200
|
-
|
|
1201
1036
|
let confirm;
|
|
1202
1037
|
try {
|
|
1203
|
-
confirm = await this.
|
|
1038
|
+
confirm = await this.promptWithESC([
|
|
1204
1039
|
{
|
|
1205
1040
|
type: 'confirm',
|
|
1206
1041
|
name: 'confirmed',
|
|
1207
1042
|
message: `确定要删除供应商 '${providerName}' 吗?`,
|
|
1208
1043
|
default: false
|
|
1209
1044
|
}
|
|
1210
|
-
])
|
|
1045
|
+
], '取消删除', () => {
|
|
1046
|
+
Logger.info('取消删除供应商');
|
|
1047
|
+
this.showManageMenu();
|
|
1048
|
+
});
|
|
1211
1049
|
} catch (error) {
|
|
1212
|
-
this.removeESCListener(escListener);
|
|
1213
1050
|
if (this.isEscCancelled(error)) {
|
|
1214
1051
|
return;
|
|
1215
1052
|
}
|
|
@@ -1223,13 +1060,9 @@ class EnvSwitcher extends BaseCommand {
|
|
|
1223
1060
|
Logger.info('删除操作已取消');
|
|
1224
1061
|
}
|
|
1225
1062
|
|
|
1226
|
-
// 移除 ESC 键监听
|
|
1227
|
-
this.removeESCListener(escListener);
|
|
1228
1063
|
return await this.showManageMenu();
|
|
1229
1064
|
|
|
1230
1065
|
} catch (error) {
|
|
1231
|
-
// 移除 ESC 键监听
|
|
1232
|
-
this.removeESCListener(escListener);
|
|
1233
1066
|
Logger.error(`删除供应商失败: ${error.message}`);
|
|
1234
1067
|
throw error;
|
|
1235
1068
|
}
|
|
@@ -204,36 +204,22 @@ class ProviderStatusChecker {
|
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
if (Array.isArray(response.content)) {
|
|
207
|
+
const textFields = ['text', 'thinking', 'output_text', 'argument', 'result'];
|
|
207
208
|
const textParts = [];
|
|
209
|
+
|
|
208
210
|
for (const block of response.content) {
|
|
209
|
-
if (!block)
|
|
210
|
-
continue;
|
|
211
|
-
}
|
|
211
|
+
if (!block) continue;
|
|
212
212
|
if (typeof block === 'string') {
|
|
213
213
|
textParts.push(block);
|
|
214
214
|
continue;
|
|
215
215
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if (typeof block.thinking === 'string' && block.thinking.trim()) {
|
|
221
|
-
textParts.push(block.thinking);
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
if (typeof block.output_text === 'string' && block.output_text.trim()) {
|
|
225
|
-
textParts.push(block.output_text);
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
if (typeof block.argument === 'string' && block.argument.trim()) {
|
|
229
|
-
textParts.push(block.argument);
|
|
230
|
-
continue;
|
|
231
|
-
}
|
|
232
|
-
if (typeof block.result === 'string' && block.result.trim()) {
|
|
233
|
-
textParts.push(block.result);
|
|
234
|
-
continue;
|
|
216
|
+
for (const field of textFields) {
|
|
217
|
+
if (typeof block[field] === 'string' && block[field].trim()) {
|
|
218
|
+
textParts.push(block[field]);
|
|
219
|
+
}
|
|
235
220
|
}
|
|
236
221
|
}
|
|
222
|
+
|
|
237
223
|
const combined = textParts
|
|
238
224
|
.map(part => part.replace(/\s+/g, ' ').trim())
|
|
239
225
|
.filter(Boolean)
|