@howells/fieldwork-sdk 0.2.0 → 0.3.1
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 +104 -38
- 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-pzPMh82H.js → errors-BiIBG9zN.js} +14 -18
- package/dist/exa.d.ts +150 -24
- package/dist/exa.js +427 -119
- package/dist/{fieldwork-nPzWEelg.d.ts → fieldwork-B3x3cxDJ.d.ts} +5 -5
- package/dist/firecrawl.d.ts +220 -28
- package/dist/firecrawl.js +855 -233
- package/dist/index.d.ts +11 -5
- package/dist/index.js +53 -35
- package/dist/parallel.d.ts +188 -19
- package/dist/parallel.js +644 -113
- package/dist/perplexity.d.ts +78 -22
- package/dist/perplexity.js +318 -92
- package/dist/serpapi.d.ts +172 -0
- package/dist/serpapi.js +517 -0
- package/dist/tavily.d.ts +104 -31
- package/dist/tavily.js +347 -102
- package/dist/tools.d.ts +42 -14
- package/dist/tools.js +1274 -484
- package/dist/types-CnomnF-6.js +27 -0
- package/dist/util-YaZYZDSk.js +287 -0
- package/package.json +19 -3
- package/dist/adapter-C_kRm6TT.d.ts +0 -178
- package/dist/adapter-D-6-GFhJ.js +0 -5
- package/dist/util-D0PLE6Rl.d.ts +0 -2
- package/dist/util-DgcIZI2K.js +0 -214
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import { i as FieldworkErrorCode, n as FieldworkOptions, r as FieldworkError, t as Fieldwork } from "./fieldwork-
|
|
1
|
+
import { A as JsonSchema, B as Price, C as Entity, D as GROUP_CAPABILITIES, E as FieldSource, F as MonitorSchedule, G as Research, H as ProductImage, I as Page, J as SearchResult, K as RunStatus, L as PageBatch, M as MonitorEvent, N as MonitorEvents, O as ImageResult, P as MonitorInfo, R as ParsedDocument, S as DocumentPage, T as FailedUrl, U as ProductVariant, V as Product, W as Recency, X as SiteMap, Y as SiteLink, Z as Usage, _ as DecisionAnswer, a as RawClient, b as Discovery, c as ActResult, d as CAPABILITIES, f as CallOptions, g as Crawl, h as Condition, i as defineAdapter, j as Meta, k as ImageSearch, l as Answer, m as Citation, n as AnyAdapter, o as RequestOptions, p as Capability, q as SearchResponse, r as Operations, s as AccountUsage, t as Adapter, u as BrowserSession, v as DecisionQuestion, w as Extraction, x as DocumentInput, y as Decisions, z as Place } from "./adapter-DGehHCMo.js";
|
|
2
|
+
import { i as FieldworkErrorCode, n as FieldworkOptions, r as FieldworkError, t as Fieldwork } from "./fieldwork-B3x3cxDJ.js";
|
|
3
3
|
type Routes = Partial<Record<Capability, AnyAdapter>>;
|
|
4
4
|
/** Each route must name an adapter whose provider offers that capability. */
|
|
5
5
|
type ValidRoutes<R extends Routes> = { [C in keyof R]: C extends Capability ? R[C] extends {
|
|
6
6
|
operations: Record<C, unknown>;
|
|
7
7
|
} ? R[C] : `${R[C] extends AnyAdapter ? R[C]["name"] : "this adapter"} does not offer ${C}` : never; };
|
|
8
8
|
type RouterOperations<R extends Routes> = { [C in keyof R & Capability]: R[C] extends {
|
|
9
|
-
operations: Record<C, infer Op extends
|
|
9
|
+
operations: Record<C, infer Op extends NonNullable<Operations[C]>>;
|
|
10
10
|
} ? Op : never; };
|
|
11
11
|
type RouterRaw<R extends Routes> = { [C in keyof R & Capability as R[C] extends AnyAdapter ? R[C]["name"] : never]: R[C] extends AnyAdapter ? R[C]["raw"] : never; };
|
|
12
12
|
/**
|
|
@@ -14,5 +14,11 @@ type RouterRaw<R extends Routes> = { [C in keyof R & Capability as R[C] extends
|
|
|
14
14
|
* Each capability goes to exactly the adapter named for it; a capability with
|
|
15
15
|
* no route is unsupported, and nothing falls back to another provider.
|
|
16
16
|
*/
|
|
17
|
-
export declare
|
|
18
|
-
|
|
17
|
+
export declare const router: <const R extends Routes>(routes: R & ValidRoutes<R>) => Adapter<"router", RouterOperations<R>, RouterRaw<R>>;
|
|
18
|
+
/**
|
|
19
|
+
* A router for routes known only at run time, such as from command-line
|
|
20
|
+
* flags. A route to an adapter that lacks its capability throws
|
|
21
|
+
* `Unsupported` here instead of failing to compile.
|
|
22
|
+
*/
|
|
23
|
+
export declare const runtimeRouter: (routes: Routes) => AnyAdapter;
|
|
24
|
+
export { AccountUsage, ActResult, type Adapter, Answer, type AnyAdapter, BrowserSession, CAPABILITIES, CallOptions, Capability, Citation, Condition, Crawl, DecisionAnswer, DecisionQuestion, Decisions, Discovery, DocumentInput, DocumentPage, Entity, Extraction, FailedUrl, FieldSource, Fieldwork, FieldworkError, type FieldworkErrorCode, type FieldworkOptions, GROUP_CAPABILITIES, ImageResult, ImageSearch, JsonSchema, Meta, MonitorEvent, MonitorEvents, MonitorInfo, MonitorSchedule, type Operations, Page, PageBatch, ParsedDocument, Place, Price, Product, ProductImage, ProductVariant, type RawClient, Recency, type RequestOptions, Research, type Routes, RunStatus, SearchResponse, SearchResult, SiteLink, SiteMap, Usage, defineAdapter };
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import { t as defineAdapter } from "./adapter-
|
|
2
|
-
import { t as FieldworkError } from "./errors-
|
|
3
|
-
|
|
4
|
-
/** Every capability Fieldwork knows. An adapter implements a subset. */
|
|
5
|
-
const CAPABILITIES = [
|
|
6
|
-
"search",
|
|
7
|
-
"read",
|
|
8
|
-
"extract",
|
|
9
|
-
"product",
|
|
10
|
-
"map",
|
|
11
|
-
"crawl",
|
|
12
|
-
"research",
|
|
13
|
-
"act",
|
|
14
|
-
"parse"
|
|
15
|
-
];
|
|
1
|
+
import { t as defineAdapter } from "./adapter-CEAQuT7F.js";
|
|
2
|
+
import { t as FieldworkError } from "./errors-BiIBG9zN.js";
|
|
3
|
+
import { n as GROUP_CAPABILITIES, t as CAPABILITIES } from "./types-CnomnF-6.js";
|
|
16
4
|
// src/fieldwork.ts
|
|
5
|
+
const bindOperation = (operations, capability) => {
|
|
6
|
+
const all = operations;
|
|
7
|
+
const operation = all[capability];
|
|
8
|
+
if (typeof operation === "function") return operation.bind(all);
|
|
9
|
+
if (GROUP_CAPABILITIES.includes(capability) && operation && typeof operation === "object") {
|
|
10
|
+
const group = operation;
|
|
11
|
+
return Object.fromEntries(Object.entries(group).map(([name, method]) => [name, typeof method === "function" ? method.bind(group) : method]));
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const unsupported = (provider, capability) => {
|
|
15
|
+
const refuse = async () => {
|
|
16
|
+
throw new FieldworkError("Unsupported", `${provider} does not offer ${capability}`, { provider });
|
|
17
|
+
};
|
|
18
|
+
if (!GROUP_CAPABILITIES.includes(capability)) return refuse;
|
|
19
|
+
return new Proxy({}, { get: () => refuse });
|
|
20
|
+
};
|
|
17
21
|
var FieldworkClient = class {
|
|
18
22
|
provider;
|
|
19
23
|
capabilities;
|
|
@@ -21,18 +25,15 @@ var FieldworkClient = class {
|
|
|
21
25
|
#providers;
|
|
22
26
|
constructor(options) {
|
|
23
27
|
const { adapter } = options;
|
|
24
|
-
const operations = adapter.operations;
|
|
25
28
|
this.provider = adapter.name;
|
|
26
29
|
this.raw = adapter.raw;
|
|
27
30
|
this.#providers = adapter.providers ?? {};
|
|
28
31
|
const capabilities = {};
|
|
29
32
|
const self = this;
|
|
30
33
|
for (const capability of CAPABILITIES) {
|
|
31
|
-
const operation = operations
|
|
32
|
-
capabilities[capability] =
|
|
33
|
-
self[capability] =
|
|
34
|
-
throw new FieldworkError("Unsupported", `${adapter.name} does not offer ${capability}`, { provider: adapter.name });
|
|
35
|
-
};
|
|
34
|
+
const operation = bindOperation(adapter.operations, capability);
|
|
35
|
+
capabilities[capability] = operation !== void 0;
|
|
36
|
+
self[capability] = operation ?? unsupported(adapter.name, capability);
|
|
36
37
|
}
|
|
37
38
|
this.capabilities = Object.freeze(capabilities);
|
|
38
39
|
}
|
|
@@ -46,28 +47,45 @@ var FieldworkClient = class {
|
|
|
46
47
|
};
|
|
47
48
|
const Fieldwork = FieldworkClient;
|
|
48
49
|
// src/router.ts
|
|
49
|
-
|
|
50
|
-
* One adapter per capability: `router({ search: parallel(), read: firecrawl() })`.
|
|
51
|
-
* Each capability goes to exactly the adapter named for it; a capability with
|
|
52
|
-
* no route is unsupported, and nothing falls back to another provider.
|
|
53
|
-
*/
|
|
54
|
-
function router(routes) {
|
|
50
|
+
const build = (routes) => {
|
|
55
51
|
const operations = {};
|
|
56
52
|
const raw = {};
|
|
57
53
|
const providers = {};
|
|
58
54
|
for (const [capability, adapter] of Object.entries(routes)) {
|
|
59
55
|
if (!adapter) continue;
|
|
60
|
-
const operation = adapter.operations
|
|
61
|
-
if (
|
|
62
|
-
operations[capability] = operation
|
|
56
|
+
const operation = bindOperation(adapter.operations, capability);
|
|
57
|
+
if (operation === void 0) throw new FieldworkError("Unsupported", `${adapter.name} does not offer ${capability}`, { provider: adapter.name });
|
|
58
|
+
operations[capability] = operation;
|
|
63
59
|
providers[capability] = adapter.name;
|
|
64
60
|
raw[adapter.name] = adapter.raw;
|
|
65
61
|
}
|
|
62
|
+
return {
|
|
63
|
+
operations,
|
|
64
|
+
providers,
|
|
65
|
+
raw
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* One adapter per capability: `router({ search: parallel(), read: firecrawl() })`.
|
|
70
|
+
* Each capability goes to exactly the adapter named for it; a capability with
|
|
71
|
+
* no route is unsupported, and nothing falls back to another provider.
|
|
72
|
+
*/
|
|
73
|
+
const router = (routes) => {
|
|
74
|
+
const built = build(routes);
|
|
66
75
|
return defineAdapter({
|
|
67
76
|
name: "router",
|
|
68
|
-
operations,
|
|
69
|
-
|
|
70
|
-
|
|
77
|
+
operations: built.operations,
|
|
78
|
+
providers: built.providers,
|
|
79
|
+
raw: built.raw
|
|
71
80
|
});
|
|
72
|
-
}
|
|
73
|
-
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* A router for routes known only at run time, such as from command-line
|
|
84
|
+
* flags. A route to an adapter that lacks its capability throws
|
|
85
|
+
* `Unsupported` here instead of failing to compile.
|
|
86
|
+
*/
|
|
87
|
+
const runtimeRouter = (routes) => defineAdapter({
|
|
88
|
+
name: "router",
|
|
89
|
+
...build(routes)
|
|
90
|
+
});
|
|
91
|
+
export { CAPABILITIES, Fieldwork, FieldworkError, GROUP_CAPABILITIES, defineAdapter, router, runtimeRouter };
|
package/dist/parallel.d.ts
CHANGED
|
@@ -1,61 +1,230 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { A as JsonSchema, F as MonitorSchedule, G as Research, I as Page, L as PageBatch, N as MonitorEvents, P as MonitorInfo, a as RawClient, b as Discovery, f as CallOptions, h as Condition, k as ImageSearch, l as Answer, q as SearchResponse, t as Adapter, v as DecisionQuestion, w as Extraction, y as Decisions } from "./adapter-DGehHCMo.js";
|
|
2
|
+
interface ParallelConfig {
|
|
3
3
|
/** Defaults to the PARALLEL_API_KEY environment variable. */
|
|
4
4
|
apiKey?: string;
|
|
5
5
|
baseUrl?: string;
|
|
6
6
|
fetch?: typeof fetch;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
/**
|
|
9
|
+
* A Task API processor. Parallel documents `processor` as a free string, so any
|
|
10
|
+
* name it accepts can be passed; the documented names autocomplete.
|
|
11
|
+
*/
|
|
12
|
+
type ParallelProcessor = "lite" | "base" | "core" | "core2x" | "pro" | "ultra" | "ultra2x" | "ultra4x" | "ultra8x" | (string & Record<never, never>);
|
|
13
|
+
/** Filters on which sources Parallel may use. */
|
|
14
|
+
interface ParallelSources {
|
|
15
|
+
/**
|
|
16
|
+
* Domains, as plain `example.com` (subdomains match), `domain/path` prefixes
|
|
17
|
+
* such as `docs.python.org/3`, or bare extensions such as `.gov`. When set,
|
|
18
|
+
* Parallel ignores `excludeDomains`, so passing both is refused.
|
|
19
|
+
*/
|
|
11
20
|
includeDomains?: string[];
|
|
12
21
|
excludeDomains?: string[];
|
|
13
22
|
/** YYYY-MM-DD. */
|
|
14
23
|
publishedAfter?: string;
|
|
15
24
|
}
|
|
16
|
-
|
|
25
|
+
/** Task metadata: keys up to 16 characters, values up to 512. */
|
|
26
|
+
type ParallelMetadata = Record<string, string | number | boolean>;
|
|
27
|
+
interface ParallelSearchOptions extends CallOptions, ParallelSources {
|
|
17
28
|
/** What the search is for, in plain words. Defaults to the query. */
|
|
18
29
|
objective?: string;
|
|
19
|
-
/** Several keyword queries; defaults to the query alone. */
|
|
30
|
+
/** Several keyword queries of 3 to 6 words; defaults to the query alone. */
|
|
20
31
|
queries?: string[];
|
|
32
|
+
/**
|
|
33
|
+
* `turbo` (about 200 ms, English and Japanese only), `fast` (about 700 ms),
|
|
34
|
+
* `basic` or `advanced` (the default, richer retrieval).
|
|
35
|
+
*/
|
|
21
36
|
mode?: "turbo" | "fast" | "basic" | "advanced";
|
|
22
37
|
limit?: number;
|
|
23
|
-
/**
|
|
38
|
+
/** ISO 3166-1 alpha-2 code such as "GB", for geo-targeted results. */
|
|
39
|
+
country?: string;
|
|
40
|
+
/** Seconds a cached copy may be old. Parallel's minimum is 600; lower values are refused. */
|
|
41
|
+
maxAge?: number;
|
|
42
|
+
/** Cap on the characters of excerpts returned for each result. */
|
|
43
|
+
maxCharsPerResult?: number;
|
|
44
|
+
/** Cap on the characters of excerpts returned across all results. */
|
|
24
45
|
maxCharsTotal?: number;
|
|
46
|
+
/** Groups calls made for one larger task; Parallel may use it to improve later results. */
|
|
47
|
+
sessionId?: string;
|
|
25
48
|
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
49
|
+
interface ParallelImagesOptions extends CallOptions {
|
|
50
|
+
/** The images wanted, in plain words, up to 5,000 characters. Defaults to the query. */
|
|
28
51
|
objective?: string;
|
|
52
|
+
/** Up to 5 image queries; defaults to the query alone. */
|
|
29
53
|
queries?: string[];
|
|
30
|
-
|
|
31
|
-
|
|
54
|
+
mode?: "fast" | "advanced";
|
|
55
|
+
limit?: number;
|
|
56
|
+
country?: string;
|
|
57
|
+
sessionId?: string;
|
|
32
58
|
}
|
|
33
|
-
|
|
34
|
-
|
|
59
|
+
interface ParallelReadOptions extends CallOptions {
|
|
60
|
+
/** Return passages that answer this as `excerpts`. Sent as Parallel's `objective`. */
|
|
61
|
+
query?: string;
|
|
62
|
+
/** Keyword queries that focus the excerpts. */
|
|
63
|
+
queries?: string[];
|
|
64
|
+
/** Seconds a cached copy may be old. Parallel's minimum is 600; lower values are refused. */
|
|
65
|
+
maxAge?: number;
|
|
66
|
+
/** Cap on the characters of the page text returned for each URL. */
|
|
67
|
+
maxContentChars?: number;
|
|
68
|
+
/** Cap on the characters of excerpts returned for each URL. */
|
|
69
|
+
maxCharsPerResult?: number;
|
|
70
|
+
/** Cap on the characters of excerpts returned across all URLs. */
|
|
71
|
+
maxCharsTotal?: number;
|
|
72
|
+
sessionId?: string;
|
|
73
|
+
}
|
|
74
|
+
type ParallelReadManyOptions = ParallelReadOptions;
|
|
75
|
+
interface ParallelExtractOptions extends CallOptions {
|
|
76
|
+
/**
|
|
77
|
+
* The values to extract. Without one, Parallel picks the fields itself (its
|
|
78
|
+
* `auto` output schema, which gives deep-research style output on `pro` and
|
|
79
|
+
* above).
|
|
80
|
+
*/
|
|
81
|
+
schema?: JsonSchema;
|
|
35
82
|
prompt?: string;
|
|
36
83
|
/** Defaults to "base". */
|
|
37
84
|
processor?: ParallelProcessor;
|
|
85
|
+
/** ISO 3166-1 alpha-2 code for geo-targeted search. */
|
|
86
|
+
country?: string;
|
|
87
|
+
metadata?: ParallelMetadata;
|
|
88
|
+
/** Milliseconds between checks. */
|
|
89
|
+
interval?: number;
|
|
38
90
|
/**
|
|
39
91
|
* The id of a job that timed out or was cancelled, from the error's
|
|
40
92
|
* `jobId`. Waits for that job instead of starting a new one.
|
|
41
93
|
*/
|
|
42
94
|
resume?: string;
|
|
43
95
|
}
|
|
44
|
-
|
|
96
|
+
interface ParallelAnswerOptions extends CallOptions {
|
|
97
|
+
/** The answer in the shape of this schema, in `output`. */
|
|
98
|
+
schema?: JsonSchema;
|
|
99
|
+
/** System instructions for the answer. */
|
|
100
|
+
instructions?: string;
|
|
101
|
+
/** How much research the answer does: `low`, `medium` (the default), `high` or `auto`. */
|
|
102
|
+
effort?: "low" | "medium" | "high" | "auto";
|
|
103
|
+
/** The `continuationId` of an earlier answer. */
|
|
104
|
+
continueFrom?: string;
|
|
105
|
+
/** Only these domains are searched. Parallel allows one of the two lists. */
|
|
106
|
+
includeDomains?: string[];
|
|
107
|
+
excludeDomains?: string[];
|
|
108
|
+
/** Up to 16 keys, keys up to 64 characters, values up to 512. */
|
|
109
|
+
metadata?: Record<string, string>;
|
|
110
|
+
}
|
|
111
|
+
interface ParallelResearchOptions extends CallOptions, ParallelSources {
|
|
112
|
+
/** Structured output in the shape of this schema; without one the output is report text. */
|
|
45
113
|
schema?: JsonSchema;
|
|
46
114
|
/** Defaults to "base". */
|
|
47
115
|
processor?: ParallelProcessor;
|
|
116
|
+
/** The `continuationId` of an earlier run. */
|
|
117
|
+
continueFrom?: string;
|
|
118
|
+
metadata?: ParallelMetadata;
|
|
119
|
+
/** ISO 3166-1 alpha-2 code for geo-targeted search. */
|
|
120
|
+
country?: string;
|
|
121
|
+
/** Milliseconds between checks. */
|
|
122
|
+
interval?: number;
|
|
48
123
|
/**
|
|
49
124
|
* The id of a job that timed out or was cancelled, from the error's
|
|
50
125
|
* `jobId`. Waits for that job instead of starting a new one.
|
|
51
126
|
*/
|
|
52
127
|
resume?: string;
|
|
53
128
|
}
|
|
54
|
-
|
|
129
|
+
interface ParallelDiscoverOptions extends CallOptions {
|
|
130
|
+
/** What kind of entity to find, such as "companies" or "people". */
|
|
131
|
+
entityType: string;
|
|
132
|
+
/** Every discovered entity is tested against all of these. */
|
|
133
|
+
conditions: Condition[];
|
|
134
|
+
/** Matches to find, 5 to 1,000. Defaults to 10. */
|
|
135
|
+
limit?: number;
|
|
136
|
+
/** `preview` tests 5 to 10 candidates; `core` and `pro` search deeper. Defaults to "base". */
|
|
137
|
+
generator?: "preview" | "base" | "core" | "pro";
|
|
138
|
+
/** Entities already known, left out of the results. Up to 10,000. */
|
|
139
|
+
exclude?: {
|
|
140
|
+
name: string;
|
|
141
|
+
url: string;
|
|
142
|
+
}[];
|
|
143
|
+
/**
|
|
144
|
+
* Fills these fields for every match (Parallel's enrichment, run as a Task
|
|
145
|
+
* after the run starts), returned in each entity's `data`.
|
|
146
|
+
*/
|
|
147
|
+
schema?: JsonSchema;
|
|
148
|
+
/** The Task processor that fills `schema`. Parallel defaults to "core". */
|
|
149
|
+
processor?: ParallelProcessor;
|
|
150
|
+
metadata?: ParallelMetadata;
|
|
151
|
+
/** Milliseconds between checks. */
|
|
152
|
+
interval?: number;
|
|
153
|
+
/**
|
|
154
|
+
* The id of a job that timed out or was cancelled, from the error's
|
|
155
|
+
* `jobId`. Waits for that job instead of starting a new one; the request
|
|
156
|
+
* options are ignored.
|
|
157
|
+
*/
|
|
158
|
+
resume?: string;
|
|
159
|
+
}
|
|
160
|
+
interface ParallelDecideOptions extends CallOptions {
|
|
161
|
+
/** ISO 3166-1 alpha-2 code for geo-targeted search. */
|
|
162
|
+
country?: string;
|
|
163
|
+
/** Keep the passages each citation was taken from. Parallel defaults to true. */
|
|
164
|
+
includeExcerpts?: boolean;
|
|
165
|
+
}
|
|
166
|
+
type ParallelWebhookEvent = "monitor.event.detected" | "monitor.execution.completed" | "monitor.execution.failed";
|
|
167
|
+
interface ParallelMonitorCreateOptions extends CallOptions, ParallelSources {
|
|
168
|
+
/**
|
|
169
|
+
* What to watch for, in plain words. Parallel searches the web for it on
|
|
170
|
+
* every run. Pass this or `taskRunId`.
|
|
171
|
+
*/
|
|
172
|
+
query?: string;
|
|
173
|
+
/**
|
|
174
|
+
* Watch the output of an earlier Task run for changes instead of a query.
|
|
175
|
+
* Cannot be combined with `query`, `schema`, `includeBackfill`, `country` or
|
|
176
|
+
* the domain filters.
|
|
177
|
+
*/
|
|
178
|
+
taskRunId?: string;
|
|
179
|
+
/** Parallel runs at a fixed interval from 1 hour to 30 days; cron is refused. */
|
|
180
|
+
schedule: MonitorSchedule;
|
|
181
|
+
/** Events come back in the shape of this schema. */
|
|
182
|
+
schema?: JsonSchema;
|
|
183
|
+
/** The first run returns a sample of recent events (a preview, not exhaustive). */
|
|
184
|
+
includeBackfill?: boolean;
|
|
185
|
+
country?: string;
|
|
186
|
+
webhookUrl?: string;
|
|
187
|
+
/** Needs `webhookUrl`. Parallel sends every event type when omitted. */
|
|
188
|
+
webhookEvents?: ParallelWebhookEvent[];
|
|
189
|
+
/** Defaults to "lite". */
|
|
190
|
+
processor?: "lite" | "base" | "core";
|
|
191
|
+
/** Keys up to 16 characters, values up to 512. */
|
|
192
|
+
metadata?: Record<string, string>;
|
|
193
|
+
}
|
|
194
|
+
interface ParallelMonitorEventsOptions extends CallOptions {
|
|
195
|
+
cursor?: string;
|
|
196
|
+
/** 1 to 100. Parallel defaults to 20. */
|
|
197
|
+
limit?: number;
|
|
198
|
+
/** Also return runs that found no change. */
|
|
199
|
+
includeCompletions?: boolean;
|
|
200
|
+
/** Only the events of one run, from an earlier event's `event_group_id`. */
|
|
201
|
+
eventGroupId?: string;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* A discovery that may have stopped early. `stopReason` is Parallel's
|
|
205
|
+
* `termination_reason` when `status` is "partial".
|
|
206
|
+
*/
|
|
207
|
+
type ParallelDiscovery<T> = Discovery<T> & {
|
|
208
|
+
stopReason?: string;
|
|
209
|
+
};
|
|
210
|
+
interface ParallelOperations {
|
|
55
211
|
search(query: string, options?: ParallelSearchOptions): Promise<SearchResponse>;
|
|
212
|
+
images(query: string, options?: ParallelImagesOptions): Promise<ImageSearch>;
|
|
56
213
|
read(url: string, options?: ParallelReadOptions): Promise<Page>;
|
|
57
|
-
|
|
214
|
+
readMany(urls: string[], options?: ParallelReadManyOptions): Promise<PageBatch>;
|
|
215
|
+
extract<T = unknown>(url: string, options?: ParallelExtractOptions): Promise<Extraction<T>>;
|
|
216
|
+
answer<T = unknown>(question: string, options?: ParallelAnswerOptions): Promise<Answer<T>>;
|
|
58
217
|
research<T = unknown>(question: string, options?: ParallelResearchOptions): Promise<Research<T>>;
|
|
218
|
+
discover<T = Record<string, unknown>>(objective: string, options: ParallelDiscoverOptions): Promise<ParallelDiscovery<T>>;
|
|
219
|
+
decide(context: unknown, questions: Record<string, DecisionQuestion>, options?: ParallelDecideOptions): Promise<Decisions>;
|
|
220
|
+
monitor: {
|
|
221
|
+
create(options: ParallelMonitorCreateOptions): Promise<MonitorInfo>;
|
|
222
|
+
get(id: string, options?: CallOptions): Promise<MonitorInfo>;
|
|
223
|
+
list(options?: CallOptions): Promise<MonitorInfo[]>;
|
|
224
|
+
/** Parallel cancels a monitor for good; it has no delete. */
|
|
225
|
+
delete(id: string, options?: CallOptions): Promise<void>;
|
|
226
|
+
events(id: string, options?: ParallelMonitorEventsOptions): Promise<MonitorEvents>;
|
|
227
|
+
};
|
|
59
228
|
}
|
|
60
|
-
export declare
|
|
61
|
-
export {};
|
|
229
|
+
export declare const parallel: (config?: ParallelConfig) => Adapter<"parallel", ParallelOperations, RawClient>;
|
|
230
|
+
export type { ParallelAnswerOptions, ParallelConfig, ParallelDecideOptions, ParallelDiscoverOptions, ParallelDiscovery, ParallelExtractOptions, ParallelImagesOptions, ParallelMetadata, ParallelMonitorCreateOptions, ParallelMonitorEventsOptions, ParallelOperations, ParallelProcessor, ParallelReadManyOptions, ParallelReadOptions, ParallelResearchOptions, ParallelSearchOptions, ParallelSources, ParallelWebhookEvent };
|