unreal-engine-mcp-server 0.3.1 → 0.4.3

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 (144) hide show
  1. package/.env.production +1 -1
  2. package/.github/copilot-instructions.md +45 -0
  3. package/.github/workflows/publish-mcp.yml +1 -1
  4. package/README.md +22 -7
  5. package/dist/index.js +137 -46
  6. package/dist/prompts/index.d.ts +10 -3
  7. package/dist/prompts/index.js +186 -7
  8. package/dist/resources/actors.d.ts +19 -1
  9. package/dist/resources/actors.js +55 -64
  10. package/dist/resources/assets.d.ts +3 -2
  11. package/dist/resources/assets.js +117 -109
  12. package/dist/resources/levels.d.ts +21 -3
  13. package/dist/resources/levels.js +31 -56
  14. package/dist/tools/actors.d.ts +3 -14
  15. package/dist/tools/actors.js +246 -302
  16. package/dist/tools/animation.d.ts +57 -102
  17. package/dist/tools/animation.js +429 -450
  18. package/dist/tools/assets.d.ts +13 -2
  19. package/dist/tools/assets.js +58 -46
  20. package/dist/tools/audio.d.ts +22 -13
  21. package/dist/tools/audio.js +467 -121
  22. package/dist/tools/blueprint.d.ts +32 -13
  23. package/dist/tools/blueprint.js +699 -448
  24. package/dist/tools/build_environment_advanced.d.ts +0 -1
  25. package/dist/tools/build_environment_advanced.js +236 -87
  26. package/dist/tools/consolidated-tool-definitions.d.ts +232 -15
  27. package/dist/tools/consolidated-tool-definitions.js +124 -255
  28. package/dist/tools/consolidated-tool-handlers.js +749 -766
  29. package/dist/tools/debug.d.ts +72 -10
  30. package/dist/tools/debug.js +170 -36
  31. package/dist/tools/editor.d.ts +9 -2
  32. package/dist/tools/editor.js +30 -44
  33. package/dist/tools/foliage.d.ts +34 -15
  34. package/dist/tools/foliage.js +97 -107
  35. package/dist/tools/introspection.js +19 -21
  36. package/dist/tools/landscape.d.ts +1 -2
  37. package/dist/tools/landscape.js +311 -168
  38. package/dist/tools/level.d.ts +3 -28
  39. package/dist/tools/level.js +642 -192
  40. package/dist/tools/lighting.d.ts +14 -3
  41. package/dist/tools/lighting.js +236 -123
  42. package/dist/tools/materials.d.ts +25 -7
  43. package/dist/tools/materials.js +102 -79
  44. package/dist/tools/niagara.d.ts +10 -12
  45. package/dist/tools/niagara.js +74 -94
  46. package/dist/tools/performance.d.ts +12 -4
  47. package/dist/tools/performance.js +38 -79
  48. package/dist/tools/physics.d.ts +34 -10
  49. package/dist/tools/physics.js +364 -292
  50. package/dist/tools/rc.js +98 -24
  51. package/dist/tools/sequence.d.ts +1 -0
  52. package/dist/tools/sequence.js +146 -24
  53. package/dist/tools/ui.d.ts +31 -4
  54. package/dist/tools/ui.js +83 -66
  55. package/dist/tools/visual.d.ts +11 -0
  56. package/dist/tools/visual.js +245 -30
  57. package/dist/types/tool-types.d.ts +0 -6
  58. package/dist/types/tool-types.js +1 -8
  59. package/dist/unreal-bridge.d.ts +32 -2
  60. package/dist/unreal-bridge.js +621 -127
  61. package/dist/utils/elicitation.d.ts +57 -0
  62. package/dist/utils/elicitation.js +104 -0
  63. package/dist/utils/error-handler.d.ts +0 -33
  64. package/dist/utils/error-handler.js +4 -111
  65. package/dist/utils/http.d.ts +2 -22
  66. package/dist/utils/http.js +12 -75
  67. package/dist/utils/normalize.d.ts +4 -4
  68. package/dist/utils/normalize.js +15 -7
  69. package/dist/utils/python-output.d.ts +18 -0
  70. package/dist/utils/python-output.js +290 -0
  71. package/dist/utils/python.d.ts +2 -0
  72. package/dist/utils/python.js +4 -0
  73. package/dist/utils/response-validator.d.ts +6 -1
  74. package/dist/utils/response-validator.js +66 -13
  75. package/dist/utils/result-helpers.d.ts +27 -0
  76. package/dist/utils/result-helpers.js +147 -0
  77. package/dist/utils/safe-json.d.ts +0 -2
  78. package/dist/utils/safe-json.js +0 -43
  79. package/dist/utils/validation.d.ts +16 -0
  80. package/dist/utils/validation.js +70 -7
  81. package/mcp-config-example.json +2 -2
  82. package/package.json +11 -10
  83. package/server.json +37 -14
  84. package/src/index.ts +146 -50
  85. package/src/prompts/index.ts +211 -13
  86. package/src/resources/actors.ts +59 -44
  87. package/src/resources/assets.ts +123 -102
  88. package/src/resources/levels.ts +37 -47
  89. package/src/tools/actors.ts +269 -313
  90. package/src/tools/animation.ts +556 -539
  91. package/src/tools/assets.ts +59 -45
  92. package/src/tools/audio.ts +507 -113
  93. package/src/tools/blueprint.ts +778 -462
  94. package/src/tools/build_environment_advanced.ts +312 -106
  95. package/src/tools/consolidated-tool-definitions.ts +136 -267
  96. package/src/tools/consolidated-tool-handlers.ts +871 -795
  97. package/src/tools/debug.ts +179 -38
  98. package/src/tools/editor.ts +35 -37
  99. package/src/tools/foliage.ts +110 -104
  100. package/src/tools/introspection.ts +24 -22
  101. package/src/tools/landscape.ts +334 -181
  102. package/src/tools/level.ts +683 -182
  103. package/src/tools/lighting.ts +244 -123
  104. package/src/tools/materials.ts +114 -83
  105. package/src/tools/niagara.ts +87 -81
  106. package/src/tools/performance.ts +49 -88
  107. package/src/tools/physics.ts +393 -299
  108. package/src/tools/rc.ts +103 -25
  109. package/src/tools/sequence.ts +157 -30
  110. package/src/tools/ui.ts +101 -70
  111. package/src/tools/visual.ts +250 -29
  112. package/src/types/tool-types.ts +0 -9
  113. package/src/unreal-bridge.ts +658 -140
  114. package/src/utils/elicitation.ts +129 -0
  115. package/src/utils/error-handler.ts +4 -159
  116. package/src/utils/http.ts +16 -115
  117. package/src/utils/normalize.ts +20 -10
  118. package/src/utils/python-output.ts +351 -0
  119. package/src/utils/python.ts +3 -0
  120. package/src/utils/response-validator.ts +68 -17
  121. package/src/utils/result-helpers.ts +193 -0
  122. package/src/utils/safe-json.ts +0 -50
  123. package/src/utils/validation.ts +94 -7
  124. package/tests/run-unreal-tool-tests.mjs +720 -0
  125. package/tsconfig.json +2 -2
  126. package/dist/python-utils.d.ts +0 -29
  127. package/dist/python-utils.js +0 -54
  128. package/dist/tools/tool-definitions.d.ts +0 -4919
  129. package/dist/tools/tool-definitions.js +0 -1065
  130. package/dist/tools/tool-handlers.d.ts +0 -47
  131. package/dist/tools/tool-handlers.js +0 -863
  132. package/dist/types/index.d.ts +0 -323
  133. package/dist/types/index.js +0 -28
  134. package/dist/utils/cache-manager.d.ts +0 -64
  135. package/dist/utils/cache-manager.js +0 -176
  136. package/dist/utils/errors.d.ts +0 -133
  137. package/dist/utils/errors.js +0 -256
  138. package/src/python/editor_compat.py +0 -181
  139. package/src/python-utils.ts +0 -57
  140. package/src/tools/tool-definitions.ts +0 -1081
  141. package/src/tools/tool-handlers.ts +0 -973
  142. package/src/types/index.ts +0 -414
  143. package/src/utils/cache-manager.ts +0 -213
  144. package/src/utils/errors.ts +0 -312
