@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,184 @@
1
+ /**
2
+ * Enhanced Runtime Adapter Interface
3
+ * Balances minimalist style with functional robustness
4
+ */
5
+ import { ServiceConfig } from '../core/types';
6
+ /**
7
+ * Process Information
8
+ */
9
+ export interface ProcessInfo {
10
+ id: string;
11
+ pid?: number;
12
+ status: 'starting' | 'running' | 'stopping' | 'stopped' | 'error';
13
+ startedAt?: Date;
14
+ config: ServiceConfig;
15
+ }
16
+ /**
17
+ * Process Status
18
+ */
19
+ export interface ProcessStatus {
20
+ running: boolean;
21
+ pid?: number;
22
+ uptime?: number;
23
+ memory?: number;
24
+ cpu?: number;
25
+ exitCode?: number;
26
+ error?: string;
27
+ }
28
+ /**
29
+ * Health Status
30
+ */
31
+ export interface HealthStatus {
32
+ healthy: boolean;
33
+ checks: Array<{
34
+ name: string;
35
+ status: 'pass' | 'fail' | 'warn';
36
+ message?: string;
37
+ duration?: number;
38
+ }>;
39
+ score: number;
40
+ }
41
+ /**
42
+ * Log Options
43
+ */
44
+ export interface LogOptions {
45
+ follow?: boolean;
46
+ tail?: number;
47
+ since?: Date;
48
+ until?: Date;
49
+ filter?: (line: string) => boolean;
50
+ }
51
+ /**
52
+ * Enhanced Runtime Adapter Interface
53
+ * Core functionality remains simple, optional features provided through extended interface
54
+ */
55
+ export interface EnhancedRuntimeAdapter {
56
+ /**
57
+ * Start service
58
+ */
59
+ start(config: ServiceConfig): Promise<ProcessInfo>;
60
+ /**
61
+ * Stop service
62
+ */
63
+ stop(processId: string): Promise<void>;
64
+ /**
65
+ * Get service status
66
+ */
67
+ status(processId: string): Promise<ProcessStatus>;
68
+ /**
69
+ * Health check (optional)
70
+ */
71
+ healthCheck?(config: ServiceConfig): Promise<HealthStatus>;
72
+ /**
73
+ * Get logs (optional)
74
+ */
75
+ logs?(processId: string, options?: LogOptions): AsyncIterable<string>;
76
+ /**
77
+ * Restart service (optional)
78
+ */
79
+ restart?(processId: string): Promise<ProcessInfo>;
80
+ /**
81
+ * Pre-start hook
82
+ */
83
+ onStart?(config: ServiceConfig): Promise<void>;
84
+ /**
85
+ * Post-start hook
86
+ */
87
+ onStarted?(processInfo: ProcessInfo): Promise<void>;
88
+ /**
89
+ * Pre-stop hook
90
+ */
91
+ onStop?(processId: string): Promise<void>;
92
+ /**
93
+ * Post-stop hook
94
+ */
95
+ onStopped?(processId: string): Promise<void>;
96
+ /**
97
+ * Error handling hook
98
+ */
99
+ onError?(error: Error, context: any): Promise<void>;
100
+ }
101
+ /**
102
+ * Adapter Factory Interface
103
+ */
104
+ export interface RuntimeAdapterFactory {
105
+ /**
106
+ * Create adapter instance
107
+ */
108
+ create(config: ServiceConfig): EnhancedRuntimeAdapter;
109
+ /**
110
+ * Check if runtime type is supported
111
+ */
112
+ supports(runtimeType: string): boolean;
113
+ }
114
+ /**
115
+ * Unified Error Type
116
+ */
117
+ export declare class RuntimeAdapterError extends Error {
118
+ code: string;
119
+ message: string;
120
+ context?: Record<string, any>;
121
+ cause?: Error;
122
+ constructor(code: string, message: string, context?: Record<string, any>, cause?: Error);
123
+ }
124
+ /**
125
+ * Error Code Enumeration
126
+ */
127
+ export declare enum RuntimeErrorCode {
128
+ CONFIG_INVALID = "CONFIG_INVALID",
129
+ CONFIG_MISSING = "CONFIG_MISSING",
130
+ PROCESS_START_FAILED = "PROCESS_START_FAILED",
131
+ PROCESS_STOP_FAILED = "PROCESS_STOP_FAILED",
132
+ PROCESS_NOT_FOUND = "PROCESS_NOT_FOUND",
133
+ RUNTIME_NOT_SUPPORTED = "RUNTIME_NOT_SUPPORTED",
134
+ RUNTIME_NOT_INSTALLED = "RUNTIME_NOT_INSTALLED",
135
+ RESOURCE_LIMIT_EXCEEDED = "RESOURCE_LIMIT_EXCEEDED",
136
+ PERMISSION_DENIED = "PERMISSION_DENIED",
137
+ NETWORK_ERROR = "NETWORK_ERROR",
138
+ CONNECTION_REFUSED = "CONNECTION_REFUSED",
139
+ TIMEOUT = "TIMEOUT",
140
+ UNKNOWN = "UNKNOWN"
141
+ }
142
+ /**
143
+ * Adapter Registry
144
+ */
145
+ export declare class RuntimeAdapterRegistry {
146
+ private static factories;
147
+ /**
148
+ * Register adapter factory
149
+ */
150
+ static register(runtimeType: string, factory: RuntimeAdapterFactory): void;
151
+ /**
152
+ * Get adapter factory
153
+ */
154
+ static getFactory(runtimeType: string): RuntimeAdapterFactory | undefined;
155
+ /**
156
+ * Create adapter instance
157
+ */
158
+ static createAdapter(runtimeType: string, config: ServiceConfig): EnhancedRuntimeAdapter;
159
+ /**
160
+ * Get all supported runtime types
161
+ */
162
+ static getSupportedRuntimes(): string[];
163
+ }
164
+ /**
165
+ * Base Adapter Abstract Class
166
+ * Provides default implementations and utility methods
167
+ */
168
+ export declare abstract class BaseRuntimeAdapter implements EnhancedRuntimeAdapter {
169
+ protected processMap: Map<string, ProcessInfo>;
170
+ abstract start(config: ServiceConfig): Promise<ProcessInfo>;
171
+ abstract stop(processId: string): Promise<void>;
172
+ abstract status(processId: string): Promise<ProcessStatus>;
173
+ healthCheck(config: ServiceConfig): Promise<HealthStatus>;
174
+ logs(processId: string, options?: LogOptions): AsyncIterable<string>;
175
+ restart(processId: string): Promise<ProcessInfo>;
176
+ protected generateProcessId(config: ServiceConfig): string;
177
+ protected validateConfig(config: ServiceConfig): void;
178
+ onStart(config: ServiceConfig): Promise<void>;
179
+ onStarted(processInfo: ProcessInfo): Promise<void>;
180
+ onStop(processId: string): Promise<void>;
181
+ onStopped(processId: string): Promise<void>;
182
+ onError(error: Error, context: any): Promise<void>;
183
+ }
184
+ //# sourceMappingURL=adapter-advanced.d.ts.map
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Enhanced Runtime Adapter Interface
3
+ * Balances minimalist style with functional robustness
4
+ */
5
+ /**
6
+ * Unified Error Type
7
+ */
8
+ export class RuntimeAdapterError extends Error {
9
+ code;
10
+ message;
11
+ context;
12
+ cause;
13
+ constructor(code, message, context, cause) {
14
+ super(message);
15
+ this.code = code;
16
+ this.message = message;
17
+ this.context = context;
18
+ this.cause = cause;
19
+ this.name = 'RuntimeAdapterError';
20
+ }
21
+ }
22
+ /**
23
+ * Error Code Enumeration
24
+ */
25
+ export var RuntimeErrorCode;
26
+ (function (RuntimeErrorCode) {
27
+ // Configuration errors
28
+ RuntimeErrorCode["CONFIG_INVALID"] = "CONFIG_INVALID";
29
+ RuntimeErrorCode["CONFIG_MISSING"] = "CONFIG_MISSING";
30
+ // Process errors
31
+ RuntimeErrorCode["PROCESS_START_FAILED"] = "PROCESS_START_FAILED";
32
+ RuntimeErrorCode["PROCESS_STOP_FAILED"] = "PROCESS_STOP_FAILED";
33
+ RuntimeErrorCode["PROCESS_NOT_FOUND"] = "PROCESS_NOT_FOUND";
34
+ // Runtime errors
35
+ RuntimeErrorCode["RUNTIME_NOT_SUPPORTED"] = "RUNTIME_NOT_SUPPORTED";
36
+ RuntimeErrorCode["RUNTIME_NOT_INSTALLED"] = "RUNTIME_NOT_INSTALLED";
37
+ // Resource errors
38
+ RuntimeErrorCode["RESOURCE_LIMIT_EXCEEDED"] = "RESOURCE_LIMIT_EXCEEDED";
39
+ RuntimeErrorCode["PERMISSION_DENIED"] = "PERMISSION_DENIED";
40
+ // Network errors
41
+ RuntimeErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
42
+ RuntimeErrorCode["CONNECTION_REFUSED"] = "CONNECTION_REFUSED";
43
+ // Timeout errors
44
+ RuntimeErrorCode["TIMEOUT"] = "TIMEOUT";
45
+ // Unknown errors
46
+ RuntimeErrorCode["UNKNOWN"] = "UNKNOWN";
47
+ })(RuntimeErrorCode || (RuntimeErrorCode = {}));
48
+ /**
49
+ * Adapter Registry
50
+ */
51
+ export class RuntimeAdapterRegistry {
52
+ static factories = new Map();
53
+ /**
54
+ * Register adapter factory
55
+ */
56
+ static register(runtimeType, factory) {
57
+ this.factories.set(runtimeType, factory);
58
+ }
59
+ /**
60
+ * Get adapter factory
61
+ */
62
+ static getFactory(runtimeType) {
63
+ return this.factories.get(runtimeType);
64
+ }
65
+ /**
66
+ * Create adapter instance
67
+ */
68
+ static createAdapter(runtimeType, config) {
69
+ const factory = this.getFactory(runtimeType);
70
+ if (!factory) {
71
+ throw new RuntimeAdapterError(RuntimeErrorCode.RUNTIME_NOT_SUPPORTED, `Runtime type '${runtimeType}' is not supported`, { runtimeType, supportedRuntimes: Array.from(this.factories.keys()) });
72
+ }
73
+ return factory.create(config);
74
+ }
75
+ /**
76
+ * Get all supported runtime types
77
+ */
78
+ static getSupportedRuntimes() {
79
+ return Array.from(this.factories.keys());
80
+ }
81
+ }
82
+ /**
83
+ * Base Adapter Abstract Class
84
+ * Provides default implementations and utility methods
85
+ */
86
+ export class BaseRuntimeAdapter {
87
+ processMap = new Map();
88
+ // Default implementations for optional methods
89
+ async healthCheck(config) {
90
+ // Default health check: Check if process is running
91
+ const processes = Array.from(this.processMap.values())
92
+ .filter(p => p.config.name === config.name);
93
+ if (processes.length === 0) {
94
+ return {
95
+ healthy: false,
96
+ checks: [{
97
+ name: 'process-exists',
98
+ status: 'fail',
99
+ message: 'No running process found',
100
+ }],
101
+ score: 0,
102
+ };
103
+ }
104
+ const runningProcesses = processes.filter(p => p.status === 'running');
105
+ return {
106
+ healthy: runningProcesses.length > 0,
107
+ checks: [{
108
+ name: 'process-running',
109
+ status: runningProcesses.length > 0 ? 'pass' : 'fail',
110
+ message: runningProcesses.length > 0
111
+ ? `${runningProcesses.length} process(es) running`
112
+ : 'No running processes',
113
+ }],
114
+ score: runningProcesses.length > 0 ? 100 : 0,
115
+ };
116
+ }
117
+ async *logs(processId, options) {
118
+ // Default implementation: Return empty log stream
119
+ // Specific adapters should override this method
120
+ yield `Logs not available for process ${processId}`;
121
+ }
122
+ async restart(processId) {
123
+ // Default implementation: Stop then start
124
+ const processInfo = this.processMap.get(processId);
125
+ if (!processInfo) {
126
+ throw new RuntimeAdapterError(RuntimeErrorCode.PROCESS_NOT_FOUND, `Process ${processId} not found`);
127
+ }
128
+ await this.stop(processId);
129
+ return this.start(processInfo.config);
130
+ }
131
+ // Utility methods
132
+ generateProcessId(config) {
133
+ return `${config.name}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
134
+ }
135
+ validateConfig(config) {
136
+ if (!config.name || !config.name.trim()) {
137
+ throw new RuntimeAdapterError(RuntimeErrorCode.CONFIG_INVALID, 'Service name is required', { config });
138
+ }
139
+ if (!config.path || !config.path.trim()) {
140
+ throw new RuntimeAdapterError(RuntimeErrorCode.CONFIG_INVALID, 'Service path is required', { config });
141
+ }
142
+ }
143
+ // Default implementations for lifecycle hooks
144
+ async onStart(config) {
145
+ // Default no-op
146
+ }
147
+ async onStarted(processInfo) {
148
+ // Default no-op
149
+ }
150
+ async onStop(processId) {
151
+ // Default no-op
152
+ }
153
+ async onStopped(processId) {
154
+ // Default no-op
155
+ }
156
+ async onError(error, context) {
157
+ console.error('Runtime adapter error:', error, context);
158
+ }
159
+ }
160
+ //# sourceMappingURL=adapter-advanced.js.map
@@ -0,0 +1,9 @@
1
+ import { ServiceConfig } from '../core/types';
2
+ export interface RuntimeAdapter {
3
+ getSpawnArgs(config: ServiceConfig): {
4
+ command: string;
5
+ args: string[];
6
+ };
7
+ setup(config: ServiceConfig): Promise<void>;
8
+ }
9
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1,59 @@
1
+ import { RuntimeType, DetectionResult } from '../core/types';
2
+ export declare class EnhancedRuntimeDetector {
3
+ /**
4
+ * Run both old and new detectors in parallel, select the best result
5
+ */
6
+ static detect(servicePath: string): Promise<DetectionResult>;
7
+ /**
8
+ * Run traditional detector
9
+ */
10
+ private static runLegacyDetector;
11
+ /**
12
+ * Run enhanced detection
13
+ */
14
+ private static runEnhancedDetection;
15
+ /**
16
+ * Analyze executable files
17
+ */
18
+ private static analyzeExecutables;
19
+ /**
20
+ * Analyze project configuration files
21
+ */
22
+ private static analyzeProjectFiles;
23
+ /**
24
+ * Analyze file statistics
25
+ */
26
+ private static analyzeFileStatistics;
27
+ /**
28
+ * Analyze file extensions
29
+ */
30
+ private static analyzeFileExtensions;
31
+ /**
32
+ * Determine runtime type from evidence
33
+ */
34
+ private static determineRuntimeFromEvidence;
35
+ /**
36
+ * Generate low confidence warning
37
+ */
38
+ private static generateLowConfidenceWarning;
39
+ /**
40
+ * Generate runtime suggestions
41
+ */
42
+ private static generateRuntimeSuggestions;
43
+ /**
44
+ * Find Python configuration files
45
+ */
46
+ private static findPythonConfigFiles;
47
+ /**
48
+ * Find Java configuration files
49
+ */
50
+ private static findJavaConfigFiles;
51
+ /**
52
+ * Quick detection (for CLI interaction)
53
+ */
54
+ static quickDetect(servicePath: string): {
55
+ runtime: RuntimeType;
56
+ confidence: number;
57
+ };
58
+ }
59
+ //# sourceMappingURL=detector-advanced.d.ts.map