@elizaos/plugin-web-search 0.25.6-alpha.1 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{README.MD → README.md} +7 -7
- package/dist/index.d.ts +4 -2
- package/dist/index.js +168 -196
- package/dist/index.js.map +1 -1
- package/package.json +45 -43
- package/LICENSE +0 -21
package/{README.MD → README.md}
RENAMED
|
@@ -15,7 +15,7 @@ This plugin provides functionality to:
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
|
|
18
|
+
bun install @elizaos/plugin-web-search
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
## Configuration
|
|
@@ -40,10 +40,10 @@ export default {
|
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
**Custom Usage**
|
|
43
|
-
If you want custom usage, for example,
|
|
43
|
+
If you want custom usage, for example, a social media client to search the web before posting, you can also import the webSearchService and use it directly. Here's how you can do it:
|
|
44
44
|
|
|
45
45
|
```typescript
|
|
46
|
-
//
|
|
46
|
+
// Example usage in a social media client
|
|
47
47
|
const webSearchService = new WebSearchService();
|
|
48
48
|
await webSearchService.initialize(runtime);
|
|
49
49
|
const latestNews = await webSearchService.search(
|
|
@@ -58,7 +58,7 @@ const state = await this.runtime.composeState(
|
|
|
58
58
|
}
|
|
59
59
|
);
|
|
60
60
|
|
|
61
|
-
// Then modify the
|
|
61
|
+
// Then modify the post template to include the {{latestNews}} and however you need
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
## Features
|
|
@@ -97,19 +97,19 @@ const response = MaxTokens(searchResult, DEFAULT_MAX_WEB_SEARCH_TOKENS);
|
|
|
97
97
|
### Building
|
|
98
98
|
|
|
99
99
|
```bash
|
|
100
|
-
|
|
100
|
+
bun run build
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
### Testing
|
|
104
104
|
|
|
105
105
|
```bash
|
|
106
|
-
|
|
106
|
+
bun run test
|
|
107
107
|
```
|
|
108
108
|
|
|
109
109
|
### Development Mode
|
|
110
110
|
|
|
111
111
|
```bash
|
|
112
|
-
|
|
112
|
+
bun run dev
|
|
113
113
|
```
|
|
114
114
|
|
|
115
115
|
## Dependencies
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { Plugin } from '@elizaos/core';
|
|
1
|
+
import { SearchCategoryRegistration, Plugin, IAgentRuntime } from '@elizaos/core';
|
|
2
2
|
|
|
3
|
+
declare const WEB_SEARCH_CATEGORY: SearchCategoryRegistration;
|
|
4
|
+
declare function registerWebSearchCategory(runtime: IAgentRuntime): void;
|
|
3
5
|
declare const webSearchPlugin: Plugin;
|
|
4
6
|
|
|
5
|
-
export { webSearchPlugin as default, webSearchPlugin };
|
|
7
|
+
export { WEB_SEARCH_CATEGORY, webSearchPlugin as default, registerWebSearchCategory, webSearchPlugin };
|
package/dist/index.js
CHANGED
|
@@ -1,225 +1,197 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
import {
|
|
3
|
-
elizaLogger
|
|
4
|
-
} from "@elizaos/core";
|
|
5
|
-
import { encodingForModel } from "js-tiktoken";
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { ServiceType as ServiceType2 } from "@elizaos/core";
|
|
6
3
|
|
|
7
4
|
// src/services/webSearchService.ts
|
|
8
|
-
import {
|
|
9
|
-
Service,
|
|
10
|
-
ServiceType
|
|
11
|
-
} from "@elizaos/core";
|
|
5
|
+
import { IWebSearchService, logger, ServiceType } from "@elizaos/core";
|
|
12
6
|
import { tavily } from "@tavily/core";
|
|
13
|
-
|
|
7
|
+
function parsePublishedDate(value) {
|
|
8
|
+
if (!value) return void 0;
|
|
9
|
+
const date = new Date(value);
|
|
10
|
+
return Number.isNaN(date.getTime()) ? void 0 : date;
|
|
11
|
+
}
|
|
12
|
+
function normalizeResponse(query, response) {
|
|
13
|
+
const results = (response.results ?? []).map((result) => {
|
|
14
|
+
const content = result.content ?? "";
|
|
15
|
+
return {
|
|
16
|
+
title: result.title ?? "Untitled",
|
|
17
|
+
url: result.url ?? "",
|
|
18
|
+
description: content,
|
|
19
|
+
content,
|
|
20
|
+
rawContent: result.rawContent,
|
|
21
|
+
score: typeof result.score === "number" ? result.score : 0,
|
|
22
|
+
publishedDate: parsePublishedDate(result.publishedDate)
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
const images = (response.images ?? []).map(
|
|
26
|
+
(image) => typeof image === "string" ? { url: image } : { url: image.url ?? "", description: image.description }
|
|
27
|
+
).filter((image) => image.url);
|
|
28
|
+
return {
|
|
29
|
+
answer: response.answer,
|
|
30
|
+
query: response.query ?? query,
|
|
31
|
+
responseTime: response.responseTime,
|
|
32
|
+
images,
|
|
33
|
+
results
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function freshnessToDays(freshness) {
|
|
37
|
+
switch (freshness) {
|
|
38
|
+
case "day":
|
|
39
|
+
return 1;
|
|
40
|
+
case "week":
|
|
41
|
+
return 7;
|
|
42
|
+
case "month":
|
|
43
|
+
return 30;
|
|
44
|
+
default:
|
|
45
|
+
return 3;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
var WebSearchService = class _WebSearchService extends IWebSearchService {
|
|
49
|
+
static serviceType = ServiceType.WEB_SEARCH;
|
|
50
|
+
capabilityDescription = "Web search and content discovery capabilities";
|
|
14
51
|
tavilyClient;
|
|
15
|
-
async
|
|
16
|
-
const
|
|
17
|
-
|
|
52
|
+
static async start(runtime) {
|
|
53
|
+
const service = new _WebSearchService(runtime);
|
|
54
|
+
await service.initialize(runtime);
|
|
55
|
+
return service;
|
|
56
|
+
}
|
|
57
|
+
async stop() {
|
|
58
|
+
}
|
|
59
|
+
async initialize(runtime) {
|
|
60
|
+
const apiKey = runtime.getSetting("TAVILY_API_KEY");
|
|
61
|
+
if (typeof apiKey !== "string" || apiKey.length === 0) {
|
|
18
62
|
throw new Error("TAVILY_API_KEY is not set");
|
|
19
63
|
}
|
|
20
64
|
this.tavilyClient = tavily({ apiKey });
|
|
21
65
|
}
|
|
22
|
-
getInstance() {
|
|
23
|
-
return _WebSearchService.getInstance();
|
|
24
|
-
}
|
|
25
|
-
static get serviceType() {
|
|
26
|
-
return ServiceType.WEB_SEARCH;
|
|
27
|
-
}
|
|
28
66
|
async search(query, options) {
|
|
29
67
|
try {
|
|
30
68
|
const response = await this.tavilyClient.search(query, {
|
|
31
|
-
includeAnswer: options
|
|
32
|
-
maxResults: options
|
|
33
|
-
topic: options
|
|
34
|
-
searchDepth: options
|
|
35
|
-
includeImages: options
|
|
36
|
-
days: options
|
|
69
|
+
includeAnswer: (options == null ? void 0 : options.includeAnswer) ?? true,
|
|
70
|
+
maxResults: (options == null ? void 0 : options.limit) ?? 3,
|
|
71
|
+
topic: (options == null ? void 0 : options.topic) ?? (options == null ? void 0 : options.type) ?? "general",
|
|
72
|
+
searchDepth: (options == null ? void 0 : options.searchDepth) ?? "basic",
|
|
73
|
+
includeImages: (options == null ? void 0 : options.includeImages) ?? false,
|
|
74
|
+
days: (options == null ? void 0 : options.days) ?? 3
|
|
37
75
|
});
|
|
38
|
-
return response;
|
|
39
|
-
} catch (
|
|
40
|
-
|
|
41
|
-
|
|
76
|
+
return normalizeResponse(query, response);
|
|
77
|
+
} catch (cause) {
|
|
78
|
+
const err = cause instanceof Error ? cause : new Error(String(cause));
|
|
79
|
+
logger.error({ src: "plugin-web-search", err }, "Web search error");
|
|
80
|
+
throw err;
|
|
42
81
|
}
|
|
43
82
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
83
|
+
async searchNews(query, options) {
|
|
84
|
+
return this.search(query, {
|
|
85
|
+
...options,
|
|
86
|
+
type: "news",
|
|
87
|
+
topic: "news",
|
|
88
|
+
days: freshnessToDays(options == null ? void 0 : options.freshness)
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
async searchImages(query, options) {
|
|
92
|
+
return this.search(query, {
|
|
93
|
+
limit: options == null ? void 0 : options.limit,
|
|
94
|
+
offset: options == null ? void 0 : options.offset,
|
|
95
|
+
language: options == null ? void 0 : options.language,
|
|
96
|
+
region: options == null ? void 0 : options.region,
|
|
97
|
+
dateRange: options == null ? void 0 : options.dateRange,
|
|
98
|
+
fileType: options == null ? void 0 : options.fileType,
|
|
99
|
+
site: options == null ? void 0 : options.site,
|
|
100
|
+
sortBy: options == null ? void 0 : options.sortBy,
|
|
101
|
+
safeSearch: options == null ? void 0 : options.safeSearch,
|
|
102
|
+
includeImages: true
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
async searchVideos(query, options) {
|
|
106
|
+
return this.search(query, options);
|
|
107
|
+
}
|
|
108
|
+
async getSuggestions(_query) {
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
async getTrendingSearches(_region) {
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
async getPageInfo(url) {
|
|
115
|
+
var _a, _b;
|
|
116
|
+
const response = await fetch(url);
|
|
117
|
+
const content = await response.text();
|
|
118
|
+
const title = ((_a = content.match(/<title[^>]*>(.*?)<\/title>/i)) == null ? void 0 : _a[1]) ?? url;
|
|
119
|
+
const description = ((_b = content.match(/<meta\s+name=["']description["']\s+content=["']([^"']+)/i)) == null ? void 0 : _b[1]) ?? "";
|
|
120
|
+
return {
|
|
121
|
+
title,
|
|
122
|
+
description,
|
|
123
|
+
content,
|
|
124
|
+
metadata: {},
|
|
125
|
+
images: [],
|
|
126
|
+
links: []
|
|
127
|
+
};
|
|
56
128
|
}
|
|
57
|
-
return data;
|
|
58
|
-
}
|
|
59
|
-
var webSearch = {
|
|
60
|
-
name: "WEB_SEARCH",
|
|
61
|
-
similes: [
|
|
62
|
-
"SEARCH_WEB",
|
|
63
|
-
"INTERNET_SEARCH",
|
|
64
|
-
"LOOKUP",
|
|
65
|
-
"QUERY_WEB",
|
|
66
|
-
"FIND_ONLINE",
|
|
67
|
-
"SEARCH_ENGINE",
|
|
68
|
-
"WEB_LOOKUP",
|
|
69
|
-
"ONLINE_SEARCH",
|
|
70
|
-
"FIND_INFORMATION"
|
|
71
|
-
],
|
|
72
|
-
suppressInitialMessage: true,
|
|
73
|
-
description: "Perform a web search to find information related to the message.",
|
|
74
|
-
// eslint-disable-next-line
|
|
75
|
-
validate: async (runtime, message) => {
|
|
76
|
-
const tavilyApiKeyOk = !!runtime.getSetting("TAVILY_API_KEY");
|
|
77
|
-
return tavilyApiKeyOk;
|
|
78
|
-
},
|
|
79
|
-
handler: async (runtime, message, state, options, callback) => {
|
|
80
|
-
elizaLogger.log("Composing state for message:", message);
|
|
81
|
-
state = await runtime.composeState(message);
|
|
82
|
-
const userId = runtime.agentId;
|
|
83
|
-
elizaLogger.log("User ID:", userId);
|
|
84
|
-
const webSearchPrompt = message.content.text;
|
|
85
|
-
elizaLogger.log("web search prompt received:", webSearchPrompt);
|
|
86
|
-
const webSearchService = new WebSearchService();
|
|
87
|
-
await webSearchService.initialize(runtime);
|
|
88
|
-
const searchResponse = await webSearchService.search(
|
|
89
|
-
webSearchPrompt
|
|
90
|
-
);
|
|
91
|
-
if (searchResponse && searchResponse.results.length) {
|
|
92
|
-
const responseList = searchResponse.answer ? `${searchResponse.answer}${Array.isArray(searchResponse.results) && searchResponse.results.length > 0 ? `
|
|
93
|
-
|
|
94
|
-
For more details, you can check out these resources:
|
|
95
|
-
${searchResponse.results.map(
|
|
96
|
-
(result, index) => `${index + 1}. [${result.title}](${result.url})`
|
|
97
|
-
).join("\n")}` : ""}` : "";
|
|
98
|
-
callback({
|
|
99
|
-
text: MaxTokens(responseList, DEFAULT_MAX_WEB_SEARCH_TOKENS)
|
|
100
|
-
});
|
|
101
|
-
} else {
|
|
102
|
-
elizaLogger.error("search failed or returned no data.");
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
examples: [
|
|
106
|
-
[
|
|
107
|
-
{
|
|
108
|
-
user: "{{user1}}",
|
|
109
|
-
content: {
|
|
110
|
-
text: "Find the latest news about SpaceX launches."
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
user: "{{agentName}}",
|
|
115
|
-
content: {
|
|
116
|
-
text: "Here is the latest news about SpaceX launches:",
|
|
117
|
-
action: "WEB_SEARCH"
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
],
|
|
121
|
-
[
|
|
122
|
-
{
|
|
123
|
-
user: "{{user1}}",
|
|
124
|
-
content: {
|
|
125
|
-
text: "Can you find details about the iPhone 16 release?"
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
user: "{{agentName}}",
|
|
130
|
-
content: {
|
|
131
|
-
text: "Here are the details I found about the iPhone 16 release:",
|
|
132
|
-
action: "WEB_SEARCH"
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
],
|
|
136
|
-
[
|
|
137
|
-
{
|
|
138
|
-
user: "{{user1}}",
|
|
139
|
-
content: {
|
|
140
|
-
text: "What is the schedule for the next FIFA World Cup?"
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
user: "{{agentName}}",
|
|
145
|
-
content: {
|
|
146
|
-
text: "Here is the schedule for the next FIFA World Cup:",
|
|
147
|
-
action: "WEB_SEARCH"
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
],
|
|
151
|
-
[
|
|
152
|
-
{
|
|
153
|
-
user: "{{user1}}",
|
|
154
|
-
content: { text: "Check the latest stock price of Tesla." }
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
user: "{{agentName}}",
|
|
158
|
-
content: {
|
|
159
|
-
text: "Here is the latest stock price of Tesla I found:",
|
|
160
|
-
action: "WEB_SEARCH"
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
],
|
|
164
|
-
[
|
|
165
|
-
{
|
|
166
|
-
user: "{{user1}}",
|
|
167
|
-
content: {
|
|
168
|
-
text: "What are the current trending movies in the US?"
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
user: "{{agentName}}",
|
|
173
|
-
content: {
|
|
174
|
-
text: "Here are the current trending movies in the US:",
|
|
175
|
-
action: "WEB_SEARCH"
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
],
|
|
179
|
-
[
|
|
180
|
-
{
|
|
181
|
-
user: "{{user1}}",
|
|
182
|
-
content: {
|
|
183
|
-
text: "What is the latest score in the NBA finals?"
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
user: "{{agentName}}",
|
|
188
|
-
content: {
|
|
189
|
-
text: "Here is the latest score from the NBA finals:",
|
|
190
|
-
action: "WEB_SEARCH"
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
],
|
|
194
|
-
[
|
|
195
|
-
{
|
|
196
|
-
user: "{{user1}}",
|
|
197
|
-
content: { text: "When is the next Apple keynote event?" }
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
user: "{{agentName}}",
|
|
201
|
-
content: {
|
|
202
|
-
text: "Here is the information about the next Apple keynote event:",
|
|
203
|
-
action: "WEB_SEARCH"
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
]
|
|
207
|
-
]
|
|
208
129
|
};
|
|
209
130
|
|
|
210
131
|
// src/index.ts
|
|
132
|
+
var WEB_SEARCH_CATEGORY = {
|
|
133
|
+
category: "web",
|
|
134
|
+
label: "Web",
|
|
135
|
+
description: "Search current web pages through plugin-web-search.",
|
|
136
|
+
contexts: ["knowledge", "browser"],
|
|
137
|
+
filters: [
|
|
138
|
+
{
|
|
139
|
+
name: "topic",
|
|
140
|
+
label: "Topic",
|
|
141
|
+
description: "Tavily search topic.",
|
|
142
|
+
type: "enum",
|
|
143
|
+
options: [
|
|
144
|
+
{ label: "General", value: "general" },
|
|
145
|
+
{ label: "News", value: "news" }
|
|
146
|
+
]
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: "searchDepth",
|
|
150
|
+
label: "Search depth",
|
|
151
|
+
description: "Tavily search depth.",
|
|
152
|
+
type: "enum",
|
|
153
|
+
options: [
|
|
154
|
+
{ label: "Basic", value: "basic" },
|
|
155
|
+
{ label: "Advanced", value: "advanced" }
|
|
156
|
+
]
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: "includeImages",
|
|
160
|
+
label: "Include images",
|
|
161
|
+
description: "Include image results when available.",
|
|
162
|
+
type: "boolean"
|
|
163
|
+
}
|
|
164
|
+
],
|
|
165
|
+
resultSchemaSummary: "SearchResponse with query, answer, results containing title/url/description/content/score, and optional images.",
|
|
166
|
+
capabilities: ["web", "news", "current-information"],
|
|
167
|
+
source: "plugin-web-search",
|
|
168
|
+
serviceType: ServiceType2.WEB_SEARCH
|
|
169
|
+
};
|
|
170
|
+
function registerWebSearchCategory(runtime) {
|
|
171
|
+
try {
|
|
172
|
+
runtime.getSearchCategory(WEB_SEARCH_CATEGORY.category, {
|
|
173
|
+
includeDisabled: true
|
|
174
|
+
});
|
|
175
|
+
return;
|
|
176
|
+
} catch {
|
|
177
|
+
runtime.registerSearchCategory(WEB_SEARCH_CATEGORY);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
211
180
|
var webSearchPlugin = {
|
|
212
181
|
name: "webSearch",
|
|
213
182
|
description: "Search the web and get news",
|
|
214
|
-
|
|
215
|
-
|
|
183
|
+
init: async (_config, runtime) => {
|
|
184
|
+
registerWebSearchCategory(runtime);
|
|
185
|
+
},
|
|
186
|
+
actions: [],
|
|
216
187
|
providers: [],
|
|
217
|
-
services: [
|
|
218
|
-
clients: []
|
|
188
|
+
services: [WebSearchService]
|
|
219
189
|
};
|
|
220
190
|
var index_default = webSearchPlugin;
|
|
221
191
|
export {
|
|
192
|
+
WEB_SEARCH_CATEGORY,
|
|
222
193
|
index_default as default,
|
|
194
|
+
registerWebSearchCategory,
|
|
223
195
|
webSearchPlugin
|
|
224
196
|
};
|
|
225
197
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/actions/webSearch.ts","../src/services/webSearchService.ts","../src/index.ts"],"sourcesContent":["import {\n type Action,\n type HandlerCallback,\n type IAgentRuntime,\n type Memory,\n type State,\n elizaLogger\n} from \"@elizaos/core\";\nimport { encodingForModel, type TiktokenModel } from \"js-tiktoken\";\nimport { WebSearchService } from \"../services/webSearchService\";\nimport type { SearchResult } from \"../types\";\n\nconst DEFAULT_MAX_WEB_SEARCH_TOKENS = 4000;\nconst DEFAULT_MODEL_ENCODING = \"gpt-3.5-turbo\";\n\nfunction getTotalTokensFromString(\n str: string,\n encodingName: TiktokenModel = DEFAULT_MODEL_ENCODING\n) {\n const encoding = encodingForModel(encodingName);\n return encoding.encode(str).length;\n}\n\nfunction MaxTokens(\n data: string,\n maxTokens: number = DEFAULT_MAX_WEB_SEARCH_TOKENS\n): string {\n if (getTotalTokensFromString(data) >= maxTokens) {\n return data.slice(0, maxTokens);\n }\n return data;\n}\n\nexport const webSearch: Action = {\n name: \"WEB_SEARCH\",\n similes: [\n \"SEARCH_WEB\",\n \"INTERNET_SEARCH\",\n \"LOOKUP\",\n \"QUERY_WEB\",\n \"FIND_ONLINE\",\n \"SEARCH_ENGINE\",\n \"WEB_LOOKUP\",\n \"ONLINE_SEARCH\",\n \"FIND_INFORMATION\",\n ],\n suppressInitialMessage: true,\n description:\n \"Perform a web search to find information related to the message.\",\n // eslint-disable-next-line\n validate: async (runtime: IAgentRuntime, message: Memory) => {\n const tavilyApiKeyOk = !!runtime.getSetting(\"TAVILY_API_KEY\");\n\n return tavilyApiKeyOk;\n },\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n state: State,\n options: any,\n callback: HandlerCallback\n ) => {\n elizaLogger.log(\"Composing state for message:\", message);\n state = (await runtime.composeState(message)) as State;\n const userId = runtime.agentId;\n elizaLogger.log(\"User ID:\", userId);\n\n const webSearchPrompt = message.content.text;\n elizaLogger.log(\"web search prompt received:\", webSearchPrompt);\n\n const webSearchService = new WebSearchService();\n await webSearchService.initialize(runtime);\n const searchResponse = await webSearchService.search(\n webSearchPrompt,\n );\n\n if (searchResponse && searchResponse.results.length) {\n const responseList = searchResponse.answer\n ? `${searchResponse.answer}${\n Array.isArray(searchResponse.results) &&\n searchResponse.results.length > 0\n ? `\\n\\nFor more details, you can check out these resources:\\n${searchResponse.results\n .map(\n (result: SearchResult, index: number) =>\n `${index + 1}. [${result.title}](${result.url})`\n )\n .join(\"\\n\")}`\n : \"\"\n }`\n : \"\";\n\n callback({\n text: MaxTokens(responseList, DEFAULT_MAX_WEB_SEARCH_TOKENS),\n });\n } else {\n elizaLogger.error(\"search failed or returned no data.\");\n }\n },\n examples: [\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"Find the latest news about SpaceX launches.\",\n },\n },\n {\n user: \"{{agentName}}\",\n content: {\n text: \"Here is the latest news about SpaceX launches:\",\n action: \"WEB_SEARCH\",\n },\n },\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"Can you find details about the iPhone 16 release?\",\n },\n },\n {\n user: \"{{agentName}}\",\n content: {\n text: \"Here are the details I found about the iPhone 16 release:\",\n action: \"WEB_SEARCH\",\n },\n },\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What is the schedule for the next FIFA World Cup?\",\n },\n },\n {\n user: \"{{agentName}}\",\n content: {\n text: \"Here is the schedule for the next FIFA World Cup:\",\n action: \"WEB_SEARCH\",\n },\n },\n ],\n [\n {\n user: \"{{user1}}\",\n content: { text: \"Check the latest stock price of Tesla.\" },\n },\n {\n user: \"{{agentName}}\",\n content: {\n text: \"Here is the latest stock price of Tesla I found:\",\n action: \"WEB_SEARCH\",\n },\n },\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What are the current trending movies in the US?\",\n },\n },\n {\n user: \"{{agentName}}\",\n content: {\n text: \"Here are the current trending movies in the US:\",\n action: \"WEB_SEARCH\",\n },\n },\n ],\n [\n {\n user: \"{{user1}}\",\n content: {\n text: \"What is the latest score in the NBA finals?\",\n },\n },\n {\n user: \"{{agentName}}\",\n content: {\n text: \"Here is the latest score from the NBA finals:\",\n action: \"WEB_SEARCH\",\n },\n },\n ],\n [\n {\n user: \"{{user1}}\",\n content: { text: \"When is the next Apple keynote event?\" },\n },\n {\n user: \"{{agentName}}\",\n content: {\n text: \"Here is the information about the next Apple keynote event:\",\n action: \"WEB_SEARCH\",\n },\n },\n ],\n ],\n} as Action;","import {\n Service,\n type IAgentRuntime,\n ServiceType,\n} from \"@elizaos/core\";\nimport { tavily } from \"@tavily/core\";\nimport type { IWebSearchService, SearchOptions, SearchResponse } from \"../types\";\n\nexport type TavilyClient = ReturnType<typeof tavily>; // declaring manually because original package does not export its types\n\nexport class WebSearchService extends Service implements IWebSearchService {\n public tavilyClient: TavilyClient\n\n async initialize(_runtime: IAgentRuntime): Promise<void> {\n const apiKey = _runtime.getSetting(\"TAVILY_API_KEY\") as string;\n if (!apiKey) {\n throw new Error(\"TAVILY_API_KEY is not set\");\n }\n this.tavilyClient = tavily({ apiKey });\n }\n\n getInstance(): IWebSearchService {\n return WebSearchService.getInstance();\n }\n\n static get serviceType(): ServiceType {\n return ServiceType.WEB_SEARCH;\n }\n\n async search(\n query: string,\n options?: SearchOptions,\n ): Promise<SearchResponse> {\n try {\n const response = await this.tavilyClient.search(query, {\n includeAnswer: options?.includeAnswer || true,\n maxResults: options?.limit || 3,\n topic: options?.type || \"general\",\n searchDepth: options?.searchDepth || \"basic\",\n includeImages: options?.includeImages || false,\n days: options?.days || 3,\n });\n\n return response;\n } catch (error) {\n console.error(\"Web search error:\", error);\n throw error;\n }\n }\n}\n","import { webSearch } from \"./actions/webSearch\";\nimport type { Plugin } from \"@elizaos/core\";\nimport { WebSearchService } from \"./services/webSearchService\";\n\nexport const webSearchPlugin: Plugin = {\n name: \"webSearch\",\n description: \"Search the web and get news\",\n actions: [webSearch],\n evaluators: [],\n providers: [],\n services: [new WebSearchService()],\n clients: [],\n};\n\nexport default webSearchPlugin;\n"],"mappings":";AAAA;AAAA,EAMI;AAAA,OACG;AACP,SAAS,wBAA4C;;;ACRrD;AAAA,EACI;AAAA,EAEA;AAAA,OACG;AACP,SAAS,cAAc;AAKhB,IAAM,mBAAN,MAAM,0BAAyB,QAAqC;AAAA,EAChE;AAAA,EAEP,MAAM,WAAW,UAAwC;AACrD,UAAM,SAAS,SAAS,WAAW,gBAAgB;AACnD,QAAI,CAAC,QAAQ;AACT,YAAM,IAAI,MAAM,2BAA2B;AAAA,IAC/C;AACA,SAAK,eAAe,OAAO,EAAE,OAAO,CAAC;AAAA,EACzC;AAAA,EAEA,cAAiC;AAC7B,WAAO,kBAAiB,YAAY;AAAA,EACxC;AAAA,EAEA,WAAW,cAA2B;AAClC,WAAO,YAAY;AAAA,EACvB;AAAA,EAEA,MAAM,OACF,OACA,SACuB;AACvB,QAAI;AACA,YAAM,WAAW,MAAM,KAAK,aAAa,OAAO,OAAO;AAAA,QACnD,eAAe,SAAS,iBAAiB;AAAA,QACzC,YAAY,SAAS,SAAS;AAAA,QAC9B,OAAO,SAAS,QAAQ;AAAA,QACxB,aAAa,SAAS,eAAe;AAAA,QACrC,eAAe,SAAS,iBAAiB;AAAA,QACzC,MAAM,SAAS,QAAQ;AAAA,MAC3B,CAAC;AAED,aAAO;AAAA,IACX,SAAS,OAAO;AACZ,cAAQ,MAAM,qBAAqB,KAAK;AACxC,YAAM;AAAA,IACV;AAAA,EACJ;AACJ;;;ADrCA,IAAM,gCAAgC;AACtC,IAAM,yBAAyB;AAE/B,SAAS,yBACL,KACA,eAA8B,wBAChC;AACE,QAAM,WAAW,iBAAiB,YAAY;AAC9C,SAAO,SAAS,OAAO,GAAG,EAAE;AAChC;AAEA,SAAS,UACL,MACA,YAAoB,+BACd;AACN,MAAI,yBAAyB,IAAI,KAAK,WAAW;AAC7C,WAAO,K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A,MACJ;AAAA,IACJ;AAAA,IACA;AAAA,MACI;AAAA,QACI,MAAM;AAAA,QACN,SAAS,EAAE,MAAM,wCAAwC;AAAA,MAC7D;AAAA,MACA;AAAA,QACI,MAAM;AAAA,QACN,SAAS;AAAA,UACL,MAAM;AAAA,UACN,QAAQ;AAAA,QACZ;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;;;AErMO,IAAM,kBAA0B;AAAA,EACnC,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS,CAAC,SAAS;AAAA,EACnB,YAAY,CAAC;AAAA,EACb,WAAW,CAAC;AAAA,EACZ,UAAU,CAAC,IAAI,iBAAiB,CAAC;AAAA,EACjC,SAAS,CAAC;AACd;AAEA,IAAO,gBAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/services/webSearchService.ts"],"sourcesContent":["import type { IAgentRuntime, Plugin, SearchCategoryRegistration } from \"@elizaos/core\";\nimport { ServiceType } from \"@elizaos/core\";\n\nimport { WebSearchService } from \"./services/webSearchService\";\n\nexport const WEB_SEARCH_CATEGORY: SearchCategoryRegistration = {\n category: \"web\",\n label: \"Web\",\n description: \"Search current web pages through plugin-web-search.\",\n contexts: [\"knowledge\", \"browser\"],\n filters: [\n {\n name: \"topic\",\n label: \"Topic\",\n description: \"Tavily search topic.\",\n type: \"enum\",\n options: [\n { label: \"General\", value: \"general\" },\n { label: \"News\", value: \"news\" },\n ],\n },\n {\n name: \"searchDepth\",\n label: \"Search depth\",\n description: \"Tavily search depth.\",\n type: \"enum\",\n options: [\n { label: \"Basic\", value: \"basic\" },\n { label: \"Advanced\", value: \"advanced\" },\n ],\n },\n {\n name: \"includeImages\",\n label: \"Include images\",\n description: \"Include image results when available.\",\n type: \"boolean\",\n },\n ],\n resultSchemaSummary:\n \"SearchResponse with query, answer, results containing title/url/description/content/score, and optional images.\",\n capabilities: [\"web\", \"news\", \"current-information\"],\n source: \"plugin-web-search\",\n serviceType: ServiceType.WEB_SEARCH,\n};\n\nexport function registerWebSearchCategory(runtime: IAgentRuntime): void {\n try {\n runtime.getSearchCategory(WEB_SEARCH_CATEGORY.category, {\n includeDisabled: true,\n });\n return;\n } catch {\n runtime.registerSearchCategory(WEB_SEARCH_CATEGORY);\n }\n}\n\nexport const webSearchPlugin: Plugin = {\n name: \"webSearch\",\n description: \"Search the web and get news\",\n init: async (_config, runtime) => {\n registerWebSearchCategory(runtime);\n },\n actions: [],\n providers: [],\n services: [WebSearchService],\n};\n\nexport default webSearchPlugin;\n","import { type IAgentRuntime, IWebSearchService, logger, ServiceType } from \"@elizaos/core\";\nimport { tavily } from \"@tavily/core\";\n\nimport type {\n ImageSearchOptions,\n NewsSearchOptions,\n SearchOptions,\n SearchResponse,\n VideoSearchOptions,\n} from \"../types\";\n\nexport type TavilyClient = ReturnType<typeof tavily>;\n\ntype TavilySearchResult = {\n title?: string;\n url?: string;\n content?: string;\n rawContent?: string;\n score?: number;\n publishedDate?: string;\n};\n\ntype TavilySearchResponse = {\n answer?: string;\n query?: string;\n responseTime?: number;\n images?: Array<{ url?: string; description?: string } | string>;\n results?: TavilySearchResult[];\n};\n\nfunction parsePublishedDate(value: string | undefined): Date | undefined {\n if (!value) return undefined;\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? undefined : date;\n}\n\nfunction normalizeResponse(query: string, response: TavilySearchResponse): SearchResponse {\n const results = (response.results ?? []).map((result) => {\n const content = result.content ?? \"\";\n return {\n title: result.title ?? \"Untitled\",\n url: result.url ?? \"\",\n description: content,\n content,\n rawContent: result.rawContent,\n score: typeof result.score === \"number\" ? result.score : 0,\n publishedDate: parsePublishedDate(result.publishedDate),\n };\n });\n const images = (response.images ?? [])\n .map((image) =>\n typeof image === \"string\"\n ? { url: image }\n : { url: image.url ?? \"\", description: image.description }\n )\n .filter((image) => image.url);\n\n return {\n answer: response.answer,\n query: response.query ?? query,\n responseTime: response.responseTime,\n images,\n results,\n };\n}\n\nfunction freshnessToDays(freshness: NewsSearchOptions[\"freshness\"]): number {\n switch (freshness) {\n case \"day\":\n return 1;\n case \"week\":\n return 7;\n case \"month\":\n return 30;\n default:\n return 3;\n }\n}\n\nexport class WebSearchService extends IWebSearchService {\n static override serviceType = ServiceType.WEB_SEARCH;\n override capabilityDescription = \"Web search and content discovery capabilities\" as const;\n\n tavilyClient!: TavilyClient;\n\n static override async start(runtime: IAgentRuntime): Promise<WebSearchService> {\n const service = new WebSearchService(runtime);\n await service.initialize(runtime);\n return service;\n }\n\n async stop(): Promise<void> {\n // Tavily client is stateless HTTP; nothing to tear down.\n }\n\n private async initialize(runtime: IAgentRuntime): Promise<void> {\n const apiKey = runtime.getSetting(\"TAVILY_API_KEY\");\n if (typeof apiKey !== \"string\" || apiKey.length === 0) {\n throw new Error(\"TAVILY_API_KEY is not set\");\n }\n this.tavilyClient = tavily({ apiKey });\n }\n\n async search(query: string, options?: SearchOptions): Promise<SearchResponse> {\n try {\n const response = await this.tavilyClient.search(query, {\n includeAnswer: options?.includeAnswer ?? true,\n maxResults: options?.limit ?? 3,\n topic: options?.topic ?? options?.type ?? \"general\",\n searchDepth: options?.searchDepth ?? \"basic\",\n includeImages: options?.includeImages ?? false,\n days: options?.days ?? 3,\n });\n\n return normalizeResponse(query, response as TavilySearchResponse);\n } catch (cause) {\n const err = cause instanceof Error ? cause : new Error(String(cause));\n logger.error({ src: \"plugin-web-search\", err }, \"Web search error\");\n throw err;\n }\n }\n\n async searchNews(query: string, options?: NewsSearchOptions): Promise<SearchResponse> {\n return this.search(query, {\n ...options,\n type: \"news\",\n topic: \"news\",\n days: freshnessToDays(options?.freshness),\n });\n }\n\n async searchImages(query: string, options?: ImageSearchOptions): Promise<SearchResponse> {\n return this.search(query, {\n limit: options?.limit,\n offset: options?.offset,\n language: options?.language,\n region: options?.region,\n dateRange: options?.dateRange,\n fileType: options?.fileType,\n site: options?.site,\n sortBy: options?.sortBy,\n safeSearch: options?.safeSearch,\n includeImages: true,\n });\n }\n\n async searchVideos(query: string, options?: VideoSearchOptions): Promise<SearchResponse> {\n return this.search(query, options);\n }\n\n async getSuggestions(_query: string): Promise<string[]> {\n return [];\n }\n\n async getTrendingSearches(_region?: string): Promise<string[]> {\n return [];\n }\n\n async getPageInfo(url: string): Promise<{\n title: string;\n description: string;\n content: string;\n metadata: Record<string, string>;\n images: string[];\n links: string[];\n }> {\n const response = await fetch(url);\n const content = await response.text();\n const title = content.match(/<title[^>]*>(.*?)<\\/title>/i)?.[1] ?? url;\n const description =\n content.match(/<meta\\s+name=[\"']description[\"']\\s+content=[\"']([^\"']+)/i)?.[1] ?? \"\";\n return {\n title,\n description,\n content,\n metadata: {},\n images: [],\n links: [],\n };\n }\n}\n"],"mappings":";AACA,SAAS,eAAAA,oBAAmB;;;ACD5B,SAA6B,mBAAmB,QAAQ,mBAAmB;AAC3E,SAAS,cAAc;AA6BvB,SAAS,mBAAmB,OAA6C;AACrE,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,OAAO,IAAI,KAAK,KAAK;AAC3B,SAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,IAAI,SAAY;AACtD;AAEA,SAAS,kBAAkB,OAAe,UAAgD;AACtF,QAAM,WAAW,SAAS,WAAW,CAAC,GAAG,IAAI,CAAC,WAAW;AACrD,UAAM,UAAU,OAAO,WAAW;AAClC,WAAO;AAAA,MACH,OAAO,OAAO,SAAS;AAAA,MACvB,KAAK,OAAO,OAAO;AAAA,MACnB,aAAa;AAAA,MACb;AAAA,MACA,YAAY,OAAO;AAAA,MACnB,OAAO,OAAO,OAAO,UAAU,WAAW,OAAO,QAAQ;AAAA,MACzD,eAAe,mBAAmB,OAAO,aAAa;AAAA,IAC1D;AAAA,EACJ,CAAC;AACD,QAAM,UAAU,SAAS,UAAU,CAAC,GAC/B;AAAA,IAAI,CAAC,UACF,OAAO,UAAU,WACX,EAAE,KAAK,MAAM,IACb,EAAE,KAAK,MAAM,OAAO,IAAI,aAAa,MAAM,YAAY;AAAA,EACjE,EACC,OAAO,CAAC,UAAU,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45 +1,47 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
2
|
+
"name": "@elizaos/plugin-web-search",
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./package.json": "./package.json",
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@elizaos/core": "2.0.0-beta.1",
|
|
22
|
+
"@tavily/core": "^0.7.0",
|
|
23
|
+
"js-tiktoken": "1.0.21",
|
|
24
|
+
"tsup": "^8.5.1"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@biomejs/biome": "2.4.14"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsup --format esm --dts",
|
|
31
|
+
"dev": "tsup --format esm --dts --watch",
|
|
32
|
+
"lint": "biome check src/",
|
|
33
|
+
"lint:fix": "biome check --write src/",
|
|
34
|
+
"format": "biome format src/",
|
|
35
|
+
"format:fix": "biome format --write src/",
|
|
36
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
37
|
+
},
|
|
38
|
+
"agentConfig": {
|
|
39
|
+
"pluginType": "elizaos:client:1.0.0",
|
|
40
|
+
"pluginParameters": {
|
|
41
|
+
"TAVILY_API_KEY": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"description": "Tavily API key for accessing news services"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
45
47
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Shaw Walters, aka Moon aka @lalalune
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|