@mcpilotx/intentorch 0.5.0
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/LICENSE +201 -0
- package/README.md +545 -0
- package/dist/ai/ai.d.ts +205 -0
- package/dist/ai/ai.js +1200 -0
- package/dist/ai/cloud-intent-engine.d.ts +270 -0
- package/dist/ai/cloud-intent-engine.js +956 -0
- package/dist/ai/command.d.ts +59 -0
- package/dist/ai/command.js +285 -0
- package/dist/ai/config.d.ts +66 -0
- package/dist/ai/config.js +211 -0
- package/dist/ai/enhanced-intent.d.ts +17 -0
- package/dist/ai/enhanced-intent.js +32 -0
- package/dist/ai/index.d.ts +29 -0
- package/dist/ai/index.js +44 -0
- package/dist/ai/intent.d.ts +16 -0
- package/dist/ai/intent.js +30 -0
- package/dist/core/ai-config.d.ts +25 -0
- package/dist/core/ai-config.js +326 -0
- package/dist/core/config-manager.d.ts +36 -0
- package/dist/core/config-manager.js +400 -0
- package/dist/core/config-validator.d.ts +9 -0
- package/dist/core/config-validator.js +184 -0
- package/dist/core/constants.d.ts +34 -0
- package/dist/core/constants.js +37 -0
- package/dist/core/error-ai.d.ts +23 -0
- package/dist/core/error-ai.js +217 -0
- package/dist/core/error-handler.d.ts +197 -0
- package/dist/core/error-handler.js +467 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/index.js +17 -0
- package/dist/core/logger.d.ts +27 -0
- package/dist/core/logger.js +108 -0
- package/dist/core/performance-monitor.d.ts +74 -0
- package/dist/core/performance-monitor.js +260 -0
- package/dist/core/providers.d.ts +36 -0
- package/dist/core/providers.js +304 -0
- package/dist/core/retry-manager.d.ts +41 -0
- package/dist/core/retry-manager.js +204 -0
- package/dist/core/types.d.ts +155 -0
- package/dist/core/types.js +2 -0
- package/dist/daemon/index.d.ts +10 -0
- package/dist/daemon/index.js +15 -0
- package/dist/daemon/intent-engine.d.ts +22 -0
- package/dist/daemon/intent-engine.js +50 -0
- package/dist/daemon/orchestrator.d.ts +24 -0
- package/dist/daemon/orchestrator.js +100 -0
- package/dist/daemon/pm.d.ts +33 -0
- package/dist/daemon/pm.js +127 -0
- package/dist/daemon/process.d.ts +11 -0
- package/dist/daemon/process.js +49 -0
- package/dist/daemon/server.d.ts +17 -0
- package/dist/daemon/server.js +435 -0
- package/dist/daemon/service.d.ts +36 -0
- package/dist/daemon/service.js +278 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +36 -0
- package/dist/mcp/client.d.ts +51 -0
- package/dist/mcp/client.js +276 -0
- package/dist/mcp/index.d.ts +162 -0
- package/dist/mcp/index.js +199 -0
- package/dist/mcp/tool-registry.d.ts +71 -0
- package/dist/mcp/tool-registry.js +308 -0
- package/dist/mcp/transport.d.ts +83 -0
- package/dist/mcp/transport.js +515 -0
- package/dist/mcp/types.d.ts +136 -0
- package/dist/mcp/types.js +31 -0
- package/dist/runtime/adapter-advanced.d.ts +184 -0
- package/dist/runtime/adapter-advanced.js +160 -0
- package/dist/runtime/adapter.d.ts +9 -0
- package/dist/runtime/adapter.js +2 -0
- package/dist/runtime/detector-advanced.d.ts +59 -0
- package/dist/runtime/detector-advanced.js +487 -0
- package/dist/runtime/detector.d.ts +5 -0
- package/dist/runtime/detector.js +56 -0
- package/dist/runtime/docker-adapter.d.ts +18 -0
- package/dist/runtime/docker-adapter.js +170 -0
- package/dist/runtime/docker.d.ts +17 -0
- package/dist/runtime/docker.js +71 -0
- package/dist/runtime/executable-analyzer.d.ts +56 -0
- package/dist/runtime/executable-analyzer.js +391 -0
- package/dist/runtime/go-adapter.d.ts +19 -0
- package/dist/runtime/go-adapter.js +190 -0
- package/dist/runtime/index.d.ts +9 -0
- package/dist/runtime/index.js +10 -0
- package/dist/runtime/node-adapter.d.ts +10 -0
- package/dist/runtime/node-adapter.js +23 -0
- package/dist/runtime/node.d.ts +20 -0
- package/dist/runtime/node.js +86 -0
- package/dist/runtime/python-adapter.d.ts +11 -0
- package/dist/runtime/python-adapter.js +102 -0
- package/dist/runtime/python.d.ts +17 -0
- package/dist/runtime/python.js +72 -0
- package/dist/runtime/rust-adapter.d.ts +21 -0
- package/dist/runtime/rust-adapter.js +267 -0
- package/dist/sdk.d.ts +500 -0
- package/dist/sdk.js +904 -0
- package/docs/README.ZH_CN.md +545 -0
- package/docs/api.md +888 -0
- package/docs/architecture.md +731 -0
- package/docs/development.md +744 -0
- package/package.json +112 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { PROVIDER_DB, getProviderDisplayName } from './providers.js';
|
|
3
|
+
export class AIErrorHandler {
|
|
4
|
+
static handleError(error) {
|
|
5
|
+
console.log(chalk.red(`❌ ${error.message}`));
|
|
6
|
+
// Provide different repair suggestions based on error type
|
|
7
|
+
const suggestions = this.getSuggestions(error);
|
|
8
|
+
if (suggestions.length > 0) {
|
|
9
|
+
console.log(chalk.yellow('\n🔧 Repair suggestions:'));
|
|
10
|
+
suggestions.forEach((suggestion, index) => {
|
|
11
|
+
console.log(` ${index + 1}. ${suggestion}`);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
// Provide next steps
|
|
15
|
+
console.log(chalk.blue('\n📝 Next steps:'));
|
|
16
|
+
this.printNextSteps(error);
|
|
17
|
+
}
|
|
18
|
+
static getSuggestions(error) {
|
|
19
|
+
const suggestions = [];
|
|
20
|
+
switch (error.type) {
|
|
21
|
+
case 'config':
|
|
22
|
+
suggestions.push('Check configuration file format is correct');
|
|
23
|
+
suggestions.push('Ensure all required fields are filled');
|
|
24
|
+
if (error.provider) {
|
|
25
|
+
const providerInfo = PROVIDER_DB[error.provider];
|
|
26
|
+
if (providerInfo?.configHint) {
|
|
27
|
+
suggestions.push(providerInfo.configHint);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
break;
|
|
31
|
+
case 'connection':
|
|
32
|
+
suggestions.push('Check network connection is normal');
|
|
33
|
+
suggestions.push('Confirm API endpoint is accessible');
|
|
34
|
+
if (error.provider === 'ollama') {
|
|
35
|
+
suggestions.push('Ensure Ollama service is running: ollama serve');
|
|
36
|
+
suggestions.push('Check Ollama host address: http://localhost:11434');
|
|
37
|
+
}
|
|
38
|
+
break;
|
|
39
|
+
case 'authentication':
|
|
40
|
+
suggestions.push('Check API key is correct');
|
|
41
|
+
suggestions.push('Confirm API key has sufficient permissions');
|
|
42
|
+
suggestions.push('Try generating a new API key');
|
|
43
|
+
if (error.provider) {
|
|
44
|
+
suggestions.push(`Visit ${this.getProviderWebsite(error.provider)} to manage API keys`);
|
|
45
|
+
}
|
|
46
|
+
break;
|
|
47
|
+
case 'validation':
|
|
48
|
+
suggestions.push('Check input parameters meet requirements');
|
|
49
|
+
suggestions.push('Confirm model name is correct');
|
|
50
|
+
suggestions.push('View provider documentation to understand parameter limits');
|
|
51
|
+
break;
|
|
52
|
+
case 'unknown':
|
|
53
|
+
suggestions.push('View detailed error logs: mcp logs');
|
|
54
|
+
suggestions.push('Try restarting MCPilot services');
|
|
55
|
+
suggestions.push('Check system resources are sufficient');
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
// Add general suggestions
|
|
59
|
+
if (error.provider) {
|
|
60
|
+
suggestions.push(`View ${getProviderDisplayName(error.provider)} configuration help: mcp ai help ${error.provider}`);
|
|
61
|
+
}
|
|
62
|
+
return suggestions;
|
|
63
|
+
}
|
|
64
|
+
static printNextSteps(error) {
|
|
65
|
+
console.log(` • Reconfigure: ${chalk.cyan('mcp ai use <provider>')}`);
|
|
66
|
+
if (error.provider) {
|
|
67
|
+
console.log(` • Test connection: ${chalk.cyan('mcp ai test')}`);
|
|
68
|
+
console.log(` • View configuration: ${chalk.cyan('mcp ai config')}`);
|
|
69
|
+
}
|
|
70
|
+
console.log(` • View help: ${chalk.cyan('mcp ai --help')}`);
|
|
71
|
+
if (error.type === 'config' || error.type === 'validation') {
|
|
72
|
+
console.log(` • View providers: ${chalk.cyan('mcp ai providers')}`);
|
|
73
|
+
}
|
|
74
|
+
if (error.details) {
|
|
75
|
+
console.log(chalk.gray(`\n💡 Detailed error information: ${JSON.stringify(error.details, null, 2)}`));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
static getProviderWebsite(provider) {
|
|
79
|
+
const websites = {
|
|
80
|
+
openai: 'https://platform.openai.com/api-keys',
|
|
81
|
+
anthropic: 'https://console.anthropic.com/keys',
|
|
82
|
+
google: 'https://makersuite.google.com/app/apikey',
|
|
83
|
+
azure: 'https://portal.azure.com/#create/Microsoft.CognitiveServicesOpenAI',
|
|
84
|
+
deepseek: 'https://platform.deepseek.com/api-keys',
|
|
85
|
+
cohere: 'https://dashboard.cohere.com/api-keys',
|
|
86
|
+
ollama: 'https://ollama.com',
|
|
87
|
+
local: '',
|
|
88
|
+
custom: '',
|
|
89
|
+
none: '',
|
|
90
|
+
};
|
|
91
|
+
return websites[provider] || '';
|
|
92
|
+
}
|
|
93
|
+
// Handle provider name errors
|
|
94
|
+
static handleProviderError(input, similarProviders) {
|
|
95
|
+
console.log(chalk.red(`❌ Unknown AI provider: '${input}'`));
|
|
96
|
+
if (similarProviders && similarProviders.length > 0) {
|
|
97
|
+
console.log(chalk.yellow('\n🔍 Similar providers:'));
|
|
98
|
+
similarProviders.forEach((similar, index) => {
|
|
99
|
+
const providerInfo = PROVIDER_DB[similar.provider];
|
|
100
|
+
const displayName = providerInfo?.name || similar.provider;
|
|
101
|
+
console.log(` • ${chalk.cyan(displayName)} (similarity ${similar.similarity}%)`);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
console.log(chalk.blue('\n📋 Supported providers:'));
|
|
105
|
+
const providerList = Object.entries(PROVIDER_DB)
|
|
106
|
+
.map(([id, info]) => `${chalk.cyan(id)} - ${info.description}`)
|
|
107
|
+
.join('\n ');
|
|
108
|
+
console.log(` ${providerList}`);
|
|
109
|
+
console.log(chalk.green('\n💡 Use the following commands:'));
|
|
110
|
+
console.log(` • View all providers: ${chalk.cyan('mcp ai providers')}`);
|
|
111
|
+
console.log(` • Configure provider: ${chalk.cyan('mcp ai use <provider>')}`);
|
|
112
|
+
}
|
|
113
|
+
// Handle model name errors
|
|
114
|
+
static handleModelError(provider, model, availableModels) {
|
|
115
|
+
const providerInfo = PROVIDER_DB[provider];
|
|
116
|
+
const displayName = providerInfo?.name || provider;
|
|
117
|
+
console.log(chalk.red(`❌ ${displayName} does not support model: '${model}'`));
|
|
118
|
+
if (availableModels && availableModels.length > 0) {
|
|
119
|
+
console.log(chalk.yellow('\n📋 Available models:'));
|
|
120
|
+
availableModels.forEach(availableModel => {
|
|
121
|
+
const description = providerInfo?.modelDescriptions?.[availableModel] || '';
|
|
122
|
+
console.log(` • ${chalk.cyan(availableModel)} ${description ? `- ${description}` : ''}`);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
else if (providerInfo?.modelDescriptions) {
|
|
126
|
+
console.log(chalk.yellow('\n📋 Common models:'));
|
|
127
|
+
Object.entries(providerInfo.modelDescriptions).forEach(([modelName, description]) => {
|
|
128
|
+
console.log(` • ${chalk.cyan(modelName)} - ${description}`);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
console.log(chalk.green('\n💡 Use the following commands:'));
|
|
132
|
+
console.log(` • View all models: ${chalk.cyan(`mcp ai models ${provider}`)}`);
|
|
133
|
+
console.log(` • Use default model: ${chalk.cyan(`mcp ai use ${provider}`)}`);
|
|
134
|
+
}
|
|
135
|
+
// Handle API key errors
|
|
136
|
+
static handleApiKeyError(provider) {
|
|
137
|
+
const providerInfo = PROVIDER_DB[provider];
|
|
138
|
+
const displayName = providerInfo?.name || provider;
|
|
139
|
+
console.log(chalk.red(`❌ ${displayName} requires API key`));
|
|
140
|
+
console.log(chalk.yellow('\n🔑 How to get API key:'));
|
|
141
|
+
switch (provider) {
|
|
142
|
+
case 'openai':
|
|
143
|
+
console.log(' 1. Visit https://platform.openai.com/api-keys');
|
|
144
|
+
console.log(' 2. Login or register OpenAI account');
|
|
145
|
+
console.log(' 3. Create new API key');
|
|
146
|
+
console.log(' 4. Key format: sk-xxx...');
|
|
147
|
+
break;
|
|
148
|
+
case 'deepseek':
|
|
149
|
+
console.log(' 1. Visit https://platform.deepseek.com/api-keys');
|
|
150
|
+
console.log(' 2. Login or register DeepSeek account');
|
|
151
|
+
console.log(' 3. Create new API key');
|
|
152
|
+
console.log(' 4. Key format: sk-xxx or obtain from platform');
|
|
153
|
+
break;
|
|
154
|
+
case 'anthropic':
|
|
155
|
+
console.log(' 1. Visit https://console.anthropic.com/keys');
|
|
156
|
+
console.log(' 2. Login or register Anthropic account');
|
|
157
|
+
console.log(' 3. Create new API key');
|
|
158
|
+
console.log(' 4. Key format: sk-ant-xxx...');
|
|
159
|
+
break;
|
|
160
|
+
case 'cohere':
|
|
161
|
+
console.log(' 1. Visit https://dashboard.cohere.com/api-keys');
|
|
162
|
+
console.log(' 2. Login or register Cohere account');
|
|
163
|
+
console.log(' 3. Create new API key');
|
|
164
|
+
break;
|
|
165
|
+
default:
|
|
166
|
+
console.log(` Please visit ${displayName} official website to get API key`);
|
|
167
|
+
}
|
|
168
|
+
console.log(chalk.green('\n💡 Configuration method:'));
|
|
169
|
+
console.log(` • Direct configuration: ${chalk.cyan(`mcp ai use ${provider} <your-api-key>`)}`);
|
|
170
|
+
console.log(` • Environment variable: ${chalk.cyan(`export ${this.getEnvVarName(provider)}=<your-api-key>`)}`);
|
|
171
|
+
}
|
|
172
|
+
static getEnvVarName(provider) {
|
|
173
|
+
const envVars = {
|
|
174
|
+
openai: 'OPENAI_API_KEY',
|
|
175
|
+
anthropic: 'ANTHROPIC_API_KEY',
|
|
176
|
+
google: 'GOOGLE_API_KEY',
|
|
177
|
+
azure: 'AZURE_OPENAI_API_KEY',
|
|
178
|
+
deepseek: 'DEEPSEEK_API_KEY',
|
|
179
|
+
cohere: 'COHERE_API_KEY',
|
|
180
|
+
ollama: '',
|
|
181
|
+
local: '',
|
|
182
|
+
custom: '',
|
|
183
|
+
none: '',
|
|
184
|
+
};
|
|
185
|
+
return envVars[provider] || `${provider.toUpperCase()}_API_KEY`;
|
|
186
|
+
}
|
|
187
|
+
// Handle connection test results
|
|
188
|
+
static handleTestResult(success, provider, details) {
|
|
189
|
+
if (success) {
|
|
190
|
+
if (provider) {
|
|
191
|
+
const providerInfo = PROVIDER_DB[provider];
|
|
192
|
+
const displayName = providerInfo?.name || provider;
|
|
193
|
+
console.log(chalk.green(`✅ ${displayName} connection test successful!`));
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
console.log(chalk.green('✅ AI connection test successful!'));
|
|
197
|
+
}
|
|
198
|
+
if (details) {
|
|
199
|
+
console.log(chalk.gray('\n📊 Test details:'));
|
|
200
|
+
console.log(JSON.stringify(details, null, 2));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
console.log(chalk.red('❌ AI connection test failed'));
|
|
205
|
+
if (details?.error) {
|
|
206
|
+
const error = {
|
|
207
|
+
type: 'connection',
|
|
208
|
+
message: details.error.message || 'Connection failed',
|
|
209
|
+
provider,
|
|
210
|
+
details: details.error,
|
|
211
|
+
};
|
|
212
|
+
this.handleError(error);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=error-ai.js.map
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IntentOrch SDK Unified Error Handling System
|
|
3
|
+
* Balances minimalist style with functional robustness
|
|
4
|
+
* Formerly known as MCPilot SDK
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Error Code Enumeration
|
|
8
|
+
* Clear categorization for easy identification and handling
|
|
9
|
+
*/
|
|
10
|
+
export declare enum ErrorCode {
|
|
11
|
+
CONFIG_INVALID = "CONFIG_001",
|
|
12
|
+
CONFIG_MISSING = "CONFIG_002",
|
|
13
|
+
CONFIG_VALIDATION_FAILED = "CONFIG_003",
|
|
14
|
+
CONFIG_MIGRATION_FAILED = "CONFIG_004",
|
|
15
|
+
SERVICE_NOT_FOUND = "SERVICE_001",
|
|
16
|
+
SERVICE_ALREADY_EXISTS = "SERVICE_002",
|
|
17
|
+
SERVICE_START_FAILED = "SERVICE_003",
|
|
18
|
+
SERVICE_STOP_FAILED = "SERVICE_004",
|
|
19
|
+
SERVICE_HEALTH_CHECK_FAILED = "SERVICE_005",
|
|
20
|
+
RUNTIME_DETECTION_FAILED = "RUNTIME_001",
|
|
21
|
+
RUNTIME_NOT_SUPPORTED = "RUNTIME_002",
|
|
22
|
+
RUNTIME_NOT_INSTALLED = "RUNTIME_003",
|
|
23
|
+
RUNTIME_ADAPTER_ERROR = "RUNTIME_004",
|
|
24
|
+
PROCESS_NOT_FOUND = "PROCESS_001",
|
|
25
|
+
PROCESS_START_FAILED = "PROCESS_002",
|
|
26
|
+
PROCESS_STOP_FAILED = "PROCESS_003",
|
|
27
|
+
PROCESS_TIMEOUT = "PROCESS_004",
|
|
28
|
+
RESOURCE_LIMIT_EXCEEDED = "RESOURCE_001",
|
|
29
|
+
MEMORY_LIMIT_EXCEEDED = "RESOURCE_002",
|
|
30
|
+
CPU_LIMIT_EXCEEDED = "RESOURCE_003",
|
|
31
|
+
DISK_SPACE_INSUFFICIENT = "RESOURCE_004",
|
|
32
|
+
PERMISSION_DENIED = "PERMISSION_001",
|
|
33
|
+
FILE_PERMISSION_ERROR = "PERMISSION_002",
|
|
34
|
+
NETWORK_PERMISSION_ERROR = "PERMISSION_003",
|
|
35
|
+
NETWORK_ERROR = "NETWORK_001",
|
|
36
|
+
CONNECTION_REFUSED = "NETWORK_002",
|
|
37
|
+
CONNECTION_TIMEOUT = "NETWORK_003",
|
|
38
|
+
DNS_RESOLUTION_FAILED = "NETWORK_004",
|
|
39
|
+
AI_CONFIG_INVALID = "AI_001",
|
|
40
|
+
AI_PROVIDER_NOT_AVAILABLE = "AI_002",
|
|
41
|
+
AI_QUERY_FAILED = "AI_003",
|
|
42
|
+
AI_MODEL_NOT_FOUND = "AI_004",
|
|
43
|
+
SYSTEM_ERROR = "SYSTEM_001",
|
|
44
|
+
UNEXPECTED_ERROR = "SYSTEM_002",
|
|
45
|
+
NOT_IMPLEMENTED = "SYSTEM_003",
|
|
46
|
+
VALIDATION_FAILED = "VALIDATION_001",
|
|
47
|
+
REQUIRED_FIELD_MISSING = "VALIDATION_002",
|
|
48
|
+
INVALID_FORMAT = "VALIDATION_003",
|
|
49
|
+
OUT_OF_RANGE = "VALIDATION_004"
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Error Severity Levels
|
|
53
|
+
*/
|
|
54
|
+
export declare enum ErrorSeverity {
|
|
55
|
+
LOW = "low",// Ignorable errors, don't affect core functionality
|
|
56
|
+
MEDIUM = "medium",// Errors that need attention, may affect some functionality
|
|
57
|
+
HIGH = "high",// Serious errors, affect core functionality
|
|
58
|
+
CRITICAL = "critical"
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Error Context Information
|
|
62
|
+
*/
|
|
63
|
+
export interface ErrorContext {
|
|
64
|
+
[key: string]: any;
|
|
65
|
+
timestamp?: Date;
|
|
66
|
+
userId?: string;
|
|
67
|
+
requestId?: string;
|
|
68
|
+
serviceName?: string;
|
|
69
|
+
runtimeType?: string;
|
|
70
|
+
configPath?: string;
|
|
71
|
+
environment?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Error Fix Suggestions
|
|
75
|
+
*/
|
|
76
|
+
export interface ErrorSuggestion {
|
|
77
|
+
title: string;
|
|
78
|
+
description: string;
|
|
79
|
+
steps: string[];
|
|
80
|
+
codeExample?: string;
|
|
81
|
+
documentationUrl?: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* IntentOrch Unified Error Class
|
|
85
|
+
*/
|
|
86
|
+
export declare class IntentOrchError extends Error {
|
|
87
|
+
code: ErrorCode;
|
|
88
|
+
message: string;
|
|
89
|
+
severity: ErrorSeverity;
|
|
90
|
+
context: ErrorContext;
|
|
91
|
+
suggestions: ErrorSuggestion[];
|
|
92
|
+
cause?: Error;
|
|
93
|
+
constructor(code: ErrorCode, message: string, severity?: ErrorSeverity, context?: ErrorContext, suggestions?: ErrorSuggestion[], cause?: Error);
|
|
94
|
+
/**
|
|
95
|
+
* Convert to JSON format for easy logging and transmission
|
|
96
|
+
*/
|
|
97
|
+
toJSON(): object;
|
|
98
|
+
/**
|
|
99
|
+
* Get error summary for display
|
|
100
|
+
*/
|
|
101
|
+
getSummary(): string;
|
|
102
|
+
/**
|
|
103
|
+
* Get detailed error information
|
|
104
|
+
*/
|
|
105
|
+
getDetails(): string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* MCPilot Unified Error Class (for backward compatibility)
|
|
109
|
+
* @deprecated Use IntentOrchError instead
|
|
110
|
+
*/
|
|
111
|
+
export declare class MCPilotError extends IntentOrchError {
|
|
112
|
+
constructor(code: ErrorCode, message: string, severity?: ErrorSeverity, context?: ErrorContext, suggestions?: ErrorSuggestion[], cause?: Error);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Error Factory - Create standardized error instances
|
|
116
|
+
*/
|
|
117
|
+
export declare class ErrorFactory {
|
|
118
|
+
/**
|
|
119
|
+
* Configuration error
|
|
120
|
+
*/
|
|
121
|
+
static configInvalid(message: string, context?: ErrorContext, cause?: Error): MCPilotError;
|
|
122
|
+
/**
|
|
123
|
+
* Service not found error
|
|
124
|
+
*/
|
|
125
|
+
static serviceNotFound(serviceName: string, context?: ErrorContext): MCPilotError;
|
|
126
|
+
/**
|
|
127
|
+
* Runtime detection failed error
|
|
128
|
+
*/
|
|
129
|
+
static runtimeDetectionFailed(path: string, context?: ErrorContext, cause?: Error): MCPilotError;
|
|
130
|
+
/**
|
|
131
|
+
* Process start failed error
|
|
132
|
+
*/
|
|
133
|
+
static processStartFailed(serviceName: string, context?: ErrorContext, cause?: Error): MCPilotError;
|
|
134
|
+
/**
|
|
135
|
+
* Permission denied error
|
|
136
|
+
*/
|
|
137
|
+
static permissionDenied(operation: string, resource: string, context?: ErrorContext): MCPilotError;
|
|
138
|
+
/**
|
|
139
|
+
* Network error
|
|
140
|
+
*/
|
|
141
|
+
static networkError(operation: string, url: string, context?: ErrorContext, cause?: Error): MCPilotError;
|
|
142
|
+
/**
|
|
143
|
+
* Not implemented error
|
|
144
|
+
*/
|
|
145
|
+
static notImplemented(feature: string, context?: ErrorContext): MCPilotError;
|
|
146
|
+
/**
|
|
147
|
+
* Validation error
|
|
148
|
+
*/
|
|
149
|
+
static validationFailed(field: string, reason: string, context?: ErrorContext): MCPilotError;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Error Handler - Handle, log and recover from errors
|
|
153
|
+
*/
|
|
154
|
+
export declare class ErrorHandler {
|
|
155
|
+
private static instance;
|
|
156
|
+
private handlers;
|
|
157
|
+
private constructor();
|
|
158
|
+
static getInstance(): ErrorHandler;
|
|
159
|
+
/**
|
|
160
|
+
* Register error handler
|
|
161
|
+
*/
|
|
162
|
+
registerHandler(handler: (error: MCPilotError) => Promise<void>): void;
|
|
163
|
+
/**
|
|
164
|
+
* Handle error
|
|
165
|
+
*/
|
|
166
|
+
handle(error: Error | MCPilotError): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* Safely execute function, automatically handle errors
|
|
169
|
+
*/
|
|
170
|
+
execute<T>(operation: string, fn: () => Promise<T>, context?: ErrorContext): Promise<T>;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Default Error Handler - Console Output
|
|
174
|
+
*/
|
|
175
|
+
export declare class ConsoleErrorHandler {
|
|
176
|
+
static handle(error: MCPilotError): Promise<void>;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Error Recovery Strategy
|
|
180
|
+
*/
|
|
181
|
+
export interface RetryStrategy {
|
|
182
|
+
maxAttempts: number;
|
|
183
|
+
backoff: 'linear' | 'exponential' | 'fixed';
|
|
184
|
+
baseDelay: number;
|
|
185
|
+
maxDelay?: number;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Error Handler with Retry
|
|
189
|
+
*/
|
|
190
|
+
export declare class RetryErrorHandler {
|
|
191
|
+
static withRetry<T>(operation: string, fn: () => Promise<T>, strategy?: RetryStrategy, context?: ErrorContext): Promise<T>;
|
|
192
|
+
}
|
|
193
|
+
export declare function createError(code: ErrorCode, message: string, severity?: ErrorSeverity, context?: ErrorContext): MCPilotError;
|
|
194
|
+
export declare function wrapError(error: Error, code?: ErrorCode, context?: ErrorContext): MCPilotError;
|
|
195
|
+
export declare function isMCPilotError(error: any): error is MCPilotError;
|
|
196
|
+
export declare function shouldRetry(error: Error): boolean;
|
|
197
|
+
//# sourceMappingURL=error-handler.d.ts.map
|