@n8n/ai-workflow-builder 0.25.1 → 0.26.1

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.
@@ -1 +1 @@
1
- export declare const CORE_INSTRUCTIONS = "You are an expert n8n workflow architect who updates node parameters based on natural language instructions.\n\n## Your Task\nUpdate the parameters of an existing n8n node based on the requested changes. Return the COMPLETE parameters object with both modified and unmodified parameters. Only modify the parameters that are explicitly mentioned in the changes, preserving all other existing parameters exactly as they are.\n\n## Reference Information\nYou will receive:\n1. The original user workflow request\n2. The current workflow JSON\n3. The selected node's current configuration (id, name, type, parameters)\n4. The node type's parameter definitions\n5. Natural language changes to apply\n\n## Parameter Update Guidelines\n1. START WITH CURRENT: If current parameters is empty {}, start with an empty object and add the requested parameters\n2. PRESERVE EXISTING VALUES: Only modify parameters mentioned in the requested changes\n3. MAINTAIN STRUCTURE: Keep the exact parameter structure required by the node type\n4. CHECK FOR RESOURCELOCATOR: If a parameter is type 'resourceLocator' in the node definition, it MUST use the ResourceLocator structure with __rl, mode, and value fields\n5. USE PROPER EXPRESSIONS: Follow n8n expression syntax when referencing other nodes\n6. VALIDATE TYPES: Ensure parameter values match their expected types\n7. HANDLE NESTED PARAMETERS: Correctly update nested structures like headers, conditions, etc.\n8. SIMPLE VALUES: For simple parameter updates like \"Set X to Y\", directly set the parameter without unnecessary nesting\n9. GENERATE IDS: When adding new items to arrays (like assignments, headers, etc.), generate unique IDs using a simple pattern like \"id-1\", \"id-2\", etc.\n10. TOOL NODE DETECTION: Check if node type ends with \"Tool\" to determine if $fromAI expressions are available";
1
+ export declare const CORE_INSTRUCTIONS = "You are an expert n8n workflow architect who updates node parameters based on natural language instructions.\n\n## Your Task\nUpdate the parameters of an existing n8n node based on the requested changes. Return the COMPLETE parameters object with both modified and unmodified parameters. Only modify the parameters that are explicitly mentioned in the changes, preserving all other existing parameters exactly as they are.\n\n## Reference Information\nYou will receive:\n1. The original user workflow request\n2. The current workflow JSON\n3. The selected node's current configuration (id, name, type, parameters)\n4. The node type's parameter definitions\n5. Natural language changes to apply\n\n## Parameter Update Guidelines\n1. START WITH CURRENT: If current parameters is empty {}, start with an empty object and add the requested parameters\n2. PRESERVE EXISTING VALUES: Only modify parameters mentioned in the requested changes\n3. MAINTAIN STRUCTURE: Keep the exact parameter structure required by the node type\n4. CHECK FOR RESOURCELOCATOR: If a parameter is type 'resourceLocator' in the node definition, it MUST use the ResourceLocator structure with __rl, mode, and value fields\n5. USE PROPER EXPRESSIONS: Follow n8n expression syntax when referencing other nodes\n6. VALIDATE TYPES: Ensure parameter values match their expected types\n7. HANDLE NESTED PARAMETERS: Correctly update nested structures like headers, conditions, etc.\n8. SIMPLE VALUES: For simple parameter updates like \"Set X to Y\", directly set the parameter without unnecessary nesting\n9. GENERATE IDS: When adding new items to arrays (like assignments, headers, etc.), generate unique IDs using a simple pattern like \"id-1\", \"id-2\", etc.\n10. TOOL NODE DETECTION: Check if node type ends with \"Tool\" to determine if $fromAI expressions are available\n11. PLACEHOLDER FORMAT: When changes specify a placeholder, copy it exactly as \"<__PLACEHOLDER_VALUE__VALUE_LABEL__>\" (no extra quotes or expressions) and keep VALUE_LABEL descriptive for the user";
@@ -24,5 +24,6 @@ You will receive:
24
24
  7. HANDLE NESTED PARAMETERS: Correctly update nested structures like headers, conditions, etc.
25
25
  8. SIMPLE VALUES: For simple parameter updates like "Set X to Y", directly set the parameter without unnecessary nesting
26
26
  9. GENERATE IDS: When adding new items to arrays (like assignments, headers, etc.), generate unique IDs using a simple pattern like "id-1", "id-2", etc.
