@mendable/firecrawl-js 1.18.2 → 1.18.3-beta.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.
- package/dist/index.cjs +11 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +11 -1
- package/package.json +1 -1
- package/src/index.ts +23 -4
package/dist/index.cjs
CHANGED
|
@@ -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
|
@@ -595,10 +595,18 @@ declare class FirecrawlApp {
|
|
|
595
595
|
handleError(response: AxiosResponse, action: string): void;
|
|
596
596
|
/**
|
|
597
597
|
* Initiates a deep research operation on a given topic and polls until completion.
|
|
598
|
+
* @param topic - The topic to research.
|
|
598
599
|
* @param params - Parameters for the deep research operation.
|
|
600
|
+
* @param onActivity - Optional callback to receive activity updates in real-time.
|
|
599
601
|
* @returns The final research results.
|
|
600
602
|
*/
|
|
601
|
-
__deepResearch(topic: string, params: DeepResearchParams
|
|
603
|
+
__deepResearch(topic: string, params: DeepResearchParams, onActivity?: (activity: {
|
|
604
|
+
type: string;
|
|
605
|
+
status: string;
|
|
606
|
+
message: string;
|
|
607
|
+
timestamp: string;
|
|
608
|
+
depth: number;
|
|
609
|
+
}) => void): Promise<DeepResearchStatusResponse | ErrorResponse>;
|
|
602
610
|
/**
|
|
603
611
|
* Initiates a deep research operation on a given topic without polling.
|
|
604
612
|
* @param params - Parameters for the deep research operation.
|
package/dist/index.d.ts
CHANGED
|
@@ -595,10 +595,18 @@ declare class FirecrawlApp {
|
|
|
595
595
|
handleError(response: AxiosResponse, action: string): void;
|
|
596
596
|
/**
|
|
597
597
|
* Initiates a deep research operation on a given topic and polls until completion.
|
|
598
|
+
* @param topic - The topic to research.
|
|
598
599
|
* @param params - Parameters for the deep research operation.
|
|
600
|
+
* @param onActivity - Optional callback to receive activity updates in real-time.
|
|
599
601
|
* @returns The final research results.
|
|
600
602
|
*/
|
|
601
|
-
__deepResearch(topic: string, params: DeepResearchParams
|
|
603
|
+
__deepResearch(topic: string, params: DeepResearchParams, onActivity?: (activity: {
|
|
604
|
+
type: string;
|
|
605
|
+
status: string;
|
|
606
|
+
message: string;
|
|
607
|
+
timestamp: string;
|
|
608
|
+
depth: number;
|
|
609
|
+
}) => void): Promise<DeepResearchStatusResponse | ErrorResponse>;
|
|
602
610
|
/**
|
|
603
611
|
* Initiates a deep research operation on a given topic without polling.
|
|
604
612
|
* @param params - Parameters for the deep research operation.
|
package/dist/index.js
CHANGED
|
@@ -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
package/src/index.ts
CHANGED
|
@@ -1391,10 +1391,22 @@ export default class FirecrawlApp {
|
|
|
1391
1391
|
|
|
1392
1392
|
/**
|
|
1393
1393
|
* Initiates a deep research operation on a given topic and polls until completion.
|
|
1394
|
+
* @param topic - The topic to research.
|
|
1394
1395
|
* @param params - Parameters for the deep research operation.
|
|
1396
|
+
* @param onActivity - Optional callback to receive activity updates in real-time.
|
|
1395
1397
|
* @returns The final research results.
|
|
1396
1398
|
*/
|
|
1397
|
-
async __deepResearch(
|
|
1399
|
+
async __deepResearch(
|
|
1400
|
+
topic: string,
|
|
1401
|
+
params: DeepResearchParams,
|
|
1402
|
+
onActivity?: (activity: {
|
|
1403
|
+
type: string;
|
|
1404
|
+
status: string;
|
|
1405
|
+
message: string;
|
|
1406
|
+
timestamp: string;
|
|
1407
|
+
depth: number;
|
|
1408
|
+
}) => void
|
|
1409
|
+
): Promise<DeepResearchStatusResponse | ErrorResponse> {
|
|
1398
1410
|
try {
|
|
1399
1411
|
const response = await this.__asyncDeepResearch(topic, params);
|
|
1400
1412
|
|
|
@@ -1408,16 +1420,24 @@ export default class FirecrawlApp {
|
|
|
1408
1420
|
|
|
1409
1421
|
const jobId = response.id;
|
|
1410
1422
|
let researchStatus;
|
|
1423
|
+
let lastActivityCount = 0;
|
|
1411
1424
|
|
|
1412
1425
|
while (true) {
|
|
1413
|
-
// console.log("Checking research status...");
|
|
1414
1426
|
researchStatus = await this.__checkDeepResearchStatus(jobId);
|
|
1415
|
-
// console.log("Research status:", researchStatus);
|
|
1416
1427
|
|
|
1417
1428
|
if ('error' in researchStatus && !researchStatus.success) {
|
|
1418
1429
|
return researchStatus;
|
|
1419
1430
|
}
|
|
1420
1431
|
|
|
1432
|
+
// Stream new activities through the callback if provided
|
|
1433
|
+
if (onActivity && researchStatus.activities) {
|
|
1434
|
+
const newActivities = researchStatus.activities.slice(lastActivityCount);
|
|
1435
|
+
for (const activity of newActivities) {
|
|
1436
|
+
onActivity(activity);
|
|
1437
|
+
}
|
|
1438
|
+
lastActivityCount = researchStatus.activities.length;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1421
1441
|
if (researchStatus.status === "completed") {
|
|
1422
1442
|
return researchStatus;
|
|
1423
1443
|
}
|
|
@@ -1435,7 +1455,6 @@ export default class FirecrawlApp {
|
|
|
1435
1455
|
|
|
1436
1456
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
1437
1457
|
}
|
|
1438
|
-
// console.log("Research status finished:", researchStatus);
|
|
1439
1458
|
|
|
1440
1459
|
return { success: false, error: "Research job terminated unexpectedly" };
|
|
1441
1460
|
} catch (error: any) {
|