sub-agents-mcp 0.13.0 → 0.14.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.
- package/README.md +21 -11
- package/dist/agents/AgentManager.d.ts +0 -45
- package/dist/agents/AgentManager.d.ts.map +1 -1
- package/dist/agents/AgentManager.js +0 -52
- package/dist/agents/AgentManager.js.map +1 -1
- package/dist/config/ServerConfig.d.ts +0 -41
- package/dist/config/ServerConfig.d.ts.map +1 -1
- package/dist/config/ServerConfig.js +0 -52
- package/dist/config/ServerConfig.js.map +1 -1
- package/dist/execution/AgentExecutor.d.ts +3 -151
- package/dist/execution/AgentExecutor.d.ts.map +1 -1
- package/dist/execution/AgentExecutor.js +30 -104
- package/dist/execution/AgentExecutor.js.map +1 -1
- package/dist/execution/StreamProcessor.d.ts +1 -10
- package/dist/execution/StreamProcessor.d.ts.map +1 -1
- package/dist/execution/StreamProcessor.js +33 -10
- package/dist/execution/StreamProcessor.js.map +1 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -15
- package/dist/index.js.map +1 -1
- package/dist/resources/AgentResources.d.ts +0 -71
- package/dist/resources/AgentResources.d.ts.map +1 -1
- package/dist/resources/AgentResources.js +0 -68
- package/dist/resources/AgentResources.js.map +1 -1
- package/dist/server/McpServer.d.ts +0 -88
- package/dist/server/McpServer.d.ts.map +1 -1
- package/dist/server/McpServer.js +0 -98
- package/dist/server/McpServer.js.map +1 -1
- package/dist/session/SessionHistoryFormatter.d.ts +0 -29
- package/dist/session/SessionHistoryFormatter.d.ts.map +1 -1
- package/dist/session/SessionHistoryFormatter.js +1 -34
- package/dist/session/SessionHistoryFormatter.js.map +1 -1
- package/dist/session/SessionManager.d.ts +0 -142
- package/dist/session/SessionManager.d.ts.map +1 -1
- package/dist/session/SessionManager.js +0 -180
- package/dist/session/SessionManager.js.map +1 -1
- package/dist/tools/RunAgentTool.d.ts +0 -121
- package/dist/tools/RunAgentTool.d.ts.map +1 -1
- package/dist/tools/RunAgentTool.js +16 -168
- package/dist/tools/RunAgentTool.js.map +1 -1
- package/dist/types/AgentDefinition.d.ts +0 -25
- package/dist/types/AgentDefinition.d.ts.map +1 -1
- package/dist/types/ExecutionParams.d.ts +0 -24
- package/dist/types/ExecutionParams.d.ts.map +1 -1
- package/dist/types/SessionData.d.ts +0 -23
- package/dist/types/SessionData.d.ts.map +1 -1
- package/dist/utils/ErrorHandler.d.ts +0 -67
- package/dist/utils/ErrorHandler.d.ts.map +1 -1
- package/dist/utils/ErrorHandler.js +0 -59
- package/dist/utils/ErrorHandler.js.map +1 -1
- package/dist/utils/Logger.d.ts +0 -78
- package/dist/utils/Logger.d.ts.map +1 -1
- package/dist/utils/Logger.js +0 -75
- package/dist/utils/Logger.js.map +1 -1
- package/package.json +6 -9
package/dist/server/McpServer.js
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Server implementation using @modelcontextprotocol/sdk
|
|
3
|
-
*
|
|
4
|
-
* Provides the foundational MCP server functionality with StdioServerTransport
|
|
5
|
-
* for stdin/stdout communication. This class serves as the entry point for
|
|
6
|
-
* the MCP server and handles basic server lifecycle operations.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const config = await ServerConfig.fromEnvironment()
|
|
11
|
-
* const server = new McpServer(config)
|
|
12
|
-
* await server.start()
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
16
2
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
17
3
|
import { CallToolRequestSchema, ListResourcesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
@@ -22,9 +8,6 @@ import { SessionManager } from '../session/SessionManager.js';
|
|
|
22
8
|
import { RunAgentTool } from '../tools/RunAgentTool.js';
|
|
23
9
|
import { AppError, ValidationError } from '../utils/ErrorHandler.js';
|
|
24
10
|
import { Logger } from '../utils/Logger.js';
|
|
25
|
-
/**
|
|
26
|
-
* MCP Server class providing foundational server functionality
|
|
27
|
-
*/
|
|
28
11
|
export class McpServer {
|
|
29
12
|
server;
|
|
30
13
|
transport = null;
|
|
@@ -34,11 +17,6 @@ export class McpServer {
|
|
|
34
17
|
runAgentTool;
|
|
35
18
|
agentResources;
|
|
36
19
|
sessionManager;
|
|
37
|
-
/**
|
|
38
|
-
* Create a new MCP server instance
|
|
39
|
-
* @param config Server configuration object
|
|
40
|
-
* @throws {Error} When server name is empty
|
|
41
|
-
*/
|
|
42
20
|
constructor(config) {
|
|
43
21
|
this.validateConfig(config);
|
|
44
22
|
this.config = config;
|
|
@@ -46,9 +24,7 @@ export class McpServer {
|
|
|
46
24
|
name: config.serverName,
|
|
47
25
|
version: config.serverVersion,
|
|
48
26
|
});
|
|
49
|
-
// Initialize agent management components
|
|
50
27
|
this.agentManager = new AgentManager(config);
|
|
51
|
-
// Create ExecutionConfig with the agent type from server config
|
|
52
28
|
const executionConfig = createExecutionConfig(config.agentType, {
|
|
53
29
|
executionTimeout: config.executionTimeoutMs,
|
|
54
30
|
permission: config.agentPermission,
|
|
@@ -59,10 +35,8 @@ export class McpServer {
|
|
|
59
35
|
...(config.glmApiKey && { glmApiKey: config.glmApiKey }),
|
|
60
36
|
...(config.kimiApiKey && { kimiApiKey: config.kimiApiKey }),
|
|
61
37
|
});
|
|
62
|
-
// Create logger with log level from config
|
|
63
38
|
const executorLogger = new Logger(config.logLevel);
|
|
64
39
|
this.agentExecutor = new AgentExecutor(executionConfig, executorLogger);
|
|
65
|
-
// Initialize SessionManager if session management is enabled
|
|
66
40
|
if (config.sessionEnabled) {
|
|
67
41
|
this.sessionManager = new SessionManager({
|
|
68
42
|
enabled: config.sessionEnabled,
|
|
@@ -79,7 +53,6 @@ export class McpServer {
|
|
|
79
53
|
}
|
|
80
54
|
this.runAgentTool = new RunAgentTool(this.agentExecutor, this.agentManager, this.sessionManager);
|
|
81
55
|
this.agentResources = new AgentResources(this.agentManager);
|
|
82
|
-
// Initialize MCP server with capabilities
|
|
83
56
|
this.server = new Server({
|
|
84
57
|
name: config.serverName,
|
|
85
58
|
version: config.serverVersion,
|
|
@@ -89,17 +62,10 @@ export class McpServer {
|
|
|
89
62
|
resources: {},
|
|
90
63
|
},
|
|
91
64
|
});
|
|
92
|
-
// Setup StdioServerTransport for stdin/stdout communication
|
|
93
65
|
this.setupTransport();
|
|
94
|
-
// Setup MCP handlers
|
|
95
66
|
this.setupHandlers();
|
|
96
67
|
this.log('info', 'MCP server initialized successfully');
|
|
97
68
|
}
|
|
98
|
-
/**
|
|
99
|
-
* Validate server configuration
|
|
100
|
-
* @param config Configuration to validate
|
|
101
|
-
* @throws {Error} When configuration is invalid
|
|
102
|
-
*/
|
|
103
69
|
validateConfig(config) {
|
|
104
70
|
if (!config.serverName || config.serverName.trim() === '') {
|
|
105
71
|
throw new Error('Server name cannot be empty');
|
|
@@ -108,12 +74,6 @@ export class McpServer {
|
|
|
108
74
|
throw new Error('Server version cannot be empty');
|
|
109
75
|
}
|
|
110
76
|
}
|
|
111
|
-
/**
|
|
112
|
-
* Log message with structured format
|
|
113
|
-
* @param level Log level
|
|
114
|
-
* @param message Log message
|
|
115
|
-
* @param metadata Additional metadata
|
|
116
|
-
*/
|
|
117
77
|
log(level, message, metadata) {
|
|
118
78
|
const logLevels = {
|
|
119
79
|
debug: 0,
|
|
@@ -133,9 +93,6 @@ export class McpServer {
|
|
|
133
93
|
console.error(JSON.stringify(logEntry));
|
|
134
94
|
}
|
|
135
95
|
}
|
|
136
|
-
/**
|
|
137
|
-
* Setup StdioServerTransport for MCP communication
|
|
138
|
-
*/
|
|
139
96
|
setupTransport() {
|
|
140
97
|
try {
|
|
141
98
|
this.transport = new StdioServerTransport();
|
|
@@ -146,12 +103,8 @@ export class McpServer {
|
|
|
146
103
|
throw new AppError('Failed to setup MCP transport', 'TRANSPORT_SETUP_FAILED');
|
|
147
104
|
}
|
|
148
105
|
}
|
|
149
|
-
/**
|
|
150
|
-
* Setup MCP protocol handlers with performance monitoring
|
|
151
|
-
*/
|
|
152
106
|
setupHandlers() {
|
|
153
107
|
try {
|
|
154
|
-
// List tools handler
|
|
155
108
|
this.server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
156
109
|
const startTime = Date.now();
|
|
157
110
|
this.log('debug', 'Received list_tools request');
|
|
@@ -179,7 +132,6 @@ export class McpServer {
|
|
|
179
132
|
throw error;
|
|
180
133
|
}
|
|
181
134
|
});
|
|
182
|
-
// Call tool handler
|
|
183
135
|
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
184
136
|
const startTime = Date.now();
|
|
185
137
|
const { params } = request;
|
|
@@ -205,7 +157,6 @@ export class McpServer {
|
|
|
205
157
|
throw error;
|
|
206
158
|
}
|
|
207
159
|
});
|
|
208
|
-
// List resources handler
|
|
209
160
|
this.server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
210
161
|
const startTime = Date.now();
|
|
211
162
|
this.log('debug', 'Received list_resources request');
|
|
@@ -225,7 +176,6 @@ export class McpServer {
|
|
|
225
176
|
throw error;
|
|
226
177
|
}
|
|
227
178
|
});
|
|
228
|
-
// Read resource handler
|
|
229
179
|
this.server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
230
180
|
const startTime = Date.now();
|
|
231
181
|
const { params } = request;
|
|
@@ -258,34 +208,18 @@ export class McpServer {
|
|
|
258
208
|
throw new AppError('Failed to setup MCP handlers', 'HANDLERS_SETUP_FAILED');
|
|
259
209
|
}
|
|
260
210
|
}
|
|
261
|
-
/**
|
|
262
|
-
* Get server information
|
|
263
|
-
* @returns Server name and version
|
|
264
|
-
*/
|
|
265
211
|
getServerInfo() {
|
|
266
212
|
return {
|
|
267
213
|
name: this.config.serverName,
|
|
268
214
|
version: this.config.serverVersion,
|
|
269
215
|
};
|
|
270
216
|
}
|
|
271
|
-
/**
|
|
272
|
-
* Check if transport is configured
|
|
273
|
-
* @returns True if transport is available
|
|
274
|
-
*/
|
|
275
217
|
hasTransport() {
|
|
276
218
|
return this.transport !== null;
|
|
277
219
|
}
|
|
278
|
-
/**
|
|
279
|
-
* Check if server is ready to start
|
|
280
|
-
* @returns True if server is ready
|
|
281
|
-
*/
|
|
282
220
|
isReady() {
|
|
283
221
|
return this.hasTransport() && this.server !== null;
|
|
284
222
|
}
|
|
285
|
-
/**
|
|
286
|
-
* Start the MCP server
|
|
287
|
-
* @throws {Error} When server is not ready or transport setup fails
|
|
288
|
-
*/
|
|
289
223
|
async start() {
|
|
290
224
|
try {
|
|
291
225
|
if (!this.isReady()) {
|
|
@@ -295,7 +229,6 @@ export class McpServer {
|
|
|
295
229
|
throw new AppError('Transport not configured', 'TRANSPORT_NOT_CONFIGURED');
|
|
296
230
|
}
|
|
297
231
|
this.log('info', 'Starting MCP server...');
|
|
298
|
-
// Connect server to transport
|
|
299
232
|
await this.server.connect(this.transport);
|
|
300
233
|
this.log('info', 'MCP server started successfully', {
|
|
301
234
|
serverName: this.config.serverName,
|
|
@@ -309,10 +242,6 @@ export class McpServer {
|
|
|
309
242
|
: new AppError('Failed to start MCP server', 'SERVER_START_FAILED');
|
|
310
243
|
}
|
|
311
244
|
}
|
|
312
|
-
/**
|
|
313
|
-
* List available tools (for testing)
|
|
314
|
-
* @returns Promise resolving to array of tool definitions
|
|
315
|
-
*/
|
|
316
245
|
async listTools() {
|
|
317
246
|
return [
|
|
318
247
|
{
|
|
@@ -322,10 +251,6 @@ export class McpServer {
|
|
|
322
251
|
},
|
|
323
252
|
];
|
|
324
253
|
}
|
|
325
|
-
/**
|
|
326
|
-
* List available resources (for testing)
|
|
327
|
-
* @returns Promise resolving to array of resource definitions
|
|
328
|
-
*/
|
|
329
254
|
async listResources() {
|
|
330
255
|
const resources = await this.agentResources.listResources();
|
|
331
256
|
return resources.map((resource) => ({
|
|
@@ -334,53 +259,30 @@ export class McpServer {
|
|
|
334
259
|
description: resource.description,
|
|
335
260
|
}));
|
|
336
261
|
}
|
|
337
|
-
/**
|
|
338
|
-
* Call a tool (for testing)
|
|
339
|
-
* @param toolName - Name of the tool to call
|
|
340
|
-
* @param params - Tool parameters
|
|
341
|
-
* @returns Promise resolving to tool response
|
|
342
|
-
*/
|
|
343
262
|
async callTool(toolName, params) {
|
|
344
263
|
if (toolName === 'run_agent') {
|
|
345
264
|
return await this.runAgentTool.execute(params);
|
|
346
265
|
}
|
|
347
266
|
throw new ValidationError(`Unknown tool: ${toolName}`, 'UNKNOWN_TOOL');
|
|
348
267
|
}
|
|
349
|
-
/**
|
|
350
|
-
* Read a resource (for testing)
|
|
351
|
-
* @param uri - Resource URI to read
|
|
352
|
-
* @returns Promise resolving to resource content
|
|
353
|
-
*/
|
|
354
268
|
async readResource(uri) {
|
|
355
269
|
if (!this.agentResources.isValidResourceUri(uri)) {
|
|
356
270
|
throw new ValidationError(`Invalid resource URI: ${uri}`, 'INVALID_RESOURCE_URI');
|
|
357
271
|
}
|
|
358
272
|
return await this.agentResources.readResource(uri);
|
|
359
273
|
}
|
|
360
|
-
/**
|
|
361
|
-
* Get server performance statistics
|
|
362
|
-
*
|
|
363
|
-
* @returns Performance and usage statistics
|
|
364
|
-
*/
|
|
365
274
|
getServerStats() {
|
|
366
275
|
return {
|
|
367
276
|
serverInfo: this.getServerInfo(),
|
|
368
277
|
executionStats: this.runAgentTool.getExecutionStats(),
|
|
369
278
|
};
|
|
370
279
|
}
|
|
371
|
-
/**
|
|
372
|
-
* Reset statistics
|
|
373
|
-
*/
|
|
374
280
|
resetStats() {
|
|
375
281
|
this.log('info', 'Server statistics reset');
|
|
376
282
|
}
|
|
377
|
-
/**
|
|
378
|
-
* Close the server and cleanup resources
|
|
379
|
-
*/
|
|
380
283
|
async close() {
|
|
381
284
|
try {
|
|
382
285
|
this.log('info', 'Shutting down MCP server...');
|
|
383
|
-
// Log final statistics before shutdown
|
|
384
286
|
const stats = this.getServerStats();
|
|
385
287
|
this.log('info', 'Final server statistics', {
|
|
386
288
|
executionCount: Array.from(stats.executionStats.values()).reduce((sum, stat) => sum + stat.count, 0),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpServer.js","sourceRoot":"","sources":["../../src/server/McpServer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAChF,OAAO,EACL,qBAAqB,EAErB,0BAA0B,EAE1B,sBAAsB,EAEtB,yBAAyB,GAE1B,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAExD,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,EAAE,MAAM,EAAiB,MAAM,oBAAoB,CAAA;AAU1D;;GAEG;AACH,MAAM,OAAO,SAAS;IACZ,MAAM,CAAQ;IACd,SAAS,GAAgC,IAAI,CAAA;IAC7C,MAAM,CAAc;IACpB,YAAY,CAAc;IAC1B,aAAa,CAAe;IAC5B,YAAY,CAAc;IAC1B,cAAc,CAAgB;IAC9B,cAAc,CAAiB;IAEvC;;;;OAIG;IACH,YAAY,MAAoB;QAC9B,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAA;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QAEpB,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,yBAAyB,EAAE;YAC1C,IAAI,EAAE,MAAM,CAAC,UAAU;Y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;SACtD,CAAA;IACH,CAAC;IAED,UAAU;QACR,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAA;IAC7C,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC;YACH,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAA;YAE/C,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,EAAE,CAAA;YACnC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,yBAAyB,EAAE;gBAC1C,cAAc,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAC9D,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,EAC/B,CAAC,CACF;aACF,CAAC,CAAA;YAEF,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;YAC3B,CAAC;YAED,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,+BAA+B,CAAC,CAAA;QACnD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,8BAA8B,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;YAC3E,MAAM,IAAI,QAAQ,CAAC,0CAA0C,EAAE,wBAAwB,CAAC,CAAA;QAC1F,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,32 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Session history formatter for LLM context
|
|
3
|
-
*
|
|
4
|
-
* Converts SessionData to Markdown format for optimal token efficiency and LLM comprehension.
|
|
5
|
-
*/
|
|
6
1
|
import type { SessionData } from '../types/SessionData.js';
|
|
7
|
-
/**
|
|
8
|
-
* Formats session history as Markdown for LLM context.
|
|
9
|
-
*
|
|
10
|
-
* Extracts only the essential conversation flow (prompts and responses),
|
|
11
|
-
* removing metadata like sessionId, timestamps, and execution details.
|
|
12
|
-
*
|
|
13
|
-
* @param sessionData - Session data to format
|
|
14
|
-
* @returns Markdown-formatted conversation history
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const history = formatSessionHistory(sessionData)
|
|
19
|
-
* // Output:
|
|
20
|
-
* // # Session History: rule-advisor
|
|
21
|
-
* //
|
|
22
|
-
* // ## 1. User Request
|
|
23
|
-
* //
|
|
24
|
-
* // Task: Fix TypeScript type errors
|
|
25
|
-
* //
|
|
26
|
-
* // ## 1. Agent Response
|
|
27
|
-
* //
|
|
28
|
-
* // To fix type errors...
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
2
|
export declare function formatSessionHistory(sessionData: SessionData): string;
|
|
32
3
|
//# sourceMappingURL=SessionHistoryFormatter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionHistoryFormatter.d.ts","sourceRoot":"","sources":["../../src/session/SessionHistoryFormatter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"SessionHistoryFormatter.d.ts","sourceRoot":"","sources":["../../src/session/SessionHistoryFormatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE1D,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CA0BrE"}
|
|
@@ -1,37 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Session history formatter for LLM context
|
|
3
|
-
*
|
|
4
|
-
* Converts SessionData to Markdown format for optimal token efficiency and LLM comprehension.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Formats session history as Markdown for LLM context.
|
|
8
|
-
*
|
|
9
|
-
* Extracts only the essential conversation flow (prompts and responses),
|
|
10
|
-
* removing metadata like sessionId, timestamps, and execution details.
|
|
11
|
-
*
|
|
12
|
-
* @param sessionData - Session data to format
|
|
13
|
-
* @returns Markdown-formatted conversation history
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* const history = formatSessionHistory(sessionData)
|
|
18
|
-
* // Output:
|
|
19
|
-
* // # Session History: rule-advisor
|
|
20
|
-
* //
|
|
21
|
-
* // ## 1. User Request
|
|
22
|
-
* //
|
|
23
|
-
* // Task: Fix TypeScript type errors
|
|
24
|
-
* //
|
|
25
|
-
* // ## 1. Agent Response
|
|
26
|
-
* //
|
|
27
|
-
* // To fix type errors...
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
1
|
export function formatSessionHistory(sessionData) {
|
|
31
2
|
const conversations = sessionData.history
|
|
32
3
|
.map((entry, index) => {
|
|
33
4
|
const number = index + 1;
|
|
34
|
-
// Extract only the 'result' field from agent response (removing metadata)
|
|
35
5
|
let agentResponse = entry.response.stdout;
|
|
36
6
|
try {
|
|
37
7
|
const parsed = JSON.parse(entry.response.stdout);
|
|
@@ -39,10 +9,7 @@ export function formatSessionHistory(sessionData) {
|
|
|
39
9
|
agentResponse = String(parsed.result);
|
|
40
10
|
}
|
|
41
11
|
}
|
|
42
|
-
catch {
|
|
43
|
-
// If parsing fails, use the raw stdout as fallback
|
|
44
|
-
// This ensures backward compatibility and error resilience
|
|
45
|
-
}
|
|
12
|
+
catch { }
|
|
46
13
|
return `## ${number}. User Request
|
|
47
14
|
|
|
48
15
|
${entry.request.prompt}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionHistoryFormatter.js","sourceRoot":"","sources":["../../src/session/SessionHistoryFormatter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SessionHistoryFormatter.js","sourceRoot":"","sources":["../../src/session/SessionHistoryFormatter.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,oBAAoB,CAAC,WAAwB;IAC3D,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO;SACtC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACpB,MAAM,MAAM,GAAG,KAAK,GAAG,CAAC,CAAA;QAExB,IAAI,aAAa,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAA;QACzC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;YAChD,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,QAAQ,IAAI,MAAM,EAAE,CAAC;gBAC/D,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YACvC,CAAC;QACH,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QAEV,OAAO,MAAM,MAAM;;EAEvB,KAAK,CAAC,OAAO,CAAC,MAAM;;KAEjB,MAAM;;EAET,aAAa,EAAE,CAAA;IACb,CAAC,CAAC;SACD,IAAI,CAAC,MAAM,CAAC,CAAA;IAEf,OAAO,sBAAsB,WAAW,CAAC,SAAS;;EAElD,aAAa,EAAE,CAAA;AACjB,CAAC"}
|
|
@@ -1,158 +1,16 @@
|
|
|
1
1
|
import type { SessionConfig, SessionData, SessionEntry } from '../types/SessionData.js';
|
|
2
|
-
/**
|
|
3
|
-
* Session manager for handling session data persistence.
|
|
4
|
-
*
|
|
5
|
-
* Manages session data storage, retrieval, and cleanup operations.
|
|
6
|
-
* Ensures secure file handling with directory traversal prevention.
|
|
7
|
-
*/
|
|
8
2
|
export declare class SessionManager {
|
|
9
3
|
private readonly config;
|
|
10
|
-
/**
|
|
11
|
-
* Creates a new SessionManager instance.
|
|
12
|
-
*
|
|
13
|
-
* Initializes the session directory synchronously to ensure it exists
|
|
14
|
-
* before any operations are performed.
|
|
15
|
-
*
|
|
16
|
-
* @param config - Session configuration containing directory path and retention settings
|
|
17
|
-
*/
|
|
18
4
|
constructor(config: SessionConfig);
|
|
19
|
-
/**
|
|
20
|
-
* Initializes the session directory by creating it if it doesn't exist.
|
|
21
|
-
* Uses synchronous file operations to ensure directory exists before returning.
|
|
22
|
-
*
|
|
23
|
-
* @private
|
|
24
|
-
* @throws {Error} If directory creation fails
|
|
25
|
-
*/
|
|
26
5
|
private initializeSessionDirectory;
|
|
27
|
-
/**
|
|
28
|
-
* Validates a session ID to ensure it only contains allowed characters.
|
|
29
|
-
* Prevents directory traversal attacks by rejecting IDs with path manipulation characters.
|
|
30
|
-
*
|
|
31
|
-
* Session IDs must:
|
|
32
|
-
* - Not be empty
|
|
33
|
-
* - Contain only alphanumeric characters, hyphens (-), and underscores (_)
|
|
34
|
-
* - Not contain path traversal sequences (../, ./, etc.)
|
|
35
|
-
*
|
|
36
|
-
* @param sessionId - The session ID to validate
|
|
37
|
-
* @throws {Error} If the session ID contains invalid characters or is empty
|
|
38
|
-
*/
|
|
39
6
|
validateSessionId(sessionId: string): void;
|
|
40
|
-
/**
|
|
41
|
-
* Builds a file path for a session file following the naming convention:
|
|
42
|
-
* [session_id]_[agent_type].json
|
|
43
|
-
*
|
|
44
|
-
* Security measures:
|
|
45
|
-
* - Validates session ID before processing
|
|
46
|
-
* - Uses path.basename to strip directory components
|
|
47
|
-
* - Verifies final path is within session directory
|
|
48
|
-
*
|
|
49
|
-
* @param sessionId - The session identifier (validated for security)
|
|
50
|
-
* @param agentType - The type of agent (e.g., 'rule-advisor', 'quality-fixer')
|
|
51
|
-
* @returns The full file path for the session file
|
|
52
|
-
* @throws {Error} If the session ID is invalid or if path traversal is detected
|
|
53
|
-
*/
|
|
54
7
|
buildFilePath(sessionId: string, agentType: string): string;
|
|
55
|
-
/**
|
|
56
|
-
* Saves session data to a JSON file.
|
|
57
|
-
*
|
|
58
|
-
* If a session file already exists, the new request-response pair is appended
|
|
59
|
-
* to the existing history. Otherwise, a new session file is created.
|
|
60
|
-
*
|
|
61
|
-
* Error handling follows the error isolation principle:
|
|
62
|
-
* - Errors are logged but not thrown
|
|
63
|
-
* - The main execution flow continues even if session save fails
|
|
64
|
-
*
|
|
65
|
-
* Security features:
|
|
66
|
-
* - Session ID validation prevents directory traversal
|
|
67
|
-
* - File permissions are set to 0o600 (owner read/write only)
|
|
68
|
-
* - All file paths are verified to stay within session directory
|
|
69
|
-
*
|
|
70
|
-
* @param sessionId - The session identifier (alphanumeric, hyphens, underscores only)
|
|
71
|
-
* @param request - The request object containing agent, prompt, and optional parameters
|
|
72
|
-
* @param response - The response object containing stdout, stderr, exitCode, and executionTime
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* await sessionManager.saveSession(
|
|
76
|
-
* 'session-001',
|
|
77
|
-
* { agent: 'rule-advisor', prompt: 'Analyze code' },
|
|
78
|
-
* { stdout: 'Analysis complete', stderr: '', exitCode: 0, executionTime: 100 }
|
|
79
|
-
* )
|
|
80
|
-
*/
|
|
81
8
|
saveSession(sessionId: string, request: SessionEntry['request'], response: SessionEntry['response']): Promise<void>;
|
|
82
|
-
/**
|
|
83
|
-
* Builds session data by either creating a new session or appending to an existing one.
|
|
84
|
-
*
|
|
85
|
-
* @param sessionId - The session identifier
|
|
86
|
-
* @param agentType - The agent type
|
|
87
|
-
* @param sessionEntry - The new session entry to add
|
|
88
|
-
* @returns Complete session data ready to be saved
|
|
89
|
-
*/
|
|
90
9
|
private buildSessionData;
|
|
91
|
-
/**
|
|
92
|
-
* Logs structured error information when session save fails.
|
|
93
|
-
*
|
|
94
|
-
* @param sessionId - The session identifier
|
|
95
|
-
* @param agentType - The agent type
|
|
96
|
-
* @param error - The error that occurred
|
|
97
|
-
*/
|
|
98
10
|
private logSaveError;
|
|
99
|
-
/**
|
|
100
|
-
* Loads a session by session ID and agent type.
|
|
101
|
-
*
|
|
102
|
-
* Searches for the most recent session file matching the session ID and agent type.
|
|
103
|
-
* If multiple files exist with the same session ID and agent type, returns the one with the latest timestamp.
|
|
104
|
-
*
|
|
105
|
-
* **CRITICAL**: Sub-agent isolation is enforced - sessions are isolated by agent type.
|
|
106
|
-
* Same session_id with different agent_type will return different sessions.
|
|
107
|
-
*
|
|
108
|
-
* Error handling follows the error isolation principle:
|
|
109
|
-
* - Returns null if session file does not exist
|
|
110
|
-
* - Returns null if JSON parsing fails
|
|
111
|
-
* - Errors are logged but not thrown
|
|
112
|
-
*
|
|
113
|
-
* @param sessionId - The session identifier (alphanumeric, hyphens, underscores only)
|
|
114
|
-
* @param agentType - The agent type to filter sessions (e.g., 'rule-advisor', 'task-executor')
|
|
115
|
-
* @returns The session data if found, null otherwise
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* const session = await sessionManager.loadSession('session-001', 'rule-advisor')
|
|
119
|
-
* if (session) {
|
|
120
|
-
* console.log(`Loaded session with ${session.history.length} entries`)
|
|
121
|
-
* }
|
|
122
|
-
*/
|
|
123
11
|
loadSession(sessionId: string, agentType: string): Promise<SessionData | null>;
|
|
124
|
-
/**
|
|
125
|
-
* Loads an existing session file if it exists.
|
|
126
|
-
*
|
|
127
|
-
* Searches for the most recent session file matching the session ID and agent type.
|
|
128
|
-
*
|
|
129
|
-
* @param sessionId - The session identifier
|
|
130
|
-
* @param agentType - The agent type
|
|
131
|
-
* @returns The session data if found, null otherwise
|
|
132
|
-
*/
|
|
133
12
|
private loadExistingSession;
|
|
134
|
-
/**
|
|
135
|
-
* Logs structured error information when session load fails.
|
|
136
|
-
*
|
|
137
|
-
* @param sessionId - The session identifier
|
|
138
|
-
* @param error - The error that occurred
|
|
139
|
-
*/
|
|
140
13
|
private logLoadError;
|
|
141
|
-
/**
|
|
142
|
-
* Cleans up old session files based on retention period.
|
|
143
|
-
*
|
|
144
|
-
* Deletes session files older than the configured retention period (default 7 days).
|
|
145
|
-
* This is a best-effort operation - errors during deletion are logged but not thrown.
|
|
146
|
-
*
|
|
147
|
-
* Error handling follows the error isolation principle:
|
|
148
|
-
* - Individual file deletion failures do not stop the cleanup process
|
|
149
|
-
* - All errors are logged for debugging purposes
|
|
150
|
-
* - The method completes successfully even if some files cannot be deleted
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* // Cleanup old sessions (runs silently, logs errors only)
|
|
154
|
-
* await sessionManager.cleanupOldSessions()
|
|
155
|
-
*/
|
|
156
14
|
cleanupOldSessions(): Promise<void>;
|
|
157
15
|
}
|
|
158
16
|
//# sourceMappingURL=SessionManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionManager.d.ts","sourceRoot":"","sources":["../../src/session/SessionManager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEvF
|
|
1
|
+
{"version":3,"file":"SessionManager.d.ts","sourceRoot":"","sources":["../../src/session/SessionManager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEvF,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,MAAM,EAAE,aAAa;IAKjC,OAAO,CAAC,0BAA0B;IAa3B,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAa1C,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;IAiBrD,WAAW,CACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,EAChC,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,GACjC,OAAO,CAAC,IAAI,CAAC;YAkBF,gBAAgB;IAwB9B,OAAO,CAAC,YAAY;IASP,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;YA2B7E,mBAAmB;IA4BjC,OAAO,CAAC,YAAY;IAQP,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;CAsDjD"}
|