sub-agents-mcp 0.5.2 → 0.5.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 (35) hide show
  1. package/README.md +12 -0
  2. package/dist/index.js +0 -0
  3. package/package.json +1 -1
  4. package/dist/execution/ExecutionLimits.d.ts +0 -141
  5. package/dist/execution/ExecutionLimits.d.ts.map +0 -1
  6. package/dist/execution/ExecutionLimits.js +0 -231
  7. package/dist/execution/ExecutionLimits.js.map +0 -1
  8. package/dist/execution/McpRequestTimeout.d.ts +0 -166
  9. package/dist/execution/McpRequestTimeout.d.ts.map +0 -1
  10. package/dist/execution/McpRequestTimeout.js +0 -278
  11. package/dist/execution/McpRequestTimeout.js.map +0 -1
  12. package/dist/execution/PromptController.d.ts +0 -92
  13. package/dist/execution/PromptController.d.ts.map +0 -1
  14. package/dist/execution/PromptController.js +0 -130
  15. package/dist/execution/PromptController.js.map +0 -1
  16. package/dist/execution/TimeoutManager.d.ts +0 -159
  17. package/dist/execution/TimeoutManager.d.ts.map +0 -1
  18. package/dist/execution/TimeoutManager.js +0 -283
  19. package/dist/execution/TimeoutManager.js.map +0 -1
  20. package/dist/session/ToonConverter.d.ts +0 -172
  21. package/dist/session/ToonConverter.d.ts.map +0 -1
  22. package/dist/session/ToonConverter.js +0 -593
  23. package/dist/session/ToonConverter.js.map +0 -1
  24. package/dist/session/ToonUtils.d.ts +0 -23
  25. package/dist/session/ToonUtils.d.ts.map +0 -1
  26. package/dist/session/ToonUtils.js +0 -75
  27. package/dist/session/ToonUtils.js.map +0 -1
  28. package/dist/types/ServerConfig.d.ts +0 -39
  29. package/dist/types/ServerConfig.d.ts.map +0 -1
  30. package/dist/types/ServerConfig.js +0 -3
  31. package/dist/types/ServerConfig.js.map +0 -1
  32. package/dist/types/index.d.ts +0 -19
  33. package/dist/types/index.d.ts.map +0 -1
  34. package/dist/types/index.js +0 -3
  35. package/dist/types/index.js.map +0 -1
package/README.md CHANGED
@@ -18,6 +18,18 @@ Claude Code offers powerful sub-agent workflows—but they're limited to its own
18
18
 
