@mastra/tavily 0.0.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/CHANGELOG.md +12 -0
- package/README.md +128 -0
- package/dist/client.d.ts +6 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/crawl.d.ts +25 -0
- package/dist/crawl.d.ts.map +1 -0
- package/dist/extract.d.ts +20 -0
- package/dist/extract.d.ts.map +1 -0
- package/dist/index.cjs +287 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +280 -0
- package/dist/index.js.map +1 -0
- package/dist/map.d.ts +18 -0
- package/dist/map.d.ts.map +1 -0
- package/dist/search.d.ts +29 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/tools.d.ts +88 -0
- package/dist/tools.d.ts.map +1 -0
- package/package.json +66 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# @mastra/tavily
|
|
2
|
+
|
|
3
|
+
## 0.1.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Initial release of `@mastra/tavily` with search, extract, crawl, and map tools for Mastra agents.
|
|
8
|
+
- `createTavilySearchTool` — Web search with full parameter support (search depth, time range, domain filtering).
|
|
9
|
+
- `createTavilyExtractTool` — Extract content from URLs in markdown or text format.
|
|
10
|
+
- `createTavilyCrawlTool` — Crawl websites with configurable depth, breadth, and domain constraints.
|
|
11
|
+
- `createTavilyMapTool` — Discover and list URLs on a website without extracting content.
|
|
12
|
+
- `createTavilyTools` — Convenience function returning all four tools with shared configuration.
|
package/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# @mastra/tavily
|
|
2
|
+
|
|
3
|
+
Tavily web search, extract, crawl, and map tools for [Mastra](https://mastra.ai) agents.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @mastra/tavily @tavily/core zod
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
Use `createTavilyTools()` to get all four tools with a shared configuration:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Agent } from '@mastra/core/agent';
|
|
17
|
+
import { createTavilyTools } from '@mastra/tavily';
|
|
18
|
+
|
|
19
|
+
const tools = createTavilyTools();
|
|
20
|
+
// Or pass an explicit API key:
|
|
21
|
+
// const tools = createTavilyTools({ apiKey: 'tvly-...' });
|
|
22
|
+
|
|
23
|
+
const agent = new Agent({
|
|
24
|
+
id: 'realtime-information-agent',
|
|
25
|
+
name: "Realtime Information Agent",
|
|
26
|
+
instructions: "You are a realtime information agent that can search the web for the latest information and provide it to the user.",
|
|
27
|
+
model: "anthropic/claude-sonnet-4-6",
|
|
28
|
+
tools,
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
By default, the tools read `TAVILY_API_KEY` from your environment. You can also pass `{ apiKey }` explicitly.
|
|
33
|
+
|
|
34
|
+
## Individual Tools
|
|
35
|
+
|
|
36
|
+
Each tool can be created independently:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { createTavilySearchTool, createTavilyExtractTool } from '@mastra/tavily';
|
|
40
|
+
|
|
41
|
+
const searchTool = createTavilySearchTool({ apiKey: 'tvly-...' });
|
|
42
|
+
const extractTool = createTavilyExtractTool(); // uses TAVILY_API_KEY env var
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Search
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { createTavilySearchTool } from '@mastra/tavily';
|
|
49
|
+
|
|
50
|
+
const searchTool = createTavilySearchTool();
|
|
51
|
+
|
|
52
|
+
// When called by an agent, accepts:
|
|
53
|
+
// - query (required)
|
|
54
|
+
// - searchDepth: 'basic' | 'advanced'
|
|
55
|
+
// - maxResults: 1-20
|
|
56
|
+
// - includeAnswer: boolean | 'basic' | 'advanced'
|
|
57
|
+
// - includeImages, includeImageDescriptions, includeRawContent
|
|
58
|
+
// - includeDomains, excludeDomains
|
|
59
|
+
// - timeRange: 'day' | 'week' | 'month' | 'year'
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Extract
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { createTavilyExtractTool } from '@mastra/tavily';
|
|
66
|
+
|
|
67
|
+
const extractTool = createTavilyExtractTool();
|
|
68
|
+
|
|
69
|
+
// Accepts: urls (1-20), extractDepth, includeImages, format ('markdown' | 'text')
|
|
70
|
+
// Returns: results[] + failedResults[]
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Crawl
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import { createTavilyCrawlTool } from '@mastra/tavily';
|
|
77
|
+
|
|
78
|
+
const crawlTool = createTavilyCrawlTool();
|
|
79
|
+
|
|
80
|
+
// Accepts: url, maxDepth, maxBreadth, limit, instructions,
|
|
81
|
+
// selectPaths, selectDomains, excludePaths, excludeDomains,
|
|
82
|
+
// allowExternal, extractDepth, includeImages, format
|
|
83
|
+
// Returns: baseUrl + results[]
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Map
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { createTavilyMapTool } from '@mastra/tavily';
|
|
90
|
+
|
|
91
|
+
const mapTool = createTavilyMapTool();
|
|
92
|
+
|
|
93
|
+
// Accepts: url, maxDepth, maxBreadth, limit, instructions,
|
|
94
|
+
// selectPaths, selectDomains, excludePaths, excludeDomains, allowExternal
|
|
95
|
+
// Returns: baseUrl + discovered URL strings
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Configuration
|
|
99
|
+
|
|
100
|
+
| Option | Type | Default | Description |
|
|
101
|
+
|--------|------|---------|-------------|
|
|
102
|
+
| `apiKey` | `string` | `process.env.TAVILY_API_KEY` | Your Tavily API key |
|
|
103
|
+
|
|
104
|
+
All tools accept `TavilyClientOptions` from `@tavily/core` (includes `apiKey`, `proxies`, `apiBaseURL`, `clientSource`, `projectId`). If no API key is found, the tool throws a clear error at execution time. `clientSource` defaults to `'mastra'`.
|
|
105
|
+
|
|
106
|
+
## RAG Pairing Example
|
|
107
|
+
|
|
108
|
+
Combine search and extract for retrieval-augmented generation:
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import { Agent } from '@mastra/core/agent';
|
|
112
|
+
import { createTavilySearchTool, createTavilyExtractTool } from '@mastra/tavily';
|
|
113
|
+
|
|
114
|
+
const agent = new Agent({
|
|
115
|
+
id: 'rag-agent',
|
|
116
|
+
name: "Research Assistant",
|
|
117
|
+
model: "anthropic/claude-sonnet-4-6",
|
|
118
|
+
instructions: `You are a research assistant. Use tavily-search to find relevant pages, then use tavily-extract to get full content from the best results.`,
|
|
119
|
+
tools: {
|
|
120
|
+
search: createTavilySearchTool(),
|
|
121
|
+
extract: createTavilyExtractTool(),
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
Apache-2.0
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { tavily } from '@tavily/core';
|
|
2
|
+
import type { TavilyClientOptions } from '@tavily/core';
|
|
3
|
+
export type { TavilyClientOptions };
|
|
4
|
+
export type TavilyClient = ReturnType<typeof tavily>;
|
|
5
|
+
export declare function getTavilyClient(config?: TavilyClientOptions): TavilyClient;
|
|
6
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,YAAY,EAAE,mBAAmB,EAAE,CAAC;AAEpC,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;AAErD,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,YAAY,CAO1E"}
|
package/dist/crawl.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TavilyClientOptions } from './client.js';
|
|
2
|
+
export declare function createTavilyCrawlTool(config?: TavilyClientOptions): import("@mastra/core/tools").Tool<{
|
|
3
|
+
url: string;
|
|
4
|
+
maxDepth?: number | undefined;
|
|
5
|
+
maxBreadth?: number | undefined;
|
|
6
|
+
limit?: number | undefined;
|
|
7
|
+
instructions?: string | undefined;
|
|
8
|
+
selectPaths?: string[] | undefined;
|
|
9
|
+
selectDomains?: string[] | undefined;
|
|
10
|
+
excludePaths?: string[] | undefined;
|
|
11
|
+
excludeDomains?: string[] | undefined;
|
|
12
|
+
allowExternal?: boolean | undefined;
|
|
13
|
+
extractDepth?: "basic" | "advanced" | undefined;
|
|
14
|
+
includeImages?: boolean | undefined;
|
|
15
|
+
format?: "markdown" | "text" | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
baseUrl: string;
|
|
18
|
+
results: {
|
|
19
|
+
url: string;
|
|
20
|
+
rawContent: string;
|
|
21
|
+
images?: string[] | undefined;
|
|
22
|
+
}[];
|
|
23
|
+
responseTime: number;
|
|
24
|
+
}, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "tavily-crawl", unknown>;
|
|
25
|
+
//# sourceMappingURL=crawl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crawl.d.ts","sourceRoot":"","sources":["../src/crawl.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAgB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAoCrE,wBAAgB,qBAAqB,CAAC,MAAM,CAAC,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;;4HA6CjE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TavilyClientOptions } from './client.js';
|
|
2
|
+
export declare function createTavilyExtractTool(config?: TavilyClientOptions): import("@mastra/core/tools").Tool<{
|
|
3
|
+
urls: string[];
|
|
4
|
+
extractDepth?: "basic" | "advanced" | undefined;
|
|
5
|
+
query?: string | undefined;
|
|
6
|
+
includeImages?: boolean | undefined;
|
|
7
|
+
format?: "markdown" | "text" | undefined;
|
|
8
|
+
}, {
|
|
9
|
+
results: {
|
|
10
|
+
url: string;
|
|
11
|
+
rawContent: string;
|
|
12
|
+
images?: string[] | undefined;
|
|
13
|
+
}[];
|
|
14
|
+
failedResults: {
|
|
15
|
+
url: string;
|
|
16
|
+
error: string;
|
|
17
|
+
}[];
|
|
18
|
+
responseTime: number;
|
|
19
|
+
}, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "tavily-extract", unknown>;
|
|
20
|
+
//# sourceMappingURL=extract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAgB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAiCrE,wBAAgB,uBAAuB,CAAC,MAAM,CAAC,EAAE,mBAAmB;;;;;;;;;;;;;;;;;8HAwCnE"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
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
|
|
8
|
+
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, clientSource: config?.clientSource ?? "mastra" });
|
|
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")
|
|
26
|
+
});
|
|
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()
|
|
46
|
+
});
|
|
47
|
+
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
|
+
});
|
|
91
|
+
}
|
|
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'")
|
|
98
|
+
});
|
|
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()
|
|
114
|
+
});
|
|
115
|
+
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
|
+
});
|
|
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'")
|
|
165
|
+
});
|
|
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()
|
|
176
|
+
});
|
|
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
|
+
});
|
|
217
|
+
}
|
|
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")
|
|
229
|
+
});
|
|
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()
|
|
234
|
+
});
|
|
235
|
+
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
|
+
});
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// src/tools.ts
|
|
271
|
+
function createTavilyTools(config) {
|
|
272
|
+
return {
|
|
273
|
+
tavilySearch: createTavilySearchTool(config),
|
|
274
|
+
tavilyExtract: createTavilyExtractTool(config),
|
|
275
|
+
tavilyCrawl: createTavilyCrawlTool(config),
|
|
276
|
+
tavilyMap: createTavilyMapTool(config)
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
exports.createTavilyCrawlTool = createTavilyCrawlTool;
|
|
281
|
+
exports.createTavilyExtractTool = createTavilyExtractTool;
|
|
282
|
+
exports.createTavilyMapTool = createTavilyMapTool;
|
|
283
|
+
exports.createTavilySearchTool = createTavilySearchTool;
|
|
284
|
+
exports.createTavilyTools = createTavilyTools;
|
|
285
|
+
exports.getTavilyClient = getTavilyClient;
|
|
286
|
+
//# sourceMappingURL=index.cjs.map
|
|
287
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/search.ts","../src/extract.ts","../src/crawl.ts","../src/map.ts","../src/tools.ts"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{ tavily } from '@tavily/core';\nimport type { TavilyClientOptions } from '@tavily/core';\n\nexport type { TavilyClientOptions };\n\nexport type TavilyClient = ReturnType<typeof tavily>;\n\nexport function getTavilyClient(config?: TavilyClientOptions): TavilyClient {\n const apiKey = config?.apiKey ?? process.env.TAVILY_API_KEY;\n if (!apiKey) {\n throw new Error('Tavily API key is required. Pass { apiKey } or set TAVILY_API_KEY env var.');\n }\n // defaulting `clientSource` to `mastra` if not provided\n return tavily({ ...config, apiKey, clientSource: config?.clientSource ?? 'mastra' });\n}\n","import { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\nimport { getTavilyClient } from './client.js';\nimport type { TavilyClient, TavilyClientOptions } from './client.js';\n\nconst inputSchema = z.object({\n query: z.string().describe('The search query'),\n searchDepth: z\n .enum(['basic', 'advanced', 'fast', 'ultra-fast'])\n .optional()\n .describe(\"Search depth — 'basic' for standard, 'advanced' for thorough, 'fast'/'ultra-fast' for low latency\"),\n maxResults: z.number().min(1).max(20).optional().describe('Maximum number of results to return (1-20)'),\n includeAnswer: z\n .union([z.boolean(), z.enum(['basic', 'advanced'])])\n .optional()\n .describe('Include an AI-generated answer summary. Pass true, \"basic\", or \"advanced\"'),\n includeImages: z.boolean().optional().describe('Include query-related images in the response'),\n includeImageDescriptions: z.boolean().optional().describe('Include descriptions for returned images'),\n includeRawContent: z\n .union([z.literal(false), z.enum(['markdown', 'text'])])\n .optional()\n .describe('Include cleaned HTML content of each result. Pass false to disable, or \"markdown\"/\"text\" for format'),\n includeDomains: z.array(z.string()).optional().describe('Restrict results to these domains'),\n excludeDomains: z.array(z.string()).optional().describe('Exclude results from these domains'),\n timeRange: z\n .enum(['day', 'week', 'month', 'year'])\n .optional()\n .describe('Time range to filter results by recency'),\n});\n\nconst outputSchema = z.object({\n query: z.string(),\n answer: z.string().optional(),\n images: z\n .array(\n z.object({\n url: z.string(),\n description: z.string().optional(),\n }),\n )\n .optional(),\n results: z.array(\n z.object({\n title: z.string(),\n url: z.string(),\n content: z.string(),\n score: z.number(),\n rawContent: z.string().optional(),\n }),\n ),\n responseTime: z.number(),\n});\n\nexport function createTavilySearchTool(config?: TavilyClientOptions) {\n let client: TavilyClient | null = null;\n\n function getClient(): TavilyClient {\n if (!client) {\n client = getTavilyClient(config);\n }\n return client;\n }\n\n return createTool({\n id: 'tavily-search',\n description:\n '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.',\n inputSchema,\n outputSchema,\n execute: async input => {\n const tavilyClient = getClient();\n\n const response = await tavilyClient.search(input.query, {\n searchDepth: input.searchDepth,\n maxResults: input.maxResults,\n includeAnswer: input.includeAnswer,\n includeImages: input.includeImages,\n includeImageDescriptions: input.includeImageDescriptions,\n includeRawContent: input.includeRawContent,\n includeDomains: input.includeDomains,\n excludeDomains: input.excludeDomains,\n timeRange: input.timeRange,\n });\n\n return {\n query: response.query,\n answer: response.answer || undefined,\n images: response.images?.map((img: any) => ({\n url: typeof img === 'string' ? img : img.url,\n description: typeof img === 'string' ? undefined : img.description,\n })),\n results: (response.results ?? []).map((r: any) => ({\n title: r.title,\n url: r.url,\n content: r.content,\n score: r.score ?? 0,\n rawContent: r.rawContent || undefined,\n })),\n responseTime: response.responseTime,\n };\n },\n });\n}\n","import { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\nimport { getTavilyClient } from './client.js';\nimport type { TavilyClient, TavilyClientOptions } from './client.js';\n\nconst inputSchema = z.object({\n urls: z.array(z.string()).min(1).max(20).describe('URLs to extract content from (1-20)'),\n extractDepth: z\n .enum(['basic', 'advanced'])\n .optional()\n .describe(\"Extraction depth — 'advanced' retrieves more data including tables and embedded content\"),\n query: z.string().optional().describe('User intent for reranking extracted content chunks. When provided, chunks are reranked based on relevance to this query.'),\n includeImages: z.boolean().optional().describe('Include images extracted from the pages'),\n format: z\n .enum(['markdown', 'text'])\n .optional()\n .describe(\"Output format for extracted content — 'markdown' (default) or 'text'\"),\n});\n\nconst outputSchema = z.object({\n results: z.array(\n z.object({\n url: z.string(),\n rawContent: z.string(),\n images: z.array(z.string()).optional(),\n }),\n ),\n failedResults: z.array(\n z.object({\n url: z.string(),\n error: z.string(),\n }),\n ),\n responseTime: z.number(),\n});\n\nexport function createTavilyExtractTool(config?: TavilyClientOptions) {\n let client: TavilyClient | null = null;\n\n function getClient(): TavilyClient {\n if (!client) {\n client = getTavilyClient(config);\n }\n return client;\n }\n\n return createTool({\n id: 'tavily-extract',\n description:\n '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.',\n inputSchema,\n outputSchema,\n execute: async input => {\n const tavilyClient = getClient();\n\n const response = await tavilyClient.extract(input.urls, {\n extractDepth: input.extractDepth,\n query: input.query,\n includeImages: input.includeImages,\n format: input.format,\n });\n\n return {\n results: ((response.results || []) as any[]).map(r => ({\n url: r.url,\n rawContent: r.rawContent,\n images: r.images || undefined,\n })),\n failedResults: ((response.failedResults || []) as any[]).map(r => ({\n url: r.url,\n error: r.error,\n })),\n responseTime: response.responseTime,\n };\n },\n });\n}\n","import { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\nimport { getTavilyClient } from './client.js';\nimport type { TavilyClient, TavilyClientOptions } from './client.js';\n\nconst inputSchema = z.object({\n url: z.string().describe('The root URL to begin the crawl'),\n maxDepth: z.number().optional().describe('Max depth of the crawl from the base URL'),\n maxBreadth: z.number().optional().describe('Max number of links to follow per page'),\n limit: z.number().optional().describe('Total number of pages the crawler will process before stopping'),\n instructions: z.string().optional().describe('Natural language instructions for the crawler'),\n selectPaths: z.array(z.string()).optional().describe('Regex patterns to select specific URL paths'),\n selectDomains: z.array(z.string()).optional().describe('Regex patterns to restrict to specific domains'),\n excludePaths: z.array(z.string()).optional().describe('Regex patterns to exclude specific URL paths'),\n excludeDomains: z.array(z.string()).optional().describe('Regex patterns to exclude specific domains'),\n allowExternal: z.boolean().optional().describe('Whether to follow links to external domains'),\n extractDepth: z\n .enum(['basic', 'advanced'])\n .optional()\n .describe(\"Extraction depth — 'advanced' retrieves more data including tables and embedded content\"),\n includeImages: z.boolean().optional().describe('Include images from crawled pages'),\n format: z\n .enum(['markdown', 'text'])\n .optional()\n .describe(\"Output format for extracted content — 'markdown' (default) or 'text'\"),\n});\n\nconst outputSchema = z.object({\n baseUrl: z.string(),\n results: z.array(\n z.object({\n url: z.string(),\n rawContent: z.string(),\n images: z.array(z.string()).optional(),\n }),\n ),\n responseTime: z.number(),\n});\n\nexport function createTavilyCrawlTool(config?: TavilyClientOptions) {\n let client: TavilyClient | null = null;\n\n function getClient(): TavilyClient {\n if (!client) {\n client = getTavilyClient(config);\n }\n return client;\n }\n\n return createTool({\n id: 'tavily-crawl',\n description:\n '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.',\n inputSchema,\n outputSchema,\n execute: async input => {\n const tavilyClient = getClient();\n\n const response = await tavilyClient.crawl(input.url, {\n maxDepth: input.maxDepth,\n maxBreadth: input.maxBreadth,\n limit: input.limit,\n instructions: input.instructions,\n selectPaths: input.selectPaths,\n selectDomains: input.selectDomains,\n excludePaths: input.excludePaths,\n excludeDomains: input.excludeDomains,\n allowExternal: input.allowExternal,\n extractDepth: input.extractDepth,\n includeImages: input.includeImages,\n format: input.format,\n });\n\n return {\n baseUrl: response.baseUrl,\n results: ((response.results || []) as any[]).map(r => ({\n url: r.url,\n rawContent: r.rawContent,\n images: r.images || undefined,\n })),\n responseTime: response.responseTime,\n };\n },\n });\n}\n","import { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\nimport { getTavilyClient } from './client.js';\nimport type { TavilyClient, TavilyClientOptions } from './client.js';\n\nconst inputSchema = z.object({\n url: z.string().describe('The root URL to begin mapping'),\n maxDepth: z.number().optional().describe('Max depth of the mapping from the base URL'),\n maxBreadth: z.number().optional().describe('Max number of links to follow per page'),\n limit: z.number().optional().describe('Total number of links the mapper will process before stopping'),\n instructions: z.string().optional().describe('Natural language instructions for the mapper'),\n selectPaths: z.array(z.string()).optional().describe('Regex patterns to select specific URL paths'),\n selectDomains: z.array(z.string()).optional().describe('Regex patterns to restrict to specific domains'),\n excludePaths: z.array(z.string()).optional().describe('Regex patterns to exclude specific URL paths'),\n excludeDomains: z.array(z.string()).optional().describe('Regex patterns to exclude specific domains'),\n allowExternal: z.boolean().optional().describe('Whether to include external domain links'),\n});\n\nconst outputSchema = z.object({\n baseUrl: z.string(),\n results: z.array(z.string()).describe('Discovered URLs'),\n responseTime: z.number(),\n});\n\nexport function createTavilyMapTool(config?: TavilyClientOptions) {\n let client: TavilyClient | null = null;\n\n function getClient(): TavilyClient {\n if (!client) {\n client = getTavilyClient(config);\n }\n return client;\n }\n\n return createTool({\n id: 'tavily-map',\n description:\n \"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.\",\n inputSchema,\n outputSchema,\n execute: async input => {\n const tavilyClient = getClient();\n\n const response = await tavilyClient.map(input.url, {\n maxDepth: input.maxDepth,\n maxBreadth: input.maxBreadth,\n limit: input.limit,\n instructions: input.instructions,\n selectPaths: input.selectPaths,\n selectDomains: input.selectDomains,\n excludePaths: input.excludePaths,\n excludeDomains: input.excludeDomains,\n allowExternal: input.allowExternal,\n });\n\n return {\n baseUrl: response.baseUrl,\n results: response.results || [],\n responseTime: response.responseTime,\n };\n },\n });\n}\n","import type { TavilyClientOptions } from './client.js';\nimport { createTavilyCrawlTool } from './crawl.js';\nimport { createTavilyExtractTool } from './extract.js';\nimport { createTavilyMapTool } from './map.js';\nimport { createTavilySearchTool } from './search.js';\n\nexport function createTavilyTools(config?: TavilyClientOptions) {\n return {\n tavilySearch: createTavilySearchTool(config),\n tavilyExtract: createTavilyExtractTool(config),\n tavilyCrawl: createTavilyCrawlTool(config),\n tavilyMap: createTavilyMapTool(config),\n };\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { getTavilyClient, type TavilyClientOptions, type TavilyClient } from './client.js';
|
|
2
|
+
export { createTavilySearchTool } from './search.js';
|
|
3
|
+
export { createTavilyExtractTool } from './extract.js';
|
|
4
|
+
export { createTavilyCrawlTool } from './crawl.js';
|
|
5
|
+
export { createTavilyMapTool } from './map.js';
|
|
6
|
+
export { createTavilyTools } from './tools.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { tavily } from '@tavily/core';
|
|
2
|
+
import { createTool } from '@mastra/core/tools';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
// src/client.ts
|
|
6
|
+
function getTavilyClient(config) {
|
|
7
|
+
const apiKey = config?.apiKey ?? process.env.TAVILY_API_KEY;
|
|
8
|
+
if (!apiKey) {
|
|
9
|
+
throw new Error("Tavily API key is required. Pass { apiKey } or set TAVILY_API_KEY env var.");
|
|
10
|
+
}
|
|
11
|
+
return tavily({ ...config, apiKey, clientSource: config?.clientSource ?? "mastra" });
|
|
12
|
+
}
|
|
13
|
+
var inputSchema = z.object({
|
|
14
|
+
query: z.string().describe("The search query"),
|
|
15
|
+
searchDepth: z.enum(["basic", "advanced", "fast", "ultra-fast"]).optional().describe("Search depth \u2014 'basic' for standard, 'advanced' for thorough, 'fast'/'ultra-fast' for low latency"),
|
|
16
|
+
maxResults: z.number().min(1).max(20).optional().describe("Maximum number of results to return (1-20)"),
|
|
17
|
+
includeAnswer: z.union([z.boolean(), z.enum(["basic", "advanced"])]).optional().describe('Include an AI-generated answer summary. Pass true, "basic", or "advanced"'),
|
|
18
|
+
includeImages: z.boolean().optional().describe("Include query-related images in the response"),
|
|
19
|
+
includeImageDescriptions: z.boolean().optional().describe("Include descriptions for returned images"),
|
|
20
|
+
includeRawContent: z.union([z.literal(false), z.enum(["markdown", "text"])]).optional().describe('Include cleaned HTML content of each result. Pass false to disable, or "markdown"/"text" for format'),
|
|
21
|
+
includeDomains: z.array(z.string()).optional().describe("Restrict results to these domains"),
|
|
22
|
+
excludeDomains: z.array(z.string()).optional().describe("Exclude results from these domains"),
|
|
23
|
+
timeRange: z.enum(["day", "week", "month", "year"]).optional().describe("Time range to filter results by recency")
|
|
24
|
+
});
|
|
25
|
+
var outputSchema = z.object({
|
|
26
|
+
query: z.string(),
|
|
27
|
+
answer: z.string().optional(),
|
|
28
|
+
images: z.array(
|
|
29
|
+
z.object({
|
|
30
|
+
url: z.string(),
|
|
31
|
+
description: z.string().optional()
|
|
32
|
+
})
|
|
33
|
+
).optional(),
|
|
34
|
+
results: z.array(
|
|
35
|
+
z.object({
|
|
36
|
+
title: z.string(),
|
|
37
|
+
url: z.string(),
|
|
38
|
+
content: z.string(),
|
|
39
|
+
score: z.number(),
|
|
40
|
+
rawContent: z.string().optional()
|
|
41
|
+
})
|
|
42
|
+
),
|
|
43
|
+
responseTime: z.number()
|
|
44
|
+
});
|
|
45
|
+
function createTavilySearchTool(config) {
|
|
46
|
+
let client = null;
|
|
47
|
+
function getClient() {
|
|
48
|
+
if (!client) {
|
|
49
|
+
client = getTavilyClient(config);
|
|
50
|
+
}
|
|
51
|
+
return client;
|
|
52
|
+
}
|
|
53
|
+
return createTool({
|
|
54
|
+
id: "tavily-search",
|
|
55
|
+
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.",
|
|
56
|
+
inputSchema,
|
|
57
|
+
outputSchema,
|
|
58
|
+
execute: async (input) => {
|
|
59
|
+
const tavilyClient = getClient();
|
|
60
|
+
const response = await tavilyClient.search(input.query, {
|
|
61
|
+
searchDepth: input.searchDepth,
|
|
62
|
+
maxResults: input.maxResults,
|
|
63
|
+
includeAnswer: input.includeAnswer,
|
|
64
|
+
includeImages: input.includeImages,
|
|
65
|
+
includeImageDescriptions: input.includeImageDescriptions,
|
|
66
|
+
includeRawContent: input.includeRawContent,
|
|
67
|
+
includeDomains: input.includeDomains,
|
|
68
|
+
excludeDomains: input.excludeDomains,
|
|
69
|
+
timeRange: input.timeRange
|
|
70
|
+
});
|
|
71
|
+
return {
|
|
72
|
+
query: response.query,
|
|
73
|
+
answer: response.answer || void 0,
|
|
74
|
+
images: response.images?.map((img) => ({
|
|
75
|
+
url: typeof img === "string" ? img : img.url,
|
|
76
|
+
description: typeof img === "string" ? void 0 : img.description
|
|
77
|
+
})),
|
|
78
|
+
results: (response.results ?? []).map((r) => ({
|
|
79
|
+
title: r.title,
|
|
80
|
+
url: r.url,
|
|
81
|
+
content: r.content,
|
|
82
|
+
score: r.score ?? 0,
|
|
83
|
+
rawContent: r.rawContent || void 0
|
|
84
|
+
})),
|
|
85
|
+
responseTime: response.responseTime
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
var inputSchema2 = z.object({
|
|
91
|
+
urls: z.array(z.string()).min(1).max(20).describe("URLs to extract content from (1-20)"),
|
|
92
|
+
extractDepth: z.enum(["basic", "advanced"]).optional().describe("Extraction depth \u2014 'advanced' retrieves more data including tables and embedded content"),
|
|
93
|
+
query: z.string().optional().describe("User intent for reranking extracted content chunks. When provided, chunks are reranked based on relevance to this query."),
|
|
94
|
+
includeImages: z.boolean().optional().describe("Include images extracted from the pages"),
|
|
95
|
+
format: z.enum(["markdown", "text"]).optional().describe("Output format for extracted content \u2014 'markdown' (default) or 'text'")
|
|
96
|
+
});
|
|
97
|
+
var outputSchema2 = z.object({
|
|
98
|
+
results: z.array(
|
|
99
|
+
z.object({
|
|
100
|
+
url: z.string(),
|
|
101
|
+
rawContent: z.string(),
|
|
102
|
+
images: z.array(z.string()).optional()
|
|
103
|
+
})
|
|
104
|
+
),
|
|
105
|
+
failedResults: z.array(
|
|
106
|
+
z.object({
|
|
107
|
+
url: z.string(),
|
|
108
|
+
error: z.string()
|
|
109
|
+
})
|
|
110
|
+
),
|
|
111
|
+
responseTime: z.number()
|
|
112
|
+
});
|
|
113
|
+
function createTavilyExtractTool(config) {
|
|
114
|
+
let client = null;
|
|
115
|
+
function getClient() {
|
|
116
|
+
if (!client) {
|
|
117
|
+
client = getTavilyClient(config);
|
|
118
|
+
}
|
|
119
|
+
return client;
|
|
120
|
+
}
|
|
121
|
+
return createTool({
|
|
122
|
+
id: "tavily-extract",
|
|
123
|
+
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.",
|
|
124
|
+
inputSchema: inputSchema2,
|
|
125
|
+
outputSchema: outputSchema2,
|
|
126
|
+
execute: async (input) => {
|
|
127
|
+
const tavilyClient = getClient();
|
|
128
|
+
const response = await tavilyClient.extract(input.urls, {
|
|
129
|
+
extractDepth: input.extractDepth,
|
|
130
|
+
query: input.query,
|
|
131
|
+
includeImages: input.includeImages,
|
|
132
|
+
format: input.format
|
|
133
|
+
});
|
|
134
|
+
return {
|
|
135
|
+
results: (response.results || []).map((r) => ({
|
|
136
|
+
url: r.url,
|
|
137
|
+
rawContent: r.rawContent,
|
|
138
|
+
images: r.images || void 0
|
|
139
|
+
})),
|
|
140
|
+
failedResults: (response.failedResults || []).map((r) => ({
|
|
141
|
+
url: r.url,
|
|
142
|
+
error: r.error
|
|
143
|
+
})),
|
|
144
|
+
responseTime: response.responseTime
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
var inputSchema3 = z.object({
|
|
150
|
+
url: z.string().describe("The root URL to begin the crawl"),
|
|
151
|
+
maxDepth: z.number().optional().describe("Max depth of the crawl from the base URL"),
|
|
152
|
+
maxBreadth: z.number().optional().describe("Max number of links to follow per page"),
|
|
153
|
+
limit: z.number().optional().describe("Total number of pages the crawler will process before stopping"),
|
|
154
|
+
instructions: z.string().optional().describe("Natural language instructions for the crawler"),
|
|
155
|
+
selectPaths: z.array(z.string()).optional().describe("Regex patterns to select specific URL paths"),
|
|
156
|
+
selectDomains: z.array(z.string()).optional().describe("Regex patterns to restrict to specific domains"),
|
|
157
|
+
excludePaths: z.array(z.string()).optional().describe("Regex patterns to exclude specific URL paths"),
|
|
158
|
+
excludeDomains: z.array(z.string()).optional().describe("Regex patterns to exclude specific domains"),
|
|
159
|
+
allowExternal: z.boolean().optional().describe("Whether to follow links to external domains"),
|
|
160
|
+
extractDepth: z.enum(["basic", "advanced"]).optional().describe("Extraction depth \u2014 'advanced' retrieves more data including tables and embedded content"),
|
|
161
|
+
includeImages: z.boolean().optional().describe("Include images from crawled pages"),
|
|
162
|
+
format: z.enum(["markdown", "text"]).optional().describe("Output format for extracted content \u2014 'markdown' (default) or 'text'")
|
|
163
|
+
});
|
|
164
|
+
var outputSchema3 = z.object({
|
|
165
|
+
baseUrl: z.string(),
|
|
166
|
+
results: z.array(
|
|
167
|
+
z.object({
|
|
168
|
+
url: z.string(),
|
|
169
|
+
rawContent: z.string(),
|
|
170
|
+
images: z.array(z.string()).optional()
|
|
171
|
+
})
|
|
172
|
+
),
|
|
173
|
+
responseTime: z.number()
|
|
174
|
+
});
|
|
175
|
+
function createTavilyCrawlTool(config) {
|
|
176
|
+
let client = null;
|
|
177
|
+
function getClient() {
|
|
178
|
+
if (!client) {
|
|
179
|
+
client = getTavilyClient(config);
|
|
180
|
+
}
|
|
181
|
+
return client;
|
|
182
|
+
}
|
|
183
|
+
return 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: inputSchema3,
|
|
187
|
+
outputSchema: outputSchema3,
|
|
188
|
+
execute: async (input) => {
|
|
189
|
+
const tavilyClient = getClient();
|
|
190
|
+
const response = await tavilyClient.crawl(input.url, {
|
|
191
|
+
maxDepth: input.maxDepth,
|
|
192
|
+
maxBreadth: input.maxBreadth,
|
|
193
|
+
limit: input.limit,
|
|
194
|
+
instructions: input.instructions,
|
|
195
|
+
selectPaths: input.selectPaths,
|
|
196
|
+
selectDomains: input.selectDomains,
|
|
197
|
+
excludePaths: input.excludePaths,
|
|
198
|
+
excludeDomains: input.excludeDomains,
|
|
199
|
+
allowExternal: input.allowExternal,
|
|
200
|
+
extractDepth: input.extractDepth,
|
|
201
|
+
includeImages: input.includeImages,
|
|
202
|
+
format: input.format
|
|
203
|
+
});
|
|
204
|
+
return {
|
|
205
|
+
baseUrl: response.baseUrl,
|
|
206
|
+
results: (response.results || []).map((r) => ({
|
|
207
|
+
url: r.url,
|
|
208
|
+
rawContent: r.rawContent,
|
|
209
|
+
images: r.images || void 0
|
|
210
|
+
})),
|
|
211
|
+
responseTime: response.responseTime
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
var inputSchema4 = z.object({
|
|
217
|
+
url: z.string().describe("The root URL to begin mapping"),
|
|
218
|
+
maxDepth: z.number().optional().describe("Max depth of the mapping from the base URL"),
|
|
219
|
+
maxBreadth: z.number().optional().describe("Max number of links to follow per page"),
|
|
220
|
+
limit: z.number().optional().describe("Total number of links the mapper will process before stopping"),
|
|
221
|
+
instructions: z.string().optional().describe("Natural language instructions for the mapper"),
|
|
222
|
+
selectPaths: z.array(z.string()).optional().describe("Regex patterns to select specific URL paths"),
|
|
223
|
+
selectDomains: z.array(z.string()).optional().describe("Regex patterns to restrict to specific domains"),
|
|
224
|
+
excludePaths: z.array(z.string()).optional().describe("Regex patterns to exclude specific URL paths"),
|
|
225
|
+
excludeDomains: z.array(z.string()).optional().describe("Regex patterns to exclude specific domains"),
|
|
226
|
+
allowExternal: z.boolean().optional().describe("Whether to include external domain links")
|
|
227
|
+
});
|
|
228
|
+
var outputSchema4 = z.object({
|
|
229
|
+
baseUrl: z.string(),
|
|
230
|
+
results: z.array(z.string()).describe("Discovered URLs"),
|
|
231
|
+
responseTime: z.number()
|
|
232
|
+
});
|
|
233
|
+
function createTavilyMapTool(config) {
|
|
234
|
+
let client = null;
|
|
235
|
+
function getClient() {
|
|
236
|
+
if (!client) {
|
|
237
|
+
client = getTavilyClient(config);
|
|
238
|
+
}
|
|
239
|
+
return client;
|
|
240
|
+
}
|
|
241
|
+
return createTool({
|
|
242
|
+
id: "tavily-map",
|
|
243
|
+
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.",
|
|
244
|
+
inputSchema: inputSchema4,
|
|
245
|
+
outputSchema: outputSchema4,
|
|
246
|
+
execute: async (input) => {
|
|
247
|
+
const tavilyClient = getClient();
|
|
248
|
+
const response = await tavilyClient.map(input.url, {
|
|
249
|
+
maxDepth: input.maxDepth,
|
|
250
|
+
maxBreadth: input.maxBreadth,
|
|
251
|
+
limit: input.limit,
|
|
252
|
+
instructions: input.instructions,
|
|
253
|
+
selectPaths: input.selectPaths,
|
|
254
|
+
selectDomains: input.selectDomains,
|
|
255
|
+
excludePaths: input.excludePaths,
|
|
256
|
+
excludeDomains: input.excludeDomains,
|
|
257
|
+
allowExternal: input.allowExternal
|
|
258
|
+
});
|
|
259
|
+
return {
|
|
260
|
+
baseUrl: response.baseUrl,
|
|
261
|
+
results: response.results || [],
|
|
262
|
+
responseTime: response.responseTime
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// src/tools.ts
|
|
269
|
+
function createTavilyTools(config) {
|
|
270
|
+
return {
|
|
271
|
+
tavilySearch: createTavilySearchTool(config),
|
|
272
|
+
tavilyExtract: createTavilyExtractTool(config),
|
|
273
|
+
tavilyCrawl: createTavilyCrawlTool(config),
|
|
274
|
+
tavilyMap: createTavilyMapTool(config)
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export { createTavilyCrawlTool, createTavilyExtractTool, createTavilyMapTool, createTavilySearchTool, createTavilyTools, getTavilyClient };
|
|
279
|
+
//# sourceMappingURL=index.js.map
|
|
280
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/search.ts","../src/extract.ts","../src/crawl.ts","../src/map.ts","../src/tools.ts"],"names":["inputSchema","z","outputSchema","createTool"],"mappings":";;;;;AAOO,SAAS,gBAAgB,MAAA,EAA4C;AAC1E,EAAA,MAAM,MAAA,GAAS,MAAA,EAAQ,MAAA,IAAU,OAAA,CAAQ,GAAA,CAAI,cAAA;AAC7C,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,IAAI,MAAM,4EAA4E,CAAA;AAAA,EAC9F;AAEA,EAAA,OAAO,MAAA,CAAO,EAAE,GAAG,MAAA,EAAQ,QAAQ,YAAA,EAAc,MAAA,EAAQ,YAAA,IAAgB,QAAA,EAAU,CAAA;AACrF;ACRA,IAAM,WAAA,GAAc,EAAE,MAAA,CAAO;AAAA,EAC3B,KAAA,EAAO,CAAA,CAAE,MAAA,EAAO,CAAE,SAAS,kBAAkB,CAAA;AAAA,EAC7C,WAAA,EAAa,CAAA,CACV,IAAA,CAAK,CAAC,OAAA,EAAS,UAAA,EAAY,MAAA,EAAQ,YAAY,CAAC,CAAA,CAChD,QAAA,EAAS,CACT,SAAS,wGAAmG,CAAA;AAAA,EAC/G,UAAA,EAAY,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA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AAM;AAAA,OACtB,CAAA;AAED,MAAA,OAAO;AAAA,QACL,SAAS,QAAA,CAAS,OAAA;AAAA,QAClB,OAAA,EAAS,QAAA,CAAS,OAAA,IAAW,EAAC;AAAA,QAC9B,cAAc,QAAA,CAAS;AAAA,OACzB;AAAA,IACF;AAAA,GACD,CAAA;AACH;;;ACzDO,SAAS,kBAAkB,MAAA,EAA8B;AAC9D,EAAA,OAAO;AAAA,IACL,YAAA,EAAc,uBAAuB,MAAM,CAAA;AAAA,IAC3C,aAAA,EAAe,wBAAwB,MAAM,CAAA;AAAA,IAC7C,WAAA,EAAa,sBAAsB,MAAM,CAAA;AAAA,IACzC,SAAA,EAAW,oBAAoB,MAAM;AAAA,GACvC;AACF","file":"index.js","sourcesContent":["import { tavily } from '@tavily/core';\nimport type { TavilyClientOptions } from '@tavily/core';\n\nexport type { TavilyClientOptions };\n\nexport type TavilyClient = ReturnType<typeof tavily>;\n\nexport function getTavilyClient(config?: TavilyClientOptions): TavilyClient {\n const apiKey = config?.apiKey ?? process.env.TAVILY_API_KEY;\n if (!apiKey) {\n throw new Error('Tavily API key is required. Pass { apiKey } or set TAVILY_API_KEY env var.');\n }\n // defaulting `clientSource` to `mastra` if not provided\n return tavily({ ...config, apiKey, clientSource: config?.clientSource ?? 'mastra' });\n}\n","import { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\nimport { getTavilyClient } from './client.js';\nimport type { TavilyClient, TavilyClientOptions } from './client.js';\n\nconst inputSchema = z.object({\n query: z.string().describe('The search query'),\n searchDepth: z\n .enum(['basic', 'advanced', 'fast', 'ultra-fast'])\n .optional()\n .describe(\"Search depth — 'basic' for standard, 'advanced' for thorough, 'fast'/'ultra-fast' for low latency\"),\n maxResults: z.number().min(1).max(20).optional().describe('Maximum number of results to return (1-20)'),\n includeAnswer: z\n .union([z.boolean(), z.enum(['basic', 'advanced'])])\n .optional()\n .describe('Include an AI-generated answer summary. Pass true, \"basic\", or \"advanced\"'),\n includeImages: z.boolean().optional().describe('Include query-related images in the response'),\n includeImageDescriptions: z.boolean().optional().describe('Include descriptions for returned images'),\n includeRawContent: z\n .union([z.literal(false), z.enum(['markdown', 'text'])])\n .optional()\n .describe('Include cleaned HTML content of each result. Pass false to disable, or \"markdown\"/\"text\" for format'),\n includeDomains: z.array(z.string()).optional().describe('Restrict results to these domains'),\n excludeDomains: z.array(z.string()).optional().describe('Exclude results from these domains'),\n timeRange: z\n .enum(['day', 'week', 'month', 'year'])\n .optional()\n .describe('Time range to filter results by recency'),\n});\n\nconst outputSchema = z.object({\n query: z.string(),\n answer: z.string().optional(),\n images: z\n .array(\n z.object({\n url: z.string(),\n description: z.string().optional(),\n }),\n )\n .optional(),\n results: z.array(\n z.object({\n title: z.string(),\n url: z.string(),\n content: z.string(),\n score: z.number(),\n rawContent: z.string().optional(),\n }),\n ),\n responseTime: z.number(),\n});\n\nexport function createTavilySearchTool(config?: TavilyClientOptions) {\n let client: TavilyClient | null = null;\n\n function getClient(): TavilyClient {\n if (!client) {\n client = getTavilyClient(config);\n }\n return client;\n }\n\n return createTool({\n id: 'tavily-search',\n description:\n '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.',\n inputSchema,\n outputSchema,\n execute: async input => {\n const tavilyClient = getClient();\n\n const response = await tavilyClient.search(input.query, {\n searchDepth: input.searchDepth,\n maxResults: input.maxResults,\n includeAnswer: input.includeAnswer,\n includeImages: input.includeImages,\n includeImageDescriptions: input.includeImageDescriptions,\n includeRawContent: input.includeRawContent,\n includeDomains: input.includeDomains,\n excludeDomains: input.excludeDomains,\n timeRange: input.timeRange,\n });\n\n return {\n query: response.query,\n answer: response.answer || undefined,\n images: response.images?.map((img: any) => ({\n url: typeof img === 'string' ? img : img.url,\n description: typeof img === 'string' ? undefined : img.description,\n })),\n results: (response.results ?? []).map((r: any) => ({\n title: r.title,\n url: r.url,\n content: r.content,\n score: r.score ?? 0,\n rawContent: r.rawContent || undefined,\n })),\n responseTime: response.responseTime,\n };\n },\n });\n}\n","import { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\nimport { getTavilyClient } from './client.js';\nimport type { TavilyClient, TavilyClientOptions } from './client.js';\n\nconst inputSchema = z.object({\n urls: z.array(z.string()).min(1).max(20).describe('URLs to extract content from (1-20)'),\n extractDepth: z\n .enum(['basic', 'advanced'])\n .optional()\n .describe(\"Extraction depth — 'advanced' retrieves more data including tables and embedded content\"),\n query: z.string().optional().describe('User intent for reranking extracted content chunks. When provided, chunks are reranked based on relevance to this query.'),\n includeImages: z.boolean().optional().describe('Include images extracted from the pages'),\n format: z\n .enum(['markdown', 'text'])\n .optional()\n .describe(\"Output format for extracted content — 'markdown' (default) or 'text'\"),\n});\n\nconst outputSchema = z.object({\n results: z.array(\n z.object({\n url: z.string(),\n rawContent: z.string(),\n images: z.array(z.string()).optional(),\n }),\n ),\n failedResults: z.array(\n z.object({\n url: z.string(),\n error: z.string(),\n }),\n ),\n responseTime: z.number(),\n});\n\nexport function createTavilyExtractTool(config?: TavilyClientOptions) {\n let client: TavilyClient | null = null;\n\n function getClient(): TavilyClient {\n if (!client) {\n client = getTavilyClient(config);\n }\n return client;\n }\n\n return createTool({\n id: 'tavily-extract',\n description:\n '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.',\n inputSchema,\n outputSchema,\n execute: async input => {\n const tavilyClient = getClient();\n\n const response = await tavilyClient.extract(input.urls, {\n extractDepth: input.extractDepth,\n query: input.query,\n includeImages: input.includeImages,\n format: input.format,\n });\n\n return {\n results: ((response.results || []) as any[]).map(r => ({\n url: r.url,\n rawContent: r.rawContent,\n images: r.images || undefined,\n })),\n failedResults: ((response.failedResults || []) as any[]).map(r => ({\n url: r.url,\n error: r.error,\n })),\n responseTime: response.responseTime,\n };\n },\n });\n}\n","import { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\nimport { getTavilyClient } from './client.js';\nimport type { TavilyClient, TavilyClientOptions } from './client.js';\n\nconst inputSchema = z.object({\n url: z.string().describe('The root URL to begin the crawl'),\n maxDepth: z.number().optional().describe('Max depth of the crawl from the base URL'),\n maxBreadth: z.number().optional().describe('Max number of links to follow per page'),\n limit: z.number().optional().describe('Total number of pages the crawler will process before stopping'),\n instructions: z.string().optional().describe('Natural language instructions for the crawler'),\n selectPaths: z.array(z.string()).optional().describe('Regex patterns to select specific URL paths'),\n selectDomains: z.array(z.string()).optional().describe('Regex patterns to restrict to specific domains'),\n excludePaths: z.array(z.string()).optional().describe('Regex patterns to exclude specific URL paths'),\n excludeDomains: z.array(z.string()).optional().describe('Regex patterns to exclude specific domains'),\n allowExternal: z.boolean().optional().describe('Whether to follow links to external domains'),\n extractDepth: z\n .enum(['basic', 'advanced'])\n .optional()\n .describe(\"Extraction depth — 'advanced' retrieves more data including tables and embedded content\"),\n includeImages: z.boolean().optional().describe('Include images from crawled pages'),\n format: z\n .enum(['markdown', 'text'])\n .optional()\n .describe(\"Output format for extracted content — 'markdown' (default) or 'text'\"),\n});\n\nconst outputSchema = z.object({\n baseUrl: z.string(),\n results: z.array(\n z.object({\n url: z.string(),\n rawContent: z.string(),\n images: z.array(z.string()).optional(),\n }),\n ),\n responseTime: z.number(),\n});\n\nexport function createTavilyCrawlTool(config?: TavilyClientOptions) {\n let client: TavilyClient | null = null;\n\n function getClient(): TavilyClient {\n if (!client) {\n client = getTavilyClient(config);\n }\n return client;\n }\n\n return createTool({\n id: 'tavily-crawl',\n description:\n '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.',\n inputSchema,\n outputSchema,\n execute: async input => {\n const tavilyClient = getClient();\n\n const response = await tavilyClient.crawl(input.url, {\n maxDepth: input.maxDepth,\n maxBreadth: input.maxBreadth,\n limit: input.limit,\n instructions: input.instructions,\n selectPaths: input.selectPaths,\n selectDomains: input.selectDomains,\n excludePaths: input.excludePaths,\n excludeDomains: input.excludeDomains,\n allowExternal: input.allowExternal,\n extractDepth: input.extractDepth,\n includeImages: input.includeImages,\n format: input.format,\n });\n\n return {\n baseUrl: response.baseUrl,\n results: ((response.results || []) as any[]).map(r => ({\n url: r.url,\n rawContent: r.rawContent,\n images: r.images || undefined,\n })),\n responseTime: response.responseTime,\n };\n },\n });\n}\n","import { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\nimport { getTavilyClient } from './client.js';\nimport type { TavilyClient, TavilyClientOptions } from './client.js';\n\nconst inputSchema = z.object({\n url: z.string().describe('The root URL to begin mapping'),\n maxDepth: z.number().optional().describe('Max depth of the mapping from the base URL'),\n maxBreadth: z.number().optional().describe('Max number of links to follow per page'),\n limit: z.number().optional().describe('Total number of links the mapper will process before stopping'),\n instructions: z.string().optional().describe('Natural language instructions for the mapper'),\n selectPaths: z.array(z.string()).optional().describe('Regex patterns to select specific URL paths'),\n selectDomains: z.array(z.string()).optional().describe('Regex patterns to restrict to specific domains'),\n excludePaths: z.array(z.string()).optional().describe('Regex patterns to exclude specific URL paths'),\n excludeDomains: z.array(z.string()).optional().describe('Regex patterns to exclude specific domains'),\n allowExternal: z.boolean().optional().describe('Whether to include external domain links'),\n});\n\nconst outputSchema = z.object({\n baseUrl: z.string(),\n results: z.array(z.string()).describe('Discovered URLs'),\n responseTime: z.number(),\n});\n\nexport function createTavilyMapTool(config?: TavilyClientOptions) {\n let client: TavilyClient | null = null;\n\n function getClient(): TavilyClient {\n if (!client) {\n client = getTavilyClient(config);\n }\n return client;\n }\n\n return createTool({\n id: 'tavily-map',\n description:\n \"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.\",\n inputSchema,\n outputSchema,\n execute: async input => {\n const tavilyClient = getClient();\n\n const response = await tavilyClient.map(input.url, {\n maxDepth: input.maxDepth,\n maxBreadth: input.maxBreadth,\n limit: input.limit,\n instructions: input.instructions,\n selectPaths: input.selectPaths,\n selectDomains: input.selectDomains,\n excludePaths: input.excludePaths,\n excludeDomains: input.excludeDomains,\n allowExternal: input.allowExternal,\n });\n\n return {\n baseUrl: response.baseUrl,\n results: response.results || [],\n responseTime: response.responseTime,\n };\n },\n });\n}\n","import type { TavilyClientOptions } from './client.js';\nimport { createTavilyCrawlTool } from './crawl.js';\nimport { createTavilyExtractTool } from './extract.js';\nimport { createTavilyMapTool } from './map.js';\nimport { createTavilySearchTool } from './search.js';\n\nexport function createTavilyTools(config?: TavilyClientOptions) {\n return {\n tavilySearch: createTavilySearchTool(config),\n tavilyExtract: createTavilyExtractTool(config),\n tavilyCrawl: createTavilyCrawlTool(config),\n tavilyMap: createTavilyMapTool(config),\n };\n}\n"]}
|
package/dist/map.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TavilyClientOptions } from './client.js';
|
|
2
|
+
export declare function createTavilyMapTool(config?: TavilyClientOptions): import("@mastra/core/tools").Tool<{
|
|
3
|
+
url: string;
|
|
4
|
+
maxDepth?: number | undefined;
|
|
5
|
+
maxBreadth?: number | undefined;
|
|
6
|
+
limit?: number | undefined;
|
|
7
|
+
instructions?: string | undefined;
|
|
8
|
+
selectPaths?: string[] | undefined;
|
|
9
|
+
selectDomains?: string[] | undefined;
|
|
10
|
+
excludePaths?: string[] | undefined;
|
|
11
|
+
excludeDomains?: string[] | undefined;
|
|
12
|
+
allowExternal?: boolean | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
baseUrl: string;
|
|
15
|
+
results: string[];
|
|
16
|
+
responseTime: number;
|
|
17
|
+
}, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "tavily-map", unknown>;
|
|
18
|
+
//# sourceMappingURL=map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAgB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAqBrE,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,mBAAmB;;;;;;;;;;;;;;;0HAsC/D"}
|
package/dist/search.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { TavilyClientOptions } from './client.js';
|
|
2
|
+
export declare function createTavilySearchTool(config?: TavilyClientOptions): import("@mastra/core/tools").Tool<{
|
|
3
|
+
query: string;
|
|
4
|
+
searchDepth?: "basic" | "advanced" | "fast" | "ultra-fast" | undefined;
|
|
5
|
+
maxResults?: number | undefined;
|
|
6
|
+
includeAnswer?: boolean | "basic" | "advanced" | undefined;
|
|
7
|
+
includeImages?: boolean | undefined;
|
|
8
|
+
includeImageDescriptions?: boolean | undefined;
|
|
9
|
+
includeRawContent?: false | "markdown" | "text" | undefined;
|
|
10
|
+
includeDomains?: string[] | undefined;
|
|
11
|
+
excludeDomains?: string[] | undefined;
|
|
12
|
+
timeRange?: "day" | "week" | "month" | "year" | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
query: string;
|
|
15
|
+
results: {
|
|
16
|
+
title: string;
|
|
17
|
+
url: string;
|
|
18
|
+
content: string;
|
|
19
|
+
score: number;
|
|
20
|
+
rawContent?: string | undefined;
|
|
21
|
+
}[];
|
|
22
|
+
responseTime: number;
|
|
23
|
+
answer?: string | undefined;
|
|
24
|
+
images?: {
|
|
25
|
+
url: string;
|
|
26
|
+
description?: string | undefined;
|
|
27
|
+
}[] | undefined;
|
|
28
|
+
}, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "tavily-search", unknown>;
|
|
29
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAgB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAkDrE,wBAAgB,sBAAsB,CAAC,MAAM,CAAC,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;6HAiDlE"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { TavilyClientOptions } from './client.js';
|
|
2
|
+
export declare function createTavilyTools(config?: TavilyClientOptions): {
|
|
3
|
+
tavilySearch: import("@mastra/core/tools").Tool<{
|
|
4
|
+
query: string;
|
|
5
|
+
searchDepth?: "basic" | "advanced" | "fast" | "ultra-fast" | undefined;
|
|
6
|
+
maxResults?: number | undefined;
|
|
7
|
+
includeAnswer?: boolean | "basic" | "advanced" | undefined;
|
|
8
|
+
includeImages?: boolean | undefined;
|
|
9
|
+
includeImageDescriptions?: boolean | undefined;
|
|
10
|
+
includeRawContent?: false | "markdown" | "text" | undefined;
|
|
11
|
+
includeDomains?: string[] | undefined;
|
|
12
|
+
excludeDomains?: string[] | undefined;
|
|
13
|
+
timeRange?: "day" | "week" | "month" | "year" | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
query: string;
|
|
16
|
+
results: {
|
|
17
|
+
title: string;
|
|
18
|
+
url: string;
|
|
19
|
+
content: string;
|
|
20
|
+
score: number;
|
|
21
|
+
rawContent?: string | undefined;
|
|
22
|
+
}[];
|
|
23
|
+
responseTime: number;
|
|
24
|
+
answer?: string | undefined;
|
|
25
|
+
images?: {
|
|
26
|
+
url: string;
|
|
27
|
+
description?: string | undefined;
|
|
28
|
+
}[] | undefined;
|
|
29
|
+
}, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "tavily-search", unknown>;
|
|
30
|
+
tavilyExtract: import("@mastra/core/tools").Tool<{
|
|
31
|
+
urls: string[];
|
|
32
|
+
extractDepth?: "basic" | "advanced" | undefined;
|
|
33
|
+
query?: string | undefined;
|
|
34
|
+
includeImages?: boolean | undefined;
|
|
35
|
+
format?: "markdown" | "text" | undefined;
|
|
36
|
+
}, {
|
|
37
|
+
results: {
|
|
38
|
+
url: string;
|
|
39
|
+
rawContent: string;
|
|
40
|
+
images?: string[] | undefined;
|
|
41
|
+
}[];
|
|
42
|
+
failedResults: {
|
|
43
|
+
url: string;
|
|
44
|
+
error: string;
|
|
45
|
+
}[];
|
|
46
|
+
responseTime: number;
|
|
47
|
+
}, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "tavily-extract", unknown>;
|
|
48
|
+
tavilyCrawl: import("@mastra/core/tools").Tool<{
|
|
49
|
+
url: string;
|
|
50
|
+
maxDepth?: number | undefined;
|
|
51
|
+
maxBreadth?: number | undefined;
|
|
52
|
+
limit?: number | undefined;
|
|
53
|
+
instructions?: string | undefined;
|
|
54
|
+
selectPaths?: string[] | undefined;
|
|
55
|
+
selectDomains?: string[] | undefined;
|
|
56
|
+
excludePaths?: string[] | undefined;
|
|
57
|
+
excludeDomains?: string[] | undefined;
|
|
58
|
+
allowExternal?: boolean | undefined;
|
|
59
|
+
extractDepth?: "basic" | "advanced" | undefined;
|
|
60
|
+
includeImages?: boolean | undefined;
|
|
61
|
+
format?: "markdown" | "text" | undefined;
|
|
62
|
+
}, {
|
|
63
|
+
baseUrl: string;
|
|
64
|
+
results: {
|
|
65
|
+
url: string;
|
|
66
|
+
rawContent: string;
|
|
67
|
+
images?: string[] | undefined;
|
|
68
|
+
}[];
|
|
69
|
+
responseTime: number;
|
|
70
|
+
}, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "tavily-crawl", unknown>;
|
|
71
|
+
tavilyMap: import("@mastra/core/tools").Tool<{
|
|
72
|
+
url: string;
|
|
73
|
+
maxDepth?: number | undefined;
|
|
74
|
+
maxBreadth?: number | undefined;
|
|
75
|
+
limit?: number | undefined;
|
|
76
|
+
instructions?: string | undefined;
|
|
77
|
+
selectPaths?: string[] | undefined;
|
|
78
|
+
selectDomains?: string[] | undefined;
|
|
79
|
+
excludePaths?: string[] | undefined;
|
|
80
|
+
excludeDomains?: string[] | undefined;
|
|
81
|
+
allowExternal?: boolean | undefined;
|
|
82
|
+
}, {
|
|
83
|
+
baseUrl: string;
|
|
84
|
+
results: string[];
|
|
85
|
+
responseTime: number;
|
|
86
|
+
}, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "tavily-map", unknown>;
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAMvD,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAO7D"}
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mastra/tavily",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Tavily web search, extract, crawl, and map tools for Mastra agents",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"CHANGELOG.md"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.cjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"./package.json": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build:lib": "tsup --silent --config tsup.config.ts",
|
|
27
|
+
"build:watch": "pnpm build:lib --watch",
|
|
28
|
+
"lint": "eslint .",
|
|
29
|
+
"test": "vitest run"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"mastra",
|
|
33
|
+
"tavily",
|
|
34
|
+
"web-search",
|
|
35
|
+
"tools",
|
|
36
|
+
"ai-agent"
|
|
37
|
+
],
|
|
38
|
+
"license": "Apache-2.0",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/mastra-ai/mastra.git",
|
|
42
|
+
"directory": "integrations/tavily"
|
|
43
|
+
},
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/mastra-ai/mastra/issues"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://mastra.ai",
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=22.13.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"@mastra/core": ">=1.0.0-0 <2.0.0-0",
|
|
53
|
+
"@tavily/core": ">=0.7.0",
|
|
54
|
+
"zod": ">=3.0.0 || >=4.0.0"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@internal/lint": "workspace:*",
|
|
58
|
+
"@internal/types-builder": "workspace:*",
|
|
59
|
+
"@mastra/core": "workspace:*",
|
|
60
|
+
"@tavily/core": "^0.7.2",
|
|
61
|
+
"tsup": "^8.5.1",
|
|
62
|
+
"typescript": "catalog:",
|
|
63
|
+
"vitest": "catalog:",
|
|
64
|
+
"zod": "catalog:"
|
|
65
|
+
}
|
|
66
|
+
}
|