@@ -1,323 +0,0 @@
1
- /**
2
- * Comprehensive type definitions for Unreal Engine MCP Server
3
- */
4
- export * from './env.js';
5
- export * from './tool-types.js';
6
- export interface Vector3 {
7
- x: number;
8
- y: number;
9
- z: number;
10
- }
11
- export interface Rotation3 {
12
- pitch: number;
13
- yaw: number;
14
- roll: number;
15
- }
16
- export interface Transform {
17
- location: Vector3;
18
- rotation: Rotation3;
19
- scale?: Vector3;
20
- }
21
- export interface Color {
22
- r: number;
23
- g: number;
24
- b: number;
25
- a?: number;
26
- }
27
- export interface Asset {
28
- Name: string;
29
- Path: string;
30
- Class: string;
31
- PackagePath: string;
32
- Type?: string;
33
- Size?: number;
34
- LastModified?: Date;
35
- }
36
- export interface Material extends Asset {
37
- BaseColor?: Color;
38
- Metallic?: number;
39
- Roughness?: number;
40
- Emissive?: Color;
41
- }
42
- export interface Texture extends Asset {
43
- Width?: number;
44
- Height?: number;
45
- Format?: string;
46
- MipLevels?: number;
47
- }
48
- export interface Actor {
49
- Name: string;
50
- Class: string;
51
- Path: string;
52
- Transform?: Transform;
53
- Components?: Component[];
54
- Tags?: string[];
55
- IsSelected?: boolean;
56
- IsHidden?: boolean;
57
- }
58
- export interface Component {
59
- Name: string;
60
- Class: string;
61
- Properties?: Record<string, any>;
62
- }
63
- export interface Level {
64
- Name: string;
65
- Path: string;
66
- IsLoaded: boolean;
67
- IsVisible: boolean;
68
- Actors?: Actor[];
69
- StreamingLevels?: StreamingLevel[];
70
- }
71
- export interface StreamingLevel {
72
- Name: string;
73
- Path: string;
74
- LoadingState: 'Unloaded' | 'Loading' | 'Loaded';
75
- ShouldBeLoaded: boolean;
76
- ShouldBeVisible: boolean;
77
- }
78
- export interface Blueprint {
79
- Name: string;
80
- Path: string;
81
- ParentClass: string;
82
- Components?: BlueprintComponent[];
83
- Variables?: BlueprintVariable[];
84
- Functions?: BlueprintFunction[];
85
- }
86
- export interface BlueprintComponent {
87
- Name: string;
88
- Type: string;
89
- DefaultProperties?: Record<string, any>;
90
- }
91
- export interface BlueprintVariable {
92
- Name: string;
93
- Type: string;
94
- DefaultValue?: any;
95
- IsPublic?: boolean;
96
- Category?: string;
97
- }
98
- export interface BlueprintFunction {
99
- Name: string;
100
- ReturnType?: string;
101
- Parameters?: FunctionParameter[];
102
- IsPublic?: boolean;
103
- }
104
- export interface FunctionParameter {
105
- Name: string;
106
- Type: string;
107
- DefaultValue?: any;
108
- IsOptional?: boolean;
109
- }
110
- export interface AnimationSequence {
111
- Name: string;
112
- Path: string;
113
- Duration: number;
114
- FrameRate: number;
115
- Skeleton?: string;
116
- }
117
- export interface AnimationMontage {
118
- Name: string;
119
- Path: string;
120
- Sections?: MontageSection[];
121
- BlendIn?: number;
122
- BlendOut?: number;
123
- }
124
- export interface MontageSection {
125
- Name: string;
126
- StartTime: number;
127
- EndTime: number;
128
- NextSection?: string;
129
- }
130
- export interface PhysicsBody {
131
- Mass: number;
132
- LinearDamping: number;
133
- AngularDamping: number;
134
- EnableGravity: boolean;
135
- IsKinematic: boolean;
136
- CollisionEnabled: boolean;
137
- }
138
- export interface PhysicsConstraint {
139
- Name: string;
140
- Actor1: string;
141
- Actor2: string;
142
- LinearLimits?: Vector3;
143
- AngularLimits?: Vector3;
144
- }
145
- export interface NiagaraSystem {
146
- Name: string;
147
- Path: string;
148
- Emitters?: NiagaraEmitter[];
149
- Parameters?: NiagaraParameter[];
150
- }
151
- export interface NiagaraEmitter {
152
- Name: string;
153
- SpawnRate: number;
154
- Lifetime: number;
155
- VelocityModule?: Vector3;
156
- ColorModule?: Color;
157
- }
158
- export interface NiagaraParameter {
159
- Name: string;
160
- Type: string;
161
- Value: any;
162
- }
163
- export interface Landscape {
164
- Name: string;
165
- ComponentCount: number;
166
- Resolution: {
167
- x: number;
168
- y: number;
169
- };
170
- Scale: Vector3;
171
- Materials?: string[];
172
- Layers?: LandscapeLayer[];
173
- }
174
- export interface LandscapeLayer {
175
- Name: string;
176
- BlendMode: string;
177
- Weight: number;
178
- }
179
- export interface RemoteControlPreset {
180
- Name: string;
181
- Path: string;
182
- ExposedProperties?: ExposedProperty[];
183
- ExposedFunctions?: ExposedFunction[];
184
- }
185
- export interface ExposedProperty {
186
- Name: string;
187
- DisplayName?: string;
188
- ObjectPath: string;
189
- PropertyPath: string;
190
- Type: string;
191
- Value?: any;
192
- Metadata?: Record<string, any>;
193
- }
194
- export interface ExposedFunction {
195
- Name: string;
196
- DisplayName?: string;
197
- ObjectPath: string;
198
- FunctionName: string;
199
- Parameters?: FunctionParameter[];
200
- }
201
- export interface LevelSequence {
202
- Name: string;
203
- Path: string;
204
- Duration: number;
205
- FrameRate: number;
206
- Tracks?: SequencerTrack[];
207
- }
208
- export interface SequencerTrack {
209
- Name: string;
210
- Type: string;
211
- BoundObject?: string;
212
- Sections?: SequencerSection[];
213
- }
214
- export interface SequencerSection {
215
- StartFrame: number;
216
- EndFrame: number;
217
- Properties?: Record<string, any>;
218
- }
219
- export interface PerformanceMetrics {
220
- FPS: number;
221
- FrameTime: number;
222
- GameThreadTime: number;
223
- RenderThreadTime: number;
224
- GPUTime: number;
225
- DrawCalls: number;
226
- Triangles: number;
227
- Memory: MemoryMetrics;
228
- }
229
- export interface MemoryMetrics {
230
- Physical: number;
231
- Virtual: number;
232
- GPU: number;
233
- TextureMemory: number;
234
- MeshMemory: number;
235
- }
236
- export interface EngineVersion {
237
- Major: number;
238
- Minor: number;
239
- Patch: number;
240
- Build?: number;
241
- Branch?: string;
242
- Compatible?: boolean;
243
- }
244
- export interface ProjectInfo {
245
- Name: string;
246
- Path: string;
247
- EngineVersion: string;
248
- Plugins?: PluginInfo[];
249
- Settings?: ProjectSettings;
250
- }
251
- export interface PluginInfo {
252
- Name: string;
253
- Version: string;
254
- Enabled: boolean;
255
- Category?: string;
256
- }
257
- export interface ProjectSettings {
258
- DefaultMap?: string;
259
- DefaultGameMode?: string;
260
- TargetFrameRate?: number;
261
- EnableRayTracing?: boolean;
262
- EnableNanite?: boolean;
263
- }
264
- export interface SuccessResponse<T = any> {
265
- success: true;
266
- data?: T;
267
- message?: string;
268
- metadata?: Record<string, any>;
269
- }
270
- export interface ErrorResponse {
271
- success: false;
272
- error: string;
273
- code?: string;
274
- statusCode?: number;
275
- details?: Record<string, any>;
276
- }
277
- export type ApiResponse<T = any> = SuccessResponse<T> | ErrorResponse;
278
- export interface ToolContext {
279
- bridge: any;
280
- tools: Record<string, any>;
281
- cache?: any;
282
- metrics?: any;
283
- }
284
- export interface ToolResult<T = any> {
285
- content: Array<{
286
- type: 'text' | 'json' | 'error';
287
- text?: string;
288
- data?: T;
289
- }>;
290
- isError?: boolean;
291
- metadata?: Record<string, any>;
292
- }
293
- export interface UnrealEvent {
294
- type: string;
295
- timestamp: Date;
296
- data: any;
297
- source?: string;
298
- }
299
- export interface PropertyChangeEvent extends UnrealEvent {
300
- type: 'property_change';
301
- objectPath: string;
302
- propertyName: string;
303
- oldValue: any;
304
- newValue: any;
305
- }
306
- export interface ActorSpawnEvent extends UnrealEvent {
307
- type: 'actor_spawn';
308
- actorName: string;
309
- actorClass: string;
310
- location: Vector3;
311
- }
312
- export type DeepPartial<T> = {
313
- [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
314
- };
315
- export type Nullable<T> = T | null;
316
- export type Optional<T> = T | undefined;
317
- export type AsyncResult<T> = Promise<ApiResponse<T>>;
318
- export type Callback<T> = (error: Error | null, result?: T) => void;
319
- export declare function isVector3(value: any): value is Vector3;
320
- export declare function isRotation3(value: any): value is Rotation3;
321
- export declare function isSuccessResponse<T>(response: ApiResponse<T>): response is SuccessResponse<T>;
322
- export declare function isErrorResponse(response: ApiResponse): response is ErrorResponse;
323
- //# sourceMappingURL=index.d.ts.map
@@ -1,28 +0,0 @@
1
- /**
2
- * Comprehensive type definitions for Unreal Engine MCP Server
3
- */
4
- // Re-export existing types
5
- export * from './env.js';
6
- export * from './tool-types.js';
7
- // Type guards
8
- export function isVector3(value) {
9
- return (typeof value === 'object' &&
10
- value !== null &&
11
- typeof value.x === 'number' &&
12
- typeof value.y === 'number' &&
13
- typeof value.z === 'number');
14
- }
15
- export function isRotation3(value) {
16
- return (typeof value === 'object' &&
17
- value !== null &&
18
- typeof value.pitch === 'number' &&
19
- typeof value.yaw === 'number' &&
20
- typeof value.roll === 'number');
21
- }
22
- export function isSuccessResponse(response) {
23
- return response.success === true;
24
- }
25
- export function isErrorResponse(response) {
26
- return response.success === false;
27
- }
28
- //# sourceMappingURL=index.js.map
@@ -1,64 +0,0 @@
1
- /**
2
- * Cache Manager for API responses
3
- * Implements LRU cache with TTL support for optimizing repeated API calls
4
- */
5
- interface CacheOptions {
6
- maxSize?: number;
7
- defaultTTL?: number;
8
- enableMetrics?: boolean;
9
- }
10
- interface CacheMetrics {
11
- hits: number;
12
- misses: number;
13
- evictions: number;
14
- size: number;
15
- }
16
- export declare class CacheManager<T = any> {
17
- private cache;
18
- private readonly maxSize;
19
- private readonly defaultTTL;
20
- private readonly enableMetrics;
21
- private metrics;
22
- constructor(options?: CacheOptions);
23
- /**
24
- * Get item from cache
25
- */
26
- get(key: string): T | null;
27
- /**
28
- * Set item in cache
29
- */
30
- set(key: string, data: T): void;
31
- /**
32
- * Check if key exists and is valid
33
- */
34
- has(key: string): boolean;
35
- /**
36
- * Clear specific key or all cache
37
- */
38
- clear(key?: string): void;
39
- /**
40
- * Get cache metrics
41
- */
42
- getMetrics(): CacheMetrics;
43
- /**
44
- * Get cache hit rate
45
- */
46
- getHitRate(): number;
47
- /**
48
- * Wrap async function with cache
49
- */
50
- wrap<R = T>(key: string, fn: () => Promise<R>): Promise<R>;
51
- /**
52
- * Batch get multiple keys
53
- */
54
- getBatch(keys: string[]): Map<string, T | null>;
55
- /**
56
- * Invalidate cache entries by pattern
57
- */
58
- invalidatePattern(pattern: RegExp): number;
59
- }
60
- export declare const assetCache: CacheManager<any>;
61
- export declare const engineCache: CacheManager<any>;
62
- export declare const commandCache: CacheManager<any>;
63
- export {};
64
- //# sourceMappingURL=cache-manager.d.ts.map
@@ -1,176 +0,0 @@
1
- /**
2
- * Cache Manager for API responses
3
- * Implements LRU cache with TTL support for optimizing repeated API calls
4
- */
5
- export class CacheManager {
6
- cache;
7
- maxSize;
8
- defaultTTL;
9
- enableMetrics;
10
- metrics;
11
- constructor(options = {}) {
12
- this.cache = new Map();
13
- this.maxSize = options.maxSize || 100;
14
- this.defaultTTL = options.defaultTTL || 60000; // 1 minute default
15
- this.enableMetrics = options.enableMetrics || false;
16
- this.metrics = {
17
- hits: 0,
18
- misses: 0,
19
- evictions: 0,
20
- size: 0
21
- };
22
- }
23
- /**
24
- * Get item from cache
25
- */
26
- get(key) {
27
- const entry = this.cache.get(key);
28
- if (!entry) {
29
- if (this.enableMetrics)
30
- this.metrics.misses++;
31
- return null;
32
- }
33
- // Check if expired
34
- if (Date.now() - entry.timestamp > this.defaultTTL) {
35
- this.cache.delete(key);
36
- if (this.enableMetrics) {
37
- this.metrics.misses++;
38
- this.metrics.size--;
39
- }
40
- return null;
41
- }
42
- // Update hit count and move to end (LRU)
43
- entry.hits++;
44
- this.cache.delete(key);
45
- this.cache.set(key, entry);
46
- if (this.enableMetrics)
47
- this.metrics.hits++;
48
- return entry.data;
49
- }
50
- /**
51
- * Set item in cache
52
- */
53
- set(key, data) {
54
- // Evict oldest if at max size
55
- if (this.cache.size >= this.maxSize && !this.cache.has(key)) {
56
- const firstKey = this.cache.keys().next().value;
57
- if (firstKey) {
58
- this.cache.delete(firstKey);
59
- if (this.enableMetrics) {
60
- this.metrics.evictions++;
61
- this.metrics.size--;
62
- }
63
- }
64
- }
65
- const entry = {
66
- data,
67
- timestamp: Date.now(),
68
- hits: 0
69
- };
70
- this.cache.set(key, entry);
71
- if (this.enableMetrics)
72
- this.metrics.size = this.cache.size;
73
- }
74
- /**
75
- * Check if key exists and is valid
76
- */
77
- has(key) {
78
- const entry = this.cache.get(key);
79
- if (!entry)
80
- return false;
81
- // Check expiration
82
- if (Date.now() - entry.timestamp > this.defaultTTL) {
83
- this.cache.delete(key);
84
- if (this.enableMetrics)
85
- this.metrics.size--;
86
- return false;
87
- }
88
- return true;
89
- }
90
- /**
91
- * Clear specific key or all cache
92
- */
93
- clear(key) {
94
- if (key) {
95
- this.cache.delete(key);
96
- if (this.enableMetrics)
97
- this.metrics.size = this.cache.size;
98
- }
99
- else {
100
- this.cache.clear();
101
- if (this.enableMetrics) {
102
- this.metrics.size = 0;
103
- }
104
- }
105
- }
106
- /**
107
- * Get cache metrics
108
- */
109
- getMetrics() {
110
- return { ...this.metrics };
111
- }
112
- /**
113
- * Get cache hit rate
114
- */
115
- getHitRate() {
116
- const total = this.metrics.hits + this.metrics.misses;
117
- return total > 0 ? this.metrics.hits / total : 0;
118
- }
119
- /**
120
- * Wrap async function with cache
121
- */
122
- async wrap(key, fn) {
123
- // Check cache first
124
- const cached = this.get(key);
125
- if (cached !== null) {
126
- return cached;
127
- }
128
- // Execute function and cache result
129
- const result = await fn();
130
- this.set(key, result);
131
- return result;
132
- }
133
- /**
134
- * Batch get multiple keys
135
- */
136
- getBatch(keys) {
137
- const results = new Map();
138
- for (const key of keys) {
139
- results.set(key, this.get(key));
140
- }
141
- return results;
142
- }
143
- /**
144
- * Invalidate cache entries by pattern
145
- */
146
- invalidatePattern(pattern) {
147
- let count = 0;
148
- for (const key of this.cache.keys()) {
149
- if (pattern.test(key)) {
150
- this.cache.delete(key);
151
- count++;
152
- }
153
- }
154
- if (this.enableMetrics) {
155
- this.metrics.size = this.cache.size;
156
- }
157
- return count;
158
- }
159
- }
160
- // Global cache instances for different purposes
161
- export const assetCache = new CacheManager({
162
- maxSize: 500,
163
- defaultTTL: 300000, // 5 minutes for assets
164
- enableMetrics: true
165
- });
166
- export const engineCache = new CacheManager({
167
- maxSize: 50,
168
- defaultTTL: 600000, // 10 minutes for engine info
169
- enableMetrics: true
170
- });
171
- export const commandCache = new CacheManager({
172
- maxSize: 100,
173
- defaultTTL: 30000, // 30 seconds for commands
174
- enableMetrics: true
175
- });
176
- //# sourceMappingURL=cache-manager.js.map
@@ -1,133 +0,0 @@
1
- /**
2
- * Enhanced error types for better error handling and recovery
3
- */
4
- export declare enum ErrorCode {
5
- CONNECTION_FAILED = "CONNECTION_FAILED",
6
- CONNECTION_TIMEOUT = "CONNECTION_TIMEOUT",
7
- CONNECTION_REFUSED = "CONNECTION_REFUSED",
8
- API_ERROR = "API_ERROR",
9
- INVALID_RESPONSE = "INVALID_RESPONSE",
10
- RATE_LIMITED = "RATE_LIMITED",
11
- VALIDATION_ERROR = "VALIDATION_ERROR",
12
- INVALID_PARAMETERS = "INVALID_PARAMETERS",
13
- MISSING_REQUIRED_FIELD = "MISSING_REQUIRED_FIELD",
14
- RESOURCE_NOT_FOUND = "RESOURCE_NOT_FOUND",
15
- RESOURCE_LOCKED = "RESOURCE_LOCKED",
16
- RESOURCE_UNAVAILABLE = "RESOURCE_UNAVAILABLE",
17
- UNAUTHORIZED = "UNAUTHORIZED",
18
- FORBIDDEN = "FORBIDDEN",
19
- INTERNAL_ERROR = "INTERNAL_ERROR",
20
- CIRCUIT_BREAKER_OPEN = "CIRCUIT_BREAKER_OPEN",
21
- SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE"
22
- }
23
- export interface ErrorMetadata {
24
- code: ErrorCode;
25
- statusCode?: number;
26
- retriable: boolean;
27
- context?: Record<string, any>;
28
- timestamp: Date;
29
- correlationId?: string;
30
- }
31
- /**
32
- * Base application error with metadata
33
- */
34
- export declare class AppError extends Error {
35
- readonly metadata: ErrorMetadata;
36
- constructor(message: string, metadata?: Partial<ErrorMetadata>);
37
- toJSON(): {
38
- stack: string | undefined;
39
- code: ErrorCode;
40
- statusCode?: number;
41
- retriable: boolean;
42
- context?: Record<string, any>;
43
- timestamp: Date;
44
- correlationId?: string;
45
- name: string;
46
- message: string;
47
- };
48
- }
49
- /**
50
- * Connection-related errors
51
- */
52
- export declare class ConnectionError extends AppError {
53
- constructor(message: string, metadata?: Partial<ErrorMetadata>);
54
- }
55
- /**
56
- * API-related errors
57
- */
58
- export declare class ApiError extends AppError {
59
- constructor(message: string, statusCode: number, metadata?: Partial<ErrorMetadata>);
60
- }
61
- /**
62
- * Validation errors
63
- */
64
- export declare class ValidationError extends AppError {
65
- constructor(message: string, metadata?: Partial<ErrorMetadata>);
66
- }
67
- /**
68
- * Resource errors
69
- */
70
- export declare class ResourceError extends AppError {
71
- constructor(message: string, code: ErrorCode, metadata?: Partial<ErrorMetadata>);
72
- }
73
- /**
74
- * Circuit Breaker implementation for fault tolerance
75
- */
76
- export declare enum CircuitState {
77
- CLOSED = "CLOSED",
78
- OPEN = "OPEN",
79
- HALF_OPEN = "HALF_OPEN"
80
- }
81
- interface CircuitBreakerOptions {
82
- threshold: number;
83
- timeout: number;
84
- resetTimeout: number;
85
- onStateChange?: (oldState: CircuitState, newState: CircuitState) => void;
86
- }
87
- export declare class CircuitBreaker {
88
- private state;
89
- private failures;
90
- private successCount;
91
- private lastFailureTime?;
92
- private readonly options;
93
- constructor(options?: Partial<CircuitBreakerOptions>);
94
- /**
95
- * Execute function with circuit breaker protection
96
- */
97
- execute<T>(fn: () => Promise<T>): Promise<T>;
98
- private onSuccess;
99
- private onFailure;
100
- private shouldAttemptReset;
101
- private transitionTo;
102
- getState(): CircuitState;
103
- getMetrics(): {
104
- state: CircuitState;
105
- failures: number;
106
- successCount: number;
107
- lastFailureTime: Date | undefined;
108
- };
109
- }
110
- /**
111
- * Error recovery strategies
112
- */
113
- export declare class ErrorRecovery {
114
- private static circuitBreakers;
115
- /**
116
- * Get or create circuit breaker for a service
117
- */
118
- static getCircuitBreaker(service: string, options?: Partial<CircuitBreakerOptions>): CircuitBreaker;
119
- /**
120
- * Wrap function with error recovery
121
- */
122
- static withRecovery<T>(fn: () => Promise<T>, options: {
123
- service: string;
124
- fallback?: () => T | Promise<T>;
125
- onError?: (error: Error) => void;
126
- }): Promise<T>;
127
- /**
128
- * Check if error is retriable
129
- */
130
- static isRetriable(error: Error): boolean;
131
- }
132
- export {};
133
- //# sourceMappingURL=errors.d.ts.map