mcpgraph 0.1.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.
Files changed (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +189 -0
  3. package/dist/config/loader.d.ts +6 -0
  4. package/dist/config/loader.d.ts.map +1 -0
  5. package/dist/config/loader.js +8 -0
  6. package/dist/config/loader.js.map +1 -0
  7. package/dist/config/parser.d.ts +6 -0
  8. package/dist/config/parser.d.ts.map +1 -0
  9. package/dist/config/parser.js +24 -0
  10. package/dist/config/parser.js.map +1 -0
  11. package/dist/config/schema.d.ts +366 -0
  12. package/dist/config/schema.d.ts.map +1 -0
  13. package/dist/config/schema.js +75 -0
  14. package/dist/config/schema.js.map +1 -0
  15. package/dist/count-files.test.d.ts +5 -0
  16. package/dist/count-files.test.d.ts.map +1 -0
  17. package/dist/count-files.test.js +46 -0
  18. package/dist/count-files.test.js.map +1 -0
  19. package/dist/execution/context.d.ts +18 -0
  20. package/dist/execution/context.d.ts.map +1 -0
  21. package/dist/execution/context.js +33 -0
  22. package/dist/execution/context.js.map +1 -0
  23. package/dist/execution/executor.d.ts +13 -0
  24. package/dist/execution/executor.d.ts.map +1 -0
  25. package/dist/execution/executor.js +72 -0
  26. package/dist/execution/executor.js.map +1 -0
  27. package/dist/execution/nodes/entry-executor.d.ts +10 -0
  28. package/dist/execution/nodes/entry-executor.d.ts.map +1 -0
  29. package/dist/execution/nodes/entry-executor.js +17 -0
  30. package/dist/execution/nodes/entry-executor.js.map +1 -0
  31. package/dist/execution/nodes/exit-executor.d.ts +9 -0
  32. package/dist/execution/nodes/exit-executor.d.ts.map +1 -0
  33. package/dist/execution/nodes/exit-executor.js +16 -0
  34. package/dist/execution/nodes/exit-executor.js.map +1 -0
  35. package/dist/execution/nodes/mcp-tool-executor.d.ts +11 -0
  36. package/dist/execution/nodes/mcp-tool-executor.d.ts.map +1 -0
  37. package/dist/execution/nodes/mcp-tool-executor.js +74 -0
  38. package/dist/execution/nodes/mcp-tool-executor.js.map +1 -0
  39. package/dist/execution/nodes/switch-executor.d.ts +10 -0
  40. package/dist/execution/nodes/switch-executor.d.ts.map +1 -0
  41. package/dist/execution/nodes/switch-executor.js +32 -0
  42. package/dist/execution/nodes/switch-executor.js.map +1 -0
  43. package/dist/execution/nodes/transform-executor.d.ts +10 -0
  44. package/dist/execution/nodes/transform-executor.d.ts.map +1 -0
  45. package/dist/execution/nodes/transform-executor.js +20 -0
  46. package/dist/execution/nodes/transform-executor.js.map +1 -0
  47. package/dist/expressions/context.d.ts +9 -0
  48. package/dist/expressions/context.d.ts.map +1 -0
  49. package/dist/expressions/context.js +10 -0
  50. package/dist/expressions/context.js.map +1 -0
  51. package/dist/expressions/json-logic.d.ts +11 -0
  52. package/dist/expressions/json-logic.d.ts.map +1 -0
  53. package/dist/expressions/json-logic.js +27 -0
  54. package/dist/expressions/json-logic.js.map +1 -0
  55. package/dist/expressions/jsonata.d.ts +5 -0
  56. package/dist/expressions/jsonata.d.ts.map +1 -0
  57. package/dist/expressions/jsonata.js +27 -0
  58. package/dist/expressions/jsonata.js.map +1 -0
  59. package/dist/graph/graph.d.ts +14 -0
  60. package/dist/graph/graph.d.ts.map +1 -0
  61. package/dist/graph/graph.js +38 -0
  62. package/dist/graph/graph.js.map +1 -0
  63. package/dist/graph/validator.d.ts +11 -0
  64. package/dist/graph/validator.d.ts.map +1 -0
  65. package/dist/graph/validator.js +90 -0
  66. package/dist/graph/validator.js.map +1 -0
  67. package/dist/logger.d.ts +23 -0
  68. package/dist/logger.d.ts.map +1 -0
  69. package/dist/logger.js +37 -0
  70. package/dist/logger.js.map +1 -0
  71. package/dist/main.d.ts +5 -0
  72. package/dist/main.d.ts.map +1 -0
  73. package/dist/main.js +93 -0
  74. package/dist/main.js.map +1 -0
  75. package/dist/mcp/client-manager.d.ts +11 -0
  76. package/dist/mcp/client-manager.d.ts.map +1 -0
  77. package/dist/mcp/client-manager.js +39 -0
  78. package/dist/mcp/client-manager.js.map +1 -0
  79. package/dist/types/config.d.ts +69 -0
  80. package/dist/types/config.d.ts.map +1 -0
  81. package/dist/types/config.js +5 -0
  82. package/dist/types/config.js.map +1 -0
  83. package/examples/count_files.yaml +57 -0
  84. package/package.json +54 -0
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Zod schemas for validating mcpGraph configuration
3
+ */
4
+ import { z } from "zod";
5
+ const jsonSchemaPropertySchema = z.object({
6
+ type: z.string(),
7
+ description: z.string().optional(),
8
+ });
9
+ const jsonSchemaSchema = z.object({
10
+ type: z.string(),
11
+ properties: z.record(jsonSchemaPropertySchema).optional(),
12
+ required: z.array(z.string()).optional(),
13
+ description: z.string().optional(),
14
+ });
15
+ const serverMetadataSchema = z.object({
16
+ name: z.string(),
17
+ version: z.string(),
18
+ description: z.string(),
19
+ });
20
+ const baseNodeSchema = z.object({
21
+ id: z.string(),
22
+ type: z.string(),
23
+ next: z.string().optional(),
24
+ });
25
+ const entryNodeSchema = baseNodeSchema.extend({
26
+ type: z.literal("entry"),
27
+ next: z.string(),
28
+ });
29
+ const exitNodeSchema = baseNodeSchema.extend({
30
+ type: z.literal("exit"),
31
+ });
32
+ const mcpToolNodeSchema = baseNodeSchema.extend({
33
+ type: z.literal("mcp_tool"),
34
+ server: z.string(),
35
+ tool: z.string(),
36
+ args: z.record(z.unknown()),
37
+ next: z.string(),
38
+ });
39
+ const transformNodeSchema = baseNodeSchema.extend({
40
+ type: z.literal("transform"),
41
+ transform: z.object({
42
+ expr: z.string(),
43
+ }),
44
+ next: z.string(),
45
+ });
46
+ const switchConditionSchema = z.object({
47
+ rule: z.unknown().optional(),
48
+ target: z.string(),
49
+ });
50
+ const switchNodeSchema = baseNodeSchema.extend({
51
+ type: z.literal("switch"),
52
+ conditions: z.array(switchConditionSchema),
53
+ });
54
+ const nodeSchema = z.discriminatedUnion("type", [
55
+ entryNodeSchema,
56
+ exitNodeSchema,
57
+ mcpToolNodeSchema,
58
+ transformNodeSchema,
59
+ switchNodeSchema,
60
+ ]);
61
+ const toolDefinitionSchema = z.object({
62
+ name: z.string(),
63
+ description: z.string(),
64
+ inputSchema: jsonSchemaSchema,
65
+ outputSchema: jsonSchemaSchema,
66
+ entryNode: z.string(),
67
+ exitNode: z.string(),
68
+ });
69
+ export const mcpGraphConfigSchema = z.object({
70
+ version: z.string(),
71
+ server: serverMetadataSchema,
72
+ tools: z.array(toolDefinitionSchema),
73
+ nodes: z.array(nodeSchema),
74
+ });
75
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACnC,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,QAAQ,EAAE;IACzD,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACxC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACnC,CAAC,CAAC;AAEH,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;CACxB,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B,EAAE,EAAE,CA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CAAC;IAC7C,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IACzB,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,qBAAqB,CAAC;CAC3C,CAAC,CAAC;AAEH,MAAM,UAAU,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IAC9C,eAAe;IACf,cAAc;IACd,iBAAiB;IACjB,mBAAmB;IACnB,gBAAgB;CACjB,CAAC,CAAC;AAEH,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,WAAW,EAAE,gBAAgB;IAC7B,YAAY,EAAE,gBAAgB;IAC9B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;CACrB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,MAAM,EAAE,oBAAoB;IAC5B,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC;IACpC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;CAC3B,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Integration test for count_files tool
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=count-files.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"count-files.test.d.ts","sourceRoot":"","sources":["../src/count-files.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Integration test for count_files tool
3
+ */
4
+ import { describe, it, before, after } from "node:test";
5
+ import { strict as assert } from "node:assert";
6
+ import { loadConfig } from "./config/loader.js";
7
+ import { validateGraph } from "./graph/validator.js";
8
+ import { GraphExecutor } from "./execution/executor.js";
9
+ import { McpClientManager } from "./mcp/client-manager.js";
10
+ import { join } from "node:path";
11
+ import { fileURLToPath } from "node:url";
12
+ import { dirname } from "node:path";
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = dirname(__filename);
15
+ const projectRoot = join(__dirname, "..");
16
+ describe("count_files tool", () => {
17
+ let executor;
18
+ let clientManager;
19
+ before(async () => {
20
+ const configPath = join(projectRoot, "examples", "count_files.yaml");
21
+ const config = loadConfig(configPath);
22
+ const errors = validateGraph(config);
23
+ if (errors.length > 0) {
24
+ throw new Error(`Graph validation failed: ${errors.map((e) => e.message).join(", ")}`);
25
+ }
26
+ clientManager = new McpClientManager();
27
+ executor = new GraphExecutor(config, clientManager);
28
+ });
29
+ after(async () => {
30
+ await clientManager.closeAll();
31
+ });
32
+ it("should count files in the test directory", async () => {
33
+ const testDir = join(projectRoot, "test");
34
+ const result = await executor.executeTool("count_files", {
35
+ directory: testDir,
36
+ });
37
+ console.log(`File count result:`, JSON.stringify(result, null, 2));
38
+ assert(result !== undefined, "Result should be defined");
39
+ assert(typeof result === "object", "Result should be an object");
40
+ assert("count" in result, "Result should have count property");
41
+ assert(typeof result.count === "number", "Count should be a number");
42
+ assert(result.count > 0, "Count should be greater than 0");
43
+ console.log(`File count result:`, result);
44
+ });
45
+ });
46
+ //# sourceMappingURL=count-files.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"count-files.test.js","sourceRoot":"","sources":["../src/count-files.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,yBA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AE,KAAK,IAAI,EAAE;QACxD,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAC1C,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,aAAa,EAAE;YACvD,SAAS,EAAE,OAAO;SACnB,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAEnE,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,0BAA0B,CAAC,CAAC;QACzD,MAAM,CAAC,OAAO,MAAM,KAAK,QAAQ,EAAE,4BAA4B,CAAC,CAAC;QACjE,MAAM,CAAC,OAAO,IAAK,MAAiB,EAAE,mCAAmC,CAAC,CAAC;QAC3E,MAAM,CAAC,OAAQ,MAA4B,CAAC,KAAK,KAAK,QAAQ,EAAE,0BAA0B,CAAC,CAAC;QAC5F,MAAM,CAAE,MAA4B,CAAC,KAAK,GAAG,CAAC,EAAE,gCAAgC,CAAC,CAAC;QAElF,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Execution context for graph execution
3
+ */
4
+ import type { ExecutionContext as ExprContext } from "../expressions/context.js";
5
+ export declare class ExecutionContext {
6
+ private data;
7
+ private history;
8
+ constructor(toolInput: Record<string, unknown>);
9
+ getData(): ExprContext;
10
+ setNodeOutput(nodeId: string, output: unknown): void;
11
+ addHistory(nodeId: string, input: unknown, output: unknown): void;
12
+ getHistory(): Array<{
13
+ nodeId: string;
14
+ input: unknown;
15
+ output: unknown;
16
+ }>;
17
+ }
18
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +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;AAEjF,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,OAAO,CAA6D;gBAEhE,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,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;IAIjE,UAAU,IAAI,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC;CAGzE"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Execution context for graph execution
3
+ */
4
+ export class ExecutionContext {
5
+ data;
6
+ history;
7
+ constructor(toolInput) {
8
+ // Initialize context with tool input available as $.input
9
+ this.data = {
10
+ input: toolInput,
11
+ // Also make input properties directly accessible for convenience
12
+ ...toolInput,
13
+ };
14
+ this.history = [];
15
+ }
16
+ getData() {
17
+ return this.data;
18
+ }
19
+ setNodeOutput(nodeId, output) {
20
+ // Store output with node ID as key for reference
21
+ this.data[nodeId] = output;
22
+ // Also store in a generic way for JSONata access
23
+ this.data.output = output;
24
+ this.data.last = output;
25
+ }
26
+ addHistory(nodeId, input, output) {
27
+ this.history.push({ nodeId, input, output });
28
+ }
29
+ getHistory() {
30
+ return this.history;
31
+ }
32
+ }
33
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/execution/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,OAAO,gBAAgB;IACnB,IAAI,CAAc;IAClB,OAAO,CAA6D;IAE5E,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,CAAC,MAAc,EAAE,KAAc,EAAE,MAAe;QACxD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Graph execution engine
3
+ */
4
+ import type { McpGraphConfig } from "../types/config.js";
5
+ import type { McpClientManager } from "../mcp/client-manager.js";
6
+ export declare class GraphExecutor {
7
+ private config;
8
+ private graph;
9
+ private clientManager;
10
+ constructor(config: McpGraphConfig, clientManager: McpClientManager);
11
+ executeTool(toolName: string, toolInput: Record<string, unknown>): Promise<unknown>;
12
+ }
13
+ //# sourceMappingURL=executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/execution/executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,oBAAoB,CAAC;AAQzE,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;gBAE5B,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,gBAAgB;IAM7D,WAAW,CACf,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,OAAO,CAAC,OAAO,CAAC;CA0DpB"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Graph execution engine
3
+ */
4
+ import { Graph } from "../graph/graph.js";
5
+ import { ExecutionContext } from "./context.js";
6
+ import { executeEntryNode } from "./nodes/entry-executor.js";
7
+ import { executeExitNode } from "./nodes/exit-executor.js";
8
+ import { executeTransformNode } from "./nodes/transform-executor.js";
9
+ import { executeMcpToolNode } from "./nodes/mcp-tool-executor.js";
10
+ import { executeSwitchNode } from "./nodes/switch-executor.js";
11
+ import { logger } from "../logger.js";
12
+ export class GraphExecutor {
13
+ config;
14
+ graph;
15
+ clientManager;
16
+ constructor(config, clientManager) {
17
+ this.config = config;
18
+ this.graph = new Graph(config.nodes);
19
+ this.clientManager = clientManager;
20
+ }
21
+ async executeTool(toolName, toolInput) {
22
+ const tool = this.config.tools.find((t) => t.name === toolName);
23
+ if (!tool) {
24
+ throw new Error(`Tool not found: ${toolName}`);
25
+ }
26
+ logger.info(`Executing tool: ${toolName}`);
27
+ const context = new ExecutionContext(toolInput);
28
+ let currentNodeId = tool.entryNode;
29
+ // Execute nodes until we reach the exit node
30
+ while (currentNodeId !== tool.exitNode) {
31
+ const node = this.graph.getNode(currentNodeId);
32
+ if (!node) {
33
+ throw new Error(`Node not found: ${currentNodeId}`);
34
+ }
35
+ logger.debug(`Executing node: ${currentNodeId} (type: ${node.type})`);
36
+ let result;
37
+ switch (node.type) {
38
+ case "entry":
39
+ result = executeEntryNode(node, toolInput, context);
40
+ break;
41
+ case "exit":
42
+ result = executeExitNode(node, context);
43
+ return result.output;
44
+ case "transform":
45
+ result = await executeTransformNode(node, context);
46
+ break;
47
+ case "mcp_tool":
48
+ result = await executeMcpToolNode(node, context, this.clientManager);
49
+ break;
50
+ case "switch":
51
+ result = await executeSwitchNode(node, context);
52
+ break;
53
+ default:
54
+ throw new Error(`Unknown node type: ${node.type}`);
55
+ }
56
+ if (result.nextNode) {
57
+ currentNodeId = result.nextNode;
58
+ }
59
+ else {
60
+ throw new Error(`Node ${currentNodeId} has no next node and is not the exit node`);
61
+ }
62
+ }
63
+ // Should not reach here, but handle exit node
64
+ const exitNode = this.graph.getNode(tool.exitNode);
65
+ if (exitNode && exitNode.type === "exit") {
66
+ const result = executeExitNode(exitNode, context);
67
+ return result.output;
68
+ }
69
+ throw new Error(`Exit node ${tool.exitNode} not found or invalid`);
70
+ }
71
+ }
72
+ //# sourceMappingURL=executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../src/execution/executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,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;IAExC,YAAY,MAAsB,EAAE,aAA+B;QACjE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG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AAK,WAAW;oBACd,MAAM,GAAG,MAAM,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;oBACnD,MAAM;gBACR,KAAK,UAAU;oBACb,MAAM,GAAG,MAAM,kBAAkB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;oBACrE,MAAM;gBACR,KAAK,QAAQ;oBACX,MAAM,GAAG,MAAM,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;oBAChD,MAAM;gBACR;oBACE,MAAM,IAAI,KAAK,CAAC,sBAAuB,IAAyB,CAAC,IAAI,EAAE,CAAC,CAAC;YAC7E,CAAC;YAED,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACpB,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC;YAClC,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CAAC,QAAQ,aAAa,4CAA4C,CAAC,CAAC;YACrF,CAAC;QACH,CAAC;QAED,8CAA8C;QAC9C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnD,IAAI,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACzC,MAAM,MAAM,GAAG,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAClD,OAAO,MAAM,CAAC,MAAM,CAAC;QACvB,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,aAAa,IAAI,CAAC,QAAQ,uBAAuB,CAAC,CAAC;IACrE,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Entry node executor
3
+ */
4
+ import type { EntryNode } from "../../types/config.js";
5
+ import type { ExecutionContext } from "../context.js";
6
+ export declare function executeEntryNode(node: EntryNode, toolInput: Record<string, unknown>, context: ExecutionContext): {
7
+ output: unknown;
8
+ nextNode: string;
9
+ };
10
+ //# sourceMappingURL=entry-executor.d.ts.map
@@ -0,0 +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,GACxB;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAcvC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Entry node executor
3
+ */
4
+ import { logger } from "../../logger.js";
5
+ export function executeEntryNode(node, toolInput, context) {
6
+ logger.debug(`Executing entry node: ${node.id}`);
7
+ // Entry node receives tool input and initializes context
8
+ // The input is already in the context, so we just pass it through
9
+ const output = toolInput;
10
+ context.setNodeOutput(node.id, output);
11
+ context.addHistory(node.id, toolInput, output);
12
+ return {
13
+ output,
14
+ nextNode: node.next,
15
+ };
16
+ }
17
+ //# sourceMappingURL=entry-executor.js.map
@@ -0,0 +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;IAEzB,MAAM,CAAC,KAAK,CAAC,yBAAyB,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IAEjD,yDAAyD;IACzD,kEAAkE;IAClE,MAAM,MAAM,GAAG,SAAS,CAAC;IAEzB,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACvC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAE/C,OAAO;QACL,MAAM;QACN,QAAQ,EAAE,IAAI,CAAC,IAAI;KACpB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Exit node executor
3
+ */
4
+ import type { ExitNode } from "../../types/config.js";
5
+ import type { ExecutionContext } from "../context.js";
6
+ export declare function executeExitNode(node: ExitNode, context: ExecutionContext): {
7
+ output: unknown;
8
+ };
9
+ //# sourceMappingURL=exit-executor.d.ts.map
@@ -0,0 +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,GACxB;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAarB"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Exit node executor
3
+ */
4
+ import { logger } from "../../logger.js";
5
+ export function executeExitNode(node, context) {
6
+ logger.debug(`Executing exit node: ${node.id}`);
7
+ // Exit node extracts the final result from context
8
+ // Use the last output or the context's output
9
+ const data = context.getData();
10
+ const output = data.output || data.last || {};
11
+ context.addHistory(node.id, data, output);
12
+ return {
13
+ output,
14
+ };
15
+ }
16
+ //# sourceMappingURL=exit-executor.js.map
@@ -0,0 +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;IAEzB,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;IAE9C,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAE1C,OAAO;QACL,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * MCP tool node executor
3
+ */
4
+ import type { McpToolNode } from "../../types/config.js";
5
+ import type { ExecutionContext } from "../context.js";
6
+ import type { McpClientManager } from "../../mcp/client-manager.js";
7
+ export declare function executeMcpToolNode(node: McpToolNode, context: ExecutionContext, clientManager: McpClientManager): Promise<{
8
+ output: unknown;
9
+ nextNode: string;
10
+ }>;
11
+ //# sourceMappingURL=mcp-tool-executor.d.ts.map
@@ -0,0 +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,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAGpE,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,gBAAgB,EACzB,aAAa,EAAE,gBAAgB,GAC9B,OAAO,CAAC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA4EhD"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * MCP tool node executor
3
+ */
4
+ import { evaluateJsonata } from "../../expressions/jsonata.js";
5
+ import { logger } from "../../logger.js";
6
+ export async function executeMcpToolNode(node, context, clientManager) {
7
+ logger.debug(`Executing MCP tool node: ${node.id} (${node.server}.${node.tool})`);
8
+ const exprContext = context.getData();
9
+ // Pre-transform: Apply JSONata to format tool arguments
10
+ const transformedArgs = {};
11
+ for (const [key, value] of Object.entries(node.args)) {
12
+ if (typeof value === "string" && value.startsWith("$")) {
13
+ // JSONata expression
14
+ const evaluated = await evaluateJsonata(value, exprContext);
15
+ transformedArgs[key] = evaluated;
16
+ logger.debug(`JSONata "${value}" evaluated to: ${JSON.stringify(evaluated)}`);
17
+ }
18
+ else {
19
+ transformedArgs[key] = value;
20
+ }
21
+ }
22
+ logger.debug(`MCP tool args: ${JSON.stringify(transformedArgs, null, 2)}`);
23
+ logger.debug(`Expression context: ${JSON.stringify(exprContext, null, 2)}`);
24
+ // Get or create MCP client
25
+ // For now, we'll assume filesystem server uses npx
26
+ // In a real implementation, server config would come from somewhere
27
+ const command = "npx";
28
+ const args = [
29
+ "-y",
30
+ "@modelcontextprotocol/server-filesystem",
31
+ // This should come from config, but for now hardcode test directory
32
+ process.cwd() + "/tests/files",
33
+ ];
34
+ const client = await clientManager.getClient(node.server, command, args);
35
+ // Call the tool
36
+ const result = await client.callTool({
37
+ name: node.tool,
38
+ arguments: transformedArgs,
39
+ });
40
+ if (result.isError) {
41
+ const content = result.content;
42
+ throw new Error(`MCP tool error: ${content[0]?.text || "Unknown error"}`);
43
+ }
44
+ // Extract result content
45
+ const content = result.content;
46
+ let toolOutput;
47
+ if (content[0] && typeof content[0] === "object" && "text" in content[0]) {
48
+ const textContent = content[0].text;
49
+ if (textContent) {
50
+ try {
51
+ toolOutput = JSON.parse(textContent);
52
+ }
53
+ catch {
54
+ toolOutput = textContent;
55
+ }
56
+ }
57
+ else {
58
+ toolOutput = content[0];
59
+ }
60
+ }
61
+ else {
62
+ toolOutput = content[0];
63
+ }
64
+ logger.debug(`MCP tool output: ${JSON.stringify(toolOutput, null, 2)}`);
65
+ // Post-transform could go here if needed
66
+ const output = toolOutput;
67
+ context.setNodeOutput(node.id, output);
68
+ context.addHistory(node.id, transformedArgs, output);
69
+ return {
70
+ output,
71
+ nextNode: node.next,
72
+ };
73
+ }
74
+ //# sourceMappingURL=mcp-tool-executor.js.map
@@ -0,0 +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,IAAiB,EACjB,OAAyB,EACzB,aAA+B;IAE/B,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,CAAC,CAAC;QAChF,CAAC;aAAM,CAAC;YACN,eAAe,CAAC,GAAG,CAAC,GAAG,KAAK,CAA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AAI,WAAW,EAAE,CAAC;YAChB,IAAI,CAAC;gBACH,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YACvC,CAAC;YAAC,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,yCAAyC;IACzC,MAAM,MAAM,GAAG,UAAU,CAAC;IAE1B,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACvC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;IAErD,OAAO;QACL,MAAM;QACN,QAAQ,EAAE,IAAI,CAAC,IAAI;KACpB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Switch node executor
3
+ */
4
+ import type { SwitchNode } from "../../types/config.js";
5
+ import type { ExecutionContext } from "../context.js";
6
+ export declare function executeSwitchNode(node: SwitchNode, context: ExecutionContext): Promise<{
7
+ output: unknown;
8
+ nextNode: string;
9
+ }>;
10
+ //# sourceMappingURL=switch-executor.d.ts.map
@@ -0,0 +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,GACxB,OAAO,CAAC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAgChD"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Switch node executor
3
+ */
4
+ import { evaluateJsonLogic } from "../../expressions/json-logic.js";
5
+ import { logger } from "../../logger.js";
6
+ export async function executeSwitchNode(node, context) {
7
+ logger.debug(`Executing switch node: ${node.id}`);
8
+ const exprContext = context.getData();
9
+ // Evaluate conditions in order
10
+ for (const condition of node.conditions) {
11
+ // If no rule is specified, this is a default/fallback case
12
+ if (condition.rule === undefined || condition.rule === null) {
13
+ logger.debug(`Switch node ${node.id}: Using default/fallback target: ${condition.target}`);
14
+ return {
15
+ output: exprContext,
16
+ nextNode: condition.target,
17
+ };
18
+ }
19
+ // Evaluate the JSON Logic rule
20
+ const ruleResult = evaluateJsonLogic(condition.rule, exprContext);
21
+ if (ruleResult) {
22
+ logger.debug(`Switch node ${node.id}: Condition matched, routing to: ${condition.target}`);
23
+ return {
24
+ output: exprContext,
25
+ nextNode: condition.target,
26
+ };
27
+ }
28
+ }
29
+ // No conditions matched and no default case
30
+ throw new Error(`Switch node ${node.id}: No conditions matched and no default case provided`);
31
+ }
32
+ //# sourceMappingURL=switch-executor.js.map
@@ -0,0 +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;IAEzB,MAAM,CAAC,KAAK,CAAC,0BAA0B,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IAElD,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAEtC,+BAA+B;IAC/B,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACxC,2DAA2D;QAC3D,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS,IAAI,SAAS,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;YAC5D,MAAM,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,EAAE,oCAAoC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;YAC3F,OAAO;gBACL,MAAM,EAAE,WAAW;gBACnB,QAAQ,EAAE,SAAS,CAAC,MAAM;aAC3B,CAAC;QACJ,CAAC;QAED,+BAA+B;QAC/B,MAAM,UAAU,GAAG,iBAAiB,CAAC,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAElE,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,EAAE,oCAAoC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;YAC3F,OAAO;gBACL,MAAM,EAAE,WAAW;gBACnB,QAAQ,EAAE,SAAS,CAAC,MAAM;aAC3B,CAAC;QACJ,CAAC;IACH,CAAC;IAED,4CAA4C;IAC5C,MAAM,IAAI,KAAK,CACb,eAAe,IAAI,CAAC,EAAE,sDAAsD,CAC7E,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Transform node executor
3
+ */
4
+ import type { TransformNode } from "../../types/config.js";
5
+ import type { ExecutionContext } from "../context.js";
6
+ export declare function executeTransformNode(node: TransformNode, context: ExecutionContext): Promise<{
7
+ output: unknown;
8
+ nextNode: string;
9
+ }>;
10
+ //# sourceMappingURL=transform-executor.d.ts.map
@@ -0,0 +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,GACxB,OAAO,CAAC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBhD"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Transform node executor
3
+ */
4
+ import { evaluateJsonata } from "../../expressions/jsonata.js";
5
+ import { logger } from "../../logger.js";
6
+ export async function executeTransformNode(node, context) {
7
+ logger.debug(`Executing transform node: ${node.id}`);
8
+ logger.debug(`Transform expression: ${node.transform.expr}`);
9
+ const exprContext = context.getData();
10
+ logger.debug(`Transform context: ${JSON.stringify(exprContext, null, 2)}`);
11
+ const output = await evaluateJsonata(node.transform.expr, exprContext);
12
+ logger.debug(`Transform output: ${JSON.stringify(output, null, 2)}`);
13
+ context.setNodeOutput(node.id, output);
14
+ context.addHistory(node.id, exprContext, output);
15
+ return {
16
+ output,
17
+ nextNode: node.next,
18
+ };
19
+ }
20
+ //# sourceMappingURL=transform-executor.js.map
@@ -0,0 +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;IAEzB,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;IAEvE,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,MAAM,CAAC,CAAC;IAEjD,OAAO;QACL,MAAM;QACN,QAAQ,EAAE,IAAI,CAAC,IAAI;KACpB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Expression evaluation context builder
3
+ */
4
+ export interface ExecutionContext {
5
+ input: Record<string, unknown>;
6
+ [key: string]: unknown;
7
+ }
8
+ export declare function buildContext(toolInput: Record<string, unknown>, nodeOutputs?: Record<string, unknown>): ExecutionContext;
9
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/expressions/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACxC,gBAAgB,CAKlB"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Expression evaluation context builder
3
+ */
4
+ export function buildContext(toolInput, nodeOutputs = {}) {
5
+ return {
6
+ input: toolInput,
7
+ ...nodeOutputs,
8
+ };
9
+ }
10
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/expressions/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,MAAM,UAAU,YAAY,CAC1B,SAAkC,EAClC,cAAuC,EAAE;IAEzC,OAAO;QACL,KAAK,EAAE,SAAS;QAChB,GAAG,WAAW;KACf,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * JSON Logic expression evaluation
3
+ */
4
+ /**
5
+ * Evaluate a JSON Logic rule with the given context data
6
+ * @param rule - JSON Logic rule (can be any valid JSON Logic structure)
7
+ * @param context - Context data object to evaluate the rule against
8
+ * @returns Boolean result of the rule evaluation
9
+ */
10
+ export declare function evaluateJsonLogic(rule: unknown, context: Record<string, unknown>): boolean;
11
+ //# sourceMappingURL=json-logic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-logic.d.ts","sourceRoot":"","sources":["../../src/expressions/json-logic.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,OAAO,CAiBT"}