firecrawl 4.38.0 → 4.39.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.
Files changed (32) hide show
  1. package/README.md +7 -2
  2. package/dist/{chunk-KSTNOGOD.js → chunk-4DPCCKWG.js} +1 -1
  3. package/dist/index.cjs +39 -9
  4. package/dist/index.d.cts +152 -4
  5. package/dist/index.d.ts +152 -4
  6. package/dist/index.js +40 -10
  7. package/dist/{package-OS7RONXY.js → package-D2QZMRW7.js} +1 -1
  8. package/package.json +1 -1
  9. package/pnpm-workspace.yaml +1 -0
  10. package/src/__tests__/e2e/v2/batch.test.ts +13 -11
  11. package/src/__tests__/e2e/v2/crawl.test.ts +24 -20
  12. package/src/__tests__/e2e/v2/extract.test.ts +32 -7
  13. package/src/__tests__/e2e/v2/map.test.ts +4 -3
  14. package/src/__tests__/e2e/v2/parse.test.ts +4 -3
  15. package/src/__tests__/e2e/v2/scrape.test.ts +10 -9
  16. package/src/__tests__/e2e/v2/search.test.ts +9 -8
  17. package/src/__tests__/e2e/v2/usage.test.ts +6 -5
  18. package/src/__tests__/e2e/v2/utils/rateLimit.ts +257 -0
  19. package/src/__tests__/e2e/v2/watcher.test.ts +4 -3
  20. package/src/__tests__/unit/v2/agent-effort-trace.unit.test.ts +1 -1
  21. package/src/__tests__/unit/v2/agent-thread.unit.test.ts +164 -0
  22. package/src/__tests__/unit/v2/e2eRateLimitRetry.test.ts +501 -0
  23. package/src/__tests__/unit/v2/extract.unit.test.ts +1 -1
  24. package/src/__tests__/unit/v2/scrapeAutoResume.test.ts +1 -1
  25. package/src/__tests__/unit/v2/search-country.unit.test.ts +32 -0
  26. package/src/__tests__/unit/v2/search-data-property.test.ts +1 -0
  27. package/src/__tests__/unit/v2/v1-aliases.test.ts +1 -0
  28. package/src/v2/client.ts +13 -1
  29. package/src/v2/methods/agent.ts +23 -1
  30. package/src/v2/methods/research.ts +14 -8
  31. package/src/v2/methods/search.ts +1 -0
  32. package/src/v2/types.ts +151 -34
