firecrawl 1.18.2 → 1.18.5

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.
package/dist/index.cjs CHANGED
@@ -111,7 +111,7 @@ var FirecrawlApp = class {
111
111
  const response = await import_axios.default.post(
112
112
  this.apiUrl + `/v1/scrape`,
113
113
  jsonData,
114
- { headers }
114
+ { headers, timeout: params?.timeout !== void 0 ? params.timeout + 5e3 : void 0 }
115
115
  );
116
116
  if (response.status === 200) {
117
117
  const responseData = response.data;
@@ -742,7 +742,7 @@ var FirecrawlApp = class {
742
742
  * @returns The response from the POST request.
743
743
  */
744
744
  postRequest(url, data, headers) {
745
- return import_axios.default.post(url, data, { headers });
745
+ return import_axios.default.post(url, data, { headers, timeout: data?.timeout ? data.timeout + 5e3 : void 0 });
746
746
  }
747
747
  /**
748
748
  * Sends a GET request to the specified URL.
@@ -853,10 +853,12 @@ var FirecrawlApp = class {
853
853
  }
854
854
  /**
855
855
  * Initiates a deep research operation on a given topic and polls until completion.
856
+ * @param topic - The topic to research.
856
857
  * @param params - Parameters for the deep research operation.
858
+ * @param onActivity - Optional callback to receive activity updates in real-time.
857
859
  * @returns The final research results.
858
860
  */
859
- async __deepResearch(topic, params) {
861
+ async __deepResearch(topic, params, onActivity) {
860
862
  try {
861
863
  const response = await this.__asyncDeepResearch(topic, params);
862
864
  if (!response.success || "error" in response) {
@@ -867,11 +869,19 @@ var FirecrawlApp = class {
867
869
  }
868
870
  const jobId = response.id;
869
871
  let researchStatus;
872
+ let lastActivityCount = 0;
870
873
  while (true) {
871
874
  researchStatus = await this.__checkDeepResearchStatus(jobId);
872
875
  if ("error" in researchStatus && !researchStatus.success) {
873
876
  return researchStatus;
874
877
  }
878
+ if (onActivity && researchStatus.activities) {
879
+ const newActivities = researchStatus.activities.slice(lastActivityCount);
880
+ for (const activity of newActivities) {
881
+ onActivity(activity);
882
+ }
883
+ lastActivityCount = researchStatus.activities.length;
884
+ }
875
885
  if (researchStatus.status === "completed") {
876
886
  return researchStatus;
877
887
  }
package/dist/index.d.cts CHANGED
@@ -334,6 +334,11 @@ interface DeepResearchParams {
334
334
  * @default 270
335
335
  */
336
336
  timeLimit?: number;
337
+ /**
338
+ * Maximum number of URLs to analyze (1-1000)
339
+ * @default 20
340
+ */
341
+ maxUrls?: number;
337
342
  /**
338
343
  * Experimental flag for streaming steps
339
344
  */
@@ -595,10 +600,18 @@ declare class FirecrawlApp {
595
600
  handleError(response: AxiosResponse, action: string): void;
596
601
  /**
597
602
  * Initiates a deep research operation on a given topic and polls until completion.
603
+ * @param topic - The topic to research.
598
604
  * @param params - Parameters for the deep research operation.
605
+ * @param onActivity - Optional callback to receive activity updates in real-time.
599
606
  * @returns The final research results.
600
607
  */
601
- __deepResearch(topic: string, params: DeepResearchParams): Promise<DeepResearchStatusResponse | ErrorResponse>;
608
+ __deepResearch(topic: string, params: DeepResearchParams, onActivity?: (activity: {
609
+ type: string;
610
+ status: string;
611
+ message: string;
612
+ timestamp: string;
613
+ depth: number;
614
+ }) => void): Promise<DeepResearchStatusResponse | ErrorResponse>;
602
615
  /**
603
616
  * Initiates a deep research operation on a given topic without polling.
604
617
  * @param params - Parameters for the deep research operation.
package/dist/index.d.ts CHANGED
@@ -334,6 +334,11 @@ interface DeepResearchParams {
334
334
  * @default 270
335
335
  */
336
336
  timeLimit?: number;
337
+ /**
338
+ * Maximum number of URLs to analyze (1-1000)
339
+ * @default 20
340
+ */
341
+ maxUrls?: number;
337
342
  /**
338
343
  * Experimental flag for streaming steps
339
344
  */
@@ -595,10 +600,18 @@ declare class FirecrawlApp {
595
600
  handleError(response: AxiosResponse, action: string): void;
596
601
  /**
597
602
  * Initiates a deep research operation on a given topic and polls until completion.
603
+ * @param topic - The topic to research.
598
604
  * @param params - Parameters for the deep research operation.
605
+ * @param onActivity - Optional callback to receive activity updates in real-time.
599
606
  * @returns The final research results.
600
607
  */
601
- __deepResearch(topic: string, params: DeepResearchParams): Promise<DeepResearchStatusResponse | ErrorResponse>;
608
+ __deepResearch(topic: string, params: DeepResearchParams, onActivity?: (activity: {
609
+ type: string;
610
+ status: string;
611
+ message: string;
612
+ timestamp: string;
613
+ depth: number;
614
+ }) => void): Promise<DeepResearchStatusResponse | ErrorResponse>;
602
615
  /**
603
616
  * Initiates a deep research operation on a given topic without polling.
604
617
  * @param params - Parameters for the deep research operation.
package/dist/index.js CHANGED
@@ -75,7 +75,7 @@ var FirecrawlApp = class {
75
75
  const response = await axios.post(
76
76
  this.apiUrl + `/v1/scrape`,
77
77
  jsonData,
78
- { headers }
78
+ { headers, timeout: params?.timeout !== void 0 ? params.timeout + 5e3 : void 0 }
79
79
  );
80
80
  if (response.status === 200) {
81
81
  const responseData = response.data;
@@ -706,7 +706,7 @@ var FirecrawlApp = class {
706
706
  * @returns The response from the POST request.
707
707
  */
708
708
  postRequest(url, data, headers) {
709
- return axios.post(url, data, { headers });
709
+ return axios.post(url, data, { headers, timeout: data?.timeout ? data.timeout + 5e3 : void 0 });
710
710
  }
711
711
  /**
712
712
  * Sends a GET request to the specified URL.
@@ -817,10 +817,12 @@ var FirecrawlApp = class {
817
817
  }
818
818
  /**
819
819
  * Initiates a deep research operation on a given topic and polls until completion.
820
+ * @param topic - The topic to research.
820
821
  * @param params - Parameters for the deep research operation.
822
+ * @param onActivity - Optional callback to receive activity updates in real-time.
821
823
  * @returns The final research results.
822
824
  */
823
- async __deepResearch(topic, params) {
825
+ async __deepResearch(topic, params, onActivity) {
824
826
  try {
825
827
  const response = await this.__asyncDeepResearch(topic, params);
826
828
  if (!response.success || "error" in response) {
@@ -831,11 +833,19 @@ var FirecrawlApp = class {
831
833
  }
832
834
  const jobId = response.id;
833
835
  let researchStatus;
836
+ let lastActivityCount = 0;
834
837
  while (true) {
835
838
  researchStatus = await this.__checkDeepResearchStatus(jobId);
836
839
  if ("error" in researchStatus && !researchStatus.success) {
837
840
  return researchStatus;
838
841
  }
842
+ if (onActivity && researchStatus.activities) {
843
+ const newActivities = researchStatus.activities.slice(lastActivityCount);
844
+ for (const activity of newActivities) {
845
+ onActivity(activity);
846
+ }
847
+ lastActivityCount = researchStatus.activities.length;
848
+ }
839
849
  if (researchStatus.status === "completed") {
840
850
  return researchStatus;
841
851
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firecrawl",
3
- "version": "1.18.2",
3
+ "version": "1.18.5",
4
4
  "description": "JavaScript SDK for Firecrawl API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -364,6 +364,11 @@ export interface DeepResearchParams {
364
364
  * @default 270
365
365
  */
366
366
  timeLimit?: number;
367
+ /**
368
+ * Maximum number of URLs to analyze (1-1000)
369
+ * @default 20
370
+ */
371
+ maxUrls?: number;
367
372
  /**
368
373
  * Experimental flag for streaming steps
369
374
  */
@@ -535,7 +540,7 @@ export default class FirecrawlApp {
535
540
  const response: AxiosResponse = await axios.post(
536
541
  this.apiUrl + `/v1/scrape`,
537
542
  jsonData,
538
- { headers }
543
+ { headers, timeout: params?.timeout !== undefined ? (params.timeout + 5000) : undefined },
539
544
  );
540
545
  if (response.status === 200) {
541
546
  const responseData = response.data;
@@ -1262,7 +1267,7 @@ export default class FirecrawlApp {
1262
1267
  data: any,
1263
1268
  headers: AxiosRequestHeaders
1264
1269
  ): Promise<AxiosResponse> {
1265
- return axios.post(url, data, { headers });
1270
+ return axios.post(url, data, { headers, timeout: (data?.timeout ? (data.timeout + 5000) : undefined) });
1266
1271
  }
1267
1272
 
1268
1273
  /**
@@ -1391,10 +1396,22 @@ export default class FirecrawlApp {
1391
1396
 
1392
1397
  /**
1393
1398
  * Initiates a deep research operation on a given topic and polls until completion.
1399
+ * @param topic - The topic to research.
1394
1400
  * @param params - Parameters for the deep research operation.
1401
+ * @param onActivity - Optional callback to receive activity updates in real-time.
1395
1402
  * @returns The final research results.
1396
1403
  */
1397
- async __deepResearch(topic: string, params: DeepResearchParams): Promise<DeepResearchStatusResponse | ErrorResponse> {
1404
+ async __deepResearch(
1405
+ topic: string,
1406
+ params: DeepResearchParams,
1407
+ onActivity?: (activity: {
1408
+ type: string;
1409
+ status: string;
1410
+ message: string;
1411
+ timestamp: string;
1412
+ depth: number;
1413
+ }) => void
1414
+ ): Promise<DeepResearchStatusResponse | ErrorResponse> {
1398
1415
  try {
1399
1416
  const response = await this.__asyncDeepResearch(topic, params);
1400
1417
 
@@ -1408,16 +1425,24 @@ export default class FirecrawlApp {
1408
1425
 
1409
1426
  const jobId = response.id;
1410
1427
  let researchStatus;
1428
+ let lastActivityCount = 0;
1411
1429
 
1412
1430
  while (true) {
1413
- // console.log("Checking research status...");
1414
1431
  researchStatus = await this.__checkDeepResearchStatus(jobId);
1415
- // console.log("Research status:", researchStatus);
1416
1432
 
1417
1433
  if ('error' in researchStatus && !researchStatus.success) {
1418
1434
  return researchStatus;
1419
1435
  }
1420
1436
 
1437
+ // Stream new activities through the callback if provided
1438
+ if (onActivity && researchStatus.activities) {
1439
+ const newActivities = researchStatus.activities.slice(lastActivityCount);
1440
+ for (const activity of newActivities) {
1441
+ onActivity(activity);
1442
+ }
1443
+ lastActivityCount = researchStatus.activities.length;
1444
+ }
1445
+
1421
1446
  if (researchStatus.status === "completed") {
1422
1447
  return researchStatus;
1423
1448
  }
@@ -1435,7 +1460,6 @@ export default class FirecrawlApp {
1435
1460
 
1436
1461
  await new Promise(resolve => setTimeout(resolve, 2000));
1437
1462
  }
1438
- // console.log("Research status finished:", researchStatus);
1439
1463
 
1440
1464
  return { success: false, error: "Research job terminated unexpectedly" };
1441
1465
  } catch (error: any) {