@mendable/n8n-nodes-firecrawl 1.0.6 → 1.2.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.
Files changed (87) hide show
  1. package/README.md +72 -8
  2. package/dist/nodes/Firecrawl/Firecrawl.node.d.ts +0 -3
  3. package/dist/nodes/Firecrawl/Firecrawl.node.js +2 -1
  4. package/dist/nodes/Firecrawl/Firecrawl.node.js.map +1 -1
  5. package/dist/nodes/Firecrawl/api/agent/index.d.ts +5 -0
  6. package/dist/nodes/Firecrawl/api/agent/index.js +364 -0
  7. package/dist/nodes/Firecrawl/api/agent/index.js.map +1 -0
  8. package/dist/nodes/Firecrawl/api/agentAsync/index.d.ts +5 -0
  9. package/dist/nodes/Firecrawl/api/agentAsync/index.js +262 -0
  10. package/dist/nodes/Firecrawl/api/agentAsync/index.js.map +1 -0
  11. package/dist/nodes/Firecrawl/api/batchScrape/index.d.ts +2 -1
  12. package/dist/nodes/Firecrawl/api/batchScrape/index.js +56 -7
  13. package/dist/nodes/Firecrawl/api/batchScrape/index.js.map +1 -1
  14. package/dist/nodes/Firecrawl/api/batchScrapeErrors/index.d.ts +1 -0
  15. package/dist/nodes/Firecrawl/api/batchScrapeErrors/index.js +4 -3
  16. package/dist/nodes/Firecrawl/api/batchScrapeErrors/index.js.map +1 -1
  17. package/dist/nodes/Firecrawl/api/batchScrapeStatus/index.d.ts +1 -0
  18. package/dist/nodes/Firecrawl/api/batchScrapeStatus/index.js +4 -3
  19. package/dist/nodes/Firecrawl/api/batchScrapeStatus/index.js.map +1 -1
  20. package/dist/nodes/Firecrawl/api/cancelBatchScrape/index.d.ts +1 -0
  21. package/dist/nodes/Firecrawl/api/cancelBatchScrape/index.js +4 -3
  22. package/dist/nodes/Firecrawl/api/cancelBatchScrape/index.js.map +1 -1
  23. package/dist/nodes/Firecrawl/api/cancelCrawl/index.d.ts +1 -0
  24. package/dist/nodes/Firecrawl/api/cancelCrawl/index.js +4 -3
  25. package/dist/nodes/Firecrawl/api/cancelCrawl/index.js.map +1 -1
  26. package/dist/nodes/Firecrawl/api/common.d.ts +7 -5
  27. package/dist/nodes/Firecrawl/api/common.js +180 -60
  28. package/dist/nodes/Firecrawl/api/common.js.map +1 -1
  29. package/dist/nodes/Firecrawl/api/crawl/index.d.ts +2 -1
  30. package/dist/nodes/Firecrawl/api/crawl/index.js +24 -23
  31. package/dist/nodes/Firecrawl/api/crawl/index.js.map +1 -1
  32. package/dist/nodes/Firecrawl/api/crawlActive/index.d.ts +1 -0
  33. package/dist/nodes/Firecrawl/api/crawlActive/index.js +3 -2
  34. package/dist/nodes/Firecrawl/api/crawlActive/index.js.map +1 -1
  35. package/dist/nodes/Firecrawl/api/crawlParamsPreview/index.d.ts +1 -0
  36. package/dist/nodes/Firecrawl/api/crawlParamsPreview/index.js +4 -3
  37. package/dist/nodes/Firecrawl/api/crawlParamsPreview/index.js.map +1 -1
  38. package/dist/nodes/Firecrawl/api/creditUsageHistorical/index.d.ts +1 -0
  39. package/dist/nodes/Firecrawl/api/creditUsageHistorical/index.js +3 -2
  40. package/dist/nodes/Firecrawl/api/creditUsageHistorical/index.js.map +1 -1
  41. package/dist/nodes/Firecrawl/api/extract/index.d.ts +1 -0
  42. package/dist/nodes/Firecrawl/api/extract/index.js +20 -19
  43. package/dist/nodes/Firecrawl/api/extract/index.js.map +1 -1
  44. package/dist/nodes/Firecrawl/api/getAgentStatus/index.d.ts +5 -0
  45. package/dist/nodes/Firecrawl/api/getAgentStatus/index.js +52 -0
  46. package/dist/nodes/Firecrawl/api/getAgentStatus/index.js.map +1 -0
  47. package/dist/nodes/Firecrawl/api/getCrawlErrors/index.d.ts +1 -0
  48. package/dist/nodes/Firecrawl/api/getCrawlErrors/index.js +4 -3
  49. package/dist/nodes/Firecrawl/api/getCrawlErrors/index.js.map +1 -1
  50. package/dist/nodes/Firecrawl/api/getCrawlStatus/index.d.ts +1 -0
  51. package/dist/nodes/Firecrawl/api/getCrawlStatus/index.js +4 -3
  52. package/dist/nodes/Firecrawl/api/getCrawlStatus/index.js.map +1 -1
  53. package/dist/nodes/Firecrawl/api/getExtractStatus/index.d.ts +1 -0
  54. package/dist/nodes/Firecrawl/api/getExtractStatus/index.js +4 -3
  55. package/dist/nodes/Firecrawl/api/getExtractStatus/index.js.map +1 -1
  56. package/dist/nodes/Firecrawl/api/index.d.ts +36 -17
  57. package/dist/nodes/Firecrawl/api/index.js +171 -54
  58. package/dist/nodes/Firecrawl/api/index.js.map +1 -1
  59. package/dist/nodes/Firecrawl/api/map/index.d.ts +2 -1
  60. package/dist/nodes/Firecrawl/api/map/index.js +15 -14
  61. package/dist/nodes/Firecrawl/api/map/index.js.map +1 -1
  62. package/dist/nodes/Firecrawl/api/scrape/index.d.ts +2 -1
  63. package/dist/nodes/Firecrawl/api/scrape/index.js +56 -7
  64. package/dist/nodes/Firecrawl/api/scrape/index.js.map +1 -1
  65. package/dist/nodes/Firecrawl/api/search/index.d.ts +2 -1
  66. package/dist/nodes/Firecrawl/api/search/index.js +13 -9
  67. package/dist/nodes/Firecrawl/api/search/index.js.map +1 -1
  68. package/dist/nodes/Firecrawl/api/teamCreditUsage/index.d.ts +1 -0
  69. package/dist/nodes/Firecrawl/api/teamCreditUsage/index.js +3 -2
  70. package/dist/nodes/Firecrawl/api/teamCreditUsage/index.js.map +1 -1
  71. package/dist/nodes/Firecrawl/api/teamQueueStatus/index.d.ts +1 -0
  72. package/dist/nodes/Firecrawl/api/teamQueueStatus/index.js +3 -2
  73. package/dist/nodes/Firecrawl/api/teamQueueStatus/index.js.map +1 -1
  74. package/dist/nodes/Firecrawl/api/teamTokenUsage/index.d.ts +1 -0
  75. package/dist/nodes/Firecrawl/api/teamTokenUsage/index.js +3 -2
  76. package/dist/nodes/Firecrawl/api/teamTokenUsage/index.js.map +1 -1
  77. package/dist/nodes/Firecrawl/api/teamTokenUsageHistorical/index.d.ts +1 -0
  78. package/dist/nodes/Firecrawl/api/teamTokenUsageHistorical/index.js +3 -2
  79. package/dist/nodes/Firecrawl/api/teamTokenUsageHistorical/index.js.map +1 -1
  80. package/dist/nodes/Firecrawl/methods.d.ts +0 -3
  81. package/dist/nodes/Firecrawl/methods.js +17 -2
  82. package/dist/nodes/Firecrawl/methods.js.map +1 -1
  83. package/dist/nodes/Firecrawl/properties.js +40 -63
  84. package/dist/nodes/Firecrawl/properties.js.map +1 -1
  85. package/dist/package.json +3 -3
  86. package/dist/tsconfig.tsbuildinfo +1 -1
  87. package/package.json +3 -3