@@ -34,6 +34,7 @@ function prepareSearchPayload(req: SearchRequest): Record<string, unknown> {
34
34
  if (req.limit != null) payload.limit = req.limit;
35
35
  if (req.tbs != null) payload.tbs = req.tbs;
36
36
  if (req.location != null) payload.location = req.location;
37
+ if (req.country != null) payload.country = req.country;
37
38
  if (req.ignoreInvalidURLs != null)
38
39
  payload.ignoreInvalidURLs = req.ignoreInvalidURLs;
39
40
  if (req.timeout != null) payload.timeout = req.timeout;
package/src/v2/types.ts CHANGED
@@ -278,12 +278,7 @@ export interface ScrapeOptions {
278
278
  }
279
279
 
280
280
  export type RedactPIIEntity =
281
- | "PERSON"
282
- | "EMAIL"
283
- | "PHONE"
284
- | "LOCATION"
285
- | "FINANCIAL"
286
- | "SECRET";
281
+ "PERSON" | "EMAIL" | "PHONE" | "LOCATION" | "FINANCIAL" | "SECRET";
287
282
 
288
283
  export interface RedactPIIOptions {
289
284
  /**
@@ -324,12 +319,7 @@ export interface ThreatProtectionOptions {
324
319
  }
325
320
 
326
321
  export type ParseFileData =
327
- | Blob
328
- | File
329
- | Buffer
330
- | Uint8Array
331
- | ArrayBuffer
332
- | string;
322
+ Blob | File | Buffer | Uint8Array | ArrayBuffer | string;
333
323
 
334
324
  export interface ParseFile {
335
325
  data: ParseFileData;
@@ -364,11 +354,7 @@ export interface WebhookConfig {
364
354
 
365
355
  // Agent webhook events differ from crawl: has 'action' and 'cancelled', no 'page'
366
356
  export type AgentWebhookEvent =
367
- | "started"
368
- | "action"
369
- | "completed"
370
- | "failed"
371
- | "cancelled";
357
+ "started" | "action" | "completed" | "failed" | "cancelled";
372
358
 
373
359
  export interface AgentWebhookConfig {
374
360
  url: string;
@@ -489,10 +475,7 @@ export interface BrandingProfile {
489
475
  headerHeight?: string;
490
476
  footerHeight?: string;
491
477
  [key: string]:
492
- | number
493
- | string
494
- | Record<string, number | string | undefined>
495
- | undefined;
478
+ number | string | Record<string, number | string | undefined> | undefined;
496
479
  };
497
480
  tone?: {
498
481
  voice?: string;
@@ -866,6 +849,8 @@ export interface SearchRequest {
866
849
  limit?: number;
867
850
  tbs?: string;
868
851
  location?: string;
852
+ /** ISO 3166-1 alpha-2 country code used to geo-target the search results. */
853
+ country?: string;
869
854
  ignoreInvalidURLs?: boolean;
870
855
  timeout?: number; // ms
871
856
  /** Generate query-relevant highlights for search results. Defaults to true. */
@@ -1095,9 +1080,7 @@ export interface MonitorSearchTarget {
1095
1080
  }
1096
1081
 
1097
1082
  export type MonitorTarget =
1098
- | MonitorScrapeTarget
1099
- | MonitorCrawlTarget
1100
- | MonitorSearchTarget;
1083
+ MonitorScrapeTarget | MonitorCrawlTarget | MonitorSearchTarget;
1101
1084
 
1102
1085
  export interface CreateMonitorRequest {
1103
1086
  name: string;
@@ -1220,11 +1203,7 @@ export interface MonitorCheck {
1220
1203
  reservedCredits?: number | null;
1221
1204
  actualCredits?: number | null;
1222
1205
  billingStatus:
1223
- | "not_applicable"
1224
- | "reserved"
1225
- | "confirmed"
1226
- | "released"
1227
- | "failed";
1206
+ "not_applicable" | "reserved" | "confirmed" | "released" | "failed";
1228
1207
  summary: MonitorSummary;
1229
1208
  targetResults?: MonitorTargetResult[];
1230
1209
  notificationStatus?: unknown;
@@ -1311,10 +1290,65 @@ export interface ExtractResponse {
1311
1290
  creditsUsed?: number;
1312
1291
  }
1313
1292
 
1293
+ /** Conversation mode for an agent run. Defaults to "extract" server-side. */
1294
+ export type AgentMode = "extract" | "chat";
1295
+
1296
+ /** Options forwarded verbatim to the agent; the server owns every default. */
1297
+ export interface AgentExchangeOptions {
1298
+ enabled?: boolean;
1299
+ /** At most 5. */
1300
+ toolkits?: string[];
1301
+ maxCalls?: number;
1302
+ requireApproval?: boolean;
1303
+ /** Answers a pendingApproval from the previous turn of the thread. */
1304
+ approve?: { approvalId: string; callIds?: string[]; always?: boolean };
1305
+ decline?: { approvalId: string };
1306
+ }
1307
+
1308
+ /** Per-run summary reported on a status response. */
1309
+ export interface AgentExchangeSummary {
1310
+ enabled: boolean;
1311
+ /** What the run resolved to after thread inheritance, not what it requested. */
1312
+ toolkits?: string[];
1313
+ requireApproval?: boolean;
1314
+ paidCalls: number;
1315
+ creditsUsed: number | null;
1316
+ }
1317
+
1318
+ /** A follow-up the agent offers for the next turn of the thread. */
1319
+ export interface AgentSuggestion {
1320
+ label: string;
1321
+ prompt: string;
1322
+ }
1323
+
1324
+ /** A turn that ended waiting for the caller to allow or refuse paid calls. */
1325
+ export interface PendingApproval {
1326
+ id: string;
1327
+ reason: string;
1328
+ calls: {
1329
+ id: string;
1330
+ provider: string;
1331
+ capability: string;
1332
+ input: Record<string, unknown>;
1333
+ more?: Record<string, unknown>[];
1334
+ creditsEstimate: number | null;
1335
+ }[];
1336
+ resolution: null | {
1337
+ approved: boolean;
1338
+ callIds: string[];
1339
+ always: boolean;
1340
+ byRunId: string;
1341
+ };
1342
+ }
1343
+
1314
1344
  export interface AgentResponse {
1315
1345
  success: boolean;
1316
1346
  id: string;
1317
1347
  error?: string;
1348
+ /** Thread this run belongs to; pass it back to continue the conversation. */
1349
+ threadId?: string;
1350
+ /** 1-based position of this run in its thread. */
1351
+ threadTurn?: number;
1318
1352
  }
1319
1353
 
1320
1354
  export interface AgentStatusResponse {
@@ -1335,6 +1369,55 @@ export interface AgentStatusResponse {
1335
1369
  effort?: "low" | "medium" | "high";
1336
1370
  expiresAt: string;
1337
1371
  creditsUsed?: number;
1372
+ threadId?: string;
1373
+ threadTurn?: number;
1374
+ mode?: AgentMode;
1375
+ /** Assistant text reply. Chat-mode runs answer here instead of in `data`. */
1376
+ message?: string;
1377
+ suggestions?: AgentSuggestion[];
1378
+ pendingApproval?: PendingApproval;
1379
+ exchange?: AgentExchangeSummary;
1380
+ }
1381
+
1382
+ /** A single run of a thread, as returned by getAgentThread. */
1383
+ export interface AgentThreadRun {
1384
+ id: string;
1385
+ turn: number;
1386
+ mode: AgentMode;
1387
+ prompt: string;
1388
+ urls?: string[];
1389
+ schema?: unknown;
1390
+ effort?: "low" | "medium" | "high";
1391
+ status:
1392
+ | "processing"
1393
+ | "succeeded"
1394
+ | "failed"
1395
+ | "cancelled"
1396
+ | "refused"
1397
+ | "credit_limit_reached";
1398
+ createdAt: string;
1399
+ finishedAt: string | null;
1400
+ creditsUsed: number | null;
1401
+ message: string | null;
1402
+ /** Only present when the request asked for includeData. */
1403
+ data?: unknown;
1404
+ suggestions?: AgentSuggestion[] | null;
1405
+ pendingApproval?: PendingApproval | null;
1406
+ exchange?: AgentExchangeSummary | null;
1407
+ }
1408
+
1409
+ export interface AgentThread {
1410
+ id: string;
1411
+ createdAt: string;
1412
+ updatedAt: string;
1413
+ status: "idle" | "running";
1414
+ runs: AgentThreadRun[];
1415
+ }
1416
+
1417
+ export interface AgentThreadResponse {
1418
+ success: boolean;
1419
+ thread?: AgentThread;
1420
+ error?: string;
1338
1421
  }
1339
1422
 
1340
1423
  /** Reasoning effort for agent jobs. Every level runs spark-2. */
@@ -1384,7 +1467,8 @@ export interface AgentListOptions {
1384
1467
  before?: number;
1385
1468
  }
1386
1469
 
1387
- export type AgentTraceAgentRole = "orchestrator" | "subagent" | "browser" | "system";
1470
+ export type AgentTraceAgentRole =
1471
+ "orchestrator" | "subagent" | "browser" | "system";
1388
1472
 
1389
1473
  export interface AgentTraceAgentIdentity {
1390
1474
  id: string;
@@ -1394,7 +1478,12 @@ export interface AgentTraceAgentIdentity {
1394
1478
  }
1395
1479
 
1396
1480
  export interface AgentTraceError {
1397
- code: "cancelled" | "credit_limit_reached" | "parent_finished" | "refused" | "internal";
1481
+ code:
1482
+ | "cancelled"
1483
+ | "credit_limit_reached"
1484
+ | "parent_finished"
1485
+ | "refused"
1486
+ | "internal";
1398
1487
  source: "agent" | "tool" | "billing" | "system";
1399
1488
  retryable: boolean;
1400
1489
  message: string;
@@ -1432,7 +1521,8 @@ export interface AgentTraceRunCancelRequestedEvent extends AgentTraceEventBase {
1432
1521
 
1433
1522
  export interface AgentTraceRunFinishedEvent extends AgentTraceEventBase {
1434
1523
  type: "run.finished";
1435
- outcome: "succeeded" | "failed" | "cancelled" | "refused" | "credit_limit_reached";
1524
+ outcome:
1525
+ "succeeded" | "failed" | "cancelled" | "refused" | "credit_limit_reached";
1436
1526
  /** The canonical schema always writes this key (nullable), but older rows may omit it. */
1437
1527
  error?: AgentTraceError | null;
1438
1528
  }
@@ -1829,7 +1919,14 @@ export interface SimilarPapersResponse {
1829
1919
  note?: string | null;
1830
1920
  }
1831
1921
 
1832
- /** Component scores; each field is present only when that signal contributed. */
1922
+ /**
1923
+ * Component scores; each field is present only when that signal contributed.
1924
+ *
1925
+ * @deprecated Use the developer index instead. The research index GitHub
1926
+ * search stops responding after 2026-11-03. The developer index does not
1927
+ * expose a score breakdown. See
1928
+ * https://docs.firecrawl.dev/features/developer.
1929
+ */
1833
1930
  export interface GitHubScoreBreakdown {
1834
1931
  rrf?: number;
1835
1932
  semantic?: number;
@@ -1838,6 +1935,11 @@ export interface GitHubScoreBreakdown {
1838
1935
  rerank?: number;
1839
1936
  }
1840
1937
 
1938
+ /**
1939
+ * @deprecated Use the developer index instead. The research index GitHub
1940
+ * search stops responding after 2026-11-03. See
1941
+ * https://docs.firecrawl.dev/features/developer.
1942
+ */
1841
1943
  export interface GitHubSearchItem {
1842
1944
  resultType?: "github_history" | "repo_readme" | "web";
1843
1945
  /** `owner/name`; empty for web results whose URL is not a repo page. */
@@ -1860,9 +1962,18 @@ export interface GitHubSearchItem {
1860
1962
  scores: GitHubScoreBreakdown;
1861
1963
  }
1862
1964
 
1965
+ /**
1966
+ * @deprecated Use the developer index instead. The research index GitHub
1967
+ * search stops responding after 2026-11-03. See
1968
+ * https://docs.firecrawl.dev/features/developer.
1969
+ */
1863
1970
  export interface GitHubSearchResponse {
1864
1971
  success: boolean;
1865
1972
  results: GitHubSearchItem[];
1973
+ /** Deprecation notice while the sunset window is live. */
1974
+ warnings?: string[];
1975
+ /** Replacement endpoint path, while the sunset window is live. */
1976
+ replacement?: string;
1866
1977
  }
1867
1978
 
1868
1979
  /** Options for `research.searchPapers`. */
@@ -1901,7 +2012,13 @@ export interface SimilarPapersOptions {
1901
2012
  anchor?: string[];
1902
2013
  }
1903
2014
 
1904
- /** Options for `research.searchGithub`. */
2015
+ /**
2016
+ * Options for `research.searchGithub`.
2017
+ *
2018
+ * @deprecated Use the developer index instead. The research index GitHub
2019
+ * search stops responding after 2026-11-03. See
2020
+ * https://docs.firecrawl.dev/features/developer.
2021
+ */
1905
2022
  export interface SearchGithubOptions {
1906
2023
  /** Number of results to return (1–100, default 20). */
1907
2024
  k?: number;