n8n-nodes-smart-browser-automation 1.6.2 → 1.6.4
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.
|
@@ -27,10 +27,36 @@ class SmartBrowserAutomation {
|
|
|
27
27
|
],
|
|
28
28
|
usableAsTool: true,
|
|
29
29
|
properties: [
|
|
30
|
+
{
|
|
31
|
+
displayName: 'Operation',
|
|
32
|
+
name: 'operation',
|
|
33
|
+
type: 'options',
|
|
34
|
+
noDataExpression: true,
|
|
35
|
+
options: [
|
|
36
|
+
{
|
|
37
|
+
name: 'Execute Tool',
|
|
38
|
+
value: 'executeTool',
|
|
39
|
+
description: 'Execute a browser automation tool',
|
|
40
|
+
action: 'Execute a tool',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'List Tools',
|
|
44
|
+
value: 'listTools',
|
|
45
|
+
description: 'Get available tools with their schemas',
|
|
46
|
+
action: 'List available tools',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
default: 'executeTool',
|
|
50
|
+
},
|
|
30
51
|
{
|
|
31
52
|
displayName: 'CDP Endpoint Override',
|
|
32
53
|
name: 'cdpOverride',
|
|
33
54
|
type: 'string',
|
|
55
|
+
displayOptions: {
|
|
56
|
+
show: {
|
|
57
|
+
operation: ['executeTool'],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
34
60
|
default: '',
|
|
35
61
|
placeholder: 'wss://gridnew.doingerp.com/devtools/...',
|
|
36
62
|
description: 'Override CDP endpoint from credentials. Use this to connect to a specific browser instance.',
|
|
@@ -39,6 +65,11 @@ class SmartBrowserAutomation {
|
|
|
39
65
|
displayName: 'Tool Name or ID',
|
|
40
66
|
name: 'toolName',
|
|
41
67
|
type: 'options',
|
|
68
|
+
displayOptions: {
|
|
69
|
+
show: {
|
|
70
|
+
operation: ['executeTool'],
|
|
71
|
+
},
|
|
72
|
+
},
|
|
42
73
|
typeOptions: {
|
|
43
74
|
loadOptionsMethod: 'getAvailableTools',
|
|
44
75
|
},
|
|
@@ -49,6 +80,11 @@ class SmartBrowserAutomation {
|
|
|
49
80
|
displayName: 'Tool Parameters',
|
|
50
81
|
name: 'toolParameters',
|
|
51
82
|
type: 'json',
|
|
83
|
+
displayOptions: {
|
|
84
|
+
show: {
|
|
85
|
+
operation: ['executeTool'],
|
|
86
|
+
},
|
|
87
|
+
},
|
|
52
88
|
required: true,
|
|
53
89
|
default: '{}',
|
|
54
90
|
description: 'Parameters to pass to the browser tool in JSON format',
|
|
@@ -82,6 +118,28 @@ class SmartBrowserAutomation {
|
|
|
82
118
|
const returnData = [];
|
|
83
119
|
const credentials = await this.getCredentials('smartBrowserAutomationApi');
|
|
84
120
|
const sessionManager = BrowserSessionManager_1.default.getInstance();
|
|
121
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
122
|
+
// Handle List Tools operation
|
|
123
|
+
if (operation === 'listTools') {
|
|
124
|
+
try {
|
|
125
|
+
await sessionManager.initialize(credentials.mcpEndpoint, false, '');
|
|
126
|
+
const tools = await sessionManager.listTools();
|
|
127
|
+
returnData.push({
|
|
128
|
+
json: {
|
|
129
|
+
tools: tools.map((tool) => ({
|
|
130
|
+
name: tool.name,
|
|
131
|
+
description: tool.description || `Execute the ${tool.name} tool`,
|
|
132
|
+
schema: tool.inputSchema || { type: 'object', properties: {}, additionalProperties: false },
|
|
133
|
+
}))
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
return [returnData];
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to list tools: ${error.message}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// Handle Execute Tool operation
|
|
85
143
|
// Get CDP override or use from credentials
|
|
86
144
|
const cdpOverride = this.getNodeParameter('cdpOverride', 0, '');
|
|
87
145
|
// Check if AI Agent sent Tool_Parameters in input
|
|
@@ -171,6 +229,13 @@ class SmartBrowserAutomation {
|
|
|
171
229
|
});
|
|
172
230
|
return [returnData];
|
|
173
231
|
}
|
|
232
|
+
// Validate tool exists before executing
|
|
233
|
+
const availableTools = await sessionManager.listTools();
|
|
234
|
+
const toolExists = availableTools.some((tool) => tool.name === toolName);
|
|
235
|
+
if (!toolExists) {
|
|
236
|
+
const availableToolNames = availableTools.map((t) => t.name).join(', ');
|
|
237
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Tool '${toolName}' does not exist. Available tools: ${availableToolNames}`);
|
|
238
|
+
}
|
|
174
239
|
// Execute the tool via MCP
|
|
175
240
|
const result = await sessionManager.callTool(toolName, toolParams);
|
|
176
241
|
returnData.push({
|