27
- 10. TOOL NODE DETECTION: Check if node type ends with "Tool" to determine if $fromAI expressions are available`;
27
+ 10. TOOL NODE DETECTION: Check if node type ends with "Tool" to determine if $fromAI expressions are available
28
+ 11. PLACEHOLDER FORMAT: When changes specify a placeholder, copy it exactly as "<__PLACEHOLDER_VALUE__VALUE_LABEL__>" (no extra quotes or expressions) and keep VALUE_LABEL descriptive for the user`;
28
29
  //# sourceMappingURL=core-instructions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"core-instructions.js","sourceRoot":"","sources":["../../../../src/chains/prompts/base/core-instructions.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;+GAuB8E,CAAC"}
1
+ {"version":3,"file":"core-instructions.js","sourceRoot":"","sources":["../../../../src/chains/prompts/base/core-instructions.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;qMAwBoK,CAAC"}
@@ -7,6 +7,7 @@ const connect_nodes_tool_1 = require("./connect-nodes.tool");
7
7
  const get_node_parameter_tool_1 = require("./get-node-parameter.tool");
8
8
  const node_details_tool_1 = require("./node-details.tool");
9
9
  const node_search_tool_1 = require("./node-search.tool");
10
+ const remove_connection_tool_1 = require("./remove-connection.tool");
10
11
  const remove_node_tool_1 = require("./remove-node.tool");
11
12
  const update_node_parameters_tool_1 = require("./update-node-parameters.tool");
12
13
  function getBuilderTools({ parsedNodeTypes, logger, llmComplexTask, instanceUrl, }) {
@@ -15,6 +16,7 @@ function getBuilderTools({ parsedNodeTypes, logger, llmComplexTask, instanceUrl,
15
16
  (0, node_details_tool_1.createNodeDetailsTool)(parsedNodeTypes),
16
17
  (0, add_node_tool_1.createAddNodeTool)(parsedNodeTypes),
17
18
  (0, connect_nodes_tool_1.createConnectNodesTool)(parsedNodeTypes, logger),
19
+ (0, remove_connection_tool_1.createRemoveConnectionTool)(logger),
18
20
  (0, remove_node_tool_1.createRemoveNodeTool)(logger),
19
21
  (0, update_node_parameters_tool_1.createUpdateNodeParametersTool)(parsedNodeTypes, llmComplexTask, logger, instanceUrl),
20
22
  (0, get_node_parameter_tool_1.createGetNodeParameterTool)(),
@@ -26,6 +28,7 @@ function getBuilderToolsForDisplay({ nodeTypes, }) {
26
28
  node_details_tool_1.NODE_DETAILS_TOOL,
27
29
  (0, add_node_tool_1.getAddNodeToolBase)(nodeTypes),
28
30
  connect_nodes_tool_1.CONNECT_NODES_TOOL,
31
+ remove_connection_tool_1.REMOVE_CONNECTION_TOOL,
29
32
  remove_node_tool_1.REMOVE_NODE_TOOL,
30
33
  update_node_parameters_tool_1.UPDATING_NODE_PARAMETER_TOOL,
31
34
  get_node_parameter_tool_1.GET_NODE_PARAMETER_TOOL,
@@ -1 +1 @@
1
- {"version":3,"file":"builder-tools.js","sourceRoot":"","sources":["../../src/tools/builder-tools.ts"],"names":[],"mappings":";;AAiBA,0CAoBC;AAOD,8DAYC;AAlDD,mDAAwE;AACxE,6DAAkF;AAClF,uEAAgG;AAChG,2DAA+E;AAC/E,yDAA4E;AAC5E,yDAA4E;AAC5E,+EAGuC;AAEvC,SAAgB,eAAe,CAAC,EAC/B,eAAe,EACf,MAAM,EACN,cAAc,EACd,WAAW,GAMX;IACA,OAAO;QACN,IAAA,uCAAoB,EAAC,eAAe,CAAC;QACrC,IAAA,yCAAqB,EAAC,eAAe,CAAC;QACtC,IAAA,iCAAiB,EAAC,eAAe,CAAC;QAClC,IAAA,2CAAsB,EAAC,eAAe,EAAE,MAAM,CAAC;QAC/C,IAAA,uCAAoB,EAAC,MAAM,CAAC;QAC5B,IAAA,4DAA8B,EAAC,eAAe,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,CAAC;QACpF,IAAA,oDAA0B,GAAE;KAC5B,CAAC;AACH,CAAC;AAOD,SAAgB,yBAAyB,CAAC,EACzC,SAAS,GAC8B;IACvC,OAAO;QACN,mCAAgB;QAChB,qCAAiB;QACjB,IAAA,kCAAkB,EAAC,SAAS,CAAC;QAC7B,uCAAkB;QAClB,mCAAgB;QAChB,0DAA4B;QAC5B,iDAAuB;KACvB,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"builder-tools.js","sourceRoot":"","sources":["../../src/tools/builder-tools.ts"],"names":[],"mappings":";;AAkBA,0CAqBC;AAOD,8DAaC;AArDD,mDAAwE;AACxE,6DAAkF;AAClF,uEAAgG;AAChG,2DAA+E;AAC/E,yDAA4E;AAC5E,qEAA8F;AAC9F,yDAA4E;AAC5E,+EAGuC;AAEvC,SAAgB,eAAe,CAAC,EAC/B,eAAe,EACf,MAAM,EACN,cAAc,EACd,WAAW,GAMX;IACA,OAAO;QACN,IAAA,uCAAoB,EAAC,eAAe,CAAC;QACrC,IAAA,yCAAqB,EAAC,eAAe,CAAC;QACtC,IAAA,iCAAiB,EAAC,eAAe,CAAC;QAClC,IAAA,2CAAsB,EAAC,eAAe,EAAE,MAAM,CAAC;QAC/C,IAAA,mDAA0B,EAAC,MAAM,CAAC;QAClC,IAAA,uCAAoB,EAAC,MAAM,CAAC;QAC5B,IAAA,4DAA8B,EAAC,eAAe,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,CAAC;QACpF,IAAA,oDAA0B,GAAE;KAC5B,CAAC;AACH,CAAC;AAOD,SAAgB,yBAAyB,CAAC,EACzC,SAAS,GAC8B;IACvC,OAAO;QACN,mCAAgB;QAChB,qCAAiB;QACjB,IAAA,kCAAkB,EAAC,SAAS,CAAC;QAC7B,uCAAkB;QAClB,+CAAsB;QACtB,mCAAgB;QAChB,0DAA4B;QAC5B,iDAAuB;KACvB,CAAC;AACH,CAAC"}
@@ -11,3 +11,4 @@ export declare function removeNodeFromWorkflow(nodeId: string): Partial<typeof W
11
11
  export declare function removeNodesFromWorkflow(nodeIds: string[]): Partial<typeof WorkflowState.State>;
12
12
  export declare function updateNodeInWorkflow(state: typeof WorkflowState.State, nodeId: string, updates: Partial<INode>): Partial<typeof WorkflowState.State>;
13
13
  export declare function addConnectionToWorkflow(sourceNodeId: string, _targetNodeId: string, connection: IConnection): Partial<typeof WorkflowState.State>;
14
+ export declare function removeConnectionFromWorkflow(sourceNode: string, targetNode: string, connectionType: string, sourceOutputIndex: number, targetInputIndex: number): Partial<typeof WorkflowState.State>;
@@ -10,6 +10,7 @@ exports.removeNodeFromWorkflow = removeNodeFromWorkflow;
10
10
  exports.removeNodesFromWorkflow = removeNodesFromWorkflow;
11
11
  exports.updateNodeInWorkflow = updateNodeInWorkflow;
12
12
  exports.addConnectionToWorkflow = addConnectionToWorkflow;
13
+ exports.removeConnectionFromWorkflow = removeConnectionFromWorkflow;
13
14
  const langgraph_1 = require("@langchain/langgraph");
14
15
  function getCurrentWorkflow(state) {
15
16
  return state.workflowJSON;
@@ -67,4 +68,18 @@ function addConnectionToWorkflow(sourceNodeId, _targetNodeId, connection) {
67
68
  ],
68
69
  };
69
70
  }
71
+ function removeConnectionFromWorkflow(sourceNode, targetNode, connectionType, sourceOutputIndex, targetInputIndex) {
72
+ return {
73
+ workflowOperations: [
74
+ {
75
+ type: 'removeConnection',
76
+ sourceNode,
77
+ targetNode,
78
+ connectionType,
79
+ sourceOutputIndex,
80
+ targetInputIndex,
81
+ },
82
+ ],
83
+ };
84
+ }
70
85
  //# sourceMappingURL=state.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../src/tools/helpers/state.ts"],"names":[],"mappings":";;AASA,gDAEC;AAED,4CAEC;AAKD,0EAGC;AAKD,8DAOC;AAKD,8CAEC;AAKD,gDAKC;AAKD,wDAKC;AAKD,0DAKC;AAKD,oDAcC;AAKD,0DAiBC;AAjHD,oDAA2D;AAS3D,SAAgB,kBAAkB,CAAC,KAAiC;IACnE,OAAO,KAAK,CAAC,YAAY,CAAC;AAC3B,CAAC;AAED,SAAgB,gBAAgB;IAC/B,OAAO,IAAA,+BAAmB,GAAE,CAAC;AAC9B,CAAC;AAKD,SAAgB,+BAA+B;IAC9C,MAAM,KAAK,GAAG,gBAAgB,EAAE,CAAC;IACjC,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC;AAKD,SAAgB,yBAAyB,CACxC,WAA0C;IAG1C,OAAO;QACN,kBAAkB,EAAE,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,WAAW,EAAE,CAAC;KAC/D,CAAC;AACH,CAAC;AAKD,SAAgB,iBAAiB,CAAC,IAAW;IAC5C,OAAO,k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EvB,MAAM,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC;IAC3E,IAAI,CAAC,YAAY,EAAE,CAAC;QACnB,OAAO,EAAE,CAAC;IACX,CAAC;IAGD,OAAO;QACN,kBAAkB,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;KAC7D,CAAC;AACH,CAAC;AAKD,SAAgB,uBAAuB,CACtC,YAAoB,EACpB,aAAqB,EACrB,UAAuB;IAEvB,OAAO;QACN,kBAAkB,EAAE;YACnB;gBACC,IAAI,EAAE,kBAAkB;gBACxB,WAAW,EAAE;oBACZ,CAAC,YAAY,CAAC,EAAE;wBACf,IAAI,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;qBACpB;iBACD;aACD;SACD;KACD,CAAC;AACH,CAAC;AAKD,SAAgB,4BAA4B,CAC3C,UAAkB,EAClB,UAAkB,EAClB,cAAsB,EACtB,iBAAyB,EACzB,gBAAwB;IAExB,OAAO;QACN,kBAAkB,EAAE;YACnB;gBACC,IAAI,EAAE,kBAAkB;gBACxB,UAAU;gBACV,UAAU;gBACV,cAAc;gBACd,iBAAiB;gBACjB,gBAAgB;aAChB;SACD;KACD,CAAC;AACH,CAAC"}
@@ -342,14 +342,18 @@ When modifying existing nodes:
342
342
  <handling_uncertainty>
343
343
  When unsure about specific values:
344
344
  - Add nodes and connections confidently
345
- - For uncertain parameters, use update_node_parameters with clear placeholders
345
+ - For uncertain parameters, use update_node_parameters with placeholders formatted exactly as "<__PLACEHOLDER_VALUE__VALUE_LABEL__>"
346
+ - Make VALUE_LABEL descriptive (e.g., "API endpoint URL", "Auth token header") so users know what to supply
346
347
  - For tool nodes with dynamic values, use $fromAI expressions instead of placeholders
347
348
  - Always mention what needs user to configure in the setup response
348
349
 
349
350
  Example for regular nodes:
350
351
  update_node_parameters({{
351
352
  nodeId: "httpRequest1",
352
- instructions: ["Set URL to YOUR_API_ENDPOINT", "Add your authentication headers"]
353
+ instructions: [
354
+ "Set URL to <__PLACEHOLDER_VALUE__API endpoint URL__>",
355
+ "Add header Authorization: <__PLACEHOLDER_VALUE__Bearer token__>"
356
+ ]
353
357
  }})
354
358
 
355
359
  Example for tool nodes:
@@ -1 +1 @@
1
- {"version":3,"file":"main-agent.prompt.js","sourceRoot":"","sources":["../../../src/tools/prompts/main-agent.prompt.ts"],"names":[],"mappings":";;;AAAA,qDAA6D;AAE7D,oEAAsE;AAEtE,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoWpB,CAAC;AAEF,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCxB,CAAC;AAEF,MAAM,mBAAmB,GAAG;;;;;;;8BAOE,CAAC;AAE/B,MAAM,oBAAoB,GAAG;;;qCAGQ,CAAC;AAEtC,MAAM,4BAA4B,GAAG;;;mCAGF,CAAC;AAEpC,MAAM,2BAA2B,GAAG;;;oBAGhB,CAAC;AAER,QAAA,eAAe,GAAG,4BAAkB,CAAC,YAAY,CAAC;IAC9D;QACC,QAAQ;QACR;YACC;gBACC,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,YAAY;gBAClB,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;;;;;;;;;;;;;;;;;;;CAuCxB,CAAC;AAEF,MAAM,mBAAmB,GAAG;;;;;;;8BAOE,CAAC;AAE/B,MAAM,oBAAoB,GAAG;;;qCAGQ,CAAC;AAEtC,MAAM,4BAA4B,GAAG;;;mCAGF,CAAC;AAEpC,MAAM,2BAA2B,GAAG;;;oBAGhB,CAAC;AAER,QAAA,eAAe,GAAG,4BAAkB,CAAC,YAAY,CAAC;IAC9D;QACC,QAAQ;QACR;YACC;gBACC,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,YAAY;gBAClB,aAAa,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;aACpC;YACD;gBACC,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,gCAAiB;aACvB;YACD;gBACC,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,mBAAmB;aACzB;YACD;gBACC,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,oBAAoB;aAC1B;YACD;gBACC,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,4BAA4B;aAClC;YACD;gBACC,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,gBAAgB;gBACtB,aAAa,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;aACpC;YACD;gBACC,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,2BAA2B;gBACjC,aAAa,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;aACpC;SACD;KACD;IACD,CAAC,aAAa,EAAE,YAAY,CAAC;CAC7B,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { Logger } from '@n8n/backend-common';
2
+ import { z } from 'zod';
3
+ import type { BuilderTool, BuilderToolBase } from '../utils/stream-processor';
4
+ export declare const removeConnectionSchema: z.ZodObject<{
5
+ sourceNodeId: z.ZodString;
6
+ targetNodeId: z.ZodString;
7
+ connectionType: z.ZodDefault<z.ZodOptional<z.ZodString>>;
8
+ sourceOutputIndex: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
9
+ targetInputIndex: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
10
+ }, "strip", z.ZodTypeAny, {
11
+ connectionType: string;
12
+ sourceOutputIndex: number;
13
+ targetInputIndex: number;
14
+ sourceNodeId: string;
15
+ targetNodeId: string;
16
+ }, {
17
+ sourceNodeId: string;
18
+ targetNodeId: string;
19
+ connectionType?: string | undefined;
20
+ sourceOutputIndex?: number | undefined;
21
+ targetInputIndex?: number | undefined;
22
+ }>;
23
+ export declare const REMOVE_CONNECTION_TOOL: BuilderToolBase;
24
+ export declare function createRemoveConnectionTool(logger?: Logger): BuilderTool;
@@ -0,0 +1,234 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.REMOVE_CONNECTION_TOOL = exports.removeConnectionSchema = void 0;
4
+ exports.createRemoveConnectionTool = createRemoveConnectionTool;
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
+ exports.removeConnectionSchema = zod_1.z.object({
13
+ sourceNodeId: zod_1.z
14
+ .string()
15
+ .describe('The UUID of the source node where the connection originates from'),
16
+ targetNodeId: zod_1.z.string().describe('The UUID of the target node where the connection goes to'),
17
+ connectionType: zod_1.z
18
+ .string()
19
+ .optional()
20
+ .default('main')
21
+ .describe('The type of connection to remove (default: "main")'),
22
+ sourceOutputIndex: zod_1.z
23
+ .number()
24
+ .optional()
25
+ .default(0)
26
+ .describe('The index of the output to disconnect from (default: 0)'),
27
+ targetInputIndex: zod_1.z
28
+ .number()
29
+ .optional()
30
+ .default(0)
31
+ .describe('The index of the input to disconnect from (default: 0)'),
32
+ });
33
+ exports.REMOVE_CONNECTION_TOOL = {
34
+ toolName: 'remove_connection',
35
+ displayTitle: 'Removing connection',
36
+ };
37
+ function buildResponseMessage(sourceNodeName, targetNodeName, connectionType, sourceOutputIndex, targetInputIndex) {
38
+ const parts = [
39
+ `Successfully removed connection: ${sourceNodeName} → ${targetNodeName} (${connectionType})`,
40
+ ];
41
+ if (sourceOutputIndex !== 0 || targetInputIndex !== 0) {
42
+ parts.push(`Output index: ${sourceOutputIndex}, Input index: ${targetInputIndex}`);
43
+ }
44
+ return parts.join('\n');
45
+ }
46
+ function createRemoveConnectionTool(logger) {
47
+ const dynamicTool = (0, tools_1.tool)((input, config) => {
48
+ const reporter = (0, progress_1.createProgressReporter)(config, exports.REMOVE_CONNECTION_TOOL.toolName, exports.REMOVE_CONNECTION_TOOL.displayTitle);
49
+ try {
50
+ const validatedInput = exports.removeConnectionSchema.parse(input);
51
+ reporter.start(validatedInput);
52
+ const state = (0, state_1.getWorkflowState)();
53
+ const workflow = (0, state_1.getCurrentWorkflow)(state);
54
+ (0, progress_1.reportProgress)(reporter, 'Finding nodes to disconnect...');
55
+ const sourceNode = (0, validation_1.validateNodeExists)(validatedInput.sourceNodeId, workflow.nodes);
56
+ const targetNode = (0, validation_1.validateNodeExists)(validatedInput.targetNodeId, workflow.nodes);
57
+ if (!sourceNode || !targetNode) {
58
+ const missingNodeId = !sourceNode
59
+ ? validatedInput.sourceNodeId
60
+ : validatedInput.targetNodeId;
61
+ const nodeError = new errors_1.NodeNotFoundError(missingNodeId);
62
+ const error = {
63
+ message: nodeError.message,
64
+ code: 'NODES_NOT_FOUND',
65
+ details: {
66
+ sourceNodeId: validatedInput.sourceNodeId,
67
+ targetNodeId: validatedInput.targetNodeId,
68
+ foundSource: !!sourceNode,
69
+ foundTarget: !!targetNode,
70
+ },
71
+ };
72
+ reporter.error(error);
73
+ return (0, response_1.createErrorResponse)(config, error);
74
+ }
75
+ logger?.debug('\n=== Remove Connection Tool ===');
76
+ logger?.debug(`Attempting to remove connection: ${sourceNode.name} -> ${targetNode.name} (${validatedInput.connectionType})`);
77
+ (0, progress_1.reportProgress)(reporter, `Removing connection from ${sourceNode.name} to ${targetNode.name}...`);
78
+ const sourceConnections = workflow.connections[sourceNode.name];
79
+ if (!sourceConnections) {
80
+ const connectionError = new errors_1.ConnectionError(`Source node "${sourceNode.name}" has no outgoing connections`, {
81
+ fromNodeId: sourceNode.id,
82
+ toNodeId: targetNode.id,
83
+ });
84
+ const error = {
85
+ message: connectionError.message,
86
+ code: 'CONNECTION_NOT_FOUND',
87
+ details: {
88
+ sourceNode: sourceNode.name,
89
+ targetNode: targetNode.name,
90
+ connectionType: validatedInput.connectionType,
91
+ },
92
+ };
93
+ reporter.error(error);
94
+ return (0, response_1.createErrorResponse)(config, error);
95
+ }
96
+ const connectionTypeOutputs = sourceConnections[validatedInput.connectionType];
97
+ if (!connectionTypeOutputs || !Array.isArray(connectionTypeOutputs)) {
98
+ const connectionError = new errors_1.ConnectionError(`Source node "${sourceNode.name}" has no connections of type "${validatedInput.connectionType}"`, {
99
+ fromNodeId: sourceNode.id,
100
+ toNodeId: targetNode.id,
101
+ });
102
+ const error = {
103
+ message: connectionError.message,
104
+ code: 'CONNECTION_TYPE_NOT_FOUND',
105
+ details: {
106
+ sourceNode: sourceNode.name,
107
+ targetNode: targetNode.name,
108
+ connectionType: validatedInput.connectionType,
109
+ availableConnectionTypes: Object.keys(sourceConnections),
110
+ },
111
+ };
112
+ reporter.error(error);
113
+ return (0, response_1.createErrorResponse)(config, error);
114
+ }
115
+ const outputConnections = connectionTypeOutputs[validatedInput.sourceOutputIndex];
116
+ if (!outputConnections || !Array.isArray(outputConnections)) {
117
+ const connectionError = new errors_1.ConnectionError(`Source node "${sourceNode.name}" has no connections at output index ${validatedInput.sourceOutputIndex}`, {
118
+ fromNodeId: sourceNode.id,
119
+ toNodeId: targetNode.id,
120
+ });
121
+ const error = {
122
+ message: connectionError.message,
123
+ code: 'OUTPUT_INDEX_NOT_FOUND',
124
+ details: {
125
+ sourceNode: sourceNode.name,
126
+ targetNode: targetNode.name,
127
+ connectionType: validatedInput.connectionType,
128
+ sourceOutputIndex: validatedInput.sourceOutputIndex,
129
+ },
130
+ };
131
+ reporter.error(error);
132
+ return (0, response_1.createErrorResponse)(config, error);
133
+ }
134
+ const connectionExists = outputConnections.some((conn) => conn.node === targetNode.name &&
135
+ conn.type === validatedInput.connectionType &&
136
+ conn.index === validatedInput.targetInputIndex);
137
+ if (!connectionExists) {
138
+ const connectionError = new errors_1.ConnectionError(`Connection not found: ${sourceNode.name} → ${targetNode.name} (${validatedInput.connectionType}) at output ${validatedInput.sourceOutputIndex} to input ${validatedInput.targetInputIndex}`, {
139
+ fromNodeId: sourceNode.id,
140
+ toNodeId: targetNode.id,
141
+ });
142
+ const error = {
143
+ message: connectionError.message,
144
+ code: 'SPECIFIC_CONNECTION_NOT_FOUND',
145
+ details: {
146
+ sourceNode: sourceNode.name,
147
+ targetNode: targetNode.name,
148
+ connectionType: validatedInput.connectionType,
149
+ sourceOutputIndex: validatedInput.sourceOutputIndex,
150
+ targetInputIndex: validatedInput.targetInputIndex,
151
+ existingConnections: outputConnections.map((conn) => ({
152
+ node: conn.node,
153
+ type: conn.type,
154
+ index: conn.index,
155
+ })),
156
+ },
157
+ };
158
+ reporter.error(error);
159
+ return (0, response_1.createErrorResponse)(config, error);
160
+ }
161
+ const message = buildResponseMessage(sourceNode.name, targetNode.name, validatedInput.connectionType, validatedInput.sourceOutputIndex, validatedInput.targetInputIndex);
162
+ logger?.debug('Connection found and will be removed');
163
+ const output = {
164
+ sourceNode: sourceNode.name,
165
+ targetNode: targetNode.name,
166
+ connectionType: validatedInput.connectionType,
167
+ sourceOutputIndex: validatedInput.sourceOutputIndex,
168
+ targetInputIndex: validatedInput.targetInputIndex,
169
+ message,
170
+ };
171
+ reporter.complete(output);
172
+ const stateUpdates = (0, state_1.removeConnectionFromWorkflow)(sourceNode.name, targetNode.name, validatedInput.connectionType, validatedInput.sourceOutputIndex, validatedInput.targetInputIndex);
173
+ return (0, response_1.createSuccessResponse)(config, message, stateUpdates);
174
+ }
175
+ catch (error) {
176
+ let toolError;
177
+ if (error instanceof zod_1.z.ZodError) {
178
+ const validationError = new errors_1.ValidationError('Invalid connection removal parameters', {
179
+ field: error.errors[0]?.path.join('.'),
180
+ value: error.errors[0]?.message,
181
+ });
182
+ toolError = {
183
+ message: validationError.message,
184
+ code: 'VALIDATION_ERROR',
185
+ details: error.errors,
186
+ };
187
+ }
188
+ else {
189
+ toolError = {
190
+ message: error instanceof Error ? error.message : 'Unknown error occurred',
191
+ code: 'EXECUTION_ERROR',
192
+ };
193
+ }
194
+ reporter.error(toolError);
195
+ return (0, response_1.createErrorResponse)(config, toolError);
196
+ }
197
+ }, {
198
+ name: exports.REMOVE_CONNECTION_TOOL.toolName,
199
+ description: `Remove a specific connection between two nodes in the workflow. This allows you to disconnect nodes without deleting them.
200
+
201
+ USAGE:
202
+ Use this tool when you need to break an existing connection while keeping both nodes in the workflow.
203
+
204
+ PARAMETERS:
205
+ - sourceNodeId: The UUID of the node that is the source of the connection (where the data comes from)
206
+ - targetNodeId: The UUID of the node that receives the connection (where the data goes to)
207
+ - connectionType: The type of connection to remove (default: "main")
208
+ * For regular data flow: "main"
209
+ * For AI connections: "ai_languageModel", "ai_tool", "ai_memory", "ai_embedding", "ai_document", etc.
210
+ - sourceOutputIndex: Which output of the source node to disconnect from (default: 0)
211
+ - targetInputIndex: Which input of the target node to disconnect from (default: 0)
212
+
213
+ EXAMPLES:
214
+ 1. Remove main data connection:
215
+ sourceNodeId: "abc-123", targetNodeId: "def-456", connectionType: "main"
216
+
217
+ 2. Remove AI model from AI Agent:
218
+ sourceNodeId: "model-id", targetNodeId: "agent-id", connectionType: "ai_languageModel"
219
+
220
+ 3. Remove specific connection when multiple exist:
221
+ sourceNodeId: "node-1", targetNodeId: "node-2", connectionType: "main", sourceOutputIndex: 1, targetInputIndex: 0
222
+
223
+ NOTES:
224
+ - Both nodes must exist in the workflow
225
+ - The specific connection must exist or an error will be returned
226
+ - Use this when restructuring workflows or replacing connections`,
227
+ schema: exports.removeConnectionSchema,
228
+ });
229
+ return {
230
+ tool: dynamicTool,
231
+ ...exports.REMOVE_CONNECTION_TOOL,
232
+ };
233
+ }
234
+ //# sourceMappingURL=remove-connection.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-connection.tool.js","sourceRoot":"","sources":["../../src/tools/remove-connection.tool.ts"],"names":[],"mappings":";;;AAuEA,gEAiQC;AAxUD,iDAA6C;AAE7C,6BAAwB;AAIxB,sCAAgF;AAEhF,iDAA4E;AAC5E,iDAAgF;AAChF,2CAIyB;AACzB,qDAA0D;AAK7C,QAAA,sBAAsB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9C,YAAY,EAAE,OAAC;SACb,MAAM,EAAE;SACR,QAAQ,CAAC,kEAAkE,CAAC;IAC9E,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0DAA0D,CAAC;IAC7F,cAAc,EAAE,OAAC;SACf,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,OAAO,CAAC,MAAM,CAAC;SACf,QAAQ,CAAC,oDAAoD,CAAC;IAChE,iBAAiB,EAAE,OAAC;SAClB,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,OAAO,CAAC,CAAC,CAAC;SACV,QAAQ,CAAC,yDAAyD,CAAC;IACrE,gBAAgB,EAAE,OAAC;SACjB,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,OAAO,CAAC,CAAC,CAAC;SACV,QAAQ,CAAC,wDAAwD,CAAC;CACpE,CAAC,CAAC;AAEU,QAAA,sBAAsB,GAAoB;IACtD,QAAQ,EAAE,mBAAmB;IAC7B,YAAY,EAAE,qBAAqB;CACnC,CAAC;AAKF,SAAS,oBAAoB,CAC5B,cAAsB,EACtB,cAAsB,EACtB,cAAsB,EACtB,iBAAyB,EACzB,gBAAwB;IAExB,MAAM,KAAK,GAAa;QACvB,oCAAoC,cAAc,MAAM,cAAc,KAAK,cAAc,GAAG;KAC5F,CAAC;IAEF,IAAI,iBAAiB,KAAK,CAAC,IAAI,gBAAgB,KAAK,CAAC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OAAC,CAAC,QAAQ,EAAE,CAAC;gBACjC,MAAM,eAAe,GAAG,IAAI,wBAAe,CAAC,uCAAuC,EAAE;oBACpF,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,8BAAsB,CAAC,QAAQ;QACrC,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;iEA2BiD;QAC9D,MAAM,EAAE,8BAAsB;KAC9B,CACD,CAAC;IAEF,OAAO;QACN,IAAI,EAAE,WAAW;QACjB,GAAG,8BAAsB;KACzB,CAAC;AACH,CAAC"}
@@ -81,3 +81,11 @@ export interface NodeSearchOutput {
81
81
  export interface GetNodeParameterOutput {
82
82
  message: string;
83
83
  }
84
+ export interface RemoveConnectionOutput {
85
+ sourceNode: string;
86
+ targetNode: string;
87
+ connectionType: string;
88
+ sourceOutputIndex: number;
89
+ targetInputIndex: number;
90
+ message: string;
91
+ }
@@ -18,6 +18,13 @@ export type WorkflowOperation = {
18
18
  } | {
19
19
  type: 'mergeConnections';
20
20
  connections: IConnections;
21
+ } | {
22
+ type: 'removeConnection';
23
+ sourceNode: string;
24
+ targetNode: string;
25
+ connectionType: string;
26
+ sourceOutputIndex: number;
27
+ targetInputIndex: number;
21
28
  } | {
22
29
  type: 'setName';
23
30
  name: string;
@@ -0,0 +1,3 @@
1
+ import type { BaseMessage } from '@langchain/core/messages';
2
+ import { RemoveMessage } from '@langchain/core/messages';
3
+ export declare function cleanupDanglingToolCallMessages(messages: BaseMessage[]): RemoveMessage[];
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cleanupDanglingToolCallMessages = cleanupDanglingToolCallMessages;
4
+ const messages_1 = require("@langchain/core/messages");
5
+ function cleanupDanglingToolCallMessages(messages) {
6
+ const toolCallIds = new Set(messages.filter((m) => m instanceof messages_1.ToolMessage).map((m) => m.tool_call_id));
7
+ const danglingToolCalls = messages.filter((m) => m instanceof messages_1.AIMessage && m.tool_calls?.some(({ id }) => id && !toolCallIds.has(id)));
8
+ return danglingToolCalls.map((m) => new messages_1.RemoveMessage({ id: m.id }));
9
+ }
10
+ //# sourceMappingURL=cleanup-dangling-tool-call-messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanup-dangling-tool-call-messages.js","sourceRoot":"","sources":["../../src/utils/cleanup-dangling-tool-call-messages.ts"],"names":[],"mappings":";;AASA,0EAcC;AAtBD,uDAAiF;AAQjF,SAAgB,+BAA+B,CAAC,QAAuB;IAEtE,MAAM,WAAW,GAAG,IAAI,GAAG,CAC1B,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAoB,EAAE,CAAC,CAAC,YAAY,sBAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAC7F,CAAC;IAIF,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CACxC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,oBAAS,IAAI,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAC3F,CAAC;IAGF,OAAO,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,wBAAa,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAG,EAAE,CAAC,CAAC,CAAC;AACvE,CAAC"}