n8n-nodes-smart-browser-automation 1.6.18 → 1.6.19
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');
|
|
@@ -218,7 +180,10 @@ class SmartBrowserAutomationTools {
|
|
|
218
180
|
}
|
|
219
181
|
return {
|
|
220
182
|
response: new SmartBrowserAutomationToolkit(tools),
|
|
221
|
-
closeFunction: async () =>
|
|
183
|
+
closeFunction: async () => {
|
|
184
|
+
// Called by n8n when Agent execution finishes
|
|
185
|
+
await sessionManager.close();
|
|
186
|
+
},
|
|
222
187
|
};
|
|
223
188
|
}
|
|
224
189
|
}
|