n8n-nodes-smart-browser-automation 1.5.3 → 1.6.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,4 +1,4 @@
|
|
|
1
|
-
import { IExecuteFunctions, ILoadOptionsFunctions, INodeExecutionData, INodePropertyOptions, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
1
|
+
import { IExecuteFunctions, ILoadOptionsFunctions, INodeExecutionData, INodePropertyOptions, INodeType, INodeTypeDescription, ISupplyDataFunctions } from 'n8n-workflow';
|
|
2
2
|
export declare class SmartBrowserAutomation implements INodeType {
|
|
3
3
|
description: INodeTypeDescription;
|
|
4
4
|
methods: {
|
|
@@ -6,5 +6,6 @@ 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>;
|
|
9
10
|
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
10
11
|
}
|
|
@@ -77,6 +77,33 @@ 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
|
+
}
|
|
80
107
|
async execute() {
|
|
81
108
|
const items = this.getInputData();
|
|
82
109
|
const returnData = [];
|
|
@@ -90,7 +117,12 @@ class SmartBrowserAutomation {
|
|
|
90
117
|
const aiAction = inputData?.action;
|
|
91
118
|
// Determine tool name: prefer AI input, fallback to manual parameter
|
|
92
119
|
let toolName;
|
|
93
|
-
|
|
120
|
+
// Check if Tool_Parameters has browser_action field
|
|
121
|
+
if (aiToolParams && typeof aiToolParams === 'object' && 'browser_action' in aiToolParams) {
|
|
122
|
+
const browserAction = aiToolParams.browser_action;
|
|
123
|
+
toolName = `browser_${browserAction}`;
|
|
124
|
+
}
|
|
125
|
+
else if (aiAction && typeof aiAction === 'string' && aiAction !== 'sendMessage') {
|
|
94
126
|
// AI Agent sent action like "click", "open", etc - map to browser tool
|
|
95
127
|
toolName = aiAction === 'open' ? 'browser_navigate' : `browser_${aiAction}`;
|
|
96
128
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-smart-browser-automation",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "n8n node for AI-driven browser automation using MCP",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|
|
@@ -57,4 +57,4 @@
|
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@modelcontextprotocol/sdk": "^1.17.0"
|
|
59
59
|
}
|
|
60
|
-
}
|
|
60
|
+
}
|