package/README.md CHANGED
@@ -6,11 +6,12 @@ This is an n8n community node. It lets you use **[Firecrawl](https://firecrawl.d
6
6
 
7
7
  [n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/reference/license/) workflow automation platform.
8
8
 
9
- [Installation](#installation)
10
- [Operations](#operations)
11
- [Credentials](#credentials)
12
- [Compatibility](#compatibility)
13
- [Resources](#resources)
9
+ [Installation](#installation)
10
+ [Operations](#operations)
11
+ [AI Agent Tool Usage](#ai-agent-tool-usage)
12
+ [Credentials](#credentials)
13
+ [Compatibility](#compatibility)
14
+ [Resources](#resources)
14
15
  [Version history](#version-history)
15
16
 
16
17
  ## Installation
@@ -76,7 +77,60 @@ The **Firecrawl** node supports the following operations:
76
77
  - Get historical token usage for your team
77
78
 
78
79
  ### Team Queue Status
79
- - Get your teams current queue load (waiting, active, max concurrency)
80
+ - Get your team's current queue load (waiting, active, max concurrency)
81
+
82
+ ## AI Agent Tool Usage
83
+
84
+ This node can be used as a tool with n8n's AI Agent node, allowing AI agents to scrape, crawl, and extract data from websites dynamically.
85
+
86
+ ### Requirements
87
+
88
+ - **n8n version 1.79.0 or higher** is required for AI tool support
89
+ - Set the environment variable `N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true` to enable community nodes as AI tools
90
+
91
+ ### Docker Configuration
92
+
93
+ ```yaml
94
+ version: '3'
95
+ services:
96
+ n8n:
97
+ image: n8nio/n8n
98
+ environment:
99
+ - N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true
100
+ ports:
101
+ - "5678:5678"
102
+ volumes:
103
+ - ~/.n8n:/home/node/.n8n
104
+ ```
105
+
106
+ ### Using with AI Agents
107
+
108
+ 1. Add the **AI Agent** node to your workflow
109
+ 2. Connect the **Firecrawl** node as a tool input to the AI Agent
110
+ 3. The AI agent can now dynamically decide when and how to use Firecrawl operations
111
+
112
+ ### Dynamic Parameters with $fromAI()
113
+
114
+ When using Firecrawl as an AI tool, you can let the AI agent decide parameter values dynamically using the `$fromAI()` function. Click the "Let the model define this parameter" button next to any field to enable this feature.
115
+
116
+ Example expressions:
117
+ ```javascript
118
+ // Let AI decide the URL to scrape
119
+ {{ $fromAI("url", "The URL to scrape", "string") }}
120
+
121
+ // Let AI decide the search query
122
+ {{ $fromAI("query", "Search query for finding relevant pages", "string") }}
123
+
124
+ // Let AI decide whether to include subdomains
125
+ {{ $fromAI("includeSubdomains", "Whether to include subdomains", "boolean", false) }}
126
+ ```
127
+
128
+ ### Best Practices for AI Tool Usage
129
+
130
+ 1. **Use clear operation names**: The AI agent uses operation descriptions to decide when to use each tool
131
+ 2. **Provide context in prompts**: When using the Extract operation, provide clear prompts to guide data extraction
132
+ 3. **Set reasonable limits**: Configure default limits to prevent excessive API usage
133
+ 4. **Use the Map operation first**: For unknown sites, use Map to discover URLs before scraping
80
134
 
81
135
  ## Credentials
82
136
 
@@ -91,10 +145,12 @@ To use the Firecrawl node, you need to:
91
145
 
92
146
  ## Compatibility
93
147
 
94
- - Minimum n8n version: 1.0.0
95
- - Tested against n8n versions: 1.0.0, 1.1.0, 1.2.0
148
+ - **Minimum n8n version: 1.79.0** (required for AI tool support)
149
+ - Tested against n8n versions: 1.79.0+
96
150
  - Node.js version: 18 or higher
97
151
 
152
+ > **Note**: If you don't need AI tool support, earlier versions of n8n may work, but 1.79.0+ is recommended.
153
+
98
154
  ## Resources
99
155
 
100
156
  * [n8n community nodes documentation](https://docs.n8n.io/integrations/community-nodes/)
@@ -103,6 +159,14 @@ To use the Firecrawl node, you need to:
103
159
 
104
160
  ## Version history
105
161
 
162
+ ### 1.1.0
163
+ - **AI Agent Tool Support**: Node can now be used as a tool with n8n's AI Agent node
164
+ - Added `usableAsTool: true` to enable tool mode
165
+ - Enhanced all field descriptions for better AI context understanding
166
+ - Supports `$fromAI()` function for dynamic parameter values
167
+ - Updated minimum n8n version requirement to 1.79.0
168
+ - Improved operation descriptions for clearer AI agent decision making
169
+
106
170
  ### 1.0.6
107
171
  - Add support for additional Firecrawl endpoints:
108
172
  - Batch Scrape (start/status/errors)
@@ -14,9 +14,6 @@ export declare class Firecrawl implements INodeType {
14
14
  resourceMapping?: {
15
15
  [functionName: string]: (this: import("n8n-workflow").ILoadOptionsFunctions) => Promise<import("n8n-workflow").ResourceMapperFields>;
16
16
  } | undefined;
17
- localResourceMapping?: {
18
- [functionName: string]: (this: import("n8n-workflow").ILocalLoadOptionsFunctions) => Promise<import("n8n-workflow").ResourceMapperFields>;
19
- } | undefined;
20
17
  actionHandler?: {
21
18
  [functionName: string]: (this: import("n8n-workflow").ILoadOptionsFunctions, payload: string | import("n8n-workflow").IDataObject | undefined) => Promise<import("n8n-workflow").NodeParameterValueType>;
22
19
  } | undefined;
@@ -12,10 +12,11 @@ class Firecrawl {
12
12
  group: ['transform'],
13
13
  version: 1,
14
14
  subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
15
- description: 'Get data from Firecrawl API',
15
+ description: 'Scrape, crawl, map, search, and extract structured data from websites using Firecrawl API',
16
16
  defaults: {
17
17
  name: 'Firecrawl',
18
18
  },
19
+ usableAsTool: true,
19
20
  inputs: `={{["main"]}}`,
20
21
  outputs: `={{["main"]}}`,
21
22
  credentials: [
@@ -1 +1 @@
1
- {"version":3,"file":"Firecrawl.node.js","sourceRoot":"","sources":["../../../nodes/Firecrawl/Firecrawl.node.ts"],"names":[],"mappings":";;;AACA,uCAAuC;AACvC,6CAA6C;AAK7C,MAAa,SAAS;IAAtB;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,WAAW;YACxB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,oBAAoB;YAC1B,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,8DAA8D;YACxE,WAAW,EAAE,6BAA6B;YAC1C,QAAQ,EAAE;gBACT,IAAI,EAAE,WAAW;aACjB;YACD,MAAM,EAAE,eAAe;YACvB,OAAO,EAAE,eAAe;YACxB,WAAW,EAAE;gBACZ;oBACC,IAAI,EAAE,cAAc;oBACpB,QAAQ,EAAE,IAAI;iBACd;aACD;YACD,eAAe,EAAE;gBAChB,OAAO,EAAE,+DAA+D;gBACxE,OAAO,EAAE;oBACR,MAAM,EAAE,kBAAkB;oBAC1B,cAAc,EAAE,kBAAkB;iBAClC;gBACD,IAAI,EAAE;oBACL,WAAW,EAAE,KAAK;iBAClB;aACD;YACD,UAAU,EAAE,0BAAa;SACzB,CAAC;QAEF,YAAO,GAAG,oBAAU,CAAC;IACtB,CAAC;CAAA;AAlCD,8BAkCC"}
1
+ {"version":3,"file":"Firecrawl.node.js","sourceRoot":"","sources":["../../../nodes/Firecrawl/Firecrawl.node.ts"],"names":[],"mappings":";;;AACA,uCAAuC;AACvC,6CAA6C;AAK7C,MAAa,SAAS;IAAtB;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,WAAW;YACxB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,oBAAoB;YAC1B,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,8DAA8D;YACxE,WAAW,EAAE,2FAA2F;YACxG,QAAQ,EAAE;gBACT,IAAI,EAAE,WAAW;aACjB;YACD,YAAY,EAAE,IAAI;YAClB,MAAM,EAAE,eAAe;YACvB,OAAO,EAAE,eAAe;YACxB,WAAW,EAAE;gBACZ;oBACC,IAAI,EAAE,cAAc;oBACpB,QAAQ,EAAE,IAAI;iBACd;aACD;YACD,eAAe,EAAE;gBAChB,OAAO,EAAE,+DAA+D;gBACxE,OAAO,EAAE;oBACR,MAAM,EAAE,kBAAkB;oBAC1B,cAAc,EAAE,kBAAkB;iBAClC;gBACD,IAAI,EAAE;oBACL,WAAW,EAAE,KAAK;iBAClB;aACD;YACD,UAAU,EAAE,0BAAa;SACzB,CAAC;QAEF,YAAO,GAAG,oBAAU,CAAC;IACtB,CAAC;CAAA;AAnCD,8BAmCC"}
@@ -0,0 +1,5 @@
1
+ import { INodeProperties } from 'n8n-workflow';
2
+ export declare const operationName = "agent";
3
+ export declare const resourceName = "Agent";
4
+ declare const options: import("n8n-workflow").INodePropertyOptions, properties: INodeProperties[];
5
+ export { options, properties };
@@ -0,0 +1,364 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.properties = exports.options = exports.resourceName = exports.operationName = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const common_1 = require("../common");
6
+ const name = 'agent';
7
+ const displayName = 'Agent - AI-powered web data extraction (waits for completion)';
8
+ exports.operationName = 'agent';
9
+ exports.resourceName = 'Agent';
10
+ const DEFAULT_POLL_INTERVAL_MS = 2000;
11
+ const DEFAULT_MAX_WAIT_TIME_SECONDS = 300;
12
+ function createPromptProperty() {
13
+ return {
14
+ displayName: 'Prompt',
15
+ name: 'prompt',
16
+ type: 'string',
17
+ typeOptions: {
18
+ rows: 4,
19
+ },
20
+ required: true,
21
+ default: '',
22
+ description: 'Natural language description of the data you want to extract (max 10,000 characters). Be specific about what data you need. Examples: "Find the founders of Firecrawl", "Extract pricing information from this page", "Compare features between these products".',
23
+ placeholder: 'e.g., Find the founders of Firecrawl and their roles',
24
+ routing: {
25
+ request: {
26
+ body: {
27
+ prompt: '={{ $value }}',
28
+ },
29
+ },
30
+ },
31
+ displayOptions: {
32
+ hide: {
33
+ useCustomBody: [true],
34
+ },
35
+ show: {
36
+ resource: [exports.resourceName],
37
+ operation: [exports.operationName],
38
+ },
39
+ },
40
+ };
41
+ }
42
+ function createSpecifyUrlsProperty() {
43
+ return {
44
+ displayName: 'Specify URLs',
45
+ name: 'specifyUrls',
46
+ type: 'boolean',
47
+ default: false,
48
+ description: 'Whether to specify URLs for the agent to focus on. If disabled, the agent will autonomously search and navigate the web to find your data.',
49
+ displayOptions: {
50
+ hide: {
51
+ useCustomBody: [true],
52
+ },
53
+ show: {
54
+ resource: [exports.resourceName],
55
+ operation: [exports.operationName],
56
+ },
57
+ },
58
+ };
59
+ }
60
+ function createUrlsProperty() {
61
+ return {
62
+ displayName: 'URLs',
63
+ name: 'urls',
64
+ type: 'string',
65
+ typeOptions: {
66
+ rows: 4,
67
+ },
68
+ default: '',
69
+ description: 'URLs to focus the agent on specific pages. Accepts multiple formats: a single URL, multiple URLs separated by commas or newlines, or a JSON array like ["url1", "url2"].',
70
+ placeholder: 'https://example.com/page1\nhttps://example.com/page2',
71
+ routing: {
72
+ request: {
73
+ body: {
74
+ urls: '={{ $value }}',
75
+ },
76
+ },
77
+ send: {
78
+ preSend: [
79
+ async function (requestOptions) {
80
+ if (typeof requestOptions.body !== 'object' || !requestOptions.body) {
81
+ return requestOptions;
82
+ }
83
+ const body = requestOptions.body;
84
+ if (body.urls !== undefined) {
85
+ const rawValue = body.urls;
86
+ if (!rawValue || (typeof rawValue === 'string' && !rawValue.trim())) {
87
+ delete body.urls;
88
+ return requestOptions;
89
+ }
90
+ const urlsArray = (0, common_1.extractUrls)(rawValue);
91
+ const uniqueUrls = [...new Set(urlsArray)].filter(Boolean);
92
+ if (uniqueUrls.length === 0) {
93
+ delete body.urls;
94
+ }
95
+ else {
96
+ body.urls = uniqueUrls;
97
+ }
98
+ }
99
+ return requestOptions;
100
+ },
101
+ ],
102
+ },
103
+ },
104
+ displayOptions: {
105
+ hide: {
106
+ useCustomBody: [true],
107
+ },
108
+ show: {
109
+ resource: [exports.resourceName],
110
+ operation: [exports.operationName],
111
+ specifyUrls: [true],
112
+ },
113
+ },
114
+ };
115
+ }
116
+ function createSchemaTypeProperty() {
117
+ return {
118
+ displayName: 'Schema Type',
119
+ name: 'schemaType',
120
+ type: 'options',
121
+ default: 'none',
122
+ description: 'Optionally define a schema for the extracted data structure',
123
+ options: [
124
+ {
125
+ name: 'None',
126
+ value: 'none',
127
+ description: 'No schema - let the agent determine the output structure',
128
+ },
129
+ {
130
+ name: 'Generate From JSON Example',
131
+ value: 'fromExample',
132
+ description: 'Generate a schema from an example JSON object',
133
+ },
134
+ {
135
+ name: 'Define Using JSON Schema',
136
+ value: 'manual',
137
+ description: 'Define the JSON schema manually',
138
+ },
139
+ ],
140
+ displayOptions: {
141
+ hide: {
142
+ useCustomBody: [true],
143
+ },
144
+ show: {
145
+ resource: [exports.resourceName],
146
+ operation: [exports.operationName],
147
+ },
148
+ },
149
+ };
150
+ }
151
+ function createJsonExampleProperty() {
152
+ return {
153
+ displayName: 'JSON Example',
154
+ name: 'jsonExample',
155
+ type: 'json',
156
+ default: '{\n "founders": [\n {\n "name": "John Doe",\n "role": "CEO"\n }\n ]\n}',
157
+ description: 'Provide an example of the JSON structure you want to extract. The schema will be automatically generated from this example.',
158
+ routing: {
159
+ request: {
160
+ body: {
161
+ jsonExample: '={{ $value }}',
162
+ },
163
+ },
164
+ send: {
165
+ preSend: [
166
+ async function (requestOptions) {
167
+ if (typeof requestOptions.body !== 'object' || !requestOptions.body) {
168
+ return requestOptions;
169
+ }
170
+ const body = requestOptions.body;
171
+ if (body.jsonExample !== undefined) {
172
+ try {
173
+ let example;
174
+ if (typeof body.jsonExample === 'string') {
175
+ const trimmed = body.jsonExample.trim();
176
+ if (!trimmed) {
177
+ delete body.jsonExample;
178
+ return requestOptions;
179
+ }
180
+ example = JSON.parse(trimmed);
181
+ }
182
+ else {
183
+ example = body.jsonExample;
184
+ }
185
+ body.schema = (0, common_1.convertToSchema)(example);
186
+ delete body.jsonExample;
187
+ }
188
+ catch (error) {
189
+ throw new Error('Invalid JSON example. Please provide valid JSON.');
190
+ }
191
+ }
192
+ return requestOptions;
193
+ },
194
+ ],
195
+ },
196
+ },
197
+ displayOptions: {
198
+ hide: {
199
+ useCustomBody: [true],
200
+ },
201
+ show: {
202
+ resource: [exports.resourceName],
203
+ operation: [exports.operationName],
204
+ schemaType: ['fromExample'],
205
+ },
206
+ },
207
+ };
208
+ }
209
+ function createSchemaProperty() {
210
+ return {
211
+ displayName: 'Schema',
212
+ name: 'schema',
213
+ type: 'json',
214
+ default: '{\n "type": "object",\n "properties": {\n "founders": {\n "type": "array",\n "items": {\n "type": "object",\n "properties": {\n "name": { "type": "string" },\n "role": { "type": "string" }\n }\n }\n }\n }\n}',
215
+ description: 'JSON Schema defining the structure of extracted data. Use JSON Schema format with type definitions. $refs syntax is currently not supported.',
216
+ routing: {
217
+ request: {
218
+ body: {
219
+ schema: '={{ JSON.parse($value) }}',
220
+ },
221
+ },
222
+ },
223
+ displayOptions: {
224
+ hide: {
225
+ useCustomBody: [true],
226
+ },
227
+ show: {
228
+ resource: [exports.resourceName],
229
+ operation: [exports.operationName],
230
+ schemaType: ['manual'],
231
+ },
232
+ },
233
+ };
234
+ }
235
+ function createMaxWaitTimeProperty() {
236
+ return {
237
+ displayName: 'Max Wait Time',
238
+ name: 'maxWaitTime',
239
+ type: 'number',
240
+ default: DEFAULT_MAX_WAIT_TIME_SECONDS,
241
+ description: 'Maximum time in seconds to wait for the agent to complete. If exceeded, the job ID will be returned so you can check status manually.',
242
+ typeOptions: {
243
+ minValue: 2,
244
+ maxValue: 600,
245
+ },
246
+ displayOptions: {
247
+ hide: {
248
+ useCustomBody: [true],
249
+ },
250
+ show: {
251
+ resource: [exports.resourceName],
252
+ operation: [exports.operationName],
253
+ },
254
+ },
255
+ };
256
+ }
257
+ function createAgentProperties() {
258
+ return [
259
+ (0, common_1.createOperationNotice)(exports.resourceName, name, 'POST'),
260
+ createPromptProperty(),
261
+ createSpecifyUrlsProperty(),
262
+ createUrlsProperty(),
263
+ createSchemaTypeProperty(),
264
+ createJsonExampleProperty(),
265
+ createSchemaProperty(),
266
+ createMaxWaitTimeProperty(),
267
+ ];
268
+ }
269
+ const { options, properties } = (0, common_1.buildApiProperties)(name, displayName, createAgentProperties());
270
+ exports.options = options;
271
+ exports.properties = properties;
272
+ options.routing = {
273
+ request: {
274
+ method: 'POST',
275
+ url: '=/agent',
276
+ },
277
+ output: {
278
+ postReceive: [
279
+ async function (items, response) {
280
+ const responseBody = response.body;
281
+ if (!responseBody.id) {
282
+ return items.map(() => ({
283
+ json: responseBody,
284
+ }));
285
+ }
286
+ const jobId = responseBody.id;
287
+ const credentials = await this.getCredentials('firecrawlApi');
288
+ const baseUrl = credentials.baseUrl || 'https://api.firecrawl.dev/v2';
289
+ const apiKey = credentials.apiKey;
290
+ const maxWaitTimeSeconds = this.getNodeParameter('maxWaitTime', DEFAULT_MAX_WAIT_TIME_SECONDS);
291
+ const maxWaitTimeMs = maxWaitTimeSeconds * 1000;
292
+ const startTime = Date.now();
293
+ let status = responseBody.status || 'processing';
294
+ const MAX_POLL_RETRIES = 3;
295
+ while (status === 'processing' || status === 'pending') {
296
+ if (Date.now() - startTime > maxWaitTimeMs) {
297
+ return [
298
+ {
299
+ json: {
300
+ success: false,
301
+ status: 'timeout',
302
+ error: `Agent job timed out after ${maxWaitTimeSeconds} seconds`,
303
+ jobId,
304
+ message: 'You can check the status manually using the "Get Agent Status" operation.',
305
+ },
306
+ },
307
+ ];
308
+ }
309
+ await (0, n8n_workflow_1.sleep)(DEFAULT_POLL_INTERVAL_MS);
310
+ let statusResponse;
311
+ let lastError;
312
+ for (let attempt = 0; attempt < MAX_POLL_RETRIES; attempt++) {
313
+ try {
314
+ statusResponse = await this.helpers.httpRequest({
315
+ method: 'GET',
316
+ url: `${baseUrl}/agent/${jobId}`,
317
+ headers: {
318
+ Authorization: `Bearer ${apiKey}`,
319
+ Accept: 'application/json',
320
+ },
321
+ json: true,
322
+ });
323
+ break;
324
+ }
325
+ catch (error) {
326
+ lastError = error;
327
+ if (attempt < MAX_POLL_RETRIES - 1) {
328
+ await (0, n8n_workflow_1.sleep)(DEFAULT_POLL_INTERVAL_MS * (attempt + 1));
329
+ }
330
+ }
331
+ }
332
+ if (!statusResponse) {
333
+ return [
334
+ {
335
+ json: {
336
+ success: false,
337
+ status: 'poll_failed',
338
+ error: `Failed to poll agent status after ${MAX_POLL_RETRIES} attempts`,
339
+ jobId,
340
+ lastError: (lastError === null || lastError === void 0 ? void 0 : lastError.message) || 'Unknown error',
341
+ message: 'You can check the status manually using the "Get Agent Status" operation.',
342
+ },
343
+ },
344
+ ];
345
+ }
346
+ status = statusResponse.status;
347
+ if (status === 'completed' || status === 'failed') {
348
+ return [
349
+ {
350
+ json: statusResponse,
351
+ },
352
+ ];
353
+ }
354
+ }
355
+ return [
356
+ {
357
+ json: responseBody,
358
+ },
359
+ ];
360
+ },
361
+ ],
362
+ },
363
+ };
364
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../nodes/Firecrawl/api/agent/index.ts"],"names":[],"mappings":";;;AAAA,+CAQsB;AACtB,sCAAoG;AAEpG,MAAM,IAAI,GAAG,OAAO,CAAC;AACrB,MAAM,WAAW,GAAG,+DAA+D,CAAC;AACvE,QAAA,aAAa,GAAG,OAAO,CAAC;AACxB,QAAA,YAAY,GAAG,OAAO,CAAC;AAGpC,MAAM,wBAAwB,GAAG,IAAI,CAAC;AACtC,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAM1C,SAAS,oBAAoB;IAC5B,OAAO;QACN,WAAW,EAAE,QAAQ;QACrB,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE;YACZ,IAAI,EAAE,CAAC;SACP;QACD,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,EAAE;QACX,WAAW,EACV,kQAAkQ;QACnQ,WAAW,EAAE,sDAAsD;QACnE,OAAO,EAAE;YACR,OAAO,EAAE;gBACR,IAAI,EAAE;oBACL,MAAM,EAAE,eAAe;iBACvB;aACD;SACD;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tD;yBACD;qBACD;oBAED,IAAI,CAAC,cAAc,EAAE;wBACpB,OAAO;4BACN;gCACC,IAAI,EAAE;oCACL,OAAO,EAAE,KAAK;oCACd,MAAM,EAAE,aAAa;oCACrB,KAAK,EAAE,qCAAqC,gBAAgB,WAAW;oCACvE,KAAK;oCACL,SAAS,EAAE,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,KAAI,eAAe;oCAChD,OAAO,EAAE,2EAA2E;iCACpF;6BACD;yBACD,CAAC;qBACF;oBAED,MAAM,GAAG,cAAc,CAAC,MAAgB,CAAC;oBAGzC,IAAI,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,QAAQ,EAAE;wBAClD,OAAO;4BACN;gCACC,IAAI,EAAE,cAA6B;6BACnC;yBACD,CAAC;qBACF;iBACD;gBAGD,OAAO;oBACN;wBACC,IAAI,EAAE,YAAY;qBAClB;iBACD,CAAC;YACH,CAAC;SACD;KACD;CACD,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { INodeProperties } from 'n8n-workflow';
2
+ export declare const operationName = "agentAsync";
3
+ export declare const resourceName = "Agent";
4
+ declare const options: import("n8n-workflow").INodePropertyOptions, properties: INodeProperties[];
5
+ export { options, properties };