@howells/fieldwork-sdk 0.8.0 → 0.10.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/README.md +28 -2
- package/dist/{adapter-Dqy-6BiH.d.ts → adapter-DQrBP1tj.d.ts} +39 -2
- package/dist/brave.d.ts +1 -1
- package/dist/browserbase.d.ts +21 -2
- package/dist/browserbase.js +93 -3
- package/dist/download-gyAym9vL.js +78 -0
- package/dist/exa.d.ts +2 -2
- package/dist/{fieldwork-CAGMQ2Cu.d.ts → fieldwork-DNwEf0Mo.d.ts} +5 -1
- package/dist/firecrawl.d.ts +21 -3
- package/dist/firecrawl.js +52 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -1
- package/dist/kernel.d.ts +15 -2
- package/dist/kernel.js +195 -105
- package/dist/llamaparse.d.ts +2 -2
- package/dist/llamaparse.js +40 -15
- package/dist/parallel.d.ts +2 -2
- package/dist/perplexity.d.ts +2 -2
- package/dist/reducto.d.ts +1 -1
- package/dist/{schema-B23Z08Ds.d.ts → schema-BFjS6CSz.d.ts} +1 -1
- package/dist/serpapi.d.ts +1 -1
- package/dist/tavily.d.ts +2 -2
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +6 -2
- package/dist/{types-CnomnF-6.js → types-rc8bl8Em.js} +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Fieldwork
|
|
2
2
|
|
|
3
|
-
One API for searching the web, reading pages, extracting values, walking sites, answering and researching questions, finding entities, watching for changes, driving a browser and
|
|
3
|
+
One API for searching the web, reading pages, extracting values, walking sites, answering and researching questions, finding entities, watching for changes, driving a browser, parsing documents and downloading files, across Exa, Firecrawl, Tavily, Parallel, Perplexity, Brave, SerpApi, Browserbase, Kernel, LlamaParse and Reducto.
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
6
|
npm i @howells/fieldwork-sdk
|
|
@@ -41,6 +41,7 @@ Each instance has only the methods its provider offers, so a call the provider c
|
|
|
41
41
|
| `act(code)` | | yes | | | | | | | | | |
|
|
42
42
|
| `browser.open()`, `browser.close(id)` | | yes | | | | | | yes | yes | | |
|
|
43
43
|
| `parse(document)` | | yes | | | | | | | | yes | yes |
|
|
44
|
+
| `download(url)` | | yes | | | | | | yes | yes | | |
|
|
44
45
|
| `monitor.create()`, `.get`, `.list`, `.delete`, `.events` | yes | yes | | yes | | | | | | | |
|
|
45
46
|
| `usage()` | | yes | yes | | | | yes | yes | | | |
|
|
46
47
|
|
|
@@ -50,6 +51,7 @@ Each instance has only the methods its provider offers, so a call the provider c
|
|
|
50
51
|
- `discover` returns a list of entities, such as companies or products, that meet every condition you give.
|
|
51
52
|
- `decide` answers closed questions about a context: yes or no, a choice, or a score on a rubric, each with a probability.
|
|
52
53
|
- `browser.open()` starts a remote browser and returns its CDP URL for Playwright or Puppeteer; `act(code)` runs one script in a fresh session.
|
|
54
|
+
- `download` returns a file's bytes, its content type and the final URL after redirects, fetched through the provider's network. See [Downloading files](#downloading-files).
|
|
53
55
|
- `monitor` repeats a search or a page check on a schedule and reports what changed. Exa and Parallel monitors watch a query; Firecrawl monitors also watch specific pages (`urls`).
|
|
54
56
|
|
|
55
57
|
### Options
|
|
@@ -69,6 +71,7 @@ Options are typed per provider. An option means the same thing under the same na
|
|
|
69
71
|
| `query` | On `read`: return the passages that answer it as `excerpts`. |
|
|
70
72
|
| `content` | On `search`: include each result's page text. |
|
|
71
73
|
| `continueFrom` | On `answer` and `research`: the `continuationId` of an earlier result, to ask a follow-up. |
|
|
74
|
+
| `maxBytes` | On `download`: the largest file accepted, in bytes. Defaults to, and may not exceed, the provider's ceiling. |
|
|
72
75
|
| `resume`, `interval` | On jobs: collect an earlier job by its id, and the milliseconds between status checks (unset: 500, doubling to 2000). |
|
|
73
76
|
|
|
74
77
|
Options only one provider has keep that provider's meaning and values, such as Tavily's `topic`, Exa's `category`, SerpApi's `engine` or Firecrawl's `proxy`. A combination a provider would reject or silently ignore, such as `includeDomains` with `excludeDomains` on Parallel, throws `InvalidRequest` before anything is sent.
|
|
@@ -104,7 +107,8 @@ Every result is normalized and keeps the provider's response in `raw`. Most also
|
|
|
104
107
|
- `answer` returns `{ answer, output, citations, continuationId }`.
|
|
105
108
|
- `research` returns `{ id, status, output, sources, fields, continuationId }`. `output` follows your schema when you pass one, otherwise it is the report text.
|
|
106
109
|
- `crawl` returns `{ pages, failed, robotsBlocked, total }`.
|
|
107
|
-
- `
|
|
110
|
+
- `download` returns `{ url, bytes, contentType, size, statusCode, etag, lastModified }`: `url` is the final URL, `bytes` a `Uint8Array` exactly as served, `contentType` the server's header unchanged. `etag` and `lastModified` come back from Browserbase and Kernel, which pass headers through.
|
|
111
|
+
- `parse` returns `{ id, markdown, pages, blocks, pageCount }`. With `blocks: true`, `blocks` lists the layout in reading order: each block's `page`, `type` (the provider's own word), `text` and `box`. With `wordBoxes: true` (LlamaParse and Reducto), blocks also carry `words` and table `cells`, each with its own box. LlamaParse also places each line: a block's `lines` and a cell's `lines` are `{ text, box }`, the text being the line's part of the block's or cell's text, Markdown included. A table's `words` and `lines` are its cells', in reading order. Reducto places no lines. LlamaParse also gives a cell that sits in several boxes each of them as `boxes`, with `box` enclosing them; marks a block read out of a page header or footer with `container: "header"` or `"footer"`; and, with `blocks` or `wordBoxes`, gives each page its `width` and `height` in points. With `pageImages: true` (LlamaParse), each page carries `image`, an address for a picture of the page that expires after about an hour; `parse({ resume: id, pageImages: true })` collects fresh addresses without the file: one request that reads the finished job, in under a second, with no new parse and no credits charged. LlamaParse does not publish how long it keeps a job's result; plan for 48 hours (its retention for parse caches and uploaded files) and treat `NotFound` on resume as a job that must be parsed again. Every box is `{ left, top, width, height }` in fractions of the page from its top-left corner, whatever units the provider used, so boxes from different providers line up.
|
|
108
112
|
|
|
109
113
|
A job that stopped early but produced output, for example on a credit or step limit, returns `status: "partial"` with `stopReason`. A job with no usable output throws `JobFailed`.
|
|
110
114
|
|
|
@@ -146,6 +150,26 @@ await web.browser.close(session.id);
|
|
|
146
150
|
|
|
147
151
|
A schedule is `{ every: "day" }`, `{ every: "6h" }` or `{ cron: "0 9 * * 1" }`. A schedule the provider cannot express throws `InvalidRequest`.
|
|
148
152
|
|
|
153
|
+
### Downloading files
|
|
154
|
+
|
|
155
|
+
`download(url)` returns the file the URL serves, fetched through the provider's own network: the provider makes the request, and Fieldwork only decodes what it returns. Nothing fetches the file directly, not even a redirect.
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
const file = await web.download(
|
|
159
|
+
"https://www.tilebar.com/media/wysiwyg/Certificates/EPD/EPD-Treveso-V3.pdf"
|
|
160
|
+
);
|
|
161
|
+
file.contentType; // "application/pdf"
|
|
162
|
+
const digest = await crypto.subtle.digest("SHA-256", file.bytes);
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
| Adapter | Ceiling | How | Cost |
|
|
166
|
+
| --- | --- | --- | --- |
|
|
167
|
+
| `firecrawl()` | 50 MiB | One scrape with `formats: ["rawBase64"]` and no parser. `maxAge: 0` skips Firecrawl's cache, which otherwise serves copies up to 2 days old. | 1 credit per file. |
|
|
168
|
+
| `kernel()` | 50 MiB | Playwright's request client in a new headless browser, which is then deleted. A file over the limit never leaves Kernel. | Browser seconds, as `meta.usage.units.uptime_ms`; 2 to 17 seconds observed. |
|
|
169
|
+
| `browserbase()` | 5 MB | Browserbase Fetch, one call per redirect, so the final URL is known. | One Fetch call per hop. |
|
|
170
|
+
|
|
171
|
+
A response that is not 2xx throws (`NotFound` for 404 and 410), a web page throws `NotAFile`, and a file over the limit throws `TooLarge`. Check `contentType` for anything narrower, such as "is this link really a PDF?". `download` is not an agent tool or MCP tool: a tool result cannot usefully carry tens of megabytes.
|
|
172
|
+
|
|
149
173
|
## Choosing a provider per capability
|
|
150
174
|
|
|
151
175
|
`router` sends each capability to exactly one adapter:
|
|
@@ -193,6 +217,8 @@ Every failure is a `FieldworkError`. It carries:
|
|
|
193
217
|
| `JobFailed` | The job ended without a result. | Start a new job if needed; resuming fails again. |
|
|
194
218
|
| `Timeout` | The call or job outlasted its time. | With `jobId`, pass it as `resume`. Without one, repeat when `retryable` is true. |
|
|
195
219
|
| `Aborted` | `signal` cancelled the call. | With `jobId`, the job may still be running; pass it as `resume`. |
|
|
220
|
+
| `TooLarge` | A downloaded file is larger than `maxBytes` or the provider's ceiling. | Raise `maxBytes`, up to the ceiling, or use a provider with a higher one. |
|
|
221
|
+
| `NotAFile` | A download reached a web page (HTML), not a file. | Use `read` for pages; the link is not the file it looked like. |
|
|
196
222
|
| `ProviderError` | Any other provider failure. | Repeat when `retryable` is true (5xx and network failures). |
|
|
197
223
|
|
|
198
224
|
An error with a `jobId` is never `retryable`, because repeating the call would start and charge for a second job. Nor is a failure, other than a rate limit, of the request that starts a job, session or monitor: the provider may already have started it, so check before repeating.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** A JSON Schema object describing the values to extract. */
|
|
2
2
|
type JsonSchema = Record<string, unknown>;
|
|
3
3
|
/** Every capability Fieldwork knows. An adapter implements a subset. */
|
|
4
|
-
declare const CAPABILITIES: readonly ["search", "images", "read", "readMany", "extract", "product", "map", "crawl", "answer", "research", "discover", "decide", "act", "browser", "parse", "monitor", "usage"];
|
|
4
|
+
declare const CAPABILITIES: readonly ["search", "images", "read", "readMany", "extract", "product", "map", "crawl", "answer", "research", "discover", "decide", "act", "browser", "parse", "download", "monitor", "usage"];
|
|
5
5
|
/** A capability's name, such as `search` or `monitor`. */
|
|
6
6
|
type Capability = (typeof CAPABILITIES)[number];
|
|
7
7
|
/**
|
|
@@ -392,6 +392,10 @@ interface DocumentPage {
|
|
|
392
392
|
markdown: string;
|
|
393
393
|
/** An address for a picture of the page, when the parse asked for page images. It expires. */
|
|
394
394
|
image?: string;
|
|
395
|
+
/** The page's width in points (1/72 inch), when the provider gives it with the blocks. */
|
|
396
|
+
width?: number;
|
|
397
|
+
/** The page's height in points (1/72 inch), when the provider gives it with the blocks. */
|
|
398
|
+
height?: number;
|
|
395
399
|
}
|
|
396
400
|
/**
|
|
397
401
|
* Where something sits on its page, as fractions of the page's width and
|
|
@@ -423,7 +427,10 @@ interface TableCell {
|
|
|
423
427
|
/** Columns the cell spans, when more than one. */
|
|
424
428
|
columnSpan?: number;
|
|
425
429
|
text: string;
|
|
430
|
+
/** Encloses every box of the cell. */
|
|
426
431
|
box?: Box;
|
|
432
|
+
/** Each box the provider gives for the cell, in its order, when it gives them one by one: a cell can sit in several. */
|
|
433
|
+
boxes?: Box[];
|
|
427
434
|
/** Where each line of the cell sits, when the provider places lines. */
|
|
428
435
|
lines?: LineBox[];
|
|
429
436
|
}
|
|
@@ -436,6 +443,8 @@ interface DocumentBlock {
|
|
|
436
443
|
/** The block's content as the provider gave it: Markdown, or HTML for some tables. */
|
|
437
444
|
text: string;
|
|
438
445
|
box?: Box;
|
|
446
|
+
/** The page header or footer the provider read this block out of, when it was in one. */
|
|
447
|
+
container?: "header" | "footer";
|
|
439
448
|
/** Where each word sits, when the parse asked for word boxes. */
|
|
440
449
|
words?: WordBox[];
|
|
441
450
|
/** Where each line sits, a table's cell lines included, when the parse asked for word boxes and the provider places lines. */
|
|
@@ -523,6 +532,34 @@ interface AccountUsage {
|
|
|
523
532
|
periodEnd?: string;
|
|
524
533
|
raw: unknown;
|
|
525
534
|
}
|
|
535
|
+
/** Settings every `download` accepts, whatever the provider. */
|
|
536
|
+
interface DownloadOptions extends CallOptions {
|
|
537
|
+
/**
|
|
538
|
+
* The largest file accepted, in bytes. Defaults to, and may not exceed,
|
|
539
|
+
* the adapter's ceiling; a larger value throws `InvalidRequest` before
|
|
540
|
+
* anything is sent. A larger file throws `TooLarge`.
|
|
541
|
+
*/
|
|
542
|
+
maxBytes?: number;
|
|
543
|
+
}
|
|
544
|
+
/** What `download` returns: one file's bytes, exactly as the provider fetched them. */
|
|
545
|
+
interface DownloadedFile {
|
|
546
|
+
/** The final URL, after every redirect. */
|
|
547
|
+
url: string;
|
|
548
|
+
/** The file's bytes, exactly as served. */
|
|
549
|
+
bytes: Uint8Array;
|
|
550
|
+
/** The Content-Type the server sent, unchanged, such as "application/pdf". */
|
|
551
|
+
contentType: string;
|
|
552
|
+
/** `bytes.byteLength`. */
|
|
553
|
+
size: number;
|
|
554
|
+
/** The HTTP status of the final response. */
|
|
555
|
+
statusCode?: number;
|
|
556
|
+
/** The server's ETag, when the provider passes headers through. */
|
|
557
|
+
etag?: string;
|
|
558
|
+
/** The server's Last-Modified, when the provider passes headers through. */
|
|
559
|
+
lastModified?: string;
|
|
560
|
+
meta?: Meta;
|
|
561
|
+
raw: unknown;
|
|
562
|
+
}
|
|
526
563
|
/** Options for one request through an adapter's `raw` client. */
|
|
527
564
|
interface RequestOptions extends CallOptions {
|
|
528
565
|
/** A JSON body. */
|
|
@@ -594,4 +631,4 @@ type AnyAdapter = Adapter<string, any, unknown>;
|
|
|
594
631
|
* It returns its argument unchanged; write a custom adapter with it.
|
|
595
632
|
*/
|
|
596
633
|
declare const defineAdapter: <Name extends string, Ops extends Operations, Raw = RawClient>(adapter: Adapter<Name, Ops, Raw>) => Adapter<Name, Ops, Raw>;
|
|
597
|
-
export {
|
|
634
|
+
export { SearchResponse as $, FailedUrl as A, MonitorInfo as B, DocumentInput as C, DownloadedFile as D, DownloadOptions as E, JsonSchema as F, Place as G, Page as H, LineBox as I, ProductImage as J, Price as K, Meta as L, GROUP_CAPABILITIES as M, ImageResult as N, Entity as O, ImageSearch as P, RunStatus as Q, MonitorEvent as R, DocumentBlock as S, DocumentUrl as T, PageBatch as U, MonitorSchedule as V, ParsedDocument as W, Recency as X, ProductVariant as Y, Research as Z, Crawl as _, RawClient as a, WordBox as at, Decisions as b, ActResult as c, BrowserSession as d, SearchResult as et, CAPABILITIES as f, Condition as g, Citation as h, defineAdapter as i, Usage as it, FieldSource as j, Extraction as k, Answer as l, Capability as m, AnyAdapter as n, SiteMap as nt, RequestOptions as o, CallOptions as p, Product as q, Operations as r, TableCell as rt, AccountUsage as s, Adapter as t, SiteLink as tt, Box as u, DecisionAnswer as v, DocumentPage as w, Discovery as x, DecisionQuestion as y, MonitorEvents as z };
|
package/dist/brave.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as SearchResponse, P as ImageSearch, X as Recency, a as RawClient, l as Answer, p as CallOptions, t as Adapter } from "./adapter-DQrBP1tj.js";
|
|
2
2
|
/** Settings for `brave()`. */
|
|
3
3
|
interface BraveConfig {
|
|
4
4
|
/** Defaults to the BRAVE_API_KEY environment variable. */
|
package/dist/browserbase.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as SearchResponse, D as DownloadedFile, E as DownloadOptions, H as Page, a as RawClient, d as BrowserSession, p as CallOptions, s as AccountUsage, t as Adapter } from "./adapter-DQrBP1tj.js";
|
|
2
2
|
/** Settings for `browserbase()`. */
|
|
3
3
|
export interface BrowserbaseConfig {
|
|
4
4
|
/** Defaults to the BROWSERBASE_API_KEY environment variable. */
|
|
@@ -55,6 +55,23 @@ export interface BrowserbaseReadOptions extends CallOptions {
|
|
|
55
55
|
/** A context whose saved cookies are sent with the request. */
|
|
56
56
|
contextId?: string;
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Options for `download`, which fetches the file with Browserbase Fetch,
|
|
60
|
+
* without a browser. Fetch returns at most 5 MB. Redirects are followed one
|
|
61
|
+
* hop at a time, each hop a Fetch call, so the final URL is known.
|
|
62
|
+
*/
|
|
63
|
+
export interface BrowserbaseDownloadOptions extends DownloadOptions {
|
|
64
|
+
/** Skip TLS certificate verification, for self-signed or expired certificates. */
|
|
65
|
+
allowInsecureSsl?: boolean;
|
|
66
|
+
/** `true` for Browserbase's default proxy exit, or a geolocation. Not combinable with `country`. */
|
|
67
|
+
proxies?: boolean | {
|
|
68
|
+
geolocation?: BrowserbaseGeolocation;
|
|
69
|
+
};
|
|
70
|
+
/** ISO 3166-1 alpha-2 code; sends the request through a proxy in that country. */
|
|
71
|
+
country?: string;
|
|
72
|
+
/** A context whose saved cookies are sent with the request. */
|
|
73
|
+
contextId?: string;
|
|
74
|
+
}
|
|
58
75
|
interface BrowserbaseSearchBase extends CallOptions {
|
|
59
76
|
/** Results to return, 1 to 25. */
|
|
60
77
|
limit?: number;
|
|
@@ -138,6 +155,8 @@ export interface BrowserbaseOpenOptions extends CallOptions {
|
|
|
138
155
|
export interface BrowserbaseOperations {
|
|
139
156
|
search: (query: string, options?: BrowserbaseSearchOptions) => Promise<SearchResponse>;
|
|
140
157
|
read: (url: string, options?: BrowserbaseReadOptions) => Promise<Page>;
|
|
158
|
+
/** Fetches a file's bytes through Browserbase Fetch, up to 5 MB. */
|
|
159
|
+
download: (url: string, options?: BrowserbaseDownloadOptions) => Promise<DownloadedFile>;
|
|
141
160
|
browser: {
|
|
142
161
|
/**
|
|
143
162
|
* Creates a session. A failure to get its live view URL does not fail the
|
|
@@ -151,7 +170,7 @@ export interface BrowserbaseOperations {
|
|
|
151
170
|
usage: (options?: CallOptions) => Promise<AccountUsage>;
|
|
152
171
|
}
|
|
153
172
|
/**
|
|
154
|
-
* An adapter for Browserbase: search, read, browser and usage. Pass it to `new Fieldwork({ adapter })`.
|
|
173
|
+
* An adapter for Browserbase: search, read, download, browser and usage. Pass it to `new Fieldwork({ adapter })`.
|
|
155
174
|
*
|
|
156
175
|
* Throws `Unauthorized` when neither `apiKey` nor `BROWSERBASE_API_KEY` is set.
|
|
157
176
|
*/
|
package/dist/browserbase.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { t as defineAdapter } from "./adapter-DWYJys20.js";
|
|
2
|
-
import { r as invalidRequest } from "./errors-DROZyb9T.js";
|
|
3
|
-
import { C as createRawClient, E as segment, S as withOriginal, T as requireKey, a as looseObject, d as optionalId, f as optionalNumber, h as optionalString, m as optionalScalar, r as arrayOf, s as optionalAnyString } from "./parse-lMLcxUsG.js";
|
|
2
|
+
import { r as invalidRequest, t as FieldworkError } from "./errors-DROZyb9T.js";
|
|
3
|
+
import { C as createRawClient, E as segment, S as withOriginal, T as requireKey, a as looseObject, d as optionalId, f as optionalNumber, h as optionalString, m as optionalScalar, r as arrayOf, s as optionalAnyString, v as recordOf } from "./parse-lMLcxUsG.js";
|
|
4
4
|
import { a as compact, f as refuseTogether, l as presentPage, p as requireJobId, s as meta, t as callSettings } from "./util-BqeRYF2b.js";
|
|
5
|
+
import { a as presentFile, i as header, n as byteLimit, o as tooLarge, r as checkFileUrl, t as MIB } from "./download-gyAym9vL.js";
|
|
5
6
|
import * as z from "zod/mini";
|
|
6
7
|
// src/adapters/browserbase/response.ts
|
|
7
8
|
/** `POST /v1/sessions`. The id keeps the value as it arrived, for the error raised when there is none. */
|
|
@@ -20,6 +21,7 @@ const FetchResponse = looseObject({
|
|
|
20
21
|
content: optionalAnyString,
|
|
21
22
|
contentType: optionalString,
|
|
22
23
|
encoding: optionalString,
|
|
24
|
+
headers: recordOf(optionalAnyString),
|
|
23
25
|
id: optionalScalar,
|
|
24
26
|
statusCode: optionalNumber
|
|
25
27
|
});
|
|
@@ -42,6 +44,90 @@ const UsageResponse = looseObject({
|
|
|
42
44
|
});
|
|
43
45
|
/** `GET /v1/projects`: an array of projects. */
|
|
44
46
|
const ProjectsResponse = arrayOf(looseObject({ id: withOriginal(optionalId) }));
|
|
47
|
+
// src/adapters/browserbase/download.ts
|
|
48
|
+
/** The largest body Browserbase Fetch returns: 5 MB. */
|
|
49
|
+
const DOWNLOAD_CEILING = 5 * MIB;
|
|
50
|
+
/** Redirects `download` follows before it gives up. */
|
|
51
|
+
const MAX_HOPS = 10;
|
|
52
|
+
/** The part of Browserbase's error body that says why. */
|
|
53
|
+
const ErrorBody = looseObject({ message: optionalString });
|
|
54
|
+
/** Whether Browserbase refused the response for exceeding its size limit. */
|
|
55
|
+
const overCeiling = (error) => error.status === 502 && (z.parse(ErrorBody, error.cause).message ?? "").includes("maximum allowed size");
|
|
56
|
+
/**
|
|
57
|
+
* The body as Fetch returned it: Base64 for a binary file, or text Fetch
|
|
58
|
+
* decoded as UTF-8. Throws `ProviderError` for text in any other encoding,
|
|
59
|
+
* whose exact bytes cannot be recovered.
|
|
60
|
+
*/
|
|
61
|
+
const contentOf = (provider, url, body) => {
|
|
62
|
+
const content = body.content ?? "";
|
|
63
|
+
if (body.encoding === "base64") return { base64: content };
|
|
64
|
+
if (body.encoding?.toLowerCase() === "utf-8") return { utf8: content };
|
|
65
|
+
throw new FieldworkError("ProviderError", `browserbase downloaded ${url} as ${body.encoding ?? "an unknown encoding"} text, which cannot be turned back into the exact bytes`, {
|
|
66
|
+
cause: body,
|
|
67
|
+
provider
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
/** Fetches `current` through Browserbase, following a redirect with another Fetch. */
|
|
71
|
+
const hop = async (download, current, hops) => {
|
|
72
|
+
const { raw, url, limit, call } = download;
|
|
73
|
+
const { provider } = raw;
|
|
74
|
+
if (hops.length > MAX_HOPS) throw new FieldworkError("ProviderError", `browserbase could not download ${url}: more than ${MAX_HOPS} redirects`, {
|
|
75
|
+
cause: hops,
|
|
76
|
+
provider
|
|
77
|
+
});
|
|
78
|
+
const { options: o, proxies } = download;
|
|
79
|
+
let response;
|
|
80
|
+
try {
|
|
81
|
+
response = await raw.request("POST", "/v1/fetch", {
|
|
82
|
+
...call,
|
|
83
|
+
body: compact({
|
|
84
|
+
allowInsecureSsl: o.allowInsecureSsl,
|
|
85
|
+
allowRedirects: false,
|
|
86
|
+
contextId: o.contextId,
|
|
87
|
+
format: "raw",
|
|
88
|
+
proxies,
|
|
89
|
+
url: current
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
} catch (error) {
|
|
93
|
+
throw error instanceof FieldworkError && overCeiling(error) ? tooLarge(provider, url, void 0, limit) : error;
|
|
94
|
+
}
|
|
95
|
+
const seen = [...hops, response];
|
|
96
|
+
const body = z.parse(FetchResponse, response);
|
|
97
|
+
const status = body.statusCode;
|
|
98
|
+
if (status !== void 0 && status >= 300 && status < 400) {
|
|
99
|
+
const location = header(body.headers, "location");
|
|
100
|
+
if (location === void 0) throw new FieldworkError("ProviderError", `browserbase could not download ${url}: ${current} answered ${status} without a Location`, {
|
|
101
|
+
cause: response,
|
|
102
|
+
provider,
|
|
103
|
+
status
|
|
104
|
+
});
|
|
105
|
+
return await hop(download, new URL(location, current).href, seen);
|
|
106
|
+
}
|
|
107
|
+
return presentFile(provider, {
|
|
108
|
+
body: contentOf(provider, url, body),
|
|
109
|
+
contentType: body.contentType,
|
|
110
|
+
headers: body.headers,
|
|
111
|
+
meta: meta({ requestId: body.id }),
|
|
112
|
+
raw: seen.length === 1 ? response : seen,
|
|
113
|
+
requested: url,
|
|
114
|
+
statusCode: status,
|
|
115
|
+
url: current
|
|
116
|
+
}, limit);
|
|
117
|
+
};
|
|
118
|
+
/** Fetches the file through Browserbase Fetch and checks it. */
|
|
119
|
+
const downloadFile = async (raw, url, o, proxies, call) => {
|
|
120
|
+
checkFileUrl(raw.provider, url);
|
|
121
|
+
const limit = byteLimit(raw.provider, DOWNLOAD_CEILING, o.maxBytes);
|
|
122
|
+
return await hop({
|
|
123
|
+
call,
|
|
124
|
+
limit,
|
|
125
|
+
options: o,
|
|
126
|
+
proxies,
|
|
127
|
+
raw,
|
|
128
|
+
url
|
|
129
|
+
}, url, []);
|
|
130
|
+
};
|
|
45
131
|
// src/adapters/browserbase.ts
|
|
46
132
|
/** The modes each search provider takes; `search` refuses any other. */
|
|
47
133
|
const SEARCH_MODES = {
|
|
@@ -53,7 +139,7 @@ const SEARCH_MODES = {
|
|
|
53
139
|
parallel: ["fast", "advanced"]
|
|
54
140
|
};
|
|
55
141
|
/**
|
|
56
|
-
* An adapter for Browserbase: search, read, browser and usage. Pass it to `new Fieldwork({ adapter })`.
|
|
142
|
+
* An adapter for Browserbase: search, read, download, browser and usage. Pass it to `new Fieldwork({ adapter })`.
|
|
57
143
|
*
|
|
58
144
|
* Throws `Unauthorized` when neither `apiKey` nor `BROWSERBASE_API_KEY` is set.
|
|
59
145
|
*/
|
|
@@ -140,6 +226,10 @@ const browserbase = (config = {}) => {
|
|
|
140
226
|
});
|
|
141
227
|
}
|
|
142
228
|
},
|
|
229
|
+
async download(url, options) {
|
|
230
|
+
const { call, rest: o } = callSettings(options);
|
|
231
|
+
return await downloadFile(raw, url, o, fetchProxies(o), call);
|
|
232
|
+
},
|
|
143
233
|
async read(url, options) {
|
|
144
234
|
const { call, rest: o } = callSettings(options);
|
|
145
235
|
const format = o.format ?? "markdown";
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { r as invalidRequest, t as FieldworkError } from "./errors-DROZyb9T.js";
|
|
2
|
+
// src/download.ts
|
|
3
|
+
/** One mebibyte, the unit the providers' ceilings are stated in. */
|
|
4
|
+
const MIB = 1048576;
|
|
5
|
+
/**
|
|
6
|
+
* Throws `InvalidRequest` unless the URL parses and is http or https, so
|
|
7
|
+
* nothing is sent for a URL no provider can download.
|
|
8
|
+
*/
|
|
9
|
+
const checkFileUrl = (provider, url) => {
|
|
10
|
+
const parsed = URL.parse(url);
|
|
11
|
+
if (parsed === null) throw invalidRequest(provider, `cannot download ${url}: it is not a URL`);
|
|
12
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw invalidRequest(provider, `downloads only http and https URLs, not ${parsed.protocol} (${url})`);
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The byte limit for a download: `maxBytes`, or the provider's ceiling when
|
|
16
|
+
* it is unset. Throws `InvalidRequest` for a limit that is not a positive
|
|
17
|
+
* whole number or exceeds the ceiling.
|
|
18
|
+
*/
|
|
19
|
+
const byteLimit = (provider, ceiling, maxBytes) => {
|
|
20
|
+
if (maxBytes === void 0) return ceiling;
|
|
21
|
+
if (!Number.isInteger(maxBytes) || maxBytes < 1) throw invalidRequest(provider, `needs maxBytes as a positive whole number, got ${maxBytes}`);
|
|
22
|
+
if (maxBytes > ceiling) throw invalidRequest(provider, `downloads at most ${ceiling} bytes; maxBytes ${maxBytes} is larger`);
|
|
23
|
+
return maxBytes;
|
|
24
|
+
};
|
|
25
|
+
/** The error for a file over the limit. */
|
|
26
|
+
const tooLarge = (provider, url, size, limit) => new FieldworkError("TooLarge", `${provider} could not download ${url}: the file is ${size === void 0 ? "larger than" : `${size} bytes, over`} the limit of ${limit} bytes`, { provider });
|
|
27
|
+
/** Content types that are web pages rather than files. */
|
|
28
|
+
const PAGE_TYPES = /* @__PURE__ */ new Set(["text/html", "application/xhtml+xml"]);
|
|
29
|
+
/** Statuses that mean the file is not there. */
|
|
30
|
+
const GONE = /* @__PURE__ */ new Set([404, 410]);
|
|
31
|
+
/** A header's value by name (lower-case) in any case, or undefined. */
|
|
32
|
+
const header = (headers, name) => Object.entries(headers ?? {}).find(([key]) => key.toLowerCase() === name)?.[1];
|
|
33
|
+
/** Throws `NotFound` for a 404 or 410 and `ProviderError` for any other status that is not 2xx. */
|
|
34
|
+
const checkStatus = (provider, fetched) => {
|
|
35
|
+
const { requested, statusCode } = fetched;
|
|
36
|
+
if (statusCode === void 0) return;
|
|
37
|
+
if (GONE.has(statusCode)) throw new FieldworkError("NotFound", `${provider} could not download ${requested}: it answered ${statusCode}`, {
|
|
38
|
+
provider,
|
|
39
|
+
status: statusCode
|
|
40
|
+
});
|
|
41
|
+
if (statusCode < 200 || statusCode > 299) throw new FieldworkError("ProviderError", `${provider} could not download ${requested}: it answered ${statusCode}`, {
|
|
42
|
+
cause: fetched.raw,
|
|
43
|
+
provider,
|
|
44
|
+
status: statusCode
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* The checked file. Throws `NotFound` for a 404 or 410, `ProviderError` for
|
|
49
|
+
* any other status that is not 2xx or a reply with no content type,
|
|
50
|
+
* `NotAFile` for an HTML page, and `TooLarge` for more bytes than `limit`.
|
|
51
|
+
*/
|
|
52
|
+
const presentFile = (provider, fetched, limit) => {
|
|
53
|
+
const { requested, statusCode } = fetched;
|
|
54
|
+
checkStatus(provider, fetched);
|
|
55
|
+
const { contentType } = fetched;
|
|
56
|
+
if (contentType === void 0 || contentType === "") throw new FieldworkError("ProviderError", `${provider} downloaded ${requested} but reported no content type`, {
|
|
57
|
+
cause: fetched.raw,
|
|
58
|
+
provider
|
|
59
|
+
});
|
|
60
|
+
const mediaType = contentType.split(";")[0]?.trim().toLowerCase() ?? "";
|
|
61
|
+
if (PAGE_TYPES.has(mediaType)) throw new FieldworkError("NotAFile", `${provider} could not download ${requested}: it is a web page (${contentType}), not a file`, { provider });
|
|
62
|
+
const bytes = "base64" in fetched.body ? new Uint8Array(Buffer.from(fetched.body.base64, "base64")) : new TextEncoder().encode(fetched.body.utf8);
|
|
63
|
+
if (bytes.byteLength > limit) throw tooLarge(provider, requested, bytes.byteLength, limit);
|
|
64
|
+
return {
|
|
65
|
+
bytes,
|
|
66
|
+
contentType,
|
|
67
|
+
...fetched.headers && {
|
|
68
|
+
etag: header(fetched.headers, "etag"),
|
|
69
|
+
lastModified: header(fetched.headers, "last-modified")
|
|
70
|
+
},
|
|
71
|
+
...fetched.meta && { meta: fetched.meta },
|
|
72
|
+
raw: fetched.raw,
|
|
73
|
+
size: bytes.byteLength,
|
|
74
|
+
...statusCode !== void 0 && { statusCode },
|
|
75
|
+
url: fetched.url
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
export { presentFile as a, header as i, byteLimit as n, tooLarge as o, checkFileUrl as r, MIB as t };
|
package/dist/exa.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as OutputSchema } from "./schema-
|
|
1
|
+
import { $ as SearchResponse, B as MonitorInfo, H as Page, U as PageBatch, V as MonitorSchedule, Z as Research, a as RawClient, k as Extraction, l as Answer, p as CallOptions, t as Adapter, z as MonitorEvents } from "./adapter-DQrBP1tj.js";
|
|
2
|
+
import { t as OutputSchema } from "./schema-BFjS6CSz.js";
|
|
3
3
|
/** Settings for the Exa adapter. */
|
|
4
4
|
interface ExaConfig {
|
|
5
5
|
/** Defaults to the EXA_API_KEY environment variable. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as Capability, n as AnyAdapter } from "./adapter-
|
|
1
|
+
import { m as Capability, n as AnyAdapter } from "./adapter-DQrBP1tj.js";
|
|
2
2
|
/** Why a call failed. Branch on this, not on the message, which can change. */
|
|
3
3
|
type FieldworkErrorCode =
|
|
4
4
|
/** The adapter's provider does not offer this capability. */
|
|
@@ -17,6 +17,10 @@ type FieldworkErrorCode =
|
|
|
17
17
|
"Timeout" |
|
|
18
18
|
/** The caller's `signal` cancelled the call. */
|
|
19
19
|
"Aborted" |
|
|
20
|
+
/** A downloaded file is larger than `maxBytes` or the provider's ceiling. */
|
|
21
|
+
"TooLarge" |
|
|
22
|
+
/** A download reached a web page (HTML), not a file. */
|
|
23
|
+
"NotAFile" |
|
|
20
24
|
/** Any other provider failure. */
|
|
21
25
|
"ProviderError";
|
|
22
26
|
/** What a `FieldworkError` carries besides its code and message. */
|
package/dist/firecrawl.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as
|
|
2
|
-
import { t as OutputSchema } from "./schema-
|
|
1
|
+
import { $ as SearchResponse, B as MonitorInfo, C as DocumentInput, D as DownloadedFile, E as DownloadOptions, H as Page, P as ImageSearch, U as PageBatch, V as MonitorSchedule, W as ParsedDocument, X as Recency, Z as Research, _ as Crawl, a as RawClient, c as ActResult, d as BrowserSession, k as Extraction, nt as SiteMap, p as CallOptions, q as Product, s as AccountUsage, t as Adapter, z as MonitorEvents } from "./adapter-DQrBP1tj.js";
|
|
2
|
+
import { t as OutputSchema } from "./schema-BFjS6CSz.js";
|
|
3
3
|
/** Settings for the Firecrawl adapter. */
|
|
4
4
|
interface FirecrawlConfig {
|
|
5
5
|
/** Defaults to the FIRECRAWL_API_KEY environment variable. */
|
|
@@ -349,6 +349,22 @@ interface FirecrawlMonitorOptions extends CallOptions {
|
|
|
349
349
|
* map, crawl, research, act, browser, parse, monitor and usage. `readMany`,
|
|
350
350
|
* `crawl` and `research` are asynchronous jobs and accept `resume`.
|
|
351
351
|
*/
|
|
352
|
+
/**
|
|
353
|
+
* Options for `download`, which fetches the file through Firecrawl's scrape
|
|
354
|
+
* (`formats: ["rawBase64"]`, no parsers) for 1 credit, whatever its size.
|
|
355
|
+
* Firecrawl's ceiling is 50 MiB.
|
|
356
|
+
*/
|
|
357
|
+
interface FirecrawlDownloadOptions extends DownloadOptions {
|
|
358
|
+
/** Which proxies fetch the file; see `FirecrawlPageSettings.proxy`. */
|
|
359
|
+
proxy?: "basic" | "enhanced" | "auto";
|
|
360
|
+
/**
|
|
361
|
+
* Seconds a cached copy may be old; 0 always fetches fresh. Firecrawl
|
|
362
|
+
* serves copies up to 2 days old unless told otherwise.
|
|
363
|
+
*/
|
|
364
|
+
maxAge?: number;
|
|
365
|
+
/** ISO 3166-1 alpha-2 code of the country the request comes from. */
|
|
366
|
+
country?: string;
|
|
367
|
+
}
|
|
352
368
|
interface FirecrawlOperations {
|
|
353
369
|
search: (query: string, options?: FirecrawlSearchOptions) => Promise<SearchResponse>;
|
|
354
370
|
images: (query: string, options?: FirecrawlImagesOptions) => Promise<ImageSearch>;
|
|
@@ -369,6 +385,8 @@ interface FirecrawlOperations {
|
|
|
369
385
|
close: (id: string, options?: CallOptions) => Promise<void>;
|
|
370
386
|
};
|
|
371
387
|
parse: (document: DocumentInput, options?: FirecrawlParseOptions) => Promise<ParsedDocument>;
|
|
388
|
+
/** Fetches a file's bytes through Firecrawl, up to 50 MiB. */
|
|
389
|
+
download: (url: string, options?: FirecrawlDownloadOptions) => Promise<DownloadedFile>;
|
|
372
390
|
monitor: {
|
|
373
391
|
create: (options: FirecrawlMonitorOptions) => Promise<MonitorInfo>;
|
|
374
392
|
get: (id: string, options?: CallOptions) => Promise<MonitorInfo>;
|
|
@@ -382,7 +400,7 @@ interface FirecrawlOperations {
|
|
|
382
400
|
usage: (options?: CallOptions) => Promise<AccountUsage>;
|
|
383
401
|
}
|
|
384
402
|
/**
|
|
385
|
-
* An adapter for Firecrawl: search, images, read, readMany, extract, product, map, crawl, research, act, browser, parse, monitor and usage. Pass it to `new Fieldwork({ adapter })`.
|
|
403
|
+
* An adapter for Firecrawl: search, images, read, readMany, extract, product, map, crawl, research, act, browser, parse, download, monitor and usage. Pass it to `new Fieldwork({ adapter })`.
|
|
386
404
|
*
|
|
387
405
|
* Throws `Unauthorized` when neither `apiKey` nor `FIRECRAWL_API_KEY` is set.
|
|
388
406
|
*/
|
package/dist/firecrawl.js
CHANGED
|
@@ -4,6 +4,7 @@ import { C as createRawClient, E as segment, S as withOriginal, T as requireKey,
|
|
|
4
4
|
import { i as startJob, n as requireOutput, r as runJob, t as jobState } from "./job-DBhGs7Ha.js";
|
|
5
5
|
import { n as jsonSchemaOf, t as checkOutput } from "./schema-COAaWnZB.js";
|
|
6
6
|
import { a as compact, f as refuseTogether, l as presentPage, p as requireJobId, s as meta, t as callSettings, u as presentPages } from "./util-BqeRYF2b.js";
|
|
7
|
+
import { a as presentFile, n as byteLimit, o as tooLarge, r as checkFileUrl, t as MIB } from "./download-gyAym9vL.js";
|
|
7
8
|
import { a as mediaTypeOf, n as documentPart, o as refuseLarger, t as MEDIA_TYPES } from "./document-DOzhDFFt.js";
|
|
8
9
|
import * as z from "zod/mini";
|
|
9
10
|
// src/adapters/firecrawl/shared.ts
|
|
@@ -772,6 +773,7 @@ const Variant = looseObject({
|
|
|
772
773
|
const metadataShape = {
|
|
773
774
|
"article:published_time": optionalString,
|
|
774
775
|
author: optionalFirstString,
|
|
776
|
+
contentType: optionalString,
|
|
775
777
|
creditsUsed: optionalNumber,
|
|
776
778
|
description: optionalFirstString,
|
|
777
779
|
favicon: optionalString,
|
|
@@ -809,6 +811,7 @@ const PageData = looseObject({
|
|
|
809
811
|
url: optionalString,
|
|
810
812
|
variants: arrayOf(Variant)
|
|
811
813
|
}),
|
|
814
|
+
rawBase64: optionalAnyString,
|
|
812
815
|
rawHtml: optionalString,
|
|
813
816
|
screenshot: optionalString,
|
|
814
817
|
summary: optionalString,
|
|
@@ -999,11 +1002,58 @@ const UsageResponse = looseObject({ data: looseObject({
|
|
|
999
1002
|
planCredits: optionalNumber,
|
|
1000
1003
|
remainingCredits: optionalNumber
|
|
1001
1004
|
}) });
|
|
1005
|
+
// src/adapters/firecrawl/download.ts
|
|
1006
|
+
/** The largest file Firecrawl's scrape returns: 50 MiB. */
|
|
1007
|
+
const DOWNLOAD_CEILING = 50 * MIB;
|
|
1008
|
+
/** The part of Firecrawl's error body that names the failure. */
|
|
1009
|
+
const ErrorBody = looseObject({ code: optionalString });
|
|
1010
|
+
/** Whether Firecrawl refused the file for exceeding its size limit. */
|
|
1011
|
+
const overCeiling = (error) => z.parse(ErrorBody, error.cause).code === "SCRAPE_UNSUPPORTED_FILE_ERROR" && error.message.includes("size limit");
|
|
1012
|
+
/** Fetches the file through Firecrawl's scrape and checks it. */
|
|
1013
|
+
const downloadFile = async (raw, url, options) => {
|
|
1014
|
+
const { provider } = raw;
|
|
1015
|
+
const { call, rest: o } = callSettings(options);
|
|
1016
|
+
checkFileUrl(provider, url);
|
|
1017
|
+
const limit = byteLimit(provider, DOWNLOAD_CEILING, o.maxBytes);
|
|
1018
|
+
let response;
|
|
1019
|
+
try {
|
|
1020
|
+
response = await raw.request("POST", "/scrape", {
|
|
1021
|
+
...call,
|
|
1022
|
+
body: {
|
|
1023
|
+
formats: ["rawBase64"],
|
|
1024
|
+
url,
|
|
1025
|
+
...pageBody({
|
|
1026
|
+
location: o.country === void 0 ? void 0 : { country: o.country.toUpperCase() },
|
|
1027
|
+
maxAge: o.maxAge,
|
|
1028
|
+
parsers: [],
|
|
1029
|
+
proxy: o.proxy
|
|
1030
|
+
})
|
|
1031
|
+
}
|
|
1032
|
+
});
|
|
1033
|
+
} catch (error) {
|
|
1034
|
+
throw error instanceof FieldworkError && overCeiling(error) ? tooLarge(provider, url, void 0, limit) : error;
|
|
1035
|
+
}
|
|
1036
|
+
const { data, warning } = z.parse(ScrapeResponse, response);
|
|
1037
|
+
const { metadata } = data;
|
|
1038
|
+
if (data.rawBase64 === void 0) throw new FieldworkError("ProviderError", `firecrawl downloaded ${url} but returned no rawBase64 content`, {
|
|
1039
|
+
cause: response,
|
|
1040
|
+
provider
|
|
1041
|
+
});
|
|
1042
|
+
return presentFile(provider, {
|
|
1043
|
+
body: { base64: data.rawBase64 },
|
|
1044
|
+
contentType: metadata.contentType,
|
|
1045
|
+
meta: pageMeta(data, warning.notes),
|
|
1046
|
+
raw: response,
|
|
1047
|
+
requested: url,
|
|
1048
|
+
statusCode: metadata.statusCode,
|
|
1049
|
+
url: metadata.url ?? url
|
|
1050
|
+
}, limit);
|
|
1051
|
+
};
|
|
1002
1052
|
// src/adapters/firecrawl.ts
|
|
1003
1053
|
/** How long closing a session may take, apart from the call's own deadline. */
|
|
1004
1054
|
const CLOSE_TIMEOUT = 15e3;
|
|
1005
1055
|
/**
|
|
1006
|
-
* An adapter for Firecrawl: search, images, read, readMany, extract, product, map, crawl, research, act, browser, parse, monitor and usage. Pass it to `new Fieldwork({ adapter })`.
|
|
1056
|
+
* An adapter for Firecrawl: search, images, read, readMany, extract, product, map, crawl, research, act, browser, parse, download, monitor and usage. Pass it to `new Fieldwork({ adapter })`.
|
|
1007
1057
|
*
|
|
1008
1058
|
* Throws `Unauthorized` when neither `apiKey` nor `FIRECRAWL_API_KEY` is set.
|
|
1009
1059
|
*/
|
|
@@ -1174,6 +1224,7 @@ const firecrawl = (config = {}) => {
|
|
|
1174
1224
|
});
|
|
1175
1225
|
});
|
|
1176
1226
|
},
|
|
1227
|
+
download: async (url, options) => await downloadFile(raw, url, options),
|
|
1177
1228
|
async extract(url, options) {
|
|
1178
1229
|
const { call, rest: o } = callSettings(options);
|
|
1179
1230
|
const { schema, prompt, ...page } = o;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { i as FieldworkErrorCode, n as FieldworkOptions, r as FieldworkError, t as Fieldwork } from "./fieldwork-
|
|
3
|
-
import { n as StandardSchemaWithJSON, t as OutputSchema } from "./schema-
|
|
1
|
+
import { $ as SearchResponse, A as FailedUrl, B as MonitorInfo, C as DocumentInput, D as DownloadedFile, E as DownloadOptions, F as JsonSchema, G as Place, H as Page, I as LineBox, J as ProductImage, K as Price, L as Meta, M as GROUP_CAPABILITIES, N as ImageResult, O as Entity, P as ImageSearch, Q as RunStatus, R as MonitorEvent, S as DocumentBlock, T as DocumentUrl, U as PageBatch, V as MonitorSchedule, W as ParsedDocument, X as Recency, Y as ProductVariant, Z as Research, _ as Crawl, a as RawClient, at as WordBox, b as Decisions, c as ActResult, d as BrowserSession, et as SearchResult, f as CAPABILITIES, g as Condition, h as Citation, i as defineAdapter, it as Usage, j as FieldSource, k as Extraction, l as Answer, m as Capability, n as AnyAdapter, nt as SiteMap, o as RequestOptions, p as CallOptions, q as Product, r as Operations, rt as TableCell, s as AccountUsage, t as Adapter, tt as SiteLink, u as Box, v as DecisionAnswer, w as DocumentPage, x as Discovery, y as DecisionQuestion, z as MonitorEvents } from "./adapter-DQrBP1tj.js";
|
|
2
|
+
import { i as FieldworkErrorCode, n as FieldworkOptions, r as FieldworkError, t as Fieldwork } from "./fieldwork-DNwEf0Mo.js";
|
|
3
|
+
import { n as StandardSchemaWithJSON, t as OutputSchema } from "./schema-BFjS6CSz.js";
|
|
4
4
|
/** Which adapter serves each capability, for `router`. */
|
|
5
5
|
type Routes = Partial<Record<Capability, AnyAdapter>>;
|
|
6
6
|
/** Each route must name an adapter whose provider offers that capability. */
|
|
@@ -23,4 +23,4 @@ export declare const router: <const R extends Routes>(routes: R & ValidRoutes<R>
|
|
|
23
23
|
* `Unsupported` here instead of failing to compile.
|
|
24
24
|
*/
|
|
25
25
|
export declare const runtimeRouter: (routes: Routes) => AnyAdapter;
|
|
26
|
-
export { AccountUsage, ActResult, type Adapter, Answer, type AnyAdapter, Box, BrowserSession, CAPABILITIES, CallOptions, Capability, Citation, Condition, Crawl, DecisionAnswer, DecisionQuestion, Decisions, Discovery, DocumentBlock, DocumentInput, DocumentPage, DocumentUrl, Entity, Extraction, FailedUrl, FieldSource, Fieldwork, FieldworkError, type FieldworkErrorCode, type FieldworkOptions, GROUP_CAPABILITIES, ImageResult, ImageSearch, JsonSchema, LineBox, Meta, MonitorEvent, MonitorEvents, MonitorInfo, MonitorSchedule, type Operations, type OutputSchema, Page, PageBatch, ParsedDocument, Place, Price, Product, ProductImage, ProductVariant, type RawClient, Recency, type RequestOptions, Research, type Routes, RunStatus, SearchResponse, SearchResult, SiteLink, SiteMap, type StandardSchemaWithJSON, TableCell, Usage, WordBox, defineAdapter };
|
|
26
|
+
export { AccountUsage, ActResult, type Adapter, Answer, type AnyAdapter, Box, BrowserSession, CAPABILITIES, CallOptions, Capability, Citation, Condition, Crawl, DecisionAnswer, DecisionQuestion, Decisions, Discovery, DocumentBlock, DocumentInput, DocumentPage, DocumentUrl, DownloadOptions, DownloadedFile, Entity, Extraction, FailedUrl, FieldSource, Fieldwork, FieldworkError, type FieldworkErrorCode, type FieldworkOptions, GROUP_CAPABILITIES, ImageResult, ImageSearch, JsonSchema, LineBox, Meta, MonitorEvent, MonitorEvents, MonitorInfo, MonitorSchedule, type Operations, type OutputSchema, Page, PageBatch, ParsedDocument, Place, Price, Product, ProductImage, ProductVariant, type RawClient, Recency, type RequestOptions, Research, type Routes, RunStatus, SearchResponse, SearchResult, SiteLink, SiteMap, type StandardSchemaWithJSON, TableCell, Usage, WordBox, defineAdapter };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as defineAdapter } from "./adapter-DWYJys20.js";
|
|
2
2
|
import { t as FieldworkError } from "./errors-DROZyb9T.js";
|
|
3
|
-
import { n as GROUP_CAPABILITIES, t as CAPABILITIES } from "./types-
|
|
3
|
+
import { n as GROUP_CAPABILITIES, t as CAPABILITIES } from "./types-rc8bl8Em.js";
|
|
4
4
|
// src/fieldwork.ts
|
|
5
5
|
/**
|
|
6
6
|
* The adapter's operation for a capability, bound to its `operations` object
|
|
@@ -49,6 +49,7 @@ var FieldworkClient = class {
|
|
|
49
49
|
crawl: has("crawl"),
|
|
50
50
|
decide: has("decide"),
|
|
51
51
|
discover: has("discover"),
|
|
52
|
+
download: has("download"),
|
|
52
53
|
extract: has("extract"),
|
|
53
54
|
images: has("images"),
|
|
54
55
|
map: has("map"),
|