@mendable/firecrawl-js 1.18.0-beta.7 → 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 -7
- package/dist/index.d.cts +2 -6
- package/dist/index.d.ts +2 -6
- package/dist/index.js +10 -7
- package/package.json +1 -1
- package/src/index.ts +11 -11
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,7 +867,7 @@ var FirecrawlApp = class {
|
|
|
867
867
|
}
|
|
868
868
|
const jobId = response.id;
|
|
869
869
|
let researchStatus;
|
|
870
|
-
|
|
870
|
+
while (true) {
|
|
871
871
|
researchStatus = await this.__checkDeepResearchStatus(jobId);
|
|
872
872
|
if ("error" in researchStatus && !researchStatus.success) {
|
|
873
873
|
return researchStatus;
|
|
@@ -881,8 +881,11 @@ var FirecrawlApp = class {
|
|
|
881
881
|
500
|
|
882
882
|
);
|
|
883
883
|
}
|
|
884
|
-
|
|
885
|
-
|
|
884
|
+
if (researchStatus.status !== "processing") {
|
|
885
|
+
break;
|
|
886
|
+
}
|
|
887
|
+
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
888
|
+
}
|
|
886
889
|
return { success: false, error: "Research job terminated unexpectedly" };
|
|
887
890
|
} catch (error) {
|
|
888
891
|
throw new FirecrawlError(error.message, 500, error.response?.data?.details);
|
|
@@ -893,12 +896,12 @@ var FirecrawlApp = class {
|
|
|
893
896
|
* @param params - Parameters for the deep research operation.
|
|
894
897
|
* @returns The response containing the research job ID.
|
|
895
898
|
*/
|
|
896
|
-
async __asyncDeepResearch(params) {
|
|
899
|
+
async __asyncDeepResearch(topic, params) {
|
|
897
900
|
const headers = this.prepareHeaders();
|
|
898
901
|
try {
|
|
899
902
|
const response = await this.postRequest(
|
|
900
903
|
`${this.apiUrl}/v1/deep-research`,
|
|
901
|
-
params,
|
|
904
|
+
{ topic, ...params },
|
|
902
905
|
headers
|
|
903
906
|
);
|
|
904
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,7 +831,7 @@ var FirecrawlApp = class {
|
|
|
831
831
|
}
|
|
832
832
|
const jobId = response.id;
|
|
833
833
|
let researchStatus;
|
|
834
|
-
|
|
834
|
+
while (true) {
|
|
835
835
|
researchStatus = await this.__checkDeepResearchStatus(jobId);
|
|
836
836
|
if ("error" in researchStatus && !researchStatus.success) {
|
|
837
837
|
return researchStatus;
|
|
@@ -845,8 +845,11 @@ var FirecrawlApp = class {
|
|
|
845
845
|
500
|
|
846
846
|
);
|
|
847
847
|
}
|
|
848
|
-
|
|
849
|
-
|
|
848
|
+
if (researchStatus.status !== "processing") {
|
|
849
|
+
break;
|
|
850
|
+
}
|
|
851
|
+
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
852
|
+
}
|
|
850
853
|
return { success: false, error: "Research job terminated unexpectedly" };
|
|
851
854
|
} catch (error) {
|
|
852
855
|
throw new FirecrawlError(error.message, 500, error.response?.data?.details);
|
|
@@ -857,12 +860,12 @@ var FirecrawlApp = class {
|
|
|
857
860
|
* @param params - Parameters for the deep research operation.
|
|
858
861
|
* @returns The response containing the research job ID.
|
|
859
862
|
*/
|
|
860
|
-
async __asyncDeepResearch(params) {
|
|
863
|
+
async __asyncDeepResearch(topic, params) {
|
|
861
864
|
const headers = this.prepareHeaders();
|
|
862
865
|
try {
|
|
863
866
|
const response = await this.postRequest(
|
|
864
867
|
`${this.apiUrl}/v1/deep-research`,
|
|
865
|
-
params,
|
|
868
|
+
{ topic, ...params },
|
|
866
869
|
headers
|
|
867
870
|
);
|
|
868
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,7 +1365,7 @@ export default class FirecrawlApp {
|
|
|
1369
1365
|
const jobId = response.id;
|
|
1370
1366
|
let researchStatus;
|
|
1371
1367
|
|
|
1372
|
-
|
|
1368
|
+
while (true) {
|
|
1373
1369
|
// console.log("Checking research status...");
|
|
1374
1370
|
researchStatus = await this.__checkDeepResearchStatus(jobId);
|
|
1375
1371
|
// console.log("Research status:", researchStatus);
|
|
@@ -1389,8 +1385,12 @@ export default class FirecrawlApp {
|
|
|
1389
1385
|
);
|
|
1390
1386
|
}
|
|
1391
1387
|
|
|
1392
|
-
|
|
1393
|
-
|
|
1388
|
+
if (researchStatus.status !== "processing") {
|
|
1389
|
+
break;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
1393
|
+
}
|
|
1394
1394
|
// console.log("Research status finished:", researchStatus);
|
|
1395
1395
|
|
|
1396
1396
|
return { success: false, error: "Research job terminated unexpectedly" };
|
|
@@ -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
|
|