@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.
Files changed (101) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +545 -0
  3. package/dist/ai/ai.d.ts +205 -0
  4. package/dist/ai/ai.js +1200 -0
  5. package/dist/ai/cloud-intent-engine.d.ts +270 -0
  6. package/dist/ai/cloud-intent-engine.js +956 -0
  7. package/dist/ai/command.d.ts +59 -0
  8. package/dist/ai/command.js +285 -0
  9. package/dist/ai/config.d.ts +66 -0
  10. package/dist/ai/config.js +211 -0
  11. package/dist/ai/enhanced-intent.d.ts +17 -0
  12. package/dist/ai/enhanced-intent.js +32 -0
  13. package/dist/ai/index.d.ts +29 -0
  14. package/dist/ai/index.js +44 -0
  15. package/dist/ai/intent.d.ts +16 -0
  16. package/dist/ai/intent.js +30 -0
  17. package/dist/core/ai-config.d.ts +25 -0
  18. package/dist/core/ai-config.js +326 -0
  19. package/dist/core/config-manager.d.ts +36 -0
  20. package/dist/core/config-manager.js +400 -0
  21. package/dist/core/config-validator.d.ts +9 -0
  22. package/dist/core/config-validator.js +184 -0
  23. package/dist/core/constants.d.ts +34 -0
  24. package/dist/core/constants.js +37 -0
  25. package/dist/core/error-ai.d.ts +23 -0
  26. package/dist/core/error-ai.js +217 -0
  27. package/dist/core/error-handler.d.ts +197 -0
  28. package/dist/core/error-handler.js +467 -0
  29. package/dist/core/index.d.ts +13 -0
  30. package/dist/core/index.js +17 -0
  31. package/dist/core/logger.d.ts +27 -0
  32. package/dist/core/logger.js +108 -0
  33. package/dist/core/performance-monitor.d.ts +74 -0
  34. package/dist/core/performance-monitor.js +260 -0
  35. package/dist/core/providers.d.ts +36 -0
  36. package/dist/core/providers.js +304 -0
  37. package/dist/core/retry-manager.d.ts +41 -0
  38. package/dist/core/retry-manager.js +204 -0
  39. package/dist/core/types.d.ts +155 -0
  40. package/dist/core/types.js +2 -0
  41. package/dist/daemon/index.d.ts +10 -0
  42. package/dist/daemon/index.js +15 -0
  43. package/dist/daemon/intent-engine.d.ts +22 -0
  44. package/dist/daemon/intent-engine.js +50 -0
  45. package/dist/daemon/orchestrator.d.ts +24 -0
  46. package/dist/daemon/orchestrator.js +100 -0
  47. package/dist/daemon/pm.d.ts +33 -0
  48. package/dist/daemon/pm.js +127 -0
  49. package/dist/daemon/process.d.ts +11 -0
  50. package/dist/daemon/process.js +49 -0
  51. package/dist/daemon/server.d.ts +17 -0
  52. package/dist/daemon/server.js +435 -0
  53. package/dist/daemon/service.d.ts +36 -0
  54. package/dist/daemon/service.js +278 -0
  55. package/dist/index.d.ts +30 -0
  56. package/dist/index.js +36 -0
  57. package/dist/mcp/client.d.ts +51 -0
  58. package/dist/mcp/client.js +276 -0
  59. package/dist/mcp/index.d.ts +162 -0
  60. package/dist/mcp/index.js +199 -0
  61. package/dist/mcp/tool-registry.d.ts +71 -0
  62. package/dist/mcp/tool-registry.js +308 -0
  63. package/dist/mcp/transport.d.ts +83 -0
  64. package/dist/mcp/transport.js +515 -0
  65. package/dist/mcp/types.d.ts +136 -0
  66. package/dist/mcp/types.js +31 -0
  67. package/dist/runtime/adapter-advanced.d.ts +184 -0
  68. package/dist/runtime/adapter-advanced.js +160 -0
  69. package/dist/runtime/adapter.d.ts +9 -0
  70. package/dist/runtime/adapter.js +2 -0
  71. package/dist/runtime/detector-advanced.d.ts +59 -0
  72. package/dist/runtime/detector-advanced.js +487 -0
  73. package/dist/runtime/detector.d.ts +5 -0
  74. package/dist/runtime/detector.js +56 -0
  75. package/dist/runtime/docker-adapter.d.ts +18 -0
  76. package/dist/runtime/docker-adapter.js +170 -0
  77. package/dist/runtime/docker.d.ts +17 -0
  78. package/dist/runtime/docker.js +71 -0
  79. package/dist/runtime/executable-analyzer.d.ts +56 -0
  80. package/dist/runtime/executable-analyzer.js +391 -0
  81. package/dist/runtime/go-adapter.d.ts +19 -0
  82. package/dist/runtime/go-adapter.js +190 -0
  83. package/dist/runtime/index.d.ts +9 -0
  84. package/dist/runtime/index.js +10 -0
  85. package/dist/runtime/node-adapter.d.ts +10 -0
  86. package/dist/runtime/node-adapter.js +23 -0
  87. package/dist/runtime/node.d.ts +20 -0
  88. package/dist/runtime/node.js +86 -0
  89. package/dist/runtime/python-adapter.d.ts +11 -0
  90. package/dist/runtime/python-adapter.js +102 -0
  91. package/dist/runtime/python.d.ts +17 -0
  92. package/dist/runtime/python.js +72 -0
  93. package/dist/runtime/rust-adapter.d.ts +21 -0
  94. package/dist/runtime/rust-adapter.js +267 -0
  95. package/dist/sdk.d.ts +500 -0
  96. package/dist/sdk.js +904 -0
  97. package/docs/README.ZH_CN.md +545 -0
  98. package/docs/api.md +888 -0
  99. package/docs/architecture.md +731 -0
  100. package/docs/development.md +744 -0
  101. package/package.json +112 -0
