@mastra/tavily 1.1.1 → 1.1.2-alpha.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/LICENSE.md CHANGED
@@ -1,10 +1,12 @@
1
1
  Portions of this software are licensed as follows:
2
2
 
3
- - All content that resides under any directory named "ee/" within this
3
+ - All content that resides under any directory named `ee/` within this
4
4
  repository, including but not limited to:
5
- - `packages/core/src/auth/ee/`
6
- - `packages/server/src/server/auth/ee/`
7
- is licensed under the license defined in `ee/LICENSE`.
5
+ - `@mastra/core/auth/ee`
6
+ - `@mastra/core/agent-builder/ee`
7
+ - `@mastra/editor/ee`
8
+
9
+ is licensed under the license defined in [`ee/LICENSE`](https://github.com/mastra-ai/mastra/blob/main/ee/LICENSE).
8
10
 
9
11
  - All third-party components incorporated into the Mastra Software are
10
12
  licensed under the original license provided by the owner of the
package/dist/crawl.d.ts CHANGED
@@ -10,7 +10,7 @@ export declare function createTavilyCrawlTool(config?: TavilyClientOptions): imp
10
10
  excludePaths?: string[] | undefined;
11
11
  excludeDomains?: string[] | undefined;
12
12
  allowExternal?: boolean | undefined;
13
- extractDepth?: "basic" | "advanced" | undefined;
13
+ extractDepth?: "advanced" | "basic" | undefined;
14
14
  includeImages?: boolean | undefined;
15
15
  format?: "markdown" | "text" | undefined;
16
16
  }, {
package/dist/extract.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { TavilyClientOptions } from './client.js';
2
2
  export declare function createTavilyExtractTool(config?: TavilyClientOptions): import("@mastra/core/tools").Tool<{
3
3
  urls: string[];
4
- extractDepth?: "basic" | "advanced" | undefined;
4
+ extractDepth?: "advanced" | "basic" | undefined;
5
5
  query?: string | undefined;
6
6
  includeImages?: boolean | undefined;
7
7
  format?: "markdown" | "text" | undefined;
package/dist/index.cjs CHANGED
@@ -1,287 +1,283 @@
1
- 'use strict';
2
-
3
- var core = require('@tavily/core');
4
- var tools = require('@mastra/core/tools');
5
- var zod = require('zod');
6
-
7
- // src/client.ts
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _tavily_core = require("@tavily/core");
3
+ let _mastra_core_tools = require("@mastra/core/tools");
4
+ let zod = require("zod");
5
+ //#region src/client.ts
8
6
  function getTavilyClient(config) {
9
- const apiKey = config?.apiKey ?? process.env.TAVILY_API_KEY;
10
- if (!apiKey) {
11
- throw new Error("Tavily API key is required. Pass { apiKey } or set TAVILY_API_KEY env var.");
12
- }
13
- return core.tavily({ ...config, apiKey, clientName: config?.clientName ?? "mastra" });
7
+ const apiKey = config?.apiKey ?? process.env.TAVILY_API_KEY;
8
+ if (!apiKey) throw new Error("Tavily API key is required. Pass { apiKey } or set TAVILY_API_KEY env var.");
9
+ return (0, _tavily_core.tavily)({
10
+ ...config,
11
+ apiKey,
12
+ clientName: config?.clientName ?? "mastra"
13
+ });
14
14
  }
15
- var inputSchema = zod.z.object({
16
- query: zod.z.string().describe("The search query"),
17
- searchDepth: zod.z.enum(["basic", "advanced", "fast", "ultra-fast"]).optional().describe("Search depth \u2014 'basic' for standard, 'advanced' for thorough, 'fast'/'ultra-fast' for low latency"),
18
- maxResults: zod.z.number().min(1).max(20).optional().describe("Maximum number of results to return (1-20)"),
19
- includeAnswer: zod.z.union([zod.z.boolean(), zod.z.enum(["basic", "advanced"])]).optional().describe('Include an AI-generated answer summary. Pass true, "basic", or "advanced"'),
20
- includeImages: zod.z.boolean().optional().describe("Include query-related images in the response"),
21
- includeImageDescriptions: zod.z.boolean().optional().describe("Include descriptions for returned images"),
22
- includeRawContent: zod.z.union([zod.z.literal(false), zod.z.enum(["markdown", "text"])]).optional().describe('Include cleaned HTML content of each result. Pass false to disable, or "markdown"/"text" for format'),
23
- includeDomains: zod.z.array(zod.z.string()).optional().describe("Restrict results to these domains"),
24
- excludeDomains: zod.z.array(zod.z.string()).optional().describe("Exclude results from these domains"),
25
- timeRange: zod.z.enum(["day", "week", "month", "year"]).optional().describe("Time range to filter results by recency")
15
+ //#endregion
16
+ //#region src/search.ts
17
+ const inputSchema$3 = zod.z.object({
18
+ query: zod.z.string().describe("The search query"),
19
+ searchDepth: zod.z.enum([
20
+ "basic",
21
+ "advanced",
22
+ "fast",
23
+ "ultra-fast"
24
+ ]).optional().describe("Search depth 'basic' for standard, 'advanced' for thorough, 'fast'/'ultra-fast' for low latency"),
25
+ maxResults: zod.z.number().min(1).max(20).optional().describe("Maximum number of results to return (1-20)"),
26
+ includeAnswer: zod.z.union([zod.z.boolean(), zod.z.enum(["basic", "advanced"])]).optional().describe("Include an AI-generated answer summary. Pass true, \"basic\", or \"advanced\""),
27
+ includeImages: zod.z.boolean().optional().describe("Include query-related images in the response"),
28
+ includeImageDescriptions: zod.z.boolean().optional().describe("Include descriptions for returned images"),
29
+ includeRawContent: zod.z.union([zod.z.literal(false), zod.z.enum(["markdown", "text"])]).optional().describe("Include cleaned HTML content of each result. Pass false to disable, or \"markdown\"/\"text\" for format"),
30
+ includeDomains: zod.z.array(zod.z.string()).optional().describe("Restrict results to these domains"),
31
+ excludeDomains: zod.z.array(zod.z.string()).optional().describe("Exclude results from these domains"),
32
+ timeRange: zod.z.enum([
33
+ "day",
34
+ "week",
35
+ "month",
36
+ "year"
37
+ ]).optional().describe("Time range to filter results by recency")
26
38
  });
27
- var outputSchema = zod.z.object({
28
- query: zod.z.string(),
29
- answer: zod.z.string().optional(),
30
- images: zod.z.array(
31
- zod.z.object({
32
- url: zod.z.string(),
33
- description: zod.z.string().optional()
34
- })
35
- ).optional(),
36
- results: zod.z.array(
37
- zod.z.object({
38
- title: zod.z.string(),
39
- url: zod.z.string(),
40
- content: zod.z.string(),
41
- score: zod.z.number(),
42
- rawContent: zod.z.string().optional()
43
- })
44
- ),
45
- responseTime: zod.z.number()
39
+ const outputSchema$3 = zod.z.object({
40
+ query: zod.z.string(),
41
+ answer: zod.z.string().optional(),
42
+ images: zod.z.array(zod.z.object({
43
+ url: zod.z.string(),
44
+ description: zod.z.string().optional()
45
+ })).optional(),
46
+ results: zod.z.array(zod.z.object({
47
+ title: zod.z.string(),
48
+ url: zod.z.string(),
49
+ content: zod.z.string(),
50
+ score: zod.z.number(),
51
+ rawContent: zod.z.string().optional()
52
+ })),
53
+ responseTime: zod.z.number()
46
54
  });
47
55
  function createTavilySearchTool(config) {
48
- let client = null;
49
- function getClient() {
50
- if (!client) {
51
- client = getTavilyClient(config);
52
- }
53
- return client;
54
- }
55
- return tools.createTool({
56
- id: "tavily-search",
57
- description: "Search the web using Tavily. Returns relevant results with content snippets, optional AI-generated answers, and images. Supports filtering by domain, time range, and search depth.",
58
- inputSchema,
59
- outputSchema,
60
- execute: async (input) => {
61
- const tavilyClient = getClient();
62
- const response = await tavilyClient.search(input.query, {
63
- searchDepth: input.searchDepth,
64
- maxResults: input.maxResults,
65
- includeAnswer: input.includeAnswer,
66
- includeImages: input.includeImages,
67
- includeImageDescriptions: input.includeImageDescriptions,
68
- includeRawContent: input.includeRawContent,
69
- includeDomains: input.includeDomains,
70
- excludeDomains: input.excludeDomains,
71
- timeRange: input.timeRange
72
- });
73
- return {
74
- query: response.query,
75
- answer: response.answer || void 0,
76
- images: response.images?.map((img) => ({
77
- url: typeof img === "string" ? img : img.url,
78
- description: typeof img === "string" ? void 0 : img.description
79
- })),
80
- results: (response.results ?? []).map((r) => ({
81
- title: r.title,
82
- url: r.url,
83
- content: r.content,
84
- score: r.score ?? 0,
85
- rawContent: r.rawContent || void 0
86
- })),
87
- responseTime: response.responseTime
88
- };
89
- }
90
- });
56
+ let client = null;
57
+ function getClient() {
58
+ if (!client) client = getTavilyClient(config);
59
+ return client;
60
+ }
61
+ return (0, _mastra_core_tools.createTool)({
62
+ id: "tavily-search",
63
+ description: "Search the web using Tavily. Returns relevant results with content snippets, optional AI-generated answers, and images. Supports filtering by domain, time range, and search depth.",
64
+ inputSchema: inputSchema$3,
65
+ outputSchema: outputSchema$3,
66
+ execute: async (input) => {
67
+ const response = await getClient().search(input.query, {
68
+ searchDepth: input.searchDepth,
69
+ maxResults: input.maxResults,
70
+ includeAnswer: input.includeAnswer,
71
+ includeImages: input.includeImages,
72
+ includeImageDescriptions: input.includeImageDescriptions,
73
+ includeRawContent: input.includeRawContent,
74
+ includeDomains: input.includeDomains,
75
+ excludeDomains: input.excludeDomains,
76
+ timeRange: input.timeRange
77
+ });
78
+ return {
79
+ query: response.query,
80
+ answer: response.answer || void 0,
81
+ images: response.images?.map((img) => ({
82
+ url: typeof img === "string" ? img : img.url,
83
+ description: typeof img === "string" ? void 0 : img.description
84
+ })),
85
+ results: (response.results ?? []).map((r) => ({
86
+ title: r.title,
87
+ url: r.url,
88
+ content: r.content,
89
+ score: r.score ?? 0,
90
+ rawContent: r.rawContent || void 0
91
+ })),
92
+ responseTime: response.responseTime
93
+ };
94
+ }
95
+ });
91
96
  }
92
- var inputSchema2 = zod.z.object({
93
- urls: zod.z.array(zod.z.string()).min(1).max(20).describe("URLs to extract content from (1-20)"),
94
- extractDepth: zod.z.enum(["basic", "advanced"]).optional().describe("Extraction depth \u2014 'advanced' retrieves more data including tables and embedded content"),
95
- query: zod.z.string().optional().describe("User intent for reranking extracted content chunks. When provided, chunks are reranked based on relevance to this query."),
96
- includeImages: zod.z.boolean().optional().describe("Include images extracted from the pages"),
97
- format: zod.z.enum(["markdown", "text"]).optional().describe("Output format for extracted content \u2014 'markdown' (default) or 'text'")
97
+ //#endregion
98
+ //#region src/extract.ts
99
+ const inputSchema$2 = zod.z.object({
100
+ urls: zod.z.array(zod.z.string()).min(1).max(20).describe("URLs to extract content from (1-20)"),
101
+ extractDepth: zod.z.enum(["basic", "advanced"]).optional().describe("Extraction depth 'advanced' retrieves more data including tables and embedded content"),
102
+ query: zod.z.string().optional().describe("User intent for reranking extracted content chunks. When provided, chunks are reranked based on relevance to this query."),
103
+ includeImages: zod.z.boolean().optional().describe("Include images extracted from the pages"),
104
+ format: zod.z.enum(["markdown", "text"]).optional().describe("Output format for extracted content — 'markdown' (default) or 'text'")
98
105
  });
99
- var outputSchema2 = zod.z.object({
100
- results: zod.z.array(
101
- zod.z.object({
102
- url: zod.z.string(),
103
- rawContent: zod.z.string(),
104
- images: zod.z.array(zod.z.string()).optional()
105
- })
106
- ),
107
- failedResults: zod.z.array(
108
- zod.z.object({
109
- url: zod.z.string(),
110
- error: zod.z.string()
111
- })
112
- ),
113
- responseTime: zod.z.number()
106
+ const outputSchema$2 = zod.z.object({
107
+ results: zod.z.array(zod.z.object({
108
+ url: zod.z.string(),
109
+ rawContent: zod.z.string(),
110
+ images: zod.z.array(zod.z.string()).optional()
111
+ })),
112
+ failedResults: zod.z.array(zod.z.object({
113
+ url: zod.z.string(),
114
+ error: zod.z.string()
115
+ })),
116
+ responseTime: zod.z.number()
114
117
  });
115
118
  function createTavilyExtractTool(config) {
116
- let client = null;
117
- function getClient() {
118
- if (!client) {
119
- client = getTavilyClient(config);
120
- }
121
- return client;
122
- }
123
- return tools.createTool({
124
- id: "tavily-extract",
125
- description: "Extract content from one or more URLs using Tavily. Returns raw page content in markdown or text format. Supports up to 20 URLs per request with basic or advanced extraction depth.",
126
- inputSchema: inputSchema2,
127
- outputSchema: outputSchema2,
128
- execute: async (input) => {
129
- const tavilyClient = getClient();
130
- const response = await tavilyClient.extract(input.urls, {
131
- extractDepth: input.extractDepth,
132
- query: input.query,
133
- includeImages: input.includeImages,
134
- format: input.format
135
- });
136
- return {
137
- results: (response.results || []).map((r) => ({
138
- url: r.url,
139
- rawContent: r.rawContent,
140
- images: r.images || void 0
141
- })),
142
- failedResults: (response.failedResults || []).map((r) => ({
143
- url: r.url,
144
- error: r.error
145
- })),
146
- responseTime: response.responseTime
147
- };
148
- }
149
- });
119
+ let client = null;
120
+ function getClient() {
121
+ if (!client) client = getTavilyClient(config);
122
+ return client;
123
+ }
124
+ return (0, _mastra_core_tools.createTool)({
125
+ id: "tavily-extract",
126
+ description: "Extract content from one or more URLs using Tavily. Returns raw page content in markdown or text format. Supports up to 20 URLs per request with basic or advanced extraction depth.",
127
+ inputSchema: inputSchema$2,
128
+ outputSchema: outputSchema$2,
129
+ execute: async (input) => {
130
+ const response = await getClient().extract(input.urls, {
131
+ extractDepth: input.extractDepth,
132
+ query: input.query,
133
+ includeImages: input.includeImages,
134
+ format: input.format
135
+ });
136
+ return {
137
+ results: (response.results || []).map((r) => ({
138
+ url: r.url,
139
+ rawContent: r.rawContent,
140
+ images: r.images || void 0
141
+ })),
142
+ failedResults: (response.failedResults || []).map((r) => ({
143
+ url: r.url,
144
+ error: r.error
145
+ })),
146
+ responseTime: response.responseTime
147
+ };
148
+ }
149
+ });
150
150
  }
151
- var inputSchema3 = zod.z.object({
152
- url: zod.z.string().describe("The root URL to begin the crawl"),
153
- maxDepth: zod.z.number().optional().describe("Max depth of the crawl from the base URL"),
154
- maxBreadth: zod.z.number().optional().describe("Max number of links to follow per page"),
155
- limit: zod.z.number().optional().describe("Total number of pages the crawler will process before stopping"),
156
- instructions: zod.z.string().optional().describe("Natural language instructions for the crawler"),
157
- selectPaths: zod.z.array(zod.z.string()).optional().describe("Regex patterns to select specific URL paths"),
158
- selectDomains: zod.z.array(zod.z.string()).optional().describe("Regex patterns to restrict to specific domains"),
159
- excludePaths: zod.z.array(zod.z.string()).optional().describe("Regex patterns to exclude specific URL paths"),
160
- excludeDomains: zod.z.array(zod.z.string()).optional().describe("Regex patterns to exclude specific domains"),
161
- allowExternal: zod.z.boolean().optional().describe("Whether to follow links to external domains"),
162
- extractDepth: zod.z.enum(["basic", "advanced"]).optional().describe("Extraction depth \u2014 'advanced' retrieves more data including tables and embedded content"),
163
- includeImages: zod.z.boolean().optional().describe("Include images from crawled pages"),
164
- format: zod.z.enum(["markdown", "text"]).optional().describe("Output format for extracted content \u2014 'markdown' (default) or 'text'")
151
+ //#endregion
152
+ //#region src/crawl.ts
153
+ const inputSchema$1 = zod.z.object({
154
+ url: zod.z.string().describe("The root URL to begin the crawl"),
155
+ maxDepth: zod.z.number().optional().describe("Max depth of the crawl from the base URL"),
156
+ maxBreadth: zod.z.number().optional().describe("Max number of links to follow per page"),
157
+ limit: zod.z.number().optional().describe("Total number of pages the crawler will process before stopping"),
158
+ instructions: zod.z.string().optional().describe("Natural language instructions for the crawler"),
159
+ selectPaths: zod.z.array(zod.z.string()).optional().describe("Regex patterns to select specific URL paths"),
160
+ selectDomains: zod.z.array(zod.z.string()).optional().describe("Regex patterns to restrict to specific domains"),
161
+ excludePaths: zod.z.array(zod.z.string()).optional().describe("Regex patterns to exclude specific URL paths"),
162
+ excludeDomains: zod.z.array(zod.z.string()).optional().describe("Regex patterns to exclude specific domains"),
163
+ allowExternal: zod.z.boolean().optional().describe("Whether to follow links to external domains"),
164
+ extractDepth: zod.z.enum(["basic", "advanced"]).optional().describe("Extraction depth 'advanced' retrieves more data including tables and embedded content"),
165
+ includeImages: zod.z.boolean().optional().describe("Include images from crawled pages"),
166
+ format: zod.z.enum(["markdown", "text"]).optional().describe("Output format for extracted content — 'markdown' (default) or 'text'")
165
167
  });
166
- var outputSchema3 = zod.z.object({
167
- baseUrl: zod.z.string(),
168
- results: zod.z.array(
169
- zod.z.object({
170
- url: zod.z.string(),
171
- rawContent: zod.z.string(),
172
- images: zod.z.array(zod.z.string()).optional()
173
- })
174
- ),
175
- responseTime: zod.z.number()
168
+ const outputSchema$1 = zod.z.object({
169
+ baseUrl: zod.z.string(),
170
+ results: zod.z.array(zod.z.object({
171
+ url: zod.z.string(),
172
+ rawContent: zod.z.string(),
173
+ images: zod.z.array(zod.z.string()).optional()
174
+ })),
175
+ responseTime: zod.z.number()
176
176
  });
177
177
  function createTavilyCrawlTool(config) {
178
- let client = null;
179
- function getClient() {
180
- if (!client) {
181
- client = getTavilyClient(config);
182
- }
183
- return client;
184
- }
185
- return tools.createTool({
186
- id: "tavily-crawl",
187
- description: "Crawl a website starting from a URL using Tavily. Extracts content from discovered pages with configurable depth, breadth, and domain constraints. Returns structured content from each crawled page.",
188
- inputSchema: inputSchema3,
189
- outputSchema: outputSchema3,
190
- execute: async (input) => {
191
- const tavilyClient = getClient();
192
- const response = await tavilyClient.crawl(input.url, {
193
- maxDepth: input.maxDepth,
194
- maxBreadth: input.maxBreadth,
195
- limit: input.limit,
196
- instructions: input.instructions,
197
- selectPaths: input.selectPaths,
198
- selectDomains: input.selectDomains,
199
- excludePaths: input.excludePaths,
200
- excludeDomains: input.excludeDomains,
201
- allowExternal: input.allowExternal,
202
- extractDepth: input.extractDepth,
203
- includeImages: input.includeImages,
204
- format: input.format
205
- });
206
- return {
207
- baseUrl: response.baseUrl,
208
- results: (response.results || []).map((r) => ({
209
- url: r.url,
210
- rawContent: r.rawContent,
211
- images: r.images || void 0
212
- })),
213
- responseTime: response.responseTime
214
- };
215
- }
216
- });
178
+ let client = null;
179
+ function getClient() {
180
+ if (!client) client = getTavilyClient(config);
181
+ return client;
182
+ }
183
+ return (0, _mastra_core_tools.createTool)({
184
+ id: "tavily-crawl",
185
+ description: "Crawl a website starting from a URL using Tavily. Extracts content from discovered pages with configurable depth, breadth, and domain constraints. Returns structured content from each crawled page.",
186
+ inputSchema: inputSchema$1,
187
+ outputSchema: outputSchema$1,
188
+ execute: async (input) => {
189
+ const response = await getClient().crawl(input.url, {
190
+ maxDepth: input.maxDepth,
191
+ maxBreadth: input.maxBreadth,
192
+ limit: input.limit,
193
+ instructions: input.instructions,
194
+ selectPaths: input.selectPaths,
195
+ selectDomains: input.selectDomains,
196
+ excludePaths: input.excludePaths,
197
+ excludeDomains: input.excludeDomains,
198
+ allowExternal: input.allowExternal,
199
+ extractDepth: input.extractDepth,
200
+ includeImages: input.includeImages,
201
+ format: input.format
202
+ });
203
+ return {
204
+ baseUrl: response.baseUrl,
205
+ results: (response.results || []).map((r) => ({
206
+ url: r.url,
207
+ rawContent: r.rawContent,
208
+ images: r.images || void 0
209
+ })),
210
+ responseTime: response.responseTime
211
+ };
212
+ }
213
+ });
217
214
  }
218
- var inputSchema4 = zod.z.object({
219
- url: zod.z.string().describe("The root URL to begin mapping"),
220
- maxDepth: zod.z.number().optional().describe("Max depth of the mapping from the base URL"),
221
- maxBreadth: zod.z.number().optional().describe("Max number of links to follow per page"),
222
- limit: zod.z.number().optional().describe("Total number of links the mapper will process before stopping"),
223
- instructions: zod.z.string().optional().describe("Natural language instructions for the mapper"),
224
- selectPaths: zod.z.array(zod.z.string()).optional().describe("Regex patterns to select specific URL paths"),
225
- selectDomains: zod.z.array(zod.z.string()).optional().describe("Regex patterns to restrict to specific domains"),
226
- excludePaths: zod.z.array(zod.z.string()).optional().describe("Regex patterns to exclude specific URL paths"),
227
- excludeDomains: zod.z.array(zod.z.string()).optional().describe("Regex patterns to exclude specific domains"),
228
- allowExternal: zod.z.boolean().optional().describe("Whether to include external domain links")
215
+ //#endregion
216
+ //#region src/map.ts
217
+ const inputSchema = zod.z.object({
218
+ url: zod.z.string().describe("The root URL to begin mapping"),
219
+ maxDepth: zod.z.number().optional().describe("Max depth of the mapping from the base URL"),
220
+ maxBreadth: zod.z.number().optional().describe("Max number of links to follow per page"),
221
+ limit: zod.z.number().optional().describe("Total number of links the mapper will process before stopping"),
222
+ instructions: zod.z.string().optional().describe("Natural language instructions for the mapper"),
223
+ selectPaths: zod.z.array(zod.z.string()).optional().describe("Regex patterns to select specific URL paths"),
224
+ selectDomains: zod.z.array(zod.z.string()).optional().describe("Regex patterns to restrict to specific domains"),
225
+ excludePaths: zod.z.array(zod.z.string()).optional().describe("Regex patterns to exclude specific URL paths"),
226
+ excludeDomains: zod.z.array(zod.z.string()).optional().describe("Regex patterns to exclude specific domains"),
227
+ allowExternal: zod.z.boolean().optional().describe("Whether to include external domain links")
229
228
  });
230
- var outputSchema4 = zod.z.object({
231
- baseUrl: zod.z.string(),
232
- results: zod.z.array(zod.z.string()).describe("Discovered URLs"),
233
- responseTime: zod.z.number()
229
+ const outputSchema = zod.z.object({
230
+ baseUrl: zod.z.string(),
231
+ results: zod.z.array(zod.z.string()).describe("Discovered URLs"),
232
+ responseTime: zod.z.number()
234
233
  });
235
234
  function createTavilyMapTool(config) {
236
- let client = null;
237
- function getClient() {
238
- if (!client) {
239
- client = getTavilyClient(config);
240
- }
241
- return client;
242
- }
243
- return tools.createTool({
244
- id: "tavily-map",
245
- description: "Map a website's structure starting from a URL using Tavily. Discovers and returns a list of URLs found on the site without extracting page content. Useful for understanding site structure before targeted extraction.",
246
- inputSchema: inputSchema4,
247
- outputSchema: outputSchema4,
248
- execute: async (input) => {
249
- const tavilyClient = getClient();
250
- const response = await tavilyClient.map(input.url, {
251
- maxDepth: input.maxDepth,
252
- maxBreadth: input.maxBreadth,
253
- limit: input.limit,
254
- instructions: input.instructions,
255
- selectPaths: input.selectPaths,
256
- selectDomains: input.selectDomains,
257
- excludePaths: input.excludePaths,
258
- excludeDomains: input.excludeDomains,
259
- allowExternal: input.allowExternal
260
- });
261
- return {
262
- baseUrl: response.baseUrl,
263
- results: response.results || [],
264
- responseTime: response.responseTime
265
- };
266
- }
267
- });
235
+ let client = null;
236
+ function getClient() {
237
+ if (!client) client = getTavilyClient(config);
238
+ return client;
239
+ }
240
+ return (0, _mastra_core_tools.createTool)({
241
+ id: "tavily-map",
242
+ description: "Map a website's structure starting from a URL using Tavily. Discovers and returns a list of URLs found on the site without extracting page content. Useful for understanding site structure before targeted extraction.",
243
+ inputSchema,
244
+ outputSchema,
245
+ execute: async (input) => {
246
+ const response = await getClient().map(input.url, {
247
+ maxDepth: input.maxDepth,
248
+ maxBreadth: input.maxBreadth,
249
+ limit: input.limit,
250
+ instructions: input.instructions,
251
+ selectPaths: input.selectPaths,
252
+ selectDomains: input.selectDomains,
253
+ excludePaths: input.excludePaths,
254
+ excludeDomains: input.excludeDomains,
255
+ allowExternal: input.allowExternal
256
+ });
257
+ return {
258
+ baseUrl: response.baseUrl,
259
+ results: response.results || [],
260
+ responseTime: response.responseTime
261
+ };
262
+ }
263
+ });
268
264
  }
269
-
270
- // src/tools.ts
265
+ //#endregion
266
+ //#region src/tools.ts
271
267
  function createTavilyTools(config) {
272
- return {
273
- tavilySearch: createTavilySearchTool(config),
274
- tavilyExtract: createTavilyExtractTool(config),
275
- tavilyCrawl: createTavilyCrawlTool(config),
276
- tavilyMap: createTavilyMapTool(config)
277
- };
268
+ return {
269
+ tavilySearch: createTavilySearchTool(config),
270
+ tavilyExtract: createTavilyExtractTool(config),
271
+ tavilyCrawl: createTavilyCrawlTool(config),
272
+ tavilyMap: createTavilyMapTool(config)
273
+ };
278
274
  }
279
-
275
+ //#endregion
280
276
  exports.createTavilyCrawlTool = createTavilyCrawlTool;
281
277
  exports.createTavilyExtractTool = createTavilyExtractTool;
282
278
  exports.createTavilyMapTool = createTavilyMapTool;
283
279
  exports.createTavilySearchTool = createTavilySearchTool;
284
280
  exports.createTavilyTools = createTavilyTools;
285
281
  exports.getTavilyClient = getTavilyClient;
286
- //# sourceMappingURL=index.cjs.map
282
+
287
283
  //# sourceMappingURL=index.cjs.map