@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,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simplified AI Command Handler
|
|
3
|
+
* Minimal command interface for AI features
|
|
4
|
+
*/
|
|
5
|
+
import { SimpleAI } from './ai';
|
|
6
|
+
import { SimpleAIConfigManager } from './config';
|
|
7
|
+
/**
|
|
8
|
+
* Simplified AI command handler
|
|
9
|
+
*/
|
|
10
|
+
export declare class SimpleAICommand {
|
|
11
|
+
private ai;
|
|
12
|
+
private configManager;
|
|
13
|
+
constructor();
|
|
14
|
+
/**
|
|
15
|
+
* Load configuration from manager
|
|
16
|
+
*/
|
|
17
|
+
private loadConfiguration;
|
|
18
|
+
/**
|
|
19
|
+
* Handle AI command
|
|
20
|
+
*/
|
|
21
|
+
handleCommand(action?: string, ...args: string[]): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Handle configure command
|
|
24
|
+
*/
|
|
25
|
+
private handleConfigure;
|
|
26
|
+
/**
|
|
27
|
+
* Handle test command
|
|
28
|
+
*/
|
|
29
|
+
private handleTest;
|
|
30
|
+
/**
|
|
31
|
+
* Handle ask command
|
|
32
|
+
*/
|
|
33
|
+
private handleAsk;
|
|
34
|
+
/**
|
|
35
|
+
* Handle ask result
|
|
36
|
+
*/
|
|
37
|
+
private handleAskResult;
|
|
38
|
+
/**
|
|
39
|
+
* Handle reset command
|
|
40
|
+
*/
|
|
41
|
+
private handleReset;
|
|
42
|
+
/**
|
|
43
|
+
* Show AI status
|
|
44
|
+
*/
|
|
45
|
+
private showStatus;
|
|
46
|
+
/**
|
|
47
|
+
* Show help
|
|
48
|
+
*/
|
|
49
|
+
private showHelp;
|
|
50
|
+
/**
|
|
51
|
+
* Get AI instance (for integration with other modules)
|
|
52
|
+
*/
|
|
53
|
+
getAIInstance(): SimpleAI;
|
|
54
|
+
/**
|
|
55
|
+
* Get config manager instance
|
|
56
|
+
*/
|
|
57
|
+
getConfigManager(): SimpleAIConfigManager;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simplified AI Command Handler
|
|
3
|
+
* Minimal command interface for AI features
|
|
4
|
+
*/
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { SimpleAI, AIError } from './ai.js';
|
|
7
|
+
import { SimpleAIConfigManager } from './config.js';
|
|
8
|
+
/**
|
|
9
|
+
* Simplified AI command handler
|
|
10
|
+
*/
|
|
11
|
+
export class SimpleAICommand {
|
|
12
|
+
ai;
|
|
13
|
+
configManager;
|
|
14
|
+
constructor() {
|
|
15
|
+
this.ai = new SimpleAI();
|
|
16
|
+
this.configManager = new SimpleAIConfigManager();
|
|
17
|
+
// Load configuration
|
|
18
|
+
this.loadConfiguration();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Load configuration from manager
|
|
22
|
+
*/
|
|
23
|
+
async loadConfiguration() {
|
|
24
|
+
try {
|
|
25
|
+
const config = this.configManager.getConfig();
|
|
26
|
+
if (config.provider !== 'none') {
|
|
27
|
+
await this.ai.configure(config);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
console.warn(`Failed to load AI configuration: ${error.message}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Handle AI command
|
|
36
|
+
*/
|
|
37
|
+
async handleCommand(action, ...args) {
|
|
38
|
+
if (!action) {
|
|
39
|
+
// Show status when no action provided
|
|
40
|
+
await this.showStatus();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
switch (action.toLowerCase()) {
|
|
44
|
+
case 'configure':
|
|
45
|
+
await this.handleConfigure(args);
|
|
46
|
+
break;
|
|
47
|
+
case 'test':
|
|
48
|
+
await this.handleTest();
|
|
49
|
+
break;
|
|
50
|
+
case 'ask':
|
|
51
|
+
await this.handleAsk(args.join(' '));
|
|
52
|
+
break;
|
|
53
|
+
case 'status':
|
|
54
|
+
await this.showStatus();
|
|
55
|
+
break;
|
|
56
|
+
case 'reset':
|
|
57
|
+
await this.handleReset();
|
|
58
|
+
break;
|
|
59
|
+
case 'help':
|
|
60
|
+
this.showHelp();
|
|
61
|
+
break;
|
|
62
|
+
default:
|
|
63
|
+
console.log(chalk.red(`Unknown action: ${action}`));
|
|
64
|
+
this.showHelp();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Handle configure command
|
|
69
|
+
*/
|
|
70
|
+
async handleConfigure(args) {
|
|
71
|
+
try {
|
|
72
|
+
// Parse configuration from arguments
|
|
73
|
+
const config = this.configManager.parseFromArgs(args);
|
|
74
|
+
// Update configuration
|
|
75
|
+
await this.configManager.updateConfig(config);
|
|
76
|
+
// Configure AI service
|
|
77
|
+
if (config.provider !== 'none') {
|
|
78
|
+
await this.ai.configure(config);
|
|
79
|
+
console.log(chalk.green(`✅ AI configured with provider: ${config.provider}`));
|
|
80
|
+
if (config.provider === 'ollama') {
|
|
81
|
+
console.log(chalk.blue('💡 Make sure Ollama service is running: ollama serve'));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
this.ai.reset();
|
|
86
|
+
console.log(chalk.yellow('⚠️ AI configuration reset'));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
console.log(chalk.red(`❌ Configuration failed: ${error.message}`));
|
|
91
|
+
if (error.message.includes('OpenAI requires API key')) {
|
|
92
|
+
console.log(chalk.yellow('\n🔧 How to get OpenAI API key:'));
|
|
93
|
+
console.log(' 1. Visit: https://platform.openai.com/api-keys');
|
|
94
|
+
console.log(' 2. Create new API key');
|
|
95
|
+
console.log(' 3. Run: mcp ai configure openai YOUR_API_KEY');
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Handle test command
|
|
101
|
+
*/
|
|
102
|
+
async handleTest() {
|
|
103
|
+
const status = this.ai.getStatus();
|
|
104
|
+
if (!status.configured) {
|
|
105
|
+
console.log(chalk.yellow('⚠️ AI not configured'));
|
|
106
|
+
console.log('Run: mcp ai configure openai YOUR_API_KEY');
|
|
107
|
+
console.log('Or: mcp ai configure ollama');
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
console.log(chalk.blue('🔌 Testing AI connection...'));
|
|
111
|
+
try {
|
|
112
|
+
const result = await this.ai.testConnection();
|
|
113
|
+
if (result.success) {
|
|
114
|
+
console.log(chalk.green(`✅ ${result.message}`));
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
console.log(chalk.red(`❌ ${result.message}`));
|
|
118
|
+
// Provide suggestions based on provider
|
|
119
|
+
const config = this.configManager.getConfig();
|
|
120
|
+
if (config.provider === 'openai') {
|
|
121
|
+
console.log(chalk.yellow('\n🔧 OpenAI troubleshooting:'));
|
|
122
|
+
console.log(' 1. Check internet connection');
|
|
123
|
+
console.log(' 2. Verify API key is valid');
|
|
124
|
+
console.log(' 3. Check OpenAI service status: https://status.openai.com');
|
|
125
|
+
}
|
|
126
|
+
else if (config.provider === 'ollama') {
|
|
127
|
+
console.log(chalk.yellow('\n🔧 Ollama troubleshooting:'));
|
|
128
|
+
console.log(' 1. Ensure Ollama is installed: https://ollama.com');
|
|
129
|
+
console.log(' 2. Start Ollama service: ollama serve');
|
|
130
|
+
console.log(' 3. Check if endpoint is correct: http://localhost:11434');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
console.log(chalk.red(`❌ Test failed: ${error.message}`));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Handle ask command
|
|
140
|
+
*/
|
|
141
|
+
async handleAsk(query) {
|
|
142
|
+
if (!query) {
|
|
143
|
+
console.log(chalk.yellow('⚠️ Please provide a query'));
|
|
144
|
+
console.log('Example: mcp ai ask "list files in current directory"');
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
console.log(chalk.blue(`🤖 Query: "${query}"`));
|
|
148
|
+
try {
|
|
149
|
+
const result = await this.ai.ask(query);
|
|
150
|
+
await this.handleAskResult(result);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
if (error instanceof AIError) {
|
|
154
|
+
console.log(SimpleAI.getFriendlyError(error));
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
console.log(chalk.red(`❌ Error: ${error.message}`));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Handle ask result
|
|
163
|
+
*/
|
|
164
|
+
async handleAskResult(result) {
|
|
165
|
+
switch (result.type) {
|
|
166
|
+
case 'tool_call':
|
|
167
|
+
console.log(chalk.green(`✅ Intent recognized (confidence: ${(result.confidence || 0) * 100}%)`));
|
|
168
|
+
console.log(chalk.blue(`🔧 Tool call: ${result.tool?.service}.${result.tool?.tool}`));
|
|
169
|
+
console.log(chalk.gray(` Parameters: ${JSON.stringify(result.tool?.params)}`));
|
|
170
|
+
// In actual implementation, this would execute the tool call
|
|
171
|
+
console.log(chalk.yellow('\n💡 Note: Tool execution would happen here'));
|
|
172
|
+
console.log(' In production, this would call the actual MCP service');
|
|
173
|
+
break;
|
|
174
|
+
case 'suggestions':
|
|
175
|
+
console.log(chalk.yellow(`⚠️ ${result.message}`));
|
|
176
|
+
if (result.help) {
|
|
177
|
+
console.log(chalk.blue(result.help));
|
|
178
|
+
}
|
|
179
|
+
if (result.suggestions && result.suggestions.length > 0) {
|
|
180
|
+
console.log(chalk.green('\n🔧 Suggested commands:'));
|
|
181
|
+
result.suggestions.forEach((suggestion, i) => {
|
|
182
|
+
console.log(` ${i + 1}. ${suggestion}`);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
break;
|
|
186
|
+
case 'error':
|
|
187
|
+
console.log(chalk.red(`❌ ${result.message}`));
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Handle reset command
|
|
193
|
+
*/
|
|
194
|
+
async handleReset() {
|
|
195
|
+
this.configManager.resetConfig();
|
|
196
|
+
this.ai.reset();
|
|
197
|
+
console.log(chalk.green('✅ AI configuration reset to defaults'));
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Show AI status
|
|
201
|
+
*/
|
|
202
|
+
async showStatus() {
|
|
203
|
+
const aiStatus = this.ai.getStatus();
|
|
204
|
+
const configStatus = this.configManager.getStatus();
|
|
205
|
+
console.log(chalk.blue('🤖 AI Status:'));
|
|
206
|
+
console.log(` Enabled: ${aiStatus.enabled ? chalk.green('Yes') : chalk.red('No')}`);
|
|
207
|
+
console.log(` Provider: ${chalk.cyan(aiStatus.provider)}`);
|
|
208
|
+
console.log(` Configured: ${configStatus.configured ? chalk.green('Yes') : chalk.yellow('No')}`);
|
|
209
|
+
if (configStatus.configured) {
|
|
210
|
+
const config = this.configManager.getConfig();
|
|
211
|
+
console.log(` Config file: ${chalk.gray(configStatus.configFile)}`);
|
|
212
|
+
if (config.provider !== 'none') {
|
|
213
|
+
console.log(chalk.blue('\n🔧 Current configuration:'));
|
|
214
|
+
console.log(this.configManager.formatConfig());
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
console.log(chalk.yellow('\n💡 AI is not configured'));
|
|
219
|
+
console.log(' To configure: mcp ai configure openai YOUR_API_KEY');
|
|
220
|
+
console.log(' Or use Ollama: mcp ai configure ollama');
|
|
221
|
+
}
|
|
222
|
+
// Show test result if configured
|
|
223
|
+
if (aiStatus.configured) {
|
|
224
|
+
console.log(chalk.blue('\n🔌 Connection test:'));
|
|
225
|
+
try {
|
|
226
|
+
const testResult = await this.ai.testConnection();
|
|
227
|
+
console.log(` Status: ${testResult.success ? chalk.green('OK') : chalk.red('Failed')}`);
|
|
228
|
+
console.log(` Message: ${testResult.message}`);
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
console.log(` Status: ${chalk.red('Error')}`);
|
|
232
|
+
console.log(` Message: ${error.message}`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Show help
|
|
238
|
+
*/
|
|
239
|
+
showHelp() {
|
|
240
|
+
console.log(chalk.blue('🤖 AI Commands:'));
|
|
241
|
+
console.log('');
|
|
242
|
+
console.log(chalk.green(' mcp ai'));
|
|
243
|
+
console.log(' Show AI status');
|
|
244
|
+
console.log('');
|
|
245
|
+
console.log(chalk.green(' mcp ai configure <provider> [options]'));
|
|
246
|
+
console.log(' Configure AI provider');
|
|
247
|
+
console.log(' Providers: openai, ollama, none');
|
|
248
|
+
console.log(' Options:');
|
|
249
|
+
console.log(' --api-key=<key> API key (for OpenAI)');
|
|
250
|
+
console.log(' --endpoint=<url> Custom endpoint');
|
|
251
|
+
console.log(' --model=<name> Model name');
|
|
252
|
+
console.log('');
|
|
253
|
+
console.log(chalk.green(' mcp ai test'));
|
|
254
|
+
console.log(' Test AI connection');
|
|
255
|
+
console.log('');
|
|
256
|
+
console.log(chalk.green(' mcp ai ask "<query>"'));
|
|
257
|
+
console.log(' Ask AI a question');
|
|
258
|
+
console.log(' Example: mcp ai ask "list files in current directory"');
|
|
259
|
+
console.log('');
|
|
260
|
+
console.log(chalk.green(' mcp ai reset'));
|
|
261
|
+
console.log(' Reset AI configuration to defaults');
|
|
262
|
+
console.log('');
|
|
263
|
+
console.log(chalk.green(' mcp ai help'));
|
|
264
|
+
console.log(' Show this help message');
|
|
265
|
+
console.log('');
|
|
266
|
+
console.log(chalk.yellow('💡 Examples:'));
|
|
267
|
+
console.log(' Configure OpenAI: mcp ai configure openai sk-xxx');
|
|
268
|
+
console.log(' Configure Ollama: mcp ai configure ollama');
|
|
269
|
+
console.log(' Ask question: mcp ai ask "start http service"');
|
|
270
|
+
console.log(' Test connection: mcp ai test');
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Get AI instance (for integration with other modules)
|
|
274
|
+
*/
|
|
275
|
+
getAIInstance() {
|
|
276
|
+
return this.ai;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Get config manager instance
|
|
280
|
+
*/
|
|
281
|
+
getConfigManager() {
|
|
282
|
+
return this.configManager;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simplified AI Configuration Manager
|
|
3
|
+
* Minimal configuration system for AI features
|
|
4
|
+
*/
|
|
5
|
+
import { SimpleAIConfig } from './ai';
|
|
6
|
+
/**
|
|
7
|
+
* Simplified AI configuration manager
|
|
8
|
+
*/
|
|
9
|
+
export declare class SimpleAIConfigManager {
|
|
10
|
+
private config;
|
|
11
|
+
constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Load configuration from file
|
|
14
|
+
*/
|
|
15
|
+
private loadConfig;
|
|
16
|
+
/**
|
|
17
|
+
* Save configuration to file
|
|
18
|
+
*/
|
|
19
|
+
private saveConfig;
|
|
20
|
+
/**
|
|
21
|
+
* Get current configuration
|
|
22
|
+
*/
|
|
23
|
+
getConfig(): SimpleAIConfig;
|
|
24
|
+
/**
|
|
25
|
+
* Update configuration
|
|
26
|
+
*/
|
|
27
|
+
updateConfig(config: SimpleAIConfig): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Validate configuration
|
|
30
|
+
*/
|
|
31
|
+
private validateConfig;
|
|
32
|
+
/**
|
|
33
|
+
* Check if string is a valid URL
|
|
34
|
+
*/
|
|
35
|
+
private isValidUrl;
|
|
36
|
+
/**
|
|
37
|
+
* Parse configuration from command line arguments
|
|
38
|
+
*/
|
|
39
|
+
parseFromArgs(args: string[]): SimpleAIConfig;
|
|
40
|
+
/**
|
|
41
|
+
* Get configuration file path
|
|
42
|
+
*/
|
|
43
|
+
getConfigFilePath(): string;
|
|
44
|
+
/**
|
|
45
|
+
* Check if configuration file exists
|
|
46
|
+
*/
|
|
47
|
+
configFileExists(): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Reset configuration to defaults
|
|
50
|
+
*/
|
|
51
|
+
resetConfig(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Get configuration status
|
|
54
|
+
*/
|
|
55
|
+
getStatus(): {
|
|
56
|
+
configured: boolean;
|
|
57
|
+
provider: string;
|
|
58
|
+
hasApiKey: boolean;
|
|
59
|
+
configFile: string;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Format configuration for display
|
|
63
|
+
*/
|
|
64
|
+
formatConfig(): string;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simplified AI Configuration Manager
|
|
3
|
+
* Minimal configuration system for AI features
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { logger } from '../core/logger.js';
|
|
8
|
+
// Configuration file path
|
|
9
|
+
const CONFIG_DIR = process.env.MCPILOT_CONFIG_DIR ||
|
|
10
|
+
path.join(process.env.HOME || process.env.USERPROFILE || '.', '.mcpilot');
|
|
11
|
+
const CONFIG_FILE = path.join(CONFIG_DIR, 'ai-config.json');
|
|
12
|
+
/**
|
|
13
|
+
* Simplified AI configuration manager
|
|
14
|
+
*/
|
|
15
|
+
export class SimpleAIConfigManager {
|
|
16
|
+
config = null;
|
|
17
|
+
constructor() {
|
|
18
|
+
this.loadConfig();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Load configuration from file
|
|
22
|
+
*/
|
|
23
|
+
loadConfig() {
|
|
24
|
+
try {
|
|
25
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
26
|
+
const content = fs.readFileSync(CONFIG_FILE, 'utf-8');
|
|
27
|
+
this.config = JSON.parse(content);
|
|
28
|
+
logger.info('[AI] Configuration loaded from file');
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
logger.info('[AI] No configuration file found, using defaults');
|
|
32
|
+
this.config = { provider: 'none' };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
logger.warn(`[AI] Failed to load configuration: ${error.message}`);
|
|
37
|
+
this.config = { provider: 'none' };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Save configuration to file
|
|
42
|
+
*/
|
|
43
|
+
saveConfig() {
|
|
44
|
+
try {
|
|
45
|
+
// Ensure config directory exists
|
|
46
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
47
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
48
|
+
}
|
|
49
|
+
// Save configuration
|
|
50
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(this.config, null, 2));
|
|
51
|
+
logger.info('[AI] Configuration saved to file');
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
logger.error(`[AI] Failed to save configuration: ${error.message}`);
|
|
55
|
+
throw new Error(`Failed to save configuration: ${error.message}`, { cause: error });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get current configuration
|
|
60
|
+
*/
|
|
61
|
+
getConfig() {
|
|
62
|
+
return this.config || { provider: 'none' };
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Update configuration
|
|
66
|
+
*/
|
|
67
|
+
async updateConfig(config) {
|
|
68
|
+
// Validate configuration
|
|
69
|
+
this.validateConfig(config);
|
|
70
|
+
// Update configuration
|
|
71
|
+
this.config = config;
|
|
72
|
+
// Save to file
|
|
73
|
+
this.saveConfig();
|
|
74
|
+
logger.info(`[AI] Configuration updated for provider: ${config.provider}`);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Validate configuration
|
|
78
|
+
*/
|
|
79
|
+
validateConfig(config) {
|
|
80
|
+
// Basic validation
|
|
81
|
+
if (!config.provider) {
|
|
82
|
+
throw new Error('Provider is required');
|
|
83
|
+
}
|
|
84
|
+
const validProviders = ['openai', 'ollama', 'none'];
|
|
85
|
+
if (!validProviders.includes(config.provider)) {
|
|
86
|
+
throw new Error(`Invalid provider: ${config.provider}. Valid providers: ${validProviders.join(', ')}`);
|
|
87
|
+
}
|
|
88
|
+
// Provider-specific validation
|
|
89
|
+
if (config.provider === 'openai' && !config.apiKey) {
|
|
90
|
+
throw new Error('OpenAI requires API key');
|
|
91
|
+
}
|
|
92
|
+
// Validate endpoint format if provided
|
|
93
|
+
if (config.endpoint && !this.isValidUrl(config.endpoint)) {
|
|
94
|
+
throw new Error(`Invalid endpoint URL: ${config.endpoint}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Check if string is a valid URL
|
|
99
|
+
*/
|
|
100
|
+
isValidUrl(url) {
|
|
101
|
+
try {
|
|
102
|
+
new URL(url);
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Parse configuration from command line arguments
|
|
111
|
+
*/
|
|
112
|
+
parseFromArgs(args) {
|
|
113
|
+
if (args.length === 0) {
|
|
114
|
+
throw new Error('No arguments provided');
|
|
115
|
+
}
|
|
116
|
+
const provider = args[0].toLowerCase();
|
|
117
|
+
const config = { provider: 'none' };
|
|
118
|
+
// Parse provider
|
|
119
|
+
if (provider === 'openai' || provider === 'ollama') {
|
|
120
|
+
config.provider = provider;
|
|
121
|
+
}
|
|
122
|
+
else if (provider === 'none' || provider === 'reset') {
|
|
123
|
+
config.provider = 'none';
|
|
124
|
+
return config;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
throw new Error(`Unknown provider: ${provider}. Use: openai, ollama, or none`);
|
|
128
|
+
}
|
|
129
|
+
// Parse additional arguments
|
|
130
|
+
for (let i = 1; i < args.length; i++) {
|
|
131
|
+
const arg = args[i];
|
|
132
|
+
if (arg.startsWith('--')) {
|
|
133
|
+
const [key, value] = arg.slice(2).split('=');
|
|
134
|
+
switch (key) {
|
|
135
|
+
case 'api-key':
|
|
136
|
+
case 'apikey':
|
|
137
|
+
config.apiKey = value;
|
|
138
|
+
break;
|
|
139
|
+
case 'endpoint':
|
|
140
|
+
config.endpoint = value;
|
|
141
|
+
break;
|
|
142
|
+
case 'model':
|
|
143
|
+
config.model = value;
|
|
144
|
+
break;
|
|
145
|
+
default:
|
|
146
|
+
logger.warn(`[AI] Unknown option: --${key}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else if (i === 1 && !arg.startsWith('--')) {
|
|
150
|
+
// First non-option argument after provider is treated as API key
|
|
151
|
+
config.apiKey = arg;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return config;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Get configuration file path
|
|
158
|
+
*/
|
|
159
|
+
getConfigFilePath() {
|
|
160
|
+
return CONFIG_FILE;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Check if configuration file exists
|
|
164
|
+
*/
|
|
165
|
+
configFileExists() {
|
|
166
|
+
return fs.existsSync(CONFIG_FILE);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Reset configuration to defaults
|
|
170
|
+
*/
|
|
171
|
+
resetConfig() {
|
|
172
|
+
this.config = { provider: 'none' };
|
|
173
|
+
this.saveConfig();
|
|
174
|
+
logger.info('[AI] Configuration reset to defaults');
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Get configuration status
|
|
178
|
+
*/
|
|
179
|
+
getStatus() {
|
|
180
|
+
return {
|
|
181
|
+
configured: this.config?.provider !== 'none',
|
|
182
|
+
provider: this.config?.provider || 'none',
|
|
183
|
+
hasApiKey: !!this.config?.apiKey,
|
|
184
|
+
configFile: CONFIG_FILE,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Format configuration for display
|
|
189
|
+
*/
|
|
190
|
+
formatConfig() {
|
|
191
|
+
const config = this.getConfig();
|
|
192
|
+
const lines = [
|
|
193
|
+
'AI Configuration:',
|
|
194
|
+
` Provider: ${config.provider}`,
|
|
195
|
+
];
|
|
196
|
+
if (config.provider !== 'none') {
|
|
197
|
+
if (config.model) {
|
|
198
|
+
lines.push(` Model: ${config.model}`);
|
|
199
|
+
}
|
|
200
|
+
if (config.endpoint) {
|
|
201
|
+
lines.push(` Endpoint: ${config.endpoint}`);
|
|
202
|
+
}
|
|
203
|
+
if (config.apiKey) {
|
|
204
|
+
lines.push(` API Key: ${config.apiKey ? '********' + config.apiKey.slice(-4) : 'Not set'}`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
lines.push(` Config file: ${CONFIG_FILE}`);
|
|
208
|
+
return lines.join('\n');
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced Intent Engine
|
|
3
|
+
* Advanced AI-powered intent parsing with context awareness
|
|
4
|
+
*/
|
|
5
|
+
export interface IntentResult {
|
|
6
|
+
service: string;
|
|
7
|
+
method: string;
|
|
8
|
+
parameters: Record<string, any>;
|
|
9
|
+
confidence: number;
|
|
10
|
+
}
|
|
11
|
+
export declare class EnhancedIntentEngine {
|
|
12
|
+
private config;
|
|
13
|
+
constructor(config: any);
|
|
14
|
+
parse(query: string, availableTools: string[]): Promise<IntentResult | null>;
|
|
15
|
+
updateConfig(config: any): void;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=enhanced-intent.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced Intent Engine
|
|
3
|
+
* Advanced AI-powered intent parsing with context awareness
|
|
4
|
+
*/
|
|
5
|
+
export class EnhancedIntentEngine {
|
|
6
|
+
config;
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.config = config;
|
|
9
|
+
// Initialize with configuration
|
|
10
|
+
}
|
|
11
|
+
async parse(query, availableTools) {
|
|
12
|
+
// Simple implementation for now
|
|
13
|
+
// In a real implementation, this would use AI to parse the query
|
|
14
|
+
// Find the first tool that matches the query
|
|
15
|
+
for (const tool of availableTools) {
|
|
16
|
+
if (tool.toLowerCase().includes(query.toLowerCase())) {
|
|
17
|
+
const [service, method] = tool.split(':');
|
|
18
|
+
return {
|
|
19
|
+
service,
|
|
20
|
+
method,
|
|
21
|
+
parameters: {},
|
|
22
|
+
confidence: 0.7,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
updateConfig(config) {
|
|
29
|
+
this.config = config;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=enhanced-intent.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Module Exports
|
|
3
|
+
* Provides unified interface for AI functionality
|
|
4
|
+
*/
|
|
5
|
+
export { SimpleAI, AIError, type SimpleAIConfig, type AskResult, type ToolCall } from './ai';
|
|
6
|
+
export { SimpleAIConfigManager } from './config';
|
|
7
|
+
export { SimpleAICommand } from './command';
|
|
8
|
+
export { CloudIntentEngine, type CloudIntentEngineConfig, type AtomicIntent, type DependencyEdge, type IntentParseResult, type ToolSelectionResult, type ExecutionContext, type ExecutionResult, type EnhancedExecutionStep, type WorkflowPlan, type EnhancedExecutionResult, } from './cloud-intent-engine';
|
|
9
|
+
export { EnhancedIntentEngine } from './enhanced-intent';
|
|
10
|
+
export { IntentEngine } from './intent';
|
|
11
|
+
/**
|
|
12
|
+
* Check AI capabilities
|
|
13
|
+
* Simplified version without vector database
|
|
14
|
+
*/
|
|
15
|
+
export declare function checkAICapabilities(config?: any): Promise<{
|
|
16
|
+
aiAvailable: boolean;
|
|
17
|
+
mode: 'api' | 'none';
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Get AI system status
|
|
21
|
+
*/
|
|
22
|
+
export declare function getAIStatus(config?: any): Promise<{
|
|
23
|
+
timestamp: string;
|
|
24
|
+
version: string;
|
|
25
|
+
note: string;
|
|
26
|
+
aiAvailable: boolean;
|
|
27
|
+
mode: "api" | "none";
|
|
28
|
+
}>;
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|