@howells/fieldwork-sdk 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +239 -2
- package/dist/adapter-CEAQuT7F.js +3 -0
- package/dist/adapter-DGehHCMo.d.ts +470 -0
- package/dist/brave.d.ts +164 -0
- package/dist/brave.js +399 -0
- package/dist/browserbase.d.ts +128 -0
- package/dist/browserbase.js +180 -0
- package/dist/errors-BiIBG9zN.js +65 -0
- package/dist/exa.d.ts +191 -0
- package/dist/exa.js +471 -0
- package/dist/fieldwork-B3x3cxDJ.d.ts +78 -0
- package/dist/firecrawl.d.ts +322 -0
- package/dist/firecrawl.js +932 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +91 -0
- package/dist/parallel.d.ts +230 -0
- package/dist/parallel.js +696 -0
- package/dist/perplexity.d.ts +101 -0
- package/dist/perplexity.js +333 -0
- package/dist/serpapi.d.ts +172 -0
- package/dist/serpapi.js +517 -0
- package/dist/tavily.d.ts +157 -0
- package/dist/tavily.js +417 -0
- package/dist/tools.d.ts +104 -0
- package/dist/tools.js +1367 -0
- package/dist/types-CnomnF-6.js +27 -0
- package/dist/util-CYenIQQT.js +265 -0
- package/package.json +98 -3
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { A as JsonSchema, F as MonitorSchedule, G as Research, I as Page, L as PageBatch, N as MonitorEvents, P as MonitorInfo, R as ParsedDocument, V as Product, W as Recency, X as SiteMap, a as RawClient, c as ActResult, f as CallOptions, g as Crawl, k as ImageSearch, q as SearchResponse, s as AccountUsage, t as Adapter, u as BrowserSession, w as Extraction, x as DocumentInput } from "./adapter-DGehHCMo.js";
|
|
2
|
+
interface FirecrawlConfig {
|
|
3
|
+
/** Defaults to the FIRECRAWL_API_KEY environment variable. */
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
fetch?: typeof fetch;
|
|
7
|
+
}
|
|
8
|
+
/** A step Firecrawl runs in the browser before it reads the page. */
|
|
9
|
+
type FirecrawlAction = {
|
|
10
|
+
type: "wait";
|
|
11
|
+
milliseconds: number;
|
|
12
|
+
} | {
|
|
13
|
+
type: "wait";
|
|
14
|
+
selector: string;
|
|
15
|
+
} | {
|
|
16
|
+
type: "screenshot";
|
|
17
|
+
fullPage?: boolean;
|
|
18
|
+
quality?: number;
|
|
19
|
+
viewport?: {
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
};
|
|
23
|
+
} | {
|
|
24
|
+
type: "click";
|
|
25
|
+
selector: string;
|
|
26
|
+
all?: boolean;
|
|
27
|
+
} |
|
|
28
|
+
/** Click the field first: Firecrawl types into the focused element. */
|
|
29
|
+
{
|
|
30
|
+
type: "write";
|
|
31
|
+
text: string;
|
|
32
|
+
} | {
|
|
33
|
+
type: "press";
|
|
34
|
+
key: string;
|
|
35
|
+
} | {
|
|
36
|
+
type: "scroll";
|
|
37
|
+
direction?: "up" | "down";
|
|
38
|
+
selector?: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: "scrape";
|
|
41
|
+
} | {
|
|
42
|
+
type: "executeJavascript";
|
|
43
|
+
script: string;
|
|
44
|
+
} | {
|
|
45
|
+
type: "pdf";
|
|
46
|
+
format?: "A0" | "A1" | "A2" | "A3" | "A4" | "A5" | "A6" | "Letter" | "Legal" | "Tabloid" | "Ledger";
|
|
47
|
+
landscape?: boolean;
|
|
48
|
+
scale?: number;
|
|
49
|
+
};
|
|
50
|
+
/** How Firecrawl reads files it meets while scraping. Parsers left out are off. */
|
|
51
|
+
type FirecrawlParser = "pdf" | "image" | FirecrawlPdfParser | {
|
|
52
|
+
type: "image";
|
|
53
|
+
};
|
|
54
|
+
interface FirecrawlPdfParser {
|
|
55
|
+
type: "pdf";
|
|
56
|
+
/** "fast" reads embedded text only, "ocr" always runs OCR, "auto" falls back to OCR. */
|
|
57
|
+
mode?: "fast" | "auto" | "ocr";
|
|
58
|
+
maxPages?: number;
|
|
59
|
+
/** Return one Markdown entry per physical page. */
|
|
60
|
+
pages?: boolean;
|
|
61
|
+
/** Return layout blocks with positions. */
|
|
62
|
+
blocks?: boolean;
|
|
63
|
+
/** Mark page breaks in the Markdown. */
|
|
64
|
+
pageMarkers?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/** Page-fetching settings Firecrawl applies before reading. */
|
|
67
|
+
interface FirecrawlPageSettings {
|
|
68
|
+
onlyMainContent?: boolean;
|
|
69
|
+
includeTags?: string[];
|
|
70
|
+
excludeTags?: string[];
|
|
71
|
+
/** Seconds a cached copy may be old; 0 always fetches fresh. */
|
|
72
|
+
maxAge?: number;
|
|
73
|
+
/** Milliseconds to wait for the page before reading it. */
|
|
74
|
+
waitFor?: number;
|
|
75
|
+
mobile?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Which proxies fetch the page. `basic` is fast and suits sites with little
|
|
78
|
+
* anti-bot protection; `enhanced` is slower and gets past stronger bot
|
|
79
|
+
* walls; `auto` retries with `enhanced` when `basic` fails. Both cost the
|
|
80
|
+
* same credits.
|
|
81
|
+
*/
|
|
82
|
+
proxy?: "basic" | "enhanced" | "auto";
|
|
83
|
+
/** Where the request comes from; `country` is ISO 3166-1 alpha-2. */
|
|
84
|
+
location?: {
|
|
85
|
+
country?: string;
|
|
86
|
+
languages?: string[];
|
|
87
|
+
};
|
|
88
|
+
/** Clicks, scrolls, waits and scripts to run before reading. */
|
|
89
|
+
actions?: FirecrawlAction[];
|
|
90
|
+
parsers?: FirecrawlParser[];
|
|
91
|
+
}
|
|
92
|
+
type FirecrawlFormat = "html" | "rawHtml" | "links" | "images" | "screenshot" | "summary";
|
|
93
|
+
/** What to read from each page, beside its Markdown. */
|
|
94
|
+
interface FirecrawlReadSettings extends FirecrawlPageSettings {
|
|
95
|
+
/** Extra formats beside Markdown. */
|
|
96
|
+
include?: FirecrawlFormat[];
|
|
97
|
+
/** Return passages that answer this as `excerpts`. */
|
|
98
|
+
query?: string;
|
|
99
|
+
/**
|
|
100
|
+
* How `query` is answered: "highlights" (the default) returns the page's
|
|
101
|
+
* relevant passages, "question" returns one written answer. Each costs
|
|
102
|
+
* 4 extra credits per page.
|
|
103
|
+
*/
|
|
104
|
+
queryFormat?: "highlights" | "question";
|
|
105
|
+
}
|
|
106
|
+
interface FirecrawlPageOptions extends CallOptions, FirecrawlPageSettings {}
|
|
107
|
+
interface FirecrawlReadOptions extends CallOptions, FirecrawlReadSettings {}
|
|
108
|
+
interface FirecrawlReadManyOptions extends FirecrawlReadOptions {
|
|
109
|
+
maxConcurrency?: number;
|
|
110
|
+
/** Firecrawl defaults to true: invalid URLs go to `failed` instead of failing the job. */
|
|
111
|
+
ignoreInvalidURLs?: boolean;
|
|
112
|
+
/** Milliseconds between status checks. */
|
|
113
|
+
interval?: number;
|
|
114
|
+
/**
|
|
115
|
+
* The id of a job that timed out or was cancelled, from the error's
|
|
116
|
+
* `jobId`. Waits for that job instead of starting a new one; `urls` is then
|
|
117
|
+
* ignored.
|
|
118
|
+
*/
|
|
119
|
+
resume?: string;
|
|
120
|
+
}
|
|
121
|
+
interface FirecrawlSearchOptions extends CallOptions {
|
|
122
|
+
/** Results per source; Firecrawl allows up to 100. */
|
|
123
|
+
limit?: number;
|
|
124
|
+
sources?: ("web" | "news" | "images")[];
|
|
125
|
+
/** "gov" cannot be combined with another category. */
|
|
126
|
+
categories?: ("developer" | "gov" | "research" | "pdf")[];
|
|
127
|
+
/** Hosts only; Firecrawl does not filter by path. Not with `excludeDomains`. */
|
|
128
|
+
includeDomains?: string[];
|
|
129
|
+
excludeDomains?: string[];
|
|
130
|
+
/** YYYY-MM-DD. Firecrawl applies dates and recency to web results only. */
|
|
131
|
+
publishedAfter?: string;
|
|
132
|
+
/** YYYY-MM-DD. */
|
|
133
|
+
publishedBefore?: string;
|
|
134
|
+
/** Not with `publishedAfter` or `publishedBefore`. */
|
|
135
|
+
recency?: Recency;
|
|
136
|
+
/** ISO 3166-1 alpha-2 country code. */
|
|
137
|
+
country?: string;
|
|
138
|
+
/** A place name such as "San Francisco,California,United States". */
|
|
139
|
+
location?: string;
|
|
140
|
+
/** Google time filter such as "sbd:1,qdr:w", for when the named options do not fit. */
|
|
141
|
+
tbs?: string;
|
|
142
|
+
/** Include each result's page text as Markdown. */
|
|
143
|
+
content?: boolean;
|
|
144
|
+
/** Filter explicit content (SafeSearch). */
|
|
145
|
+
safe?: boolean;
|
|
146
|
+
ignoreInvalidURLs?: boolean;
|
|
147
|
+
}
|
|
148
|
+
interface FirecrawlImagesOptions extends CallOptions {
|
|
149
|
+
limit?: number;
|
|
150
|
+
country?: string;
|
|
151
|
+
location?: string;
|
|
152
|
+
safe?: boolean;
|
|
153
|
+
}
|
|
154
|
+
interface FirecrawlExtractOptions extends FirecrawlPageOptions {
|
|
155
|
+
schema: JsonSchema;
|
|
156
|
+
prompt?: string;
|
|
157
|
+
}
|
|
158
|
+
interface FirecrawlMapOptions extends CallOptions {
|
|
159
|
+
limit?: number;
|
|
160
|
+
/** Order links by relevance to this text. */
|
|
161
|
+
search?: string;
|
|
162
|
+
sitemap?: "skip" | "include" | "only";
|
|
163
|
+
includeSubdomains?: boolean;
|
|
164
|
+
/** Firecrawl defaults to true, which merges URLs that differ only by query. */
|
|
165
|
+
ignoreQueryParameters?: boolean;
|
|
166
|
+
/** Skip the sitemap cache, which can be up to 7 days old. */
|
|
167
|
+
ignoreCache?: boolean;
|
|
168
|
+
location?: {
|
|
169
|
+
country?: string;
|
|
170
|
+
languages?: string[];
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
interface FirecrawlCrawlOptions extends CallOptions {
|
|
174
|
+
limit?: number;
|
|
175
|
+
/** Plain-words crawl instructions; the options you set override it. */
|
|
176
|
+
prompt?: string;
|
|
177
|
+
/** Regular expressions on the URL path (not hosts); a page must match one. */
|
|
178
|
+
includePaths?: string[];
|
|
179
|
+
/** Regular expressions on the URL path; a page matching one is skipped. */
|
|
180
|
+
excludePaths?: string[];
|
|
181
|
+
/** Match the two lists above against the full URL instead of the path. */
|
|
182
|
+
regexOnFullURL?: boolean;
|
|
183
|
+
maxDiscoveryDepth?: number;
|
|
184
|
+
sitemap?: "skip" | "include" | "only";
|
|
185
|
+
crawlEntireDomain?: boolean;
|
|
186
|
+
allowSubdomains?: boolean;
|
|
187
|
+
allowExternalLinks?: boolean;
|
|
188
|
+
ignoreQueryParameters?: boolean;
|
|
189
|
+
/** Seconds between page requests; forces one page at a time. */
|
|
190
|
+
delay?: number;
|
|
191
|
+
maxConcurrency?: number;
|
|
192
|
+
/** How each crawled page is read. */
|
|
193
|
+
scrapeOptions?: FirecrawlReadSettings;
|
|
194
|
+
/** Milliseconds between status checks. */
|
|
195
|
+
interval?: number;
|
|
196
|
+
/**
|
|
197
|
+
* The id of a job that timed out or was cancelled, from the error's
|
|
198
|
+
* `jobId`. Waits for that job instead of starting a new one.
|
|
199
|
+
*/
|
|
200
|
+
resume?: string;
|
|
201
|
+
}
|
|
202
|
+
interface FirecrawlResearchOptions extends CallOptions {
|
|
203
|
+
schema?: JsonSchema;
|
|
204
|
+
/** Pages to start from. */
|
|
205
|
+
urls?: string[];
|
|
206
|
+
/** Visit only `urls`. */
|
|
207
|
+
strictConstrainToURLs?: boolean;
|
|
208
|
+
/** Credit cap for the run; Firecrawl defaults to 2500. */
|
|
209
|
+
maxCredits?: number;
|
|
210
|
+
model?: "spark-2";
|
|
211
|
+
effort?: "low" | "medium" | "high";
|
|
212
|
+
/** The `continuationId` of an earlier run: this run is the next turn of its thread. */
|
|
213
|
+
continueFrom?: string;
|
|
214
|
+
/** ISO 3166-1 alpha-2 country the agent browses from. */
|
|
215
|
+
country?: string;
|
|
216
|
+
/** Milliseconds between status checks. */
|
|
217
|
+
interval?: number;
|
|
218
|
+
/**
|
|
219
|
+
* The id of a job that timed out or was cancelled, from the error's
|
|
220
|
+
* `jobId`. Waits for that job instead of starting a new one.
|
|
221
|
+
*/
|
|
222
|
+
resume?: string;
|
|
223
|
+
}
|
|
224
|
+
interface FirecrawlSessionSettings {
|
|
225
|
+
/** Seconds the browser session may live (30 to 3600). */
|
|
226
|
+
ttl?: number;
|
|
227
|
+
/** Seconds the session may sit idle; defaults to `ttl`. */
|
|
228
|
+
activityTtl?: number;
|
|
229
|
+
/** Keeps cookies and storage between sessions that share the name. */
|
|
230
|
+
profile?: {
|
|
231
|
+
name: string;
|
|
232
|
+
saveChanges?: boolean;
|
|
233
|
+
};
|
|
234
|
+
/** ISO 3166-1 alpha-2 country the browser connects from. */
|
|
235
|
+
country?: string;
|
|
236
|
+
}
|
|
237
|
+
interface FirecrawlActOptions extends CallOptions, FirecrawlSessionSettings {
|
|
238
|
+
language?: "node" | "python" | "bash";
|
|
239
|
+
/**
|
|
240
|
+
* Run in this open session (from `browser.open` or an earlier `act` with
|
|
241
|
+
* `keepSession`) instead of a new one. Not with the session settings.
|
|
242
|
+
*/
|
|
243
|
+
session?: string;
|
|
244
|
+
/**
|
|
245
|
+
* Leave the session open and return its id as `sessionId`. Defaults to true
|
|
246
|
+
* when `session` is given and false otherwise. A session left open bills
|
|
247
|
+
* until it expires or you close it.
|
|
248
|
+
*/
|
|
249
|
+
keepSession?: boolean;
|
|
250
|
+
}
|
|
251
|
+
type FirecrawlBrowserOptions = CallOptions & FirecrawlSessionSettings;
|
|
252
|
+
interface FirecrawlParseOptions extends CallOptions {
|
|
253
|
+
/** "fast" reads embedded text only, "ocr" always runs OCR, "auto" falls back to OCR. */
|
|
254
|
+
mode?: "auto" | "fast" | "ocr";
|
|
255
|
+
maxPages?: number;
|
|
256
|
+
/** Return one Markdown entry per physical page. */
|
|
257
|
+
pages?: boolean;
|
|
258
|
+
/** Return layout blocks with positions. */
|
|
259
|
+
blocks?: boolean;
|
|
260
|
+
/** Mark page breaks in the Markdown. */
|
|
261
|
+
pageMarkers?: boolean;
|
|
262
|
+
}
|
|
263
|
+
interface FirecrawlMonitorOptions extends CallOptions {
|
|
264
|
+
/** A name for the monitor; defaults to the query or first URL. */
|
|
265
|
+
name?: string;
|
|
266
|
+
/**
|
|
267
|
+
* What counts as a meaningful change, in plain words. With `urls` it judges
|
|
268
|
+
* their changes; without `urls` it is also the search the monitor runs.
|
|
269
|
+
*/
|
|
270
|
+
query?: string;
|
|
271
|
+
/** Pages to watch. */
|
|
272
|
+
urls?: string[];
|
|
273
|
+
/** A cron expression (five fields, at least 5 minutes apart) or a named interval. */
|
|
274
|
+
schedule: MonitorSchedule;
|
|
275
|
+
/** IANA time zone for the schedule. Defaults to UTC. */
|
|
276
|
+
timezone?: string;
|
|
277
|
+
webhookUrl?: string;
|
|
278
|
+
/** Days Firecrawl keeps check history, 1 to 365. */
|
|
279
|
+
retentionDays?: number;
|
|
280
|
+
/** Search monitors only: how far back results may be published. */
|
|
281
|
+
searchWindow?: "5m" | "15m" | "1h" | "6h" | "24h" | "7d";
|
|
282
|
+
/** Search monitors only: results to judge per check, 1 to 50. */
|
|
283
|
+
maxResults?: number;
|
|
284
|
+
/** Search monitors only. */
|
|
285
|
+
includeDomains?: string[];
|
|
286
|
+
/** Search monitors only. */
|
|
287
|
+
excludeDomains?: string[];
|
|
288
|
+
}
|
|
289
|
+
interface FirecrawlOperations {
|
|
290
|
+
search(query: string, options?: FirecrawlSearchOptions): Promise<SearchResponse>;
|
|
291
|
+
images(query: string, options?: FirecrawlImagesOptions): Promise<ImageSearch>;
|
|
292
|
+
read(url: string, options?: FirecrawlReadOptions): Promise<Page>;
|
|
293
|
+
/** Reads many pages in one background job. */
|
|
294
|
+
readMany(urls: string[], options?: FirecrawlReadManyOptions): Promise<PageBatch>;
|
|
295
|
+
extract<T = unknown>(url: string, options: FirecrawlExtractOptions): Promise<Extraction<T>>;
|
|
296
|
+
/** Reads product and variant data from the page's structured data, without a model. */
|
|
297
|
+
product(url: string, options?: FirecrawlPageOptions): Promise<Product>;
|
|
298
|
+
map(url: string, options?: FirecrawlMapOptions): Promise<SiteMap>;
|
|
299
|
+
crawl(url: string, options?: FirecrawlCrawlOptions): Promise<Crawl>;
|
|
300
|
+
research<T = unknown>(question: string, options?: FirecrawlResearchOptions): Promise<Research<T>>;
|
|
301
|
+
/** Runs a script in a browser session; closes the session unless `keepSession` is set. */
|
|
302
|
+
act(code: string, options?: FirecrawlActOptions): Promise<ActResult>;
|
|
303
|
+
browser: {
|
|
304
|
+
/** Opens a remote browser you drive over CDP; it bills until it expires or you close it. */
|
|
305
|
+
open(options?: FirecrawlBrowserOptions): Promise<BrowserSession>;
|
|
306
|
+
close(id: string, options?: CallOptions): Promise<void>;
|
|
307
|
+
};
|
|
308
|
+
parse(document: DocumentInput, options?: FirecrawlParseOptions): Promise<ParsedDocument>;
|
|
309
|
+
monitor: {
|
|
310
|
+
create(options: FirecrawlMonitorOptions): Promise<MonitorInfo>;
|
|
311
|
+
get(id: string, options?: CallOptions): Promise<MonitorInfo>;
|
|
312
|
+
list(options?: CallOptions): Promise<MonitorInfo[]>;
|
|
313
|
+
delete(id: string, options?: CallOptions): Promise<void>;
|
|
314
|
+
/** One event per check the monitor ran, newest first. */
|
|
315
|
+
events(id: string, options?: CallOptions & {
|
|
316
|
+
cursor?: string;
|
|
317
|
+
}): Promise<MonitorEvents>;
|
|
318
|
+
};
|
|
319
|
+
usage(options?: CallOptions): Promise<AccountUsage>;
|
|
320
|
+
}
|
|
321
|
+
export declare const firecrawl: (config?: FirecrawlConfig) => Adapter<"firecrawl", FirecrawlOperations, RawClient>;
|
|
322
|
+
export type { FirecrawlActOptions, FirecrawlAction, FirecrawlBrowserOptions, FirecrawlConfig, FirecrawlCrawlOptions, FirecrawlExtractOptions, FirecrawlFormat, FirecrawlImagesOptions, FirecrawlMapOptions, FirecrawlMonitorOptions, FirecrawlOperations, FirecrawlPageOptions, FirecrawlPageSettings, FirecrawlParseOptions, FirecrawlParser, FirecrawlPdfParser, FirecrawlReadManyOptions, FirecrawlReadOptions, FirecrawlReadSettings, FirecrawlResearchOptions, FirecrawlSearchOptions, FirecrawlSessionSettings };
|