@howells/fieldwork-sdk 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,470 @@
1
+ /**
2
+ * The shapes every adapter returns. Each result keeps the provider's own
3
+ * response in `raw`, so nothing the provider sent is lost by normalizing it.
4
+ */
5
+ /** A JSON Schema object describing the values to extract. */
6
+ type JsonSchema = Record<string, unknown>;
7
+ /** Every capability Fieldwork knows. An adapter implements a subset. */
8
+ declare const CAPABILITIES: readonly ["search", "images", "read", "readMany", "extract", "product", "map", "crawl", "answer", "research", "discover", "decide", "act", "browser", "parse", "monitor", "usage"];
9
+ type Capability = (typeof CAPABILITIES)[number];
10
+ /**
11
+ * Capabilities whose operation is a group of methods rather than one method:
12
+ * `web.monitor.create(...)`, `web.browser.open(...)`.
13
+ */
14
+ declare const GROUP_CAPABILITIES: readonly Capability[];
15
+ /** Settings every call accepts, whatever the provider. */
16
+ interface CallOptions {
17
+ /** Cancels the call, including any polling for an asynchronous job. */
18
+ signal?: AbortSignal;
19
+ /** Milliseconds before the call gives up. */
20
+ timeout?: number;
21
+ }
22
+ /** How recent results must be, where a provider filters by a named window. */
23
+ type Recency = "hour" | "day" | "week" | "month" | "year";
24
+ /** What the provider charged or counted for a call, in its own units. */
25
+ interface Usage {
26
+ /** Provider credits, for providers that bill in credits. */
27
+ credits?: number;
28
+ /** The cost in US dollars, when the provider reports it. */
29
+ costUsd?: number;
30
+ /** Other counted units, such as tokens or billed SKUs, by name. */
31
+ units?: Record<string, number>;
32
+ }
33
+ /** Details every result can carry besides its content. */
34
+ interface Meta {
35
+ /** The provider's id for the request, for support tickets and feedback. */
36
+ requestId?: string;
37
+ usage?: Usage;
38
+ /**
39
+ * Warnings the provider returned, such as an ignored option or a page it
40
+ * could not fully read.
41
+ */
42
+ warnings?: string[];
43
+ }
44
+ /** A source a provider cited. */
45
+ interface Citation {
46
+ url: string;
47
+ title?: string;
48
+ /** Passages the provider quoted from the source, when it returned any. */
49
+ excerpts?: string[];
50
+ }
51
+ /** The sources a provider gave for one field of a structured result. */
52
+ interface FieldSource {
53
+ /** The field's name or path, as the provider reports it. */
54
+ field: string;
55
+ citations: Citation[];
56
+ /** The provider's own confidence label or score, unchanged. */
57
+ confidence?: string | number;
58
+ reasoning?: string;
59
+ }
60
+ /** An amount of money as the provider stated it. */
61
+ interface Price {
62
+ /** The amount as text, so no precision is lost: "12.50". */
63
+ amount?: string;
64
+ /** ISO 4217 code, such as "USD". */
65
+ currency?: string;
66
+ /** The price as the page showed it: "$12.50". */
67
+ formatted?: string;
68
+ }
69
+ interface Place {
70
+ address?: string;
71
+ latitude?: number;
72
+ longitude?: number;
73
+ }
74
+ interface SearchResult {
75
+ url: string;
76
+ title?: string;
77
+ /** Text from the page that matched the query. */
78
+ snippet?: string;
79
+ /** Page text, when the search was asked to include it. */
80
+ content?: string;
81
+ /** When the page was published, as the provider reports it. */
82
+ publishedAt?: string;
83
+ /** When the page last changed, where the provider tracks it separately. */
84
+ lastUpdatedAt?: string;
85
+ score?: number;
86
+ author?: string;
87
+ /** An image that represents the page. */
88
+ image?: string;
89
+ favicon?: string;
90
+ /**
91
+ * The kind of result, when a search mixes or picks kinds: "web", "news",
92
+ * "research", "shopping", "place", "scholar", "patent", "person" and so on.
93
+ */
94
+ kind?: string;
95
+ /** Shopping results. */
96
+ price?: Price;
97
+ rating?: number;
98
+ reviewCount?: number;
99
+ /** Place results. */
100
+ place?: Place;
101
+ }
102
+ interface ImageResult {
103
+ /** The image itself. */
104
+ url: string;
105
+ thumbnailUrl?: string;
106
+ /** The page the image appears on. */
107
+ sourceUrl?: string;
108
+ title?: string;
109
+ description?: string;
110
+ width?: number;
111
+ height?: number;
112
+ }
113
+ interface SearchResponse {
114
+ results: SearchResult[];
115
+ /** A generated answer, when the provider was asked for one. */
116
+ answer?: string;
117
+ /** Images found alongside the results, when the search was asked for them. */
118
+ images?: ImageResult[];
119
+ meta?: Meta;
120
+ raw: unknown;
121
+ }
122
+ interface ImageSearch {
123
+ results: ImageResult[];
124
+ meta?: Meta;
125
+ raw: unknown;
126
+ }
127
+ interface Page {
128
+ url: string;
129
+ title?: string;
130
+ description?: string;
131
+ /** The page as Markdown. */
132
+ markdown?: string;
133
+ /** Cleaned HTML. */
134
+ html?: string;
135
+ /** The HTML exactly as the provider received it. */
136
+ rawHtml?: string;
137
+ links?: string[];
138
+ images?: string[];
139
+ /** The page's main image as the page declares it, such as its og:image. */
140
+ image?: string;
141
+ /** Passages that answer the query, when the read was given one. */
142
+ excerpts?: string[];
143
+ /** A short summary, when the read asked for one. */
144
+ summary?: string;
145
+ publishedAt?: string;
146
+ author?: string;
147
+ favicon?: string;
148
+ /** ISO 639-1 language code. */
149
+ language?: string;
150
+ /** The HTTP status the page returned to the provider. */
151
+ statusCode?: number;
152
+ /** A URL of a screenshot of the page; providers expire these. */
153
+ screenshot?: string;
154
+ meta?: Meta;
155
+ raw: unknown;
156
+ }
157
+ /** A URL a multi-page call could not read, and why. */
158
+ interface FailedUrl {
159
+ url: string;
160
+ error: string;
161
+ }
162
+ interface PageBatch {
163
+ /** The provider's job id, for providers that read in a background job. */
164
+ id?: string;
165
+ pages: Page[];
166
+ failed: FailedUrl[];
167
+ meta?: Meta;
168
+ raw: unknown;
169
+ }
170
+ interface Extraction<T> {
171
+ /** The values, in the shape of the schema. */
172
+ data: T;
173
+ /** Per-field sources, when the provider returns them. */
174
+ fields?: FieldSource[];
175
+ meta?: Meta;
176
+ raw: unknown;
177
+ }
178
+ interface ProductImage {
179
+ url: string;
180
+ alt?: string;
181
+ }
182
+ interface ProductVariant {
183
+ id?: string;
184
+ sku?: string;
185
+ title?: string;
186
+ /** Option values that pick this variant, such as color or size. */
187
+ values?: Record<string, string>;
188
+ price?: Price;
189
+ /** The price before a sale, when the variant is on sale. */
190
+ originalPrice?: Price;
191
+ inStock?: boolean;
192
+ /** The availability as the page stated it: "Ships in 2-3 weeks". */
193
+ availability?: string;
194
+ images?: ProductImage[];
195
+ /** Barcode: GTIN, EAN or UPC. */
196
+ gtin?: string;
197
+ }
198
+ interface Product {
199
+ title?: string;
200
+ brand?: string;
201
+ category?: string;
202
+ description?: string;
203
+ url?: string;
204
+ images?: ProductImage[];
205
+ variants: ProductVariant[];
206
+ meta?: Meta;
207
+ raw: unknown;
208
+ }
209
+ interface SiteLink {
210
+ url: string;
211
+ title?: string;
212
+ description?: string;
213
+ }
214
+ interface SiteMap {
215
+ links: SiteLink[];
216
+ meta?: Meta;
217
+ raw: unknown;
218
+ }
219
+ interface Crawl {
220
+ /** The provider's job id, for providers that crawl in a background job. */
221
+ id?: string;
222
+ pages: Page[];
223
+ /** Pages the provider tried and could not read. */
224
+ failed?: FailedUrl[];
225
+ /** URLs the site's robots.txt kept the provider from reading. */
226
+ robotsBlocked?: string[];
227
+ /** Pages the provider found to crawl, when it reports it. */
228
+ total?: number;
229
+ meta?: Meta;
230
+ raw: unknown;
231
+ }
232
+ /**
233
+ * A finished run is `completed`. A run that stopped early, on a budget, a time
234
+ * limit or a step limit, and still returned output is `partial`; `stopReason`
235
+ * says why. A run with no output throws `JobFailed`.
236
+ */
237
+ type RunStatus = "completed" | "partial";
238
+ interface Answer<T> {
239
+ /** The answer text. */
240
+ answer: string;
241
+ /** The answer in the shape of the schema, when one was given. */
242
+ output?: T;
243
+ /** The sources the answer cites. */
244
+ citations: Citation[];
245
+ fields?: FieldSource[];
246
+ /** Pass as `continueFrom` to ask a follow-up in the same thread. */
247
+ continuationId?: string;
248
+ meta?: Meta;
249
+ raw: unknown;
250
+ }
251
+ interface Research<T> {
252
+ /** The provider's id for the run. */
253
+ id: string;
254
+ status: RunStatus;
255
+ /** Why the run stopped, as the provider reports it. */
256
+ stopReason?: string;
257
+ /** Structured output when a schema was given, otherwise the report text. */
258
+ output: T;
259
+ /** The sources the output cites. */
260
+ sources: Citation[];
261
+ /** Every source the run looked at, where the provider lists them apart from what it cited. */
262
+ retrieved?: Citation[];
263
+ fields?: FieldSource[];
264
+ /** Pass as `continueFrom` to build on this run. */
265
+ continuationId?: string;
266
+ meta?: Meta;
267
+ raw: unknown;
268
+ }
269
+ /** One entity a discovery run found. */
270
+ interface Entity<T = Record<string, unknown>> {
271
+ name: string;
272
+ url?: string;
273
+ description?: string;
274
+ /** Whether the entity met every condition, when the provider judged it. */
275
+ matched?: boolean;
276
+ /** Values the run filled for the entity, such as enrichment fields. */
277
+ data?: T;
278
+ citations?: Citation[];
279
+ fields?: FieldSource[];
280
+ }
281
+ interface Discovery<T = Record<string, unknown>> {
282
+ /** The provider's id for the run. */
283
+ id: string;
284
+ status: RunStatus;
285
+ entities: Entity<T>[];
286
+ meta?: Meta;
287
+ raw: unknown;
288
+ }
289
+ /** A condition every discovered entity must meet. */
290
+ interface Condition {
291
+ name: string;
292
+ /** The condition in plain words. */
293
+ description: string;
294
+ }
295
+ /**
296
+ * A closed question for `decide`. `yesno` returns a probability that the
297
+ * answer is yes; `choice` returns a probability for each choice; `score`
298
+ * returns a probability for each point of a rubric.
299
+ */
300
+ type DecisionQuestion = {
301
+ type: "yesno";
302
+ question: string;
303
+ } | {
304
+ type: "choice";
305
+ question: string;
306
+ choices: string[];
307
+ } | {
308
+ type: "score";
309
+ question: string;
310
+ /** The rubric: each score and what it means. */
311
+ scale: Record<string, string>;
312
+ };
313
+ interface DecisionAnswer {
314
+ /** For `yesno`: the probability that the answer is yes, 0 to 1. */
315
+ probability?: number;
316
+ /** For `choice` and `score`: the most likely option. */
317
+ choice?: string;
318
+ /** For `choice` and `score`: the probability of each option. */
319
+ probabilities?: Record<string, number>;
320
+ confidence?: string | number;
321
+ /** Set when the provider declined to answer, with its reason. */
322
+ refusal?: string;
323
+ }
324
+ interface Decisions {
325
+ /** Answers keyed by the question names given. */
326
+ answers: Record<string, DecisionAnswer>;
327
+ /** Sources behind the answers, for providers that ground them on the web. */
328
+ citations: Citation[];
329
+ meta?: Meta;
330
+ raw: unknown;
331
+ }
332
+ interface ActResult {
333
+ /** What the script printed. */
334
+ stdout: string;
335
+ stderr: string;
336
+ /** The value the script returned, as the provider reports it. */
337
+ result?: unknown;
338
+ exitCode?: number;
339
+ /** Set when the script failed, with the provider's message. */
340
+ error?: string;
341
+ /** Whether the provider stopped the script, for example on its time limit. */
342
+ killed?: boolean;
343
+ /** The browser session the script ran in, when it was kept open. */
344
+ sessionId?: string;
345
+ meta?: Meta;
346
+ raw: unknown;
347
+ }
348
+ /** A remote browser kept open for your own automation over CDP. */
349
+ interface BrowserSession {
350
+ id: string;
351
+ /** Chrome DevTools Protocol WebSocket URL for Playwright or Puppeteer. */
352
+ cdpUrl?: string;
353
+ /** A URL where a person can watch the session. */
354
+ liveViewUrl?: string;
355
+ /** ISO time the provider will close the session. */
356
+ expiresAt?: string;
357
+ meta?: Meta;
358
+ raw: unknown;
359
+ }
360
+ interface DocumentPage {
361
+ /** The physical page number, starting at 1. */
362
+ pageNumber: number;
363
+ markdown: string;
364
+ }
365
+ interface ParsedDocument {
366
+ markdown: string;
367
+ pages?: DocumentPage[];
368
+ /** Layout blocks with positions, as the provider returns them. */
369
+ blocks?: unknown[];
370
+ /** Pages in the file; more than `pages.length` means the parse was cut short. */
371
+ pageCount?: number;
372
+ meta?: Meta;
373
+ raw: unknown;
374
+ }
375
+ /** A file to parse: its bytes and its name, which tells the provider the type. */
376
+ interface DocumentInput {
377
+ data: Blob | Uint8Array | ArrayBuffer;
378
+ name: string;
379
+ }
380
+ /** How often a monitor checks: a cron expression or a named interval. */
381
+ type MonitorSchedule = {
382
+ cron: string;
383
+ } | {
384
+ every: "hour" | "day" | "week" | `${number}h` | `${number}d`;
385
+ };
386
+ interface MonitorInfo {
387
+ id: string;
388
+ /** What the monitor watches: a query, a URL list or a goal. */
389
+ watch?: string;
390
+ status?: string;
391
+ schedule?: string;
392
+ webhookUrl?: string;
393
+ createdAt?: string;
394
+ raw: unknown;
395
+ }
396
+ /** Something a monitor noticed. */
397
+ interface MonitorEvent {
398
+ id?: string;
399
+ /** When the provider recorded the event. */
400
+ at?: string;
401
+ /** What changed, in the provider's words. */
402
+ summary?: string;
403
+ url?: string;
404
+ /** Structured output, when the monitor was given a schema. */
405
+ output?: unknown;
406
+ citations?: Citation[];
407
+ raw: unknown;
408
+ }
409
+ interface MonitorEvents {
410
+ events: MonitorEvent[];
411
+ /** Pass as `cursor` for the next page. */
412
+ next?: string;
413
+ raw: unknown;
414
+ }
415
+ /** The account's spend and remaining allowance, as the provider reports it. */
416
+ interface AccountUsage {
417
+ /** Credits used in the current period. */
418
+ used?: number;
419
+ /** Credits left in the current period. */
420
+ remaining?: number;
421
+ /** The period's credit allowance. */
422
+ limit?: number;
423
+ /** Usage by endpoint or product, in the provider's own names. */
424
+ breakdown?: Record<string, number>;
425
+ /** ISO time the current period ends. */
426
+ periodEnd?: string;
427
+ raw: unknown;
428
+ }
429
+ interface RequestOptions extends CallOptions {
430
+ /** A JSON body. */
431
+ body?: unknown;
432
+ /** A multipart body, sent as is. */
433
+ form?: FormData;
434
+ query?: Record<string, string | number | boolean | undefined>;
435
+ }
436
+ /**
437
+ * The provider's HTTP API with authentication applied: the escape hatch for
438
+ * anything Fieldwork does not wrap. Paths are relative to the provider's base
439
+ * URL, so `raw.request("GET", "/usage")` calls the provider directly.
440
+ */
441
+ interface RawClient {
442
+ readonly provider: string;
443
+ readonly baseUrl: string;
444
+ request<T = unknown>(method: string, path: string, options?: RequestOptions): Promise<T>;
445
+ }
446
+ type Method = (...args: never[]) => Promise<unknown>;
447
+ /**
448
+ * The methods an adapter implements, keyed by capability. Most capabilities
449
+ * are one method; `monitor` and `browser` are a group of methods.
450
+ */
451
+ type Operations = Partial<Record<Capability, Method | Readonly<Record<string, Method>>>>;
452
+ /**
453
+ * A provider bound to its credentials. `operations` holds only the
454
+ * capabilities the provider offers, each typed with that provider's options,
455
+ * so a capability or option the provider lacks cannot be called.
456
+ */
457
+ interface Adapter<Name extends string = string, Ops extends Operations = Operations, Raw = RawClient> {
458
+ readonly name: Name;
459
+ readonly operations: Ops;
460
+ /** The provider's HTTP API, for anything Fieldwork does not wrap. */
461
+ readonly raw: Raw;
462
+ /**
463
+ * The provider behind each capability, when it is not `name`. Only a router
464
+ * sets this.
465
+ */
466
+ readonly providers?: Partial<Record<Capability, string>>;
467
+ }
468
+ type AnyAdapter = Adapter<string, any, unknown>;
469
+ declare const defineAdapter: <Name extends string, Ops extends Operations, Raw = RawClient>(adapter: Adapter<Name, Ops, Raw>) => Adapter<Name, Ops, Raw>;
470
+ export { JsonSchema as A, Price as B, Entity as C, GROUP_CAPABILITIES as D, FieldSource as E, MonitorSchedule as F, Research as G, ProductImage as H, Page as I, SearchResult as J, RunStatus as K, PageBatch as L, MonitorEvent as M, MonitorEvents as N, ImageResult as O, MonitorInfo as P, ParsedDocument as R, DocumentPage as S, FailedUrl as T, ProductVariant as U, Product as V, Recency as W, SiteMap as X, SiteLink as Y, Usage as Z, DecisionAnswer as _, RawClient as a, Discovery as b, ActResult as c, CAPABILITIES as d, CallOptions as f, Crawl as g, Condition as h, defineAdapter as i, Meta as j, ImageSearch as k, Answer as l, Citation as m, AnyAdapter as n, RequestOptions as o, Capability as p, SearchResponse as q, Operations as r, AccountUsage as s, Adapter as t, BrowserSession as u, DecisionQuestion as v, Extraction as w, DocumentInput as x, Decisions as y, Place as z };
@@ -0,0 +1,164 @@
1
+ import { W as Recency, a as RawClient, f as CallOptions, k as ImageSearch, l as Answer, q as SearchResponse, t as Adapter } from "./adapter-DGehHCMo.js";
2
+ interface BraveConfig {
3
+ /** Defaults to the BRAVE_API_KEY environment variable. */
4
+ apiKey?: string;
5
+ /** Defaults to https://api.search.brave.com/res/v1. */
6
+ baseUrl?: string;
7
+ fetch?: typeof fetch;
8
+ }
9
+ type BraveSafeSearch = "off" | "moderate" | "strict";
10
+ /** Brave's named freshness windows start at a day; it has no hour window. */
11
+ type BraveRecency = Exclude<Recency, "hour">;
12
+ /** Options every Brave search shares, whichever endpoint serves it. */
13
+ interface BraveSearchBase extends CallOptions {
14
+ /**
15
+ * Results to return. Web search allows 1 to 20 (web results only), news and
16
+ * video search 1 to 50, content search 1 to 50. Brave may return fewer.
17
+ */
18
+ limit?: number;
19
+ /** ISO 3166-1 alpha-2 code such as "GB", or "ALL" for worldwide. */
20
+ country?: string;
21
+ /** Content language such as "en", "en-gb", "zh-hans" or "pt-br". */
22
+ language?: string;
23
+ /** Pages from the last day, 7 days, 31 days or 365 days. */
24
+ recency?: BraveRecency;
25
+ /**
26
+ * YYYY-MM-DD. Brave's date range needs both ends: without `publishedBefore`
27
+ * the range ends today. Not combinable with `recency`.
28
+ */
29
+ publishedAfter?: string;
30
+ /** YYYY-MM-DD. Needs `publishedAfter`. Not combinable with `recency`. */
31
+ publishedBefore?: string;
32
+ /** Web and news default to "moderate"; Brave's news default is "strict". */
33
+ safesearch?: BraveSafeSearch;
34
+ }
35
+ /** Result types web search can return besides web results. */
36
+ type BraveResultType = "web" | "news" | "videos" | "discussions" | "locations";
37
+ /** `/web/search`: web results, plus news, videos, discussions and locations. */
38
+ interface BraveWebSearchOptions extends BraveSearchBase {
39
+ vertical?: "web";
40
+ content?: false;
41
+ maxTokens?: never;
42
+ maxTokensPerUrl?: never;
43
+ relevance?: never;
44
+ sourceMetadata?: never;
45
+ /**
46
+ * The page of results, counting from 0 (Brave allows 0 to 9). It counts pages
47
+ * of `limit` results, and pages can overlap.
48
+ */
49
+ offset?: number;
50
+ /** Keep only these result types. Brave returns every type the plan has when unset. */
51
+ resultTypes?: BraveResultType[];
52
+ /**
53
+ * Add up to 5 more excerpts from each result to `snippet`, after the
54
+ * description.
55
+ */
56
+ extraSnippets?: boolean;
57
+ /** Search the spell-corrected query (Brave's default). */
58
+ spellcheck?: boolean;
59
+ /** Language of response metadata, such as "en-US". */
60
+ uiLanguage?: string;
61
+ units?: "metric" | "imperial";
62
+ /** Apply search operators such as `site:` in the query (Brave's default). */
63
+ operators?: boolean;
64
+ /** A Goggle URL or inline rules, up to 3. Re-ranks the results. */
65
+ goggles?: string | string[];
66
+ /** Keep Brave's highlight markers in snippets. Fieldwork asks for none. */
67
+ textDecorations?: boolean;
68
+ }
69
+ /** `/news/search`. */
70
+ interface BraveNewsSearchOptions extends BraveSearchBase {
71
+ vertical: "news";
72
+ content?: false;
73
+ resultTypes?: never;
74
+ units?: never;
75
+ textDecorations?: never;
76
+ maxTokens?: never;
77
+ maxTokensPerUrl?: never;
78
+ relevance?: never;
79
+ sourceMetadata?: never;
80
+ offset?: number;
81
+ extraSnippets?: boolean;
82
+ spellcheck?: boolean;
83
+ uiLanguage?: string;
84
+ operators?: boolean;
85
+ goggles?: string | string[];
86
+ }
87
+ /** `/videos/search`. */
88
+ interface BraveVideoSearchOptions extends BraveSearchBase {
89
+ vertical: "videos";
90
+ content?: false;
91
+ resultTypes?: never;
92
+ extraSnippets?: never;
93
+ units?: never;
94
+ textDecorations?: never;
95
+ goggles?: never;
96
+ maxTokens?: never;
97
+ maxTokensPerUrl?: never;
98
+ relevance?: never;
99
+ sourceMetadata?: never;
100
+ offset?: number;
101
+ spellcheck?: boolean;
102
+ uiLanguage?: string;
103
+ operators?: boolean;
104
+ }
105
+ /**
106
+ * `/llm/context`: Brave fetches each result and returns the passages of its
107
+ * text that fit the query, as `content`.
108
+ */
109
+ interface BraveContentSearchOptions extends BraveSearchBase {
110
+ content: true;
111
+ vertical?: never;
112
+ offset?: never;
113
+ resultTypes?: never;
114
+ extraSnippets?: never;
115
+ spellcheck?: never;
116
+ uiLanguage?: never;
117
+ units?: never;
118
+ textDecorations?: never;
119
+ /** Total token budget for all passages, 1024 to 32768 (Brave's default is 8192). */
120
+ maxTokens?: number;
121
+ /** Token cap for one page's passages, 512 to 8192 (default 4096). */
122
+ maxTokensPerUrl?: number;
123
+ /** How strictly passages must match the query. */
124
+ relevance?: "strict" | "balanced" | "lenient" | "disabled";
125
+ /** Return the site name, favicon, thumbnail and description of each source. */
126
+ sourceMetadata?: boolean;
127
+ operators?: boolean;
128
+ goggles?: string | string[];
129
+ }
130
+ type BraveSearchOptions = BraveWebSearchOptions | BraveNewsSearchOptions | BraveVideoSearchOptions | BraveContentSearchOptions;
131
+ interface BraveImageOptions extends CallOptions {
132
+ /** Images to return, 1 to 200 (Brave's default is 50). Brave has no paging. */
133
+ limit?: number;
134
+ country?: string;
135
+ language?: string;
136
+ /** "strict" removes all adult content; "off" removes only illegal content. */
137
+ safesearch?: "off" | "strict";
138
+ spellcheck?: boolean;
139
+ }
140
+ interface BraveAnswerOptions extends CallOptions {
141
+ /** Brave's answer model; "brave-pro" is its default. */
142
+ model?: "brave" | "brave-pro";
143
+ country?: string;
144
+ language?: string;
145
+ safesearch?: BraveSafeSearch;
146
+ /** Caps the answer's length in tokens. */
147
+ maxTokens?: number;
148
+ /** How much search material Brave puts behind the answer. */
149
+ searchContextSize?: "low" | "medium" | "high";
150
+ /** Where the asker is, to answer local questions. */
151
+ userLocation?: {
152
+ city?: string;
153
+ region?: string;
154
+ country?: string;
155
+ timezone?: string;
156
+ };
157
+ }
158
+ interface BraveOperations {
159
+ search(query: string, options?: BraveSearchOptions): Promise<SearchResponse>;
160
+ images(query: string, options?: BraveImageOptions): Promise<ImageSearch>;
161
+ answer(question: string, options?: BraveAnswerOptions): Promise<Answer<unknown>>;
162
+ }
163
+ export declare const brave: (config?: BraveConfig) => Adapter<"brave", BraveOperations, RawClient>;
164
+ export type { BraveAnswerOptions, BraveConfig, BraveContentSearchOptions, BraveImageOptions, BraveNewsSearchOptions, BraveOperations, BraveRecency, BraveResultType, BraveSafeSearch, BraveSearchOptions, BraveVideoSearchOptions, BraveWebSearchOptions };