@pikecode/api-key-manager 2.1.1 → 2.1.3
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 +2 -1
- package/src/utils/env-launcher.js +19 -5
package/package.json
CHANGED
package/src/commands/switch.js
CHANGED
|
@@ -195,7 +195,7 @@ class EnvSwitcher extends BaseCommand {
|
|
|
195
195
|
|
|
196
196
|
// 如果是 Claude Code 的"没有可恢复的会话"错误,自动移除 --continue 参数并重试
|
|
197
197
|
if (!isCodex &&
|
|
198
|
-
error.
|
|
198
|
+
error.code === 'NO_CONVERSATION_FOUND' &&
|
|
199
199
|
selectedLaunchArgs.includes('--continue')) {
|
|
200
200
|
Logger.info('会话不可用,自动移除 --continue 参数重新启动...');
|
|
201
201
|
console.log();
|
|
@@ -210,6 +210,7 @@ class EnvSwitcher extends BaseCommand {
|
|
|
210
210
|
console.log(UIHelper.createCard('准备就绪', `环境配置完成,正在启动 🚀 ${ideDisplayName}(新会话)...`, UIHelper.icons.success));
|
|
211
211
|
console.log();
|
|
212
212
|
await launchProviderProcess(provider, retryArgs);
|
|
213
|
+
return;
|
|
213
214
|
} catch (retryError) {
|
|
214
215
|
UIHelper.clearLoadingAnimation(retryLoadingInterval);
|
|
215
216
|
throw retryError;
|
|
@@ -59,18 +59,24 @@ async function executeWithEnv(config, launchArgs = []) {
|
|
|
59
59
|
|
|
60
60
|
return new Promise((resolve, reject) => {
|
|
61
61
|
const child = spawn('claude', args, {
|
|
62
|
-
stdio: ['inherit', '
|
|
62
|
+
stdio: ['inherit', 'pipe', 'pipe'],
|
|
63
63
|
env,
|
|
64
64
|
shell: false
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
let stderrOutput = '';
|
|
68
|
+
let stdoutOutput = '';
|
|
69
|
+
|
|
70
|
+
// 捕获 stdout 和 stderr 用于检查错误信息
|
|
71
|
+
child.stdout.on('data', (data) => {
|
|
72
|
+
const output = data.toString();
|
|
73
|
+
stdoutOutput += output;
|
|
74
|
+
process.stdout.write(data);
|
|
75
|
+
});
|
|
68
76
|
|
|
69
|
-
// 捕获 stderr 用于检查错误信息
|
|
70
77
|
child.stderr.on('data', (data) => {
|
|
71
78
|
const output = data.toString();
|
|
72
79
|
stderrOutput += output;
|
|
73
|
-
// 同时输出 stderr 给用户
|
|
74
80
|
process.stderr.write(data);
|
|
75
81
|
});
|
|
76
82
|
|
|
@@ -79,8 +85,16 @@ async function executeWithEnv(config, launchArgs = []) {
|
|
|
79
85
|
resolve();
|
|
80
86
|
} else {
|
|
81
87
|
// 检查是否是"没有可恢复会话"的错误
|
|
82
|
-
|
|
83
|
-
|
|
88
|
+
// 检查 stdout 和 stderr 中是否包含错误消息
|
|
89
|
+
const combinedOutput = (stderrOutput + stdoutOutput).toLowerCase();
|
|
90
|
+
const isNoConversationError =
|
|
91
|
+
combinedOutput.includes('no conversation found') ||
|
|
92
|
+
combinedOutput.includes('no recoverable session');
|
|
93
|
+
|
|
94
|
+
if (isNoConversationError) {
|
|
95
|
+
const error = new Error('没有可恢复的会话\n提示: 请选择不带 --continue 参数重新开始');
|
|
96
|
+
error.code = 'NO_CONVERSATION_FOUND';
|
|
97
|
+
reject(error);
|
|
84
98
|
} else {
|
|
85
99
|
reject(new Error(`Claude Code 异常退出,退出代码: ${code}\n提示: 请检查 API 配置是否正确`));
|
|
86
100
|
}
|