@parcha/agentrun-web 0.1.0-beta.70 → 0.1.0-beta.74
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 +2 -1
- package/dist/fees.d.ts +12 -0
- package/dist/fees.js +33 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/providers/direct.js +1 -1
- package/dist/providers/firecrawl.d.ts +17 -5
- package/dist/providers/firecrawl.js +21 -6
- package/dist/providers/parallel.d.ts +1 -1
- package/dist/providers/parallel.js +5 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -188,7 +188,8 @@ The pieces `createWeb` is built from are exported too: `searchInTurn` and `break
|
|
|
188
188
|
providers (`exaSearch`, `firecrawlFetch`, `firecrawlScrape`, `firecrawlSearch`, `parallelExtract`, `parallelSearched`)
|
|
189
189
|
and Parallel's prices and fees (`PARALLEL_EXTRACT_USD`, `PARALLEL_SEARCH_USD`, `PARALLEL_SEARCH_INCLUDED`,
|
|
190
190
|
`PARALLEL_SEARCH_MODE_USD`, `PARALLEL_SEARCH_RESULT_USD`, `parallelExtractFee`, `parallelSearchFee`, `parallelFeeOf`,
|
|
191
|
-
`
|
|
191
|
+
`parallelChargeOf` (an extract charged the URLs Parallel's `usage` says it billed: none for a URL it lists in `errors`,
|
|
192
|
+
the hold when its answer says nothing certain), `PaidRefused` and `unmetered`). The package's entry names each export; nothing else in it is API.
|
|
192
193
|
`@parcha/agentrun-web/text-urls` holds the link finder alone, for code that only finds the URLs in a text (the
|
|
193
194
|
console's timeline compiles it from source).
|
|
194
195
|
|
package/dist/fees.d.ts
CHANGED
|
@@ -32,6 +32,18 @@ export declare const parallelExtractFee: (urls?: number) => Fee;
|
|
|
32
32
|
* default), or its extract's, by the URLs; undefined for an endpoint the web tools do not ask, and for a search whose
|
|
33
33
|
* mode has no price here (one naming none, or one Parallel added since): never $0, never another mode's price. */
|
|
34
34
|
export declare function parallelFeeOf(url: string, body: unknown): Fee | undefined;
|
|
35
|
+
/** The URLs a 2xx extract's `usage` says Parallel billed: the sum of its extract SKUs' counts (`sku_extract_*`, one a
|
|
36
|
+
* URL it read), so an empty `usage` is none. Undefined when it says nothing this server can be sure of: no `usage`
|
|
37
|
+
* array, an item that is not a SKU with a whole count, or a SKU other than an extract's. */
|
|
38
|
+
export declare function parallelExtractBilled(json: unknown): number | undefined;
|
|
39
|
+
/** What an answer of `status` to Parallel's `path` held at `fee` is charged, and the receipt's line for it. A 2xx extract
|
|
40
|
+
* is charged the URLs Parallel's `usage` says it billed (parallelExtractBilled), at its list price: Parallel bills no URL
|
|
41
|
+
* it lists in `errors` (its usage is empty for one), so a page it could not read costs nothing. An extract whose usage
|
|
42
|
+
* says nothing certain, or none at all, is charged its fee, as is every other answer: an unknown is never free. */
|
|
43
|
+
export declare function parallelChargeOf(fee: Fee, path: string, json: unknown, status: number): {
|
|
44
|
+
usd: number;
|
|
45
|
+
basis: string;
|
|
46
|
+
};
|
|
35
47
|
/** Exa's search types priced here (https://exa.ai/pricing, read 2026-11-24): per request, 10 results included. A search
|
|
36
48
|
* in a type with no price here is never sent. */
|
|
37
49
|
export type ExaSearchType = "lite" | "instant" | "auto" | "fast" | "deep-lite" | "deep" | "deep-reasoning";
|
package/dist/fees.js
CHANGED
|
@@ -32,6 +32,39 @@ export function parallelFeeOf(url, body) {
|
|
|
32
32
|
return parallelExtractFee(Array.isArray(asked.urls) ? Math.max(1, asked.urls.length) : 1);
|
|
33
33
|
return undefined;
|
|
34
34
|
}
|
|
35
|
+
/** The URLs a 2xx extract's `usage` says Parallel billed: the sum of its extract SKUs' counts (`sku_extract_*`, one a
|
|
36
|
+
* URL it read), so an empty `usage` is none. Undefined when it says nothing this server can be sure of: no `usage`
|
|
37
|
+
* array, an item that is not a SKU with a whole count, or a SKU other than an extract's. */
|
|
38
|
+
export function parallelExtractBilled(json) {
|
|
39
|
+
const usage = json?.usage;
|
|
40
|
+
if (!Array.isArray(usage))
|
|
41
|
+
return undefined;
|
|
42
|
+
let urls = 0;
|
|
43
|
+
for (const item of usage) {
|
|
44
|
+
const { name, count } = (item ?? {});
|
|
45
|
+
if (typeof name !== "string" || !name.startsWith("sku_extract_") || typeof count !== "number" || !Number.isInteger(count) || count < 0)
|
|
46
|
+
return undefined;
|
|
47
|
+
urls += count;
|
|
48
|
+
}
|
|
49
|
+
return urls;
|
|
50
|
+
}
|
|
51
|
+
/** What an answer of `status` to Parallel's `path` held at `fee` is charged, and the receipt's line for it. A 2xx extract
|
|
52
|
+
* is charged the URLs Parallel's `usage` says it billed (parallelExtractBilled), at its list price: Parallel bills no URL
|
|
53
|
+
* it lists in `errors` (its usage is empty for one), so a page it could not read costs nothing. An extract whose usage
|
|
54
|
+
* says nothing certain, or none at all, is charged its fee, as is every other answer: an unknown is never free. */
|
|
55
|
+
export function parallelChargeOf(fee, path, json, status) {
|
|
56
|
+
const billed = path === "/v1/extract" && status >= 200 && status < 300 ? parallelExtractBilled(json) : undefined;
|
|
57
|
+
if (billed === undefined)
|
|
58
|
+
return { usd: fee.usd, basis: fee.basis };
|
|
59
|
+
const urls = (n) => `${n} URL${n === 1 ? "" : "s"}`;
|
|
60
|
+
const charged = usd(PARALLEL_EXTRACT_USD * billed);
|
|
61
|
+
// Usage that bills what was held (one URL read, as asked) leaves the receipt's line as it was.
|
|
62
|
+
if (charged === fee.usd)
|
|
63
|
+
return { usd: fee.usd, basis: fee.basis };
|
|
64
|
+
if (charged > fee.usd)
|
|
65
|
+
return { usd: fee.usd, basis: `the hold, ${fee.basis}; Parallel's usage said ${urls(billed)}` };
|
|
66
|
+
return { usd: charged, basis: billed === 0 ? "Parallel's usage billed no URL: it listed each in errors" : `Parallel's usage billed ${urls(billed)}, at its list price` };
|
|
67
|
+
}
|
|
35
68
|
export const EXA_SEARCH_TYPE_USD = Object.freeze({ lite: 0.004, instant: 0.004, auto: 0.007, fast: 0.007, "deep-lite": 0.012, deep: 0.012, "deep-reasoning": 0.015 });
|
|
36
69
|
/** Each search result past the 10 a type includes: $1 per 1,000. */
|
|
37
70
|
export const EXA_SEARCH_RESULT_USD = 0.001;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { type Destination, type Destinations, type FetchOptions, type Hold, type
|
|
|
2
2
|
export { type Guard, type GuardOptions, type HtmlRead, type HtmlReader, type PublicAnswer, type PublicCheck, type PublicFetch } from "./guard.js";
|
|
3
3
|
export { type FetchShape, type NativeSearch, type ProviderParts, type ProviderRun, type ReadFailed, type Reader, type SearchAsk, type SettingsSpec, type WebClient, type WebProvider, defineProvider, holdingWords, readerOf, } from "./provider.js";
|
|
4
4
|
export { type AheadProvider, type FetchProvider, type KeyedProvider, type ProviderId, type ProviderSettings, type SaidProvider, type SearchProvider, AHEAD, isProviderId, PROVIDERS, providerName, providerOf, SAID, serves, settingsProblemsOf, } from "./providers/registry.js";
|
|
5
|
-
export { type ExaSearchType, type Fee, type ParallelSearchMode, type Pay, EXA_CONTENT_USD, EXA_SEARCH_INCLUDED, EXA_SEARCH_RESULT_USD, EXA_SEARCH_TYPE_USD, EXA_SUMMARY_USD, exaFeeOf, FIRECRAWL_CREDIT_USD, FIRECRAWL_JSON_CREDITS, FIRECRAWL_SCRAPE_CREDITS, FIRECRAWL_SEARCH_CREDITS, firecrawlFeeOf, PARALLEL_EXTRACT_USD, PARALLEL_SEARCH_INCLUDED, PARALLEL_SEARCH_MODE_USD, PARALLEL_SEARCH_RESULT_USD, PARALLEL_SEARCH_USD, PaidRefused, parallelExtractFee, parallelFeeOf, parallelSearchFee, unmetered, } from "./fees.js";
|
|
5
|
+
export { type ExaSearchType, type Fee, type ParallelSearchMode, type Pay, EXA_CONTENT_USD, EXA_SEARCH_INCLUDED, EXA_SEARCH_RESULT_USD, EXA_SEARCH_TYPE_USD, EXA_SUMMARY_USD, exaFeeOf, FIRECRAWL_CREDIT_USD, FIRECRAWL_JSON_CREDITS, FIRECRAWL_SCRAPE_CREDITS, FIRECRAWL_SEARCH_CREDITS, firecrawlFeeOf, PARALLEL_EXTRACT_USD, PARALLEL_SEARCH_INCLUDED, PARALLEL_SEARCH_MODE_USD, PARALLEL_SEARCH_RESULT_USD, PARALLEL_SEARCH_USD, PaidRefused, parallelChargeOf, parallelExtractFee, parallelFeeOf, parallelSearchFee, unmetered, } from "./fees.js";
|
|
6
6
|
export { type Backend, type Breaker, type Failure, type FailureClass, type Hit, type Holding, type Limit, type Search, type SearchBounds, type Searched, type Try, ANSWER_MAX, breakers, CITE, fitSearch, OBJECTIVE_MAX, QUERIES_MAX, QUERY_MAX, RESULTS_DEFAULT, RESULTS_MAX, SEARCH_MAX_CHARS, SNIPPET_MAX, searchArgs, searchBreaker, searchInTurn, searchText, snippetOf, } from "./search.js";
|
|
7
7
|
export { type FetchTry, type Pages, type Readers, type Via, type WebFetchOptions, type WebLog, type WebPage, type WebRead, type WebUnread, FETCH_ORDER, PAGES_HELD, webFetch, webFetchText, } from "./fetch.js";
|
|
8
8
|
export { type Page, type Part, type Read, type Unread, askedUrl, clip, HTML_READ_CHARS, LINKS_CAP, LINKS_CHARS, MAX_CHARS_MIN, PAGE_CHARS, PAGE_MAX_BYTES, PAGE_READ_MAX_CHARS, partEnd, partProblem, TEXT_CAP, TITLE_CAP, URL_MAX, } from "./page.js";
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
export { createWeb, destinationsLine, destinationsWords, } from "./web.js";
|
|
9
9
|
export { defineProvider, holdingWords, readerOf, } from "./provider.js";
|
|
10
10
|
export { AHEAD, isProviderId, PROVIDERS, providerName, providerOf, SAID, serves, settingsProblemsOf, } from "./providers/registry.js";
|
|
11
|
-
export { EXA_CONTENT_USD, EXA_SEARCH_INCLUDED, EXA_SEARCH_RESULT_USD, EXA_SEARCH_TYPE_USD, EXA_SUMMARY_USD, exaFeeOf, FIRECRAWL_CREDIT_USD, FIRECRAWL_JSON_CREDITS, FIRECRAWL_SCRAPE_CREDITS, FIRECRAWL_SEARCH_CREDITS, firecrawlFeeOf, PARALLEL_EXTRACT_USD, PARALLEL_SEARCH_INCLUDED, PARALLEL_SEARCH_MODE_USD, PARALLEL_SEARCH_RESULT_USD, PARALLEL_SEARCH_USD, PaidRefused, parallelExtractFee, parallelFeeOf, parallelSearchFee, unmetered, } from "./fees.js";
|
|
11
|
+
export { EXA_CONTENT_USD, EXA_SEARCH_INCLUDED, EXA_SEARCH_RESULT_USD, EXA_SEARCH_TYPE_USD, EXA_SUMMARY_USD, exaFeeOf, FIRECRAWL_CREDIT_USD, FIRECRAWL_JSON_CREDITS, FIRECRAWL_SCRAPE_CREDITS, FIRECRAWL_SEARCH_CREDITS, firecrawlFeeOf, PARALLEL_EXTRACT_USD, PARALLEL_SEARCH_INCLUDED, PARALLEL_SEARCH_MODE_USD, PARALLEL_SEARCH_RESULT_USD, PARALLEL_SEARCH_USD, PaidRefused, parallelChargeOf, parallelExtractFee, parallelFeeOf, parallelSearchFee, unmetered, } from "./fees.js";
|
|
12
12
|
export { ANSWER_MAX, breakers, CITE, fitSearch, OBJECTIVE_MAX, QUERIES_MAX, QUERY_MAX, RESULTS_DEFAULT, RESULTS_MAX, SEARCH_MAX_CHARS, SNIPPET_MAX, searchArgs, searchBreaker, searchInTurn, searchText, snippetOf, } from "./search.js";
|
|
13
13
|
export { FETCH_ORDER, PAGES_HELD, webFetch, webFetchText, } from "./fetch.js";
|
|
14
14
|
export { askedUrl, clip, HTML_READ_CHARS, LINKS_CAP, LINKS_CHARS, MAX_CHARS_MIN, PAGE_CHARS, PAGE_MAX_BYTES, PAGE_READ_MAX_CHARS, partEnd, partProblem, TEXT_CAP, TITLE_CAP, URL_MAX, } from "./page.js";
|
package/dist/providers/direct.js
CHANGED
|
@@ -51,7 +51,7 @@ async function readTyped(url, guard, options) {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
catch (error) {
|
|
54
|
-
// Never a URL's user name or password:
|
|
54
|
+
// Never a URL's user name or password: an error may quote a URL whole (undici's refusal of one does).
|
|
55
55
|
const message = withoutUserinfo(error?.message ?? String(error));
|
|
56
56
|
if (isRefused(error))
|
|
57
57
|
return failed("refused", "GUARD", { refused: message });
|
|
@@ -3,8 +3,18 @@ import { type Read } from "../page.js";
|
|
|
3
3
|
import { type Failed, type Hit, type SearchAsk, type Searched } from "../search.js";
|
|
4
4
|
import { type Keyed, type KeyedFailed } from "./keyed.js";
|
|
5
5
|
export declare const FIRECRAWL_API_URL = "https://api.firecrawl.dev";
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/** This client's bound on one request: past it, it hangs up. A scrape tells Firecrawl to stop well before it
|
|
7
|
+
* (FIRECRAWL_SCRAPE_TIMEOUT_MS), so Firecrawl answers first. */
|
|
8
|
+
export declare const FIRECRAWL_KEYED_MS = 120000;
|
|
9
|
+
/** The time a scrape gives Firecrawl (its body's `timeout`): below this client's bound by the time its answer, up to
|
|
10
|
+
* KEYED_MAX_BYTES, takes to come back. A scrape sent with no timeout has no limit at Firecrawl: a PDF is parsed to its
|
|
11
|
+
* last page asked, and billed, after this client has hung up. With one, a PDF Firecrawl reckons it cannot parse in
|
|
12
|
+
* time (150 ms a page, out of the time left once it has the file) is refused at once, and a scrape that runs out
|
|
13
|
+
* answers 408; Firecrawl bills neither (fees.ts firecrawlChargeOf charges them 0 credits). */
|
|
14
|
+
export declare const FIRECRAWL_SCRAPE_TIMEOUT_MS = 100000;
|
|
15
|
+
/** The most PDF pages a scrape asks unless pdfMaxPages says otherwise: what Firecrawl reads within its timeout once it
|
|
16
|
+
* has the file, 200. Past it a PDF comes back cut, and its text says which pages it holds (firecrawlPageOf). */
|
|
17
|
+
export declare const FIRECRAWL_PDF_PAGES_IN_TIME: number;
|
|
8
18
|
/** How Firecrawl searches and reads, each setting optional (FIRECRAWL_DEFAULTS):
|
|
9
19
|
* - `onlyMainContent`: a scrape leaves out a page's headers, navigation and footers, default true;
|
|
10
20
|
* - `maxAgeMs`: the oldest cached page a scrape may answer from, 0 a fresh scrape; unset, Firecrawl's own (2 days);
|
|
@@ -13,8 +23,9 @@ export declare const FIRECRAWL_KEYED_MS = 60000;
|
|
|
13
23
|
* - `country`: the country a search is made from, ISO 3166-1 alpha-2; unset, Firecrawl's own (US);
|
|
14
24
|
* - `highlights`: each result's description is its query-relevant highlight; unset, Firecrawl's own (true);
|
|
15
25
|
* - `pdfMaxPages`: the most pages of a PDF a web_fetch parses, and is held for (1 credit a page), 1 to 10,000; unset,
|
|
16
|
-
*
|
|
17
|
-
*
|
|
26
|
+
* the pages Firecrawl reads within its timeout, FIRECRAWL_PDF_PAGES_IN_TIME (200). Set past that, a long PDF may be
|
|
27
|
+
* one Firecrawl refuses or runs out of time on, at no charge. A run whose cap has less than the hold left holds what
|
|
28
|
+
* it has left and asks only the pages that buys (firecrawlFitOf). */
|
|
18
29
|
export type FirecrawlSettings = {
|
|
19
30
|
onlyMainContent?: boolean;
|
|
20
31
|
maxAgeMs?: number;
|
|
@@ -60,7 +71,8 @@ export declare function firecrawlSearchBody(query: string, n: number, settings?:
|
|
|
60
71
|
* up to FIRECRAWL_QUERIES_MAX of its queries, one paid request each, all at once, merged (firecrawlMerged), and the
|
|
61
72
|
* limit Firecrawl answered for the run's key, if any. */
|
|
62
73
|
export declare function firecrawlSearched(args: Record<string, unknown>, client: Keyed | null, settings?: FirecrawlSettings, signal?: AbortSignal): Promise<Searched>;
|
|
63
|
-
/** The /v2/scrape request for `url` under `settings`: markdown alone, on the basic proxy,
|
|
74
|
+
/** The /v2/scrape request for `url` under `settings`: markdown alone, on the basic proxy, within Firecrawl's timeout, a
|
|
75
|
+
* PDF to pdfMaxPages, else to the pages that timeout reads. */
|
|
64
76
|
export declare function firecrawlScrapeBody(url: string, settings?: FirecrawlSettings): Record<string, unknown>;
|
|
65
77
|
/** A page Firecrawl scraped for `url` (`page`, its scrape's `{markdown, metadata}`, keyed or keyless alike) as a Read:
|
|
66
78
|
* the url it ended at (metadata's url, else its sourceURL, else `url`), its title (a list's first string), its status.
|
|
@@ -8,8 +8,22 @@ import { defineProvider, settingsOf } from "../provider.js";
|
|
|
8
8
|
import { failed, failure, retryAfterMs, searchArgs, snippetOf, waitOf } from "../search.js";
|
|
9
9
|
import { domains, keyedCall, keyedClient, matching, settingsProblems, wholeIn, yesNo } from "./keyed.js";
|
|
10
10
|
export const FIRECRAWL_API_URL = "https://api.firecrawl.dev";
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/** This client's bound on one request: past it, it hangs up. A scrape tells Firecrawl to stop well before it
|
|
12
|
+
* (FIRECRAWL_SCRAPE_TIMEOUT_MS), so Firecrawl answers first. */
|
|
13
|
+
export const FIRECRAWL_KEYED_MS = 120_000;
|
|
14
|
+
/** The time a scrape gives Firecrawl (its body's `timeout`): below this client's bound by the time its answer, up to
|
|
15
|
+
* KEYED_MAX_BYTES, takes to come back. A scrape sent with no timeout has no limit at Firecrawl: a PDF is parsed to its
|
|
16
|
+
* last page asked, and billed, after this client has hung up. With one, a PDF Firecrawl reckons it cannot parse in
|
|
17
|
+
* time (150 ms a page, out of the time left once it has the file) is refused at once, and a scrape that runs out
|
|
18
|
+
* answers 408; Firecrawl bills neither (fees.ts firecrawlChargeOf charges them 0 credits). */
|
|
19
|
+
export const FIRECRAWL_SCRAPE_TIMEOUT_MS = 100_000;
|
|
20
|
+
/** How long Firecrawl may take to fetch a PDF before it parses a page: an 841-page federal PDF took 46 s. */
|
|
21
|
+
const PDF_FETCH_ALLOWANCE_MS = 50_000;
|
|
22
|
+
/** How long Firecrawl takes to parse a PDF page: that PDF's pages took 0.22 s each. */
|
|
23
|
+
const PDF_PAGE_MS = 250;
|
|
24
|
+
/** The most PDF pages a scrape asks unless pdfMaxPages says otherwise: what Firecrawl reads within its timeout once it
|
|
25
|
+
* has the file, 200. Past it a PDF comes back cut, and its text says which pages it holds (firecrawlPageOf). */
|
|
26
|
+
export const FIRECRAWL_PDF_PAGES_IN_TIME = Math.floor((FIRECRAWL_SCRAPE_TIMEOUT_MS - PDF_FETCH_ALLOWANCE_MS) / PDF_PAGE_MS);
|
|
13
27
|
export const FIRECRAWL_DEFAULTS = Object.freeze({ onlyMainContent: true });
|
|
14
28
|
const FIRECRAWL_CHECKS = {
|
|
15
29
|
onlyMainContent: yesNo,
|
|
@@ -35,9 +49,9 @@ export const FIRECRAWL_QUERIES_MAX = 3;
|
|
|
35
49
|
/** The scrape keyless Firecrawl's search asks of each result, as Firecrawl's guidance for agents asks: its page as
|
|
36
50
|
* markdown, its main content alone unless `settings` say otherwise. A keyed search asks none (firecrawlSearchBody). */
|
|
37
51
|
export const firecrawlScrapeOptions = (settings = {}) => ({ formats: ["markdown"], onlyMainContent: settings.onlyMainContent ?? FIRECRAWL_DEFAULTS.onlyMainContent });
|
|
38
|
-
/** How a keyed web_fetch has Firecrawl read a page: on its basic proxy (the one priced here),
|
|
39
|
-
*
|
|
40
|
-
const keyedRead = (pages) => ({ proxy: "basic",
|
|
52
|
+
/** How a keyed web_fetch has Firecrawl read a page: on its basic proxy (the one priced here), within its timeout
|
|
53
|
+
* (FIRECRAWL_SCRAPE_TIMEOUT_MS), a PDF to `pages` at most (pdfMaxPages), else to what that timeout reads. */
|
|
54
|
+
const keyedRead = (pages) => ({ proxy: "basic", timeout: FIRECRAWL_SCRAPE_TIMEOUT_MS, parsers: [{ type: "pdf", maxPages: pages ?? FIRECRAWL_PDF_PAGES_IN_TIME }] });
|
|
41
55
|
/** Firecrawl's search rows, an answer's `data` or its `data.web`, as hits: each row whose url parses, its snippet its
|
|
42
56
|
* page's markdown, else its description; undefined where the answer holds no rows this server reads. */
|
|
43
57
|
export function firecrawlHits(data) {
|
|
@@ -117,7 +131,8 @@ export async function firecrawlSearched(args, client, settings = {}, signal) {
|
|
|
117
131
|
}));
|
|
118
132
|
return firecrawlMerged("firecrawl", ask, each);
|
|
119
133
|
}
|
|
120
|
-
/** The /v2/scrape request for `url` under `settings`: markdown alone, on the basic proxy,
|
|
134
|
+
/** The /v2/scrape request for `url` under `settings`: markdown alone, on the basic proxy, within Firecrawl's timeout, a
|
|
135
|
+
* PDF to pdfMaxPages, else to the pages that timeout reads. */
|
|
121
136
|
export function firecrawlScrapeBody(url, settings = {}) {
|
|
122
137
|
return { url, formats: ["markdown"], onlyMainContent: settings.onlyMainContent ?? FIRECRAWL_DEFAULTS.onlyMainContent, ...(settings.maxAgeMs === undefined ? {} : { maxAge: settings.maxAgeMs }), ...keyedRead(settings.pdfMaxPages) };
|
|
123
138
|
}
|
|
@@ -34,7 +34,7 @@ export type Extract = {
|
|
|
34
34
|
read(url: string, signal?: AbortSignal, client?: WebClient): Promise<Read | string>;
|
|
35
35
|
post(url: string, body: unknown, signal?: AbortSignal): Promise<Response>;
|
|
36
36
|
};
|
|
37
|
-
/** Parallel's extract on `apiKey`: one URL a request, each
|
|
37
|
+
/** Parallel's extract on `apiKey`: one URL a request, each billed as its usage says, its full content to the most of a page
|
|
38
38
|
* web_fetch reads as the page's text (markdown), its links read from it, status 200 (Parallel answers a page it could
|
|
39
39
|
* not read in `errors`, with no content), told the read's client (clientFields). */
|
|
40
40
|
export declare function parallelExtract(apiKey: string, send?: typeof fetch, pay?: Pay, settings?: ParallelSettings): Extract;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Parallel on the run's key: Extract for web_fetch, Search for web_search. Every request is paid through the injected
|
|
2
2
|
// Pay at its endpoint's price, and a 401 or 403 stops both for the client's life. Nothing is retried; each ends at 60 s.
|
|
3
|
-
import { PARALLEL_SEARCH_MODE_USD, PaidRefused, parallelFeeOf, unmetered } from "../fees.js";
|
|
3
|
+
import { PARALLEL_SEARCH_MODE_USD, PaidRefused, parallelChargeOf, parallelFeeOf, unmetered } from "../fees.js";
|
|
4
4
|
import { clip, cutAt, markdownRead, PAGE_READ_MAX_CHARS, TITLE_CAP } from "../page.js";
|
|
5
5
|
import { failed, failure, keyWide, searchArgs, searchFailed, snippetOf } from "../search.js";
|
|
6
6
|
import { defineProvider, settingsOf } from "../provider.js";
|
|
@@ -37,14 +37,15 @@ const clientFields = (client) => ({
|
|
|
37
37
|
...(client.model ? { client_model: client.model } : {}),
|
|
38
38
|
...(client.session ? { session_id: client.session.slice(0, SESSION_MAX) } : {}),
|
|
39
39
|
});
|
|
40
|
-
/** Parallel's extract on `apiKey`: one URL a request, each
|
|
40
|
+
/** Parallel's extract on `apiKey`: one URL a request, each billed as its usage says, its full content to the most of a page
|
|
41
41
|
* web_fetch reads as the page's text (markdown), its links read from it, status 200 (Parallel answers a page it could
|
|
42
42
|
* not read in `errors`, with no content), told the read's client (clientFields). */
|
|
43
43
|
export function parallelExtract(apiKey, send = fetch, pay = unmetered, settings = {}) {
|
|
44
44
|
// One keyed client for both tools (keyed.ts keyedClient): each request paid through `pay` at its endpoint's price
|
|
45
45
|
// (fees.ts; serve's paid-calls.ts holds it to the run's cap), one with no price, or one the cap refuses, not sent
|
|
46
|
-
// (PaidRefused), a stopped call sending nothing and one that never left not billed (paidSend).
|
|
47
|
-
|
|
46
|
+
// (PaidRefused), a stopped call sending nothing and one that never left not billed (paidSend). An extract is charged
|
|
47
|
+
// the URLs Parallel's usage says it billed (parallelChargeOf): none for a URL it lists in errors.
|
|
48
|
+
const client = keyedClient({ who: "Parallel", base: PARALLEL_API_URL, headers: { "x-api-key": apiKey }, feeOf: (path, body) => parallelFeeOf(`${PARALLEL_API_URL}${path}`, body), chargeOf: parallelChargeOf, timeoutMs: PARALLEL_TIMEOUT_MS, refuseOn: [401, 403] }, send, pay);
|
|
48
49
|
const post = async (url, body, signal) => {
|
|
49
50
|
// It carries the key: a URL not below Parallel's API is never sent, as a request with no price here.
|
|
50
51
|
if (!url.startsWith(`${PARALLEL_API_URL}/`))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun-web",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.74",
|
|
4
4
|
"description": "Web search and web fetch for agents: providers asked in an order given as data, a breaker per provider, a per-run page cache read in parts, and a direct fetch through an injected public-host guard.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentrun",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"undici": "^8.14.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@parcha/pi-browser": "0.1.0-beta.
|
|
49
|
+
"@parcha/pi-browser": "0.1.0-beta.74"
|
|
50
50
|
},
|
|
51
51
|
"repository": {
|
|
52
52
|
"type": "git",
|