firecrawl 4.35.0 → 4.38.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-666CR5HH.js → chunk-KSTNOGOD.js} +1 -1
- package/dist/index.cjs +114 -15
- package/dist/index.d.cts +224 -2
- package/dist/index.d.ts +224 -2
- package/dist/index.js +115 -16
- package/dist/{package-ZOVFJE7Z.js → package-OS7RONXY.js} +1 -1
- package/package.json +1 -1
- package/src/__tests__/unit/v2/agent-effort-trace.unit.test.ts +140 -0
- package/src/__tests__/unit/v2/agent-list.unit.test.ts +68 -0
- package/src/__tests__/unit/v2/scrapeAutoResume.test.ts +145 -0
- package/src/v1/index.ts +1 -0
- package/src/v2/client.ts +35 -4
- package/src/v2/methods/agent.ts +46 -1
- package/src/v2/methods/scrape.ts +123 -19
- package/src/v2/types.ts +209 -0
- package/src/v2/utils/httpClient.ts +6 -0
|
@@ -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.
|
|
15
|
+
version: "4.38.0",
|
|
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",
|
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
|
+
version: "4.38.0",
|
|
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",
|
|
@@ -179,6 +179,11 @@ var HttpClient = class {
|
|
|
179
179
|
getApiKey() {
|
|
180
180
|
return this.apiKey;
|
|
181
181
|
}
|
|
182
|
+
/** The client-wide default request timeout, for callers that need to
|
|
183
|
+
* extend a specific request beyond it (e.g. scrape auto-resume). */
|
|
184
|
+
getTimeoutMs() {
|
|
185
|
+
return this.instance.defaults.timeout ?? 3e5;
|
|
186
|
+
}
|
|
182
187
|
async request(config) {
|
|
183
188
|
const version = getVersion();
|
|
184
189
|
config.headers = {
|
|
@@ -559,26 +564,60 @@ function isRetryableError(err) {
|
|
|
559
564
|
}
|
|
560
565
|
|
|
561
566
|
// src/v2/methods/scrape.ts
|
|
562
|
-
|
|
567
|
+
var RESUME_MAX_ATTEMPTS = 5;
|
|
568
|
+
var RESUME_MAX_TOTAL_WAIT_MS = 20 * 60 * 1e3;
|
|
569
|
+
var RESUME_MIN_DELAY_MS = 5 * 1e3;
|
|
570
|
+
var RESUME_MAX_DELAY_MS = 10 * 60 * 1e3;
|
|
571
|
+
function processingContinuesDelayMs(err) {
|
|
572
|
+
const response = err?.isAxiosError ? err.response : void 0;
|
|
573
|
+
if (!response || response.status !== 408) return void 0;
|
|
574
|
+
const body = response.data;
|
|
575
|
+
if (body?.code !== "SCRAPE_TIMEOUT" || body?.details?.state !== "processing_continues") {
|
|
576
|
+
return void 0;
|
|
577
|
+
}
|
|
578
|
+
const headerSeconds = Number(response.headers?.["retry-after"]);
|
|
579
|
+
const seconds = typeof body.details.retryAfterSeconds === "number" && Number.isFinite(body.details.retryAfterSeconds) ? body.details.retryAfterSeconds : Number.isFinite(headerSeconds) ? headerSeconds : 60;
|
|
580
|
+
return Math.min(RESUME_MAX_DELAY_MS, Math.max(RESUME_MIN_DELAY_MS, seconds * 1e3));
|
|
581
|
+
}
|
|
582
|
+
async function scrape(http, url, options, deps = {}) {
|
|
583
|
+
const sleep = deps.sleepImpl ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
563
584
|
if (!url || !url.trim()) {
|
|
564
585
|
throw new Error("URL cannot be empty");
|
|
565
586
|
}
|
|
566
587
|
if (options) ensureValidScrapeOptions(options);
|
|
588
|
+
const { autoResume, ...requestOptions } = options ?? {};
|
|
567
589
|
const payload = { url: url.trim() };
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
"
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
590
|
+
Object.assign(payload, requestOptions);
|
|
591
|
+
const requestTimeout = autoResume === false ? typeof options?.timeout === "number" ? { timeoutMs: options.timeout + 5e3 } : {} : {
|
|
592
|
+
timeoutMs: Math.max(
|
|
593
|
+
typeof options?.timeout === "number" ? options.timeout : 3e5,
|
|
594
|
+
typeof http.getTimeoutMs === "function" ? http.getTimeoutMs() : 0
|
|
595
|
+
) + 3e4
|
|
596
|
+
};
|
|
597
|
+
let resumes = 0;
|
|
598
|
+
let resumeWaitedMs = 0;
|
|
599
|
+
while (true) {
|
|
600
|
+
try {
|
|
601
|
+
const res = await http.post(
|
|
602
|
+
"/v2/scrape",
|
|
603
|
+
payload,
|
|
604
|
+
requestTimeout
|
|
605
|
+
);
|
|
606
|
+
if (res.status !== 200 || !res.data?.success) {
|
|
607
|
+
throwForBadResponse(res, "scrape");
|
|
608
|
+
}
|
|
609
|
+
return res.data.data || {};
|
|
610
|
+
} catch (err) {
|
|
611
|
+
const delayMs = autoResume !== false ? processingContinuesDelayMs(err) : void 0;
|
|
612
|
+
if (delayMs !== void 0 && resumes < RESUME_MAX_ATTEMPTS && resumeWaitedMs + delayMs <= RESUME_MAX_TOTAL_WAIT_MS) {
|
|
613
|
+
resumes += 1;
|
|
614
|
+
resumeWaitedMs += delayMs;
|
|
615
|
+
await sleep(delayMs);
|
|
616
|
+
continue;
|
|
617
|
+
}
|
|
618
|
+
if (err?.isAxiosError) return normalizeAxiosError(err, "scrape");
|
|
619
|
+
throw err;
|
|
577
620
|
}
|
|
578
|
-
return res.data.data || {};
|
|
579
|
-
} catch (err) {
|
|
580
|
-
if (err?.isAxiosError) return normalizeAxiosError(err, "scrape");
|
|
581
|
-
throw err;
|
|
582
621
|
}
|
|
583
622
|
}
|
|
584
623
|
async function interact(http, jobId, args) {
|
|
@@ -1326,6 +1365,7 @@ function prepareAgentPayload(args) {
|
|
|
1326
1365
|
if (args.maxCredits !== null && args.maxCredits !== void 0) body.maxCredits = args.maxCredits;
|
|
1327
1366
|
if (args.strictConstrainToURLs !== null && args.strictConstrainToURLs !== void 0) body.strictConstrainToURLs = args.strictConstrainToURLs;
|
|
1328
1367
|
if (args.model !== null && args.model !== void 0) body.model = args.model;
|
|
1368
|
+
if (args.effort !== null && args.effort !== void 0) body.effort = args.effort;
|
|
1329
1369
|
if (args.webhook != null) body.webhook = args.webhook;
|
|
1330
1370
|
if (args.threatProtection != null)
|
|
1331
1371
|
body.threatProtection = args.threatProtection;
|
|
@@ -1354,6 +1394,17 @@ async function getAgentStatus(http, jobId) {
|
|
|
1354
1394
|
throw err;
|
|
1355
1395
|
}
|
|
1356
1396
|
}
|
|
1397
|
+
async function listAgents(http, options) {
|
|
1398
|
+
try {
|
|
1399
|
+
const query = options?.before !== void 0 ? `?before=${options.before}` : "";
|
|
1400
|
+
const res = await http.get(`/v2/agent${query}`);
|
|
1401
|
+
if (res.status !== 200) throwForBadResponse(res, "list agents");
|
|
1402
|
+
return res.data;
|
|
1403
|
+
} catch (err) {
|
|
1404
|
+
if (err?.isAxiosError) return normalizeAxiosError(err, "list agents");
|
|
1405
|
+
throw err;
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1357
1408
|
async function waitAgent(http, jobId, pollInterval = 2, timeout) {
|
|
1358
1409
|
const start = Date.now();
|
|
1359
1410
|
while (true) {
|
|
@@ -1369,6 +1420,27 @@ async function agent(http, args) {
|
|
|
1369
1420
|
if (!jobId) return started;
|
|
1370
1421
|
return waitAgent(http, jobId, args.pollInterval ?? 2, args.timeout);
|
|
1371
1422
|
}
|
|
1423
|
+
async function getAgentTrace(http, jobId, options) {
|
|
1424
|
+
try {
|
|
1425
|
+
const query = options?.liveView ? "?liveView=true" : "";
|
|
1426
|
+
const res = await http.get(`/v2/agent/${jobId}/trace${query}`);
|
|
1427
|
+
if (res.status !== 200) throwForBadResponse(res, "agent trace");
|
|
1428
|
+
return res.data;
|
|
1429
|
+
} catch (err) {
|
|
1430
|
+
if (err?.isAxiosError) return normalizeAxiosError(err, "agent trace");
|
|
1431
|
+
throw err;
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
async function getAgentSnapshot(http, jobId, snapshotId) {
|
|
1435
|
+
try {
|
|
1436
|
+
const res = await http.get(`/v2/agent/${jobId}/snapshots/${snapshotId}`);
|
|
1437
|
+
if (res.status !== 200) throwForBadResponse(res, "agent snapshot");
|
|
1438
|
+
return res.data;
|
|
1439
|
+
} catch (err) {
|
|
1440
|
+
if (err?.isAxiosError) return normalizeAxiosError(err, "agent snapshot");
|
|
1441
|
+
throw err;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1372
1444
|
async function cancelAgent(http, jobId) {
|
|
1373
1445
|
try {
|
|
1374
1446
|
const res = await http.delete(`/v2/agent/${jobId}`);
|
|
@@ -2354,6 +2426,17 @@ var FirecrawlClient = class {
|
|
|
2354
2426
|
async getAgentStatus(jobId) {
|
|
2355
2427
|
return getAgentStatus(this.http, jobId);
|
|
2356
2428
|
}
|
|
2429
|
+
/**
|
|
2430
|
+
* List agent runs, most recent first.
|
|
2431
|
+
*
|
|
2432
|
+
* Pages are fixed at 20 runs. To fetch the next page, pass the `before`
|
|
2433
|
+
* value from the previous page's `next` URL. This method does not
|
|
2434
|
+
* auto-paginate.
|
|
2435
|
+
* @param options.before Only return runs created before this unix ms timestamp.
|
|
2436
|
+
*/
|
|
2437
|
+
async listAgents(options) {
|
|
2438
|
+
return listAgents(this.http, options);
|
|
2439
|
+
}
|
|
2357
2440
|
/**
|
|
2358
2441
|
* Convenience waiter: start an agent and poll until it finishes.
|
|
2359
2442
|
* @param args Agent request plus waiter controls (pollInterval, timeout seconds).
|
|
@@ -2370,6 +2453,22 @@ var FirecrawlClient = class {
|
|
|
2370
2453
|
async cancelAgent(jobId) {
|
|
2371
2454
|
return cancelAgent(this.http, jobId);
|
|
2372
2455
|
}
|
|
2456
|
+
/**
|
|
2457
|
+
* Get the execution trace of an agent job (spark-2 runs only).
|
|
2458
|
+
* @param jobId Agent job id.
|
|
2459
|
+
* @param options.liveView Also include currently active browser sessions with live view URLs.
|
|
2460
|
+
*/
|
|
2461
|
+
async getAgentTrace(jobId, options) {
|
|
2462
|
+
return getAgentTrace(this.http, jobId, options);
|
|
2463
|
+
}
|
|
2464
|
+
/**
|
|
2465
|
+
* Get the full content of an artifact snapshot referenced by a trace event.
|
|
2466
|
+
* @param jobId Agent job id.
|
|
2467
|
+
* @param snapshotId Snapshot id from an artifact.updated trace event.
|
|
2468
|
+
*/
|
|
2469
|
+
async getAgentSnapshot(jobId, snapshotId) {
|
|
2470
|
+
return getAgentSnapshot(this.http, jobId, snapshotId);
|
|
2471
|
+
}
|
|
2373
2472
|
// Browser
|
|
2374
2473
|
/**
|
|
2375
2474
|
* Create a new browser session.
|
package/dist/index.d.cts
CHANGED
|
@@ -16,6 +16,7 @@ interface JsonFormat extends Format {
|
|
|
16
16
|
type: "json";
|
|
17
17
|
prompt?: string;
|
|
18
18
|
schema?: Record<string, unknown> | ZodTypeAny;
|
|
19
|
+
checkPromptInjection?: boolean;
|
|
19
20
|
}
|
|
20
21
|
interface ScreenshotFormat {
|
|
21
22
|
type: "screenshot";
|
|
@@ -1102,9 +1103,181 @@ interface AgentStatusResponse {
|
|
|
1102
1103
|
* names makes every future model a type error at the call site.
|
|
1103
1104
|
*/
|
|
1104
1105
|
model?: "spark-1-pro" | "spark-1-mini" | "spark-2" | (string & {});
|
|
1106
|
+
/**
|
|
1107
|
+
* Reasoning effort the job ran with. Only set for runs that specified it;
|
|
1108
|
+
* older rows and default runs have no effort.
|
|
1109
|
+
*/
|
|
1110
|
+
effort?: "low" | "medium" | "high";
|
|
1105
1111
|
expiresAt: string;
|
|
1106
1112
|
creditsUsed?: number;
|
|
1107
1113
|
}
|
|
1114
|
+
/** Reasoning effort for agent jobs. Every level runs spark-2. */
|
|
1115
|
+
type AgentEffort = "low" | "medium" | "high";
|
|
1116
|
+
/** A single agent run as returned by the agent list endpoint. */
|
|
1117
|
+
interface AgentListItem {
|
|
1118
|
+
id: string;
|
|
1119
|
+
createdAt: string;
|
|
1120
|
+
targetHint: string;
|
|
1121
|
+
origin: string;
|
|
1122
|
+
integration?: string;
|
|
1123
|
+
settings: {
|
|
1124
|
+
hidden: boolean;
|
|
1125
|
+
starred: boolean;
|
|
1126
|
+
label?: string;
|
|
1127
|
+
};
|
|
1128
|
+
status: "processing" | "completed" | "failed";
|
|
1129
|
+
options?: {
|
|
1130
|
+
urls?: string[];
|
|
1131
|
+
prompt: string;
|
|
1132
|
+
schema?: unknown;
|
|
1133
|
+
/**
|
|
1134
|
+
* Server-provided model name. Widened past the request-side union on
|
|
1135
|
+
* purpose: new models ship without an SDK release, so pinning this to
|
|
1136
|
+
* known names makes every future model a type error at the call site.
|
|
1137
|
+
*/
|
|
1138
|
+
model: "spark-1-pro" | "spark-1-mini" | "spark-2" | (string & {});
|
|
1139
|
+
effort?: AgentEffort;
|
|
1140
|
+
};
|
|
1141
|
+
}
|
|
1142
|
+
interface AgentListResponse {
|
|
1143
|
+
success: boolean;
|
|
1144
|
+
agents?: AgentListItem[];
|
|
1145
|
+
/**
|
|
1146
|
+
* Absolute URL of the next page (pass its `before` value to listAgents to
|
|
1147
|
+
* continue). Only present when more pages exist.
|
|
1148
|
+
*/
|
|
1149
|
+
next?: string;
|
|
1150
|
+
error?: string;
|
|
1151
|
+
}
|
|
1152
|
+
/** Options for listing agent runs. */
|
|
1153
|
+
interface AgentListOptions {
|
|
1154
|
+
/** Only return agent runs created before this unix millisecond timestamp. */
|
|
1155
|
+
before?: number;
|
|
1156
|
+
}
|
|
1157
|
+
type AgentTraceAgentRole = "orchestrator" | "subagent" | "browser" | "system";
|
|
1158
|
+
interface AgentTraceAgentIdentity {
|
|
1159
|
+
id: string;
|
|
1160
|
+
role: AgentTraceAgentRole;
|
|
1161
|
+
name: string;
|
|
1162
|
+
parentId?: string;
|
|
1163
|
+
}
|
|
1164
|
+
interface AgentTraceError {
|
|
1165
|
+
code: "cancelled" | "credit_limit_reached" | "parent_finished" | "refused" | "internal";
|
|
1166
|
+
source: "agent" | "tool" | "billing" | "system";
|
|
1167
|
+
retryable: boolean;
|
|
1168
|
+
message: string;
|
|
1169
|
+
}
|
|
1170
|
+
interface AgentTraceArtifactChange {
|
|
1171
|
+
kind: "json" | "markdown" | "html" | "screenshot" | "text";
|
|
1172
|
+
artifactId: string;
|
|
1173
|
+
path?: string;
|
|
1174
|
+
/** Fetch the full content via getAgentSnapshot(jobId, snapshotId). */
|
|
1175
|
+
snapshotId: string;
|
|
1176
|
+
change: "init" | "partial" | "append" | "modify" | "update";
|
|
1177
|
+
changedFields?: string[];
|
|
1178
|
+
itemCount?: number;
|
|
1179
|
+
sourceToolCallId?: string;
|
|
1180
|
+
}
|
|
1181
|
+
interface AgentTraceEventBase {
|
|
1182
|
+
schemaVersion: 1;
|
|
1183
|
+
eventId: string;
|
|
1184
|
+
runId: string;
|
|
1185
|
+
occurredAt: string;
|
|
1186
|
+
producerSequence: number;
|
|
1187
|
+
agent: AgentTraceAgentIdentity;
|
|
1188
|
+
}
|
|
1189
|
+
interface AgentTraceRunStartedEvent extends AgentTraceEventBase {
|
|
1190
|
+
type: "run.started";
|
|
1191
|
+
}
|
|
1192
|
+
interface AgentTraceRunCancelRequestedEvent extends AgentTraceEventBase {
|
|
1193
|
+
type: "run.cancel_requested";
|
|
1194
|
+
reason: "user";
|
|
1195
|
+
}
|
|
1196
|
+
interface AgentTraceRunFinishedEvent extends AgentTraceEventBase {
|
|
1197
|
+
type: "run.finished";
|
|
1198
|
+
outcome: "succeeded" | "failed" | "cancelled" | "refused" | "credit_limit_reached";
|
|
1199
|
+
/** The canonical schema always writes this key (nullable), but older rows may omit it. */
|
|
1200
|
+
error?: AgentTraceError | null;
|
|
1201
|
+
}
|
|
1202
|
+
interface AgentTraceAgentStartedEvent extends AgentTraceEventBase {
|
|
1203
|
+
type: "agent.started";
|
|
1204
|
+
}
|
|
1205
|
+
interface AgentTraceAgentFinishedEvent extends AgentTraceEventBase {
|
|
1206
|
+
type: "agent.finished";
|
|
1207
|
+
outcome: "succeeded" | "failed" | "cancelled" | "refused";
|
|
1208
|
+
durationMs: number;
|
|
1209
|
+
/** The canonical schema always writes this key (nullable), but older rows may omit it. */
|
|
1210
|
+
error?: AgentTraceError | null;
|
|
1211
|
+
}
|
|
1212
|
+
interface AgentTraceBrowserSessionStartedEvent extends AgentTraceEventBase {
|
|
1213
|
+
type: "browser.session.started";
|
|
1214
|
+
sessionId: string;
|
|
1215
|
+
}
|
|
1216
|
+
interface AgentTraceBrowserSessionFinishedEvent extends AgentTraceEventBase {
|
|
1217
|
+
type: "browser.session.finished";
|
|
1218
|
+
sessionId: string;
|
|
1219
|
+
durationMs: number;
|
|
1220
|
+
}
|
|
1221
|
+
interface AgentTraceProgressReportedEvent extends AgentTraceEventBase {
|
|
1222
|
+
type: "progress.reported";
|
|
1223
|
+
phase: "planning" | "working" | "finalizing";
|
|
1224
|
+
message: string;
|
|
1225
|
+
}
|
|
1226
|
+
interface AgentTraceReasoningSummaryEvent extends AgentTraceEventBase {
|
|
1227
|
+
type: "reasoning.summary";
|
|
1228
|
+
text: string;
|
|
1229
|
+
}
|
|
1230
|
+
interface AgentTraceToolCallStartedEvent extends AgentTraceEventBase {
|
|
1231
|
+
type: "tool_call.started";
|
|
1232
|
+
toolCallId: string;
|
|
1233
|
+
toolName: string;
|
|
1234
|
+
parameters: unknown;
|
|
1235
|
+
}
|
|
1236
|
+
interface AgentTraceToolCallFinishedEvent extends AgentTraceEventBase {
|
|
1237
|
+
type: "tool_call.finished";
|
|
1238
|
+
toolCallId: string;
|
|
1239
|
+
toolName: string;
|
|
1240
|
+
result: unknown;
|
|
1241
|
+
}
|
|
1242
|
+
interface AgentTraceArtifactUpdatedEvent extends AgentTraceEventBase {
|
|
1243
|
+
type: "artifact.updated";
|
|
1244
|
+
artifact: AgentTraceArtifactChange;
|
|
1245
|
+
}
|
|
1246
|
+
interface AgentTraceErrorOccurredEvent extends AgentTraceEventBase {
|
|
1247
|
+
type: "error.occurred";
|
|
1248
|
+
error: AgentTraceError;
|
|
1249
|
+
}
|
|
1250
|
+
/**
|
|
1251
|
+
* One event in an agent job's trace. Mirrors the canonical event schema of
|
|
1252
|
+
* the agent service (schemaVersion 1); `usage.recorded` events are withheld
|
|
1253
|
+
* server-side and `agent.started` carries no model name.
|
|
1254
|
+
*/
|
|
1255
|
+
type AgentTraceEvent = AgentTraceRunStartedEvent | AgentTraceRunCancelRequestedEvent | AgentTraceRunFinishedEvent | AgentTraceAgentStartedEvent | AgentTraceAgentFinishedEvent | AgentTraceBrowserSessionStartedEvent | AgentTraceBrowserSessionFinishedEvent | AgentTraceProgressReportedEvent | AgentTraceReasoningSummaryEvent | AgentTraceToolCallStartedEvent | AgentTraceToolCallFinishedEvent | AgentTraceArtifactUpdatedEvent | AgentTraceErrorOccurredEvent;
|
|
1256
|
+
interface AgentTraceActiveBrowserSession {
|
|
1257
|
+
id: string;
|
|
1258
|
+
liveViewUrl: string;
|
|
1259
|
+
viewport: {
|
|
1260
|
+
width: number;
|
|
1261
|
+
height: number;
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
interface AgentTraceResponse {
|
|
1265
|
+
success: boolean;
|
|
1266
|
+
id?: string;
|
|
1267
|
+
events?: AgentTraceEvent[];
|
|
1268
|
+
creditsUsed?: number;
|
|
1269
|
+
/** Present only when the trace was requested with liveView: true. */
|
|
1270
|
+
activeBrowserSessions?: AgentTraceActiveBrowserSession[];
|
|
1271
|
+
error?: string;
|
|
1272
|
+
}
|
|
1273
|
+
interface AgentSnapshotResponse {
|
|
1274
|
+
success: boolean;
|
|
1275
|
+
id?: string;
|
|
1276
|
+
snapshotId?: string;
|
|
1277
|
+
/** Full artifact content as a JSON/string blob. */
|
|
1278
|
+
snapshot?: string;
|
|
1279
|
+
error?: string;
|
|
1280
|
+
}
|
|
1108
1281
|
interface AgentOptions$1 {
|
|
1109
1282
|
model: "FIRE-1" | "v3-beta";
|
|
1110
1283
|
}
|
|
@@ -1424,6 +1597,9 @@ declare class HttpClient {
|
|
|
1424
1597
|
constructor(options: HttpClientOptions);
|
|
1425
1598
|
getApiUrl(): string;
|
|
1426
1599
|
getApiKey(): string;
|
|
1600
|
+
/** The client-wide default request timeout, for callers that need to
|
|
1601
|
+
* extend a specific request beyond it (e.g. scrape auto-resume). */
|
|
1602
|
+
getTimeoutMs(): number;
|
|
1427
1603
|
private request;
|
|
1428
1604
|
private sleep;
|
|
1429
1605
|
post<T = any>(endpoint: string, body: Record<string, unknown>, options?: RequestOptions): Promise<AxiosResponse<T, any, {}>>;
|
|
@@ -1434,6 +1610,27 @@ declare class HttpClient {
|
|
|
1434
1610
|
prepareHeaders(idempotencyKey?: string): Record<string, string>;
|
|
1435
1611
|
}
|
|
1436
1612
|
|
|
1613
|
+
/**
|
|
1614
|
+
* Options for a direct scrape call. `autoResume` lives here — NOT on the
|
|
1615
|
+
* shared ScrapeOptions — because that type is reused verbatim inside
|
|
1616
|
+
* batch/crawl/search/extract payloads, where an SDK-only key would leak
|
|
1617
|
+
* onto the wire and fail strict endpoints.
|
|
1618
|
+
*/
|
|
1619
|
+
type ScrapeCallOptions = ScrapeOptions & {
|
|
1620
|
+
/**
|
|
1621
|
+
* SDK-only (never sent to the API). Large documents (big PDFs) that
|
|
1622
|
+
* outlive the request window keep processing server-side; the API's
|
|
1623
|
+
* timeout error then carries `details.state === "processing_continues"`
|
|
1624
|
+
* and a Retry-After. When this is not `false`, the SDK sleeps that
|
|
1625
|
+
* long and re-issues the same request — the retry attaches to the
|
|
1626
|
+
* in-flight job and returns the finished result, so a large document
|
|
1627
|
+
* behaves like one slow successful call. Bounded (at most 5 resumes /
|
|
1628
|
+
* 20 minutes total wait); set `false` to surface the timeout error
|
|
1629
|
+
* immediately instead.
|
|
1630
|
+
*/
|
|
1631
|
+
autoResume?: boolean;
|
|
1632
|
+
};
|
|
1633
|
+
|
|
1437
1634
|
declare function prepareExtractPayload(args: {
|
|
1438
1635
|
urls?: string[];
|
|
1439
1636
|
prompt?: string;
|
|
@@ -1465,6 +1662,7 @@ declare function prepareAgentPayload(args: {
|
|
|
1465
1662
|
maxCredits?: number;
|
|
1466
1663
|
strictConstrainToURLs?: boolean;
|
|
1467
1664
|
model?: "spark-1-pro" | "spark-1-mini" | "spark-2";
|
|
1665
|
+
effort?: AgentEffort;
|
|
1468
1666
|
webhook?: string | AgentWebhookConfig;
|
|
1469
1667
|
threatProtection?: ThreatProtectionOptions;
|
|
1470
1668
|
auditMetadata?: AuditMetadata$1;
|
|
@@ -1636,7 +1834,7 @@ declare class FirecrawlClient {
|
|
|
1636
1834
|
scrape<Opts extends ScrapeOptions>(url: string, options: Opts): Promise<Omit<Document, "json"> & {
|
|
1637
1835
|
json?: InferredJsonFromOptions<Opts>;
|
|
1638
1836
|
}>;
|
|
1639
|
-
scrape(url: string, options?:
|
|
1837
|
+
scrape(url: string, options?: ScrapeCallOptions): Promise<Document>;
|
|
1640
1838
|
/**
|
|
1641
1839
|
* Interact with the browser session associated with a scrape job.
|
|
1642
1840
|
* @param jobId Scrape job id.
|
|
@@ -1869,6 +2067,15 @@ declare class FirecrawlClient {
|
|
|
1869
2067
|
* @param jobId Agent job id.
|
|
1870
2068
|
*/
|
|
1871
2069
|
getAgentStatus(jobId: string): Promise<AgentStatusResponse>;
|
|
2070
|
+
/**
|
|
2071
|
+
* List agent runs, most recent first.
|
|
2072
|
+
*
|
|
2073
|
+
* Pages are fixed at 20 runs. To fetch the next page, pass the `before`
|
|
2074
|
+
* value from the previous page's `next` URL. This method does not
|
|
2075
|
+
* auto-paginate.
|
|
2076
|
+
* @param options.before Only return runs created before this unix ms timestamp.
|
|
2077
|
+
*/
|
|
2078
|
+
listAgents(options?: AgentListOptions): Promise<AgentListResponse>;
|
|
1872
2079
|
/**
|
|
1873
2080
|
* Convenience waiter: start an agent and poll until it finishes.
|
|
1874
2081
|
* @param args Agent request plus waiter controls (pollInterval, timeout seconds).
|
|
@@ -1884,6 +2091,20 @@ declare class FirecrawlClient {
|
|
|
1884
2091
|
* @returns True if cancelled.
|
|
1885
2092
|
*/
|
|
1886
2093
|
cancelAgent(jobId: string): Promise<boolean>;
|
|
2094
|
+
/**
|
|
2095
|
+
* Get the execution trace of an agent job (spark-2 runs only).
|
|
2096
|
+
* @param jobId Agent job id.
|
|
2097
|
+
* @param options.liveView Also include currently active browser sessions with live view URLs.
|
|
2098
|
+
*/
|
|
2099
|
+
getAgentTrace(jobId: string, options?: {
|
|
2100
|
+
liveView?: boolean;
|
|
2101
|
+
}): Promise<AgentTraceResponse>;
|
|
2102
|
+
/**
|
|
2103
|
+
* Get the full content of an artifact snapshot referenced by a trace event.
|
|
2104
|
+
* @param jobId Agent job id.
|
|
2105
|
+
* @param snapshotId Snapshot id from an artifact.updated trace event.
|
|
2106
|
+
*/
|
|
2107
|
+
getAgentSnapshot(jobId: string, snapshotId: string): Promise<AgentSnapshotResponse>;
|
|
1887
2108
|
/**
|
|
1888
2109
|
* Create a new browser session.
|
|
1889
2110
|
* @param args Session options (ttl, activityTtl, streamWebView, profile).
|
|
@@ -2124,6 +2345,7 @@ interface ScrapeParams<LLMSchema extends zt.ZodSchema = any, ActionsSchema exten
|
|
|
2124
2345
|
prompt?: string;
|
|
2125
2346
|
schema?: LLMSchema;
|
|
2126
2347
|
systemPrompt?: string;
|
|
2348
|
+
checkPromptInjection?: boolean;
|
|
2127
2349
|
};
|
|
2128
2350
|
changeTrackingOptions?: {
|
|
2129
2351
|
prompt?: string;
|
|
@@ -2885,4 +3107,4 @@ declare class Firecrawl extends FirecrawlClient {
|
|
|
2885
3107
|
get v1(): FirecrawlApp;
|
|
2886
3108
|
}
|
|
2887
3109
|
|
|
2888
|
-
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentStatusResponse, type AgentWebhookConfig, type AgentWebhookEvent, 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 Document, type DocumentMetadata, type EndpointFeedbackEndpoint, type EndpointFeedbackRequest, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, type FeedbackMissingContent, type FeedbackRating, type FeedbackResponse, type FeedbackValuableSource, 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, 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 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, 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 };
|
|
3110
|
+
export { type ActionOption, type ActiveCrawl, type ActiveCrawlsResponse, type AgentEffort, type AgentListItem, type AgentListOptions, type AgentListResponse, type AgentOptions$1 as AgentOptions, type AgentResponse, type AgentSnapshotResponse, type AgentStatusResponse, 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 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 Document, type DocumentMetadata, type EndpointFeedbackEndpoint, type EndpointFeedbackRequest, type ErrorDetails, type ExecuteJavascriptAction, type ExtractResponse$1 as ExtractResponse, type FeedbackMissingContent, type FeedbackRating, type FeedbackResponse, type FeedbackValuableSource, 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, 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 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, 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 };
|