@@ -0,0 +1,270 @@
1
+ /**
2
+ * Cloud LLM Intent Engine
3
+ * Cloud LLM-based intent parsing and MCP capability auto-mapping engine
4
+ *
5
+ * Core capabilities:
6
+ * 1. Decompose natural language instructions into atomic intents (with parameters)
7
+ * 2. Infer dependencies between atomic intents (generate DAG)
8
+ * 3. Select the most appropriate tool from MCP tools for each atomic intent
9
+ * 4. Map intent parameters to tool input parameters
10
+ * 5. Execute tool calls in dependency order
11
+ */
12
+ import { type SimpleAIConfig } from './ai';
13
+ import type { Tool } from '../mcp/types';
14
+ /**
15
+ * Atomic intent
16
+ */
17
+ export interface AtomicIntent {
18
+ id: string;
19
+ type: string;
20
+ description: string;
21
+ parameters: Record<string, any>;
22
+ }
23
+ /**
24
+ * Dependency edge
25
+ */
26
+ export interface DependencyEdge {
27
+ from: string;
28
+ to: string;
29
+ }
30
+ /**
31
+ * Intent parsing result
32
+ */
33
+ export interface IntentParseResult {
34
+ intents: AtomicIntent[];
35
+ edges: DependencyEdge[];
36
+ }
37
+ /**
38
+ * Tool selection result
39
+ */
40
+ export interface ToolSelectionResult {
41
+ intentId: string;
42
+ toolName: string;
43
+ toolDescription: string;
44
+ mappedParameters: Record<string, any>;
45
+ confidence: number;
46
+ serverId?: string;
47
+ serverName?: string;
48
+ }
49
+ /**
50
+ * Execution context
51
+ */
52
+ export interface ExecutionContext {
53
+ results: Map<string, any>;
54
+ variables: Map<string, any>;
55
+ }
56
+ /**
57
+ * Enhanced execution step result
58
+ */
59
+ export interface EnhancedExecutionStep {
60
+ intentId: string;
61
+ intentDescription: string;
62
+ intentType: string;
63
+ intentParameters: Record<string, any>;
64
+ toolName: string;
65
+ toolDescription: string;
66
+ mappedParameters: Record<string, any>;
67
+ confidence: number;
68
+ success: boolean;
69
+ result?: any;
70
+ error?: string;
71
+ duration?: number;
72
+ startedAt?: Date;
73
+ completedAt?: Date;
74
+ }
75
+ /**
76
+ * Workflow plan (pre-execution)
77
+ */
78
+ export interface WorkflowPlan {
79
+ query: string;
80
+ parsedIntents: AtomicIntent[];
81
+ dependencies: DependencyEdge[];
82
+ toolSelections: ToolSelectionResult[];
83
+ executionOrder: string[];
84
+ estimatedSteps: number;
85
+ createdAt: Date;
86
+ }
87
+ /**
88
+ * Enhanced execution result
89
+ */
90
+ export interface EnhancedExecutionResult {
91
+ success: boolean;
92
+ finalResult?: any;
93
+ parsedIntents: AtomicIntent[];
94
+ dependencies: DependencyEdge[];
95
+ toolSelections: ToolSelectionResult[];
96
+ executionSteps: EnhancedExecutionStep[];
97
+ statistics: {
98
+ totalSteps: number;
99
+ successfulSteps: number;
100
+ failedSteps: number;
101
+ totalDuration: number;
102
+ averageStepDuration: number;
103
+ llmCalls: number;
104
+ parsingTime?: number;
105
+ toolSelectionTime?: number;
106
+ executionTime?: number;
107
+ };
108
+ }
109
+ /**
110
+ * Execution result (legacy)
111
+ */
112
+ export interface ExecutionResult {
113
+ success: boolean;
114
+ finalResult?: any;
115
+ stepResults: Array<{
116
+ intentId: string;
117
+ toolName: string;
118
+ success: boolean;
119
+ result?: any;
120
+ error?: string;
121
+ }>;
122
+ }
123
+ export interface CloudIntentEngineConfig {
124
+ llm: {
125
+ provider: SimpleAIConfig['provider'];
126
+ apiKey?: string;
127
+ endpoint?: string;
128
+ model?: string;
129
+ temperature?: number;
130
+ maxTokens?: number;
131
+ timeout?: number;
132
+ maxRetries?: number;
133
+ };
134
+ execution: {
135
+ maxConcurrentTools?: number;
136
+ timeout?: number;
137
+ retryAttempts?: number;
138
+ retryDelay?: number;
139
+ };
140
+ fallback: {
141
+ enableKeywordMatching?: boolean;
142
+ askUserOnFailure?: boolean;
143
+ defaultTools?: Record<string, string>;
144
+ };
145
+ }
146
+ export declare class CloudIntentEngine {
147
+ private ai;
148
+ private config;
149
+ private availableTools;
150
+ private toolCache;
151
+ constructor(config: CloudIntentEngineConfig);
152
+ /**
153
+ * Initialize the engine
154
+ */
155
+ initialize(): Promise<void>;
156
+ /**
157
+ * Set available tools list
158
+ */
159
+ setAvailableTools(tools: Tool[]): void;
160
+ /**
161
+ * Parse natural language instruction into atomic intents and dependencies
162
+ */
163
+ parseIntent(query: string): Promise<IntentParseResult>;
164
+ /**
165
+ * Select the most appropriate tool for each intent
166
+ */
167
+ selectTools(intents: AtomicIntent[]): Promise<ToolSelectionResult[]>;
168
+ /**
169
+ * Execute workflow
170
+ */
171
+ executeWorkflow(intents: AtomicIntent[], toolSelections: ToolSelectionResult[], edges: DependencyEdge[], toolExecutor: (toolName: string, params: Record<string, any>) => Promise<any>): Promise<ExecutionResult>;
172
+ /**
173
+ * Parse and plan workflow (without execution)
174
+ */
175
+ parseAndPlan(query: string): Promise<WorkflowPlan>;
176
+ /**
177
+ * Execute workflow with enhanced tracking
178
+ */
179
+ executeWorkflowWithTracking(intents: AtomicIntent[], toolSelections: ToolSelectionResult[], edges: DependencyEdge[], toolExecutor: (toolName: string, params: Record<string, any>) => Promise<any>, callbacks?: {
180
+ onStepStarted?: (step: {
181
+ intentId: string;
182
+ toolName: string;
183
+ intentDescription: string;
184
+ }) => void;
185
+ onStepCompleted?: (step: EnhancedExecutionStep) => void;
186
+ onStepFailed?: (step: EnhancedExecutionStep) => void;
187
+ }): Promise<EnhancedExecutionResult>;
188
+ /**
189
+ * Preview workflow plan (parse and select tools only)
190
+ */
191
+ previewPlan(query: string): Promise<WorkflowPlan>;
192
+ /**
193
+ * Confirm and execute workflow plan
194
+ */
195
+ confirmAndExecute(plan: WorkflowPlan, toolExecutor: (toolName: string, params: Record<string, any>) => Promise<any>, callbacks?: {
196
+ onStepStarted?: (step: {
197
+ intentId: string;
198
+ toolName: string;
199
+ intentDescription: string;
200
+ }) => void;
201
+ onStepCompleted?: (step: EnhancedExecutionStep) => void;
202
+ onStepFailed?: (step: EnhancedExecutionStep) => void;
203
+ }): Promise<EnhancedExecutionResult>;
204
+ /**
205
+ * Build intent parsing prompt
206
+ */
207
+ private buildIntentParsePrompt;
208
+ /**
209
+ * Call LLM
210
+ */
211
+ private callLLM;
212
+ /**
213
+ * Parse intent response
214
+ */
215
+ private parseIntentResponse;
216
+ /**
217
+ * Fallback: use simple rule-based intent parsing
218
+ */
219
+ private fallbackIntentParse;
220
+ /**
221
+ * Select tool for a single intent
222
+ */
223
+ private selectToolForIntent;
224
+ /**
225
+ * Build tool selection prompt
226
+ */
227
+ private buildToolSelectionPrompt;
228
+ /**
229
+ * Parse tool selection response
230
+ */
231
+ private parseToolSelectionResponse;
232
+ /**
233
+ * Fallback tool selection using keyword matching
234
+ */
235
+ private fallbackToolSelection;
236
+ /**
237
+ * Enhanced parameter mapping with better handling of parameter name mismatches
238
+ */
239
+ private simpleParameterMapping;
240
+ /**
241
+ * Extract URL from query
242
+ */
243
+ private extractUrl;
244
+ /**
245
+ * Extract keyword from query
246
+ */
247
+ private extractKeyword;
248
+ /**
249
+ * Build dependency graph
250
+ */
251
+ private buildDependencyGraph;
252
+ /**
253
+ * Topological sort (Kahn's algorithm)
254
+ */
255
+ private topologicalSort;
256
+ /**
257
+ * Resolve parameters with variable substitution
258
+ */
259
+ private resolveParameters;
260
+ /**
261
+ * Get engine status
262
+ */
263
+ getStatus(): {
264
+ initialized: boolean;
265
+ toolsCount: number;
266
+ llmProvider: string;
267
+ llmConfigured: boolean;
268
+ };
269
+ }
270
+ //# sourceMappingURL=cloud-intent-engine.d.ts.map