firecrawl 4.37.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 (33) hide show
  1. package/README.md +7 -2
  2. package/dist/{chunk-LFX7WDGT.js → chunk-4DPCCKWG.js} +1 -1
  3. package/dist/index.cjs +61 -9
  4. package/dist/index.d.cts +202 -4
  5. package/dist/index.d.ts +202 -4
  6. package/dist/index.js +62 -10
  7. package/dist/{package-SHMK2LJE.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-list.unit.test.ts +68 -0
  22. package/src/__tests__/unit/v2/agent-thread.unit.test.ts +164 -0
  23. package/src/__tests__/unit/v2/e2eRateLimitRetry.test.ts +501 -0
  24. package/src/__tests__/unit/v2/extract.unit.test.ts +1 -1
  25. package/src/__tests__/unit/v2/scrapeAutoResume.test.ts +1 -1
  26. package/src/__tests__/unit/v2/search-country.unit.test.ts +32 -0
  27. package/src/__tests__/unit/v2/search-data-property.test.ts +1 -0
  28. package/src/__tests__/unit/v2/v1-aliases.test.ts +1 -0
  29. package/src/v2/client.ts +26 -1
  30. package/src/v2/methods/agent.ts +35 -1
  31. package/src/v2/methods/research.ts +14 -8
  32. package/src/v2/methods/search.ts +1 -0
  33. package/src/v2/types.ts +195 -34
@@ -159,9 +159,9 @@ export class ResearchClient {
159
159
  appendParam(params, "query", options.query);
160
160
  appendParam(params, "k", options.k);
161
161
  try {
162
- const res = await this.http.get<PaperMetadataResponse | ReadPaperResponse>(
163
- withQuery(`${BASE}/papers/${encodeURIComponent(id)}`, params),
164
- );
162
+ const res = await this.http.get<
163
+ PaperMetadataResponse | ReadPaperResponse
164
+ >(withQuery(`${BASE}/papers/${encodeURIComponent(id)}`, params));
165
165
  if (res.status !== 200) throwForBadResponse(res, "get paper");
166
166
  return res.data;
167
167
  } catch (err) {
@@ -191,10 +191,7 @@ export class ResearchClient {
191
191
  appendParam(params, "anchor", options.anchor);
192
192
  try {
193
193
  const res = await this.http.get<SimilarPapersResponse>(
194
- withQuery(
195
- `${BASE}/papers/${encodeURIComponent(id)}/similar`,
196
- params,
197
- ),
194
+ withQuery(`${BASE}/papers/${encodeURIComponent(id)}/similar`, params),
198
195
  );
199
196
  if (res.status !== 200) throwForBadResponse(res, "find similar papers");
200
197
  return res.data;
@@ -204,7 +201,16 @@ export class ResearchClient {
204
201
  }
205
202
 
206
203
  /**
207
- * Search GitHub issue/PR history and repository readmes.
204
+ * Search the research index GitHub slice: issue/PR history and repository
205
+ * readmes.
206
+ *
207
+ * @deprecated Use `developerSearch()` on the client instead. This
208
+ * endpoint stops responding after 2026-11-03. The developer index searches
209
+ * GitHub issues, pull requests and readmes plus curated documentation
210
+ * sources, returns matched passages, and adds filters for repo, language,
211
+ * license and stars. It does not carry over the `scores` breakdown or the
212
+ * `resultType: "web"` fallback results. See
213
+ * https://docs.firecrawl.dev/features/developer.
208
214
  * @param query Search query.
209
215
  * @param options Optional `k`.
210
216
  */
@@ -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,12 +1369,106 @@ 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. */
1341
1424
  export type AgentEffort = "low" | "medium" | "high";
1342
1425
 
1343
- export type AgentTraceAgentRole = "orchestrator" | "subagent" | "browser" | "system";
1426
+ /** A single agent run as returned by the agent list endpoint. */
1427
+ export interface AgentListItem {
1428
+ id: string;
1429
+ createdAt: string;
1430
+ targetHint: string;
1431
+ origin: string;
1432
+ integration?: string;
1433
+ settings: {
1434
+ hidden: boolean;
1435
+ starred: boolean;
1436
+ label?: string;
1437
+ };
1438
+ status: "processing" | "completed" | "failed";
1439
+ options?: {
1440
+ urls?: string[];
1441
+ prompt: string;
1442
+ schema?: unknown;
1443
+ /**
1444
+ * Server-provided model name. Widened past the request-side union on
1445
+ * purpose: new models ship without an SDK release, so pinning this to
1446
+ * known names makes every future model a type error at the call site.
1447
+ */
1448
+ model: "spark-1-pro" | "spark-1-mini" | "spark-2" | (string & {});
1449
+ effort?: AgentEffort;
1450
+ };
1451
+ }
1452
+
1453
+ export interface AgentListResponse {
1454
+ success: boolean;
1455
+ agents?: AgentListItem[];
1456
+ /**
1457
+ * Absolute URL of the next page (pass its `before` value to listAgents to
1458
+ * continue). Only present when more pages exist.
1459
+ */
1460
+ next?: string;
1461
+ error?: string;
1462
+ }
1463
+
1464
+ /** Options for listing agent runs. */
1465
+ export interface AgentListOptions {
1466
+ /** Only return agent runs created before this unix millisecond timestamp. */
1467
+ before?: number;
1468
+ }
1469
+
1470
+ export type AgentTraceAgentRole =
1471
+ "orchestrator" | "subagent" | "browser" | "system";
1344
1472
 
1345
1473
  export interface AgentTraceAgentIdentity {
1346
1474
  id: string;
@@ -1350,7 +1478,12 @@ export interface AgentTraceAgentIdentity {
1350
1478
  }
1351
1479
 
1352
1480
  export interface AgentTraceError {
1353
- code: "cancelled" | "credit_limit_reached" | "parent_finished" | "refused" | "internal";
1481
+ code:
1482
+ | "cancelled"
1483
+ | "credit_limit_reached"
1484
+ | "parent_finished"
1485
+ | "refused"
1486
+ | "internal";
1354
1487
  source: "agent" | "tool" | "billing" | "system";
1355
1488
  retryable: boolean;
1356
1489
  message: string;
@@ -1388,7 +1521,8 @@ export interface AgentTraceRunCancelRequestedEvent extends AgentTraceEventBase {
1388
1521
 
1389
1522
  export interface AgentTraceRunFinishedEvent extends AgentTraceEventBase {
1390
1523
  type: "run.finished";
1391
- outcome: "succeeded" | "failed" | "cancelled" | "refused" | "credit_limit_reached";
1524
+ outcome:
1525
+ "succeeded" | "failed" | "cancelled" | "refused" | "credit_limit_reached";
1392
1526
  /** The canonical schema always writes this key (nullable), but older rows may omit it. */
1393
1527
  error?: AgentTraceError | null;
1394
1528
  }
@@ -1785,7 +1919,14 @@ export interface SimilarPapersResponse {
1785
1919
  note?: string | null;
1786
1920
  }
1787
1921
 
1788
- /** 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
+ */
1789
1930
  export interface GitHubScoreBreakdown {
1790
1931
  rrf?: number;
1791
1932
  semantic?: number;
@@ -1794,6 +1935,11 @@ export interface GitHubScoreBreakdown {
1794
1935
  rerank?: number;
1795
1936
  }
1796
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
+ */
1797
1943
  export interface GitHubSearchItem {
1798
1944
  resultType?: "github_history" | "repo_readme" | "web";
1799
1945
  /** `owner/name`; empty for web results whose URL is not a repo page. */
@@ -1816,9 +1962,18 @@ export interface GitHubSearchItem {
1816
1962
  scores: GitHubScoreBreakdown;
1817
1963
  }
1818
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
+ */
1819
1970
  export interface GitHubSearchResponse {
1820
1971
  success: boolean;
1821
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;
1822
1977
  }
1823
1978
 
1824
1979
  /** Options for `research.searchPapers`. */
@@ -1857,7 +2012,13 @@ export interface SimilarPapersOptions {
1857
2012
  anchor?: string[];
1858
2013
  }
1859
2014
 
1860
- /** 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
+ */
1861
2022
  export interface SearchGithubOptions {
1862
2023
  /** Number of results to return (1–100, default 20). */
1863
2024
  k?: number;