@pikecode/api-key-manager 1.3.2 → 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 +58 -221
- 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,27 +643,27 @@ 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',
|
|
788
652
|
message: `选择供应商或操作 (总计 ${providers.length} 个):`,
|
|
789
653
|
choices,
|
|
790
654
|
pageSize: this._getPageSize(choices.length)
|
|
655
|
+
}
|
|
656
|
+
], '返回供应商选择', () => {
|
|
657
|
+
Logger.info('返回供应商选择');
|
|
658
|
+
this.showProviderSelection();
|
|
659
|
+
});
|
|
660
|
+
} catch (error) {
|
|
661
|
+
if (this.isEscCancelled(error)) {
|
|
791
662
|
return;
|
|
792
663
|
}
|
|
793
664
|
throw error;
|
|
794
665
|
}
|
|
795
666
|
|
|
796
|
-
this.removeESCListener(escListener);
|
|
797
|
-
|
|
798
667
|
this._cancelStatusRefresh();
|
|
799
668
|
|
|
800
669
|
const result = await this.handleManageAction(answer.action);
|
|
@@ -1025,24 +894,20 @@ class EnvSwitcher extends BaseCommand {
|
|
|
1025
894
|
console.log();
|
|
1026
895
|
}
|
|
1027
896
|
|
|
1028
|
-
// 设置 ESC 键监听
|
|
1029
|
-
escListener = this.createESCListener(() => {
|
|
1030
|
-
Logger.info('返回管理列表');
|
|
1031
|
-
this.showManageMenu();
|
|
1032
|
-
}, '返回管理列表');
|
|
1033
|
-
|
|
1034
897
|
let answer;
|
|
1035
898
|
try {
|
|
1036
|
-
answer = await this.
|
|
899
|
+
answer = await this.promptWithESC([
|
|
1037
900
|
{
|
|
1038
901
|
type: 'list',
|
|
1039
902
|
name: 'action',
|
|
1040
903
|
message: '选择操作:',
|
|
1041
904
|
choices: ProviderDetailsHelper.buildActionChoices(UIHelper.icons)
|
|
1042
905
|
}
|
|
1043
|
-
])
|
|
906
|
+
], '返回管理列表', () => {
|
|
907
|
+
Logger.info('返回管理列表');
|
|
908
|
+
this.showManageMenu();
|
|
909
|
+
});
|
|
1044
910
|
} catch (error) {
|
|
1045
|
-
this.removeESCListener(escListener);
|
|
1046
911
|
if (this.isEscCancelled(error)) {
|
|
1047
912
|
return;
|
|
1048
913
|
}
|
|
@@ -1051,32 +916,21 @@ class EnvSwitcher extends BaseCommand {
|
|
|
1051
916
|
|
|
1052
917
|
switch (answer.action) {
|
|
1053
918
|
case 'back':
|
|
1054
|
-
// 移除 ESC 键监听
|
|
1055
|
-
this.removeESCListener(escListener);
|
|
1056
919
|
return await this.showManageMenu();
|
|
1057
920
|
case 'edit':
|
|
1058
|
-
// 移除 ESC 键监听
|
|
1059
|
-
this.removeESCListener(escListener);
|
|
1060
921
|
return await this.editProvider(providerName);
|
|
1061
922
|
case 'remove':
|
|
1062
|
-
// 移除 ESC 键监听
|
|
1063
|
-
this.removeESCListener(escListener);
|
|
1064
923
|
return await this.removeProvider(providerName);
|
|
1065
924
|
case 'launch':
|
|
1066
|
-
// 移除 ESC 键监听
|
|
1067
|
-
this.removeESCListener(escListener);
|
|
1068
925
|
return await this.showLaunchArgsSelection(providerName);
|
|
1069
926
|
}
|
|
1070
927
|
|
|
1071
928
|
} catch (error) {
|
|
1072
|
-
// 移除 ESC 键监听
|
|
1073
|
-
this.removeESCListener(escListener);
|
|
1074
929
|
await this.handleError(error, '显示供应商详情');
|
|
1075
930
|
}
|
|
1076
931
|
}
|
|
1077
932
|
|
|
1078
933
|
async editProvider(providerName) {
|
|
1079
|
-
let escListener;
|
|
1080
934
|
try {
|
|
1081
935
|
await this.configManager.load();
|
|
1082
936
|
let provider = this.configManager.getProvider(providerName);
|
|
@@ -1087,21 +941,17 @@ class EnvSwitcher extends BaseCommand {
|
|
|
1087
941
|
return await this.showManageMenu();
|
|
1088
942
|
}
|
|
1089
943
|
|
|
1090
|
-
// 设置 ESC 键监听
|
|
1091
|
-
escListener = this.createESCListener(() => {
|
|
1092
|
-
Logger.info('取消编辑供应商');
|
|
1093
|
-
this.showManageMenu();
|
|
1094
|
-
}, '取消编辑');
|
|
1095
|
-
|
|
1096
944
|
// 根据 IDE 类型构建不同的问卷
|
|
1097
945
|
const isCodex = provider.ideName === 'codex';
|
|
1098
946
|
const questions = ProviderEditQuestionsHelper.buildQuestions(provider, validator);
|
|
1099
947
|
|
|
1100
948
|
let answers;
|
|
1101
949
|
try {
|
|
1102
|
-
answers = await this.
|
|
950
|
+
answers = await this.promptWithESC(questions, '取消编辑', () => {
|
|
951
|
+
Logger.info('取消编辑供应商');
|
|
952
|
+
this.showManageMenu();
|
|
953
|
+
});
|
|
1103
954
|
} catch (error) {
|
|
1104
|
-
this.removeESCListener(escListener);
|
|
1105
955
|
if (this.isEscCancelled(error)) {
|
|
1106
956
|
return;
|
|
1107
957
|
}
|
|
@@ -1164,20 +1014,15 @@ class EnvSwitcher extends BaseCommand {
|
|
|
1164
1014
|
await this.configManager.save();
|
|
1165
1015
|
Logger.success(`供应商 '${newName}' 已更新`);
|
|
1166
1016
|
|
|
1167
|
-
// 移除 ESC 键监听
|
|
1168
|
-
this.removeESCListener(escListener);
|
|
1169
1017
|
return await this.showManageMenu();
|
|
1170
1018
|
|
|
1171
1019
|
} catch (error) {
|
|
1172
|
-
// 移除 ESC 键监听
|
|
1173
|
-
this.removeESCListener(escListener);
|
|
1174
1020
|
Logger.error(`编辑供应商失败: ${error.message}`);
|
|
1175
1021
|
throw error;
|
|
1176
1022
|
}
|
|
1177
1023
|
}
|
|
1178
1024
|
|
|
1179
1025
|
async removeProvider(providerName) {
|
|
1180
|
-
let escListener;
|
|
1181
1026
|
try {
|
|
1182
1027
|
await this.configManager.load();
|
|
1183
1028
|
const provider = this.configManager.getProvider(providerName);
|
|
@@ -1188,24 +1033,20 @@ class EnvSwitcher extends BaseCommand {
|
|
|
1188
1033
|
return await this.showManageMenu();
|
|
1189
1034
|
}
|
|
1190
1035
|
|
|
1191
|
-
// 设置 ESC 键监听
|
|
1192
|
-
escListener = this.createESCListener(() => {
|
|
1193
|
-
Logger.info('取消删除供应商');
|
|
1194
|
-
this.showManageMenu();
|
|
1195
|
-
}, '取消删除');
|
|
1196
|
-
|
|
1197
1036
|
let confirm;
|
|
1198
1037
|
try {
|
|
1199
|
-
confirm = await this.
|
|
1038
|
+
confirm = await this.promptWithESC([
|
|
1200
1039
|
{
|
|
1201
1040
|
type: 'confirm',
|
|
1202
1041
|
name: 'confirmed',
|
|
1203
1042
|
message: `确定要删除供应商 '${providerName}' 吗?`,
|
|
1204
1043
|
default: false
|
|
1205
1044
|
}
|
|
1206
|
-
])
|
|
1045
|
+
], '取消删除', () => {
|
|
1046
|
+
Logger.info('取消删除供应商');
|
|
1047
|
+
this.showManageMenu();
|
|
1048
|
+
});
|
|
1207
1049
|
} catch (error) {
|
|
1208
|
-
this.removeESCListener(escListener);
|
|
1209
1050
|
if (this.isEscCancelled(error)) {
|
|
1210
1051
|
return;
|
|
1211
1052
|
}
|
|
@@ -1219,13 +1060,9 @@ class EnvSwitcher extends BaseCommand {
|
|
|
1219
1060
|
Logger.info('删除操作已取消');
|
|
1220
1061
|
}
|
|
1221
1062
|
|
|
1222
|
-
// 移除 ESC 键监听
|
|
1223
|
-
this.removeESCListener(escListener);
|
|
1224
1063
|
return await this.showManageMenu();
|
|
1225
1064
|
|
|
1226
1065
|
} catch (error) {
|
|
1227
|
-
// 移除 ESC 键监听
|
|
1228
|
-
this.removeESCListener(escListener);
|
|
1229
1066
|
Logger.error(`删除供应商失败: ${error.message}`);
|
|
1230
1067
|
throw error;
|
|
1231
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)
|