@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.
package/dist/tavily.d.ts CHANGED
@@ -1,71 +1,140 @@
1
- import { C as SearchResponse, E as SiteMap, S as Research, _ as JsonSchema, a as RawClient, f as Crawl, l as CallOptions, t as Adapter, v as Page } from "./adapter-C_kRm6TT.js";
2
- export interface TavilyConfig {
1
+ import { A as JsonSchema, G as Research, I as Page, L as PageBatch, W as Recency, X as SiteMap, a as RawClient, f as CallOptions, g as Crawl, k as ImageSearch, l as Answer, q as SearchResponse, s as AccountUsage, t as Adapter } from "./adapter-DGehHCMo.js";
2
+ interface TavilyConfig {
3
3
  /** Defaults to the TAVILY_API_KEY environment variable. */
4
4
  apiKey?: string;
5
+ /** Sent as the X-Project-ID header, so Tavily groups usage and logs by project. */
6
+ projectId?: string;
5
7
  baseUrl?: string;
6
8
  fetch?: typeof fetch;
7
9
  }
8
- export interface TavilySearchOptions extends CallOptions {
9
- /** Results to return; Tavily allows up to 20. */
10
+ type TavilySearchDepth = "ultra-fast" | "fast" | "basic" | "advanced";
11
+ interface TavilySearchOptions extends CallOptions {
12
+ /** Results to return; Tavily allows 0 to 20. */
10
13
  limit?: number;
11
- depth?: "ultra-fast" | "fast" | "basic" | "advanced";
14
+ /**
15
+ * `advanced` costs 2 credits and is the most relevant. `ultra-fast` returns
16
+ * one summary per page instead of several passages.
17
+ */
18
+ searchDepth?: TavilySearchDepth;
12
19
  topic?: "general" | "news" | "finance";
13
- timeRange?: "day" | "week" | "month" | "year";
20
+ /** Only results from this far back. Tavily has no `hour` window. */
21
+ recency?: Exclude<Recency, "hour">;
14
22
  /** YYYY-MM-DD. */
15
23
  publishedAfter?: string;
16
24
  /** YYYY-MM-DD. */
17
25
  publishedBefore?: string;
26
+ /**
27
+ * Drop results outside the date window, and results with no detectable date.
28
+ * Without it Tavily keeps undated results when a window is set.
29
+ */
30
+ filterByPublishedDate?: boolean;
31
+ /** Passages to return per page, 1 to 3. Not available with `ultra-fast`. */
32
+ chunksPerSource?: number;
18
33
  includeDomains?: string[];
19
34
  excludeDomains?: string[];
20
35
  /** "restrict" keeps to includeDomains; "prefer" only ranks them higher. */
21
36
  includeDomainsMode?: "restrict" | "prefer";
22
- /** A country name in lower case, such as "united states". */
37
+ /** ISO 3166-1 alpha-2 code such as "GB". Ranks that country higher; general topic only. */
23
38
  country?: string;
24
- /** Add a generated answer above the results. */
25
- answer?: boolean | "basic" | "advanced";
26
- /** Include each result's page text. */
27
- content?: boolean;
39
+ /** ISO 639-1 code. Ranks pages in that language higher. */
40
+ language?: string;
41
+ /** Remove pages that are not in `language`, instead of only ranking them lower. */
42
+ filterByLanguage?: boolean;
43
+ /** Remove adult and unsafe pages. Not available with `fast` or `ultra-fast`. */
44
+ safeSearch?: boolean;
45
+ /** Let Tavily choose parameters from the query; it may switch to `advanced` (2 credits). */
46
+ autoParameters?: boolean;
47
+ /** Only pages containing the quoted phrases in the query. */
28
48
  exactMatch?: boolean;
29
- /** Hours of cache Tavily may use; 0 forces live results. */
30
- maxAgeHours?: number;
49
+ /** Seconds a cached copy may be old; 0 always fetches live, a negative number never does. Tavily counts hours, up to 720. */
50
+ maxAge?: number;
51
+ /** Include each result's page text; `true` means Markdown. */
52
+ content?: boolean | "markdown" | "text";
53
+ /** Return images found for the query in `images`. */
54
+ includeImages?: boolean;
55
+ /** Add a description to each image. Needs `includeImages`. */
56
+ imageDescriptions?: boolean;
57
+ /** Return each result's favicon. */
58
+ favicon?: boolean;
31
59
  }
32
- export interface TavilyReadOptions extends CallOptions {
33
- /** "advanced" handles JavaScript, tables and embedded content. */
34
- depth?: "basic" | "advanced";
35
- /** Return only the passages that answer this query, not the whole page. */
60
+ interface TavilyImagesOptions extends CallOptions {
61
+ searchDepth?: TavilySearchDepth;
62
+ topic?: "general" | "news" | "finance";
63
+ includeDomains?: string[];
64
+ excludeDomains?: string[];
65
+ safeSearch?: boolean;
66
+ /** Describe each image. Defaults to true. */
67
+ descriptions?: boolean;
68
+ }
69
+ interface TavilyAnswerOptions extends Omit<TavilySearchOptions, "content" | "includeImages" | "imageDescriptions" | "favicon"> {
70
+ /** `advanced` writes a more detailed answer. Defaults to `basic`. */
71
+ answerDepth?: "basic" | "advanced";
72
+ }
73
+ interface TavilyExtractOptions extends CallOptions {
74
+ /** `advanced` also reads tables and embedded content, and costs 2 credits per 5 pages. */
75
+ extractDepth?: "basic" | "advanced";
76
+ /** Return only the passages that answer this, as `excerpts`, instead of the whole page. */
36
77
  query?: string;
78
+ /** Passages to return per page, 1 to 5. Needs `query`. */
37
79
  chunksPerSource?: number;
80
+ /** `text` returns plain text, in `markdown`. */
38
81
  format?: "markdown" | "text";
39
82
  includeImages?: boolean;
83
+ favicon?: boolean;
84
+ /** Seconds Tavily waits for the page, 1 to 60. Not the same as `timeout`, which is milliseconds on our side. */
85
+ serverTimeout?: number;
40
86
  }
87
+ type TavilyReadOptions = TavilyExtractOptions;
88
+ type TavilyReadManyOptions = TavilyExtractOptions;
41
89
  interface TavilyTraversal {
42
- /** Plain-words instructions that focus the walk. */
90
+ /** Plain-words instructions that focus the walk. Raises the cost. */
43
91
  instructions?: string;
44
92
  maxDepth?: number;
45
93
  maxBreadth?: number;
94
+ /** Links to process before stopping. */
46
95
  limit?: number;
47
- selectPaths?: string[];
48
- excludePaths?: string[];
49
- selectDomains?: string[];
50
- excludeDomains?: string[];
51
- /** Tavily defaults to true. */
96
+ /** Regular expressions; a URL's path must match one. */
97
+ selectPathPatterns?: string[];
98
+ /** Regular expressions; a URL whose path matches one is skipped. */
99
+ excludePathPatterns?: string[];
100
+ /** Regular expressions such as `^docs\\.example\\.com$`; a URL's host must match one. */
101
+ selectDomainPatterns?: string[];
102
+ /** Regular expressions; a URL whose host matches one is skipped. */
103
+ excludeDomainPatterns?: string[];
104
+ /** Include links to other domains. Tavily defaults to true. */
52
105
  allowExternal?: boolean;
106
+ /** Seconds Tavily works before stopping, 10 to 150. Not the same as `timeout`, which is milliseconds on our side. */
107
+ serverTimeout?: number;
53
108
  }
54
- export interface TavilyMapOptions extends CallOptions, TavilyTraversal {}
55
- export interface TavilyCrawlOptions extends CallOptions, TavilyTraversal {
109
+ interface TavilyMapOptions extends CallOptions, TavilyTraversal {}
110
+ interface TavilyCrawlOptions extends CallOptions, TavilyTraversal {
56
111
  extractDepth?: "basic" | "advanced";
57
112
  format?: "markdown" | "text";
113
+ /** Passages to return per page, 1 to 5. Needs `instructions`. */
114
+ chunksPerSource?: number;
58
115
  includeImages?: boolean;
116
+ favicon?: boolean;
117
+ }
118
+ /** A file the research agent reads as a source and cites. */
119
+ interface TavilyResearchFile {
120
+ /** With an extension of `.txt`, `.md` or `.json`. */
121
+ name: string;
122
+ /** The file's text, or its bytes. Sent base64-encoded. */
123
+ data: string | Uint8Array;
59
124
  }
60
- export interface TavilyResearchOptions extends CallOptions {
61
- /** Tavily accepts object, string, integer, number and array types only. */
125
+ interface TavilyResearchOptions extends CallOptions {
126
+ /** Tavily accepts object, string, integer, number and array types only, and each property needs a description. */
62
127
  schema?: JsonSchema;
63
128
  model?: "mini" | "pro" | "auto";
64
129
  citationFormat?: "numbered" | "mla" | "apa" | "chicago";
65
130
  outputLength?: "short" | "standard" | "long";
66
- /** A preference, not a restriction. */
131
+ /** A preference, not a restriction. Up to 20. */
67
132
  includeDomains?: string[];
133
+ /** Never cited, subdomains included. Up to 20. */
68
134
  excludeDomains?: string[];
135
+ /** Up to 5 files, 80,000 words in all. */
136
+ files?: TavilyResearchFile[];
137
+ /** Milliseconds between checks. */
69
138
  interval?: number;
70
139
  /**
71
140
  * The id of a job that timed out or was cancelled, from the error's
@@ -73,12 +142,16 @@ export interface TavilyResearchOptions extends CallOptions {
73
142
  */
74
143
  resume?: string;
75
144
  }
76
- export interface TavilyOperations {
145
+ interface TavilyOperations {
77
146
  search(query: string, options?: TavilySearchOptions): Promise<SearchResponse>;
147
+ images(query: string, options?: TavilyImagesOptions): Promise<ImageSearch>;
78
148
  read(url: string, options?: TavilyReadOptions): Promise<Page>;
149
+ readMany(urls: string[], options?: TavilyReadManyOptions): Promise<PageBatch>;
79
150
  map(url: string, options?: TavilyMapOptions): Promise<SiteMap>;
80
151
  crawl(url: string, options?: TavilyCrawlOptions): Promise<Crawl>;
152
+ answer(question: string, options?: TavilyAnswerOptions): Promise<Answer<unknown>>;
81
153
  research<T = unknown>(question: string, options?: TavilyResearchOptions): Promise<Research<T>>;
154
+ usage(options?: CallOptions): Promise<AccountUsage>;
82
155
  }
83
- export declare function tavily(config?: TavilyConfig): Adapter<"tavily", TavilyOperations, RawClient>;
84
- export {};
156
+ export declare const tavily: (config?: TavilyConfig) => Adapter<"tavily", TavilyOperations, RawClient>;
157
+ export type { TavilyAnswerOptions, TavilyConfig, TavilyCrawlOptions, TavilyImagesOptions, TavilyMapOptions, TavilyOperations, TavilyReadManyOptions, TavilyReadOptions, TavilyResearchFile, TavilyResearchOptions, TavilySearchDepth, TavilySearchOptions };