sub-agents-mcp 0.1.5 → 0.2.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 +97 -0
- package/dist/config/ServerConfig.d.ts +9 -0
- package/dist/config/ServerConfig.d.ts.map +1 -1
- package/dist/config/ServerConfig.js +17 -0
- package/dist/config/ServerConfig.js.map +1 -1
- package/dist/server/McpServer.d.ts +1 -0
- package/dist/server/McpServer.d.ts.map +1 -1
- package/dist/server/McpServer.js +17 -1
- package/dist/server/McpServer.js.map +1 -1
- package/dist/session/SessionHistoryFormatter.d.ts +32 -0
- package/dist/session/SessionHistoryFormatter.d.ts.map +1 -0
- package/dist/session/SessionHistoryFormatter.js +62 -0
- package/dist/session/SessionHistoryFormatter.js.map +1 -0
- package/dist/session/SessionManager.d.ts +158 -0
- package/dist/session/SessionManager.d.ts.map +1 -0
- package/dist/session/SessionManager.js +410 -0
- package/dist/session/SessionManager.js.map +1 -0
- package/dist/session/ToonConverter.d.ts +172 -0
- package/dist/session/ToonConverter.d.ts.map +1 -0
- package/dist/session/ToonConverter.js +593 -0
- package/dist/session/ToonConverter.js.map +1 -0
- package/dist/session/ToonUtils.d.ts +23 -0
- package/dist/session/ToonUtils.d.ts.map +1 -0
- package/dist/session/ToonUtils.js +75 -0
- package/dist/session/ToonUtils.js.map +1 -0
- package/dist/tools/RunAgentTool.d.ts +62 -4
- package/dist/tools/RunAgentTool.d.ts.map +1 -1
- package/dist/tools/RunAgentTool.js +223 -46
- package/dist/tools/RunAgentTool.js.map +1 -1
- package/dist/types/SessionData.d.ts +63 -0
- package/dist/types/SessionData.d.ts.map +1 -0
- package/dist/types/SessionData.js +3 -0
- package/dist/types/SessionData.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,7 +25,9 @@ Claude Code offers powerful sub-agent workflows—but they're limited to its own
|
|
|
25
25
|
- [Usage Examples](#usage-examples)
|
|
26
26
|
- [Agent Examples](#agent-examples)
|
|
27
27
|
- [Configuration Reference](#configuration-reference)
|
|
28
|
+
- [Session Management](#session-management)
|
|
28
29
|
- [Troubleshooting](#troubleshooting)
|
|
30
|
+
- [Design Philosophy](#design-philosophy)
|
|
29
31
|
- [How It Works](#how-it-works)
|
|
30
32
|
|
|
31
33
|
## Prerequisites
|
|
@@ -237,6 +239,78 @@ Example with timeout:
|
|
|
237
239
|
|
|
238
240
|
Agents have access to your project directory. Only use agent definitions from trusted sources.
|
|
239
241
|
|
|
242
|
+
## Session Management
|
|
243
|
+
|
|
244
|
+
Session management allows sub-agents to remember previous executions, which helps when you want agents to build on earlier work or maintain context across multiple calls.
|
|
245
|
+
|
|
246
|
+
### Why Sessions Matter
|
|
247
|
+
|
|
248
|
+
By default, each sub-agent execution starts with no context. With sessions enabled:
|
|
249
|
+
- Agents can reference their earlier work
|
|
250
|
+
- You get execution history for debugging
|
|
251
|
+
- Related tasks share context
|
|
252
|
+
|
|
253
|
+
### Enabling Sessions
|
|
254
|
+
|
|
255
|
+
Add these environment variables to your MCP configuration:
|
|
256
|
+
|
|
257
|
+
```json
|
|
258
|
+
{
|
|
259
|
+
"mcpServers": {
|
|
260
|
+
"sub-agents": {
|
|
261
|
+
"command": "npx",
|
|
262
|
+
"args": ["-y", "sub-agents-mcp"],
|
|
263
|
+
"env": {
|
|
264
|
+
"AGENTS_DIR": "/absolute/path/to/agents",
|
|
265
|
+
"AGENT_TYPE": "cursor",
|
|
266
|
+
"SESSION_ENABLED": "true",
|
|
267
|
+
"SESSION_DIR": "/absolute/path/to/session-storage",
|
|
268
|
+
"SESSION_RETENTION_DAYS": "7"
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
**Configuration options:**
|
|
276
|
+
|
|
277
|
+
- `SESSION_ENABLED` - Set to `"true"` to enable session management (default: `false`)
|
|
278
|
+
- `SESSION_DIR` - Where to store session files (default: `.mcp-sessions` in the current working directory)
|
|
279
|
+
- `SESSION_RETENTION_DAYS` - How long to keep session history in days (default: 7)
|
|
280
|
+
|
|
281
|
+
**Security consideration:** Session files contain execution history and may include sensitive information. Use absolute paths for `SESSION_DIR`.
|
|
282
|
+
|
|
283
|
+
### When to Use Sessions
|
|
284
|
+
|
|
285
|
+
Sessions work well for:
|
|
286
|
+
- **Iterative development**: "Based on your earlier findings, now fix the issues"
|
|
287
|
+
- **Multi-step workflows**: Breaking complex tasks into smaller sub-agent calls
|
|
288
|
+
- **Debugging**: Reviewing exactly what was executed and what results were returned
|
|
289
|
+
|
|
290
|
+
Note that sessions require additional storage and processing overhead.
|
|
291
|
+
|
|
292
|
+
### How Session Continuity Works
|
|
293
|
+
|
|
294
|
+
When sessions are enabled, the MCP response includes a `session_id` field. To continue the same session, pass this ID back in the next request.
|
|
295
|
+
|
|
296
|
+
**Important:** Your AI assistant must explicitly include the session_id in subsequent requests. While some assistants may do this automatically, it's not guaranteed. For reliable session continuity, add explicit instructions to your prompts or project rules.
|
|
297
|
+
|
|
298
|
+
**Example prompt instruction:**
|
|
299
|
+
```markdown
|
|
300
|
+
When using sub-agents with sessions enabled, always include the session_id
|
|
301
|
+
from the previous response in your next request to maintain context.
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
**Example project rule (e.g., `AGENTS.md`):**
|
|
305
|
+
```markdown
|
|
306
|
+
# Sub-Agent Session Guidelines
|
|
307
|
+
|
|
308
|
+
When calling the same sub-agent multiple times:
|
|
309
|
+
1. Extract the session_id from the MCP response
|
|
310
|
+
2. Pass it as a parameter in subsequent calls
|
|
311
|
+
3. This preserves context between executions
|
|
312
|
+
```
|
|
313
|
+
|
|
240
314
|
## Troubleshooting
|
|
241
315
|
|
|
242
316
|
### Timeout errors or authentication failures
|
|
@@ -265,6 +339,29 @@ Check that:
|
|
|
265
339
|
2. Ensure your chosen CLI tool is installed and accessible
|
|
266
340
|
3. Double-check that all environment variables are set in the MCP config
|
|
267
341
|
|
|
342
|
+
## Design Philosophy
|
|
343
|
+
|
|
344
|
+
### Why Independent Contexts Matter
|
|
345
|
+
|
|
346
|
+
Every sub-agent starts with a fresh context. This adds some startup overhead for each call, but it ensures that every task runs independently and without leftover state from previous runs.
|
|
347
|
+
|
|
348
|
+
**Context Isolation**
|
|
349
|
+
- Each agent only receives the information relevant to its task
|
|
350
|
+
- No context leakage between runs
|
|
351
|
+
- The main agent stays focused and lightweight
|
|
352
|
+
|
|
353
|
+
**Accuracy and Reliability**
|
|
354
|
+
- Sub-agents can specialize in a single goal without interference
|
|
355
|
+
- Less risk of confusion from unrelated context
|
|
356
|
+
- More consistent results in complex, multi-step workflows
|
|
357
|
+
|
|
358
|
+
**Scalability**
|
|
359
|
+
- Large tasks can be safely split into smaller sub-tasks
|
|
360
|
+
- Each sub-agent operates within its own token limit
|
|
361
|
+
- The main agent coordinates without hitting global context limits
|
|
362
|
+
|
|
363
|
+
The startup overhead is an intentional trade-off: the system favors clarity and accuracy over raw execution speed.
|
|
364
|
+
|
|
268
365
|
## How It Works
|
|
269
366
|
|
|
270
367
|
This MCP server acts as a bridge between your AI tool and a supported execution engine (Cursor CLI or Claude Code CLI).
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
* - AGENTS_DIR: Directory containing agent definition files (REQUIRED - must be absolute path)
|
|
11
11
|
* - AGENT_TYPE: Type of agent to use ('cursor' | 'claude') (default: 'cursor')
|
|
12
12
|
* - LOG_LEVEL: Log level for server operations (default: 'info')
|
|
13
|
+
* - SESSION_ENABLED: Enable session management functionality (default: false)
|
|
14
|
+
* - SESSION_DIR: Directory for storing session files (default: '.mcp-sessions')
|
|
15
|
+
* - SESSION_RETENTION_DAYS: Number of days to retain session files (default: 1)
|
|
13
16
|
*/
|
|
14
17
|
export declare class ServerConfig {
|
|
15
18
|
/** Server name identifier used for MCP registration */
|
|
@@ -24,6 +27,12 @@ export declare class ServerConfig {
|
|
|
24
27
|
readonly logLevel: 'debug' | 'info' | 'warn' | 'error';
|
|
25
28
|
/** Maximum execution timeout in milliseconds for agent execution */
|
|
26
29
|
readonly executionTimeoutMs: number;
|
|
30
|
+
/** Enable session management functionality */
|
|
31
|
+
readonly sessionEnabled: boolean;
|
|
32
|
+
/** Directory for storing session files */
|
|
33
|
+
readonly sessionDir: string;
|
|
34
|
+
/** Number of days to retain session files before cleanup */
|
|
35
|
+
readonly sessionRetentionDays: number;
|
|
27
36
|
/**
|
|
28
37
|
* Creates a new ServerConfig instance by loading values from environment variables
|
|
29
38
|
* or using default values.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerConfig.d.ts","sourceRoot":"","sources":["../../src/config/ServerConfig.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ServerConfig.d.ts","sourceRoot":"","sources":["../../src/config/ServerConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAY;IACvB,uDAAuD;IACvD,SAAgB,UAAU,EAAE,MAAM,CAAA;IAElC,6CAA6C;IAC7C,SAAgB,aAAa,EAAE,MAAM,CAAA;IAErC,gEAAgE;IAChE,SAAgB,SAAS,EAAE,MAAM,CAAA;IAEjC,yCAAyC;IACzC,SAAgB,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAE9C,sCAAsC;IACtC,SAAgB,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;IAE7D,oEAAoE;IACpE,SAAgB,kBAAkB,EAAE,MAAM,CAAA;IAE1C,8CAA8C;IAC9C,SAAgB,cAAc,EAAE,OAAO,CAAA;IAEvC,0CAA0C;IAC1C,SAAgB,UAAU,EAAE,MAAM,CAAA;IAElC,4DAA4D;IAC5D,SAAgB,oBAAoB,EAAE,MAAM,CAAA;IAE5C;;;;OAIG;;CAiDJ"}
|
|
@@ -13,6 +13,9 @@ exports.ServerConfig = void 0;
|
|
|
13
13
|
* - AGENTS_DIR: Directory containing agent definition files (REQUIRED - must be absolute path)
|
|
14
14
|
* - AGENT_TYPE: Type of agent to use ('cursor' | 'claude') (default: 'cursor')
|
|
15
15
|
* - LOG_LEVEL: Log level for server operations (default: 'info')
|
|
16
|
+
* - SESSION_ENABLED: Enable session management functionality (default: false)
|
|
17
|
+
* - SESSION_DIR: Directory for storing session files (default: '.mcp-sessions')
|
|
18
|
+
* - SESSION_RETENTION_DAYS: Number of days to retain session files (default: 1)
|
|
16
19
|
*/
|
|
17
20
|
class ServerConfig {
|
|
18
21
|
/**
|
|
@@ -48,6 +51,20 @@ class ServerConfig {
|
|
|
48
51
|
else {
|
|
49
52
|
this.executionTimeoutMs = 300000;
|
|
50
53
|
}
|
|
54
|
+
// Session management configuration
|
|
55
|
+
// Only 'true' string enables session management, all other values are treated as false
|
|
56
|
+
this.sessionEnabled = process.env['SESSION_ENABLED'] === 'true';
|
|
57
|
+
this.sessionDir = process.env['SESSION_DIR'] || '.mcp-sessions';
|
|
58
|
+
// Parse SESSION_RETENTION_DAYS with validation (must be positive integer)
|
|
59
|
+
const retentionDaysEnv = process.env['SESSION_RETENTION_DAYS'];
|
|
60
|
+
if (retentionDaysEnv?.trim()) {
|
|
61
|
+
const parsedDays = Number.parseInt(retentionDaysEnv, 10);
|
|
62
|
+
// Use default (1 day) for invalid values (NaN, zero, or negative)
|
|
63
|
+
this.sessionRetentionDays = Number.isNaN(parsedDays) || parsedDays <= 0 ? 1 : parsedDays;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this.sessionRetentionDays = 1;
|
|
67
|
+
}
|
|
51
68
|
}
|
|
52
69
|
}
|
|
53
70
|
exports.ServerConfig = ServerConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerConfig.js","sourceRoot":"","sources":["../../src/config/ServerConfig.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"ServerConfig.js","sourceRoot":"","sources":["../../src/config/ServerConfig.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,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,MAAM,CAAA;QAC/D,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,eAAe,CAAA;QAE/D,0EAA0E;QAC1E,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAA;QAC9D,IAAI,gBAAgB,EAAE,IAAI,EAAE,EAAE,CAAC;YAC7B,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAA;YACxD,kEAAkE;YAClE,IAAI,CAAC,oBAAoB,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAA;QAC1F,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC;CACF;AAjFD,oCAiFC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpServer.d.ts","sourceRoot":"","sources":["../../src/server/McpServer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAeH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"McpServer.d.ts","sourceRoot":"","sources":["../../src/server/McpServer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAeH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAQ3D;;GAEG;AACH,UAAU,UAAU;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB;AAOD;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,SAAS,CAAoC;IACrD,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,aAAa,C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,EAAE,IAAI,CAAA;SAAE,CAAC,CAAA;KAClF;IAOD;;OAEG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAuB7B"}
|
package/dist/server/McpServer.js
CHANGED
|
@@ -21,6 +21,7 @@ const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
|
21
21
|
const AgentManager_1 = require("../agents/AgentManager");
|
|
22
22
|
const AgentExecutor_1 = require("../execution/AgentExecutor");
|
|
23
23
|
const AgentResources_1 = require("../resources/AgentResources");
|
|
24
|
+
const SessionManager_1 = require("../session/SessionManager");
|
|
24
25
|
const RunAgentTool_1 = require("../tools/RunAgentTool");
|
|
25
26
|
const ErrorHandler_1 = require("../utils/ErrorHandler");
|
|
26
27
|
const Logger_1 = require("../utils/Logger");
|
|
@@ -50,7 +51,22 @@ class McpServer {
|
|
|
50
51
|
// Create logger with log level from config
|
|
51
52
|
const executorLogger = new Logger_1.Logger(config.logLevel);
|
|
52
53
|
this.agentExecutor = new AgentExecutor_1.AgentExecutor(executionConfig, executorLogger);
|
|
53
|
-
|
|
54
|
+
// Initialize SessionManager if session management is enabled
|
|
55
|
+
if (config.sessionEnabled) {
|
|
56
|
+
this.sessionManager = new SessionManager_1.SessionManager({
|
|
57
|
+
enabled: config.sessionEnabled,
|
|
58
|
+
sessionDir: config.sessionDir,
|
|
59
|
+
retentionDays: config.sessionRetentionDays,
|
|
60
|
+
});
|
|
61
|
+
this.log('info', 'Session management enabled', {
|
|
62
|
+
sessionDir: config.sessionDir,
|
|
63
|
+
retentionDays: config.sessionRetentionDays,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this.log('info', 'Session management disabled');
|
|
68
|
+
}
|
|
69
|
+
this.runAgentTool = new RunAgentTool_1.RunAgentTool(this.agentExecutor, this.agentManager, this.sessionManager);
|
|
54
70
|
this.agentResources = new AgentResources_1.AgentResources(this.agentManager);
|
|
55
71
|
// Initialize MCP server with capabilities
|
|
56
72
|
this.server = new index_js_1.Server({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpServer.js","sourceRoot":"","sources":["../../src/server/McpServer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAEH,wEAAkE;AAClE,wEAAgF;AAChF,iEAS2C;AAC3C,0DAAsD;AAEtD,+DAAkF;AAClF,iEAA6D;AAC7D,yDAAqD;AACrD,yDAAkE;AAClE,6CAAyC;AAezC;;GAEG;AACH,MAAa,SAAS;IASpB;;;;OAIG;IACH,YAAY,MAAoB;QAZxB,cAAS,GAAgC,IAAI,CAAA;QAanD,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;YACvB,OAAO,EAAE,MAAM,CAAC,aAAa;SAC9B,CAAC,CAAA;QAEF,yCAAyC;QACzC,IAAI,CAAC,YAAY,GAAG,IAAI,2BAAY,CAAC,MAAM,CAAC,CAAA;QAE5C,gEAAgE;QAChE,MAAM,eAAe,GAAG,IAAA,qCAAqB,EAAC,MAAM,CAAC,SAAS,EAAE;YAC9D,gBAAgB,EAAE,MAAM,CAAC,kBAAkB,EAAE,mDAAmD;SACjG,CAAC,CAAA;QAEF,2CAA2C;QAC3C,MAAM,cAAc,GAAG,IAAI,eAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QAElD,IAAI,CAAC,aAAa,GAAG,IAAI,6BAAa,CAAC,eAAe,EAAE,cAAc,CAAC,CAAA;QACvE,IAAI,CAAC,YAAY,GAAG,IAAI,2BAAY,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;QAC3E,IAAI,CAAC,cAAc,GAAG,IAAI,+BAAc,CAAC,IAAI,CAAC,YAAY,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,EAAE;YAChC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,iBAAiB,EAAE;SACtD,CAAA;IACH,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAA;IAC7C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,IAAI,CAAC;YACH,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAA;YAE/C,uCAAuC;YACvC,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,uBAAQ,CAAC,0CAA0C,EAAE,wBAAwB,CAAC,CAAA;QAC1F,CAAC;IACH,CAAC;CACF;AA5aD,8BA4aC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session history formatter for LLM context
|
|
3
|
+
*
|
|
4
|
+
* Converts SessionData to Markdown format for optimal token efficiency and LLM comprehension.
|
|
5
|
+
*/
|
|
6
|
+
import type { SessionData } from '../types/SessionData';
|
|
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
|
+
export declare function formatSessionHistory(sessionData: SessionData): string;
|
|
32
|
+
//# sourceMappingURL=SessionHistoryFormatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionHistoryFormatter.d.ts","sourceRoot":"","sources":["../../src/session/SessionHistoryFormatter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CA8BrE"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Session history formatter for LLM context
|
|
4
|
+
*
|
|
5
|
+
* Converts SessionData to Markdown format for optimal token efficiency and LLM comprehension.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.formatSessionHistory = formatSessionHistory;
|
|
9
|
+
/**
|
|
10
|
+
* Formats session history as Markdown for LLM context.
|
|
11
|
+
*
|
|
12
|
+
* Extracts only the essential conversation flow (prompts and responses),
|
|
13
|
+
* removing metadata like sessionId, timestamps, and execution details.
|
|
14
|
+
*
|
|
15
|
+
* @param sessionData - Session data to format
|
|
16
|
+
* @returns Markdown-formatted conversation history
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const history = formatSessionHistory(sessionData)
|
|
21
|
+
* // Output:
|
|
22
|
+
* // # Session History: rule-advisor
|
|
23
|
+
* //
|
|
24
|
+
* // ## 1. User Request
|
|
25
|
+
* //
|
|
26
|
+
* // Task: Fix TypeScript type errors
|
|
27
|
+
* //
|
|
28
|
+
* // ## 1. Agent Response
|
|
29
|
+
* //
|
|
30
|
+
* // To fix type errors...
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
function formatSessionHistory(sessionData) {
|
|
34
|
+
const conversations = sessionData.history
|
|
35
|
+
.map((entry, index) => {
|
|
36
|
+
const number = index + 1;
|
|
37
|
+
// Extract only the 'result' field from agent response (removing metadata)
|
|
38
|
+
let agentResponse = entry.response.stdout;
|
|
39
|
+
try {
|
|
40
|
+
const parsed = JSON.parse(entry.response.stdout);
|
|
41
|
+
if (parsed && typeof parsed === 'object' && 'result' in parsed) {
|
|
42
|
+
agentResponse = String(parsed.result);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// If parsing fails, use the raw stdout as fallback
|
|
47
|
+
// This ensures backward compatibility and error resilience
|
|
48
|
+
}
|
|
49
|
+
return `## ${number}. User Request
|
|
50
|
+
|
|
51
|
+
${entry.request.prompt}
|
|
52
|
+
|
|
53
|
+
## ${number}. Agent Response
|
|
54
|
+
|
|
55
|
+
${agentResponse}`;
|
|
56
|
+
})
|
|
57
|
+
.join('\n\n');
|
|
58
|
+
return `# Session History: ${sessionData.agentType}
|
|
59
|
+
|
|
60
|
+
${conversations}`;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=SessionHistoryFormatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionHistoryFormatter.js","sourceRoot":"","sources":["../../src/session/SessionHistoryFormatter.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AA4BH,oDA8BC;AAtDD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAgB,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,0EAA0E;QAC1E,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;YACP,mDAAmD;YACnD,2DAA2D;QAC7D,CAAC;QAED,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"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { SessionConfig, SessionData, SessionEntry } from '../types/SessionData';
|
|
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
|
+
export declare class SessionManager {
|
|
9
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
cleanupOldSessions(): Promise<void>;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=SessionManager.d.ts.map
|
|
@@ -0,0 +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,sBAAsB,CAAA;AAEpF;;;;;GAKG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IAEtC;;;;;;;OAOG;gBACS,MAAM,EAAE,aAAa;IAKjC;;;;;;OAMG;IACH,OAAO,CAAC,0BAA0B;IAalC;;;;;;;;;;;OAWG;IACI,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAcjD;;;;;;;;;;;;;OAaG;IACI,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;IA0BlE;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACU,WAAW,CACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,EAChC,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,GACjC,OAAO,CAAC,IAAI,CAAC;IA6BhB;;;;;;;OAOG;YACW,gBAAgB;IA0B9B;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;IASpB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACU,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAoC3F;;;;;;;;OAQG;YACW,mBAAmB;IAkCjC;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAQpB;;;;;;;;;;;;;;OAcG;IACU,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;CAmEjD"}
|