19
19
  → [Read the full story](https://dev.to/shinpr/bringing-claude-codes-sub-agents-to-any-mcp-compatible-tool-1hb9)
20
20
 
21
+ ## Alternative: Agent Skills
22
+
23
+ [sub-agents-skills](https://github.com/shinpr/sub-agents-skills) offers a lightweight alternative.
24
+
25
+ | | sub-agents-mcp | sub-agents-skills |
26
+ |---|---|---|
27
+ | **Setup** | MCP configuration required | Copy skill files to your environment |
28
+ | **Features** | Session management, error handling | Minimal |
29
+ | **Stability** | More robust | Lightweight |
30
+
31
+ Choose **sub-agents-mcp** for production use with reliability features. Choose **sub-agents-skills** for quick setup in Skill-compatible environments.
32
+
21
33
  ## Table of Contents
22
34
 
23
35
  - [Prerequisites](#prerequisites)
package/dist/index.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sub-agents-mcp",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "mcpName": "io.github.shinpr/sub-agents-mcp",
5
5
  "description": "MCP server for delegating tasks to specialized AI assistants in Cursor and other tools",
6
6
  "main": "dist/index.js",
@@ -1,141 +0,0 @@
1
- /**
2
- * Execution limits configuration and enforcement for agent execution.
3
- *
4
- * Provides configurable limits for resource usage including memory, concurrency,
5
- * execution time, and output size to ensure system stability and prevent abuse.
6
- */
7
- /**
8
- * Configuration interface for execution limits.
9
- */
10
- export interface ExecutionLimitsConfig {
11
- /** Maximum number of concurrent agent executions (default: 5) */
12
- maxConcurrentExecutions: number;
13
- /** Maximum memory usage per execution in MB (default: 100) */
14
- maxMemoryUsageMB: number;
15
- /** Maximum output size in bytes (default: 1MB) */
16
- maxOutputSizeBytes: number;
17
- /** Maximum execution time in milliseconds (default: 90000) */
18
- maxExecutionTimeMs: number;
19
- /** Enable resource monitoring (default: true) */
20
- enableResourceMonitoring: boolean;
21
- }
22
- /**
23
- * Resource usage statistics for monitoring.
24
- */
25
- export interface ResourceUsage {
26
- /** Current memory usage in MB */
27
- memoryUsageMB: number;
28
- /** Current number of active executions */
29
- activeExecutions: number;
30
- /** Current output size in bytes */
31
- outputSizeBytes: number;
32
- /** Execution time elapsed in milliseconds */
33
- executionTimeMs: number;
34
- }
35
- /**
36
- * Default execution limits configuration.
37
- */
38
- export declare const DEFAULT_EXECUTION_LIMITS: ExecutionLimitsConfig;
39
- /**
40
- * Execution limits enforcer for resource constraint management.
41
- *
42
- * Monitors and enforces limits on concurrent executions, memory usage,
43
- * output size, and execution time to prevent resource exhaustion.
44
- */
45
- export declare class ExecutionLimits {
46
- private readonly config;
47
- private activeExecutions;
48
- /**
49
- * Creates a new ExecutionLimits instance.
50
- *
51
- * @param config - Execution limits configuration (uses defaults if not provided)
52
- */
53
- constructor(config?: Partial<ExecutionLimitsConfig>);
54
- /**
55
- * Checks if a new execution can be started within limits.
56
- *
57
- * @param executionId - Unique identifier for the execution
58
- * @throws {ResourceLimitError} When concurrent execution limit is exceeded
59
- */
60
- checkConcurrencyLimit(executionId: string): void;
61
- /**
62
- * Registers a new execution as active.
63
- *
64
- * @param executionId - Unique identifier for the execution
65
- */
66
- registerExecution(executionId: string): void;
67
- /**
68
- * Unregisters an execution as completed.
69
- *
70
- * @param executionId - Unique identifier for the execution
71
- */
72
- unregisterExecution(executionId: string): void;
73
- /**
74
- * Checks if memory usage is within limits.
75
- *
76
- * @param memoryUsageMB - Current memory usage in MB
77
- * @throws {ResourceLimitError} When memory limit is exceeded
78
- */
79
- checkMemoryLimit(memoryUsageMB: number): void;
80
- /**
81
- * Checks if output size is within limits.
82
- *
83
- * @param outputSizeBytes - Current output size in bytes
84
- * @throws {ResourceLimitError} When output size limit is exceeded
85
- */
86
- checkOutputSizeLimit(outputSizeBytes: number): void;
87
- /**
88
- * Gets current resource usage statistics.
89
- *
90
- * @param currentMemoryMB - Current memory usage in MB
91
- * @param currentOutputBytes - Current output size in bytes
92
- * @param executionTimeMs - Current execution time in milliseconds
93
- * @returns Resource usage statistics
94
- */
95
- getResourceUsage(currentMemoryMB?: number, currentOutputBytes?: number, executionTimeMs?: number): ResourceUsage;
96
- /**
97
- * Gets the current configuration.
98
- *
99
- * @returns Execution limits configuration
100
- */
101
- getConfig(): ExecutionLimitsConfig;
102
- /**
103
- * Gets the number of active executions.
104
- *
105
- * @returns Number of active executions
106
- */
107
- getActiveExecutionCount(): number;
108
- /**
109
- * Checks if resource monitoring is enabled.
110
- *
111
- * @returns True if resource monitoring is enabled
112
- */
113
- isResourceMonitoringEnabled(): boolean;
114
- /**
115
- * Gets adaptive resource limits based on current system state.
116
- *
117
- * @param systemMemoryMB - Current available system memory in MB
118
- * @param systemLoad - Current system load (0-1)
119
- * @returns Adjusted execution limits configuration
120
- */
121
- getAdaptiveLimits(systemMemoryMB: number, systemLoad?: number): ExecutionLimitsConfig;
122
- /**
123
- * Monitors resource usage and suggests optimizations.
124
- *
125
- * @param currentUsage - Current resource usage
126
- * @returns Resource optimization suggestions
127
- */
128
- analyzeResourceUsage(currentUsage: ResourceUsage): {
129
- recommendations: string[];
130
- severity: 'low' | 'medium' | 'high';
131
- shouldThrottle: boolean;
132
- };
133
- /**
134
- * Creates execution limits optimized for specific operation types.
135
- *
136
- * @param operationType - Type of operation (light, standard, heavy)
137
- * @returns Optimized execution limits configuration
138
- */
139
- createOptimizedConfig(operationType: 'light' | 'standard' | 'heavy'): ExecutionLimitsConfig;
140
- }
141
- //# sourceMappingURL=ExecutionLimits.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExecutionLimits.d.ts","sourceRoot":"","sources":["../../src/execution/ExecutionLimits.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,iEAAiE;IACjE,uBAAuB,EAAE,MAAM,CAAA;IAE/B,8DAA8D;IAC9D,gBAAgB,EAAE,MAAM,CAAA;IAExB,kDAAkD;IAClD,kBAAkB,EAAE,MAAM,CAAA;IAE1B,8DAA8D;IAC9D,kBAAkB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AAa,GAAG;QACjD,eAAe,EAAE,MAAM,EAAE,CAAA;QACzB,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAA;QACnC,cAAc,EAAE,OAAO,CAAA;KACxB;IAmDD;;;;;OAKG;IACH,qBAAqB,CAAC,aAAa,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,GAAG,qBAAqB;CA0B5F"}
@@ -1,231 +0,0 @@
1
- "use strict";
2
- /**
3
- * Execution limits configuration and enforcement for agent execution.
4
- *
5
- * Provides configurable limits for resource usage including memory, concurrency,
6
- * execution time, and output size to ensure system stability and prevent abuse.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.ExecutionLimits = exports.DEFAULT_EXECUTION_LIMITS = void 0;
10
- const ErrorHandler_1 = require("../utils/ErrorHandler");
11
- /**
12
- * Default execution limits configuration.
13
- */
14
- exports.DEFAULT_EXECUTION_LIMITS = {
15
- maxConcurrentExecutions: 5,
16
- maxMemoryUsageMB: 100,
17
- maxOutputSizeBytes: 1024 * 1024, // 1MB
18
- maxExecutionTimeMs: 90000, // 90 seconds
19
- enableResourceMonitoring: true,
20
- };
21
- /**
22
- * Execution limits enforcer for resource constraint management.
23
- *
24
- * Monitors and enforces limits on concurrent executions, memory usage,
25
- * output size, and execution time to prevent resource exhaustion.
26
- */
27
- class ExecutionLimits {
28
- /**
29
- * Creates a new ExecutionLimits instance.
30
- *
31
- * @param config - Execution limits configuration (uses defaults if not provided)
32
- */
33
- constructor(config = {}) {
34
- this.activeExecutions = new Set();
35
- this.config = { ...exports.DEFAULT_EXECUTION_LIMITS, ...config };
36
- }
37
- /**
38
- * Checks if a new execution can be started within limits.
39
- *
40
- * @param executionId - Unique identifier for the execution
41
- * @throws {ResourceLimitError} When concurrent execution limit is exceeded
42
- */
43
- checkConcurrencyLimit(executionId) {
44
- if (this.activeExecutions.size >= this.config.maxConcurrentExecutions) {
45
- throw new ErrorHandler_1.ResourceLimitError(`Maximum concurrent executions exceeded: ${this.config.maxConcurrentExecutions}`, 'CONCURRENCY_LIMIT_EXCEEDED', 'concurrency', this.config.maxConcurrentExecutions, {
46
- operation: 'concurrency_check',
47
- metadata: { executionId, currentCount: this.activeExecutions.size },
48
- });
49
- }
50
- }
51
- /**
52
- * Registers a new execution as active.
53
- *
54
- * @param executionId - Unique identifier for the execution
55
- */
56
- registerExecution(executionId) {
57
- this.checkConcurrencyLimit(executionId);
58
- this.activeExecutions.add(executionId);
59
- }
60
- /**
61
- * Unregisters an execution as completed.
62
- *
63
- * @param executionId - Unique identifier for the execution
64
- */
65
- unregisterExecution(executionId) {
66
- this.activeExecutions.delete(executionId);
67
- }
68
- /**
69
- * Checks if memory usage is within limits.
70
- *
71
- * @param memoryUsageMB - Current memory usage in MB
72
- * @throws {ResourceLimitError} When memory limit is exceeded
73
- */
74
- checkMemoryLimit(memoryUsageMB) {
75
- if (memoryUsageMB > this.config.maxMemoryUsageMB) {
76
- throw new ErrorHandler_1.ResourceLimitError(`Memory usage exceeded: ${memoryUsageMB}MB > ${this.config.maxMemoryUsageMB}MB`, 'MEMORY_LIMIT_EXCEEDED', 'memory', this.config.maxMemoryUsageMB);
77
- }
78
- }
79
- /**
80
- * Checks if output size is within limits.
81
- *
82
- * @param outputSizeBytes - Current output size in bytes
83
- * @throws {ResourceLimitError} When output size limit is exceeded
84
- */
85
- checkOutputSizeLimit(outputSizeBytes) {
86
- if (outputSizeBytes > this.config.maxOutputSizeBytes) {
87
- throw new ErrorHandler_1.ResourceLimitError(`Output size exceeded: ${outputSizeBytes} bytes > ${this.config.maxOutputSizeBytes} bytes`, 'OUTPUT_SIZE_LIMIT_EXCEEDED', 'output_size', this.config.maxOutputSizeBytes);
88
- }
89
- }
90
- /**
91
- * Gets current resource usage statistics.
92
- *
93
- * @param currentMemoryMB - Current memory usage in MB
94
- * @param currentOutputBytes - Current output size in bytes
95
- * @param executionTimeMs - Current execution time in milliseconds
96
- * @returns Resource usage statistics
97
- */
98
- getResourceUsage(currentMemoryMB = 0, currentOutputBytes = 0, executionTimeMs = 0) {
99
- return {
100
- memoryUsageMB: currentMemoryMB,
101
- activeExecutions: this.activeExecutions.size,
102
- outputSizeBytes: currentOutputBytes,
103
- executionTimeMs,
104
- };
105
- }
106
- /**
107
- * Gets the current configuration.
108
- *
109
- * @returns Execution limits configuration
110
- */
111
- getConfig() {
112
- return { ...this.config };
113
- }
114
- /**
115
- * Gets the number of active executions.
116
- *
117
- * @returns Number of active executions
118
- */
119
- getActiveExecutionCount() {
120
- return this.activeExecutions.size;
121
- }
122
- /**
123
- * Checks if resource monitoring is enabled.
124
- *
125
- * @returns True if resource monitoring is enabled
126
- */
127
- isResourceMonitoringEnabled() {
128
- return this.config.enableResourceMonitoring;
129
- }
130
- /**
131
- * Gets adaptive resource limits based on current system state.
132
- *
133
- * @param systemMemoryMB - Current available system memory in MB
134
- * @param systemLoad - Current system load (0-1)
135
- * @returns Adjusted execution limits configuration
136
- */
137
- getAdaptiveLimits(systemMemoryMB, systemLoad = 0.5) {
138
- const baseLimits = this.getConfig();
139
- // Adjust limits based on available system resources
140
- const memoryMultiplier = Math.min(systemMemoryMB / 1000, 2); // Scale up to 2x for high memory systems
141
- const loadMultiplier = Math.max(1 - systemLoad, 0.3); // Reduce limits under high load
142
- return {
143
- ...baseLimits,
144
- maxConcurrentExecutions: Math.max(Math.floor(baseLimits.maxConcurrentExecutions * loadMultiplier), 1),
145
- maxMemoryUsageMB: Math.floor(baseLimits.maxMemoryUsageMB * memoryMultiplier),
146
- maxExecutionTimeMs: systemLoad > 0.8
147
- ? Math.floor(baseLimits.maxExecutionTimeMs * 1.5) // More time under high load
148
- : baseLimits.maxExecutionTimeMs,
149
- };
150
- }
151
- /**
152
- * Monitors resource usage and suggests optimizations.
153
- *
154
- * @param currentUsage - Current resource usage
155
- * @returns Resource optimization suggestions
156
- */
157
- analyzeResourceUsage(currentUsage) {
158
- const config = this.getConfig();
159
- const recommendations = [];
160
- let severity = 'low';
161
- let shouldThrottle = false;
162
- // Analyze concurrency
163
- const concurrencyUtilization = currentUsage.activeExecutions / config.maxConcurrentExecutions;
164
- if (concurrencyUtilization > 0.8) {
165
- recommendations.push('High concurrency utilization detected - consider queuing new requests');
166
- severity = 'medium';
167
- shouldThrottle = true;
168
- }
169
- // Analyze memory usage
170
- const memoryUtilization = currentUsage.memoryUsageMB / config.maxMemoryUsageMB;
171
- if (memoryUtilization > 0.9) {
172
- recommendations.push('Memory usage approaching limit - consider reducing concurrent executions');
173
- severity = 'high';
174
- shouldThrottle = true;
175
- }
176
- else if (memoryUtilization > 0.7) {
177
- recommendations.push('Memory usage elevated - monitor closely');
178
- if (severity === 'low')
179
- severity = 'medium';
180
- }
181
- // Analyze output size trends
182
- const outputUtilization = currentUsage.outputSizeBytes / config.maxOutputSizeBytes;
183
- if (outputUtilization > 0.8) {
184
- recommendations.push('Output size approaching limit - consider using spawn method for large outputs');
185
- if (severity === 'low')
186
- severity = 'medium';
187
- }
188
- // Analyze execution time
189
- if (currentUsage.executionTimeMs > config.maxExecutionTimeMs * 0.8) {
190
- recommendations.push('Execution time approaching timeout - consider optimizing agent performance');
191
- if (severity === 'low')
192
- severity = 'medium';
193
- }
194
- return {
195
- recommendations,
196
- severity,
197
- shouldThrottle,
198
- };
199
- }
200
- /**
201
- * Creates execution limits optimized for specific operation types.
202
- *
203
- * @param operationType - Type of operation (light, standard, heavy)
204
- * @returns Optimized execution limits configuration
205
- */
206
- createOptimizedConfig(operationType) {
207
- const baseLimits = exports.DEFAULT_EXECUTION_LIMITS;
208
- switch (operationType) {
209
- case 'light':
210
- return {
211
- ...baseLimits,
212
- maxConcurrentExecutions: baseLimits.maxConcurrentExecutions * 2,
213
- maxMemoryUsageMB: baseLimits.maxMemoryUsageMB * 0.5,
214
- maxExecutionTimeMs: baseLimits.maxExecutionTimeMs * 0.5,
215
- maxOutputSizeBytes: baseLimits.maxOutputSizeBytes * 0.5,
216
- };
217
- case 'heavy':
218
- return {
219
- ...baseLimits,
220
- maxConcurrentExecutions: Math.max(baseLimits.maxConcurrentExecutions * 0.5, 1),
221
- maxMemoryUsageMB: baseLimits.maxMemoryUsageMB * 2,
222
- maxExecutionTimeMs: baseLimits.maxExecutionTimeMs * 2,
223
- maxOutputSizeBytes: baseLimits.maxOutputSizeBytes * 2,
224
- };
225
- default: // standard
226
- return baseLimits;
227
- }
228
- }
229
- }
230
- exports.ExecutionLimits = ExecutionLimits;
231
- //# sourceMappingURL=ExecutionLimits.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExecutionLimits.js","sourceRoot":"","sources":["../../src/execution/ExecutionLimits.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,yDAA2D;AAuC3D;;GAEG;AACU,QAAA,wBAAwB,GAA0B;IAC7D,uBAAuB,EAAE,CAAC;IAC1B,gBAAgB,EAAE,GAAG;IACrB,kBAAkB,EAAE,IAAI,GAAG,IAAI,EAAE,MAAM;IACvC,kBAAkB,EAAE,KAAK,EAAE,aAAa;IACxC,wBAAwB,EAAE,IAAI;CAC/B,CAAA;AAED;;;;;GAKG;AACH,MAAa,eAAe;IAI1B;;;;OAIG;IACH,YAAY,SAAyC,EAAE;QAP/C,qBAAgB,GAAgB,IAAI,GAAG,EAAE,CAAA;QAQ/C,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,gCAAwB,EAAE,GAAG,MAAM,EAAE,CAAA;IAC1D,CAAC;IAED;;;;;OAKG;IACH,qBAAqB,CAAC,WAAmB;QACvC,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,uBAAuB,EAAE,CAAC;YACtE,MAAM,IAAI,iCAAkB,CAC1B,2CAA2C,IAAI,CAAC,MAAM,CAAC,uBAAuB,EAAE,EAChF,4BAA4B,EAC5B,aAAa,EACb,IAAI,CAAC,MAAM,CAAC,uBAAuB,EACnC;gBACE,SAAS,EAAE,mBAAmB;gBAC9B,QAAQ,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,CA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eAAe;YACf,QAAQ;YACR,cAAc;SACf,CAAA;IACH,CAAC;IAED;;;;;OAKG;IACH,qBAAqB,CAAC,aAA6C;QACjE,MAAM,UAAU,GAAG,gCAAwB,CAAA;QAE3C,QAAQ,aAAa,EAAE,CAAC;YACtB,KAAK,OAAO;gBACV,OAAO;oBACL,GAAG,UAAU;oBACb,uBAAuB,EAAE,UAAU,CAAC,uBAAuB,GAAG,CAAC;oBAC/D,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,GAAG,GAAG;oBACnD,kBAAkB,EAAE,UAAU,CAAC,kBAAkB,GAAG,GAAG;oBACvD,kBAAkB,EAAE,UAAU,CAAC,kBAAkB,GAAG,GAAG;iBACxD,CAAA;YAEH,KAAK,OAAO;gBACV,OAAO;oBACL,GAAG,UAAU;oBACb,uBAAuB,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,uBAAuB,GAAG,GAAG,EAAE,CAAC,CAAC;oBAC9E,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,GAAG,CAAC;oBACjD,kBAAkB,EAAE,UAAU,CAAC,kBAAkB,GAAG,CAAC;oBACrD,kBAAkB,EAAE,UAAU,CAAC,kBAAkB,GAAG,CAAC;iBACtD,CAAA;YAEH,SAAS,WAAW;gBAClB,OAAO,UAAU,CAAA;QACrB,CAAC;IACH,CAAC;CACF;AAhQD,0CAgQC"}
@@ -1,166 +0,0 @@
1
- import { Logger } from '../utils/Logger';
2
- /**
3
- * Configuration for MCP request timeout management
4
- * Following MCP specification recommendations for handling long-running LLM operations
5
- */
6
- export interface McpTimeoutConfig {
7
- /**
8
- * Default timeout for MCP requests in milliseconds
9
- * Considering LLM processing characteristics, set to 2 minutes by default
10
- */
11
- defaultTimeoutMs: number;
12
- /**
13
- * Maximum absolute timeout in milliseconds
14
- * Prevents infinite waiting even with progress updates (5 minutes by default)
15
- */
16
- maxTimeoutMs: number;
17
- /**
18
- * Whether to reset timeout when progress notification is received
19
- * Recommended by MCP specification for long-running operations
20
- */
21
- progressResetEnabled: boolean;
22
- /**
23
- * Warning threshold in milliseconds
24
- * Sends progress notification to improve UX (1 minute by default)
25
- */
26
- warningThresholdMs: number;
27
- /**
28
- * Enable debug logging for timeout operations
29
- */
30
- enableDebugLogging: boolean;
31
- }
32
- /**
33
- * Default timeout configuration for MCP requests
34
- * Based on MCP best practices and LLM operation characteristics
35
- */
36
- export declare const DEFAULT_MCP_TIMEOUT_CONFIG: McpTimeoutConfig;
37
- /**
38
- * Progress notification data for MCP requests
39
- */
40
- export interface ProgressNotification {
41
- requestId: string;
42
- message: string;
43
- percentage?: number;
44
- timestamp: number;
45
- }
46
- /**
47
- * Timeout context for tracking request execution
48
- */
49
- export interface TimeoutContext {
50
- requestId: string;
51
- startTime: number;
52
- currentTimeout: NodeJS.Timeout | null;
53
- warningTimeout: NodeJS.Timeout | null;
54
- maxTimeout: NodeJS.Timeout | null;
55
- progressCount: number;
56
- lastProgressTime: number;
57
- isCompleted: boolean;
58
- isCancelled: boolean;
59
- onTimeout?: TimeoutCallback;
60
- onProgress?: ProgressCallback;
61
- }
62
- /**
63
- * Callback for handling timeout events
64
- */
65
- export type TimeoutCallback = (context: TimeoutContext) => void;
66
- /**
67
- * Callback for sending progress notifications
68
- */
69
- export type ProgressCallback = (notification: ProgressNotification) => void;
70
- /**
71
- * McpRequestTimeout manages timeout behavior for MCP server requests
72
- * Implements MCP specification recommendations for handling long-running operations
73
- *
74
- * This class handles AI -> MCP level timeouts, separate from MCP -> AI (AgentExecutor) timeouts
75
- * Following MCP best practices:
76
- * - Progressive timeout with reset on progress
77
- * - Maximum absolute timeout enforcement
78
- * - Progress notifications for better UX
79
- * - Graceful cancellation support
80
- */
81
- export declare class McpRequestTimeout {
82
- private readonly config;
83
- private readonly logger;
84
- private readonly contexts;
85
- /**
86
- * Creates a new McpRequestTimeout instance
87
- *
88
- * @param config - Optional timeout configuration
89
- * @param logger - Optional logger instance
90
- */
91
- constructor(config?: Partial<McpTimeoutConfig>, logger?: Logger);
92
- /**
93
- * Start timeout tracking for a request
94
- *
95
- * @param requestId - Unique request identifier
96
- * @param onTimeout - Callback when timeout occurs
97
- * @param onProgress - Optional callback for progress notifications
98
- * @returns TimeoutContext for the request
99
- */
100
- startTimeout(requestId: string, onTimeout: TimeoutCallback, onProgress?: ProgressCallback): TimeoutContext;
101
- /**
102
- * Report progress and optionally reset timeout
103
- * Following MCP specification: MAY reset timeout on progress, but enforce maximum
104
- *
105
- * @param requestId - Request identifier
106
- * @param message - Progress message
107
- * @param percentage - Optional completion percentage
108
- */
109
- reportProgress(requestId: string, message: string, percentage?: number): void;
110
- /**
111
- * Mark request as completed and clear timeouts
112
- *
113
- * @param requestId - Request identifier
114
- */
115
- complete(requestId: string): void;
116
- /**
117
- * Cancel request and clear timeouts
118
- * Following MCP specification for cancellation
119
- *
120
- * @param requestId - Request identifier
121
- * @param reason - Cancellation reason
122
- */
123
- cancel(requestId: string, reason: string): void;
124
- /**
125
- * Clear timeout for a request
126
- *
127
- * @param requestId - Request identifier
128
- */
129
- clearTimeout(requestId: string): void;
130
- /**
131
- * Check if request has timed out
132
- *
133
- * @param requestId - Request identifier
134
- * @returns true if timed out
135
- */
136
- hasTimedOut(requestId: string): boolean;
137
- /**
138
- * Get timeout statistics for monitoring
139
- *
140
- * @returns Current timeout statistics
141
- */
142
- getStats(): {
143
- activeRequests: number;
144
- averageProgressCount: number;
145
- longestRunningMs: number;
146
- };
147
- /**
148
- * Handle timeout event
149
- *
150
- * @private
151
- */
152
- private handleTimeout;
153
- /**
154
- * Send progress notification
155
- *
156
- * @private
157
- */
158
- private sendProgressNotification;
159
- /**
160
- * Clear all timeouts for a context
161
- *
162
- * @private
163
- */
164
- private clearTimeouts;
165
- }
166
- //# sourceMappingURL=McpRequestTimeout.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"McpRequestTimeout.d.ts","sourceRoot":"","sources":["../../src/execution/McpRequestTimeout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAE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