firecrawl 1.18.2 → 1.18.4
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/package.json +1 -1
- package/src/index.ts +30 -6
- package/dist/index.cjs +0 -1139
- package/dist/index.d.cts +0 -656
- package/dist/index.d.ts +0 -656
- package/dist/index.js +0 -1103
- package/dump.rdb +0 -0
package/package.json
CHANGED
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(
|
|
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) {
|