sub-agents-mcp 0.1.2
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 +21 -0
- package/README.md +265 -0
- package/dist/agents/AgentManager.d.ts +58 -0
- package/dist/agents/AgentManager.d.ts.map +1 -0
- package/dist/agents/AgentManager.js +182 -0
- package/dist/agents/AgentManager.js.map +1 -0
- package/dist/config/ServerConfig.d.ts +34 -0
- package/dist/config/ServerConfig.d.ts.map +1 -0
- package/dist/config/ServerConfig.js +54 -0
- package/dist/config/ServerConfig.js.map +1 -0
- package/dist/execution/AgentExecutor.d.ts +114 -0
- package/dist/execution/AgentExecutor.d.ts.map +1 -0
- package/dist/execution/AgentExecutor.js +234 -0
- package/dist/execution/AgentExecutor.js.map +1 -0
- package/dist/execution/ExecutionLimits.d.ts +141 -0
- package/dist/execution/ExecutionLimits.d.ts.map +1 -0
- package/dist/execution/ExecutionLimits.js +231 -0
- package/dist/execution/ExecutionLimits.js.map +1 -0
- package/dist/execution/McpRequestTimeout.d.ts +166 -0
- package/dist/execution/McpRequestTimeout.d.ts.map +1 -0
- package/dist/execution/McpRequestTimeout.js +278 -0
- package/dist/execution/McpRequestTimeout.js.map +1 -0
- package/dist/execution/PromptController.d.ts +92 -0
- package/dist/execution/PromptController.d.ts.map +1 -0
- package/dist/execution/PromptController.js +130 -0
- package/dist/execution/PromptController.js.map +1 -0
- package/dist/execution/StreamProcessor.d.ts +23 -0
- package/dist/execution/StreamProcessor.d.ts.map +1 -0
- package/dist/execution/StreamProcessor.js +51 -0
- package/dist/execution/StreamProcessor.js.map +1 -0
- package/dist/execution/TimeoutManager.d.ts +159 -0
- package/dist/execution/TimeoutManager.d.ts.map +1 -0
- package/dist/execution/TimeoutManager.js +283 -0
- package/dist/execution/TimeoutManager.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/AgentResources.d.ts +104 -0
- package/dist/resources/AgentResources.d.ts.map +1 -0
- package/dist/resources/AgentResources.js +315 -0
- package/dist/resources/AgentResources.js.map +1 -0
- package/dist/server/McpServer.d.ts +138 -0
- package/dist/server/McpServer.d.ts.map +1 -0
- package/dist/server/McpServer.js +373 -0
- package/dist/server/McpServer.js.map +1 -0
- package/dist/tools/RunAgentTool.d.ts +140 -0
- package/dist/tools/RunAgentTool.d.ts.map +1 -0
- package/dist/tools/RunAgentTool.js +371 -0
- package/dist/tools/RunAgentTool.js.map +1 -0
- package/dist/types/AgentDefinition.d.ts +33 -0
- package/dist/types/AgentDefinition.d.ts.map +1 -0
- package/dist/types/AgentDefinition.js +3 -0
- package/dist/types/AgentDefinition.js.map +1 -0
- package/dist/types/ExecutionParams.d.ts +48 -0
- package/dist/types/ExecutionParams.d.ts.map +1 -0
- package/dist/types/ExecutionParams.js +3 -0
- package/dist/types/ExecutionParams.js.map +1 -0
- package/dist/types/ServerConfig.d.ts +39 -0
- package/dist/types/ServerConfig.d.ts.map +1 -0
- package/dist/types/ServerConfig.js +3 -0
- package/dist/types/ServerConfig.js.map +1 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/ErrorHandler.d.ts +86 -0
- package/dist/utils/ErrorHandler.d.ts.map +1 -0
- package/dist/utils/ErrorHandler.js +99 -0
- package/dist/utils/ErrorHandler.js.map +1 -0
- package/dist/utils/Logger.d.ts +99 -0
- package/dist/utils/Logger.d.ts.map +1 -0
- package/dist/utils/Logger.js +151 -0
- package/dist/utils/Logger.js.map +1 -0
- package/package.json +92 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpRequestTimeout.js","sourceRoot":"","sources":["../../src/execution/McpRequestTimeout.ts"],"names":[],"mappings":";;;AAAA,6CAAwD;AAqCxD;;;GAGG;AACU,QAAA,0BAA0B,GAAqB;IAC1D,gB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CAAC;YAC3B,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;YACpC,OAAO,CAAC,cAAc,GAAG,IAAI,CAAA;QAC/B,CAAC;QACD,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;YAC3B,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;YACpC,OAAO,CAAC,cAAc,GAAG,IAAI,CAAA;QAC/B,CAAC;QACD,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACvB,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;YAChC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAA;QAC3B,CAAC;IACH,CAAC;CACF;AAnTD,8CAmTC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { ExecutionParams } from '../types/ExecutionParams';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for recursion prevention warnings.
|
|
4
|
+
* Allows customization of warning messages and formatting.
|
|
5
|
+
*/
|
|
6
|
+
export interface RecursionWarningConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The warning message template to add to prompts.
|
|
9
|
+
* Should contain clear instructions to prevent recursion.
|
|
10
|
+
*/
|
|
11
|
+
warningTemplate: string;
|
|
12
|
+
/**
|
|
13
|
+
* Whether to format the warning with visual separators.
|
|
14
|
+
* Defaults to true for better readability.
|
|
15
|
+
*/
|
|
16
|
+
useFormatting: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Default configuration for recursion prevention warnings.
|
|
20
|
+
* Uses clear English instructions to prevent sub-agents-mcp MCP tool usage.
|
|
21
|
+
*/
|
|
22
|
+
export declare const DEFAULT_RECURSION_WARNING_CONFIG: RecursionWarningConfig;
|
|
23
|
+
/**
|
|
24
|
+
* Controller class for enhancing prompts with recursion prevention instructions.
|
|
25
|
+
* Implements the security strategy defined in ADR-0001 for preventing infinite loops
|
|
26
|
+
* in agent-to-agent communication through prompt control.
|
|
27
|
+
*/
|
|
28
|
+
export declare class PromptController {
|
|
29
|
+
private readonly config;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new PromptController instance.
|
|
32
|
+
*
|
|
33
|
+
* @param config - Optional configuration for recursion warning behavior
|
|
34
|
+
*/
|
|
35
|
+
constructor(config?: RecursionWarningConfig);
|
|
36
|
+
/**
|
|
37
|
+
* Adds recursion prevention warning to a prompt string.
|
|
38
|
+
*
|
|
39
|
+
* This method implements the prompt control strategy defined in ADR-0001
|
|
40
|
+
* to prevent infinite loops in agent-to-agent communication. It preserves
|
|
41
|
+
* the original prompt content while adding clear security instructions
|
|
42
|
+
* that explicitly prohibit the use of sub-agents-mcp MCP tools.
|
|
43
|
+
*
|
|
44
|
+
* @param originalPrompt - The original user prompt to enhance
|
|
45
|
+
* @returns Enhanced prompt with recursion prevention instructions appended
|
|
46
|
+
* @throws {Error} When originalPrompt is empty or contains only whitespace
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const controller = new PromptController()
|
|
51
|
+
* const enhanced = controller.addRecursionWarning("Help me debug this code")
|
|
52
|
+
* console.log(enhanced)
|
|
53
|
+
* // Output: "Help me debug this code\n============...===========\nIMPORTANT RECURSION PREVENTION INSTRUCTIONS:\n- Do NOT use sub-agents-mcp MCP tools..."
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
addRecursionWarning(originalPrompt: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Formats the warning message according to the current configuration.
|
|
59
|
+
*
|
|
60
|
+
* @private
|
|
61
|
+
* @returns Formatted warning message with or without visual separators
|
|
62
|
+
*/
|
|
63
|
+
private formatWarningMessage;
|
|
64
|
+
/**
|
|
65
|
+
* Enhances ExecutionParams by adding recursion prevention to the prompt field.
|
|
66
|
+
*
|
|
67
|
+
* This method is the primary interface for integrating prompt enhancement
|
|
68
|
+
* into the agent execution pipeline. It creates a new ExecutionParams object
|
|
69
|
+
* with an enhanced prompt while preserving all other execution parameters.
|
|
70
|
+
* The enhanced prompt includes ADR-0001 compliant security instructions.
|
|
71
|
+
*
|
|
72
|
+
* @param params - Original execution parameters to enhance
|
|
73
|
+
* @returns New ExecutionParams object with enhanced prompt field
|
|
74
|
+
* @throws {Error} When params is invalid or prompt enhancement fails
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const controller = new PromptController()
|
|
79
|
+
* const original = {
|
|
80
|
+
* agent: "code-helper",
|
|
81
|
+
* prompt: "Fix this bug",
|
|
82
|
+
* cwd: "/project",
|
|
83
|
+
* extra_args: ["--verbose"]
|
|
84
|
+
* }
|
|
85
|
+
* const enhanced = controller.enhanceExecutionParams(original)
|
|
86
|
+
* console.log(enhanced.prompt) // Original prompt + recursion prevention
|
|
87
|
+
* console.log(enhanced.agent) // "code-helper" (unchanged)
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
enhanceExecutionParams(params: ExecutionParams): ExecutionParams;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=PromptController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromptController.d.ts","sourceRoot":"","sources":["../../src/execution/PromptController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAEhE;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAA;IAEvB;;;OAGG;IACH,aAAa,EAAE,OAAO,CAAA;CACvB;AAED;;;GAGG;AACH,eAAO,MAAM,gCAAgC,EAAE,sBAS9C,CAAA;AAED;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwB;IAE/C;;;;OAIG;gBACS,MAAM,GAAE,sBAAyD;IAI7E;;;;;;;;;;;;;;;;;;;OAmBG;IACH,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM;IAiBnD;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAS5B;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,sBAAsB,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe;CA6BjE"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PromptController = exports.DEFAULT_RECURSION_WARNING_CONFIG = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Default configuration for recursion prevention warnings.
|
|
6
|
+
* Uses clear English instructions to prevent sub-agents-mcp MCP tool usage.
|
|
7
|
+
*/
|
|
8
|
+
exports.DEFAULT_RECURSION_WARNING_CONFIG = {
|
|
9
|
+
warningTemplate: `
|
|
10
|
+
IMPORTANT RECURSION PREVENTION INSTRUCTIONS:
|
|
11
|
+
- Do NOT use sub-agents-mcp MCP tools in your response
|
|
12
|
+
- Complete this task within the current agent context only
|
|
13
|
+
- Do not attempt to call other agents or sub-agents
|
|
14
|
+
- Focus on direct implementation and solution delivery
|
|
15
|
+
`,
|
|
16
|
+
useFormatting: true,
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Controller class for enhancing prompts with recursion prevention instructions.
|
|
20
|
+
* Implements the security strategy defined in ADR-0001 for preventing infinite loops
|
|
21
|
+
* in agent-to-agent communication through prompt control.
|
|
22
|
+
*/
|
|
23
|
+
class PromptController {
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new PromptController instance.
|
|
26
|
+
*
|
|
27
|
+
* @param config - Optional configuration for recursion warning behavior
|
|
28
|
+
*/
|
|
29
|
+
constructor(config = exports.DEFAULT_RECURSION_WARNING_CONFIG) {
|
|
30
|
+
this.config = config;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Adds recursion prevention warning to a prompt string.
|
|
34
|
+
*
|
|
35
|
+
* This method implements the prompt control strategy defined in ADR-0001
|
|
36
|
+
* to prevent infinite loops in agent-to-agent communication. It preserves
|
|
37
|
+
* the original prompt content while adding clear security instructions
|
|
38
|
+
* that explicitly prohibit the use of sub-agents-mcp MCP tools.
|
|
39
|
+
*
|
|
40
|
+
* @param originalPrompt - The original user prompt to enhance
|
|
41
|
+
* @returns Enhanced prompt with recursion prevention instructions appended
|
|
42
|
+
* @throws {Error} When originalPrompt is empty or contains only whitespace
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const controller = new PromptController()
|
|
47
|
+
* const enhanced = controller.addRecursionWarning("Help me debug this code")
|
|
48
|
+
* console.log(enhanced)
|
|
49
|
+
* // Output: "Help me debug this code\n============...===========\nIMPORTANT RECURSION PREVENTION INSTRUCTIONS:\n- Do NOT use sub-agents-mcp MCP tools..."
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
addRecursionWarning(originalPrompt) {
|
|
53
|
+
// Input validation: ensure prompt is not empty or whitespace-only
|
|
54
|
+
if (typeof originalPrompt !== 'string') {
|
|
55
|
+
throw new Error('Original prompt must be a string');
|
|
56
|
+
}
|
|
57
|
+
if (originalPrompt.trim().length === 0) {
|
|
58
|
+
throw new Error('Original prompt cannot be empty');
|
|
59
|
+
}
|
|
60
|
+
// Format warning based on configuration
|
|
61
|
+
const warning = this.formatWarningMessage();
|
|
62
|
+
// Concatenate original prompt with warning
|
|
63
|
+
return `${originalPrompt}${warning}`;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Formats the warning message according to the current configuration.
|
|
67
|
+
*
|
|
68
|
+
* @private
|
|
69
|
+
* @returns Formatted warning message with or without visual separators
|
|
70
|
+
*/
|
|
71
|
+
formatWarningMessage() {
|
|
72
|
+
if (this.config.useFormatting) {
|
|
73
|
+
const separator = '='.repeat(60);
|
|
74
|
+
return `\n${separator}\n${this.config.warningTemplate}\n${separator}\n`;
|
|
75
|
+
}
|
|
76
|
+
return this.config.warningTemplate;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Enhances ExecutionParams by adding recursion prevention to the prompt field.
|
|
80
|
+
*
|
|
81
|
+
* This method is the primary interface for integrating prompt enhancement
|
|
82
|
+
* into the agent execution pipeline. It creates a new ExecutionParams object
|
|
83
|
+
* with an enhanced prompt while preserving all other execution parameters.
|
|
84
|
+
* The enhanced prompt includes ADR-0001 compliant security instructions.
|
|
85
|
+
*
|
|
86
|
+
* @param params - Original execution parameters to enhance
|
|
87
|
+
* @returns New ExecutionParams object with enhanced prompt field
|
|
88
|
+
* @throws {Error} When params is invalid or prompt enhancement fails
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const controller = new PromptController()
|
|
93
|
+
* const original = {
|
|
94
|
+
* agent: "code-helper",
|
|
95
|
+
* prompt: "Fix this bug",
|
|
96
|
+
* cwd: "/project",
|
|
97
|
+
* extra_args: ["--verbose"]
|
|
98
|
+
* }
|
|
99
|
+
* const enhanced = controller.enhanceExecutionParams(original)
|
|
100
|
+
* console.log(enhanced.prompt) // Original prompt + recursion prevention
|
|
101
|
+
* console.log(enhanced.agent) // "code-helper" (unchanged)
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
enhanceExecutionParams(params) {
|
|
105
|
+
// Input validation: ensure params is valid ExecutionParams object
|
|
106
|
+
if (!params || typeof params !== 'object') {
|
|
107
|
+
throw new Error('ExecutionParams must be a valid object');
|
|
108
|
+
}
|
|
109
|
+
if (!params.agent || typeof params.agent !== 'string') {
|
|
110
|
+
throw new Error('ExecutionParams must have a valid agent field');
|
|
111
|
+
}
|
|
112
|
+
if (!params.prompt || typeof params.prompt !== 'string') {
|
|
113
|
+
throw new Error('ExecutionParams must have a valid prompt field');
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
// Enhance the prompt with recursion prevention instructions
|
|
117
|
+
const enhancedPrompt = this.addRecursionWarning(params.prompt);
|
|
118
|
+
// Return new object with enhanced prompt, preserving all other fields
|
|
119
|
+
return {
|
|
120
|
+
...params,
|
|
121
|
+
prompt: enhancedPrompt,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
throw new Error(`Failed to enhance execution parameters: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.PromptController = PromptController;
|
|
130
|
+
//# sourceMappingURL=PromptController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromptController.js","sourceRoot":"","sources":["../../src/execution/PromptController.ts"],"names":[],"mappings":";;;AAoBA;;;GAGG;AACU,QAAA,gCAAgC,GAA2B;IACtE,eAAe,EAAE;;;;;;CAMlB;IACC,aAAa,EAAE,IAAI;CACpB,CAAA;AAED;;;;GAIG;AACH,MAAa,gBAAgB;IAG3B;;;;OAIG;IACH,YAAY,SAAiC,wCAAgC;QAC3E,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,mBAAmB,CAAC,cAAsB;QACxC,kEAAkE;QAClE,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;QACrD,CAAC;QAED,IAAI,cAAc,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;QACpD,CAAC;QAED,wCAAwC;QACxC,MAAM,OAAO,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAA;QAE3C,2CAA2C;QAC3C,OAAO,GAAG,cAAc,GAAG,OAAO,EAAE,CAAA;IACtC,CAAC;IAED;;;;;OAKG;IACK,oBAAoB;QAC1B,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;YAC9B,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;YAChC,OAAO,KAAK,SAAS,KAAK,IAAI,CAAC,MAAM,CAAC,eAAe,KAAK,SAAS,IAAI,CAAA;QACzE,CAAC;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAA;IACpC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,sBAAsB,CAAC,MAAuB;QAC5C,kEAAkE;QAClE,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAA;QAC3D,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;QAClE,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YACxD,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAA;QACnE,CAAC;QAED,IAAI,CAAC;YACH,4DAA4D;YAC5D,MAAM,cAAc,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YAE9D,sEAAsE;YACtE,OAAO;gBACL,GAAG,MAAM;gBACT,MAAM,EAAE,cAAc;aACvB,CAAA;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CACb,2CAA2C,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CACtG,CAAA;QACH,CAAC;IACH,CAAC;CACF;AAvHD,4CAuHC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StreamProcessor - Simplified stream processing for agent output
|
|
3
|
+
*
|
|
4
|
+
* Handles both cursor and claude output in JSON format.
|
|
5
|
+
* Both agents now use --output-format json and return a single JSON response.
|
|
6
|
+
*/
|
|
7
|
+
export declare class StreamProcessor {
|
|
8
|
+
private resultJson;
|
|
9
|
+
/**
|
|
10
|
+
* Process a single line from the agent output stream.
|
|
11
|
+
* Returns true when a valid JSON is detected, false otherwise.
|
|
12
|
+
*
|
|
13
|
+
* @param line - Raw line from stdout
|
|
14
|
+
* @returns true if processing is complete, false to continue
|
|
15
|
+
*/
|
|
16
|
+
processLine(line: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Get the final result JSON.
|
|
19
|
+
* @returns The stored result JSON or null if not yet available
|
|
20
|
+
*/
|
|
21
|
+
getResult(): unknown;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=StreamProcessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StreamProcessor.d.ts","sourceRoot":"","sources":["../../src/execution/StreamProcessor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,UAAU,CAAgB;IAElC;;;;;;OAMG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAwBlC;;;OAGG;IACH,SAAS,IAAI,OAAO;CAGrB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StreamProcessor = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* StreamProcessor - Simplified stream processing for agent output
|
|
6
|
+
*
|
|
7
|
+
* Handles both cursor and claude output in JSON format.
|
|
8
|
+
* Both agents now use --output-format json and return a single JSON response.
|
|
9
|
+
*/
|
|
10
|
+
class StreamProcessor {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.resultJson = null;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Process a single line from the agent output stream.
|
|
16
|
+
* Returns true when a valid JSON is detected, false otherwise.
|
|
17
|
+
*
|
|
18
|
+
* @param line - Raw line from stdout
|
|
19
|
+
* @returns true if processing is complete, false to continue
|
|
20
|
+
*/
|
|
21
|
+
processLine(line) {
|
|
22
|
+
const trimmedLine = line.trim();
|
|
23
|
+
// Empty lines are ignored
|
|
24
|
+
if (!trimmedLine) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
// Try to parse as JSON
|
|
28
|
+
try {
|
|
29
|
+
const json = JSON.parse(trimmedLine);
|
|
30
|
+
// Store the first valid JSON response
|
|
31
|
+
if (!this.resultJson) {
|
|
32
|
+
this.resultJson = json;
|
|
33
|
+
return true; // Processing complete
|
|
34
|
+
}
|
|
35
|
+
return false; // Ignore subsequent JSONs
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
// Not valid JSON, ignore
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get the final result JSON.
|
|
44
|
+
* @returns The stored result JSON or null if not yet available
|
|
45
|
+
*/
|
|
46
|
+
getResult() {
|
|
47
|
+
return this.resultJson;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.StreamProcessor = StreamProcessor;
|
|
51
|
+
//# sourceMappingURL=StreamProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StreamProcessor.js","sourceRoot":"","sources":["../../src/execution/StreamProcessor.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,MAAa,eAAe;IAA5B;QACU,eAAU,GAAY,IAAI,CAAA;IAwCpC,CAAC;IAtCC;;;;;;OAMG;IACH,WAAW,CAAC,IAAY;QACtB,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;QAE/B,0BAA0B;QAC1B,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,KAAK,CAAA;QACd,CAAC;QAED,uBAAuB;QACvB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;YAEpC,sCAAsC;YACtC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;gBACrB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAA;gBACtB,OAAO,IAAI,CAAA,CAAC,sBAAsB;YACpC,CAAC;YACD,OAAO,KAAK,CAAA,CAAC,0BAA0B;QACzC,CAAC;QAAC,MAAM,CAAC;YACP,yBAAyB;YACzB,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;CACF;AAzCD,0CAyCC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timeout management for agent execution with configurable limits and cleanup.
|
|
3
|
+
*
|
|
4
|
+
* Provides timeout enforcement with warning mechanisms, graceful cleanup,
|
|
5
|
+
* and integration with agent execution processes.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Configuration interface for timeout management.
|
|
9
|
+
*/
|
|
10
|
+
export interface TimeoutConfig {
|
|
11
|
+
/** Default timeout in milliseconds (default: 30000) */
|
|
12
|
+
defaultTimeoutMs: number;
|
|
13
|
+
/** Warning threshold as percentage of timeout (default: 0.8 for 80%) */
|
|
14
|
+
warningThresholdPercent: number;
|
|
15
|
+
/** Enable timeout warnings (default: true) */
|
|
16
|
+
enableWarnings: boolean;
|
|
17
|
+
/** Grace period for cleanup in milliseconds (default: 5000) */
|
|
18
|
+
cleanupGracePeriodMs: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Timeout execution context for tracking active operations.
|
|
22
|
+
*/
|
|
23
|
+
export interface TimeoutContext {
|
|
24
|
+
/** Unique identifier for the operation */
|
|
25
|
+
operationId: string;
|
|
26
|
+
/** Start time of the operation */
|
|
27
|
+
startTime: Date;
|
|
28
|
+
/** Timeout duration in milliseconds */
|
|
29
|
+
timeoutMs: number;
|
|
30
|
+
/** Warning callback function */
|
|
31
|
+
onWarning?: (remainingMs: number) => void;
|
|
32
|
+
/** Cleanup callback function */
|
|
33
|
+
onCleanup?: () => Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Default timeout configuration.
|
|
37
|
+
*/
|
|
38
|
+
export declare const DEFAULT_TIMEOUT_CONFIG: TimeoutConfig;
|
|
39
|
+
/**
|
|
40
|
+
* Timeout manager for execution time monitoring and enforcement.
|
|
41
|
+
*
|
|
42
|
+
* Manages timeout enforcement with configurable limits, warning mechanisms,
|
|
43
|
+
* and graceful cleanup for agent execution processes.
|
|
44
|
+
*/
|
|
45
|
+
export declare class TimeoutManager {
|
|
46
|
+
private readonly config;
|
|
47
|
+
private readonly activeTimeouts;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new TimeoutManager instance.
|
|
50
|
+
*
|
|
51
|
+
* @param config - Timeout configuration (uses defaults if not provided)
|
|
52
|
+
*/
|
|
53
|
+
constructor(config?: Partial<TimeoutConfig>);
|
|
54
|
+
/**
|
|
55
|
+
* Starts timeout monitoring for an operation.
|
|
56
|
+
*
|
|
57
|
+
* @param context - Timeout context for the operation
|
|
58
|
+
* @returns Operation ID for tracking
|
|
59
|
+
* @throws {Error} If operation ID is already being tracked
|
|
60
|
+
*/
|
|
61
|
+
startTimeout(context: TimeoutContext): string;
|
|
62
|
+
/**
|
|
63
|
+
* Clears timeout monitoring for an operation.
|
|
64
|
+
*
|
|
65
|
+
* @param operationId - Operation ID to clear
|
|
66
|
+
* @returns True if timeout was cleared, false if not found
|
|
67
|
+
*/
|
|
68
|
+
clearTimeout(operationId: string): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Gets the remaining time for an operation.
|
|
71
|
+
*
|
|
72
|
+
* @param operationId - Operation ID to check
|
|
73
|
+
* @returns Remaining time in milliseconds, or null if not found
|
|
74
|
+
*/
|
|
75
|
+
getRemainingTime(operationId: string): number | null;
|
|
76
|
+
/**
|
|
77
|
+
* Gets the elapsed time for an operation.
|
|
78
|
+
*
|
|
79
|
+
* @param operationId - Operation ID to check
|
|
80
|
+
* @returns Elapsed time in milliseconds, or null if not found
|
|
81
|
+
*/
|
|
82
|
+
getElapsedTime(operationId: string): number | null;
|
|
83
|
+
/**
|
|
84
|
+
* Checks if an operation is currently being tracked.
|
|
85
|
+
*
|
|
86
|
+
* @param operationId - Operation ID to check
|
|
87
|
+
* @returns True if operation is being tracked
|
|
88
|
+
*/
|
|
89
|
+
isActive(operationId: string): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Gets all active operation IDs.
|
|
92
|
+
*
|
|
93
|
+
* @returns Array of active operation IDs
|
|
94
|
+
*/
|
|
95
|
+
getActiveOperations(): string[];
|
|
96
|
+
/**
|
|
97
|
+
* Creates a timeout context with default values.
|
|
98
|
+
*
|
|
99
|
+
* @param operationId - Unique operation identifier
|
|
100
|
+
* @param timeoutMs - Timeout duration (uses default if not provided)
|
|
101
|
+
* @param options - Additional context options
|
|
102
|
+
* @returns Timeout context
|
|
103
|
+
*/
|
|
104
|
+
createContext(operationId: string, timeoutMs?: number, options?: {
|
|
105
|
+
onWarning?: (remainingMs: number) => void;
|
|
106
|
+
onCleanup?: () => Promise<void>;
|
|
107
|
+
}): TimeoutContext;
|
|
108
|
+
/**
|
|
109
|
+
* Gets the current configuration.
|
|
110
|
+
*
|
|
111
|
+
* @returns Timeout configuration
|
|
112
|
+
*/
|
|
113
|
+
getConfig(): TimeoutConfig;
|
|
114
|
+
/**
|
|
115
|
+
* Clears all active timeouts.
|
|
116
|
+
*
|
|
117
|
+
* @returns Number of timeouts cleared
|
|
118
|
+
*/
|
|
119
|
+
clearAllTimeouts(): number;
|
|
120
|
+
/**
|
|
121
|
+
* Gets timeout statistics for monitoring and optimization.
|
|
122
|
+
*
|
|
123
|
+
* @returns Timeout statistics
|
|
124
|
+
*/
|
|
125
|
+
getTimeoutStats(): {
|
|
126
|
+
activeOperations: number;
|
|
127
|
+
totalOperationsStarted: number;
|
|
128
|
+
averageCompletionTime: number;
|
|
129
|
+
timeoutRate: number;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Suggests optimal timeout based on historical data.
|
|
133
|
+
*
|
|
134
|
+
* @param operationType - Type of operation for historical analysis (reserved for future use)
|
|
135
|
+
* @returns Suggested timeout in milliseconds
|
|
136
|
+
*/
|
|
137
|
+
suggestOptimalTimeout(operationType?: string): number;
|
|
138
|
+
/**
|
|
139
|
+
* Updates timeout statistics.
|
|
140
|
+
*
|
|
141
|
+
* @param operationId - Operation that completed/timed out
|
|
142
|
+
* @param completed - Whether operation completed successfully
|
|
143
|
+
* @private
|
|
144
|
+
*/
|
|
145
|
+
private updateStats;
|
|
146
|
+
/**
|
|
147
|
+
* Handles timeout event with cleanup and error throwing.
|
|
148
|
+
*
|
|
149
|
+
* @param context - Timeout context
|
|
150
|
+
* @private
|
|
151
|
+
*/
|
|
152
|
+
private handleTimeout;
|
|
153
|
+
/**
|
|
154
|
+
* Statistics tracking for timeout optimization.
|
|
155
|
+
* @private
|
|
156
|
+
*/
|
|
157
|
+
private stats;
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=TimeoutManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeoutManager.d.ts","sourceRoot":"","sources":["../../src/execution/TimeoutManager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,uDAAuD;IACvD,gBAAgB,EAAE,MAAM,CAAA;IAExB,wEAAwE;IACxE,uBAAuB,EAAE,MAAM,CAAA;IAE/B,8CAA8C;IAC9C,cAAc,EAAE,OAAO,CAAA;IAEvB,+DAA+D;IAC/D,oBAAoB,EAAE,MAAM,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAA;IAEnB,kCAAkC;IAClC,SAAS,EAAE,IAAI,CAAA;IAEf,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAA;IAEjB,g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