mcp-ai-agent-guidelines 0.11.2 → 0.12.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 +2 -0
- package/dist/tools/agent-orchestrator.d.ts +39 -0
- package/dist/tools/agent-orchestrator.d.ts.map +1 -0
- package/dist/tools/agent-orchestrator.js +360 -0
- package/dist/tools/agent-orchestrator.js.map +1 -0
- package/dist/tools/shared/a2a-context.d.ts +154 -0
- package/dist/tools/shared/a2a-context.d.ts.map +1 -0
- package/dist/tools/shared/a2a-context.js +170 -0
- package/dist/tools/shared/a2a-context.js.map +1 -0
- package/dist/tools/shared/a2a-errors.d.ts +73 -0
- package/dist/tools/shared/a2a-errors.d.ts.map +1 -0
- package/dist/tools/shared/a2a-errors.js +132 -0
- package/dist/tools/shared/a2a-errors.js.map +1 -0
- package/dist/tools/shared/async-patterns.d.ts +143 -0
- package/dist/tools/shared/async-patterns.d.ts.map +1 -0
- package/dist/tools/shared/async-patterns.js +339 -0
- package/dist/tools/shared/async-patterns.js.map +1 -0
- package/dist/tools/shared/execution-controller.d.ts +92 -0
- package/dist/tools/shared/execution-controller.d.ts.map +1 -0
- package/dist/tools/shared/execution-controller.js +337 -0
- package/dist/tools/shared/execution-controller.js.map +1 -0
- package/dist/tools/shared/index.d.ts +23 -0
- package/dist/tools/shared/index.d.ts.map +1 -0
- package/dist/tools/shared/index.js +24 -0
- package/dist/tools/shared/index.js.map +1 -0
- package/dist/tools/shared/tool-invoker.d.ts +71 -0
- package/dist/tools/shared/tool-invoker.d.ts.map +1 -0
- package/dist/tools/shared/tool-invoker.js +255 -0
- package/dist/tools/shared/tool-invoker.js.map +1 -0
- package/dist/tools/shared/tool-registry.d.ts +153 -0
- package/dist/tools/shared/tool-registry.d.ts.map +1 -0
- package/dist/tools/shared/tool-registry.js +232 -0
- package/dist/tools/shared/tool-registry.js.map +1 -0
- package/dist/tools/shared/trace-logger.d.ts +191 -0
- package/dist/tools/shared/trace-logger.d.ts.map +1 -0
- package/dist/tools/shared/trace-logger.js +437 -0
- package/dist/tools/shared/trace-logger.js.map +1 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -95,6 +95,8 @@ Configuration is in `.mlc_config.json`. Ignored patterns and retries are configu
|
|
|
95
95
|
### Advanced Features
|
|
96
96
|
|
|
97
97
|
- **[🌊 Flow-Based Prompting](./docs/tips/flow-prompting-examples.md)** - Multi-step prompt workflows
|
|
98
|
+
- **[🔗 Agent-to-Agent (A2A) Orchestration](./docs/tips/a2a-orchestration-guide.md)** - Tool-to-tool chaining with context propagation
|
|
99
|
+
- **[📋 A2A Practical Examples](./docs/tips/a2a-examples.md)** - Real-world A2A workflow patterns
|
|
98
100
|
- **[🎨 Mermaid Diagram Generation](./docs/tips/mermaid-diagram-examples.md)** - Create flowcharts, sequences, ER diagrams
|
|
99
101
|
- **[🔍 Code Quality Analysis](./docs/tips/code-quality-improvements.md)** - Hygiene scoring and best practices
|
|
100
102
|
- **[⚡ Sprint Planning](./docs/tips/sprint-planning-reliability.md)** - Dependency-aware timeline calculation
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Orchestrator Tool
|
|
3
|
+
*
|
|
4
|
+
* High-level MCP tool for Agent-to-Agent (A2A) orchestration.
|
|
5
|
+
* Enables declarative workflow execution using registered tools.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Execute pre-defined workflow templates
|
|
9
|
+
* - Custom workflow execution from user-provided plans
|
|
10
|
+
* - Automatic context management and tracing
|
|
11
|
+
* - Error handling with fallback strategies
|
|
12
|
+
* - Execution visualization and reporting
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Workflow template identifier
|
|
16
|
+
*/
|
|
17
|
+
export type WorkflowTemplate = "quality-audit" | "security-scan" | "code-analysis-pipeline" | "documentation-generation";
|
|
18
|
+
/**
|
|
19
|
+
* Agent Orchestrator Tool
|
|
20
|
+
*
|
|
21
|
+
* Orchestrates multi-tool workflows with A2A chaining capabilities.
|
|
22
|
+
*
|
|
23
|
+
* @param args - Orchestrator configuration
|
|
24
|
+
* @returns Workflow execution result with trace and summary
|
|
25
|
+
*/
|
|
26
|
+
export declare function agentOrchestrator(args: unknown): Promise<{
|
|
27
|
+
content: {
|
|
28
|
+
type: string;
|
|
29
|
+
text: string;
|
|
30
|
+
}[];
|
|
31
|
+
isError?: undefined;
|
|
32
|
+
} | {
|
|
33
|
+
content: {
|
|
34
|
+
type: string;
|
|
35
|
+
text: string;
|
|
36
|
+
}[];
|
|
37
|
+
isError: boolean;
|
|
38
|
+
}>;
|
|
39
|
+
//# sourceMappingURL=agent-orchestrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-orchestrator.d.ts","sourceRoot":"","sources":["../../src/tools/agent-orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAiBH;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACzB,eAAe,GACf,eAAe,GACf,wBAAwB,GACxB,0BAA0B,CAAC;AA6F9B;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,OAAO;;;;;;;;;;;;GA0HpD"}
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Orchestrator Tool
|
|
3
|
+
*
|
|
4
|
+
* High-level MCP tool for Agent-to-Agent (A2A) orchestration.
|
|
5
|
+
* Enables declarative workflow execution using registered tools.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Execute pre-defined workflow templates
|
|
9
|
+
* - Custom workflow execution from user-provided plans
|
|
10
|
+
* - Automatic context management and tracing
|
|
11
|
+
* - Error handling with fallback strategies
|
|
12
|
+
* - Execution visualization and reporting
|
|
13
|
+
*/
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
import { createA2AContext, getExecutionSummary, } from "./shared/a2a-context.js";
|
|
16
|
+
import { executeChain, } from "./shared/execution-controller.js";
|
|
17
|
+
import { logger } from "./shared/logger.js";
|
|
18
|
+
import { createTraceFromContext, traceLogger } from "./shared/trace-logger.js";
|
|
19
|
+
/**
|
|
20
|
+
* Input schema for agent orchestrator
|
|
21
|
+
*/
|
|
22
|
+
const AgentOrchestratorSchema = z.object({
|
|
23
|
+
// Workflow execution mode
|
|
24
|
+
mode: z
|
|
25
|
+
.enum(["template", "custom"])
|
|
26
|
+
.describe("Execution mode: template for pre-defined workflows, custom for user-defined"),
|
|
27
|
+
// Template workflow (for mode: template)
|
|
28
|
+
template: z
|
|
29
|
+
.enum([
|
|
30
|
+
"quality-audit",
|
|
31
|
+
"security-scan",
|
|
32
|
+
"code-analysis-pipeline",
|
|
33
|
+
"documentation-generation",
|
|
34
|
+
])
|
|
35
|
+
.optional()
|
|
36
|
+
.describe("Pre-defined workflow template to execute"),
|
|
37
|
+
// Custom execution plan (for mode: custom)
|
|
38
|
+
executionPlan: z
|
|
39
|
+
.object({
|
|
40
|
+
strategy: z.enum([
|
|
41
|
+
"sequential",
|
|
42
|
+
"parallel",
|
|
43
|
+
"parallel-with-join",
|
|
44
|
+
"conditional",
|
|
45
|
+
"retry-with-backoff",
|
|
46
|
+
]),
|
|
47
|
+
steps: z.array(z.object({
|
|
48
|
+
id: z.string(),
|
|
49
|
+
toolName: z.string(),
|
|
50
|
+
args: z.unknown().describe("Arguments to pass to the tool"),
|
|
51
|
+
dependencies: z.array(z.string()).optional(),
|
|
52
|
+
})),
|
|
53
|
+
onError: z.enum(["abort", "skip", "fallback"]),
|
|
54
|
+
fallbackTool: z.string().optional(),
|
|
55
|
+
fallbackArgs: z
|
|
56
|
+
.unknown()
|
|
57
|
+
.optional()
|
|
58
|
+
.describe("Arguments for fallback tool"),
|
|
59
|
+
})
|
|
60
|
+
.optional()
|
|
61
|
+
.describe("Custom execution plan for the workflow"),
|
|
62
|
+
// Workflow parameters (passed to tools in the workflow)
|
|
63
|
+
parameters: z
|
|
64
|
+
.record(z.unknown())
|
|
65
|
+
.optional()
|
|
66
|
+
.describe("Parameters to pass to workflow steps"),
|
|
67
|
+
// Orchestration config
|
|
68
|
+
config: z
|
|
69
|
+
.object({
|
|
70
|
+
maxDepth: z.number().optional().describe("Maximum recursion depth"),
|
|
71
|
+
timeoutMs: z
|
|
72
|
+
.number()
|
|
73
|
+
.optional()
|
|
74
|
+
.describe("Per-tool timeout in milliseconds"),
|
|
75
|
+
chainTimeoutMs: z
|
|
76
|
+
.number()
|
|
77
|
+
.optional()
|
|
78
|
+
.describe("Total chain timeout in milliseconds"),
|
|
79
|
+
correlationId: z
|
|
80
|
+
.string()
|
|
81
|
+
.optional()
|
|
82
|
+
.describe("Custom correlation ID for tracing"),
|
|
83
|
+
})
|
|
84
|
+
.optional()
|
|
85
|
+
.describe("Orchestration configuration"),
|
|
86
|
+
// Output options
|
|
87
|
+
includeTrace: z
|
|
88
|
+
.boolean()
|
|
89
|
+
.optional()
|
|
90
|
+
.default(true)
|
|
91
|
+
.describe("Include execution trace in output"),
|
|
92
|
+
includeVisualization: z
|
|
93
|
+
.boolean()
|
|
94
|
+
.optional()
|
|
95
|
+
.default(false)
|
|
96
|
+
.describe("Include Mermaid visualization of execution"),
|
|
97
|
+
});
|
|
98
|
+
/**
|
|
99
|
+
* Agent Orchestrator Tool
|
|
100
|
+
*
|
|
101
|
+
* Orchestrates multi-tool workflows with A2A chaining capabilities.
|
|
102
|
+
*
|
|
103
|
+
* @param args - Orchestrator configuration
|
|
104
|
+
* @returns Workflow execution result with trace and summary
|
|
105
|
+
*/
|
|
106
|
+
export async function agentOrchestrator(args) {
|
|
107
|
+
const input = AgentOrchestratorSchema.parse(args);
|
|
108
|
+
logger.info("Starting agent orchestration", {
|
|
109
|
+
mode: input.mode,
|
|
110
|
+
template: input.template,
|
|
111
|
+
});
|
|
112
|
+
// Create A2A context
|
|
113
|
+
const context = createA2AContext(input.config?.correlationId, input.config);
|
|
114
|
+
// Start tracing
|
|
115
|
+
if (input.includeTrace) {
|
|
116
|
+
traceLogger.startChain(context);
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
// Get execution plan
|
|
120
|
+
let plan;
|
|
121
|
+
if (input.mode === "template") {
|
|
122
|
+
if (!input.template) {
|
|
123
|
+
throw new Error("Template name is required for template mode");
|
|
124
|
+
}
|
|
125
|
+
plan = getTemplateWorkflow(input.template, input.parameters || {});
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
if (!input.executionPlan) {
|
|
129
|
+
throw new Error("Execution plan is required for custom mode");
|
|
130
|
+
}
|
|
131
|
+
plan = convertCustomPlan(input.executionPlan, input.parameters || {});
|
|
132
|
+
}
|
|
133
|
+
// Execute workflow
|
|
134
|
+
const result = await executeChain(plan, context);
|
|
135
|
+
// End tracing
|
|
136
|
+
if (input.includeTrace) {
|
|
137
|
+
traceLogger.endChain(context, result.success);
|
|
138
|
+
}
|
|
139
|
+
// Get execution summary
|
|
140
|
+
const summary = getExecutionSummary(context);
|
|
141
|
+
// Build response
|
|
142
|
+
const response = {
|
|
143
|
+
success: result.success,
|
|
144
|
+
finalOutput: result.finalOutput,
|
|
145
|
+
summary: {
|
|
146
|
+
...result.summary,
|
|
147
|
+
correlationId: summary.correlationId,
|
|
148
|
+
maxDepthReached: summary.maxDepthReached,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
// Add trace if requested
|
|
152
|
+
if (input.includeTrace) {
|
|
153
|
+
const trace = createTraceFromContext(context);
|
|
154
|
+
response.trace = {
|
|
155
|
+
correlationId: trace.correlationId,
|
|
156
|
+
spans: trace.spans.map((span) => ({
|
|
157
|
+
toolName: span.toolName,
|
|
158
|
+
durationMs: span.durationMs,
|
|
159
|
+
status: span.status,
|
|
160
|
+
depth: span.depth,
|
|
161
|
+
})),
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
// Add visualization if requested
|
|
165
|
+
if (input.includeVisualization) {
|
|
166
|
+
response.visualization = generateWorkflowVisualization(context, result);
|
|
167
|
+
}
|
|
168
|
+
// Add step details
|
|
169
|
+
response.steps = Array.from(result.stepResults.entries()).map(([id, stepResult]) => ({
|
|
170
|
+
id,
|
|
171
|
+
success: stepResult.success,
|
|
172
|
+
error: stepResult.error,
|
|
173
|
+
}));
|
|
174
|
+
return {
|
|
175
|
+
content: [
|
|
176
|
+
{
|
|
177
|
+
type: "text",
|
|
178
|
+
text: JSON.stringify(response, null, 2),
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
// End tracing with error
|
|
185
|
+
if (input.includeTrace) {
|
|
186
|
+
traceLogger.endChain(context, false, error instanceof Error ? error.message : String(error));
|
|
187
|
+
}
|
|
188
|
+
logger.error("Agent orchestration failed", {
|
|
189
|
+
error: error instanceof Error ? error.message : String(error),
|
|
190
|
+
correlationId: context.correlationId,
|
|
191
|
+
});
|
|
192
|
+
return {
|
|
193
|
+
content: [
|
|
194
|
+
{
|
|
195
|
+
type: "text",
|
|
196
|
+
text: JSON.stringify({
|
|
197
|
+
success: false,
|
|
198
|
+
error: error instanceof Error ? error.message : String(error),
|
|
199
|
+
correlationId: context.correlationId,
|
|
200
|
+
}, null, 2),
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
isError: true,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Get pre-defined workflow template
|
|
209
|
+
*/
|
|
210
|
+
function getTemplateWorkflow(template, parameters) {
|
|
211
|
+
switch (template) {
|
|
212
|
+
case "quality-audit":
|
|
213
|
+
return {
|
|
214
|
+
strategy: "sequential",
|
|
215
|
+
onError: "abort",
|
|
216
|
+
steps: [
|
|
217
|
+
{
|
|
218
|
+
id: "clean-code",
|
|
219
|
+
toolName: "clean-code-scorer",
|
|
220
|
+
args: {
|
|
221
|
+
projectPath: parameters.projectPath || ".",
|
|
222
|
+
...parameters,
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
id: "code-hygiene",
|
|
227
|
+
toolName: "code-hygiene-analyzer",
|
|
228
|
+
args: {
|
|
229
|
+
codeContent: parameters.codeContent || "",
|
|
230
|
+
language: parameters.language || "typescript",
|
|
231
|
+
...parameters,
|
|
232
|
+
},
|
|
233
|
+
dependencies: ["clean-code"],
|
|
234
|
+
},
|
|
235
|
+
],
|
|
236
|
+
};
|
|
237
|
+
case "security-scan":
|
|
238
|
+
return {
|
|
239
|
+
strategy: "parallel",
|
|
240
|
+
onError: "skip",
|
|
241
|
+
steps: [
|
|
242
|
+
{
|
|
243
|
+
id: "dependency-audit",
|
|
244
|
+
toolName: "dependency-auditor",
|
|
245
|
+
args: {
|
|
246
|
+
dependencyContent: parameters.dependencyContent || "",
|
|
247
|
+
...parameters,
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
id: "security-hardening",
|
|
252
|
+
toolName: "security-hardening-prompt-builder",
|
|
253
|
+
args: {
|
|
254
|
+
codeContext: parameters.codeContext || "",
|
|
255
|
+
...parameters,
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
],
|
|
259
|
+
};
|
|
260
|
+
case "code-analysis-pipeline":
|
|
261
|
+
return {
|
|
262
|
+
strategy: "sequential",
|
|
263
|
+
onError: "abort",
|
|
264
|
+
steps: [
|
|
265
|
+
{
|
|
266
|
+
id: "semantic-analysis",
|
|
267
|
+
toolName: "semantic-code-analyzer",
|
|
268
|
+
args: {
|
|
269
|
+
codeContent: parameters.codeContent || "",
|
|
270
|
+
...parameters,
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
id: "clean-code-score",
|
|
275
|
+
toolName: "clean-code-scorer",
|
|
276
|
+
args: {
|
|
277
|
+
projectPath: parameters.projectPath || ".",
|
|
278
|
+
...parameters,
|
|
279
|
+
},
|
|
280
|
+
dependencies: ["semantic-analysis"],
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
id: "diagram-generation",
|
|
284
|
+
toolName: "mermaid-diagram-generator",
|
|
285
|
+
args: {
|
|
286
|
+
description: parameters.description || "Code analysis results",
|
|
287
|
+
diagramType: "flowchart",
|
|
288
|
+
...parameters,
|
|
289
|
+
},
|
|
290
|
+
dependencies: ["clean-code-score"],
|
|
291
|
+
},
|
|
292
|
+
],
|
|
293
|
+
};
|
|
294
|
+
case "documentation-generation":
|
|
295
|
+
return {
|
|
296
|
+
strategy: "sequential",
|
|
297
|
+
onError: "abort",
|
|
298
|
+
steps: [
|
|
299
|
+
{
|
|
300
|
+
id: "project-onboarding",
|
|
301
|
+
toolName: "project-onboarding",
|
|
302
|
+
args: {
|
|
303
|
+
projectPath: parameters.projectPath || ".",
|
|
304
|
+
...parameters,
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
id: "doc-generation",
|
|
309
|
+
toolName: "documentation-generator-prompt-builder",
|
|
310
|
+
args: {
|
|
311
|
+
contentType: parameters.contentType || "API",
|
|
312
|
+
...parameters,
|
|
313
|
+
},
|
|
314
|
+
dependencies: ["project-onboarding"],
|
|
315
|
+
},
|
|
316
|
+
],
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Convert custom execution plan to internal format
|
|
322
|
+
*/
|
|
323
|
+
function convertCustomPlan(customPlan, parameters) {
|
|
324
|
+
const steps = customPlan.steps.map((step) => ({
|
|
325
|
+
id: step.id,
|
|
326
|
+
toolName: step.toolName,
|
|
327
|
+
args: typeof step.args === "object" && step.args !== null
|
|
328
|
+
? { ...step.args, ...parameters }
|
|
329
|
+
: parameters || step.args,
|
|
330
|
+
dependencies: step.dependencies,
|
|
331
|
+
}));
|
|
332
|
+
return {
|
|
333
|
+
strategy: customPlan.strategy,
|
|
334
|
+
steps,
|
|
335
|
+
onError: customPlan.onError,
|
|
336
|
+
fallbackTool: customPlan.fallbackTool,
|
|
337
|
+
fallbackArgs: customPlan.fallbackArgs,
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Generate Mermaid visualization of workflow execution
|
|
342
|
+
*/
|
|
343
|
+
function generateWorkflowVisualization(context, _result) {
|
|
344
|
+
const lines = ["```mermaid", "graph TD"];
|
|
345
|
+
// Add nodes for each tool invocation
|
|
346
|
+
for (const entry of context.executionLog) {
|
|
347
|
+
const nodeId = `${entry.toolName}_${entry.depth}`;
|
|
348
|
+
const status = entry.status === "success" ? "✅" : "❌";
|
|
349
|
+
const label = `${status} ${entry.toolName}<br/>${entry.durationMs}ms`;
|
|
350
|
+
lines.push(` ${nodeId}["${label}"]`);
|
|
351
|
+
// Add edge from parent if exists
|
|
352
|
+
if (entry.parentToolName) {
|
|
353
|
+
const parentId = `${entry.parentToolName}_${entry.depth - 1}`;
|
|
354
|
+
lines.push(` ${parentId} --> ${nodeId}`);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
lines.push("```");
|
|
358
|
+
return lines.join("\n");
|
|
359
|
+
}
|
|
360
|
+
//# sourceMappingURL=agent-orchestrator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-orchestrator.js","sourceRoot":"","sources":["../../src/tools/agent-orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEN,gBAAgB,EAChB,mBAAmB,GACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAIN,YAAY,GACZ,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAW/E;;GAEG;AACH,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,0BAA0B;IAC1B,IAAI,EAAE,CAAC;SACL,IAAI,CAAC,CAAC,UAAU,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EnD,qCAAqC;IACrC,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;QAC1C,MAAM,MAAM,GAAG,GAAG,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAClD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;QACtD,MAAM,KAAK,GAAG,GAAG,MAAM,IAAI,KAAK,CAAC,QAAQ,QAAQ,KAAK,CAAC,UAAU,IAAI,CAAC;QAEtE,KAAK,CAAC,IAAI,CAAC,OAAO,MAAM,KAAK,KAAK,IAAI,CAAC,CAAC;QAExC,iCAAiC;QACjC,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;YAC1B,MAAM,QAAQ,GAAG,GAAG,KAAK,CAAC,cAAc,IAAI,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;YAC9D,KAAK,CAAC,IAAI,CAAC,OAAO,QAAQ,QAAQ,MAAM,EAAE,CAAC,CAAC;QAC7C,CAAC;IACF,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAElB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent-to-Agent (A2A) Context Management
|
|
3
|
+
*
|
|
4
|
+
* Provides context propagation, state management, and execution tracing
|
|
5
|
+
* for tool-to-tool invocation chains within the MCP server.
|
|
6
|
+
*
|
|
7
|
+
* Key Features:
|
|
8
|
+
* - Correlation ID tracking for distributed tracing
|
|
9
|
+
* - Recursion depth guards to prevent infinite loops
|
|
10
|
+
* - Shared state management across tool invocations
|
|
11
|
+
* - Execution audit trail for observability
|
|
12
|
+
* - Timeout enforcement per step and total chain
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Execution log entry for a single tool invocation
|
|
16
|
+
*/
|
|
17
|
+
export interface ExecutionLogEntry {
|
|
18
|
+
/** Timestamp when the tool was invoked */
|
|
19
|
+
timestamp: Date;
|
|
20
|
+
/** Name of the tool that was invoked */
|
|
21
|
+
toolName: string;
|
|
22
|
+
/** Hash of input parameters for deduplication */
|
|
23
|
+
inputHash: string;
|
|
24
|
+
/** Summary of the tool's output */
|
|
25
|
+
outputSummary: string;
|
|
26
|
+
/** Duration of tool execution in milliseconds */
|
|
27
|
+
durationMs: number;
|
|
28
|
+
/** Execution status */
|
|
29
|
+
status: "success" | "error" | "skipped";
|
|
30
|
+
/** Error details if status is 'error' */
|
|
31
|
+
errorDetails?: string;
|
|
32
|
+
/** Parent tool that invoked this tool (if nested) */
|
|
33
|
+
parentToolName?: string;
|
|
34
|
+
/** Nesting depth at time of invocation */
|
|
35
|
+
depth: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A2A Context for managing tool-to-tool invocation state
|
|
39
|
+
*
|
|
40
|
+
* This context is passed between tools during orchestration to:
|
|
41
|
+
* - Track execution flow with correlation IDs
|
|
42
|
+
* - Prevent infinite recursion with depth tracking
|
|
43
|
+
* - Share state between tool invocations
|
|
44
|
+
* - Maintain audit trail for debugging and monitoring
|
|
45
|
+
*/
|
|
46
|
+
export interface A2AContext {
|
|
47
|
+
/** Unique trace ID for the entire invocation chain */
|
|
48
|
+
correlationId: string;
|
|
49
|
+
/** Name of the calling tool (undefined for initial invocation) */
|
|
50
|
+
parentToolName?: string;
|
|
51
|
+
/** Current nesting depth (0 for top-level invocation) */
|
|
52
|
+
depth: number;
|
|
53
|
+
/** Maximum allowed recursion depth (default: 10) */
|
|
54
|
+
maxDepth: number;
|
|
55
|
+
/** Shared state accessible to all tools in the chain */
|
|
56
|
+
sharedState: Map<string, unknown>;
|
|
57
|
+
/** Audit trail of all tool invocations */
|
|
58
|
+
executionLog: ExecutionLogEntry[];
|
|
59
|
+
/** Timeout for individual tool invocations (milliseconds) */
|
|
60
|
+
timeoutMs?: number;
|
|
61
|
+
/** Start time of the entire chain execution */
|
|
62
|
+
chainStartTime: Date;
|
|
63
|
+
/** Maximum total chain execution time (milliseconds) */
|
|
64
|
+
chainTimeoutMs?: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Default configuration for A2A contexts
|
|
68
|
+
*/
|
|
69
|
+
export declare const A2A_DEFAULTS: {
|
|
70
|
+
/** Default maximum recursion depth */
|
|
71
|
+
readonly MAX_DEPTH: 10;
|
|
72
|
+
/** Default per-tool timeout (30 seconds) */
|
|
73
|
+
readonly DEFAULT_TIMEOUT_MS: 30000;
|
|
74
|
+
/** Default total chain timeout (5 minutes) */
|
|
75
|
+
readonly DEFAULT_CHAIN_TIMEOUT_MS: 300000;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Create a new A2A context for a top-level tool invocation
|
|
79
|
+
*
|
|
80
|
+
* @param correlationId - Optional correlation ID (generated if not provided)
|
|
81
|
+
* @param config - Optional configuration overrides
|
|
82
|
+
* @returns A new A2A context
|
|
83
|
+
*/
|
|
84
|
+
export declare function createA2AContext(correlationId?: string, config?: {
|
|
85
|
+
maxDepth?: number;
|
|
86
|
+
timeoutMs?: number;
|
|
87
|
+
chainTimeoutMs?: number;
|
|
88
|
+
}): A2AContext;
|
|
89
|
+
/**
|
|
90
|
+
* Create a child context for a nested tool invocation
|
|
91
|
+
*
|
|
92
|
+
* @param parent - Parent context
|
|
93
|
+
* @param toolName - Name of the calling tool
|
|
94
|
+
* @returns A new child context
|
|
95
|
+
* @throws Error if maximum depth would be exceeded
|
|
96
|
+
*/
|
|
97
|
+
export declare function createChildContext(parent: A2AContext, toolName: string): A2AContext;
|
|
98
|
+
/**
|
|
99
|
+
* Add an execution log entry to the context
|
|
100
|
+
*
|
|
101
|
+
* @param context - A2A context
|
|
102
|
+
* @param entry - Execution log entry to add
|
|
103
|
+
*/
|
|
104
|
+
export declare function addExecutionLogEntry(context: A2AContext, entry: Omit<ExecutionLogEntry, "timestamp" | "depth">): void;
|
|
105
|
+
/**
|
|
106
|
+
* Check if the chain has exceeded its total timeout
|
|
107
|
+
*
|
|
108
|
+
* @param context - A2A context
|
|
109
|
+
* @returns true if chain has timed out
|
|
110
|
+
*/
|
|
111
|
+
export declare function hasChainTimedOut(context: A2AContext): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Get remaining time in milliseconds for the chain
|
|
114
|
+
*
|
|
115
|
+
* @param context - A2A context
|
|
116
|
+
* @returns Remaining time in milliseconds (undefined if no timeout set)
|
|
117
|
+
*/
|
|
118
|
+
export declare function getRemainingChainTime(context: A2AContext): number | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* Create a hash of input parameters for deduplication
|
|
121
|
+
*
|
|
122
|
+
* @param input - Input parameters
|
|
123
|
+
* @returns Hash string
|
|
124
|
+
*
|
|
125
|
+
* @remarks
|
|
126
|
+
* This is a demonstration implementation using a simple string-based hash.
|
|
127
|
+
* For production deployments, replace with a proper hashing library like
|
|
128
|
+
* `crypto.createHash('sha256')` for better collision resistance and performance
|
|
129
|
+
* with large inputs.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* // Production implementation:
|
|
134
|
+
* import { createHash } from 'crypto';
|
|
135
|
+
* const hash = createHash('sha256').update(JSON.stringify(input)).digest('hex');
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export declare function hashInput(input: unknown): string;
|
|
139
|
+
/**
|
|
140
|
+
* Get execution summary from context
|
|
141
|
+
*
|
|
142
|
+
* @param context - A2A context
|
|
143
|
+
* @returns Execution summary
|
|
144
|
+
*/
|
|
145
|
+
export declare function getExecutionSummary(context: A2AContext): {
|
|
146
|
+
correlationId: string;
|
|
147
|
+
totalDurationMs: number;
|
|
148
|
+
toolCount: number;
|
|
149
|
+
successCount: number;
|
|
150
|
+
errorCount: number;
|
|
151
|
+
skippedCount: number;
|
|
152
|
+
maxDepthReached: number;
|
|
153
|
+
};
|
|
154
|
+
//# sourceMappingURL=a2a-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a2a-context.d.ts","sourceRoot":"","sources":["../../../src/tools/shared/a2a-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,0CAA0C;IAC1C,SAAS,EAAE,IAAI,CAAC;IAChB,wCAAwC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,mCAAmC;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,uBAAuB;IACvB,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IACxC,yCAAyC;IACzC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IAC1B,sDAAsD;IACtD,aAAa,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,0CAA0C;IAC1C,YAAY,EAAE,iBAAiB,EAAE,CAAC;IAClC,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,cAAc,EAAE,IAAI,CAAC;IACrB,wDAAwD;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,eAAO,MAAM,YAAY;IACxB,sCAAsC;;IAE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