@framers/agentos-ext-web-search 1.1.0 → 1.1.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 +31 -188
- package/dist/index.d.ts +14 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -50
- package/dist/index.js.map +1 -1
- package/dist/services/searchProvider.d.ts +54 -2
- package/dist/services/searchProvider.d.ts.map +1 -1
- package/dist/services/searchProvider.js +168 -17
- package/dist/services/searchProvider.js.map +1 -1
- package/dist/tools/factCheck.d.ts +46 -88
- package/dist/tools/factCheck.d.ts.map +1 -1
- package/dist/tools/factCheck.js +134 -170
- package/dist/tools/factCheck.js.map +1 -1
- package/dist/tools/researchAggregator.d.ts +37 -91
- package/dist/tools/researchAggregator.d.ts.map +1 -1
- package/dist/tools/researchAggregator.js +134 -175
- package/dist/tools/researchAggregator.js.map +1 -1
- package/dist/tools/webSearch.d.ts +31 -59
- package/dist/tools/webSearch.d.ts.map +1 -1
- package/dist/tools/webSearch.js +69 -87
- package/dist/tools/webSearch.js.map +1 -1
- package/dist/types.js +1 -2
- package/dist/types.js.map +1 -1
- package/manifest.json +11 -6
- package/package.json +2 -2
- package/src/index.ts +64 -46
- package/src/services/searchProvider.ts +231 -25
- package/src/tools/factCheck.ts +206 -224
- package/src/tools/researchAggregator.ts +209 -217
- package/src/tools/webSearch.ts +103 -102
- package/test/integration.spec.ts +240 -39
- package/test/searchProvider.spec.ts +263 -18
- package/test/webSearch.spec.ts +129 -27
- package/tsconfig.json +7 -2
|
@@ -1,90 +1,133 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResearchAggregatorTool = void 0;
|
|
4
1
|
/**
|
|
5
|
-
* Research
|
|
2
|
+
* Research Aggregator Tool — runs multiple searches on a topic and aggregates results.
|
|
6
3
|
*
|
|
7
|
-
*
|
|
8
|
-
* @implements {ITool}
|
|
4
|
+
* Updated to conform to AgentOS `ITool` (inputSchema + ToolExecutionContext).
|
|
9
5
|
*
|
|
10
|
-
* @
|
|
11
|
-
* ```typescript
|
|
12
|
-
* const tool = new ResearchAggregatorTool(searchService);
|
|
13
|
-
* const result = await tool.execute({
|
|
14
|
-
* topic: 'AI safety research',
|
|
15
|
-
* sources: 3,
|
|
16
|
-
* depth: 'comprehensive'
|
|
17
|
-
* });
|
|
18
|
-
* ```
|
|
6
|
+
* @module @framers/agentos-ext-web-search
|
|
19
7
|
*/
|
|
20
|
-
class ResearchAggregatorTool {
|
|
8
|
+
export class ResearchAggregatorTool {
|
|
21
9
|
searchService;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
10
|
+
defaultMultiSearch;
|
|
11
|
+
id = 'research-aggregator-v1';
|
|
12
|
+
/** Tool call name used by the LLM / ToolExecutor. */
|
|
13
|
+
name = 'research_aggregate';
|
|
14
|
+
displayName = 'Research Aggregator';
|
|
15
|
+
description = 'Aggregate research from multiple web searches on a topic (deduplicated + categorized).';
|
|
16
|
+
category = 'research';
|
|
17
|
+
hasSideEffects = false;
|
|
18
|
+
inputSchema = {
|
|
19
|
+
type: 'object',
|
|
20
|
+
required: ['topic'],
|
|
21
|
+
properties: {
|
|
22
|
+
topic: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
description: 'The research topic to aggregate information about',
|
|
25
|
+
},
|
|
26
|
+
sources: {
|
|
27
|
+
type: 'integer',
|
|
28
|
+
description: 'Number of different search angles to explore',
|
|
29
|
+
default: 3,
|
|
30
|
+
minimum: 1,
|
|
31
|
+
maximum: 10,
|
|
32
|
+
},
|
|
33
|
+
depth: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
description: 'Research depth level',
|
|
36
|
+
enum: ['quick', 'moderate', 'comprehensive'],
|
|
37
|
+
default: 'moderate',
|
|
38
|
+
},
|
|
39
|
+
multiSearch: {
|
|
40
|
+
type: 'boolean',
|
|
41
|
+
description: 'When true, each search query fans out to ALL available providers in parallel, returning merged and deduplicated results ranked by cross-provider agreement.',
|
|
42
|
+
default: false,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
additionalProperties: false,
|
|
46
|
+
};
|
|
47
|
+
requiredCapabilities = ['capability:web_search'];
|
|
48
|
+
constructor(searchService, defaultMultiSearch = false) {
|
|
30
49
|
this.searchService = searchService;
|
|
50
|
+
this.defaultMultiSearch = defaultMultiSearch;
|
|
31
51
|
}
|
|
32
|
-
|
|
33
|
-
* Executes research aggregation on a topic
|
|
34
|
-
*
|
|
35
|
-
* @param {Object} input - The research parameters
|
|
36
|
-
* @param {string} input.topic - The research topic
|
|
37
|
-
* @param {number} [input.sources=3] - Number of different search angles to explore
|
|
38
|
-
* @param {string} [input.depth='moderate'] - Research depth (quick, moderate, comprehensive)
|
|
39
|
-
* @returns {Promise<{success: boolean, output?: any, error?: string}>} Aggregated research results
|
|
40
|
-
*/
|
|
41
|
-
async execute(input) {
|
|
52
|
+
async execute(input, _context) {
|
|
42
53
|
try {
|
|
43
54
|
const sources = input.sources || 3;
|
|
44
55
|
const depth = input.depth || 'moderate';
|
|
45
|
-
|
|
56
|
+
const useMultiSearch = input.multiSearch ?? this.defaultMultiSearch;
|
|
46
57
|
const queries = this.generateSearchQueries(input.topic, sources, depth);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
const perQueryMaxResults = depth === 'quick' ? 5 : depth === 'moderate' ? 10 : 15;
|
|
59
|
+
let searchResults;
|
|
60
|
+
if (useMultiSearch) {
|
|
61
|
+
// Fan out each query to ALL providers in parallel, then normalize into ProviderResponse shape
|
|
62
|
+
const multiPromises = queries.map((query) => this.searchService
|
|
63
|
+
.multiSearch(query, { maxResults: perQueryMaxResults })
|
|
64
|
+
.then((multi) => ({
|
|
65
|
+
provider: 'multi',
|
|
66
|
+
results: multi.results,
|
|
67
|
+
metadata: { query, timestamp: multi.metadata.timestamp },
|
|
68
|
+
}))
|
|
69
|
+
.catch((err) => ({
|
|
70
|
+
provider: 'error',
|
|
71
|
+
results: [],
|
|
72
|
+
metadata: { query, error: err?.message || String(err), timestamp: new Date().toISOString() },
|
|
73
|
+
})));
|
|
74
|
+
searchResults = (await Promise.all(multiPromises));
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const searchPromises = queries.map((query) => this.searchService
|
|
78
|
+
.search(query, { maxResults: perQueryMaxResults })
|
|
79
|
+
.catch((err) => ({
|
|
80
|
+
provider: 'error',
|
|
81
|
+
results: [],
|
|
82
|
+
metadata: { query, error: err?.message || String(err), timestamp: new Date().toISOString() },
|
|
83
|
+
})));
|
|
84
|
+
searchResults = (await Promise.all(searchPromises));
|
|
85
|
+
}
|
|
86
|
+
const aggregatedResults = this.aggregateResults(searchResults, input.topic);
|
|
58
87
|
return {
|
|
59
88
|
success: true,
|
|
60
89
|
output: {
|
|
61
90
|
topic: input.topic,
|
|
62
|
-
sources
|
|
63
|
-
depth
|
|
64
|
-
queries
|
|
65
|
-
aggregatedResults
|
|
66
|
-
timestamp: new Date().toISOString()
|
|
67
|
-
}
|
|
91
|
+
sources,
|
|
92
|
+
depth,
|
|
93
|
+
queries,
|
|
94
|
+
aggregatedResults,
|
|
95
|
+
timestamp: new Date().toISOString(),
|
|
96
|
+
},
|
|
68
97
|
};
|
|
69
98
|
}
|
|
70
99
|
catch (error) {
|
|
71
|
-
return {
|
|
72
|
-
success: false,
|
|
73
|
-
error: error.message
|
|
74
|
-
};
|
|
100
|
+
return { success: false, error: error?.message || String(error) };
|
|
75
101
|
}
|
|
76
102
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
103
|
+
validateArgs(input) {
|
|
104
|
+
const errors = [];
|
|
105
|
+
if (!input.topic) {
|
|
106
|
+
errors.push('Topic is required');
|
|
107
|
+
}
|
|
108
|
+
else if (typeof input.topic !== 'string') {
|
|
109
|
+
errors.push('Topic must be a string');
|
|
110
|
+
}
|
|
111
|
+
if (input.sources !== undefined) {
|
|
112
|
+
if (typeof input.sources !== 'number' || input.sources < 1 || input.sources > 10) {
|
|
113
|
+
errors.push('Sources must be a number between 1 and 10');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (input.depth !== undefined) {
|
|
117
|
+
if (!['quick', 'moderate', 'comprehensive'].includes(input.depth)) {
|
|
118
|
+
errors.push('Depth must be quick, moderate, or comprehensive');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (input.multiSearch !== undefined && typeof input.multiSearch !== 'boolean') {
|
|
122
|
+
errors.push('multiSearch must be a boolean');
|
|
123
|
+
}
|
|
124
|
+
return errors.length === 0 ? { isValid: true } : { isValid: false, errors };
|
|
125
|
+
}
|
|
126
|
+
// ============================================================================
|
|
127
|
+
// Internals (ported from the previous implementation)
|
|
128
|
+
// ============================================================================
|
|
86
129
|
generateSearchQueries(topic, count, depth) {
|
|
87
|
-
const queries = [topic];
|
|
130
|
+
const queries = [topic];
|
|
88
131
|
const modifiers = {
|
|
89
132
|
quick: ['overview', 'summary'],
|
|
90
133
|
moderate: ['overview', 'recent developments', 'key concepts', 'applications'],
|
|
@@ -96,8 +139,8 @@ class ResearchAggregatorTool {
|
|
|
96
139
|
'future directions',
|
|
97
140
|
'industry applications',
|
|
98
141
|
'academic papers',
|
|
99
|
-
'expert opinions'
|
|
100
|
-
]
|
|
142
|
+
'expert opinions',
|
|
143
|
+
],
|
|
101
144
|
};
|
|
102
145
|
const selectedModifiers = modifiers[depth];
|
|
103
146
|
for (let i = 1; i < Math.min(count, selectedModifiers.length + 1); i++) {
|
|
@@ -107,42 +150,33 @@ class ResearchAggregatorTool {
|
|
|
107
150
|
}
|
|
108
151
|
return queries;
|
|
109
152
|
}
|
|
110
|
-
/**
|
|
111
|
-
* Aggregates and deduplicates search results
|
|
112
|
-
*
|
|
113
|
-
* @private
|
|
114
|
-
* @param {any[]} searchResults - Array of search results from different queries
|
|
115
|
-
* @param {string} topic - The original research topic
|
|
116
|
-
* @returns {Object} Aggregated and organized results
|
|
117
|
-
*/
|
|
118
153
|
aggregateResults(searchResults, topic) {
|
|
119
154
|
const seenUrls = new Set();
|
|
120
155
|
const categories = {
|
|
121
156
|
overview: [],
|
|
122
157
|
research: [],
|
|
123
158
|
applications: [],
|
|
124
|
-
resources: []
|
|
159
|
+
resources: [],
|
|
125
160
|
};
|
|
126
161
|
for (const searchResult of searchResults) {
|
|
127
162
|
if (!searchResult.results)
|
|
128
163
|
continue;
|
|
129
164
|
for (const result of searchResult.results) {
|
|
130
|
-
// Skip duplicates
|
|
131
165
|
if (seenUrls.has(result.url))
|
|
132
166
|
continue;
|
|
133
167
|
seenUrls.add(result.url);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const lowerSnippet = result.snippet.toLowerCase();
|
|
137
|
-
if (lowerTitle.includes('overview') || lowerTitle.includes('introduction') ||
|
|
138
|
-
lowerTitle.includes('what is')) {
|
|
168
|
+
const lowerTitle = String(result.title || '').toLowerCase();
|
|
169
|
+
if (lowerTitle.includes('overview') || lowerTitle.includes('introduction') || lowerTitle.includes('what is')) {
|
|
139
170
|
categories.overview.push(result);
|
|
140
171
|
}
|
|
141
|
-
else if (lowerTitle.includes('research') ||
|
|
142
|
-
lowerTitle.includes('
|
|
172
|
+
else if (lowerTitle.includes('research') ||
|
|
173
|
+
lowerTitle.includes('study') ||
|
|
174
|
+
lowerTitle.includes('paper') ||
|
|
175
|
+
lowerTitle.includes('journal')) {
|
|
143
176
|
categories.research.push(result);
|
|
144
177
|
}
|
|
145
|
-
else if (lowerTitle.includes('application') ||
|
|
178
|
+
else if (lowerTitle.includes('application') ||
|
|
179
|
+
lowerTitle.includes('use case') ||
|
|
146
180
|
lowerTitle.includes('implementation')) {
|
|
147
181
|
categories.applications.push(result);
|
|
148
182
|
}
|
|
@@ -151,125 +185,50 @@ class ResearchAggregatorTool {
|
|
|
151
185
|
}
|
|
152
186
|
}
|
|
153
187
|
}
|
|
154
|
-
// Calculate relevance scores
|
|
155
188
|
const scoredCategories = Object.entries(categories).reduce((acc, [key, items]) => {
|
|
156
|
-
acc[key] = items
|
|
189
|
+
acc[key] = items
|
|
190
|
+
.map((item) => ({
|
|
157
191
|
...item,
|
|
158
|
-
relevanceScore: this.calculateRelevance(item, topic)
|
|
159
|
-
}))
|
|
192
|
+
relevanceScore: this.calculateRelevance(item, topic),
|
|
193
|
+
}))
|
|
194
|
+
.sort((a, b) => b.relevanceScore - a.relevanceScore);
|
|
160
195
|
return acc;
|
|
161
196
|
}, {});
|
|
162
197
|
return {
|
|
163
198
|
categories: scoredCategories,
|
|
164
199
|
totalResults: seenUrls.size,
|
|
165
|
-
topResults: this.getTopResults(scoredCategories, 10)
|
|
200
|
+
topResults: this.getTopResults(scoredCategories, 10),
|
|
166
201
|
};
|
|
167
202
|
}
|
|
168
|
-
/**
|
|
169
|
-
* Calculates relevance score for a search result
|
|
170
|
-
*
|
|
171
|
-
* @private
|
|
172
|
-
* @param {any} result - Search result object
|
|
173
|
-
* @param {string} topic - Original topic for comparison
|
|
174
|
-
* @returns {number} Relevance score (0-100)
|
|
175
|
-
*/
|
|
176
203
|
calculateRelevance(result, topic) {
|
|
177
|
-
let score = 50;
|
|
204
|
+
let score = 50;
|
|
178
205
|
const topicWords = topic.toLowerCase().split(/\s+/);
|
|
179
|
-
const titleWords = result.title.toLowerCase();
|
|
180
|
-
const snippetWords = result.snippet.toLowerCase();
|
|
181
|
-
// Check title relevance
|
|
206
|
+
const titleWords = String(result.title || '').toLowerCase();
|
|
207
|
+
const snippetWords = String(result.snippet || '').toLowerCase();
|
|
182
208
|
for (const word of topicWords) {
|
|
183
209
|
if (titleWords.includes(word))
|
|
184
210
|
score += 15;
|
|
185
211
|
if (snippetWords.includes(word))
|
|
186
212
|
score += 5;
|
|
187
213
|
}
|
|
188
|
-
// Boost for certain indicators
|
|
189
214
|
if (titleWords.includes('official'))
|
|
190
215
|
score += 10;
|
|
191
216
|
if (titleWords.includes('guide'))
|
|
192
217
|
score += 5;
|
|
193
218
|
if (titleWords.includes('tutorial'))
|
|
194
219
|
score += 5;
|
|
220
|
+
// Bonus for multi-search results with cross-provider agreement
|
|
221
|
+
if (typeof result.confidenceScore === 'number') {
|
|
222
|
+
score += (result.confidenceScore / 100) * 20;
|
|
223
|
+
}
|
|
195
224
|
return Math.min(100, score);
|
|
196
225
|
}
|
|
197
|
-
/**
|
|
198
|
-
* Gets top results across all categories
|
|
199
|
-
*
|
|
200
|
-
* @private
|
|
201
|
-
* @param {any} categories - Categorized results
|
|
202
|
-
* @param {number} count - Number of top results to return
|
|
203
|
-
* @returns {any[]} Top results by relevance
|
|
204
|
-
*/
|
|
205
226
|
getTopResults(categories, count) {
|
|
206
227
|
const allResults = [];
|
|
207
228
|
for (const items of Object.values(categories)) {
|
|
208
229
|
allResults.push(...items);
|
|
209
230
|
}
|
|
210
|
-
return allResults
|
|
211
|
-
.sort((a, b) => b.relevanceScore - a.relevanceScore)
|
|
212
|
-
.slice(0, count);
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Validates input parameters
|
|
216
|
-
*
|
|
217
|
-
* @param {any} input - Input to validate
|
|
218
|
-
* @returns {{valid: boolean, errors: string[]}} Validation result
|
|
219
|
-
*/
|
|
220
|
-
validate(input) {
|
|
221
|
-
const errors = [];
|
|
222
|
-
if (!input.topic) {
|
|
223
|
-
errors.push('Topic is required');
|
|
224
|
-
}
|
|
225
|
-
else if (typeof input.topic !== 'string') {
|
|
226
|
-
errors.push('Topic must be a string');
|
|
227
|
-
}
|
|
228
|
-
if (input.sources !== undefined) {
|
|
229
|
-
if (typeof input.sources !== 'number' || input.sources < 1 || input.sources > 10) {
|
|
230
|
-
errors.push('Sources must be a number between 1 and 10');
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
if (input.depth !== undefined) {
|
|
234
|
-
if (!['quick', 'moderate', 'comprehensive'].includes(input.depth)) {
|
|
235
|
-
errors.push('Depth must be quick, moderate, or comprehensive');
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
return {
|
|
239
|
-
valid: errors.length === 0,
|
|
240
|
-
errors
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Returns the JSON schema for the tool's input
|
|
245
|
-
*
|
|
246
|
-
* @returns {Object} JSON Schema object
|
|
247
|
-
*/
|
|
248
|
-
getSchema() {
|
|
249
|
-
return {
|
|
250
|
-
type: 'object',
|
|
251
|
-
required: ['topic'],
|
|
252
|
-
properties: {
|
|
253
|
-
topic: {
|
|
254
|
-
type: 'string',
|
|
255
|
-
description: 'The research topic to aggregate information about'
|
|
256
|
-
},
|
|
257
|
-
sources: {
|
|
258
|
-
type: 'number',
|
|
259
|
-
description: 'Number of different search angles to explore',
|
|
260
|
-
default: 3,
|
|
261
|
-
minimum: 1,
|
|
262
|
-
maximum: 10
|
|
263
|
-
},
|
|
264
|
-
depth: {
|
|
265
|
-
type: 'string',
|
|
266
|
-
description: 'Research depth level',
|
|
267
|
-
enum: ['quick', 'moderate', 'comprehensive'],
|
|
268
|
-
default: 'moderate'
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
};
|
|
231
|
+
return allResults.sort((a, b) => b.relevanceScore - a.relevanceScore).slice(0, count);
|
|
272
232
|
}
|
|
273
233
|
}
|
|
274
|
-
exports.ResearchAggregatorTool = ResearchAggregatorTool;
|
|
275
234
|
//# sourceMappingURL=researchAggregator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"researchAggregator.js","sourceRoot":"","sources":["../../src/tools/researchAggregator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"researchAggregator.js","sourceRoot":"","sources":["../../src/tools/researchAggregator.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AAe,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;QAC/C,CAAC;QAED,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC;IAEO,aAAa,CAAC,UAAe,EAAE,KAAa;QAClD,MAAM,UAAU,GAAU,EAAE,CAAC;QAE7B,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9C,UAAU,CAAC,IAAI,CAAC,GAAI,KAAe,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,GAAG,CAAC,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACxF,CAAC;CACF"}
|
|
@@ -1,66 +1,38 @@
|
|
|
1
|
-
import { ITool } from '@framers/agentos';
|
|
2
|
-
import { SearchProviderService } from '../services/searchProvider';
|
|
3
1
|
/**
|
|
4
|
-
* Web
|
|
2
|
+
* Web Search Tool — multi-provider search via SearchProviderService.
|
|
5
3
|
*
|
|
6
|
-
*
|
|
7
|
-
* @implements {ITool}
|
|
4
|
+
* Updated to conform to AgentOS `ITool` (inputSchema + ToolExecutionContext).
|
|
8
5
|
*
|
|
9
|
-
* @
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const tool = new WebSearchTool(searchService);
|
|
12
|
-
* const result = await tool.execute({
|
|
13
|
-
* query: 'AgentOS extensions',
|
|
14
|
-
* maxResults: 10,
|
|
15
|
-
* provider: 'serper'
|
|
16
|
-
* });
|
|
17
|
-
* ```
|
|
6
|
+
* @module @framers/agentos-ext-web-search
|
|
18
7
|
*/
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
error?: string;
|
|
48
|
-
}>;
|
|
49
|
-
/**
|
|
50
|
-
* Validates input parameters for the web search
|
|
51
|
-
*
|
|
52
|
-
* @param {any} input - The input to validate
|
|
53
|
-
* @returns {{valid: boolean, errors: string[]}} Validation result
|
|
54
|
-
*/
|
|
55
|
-
validate(input: any): {
|
|
56
|
-
valid: boolean;
|
|
57
|
-
errors: string[];
|
|
8
|
+
import type { ITool, JSONSchemaObject, ToolExecutionContext, ToolExecutionResult } from '@framers/agentos';
|
|
9
|
+
import type { ProviderResponse, MultiSearchResponse } from '../services/searchProvider.js';
|
|
10
|
+
import { SearchProviderService } from '../services/searchProvider.js';
|
|
11
|
+
export interface WebSearchInput {
|
|
12
|
+
query: string;
|
|
13
|
+
maxResults?: number;
|
|
14
|
+
provider?: 'serper' | 'serpapi' | 'brave' | 'searxng' | 'duckduckgo';
|
|
15
|
+
multiSearch?: boolean;
|
|
16
|
+
category?: string;
|
|
17
|
+
}
|
|
18
|
+
export type WebSearchOutput = ProviderResponse | MultiSearchResponse;
|
|
19
|
+
export declare class WebSearchTool implements ITool<WebSearchInput, WebSearchOutput> {
|
|
20
|
+
private readonly searchService;
|
|
21
|
+
private readonly defaultMultiSearch;
|
|
22
|
+
readonly id = "web-search-v1";
|
|
23
|
+
/** Tool call name used by the LLM / ToolExecutor. */
|
|
24
|
+
readonly name = "web_search";
|
|
25
|
+
readonly displayName = "Web Search";
|
|
26
|
+
readonly description = "Search the web using multiple providers (Serper, SerpAPI, Brave, SearXNG, DuckDuckGo fallback). Set multiSearch=true to query ALL providers in parallel for higher-confidence, deduplicated results.";
|
|
27
|
+
readonly category = "research";
|
|
28
|
+
readonly hasSideEffects = false;
|
|
29
|
+
readonly inputSchema: JSONSchemaObject;
|
|
30
|
+
readonly requiredCapabilities: string[];
|
|
31
|
+
constructor(searchService: SearchProviderService, defaultMultiSearch?: boolean);
|
|
32
|
+
execute(input: WebSearchInput, _context: ToolExecutionContext): Promise<ToolExecutionResult<WebSearchOutput>>;
|
|
33
|
+
validateArgs(input: Record<string, any>): {
|
|
34
|
+
isValid: boolean;
|
|
35
|
+
errors?: any[];
|
|
58
36
|
};
|
|
59
|
-
/**
|
|
60
|
-
* Returns the JSON schema for the tool's input
|
|
61
|
-
*
|
|
62
|
-
* @returns {Object} JSON Schema object
|
|
63
|
-
*/
|
|
64
|
-
getSchema(): any;
|
|
65
37
|
}
|
|
66
38
|
//# sourceMappingURL=webSearch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webSearch.d.ts","sourceRoot":"","sources":["../../src/tools/webSearch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"webSearch.d.ts","sourceRoot":"","sources":["../../src/tools/webSearch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC3G,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,YAAY,CAAC;IACrE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,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