n8n-nodes-smart-browser-automation 1.6.1 → 1.6.3
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,4 +1,4 @@
|
|
|
1
|
-
import { IExecuteFunctions, ILoadOptionsFunctions, INodeExecutionData, INodePropertyOptions, INodeType, INodeTypeDescription
|
|
1
|
+
import { IExecuteFunctions, ILoadOptionsFunctions, INodeExecutionData, INodePropertyOptions, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
2
|
export declare class SmartBrowserAutomation implements INodeType {
|
|
3
3
|
description: INodeTypeDescription;
|
|
4
4
|
methods: {
|
|
@@ -6,6 +6,5 @@ export declare class SmartBrowserAutomation implements INodeType {
|
|
|
6
6
|
getAvailableTools(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
7
7
|
};
|
|
8
8
|
};
|
|
9
|
-
supplyData(this: ISupplyDataFunctions, _itemIndex: number): Promise<any>;
|
|
10
9
|
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
11
10
|
}
|
|
@@ -77,33 +77,6 @@ class SmartBrowserAutomation {
|
|
|
77
77
|
},
|
|
78
78
|
},
|
|
79
79
|
};
|
|
80
|
-
async supplyData(_itemIndex) {
|
|
81
|
-
const credentials = await this.getCredentials('smartBrowserAutomationApi');
|
|
82
|
-
const sessionManager = BrowserSessionManager_1.default.getInstance();
|
|
83
|
-
// Initialize session
|
|
84
|
-
const cdpEndpoint = credentials.cdpEndpoint || '';
|
|
85
|
-
await sessionManager.initialize(credentials.mcpEndpoint, !!cdpEndpoint, cdpEndpoint);
|
|
86
|
-
// Get all available tools from MCP server
|
|
87
|
-
const mcpTools = await sessionManager.listTools();
|
|
88
|
-
// Convert MCP tools to n8n tool format
|
|
89
|
-
const n8nTools = mcpTools.map((tool) => ({
|
|
90
|
-
name: tool.name,
|
|
91
|
-
description: tool.description || `Execute the ${tool.name} tool`,
|
|
92
|
-
schema: tool.inputSchema || { type: 'object', properties: {}, additionalProperties: false },
|
|
93
|
-
func: async (params) => {
|
|
94
|
-
try {
|
|
95
|
-
const result = await sessionManager.callTool(tool.name, params);
|
|
96
|
-
return JSON.stringify(result);
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Tool execution failed: ${error.message}`);
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
}));
|
|
103
|
-
return {
|
|
104
|
-
response: n8nTools,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
80
|
async execute() {
|
|
108
81
|
const items = this.getInputData();
|
|
109
82
|
const returnData = [];
|
|
@@ -198,6 +171,13 @@ class SmartBrowserAutomation {
|
|
|
198
171
|
});
|
|
199
172
|
return [returnData];
|
|
200
173
|
}
|
|
174
|
+
// Validate tool exists before executing
|
|
175
|
+
const availableTools = await sessionManager.listTools();
|
|
176
|
+
const toolExists = availableTools.some((tool) => tool.name === toolName);
|
|
177
|
+
if (!toolExists) {
|
|
178
|
+
const availableToolNames = availableTools.map((t) => t.name).join(', ');
|
|
179
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Tool '${toolName}' does not exist. Available tools: ${availableToolNames}`);
|
|
180
|
+
}
|
|
201
181
|
// Execute the tool via MCP
|
|
202
182
|
const result = await sessionManager.callTool(toolName, toolParams);
|
|
203
183
|
returnData.push({
|