@n8n/ai-workflow-builder 0.12.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-workflow-builder-agent.service.d.ts +28 -0
- package/dist/ai-workflow-builder-agent.service.js +160 -0
- package/dist/ai-workflow-builder-agent.service.js.map +1 -0
- package/dist/build.tsbuildinfo +1 -1
- package/dist/chains/conversation-compact.d.ts +8 -0
- package/dist/chains/conversation-compact.js +56 -0
- package/dist/chains/conversation-compact.js.map +1 -0
- package/dist/chains/parameter-updater.d.ts +16 -0
- package/dist/chains/parameter-updater.js +94 -0
- package/dist/chains/parameter-updater.js.map +1 -0
- package/dist/chains/planner.js +2 -2
- package/dist/chains/planner.js.map +1 -1
- package/dist/chains/prompts/base/common-patterns.d.ts +1 -0
- package/dist/chains/prompts/base/common-patterns.js +13 -0
- package/dist/chains/prompts/base/common-patterns.js.map +1 -0
- package/dist/chains/prompts/base/core-instructions.d.ts +1 -0
- package/dist/chains/prompts/base/core-instructions.js +28 -0
- package/dist/chains/prompts/base/core-instructions.js.map +1 -0
- package/dist/chains/prompts/base/expression-rules.d.ts +1 -0
- package/dist/chains/prompts/base/expression-rules.js +15 -0
- package/dist/chains/prompts/base/expression-rules.js.map +1 -0
- package/dist/chains/prompts/base/output-format.d.ts +1 -0
- package/dist/chains/prompts/base/output-format.js +7 -0
- package/dist/chains/prompts/base/output-format.js.map +1 -0
- package/dist/chains/prompts/examples/advanced/resource-locator-examples.d.ts +1 -0
- package/dist/chains/prompts/examples/advanced/resource-locator-examples.js +79 -0
- package/dist/chains/prompts/examples/advanced/resource-locator-examples.js.map +1 -0
- package/dist/chains/prompts/examples/advanced/tool-node-examples.d.ts +1 -0
- package/dist/chains/prompts/examples/advanced/tool-node-examples.js +71 -0
- package/dist/chains/prompts/examples/advanced/tool-node-examples.js.map +1 -0
- package/dist/chains/prompts/examples/basic/if-node-examples.d.ts +1 -0
- package/dist/chains/prompts/examples/basic/if-node-examples.js +138 -0
- package/dist/chains/prompts/examples/basic/if-node-examples.js.map +1 -0
- package/dist/chains/prompts/examples/basic/set-node-examples.d.ts +1 -0
- package/dist/chains/prompts/examples/basic/set-node-examples.js +148 -0
- package/dist/chains/prompts/examples/basic/set-node-examples.js.map +1 -0
- package/dist/chains/prompts/examples/basic/simple-updates.d.ts +1 -0
- package/dist/chains/prompts/examples/basic/simple-updates.js +51 -0
- package/dist/chains/prompts/examples/basic/simple-updates.js.map +1 -0
- package/dist/chains/prompts/node-types/http-request.d.ts +1 -0
- package/dist/chains/prompts/node-types/http-request.js +113 -0
- package/dist/chains/prompts/node-types/http-request.js.map +1 -0
- package/dist/chains/prompts/node-types/if-node.d.ts +1 -0
- package/dist/chains/prompts/node-types/if-node.js +158 -0
- package/dist/chains/prompts/node-types/if-node.js.map +1 -0
- package/dist/chains/prompts/node-types/set-node.d.ts +1 -0
- package/dist/chains/prompts/node-types/set-node.js +91 -0
- package/dist/chains/prompts/node-types/set-node.js.map +1 -0
- package/dist/chains/prompts/node-types/tool-nodes.d.ts +1 -0
- package/dist/chains/prompts/node-types/tool-nodes.js +73 -0
- package/dist/chains/prompts/node-types/tool-nodes.js.map +1 -0
- package/dist/chains/prompts/parameter-types/resource-locator.d.ts +1 -0
- package/dist/chains/prompts/parameter-types/resource-locator.js +95 -0
- package/dist/chains/prompts/parameter-types/resource-locator.js.map +1 -0
- package/dist/chains/prompts/parameter-types/text-fields.d.ts +1 -0
- package/dist/chains/prompts/parameter-types/text-fields.js +22 -0
- package/dist/chains/prompts/parameter-types/text-fields.js.map +1 -0
- package/dist/chains/prompts/prompt-builder.d.ts +14 -0
- package/dist/chains/prompts/prompt-builder.js +118 -0
- package/dist/chains/prompts/prompt-builder.js.map +1 -0
- package/dist/chains/prompts/prompt-config.d.ts +5 -0
- package/dist/chains/prompts/prompt-config.js +52 -0
- package/dist/chains/prompts/prompt-config.js.map +1 -0
- package/dist/errors/index.d.ts +45 -0
- package/dist/errors/index.js +122 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/llm-config.d.ts +6 -5
- package/dist/llm-config.js +19 -4
- package/dist/llm-config.js.map +1 -1
- package/dist/tools/add-node.tool.d.ts +56 -0
- package/dist/tools/add-node.tool.js +136 -0
- package/dist/tools/add-node.tool.js.map +1 -0
- package/dist/tools/connect-nodes.tool.d.ts +45 -0
- package/dist/tools/connect-nodes.tool.js +223 -0
- package/dist/tools/connect-nodes.tool.js.map +1 -0
- package/dist/tools/engines/node-search-engine.d.ts +25 -0
- package/dist/tools/engines/node-search-engine.js +121 -0
- package/dist/tools/engines/node-search-engine.js.map +1 -0
- package/dist/tools/helpers/index.d.ts +4 -0
- package/dist/tools/helpers/index.js +21 -0
- package/dist/tools/helpers/index.js.map +1 -0
- package/dist/tools/helpers/progress.d.ts +9 -0
- package/dist/tools/helpers/progress.js +114 -0
- package/dist/tools/helpers/progress.js.map +1 -0
- package/dist/tools/helpers/response.d.ts +7 -0
- package/dist/tools/helpers/response.js +31 -0
- package/dist/tools/helpers/response.js.map +1 -0
- package/dist/tools/helpers/state.d.ts +13 -0
- package/dist/tools/helpers/state.js +70 -0
- package/dist/tools/helpers/state.js.map +1 -0
- package/dist/tools/helpers/validation.d.ts +12 -0
- package/dist/tools/helpers/validation.js +69 -0
- package/dist/tools/helpers/validation.js.map +1 -0
- package/dist/tools/node-details.tool.d.ts +19 -0
- package/dist/tools/node-details.tool.js +133 -0
- package/dist/tools/node-details.tool.js.map +1 -0
- package/dist/tools/node-search.tool.d.ts +49 -0
- package/dist/tools/node-search.tool.js +146 -0
- package/dist/tools/node-search.tool.js.map +1 -0
- package/dist/tools/prompts/main-agent.prompt.d.ts +2 -0
- package/dist/tools/prompts/main-agent.prompt.js +390 -0
- package/dist/tools/prompts/main-agent.prompt.js.map +1 -0
- package/dist/tools/remove-node.tool.d.ts +13 -0
- package/dist/tools/remove-node.tool.js +97 -0
- package/dist/tools/remove-node.tool.js.map +1 -0
- package/dist/tools/update-node-parameters.tool.d.ts +19 -0
- package/dist/tools/update-node-parameters.tool.js +131 -0
- package/dist/tools/update-node-parameters.tool.js.map +1 -0
- package/dist/tools/utils/connection-parameters.utils.d.ts +8 -0
- package/dist/tools/utils/connection-parameters.utils.js +47 -0
- package/dist/tools/utils/connection-parameters.utils.js.map +1 -0
- package/dist/tools/utils/connection.utils.d.ts +15 -0
- package/dist/tools/utils/connection.utils.js +321 -0
- package/dist/tools/utils/connection.utils.js.map +1 -0
- package/dist/tools/utils/node-creation.utils.d.ts +8 -0
- package/dist/tools/utils/node-creation.utils.js +52 -0
- package/dist/tools/utils/node-creation.utils.js.map +1 -0
- package/dist/tools/utils/node-positioning.utils.d.ts +17 -0
- package/dist/tools/utils/node-positioning.utils.js +87 -0
- package/dist/tools/utils/node-positioning.utils.js.map +1 -0
- package/dist/tools/utils/parameter-update.utils.d.ts +6 -0
- package/dist/tools/utils/parameter-update.utils.js +75 -0
- package/dist/tools/utils/parameter-update.utils.js.map +1 -0
- package/dist/types/config.d.ts +53 -0
- package/dist/{interfaces.js → types/config.js} +1 -1
- package/dist/types/config.js.map +1 -0
- package/dist/types/connections.d.ts +30 -0
- package/dist/types/connections.js +3 -0
- package/dist/types/connections.js.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.js +25 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/messages.d.ts +38 -0
- package/dist/types/messages.js +3 -0
- package/dist/types/messages.js.map +1 -0
- package/dist/types/nodes.d.ts +26 -0
- package/dist/{types.js → types/nodes.js} +1 -1
- package/dist/types/nodes.js.map +1 -0
- package/dist/types/streaming.d.ts +33 -0
- package/dist/types/streaming.js +3 -0
- package/dist/types/streaming.js.map +1 -0
- package/dist/types/tools.d.ts +76 -0
- package/dist/types/tools.js +3 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/types/utils.d.ts +2 -0
- package/dist/types/utils.js +3 -0
- package/dist/types/utils.js.map +1 -0
- package/dist/types/workflow.d.ts +21 -0
- package/dist/types/workflow.js +3 -0
- package/dist/types/workflow.js.map +1 -0
- package/dist/utils/node-helpers.d.ts +2 -0
- package/dist/utils/node-helpers.js +54 -0
- package/dist/utils/node-helpers.js.map +1 -0
- package/dist/utils/operations-processor.d.ts +10 -0
- package/dist/utils/operations-processor.js +114 -0
- package/dist/utils/operations-processor.js.map +1 -0
- package/dist/utils/stream-processor.d.ts +6 -0
- package/dist/utils/stream-processor.js +153 -0
- package/dist/utils/stream-processor.js.map +1 -0
- package/dist/utils/tool-executor.d.ts +3 -0
- package/dist/utils/tool-executor.js +86 -0
- package/dist/utils/tool-executor.js.map +1 -0
- package/dist/workflow-builder-agent.d.ts +41 -0
- package/dist/workflow-builder-agent.js +205 -0
- package/dist/workflow-builder-agent.js.map +1 -0
- package/dist/workflow-state.d.ts +12 -7
- package/dist/workflow-state.js +26 -7
- package/dist/workflow-state.js.map +1 -1
- package/package.json +26 -7
- package/dist/ai-workflow-builder.service.d.ts +0 -25
- package/dist/ai-workflow-builder.service.js +0 -308
- package/dist/ai-workflow-builder.service.js.map +0 -1
- package/dist/chains/connection-composer.d.ts +0 -10
- package/dist/chains/connection-composer.js +0 -135
- package/dist/chains/connection-composer.js.map +0 -1
- package/dist/chains/node-selector.d.ts +0 -8
- package/dist/chains/node-selector.js +0 -90
- package/dist/chains/node-selector.js.map +0 -1
- package/dist/chains/nodes-composer.d.ts +0 -8
- package/dist/chains/nodes-composer.js +0 -451
- package/dist/chains/nodes-composer.js.map +0 -1
- package/dist/chains/validator.d.ts +0 -2
- package/dist/chains/validator.js +0 -67
- package/dist/chains/validator.js.map +0 -1
- package/dist/interfaces.d.ts +0 -4
- package/dist/interfaces.js.map +0 -1
- package/dist/types.d.ts +0 -87
- package/dist/types.js.map +0 -1
package/dist/llm-config.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
36
|
+
exports.anthropicClaudeSonnet4 = exports.gpt41 = exports.gpt41mini = exports.o4mini = void 0;
|
|
37
37
|
const o4mini = async (config) => {
|
|
38
38
|
const { ChatOpenAI } = await Promise.resolve().then(() => __importStar(require('@langchain/openai')));
|
|
39
39
|
return new ChatOpenAI({
|
|
@@ -52,6 +52,7 @@ const gpt41mini = async (config) => {
|
|
|
52
52
|
model: 'gpt-4.1-mini-2025-04-14',
|
|
53
53
|
apiKey: config.apiKey,
|
|
54
54
|
temperature: 0,
|
|
55
|
+
maxTokens: -1,
|
|
55
56
|
configuration: {
|
|
56
57
|
baseURL: config.baseUrl,
|
|
57
58
|
defaultHeaders: config.headers,
|
|
@@ -59,10 +60,24 @@ const gpt41mini = async (config) => {
|
|
|
59
60
|
});
|
|
60
61
|
};
|
|
61
62
|
exports.gpt41mini = gpt41mini;
|
|
62
|
-
const
|
|
63
|
+
const gpt41 = async (config) => {
|
|
64
|
+
const { ChatOpenAI } = await Promise.resolve().then(() => __importStar(require('@langchain/openai')));
|
|
65
|
+
return new ChatOpenAI({
|
|
66
|
+
model: 'gpt-4.1-2025-04-14',
|
|
67
|
+
apiKey: config.apiKey,
|
|
68
|
+
temperature: 0.3,
|
|
69
|
+
maxTokens: -1,
|
|
70
|
+
configuration: {
|
|
71
|
+
baseURL: config.baseUrl,
|
|
72
|
+
defaultHeaders: config.headers,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
exports.gpt41 = gpt41;
|
|
77
|
+
const anthropicClaudeSonnet4 = async (config) => {
|
|
63
78
|
const { ChatAnthropic } = await Promise.resolve().then(() => __importStar(require('@langchain/anthropic')));
|
|
64
79
|
return new ChatAnthropic({
|
|
65
|
-
model: 'claude-
|
|
80
|
+
model: 'claude-sonnet-4-20250514',
|
|
66
81
|
apiKey: config.apiKey,
|
|
67
82
|
temperature: 0,
|
|
68
83
|
maxTokens: 16000,
|
|
@@ -72,5 +87,5 @@ const anthropicClaude37Sonnet = async (config) => {
|
|
|
72
87
|
},
|
|
73
88
|
});
|
|
74
89
|
};
|
|
75
|
-
exports.
|
|
90
|
+
exports.anthropicClaudeSonnet4 = anthropicClaudeSonnet4;
|
|
76
91
|
//# sourceMappingURL=llm-config.js.map
|
package/dist/llm-config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-config.js","sourceRoot":"","sources":["../src/llm-config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"llm-config.js","sourceRoot":"","sources":["../src/llm-config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOO,MAAM,MAAM,GAAG,KAAK,EAAE,MAAyB,EAAE,EAAE;IACzD,MAAM,EAAE,UAAU,EAAE,GAAG,wDAAa,mBAAmB,GAAC,CAAC;IACzD,OAAO,IAAI,UAAU,CAAC;QACrB,KAAK,EAAE,oBAAoB;QAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,aAAa,EAAE;YACd,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,cAAc,EAAE,MAAM,CAAC,OAAO;SAC9B;KACD,CAAC,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,MAAM,UAUjB;AAEK,MAAM,SAAS,GAAG,KAAK,EAAE,MAAyB,EAAE,EAAE;IAC5D,MAAM,EAAE,UAAU,EAAE,GAAG,wDAAa,mBAAmB,GAAC,CAAC;IACzD,OAAO,IAAI,UAAU,CAAC;QACrB,KAAK,EAAE,yBAAyB;QAChC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,WAAW,EAAE,CAAC;QACd,SAAS,EAAE,CAAC,CAAC;QACb,aAAa,EAAE;YACd,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,cAAc,EAAE,MAAM,CAAC,OAAO;SAC9B;KACD,CAAC,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,SAAS,aAYpB;AAEK,MAAM,KAAK,GAAG,KAAK,EAAE,MAAyB,EAAE,EAAE;IACxD,MAAM,EAAE,UAAU,EAAE,GAAG,wDAAa,mBAAmB,GAAC,CAAC;IACzD,OAAO,IAAI,UAAU,CAAC;QACrB,KAAK,EAAE,oBAAoB;QAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,WAAW,EAAE,GAAG;QAChB,SAAS,EAAE,CAAC,CAAC;QACb,aAAa,EAAE;YACd,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,cAAc,EAAE,MAAM,CAAC,OAAO;SAC9B;KACD,CAAC,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,KAAK,SAYhB;AAEK,MAAM,sBAAsB,GAAG,KAAK,EAAE,MAAyB,EAAE,EAAE;IACzE,MAAM,EAAE,aAAa,EAAE,GAAG,wDAAa,sBAAsB,GAAC,CAAC;IAC/D,OAAO,IAAI,aAAa,CAAC;QACxB,KAAK,EAAE,0BAA0B;QACjC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,WAAW,EAAE,CAAC;QACd,SAAS,EAAE,KAAK;QAChB,eAAe,EAAE,MAAM,CAAC,OAAO;QAC/B,aAAa,EAAE;YACd,cAAc,EAAE,MAAM,CAAC,OAAO;SAC9B;KACD,CAAC,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,sBAAsB,0BAYjC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const nodeCreationSchema: z.ZodObject<{
|
|
4
|
+
nodeType: z.ZodString;
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
connectionParametersReasoning: z.ZodString;
|
|
7
|
+
connectionParameters: z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
nodeType: string;
|
|
10
|
+
name: string;
|
|
11
|
+
connectionParametersReasoning: string;
|
|
12
|
+
connectionParameters: {} & {
|
|
13
|
+
[k: string]: unknown;
|
|
14
|
+
};
|
|
15
|
+
}, {
|
|
16
|
+
nodeType: string;
|
|
17
|
+
name: string;
|
|
18
|
+
connectionParametersReasoning: string;
|
|
19
|
+
connectionParameters: {} & {
|
|
20
|
+
[k: string]: unknown;
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
23
|
+
export declare function createAddNodeTool(nodeTypes: INodeTypeDescription[]): import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
24
|
+
nodeType: z.ZodString;
|
|
25
|
+
name: z.ZodString;
|
|
26
|
+
connectionParametersReasoning: z.ZodString;
|
|
27
|
+
connectionParameters: z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>;
|
|
28
|
+
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
nodeType: string;
|
|
30
|
+
name: string;
|
|
31
|
+
connectionParametersReasoning: string;
|
|
32
|
+
connectionParameters: {} & {
|
|
33
|
+
[k: string]: unknown;
|
|
34
|
+
};
|
|
35
|
+
}, {
|
|
36
|
+
nodeType: string;
|
|
37
|
+
name: string;
|
|
38
|
+
connectionParametersReasoning: string;
|
|
39
|
+
connectionParameters: {} & {
|
|
40
|
+
[k: string]: unknown;
|
|
41
|
+
};
|
|
42
|
+
}>, {
|
|
43
|
+
nodeType: string;
|
|
44
|
+
name: string;
|
|
45
|
+
connectionParametersReasoning: string;
|
|
46
|
+
connectionParameters: {} & {
|
|
47
|
+
[k: string]: unknown;
|
|
48
|
+
};
|
|
49
|
+
}, {
|
|
50
|
+
nodeType: string;
|
|
51
|
+
name: string;
|
|
52
|
+
connectionParametersReasoning: string;
|
|
53
|
+
connectionParameters: {} & {
|
|
54
|
+
[k: string]: unknown;
|
|
55
|
+
};
|
|
56
|
+
}, import("@langchain/langgraph").Command<unknown>>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nodeCreationSchema = void 0;
|
|
4
|
+
exports.createAddNodeTool = createAddNodeTool;
|
|
5
|
+
const tools_1 = require("@langchain/core/tools");
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const errors_1 = require("../errors");
|
|
8
|
+
const node_creation_utils_1 = require("./utils/node-creation.utils");
|
|
9
|
+
const node_positioning_utils_1 = require("./utils/node-positioning.utils");
|
|
10
|
+
const node_helpers_1 = require("../utils/node-helpers");
|
|
11
|
+
const progress_1 = require("./helpers/progress");
|
|
12
|
+
const response_1 = require("./helpers/response");
|
|
13
|
+
const state_1 = require("./helpers/state");
|
|
14
|
+
const validation_1 = require("./helpers/validation");
|
|
15
|
+
exports.nodeCreationSchema = zod_1.z.object({
|
|
16
|
+
nodeType: zod_1.z.string().describe('The type of node to add (e.g., n8n-nodes-base.httpRequest)'),
|
|
17
|
+
name: zod_1.z
|
|
18
|
+
.string()
|
|
19
|
+
.describe('A descriptive name for the node that clearly indicates its purpose in the workflow'),
|
|
20
|
+
connectionParametersReasoning: zod_1.z
|
|
21
|
+
.string()
|
|
22
|
+
.describe('REQUIRED: Explain your reasoning about connection parameters. Consider: Does this node have dynamic inputs/outputs? Does it need mode/operation parameters? For example: "Vector Store has dynamic inputs based on mode, so I need to set mode:insert for document input" or "HTTP Request has static inputs, so no special parameters needed"'),
|
|
23
|
+
connectionParameters: zod_1.z
|
|
24
|
+
.object({})
|
|
25
|
+
.passthrough()
|
|
26
|
+
.describe('Parameters that affect node connections (e.g., mode: "insert" for Vector Store). Pass an empty object {} if no connection parameters are needed. Only connection-affecting parameters like mode, operation, resource, action, etc. are allowed.'),
|
|
27
|
+
});
|
|
28
|
+
function createNode(nodeType, customName, existingNodes, nodeTypes, connectionParameters) {
|
|
29
|
+
const baseName = customName ?? nodeType.defaults?.name ?? nodeType.displayName;
|
|
30
|
+
const uniqueName = (0, node_creation_utils_1.generateUniqueName)(baseName, existingNodes);
|
|
31
|
+
const position = (0, node_positioning_utils_1.calculateNodePosition)(existingNodes, (0, node_helpers_1.isSubNode)(nodeType), nodeTypes);
|
|
32
|
+
return (0, node_creation_utils_1.createNodeInstance)(nodeType, uniqueName, position, connectionParameters);
|
|
33
|
+
}
|
|
34
|
+
function buildResponseMessage(addedNode, nodeTypes) {
|
|
35
|
+
const nodeType = nodeTypes.find((nt) => nt.name === addedNode.type);
|
|
36
|
+
const nodeTypeInfo = nodeType && (0, node_helpers_1.isSubNode)(nodeType) ? ' (sub-node)' : '';
|
|
37
|
+
return `Successfully added "${addedNode.name}" (${addedNode.displayName ?? addedNode.type})${nodeTypeInfo} with ID ${addedNode.id}`;
|
|
38
|
+
}
|
|
39
|
+
function createAddNodeTool(nodeTypes) {
|
|
40
|
+
return (0, tools_1.tool)(async (input, config) => {
|
|
41
|
+
const reporter = (0, progress_1.createProgressReporter)(config, 'add_nodes');
|
|
42
|
+
try {
|
|
43
|
+
const validatedInput = exports.nodeCreationSchema.parse(input);
|
|
44
|
+
const { nodeType, name, connectionParametersReasoning, connectionParameters } = validatedInput;
|
|
45
|
+
reporter.start(validatedInput);
|
|
46
|
+
const state = (0, state_1.getWorkflowState)();
|
|
47
|
+
const workflow = (0, state_1.getCurrentWorkflow)(state);
|
|
48
|
+
reporter.progress(`Adding ${name} (${connectionParametersReasoning})`);
|
|
49
|
+
const nodeTypeDesc = (0, validation_1.findNodeType)(nodeType, nodeTypes);
|
|
50
|
+
if (!nodeTypeDesc) {
|
|
51
|
+
const nodeError = new errors_1.NodeTypeNotFoundError(nodeType);
|
|
52
|
+
const error = {
|
|
53
|
+
message: nodeError.message,
|
|
54
|
+
code: 'NODE_TYPE_NOT_FOUND',
|
|
55
|
+
details: { nodeType },
|
|
56
|
+
};
|
|
57
|
+
reporter.error(error);
|
|
58
|
+
return (0, response_1.createErrorResponse)(config, error);
|
|
59
|
+
}
|
|
60
|
+
const newNode = createNode(nodeTypeDesc, name, workflow.nodes, nodeTypes, connectionParameters);
|
|
61
|
+
const addedNodeInfo = {
|
|
62
|
+
id: newNode.id,
|
|
63
|
+
name: newNode.name,
|
|
64
|
+
type: newNode.type,
|
|
65
|
+
displayName: nodeTypeDesc.displayName,
|
|
66
|
+
position: newNode.position,
|
|
67
|
+
parameters: newNode.parameters,
|
|
68
|
+
};
|
|
69
|
+
const message = buildResponseMessage(addedNodeInfo, nodeTypes);
|
|
70
|
+
const output = {
|
|
71
|
+
addedNode: addedNodeInfo,
|
|
72
|
+
message,
|
|
73
|
+
};
|
|
74
|
+
reporter.complete(output);
|
|
75
|
+
const stateUpdates = (0, state_1.addNodeToWorkflow)(newNode);
|
|
76
|
+
return (0, response_1.createSuccessResponse)(config, message, stateUpdates);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
let toolError;
|
|
80
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
81
|
+
const validationError = new errors_1.ValidationError('Invalid input parameters', {
|
|
82
|
+
field: error.errors[0]?.path.join('.'),
|
|
83
|
+
value: error.errors[0]?.message,
|
|
84
|
+
});
|
|
85
|
+
toolError = {
|
|
86
|
+
message: validationError.message,
|
|
87
|
+
code: 'VALIDATION_ERROR',
|
|
88
|
+
details: error.errors,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
toolError = {
|
|
93
|
+
message: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
94
|
+
code: 'EXECUTION_ERROR',
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
reporter.error(toolError);
|
|
98
|
+
return (0, response_1.createErrorResponse)(config, toolError);
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
name: 'add_nodes',
|
|
102
|
+
description: `Add a node to the workflow canvas. Each node represents a specific action or operation (e.g., HTTP request, data transformation, database query). Always provide descriptive names that explain what the node does (e.g., "Get Customer Data", "Filter Active Users", "Send Email Notification"). The tool handles automatic positioning. Use this tool after searching for available node types to ensure they exist.
|
|
103
|
+
|
|
104
|
+
To add multiple nodes, call this tool multiple times in parallel.
|
|
105
|
+
|
|
106
|
+
CRITICAL: You MUST provide:
|
|
107
|
+
1. connectionParametersReasoning - Explain why you're choosing specific connection parameters or using {}
|
|
108
|
+
2. connectionParameters - The actual parameters (use {} for nodes without special needs)
|
|
109
|
+
|
|
110
|
+
IMPORTANT: DO NOT rely on default values! Always explicitly set connection-affecting parameters when they exist.
|
|
111
|
+
|
|
112
|
+
REASONING EXAMPLES:
|
|
113
|
+
- "Vector Store has dynamic inputs that change based on mode parameter, setting mode:insert to accept document inputs"
|
|
114
|
+
- "HTTP Request has static inputs/outputs, no connection parameters needed"
|
|
115
|
+
- "Document Loader needs textSplittingMode:custom to accept text splitter connections"
|
|
116
|
+
- "AI Agent has dynamic inputs, setting hasOutputParser:true to enable output parser connections"
|
|
117
|
+
- "Set node has standard main connections only, using empty parameters"
|
|
118
|
+
|
|
119
|
+
CONNECTION PARAMETERS (NEVER rely on defaults - always set explicitly):
|
|
120
|
+
- AI Agent (@n8n/n8n-nodes-langchain.agent):
|
|
121
|
+
- For output parser support: { hasOutputParser: true }
|
|
122
|
+
- Without output parser: { hasOutputParser: false }
|
|
123
|
+
- Vector Store (@n8n/n8n-nodes-langchain.vectorStoreInMemory):
|
|
124
|
+
- For document input: { mode: "insert" }
|
|
125
|
+
- For querying: { mode: "retrieve" }
|
|
126
|
+
- For AI tool use: { mode: "retrieve-as-tool" }
|
|
127
|
+
- Document Loader (@n8n/n8n-nodes-langchain.documentDefaultDataLoader):
|
|
128
|
+
- For text splitter input: { textSplittingMode: "custom" }
|
|
129
|
+
- For built-in splitting: { textSplittingMode: "simple" }
|
|
130
|
+
- Regular nodes (HTTP Request, Set, Code, etc.): {}
|
|
131
|
+
|
|
132
|
+
Think through the connectionParametersReasoning FIRST, then set connectionParameters based on your reasoning. If a parameter affects connections, SET IT EXPLICITLY.`,
|
|
133
|
+
schema: exports.nodeCreationSchema,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=add-node.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-node.tool.js","sourceRoot":"","sources":["../../src/tools/add-node.tool.ts"],"names":[],"mappings":";;;AAqEA,8CA+HC;AApMD,iDAA6C;AAE7C,6BAAwB;AAExB,sCAAmE;AACnE,qEAAqF;AACrF,2EAAuE;AACvE,wDAAkD;AAClD,iDAA4D;AAC5D,iDAAgF;AAChF,2CAA0F;AAC1F,qDAAoD;AAOvC,QAAA,kBAAkB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC1C,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4DAA4D,CAAC;IAC3F,IAAI,EAAE,OAAC;SACL,MAAM,EAAE;SACR,QAAQ,CAAC,oFAAoF,CAAC;IAChG,6BAA6B,EAAE,OAAC;SAC9B,MAAM,EAAE;SACR,QAAQ,CACR,gVAAgV,CAChV;IACF,oBAAoB,EAAE,OAAC;SACrB,MAAM,CAAC,EAAE,CAAC;SACV,WAAW,EAAE;SACb,QAAQ,CACR,iPAAiP,CACjP;CACF,CAAC,CAAC;AAKH,SAAS,UAAU,CAClB,QAA8B,EAC9B,UAAkB,EAClB,aAAsB,EACtB,SAAiC,EACjC,oBAAsC;IAGtC,MAAM,QAAQ,GAAG,UAAU,IAAI,QAAQ,CAAC,QAAQ,EAAE,IAAI,IAAI,QAAQ,CAAC,WAAW,CAAC;IAC/E,MAAM,UAAU,GAAG,IAAA,wCAAkB,EAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IAG/D,MAAM,QAAQ,GAAG,IAAA,8CAAqB,EAAC,aAAa,EAAE,IAAA,wBAAS,EAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC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AAe,GAAG,IAAI,wBAAe,CAAC,0BAA0B,EAAE;oBACvE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;oBACtC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO;iBAC/B,CAAC,CAAC;gBACH,SAAS,GAAG;oBACX,OAAO,EAAE,eAAe,CAAC,OAAO;oBAChC,IAAI,EAAE,kBAAkB;oBACxB,OAAO,EAAE,KAAK,CAAC,MAAM;iBACrB,CAAC;YACH,CAAC;iBAAM,CAAC;gBACP,SAAS,GAAG;oBACX,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB;oBAC1E,IAAI,EAAE,iBAAiB;iBACvB,CAAC;YACH,CAAC;YAED,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAC1B,OAAO,IAAA,8BAAmB,EAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAC/C,CAAC;IACF,CAAC,EACD;QACC,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qKA8BqJ;QAClK,MAAM,EAAE,0BAAkB;KAC1B,CACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Logger } from '@n8n/backend-common';
|
|
2
|
+
import { type INodeTypeDescription } from 'n8n-workflow';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export declare const nodeConnectionSchema: z.ZodObject<{
|
|
5
|
+
sourceNodeId: z.ZodString;
|
|
6
|
+
targetNodeId: z.ZodString;
|
|
7
|
+
sourceOutputIndex: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
targetInputIndex: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
sourceNodeId: string;
|
|
11
|
+
targetNodeId: string;
|
|
12
|
+
sourceOutputIndex?: number | undefined;
|
|
13
|
+
targetInputIndex?: number | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
sourceNodeId: string;
|
|
16
|
+
targetNodeId: string;
|
|
17
|
+
sourceOutputIndex?: number | undefined;
|
|
18
|
+
targetInputIndex?: number | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function createConnectNodesTool(nodeTypes: INodeTypeDescription[], logger?: Logger): import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
21
|
+
sourceNodeId: z.ZodString;
|
|
22
|
+
targetNodeId: z.ZodString;
|
|
23
|
+
sourceOutputIndex: z.ZodOptional<z.ZodNumber>;
|
|
24
|
+
targetInputIndex: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
sourceNodeId: string;
|
|
27
|
+
targetNodeId: string;
|
|
28
|
+
sourceOutputIndex?: number | undefined;
|
|
29
|
+
targetInputIndex?: number | undefined;
|
|
30
|
+
}, {
|
|
31
|
+
sourceNodeId: string;
|
|
32
|
+
targetNodeId: string;
|
|
33
|
+
sourceOutputIndex?: number | undefined;
|
|
34
|
+
targetInputIndex?: number | undefined;
|
|
35
|
+
}>, {
|
|
36
|
+
sourceNodeId: string;
|
|
37
|
+
targetNodeId: string;
|
|
38
|
+
sourceOutputIndex?: number | undefined;
|
|
39
|
+
targetInputIndex?: number | undefined;
|
|
40
|
+
}, {
|
|
41
|
+
sourceNodeId: string;
|
|
42
|
+
targetNodeId: string;
|
|
43
|
+
sourceOutputIndex?: number | undefined;
|
|
44
|
+
targetInputIndex?: number | undefined;
|
|
45
|
+
}, import("@langchain/langgraph").Command<unknown>>;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nodeConnectionSchema = void 0;
|
|
4
|
+
exports.createConnectNodesTool = createConnectNodesTool;
|
|
5
|
+
const tools_1 = require("@langchain/core/tools");
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const errors_1 = require("../errors");
|
|
8
|
+
const progress_1 = require("./helpers/progress");
|
|
9
|
+
const response_1 = require("./helpers/response");
|
|
10
|
+
const state_1 = require("./helpers/state");
|
|
11
|
+
const validation_1 = require("./helpers/validation");
|
|
12
|
+
const connection_utils_1 = require("./utils/connection.utils");
|
|
13
|
+
exports.nodeConnectionSchema = zod_1.z.object({
|
|
14
|
+
sourceNodeId: zod_1.z
|
|
15
|
+
.string()
|
|
16
|
+
.describe('The UUID of the source node. For ai_* connections (ai_languageModel, ai_tool, etc.), this MUST be the sub-node (e.g., OpenAI Chat Model). For main connections, this is the node producing the output'),
|
|
17
|
+
targetNodeId: zod_1.z
|
|
18
|
+
.string()
|
|
19
|
+
.describe('The UUID of the target node. For ai_* connections, this MUST be the main node that accepts the sub-node (e.g., AI Agent, Basic LLM Chain). For main connections, this is the node receiving the input'),
|
|
20
|
+
sourceOutputIndex: zod_1.z
|
|
21
|
+
.number()
|
|
22
|
+
.optional()
|
|
23
|
+
.describe('The index of the output to connect from (default: 0)'),
|
|
24
|
+
targetInputIndex: zod_1.z
|
|
25
|
+
.number()
|
|
26
|
+
.optional()
|
|
27
|
+
.describe('The index of the input to connect to (default: 0)'),
|
|
28
|
+
});
|
|
29
|
+
function createConnectNodesTool(nodeTypes, logger) {
|
|
30
|
+
return (0, tools_1.tool)((input, config) => {
|
|
31
|
+
const reporter = (0, progress_1.createProgressReporter)(config, 'connect_nodes');
|
|
32
|
+
try {
|
|
33
|
+
const validatedInput = exports.nodeConnectionSchema.parse(input);
|
|
34
|
+
reporter.start(validatedInput);
|
|
35
|
+
const state = (0, state_1.getWorkflowState)();
|
|
36
|
+
const workflow = (0, state_1.getCurrentWorkflow)(state);
|
|
37
|
+
(0, progress_1.reportProgress)(reporter, 'Finding nodes to connect...');
|
|
38
|
+
let matchedSourceNode = (0, validation_1.validateNodeExists)(validatedInput.sourceNodeId, workflow.nodes);
|
|
39
|
+
let matchedTargetNode = (0, validation_1.validateNodeExists)(validatedInput.targetNodeId, workflow.nodes);
|
|
40
|
+
if (!matchedSourceNode || !matchedTargetNode) {
|
|
41
|
+
const missingNodeId = !matchedSourceNode
|
|
42
|
+
? validatedInput.sourceNodeId
|
|
43
|
+
: validatedInput.targetNodeId;
|
|
44
|
+
const nodeError = new errors_1.NodeNotFoundError(missingNodeId);
|
|
45
|
+
const error = {
|
|
46
|
+
message: nodeError.message,
|
|
47
|
+
code: 'NODES_NOT_FOUND',
|
|
48
|
+
details: {
|
|
49
|
+
sourceNodeId: validatedInput.sourceNodeId,
|
|
50
|
+
targetNodeId: validatedInput.targetNodeId,
|
|
51
|
+
foundSource: !!matchedSourceNode,
|
|
52
|
+
foundTarget: !!matchedTargetNode,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
reporter.error(error);
|
|
56
|
+
return (0, response_1.createErrorResponse)(config, error);
|
|
57
|
+
}
|
|
58
|
+
const sourceNodeType = nodeTypes.find((nt) => nt.name === matchedSourceNode.type);
|
|
59
|
+
const targetNodeType = nodeTypes.find((nt) => nt.name === matchedTargetNode.type);
|
|
60
|
+
if (!sourceNodeType || !targetNodeType) {
|
|
61
|
+
const missingType = !sourceNodeType ? matchedSourceNode.type : matchedTargetNode.type;
|
|
62
|
+
const typeError = new errors_1.NodeTypeNotFoundError(missingType);
|
|
63
|
+
const error = {
|
|
64
|
+
message: typeError.message,
|
|
65
|
+
code: 'NODE_TYPE_NOT_FOUND',
|
|
66
|
+
details: {
|
|
67
|
+
sourceType: matchedSourceNode.type,
|
|
68
|
+
targetType: matchedTargetNode.type,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
reporter.error(error);
|
|
72
|
+
return (0, response_1.createErrorResponse)(config, error);
|
|
73
|
+
}
|
|
74
|
+
(0, progress_1.reportProgress)(reporter, 'Inferring connection type...');
|
|
75
|
+
logger?.debug('\n=== Connect Nodes Tool ===');
|
|
76
|
+
logger?.debug(`Attempting to connect: ${matchedSourceNode.name} -> ${matchedTargetNode.name}`);
|
|
77
|
+
const inferResult = (0, connection_utils_1.inferConnectionType)(matchedSourceNode, matchedTargetNode, sourceNodeType, targetNodeType);
|
|
78
|
+
if (inferResult.error) {
|
|
79
|
+
const connectionError = new errors_1.ConnectionError(inferResult.error, {
|
|
80
|
+
fromNodeId: matchedSourceNode.id,
|
|
81
|
+
toNodeId: matchedTargetNode.id,
|
|
82
|
+
});
|
|
83
|
+
const error = {
|
|
84
|
+
message: connectionError.message,
|
|
85
|
+
code: 'CONNECTION_TYPE_INFERENCE_ERROR',
|
|
86
|
+
details: {
|
|
87
|
+
sourceNode: matchedSourceNode.name,
|
|
88
|
+
targetNode: matchedTargetNode.name,
|
|
89
|
+
possibleTypes: inferResult.possibleTypes,
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
reporter.error(error);
|
|
93
|
+
return (0, response_1.createErrorResponse)(config, error);
|
|
94
|
+
}
|
|
95
|
+
if (!inferResult.connectionType) {
|
|
96
|
+
const error = {
|
|
97
|
+
message: 'Could not infer connection type',
|
|
98
|
+
code: 'CONNECTION_TYPE_INFERENCE_FAILED',
|
|
99
|
+
details: {
|
|
100
|
+
sourceNode: matchedSourceNode.name,
|
|
101
|
+
targetNode: matchedTargetNode.name,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
reporter.error(error);
|
|
105
|
+
return (0, response_1.createErrorResponse)(config, error);
|
|
106
|
+
}
|
|
107
|
+
const connectionType = inferResult.connectionType;
|
|
108
|
+
const inferredSwap = inferResult.requiresSwap ?? false;
|
|
109
|
+
if (inferredSwap) {
|
|
110
|
+
logger?.debug('Swapping nodes based on inference result');
|
|
111
|
+
const temp = matchedSourceNode;
|
|
112
|
+
matchedSourceNode = matchedTargetNode;
|
|
113
|
+
matchedTargetNode = temp;
|
|
114
|
+
}
|
|
115
|
+
(0, progress_1.reportProgress)(reporter, `Inferred connection type: ${connectionType}${inferredSwap ? ' (swapped nodes)' : ''}`);
|
|
116
|
+
logger?.debug(`Final connection: ${matchedSourceNode.name} -> ${matchedTargetNode.name} (${connectionType})\n`);
|
|
117
|
+
(0, progress_1.reportProgress)(reporter, `Connecting ${matchedSourceNode.name} to ${matchedTargetNode.name}...`);
|
|
118
|
+
const validation = (0, connection_utils_1.validateConnection)(matchedSourceNode, matchedTargetNode, connectionType, nodeTypes);
|
|
119
|
+
if (!validation.valid) {
|
|
120
|
+
const connectionError = new errors_1.ConnectionError(validation.error ?? 'Invalid connection', {
|
|
121
|
+
fromNodeId: matchedSourceNode.id,
|
|
122
|
+
toNodeId: matchedTargetNode.id,
|
|
123
|
+
});
|
|
124
|
+
const error = {
|
|
125
|
+
message: connectionError.message,
|
|
126
|
+
code: 'INVALID_CONNECTION',
|
|
127
|
+
details: {
|
|
128
|
+
sourceNode: matchedSourceNode.name,
|
|
129
|
+
targetNode: matchedTargetNode.name,
|
|
130
|
+
connectionType,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
reporter.error(error);
|
|
134
|
+
return (0, response_1.createErrorResponse)(config, error);
|
|
135
|
+
}
|
|
136
|
+
const actualSourceNode = validation.swappedSource ?? matchedSourceNode;
|
|
137
|
+
const actualTargetNode = validation.swappedTarget ?? matchedTargetNode;
|
|
138
|
+
const swapped = inferredSwap || !!validation.shouldSwap;
|
|
139
|
+
const sourceIndex = validatedInput.sourceOutputIndex ?? 0;
|
|
140
|
+
const targetIndex = validatedInput.targetInputIndex ?? 0;
|
|
141
|
+
const newConnection = {
|
|
142
|
+
[actualSourceNode.name]: {
|
|
143
|
+
[connectionType]: Array(sourceIndex + 1)
|
|
144
|
+
.fill(null)
|
|
145
|
+
.map((_, i) => i === sourceIndex
|
|
146
|
+
? [
|
|
147
|
+
{
|
|
148
|
+
node: actualTargetNode.name,
|
|
149
|
+
type: connectionType,
|
|
150
|
+
index: targetIndex,
|
|
151
|
+
},
|
|
152
|
+
]
|
|
153
|
+
: []),
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
const message = (0, connection_utils_1.formatConnectionMessage)(actualSourceNode.name, actualTargetNode.name, connectionType, swapped);
|
|
157
|
+
const output = {
|
|
158
|
+
sourceNode: actualSourceNode.name,
|
|
159
|
+
targetNode: actualTargetNode.name,
|
|
160
|
+
connectionType,
|
|
161
|
+
swapped,
|
|
162
|
+
message,
|
|
163
|
+
found: {
|
|
164
|
+
sourceNode: true,
|
|
165
|
+
targetNode: true,
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
reporter.complete(output);
|
|
169
|
+
const stateUpdates = (0, state_1.updateWorkflowConnections)(newConnection);
|
|
170
|
+
return (0, response_1.createSuccessResponse)(config, message, stateUpdates);
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
let toolError;
|
|
174
|
+
if (error instanceof zod_1.z.ZodError) {
|
|
175
|
+
const validationError = new errors_1.ValidationError('Invalid connection parameters', {
|
|
176
|
+
field: error.errors[0]?.path.join('.'),
|
|
177
|
+
value: error.errors[0]?.message,
|
|
178
|
+
});
|
|
179
|
+
toolError = {
|
|
180
|
+
message: validationError.message,
|
|
181
|
+
code: 'VALIDATION_ERROR',
|
|
182
|
+
details: error.errors,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
toolError = {
|
|
187
|
+
message: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
188
|
+
code: 'EXECUTION_ERROR',
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
reporter.error(toolError);
|
|
192
|
+
return (0, response_1.createErrorResponse)(config, toolError);
|
|
193
|
+
}
|
|
194
|
+
}, {
|
|
195
|
+
name: 'connect_nodes',
|
|
196
|
+
description: `Connect two nodes in the workflow. The tool automatically determines the connection type based on node capabilities and ensures correct connection direction.
|
|
197
|
+
|
|
198
|
+
UNDERSTANDING CONNECTIONS:
|
|
199
|
+
- SOURCE NODE: The node that PRODUCES output/provides capability
|
|
200
|
+
- TARGET NODE: The node that RECEIVES input/uses capability
|
|
201
|
+
- Flow direction: Source → Target
|
|
202
|
+
|
|
203
|
+
AUTOMATIC CONNECTION TYPE DETECTION:
|
|
204
|
+
- The tool analyzes the nodes' inputs and outputs to determine the appropriate connection type
|
|
205
|
+
- If multiple connection types are possible, the tool will provide an error with the available options
|
|
206
|
+
- The connection type is determined by matching compatible input/output types between nodes
|
|
207
|
+
|
|
208
|
+
For ai_* connections (ai_languageModel, ai_tool, ai_memory, ai_embedding, etc.):
|
|
209
|
+
- Sub-nodes are ALWAYS the source (they provide capabilities)
|
|
210
|
+
- Main nodes are ALWAYS the target (they use capabilities)
|
|
211
|
+
- The tool will AUTO-CORRECT if you specify them backwards
|
|
212
|
+
|
|
213
|
+
CONNECTION EXAMPLES:
|
|
214
|
+
- OpenAI Chat Model → AI Agent (detects ai_languageModel)
|
|
215
|
+
- Calculator Tool → AI Agent (detects ai_tool)
|
|
216
|
+
- Simple Memory → Basic LLM Chain (detects ai_memory)
|
|
217
|
+
- Embeddings OpenAI → Vector Store (detects ai_embedding)
|
|
218
|
+
- Document Loader → Embeddings OpenAI (detects ai_document)
|
|
219
|
+
- HTTP Request → Set (detects main)`,
|
|
220
|
+
schema: exports.nodeConnectionSchema,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=connect-nodes.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connect-nodes.tool.js","sourceRoot":"","sources":["../../src/tools/connect-nodes.tool.ts"],"names":[],"mappings":";;;AAkDA,wDA4QC;AA9TD,iDAA6C;AAG7C,6BAAwB;AAExB,sCAKmB;AAEnB,iDAA4E;AAC5E,iDAAgF;AAChF,2CAAkG;AAClG,qDAA0D;AAC1D,+DAIkC;AAMrB,QAAA,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,YAAY,EAAE,OAAC;SACb,MAAM,EAAE;SACR,QAAQ,CACR,uMAAuM,CACvM;IACF,YA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
|
+
import type { INodeTypeDescription, NodeConnectionType } from 'n8n-workflow';
|
|
2
|
+
import type { NodeSearchResult } from '../../types/nodes';
|
|
3
|
+
export declare const SCORE_WEIGHTS: {
|
|
4
|
+
readonly NAME_CONTAINS: 10;
|
|
5
|
+
readonly DISPLAY_NAME_CONTAINS: 8;
|
|
6
|
+
readonly DESCRIPTION_CONTAINS: 5;
|
|
7
|
+
readonly ALIAS_CONTAINS: 8;
|
|
8
|
+
readonly NAME_EXACT: 20;
|
|
9
|
+
readonly DISPLAY_NAME_EXACT: 15;
|
|
10
|
+
readonly CONNECTION_EXACT: 100;
|
|
11
|
+
readonly CONNECTION_IN_EXPRESSION: 50;
|
|
12
|
+
};
|
|
13
|
+
export declare class NodeSearchEngine {
|
|
14
|
+
private readonly nodeTypes;
|
|
15
|
+
constructor(nodeTypes: INodeTypeDescription[]);
|
|
16
|
+
searchByName(query: string, limit?: number): NodeSearchResult[];
|
|
17
|
+
searchByConnectionType(connectionType: NodeConnectionType, limit?: number, nameFilter?: string): NodeSearchResult[];
|
|
18
|
+
formatResult(result: NodeSearchResult): string;
|
|
19
|
+
private calculateNameScore;
|
|
20
|
+
private getConnectionScore;
|
|
21
|
+
private createSearchResult;
|
|
22
|
+
private sortAndLimit;
|
|
23
|
+
static isAiConnectionType(connectionType: string): boolean;
|
|
24
|
+
static getAiConnectionTypes(): NodeConnectionType[];
|
|
25
|
+
}
|