@mendable/firecrawl-js 1.18.0-beta.5 → 1.18.0-beta.8
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 +10 -10
- package/dist/index.d.cts +2 -6
- package/dist/index.d.ts +2 -6
- package/dist/index.js +10 -10
- package/package.json +1 -1
- package/src/index.ts +14 -14
package/dist/index.cjs
CHANGED
|
@@ -856,9 +856,9 @@ var FirecrawlApp = class {
|
|
|
856
856
|
* @param params - Parameters for the deep research operation.
|
|
857
857
|
* @returns The final research results.
|
|
858
858
|
*/
|
|
859
|
-
async __deepResearch(params) {
|
|
859
|
+
async __deepResearch(topic, params) {
|
|
860
860
|
try {
|
|
861
|
-
const response = await this.__asyncDeepResearch(params);
|
|
861
|
+
const response = await this.__asyncDeepResearch(topic, params);
|
|
862
862
|
if (!response.success || "error" in response) {
|
|
863
863
|
return { success: false, error: "error" in response ? response.error : "Unknown error" };
|
|
864
864
|
}
|
|
@@ -867,10 +867,8 @@ var FirecrawlApp = class {
|
|
|
867
867
|
}
|
|
868
868
|
const jobId = response.id;
|
|
869
869
|
let researchStatus;
|
|
870
|
-
|
|
871
|
-
console.log("Checking research status...");
|
|
870
|
+
while (true) {
|
|
872
871
|
researchStatus = await this.__checkDeepResearchStatus(jobId);
|
|
873
|
-
console.log("Research status:", researchStatus);
|
|
874
872
|
if ("error" in researchStatus && !researchStatus.success) {
|
|
875
873
|
return researchStatus;
|
|
876
874
|
}
|
|
@@ -883,9 +881,11 @@ var FirecrawlApp = class {
|
|
|
883
881
|
500
|
|
884
882
|
);
|
|
885
883
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
884
|
+
if (researchStatus.status !== "processing") {
|
|
885
|
+
break;
|
|
886
|
+
}
|
|
887
|
+
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
888
|
+
}
|
|
889
889
|
return { success: false, error: "Research job terminated unexpectedly" };
|
|
890
890
|
} catch (error) {
|
|
891
891
|
throw new FirecrawlError(error.message, 500, error.response?.data?.details);
|
|
@@ -896,12 +896,12 @@ var FirecrawlApp = class {
|
|
|
896
896
|
* @param params - Parameters for the deep research operation.
|
|
897
897
|
* @returns The response containing the research job ID.
|
|
898
898
|
*/
|
|
899
|
-
async __asyncDeepResearch(params) {
|
|
899
|
+
async __asyncDeepResearch(topic, params) {
|
|
900
900
|
const headers = this.prepareHeaders();
|
|
901
901
|
try {
|
|
902
902
|
const response = await this.postRequest(
|
|
903
903
|
`${this.apiUrl}/v1/deep-research`,
|
|
904
|
-
params,
|
|
904
|
+
{ topic, ...params },
|
|
905
905
|
headers
|
|
906
906
|
);
|
|
907
907
|
if (response.status === 200) {
|
package/dist/index.d.cts
CHANGED
|
@@ -322,10 +322,6 @@ interface CrawlErrorsResponse {
|
|
|
322
322
|
* Defines options for conducting deep research on a topic.
|
|
323
323
|
*/
|
|
324
324
|
interface DeepResearchParams {
|
|
325
|
-
/**
|
|
326
|
-
* The topic or question to research
|
|
327
|
-
*/
|
|
328
|
-
topic: string;
|
|
329
325
|
/**
|
|
330
326
|
* Maximum depth of research iterations (1-10)
|
|
331
327
|
* @default 7
|
|
@@ -561,13 +557,13 @@ declare class FirecrawlApp {
|
|
|
561
557
|
* @param params - Parameters for the deep research operation.
|
|
562
558
|
* @returns The final research results.
|
|
563
559
|
*/
|
|
564
|
-
__deepResearch(params: DeepResearchParams): Promise<DeepResearchStatusResponse | ErrorResponse>;
|
|
560
|
+
__deepResearch(topic: string, params: DeepResearchParams): Promise<DeepResearchStatusResponse | ErrorResponse>;
|
|
565
561
|
/**
|
|
566
562
|
* Initiates a deep research operation on a given topic without polling.
|
|
567
563
|
* @param params - Parameters for the deep research operation.
|
|
568
564
|
* @returns The response containing the research job ID.
|
|
569
565
|
*/
|
|
570
|
-
__asyncDeepResearch(params: DeepResearchParams): Promise<DeepResearchResponse | ErrorResponse>;
|
|
566
|
+
__asyncDeepResearch(topic: string, params: DeepResearchParams): Promise<DeepResearchResponse | ErrorResponse>;
|
|
571
567
|
/**
|
|
572
568
|
* Checks the status of a deep research operation.
|
|
573
569
|
* @param id - The ID of the deep research operation.
|
package/dist/index.d.ts
CHANGED
|
@@ -322,10 +322,6 @@ interface CrawlErrorsResponse {
|
|
|
322
322
|
* Defines options for conducting deep research on a topic.
|
|
323
323
|
*/
|
|
324
324
|
interface DeepResearchParams {
|
|
325
|
-
/**
|
|
326
|
-
* The topic or question to research
|
|
327
|
-
*/
|
|
328
|
-
topic: string;
|
|
329
325
|
/**
|
|
330
326
|
* Maximum depth of research iterations (1-10)
|
|
331
327
|
* @default 7
|
|
@@ -561,13 +557,13 @@ declare class FirecrawlApp {
|
|
|
561
557
|
* @param params - Parameters for the deep research operation.
|
|
562
558
|
* @returns The final research results.
|
|
563
559
|
*/
|
|
564
|
-
__deepResearch(params: DeepResearchParams): Promise<DeepResearchStatusResponse | ErrorResponse>;
|
|
560
|
+
__deepResearch(topic: string, params: DeepResearchParams): Promise<DeepResearchStatusResponse | ErrorResponse>;
|
|
565
561
|
/**
|
|
566
562
|
* Initiates a deep research operation on a given topic without polling.
|
|
567
563
|
* @param params - Parameters for the deep research operation.
|
|
568
564
|
* @returns The response containing the research job ID.
|
|
569
565
|
*/
|
|
570
|
-
__asyncDeepResearch(params: DeepResearchParams): Promise<DeepResearchResponse | ErrorResponse>;
|
|
566
|
+
__asyncDeepResearch(topic: string, params: DeepResearchParams): Promise<DeepResearchResponse | ErrorResponse>;
|
|
571
567
|
/**
|
|
572
568
|
* Checks the status of a deep research operation.
|
|
573
569
|
* @param id - The ID of the deep research operation.
|
package/dist/index.js
CHANGED
|
@@ -820,9 +820,9 @@ var FirecrawlApp = class {
|
|
|
820
820
|
* @param params - Parameters for the deep research operation.
|
|
821
821
|
* @returns The final research results.
|
|
822
822
|
*/
|
|
823
|
-
async __deepResearch(params) {
|
|
823
|
+
async __deepResearch(topic, params) {
|
|
824
824
|
try {
|
|
825
|
-
const response = await this.__asyncDeepResearch(params);
|
|
825
|
+
const response = await this.__asyncDeepResearch(topic, params);
|
|
826
826
|
if (!response.success || "error" in response) {
|
|
827
827
|
return { success: false, error: "error" in response ? response.error : "Unknown error" };
|
|
828
828
|
}
|
|
@@ -831,10 +831,8 @@ var FirecrawlApp = class {
|
|
|
831
831
|
}
|
|
832
832
|
const jobId = response.id;
|
|
833
833
|
let researchStatus;
|
|
834
|
-
|
|
835
|
-
console.log("Checking research status...");
|
|
834
|
+
while (true) {
|
|
836
835
|
researchStatus = await this.__checkDeepResearchStatus(jobId);
|
|
837
|
-
console.log("Research status:", researchStatus);
|
|
838
836
|
if ("error" in researchStatus && !researchStatus.success) {
|
|
839
837
|
return researchStatus;
|
|
840
838
|
}
|
|
@@ -847,9 +845,11 @@ var FirecrawlApp = class {
|
|
|
847
845
|
500
|
|
848
846
|
);
|
|
849
847
|
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
848
|
+
if (researchStatus.status !== "processing") {
|
|
849
|
+
break;
|
|
850
|
+
}
|
|
851
|
+
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
852
|
+
}
|
|
853
853
|
return { success: false, error: "Research job terminated unexpectedly" };
|
|
854
854
|
} catch (error) {
|
|
855
855
|
throw new FirecrawlError(error.message, 500, error.response?.data?.details);
|
|
@@ -860,12 +860,12 @@ var FirecrawlApp = class {
|
|
|
860
860
|
* @param params - Parameters for the deep research operation.
|
|
861
861
|
* @returns The response containing the research job ID.
|
|
862
862
|
*/
|
|
863
|
-
async __asyncDeepResearch(params) {
|
|
863
|
+
async __asyncDeepResearch(topic, params) {
|
|
864
864
|
const headers = this.prepareHeaders();
|
|
865
865
|
try {
|
|
866
866
|
const response = await this.postRequest(
|
|
867
867
|
`${this.apiUrl}/v1/deep-research`,
|
|
868
|
-
params,
|
|
868
|
+
{ topic, ...params },
|
|
869
869
|
headers
|
|
870
870
|
);
|
|
871
871
|
if (response.status === 200) {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -352,10 +352,6 @@ export interface CrawlErrorsResponse {
|
|
|
352
352
|
* Defines options for conducting deep research on a topic.
|
|
353
353
|
*/
|
|
354
354
|
export interface DeepResearchParams {
|
|
355
|
-
/**
|
|
356
|
-
* The topic or question to research
|
|
357
|
-
*/
|
|
358
|
-
topic: string;
|
|
359
355
|
/**
|
|
360
356
|
* Maximum depth of research iterations (1-10)
|
|
361
357
|
* @default 7
|
|
@@ -1354,9 +1350,9 @@ export default class FirecrawlApp {
|
|
|
1354
1350
|
* @param params - Parameters for the deep research operation.
|
|
1355
1351
|
* @returns The final research results.
|
|
1356
1352
|
*/
|
|
1357
|
-
async __deepResearch(params: DeepResearchParams): Promise<DeepResearchStatusResponse | ErrorResponse> {
|
|
1353
|
+
async __deepResearch(topic: string, params: DeepResearchParams): Promise<DeepResearchStatusResponse | ErrorResponse> {
|
|
1358
1354
|
try {
|
|
1359
|
-
const response = await this.__asyncDeepResearch(params);
|
|
1355
|
+
const response = await this.__asyncDeepResearch(topic, params);
|
|
1360
1356
|
|
|
1361
1357
|
if (!response.success || 'error' in response) {
|
|
1362
1358
|
return { success: false, error: 'error' in response ? response.error : 'Unknown error' };
|
|
@@ -1369,10 +1365,10 @@ export default class FirecrawlApp {
|
|
|
1369
1365
|
const jobId = response.id;
|
|
1370
1366
|
let researchStatus;
|
|
1371
1367
|
|
|
1372
|
-
|
|
1373
|
-
console.log("Checking research status...");
|
|
1368
|
+
while (true) {
|
|
1369
|
+
// console.log("Checking research status...");
|
|
1374
1370
|
researchStatus = await this.__checkDeepResearchStatus(jobId);
|
|
1375
|
-
console.log("Research status:", researchStatus);
|
|
1371
|
+
// console.log("Research status:", researchStatus);
|
|
1376
1372
|
|
|
1377
1373
|
if ('error' in researchStatus && !researchStatus.success) {
|
|
1378
1374
|
return researchStatus;
|
|
@@ -1389,9 +1385,13 @@ export default class FirecrawlApp {
|
|
|
1389
1385
|
);
|
|
1390
1386
|
}
|
|
1391
1387
|
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1388
|
+
if (researchStatus.status !== "processing") {
|
|
1389
|
+
break;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
1393
|
+
}
|
|
1394
|
+
// console.log("Research status finished:", researchStatus);
|
|
1395
1395
|
|
|
1396
1396
|
return { success: false, error: "Research job terminated unexpectedly" };
|
|
1397
1397
|
} catch (error: any) {
|
|
@@ -1404,12 +1404,12 @@ export default class FirecrawlApp {
|
|
|
1404
1404
|
* @param params - Parameters for the deep research operation.
|
|
1405
1405
|
* @returns The response containing the research job ID.
|
|
1406
1406
|
*/
|
|
1407
|
-
async __asyncDeepResearch(params: DeepResearchParams): Promise<DeepResearchResponse | ErrorResponse> {
|
|
1407
|
+
async __asyncDeepResearch(topic: string, params: DeepResearchParams): Promise<DeepResearchResponse | ErrorResponse> {
|
|
1408
1408
|
const headers = this.prepareHeaders();
|
|
1409
1409
|
try {
|
|
1410
1410
|
const response: AxiosResponse = await this.postRequest(
|
|
1411
1411
|
`${this.apiUrl}/v1/deep-research`,
|
|
1412
|
-
params,
|
|
1412
|
+
{ topic, ...params },
|
|
1413
1413
|
headers
|
|
1414
1414
|
);
|
|
1415
1415
|
|