mcpgraph 0.1.5 → 0.1.6
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 +1 -0
- package/dist/api.d.ts +17 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +33 -4
- package/dist/api.js.map +1 -1
- package/dist/execution/context.d.ts +3 -6
- package/dist/execution/context.d.ts.map +1 -1
- package/dist/execution/context.js +11 -2
- package/dist/execution/context.js.map +1 -1
- package/dist/execution/controller.d.ts +29 -0
- package/dist/execution/controller.d.ts.map +1 -0
- package/dist/execution/controller.js +95 -0
- package/dist/execution/controller.js.map +1 -0
- package/dist/execution/executor.d.ts +8 -1
- package/dist/execution/executor.d.ts.map +1 -1
- package/dist/execution/executor.js +184 -37
- package/dist/execution/executor.js.map +1 -1
- package/dist/execution/nodes/entry-executor.d.ts +1 -1
- package/dist/execution/nodes/entry-executor.d.ts.map +1 -1
- package/dist/execution/nodes/entry-executor.js +3 -2
- package/dist/execution/nodes/entry-executor.js.map +1 -1
- package/dist/execution/nodes/exit-executor.d.ts +1 -1
- package/dist/execution/nodes/exit-executor.d.ts.map +1 -1
- package/dist/execution/nodes/exit-executor.js +3 -2
- package/dist/execution/nodes/exit-executor.js.map +1 -1
- package/dist/execution/nodes/mcp-tool-executor.d.ts +1 -1
- package/dist/execution/nodes/mcp-tool-executor.d.ts.map +1 -1
- package/dist/execution/nodes/mcp-tool-executor.js +3 -2
- package/dist/execution/nodes/mcp-tool-executor.js.map +1 -1
- package/dist/execution/nodes/switch-executor.d.ts +1 -1
- package/dist/execution/nodes/switch-executor.d.ts.map +1 -1
- package/dist/execution/nodes/switch-executor.js +7 -2
- package/dist/execution/nodes/switch-executor.js.map +1 -1
- package/dist/execution/nodes/transform-executor.d.ts +1 -1
- package/dist/execution/nodes/transform-executor.d.ts.map +1 -1
- package/dist/execution/nodes/transform-executor.js +3 -2
- package/dist/execution/nodes/transform-executor.js.map +1 -1
- package/dist/types/execution.d.ts +92 -0
- package/dist/types/execution.d.ts.map +1 -0
- package/dist/types/execution.js +5 -0
- package/dist/types/execution.js.map +1 -0
- package/examples/api-usage.ts +49 -1
- package/examples/switch_example.yaml +80 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -190,3 +190,4 @@ See [`examples/api-usage.ts`](examples/api-usage.ts) for a complete example.
|
|
|
190
190
|
- [Contributing Guide](CONTRIBUTING.md) - Setup, development, and contribution guidelines
|
|
191
191
|
- [Design Document](docs/design.md) - Complete design and architecture
|
|
192
192
|
- [Implementation](docs/implementation.md) - Implementation details and architecture
|
|
193
|
+
- [Introspection & Debugging](docs/introspection-debugging.md) - Guide for building visualizer applications and debuggers
|
package/dist/api.d.ts
CHANGED
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { McpGraphConfig } from './types/config.js';
|
|
10
10
|
import { type ValidationError } from './graph/validator.js';
|
|
11
|
+
import type { ExecutionOptions, ExecutionResult as CoreExecutionResult, ExecutionController, ExecutionState } from './types/execution.js';
|
|
11
12
|
export type { NodeDefinition, McpGraphConfig } from './types/config.js';
|
|
13
|
+
export type { ExecutionOptions, ExecutionHooks, ExecutionController, ExecutionState, ExecutionStatus, NodeExecutionRecord, ExecutionTelemetry, } from './types/execution.js';
|
|
12
14
|
export interface ToolInfo {
|
|
13
15
|
name: string;
|
|
14
16
|
description: string;
|
|
@@ -18,6 +20,8 @@ export interface ToolInfo {
|
|
|
18
20
|
export interface ExecutionResult {
|
|
19
21
|
result: unknown;
|
|
20
22
|
structuredContent?: Record<string, unknown>;
|
|
23
|
+
executionHistory?: CoreExecutionResult['executionHistory'];
|
|
24
|
+
telemetry?: CoreExecutionResult['telemetry'];
|
|
21
25
|
}
|
|
22
26
|
export declare class McpGraphApi {
|
|
23
27
|
private config;
|
|
@@ -48,7 +52,19 @@ export declare class McpGraphApi {
|
|
|
48
52
|
/**
|
|
49
53
|
* Execute a tool with the given arguments
|
|
50
54
|
*/
|
|
51
|
-
executeTool(toolName: string, toolArguments?: Record<string, unknown
|
|
55
|
+
executeTool(toolName: string, toolArguments?: Record<string, unknown>, options?: ExecutionOptions): Promise<ExecutionResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Get the execution controller (available during execution with hooks/breakpoints)
|
|
58
|
+
*/
|
|
59
|
+
getController(): ExecutionController | null;
|
|
60
|
+
/**
|
|
61
|
+
* Get the graph structure
|
|
62
|
+
*/
|
|
63
|
+
getGraph(): import("./graph/graph.js").Graph;
|
|
64
|
+
/**
|
|
65
|
+
* Get the current execution state (if execution is in progress)
|
|
66
|
+
*/
|
|
67
|
+
getExecutionState(): ExecutionState | null;
|
|
52
68
|
/**
|
|
53
69
|
* Get the full configuration
|
|
54
70
|
*/
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAiB,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAiB,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG3E,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,IAAI,mBAAmB,EACtC,mBAAmB,EACnB,cAAc,EAEf,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxE,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAE9B,MA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AAC,UAAU,EAAE,MAAM,GAAG,eAAe,EAAE;IAK5D;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG;QAChD,MAAM,EAAE,cAAc,CAAC;QACvB,MAAM,EAAE,eAAe,EAAE,CAAC;KAC3B;IAMD;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
package/dist/api.js
CHANGED
|
@@ -73,13 +73,42 @@ export class McpGraphApi {
|
|
|
73
73
|
/**
|
|
74
74
|
* Execute a tool with the given arguments
|
|
75
75
|
*/
|
|
76
|
-
async executeTool(toolName, toolArguments = {}) {
|
|
77
|
-
const
|
|
76
|
+
async executeTool(toolName, toolArguments = {}, options) {
|
|
77
|
+
const executionResult = await this.executor.executeTool(toolName, toolArguments, options);
|
|
78
78
|
return {
|
|
79
|
-
result,
|
|
80
|
-
structuredContent: result,
|
|
79
|
+
result: executionResult.result,
|
|
80
|
+
structuredContent: executionResult.result,
|
|
81
|
+
executionHistory: executionResult.executionHistory,
|
|
82
|
+
telemetry: executionResult.telemetry,
|
|
81
83
|
};
|
|
82
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Get the execution controller (available during execution with hooks/breakpoints)
|
|
87
|
+
*/
|
|
88
|
+
getController() {
|
|
89
|
+
return this.executor.getController();
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get the graph structure
|
|
93
|
+
*/
|
|
94
|
+
getGraph() {
|
|
95
|
+
return this.executor.getGraph();
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Get the current execution state (if execution is in progress)
|
|
99
|
+
*/
|
|
100
|
+
getExecutionState() {
|
|
101
|
+
const controller = this.executor.getController();
|
|
102
|
+
if (!controller) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
return controller.getState();
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
83
112
|
/**
|
|
84
113
|
* Get the full configuration
|
|
85
114
|
*/
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAwB,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAwB,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAmC3D,MAAM,OAAO,WAAW;IACd,MAAM,CAAiB;IACvB,QAAQ,CAAgB;IACxB,aAAa,CAAmB;IAExC;;;;OAIG;IACH,YAAY,UAAkB;QAC5B,MAAM,CAAC,IAAI,CAAC,+BAA+B,UAAU,EAAE,CAAC,CAAC;QAEzD,MAAM,MAAM,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;QAEtC,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QACrC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,C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P,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,UAAkB;QACtC,MAAM,MAAM,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;QACtC,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAAC,UAAkB;QAI7C,MAAM,MAAM,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;QACtC,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QACrC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -2,17 +2,14 @@
|
|
|
2
2
|
* Execution context for graph execution
|
|
3
3
|
*/
|
|
4
4
|
import type { ExecutionContext as ExprContext } from "../expressions/context.js";
|
|
5
|
+
import type { NodeExecutionRecord } from "../types/execution.js";
|
|
5
6
|
export declare class ExecutionContext {
|
|
6
7
|
private data;
|
|
7
8
|
private history;
|
|
8
9
|
constructor(toolInput: Record<string, unknown>);
|
|
9
10
|
getData(): ExprContext;
|
|
10
11
|
setNodeOutput(nodeId: string, output: unknown): void;
|
|
11
|
-
addHistory(nodeId: string, input: unknown, output: unknown): void;
|
|
12
|
-
getHistory():
|
|
13
|
-
nodeId: string;
|
|
14
|
-
input: unknown;
|
|
15
|
-
output: unknown;
|
|
16
|
-
}>;
|
|
12
|
+
addHistory(nodeId: string, nodeType: string, input: unknown, output: unknown, startTime: number, endTime: number, error?: Error): void;
|
|
13
|
+
getHistory(): NodeExecutionRecord[];
|
|
17
14
|
}
|
|
18
15
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/execution/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/execution/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,OAAO,CAAwB;gBAE3B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAU9C,OAAO,IAAI,WAAW;IAItB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAQpD,UAAU,CACR,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,KAAK,GACZ,IAAI;IAaP,UAAU,IAAI,mBAAmB,EAAE;CAGpC"}
|
|
@@ -23,8 +23,17 @@ export class ExecutionContext {
|
|
|
23
23
|
this.data.output = output;
|
|
24
24
|
this.data.last = output;
|
|
25
25
|
}
|
|
26
|
-
addHistory(nodeId, input, output) {
|
|
27
|
-
this.history.push({
|
|
26
|
+
addHistory(nodeId, nodeType, input, output, startTime, endTime, error) {
|
|
27
|
+
this.history.push({
|
|
28
|
+
nodeId,
|
|
29
|
+
nodeType,
|
|
30
|
+
input,
|
|
31
|
+
output,
|
|
32
|
+
startTime,
|
|
33
|
+
endTime,
|
|
34
|
+
duration: endTime - startTime,
|
|
35
|
+
error,
|
|
36
|
+
});
|
|
28
37
|
}
|
|
29
38
|
getHistory() {
|
|
30
39
|
return this.history;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/execution/context.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/execution/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,OAAO,gBAAgB;IACnB,IAAI,CAAc;IAClB,OAAO,CAAwB;IAEvC,YAAY,SAAkC;QAC5C,0DAA0D;QAC1D,IAAI,CAAC,IAAI,GAAG;YACV,KAAK,EAAE,SAAS;YAChB,iEAAiE;YACjE,GAAG,SAAS;SACb,CAAC;QACF,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACpB,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,aAAa,CAAC,MAAc,EAAE,MAAe;QAC3C,iDAAiD;QACjD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;QAC3B,iDAAiD;QACjD,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAC1B,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;IAC1B,CAAC;IAED,UAAU,CACR,MAAc,EACd,QAAgB,EAChB,KAAc,EACd,MAAe,EACf,SAAiB,EACjB,OAAe,EACf,KAAa;QAEb,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YAChB,MAAM;YACN,QAAQ;YACR,KAAK;YACL,MAAM;YACN,SAAS;YACT,OAAO;YACP,QAAQ,EAAE,OAAO,GAAG,SAAS;YAC7B,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution controller for debugging and introspection
|
|
3
|
+
*/
|
|
4
|
+
import type { ExecutionState, ExecutionStatus, ExecutionController as IExecutionController } from "../types/execution.js";
|
|
5
|
+
import type { ExecutionContext } from "./context.js";
|
|
6
|
+
export declare class ExecutionController implements IExecutionController {
|
|
7
|
+
private status;
|
|
8
|
+
private currentNodeId;
|
|
9
|
+
private context;
|
|
10
|
+
private breakpoints;
|
|
11
|
+
private pauseRequested;
|
|
12
|
+
private stepRequested;
|
|
13
|
+
private resumePromise;
|
|
14
|
+
private resumeResolve;
|
|
15
|
+
setContext(context: ExecutionContext): void;
|
|
16
|
+
setStatus(status: ExecutionStatus): void;
|
|
17
|
+
setCurrentNode(nodeId: string | null): void;
|
|
18
|
+
waitIfPaused(): Promise<void>;
|
|
19
|
+
shouldPause(nodeId: string): boolean;
|
|
20
|
+
pause(): void;
|
|
21
|
+
resume(): void;
|
|
22
|
+
step(): Promise<void>;
|
|
23
|
+
getState(): ExecutionState;
|
|
24
|
+
setBreakpoints(nodeIds: string[]): void;
|
|
25
|
+
clearBreakpoints(): void;
|
|
26
|
+
getBreakpoints(): string[];
|
|
27
|
+
markStepComplete(): void;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/execution/controller.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,mBAAmB,IAAI,oBAAoB,EAC5C,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,qBAAa,mBAAoB,YAAW,oBAAoB;IAC9D,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,aAAa,CAA8B;IACnD,OAAO,CAAC,aAAa,CAA6B;IAElD,UAAU,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAI3C,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IAIxC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAIrC,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBnC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAIpC,KAAK,IAAI,IAAI;IAQb,MAAM,IAAI,IAAI;IAWR,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAW3B,QAAQ,IAAI,cAAc;IAa1B,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAIvC,gBAAgB,IAAI,IAAI;IAIxB,cAAc,IAAI,MAAM,EAAE;IAI1B,gBAAgB,IAAI,IAAI;CAMzB"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution controller for debugging and introspection
|
|
3
|
+
*/
|
|
4
|
+
export class ExecutionController {
|
|
5
|
+
status = "not_started";
|
|
6
|
+
currentNodeId = null;
|
|
7
|
+
context = null;
|
|
8
|
+
breakpoints = new Set();
|
|
9
|
+
pauseRequested = false;
|
|
10
|
+
stepRequested = false;
|
|
11
|
+
resumePromise = null;
|
|
12
|
+
resumeResolve = null;
|
|
13
|
+
setContext(context) {
|
|
14
|
+
this.context = context;
|
|
15
|
+
}
|
|
16
|
+
setStatus(status) {
|
|
17
|
+
this.status = status;
|
|
18
|
+
}
|
|
19
|
+
setCurrentNode(nodeId) {
|
|
20
|
+
this.currentNodeId = nodeId;
|
|
21
|
+
}
|
|
22
|
+
async waitIfPaused() {
|
|
23
|
+
if (this.status === "paused" || this.pauseRequested) {
|
|
24
|
+
this.status = "paused";
|
|
25
|
+
this.pauseRequested = false;
|
|
26
|
+
// Create promise for resume
|
|
27
|
+
this.resumePromise = new Promise((resolve) => {
|
|
28
|
+
this.resumeResolve = resolve;
|
|
29
|
+
});
|
|
30
|
+
await this.resumePromise;
|
|
31
|
+
this.resumePromise = null;
|
|
32
|
+
this.resumeResolve = null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
shouldPause(nodeId) {
|
|
36
|
+
return this.breakpoints.has(nodeId) || this.pauseRequested;
|
|
37
|
+
}
|
|
38
|
+
pause() {
|
|
39
|
+
if (this.status === "running") {
|
|
40
|
+
this.pauseRequested = true;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
throw new Error(`Cannot pause: execution status is "${this.status}"`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
resume() {
|
|
47
|
+
if (this.status === "paused") {
|
|
48
|
+
this.status = "running";
|
|
49
|
+
if (this.resumeResolve) {
|
|
50
|
+
this.resumeResolve();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
throw new Error(`Cannot resume: execution status is "${this.status}"`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async step() {
|
|
58
|
+
if (this.status === "paused") {
|
|
59
|
+
this.stepRequested = true;
|
|
60
|
+
this.resume();
|
|
61
|
+
// Wait for step to complete (will be paused again after one node)
|
|
62
|
+
await this.waitIfPaused();
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
throw new Error(`Cannot step: execution status is "${this.status}"`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
getState() {
|
|
69
|
+
if (!this.context) {
|
|
70
|
+
throw new Error("Execution context not set");
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
status: this.status,
|
|
74
|
+
currentNodeId: this.currentNodeId,
|
|
75
|
+
executionHistory: this.context.getHistory(),
|
|
76
|
+
context: this.context,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
setBreakpoints(nodeIds) {
|
|
80
|
+
this.breakpoints = new Set(nodeIds);
|
|
81
|
+
}
|
|
82
|
+
clearBreakpoints() {
|
|
83
|
+
this.breakpoints.clear();
|
|
84
|
+
}
|
|
85
|
+
getBreakpoints() {
|
|
86
|
+
return Array.from(this.breakpoints);
|
|
87
|
+
}
|
|
88
|
+
markStepComplete() {
|
|
89
|
+
if (this.stepRequested) {
|
|
90
|
+
this.stepRequested = false;
|
|
91
|
+
this.pauseRequested = true;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../src/execution/controller.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,MAAM,OAAO,mBAAmB;IACtB,MAAM,GAAoB,aAAa,CAAC;IACxC,aAAa,GAAkB,IAAI,CAAC;IACpC,OAAO,GAA4B,IAAI,CAAC;IACxC,WAAW,GAAgB,IAAI,GAAG,EAAE,CAAC;IACrC,cAAc,GAAY,KAAK,CAAC;IAChC,aAAa,GAAY,KAAK,CAAC;IAC/B,aAAa,GAAyB,IAAI,CAAC;IAC3C,aAAa,GAAwB,IAAI,CAAC;IAElD,UAAU,CAAC,OAAyB;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,SAAS,CAAC,MAAuB;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,cAAc,CAAC,MAAqB;QAClC,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACpD,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC;YACvB,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;YAE5B,4BAA4B;YAC5B,IAAI,CAAC,aAAa,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC3C,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;Y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CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC/C,CAAC;QAED,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,gBAAgB,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YAC3C,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;IAED,cAAc,CAAC,OAAiB;QAC9B,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,gBAAgB;QACd,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IAED,cAAc;QACZ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;IAED,gBAAgB;QACd,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;YAC3B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC7B,CAAC;IACH,CAAC;CACF"}
|
|
@@ -2,13 +2,20 @@
|
|
|
2
2
|
* Graph execution engine
|
|
3
3
|
*/
|
|
4
4
|
import type { McpGraphConfig } from "../types/config.js";
|
|
5
|
+
import type { ExecutionOptions, ExecutionResult, ExecutionController as IExecutionController } from "../types/execution.js";
|
|
6
|
+
import { Graph } from "../graph/graph.js";
|
|
5
7
|
import type { McpClientManager } from "../mcp/client-manager.js";
|
|
6
8
|
export declare class GraphExecutor {
|
|
7
9
|
private config;
|
|
8
10
|
private graph;
|
|
9
11
|
private clientManager;
|
|
12
|
+
private controller;
|
|
10
13
|
constructor(config: McpGraphConfig, clientManager: McpClientManager);
|
|
14
|
+
getController(): IExecutionController | null;
|
|
15
|
+
getGraph(): Graph;
|
|
16
|
+
getConfig(): McpGraphConfig;
|
|
11
17
|
private getServerConfig;
|
|
12
|
-
executeTool(toolName: string, toolInput: Record<string, unknown
|
|
18
|
+
executeTool(toolName: string, toolInput: Record<string, unknown>, options?: ExecutionOptions): Promise<ExecutionResult>;
|
|
19
|
+
private buildTelemetry;
|
|
13
20
|
}
|
|
14
21
|
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/execution/executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/execution/executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAgD,MAAM,oBAAoB,CAAC;AACvG,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAGf,mBAAmB,IAAI,oBAAoB,EAC5C,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAQ1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGjE,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,aAAa,CAAmB;IACxC,OAAO,CAAC,UAAU,CAAoC;gBAE1C,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,gBAAgB;IAMnE,aAAa,IAAI,oBAAoB,GAAG,IAAI;IAI5C,QAAQ,IAAI,KAAK;IAIjB,SAAS,IAAI,cAAc;IAI3B,OAAO,CAAC,eAAe;IAOjB,WAAW,CACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,eAAe,CAAC;IAgO3B,OAAO,CAAC,cAAc;CAgCvB"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Graph } from "../graph/graph.js";
|
|
5
5
|
import { ExecutionContext } from "./context.js";
|
|
6
|
+
import { ExecutionController } from "./controller.js";
|
|
6
7
|
import { executeEntryNode } from "./nodes/entry-executor.js";
|
|
7
8
|
import { executeExitNode } from "./nodes/exit-executor.js";
|
|
8
9
|
import { executeTransformNode } from "./nodes/transform-executor.js";
|
|
@@ -13,23 +14,43 @@ export class GraphExecutor {
|
|
|
13
14
|
config;
|
|
14
15
|
graph;
|
|
15
16
|
clientManager;
|
|
17
|
+
controller = null;
|
|
16
18
|
constructor(config, clientManager) {
|
|
17
19
|
this.config = config;
|
|
18
20
|
this.graph = new Graph(config.nodes);
|
|
19
21
|
this.clientManager = clientManager;
|
|
20
22
|
}
|
|
23
|
+
getController() {
|
|
24
|
+
return this.controller;
|
|
25
|
+
}
|
|
26
|
+
getGraph() {
|
|
27
|
+
return this.graph;
|
|
28
|
+
}
|
|
29
|
+
getConfig() {
|
|
30
|
+
return this.config;
|
|
31
|
+
}
|
|
21
32
|
getServerConfig(serverName) {
|
|
22
33
|
if (!this.config.servers || !this.config.servers[serverName]) {
|
|
23
34
|
throw new Error(`Server configuration not found: ${serverName}`);
|
|
24
35
|
}
|
|
25
36
|
return this.config.servers[serverName];
|
|
26
37
|
}
|
|
27
|
-
async executeTool(toolName, toolInput) {
|
|
38
|
+
async executeTool(toolName, toolInput, options) {
|
|
28
39
|
const tool = this.config.tools.find((t) => t.name === toolName);
|
|
29
40
|
if (!tool) {
|
|
30
41
|
throw new Error(`Tool not found: ${toolName}`);
|
|
31
42
|
}
|
|
32
43
|
logger.info(`Executing tool: ${toolName}`);
|
|
44
|
+
// Initialize execution options
|
|
45
|
+
const hooks = options?.hooks;
|
|
46
|
+
const breakpoints = options?.breakpoints || [];
|
|
47
|
+
const enableTelemetry = options?.enableTelemetry ?? false;
|
|
48
|
+
// Initialize controller if hooks or breakpoints are provided
|
|
49
|
+
if (hooks || breakpoints.length > 0) {
|
|
50
|
+
this.controller = new ExecutionController();
|
|
51
|
+
this.controller.setBreakpoints(breakpoints);
|
|
52
|
+
this.controller.setStatus("not_started");
|
|
53
|
+
}
|
|
33
54
|
// Find entry node for this tool
|
|
34
55
|
const entryNode = this.config.nodes.find((n) => n.type === "entry" && n.tool === toolName);
|
|
35
56
|
if (!entryNode) {
|
|
@@ -41,49 +62,175 @@ export class GraphExecutor {
|
|
|
41
62
|
throw new Error(`Exit node not found for tool: ${toolName}`);
|
|
42
63
|
}
|
|
43
64
|
const context = new ExecutionContext(toolInput);
|
|
65
|
+
if (this.controller) {
|
|
66
|
+
this.controller.setContext(context);
|
|
67
|
+
}
|
|
68
|
+
const startTime = Date.now();
|
|
44
69
|
let currentNodeId = entryNode.id;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (!node) {
|
|
49
|
-
throw new Error(`Node not found: ${currentNodeId}`);
|
|
70
|
+
try {
|
|
71
|
+
if (this.controller) {
|
|
72
|
+
this.controller.setStatus("running");
|
|
50
73
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
// Execute nodes until we reach the exit node
|
|
75
|
+
while (currentNodeId !== exitNode.id) {
|
|
76
|
+
const node = this.graph.getNode(currentNodeId);
|
|
77
|
+
if (!node) {
|
|
78
|
+
throw new Error(`Node not found: ${currentNodeId}`);
|
|
79
|
+
}
|
|
80
|
+
// Update controller with current node
|
|
81
|
+
if (this.controller) {
|
|
82
|
+
this.controller.setCurrentNode(currentNodeId);
|
|
83
|
+
}
|
|
84
|
+
// Check for breakpoint or pause request
|
|
85
|
+
if (this.controller && this.controller.shouldPause(currentNodeId)) {
|
|
86
|
+
await this.controller.waitIfPaused();
|
|
87
|
+
}
|
|
88
|
+
// Call onNodeStart hook
|
|
89
|
+
if (hooks?.onNodeStart) {
|
|
90
|
+
const shouldContinue = await hooks.onNodeStart(currentNodeId, node, context);
|
|
91
|
+
if (shouldContinue === false) {
|
|
92
|
+
// Hook requested pause
|
|
93
|
+
if (this.controller) {
|
|
94
|
+
await this.controller.waitIfPaused();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
logger.debug(`Executing node: ${currentNodeId} (type: ${node.type})`);
|
|
99
|
+
const nodeStartTime = Date.now();
|
|
100
|
+
let result;
|
|
101
|
+
let nodeError;
|
|
102
|
+
try {
|
|
103
|
+
switch (node.type) {
|
|
104
|
+
case "entry":
|
|
105
|
+
result = executeEntryNode(node, toolInput, context, nodeStartTime);
|
|
106
|
+
break;
|
|
107
|
+
case "exit":
|
|
108
|
+
result = executeExitNode(node, context, nodeStartTime);
|
|
109
|
+
// Call onNodeComplete hook for exit node
|
|
110
|
+
if (hooks?.onNodeComplete) {
|
|
111
|
+
await hooks.onNodeComplete(currentNodeId, node, context.getData(), result.output, Date.now() - nodeStartTime);
|
|
112
|
+
}
|
|
113
|
+
if (this.controller) {
|
|
114
|
+
this.controller.setStatus("finished");
|
|
115
|
+
this.controller.setCurrentNode(null);
|
|
116
|
+
}
|
|
117
|
+
const endTime = Date.now();
|
|
118
|
+
const telemetry = enableTelemetry
|
|
119
|
+
? this.buildTelemetry(context, startTime, endTime)
|
|
120
|
+
: undefined;
|
|
121
|
+
return {
|
|
122
|
+
result: result.output,
|
|
123
|
+
executionHistory: context.getHistory(),
|
|
124
|
+
telemetry,
|
|
125
|
+
};
|
|
126
|
+
case "transform":
|
|
127
|
+
result = await executeTransformNode(node, context, nodeStartTime);
|
|
128
|
+
break;
|
|
129
|
+
case "mcp":
|
|
130
|
+
const serverConfig = this.getServerConfig(node.server);
|
|
131
|
+
result = await executeMcpToolNode(node, context, this.clientManager, serverConfig, nodeStartTime);
|
|
132
|
+
break;
|
|
133
|
+
case "switch":
|
|
134
|
+
result = await executeSwitchNode(node, context, nodeStartTime);
|
|
135
|
+
break;
|
|
136
|
+
default:
|
|
137
|
+
throw new Error(`Unknown node type: ${node.type}`);
|
|
138
|
+
}
|
|
139
|
+
// Call onNodeComplete hook
|
|
140
|
+
if (hooks?.onNodeComplete) {
|
|
141
|
+
await hooks.onNodeComplete(currentNodeId, node, context.getData(), result.output, Date.now() - nodeStartTime);
|
|
142
|
+
}
|
|
143
|
+
// Mark step complete if stepping
|
|
144
|
+
if (this.controller) {
|
|
145
|
+
this.controller.markStepComplete();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
nodeError = error instanceof Error ? error : new Error(String(error));
|
|
150
|
+
const nodeEndTime = Date.now();
|
|
151
|
+
// Record error in history (if not already recorded by node executor)
|
|
152
|
+
const history = context.getHistory();
|
|
153
|
+
const lastRecord = history[history.length - 1];
|
|
154
|
+
if (!lastRecord || lastRecord.nodeId !== currentNodeId) {
|
|
155
|
+
context.addHistory(currentNodeId, node.type, context.getData(), null, nodeStartTime, nodeEndTime, nodeError);
|
|
156
|
+
}
|
|
157
|
+
// Call onNodeError hook
|
|
158
|
+
if (hooks?.onNodeError) {
|
|
159
|
+
await hooks.onNodeError(currentNodeId, node, nodeError, context);
|
|
160
|
+
}
|
|
161
|
+
if (this.controller) {
|
|
162
|
+
this.controller.setStatus("error");
|
|
163
|
+
this.controller.setCurrentNode(null);
|
|
164
|
+
}
|
|
165
|
+
throw nodeError;
|
|
166
|
+
}
|
|
167
|
+
if (result.nextNode) {
|
|
168
|
+
currentNodeId = result.nextNode;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
throw new Error(`Node ${currentNodeId} has no next node and is not the exit node`);
|
|
172
|
+
}
|
|
72
173
|
}
|
|
73
|
-
|
|
74
|
-
|
|
174
|
+
// Should not reach here, but handle exit node
|
|
175
|
+
const finalExitNode = this.graph.getNode(exitNode.id);
|
|
176
|
+
if (finalExitNode && finalExitNode.type === "exit") {
|
|
177
|
+
const result = executeExitNode(finalExitNode, context, Date.now());
|
|
178
|
+
if (this.controller) {
|
|
179
|
+
this.controller.setStatus("finished");
|
|
180
|
+
this.controller.setCurrentNode(null);
|
|
181
|
+
}
|
|
182
|
+
const endTime = Date.now();
|
|
183
|
+
const telemetry = enableTelemetry
|
|
184
|
+
? this.buildTelemetry(context, startTime, endTime)
|
|
185
|
+
: undefined;
|
|
186
|
+
return {
|
|
187
|
+
result: result.output,
|
|
188
|
+
executionHistory: context.getHistory(),
|
|
189
|
+
telemetry,
|
|
190
|
+
};
|
|
75
191
|
}
|
|
76
|
-
|
|
77
|
-
|
|
192
|
+
throw new Error(`Exit node ${exitNode.id} not found or invalid`);
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
if (this.controller) {
|
|
196
|
+
this.controller.setStatus("error");
|
|
197
|
+
this.controller.setCurrentNode(null);
|
|
198
|
+
if (error instanceof Error) {
|
|
199
|
+
// Store error in controller state would require extending ExecutionState
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
throw error;
|
|
203
|
+
}
|
|
204
|
+
finally {
|
|
205
|
+
// Clean up controller after execution
|
|
206
|
+
if (this.controller) {
|
|
207
|
+
this.controller = null;
|
|
78
208
|
}
|
|
79
209
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
210
|
+
}
|
|
211
|
+
buildTelemetry(context, startTime, endTime) {
|
|
212
|
+
const history = context.getHistory();
|
|
213
|
+
const nodeDurations = new Map();
|
|
214
|
+
const nodeCounts = new Map();
|
|
215
|
+
let errorCount = 0;
|
|
216
|
+
for (const record of history) {
|
|
217
|
+
// Aggregate durations by node type
|
|
218
|
+
const currentDuration = nodeDurations.get(record.nodeType) || 0;
|
|
219
|
+
nodeDurations.set(record.nodeType, currentDuration + record.duration);
|
|
220
|
+
// Count nodes by type
|
|
221
|
+
const currentCount = nodeCounts.get(record.nodeType) || 0;
|
|
222
|
+
nodeCounts.set(record.nodeType, currentCount + 1);
|
|
223
|
+
// Count errors
|
|
224
|
+
if (record.error) {
|
|
225
|
+
errorCount++;
|
|
226
|
+
}
|
|
85
227
|
}
|
|
86
|
-
|
|
228
|
+
return {
|
|
229
|
+
totalDuration: endTime - startTime,
|
|
230
|
+
nodeDurations,
|
|
231
|
+
nodeCounts,
|
|
232
|
+
errorCount,
|
|
233
|
+
};
|
|
87
234
|
}
|
|
88
235
|
}
|
|
89
236
|
//# sourceMappingURL=executor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/execution/executor.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/execution/executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,MAAM,OAAO,aAAa;IAChB,MAAM,CAAiB;IACvB,KAAK,CAAQ;IACb,aAAa,CAAmB;IAChC,UAAU,GAA+B,IAAI,CAAC;IAEtD,YAAY,MAAsB,EAAE,aAA+B;QACjE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,I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AAC;YAC1D,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;YAElD,eAAe;YACf,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;gBACjB,UAAU,EAAE,CAAC;YACf,CAAC;QACH,CAAC;QAED,OAAO;YACL,aAAa,EAAE,OAAO,GAAG,SAAS;YAClC,aAAa;YACb,UAAU;YACV,UAAU;SACX,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { EntryNode } from "../../types/config.js";
|
|
5
5
|
import type { ExecutionContext } from "../context.js";
|
|
6
|
-
export declare function executeEntryNode(node: EntryNode, toolInput: Record<string, unknown>, context: ExecutionContext): {
|
|
6
|
+
export declare function executeEntryNode(node: EntryNode, toolInput: Record<string, unknown>, context: ExecutionContext, startTime: number): {
|
|
7
7
|
output: unknown;
|
|
8
8
|
nextNode: string;
|
|
9
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-executor.d.ts","sourceRoot":"","sources":["../../../src/execution/nodes/entry-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"entry-executor.d.ts","sourceRoot":"","sources":["../../../src/execution/nodes/entry-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,OAAO,EAAE,gBAAgB,EACzB,SAAS,EAAE,MAAM,GAChB;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAevC"}
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
* Entry node executor
|
|
3
3
|
*/
|
|
4
4
|
import { logger } from "../../logger.js";
|
|
5
|
-
export function executeEntryNode(node, toolInput, context) {
|
|
5
|
+
export function executeEntryNode(node, toolInput, context, startTime) {
|
|
6
6
|
logger.debug(`Executing entry node: ${node.id}`);
|
|
7
7
|
// Entry node receives tool input and initializes context
|
|
8
8
|
// The input is already in the context, so we just pass it through
|
|
9
9
|
const output = toolInput;
|
|
10
|
+
const endTime = Date.now();
|
|
10
11
|
context.setNodeOutput(node.id, output);
|
|
11
|
-
context.addHistory(node.id, toolInput, output);
|
|
12
|
+
context.addHistory(node.id, "entry", toolInput, output, startTime, endTime);
|
|
12
13
|
return {
|
|
13
14
|
output,
|
|
14
15
|
nextNode: node.next,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-executor.js","sourceRoot":"","sources":["../../../src/execution/nodes/entry-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,UAAU,gBAAgB,CAC9B,IAAe,EACf,SAAkC,EAClC,OAAyB;
|
|
1
|
+
{"version":3,"file":"entry-executor.js","sourceRoot":"","sources":["../../../src/execution/nodes/entry-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,UAAU,gBAAgB,CAC9B,IAAe,EACf,SAAkC,EAClC,OAAyB,EACzB,SAAiB;IAEjB,MAAM,CAAC,KAAK,CAAC,yBAAyB,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IAEjD,yDAAyD;IACzD,kEAAkE;IAClE,MAAM,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE3B,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACvC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAE5E,OAAO;QACL,MAAM;QACN,QAAQ,EAAE,IAAI,CAAC,IAAI;KACpB,CAAC;AACJ,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { ExitNode } from "../../types/config.js";
|
|
5
5
|
import type { ExecutionContext } from "../context.js";
|
|
6
|
-
export declare function executeExitNode(node: ExitNode, context: ExecutionContext): {
|
|
6
|
+
export declare function executeExitNode(node: ExitNode, context: ExecutionContext, startTime: number): {
|
|
7
7
|
output: unknown;
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=exit-executor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exit-executor.d.ts","sourceRoot":"","sources":["../../../src/execution/nodes/exit-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD,wBAAgB,eAAe,CAC7B,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"exit-executor.d.ts","sourceRoot":"","sources":["../../../src/execution/nodes/exit-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD,wBAAgB,eAAe,CAC7B,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,gBAAgB,EACzB,SAAS,EAAE,MAAM,GAChB;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAcrB"}
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
* Exit node executor
|
|
3
3
|
*/
|
|
4
4
|
import { logger } from "../../logger.js";
|
|
5
|
-
export function executeExitNode(node, context) {
|
|
5
|
+
export function executeExitNode(node, context, startTime) {
|
|
6
6
|
logger.debug(`Executing exit node: ${node.id}`);
|
|
7
7
|
// Exit node extracts the final result from context
|
|
8
8
|
// Use the last output or the context's output
|
|
9
9
|
const data = context.getData();
|
|
10
10
|
const output = data.output || data.last || {};
|
|
11
|
-
|
|
11
|
+
const endTime = Date.now();
|
|
12
|
+
context.addHistory(node.id, "exit", data, output, startTime, endTime);
|
|
12
13
|
return {
|
|
13
14
|
output,
|
|
14
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exit-executor.js","sourceRoot":"","sources":["../../../src/execution/nodes/exit-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,UAAU,eAAe,CAC7B,IAAc,EACd,OAAyB;
|
|
1
|
+
{"version":3,"file":"exit-executor.js","sourceRoot":"","sources":["../../../src/execution/nodes/exit-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,UAAU,eAAe,CAC7B,IAAc,EACd,OAAyB,EACzB,SAAiB;IAEjB,MAAM,CAAC,KAAK,CAAC,wBAAwB,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IAEhD,mDAAmD;IACnD,8CAA8C;IAC9C,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;IAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE3B,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAEtE,OAAO;QACL,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type { McpNode, ServerConfig } from "../../types/config.js";
|
|
5
5
|
import type { ExecutionContext } from "../context.js";
|
|
6
6
|
import type { McpClientManager } from "../../mcp/client-manager.js";
|
|
7
|
-
export declare function executeMcpToolNode(node: McpNode, context: ExecutionContext, clientManager: McpClientManager, serverConfig: ServerConfig): Promise<{
|
|
7
|
+
export declare function executeMcpToolNode(node: McpNode, context: ExecutionContext, clientManager: McpClientManager, serverConfig: ServerConfig, startTime: number): Promise<{
|
|
8
8
|
output: unknown;
|
|
9
9
|
nextNode: string;
|
|
10
10
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-tool-executor.d.ts","sourceRoot":"","sources":["../../../src/execution/nodes/mcp-tool-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAGpE,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,gBAAgB,EACzB,aAAa,EAAE,gBAAgB,EAC/B,YAAY,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"mcp-tool-executor.d.ts","sourceRoot":"","sources":["../../../src/execution/nodes/mcp-tool-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAGpE,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,gBAAgB,EACzB,aAAa,EAAE,gBAAgB,EAC/B,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAkEhD"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { evaluateJsonata } from "../../expressions/jsonata.js";
|
|
5
5
|
import { logger } from "../../logger.js";
|
|
6
|
-
export async function executeMcpToolNode(node, context, clientManager, serverConfig) {
|
|
6
|
+
export async function executeMcpToolNode(node, context, clientManager, serverConfig, startTime) {
|
|
7
7
|
logger.debug(`Executing MCP tool node: ${node.id} (${node.server}.${node.tool})`);
|
|
8
8
|
const exprContext = context.getData();
|
|
9
9
|
// Pre-transform: Apply JSONata to format tool arguments
|
|
@@ -54,8 +54,9 @@ export async function executeMcpToolNode(node, context, clientManager, serverCon
|
|
|
54
54
|
}
|
|
55
55
|
logger.debug(`MCP tool output: ${JSON.stringify(toolOutput, null, 2)}`);
|
|
56
56
|
const output = toolOutput;
|
|
57
|
+
const endTime = Date.now();
|
|
57
58
|
context.setNodeOutput(node.id, output);
|
|
58
|
-
context.addHistory(node.id, transformedArgs, output);
|
|
59
|
+
context.addHistory(node.id, "mcp", transformedArgs, output, startTime, endTime);
|
|
59
60
|
return {
|
|
60
61
|
output,
|
|
61
62
|
nextNode: node.next,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-tool-executor.js","sourceRoot":"","sources":["../../../src/execution/nodes/mcp-tool-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,IAAa,EACb,OAAyB,EACzB,aAA+B,EAC/B,YAA0B;
|
|
1
|
+
{"version":3,"file":"mcp-tool-executor.js","sourceRoot":"","sources":["../../../src/execution/nodes/mcp-tool-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,IAAa,EACb,OAAyB,EACzB,aAA+B,EAC/B,YAA0B,EAC1B,SAAiB;IAEjB,MAAM,CAAC,KAAK,CAAC,4BAA4B,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;IAElF,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAEtC,wDAAwD;IACxD,MAAM,eAAe,GAA4B,EAAE,CAAC;IACpD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACvD,qBAAqB;YACrB,MAAM,SAAS,GAAG,MAAM,eAAe,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;YAC5D,eAAe,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;YACjC,MAAM,CAAC,KAAK,CAAC,YAAY,KAAK,mBAAmB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,C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MAAM,CAAC;gBACP,UAAU,GAAG,WAAW,CAAC;YAC3B,CAAC;QACH,CAAC;aAAM,CAAC;YACN,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;SAAM,CAAC;QACN,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,oBAAoB,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAExE,MAAM,MAAM,GAAG,UAAU,CAAC;IAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE3B,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACvC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAEhF,OAAO;QACL,MAAM;QACN,QAAQ,EAAE,IAAI,CAAC,IAAI;KACpB,CAAC;AACJ,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { SwitchNode } from "../../types/config.js";
|
|
5
5
|
import type { ExecutionContext } from "../context.js";
|
|
6
|
-
export declare function executeSwitchNode(node: SwitchNode, context: ExecutionContext): Promise<{
|
|
6
|
+
export declare function executeSwitchNode(node: SwitchNode, context: ExecutionContext, startTime: number): Promise<{
|
|
7
7
|
output: unknown;
|
|
8
8
|
nextNode: string;
|
|
9
9
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch-executor.d.ts","sourceRoot":"","sources":["../../../src/execution/nodes/switch-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAItD,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"switch-executor.d.ts","sourceRoot":"","sources":["../../../src/execution/nodes/switch-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAItD,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,gBAAgB,EACzB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAqChD"}
|
|
@@ -3,14 +3,16 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { evaluateJsonLogic } from "../../expressions/json-logic.js";
|
|
5
5
|
import { logger } from "../../logger.js";
|
|
6
|
-
export async function executeSwitchNode(node, context) {
|
|
6
|
+
export async function executeSwitchNode(node, context, startTime) {
|
|
7
7
|
logger.debug(`Executing switch node: ${node.id}`);
|
|
8
8
|
const exprContext = context.getData();
|
|
9
|
+
const endTime = Date.now();
|
|
9
10
|
// Evaluate conditions in order
|
|
10
11
|
for (const condition of node.conditions) {
|
|
11
12
|
// If no rule is specified, this is a default/fallback case
|
|
12
13
|
if (condition.rule === undefined || condition.rule === null) {
|
|
13
14
|
logger.debug(`Switch node ${node.id}: Using default/fallback target: ${condition.target}`);
|
|
15
|
+
context.addHistory(node.id, "switch", exprContext, exprContext, startTime, endTime);
|
|
14
16
|
return {
|
|
15
17
|
output: exprContext,
|
|
16
18
|
nextNode: condition.target,
|
|
@@ -20,6 +22,7 @@ export async function executeSwitchNode(node, context) {
|
|
|
20
22
|
const ruleResult = evaluateJsonLogic(condition.rule, exprContext);
|
|
21
23
|
if (ruleResult) {
|
|
22
24
|
logger.debug(`Switch node ${node.id}: Condition matched, routing to: ${condition.target}`);
|
|
25
|
+
context.addHistory(node.id, "switch", exprContext, exprContext, startTime, endTime);
|
|
23
26
|
return {
|
|
24
27
|
output: exprContext,
|
|
25
28
|
nextNode: condition.target,
|
|
@@ -27,6 +30,8 @@ export async function executeSwitchNode(node, context) {
|
|
|
27
30
|
}
|
|
28
31
|
}
|
|
29
32
|
// No conditions matched and no default case
|
|
30
|
-
|
|
33
|
+
const error = new Error(`Switch node ${node.id}: No conditions matched and no default case provided`);
|
|
34
|
+
context.addHistory(node.id, "switch", exprContext, null, startTime, endTime, error);
|
|
35
|
+
throw error;
|
|
31
36
|
}
|
|
32
37
|
//# sourceMappingURL=switch-executor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch-executor.js","sourceRoot":"","sources":["../../../src/execution/nodes/switch-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAgB,EAChB,OAAyB;
|
|
1
|
+
{"version":3,"file":"switch-executor.js","sourceRoot":"","sources":["../../../src/execution/nodes/switch-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAgB,EAChB,OAAyB,EACzB,SAAiB;IAEjB,MAAM,CAAC,KAAK,CAAC,0BAA0B,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IAElD,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IACtC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE3B,+BAA+B;IAC/B,KAAK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|
|
3
3
|
*/
|
|
4
4
|
import type { TransformNode } from "../../types/config.js";
|
|
5
5
|
import type { ExecutionContext } from "../context.js";
|
|
6
|
-
export declare function executeTransformNode(node: TransformNode, context: ExecutionContext): Promise<{
|
|
6
|
+
export declare function executeTransformNode(node: TransformNode, context: ExecutionContext, startTime: number): Promise<{
|
|
7
7
|
output: unknown;
|
|
8
8
|
nextNode: string;
|
|
9
9
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-executor.d.ts","sourceRoot":"","sources":["../../../src/execution/nodes/transform-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAItD,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"transform-executor.d.ts","sourceRoot":"","sources":["../../../src/execution/nodes/transform-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAItD,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,gBAAgB,EACzB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAmBhD"}
|
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { evaluateJsonata } from "../../expressions/jsonata.js";
|
|
5
5
|
import { logger } from "../../logger.js";
|
|
6
|
-
export async function executeTransformNode(node, context) {
|
|
6
|
+
export async function executeTransformNode(node, context, startTime) {
|
|
7
7
|
logger.debug(`Executing transform node: ${node.id}`);
|
|
8
8
|
logger.debug(`Transform expression: ${node.transform.expr}`);
|
|
9
9
|
const exprContext = context.getData();
|
|
10
10
|
logger.debug(`Transform context: ${JSON.stringify(exprContext, null, 2)}`);
|
|
11
11
|
const output = await evaluateJsonata(node.transform.expr, exprContext);
|
|
12
|
+
const endTime = Date.now();
|
|
12
13
|
logger.debug(`Transform output: ${JSON.stringify(output, null, 2)}`);
|
|
13
14
|
context.setNodeOutput(node.id, output);
|
|
14
|
-
context.addHistory(node.id, exprContext, output);
|
|
15
|
+
context.addHistory(node.id, "transform", exprContext, output, startTime, endTime);
|
|
15
16
|
return {
|
|
16
17
|
output,
|
|
17
18
|
nextNode: node.next,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-executor.js","sourceRoot":"","sources":["../../../src/execution/nodes/transform-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,IAAmB,EACnB,OAAyB;
|
|
1
|
+
{"version":3,"file":"transform-executor.js","sourceRoot":"","sources":["../../../src/execution/nodes/transform-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,IAAmB,EACnB,OAAyB,EACzB,SAAiB;IAEjB,MAAM,CAAC,KAAK,CAAC,6BAA6B,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IACrD,MAAM,CAAC,KAAK,CAAC,yBAAyB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IAE7D,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IACtC,MAAM,CAAC,KAAK,CAAC,sBAAsB,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAE3E,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IACvE,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE3B,MAAM,CAAC,KAAK,CAAC,qBAAqB,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAErE,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACvC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAElF,OAAO;QACL,MAAM;QACN,QAAQ,EAAE,IAAI,CAAC,IAAI;KACpB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for execution introspection and debugging
|
|
3
|
+
*/
|
|
4
|
+
import type { NodeDefinition } from "./config.js";
|
|
5
|
+
import type { ExecutionContext } from "../execution/context.js";
|
|
6
|
+
export type ExecutionStatus = "not_started" | "running" | "paused" | "finished" | "error";
|
|
7
|
+
export interface NodeExecutionRecord {
|
|
8
|
+
nodeId: string;
|
|
9
|
+
nodeType: string;
|
|
10
|
+
startTime: number;
|
|
11
|
+
endTime: number;
|
|
12
|
+
duration: number;
|
|
13
|
+
input: unknown;
|
|
14
|
+
output: unknown;
|
|
15
|
+
error?: Error;
|
|
16
|
+
}
|
|
17
|
+
export interface ExecutionState {
|
|
18
|
+
status: ExecutionStatus;
|
|
19
|
+
currentNodeId: string | null;
|
|
20
|
+
executionHistory: NodeExecutionRecord[];
|
|
21
|
+
context: ExecutionContext;
|
|
22
|
+
error?: Error;
|
|
23
|
+
}
|
|
24
|
+
export interface ExecutionHooks {
|
|
25
|
+
/**
|
|
26
|
+
* Called before a node executes
|
|
27
|
+
* Return false to pause execution (breakpoint)
|
|
28
|
+
*/
|
|
29
|
+
onNodeStart?: (nodeId: string, node: NodeDefinition, context: ExecutionContext) => Promise<boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* Called after a node completes successfully
|
|
32
|
+
*/
|
|
33
|
+
onNodeComplete?: (nodeId: string, node: NodeDefinition, input: unknown, output: unknown, duration: number) => Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Called when a node encounters an error
|
|
36
|
+
*/
|
|
37
|
+
onNodeError?: (nodeId: string, node: NodeDefinition, error: Error, context: ExecutionContext) => Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Called when execution pauses (breakpoint hit or manual pause)
|
|
40
|
+
*/
|
|
41
|
+
onPause?: (nodeId: string, context: ExecutionContext) => Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Called when execution resumes
|
|
44
|
+
*/
|
|
45
|
+
onResume?: () => Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
export interface ExecutionController {
|
|
48
|
+
/**
|
|
49
|
+
* Pause execution at the next node boundary
|
|
50
|
+
* Only valid when status is "running"
|
|
51
|
+
*/
|
|
52
|
+
pause(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Resume execution
|
|
55
|
+
* Only valid when status is "paused"
|
|
56
|
+
*/
|
|
57
|
+
resume(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Step to the next node (step over)
|
|
60
|
+
* Only valid when status is "paused"
|
|
61
|
+
*/
|
|
62
|
+
step(): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Get current execution state
|
|
65
|
+
*/
|
|
66
|
+
getState(): ExecutionState;
|
|
67
|
+
/**
|
|
68
|
+
* Set breakpoints
|
|
69
|
+
*/
|
|
70
|
+
setBreakpoints(nodeIds: string[]): void;
|
|
71
|
+
/**
|
|
72
|
+
* Clear breakpoints
|
|
73
|
+
*/
|
|
74
|
+
clearBreakpoints(): void;
|
|
75
|
+
}
|
|
76
|
+
export interface ExecutionOptions {
|
|
77
|
+
hooks?: ExecutionHooks;
|
|
78
|
+
breakpoints?: string[];
|
|
79
|
+
enableTelemetry?: boolean;
|
|
80
|
+
}
|
|
81
|
+
export interface ExecutionTelemetry {
|
|
82
|
+
totalDuration: number;
|
|
83
|
+
nodeDurations: Map<string, number>;
|
|
84
|
+
nodeCounts: Map<string, number>;
|
|
85
|
+
errorCount: number;
|
|
86
|
+
}
|
|
87
|
+
export interface ExecutionResult {
|
|
88
|
+
result: unknown;
|
|
89
|
+
executionHistory: NodeExecutionRecord[];
|
|
90
|
+
telemetry?: ExecutionTelemetry;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/types/execution.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;AAE1F,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,eAAe,CAAC;IACxB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,gBAAgB,EAAE,mBAAmB,EAAE,CA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AAC,EAAE,MAAM,EAAE,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,EAAE,mBAAmB,EAAE,CAAC;IACxC,SAAS,CAAC,EAAE,kBAAkB,CAAC;CAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.js","sourceRoot":"","sources":["../../src/types/execution.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/examples/api-usage.ts
CHANGED
|
@@ -38,6 +38,48 @@ async function example() {
|
|
|
38
38
|
await api.close();
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
// Example: Using introspection and debugging features
|
|
42
|
+
async function introspectionExample() {
|
|
43
|
+
const api = new McpGraphApi('examples/count_files.yaml');
|
|
44
|
+
|
|
45
|
+
// Execute with hooks and telemetry
|
|
46
|
+
const result = await api.executeTool('count_files', {
|
|
47
|
+
directory: './tests/files',
|
|
48
|
+
}, {
|
|
49
|
+
hooks: {
|
|
50
|
+
onNodeStart: async (nodeId, node) => {
|
|
51
|
+
console.log(`[Hook] Starting node: ${nodeId} (${node.type})`);
|
|
52
|
+
return true; // Continue execution
|
|
53
|
+
},
|
|
54
|
+
onNodeComplete: async (nodeId, node, input, output, duration) => {
|
|
55
|
+
console.log(`[Hook] Node ${nodeId} completed in ${duration}ms`);
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
enableTelemetry: true,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Access execution history
|
|
62
|
+
if (result.executionHistory) {
|
|
63
|
+
console.log('\nExecution History:');
|
|
64
|
+
for (const record of result.executionHistory) {
|
|
65
|
+
console.log(` ${record.nodeId} (${record.nodeType}): ${record.duration}ms`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Access telemetry
|
|
70
|
+
if (result.telemetry) {
|
|
71
|
+
console.log('\nTelemetry:');
|
|
72
|
+
console.log(` Total duration: ${result.telemetry.totalDuration}ms`);
|
|
73
|
+
console.log(` Errors: ${result.telemetry.errorCount}`);
|
|
74
|
+
for (const [nodeType, duration] of result.telemetry.nodeDurations) {
|
|
75
|
+
const count = result.telemetry.nodeCounts.get(nodeType) || 0;
|
|
76
|
+
console.log(` ${nodeType}: ${count} executions, ${duration}ms total`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
await api.close();
|
|
81
|
+
}
|
|
82
|
+
|
|
41
83
|
// Example: Validate config without creating an API instance
|
|
42
84
|
function validateConfigExample() {
|
|
43
85
|
const errors = McpGraphApi.validateConfig('examples/count_files.yaml');
|
|
@@ -64,6 +106,12 @@ function loadAndValidateExample() {
|
|
|
64
106
|
|
|
65
107
|
// Run examples
|
|
66
108
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
67
|
-
|
|
109
|
+
const exampleToRun = process.argv[2] || 'basic';
|
|
110
|
+
|
|
111
|
+
if (exampleToRun === 'introspection') {
|
|
112
|
+
introspectionExample().catch(console.error);
|
|
113
|
+
} else {
|
|
114
|
+
example().catch(console.error);
|
|
115
|
+
}
|
|
68
116
|
}
|
|
69
117
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
version: "1.0"
|
|
2
|
+
|
|
3
|
+
# MCP Server Metadata
|
|
4
|
+
server:
|
|
5
|
+
name: "switchExample"
|
|
6
|
+
version: "1.0.0"
|
|
7
|
+
description: "Example demonstrating switch node functionality"
|
|
8
|
+
|
|
9
|
+
# Tool Definitions
|
|
10
|
+
tools:
|
|
11
|
+
- name: "test_switch"
|
|
12
|
+
description: "Test switch node with conditional routing"
|
|
13
|
+
inputSchema:
|
|
14
|
+
type: "object"
|
|
15
|
+
properties:
|
|
16
|
+
value:
|
|
17
|
+
type: "number"
|
|
18
|
+
description: "A numeric value to route based on"
|
|
19
|
+
required:
|
|
20
|
+
- value
|
|
21
|
+
outputSchema:
|
|
22
|
+
type: "object"
|
|
23
|
+
properties:
|
|
24
|
+
result:
|
|
25
|
+
type: "string"
|
|
26
|
+
description: "The routing result"
|
|
27
|
+
|
|
28
|
+
# Graph Nodes
|
|
29
|
+
nodes:
|
|
30
|
+
# Entry node: Receives tool arguments
|
|
31
|
+
- id: "entry"
|
|
32
|
+
type: "entry"
|
|
33
|
+
tool: "test_switch"
|
|
34
|
+
next: "switch_node"
|
|
35
|
+
|
|
36
|
+
# Switch node: Routes based on value
|
|
37
|
+
- id: "switch_node"
|
|
38
|
+
type: "switch"
|
|
39
|
+
conditions:
|
|
40
|
+
- rule:
|
|
41
|
+
">":
|
|
42
|
+
- { var: "value" }
|
|
43
|
+
- 10
|
|
44
|
+
target: "high_path"
|
|
45
|
+
- rule:
|
|
46
|
+
">":
|
|
47
|
+
- { var: "value" }
|
|
48
|
+
- 0
|
|
49
|
+
target: "low_path"
|
|
50
|
+
- target: "zero_path"
|
|
51
|
+
|
|
52
|
+
# High path (> 10)
|
|
53
|
+
- id: "high_path"
|
|
54
|
+
type: "transform"
|
|
55
|
+
transform:
|
|
56
|
+
expr: |
|
|
57
|
+
{ "result": "high" }
|
|
58
|
+
next: "exit"
|
|
59
|
+
|
|
60
|
+
# Low path (> 0 but <= 10)
|
|
61
|
+
- id: "low_path"
|
|
62
|
+
type: "transform"
|
|
63
|
+
transform:
|
|
64
|
+
expr: |
|
|
65
|
+
{ "result": "low" }
|
|
66
|
+
next: "exit"
|
|
67
|
+
|
|
68
|
+
# Zero/negative path (default)
|
|
69
|
+
- id: "zero_path"
|
|
70
|
+
type: "transform"
|
|
71
|
+
transform:
|
|
72
|
+
expr: |
|
|
73
|
+
{ "result": "zero_or_negative" }
|
|
74
|
+
next: "exit"
|
|
75
|
+
|
|
76
|
+
# Exit node: Returns the result
|
|
77
|
+
- id: "exit"
|
|
78
|
+
type: "exit"
|
|
79
|
+
tool: "test_switch"
|
|
80
|
+
|