fix(config): 优雅处理 Provider 未配置错误
- 添加 ConfigurationError 类替代 process.exit(1) - Server 端捕获配置错误并返回友好消息 - UI 端支持 config_error 类型的 WebSocket 消息 - 服务器不再因配置缺失而崩溃
This commit is contained in:
@@ -122,6 +122,8 @@ export type {
|
||||
CompressionStatus,
|
||||
CompressionType,
|
||||
CompressionResult,
|
||||
// WebSocket error types
|
||||
ConfigErrorPayload,
|
||||
} from './types.js';
|
||||
|
||||
// API Configuration
|
||||
|
||||
@@ -756,3 +756,21 @@ export interface CompressionResult {
|
||||
summaryTokens?: number;
|
||||
}
|
||||
|
||||
// ============ WebSocket 错误相关 ============
|
||||
|
||||
/**
|
||||
* 配置错误 Payload
|
||||
*
|
||||
* 当 Provider 未配置 API Key 时,通过 WebSocket 返回此错误
|
||||
*/
|
||||
export interface ConfigErrorPayload {
|
||||
/** 错误类型标识 */
|
||||
type: 'config_error';
|
||||
/** 错误消息 */
|
||||
message: string;
|
||||
/** 缺失配置的 Provider */
|
||||
provider?: string;
|
||||
/** 建议的操作 */
|
||||
action: 'open_providers_panel' | 'open_settings';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user