n8n-nodes-smart-browser-automation 1.6.18 → 1.6.20
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,6 +1,5 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type INodeType, type INodeTypeDescription, type ISupplyDataFunctions, type SupplyData } from 'n8n-workflow';
|
|
2
2
|
export declare class SmartBrowserAutomationTools implements INodeType {
|
|
3
3
|
description: INodeTypeDescription;
|
|
4
|
-
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
4
|
supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData>;
|
|
6
5
|
}
|
|
@@ -86,8 +86,8 @@ class SmartBrowserAutomationTools {
|
|
|
86
86
|
name: 'Browser Automation Tools',
|
|
87
87
|
},
|
|
88
88
|
inputs: [],
|
|
89
|
-
outputs: [n8n_workflow_1.NodeConnectionTypes.AiTool
|
|
90
|
-
outputNames: ['Tools'
|
|
89
|
+
outputs: [n8n_workflow_1.NodeConnectionTypes.AiTool],
|
|
90
|
+
outputNames: ['Tools'],
|
|
91
91
|
icon: 'file:smartBrowserAutomation.svg',
|
|
92
92
|
credentials: [
|
|
93
93
|
{
|
|
@@ -106,44 +106,6 @@ class SmartBrowserAutomationTools {
|
|
|
106
106
|
},
|
|
107
107
|
],
|
|
108
108
|
};
|
|
109
|
-
async execute() {
|
|
110
|
-
const node = this.getNode();
|
|
111
|
-
const sessionManager = BrowserSessionManager_1.default.getInstance();
|
|
112
|
-
const itemIndex = 0;
|
|
113
|
-
try {
|
|
114
|
-
const credentials = await this.getCredentials('smartBrowserAutomationApi');
|
|
115
|
-
const cdpOverride = this.getNodeParameter('cdpOverride', itemIndex, '');
|
|
116
|
-
const useCDP = credentials.browserMode === 'cdp';
|
|
117
|
-
const cdpUrl = (cdpOverride || credentials.cdpEndpoint || '').trim();
|
|
118
|
-
await sessionManager.initialize(credentials.mcpEndpoint, useCDP, useCDP ? cdpUrl : undefined);
|
|
119
|
-
const mcpTools = await sessionManager.listTools();
|
|
120
|
-
const debugJson = {
|
|
121
|
-
mcpEndpoint: credentials.mcpEndpoint,
|
|
122
|
-
browserMode: credentials.browserMode,
|
|
123
|
-
useCDP,
|
|
124
|
-
cdpEndpoint: useCDP ? cdpUrl : undefined,
|
|
125
|
-
toolCount: mcpTools.length,
|
|
126
|
-
tools: mcpTools.map((t) => ({
|
|
127
|
-
name: t.name,
|
|
128
|
-
description: t.description ?? '',
|
|
129
|
-
inputSchema: t.inputSchema ?? undefined,
|
|
130
|
-
})),
|
|
131
|
-
};
|
|
132
|
-
return [[], [{ json: debugJson }]];
|
|
133
|
-
}
|
|
134
|
-
catch (error) {
|
|
135
|
-
const err = error;
|
|
136
|
-
const debugJson = {
|
|
137
|
-
error: true,
|
|
138
|
-
message: err?.message ? String(err.message) : String(err),
|
|
139
|
-
code: err?.code ? String(err.code) : undefined,
|
|
140
|
-
};
|
|
141
|
-
throw new n8n_workflow_1.NodeOperationError(node, debugJson.message, { itemIndex, description: JSON.stringify(debugJson) });
|
|
142
|
-
}
|
|
143
|
-
finally {
|
|
144
|
-
await sessionManager.close();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
109
|
async supplyData(itemIndex) {
|
|
148
110
|
const node = this.getNode();
|
|
149
111
|
const credentials = await this.getCredentials('smartBrowserAutomationApi');
|
|
@@ -151,14 +113,21 @@ class SmartBrowserAutomationTools {
|
|
|
151
113
|
const cdpOverride = this.getNodeParameter('cdpOverride', itemIndex, '');
|
|
152
114
|
const useCDP = credentials.browserMode === 'cdp';
|
|
153
115
|
const cdpUrl = (cdpOverride || credentials.cdpEndpoint || '').trim();
|
|
116
|
+
const mcpEndpoint = (credentials.mcpEndpoint || '').trim();
|
|
117
|
+
if (!mcpEndpoint) {
|
|
118
|
+
throw new n8n_workflow_1.NodeOperationError(node, 'MCP Endpoint is required in credentials', {
|
|
119
|
+
itemIndex,
|
|
120
|
+
description: 'Please configure the MCP Endpoint in your Smart Browser Automation credentials',
|
|
121
|
+
});
|
|
122
|
+
}
|
|
154
123
|
try {
|
|
155
|
-
await sessionManager.initialize(
|
|
124
|
+
await sessionManager.initialize(mcpEndpoint, useCDP, useCDP ? cdpUrl : undefined);
|
|
156
125
|
}
|
|
157
126
|
catch (error) {
|
|
158
127
|
throw new n8n_workflow_1.NodeOperationError(node, `Failed to connect to MCP server: ${error.message}`, {
|
|
159
128
|
itemIndex,
|
|
160
129
|
description: JSON.stringify({
|
|
161
|
-
mcpEndpoint
|
|
130
|
+
mcpEndpoint,
|
|
162
131
|
browserMode: credentials.browserMode,
|
|
163
132
|
useCDP,
|
|
164
133
|
cdpEndpoint: useCDP ? cdpUrl : undefined,
|
|
@@ -218,7 +187,10 @@ class SmartBrowserAutomationTools {
|
|
|
218
187
|
}
|
|
219
188
|
return {
|
|
220
189
|
response: new SmartBrowserAutomationToolkit(tools),
|
|
221
|
-
closeFunction: async () =>
|
|
190
|
+
closeFunction: async () => {
|
|
191
|
+
// Called by n8n when Agent execution finishes
|
|
192
|
+
await sessionManager.close();
|
|
193
|
+
},
|
|
222
194
|
};
|
|
223
195
|
}
|
|
224
196
|
}
|