firecrawl 4.42.1 → 4.42.3
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/README.md +7 -0
- package/dist/{chunk-YG554MNR.js → chunk-AMV6GR2H.js} +3 -3
- package/dist/index.cjs +31 -12
- package/dist/index.d.cts +35 -10
- package/dist/index.d.ts +35 -10
- package/dist/index.js +30 -11
- package/dist/{package-FOKY5K5X.js → package-RQDQRVLO.js} +1 -1
- package/package.json +3 -3
- package/pnpm-workspace.yaml +6 -1
- package/src/__tests__/e2e/v2/parse.test.ts +26 -0
- package/src/__tests__/unit/v1/batch-scrape-poll.test.ts +91 -0
- package/src/__tests__/unit/v1/monitor-job-status-retry.test.ts +84 -131
- package/src/__tests__/unit/v2/parse-formats.unit.test.ts +84 -0
- package/src/__tests__/unit/v2/scrape.unit.test.ts +55 -6
- package/src/v1/index.ts +12 -9
- package/src/v2/client.ts +10 -1
- package/src/v2/methods/agent.ts +1 -0
- package/src/v2/methods/parse.ts +12 -1
- package/src/v2/types.ts +20 -0
package/README.md
CHANGED
|
@@ -102,6 +102,13 @@ const parsed = await app.parse(
|
|
|
102
102
|
console.log(parsed.markdown);
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
+
To see which file formats `parse` accepts, call `getParseFormats`. Each entry has `format`, `kind` (for example, `document` or `image`), `extensions`, `mimeTypes`, and `available` (false when the format is not enabled on this deployment).
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
const formats = await app.getParseFormats();
|
|
109
|
+
console.log(formats.filter((f) => f.available).map((f) => f.format));
|
|
110
|
+
```
|
|
111
|
+
|
|
105
112
|
### Crawling a Website
|
|
106
113
|
|
|
107
114
|
To crawl a website with error handling, use the `crawl` method. It takes the starting URL and optional parameters, including limits and per‑page `scrapeOptions`.
|
|
@@ -12,7 +12,7 @@ var require_package = __commonJS({
|
|
|
12
12
|
"package.json"(exports, module) {
|
|
13
13
|
module.exports = {
|
|
14
14
|
name: "@mendable/firecrawl-js",
|
|
15
|
-
version: "4.42.
|
|
15
|
+
version: "4.42.3",
|
|
16
16
|
description: "JavaScript SDK for the Firecrawl API: web scraping, crawling, web search, and scientific literature search over a research paper index of PubMed, bioRxiv, medRxiv and arXiv abstracts",
|
|
17
17
|
main: "dist/index.js",
|
|
18
18
|
types: "dist/index.d.ts",
|
|
@@ -29,7 +29,7 @@ var require_package = __commonJS({
|
|
|
29
29
|
"build-and-publish": "pnpm run build && pnpm publish --access public",
|
|
30
30
|
"publish-beta": "pnpm run build && pnpm publish --access public --tag beta",
|
|
31
31
|
test: "NODE_OPTIONS=--experimental-vm-modules jest --verbose src/__tests__/e2e/v2/*.test.ts --detectOpenHandles",
|
|
32
|
-
"test:unit": "NODE_OPTIONS=--experimental-vm-modules jest --verbose src/__tests__/unit
|
|
32
|
+
"test:unit": "NODE_OPTIONS=--experimental-vm-modules jest --verbose src/__tests__/unit"
|
|
33
33
|
},
|
|
34
34
|
repository: {
|
|
35
35
|
type: "git",
|
|
@@ -38,7 +38,7 @@ var require_package = __commonJS({
|
|
|
38
38
|
author: "Mendable.ai",
|
|
39
39
|
license: "MIT",
|
|
40
40
|
dependencies: {
|
|
41
|
-
axios: "1.
|
|
41
|
+
axios: "1.20.0",
|
|
42
42
|
firecrawl: "4.30.1",
|
|
43
43
|
"typescript-event-target": "^1.1.1",
|
|
44
44
|
zod: "^3.23.8",
|
package/dist/index.cjs
CHANGED
|
@@ -39,7 +39,7 @@ var require_package = __commonJS({
|
|
|
39
39
|
"package.json"(exports2, module2) {
|
|
40
40
|
module2.exports = {
|
|
41
41
|
name: "@mendable/firecrawl-js",
|
|
42
|
-
version: "4.42.
|
|
42
|
+
version: "4.42.3",
|
|
43
43
|
description: "JavaScript SDK for the Firecrawl API: web scraping, crawling, web search, and scientific literature search over a research paper index of PubMed, bioRxiv, medRxiv and arXiv abstracts",
|
|
44
44
|
main: "dist/index.js",
|
|
45
45
|
types: "dist/index.d.ts",
|
|
@@ -56,7 +56,7 @@ var require_package = __commonJS({
|
|
|
56
56
|
"build-and-publish": "pnpm run build && pnpm publish --access public",
|
|
57
57
|
"publish-beta": "pnpm run build && pnpm publish --access public --tag beta",
|
|
58
58
|
test: "NODE_OPTIONS=--experimental-vm-modules jest --verbose src/__tests__/e2e/v2/*.test.ts --detectOpenHandles",
|
|
59
|
-
"test:unit": "NODE_OPTIONS=--experimental-vm-modules jest --verbose src/__tests__/unit
|
|
59
|
+
"test:unit": "NODE_OPTIONS=--experimental-vm-modules jest --verbose src/__tests__/unit"
|
|
60
60
|
},
|
|
61
61
|
repository: {
|
|
62
62
|
type: "git",
|
|
@@ -65,7 +65,7 @@ var require_package = __commonJS({
|
|
|
65
65
|
author: "Mendable.ai",
|
|
66
66
|
license: "MIT",
|
|
67
67
|
dependencies: {
|
|
68
|
-
axios: "1.
|
|
68
|
+
axios: "1.20.0",
|
|
69
69
|
firecrawl: "4.30.1",
|
|
70
70
|
"typescript-event-target": "^1.1.1",
|
|
71
71
|
zod: "^3.23.8",
|
|
@@ -786,6 +786,16 @@ async function parse(http, file, options) {
|
|
|
786
786
|
throw err;
|
|
787
787
|
}
|
|
788
788
|
}
|
|
789
|
+
async function getParseFormats(http) {
|
|
790
|
+
try {
|
|
791
|
+
const res = await http.get("/v2/parse/formats");
|
|
792
|
+
if (res.status !== 200 || !res.data?.success) throwForBadResponse(res, "get parse formats");
|
|
793
|
+
return res.data.data?.formats ?? [];
|
|
794
|
+
} catch (err) {
|
|
795
|
+
if (err?.isAxiosError) return normalizeAxiosError(err, "get parse formats");
|
|
796
|
+
throw err;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
789
799
|
|
|
790
800
|
// src/v2/methods/search.ts
|
|
791
801
|
function prepareSearchPayload(req) {
|
|
@@ -2368,6 +2378,13 @@ var FirecrawlClient = class {
|
|
|
2368
2378
|
async parse(file, options) {
|
|
2369
2379
|
return parse(this.http, file, options);
|
|
2370
2380
|
}
|
|
2381
|
+
/**
|
|
2382
|
+
* List the file formats the parse endpoint accepts on this deployment.
|
|
2383
|
+
* @returns Formats with their kind, extensions, MIME types, and availability.
|
|
2384
|
+
*/
|
|
2385
|
+
async getParseFormats() {
|
|
2386
|
+
return getParseFormats(this.http);
|
|
2387
|
+
}
|
|
2371
2388
|
// Search
|
|
2372
2389
|
/**
|
|
2373
2390
|
* Search the web and optionally scrape each result.
|
|
@@ -3216,7 +3233,7 @@ var FirecrawlApp = class {
|
|
|
3216
3233
|
);
|
|
3217
3234
|
if (response.status === 200) {
|
|
3218
3235
|
const id = response.data.id;
|
|
3219
|
-
return this.monitorJobStatus(id, headers, pollInterval);
|
|
3236
|
+
return this.monitorJobStatus(id, headers, pollInterval, "batch");
|
|
3220
3237
|
} else {
|
|
3221
3238
|
this.handleError(response, "start batch scrape job");
|
|
3222
3239
|
}
|
|
@@ -3520,21 +3537,23 @@ var FirecrawlApp = class {
|
|
|
3520
3537
|
}
|
|
3521
3538
|
}
|
|
3522
3539
|
/**
|
|
3523
|
-
* Monitors the status of a crawl job until completion or failure.
|
|
3524
|
-
* @param id - The ID of the crawl operation.
|
|
3540
|
+
* Monitors the status of a crawl or batch scrape job until completion or failure.
|
|
3541
|
+
* @param id - The ID of the crawl or batch scrape operation.
|
|
3525
3542
|
* @param headers - The headers for the request.
|
|
3526
3543
|
* @param checkInterval - Interval in seconds for job status checks.
|
|
3527
|
-
* @param
|
|
3544
|
+
* @param jobType - Which status endpoint to poll. Defaults to `"crawl"`.
|
|
3528
3545
|
* @returns The final job status or data.
|
|
3529
3546
|
*/
|
|
3530
|
-
async monitorJobStatus(id, headers, checkInterval) {
|
|
3547
|
+
async monitorJobStatus(id, headers, checkInterval, jobType = "crawl") {
|
|
3548
|
+
const statusPath = jobType === "batch" ? "batch/scrape" : "crawl";
|
|
3549
|
+
const jobLabel = jobType === "batch" ? "Batch scrape" : "Crawl";
|
|
3531
3550
|
let failedTries = 0;
|
|
3532
3551
|
let networkRetries = 0;
|
|
3533
3552
|
const maxNetworkRetries = 3;
|
|
3534
3553
|
while (true) {
|
|
3535
3554
|
try {
|
|
3536
3555
|
let statusResponse = await this.getRequest(
|
|
3537
|
-
`${this.apiUrl}/v1
|
|
3556
|
+
`${this.apiUrl}/v1/${statusPath}/${id}`,
|
|
3538
3557
|
headers
|
|
3539
3558
|
);
|
|
3540
3559
|
if (statusResponse.status === 200) {
|
|
@@ -3555,7 +3574,7 @@ var FirecrawlApp = class {
|
|
|
3555
3574
|
statusData.data = data;
|
|
3556
3575
|
return statusData;
|
|
3557
3576
|
} else {
|
|
3558
|
-
throw new FirecrawlError(
|
|
3577
|
+
throw new FirecrawlError(`${jobLabel} job completed but no data was returned`, 500);
|
|
3559
3578
|
}
|
|
3560
3579
|
} else if (["active", "paused", "pending", "queued", "waiting", "scraping"].includes(statusData.status)) {
|
|
3561
3580
|
checkInterval = Math.max(checkInterval, 2);
|
|
@@ -3564,14 +3583,14 @@ var FirecrawlApp = class {
|
|
|
3564
3583
|
);
|
|
3565
3584
|
} else {
|
|
3566
3585
|
throw new FirecrawlError(
|
|
3567
|
-
|
|
3586
|
+
`${jobLabel} job failed or was stopped. Status: ${statusData.status}`,
|
|
3568
3587
|
500
|
|
3569
3588
|
);
|
|
3570
3589
|
}
|
|
3571
3590
|
} else {
|
|
3572
3591
|
failedTries++;
|
|
3573
3592
|
if (failedTries >= 3) {
|
|
3574
|
-
this.handleError(statusResponse,
|
|
3593
|
+
this.handleError(statusResponse, `check ${jobLabel.toLowerCase()} status`);
|
|
3575
3594
|
}
|
|
3576
3595
|
}
|
|
3577
3596
|
} catch (error) {
|
package/dist/index.d.cts
CHANGED
|
@@ -267,6 +267,17 @@ type ParseOptions = Omit<ScrapeOptions, "formats" | "waitFor" | "mobile" | "acti
|
|
|
267
267
|
formats?: ParseFormatOption[];
|
|
268
268
|
proxy?: "basic" | "auto";
|
|
269
269
|
};
|
|
270
|
+
/** A file format accepted by the parse endpoint. */
|
|
271
|
+
interface ParseFormatInfo {
|
|
272
|
+
/** Format identifier, e.g. "pdf". */
|
|
273
|
+
format: string;
|
|
274
|
+
kind: "document" | "image" | (string & {});
|
|
275
|
+
/** File extensions including the leading dot, e.g. ".pdf". */
|
|
276
|
+
extensions: string[];
|
|
277
|
+
mimeTypes: string[];
|
|
278
|
+
/** False when the format is recognized but not enabled on this deployment. */
|
|
279
|
+
available: boolean;
|
|
280
|
+
}
|
|
270
281
|
interface WebhookConfig {
|
|
271
282
|
url: string;
|
|
272
283
|
headers?: Record<string, string>;
|
|
@@ -1409,6 +1420,11 @@ interface AgentStatusResponse {
|
|
|
1409
1420
|
status: "processing" | "completed" | "failed";
|
|
1410
1421
|
error?: string;
|
|
1411
1422
|
data?: unknown;
|
|
1423
|
+
/** Best-effort result on a failed run; never a completed `data` value. */
|
|
1424
|
+
partial?: unknown;
|
|
1425
|
+
/** Schema validity of `partial`, when a schema was supplied. */
|
|
1426
|
+
partialSchemaValid?: boolean;
|
|
1427
|
+
stopReason?: "credit_limit_reached";
|
|
1412
1428
|
/**
|
|
1413
1429
|
* Server-provided model name. Widened past the request-side union on
|
|
1414
1430
|
* purpose: new models ship without an SDK release, so pinning this to known
|
|
@@ -1447,6 +1463,9 @@ interface AgentThreadRun {
|
|
|
1447
1463
|
message: string | null;
|
|
1448
1464
|
/** Only present when the request asked for includeData. */
|
|
1449
1465
|
data?: unknown;
|
|
1466
|
+
partial?: unknown;
|
|
1467
|
+
partialSchemaValid?: boolean;
|
|
1468
|
+
stopReason?: "credit_limit_reached";
|
|
1450
1469
|
suggestions?: AgentSuggestion[] | null;
|
|
1451
1470
|
pendingApproval?: PendingApproval | null;
|
|
1452
1471
|
exchange?: AgentExchangeSummary | null;
|
|
@@ -1999,11 +2018,11 @@ declare class HttpClient {
|
|
|
1999
2018
|
getTimeoutMs(): number;
|
|
2000
2019
|
private request;
|
|
2001
2020
|
private sleep;
|
|
2002
|
-
post<T = any>(endpoint: string, body: Record<string, unknown>, options?: RequestOptions): Promise<AxiosResponse<T, any, {}>>;
|
|
2003
|
-
postMultipart<T = any>(endpoint: string, formData: FormData, options?: RequestOptions): Promise<AxiosResponse<T, any, {}>>;
|
|
2004
|
-
get<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any, {}>>;
|
|
2005
|
-
delete<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any, {}>>;
|
|
2006
|
-
patch<T = any>(endpoint: string, body: Record<string, unknown>, options?: RequestOptions): Promise<AxiosResponse<T, any, {}>>;
|
|
2021
|
+
post<T = any>(endpoint: string, body: Record<string, unknown>, options?: RequestOptions): Promise<AxiosResponse<T, any, {}, any>>;
|
|
2022
|
+
postMultipart<T = any>(endpoint: string, formData: FormData, options?: RequestOptions): Promise<AxiosResponse<T, any, {}, any>>;
|
|
2023
|
+
get<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any, {}, any>>;
|
|
2024
|
+
delete<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any, {}, any>>;
|
|
2025
|
+
patch<T = any>(endpoint: string, body: Record<string, unknown>, options?: RequestOptions): Promise<AxiosResponse<T, any, {}, any>>;
|
|
2007
2026
|
prepareHeaders(idempotencyKey?: string): Record<string, string>;
|
|
2008
2027
|
}
|
|
2009
2028
|
|
|
@@ -2058,6 +2077,7 @@ declare function prepareAgentPayload(args: {
|
|
|
2058
2077
|
origin?: string;
|
|
2059
2078
|
maxCredits?: number;
|
|
2060
2079
|
strictConstrainToURLs?: boolean;
|
|
2080
|
+
/** Defaults to spark-2. "spark-1-pro" and "spark-1-mini" are deprecated and run spark-2. */
|
|
2061
2081
|
model?: "spark-1-pro" | "spark-1-mini" | "spark-2";
|
|
2062
2082
|
effort?: AgentEffort;
|
|
2063
2083
|
webhook?: string | AgentWebhookConfig;
|
|
@@ -2284,6 +2304,11 @@ declare class FirecrawlClient {
|
|
|
2284
2304
|
json?: InferredJsonFromOptions<Opts>;
|
|
2285
2305
|
}>;
|
|
2286
2306
|
parse(file: ParseFile, options?: ParseOptions): Promise<Document>;
|
|
2307
|
+
/**
|
|
2308
|
+
* List the file formats the parse endpoint accepts on this deployment.
|
|
2309
|
+
* @returns Formats with their kind, extensions, MIME types, and availability.
|
|
2310
|
+
*/
|
|
2311
|
+
getParseFormats(): Promise<ParseFormatInfo[]>;
|
|
2287
2312
|
/**
|
|
2288
2313
|
* Search the web and optionally scrape each result.
|
|
2289
2314
|
* @param query Search query string.
|
|
@@ -3363,14 +3388,14 @@ declare class FirecrawlApp {
|
|
|
3363
3388
|
*/
|
|
3364
3389
|
deleteRequest(url: string, headers: AxiosRequestHeaders): Promise<AxiosResponse>;
|
|
3365
3390
|
/**
|
|
3366
|
-
* Monitors the status of a crawl job until completion or failure.
|
|
3367
|
-
* @param id - The ID of the crawl operation.
|
|
3391
|
+
* Monitors the status of a crawl or batch scrape job until completion or failure.
|
|
3392
|
+
* @param id - The ID of the crawl or batch scrape operation.
|
|
3368
3393
|
* @param headers - The headers for the request.
|
|
3369
3394
|
* @param checkInterval - Interval in seconds for job status checks.
|
|
3370
|
-
* @param
|
|
3395
|
+
* @param jobType - Which status endpoint to poll. Defaults to `"crawl"`.
|
|
3371
3396
|
* @returns The final job status or data.
|
|
3372
3397
|
*/
|
|
3373
|
-
monitorJobStatus(id: string, headers: AxiosRequestHeaders, checkInterval: number): Promise<CrawlStatusResponse | ErrorResponse>;
|
|
3398
|
+
monitorJobStatus(id: string, headers: AxiosRequestHeaders, checkInterval: number, jobType?: "crawl" | "batch"): Promise<CrawlStatusResponse | ErrorResponse>;
|
|
3374
3399
|
/**
|
|
3375
3400
|
* Determines if an error is retryable (transient network error)
|
|
3376
3401
|
* @param error - The error to check
|
|
@@ -3532,4 +3557,4 @@ declare class Firecrawl extends FirecrawlClient {
|
|
|
3532
3557
|
get v1(): FirecrawlApp;
|
|
3533
3558
|
}
|
|
3534
3559
|
|
|
3535
|
-
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentEffort, type AgentExchangeOptions, type AgentExchangeSummary, type AgentListItem, type AgentListOptions, type AgentListResponse, type AgentMode, type AgentOnTermsRequired, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentSkippedProvider, type AgentSnapshotResponse, type AgentStatusResponse, type AgentSuggestion, type AgentTermsGate, type AgentTermsRequiredAction, type AgentThread, type AgentThreadResponse, type AgentThreadRun, type AgentTraceActiveBrowserSession, type AgentTraceAgentFinishedEvent, type AgentTraceAgentIdentity, type AgentTraceAgentRole, type AgentTraceAgentStartedEvent, type AgentTraceArtifactChange, type AgentTraceArtifactUpdatedEvent, type AgentTraceBrowserSessionFinishedEvent, type AgentTraceBrowserSessionStartedEvent, type AgentTraceError, type AgentTraceErrorOccurredEvent, type AgentTraceEvent, type AgentTraceProgressReportedEvent, type AgentTraceReasoningSummaryEvent, type AgentTraceResponse, type AgentTraceRunCancelRequestedEvent, type AgentTraceRunFinishedEvent, type AgentTraceRunStartedEvent, type AgentTraceToolCallFinishedEvent, type AgentTraceToolCallStartedEvent, type AgentWebhookConfig, type AgentWebhookEvent, type AlexandriaCall, type AlexandriaOptions, type AlexandriaScrapeData, type AlexandriaScrapeError, type AlexandriaScrapeRequest, type AlexandriaScrapeResult, type AttributesFormat, type AuditMetadata$1 as AuditMetadata, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreateMonitorRequest, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type DeveloperSearchLicenseDisclosure, type DeveloperSearchOptions, type DeveloperSearchPassage, type DeveloperSearchRepoStatus, type DeveloperSearchResponse, type DeveloperSearchResult, type DeveloperSearchSourceStatus, type DeveloperSearchType, type DiscoveredTool, type Document, type DocumentMetadata, type EndpointFeedbackEndpoint, type EndpointFeedbackRequest, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, type FeedbackMissingContent, type FeedbackRating, type FeedbackResponse, type FeedbackValuableSource, type FindToolsData, type FindToolsOptions, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientInput, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, type GetMonitorCheckOptions, type GetPaperOptions, type GitHubScoreBreakdown, type GitHubSearchItem, type GitHubSearchResponse, type HighlightsFormat, type IdMap, type ImageParser, JobTimeoutError, type JsonFormat, type ListMonitorChecksOptions, type ListMonitorsOptions, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type MenuAvailability, type MenuImage, type MenuItem, type MenuItemIdentifiers, type MenuMerchant, type MenuPrice, type MenuProfile, type MenuSection, type Monitor, type MonitorCheck, type MonitorCheckDetail, type MonitorCheckPage, type MonitorCrawlTarget, type MonitorCrawlTargetResult, type MonitorEmailNotification, type MonitorEmailRecipientSubscription, type MonitorJsonFieldDiff, type MonitorNotification, type MonitorPageDiff, type MonitorPageJudgment, type MonitorPageSnapshot, type MonitorSchedule, type MonitorScrapeTarget, type MonitorScrapeTargetResult, type MonitorSearchTarget, type MonitorSearchTargetResult, type MonitorSummary, type MonitorTarget, type MonitorTargetResult, type MonitorWebhookConfig, type PDFAction, type PDFParser, type PaginationConfig, type PaperMetadata, type PaperMetadataResponse, type PaperResult, type PaperSignals, type ParseFile, type ParseFileData, type ParseFormat, type ParseFormatOption, type ParseFormatString, type ParseOptions, type Passage, type PdfBlockConfidence, type PdfBlockItem, type PdfPage, type PdfPageBlocks, type PendingApproval, type PendingApprovalCall, type PendingCallsApproval, type PendingTermsApproval, type PressAction, type ProductAvailability, type ProductImage, type ProductPrice, type ProductProfile, type ProductSale, type ProductVariant, type QueryFormat, type QuestionFormat, type QueueStatusResponse$1 as QueueStatusResponse, type ReadPaperResponse, type RedactPIIEntity, type RedactPIIOptions, type RequiresAction, ResearchClient, type ScrapeAction, type ScrapeBrowserDeleteResponse, type ScrapeExecuteRequest, type ScrapeExecuteResponse, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchFeedbackRequest, type SearchGithubOptions, type SearchPapersOptions, type SearchPapersResponse, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type SimilarPapersOptions, type SimilarPapersResponse, type ThreatProtectionOptions, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type UpdateMonitorRequest, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default, parseRequiresAction };
|
|
3560
|
+
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentEffort, type AgentExchangeOptions, type AgentExchangeSummary, type AgentListItem, type AgentListOptions, type AgentListResponse, type AgentMode, type AgentOnTermsRequired, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentSkippedProvider, type AgentSnapshotResponse, type AgentStatusResponse, type AgentSuggestion, type AgentTermsGate, type AgentTermsRequiredAction, type AgentThread, type AgentThreadResponse, type AgentThreadRun, type AgentTraceActiveBrowserSession, type AgentTraceAgentFinishedEvent, type AgentTraceAgentIdentity, type AgentTraceAgentRole, type AgentTraceAgentStartedEvent, type AgentTraceArtifactChange, type AgentTraceArtifactUpdatedEvent, type AgentTraceBrowserSessionFinishedEvent, type AgentTraceBrowserSessionStartedEvent, type AgentTraceError, type AgentTraceErrorOccurredEvent, type AgentTraceEvent, type AgentTraceProgressReportedEvent, type AgentTraceReasoningSummaryEvent, type AgentTraceResponse, type AgentTraceRunCancelRequestedEvent, type AgentTraceRunFinishedEvent, type AgentTraceRunStartedEvent, type AgentTraceToolCallFinishedEvent, type AgentTraceToolCallStartedEvent, type AgentWebhookConfig, type AgentWebhookEvent, type AlexandriaCall, type AlexandriaOptions, type AlexandriaScrapeData, type AlexandriaScrapeError, type AlexandriaScrapeRequest, type AlexandriaScrapeResult, type AttributesFormat, type AuditMetadata$1 as AuditMetadata, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreateMonitorRequest, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type DeveloperSearchLicenseDisclosure, type DeveloperSearchOptions, type DeveloperSearchPassage, type DeveloperSearchRepoStatus, type DeveloperSearchResponse, type DeveloperSearchResult, type DeveloperSearchSourceStatus, type DeveloperSearchType, type DiscoveredTool, type Document, type DocumentMetadata, type EndpointFeedbackEndpoint, type EndpointFeedbackRequest, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, type FeedbackMissingContent, type FeedbackRating, type FeedbackResponse, type FeedbackValuableSource, type FindToolsData, type FindToolsOptions, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientInput, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, type GetMonitorCheckOptions, type GetPaperOptions, type GitHubScoreBreakdown, type GitHubSearchItem, type GitHubSearchResponse, type HighlightsFormat, type IdMap, type ImageParser, JobTimeoutError, type JsonFormat, type ListMonitorChecksOptions, type ListMonitorsOptions, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type MenuAvailability, type MenuImage, type MenuItem, type MenuItemIdentifiers, type MenuMerchant, type MenuPrice, type MenuProfile, type MenuSection, type Monitor, type MonitorCheck, type MonitorCheckDetail, type MonitorCheckPage, type MonitorCrawlTarget, type MonitorCrawlTargetResult, type MonitorEmailNotification, type MonitorEmailRecipientSubscription, type MonitorJsonFieldDiff, type MonitorNotification, type MonitorPageDiff, type MonitorPageJudgment, type MonitorPageSnapshot, type MonitorSchedule, type MonitorScrapeTarget, type MonitorScrapeTargetResult, type MonitorSearchTarget, type MonitorSearchTargetResult, type MonitorSummary, type MonitorTarget, type MonitorTargetResult, type MonitorWebhookConfig, type PDFAction, type PDFParser, type PaginationConfig, type PaperMetadata, type PaperMetadataResponse, type PaperResult, type PaperSignals, type ParseFile, type ParseFileData, type ParseFormat, type ParseFormatInfo, type ParseFormatOption, type ParseFormatString, type ParseOptions, type Passage, type PdfBlockConfidence, type PdfBlockItem, type PdfPage, type PdfPageBlocks, type PendingApproval, type PendingApprovalCall, type PendingCallsApproval, type PendingTermsApproval, type PressAction, type ProductAvailability, type ProductImage, type ProductPrice, type ProductProfile, type ProductSale, type ProductVariant, type QueryFormat, type QuestionFormat, type QueueStatusResponse$1 as QueueStatusResponse, type ReadPaperResponse, type RedactPIIEntity, type RedactPIIOptions, type RequiresAction, ResearchClient, type ScrapeAction, type ScrapeBrowserDeleteResponse, type ScrapeExecuteRequest, type ScrapeExecuteResponse, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchFeedbackRequest, type SearchGithubOptions, type SearchPapersOptions, type SearchPapersResponse, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type SimilarPapersOptions, type SimilarPapersResponse, type ThreatProtectionOptions, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type UpdateMonitorRequest, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default, parseRequiresAction };
|
package/dist/index.d.ts
CHANGED
|
@@ -267,6 +267,17 @@ type ParseOptions = Omit<ScrapeOptions, "formats" | "waitFor" | "mobile" | "acti
|
|
|
267
267
|
formats?: ParseFormatOption[];
|
|
268
268
|
proxy?: "basic" | "auto";
|
|
269
269
|
};
|
|
270
|
+
/** A file format accepted by the parse endpoint. */
|
|
271
|
+
interface ParseFormatInfo {
|
|
272
|
+
/** Format identifier, e.g. "pdf". */
|
|
273
|
+
format: string;
|
|
274
|
+
kind: "document" | "image" | (string & {});
|
|
275
|
+
/** File extensions including the leading dot, e.g. ".pdf". */
|
|
276
|
+
extensions: string[];
|
|
277
|
+
mimeTypes: string[];
|
|
278
|
+
/** False when the format is recognized but not enabled on this deployment. */
|
|
279
|
+
available: boolean;
|
|
280
|
+
}
|
|
270
281
|
interface WebhookConfig {
|
|
271
282
|
url: string;
|
|
272
283
|
headers?: Record<string, string>;
|
|
@@ -1409,6 +1420,11 @@ interface AgentStatusResponse {
|
|
|
1409
1420
|
status: "processing" | "completed" | "failed";
|
|
1410
1421
|
error?: string;
|
|
1411
1422
|
data?: unknown;
|
|
1423
|
+
/** Best-effort result on a failed run; never a completed `data` value. */
|
|
1424
|
+
partial?: unknown;
|
|
1425
|
+
/** Schema validity of `partial`, when a schema was supplied. */
|
|
1426
|
+
partialSchemaValid?: boolean;
|
|
1427
|
+
stopReason?: "credit_limit_reached";
|
|
1412
1428
|
/**
|
|
1413
1429
|
* Server-provided model name. Widened past the request-side union on
|
|
1414
1430
|
* purpose: new models ship without an SDK release, so pinning this to known
|
|
@@ -1447,6 +1463,9 @@ interface AgentThreadRun {
|
|
|
1447
1463
|
message: string | null;
|
|
1448
1464
|
/** Only present when the request asked for includeData. */
|
|
1449
1465
|
data?: unknown;
|
|
1466
|
+
partial?: unknown;
|
|
1467
|
+
partialSchemaValid?: boolean;
|
|
1468
|
+
stopReason?: "credit_limit_reached";
|
|
1450
1469
|
suggestions?: AgentSuggestion[] | null;
|
|
1451
1470
|
pendingApproval?: PendingApproval | null;
|
|
1452
1471
|
exchange?: AgentExchangeSummary | null;
|
|
@@ -1999,11 +2018,11 @@ declare class HttpClient {
|
|
|
1999
2018
|
getTimeoutMs(): number;
|
|
2000
2019
|
private request;
|
|
2001
2020
|
private sleep;
|
|
2002
|
-
post<T = any>(endpoint: string, body: Record<string, unknown>, options?: RequestOptions): Promise<AxiosResponse<T, any, {}>>;
|
|
2003
|
-
postMultipart<T = any>(endpoint: string, formData: FormData, options?: RequestOptions): Promise<AxiosResponse<T, any, {}>>;
|
|
2004
|
-
get<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any, {}>>;
|
|
2005
|
-
delete<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any, {}>>;
|
|
2006
|
-
patch<T = any>(endpoint: string, body: Record<string, unknown>, options?: RequestOptions): Promise<AxiosResponse<T, any, {}>>;
|
|
2021
|
+
post<T = any>(endpoint: string, body: Record<string, unknown>, options?: RequestOptions): Promise<AxiosResponse<T, any, {}, any>>;
|
|
2022
|
+
postMultipart<T = any>(endpoint: string, formData: FormData, options?: RequestOptions): Promise<AxiosResponse<T, any, {}, any>>;
|
|
2023
|
+
get<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any, {}, any>>;
|
|
2024
|
+
delete<T = any>(endpoint: string, headers?: Record<string, string>): Promise<AxiosResponse<T, any, {}, any>>;
|
|
2025
|
+
patch<T = any>(endpoint: string, body: Record<string, unknown>, options?: RequestOptions): Promise<AxiosResponse<T, any, {}, any>>;
|
|
2007
2026
|
prepareHeaders(idempotencyKey?: string): Record<string, string>;
|
|
2008
2027
|
}
|
|
2009
2028
|
|
|
@@ -2058,6 +2077,7 @@ declare function prepareAgentPayload(args: {
|
|
|
2058
2077
|
origin?: string;
|
|
2059
2078
|
maxCredits?: number;
|
|
2060
2079
|
strictConstrainToURLs?: boolean;
|
|
2080
|
+
/** Defaults to spark-2. "spark-1-pro" and "spark-1-mini" are deprecated and run spark-2. */
|
|
2061
2081
|
model?: "spark-1-pro" | "spark-1-mini" | "spark-2";
|
|
2062
2082
|
effort?: AgentEffort;
|
|
2063
2083
|
webhook?: string | AgentWebhookConfig;
|
|
@@ -2284,6 +2304,11 @@ declare class FirecrawlClient {
|
|
|
2284
2304
|
json?: InferredJsonFromOptions<Opts>;
|
|
2285
2305
|
}>;
|
|
2286
2306
|
parse(file: ParseFile, options?: ParseOptions): Promise<Document>;
|
|
2307
|
+
/**
|
|
2308
|
+
* List the file formats the parse endpoint accepts on this deployment.
|
|
2309
|
+
* @returns Formats with their kind, extensions, MIME types, and availability.
|
|
2310
|
+
*/
|
|
2311
|
+
getParseFormats(): Promise<ParseFormatInfo[]>;
|
|
2287
2312
|
/**
|
|
2288
2313
|
* Search the web and optionally scrape each result.
|
|
2289
2314
|
* @param query Search query string.
|
|
@@ -3363,14 +3388,14 @@ declare class FirecrawlApp {
|
|
|
3363
3388
|
*/
|
|
3364
3389
|
deleteRequest(url: string, headers: AxiosRequestHeaders): Promise<AxiosResponse>;
|
|
3365
3390
|
/**
|
|
3366
|
-
* Monitors the status of a crawl job until completion or failure.
|
|
3367
|
-
* @param id - The ID of the crawl operation.
|
|
3391
|
+
* Monitors the status of a crawl or batch scrape job until completion or failure.
|
|
3392
|
+
* @param id - The ID of the crawl or batch scrape operation.
|
|
3368
3393
|
* @param headers - The headers for the request.
|
|
3369
3394
|
* @param checkInterval - Interval in seconds for job status checks.
|
|
3370
|
-
* @param
|
|
3395
|
+
* @param jobType - Which status endpoint to poll. Defaults to `"crawl"`.
|
|
3371
3396
|
* @returns The final job status or data.
|
|
3372
3397
|
*/
|
|
3373
|
-
monitorJobStatus(id: string, headers: AxiosRequestHeaders, checkInterval: number): Promise<CrawlStatusResponse | ErrorResponse>;
|
|
3398
|
+
monitorJobStatus(id: string, headers: AxiosRequestHeaders, checkInterval: number, jobType?: "crawl" | "batch"): Promise<CrawlStatusResponse | ErrorResponse>;
|
|
3374
3399
|
/**
|
|
3375
3400
|
* Determines if an error is retryable (transient network error)
|
|
3376
3401
|
* @param error - The error to check
|
|
@@ -3532,4 +3557,4 @@ declare class Firecrawl extends FirecrawlClient {
|
|
|
3532
3557
|
get v1(): FirecrawlApp;
|
|
3533
3558
|
}
|
|
3534
3559
|
|
|
3535
|
-
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentEffort, type AgentExchangeOptions, type AgentExchangeSummary, type AgentListItem, type AgentListOptions, type AgentListResponse, type AgentMode, type AgentOnTermsRequired, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentSkippedProvider, type AgentSnapshotResponse, type AgentStatusResponse, type AgentSuggestion, type AgentTermsGate, type AgentTermsRequiredAction, type AgentThread, type AgentThreadResponse, type AgentThreadRun, type AgentTraceActiveBrowserSession, type AgentTraceAgentFinishedEvent, type AgentTraceAgentIdentity, type AgentTraceAgentRole, type AgentTraceAgentStartedEvent, type AgentTraceArtifactChange, type AgentTraceArtifactUpdatedEvent, type AgentTraceBrowserSessionFinishedEvent, type AgentTraceBrowserSessionStartedEvent, type AgentTraceError, type AgentTraceErrorOccurredEvent, type AgentTraceEvent, type AgentTraceProgressReportedEvent, type AgentTraceReasoningSummaryEvent, type AgentTraceResponse, type AgentTraceRunCancelRequestedEvent, type AgentTraceRunFinishedEvent, type AgentTraceRunStartedEvent, type AgentTraceToolCallFinishedEvent, type AgentTraceToolCallStartedEvent, type AgentWebhookConfig, type AgentWebhookEvent, type AlexandriaCall, type AlexandriaOptions, type AlexandriaScrapeData, type AlexandriaScrapeError, type AlexandriaScrapeRequest, type AlexandriaScrapeResult, type AttributesFormat, type AuditMetadata$1 as AuditMetadata, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreateMonitorRequest, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type DeveloperSearchLicenseDisclosure, type DeveloperSearchOptions, type DeveloperSearchPassage, type DeveloperSearchRepoStatus, type DeveloperSearchResponse, type DeveloperSearchResult, type DeveloperSearchSourceStatus, type DeveloperSearchType, type DiscoveredTool, type Document, type DocumentMetadata, type EndpointFeedbackEndpoint, type EndpointFeedbackRequest, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, type FeedbackMissingContent, type FeedbackRating, type FeedbackResponse, type FeedbackValuableSource, type FindToolsData, type FindToolsOptions, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientInput, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, type GetMonitorCheckOptions, type GetPaperOptions, type GitHubScoreBreakdown, type GitHubSearchItem, type GitHubSearchResponse, type HighlightsFormat, type IdMap, type ImageParser, JobTimeoutError, type JsonFormat, type ListMonitorChecksOptions, type ListMonitorsOptions, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type MenuAvailability, type MenuImage, type MenuItem, type MenuItemIdentifiers, type MenuMerchant, type MenuPrice, type MenuProfile, type MenuSection, type Monitor, type MonitorCheck, type MonitorCheckDetail, type MonitorCheckPage, type MonitorCrawlTarget, type MonitorCrawlTargetResult, type MonitorEmailNotification, type MonitorEmailRecipientSubscription, type MonitorJsonFieldDiff, type MonitorNotification, type MonitorPageDiff, type MonitorPageJudgment, type MonitorPageSnapshot, type MonitorSchedule, type MonitorScrapeTarget, type MonitorScrapeTargetResult, type MonitorSearchTarget, type MonitorSearchTargetResult, type MonitorSummary, type MonitorTarget, type MonitorTargetResult, type MonitorWebhookConfig, type PDFAction, type PDFParser, type PaginationConfig, type PaperMetadata, type PaperMetadataResponse, type PaperResult, type PaperSignals, type ParseFile, type ParseFileData, type ParseFormat, type ParseFormatOption, type ParseFormatString, type ParseOptions, type Passage, type PdfBlockConfidence, type PdfBlockItem, type PdfPage, type PdfPageBlocks, type PendingApproval, type PendingApprovalCall, type PendingCallsApproval, type PendingTermsApproval, type PressAction, type ProductAvailability, type ProductImage, type ProductPrice, type ProductProfile, type ProductSale, type ProductVariant, type QueryFormat, type QuestionFormat, type QueueStatusResponse$1 as QueueStatusResponse, type ReadPaperResponse, type RedactPIIEntity, type RedactPIIOptions, type RequiresAction, ResearchClient, type ScrapeAction, type ScrapeBrowserDeleteResponse, type ScrapeExecuteRequest, type ScrapeExecuteResponse, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchFeedbackRequest, type SearchGithubOptions, type SearchPapersOptions, type SearchPapersResponse, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type SimilarPapersOptions, type SimilarPapersResponse, type ThreatProtectionOptions, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type UpdateMonitorRequest, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default, parseRequiresAction };
|
|
3560
|
+
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentEffort, type AgentExchangeOptions, type AgentExchangeSummary, type AgentListItem, type AgentListOptions, type AgentListResponse, type AgentMode, type AgentOnTermsRequired, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentSkippedProvider, type AgentSnapshotResponse, type AgentStatusResponse, type AgentSuggestion, type AgentTermsGate, type AgentTermsRequiredAction, type AgentThread, type AgentThreadResponse, type AgentThreadRun, type AgentTraceActiveBrowserSession, type AgentTraceAgentFinishedEvent, type AgentTraceAgentIdentity, type AgentTraceAgentRole, type AgentTraceAgentStartedEvent, type AgentTraceArtifactChange, type AgentTraceArtifactUpdatedEvent, type AgentTraceBrowserSessionFinishedEvent, type AgentTraceBrowserSessionStartedEvent, type AgentTraceError, type AgentTraceErrorOccurredEvent, type AgentTraceEvent, type AgentTraceProgressReportedEvent, type AgentTraceReasoningSummaryEvent, type AgentTraceResponse, type AgentTraceRunCancelRequestedEvent, type AgentTraceRunFinishedEvent, type AgentTraceRunStartedEvent, type AgentTraceToolCallFinishedEvent, type AgentTraceToolCallStartedEvent, type AgentWebhookConfig, type AgentWebhookEvent, type AlexandriaCall, type AlexandriaOptions, type AlexandriaScrapeData, type AlexandriaScrapeError, type AlexandriaScrapeRequest, type AlexandriaScrapeResult, type AttributesFormat, type AuditMetadata$1 as AuditMetadata, type BatchScrapeJob, type BatchScrapeOptions, type BatchScrapeResponse$1 as BatchScrapeResponse, type BrandingProfile, type BrowserCreateResponse, type BrowserDeleteResponse, type BrowserExecuteResponse, type BrowserListResponse, type BrowserSession, type CategoryOption, type ChangeTrackingFormat, type ClickAction, type ConcurrencyCheck, type CrawlErrorsResponse$1 as CrawlErrorsResponse, type CrawlJob, type CrawlOptions, type CrawlResponse$1 as CrawlResponse, type CreateMonitorRequest, type CreditUsage, type CreditUsageHistoricalPeriod, type CreditUsageHistoricalResponse, type DeveloperSearchLicenseDisclosure, type DeveloperSearchOptions, type DeveloperSearchPassage, type DeveloperSearchRepoStatus, type DeveloperSearchResponse, type DeveloperSearchResult, type DeveloperSearchSourceStatus, type DeveloperSearchType, type DiscoveredTool, type Document, type DocumentMetadata, type EndpointFeedbackEndpoint, type EndpointFeedbackRequest, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, type FeedbackMissingContent, type FeedbackRating, type FeedbackResponse, type FeedbackValuableSource, type FindToolsData, type FindToolsOptions, Firecrawl, FirecrawlApp as FirecrawlAppV1, FirecrawlClient, type FirecrawlClientInput, type FirecrawlClientOptions, type Format, type FormatOption, type FormatString, type GetMonitorCheckOptions, type GetPaperOptions, type GitHubScoreBreakdown, type GitHubSearchItem, type GitHubSearchResponse, type HighlightsFormat, type IdMap, type ImageParser, JobTimeoutError, type JsonFormat, type ListMonitorChecksOptions, type ListMonitorsOptions, type LocationConfig$1 as LocationConfig, type MapData, type MapOptions, type MenuAvailability, type MenuImage, type MenuItem, type MenuItemIdentifiers, type MenuMerchant, type MenuPrice, type MenuProfile, type MenuSection, type Monitor, type MonitorCheck, type MonitorCheckDetail, type MonitorCheckPage, type MonitorCrawlTarget, type MonitorCrawlTargetResult, type MonitorEmailNotification, type MonitorEmailRecipientSubscription, type MonitorJsonFieldDiff, type MonitorNotification, type MonitorPageDiff, type MonitorPageJudgment, type MonitorPageSnapshot, type MonitorSchedule, type MonitorScrapeTarget, type MonitorScrapeTargetResult, type MonitorSearchTarget, type MonitorSearchTargetResult, type MonitorSummary, type MonitorTarget, type MonitorTargetResult, type MonitorWebhookConfig, type PDFAction, type PDFParser, type PaginationConfig, type PaperMetadata, type PaperMetadataResponse, type PaperResult, type PaperSignals, type ParseFile, type ParseFileData, type ParseFormat, type ParseFormatInfo, type ParseFormatOption, type ParseFormatString, type ParseOptions, type Passage, type PdfBlockConfidence, type PdfBlockItem, type PdfPage, type PdfPageBlocks, type PendingApproval, type PendingApprovalCall, type PendingCallsApproval, type PendingTermsApproval, type PressAction, type ProductAvailability, type ProductImage, type ProductPrice, type ProductProfile, type ProductSale, type ProductVariant, type QueryFormat, type QuestionFormat, type QueueStatusResponse$1 as QueueStatusResponse, type ReadPaperResponse, type RedactPIIEntity, type RedactPIIOptions, type RequiresAction, ResearchClient, type ScrapeAction, type ScrapeBrowserDeleteResponse, type ScrapeExecuteRequest, type ScrapeExecuteResponse, type ScrapeOptions, type ScreenshotAction, type ScreenshotFormat, type ScrollAction, SdkError, type SearchData, type SearchFeedbackRequest, type SearchGithubOptions, type SearchPapersOptions, type SearchPapersResponse, type SearchRequest, type SearchResultImages, type SearchResultNews, type SearchResultWeb, type SimilarPapersOptions, type SimilarPapersResponse, type ThreatProtectionOptions, type TokenUsage, type TokenUsageHistoricalPeriod, type TokenUsageHistoricalResponse, type UpdateMonitorRequest, type Viewport, type WaitAction, Watcher, type WatcherOptions, type WebhookConfig, type WriteAction, Firecrawl as default, parseRequiresAction };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
require_package
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-AMV6GR2H.js";
|
|
4
4
|
|
|
5
5
|
// src/v2/utils/httpClient.ts
|
|
6
6
|
import axios from "axios";
|
|
@@ -654,6 +654,16 @@ async function parse(http, file, options) {
|
|
|
654
654
|
throw err;
|
|
655
655
|
}
|
|
656
656
|
}
|
|
657
|
+
async function getParseFormats(http) {
|
|
658
|
+
try {
|
|
659
|
+
const res = await http.get("/v2/parse/formats");
|
|
660
|
+
if (res.status !== 200 || !res.data?.success) throwForBadResponse(res, "get parse formats");
|
|
661
|
+
return res.data.data?.formats ?? [];
|
|
662
|
+
} catch (err) {
|
|
663
|
+
if (err?.isAxiosError) return normalizeAxiosError(err, "get parse formats");
|
|
664
|
+
throw err;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
657
667
|
|
|
658
668
|
// src/v2/methods/search.ts
|
|
659
669
|
function prepareSearchPayload(req) {
|
|
@@ -2236,6 +2246,13 @@ var FirecrawlClient = class {
|
|
|
2236
2246
|
async parse(file, options) {
|
|
2237
2247
|
return parse(this.http, file, options);
|
|
2238
2248
|
}
|
|
2249
|
+
/**
|
|
2250
|
+
* List the file formats the parse endpoint accepts on this deployment.
|
|
2251
|
+
* @returns Formats with their kind, extensions, MIME types, and availability.
|
|
2252
|
+
*/
|
|
2253
|
+
async getParseFormats() {
|
|
2254
|
+
return getParseFormats(this.http);
|
|
2255
|
+
}
|
|
2239
2256
|
// Search
|
|
2240
2257
|
/**
|
|
2241
2258
|
* Search the web and optionally scrape each result.
|
|
@@ -2689,7 +2706,7 @@ var FirecrawlApp = class {
|
|
|
2689
2706
|
if (typeof process !== "undefined" && process.env && process.env.npm_package_version) {
|
|
2690
2707
|
return process.env.npm_package_version;
|
|
2691
2708
|
}
|
|
2692
|
-
const packageJson = await import("./package-
|
|
2709
|
+
const packageJson = await import("./package-RQDQRVLO.js");
|
|
2693
2710
|
return packageJson.default.version;
|
|
2694
2711
|
} catch (error) {
|
|
2695
2712
|
const isTest = typeof process !== "undefined" && (process.env.JEST_WORKER_ID != null || false);
|
|
@@ -3084,7 +3101,7 @@ var FirecrawlApp = class {
|
|
|
3084
3101
|
);
|
|
3085
3102
|
if (response.status === 200) {
|
|
3086
3103
|
const id = response.data.id;
|
|
3087
|
-
return this.monitorJobStatus(id, headers, pollInterval);
|
|
3104
|
+
return this.monitorJobStatus(id, headers, pollInterval, "batch");
|
|
3088
3105
|
} else {
|
|
3089
3106
|
this.handleError(response, "start batch scrape job");
|
|
3090
3107
|
}
|
|
@@ -3388,21 +3405,23 @@ var FirecrawlApp = class {
|
|
|
3388
3405
|
}
|
|
3389
3406
|
}
|
|
3390
3407
|
/**
|
|
3391
|
-
* Monitors the status of a crawl job until completion or failure.
|
|
3392
|
-
* @param id - The ID of the crawl operation.
|
|
3408
|
+
* Monitors the status of a crawl or batch scrape job until completion or failure.
|
|
3409
|
+
* @param id - The ID of the crawl or batch scrape operation.
|
|
3393
3410
|
* @param headers - The headers for the request.
|
|
3394
3411
|
* @param checkInterval - Interval in seconds for job status checks.
|
|
3395
|
-
* @param
|
|
3412
|
+
* @param jobType - Which status endpoint to poll. Defaults to `"crawl"`.
|
|
3396
3413
|
* @returns The final job status or data.
|
|
3397
3414
|
*/
|
|
3398
|
-
async monitorJobStatus(id, headers, checkInterval) {
|
|
3415
|
+
async monitorJobStatus(id, headers, checkInterval, jobType = "crawl") {
|
|
3416
|
+
const statusPath = jobType === "batch" ? "batch/scrape" : "crawl";
|
|
3417
|
+
const jobLabel = jobType === "batch" ? "Batch scrape" : "Crawl";
|
|
3399
3418
|
let failedTries = 0;
|
|
3400
3419
|
let networkRetries = 0;
|
|
3401
3420
|
const maxNetworkRetries = 3;
|
|
3402
3421
|
while (true) {
|
|
3403
3422
|
try {
|
|
3404
3423
|
let statusResponse = await this.getRequest(
|
|
3405
|
-
`${this.apiUrl}/v1
|
|
3424
|
+
`${this.apiUrl}/v1/${statusPath}/${id}`,
|
|
3406
3425
|
headers
|
|
3407
3426
|
);
|
|
3408
3427
|
if (statusResponse.status === 200) {
|
|
@@ -3423,7 +3442,7 @@ var FirecrawlApp = class {
|
|
|
3423
3442
|
statusData.data = data;
|
|
3424
3443
|
return statusData;
|
|
3425
3444
|
} else {
|
|
3426
|
-
throw new FirecrawlError(
|
|
3445
|
+
throw new FirecrawlError(`${jobLabel} job completed but no data was returned`, 500);
|
|
3427
3446
|
}
|
|
3428
3447
|
} else if (["active", "paused", "pending", "queued", "waiting", "scraping"].includes(statusData.status)) {
|
|
3429
3448
|
checkInterval = Math.max(checkInterval, 2);
|
|
@@ -3432,14 +3451,14 @@ var FirecrawlApp = class {
|
|
|
3432
3451
|
);
|
|
3433
3452
|
} else {
|
|
3434
3453
|
throw new FirecrawlError(
|
|
3435
|
-
|
|
3454
|
+
`${jobLabel} job failed or was stopped. Status: ${statusData.status}`,
|
|
3436
3455
|
500
|
|
3437
3456
|
);
|
|
3438
3457
|
}
|
|
3439
3458
|
} else {
|
|
3440
3459
|
failedTries++;
|
|
3441
3460
|
if (failedTries >= 3) {
|
|
3442
|
-
this.handleError(statusResponse,
|
|
3461
|
+
this.handleError(statusResponse, `check ${jobLabel.toLowerCase()} status`);
|
|
3443
3462
|
}
|
|
3444
3463
|
}
|
|
3445
3464
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firecrawl",
|
|
3
|
-
"version": "4.42.
|
|
3
|
+
"version": "4.42.3",
|
|
4
4
|
"description": "JavaScript SDK for the Firecrawl API: web scraping, crawling, web search, and scientific literature search over a research paper index of PubMed, bioRxiv, medRxiv and arXiv abstracts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"author": "Mendable.ai",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"axios": "1.
|
|
22
|
+
"axios": "1.20.0",
|
|
23
23
|
"typescript-event-target": "^1.1.1",
|
|
24
24
|
"zod": "^3.23.8",
|
|
25
25
|
"zod-to-json-schema": "^3.23.0"
|
|
@@ -73,6 +73,6 @@
|
|
|
73
73
|
"build-and-publish": "pnpm run build && pnpm publish --access public",
|
|
74
74
|
"publish-beta": "pnpm run build && pnpm publish --access public --tag beta",
|
|
75
75
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest --verbose src/__tests__/e2e/v2/*.test.ts --detectOpenHandles",
|
|
76
|
-
"test:unit": "NODE_OPTIONS=--experimental-vm-modules jest --verbose src/__tests__/unit
|
|
76
|
+
"test:unit": "NODE_OPTIONS=--experimental-vm-modules jest --verbose src/__tests__/unit"
|
|
77
77
|
}
|
|
78
78
|
}
|
package/pnpm-workspace.yaml
CHANGED
|
@@ -12,7 +12,12 @@ overrides:
|
|
|
12
12
|
"brace-expansion@>=5.0.0 <5.0.12": "5.0.12"
|
|
13
13
|
"js-yaml@>=3.0.0 <3.15.2": "3.15.2"
|
|
14
14
|
"js-yaml@>=4.0.0 <4.3.2": "4.3.2"
|
|
15
|
-
|
|
15
|
+
# GHSA-vh66-26gq-q6x8 / GHSA-9fr6-4gfg-395g / GHSA-c29m-xwm3-cm6r /
|
|
16
|
+
# GHSA-mghh-pgcx-3jjj / GHSA-x97p-jq2g-jp4f / GHSA-3pq3-5fj3-cg6v /
|
|
17
|
+
# GHSA-542g-h47m-68v8 / GHSA-j8rh-479h-cp32 / GHSA-4hqw-qxg8-jxx2 /
|
|
18
|
+
# GHSA-m8m8-qj5v-23w3 / GHSA-44g4-m2mj-wpvx / GHSA-r4gj-5m52-g5wh:
|
|
19
|
+
# pin the 1.x line only. Exact 1.20.0 cannot resolve to 2.x.
|
|
20
|
+
"axios@>=1.0.0 <1.20.0": "1.20.0"
|
|
16
21
|
"follow-redirects@<1.16.0": ">=1.16.0 <2.0.0"
|
|
17
22
|
"form-data@>=4.0.0 <4.0.6": "4.0.6"
|
|
18
23
|
"@babel/core@>=7.0.0 <7.29.6": "7.29.7"
|
|
@@ -3,6 +3,7 @@ import { config } from "dotenv";
|
|
|
3
3
|
import { getIdentity, getApiUrl } from "./utils/idmux";
|
|
4
4
|
import { testTimeoutMs, withRateLimitRetry } from "./utils/rateLimit";
|
|
5
5
|
import { describe, test, expect, beforeAll } from "@jest/globals";
|
|
6
|
+
import { SdkError } from "../../../v2/types";
|
|
6
7
|
|
|
7
8
|
config();
|
|
8
9
|
|
|
@@ -65,4 +66,29 @@ describe("v2.parse e2e", () => {
|
|
|
65
66
|
},
|
|
66
67
|
testTimeoutMs(60_000),
|
|
67
68
|
);
|
|
69
|
+
|
|
70
|
+
test(
|
|
71
|
+
"lists supported parse formats",
|
|
72
|
+
async () => {
|
|
73
|
+
if (!client) throw new Error();
|
|
74
|
+
|
|
75
|
+
let formats;
|
|
76
|
+
try {
|
|
77
|
+
formats = await client.getParseFormats();
|
|
78
|
+
} catch (err) {
|
|
79
|
+
if (err instanceof SdkError && err.status === 404) {
|
|
80
|
+
console.warn("Skipping: /v2/parse/formats is not deployed on this API");
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
throw err;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
expect(formats.length).toBeGreaterThan(0);
|
|
87
|
+
const pdf = formats.find(f => f.format === "pdf");
|
|
88
|
+
expect(pdf?.kind).toBe("document");
|
|
89
|
+
expect(pdf?.extensions).toContain(".pdf");
|
|
90
|
+
expect(pdf?.mimeTypes).toContain("application/pdf");
|
|
91
|
+
},
|
|
92
|
+
testTimeoutMs(60_000),
|
|
93
|
+
);
|
|
68
94
|
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { describe, test, expect, jest, afterEach, beforeEach } from "@jest/globals";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import FirecrawlApp from "../../../v1";
|
|
4
|
+
|
|
5
|
+
const API_URL = "https://api.firecrawl.dev";
|
|
6
|
+
const API_KEY = "fc-test";
|
|
7
|
+
|
|
8
|
+
const scrapingPage = () => ({ success: true, status: "scraping", total: 2, completed: 0, data: [] });
|
|
9
|
+
const completedPage = (next: string) => ({
|
|
10
|
+
success: true,
|
|
11
|
+
status: "completed",
|
|
12
|
+
total: 2,
|
|
13
|
+
completed: 2,
|
|
14
|
+
expiresAt: "2030-01-01T00:00:00Z",
|
|
15
|
+
data: [{ markdown: "a" }],
|
|
16
|
+
next,
|
|
17
|
+
});
|
|
18
|
+
const lastPage = () => ({ success: true, status: "completed", data: [{ markdown: "b" }] });
|
|
19
|
+
|
|
20
|
+
function mockPoll(path: string, nextOrigin = API_URL) {
|
|
21
|
+
const sent: string[] = [];
|
|
22
|
+
let polls = 0;
|
|
23
|
+
jest.spyOn(axios, "get").mockImplementation(async (url: string) => {
|
|
24
|
+
sent.push(url);
|
|
25
|
+
if (new URL(url).searchParams.has("skip")) return { status: 200, data: lastPage() };
|
|
26
|
+
polls++;
|
|
27
|
+
return { status: 200, data: polls === 1 ? scrapingPage() : completedPage(`${nextOrigin}${path}?skip=1`) };
|
|
28
|
+
});
|
|
29
|
+
return sent;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe("v1 batch scrape waits on the batch scrape status endpoint", () => {
|
|
33
|
+
const app = new FirecrawlApp({ apiKey: API_KEY, apiUrl: API_URL });
|
|
34
|
+
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
jest.spyOn(global, "setTimeout").mockImplementation(((fn: () => void) => {
|
|
37
|
+
fn();
|
|
38
|
+
return 0;
|
|
39
|
+
}) as any);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
jest.restoreAllMocks();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("batchScrapeUrls polls /v1/batch/scrape/{id} and follows pinned next pages", async () => {
|
|
47
|
+
const post = jest.spyOn(axios, "post").mockResolvedValue({ status: 200, data: { success: true, id: "abc" } });
|
|
48
|
+
const path = "/v1/batch/scrape/abc";
|
|
49
|
+
const sent = mockPoll(path, "https://evil.example");
|
|
50
|
+
|
|
51
|
+
const res: any = await app.batchScrapeUrls(["https://example.com", "https://example.org"], {});
|
|
52
|
+
|
|
53
|
+
expect(post.mock.calls[0][0]).toBe(`${API_URL}/v1/batch/scrape`);
|
|
54
|
+
expect(sent).toEqual([`${API_URL}${path}`, `${API_URL}${path}`, `${API_URL}${path}?skip=1`]);
|
|
55
|
+
expect(sent.some(url => url.includes("/v1/crawl/"))).toBe(false);
|
|
56
|
+
expect(res.status).toBe("completed");
|
|
57
|
+
expect(res.data).toHaveLength(2);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("batchScrapeUrls reports batch scrape failures as batch scrape errors", async () => {
|
|
61
|
+
jest.spyOn(axios, "post").mockResolvedValue({ status: 200, data: { success: true, id: "abc" } });
|
|
62
|
+
const sent: string[] = [];
|
|
63
|
+
jest.spyOn(axios, "get").mockImplementation(async (url: string) => {
|
|
64
|
+
sent.push(url);
|
|
65
|
+
return { status: 200, data: { success: true, status: "failed", data: [] } };
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
await expect(app.batchScrapeUrls(["https://example.com"], {})).rejects.toThrow("Batch scrape job failed or was stopped");
|
|
69
|
+
expect(sent.every(url => url === `${API_URL}/v1/batch/scrape/abc`)).toBe(true);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("monitorJobStatus still polls /v1/crawl/{id} by default", async () => {
|
|
73
|
+
const path = "/v1/crawl/abc";
|
|
74
|
+
const sent = mockPoll(path);
|
|
75
|
+
|
|
76
|
+
const res: any = await app.monitorJobStatus("abc", app.prepareHeaders(), 0);
|
|
77
|
+
|
|
78
|
+
expect(sent).toEqual([`${API_URL}${path}`, `${API_URL}${path}`, `${API_URL}${path}?skip=1`]);
|
|
79
|
+
expect(res.data).toHaveLength(2);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test("monitorJobStatus polls /v1/batch/scrape/{id} for batch jobs", async () => {
|
|
83
|
+
const path = "/v1/batch/scrape/abc";
|
|
84
|
+
const sent = mockPoll(path);
|
|
85
|
+
|
|
86
|
+
const res: any = await app.monitorJobStatus("abc", app.prepareHeaders(), 0, "batch");
|
|
87
|
+
|
|
88
|
+
expect(sent).toEqual([`${API_URL}${path}`, `${API_URL}${path}`, `${API_URL}${path}?skip=1`]);
|
|
89
|
+
expect(res.data).toHaveLength(2);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -1,154 +1,107 @@
|
|
|
1
|
-
import FirecrawlApp from '../../../
|
|
1
|
+
import FirecrawlApp from '../../../v1';
|
|
2
2
|
import { describe, test, expect, jest, beforeEach, afterEach } from '@jest/globals';
|
|
3
3
|
|
|
4
|
+
const successResponse = {
|
|
5
|
+
status: 200,
|
|
6
|
+
data: { status: 'completed', data: [{ url: 'test.com', markdown: 'test' }] },
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
function networkError(message: string, code: string) {
|
|
10
|
+
return Object.assign(new Error(message), { code });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function httpError(message: string, status: number) {
|
|
14
|
+
return Object.assign(new Error(message), { response: { status, data: { error: message } } });
|
|
15
|
+
}
|
|
16
|
+
|
|
4
17
|
describe('monitorJobStatus retry logic', () => {
|
|
5
18
|
let app: FirecrawlApp;
|
|
6
|
-
let
|
|
7
|
-
|
|
19
|
+
let delays: number[];
|
|
20
|
+
|
|
8
21
|
beforeEach(() => {
|
|
9
22
|
app = new FirecrawlApp({ apiKey: 'test-key', apiUrl: 'https://test.com' });
|
|
10
|
-
|
|
11
|
-
|
|
23
|
+
delays = [];
|
|
24
|
+
jest.useFakeTimers();
|
|
25
|
+
const fakeSetTimeout = globalThis.setTimeout;
|
|
26
|
+
jest.spyOn(globalThis, 'setTimeout').mockImplementation(((fn: () => void, ms?: number) => {
|
|
27
|
+
delays.push(ms ?? 0);
|
|
28
|
+
return fakeSetTimeout(fn, ms);
|
|
29
|
+
}) as any);
|
|
12
30
|
});
|
|
13
31
|
|
|
14
32
|
afterEach(() => {
|
|
15
|
-
|
|
16
|
-
jest.
|
|
33
|
+
jest.restoreAllMocks();
|
|
34
|
+
jest.useRealTimers();
|
|
17
35
|
});
|
|
18
36
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
status
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
function failFirst(n: number, error: Error, statuses: string[] = []) {
|
|
38
|
+
let calls = 0;
|
|
39
|
+
app.getRequest = (async () => {
|
|
40
|
+
calls++;
|
|
41
|
+
if (calls <= n) throw error;
|
|
42
|
+
const status = statuses.shift();
|
|
43
|
+
return status ? { status: 200, data: { status } } : successResponse;
|
|
44
|
+
}) as any;
|
|
45
|
+
return () => calls;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function monitor() {
|
|
49
|
+
const result = app.monitorJobStatus('test-id', {} as any, 1);
|
|
50
|
+
result.catch(() => {});
|
|
51
|
+
await jest.runAllTimersAsync();
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
test.each([
|
|
56
|
+
['socket hang up', networkError('socket hang up', 'ECONNRESET')],
|
|
57
|
+
['ETIMEDOUT', networkError('timeout', 'ETIMEDOUT')],
|
|
58
|
+
['HTTP 408', httpError('Request timeout', 408)],
|
|
59
|
+
['HTTP 504', httpError('Gateway timeout', 504)],
|
|
60
|
+
])('retries once after a %s error and returns the job data', async (_label, error) => {
|
|
61
|
+
const calls = failFirst(1, error);
|
|
62
|
+
|
|
63
|
+
const result = await monitor();
|
|
64
|
+
|
|
65
|
+
expect(calls()).toBe(2);
|
|
42
66
|
expect(result).toEqual(successResponse.data);
|
|
43
|
-
expect(
|
|
44
|
-
expect.stringContaining('Network error during job status check (attempt 1/3): socket hang up')
|
|
45
|
-
);
|
|
67
|
+
expect(delays).toEqual([1000]);
|
|
46
68
|
});
|
|
47
69
|
|
|
48
|
-
test('
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
data: { status: 'completed', data: [{ url: 'test.com', markdown: 'test' }] }
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const originalGetRequest = app.getRequest;
|
|
58
|
-
let callCount = 0;
|
|
59
|
-
|
|
60
|
-
app.getRequest = async function(url: string, headers: any) {
|
|
61
|
-
callCount++;
|
|
62
|
-
if (callCount === 1) {
|
|
63
|
-
throw timeoutError;
|
|
64
|
-
}
|
|
65
|
-
return successResponse;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const result = await app.monitorJobStatus('test-id', {}, 1);
|
|
69
|
-
|
|
70
|
-
expect(callCount).toBe(2);
|
|
70
|
+
test('uses exponential backoff between retries', async () => {
|
|
71
|
+
const calls = failFirst(2, networkError('socket hang up', 'ECONNRESET'));
|
|
72
|
+
|
|
73
|
+
const result = await monitor();
|
|
74
|
+
|
|
75
|
+
expect(calls()).toBe(3);
|
|
71
76
|
expect(result).toEqual(successResponse.data);
|
|
77
|
+
expect(delays).toEqual([1000, 2000]);
|
|
72
78
|
});
|
|
73
79
|
|
|
74
|
-
test('
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
app.getRequest = async function(url: string, headers: any) {
|
|
79
|
-
throw socketHangUpError;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
await expect(app.monitorJobStatus('test-id', {}, 1)).rejects.toThrow('socket hang up');
|
|
83
|
-
|
|
84
|
-
expect(console.warn).toHaveBeenCalledTimes(3);
|
|
85
|
-
}, 15000);
|
|
86
|
-
|
|
87
|
-
test('should not retry on non-retryable errors', async () => {
|
|
88
|
-
const authError = new Error('Unauthorized') as any;
|
|
89
|
-
authError.response = { status: 401, data: { error: 'Unauthorized' } };
|
|
90
|
-
|
|
91
|
-
app.getRequest = async function(url: string, headers: any) {
|
|
92
|
-
throw authError;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
await expect(app.monitorJobStatus('test-id', {}, 1)).rejects.toThrow('Unauthorized');
|
|
96
|
-
|
|
97
|
-
expect(console.warn).not.toHaveBeenCalled();
|
|
98
|
-
});
|
|
80
|
+
test('records both the retry backoff and the 2s poll wait for an active job', async () => {
|
|
81
|
+
const calls = failFirst(1, networkError('socket hang up', 'ECONNRESET'), ['active']);
|
|
82
|
+
|
|
83
|
+
const result = await monitor();
|
|
99
84
|
|
|
100
|
-
|
|
101
|
-
const timeoutError = new Error('Request timeout') as any;
|
|
102
|
-
timeoutError.response = { status: 408, data: { error: 'Request timeout' } };
|
|
103
|
-
|
|
104
|
-
const successResponse = {
|
|
105
|
-
status: 200,
|
|
106
|
-
data: { status: 'completed', data: [{ url: 'test.com', markdown: 'test' }] }
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const originalGetRequest = app.getRequest;
|
|
110
|
-
let callCount = 0;
|
|
111
|
-
|
|
112
|
-
app.getRequest = async function(url: string, headers: any) {
|
|
113
|
-
callCount++;
|
|
114
|
-
if (callCount === 1) {
|
|
115
|
-
throw timeoutError;
|
|
116
|
-
}
|
|
117
|
-
return successResponse;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const result = await app.monitorJobStatus('test-id', {}, 1);
|
|
121
|
-
|
|
122
|
-
expect(callCount).toBe(2);
|
|
85
|
+
expect(calls()).toBe(3);
|
|
123
86
|
expect(result).toEqual(successResponse.data);
|
|
87
|
+
expect(delays).toEqual([1000, 2000]);
|
|
124
88
|
});
|
|
125
89
|
|
|
126
|
-
test('
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
return successResponse;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
const startTime = Date.now();
|
|
147
|
-
const result = await app.monitorJobStatus('test-id', {}, 1);
|
|
148
|
-
const endTime = Date.now();
|
|
149
|
-
|
|
150
|
-
expect(callCount).toBe(3);
|
|
151
|
-
expect(result).toEqual(successResponse.data);
|
|
152
|
-
expect(endTime - startTime).toBeGreaterThan(3000);
|
|
90
|
+
test('fails after max retries are exceeded', async () => {
|
|
91
|
+
const calls = failFirst(Infinity, networkError('socket hang up', 'ECONNRESET'));
|
|
92
|
+
|
|
93
|
+
await expect(monitor()).rejects.toThrow('socket hang up');
|
|
94
|
+
|
|
95
|
+
expect(calls()).toBe(4);
|
|
96
|
+
expect(delays).toEqual([1000, 2000, 4000]);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('does not retry non-retryable errors', async () => {
|
|
100
|
+
const calls = failFirst(Infinity, httpError('Unauthorized', 401));
|
|
101
|
+
|
|
102
|
+
await expect(monitor()).rejects.toThrow('Unauthorized');
|
|
103
|
+
|
|
104
|
+
expect(calls()).toBe(1);
|
|
105
|
+
expect(delays).toEqual([]);
|
|
153
106
|
});
|
|
154
107
|
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { describe, test, expect } from "@jest/globals";
|
|
2
|
+
import axios, { type AxiosAdapter } from "axios";
|
|
3
|
+
import { Firecrawl } from "../../../index";
|
|
4
|
+
import { SdkError } from "../../../v2/types";
|
|
5
|
+
|
|
6
|
+
const API_URL = "https://api.firecrawl.dev";
|
|
7
|
+
const API_KEY = "fc-test";
|
|
8
|
+
|
|
9
|
+
function makeClient(status: number, data: unknown) {
|
|
10
|
+
const client = new Firecrawl({ apiKey: API_KEY, apiUrl: API_URL });
|
|
11
|
+
const sent: Array<{ url: string; method?: string; authorization: unknown }> = [];
|
|
12
|
+
const adapter: AxiosAdapter = async config => {
|
|
13
|
+
sent.push({ url: axios.getUri(config), method: config.method, authorization: config.headers.Authorization });
|
|
14
|
+
const response = { data, status, statusText: "", headers: {}, config };
|
|
15
|
+
if (status >= 400) {
|
|
16
|
+
throw new axios.AxiosError(`Request failed with status code ${status}`, "ERR_BAD_RESPONSE", config, null, response);
|
|
17
|
+
}
|
|
18
|
+
return response;
|
|
19
|
+
};
|
|
20
|
+
(client as any).http.instance.defaults.adapter = adapter;
|
|
21
|
+
return { client, sent };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
describe("v2.getParseFormats unit", () => {
|
|
25
|
+
test("GETs /v2/parse/formats with auth and unwraps data.formats", async () => {
|
|
26
|
+
const { client, sent } = makeClient(200, {
|
|
27
|
+
success: true,
|
|
28
|
+
data: {
|
|
29
|
+
formats: [
|
|
30
|
+
{ format: "pdf", kind: "document", extensions: [".pdf"], mimeTypes: ["application/pdf"], available: true },
|
|
31
|
+
{ format: "png", kind: "image", extensions: [".png"], mimeTypes: ["image/png"], available: false },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const formats = await client.getParseFormats();
|
|
37
|
+
|
|
38
|
+
expect(sent).toEqual([{ url: `${API_URL}/v2/parse/formats`, method: "get", authorization: `Bearer ${API_KEY}` }]);
|
|
39
|
+
expect(formats).toHaveLength(2);
|
|
40
|
+
expect(formats[0]).toEqual({ format: "pdf", kind: "document", extensions: [".pdf"], mimeTypes: ["application/pdf"], available: true });
|
|
41
|
+
expect(formats[1]!.kind).toBe("image");
|
|
42
|
+
expect(formats[1]!.mimeTypes).toEqual(["image/png"]);
|
|
43
|
+
expect(formats[1]!.available).toBe(false);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("tolerates unknown kinds and extra fields", async () => {
|
|
47
|
+
const { client } = makeClient(200, {
|
|
48
|
+
success: true,
|
|
49
|
+
data: {
|
|
50
|
+
formats: [
|
|
51
|
+
{ format: "mp3", kind: "audio", extensions: [".mp3"], mimeTypes: ["audio/mpeg"], available: true, maxSizeMb: 50 },
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const [format] = await client.getParseFormats();
|
|
57
|
+
|
|
58
|
+
expect(format!.format).toBe("mp3");
|
|
59
|
+
expect(format!.kind).toBe("audio");
|
|
60
|
+
expect(format!.mimeTypes).toEqual(["audio/mpeg"]);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("returns an empty list when formats is missing", async () => {
|
|
64
|
+
const { client } = makeClient(200, { success: true, data: {} });
|
|
65
|
+
|
|
66
|
+
await expect(client.getParseFormats()).resolves.toEqual([]);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test.each([401, 500])("throws SdkError on %i", async status => {
|
|
70
|
+
const { client } = makeClient(status, { success: false, error: "Unauthorized" });
|
|
71
|
+
|
|
72
|
+
const err = await client.getParseFormats().catch(e => e);
|
|
73
|
+
|
|
74
|
+
expect(err).toBeInstanceOf(SdkError);
|
|
75
|
+
expect(err.status).toBe(status);
|
|
76
|
+
expect(err.message).toBe("Unauthorized");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test("throws SdkError when success is false", async () => {
|
|
80
|
+
const { client } = makeClient(200, { success: false, error: "nope" });
|
|
81
|
+
|
|
82
|
+
await expect(client.getParseFormats()).rejects.toBeInstanceOf(SdkError);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -1,11 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
1
|
+
import { describe, test, expect } from "@jest/globals";
|
|
2
|
+
import axios, { type AxiosAdapter } from "axios";
|
|
4
3
|
import { FirecrawlClient } from "../../../v2/client";
|
|
5
4
|
|
|
5
|
+
const API_URL = "https://api.firecrawl.dev";
|
|
6
|
+
|
|
7
|
+
function makeClient(apiKey: string) {
|
|
8
|
+
const client = new FirecrawlClient({ apiKey, apiUrl: API_URL });
|
|
9
|
+
const sent: Array<{ method?: string; url: string; authorization: unknown; body: unknown }> = [];
|
|
10
|
+
const adapter: AxiosAdapter = async config => {
|
|
11
|
+
sent.push({
|
|
12
|
+
method: config.method,
|
|
13
|
+
url: axios.getUri(config),
|
|
14
|
+
authorization: config.headers.Authorization,
|
|
15
|
+
body: JSON.parse(config.data),
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
data: { success: true, data: { markdown: "# hello" } },
|
|
19
|
+
status: 200,
|
|
20
|
+
statusText: "OK",
|
|
21
|
+
headers: {},
|
|
22
|
+
config,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
(client as any).http.instance.defaults.adapter = adapter;
|
|
26
|
+
return { client, sent };
|
|
27
|
+
}
|
|
28
|
+
|
|
6
29
|
describe("v2.scrape unit", () => {
|
|
7
|
-
test("
|
|
8
|
-
|
|
30
|
+
test("constructs without an API key and scrapes keyless, without an Authorization header", async () => {
|
|
31
|
+
const { client, sent } = makeClient("");
|
|
32
|
+
const doc = await client.scrape(" https://example.com ", { formats: ["markdown"] });
|
|
33
|
+
|
|
34
|
+
expect(doc.markdown).toBe("# hello");
|
|
35
|
+
expect(sent).toHaveLength(1);
|
|
36
|
+
expect(sent[0]!.method).toBe("post");
|
|
37
|
+
expect(sent[0]!.url).toBe(`${API_URL}/v2/scrape`);
|
|
38
|
+
expect(sent[0]!.authorization).toBeUndefined();
|
|
39
|
+
expect(sent[0]!.body).toEqual({
|
|
40
|
+
url: "https://example.com",
|
|
41
|
+
formats: ["markdown"],
|
|
42
|
+
origin: expect.stringMatching(/^js-sdk@/),
|
|
43
|
+
});
|
|
9
44
|
});
|
|
10
|
-
});
|
|
11
45
|
|
|
46
|
+
test("sends the API key as a bearer token when one is set", async () => {
|
|
47
|
+
const { client, sent } = makeClient("fc-test");
|
|
48
|
+
await client.scrape("https://example.com");
|
|
49
|
+
|
|
50
|
+
expect(sent).toHaveLength(1);
|
|
51
|
+
expect(sent[0]!.authorization).toBe("Bearer fc-test");
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("rejects an empty URL before sending a request", async () => {
|
|
55
|
+
const { client, sent } = makeClient("fc-test");
|
|
56
|
+
|
|
57
|
+
await expect(client.scrape(" ")).rejects.toThrow("URL cannot be empty");
|
|
58
|
+
expect(sent).toHaveLength(0);
|
|
59
|
+
});
|
|
60
|
+
});
|
package/src/v1/index.ts
CHANGED
|
@@ -1128,7 +1128,7 @@ export default class FirecrawlApp {
|
|
|
1128
1128
|
);
|
|
1129
1129
|
if (response.status === 200) {
|
|
1130
1130
|
const id: string = response.data.id;
|
|
1131
|
-
return this.monitorJobStatus(id, headers, pollInterval);
|
|
1131
|
+
return this.monitorJobStatus(id, headers, pollInterval, "batch");
|
|
1132
1132
|
} else {
|
|
1133
1133
|
this.handleError(response, "start batch scrape job");
|
|
1134
1134
|
}
|
|
@@ -1484,18 +1484,21 @@ export default class FirecrawlApp {
|
|
|
1484
1484
|
}
|
|
1485
1485
|
|
|
1486
1486
|
/**
|
|
1487
|
-
* Monitors the status of a crawl job until completion or failure.
|
|
1488
|
-
* @param id - The ID of the crawl operation.
|
|
1487
|
+
* Monitors the status of a crawl or batch scrape job until completion or failure.
|
|
1488
|
+
* @param id - The ID of the crawl or batch scrape operation.
|
|
1489
1489
|
* @param headers - The headers for the request.
|
|
1490
1490
|
* @param checkInterval - Interval in seconds for job status checks.
|
|
1491
|
-
* @param
|
|
1491
|
+
* @param jobType - Which status endpoint to poll. Defaults to `"crawl"`.
|
|
1492
1492
|
* @returns The final job status or data.
|
|
1493
1493
|
*/
|
|
1494
1494
|
async monitorJobStatus(
|
|
1495
1495
|
id: string,
|
|
1496
1496
|
headers: AxiosRequestHeaders,
|
|
1497
|
-
checkInterval: number
|
|
1497
|
+
checkInterval: number,
|
|
1498
|
+
jobType: "crawl" | "batch" = "crawl"
|
|
1498
1499
|
): Promise<CrawlStatusResponse | ErrorResponse> {
|
|
1500
|
+
const statusPath = jobType === "batch" ? "batch/scrape" : "crawl";
|
|
1501
|
+
const jobLabel = jobType === "batch" ? "Batch scrape" : "Crawl";
|
|
1499
1502
|
let failedTries = 0;
|
|
1500
1503
|
let networkRetries = 0;
|
|
1501
1504
|
const maxNetworkRetries = 3;
|
|
@@ -1503,7 +1506,7 @@ export default class FirecrawlApp {
|
|
|
1503
1506
|
while (true) {
|
|
1504
1507
|
try {
|
|
1505
1508
|
let statusResponse: AxiosResponse = await this.getRequest(
|
|
1506
|
-
`${this.apiUrl}/v1
|
|
1509
|
+
`${this.apiUrl}/v1/${statusPath}/${id}`,
|
|
1507
1510
|
headers
|
|
1508
1511
|
);
|
|
1509
1512
|
|
|
@@ -1526,7 +1529,7 @@ export default class FirecrawlApp {
|
|
|
1526
1529
|
statusData.data = data;
|
|
1527
1530
|
return statusData;
|
|
1528
1531
|
} else {
|
|
1529
|
-
throw new FirecrawlError(
|
|
1532
|
+
throw new FirecrawlError(`${jobLabel} job completed but no data was returned`, 500);
|
|
1530
1533
|
}
|
|
1531
1534
|
} else if (
|
|
1532
1535
|
["active", "paused", "pending", "queued", "waiting", "scraping"].includes(statusData.status)
|
|
@@ -1537,14 +1540,14 @@ export default class FirecrawlApp {
|
|
|
1537
1540
|
);
|
|
1538
1541
|
} else {
|
|
1539
1542
|
throw new FirecrawlError(
|
|
1540
|
-
|
|
1543
|
+
`${jobLabel} job failed or was stopped. Status: ${statusData.status}`,
|
|
1541
1544
|
500
|
|
1542
1545
|
);
|
|
1543
1546
|
}
|
|
1544
1547
|
} else {
|
|
1545
1548
|
failedTries++;
|
|
1546
1549
|
if (failedTries >= 3) {
|
|
1547
|
-
this.handleError(statusResponse,
|
|
1550
|
+
this.handleError(statusResponse, `check ${jobLabel.toLowerCase()} status`);
|
|
1548
1551
|
}
|
|
1549
1552
|
}
|
|
1550
1553
|
} catch (error: any) {
|
package/src/v2/client.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
interact as interactMethod,
|
|
5
5
|
stopInteraction as stopInteractionMethod,
|
|
6
6
|
} from "./methods/scrape";
|
|
7
|
-
import { parse as parseMethod } from "./methods/parse";
|
|
7
|
+
import { parse as parseMethod, getParseFormats } from "./methods/parse";
|
|
8
8
|
import { search } from "./methods/search";
|
|
9
9
|
import { scrapeAlexandria, findTools } from "./methods/tools";
|
|
10
10
|
import { developerSearch as developerSearchMethod } from "./methods/developer";
|
|
@@ -53,6 +53,7 @@ import type {
|
|
|
53
53
|
FindToolsData,
|
|
54
54
|
AlexandriaScrapeData,
|
|
55
55
|
ParseFile,
|
|
56
|
+
ParseFormatInfo,
|
|
56
57
|
ParseOptions,
|
|
57
58
|
ScrapeOptions,
|
|
58
59
|
SearchData,
|
|
@@ -273,6 +274,14 @@ export class FirecrawlClient {
|
|
|
273
274
|
return parseMethod(this.http, file, options);
|
|
274
275
|
}
|
|
275
276
|
|
|
277
|
+
/**
|
|
278
|
+
* List the file formats the parse endpoint accepts on this deployment.
|
|
279
|
+
* @returns Formats with their kind, extensions, MIME types, and availability.
|
|
280
|
+
*/
|
|
281
|
+
async getParseFormats(): Promise<ParseFormatInfo[]> {
|
|
282
|
+
return getParseFormats(this.http);
|
|
283
|
+
}
|
|
284
|
+
|
|
276
285
|
// Search
|
|
277
286
|
/**
|
|
278
287
|
* Search the web and optionally scrape each result.
|
package/src/v2/methods/agent.ts
CHANGED
|
@@ -12,6 +12,7 @@ function prepareAgentPayload(args: {
|
|
|
12
12
|
origin?: string;
|
|
13
13
|
maxCredits?: number;
|
|
14
14
|
strictConstrainToURLs?: boolean;
|
|
15
|
+
/** Defaults to spark-2. "spark-1-pro" and "spark-1-mini" are deprecated and run spark-2. */
|
|
15
16
|
model?: "spark-1-pro" | "spark-1-mini" | "spark-2";
|
|
16
17
|
effort?: AgentEffort;
|
|
17
18
|
webhook?: string | AgentWebhookConfig;
|
package/src/v2/methods/parse.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Document, type ParseFile, type ParseOptions } from "../types";
|
|
1
|
+
import { type Document, type ParseFile, type ParseFormatInfo, type ParseOptions } from "../types";
|
|
2
2
|
import { HttpClient } from "../utils/httpClient";
|
|
3
3
|
import { agentHintMetadata } from "../utils/agentHints";
|
|
4
4
|
import { ensureValidParseOptions } from "../utils/validation";
|
|
@@ -95,3 +95,14 @@ export async function parse(
|
|
|
95
95
|
throw err;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
+
|
|
99
|
+
export async function getParseFormats(http: HttpClient): Promise<ParseFormatInfo[]> {
|
|
100
|
+
try {
|
|
101
|
+
const res = await http.get<{ success: boolean; data?: { formats: ParseFormatInfo[] } }>("/v2/parse/formats");
|
|
102
|
+
if (res.status !== 200 || !res.data?.success) throwForBadResponse(res, "get parse formats");
|
|
103
|
+
return res.data.data?.formats ?? [];
|
|
104
|
+
} catch (err: any) {
|
|
105
|
+
if (err?.isAxiosError) return normalizeAxiosError(err, "get parse formats");
|
|
106
|
+
throw err;
|
|
107
|
+
}
|
|
108
|
+
}
|
package/src/v2/types.ts
CHANGED
|
@@ -366,6 +366,18 @@ export type ParseOptions = Omit<
|
|
|
366
366
|
proxy?: "basic" | "auto";
|
|
367
367
|
};
|
|
368
368
|
|
|
369
|
+
/** A file format accepted by the parse endpoint. */
|
|
370
|
+
export interface ParseFormatInfo {
|
|
371
|
+
/** Format identifier, e.g. "pdf". */
|
|
372
|
+
format: string;
|
|
373
|
+
kind: "document" | "image" | (string & {});
|
|
374
|
+
/** File extensions including the leading dot, e.g. ".pdf". */
|
|
375
|
+
extensions: string[];
|
|
376
|
+
mimeTypes: string[];
|
|
377
|
+
/** False when the format is recognized but not enabled on this deployment. */
|
|
378
|
+
available: boolean;
|
|
379
|
+
}
|
|
380
|
+
|
|
369
381
|
export interface WebhookConfig {
|
|
370
382
|
url: string;
|
|
371
383
|
headers?: Record<string, string>;
|
|
@@ -1627,6 +1639,11 @@ export interface AgentStatusResponse {
|
|
|
1627
1639
|
status: "processing" | "completed" | "failed";
|
|
1628
1640
|
error?: string;
|
|
1629
1641
|
data?: unknown;
|
|
1642
|
+
/** Best-effort result on a failed run; never a completed `data` value. */
|
|
1643
|
+
partial?: unknown;
|
|
1644
|
+
/** Schema validity of `partial`, when a schema was supplied. */
|
|
1645
|
+
partialSchemaValid?: boolean;
|
|
1646
|
+
stopReason?: "credit_limit_reached";
|
|
1630
1647
|
/**
|
|
1631
1648
|
* Server-provided model name. Widened past the request-side union on
|
|
1632
1649
|
* purpose: new models ship without an SDK release, so pinning this to known
|
|
@@ -1672,6 +1689,9 @@ export interface AgentThreadRun {
|
|
|
1672
1689
|
message: string | null;
|
|
1673
1690
|
/** Only present when the request asked for includeData. */
|
|
1674
1691
|
data?: unknown;
|
|
1692
|
+
partial?: unknown;
|
|
1693
|
+
partialSchemaValid?: boolean;
|
|
1694
|
+
stopReason?: "credit_limit_reached";
|
|
1675
1695
|
suggestions?: AgentSuggestion[] | null;
|
|
1676
1696
|
pendingApproval?: PendingApproval | null;
|
|
1677
1697
|
exchange?: AgentExchangeSummary | null;
|