firecrawl 1.20.0 → 1.21.0
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 +17 -2
- package/dist/index.d.cts +22 -5
- package/dist/index.d.ts +22 -5
- package/dist/index.js +17 -2
- package/package.json +1 -1
- package/src/index.ts +46 -6
package/dist/index.cjs
CHANGED
|
@@ -841,7 +841,7 @@ var FirecrawlApp = class {
|
|
|
841
841
|
* @param {string} action - The action being performed when the error occurred.
|
|
842
842
|
*/
|
|
843
843
|
handleError(response, action) {
|
|
844
|
-
if ([400, 402, 408, 409, 500].includes(response.status)) {
|
|
844
|
+
if ([400, 402, 403, 408, 409, 500].includes(response.status)) {
|
|
845
845
|
const errorMessage = response.data.error || "Unknown error occurred";
|
|
846
846
|
const details = response.data.details ? ` - ${JSON.stringify(response.data.details)}` : "";
|
|
847
847
|
throw new FirecrawlError(
|
|
@@ -922,10 +922,25 @@ var FirecrawlApp = class {
|
|
|
922
922
|
*/
|
|
923
923
|
async asyncDeepResearch(query, params) {
|
|
924
924
|
const headers = this.prepareHeaders();
|
|
925
|
+
let jsonData = { query, ...params };
|
|
926
|
+
if (jsonData?.jsonOptions?.schema) {
|
|
927
|
+
let schema = jsonData.jsonOptions.schema;
|
|
928
|
+
try {
|
|
929
|
+
schema = (0, import_zod_to_json_schema.zodToJsonSchema)(schema);
|
|
930
|
+
} catch (error) {
|
|
931
|
+
}
|
|
932
|
+
jsonData = {
|
|
933
|
+
...jsonData,
|
|
934
|
+
jsonOptions: {
|
|
935
|
+
...jsonData.jsonOptions,
|
|
936
|
+
schema
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
}
|
|
925
940
|
try {
|
|
926
941
|
const response = await this.postRequest(
|
|
927
942
|
`${this.apiUrl}/v1/deep-research`,
|
|
928
|
-
|
|
943
|
+
jsonData,
|
|
929
944
|
headers
|
|
930
945
|
);
|
|
931
946
|
if (response.status === 200) {
|
package/dist/index.d.cts
CHANGED
|
@@ -97,6 +97,7 @@ type Action = {
|
|
|
97
97
|
} | {
|
|
98
98
|
type: "click";
|
|
99
99
|
selector: string;
|
|
100
|
+
all?: boolean;
|
|
100
101
|
} | {
|
|
101
102
|
type: "screenshot";
|
|
102
103
|
fullPage?: boolean;
|
|
@@ -325,7 +326,7 @@ interface CrawlErrorsResponse {
|
|
|
325
326
|
* Parameters for deep research operations.
|
|
326
327
|
* Defines options for conducting deep research on a query.
|
|
327
328
|
*/
|
|
328
|
-
interface DeepResearchParams {
|
|
329
|
+
interface DeepResearchParams<LLMSchema extends zt.ZodSchema = any> {
|
|
329
330
|
/**
|
|
330
331
|
* Maximum depth of research iterations (1-10)
|
|
331
332
|
* @default 7
|
|
@@ -342,9 +343,25 @@ interface DeepResearchParams {
|
|
|
342
343
|
*/
|
|
343
344
|
maxUrls?: number;
|
|
344
345
|
/**
|
|
345
|
-
*
|
|
346
|
+
* The prompt to use for the final analysis
|
|
346
347
|
*/
|
|
347
|
-
|
|
348
|
+
analysisPrompt?: string;
|
|
349
|
+
/**
|
|
350
|
+
* The system prompt to use for the research agent
|
|
351
|
+
*/
|
|
352
|
+
systemPrompt?: string;
|
|
353
|
+
/**
|
|
354
|
+
* The formats to use for the final analysis
|
|
355
|
+
*/
|
|
356
|
+
formats?: ("markdown" | "json")[];
|
|
357
|
+
/**
|
|
358
|
+
* The JSON options to use for the final analysis
|
|
359
|
+
*/
|
|
360
|
+
jsonOptions?: {
|
|
361
|
+
prompt?: string;
|
|
362
|
+
schema?: LLMSchema;
|
|
363
|
+
systemPrompt?: string;
|
|
364
|
+
};
|
|
348
365
|
}
|
|
349
366
|
/**
|
|
350
367
|
* Response interface for deep research operations.
|
|
@@ -613,7 +630,7 @@ declare class FirecrawlApp {
|
|
|
613
630
|
* @param onSource - Optional callback to receive source updates in real-time.
|
|
614
631
|
* @returns The final research results.
|
|
615
632
|
*/
|
|
616
|
-
deepResearch(query: string, params: DeepResearchParams
|
|
633
|
+
deepResearch(query: string, params: DeepResearchParams<zt.ZodSchema>, onActivity?: (activity: {
|
|
617
634
|
type: string;
|
|
618
635
|
status: string;
|
|
619
636
|
message: string;
|
|
@@ -630,7 +647,7 @@ declare class FirecrawlApp {
|
|
|
630
647
|
* @param params - Parameters for the deep research operation.
|
|
631
648
|
* @returns The response containing the research job ID.
|
|
632
649
|
*/
|
|
633
|
-
asyncDeepResearch(query: string, params: DeepResearchParams): Promise<DeepResearchResponse | ErrorResponse>;
|
|
650
|
+
asyncDeepResearch(query: string, params: DeepResearchParams<zt.ZodSchema>): Promise<DeepResearchResponse | ErrorResponse>;
|
|
634
651
|
/**
|
|
635
652
|
* Checks the status of a deep research operation.
|
|
636
653
|
* @param id - The ID of the deep research operation.
|
package/dist/index.d.ts
CHANGED
|
@@ -97,6 +97,7 @@ type Action = {
|
|
|
97
97
|
} | {
|
|
98
98
|
type: "click";
|
|
99
99
|
selector: string;
|
|
100
|
+
all?: boolean;
|
|
100
101
|
} | {
|
|
101
102
|
type: "screenshot";
|
|
102
103
|
fullPage?: boolean;
|
|
@@ -325,7 +326,7 @@ interface CrawlErrorsResponse {
|
|
|
325
326
|
* Parameters for deep research operations.
|
|
326
327
|
* Defines options for conducting deep research on a query.
|
|
327
328
|
*/
|
|
328
|
-
interface DeepResearchParams {
|
|
329
|
+
interface DeepResearchParams<LLMSchema extends zt.ZodSchema = any> {
|
|
329
330
|
/**
|
|
330
331
|
* Maximum depth of research iterations (1-10)
|
|
331
332
|
* @default 7
|
|
@@ -342,9 +343,25 @@ interface DeepResearchParams {
|
|
|
342
343
|
*/
|
|
343
344
|
maxUrls?: number;
|
|
344
345
|
/**
|
|
345
|
-
*
|
|
346
|
+
* The prompt to use for the final analysis
|
|
346
347
|
*/
|
|
347
|
-
|
|
348
|
+
analysisPrompt?: string;
|
|
349
|
+
/**
|
|
350
|
+
* The system prompt to use for the research agent
|
|
351
|
+
*/
|
|
352
|
+
systemPrompt?: string;
|
|
353
|
+
/**
|
|
354
|
+
* The formats to use for the final analysis
|
|
355
|
+
*/
|
|
356
|
+
formats?: ("markdown" | "json")[];
|
|
357
|
+
/**
|
|
358
|
+
* The JSON options to use for the final analysis
|
|
359
|
+
*/
|
|
360
|
+
jsonOptions?: {
|
|
361
|
+
prompt?: string;
|
|
362
|
+
schema?: LLMSchema;
|
|
363
|
+
systemPrompt?: string;
|
|
364
|
+
};
|
|
348
365
|
}
|
|
349
366
|
/**
|
|
350
367
|
* Response interface for deep research operations.
|
|
@@ -613,7 +630,7 @@ declare class FirecrawlApp {
|
|
|
613
630
|
* @param onSource - Optional callback to receive source updates in real-time.
|
|
614
631
|
* @returns The final research results.
|
|
615
632
|
*/
|
|
616
|
-
deepResearch(query: string, params: DeepResearchParams
|
|
633
|
+
deepResearch(query: string, params: DeepResearchParams<zt.ZodSchema>, onActivity?: (activity: {
|
|
617
634
|
type: string;
|
|
618
635
|
status: string;
|
|
619
636
|
message: string;
|
|
@@ -630,7 +647,7 @@ declare class FirecrawlApp {
|
|
|
630
647
|
* @param params - Parameters for the deep research operation.
|
|
631
648
|
* @returns The response containing the research job ID.
|
|
632
649
|
*/
|
|
633
|
-
asyncDeepResearch(query: string, params: DeepResearchParams): Promise<DeepResearchResponse | ErrorResponse>;
|
|
650
|
+
asyncDeepResearch(query: string, params: DeepResearchParams<zt.ZodSchema>): Promise<DeepResearchResponse | ErrorResponse>;
|
|
634
651
|
/**
|
|
635
652
|
* Checks the status of a deep research operation.
|
|
636
653
|
* @param id - The ID of the deep research operation.
|
package/dist/index.js
CHANGED
|
@@ -805,7 +805,7 @@ var FirecrawlApp = class {
|
|
|
805
805
|
* @param {string} action - The action being performed when the error occurred.
|
|
806
806
|
*/
|
|
807
807
|
handleError(response, action) {
|
|
808
|
-
if ([400, 402, 408, 409, 500].includes(response.status)) {
|
|
808
|
+
if ([400, 402, 403, 408, 409, 500].includes(response.status)) {
|
|
809
809
|
const errorMessage = response.data.error || "Unknown error occurred";
|
|
810
810
|
const details = response.data.details ? ` - ${JSON.stringify(response.data.details)}` : "";
|
|
811
811
|
throw new FirecrawlError(
|
|
@@ -886,10 +886,25 @@ var FirecrawlApp = class {
|
|
|
886
886
|
*/
|
|
887
887
|
async asyncDeepResearch(query, params) {
|
|
888
888
|
const headers = this.prepareHeaders();
|
|
889
|
+
let jsonData = { query, ...params };
|
|
890
|
+
if (jsonData?.jsonOptions?.schema) {
|
|
891
|
+
let schema = jsonData.jsonOptions.schema;
|
|
892
|
+
try {
|
|
893
|
+
schema = zodToJsonSchema(schema);
|
|
894
|
+
} catch (error) {
|
|
895
|
+
}
|
|
896
|
+
jsonData = {
|
|
897
|
+
...jsonData,
|
|
898
|
+
jsonOptions: {
|
|
899
|
+
...jsonData.jsonOptions,
|
|
900
|
+
schema
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
}
|
|
889
904
|
try {
|
|
890
905
|
const response = await this.postRequest(
|
|
891
906
|
`${this.apiUrl}/v1/deep-research`,
|
|
892
|
-
|
|
907
|
+
jsonData,
|
|
893
908
|
headers
|
|
894
909
|
);
|
|
895
910
|
if (response.status === 200) {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -104,6 +104,7 @@ export type Action = {
|
|
|
104
104
|
} | {
|
|
105
105
|
type: "click",
|
|
106
106
|
selector: string,
|
|
107
|
+
all?: boolean,
|
|
107
108
|
} | {
|
|
108
109
|
type: "screenshot",
|
|
109
110
|
fullPage?: boolean,
|
|
@@ -355,7 +356,7 @@ export interface CrawlErrorsResponse {
|
|
|
355
356
|
* Parameters for deep research operations.
|
|
356
357
|
* Defines options for conducting deep research on a query.
|
|
357
358
|
*/
|
|
358
|
-
export interface DeepResearchParams {
|
|
359
|
+
export interface DeepResearchParams<LLMSchema extends zt.ZodSchema = any> {
|
|
359
360
|
/**
|
|
360
361
|
* Maximum depth of research iterations (1-10)
|
|
361
362
|
* @default 7
|
|
@@ -372,9 +373,29 @@ export interface DeepResearchParams {
|
|
|
372
373
|
*/
|
|
373
374
|
maxUrls?: number;
|
|
374
375
|
/**
|
|
376
|
+
* The prompt to use for the final analysis
|
|
377
|
+
*/
|
|
378
|
+
analysisPrompt?: string;
|
|
379
|
+
/**
|
|
380
|
+
* The system prompt to use for the research agent
|
|
381
|
+
*/
|
|
382
|
+
systemPrompt?: string;
|
|
383
|
+
/**
|
|
384
|
+
* The formats to use for the final analysis
|
|
385
|
+
*/
|
|
386
|
+
formats?: ("markdown" | "json")[];
|
|
387
|
+
/**
|
|
388
|
+
* The JSON options to use for the final analysis
|
|
389
|
+
*/
|
|
390
|
+
jsonOptions?:{
|
|
391
|
+
prompt?: string;
|
|
392
|
+
schema?: LLMSchema;
|
|
393
|
+
systemPrompt?: string;
|
|
394
|
+
};
|
|
395
|
+
/**
|
|
375
396
|
* Experimental flag for streaming steps
|
|
376
397
|
*/
|
|
377
|
-
__experimental_streamSteps?: boolean;
|
|
398
|
+
// __experimental_streamSteps?: boolean;
|
|
378
399
|
}
|
|
379
400
|
|
|
380
401
|
/**
|
|
@@ -1388,7 +1409,7 @@ export default class FirecrawlApp {
|
|
|
1388
1409
|
* @param {string} action - The action being performed when the error occurred.
|
|
1389
1410
|
*/
|
|
1390
1411
|
handleError(response: AxiosResponse, action: string): void {
|
|
1391
|
-
if ([400, 402, 408, 409, 500].includes(response.status)) {
|
|
1412
|
+
if ([400, 402, 403, 408, 409, 500].includes(response.status)) {
|
|
1392
1413
|
const errorMessage: string =
|
|
1393
1414
|
response.data.error || "Unknown error occurred";
|
|
1394
1415
|
const details = response.data.details ? ` - ${JSON.stringify(response.data.details)}` : '';
|
|
@@ -1415,7 +1436,7 @@ export default class FirecrawlApp {
|
|
|
1415
1436
|
*/
|
|
1416
1437
|
async deepResearch(
|
|
1417
1438
|
query: string,
|
|
1418
|
-
params: DeepResearchParams
|
|
1439
|
+
params: DeepResearchParams<zt.ZodSchema>,
|
|
1419
1440
|
onActivity?: (activity: {
|
|
1420
1441
|
type: string;
|
|
1421
1442
|
status: string;
|
|
@@ -1500,12 +1521,31 @@ export default class FirecrawlApp {
|
|
|
1500
1521
|
* @param params - Parameters for the deep research operation.
|
|
1501
1522
|
* @returns The response containing the research job ID.
|
|
1502
1523
|
*/
|
|
1503
|
-
async asyncDeepResearch(query: string, params: DeepResearchParams): Promise<DeepResearchResponse | ErrorResponse> {
|
|
1524
|
+
async asyncDeepResearch(query: string, params: DeepResearchParams<zt.ZodSchema>): Promise<DeepResearchResponse | ErrorResponse> {
|
|
1504
1525
|
const headers = this.prepareHeaders();
|
|
1526
|
+
let jsonData: any = { query, ...params };
|
|
1527
|
+
|
|
1528
|
+
if (jsonData?.jsonOptions?.schema) {
|
|
1529
|
+
let schema = jsonData.jsonOptions.schema;
|
|
1530
|
+
// Try parsing the schema as a Zod schema
|
|
1531
|
+
try {
|
|
1532
|
+
schema = zodToJsonSchema(schema);
|
|
1533
|
+
} catch (error) {
|
|
1534
|
+
|
|
1535
|
+
}
|
|
1536
|
+
jsonData = {
|
|
1537
|
+
...jsonData,
|
|
1538
|
+
jsonOptions: {
|
|
1539
|
+
...jsonData.jsonOptions,
|
|
1540
|
+
schema: schema,
|
|
1541
|
+
},
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1505
1545
|
try {
|
|
1506
1546
|
const response: AxiosResponse = await this.postRequest(
|
|
1507
1547
|
`${this.apiUrl}/v1/deep-research`,
|
|
1508
|
-
|
|
1548
|
+
jsonData,
|
|
1509
1549
|
headers
|
|
1510
1550
|
);
|
|
1511
1551
|
|