@elizaos/plugin-web-search 2.0.3-beta.5 → 2.0.3-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ import { SearchCategoryRegistration, Plugin, IAgentRuntime } from '@elizaos/core';
2
+
3
+ declare const WEB_SEARCH_CATEGORY: SearchCategoryRegistration;
4
+ declare function registerWebSearchCategory(runtime: IAgentRuntime): void;
5
+ declare const webSearchPlugin: Plugin;
6
+
7
+ export { WEB_SEARCH_CATEGORY, webSearchPlugin as default, registerWebSearchCategory, webSearchPlugin };
package/dist/index.js ADDED
@@ -0,0 +1,308 @@
1
+ // src/index.ts
2
+ import { ServiceType as ServiceType2 } from "@elizaos/core";
3
+
4
+ // src/services/webSearchService.ts
5
+ import { IWebSearchService, logger, ServiceType } from "@elizaos/core";
6
+ import { tavily } from "@tavily/core";
7
+ function isRecord(value) {
8
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
9
+ }
10
+ function parsePublishedDate(value) {
11
+ if (!value) return void 0;
12
+ const date = new Date(value);
13
+ return Number.isNaN(date.getTime()) ? void 0 : date;
14
+ }
15
+ function normalizeApiKey(value) {
16
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
17
+ }
18
+ function validateSearchQuery(query) {
19
+ if (typeof query !== "string" || !query.trim()) {
20
+ throw new Error("search query is required");
21
+ }
22
+ return query.trim();
23
+ }
24
+ function assertOptionalPositiveInteger(value, name) {
25
+ if (value !== void 0 && (typeof value !== "number" || !Number.isFinite(value) || !Number.isInteger(value) || value < 1)) {
26
+ throw new Error(`${name} must be a positive finite integer`);
27
+ }
28
+ }
29
+ function assertOptionalNonNegativeInteger(value, name) {
30
+ if (value !== void 0 && (typeof value !== "number" || !Number.isFinite(value) || !Number.isInteger(value) || value < 0)) {
31
+ throw new Error(`${name} must be a non-negative finite integer`);
32
+ }
33
+ }
34
+ function validateSearchOptions(options) {
35
+ if (options === void 0) return;
36
+ if (!isRecord(options)) {
37
+ throw new Error("search options must be an object");
38
+ }
39
+ assertOptionalPositiveInteger(options.limit, "limit");
40
+ assertOptionalNonNegativeInteger(options.days, "days");
41
+ if (options.topic !== void 0 && options.topic !== "general" && options.topic !== "news") {
42
+ throw new Error("topic must be general or news");
43
+ }
44
+ if (options.type !== void 0 && options.type !== "general" && options.type !== "news") {
45
+ throw new Error("type must be general or news");
46
+ }
47
+ if (options.searchDepth !== void 0 && options.searchDepth !== "basic" && options.searchDepth !== "advanced") {
48
+ throw new Error("searchDepth must be basic or advanced");
49
+ }
50
+ if (options.includeAnswer !== void 0 && typeof options.includeAnswer !== "boolean") {
51
+ throw new Error("includeAnswer must be a boolean");
52
+ }
53
+ if (options.includeImages !== void 0 && typeof options.includeImages !== "boolean") {
54
+ throw new Error("includeImages must be a boolean");
55
+ }
56
+ }
57
+ function normalizeResponse(query, response) {
58
+ const payload = isRecord(response) ? response : {};
59
+ const rawResults = Array.isArray(payload.results) ? payload.results : [];
60
+ const results = rawResults.filter(isRecord).map((result) => {
61
+ const content = typeof result.content === "string" ? result.content : "";
62
+ return {
63
+ title: typeof result.title === "string" ? result.title : "Untitled",
64
+ url: typeof result.url === "string" ? result.url : "",
65
+ description: content,
66
+ content,
67
+ rawContent: typeof result.rawContent === "string" ? result.rawContent : void 0,
68
+ score: typeof result.score === "number" && Number.isFinite(result.score) ? result.score : 0,
69
+ publishedDate: parsePublishedDate(
70
+ typeof result.publishedDate === "string" ? result.publishedDate : void 0
71
+ )
72
+ };
73
+ });
74
+ const rawImages = Array.isArray(payload.images) ? payload.images : [];
75
+ const images = rawImages.map(
76
+ (image) => typeof image === "string" ? { url: image } : isRecord(image) ? {
77
+ url: typeof image.url === "string" ? image.url : "",
78
+ description: typeof image.description === "string" ? image.description : void 0
79
+ } : { url: "" }
80
+ ).filter((image) => image.url);
81
+ return {
82
+ answer: typeof payload.answer === "string" ? payload.answer : void 0,
83
+ query: typeof payload.query === "string" ? payload.query : query,
84
+ responseTime: typeof payload.responseTime === "number" ? payload.responseTime : void 0,
85
+ images,
86
+ results
87
+ };
88
+ }
89
+ function uniqueResultTitles(response, limit) {
90
+ const seen = /* @__PURE__ */ new Set();
91
+ const titles = [];
92
+ for (const result of response.results) {
93
+ const title = result.title.trim();
94
+ if (!title || title === "Untitled") continue;
95
+ const key = title.toLocaleLowerCase();
96
+ if (seen.has(key)) continue;
97
+ seen.add(key);
98
+ titles.push(title);
99
+ if (titles.length >= limit) break;
100
+ }
101
+ return titles;
102
+ }
103
+ function freshnessToDays(freshness) {
104
+ switch (freshness) {
105
+ case "day":
106
+ return 1;
107
+ case "week":
108
+ return 7;
109
+ case "month":
110
+ return 30;
111
+ default:
112
+ return 3;
113
+ }
114
+ }
115
+ var WebSearchService = class _WebSearchService extends IWebSearchService {
116
+ static serviceType = ServiceType.WEB_SEARCH;
117
+ capabilityDescription = "Web search and content discovery capabilities";
118
+ tavilyClient;
119
+ configured = false;
120
+ static async start(runtime) {
121
+ const service = new _WebSearchService(runtime);
122
+ await service.initialize(runtime);
123
+ return service;
124
+ }
125
+ async stop() {
126
+ }
127
+ async initialize(runtime) {
128
+ const apiKey = normalizeApiKey(runtime.getSetting("TAVILY_API_KEY"));
129
+ if (!apiKey) {
130
+ this.configured = false;
131
+ logger.warn(
132
+ { src: "plugin-web-search" },
133
+ "TAVILY_API_KEY not set \u2014 web search is inert until a key is provided"
134
+ );
135
+ return;
136
+ }
137
+ this.tavilyClient = tavily({ apiKey });
138
+ this.configured = true;
139
+ }
140
+ async search(query, options) {
141
+ const normalizedQuery = validateSearchQuery(query);
142
+ validateSearchOptions(options);
143
+ if (!this.configured || !this.tavilyClient) {
144
+ throw new Error("Web search is not configured: set TAVILY_API_KEY to enable it.");
145
+ }
146
+ try {
147
+ const response = await this.tavilyClient.search(normalizedQuery, {
148
+ includeAnswer: (options == null ? void 0 : options.includeAnswer) ?? true,
149
+ maxResults: (options == null ? void 0 : options.limit) ?? 3,
150
+ topic: (options == null ? void 0 : options.topic) ?? (options == null ? void 0 : options.type) ?? "general",
151
+ searchDepth: (options == null ? void 0 : options.searchDepth) ?? "basic",
152
+ includeImages: (options == null ? void 0 : options.includeImages) ?? false,
153
+ days: (options == null ? void 0 : options.days) ?? 3
154
+ });
155
+ return normalizeResponse(normalizedQuery, response);
156
+ } catch (cause) {
157
+ const err = cause instanceof Error ? cause : new Error(String(cause));
158
+ logger.error({ src: "plugin-web-search", err }, "Web search error");
159
+ throw err;
160
+ }
161
+ }
162
+ async searchNews(query, options) {
163
+ return this.search(query, {
164
+ ...options,
165
+ type: "news",
166
+ topic: "news",
167
+ days: freshnessToDays(options == null ? void 0 : options.freshness)
168
+ });
169
+ }
170
+ async searchImages(query, options) {
171
+ return this.search(query, {
172
+ limit: options == null ? void 0 : options.limit,
173
+ offset: options == null ? void 0 : options.offset,
174
+ language: options == null ? void 0 : options.language,
175
+ region: options == null ? void 0 : options.region,
176
+ dateRange: options == null ? void 0 : options.dateRange,
177
+ fileType: options == null ? void 0 : options.fileType,
178
+ site: options == null ? void 0 : options.site,
179
+ sortBy: options == null ? void 0 : options.sortBy,
180
+ safeSearch: options == null ? void 0 : options.safeSearch,
181
+ includeImages: true
182
+ });
183
+ }
184
+ async searchVideos(query, options) {
185
+ const normalizedQuery = validateSearchQuery(query);
186
+ return this.search(`${normalizedQuery} video`, {
187
+ ...options,
188
+ includeImages: true
189
+ });
190
+ }
191
+ async getSuggestions(query) {
192
+ const response = await this.search(validateSearchQuery(query), {
193
+ includeAnswer: false,
194
+ limit: 5,
195
+ searchDepth: "basic"
196
+ });
197
+ return uniqueResultTitles(response, 5);
198
+ }
199
+ async getTrendingSearches(region) {
200
+ const normalizedRegion = typeof region === "string" ? region.trim() : "";
201
+ const query = normalizedRegion ? `trending news in ${normalizedRegion}` : "trending news";
202
+ const response = await this.searchNews(query, {
203
+ freshness: "day",
204
+ limit: 5,
205
+ region: normalizedRegion || void 0
206
+ });
207
+ return uniqueResultTitles(response, 5);
208
+ }
209
+ async getPageInfo(url) {
210
+ var _a, _b;
211
+ let parsedUrl;
212
+ try {
213
+ parsedUrl = new URL(url);
214
+ } catch {
215
+ throw new Error("Invalid page info URL");
216
+ }
217
+ if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {
218
+ throw new Error("Page info URL must use http or https");
219
+ }
220
+ const response = await fetch(parsedUrl.toString());
221
+ if (!response.ok) {
222
+ throw new Error(`Failed to fetch page info: ${response.status} ${response.statusText}`);
223
+ }
224
+ const content = await response.text();
225
+ const title = ((_a = content.match(/<title[^>]*>(.*?)<\/title>/i)) == null ? void 0 : _a[1]) ?? url;
226
+ const description = ((_b = content.match(/<meta\s+name=["']description["']\s+content=["']([^"']+)/i)) == null ? void 0 : _b[1]) ?? "";
227
+ return {
228
+ title,
229
+ description,
230
+ content,
231
+ metadata: {},
232
+ images: [],
233
+ links: []
234
+ };
235
+ }
236
+ };
237
+
238
+ // src/index.ts
239
+ var WEB_SEARCH_CATEGORY = {
240
+ category: "web",
241
+ label: "Web",
242
+ description: "Search current web pages through plugin-web-search.",
243
+ contexts: ["knowledge", "browser"],
244
+ filters: [
245
+ {
246
+ name: "topic",
247
+ label: "Topic",
248
+ description: "Tavily search topic.",
249
+ type: "enum",
250
+ options: [
251
+ { label: "General", value: "general" },
252
+ { label: "News", value: "news" }
253
+ ]
254
+ },
255
+ {
256
+ name: "searchDepth",
257
+ label: "Search depth",
258
+ description: "Tavily search depth.",
259
+ type: "enum",
260
+ options: [
261
+ { label: "Basic", value: "basic" },
262
+ { label: "Advanced", value: "advanced" }
263
+ ]
264
+ },
265
+ {
266
+ name: "includeImages",
267
+ label: "Include images",
268
+ description: "Include image results when available.",
269
+ type: "boolean"
270
+ }
271
+ ],
272
+ resultSchemaSummary: "SearchResponse with query, answer, results containing title/url/description/content/score, and optional images.",
273
+ capabilities: ["web", "news", "current-information"],
274
+ source: "plugin-web-search",
275
+ serviceType: ServiceType2.WEB_SEARCH
276
+ };
277
+ function registerWebSearchCategory(runtime) {
278
+ try {
279
+ runtime.getSearchCategory(WEB_SEARCH_CATEGORY.category, {
280
+ includeDisabled: true
281
+ });
282
+ return;
283
+ } catch {
284
+ runtime.registerSearchCategory(WEB_SEARCH_CATEGORY);
285
+ }
286
+ }
287
+ var webSearchPlugin = {
288
+ name: "webSearch",
289
+ description: "Search the web and get news",
290
+ init: async (_config, runtime) => {
291
+ registerWebSearchCategory(runtime);
292
+ },
293
+ async dispose(runtime) {
294
+ const svc = runtime.getService(WebSearchService.serviceType);
295
+ await (svc == null ? void 0 : svc.stop());
296
+ },
297
+ actions: [],
298
+ providers: [],
299
+ services: [WebSearchService]
300
+ };
301
+ var index_default = webSearchPlugin;
302
+ export {
303
+ WEB_SEARCH_CATEGORY,
304
+ index_default as default,
305
+ registerWebSearchCategory,
306
+ webSearchPlugin
307
+ };
308
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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 async dispose(runtime) {\n const svc = runtime.getService<WebSearchService>(WebSearchService.serviceType);\n await svc?.stop();\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\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === \"object\" && !Array.isArray(value);\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 normalizeApiKey(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim() ? value.trim() : undefined;\n}\n\nfunction validateSearchQuery(query: unknown): string {\n if (typeof query !== \"string\" || !query.trim()) {\n throw new Error(\"search query is required\");\n }\n return query.trim();\n}\n\nfunction assertOptionalPositiveInteger(value: unknown, name: string): void {\n if (\n value !== undefined &&\n (typeof value !== \"number\" ||\n !Number.isFinite(value) ||\n !Number.isInteger(value) ||\n value < 1)\n ) {\n throw new Error(`${name} must be a positive finite integer`);\n }\n}\n\nfunction assertOptionalNonNegativeInteger(value: unknown, name: string): void {\n if (\n value !== undefined &&\n (typeof value !== \"number\" ||\n !Number.isFinite(value) ||\n !Number.isInteger(value) ||\n value < 0)\n ) {\n throw new Error(`${name} must be a non-negative finite integer`);\n }\n}\n\nfunction validateSearchOptions(options?: SearchOptions): void {\n if (options === undefined) return;\n if (!isRecord(options)) {\n throw new Error(\"search options must be an object\");\n }\n assertOptionalPositiveInteger(options.limit, \"limit\");\n assertOptionalNonNegativeInteger(options.days, \"days\");\n if (options.topic !== undefined && options.topic !== \"general\" && options.topic !== \"news\") {\n throw new Error(\"topic must be general or news\");\n }\n if (options.type !== undefined && options.type !== \"general\" && options.type !== \"news\") {\n throw new Error(\"type must be general or news\");\n }\n if (\n options.searchDepth !== undefined &&\n options.searchDepth !== \"basic\" &&\n options.searchDepth !== \"advanced\"\n ) {\n throw new Error(\"searchDepth must be basic or advanced\");\n }\n if (options.includeAnswer !== undefined && typeof options.includeAnswer !== \"boolean\") {\n throw new Error(\"includeAnswer must be a boolean\");\n }\n if (options.includeImages !== undefined && typeof options.includeImages !== \"boolean\") {\n throw new Error(\"includeImages must be a boolean\");\n }\n}\n\nfunction normalizeResponse(query: string, response: unknown): SearchResponse {\n const payload = isRecord(response) ? response : {};\n const rawResults = Array.isArray(payload.results) ? payload.results : [];\n const results = rawResults.filter(isRecord).map((result) => {\n const content = typeof result.content === \"string\" ? result.content : \"\";\n return {\n title: typeof result.title === \"string\" ? result.title : \"Untitled\",\n url: typeof result.url === \"string\" ? result.url : \"\",\n description: content,\n content,\n rawContent: typeof result.rawContent === \"string\" ? result.rawContent : undefined,\n score:\n typeof result.score === \"number\" && Number.isFinite(result.score)\n ? result.score\n : 0,\n publishedDate: parsePublishedDate(\n typeof result.publishedDate === \"string\" ? result.publishedDate : undefined\n ),\n };\n });\n const rawImages = Array.isArray(payload.images) ? payload.images : [];\n const images = rawImages\n .map((image) =>\n typeof image === \"string\"\n ? { url: image }\n : isRecord(image)\n ? {\n url: typeof image.url === \"string\" ? image.url : \"\",\n description:\n typeof image.description === \"string\" ? image.description : undefined,\n }\n : { url: \"\" }\n )\n .filter((image) => image.url);\n\n return {\n answer: typeof payload.answer === \"string\" ? payload.answer : undefined,\n query: typeof payload.query === \"string\" ? payload.query : query,\n responseTime: typeof payload.responseTime === \"number\" ? payload.responseTime : undefined,\n images,\n results,\n };\n}\n\nfunction uniqueResultTitles(response: SearchResponse, limit: number): string[] {\n const seen = new Set<string>();\n const titles: string[] = [];\n for (const result of response.results) {\n const title = result.title.trim();\n if (!title || title === \"Untitled\") continue;\n const key = title.toLocaleLowerCase();\n if (seen.has(key)) continue;\n seen.add(key);\n titles.push(title);\n if (titles.length >= limit) break;\n }\n return titles;\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 | undefined;\n private configured = false;\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 = normalizeApiKey(runtime.getSetting(\"TAVILY_API_KEY\"));\n if (!apiKey) {\n // Degrade gracefully instead of throwing, so the plugin can be\n // installed unconfigured without crashing agent boot. The service\n // stays inert and `search()` reports an honest, recoverable error\n // until a TAVILY_API_KEY is provided.\n this.configured = false;\n logger.warn(\n { src: \"plugin-web-search\" },\n \"TAVILY_API_KEY not set — web search is inert until a key is provided\"\n );\n return;\n }\n this.tavilyClient = tavily({ apiKey });\n this.configured = true;\n }\n\n async search(query: string, options?: SearchOptions): Promise<SearchResponse> {\n const normalizedQuery = validateSearchQuery(query);\n validateSearchOptions(options);\n if (!this.configured || !this.tavilyClient) {\n throw new Error(\"Web search is not configured: set TAVILY_API_KEY to enable it.\");\n }\n try {\n const response = await this.tavilyClient.search(normalizedQuery, {\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(normalizedQuery, response);\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 const normalizedQuery = validateSearchQuery(query);\n return this.search(`${normalizedQuery} video`, {\n ...options,\n includeImages: true,\n });\n }\n\n async getSuggestions(query: string): Promise<string[]> {\n const response = await this.search(validateSearchQuery(query), {\n includeAnswer: false,\n limit: 5,\n searchDepth: \"basic\",\n });\n return uniqueResultTitles(response, 5);\n }\n\n async getTrendingSearches(region?: string): Promise<string[]> {\n const normalizedRegion = typeof region === \"string\" ? region.trim() : \"\";\n const query = normalizedRegion ? `trending news in ${normalizedRegion}` : \"trending news\";\n const response = await this.searchNews(query, {\n freshness: \"day\",\n limit: 5,\n region: normalizedRegion || undefined,\n });\n return uniqueResultTitles(response, 5);\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 let parsedUrl: URL;\n try {\n parsedUrl = new URL(url);\n } catch {\n throw new Error(\"Invalid page info URL\");\n }\n if (parsedUrl.protocol !== \"http:\" && parsedUrl.protocol !== \"https:\") {\n throw new Error(\"Page info URL must use http or https\");\n }\n\n const response = await fetch(parsedUrl.toString());\n if (!response.ok) {\n throw new Error(`Failed to fetch page info: ${response.status} ${response.statusText}`);\n }\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;AAYvB,SAAS,SAAS,OAAkD;AAChE,SAAO,QAAQ,KAAK,KAAK,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AAC9E;AAEA,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,gBAAgB,OAAoC;AACzD,SAAO,OAAO,UAAU,YAAY,MAAM,KAAK,IAAI,MAAM,KAAK,IAAI;AACtE;AAEA,SAAS,oBAAoB,OAAwB;AACjD,MAAI,OAAO,UAAU,YAAY,CAAC,MAAM,KAAK,GAAG;AAC5C,UAAM,IAAI,MAAM,0BAA0B;AAAA,EAC9C;AACA,SAAO,MAAM,KAAK;AACtB;AAEA,SAAS,8BAA8B,OAAgB,MAAoB;AACvE,MACI,UAAU,WACT,OAAO,UAAU,YACd,CAAC,OAAO,SAAS,KAAK,KACtB,CAAC,OAAO,UAAU,KAAK,KACvB,QAAQ,IACd;AACE,UAAM,IAAI,MAAM,GAAG,IAAI,oCAA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"2.0.3-beta.5",
3
+ "version": "2.0.3-beta.7",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -34,7 +34,7 @@
34
34
  "dist"
35
35
  ],
36
36
  "dependencies": {
37
- "@elizaos/core": "2.0.3-beta.5",
37
+ "@elizaos/core": "2.0.3-beta.7",
38
38
  "@tavily/core": "^0.7.0"
39
39
  },
40
40
  "devDependencies": {
@@ -65,5 +65,5 @@
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  },
68
- "gitHead": "ff6157011c9459670021cc28a6797592a78b8817"
68
+ "gitHead": "61094f10458d11055c75b3dd0bae374e3f66bac5"
69
69
  }