firecrawl 4.40.0 → 4.42.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/{chunk-OJ4YJQ4J.js → chunk-OCJTYRX5.js} +1 -1
- package/dist/index.cjs +18 -10
- package/dist/index.d.cts +166 -27
- package/dist/index.d.ts +166 -27
- package/dist/index.js +19 -11
- package/dist/{package-F6O7J2XI.js → package-ECWDBUY3.js} +1 -1
- package/package.json +1 -1
- package/src/__tests__/unit/v2/agent-hints.test.ts +116 -0
- package/src/__tests__/unit/v2/agent-thread.unit.test.ts +122 -0
- package/src/__tests__/unit/v2/extract.unit.test.ts +23 -0
- package/src/__tests__/unit/v2/tools.unit.test.ts +66 -9
- package/src/v2/methods/extract.ts +2 -1
- package/src/v2/methods/map.ts +2 -1
- package/src/v2/methods/parse.ts +2 -1
- package/src/v2/methods/scrape.ts +2 -1
- package/src/v2/methods/search.ts +3 -1
- package/src/v2/types.ts +172 -25
- package/src/v2/utils/agentHints.ts +7 -0
- package/src/v2/utils/errorHandler.ts +5 -5
package/src/v2/types.ts
CHANGED
|
@@ -188,6 +188,16 @@ export interface AuditMetadata {
|
|
|
188
188
|
username: string;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
+
/**
|
|
192
|
+
* OCR raster images (PNG, JPEG, JPEG 2000, TIFF, GIF, BMP, WebP, AVIF) as
|
|
193
|
+
* one-page documents. Part of the default parsers list next to "pdf"; takes
|
|
194
|
+
* no options, so the string "image" is equivalent. Omit it from an explicit
|
|
195
|
+
* list to keep image URLs failing as unsupported files.
|
|
196
|
+
*/
|
|
197
|
+
export type ImageParser = {
|
|
198
|
+
type: "image";
|
|
199
|
+
};
|
|
200
|
+
|
|
191
201
|
export type PDFParser = {
|
|
192
202
|
type: "pdf";
|
|
193
203
|
mode?: "fast" | "auto" | "ocr";
|
|
@@ -249,7 +259,7 @@ export interface ScrapeOptions {
|
|
|
249
259
|
timeout?: number;
|
|
250
260
|
waitFor?: number;
|
|
251
261
|
mobile?: boolean;
|
|
252
|
-
parsers?: Array<string | PDFParser>;
|
|
262
|
+
parsers?: Array<string | PDFParser | ImageParser>;
|
|
253
263
|
actions?: ActionOption[];
|
|
254
264
|
location?: LocationConfig;
|
|
255
265
|
skipTlsVerification?: boolean;
|
|
@@ -275,8 +285,10 @@ export interface ScrapeOptions {
|
|
|
275
285
|
};
|
|
276
286
|
integration?: string;
|
|
277
287
|
origin?: string;
|
|
278
|
-
/** Include domain-matched Alexandria
|
|
288
|
+
/** Include domain-matched Alexandria tools for this URL in `tools`. Default off. */
|
|
279
289
|
domainTools?: boolean;
|
|
290
|
+
/** Summary by default; compact returns identity and description, full includes contracts. */
|
|
291
|
+
toolDetail?: "compact" | "summary" | "full";
|
|
280
292
|
}
|
|
281
293
|
|
|
282
294
|
export type RedactPIIEntity =
|
|
@@ -306,8 +318,14 @@ export interface RedactPIIOptions {
|
|
|
306
318
|
* fields you provide replace the team policy's values.
|
|
307
319
|
*/
|
|
308
320
|
export interface ThreatProtectionOptions {
|
|
309
|
-
/**
|
|
310
|
-
|
|
321
|
+
/**
|
|
322
|
+
* "off" disables scanning for this request; "manual-only" enforces only the
|
|
323
|
+
* blacklist / whitelist / blocked TLDs (no provider scan, no scan fee);
|
|
324
|
+
* "normal" scans with Google Web Risk; "zscaler" classifies through your
|
|
325
|
+
* organization's Zscaler connection. Enforced teams may raise the mode per
|
|
326
|
+
* request but never lower it.
|
|
327
|
+
*/
|
|
328
|
+
mode?: "off" | "manual-only" | "normal" | "zscaler";
|
|
311
329
|
/** Block verdicts at or above this risk score (integer 0-100). */
|
|
312
330
|
riskScoreThreshold?: number;
|
|
313
331
|
/** Exact domains or globs like "*.example.com" to always block (max 1000). */
|
|
@@ -342,6 +360,7 @@ export type ParseOptions = Omit<
|
|
|
342
360
|
| "lockdown"
|
|
343
361
|
| "proxy"
|
|
344
362
|
| "threatProtection"
|
|
363
|
+
| "toolDetail"
|
|
345
364
|
> & {
|
|
346
365
|
formats?: ParseFormatOption[];
|
|
347
366
|
proxy?: "basic" | "auto";
|
|
@@ -659,6 +678,8 @@ export interface DocumentMetadata {
|
|
|
659
678
|
}
|
|
660
679
|
|
|
661
680
|
export interface Document {
|
|
681
|
+
/** API guidance, separate from extracted page content. */
|
|
682
|
+
agent_hints?: string[];
|
|
662
683
|
markdown?: string;
|
|
663
684
|
html?: string;
|
|
664
685
|
rawHtml?: string;
|
|
@@ -801,6 +822,7 @@ export interface SearchResultImages {
|
|
|
801
822
|
}
|
|
802
823
|
|
|
803
824
|
export interface SearchData {
|
|
825
|
+
agent_hints?: string[];
|
|
804
826
|
warning?: string;
|
|
805
827
|
web?: Array<SearchResultWeb | Document>;
|
|
806
828
|
news?: Array<SearchResultNews | Document>;
|
|
@@ -810,14 +832,15 @@ export interface SearchData {
|
|
|
810
832
|
|
|
811
833
|
/** A complete tool contract returned by semantic or contextual discovery. */
|
|
812
834
|
export interface DiscoveredTool {
|
|
835
|
+
next?: AlexandriaCall;
|
|
813
836
|
id?: string;
|
|
814
837
|
provider: string;
|
|
815
838
|
capability: string;
|
|
816
|
-
name
|
|
839
|
+
name?: string;
|
|
817
840
|
description: string;
|
|
818
|
-
creditsCost
|
|
819
|
-
perRecord
|
|
820
|
-
options
|
|
841
|
+
creditsCost?: number;
|
|
842
|
+
perRecord?: boolean;
|
|
843
|
+
options?: Array<{
|
|
821
844
|
name: string;
|
|
822
845
|
type: string;
|
|
823
846
|
required?: boolean;
|
|
@@ -954,8 +977,10 @@ export interface CategoryOption {
|
|
|
954
977
|
|
|
955
978
|
export interface SearchRequest {
|
|
956
979
|
query: string;
|
|
957
|
-
/** Include domain-matched
|
|
980
|
+
/** Include domain-matched tools in tools alongside semantic matches. */
|
|
958
981
|
domainTools?: boolean;
|
|
982
|
+
/** Compact by default; summary adds metadata, full includes contracts. */
|
|
983
|
+
toolDetail?: "compact" | "summary" | "full";
|
|
959
984
|
sources?: Array<
|
|
960
985
|
"web" | "news" | "images" | "alexandria"
|
|
961
986
|
| { type: "web" | "news" | "images" | "alexandria" }
|
|
@@ -982,7 +1007,7 @@ export interface SearchRequest {
|
|
|
982
1007
|
timeout?: number; // ms
|
|
983
1008
|
/** Generate query-relevant highlights for search results. Defaults to true. */
|
|
984
1009
|
highlights?: boolean;
|
|
985
|
-
scrapeOptions?: ScrapeOptions
|
|
1010
|
+
scrapeOptions?: Omit<ScrapeOptions, "toolDetail">;
|
|
986
1011
|
/**
|
|
987
1012
|
* Enterprise search options. Use `["zdr"]` for end-to-end Zero Data
|
|
988
1013
|
* Retention or `["anon"]` for anonymized search. Must be enabled for
|
|
@@ -1011,7 +1036,7 @@ export interface CrawlOptions {
|
|
|
1011
1036
|
delay?: number | null;
|
|
1012
1037
|
maxConcurrency?: number | null;
|
|
1013
1038
|
webhook?: string | WebhookConfig | null;
|
|
1014
|
-
scrapeOptions?: ScrapeOptions | null;
|
|
1039
|
+
scrapeOptions?: Omit<ScrapeOptions, "toolDetail"> | null;
|
|
1015
1040
|
regexOnFullURL?: boolean;
|
|
1016
1041
|
zeroDataRetention?: boolean;
|
|
1017
1042
|
integration?: string;
|
|
@@ -1035,7 +1060,7 @@ export interface CrawlJob {
|
|
|
1035
1060
|
}
|
|
1036
1061
|
|
|
1037
1062
|
export interface BatchScrapeOptions {
|
|
1038
|
-
options?: ScrapeOptions
|
|
1063
|
+
options?: Omit<ScrapeOptions, "toolDetail">;
|
|
1039
1064
|
webhook?: string | WebhookConfig;
|
|
1040
1065
|
appendToId?: string;
|
|
1041
1066
|
ignoreInvalidURLs?: boolean;
|
|
@@ -1064,6 +1089,7 @@ export interface BatchScrapeJob {
|
|
|
1064
1089
|
}
|
|
1065
1090
|
|
|
1066
1091
|
export interface MapData {
|
|
1092
|
+
agent_hints?: string[];
|
|
1067
1093
|
id?: string;
|
|
1068
1094
|
links: SearchResultWeb[];
|
|
1069
1095
|
}
|
|
@@ -1185,7 +1211,7 @@ export interface MonitorScrapeTarget {
|
|
|
1185
1211
|
id?: string;
|
|
1186
1212
|
type: "scrape";
|
|
1187
1213
|
urls: string[];
|
|
1188
|
-
scrapeOptions?: ScrapeOptions
|
|
1214
|
+
scrapeOptions?: Omit<ScrapeOptions, "toolDetail">;
|
|
1189
1215
|
}
|
|
1190
1216
|
|
|
1191
1217
|
export interface MonitorCrawlTarget {
|
|
@@ -1193,7 +1219,7 @@ export interface MonitorCrawlTarget {
|
|
|
1193
1219
|
type: "crawl";
|
|
1194
1220
|
url: string;
|
|
1195
1221
|
crawlOptions?: CrawlOptions;
|
|
1196
|
-
scrapeOptions?: ScrapeOptions
|
|
1222
|
+
scrapeOptions?: Omit<ScrapeOptions, "toolDetail">;
|
|
1197
1223
|
}
|
|
1198
1224
|
|
|
1199
1225
|
export interface MonitorSearchTarget {
|
|
@@ -1427,9 +1453,83 @@ export interface AgentExchangeOptions {
|
|
|
1427
1453
|
toolkits?: string[];
|
|
1428
1454
|
maxCalls?: number;
|
|
1429
1455
|
requireApproval?: boolean;
|
|
1430
|
-
/**
|
|
1456
|
+
/**
|
|
1457
|
+
* Answers a pendingApproval from the previous turn of the thread. A `terms`
|
|
1458
|
+
* approval is accepted or declined as a whole: `callIds` and `always` are
|
|
1459
|
+
* ignored on it.
|
|
1460
|
+
*/
|
|
1431
1461
|
approve?: { approvalId: string; callIds?: string[]; always?: boolean };
|
|
1432
1462
|
decline?: { approvalId: string };
|
|
1463
|
+
/**
|
|
1464
|
+
* What to do when a provider the agent would use needs data terms the team
|
|
1465
|
+
* has not accepted. Gated providers are never called in any mode:
|
|
1466
|
+
* - "skip" (server default): answer with accepted providers only and list
|
|
1467
|
+
* the gated ones in `exchange.skippedProviders`.
|
|
1468
|
+
* - "ask": the same, plus `exchange.requiresAction` and a `terms`
|
|
1469
|
+
* pendingApproval. Get your user's explicit consent, call terms/accept,
|
|
1470
|
+
* then continue the thread with `approve: { approvalId }`.
|
|
1471
|
+
* Terms gating is rolling out: until it is on for a thread, none of the
|
|
1472
|
+
* terms fields appear. There is no auto-accept mode. Omitted on a follow-up turn inherits the
|
|
1473
|
+
* previous turn's value.
|
|
1474
|
+
*/
|
|
1475
|
+
onTermsRequired?: AgentOnTermsRequired;
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
export type AgentOnTermsRequired = "skip" | "ask";
|
|
1479
|
+
|
|
1480
|
+
/** A gated provider the run would have used but did not. */
|
|
1481
|
+
export interface AgentSkippedProvider {
|
|
1482
|
+
provider: string;
|
|
1483
|
+
name: string;
|
|
1484
|
+
capability?: string;
|
|
1485
|
+
/** What it would have added, in the agent's words. */
|
|
1486
|
+
adds?: string;
|
|
1487
|
+
reason: "terms_required";
|
|
1488
|
+
/** The gating terms version. */
|
|
1489
|
+
version: string;
|
|
1490
|
+
/** Where a person accepts the terms in the dashboard. */
|
|
1491
|
+
termsUrl: string;
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
/**
|
|
1495
|
+
* The exact Exchange calls to view and accept a provider's terms. Nothing here
|
|
1496
|
+
* is executed for you, and terms/accept must only be called after the user
|
|
1497
|
+
* has explicitly agreed to that provider's terms.
|
|
1498
|
+
*/
|
|
1499
|
+
export interface AgentTermsRequiredAction {
|
|
1500
|
+
type: "accept_terms";
|
|
1501
|
+
/**
|
|
1502
|
+
* The `terms` pendingApproval that answers this. After the user agrees and
|
|
1503
|
+
* terms/accept succeeds, continue the thread with
|
|
1504
|
+
* `exchange.approve: { approvalId }`, or refuse with `decline`.
|
|
1505
|
+
*/
|
|
1506
|
+
approvalId: string;
|
|
1507
|
+
providers: {
|
|
1508
|
+
provider: string;
|
|
1509
|
+
name: string;
|
|
1510
|
+
capability?: string;
|
|
1511
|
+
adds?: string;
|
|
1512
|
+
version: string;
|
|
1513
|
+
/** null when the catalog published no digest; terms/show returns it. */
|
|
1514
|
+
digest: string | null;
|
|
1515
|
+
url: string;
|
|
1516
|
+
show: {
|
|
1517
|
+
provider: "firecrawl";
|
|
1518
|
+
capability: "terms/show";
|
|
1519
|
+
options: { provider: string };
|
|
1520
|
+
};
|
|
1521
|
+
accept: {
|
|
1522
|
+
provider: "firecrawl";
|
|
1523
|
+
capability: "terms/accept";
|
|
1524
|
+
options: {
|
|
1525
|
+
provider: string;
|
|
1526
|
+
version: string;
|
|
1527
|
+
/** null when the catalog published no digest; terms/show returns it. */
|
|
1528
|
+
digest: string | null;
|
|
1529
|
+
confirmed: true;
|
|
1530
|
+
};
|
|
1531
|
+
};
|
|
1532
|
+
}[];
|
|
1433
1533
|
}
|
|
1434
1534
|
|
|
1435
1535
|
/** Per-run summary reported on a status response. */
|
|
@@ -1438,8 +1538,26 @@ export interface AgentExchangeSummary {
|
|
|
1438
1538
|
/** What the run resolved to after thread inheritance, not what it requested. */
|
|
1439
1539
|
toolkits?: string[];
|
|
1440
1540
|
requireApproval?: boolean;
|
|
1541
|
+
onTermsRequired?: AgentOnTermsRequired;
|
|
1441
1542
|
paidCalls: number;
|
|
1442
1543
|
creditsUsed: number | null;
|
|
1544
|
+
/** Gated providers that would have helped and were not used. Any mode. */
|
|
1545
|
+
skippedProviders?: AgentSkippedProvider[];
|
|
1546
|
+
/** "ask" mode, when a terms offer ended the turn. */
|
|
1547
|
+
requiresAction?: AgentTermsRequiredAction;
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
/** A provider in a `terms` pendingApproval. */
|
|
1551
|
+
export interface AgentTermsGate {
|
|
1552
|
+
provider: string;
|
|
1553
|
+
name: string;
|
|
1554
|
+
logo?: string;
|
|
1555
|
+
capability?: string;
|
|
1556
|
+
adds?: string;
|
|
1557
|
+
version: string;
|
|
1558
|
+
/** null when the catalog published no digest; terms/show returns it. */
|
|
1559
|
+
digest: string | null;
|
|
1560
|
+
url: string;
|
|
1443
1561
|
}
|
|
1444
1562
|
|
|
1445
1563
|
/** A follow-up the agent offers for the next turn of the thread. */
|
|
@@ -1448,26 +1566,52 @@ export interface AgentSuggestion {
|
|
|
1448
1566
|
prompt: string;
|
|
1449
1567
|
}
|
|
1450
1568
|
|
|
1451
|
-
/** A
|
|
1452
|
-
export interface
|
|
1569
|
+
/** A paid call a `calls` pendingApproval is holding back. */
|
|
1570
|
+
export interface PendingApprovalCall {
|
|
1571
|
+
id: string;
|
|
1572
|
+
provider: string;
|
|
1573
|
+
capability: string;
|
|
1574
|
+
input: Record<string, unknown>;
|
|
1575
|
+
more?: Record<string, unknown>[];
|
|
1576
|
+
creditsEstimate: number | null;
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
interface PendingApprovalBase {
|
|
1453
1580
|
id: string;
|
|
1454
1581
|
reason: string;
|
|
1455
|
-
calls: {
|
|
1456
|
-
id: string;
|
|
1457
|
-
provider: string;
|
|
1458
|
-
capability: string;
|
|
1459
|
-
input: Record<string, unknown>;
|
|
1460
|
-
more?: Record<string, unknown>[];
|
|
1461
|
-
creditsEstimate: number | null;
|
|
1462
|
-
}[];
|
|
1463
1582
|
resolution: null | {
|
|
1464
1583
|
approved: boolean;
|
|
1584
|
+
/** Calls approved. Ignored on terms offers. */
|
|
1465
1585
|
callIds: string[];
|
|
1466
1586
|
always: boolean;
|
|
1467
1587
|
byRunId: string;
|
|
1468
1588
|
};
|
|
1469
1589
|
}
|
|
1470
1590
|
|
|
1591
|
+
/**
|
|
1592
|
+
* A turn that ended waiting for the caller to allow or refuse paid calls.
|
|
1593
|
+
* `kind` is absent on items written before terms offers existed.
|
|
1594
|
+
*/
|
|
1595
|
+
export interface PendingCallsApproval extends PendingApprovalBase {
|
|
1596
|
+
kind?: "calls";
|
|
1597
|
+
calls: PendingApprovalCall[];
|
|
1598
|
+
terms?: never;
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
/**
|
|
1602
|
+
* A turn that ended waiting for the caller to accept providers' data terms
|
|
1603
|
+
* ("ask" mode). `calls` is always empty (typed `never[]` rather
|
|
1604
|
+
* than `[]` so existing `pendingApproval.calls[0]` code still compiles).
|
|
1605
|
+
*/
|
|
1606
|
+
export interface PendingTermsApproval extends PendingApprovalBase {
|
|
1607
|
+
kind: "terms";
|
|
1608
|
+
calls: never[];
|
|
1609
|
+
terms: AgentTermsGate[];
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
/** Narrow on `kind === "terms"`. */
|
|
1613
|
+
export type PendingApproval = PendingCallsApproval | PendingTermsApproval;
|
|
1614
|
+
|
|
1471
1615
|
export interface AgentResponse {
|
|
1472
1616
|
success: boolean;
|
|
1473
1617
|
id: string;
|
|
@@ -1854,6 +1998,7 @@ export function parseRequiresAction(value: unknown): RequiresAction | undefined
|
|
|
1854
1998
|
}
|
|
1855
1999
|
|
|
1856
2000
|
export class SdkError extends Error {
|
|
2001
|
+
declare agent_hints?: string[];
|
|
1857
2002
|
requestId?: string;
|
|
1858
2003
|
status?: number;
|
|
1859
2004
|
code?: string;
|
|
@@ -1934,11 +2079,13 @@ export interface BrowserExecuteResponse {
|
|
|
1934
2079
|
stderr?: string;
|
|
1935
2080
|
exitCode?: number;
|
|
1936
2081
|
killed?: boolean;
|
|
2082
|
+
truncated?: boolean;
|
|
1937
2083
|
error?: string;
|
|
1938
2084
|
}
|
|
1939
2085
|
|
|
1940
2086
|
export interface BrowserDeleteResponse {
|
|
1941
2087
|
success: boolean;
|
|
2088
|
+
status?: string;
|
|
1942
2089
|
sessionDurationMs?: number;
|
|
1943
2090
|
creditsBilled?: number;
|
|
1944
2091
|
error?: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Keep response guidance as metadata when convenience methods unwrap data. */
|
|
2
|
+
export function agentHintMetadata(body: unknown): { agent_hints?: string[] } {
|
|
3
|
+
const hints = (body as { agent_hints?: unknown } | null)?.agent_hints;
|
|
4
|
+
return Array.isArray(hints) && hints.every((hint) => typeof hint === "string")
|
|
5
|
+
? { agent_hints: [...hints] }
|
|
6
|
+
: {};
|
|
7
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type AxiosError, type AxiosResponse } from "axios";
|
|
2
2
|
import { SdkError, JobTimeoutError, parseRequiresAction } from "../types";
|
|
3
|
+
import { agentHintMetadata } from "./agentHints";
|
|
3
4
|
|
|
4
5
|
export function throwForBadResponse(resp: AxiosResponse, action: string): never {
|
|
5
6
|
const status = resp.status;
|
|
6
7
|
const body = resp.data || {};
|
|
7
8
|
const msg = body?.error || body?.message || `Request failed (${status}) while trying to ${action}`;
|
|
8
|
-
throw new SdkError(
|
|
9
|
+
throw Object.assign(new SdkError(
|
|
9
10
|
msg,
|
|
10
11
|
status,
|
|
11
12
|
body?.code,
|
|
@@ -13,7 +14,7 @@ export function throwForBadResponse(resp: AxiosResponse, action: string): never
|
|
|
13
14
|
undefined,
|
|
14
15
|
body?.chargeId,
|
|
15
16
|
parseRequiresAction(body?.requiresAction),
|
|
16
|
-
);
|
|
17
|
+
), agentHintMetadata(body));
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export function normalizeAxiosError(err: AxiosError, action: string): never {
|
|
@@ -21,7 +22,7 @@ export function normalizeAxiosError(err: AxiosError, action: string): never {
|
|
|
21
22
|
const body: any = err.response?.data;
|
|
22
23
|
const message = body?.error || err.message || `Request failed${status ? ` (${status})` : ""} while trying to ${action}`;
|
|
23
24
|
const code = (body?.code as string) || err.code;
|
|
24
|
-
throw new SdkError(
|
|
25
|
+
throw Object.assign(new SdkError(
|
|
25
26
|
message,
|
|
26
27
|
status,
|
|
27
28
|
code,
|
|
@@ -29,7 +30,7 @@ export function normalizeAxiosError(err: AxiosError, action: string): never {
|
|
|
29
30
|
undefined,
|
|
30
31
|
body?.chargeId,
|
|
31
32
|
parseRequiresAction(body?.requiresAction),
|
|
32
|
-
);
|
|
33
|
+
), agentHintMetadata(body));
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
export function isRetryableError(err: any): boolean {
|
|
@@ -64,4 +65,3 @@ export function isRetryableError(err: any): boolean {
|
|
|
64
65
|
// Default: retry on unknown errors (safer than not retrying)
|
|
65
66
|
return true;
|
|
66
67
|
}
|
|
67
|
-
|