@framers/agentos-ext-web-search 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -188
- package/dist/index.d.ts +18 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +57 -50
- package/dist/index.js.map +1 -1
- package/dist/services/searchProvider.d.ts +89 -3
- package/dist/services/searchProvider.d.ts.map +1 -1
- package/dist/services/searchProvider.js +342 -26
- 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 +141 -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 +141 -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 +76 -87
- package/dist/tools/webSearch.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -2
- package/dist/types.js.map +1 -1
- package/manifest.json +14 -9
- package/package.json +26 -16
- package/.eslintrc.json +0 -21
- package/CHANGELOG.md +0 -16
- package/src/index.ts +0 -123
- package/src/services/searchProvider.ts +0 -416
- package/src/tools/factCheck.ts +0 -318
- package/src/tools/researchAggregator.ts +0 -297
- package/src/tools/webSearch.ts +0 -128
- package/src/types.ts +0 -41
- package/test/integration.spec.ts +0 -173
- package/test/searchProvider.spec.ts +0 -153
- package/test/webSearch.spec.ts +0 -128
- package/tsconfig.json +0 -21
- package/vitest.config.ts +0 -32
package/README.md
CHANGED
|
@@ -1,218 +1,61 @@
|
|
|
1
1
|
# Web Search Extension for AgentOS
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Professional web search, research aggregation, and fact-checking for AgentOS agents.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- 🔍 **Web Search** - Search the web with multiple providers
|
|
8
|
-
- 📚 **Research Aggregator** - Compile research from multiple searches
|
|
9
|
-
- ✅ **Fact Checker** - Verify claims across sources
|
|
10
|
-
- 🌍 **Multi-provider Support** - Serper, SerpAPI, Brave, DuckDuckGo
|
|
5
|
+
Supports multiple providers (Serper.dev, SerpAPI, Brave) with a DuckDuckGo fallback when no API keys are configured.
|
|
11
6
|
|
|
12
7
|
## Installation
|
|
13
8
|
|
|
14
9
|
```bash
|
|
15
|
-
npm install @framers/agentos-ext-search
|
|
10
|
+
npm install @framers/agentos-ext-web-search
|
|
16
11
|
```
|
|
17
12
|
|
|
18
13
|
## Quick Start
|
|
19
14
|
|
|
20
|
-
```
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
|
|
24
|
-
const agentos = new AgentOS();
|
|
25
|
-
|
|
26
|
-
await agentos.initialize({
|
|
27
|
-
// ... other config
|
|
28
|
-
extensionManifest: {
|
|
29
|
-
packs: [
|
|
30
|
-
{
|
|
31
|
-
factory: () => searchExtension({
|
|
32
|
-
manifestEntry: {} as any,
|
|
33
|
-
source: { sourceName: '@framers/agentos-ext-search' },
|
|
34
|
-
options: {
|
|
35
|
-
search: {
|
|
36
|
-
provider: 'serper',
|
|
37
|
-
apiKey: process.env.SERPER_API_KEY
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
]
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## Configuration
|
|
48
|
-
|
|
49
|
-
### Environment Variables
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
# Option 1: Serper (2,500 free queries)
|
|
53
|
-
SERPER_API_KEY=your_serper_api_key
|
|
54
|
-
|
|
55
|
-
# Option 2: SerpAPI (100 free/month)
|
|
56
|
-
SERPAPI_API_KEY=your_serpapi_key
|
|
57
|
-
|
|
58
|
-
# Option 3: Brave (2,000 free/month)
|
|
59
|
-
BRAVE_SEARCH_API_KEY=your_brave_api_key
|
|
60
|
-
|
|
61
|
-
# Optional: Override provider
|
|
62
|
-
SEARCH_PROVIDER=serper # or serpapi, brave, duckduckgo
|
|
63
|
-
```
|
|
15
|
+
```ts
|
|
16
|
+
import { ExtensionManager } from '@framers/agentos';
|
|
17
|
+
import { createExtensionPack } from '@framers/agentos-ext-web-search';
|
|
64
18
|
|
|
65
|
-
|
|
19
|
+
const extensionManager = new ExtensionManager();
|
|
66
20
|
|
|
67
|
-
|
|
68
|
-
{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
21
|
+
extensionManager.register(createExtensionPack({
|
|
22
|
+
options: {
|
|
23
|
+
// Any one of these is enough; Serper/SerpAPI/Brave are tried in order.
|
|
24
|
+
serperApiKey: process.env.SERPER_API_KEY,
|
|
25
|
+
serpApiKey: process.env.SERPAPI_API_KEY,
|
|
26
|
+
braveApiKey: process.env.BRAVE_API_KEY,
|
|
27
|
+
},
|
|
28
|
+
logger: console,
|
|
29
|
+
}));
|
|
75
30
|
```
|
|
76
31
|
|
|
77
|
-
##
|
|
32
|
+
## Environment Variables
|
|
78
33
|
|
|
79
|
-
|
|
34
|
+
- `SERPER_API_KEY` (optional)
|
|
35
|
+
- `SERPAPI_API_KEY` (optional)
|
|
36
|
+
- `BRAVE_API_KEY` (optional)
|
|
80
37
|
|
|
81
|
-
|
|
38
|
+
If none are set, the extension falls back to DuckDuckGo.
|
|
82
39
|
|
|
83
|
-
|
|
84
|
-
```typescript
|
|
85
|
-
{
|
|
86
|
-
query: string; // Search query
|
|
87
|
-
numResults?: number; // Results to return (1-10, default: 5)
|
|
88
|
-
searchType?: string; // 'web' | 'news' | 'images' | 'videos'
|
|
89
|
-
timeRange?: string; // 'any' | 'day' | 'week' | 'month' | 'year'
|
|
90
|
-
region?: string; // Country code: 'us', 'uk', 'fr', etc.
|
|
91
|
-
}
|
|
92
|
-
```
|
|
40
|
+
## Tools
|
|
93
41
|
|
|
94
|
-
|
|
95
|
-
```typescript
|
|
96
|
-
const result = await tool.execute({
|
|
97
|
-
query: "latest AI developments",
|
|
98
|
-
numResults: 5,
|
|
99
|
-
timeRange: "week"
|
|
100
|
-
});
|
|
101
|
-
```
|
|
42
|
+
### `web_search`
|
|
102
43
|
|
|
103
|
-
|
|
44
|
+
Search the web.
|
|
104
45
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
**Input:**
|
|
108
|
-
```typescript
|
|
109
|
-
{
|
|
110
|
-
topic: string; // Research topic
|
|
111
|
-
searchQueries?: string[]; // Specific queries to run
|
|
112
|
-
sources?: string[]; // 'web' | 'academic' | 'news'
|
|
113
|
-
maxResultsPerQuery?: number; // Results per query (default: 3)
|
|
114
|
-
}
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### 3. Fact Checker
|
|
118
|
-
|
|
119
|
-
Verify claims across multiple sources.
|
|
120
|
-
|
|
121
|
-
**Input:**
|
|
122
|
-
```typescript
|
|
123
|
-
{
|
|
124
|
-
claim: string; // Claim to verify
|
|
125
|
-
context?: string; // Additional context
|
|
126
|
-
sources?: string[]; // Specific sources to check
|
|
127
|
-
}
|
|
128
|
-
```
|
|
46
|
+
### `research_aggregate`
|
|
129
47
|
|
|
130
|
-
|
|
48
|
+
Run multiple searches and aggregate results.
|
|
131
49
|
|
|
132
|
-
###
|
|
133
|
-
1. Sign up: https://serper.dev/signup
|
|
134
|
-
2. Get API key from dashboard
|
|
135
|
-
3. 2,500 free queries
|
|
50
|
+
### `fact_check`
|
|
136
51
|
|
|
137
|
-
|
|
138
|
-
1. Sign up: https://serpapi.com/users/sign_up
|
|
139
|
-
2. Copy API key from account page
|
|
140
|
-
3. 100 free searches/month
|
|
52
|
+
Cross-check a claim across sources.
|
|
141
53
|
|
|
142
|
-
|
|
143
|
-
1. Register: https://brave.com/search/api/
|
|
144
|
-
2. Get API key
|
|
145
|
-
3. 2,000 free queries/month
|
|
54
|
+
## Notes
|
|
146
55
|
|
|
147
|
-
|
|
148
|
-
-
|
|
149
|
-
- Limited functionality
|
|
150
|
-
- Rate limited
|
|
151
|
-
|
|
152
|
-
## Usage with Agents
|
|
153
|
-
|
|
154
|
-
Once installed, agents can use search tools:
|
|
155
|
-
|
|
156
|
-
```typescript
|
|
157
|
-
// Agent conversation
|
|
158
|
-
User: "Search for information about quantum computing"
|
|
159
|
-
Agent: [Uses webSearch tool] Here's what I found about quantum computing...
|
|
160
|
-
|
|
161
|
-
User: "Research the latest renewable energy developments"
|
|
162
|
-
Agent: [Uses researchAggregator tool] I've compiled research from multiple sources...
|
|
163
|
-
|
|
164
|
-
User: "Fact check: Is coffee the second most traded commodity?"
|
|
165
|
-
Agent: [Uses factCheck tool] After checking multiple sources...
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
## Error Handling
|
|
169
|
-
|
|
170
|
-
The extension handles various error scenarios:
|
|
171
|
-
|
|
172
|
-
```typescript
|
|
173
|
-
// Missing API key
|
|
174
|
-
{
|
|
175
|
-
success: false,
|
|
176
|
-
error: "Search provider not configured",
|
|
177
|
-
details: {
|
|
178
|
-
message: "Please configure a search API key",
|
|
179
|
-
providers: [/* signup links */]
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// Rate limiting
|
|
184
|
-
// Automatically enforced based on provider limits
|
|
185
|
-
|
|
186
|
-
// Network errors
|
|
187
|
-
{
|
|
188
|
-
success: false,
|
|
189
|
-
error: "Search failed: Network error",
|
|
190
|
-
details: { provider: "serper", timestamp: "..." }
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
## Development
|
|
195
|
-
|
|
196
|
-
```bash
|
|
197
|
-
# Install dependencies
|
|
198
|
-
npm install
|
|
199
|
-
|
|
200
|
-
# Build
|
|
201
|
-
npm run build
|
|
202
|
-
|
|
203
|
-
# Run tests
|
|
204
|
-
npm test
|
|
205
|
-
|
|
206
|
-
# Watch mode
|
|
207
|
-
npm run dev
|
|
208
|
-
```
|
|
56
|
+
- Tools are read-only (no side effects).
|
|
57
|
+
- Provider selection is automatic based on which keys are configured.
|
|
209
58
|
|
|
210
59
|
## License
|
|
211
60
|
|
|
212
61
|
MIT © Frame.dev
|
|
213
|
-
|
|
214
|
-
## Support
|
|
215
|
-
|
|
216
|
-
- Issues: https://github.com/framersai/agentos-extensions/issues
|
|
217
|
-
- Documentation: https://agentos.sh/docs/extensions
|
|
218
|
-
- Discord: https://discord.gg/agentos
|
package/dist/index.d.ts
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
* Provides web search capabilities through multiple providers with automatic fallback.
|
|
5
5
|
*
|
|
6
6
|
* @module @framers/agentos-ext-web-search
|
|
7
|
-
* @version 1.
|
|
7
|
+
* @version 1.1.0
|
|
8
8
|
* @license MIT
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
11
|
-
import { WebSearchTool } from './tools/webSearch';
|
|
12
|
-
import { ResearchAggregatorTool } from './tools/researchAggregator';
|
|
13
|
-
import { FactCheckTool } from './tools/factCheck';
|
|
10
|
+
import type { ExtensionPackContext, ExtensionPack } from '@framers/agentos';
|
|
11
|
+
import { WebSearchTool } from './tools/webSearch.js';
|
|
12
|
+
import { ResearchAggregatorTool } from './tools/researchAggregator.js';
|
|
13
|
+
import { FactCheckTool } from './tools/factCheck.js';
|
|
14
14
|
/**
|
|
15
15
|
* Extension configuration options
|
|
16
16
|
*/
|
|
@@ -21,6 +21,12 @@ export interface WebSearchExtensionOptions {
|
|
|
21
21
|
serpApiKey?: string;
|
|
22
22
|
/** Brave Search API key */
|
|
23
23
|
braveApiKey?: string;
|
|
24
|
+
/** Tavily API key — AI-optimized search for RAG, research, citations */
|
|
25
|
+
tavilyApiKey?: string;
|
|
26
|
+
/** Firecrawl API key — web scraping + search */
|
|
27
|
+
firecrawlApiKey?: string;
|
|
28
|
+
/** SearXNG instance URL (e.g. http://searxng:8080 or http://localhost:8888) */
|
|
29
|
+
searxngUrl?: string;
|
|
24
30
|
/** Default maximum results for searches */
|
|
25
31
|
defaultMaxResults?: number;
|
|
26
32
|
/** Rate limiting configuration */
|
|
@@ -28,13 +34,15 @@ export interface WebSearchExtensionOptions {
|
|
|
28
34
|
maxRequests: number;
|
|
29
35
|
windowMs: number;
|
|
30
36
|
};
|
|
37
|
+
/** Default multi-provider parallel search for all search tools */
|
|
38
|
+
defaultMultiSearch?: boolean;
|
|
31
39
|
/** Extension priority in the stack */
|
|
32
40
|
priority?: number;
|
|
33
41
|
}
|
|
34
42
|
/**
|
|
35
43
|
* Creates the web search extension pack
|
|
36
44
|
*
|
|
37
|
-
* @param {
|
|
45
|
+
* @param {ExtensionPackContext} context - The extension context
|
|
38
46
|
* @returns {ExtensionPack} The configured extension pack
|
|
39
47
|
*
|
|
40
48
|
* @example
|
|
@@ -45,14 +53,13 @@ export interface WebSearchExtensionOptions {
|
|
|
45
53
|
* options: {
|
|
46
54
|
* serperApiKey: process.env.SERPER_API_KEY,
|
|
47
55
|
* defaultMaxResults: 10
|
|
48
|
-
* }
|
|
49
|
-
* logger: console
|
|
56
|
+
* }
|
|
50
57
|
* });
|
|
51
58
|
* ```
|
|
52
59
|
*/
|
|
53
|
-
export declare function createExtensionPack(context:
|
|
60
|
+
export declare function createExtensionPack(context: ExtensionPackContext): ExtensionPack;
|
|
54
61
|
export { WebSearchTool, ResearchAggregatorTool, FactCheckTool };
|
|
55
|
-
export { SearchProviderService, SearchResult, ProviderResponse } from './services/searchProvider';
|
|
56
|
-
export type { SearchProviderConfig } from './services/searchProvider';
|
|
62
|
+
export { SearchProviderService, SearchResult, ProviderResponse } from './services/searchProvider.js';
|
|
63
|
+
export type { SearchProviderConfig, MultiSearchResult, MultiSearchResponse } from './services/searchProvider.js';
|
|
57
64
|
export default createExtensionPack;
|
|
58
65
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAA6B,MAAM,kBAAkB,CAAC;AACvG,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,yBAAyB;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sBAAsB;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gDAAgD;IAChD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kCAAkC;IAClC,SAAS,CAAC,EAAE;QACV,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,kEAAkE;IAClE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CA+EhF;AAGD,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,aAAa,EAAE,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrG,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGjH,eAAe,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-nocheck
|
|
2
2
|
/**
|
|
3
3
|
* AgentOS Web Search Extension
|
|
4
4
|
*
|
|
5
5
|
* Provides web search capabilities through multiple providers with automatic fallback.
|
|
6
6
|
*
|
|
7
7
|
* @module @framers/agentos-ext-web-search
|
|
8
|
-
* @version 1.
|
|
8
|
+
* @version 1.1.0
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(exports, "WebSearchTool", { enumerable: true, get: function () { return webSearch_1.WebSearchTool; } });
|
|
16
|
-
const researchAggregator_1 = require("./tools/researchAggregator");
|
|
17
|
-
Object.defineProperty(exports, "ResearchAggregatorTool", { enumerable: true, get: function () { return researchAggregator_1.ResearchAggregatorTool; } });
|
|
18
|
-
const factCheck_1 = require("./tools/factCheck");
|
|
19
|
-
Object.defineProperty(exports, "FactCheckTool", { enumerable: true, get: function () { return factCheck_1.FactCheckTool; } });
|
|
20
|
-
const searchProvider_1 = require("./services/searchProvider");
|
|
11
|
+
import { WebSearchTool } from './tools/webSearch.js';
|
|
12
|
+
import { ResearchAggregatorTool } from './tools/researchAggregator.js';
|
|
13
|
+
import { FactCheckTool } from './tools/factCheck.js';
|
|
14
|
+
import { SearchProviderService } from './services/searchProvider.js';
|
|
21
15
|
/**
|
|
22
16
|
* Creates the web search extension pack
|
|
23
17
|
*
|
|
24
|
-
* @param {
|
|
18
|
+
* @param {ExtensionPackContext} context - The extension context
|
|
25
19
|
* @returns {ExtensionPack} The configured extension pack
|
|
26
20
|
*
|
|
27
21
|
* @example
|
|
@@ -32,69 +26,82 @@ const searchProvider_1 = require("./services/searchProvider");
|
|
|
32
26
|
* options: {
|
|
33
27
|
* serperApiKey: process.env.SERPER_API_KEY,
|
|
34
28
|
* defaultMaxResults: 10
|
|
35
|
-
* }
|
|
36
|
-
* logger: console
|
|
29
|
+
* }
|
|
37
30
|
* });
|
|
38
31
|
* ```
|
|
39
32
|
*/
|
|
40
|
-
function createExtensionPack(context) {
|
|
41
|
-
const options = context.options
|
|
33
|
+
export function createExtensionPack(context) {
|
|
34
|
+
const options = (context.options ?? {});
|
|
35
|
+
const serperApiKey = options.serperApiKey || process.env.SERPER_API_KEY;
|
|
36
|
+
const serpApiKey = options.serpApiKey || process.env.SERPAPI_API_KEY;
|
|
37
|
+
const braveApiKey = options.braveApiKey || process.env.BRAVE_API_KEY;
|
|
38
|
+
const tavilyApiKey = options.tavilyApiKey || process.env.TAVILY_API_KEY;
|
|
39
|
+
const firecrawlApiKey = options.firecrawlApiKey || process.env.FIRECRAWL_API_KEY;
|
|
40
|
+
const searxngUrl = options.searxngUrl || process.env.SEARXNG_URL;
|
|
42
41
|
// Initialize search service with configuration
|
|
43
|
-
const searchService = new
|
|
44
|
-
serperApiKey
|
|
45
|
-
serpApiKey
|
|
46
|
-
braveApiKey
|
|
42
|
+
const searchService = new SearchProviderService({
|
|
43
|
+
serperApiKey,
|
|
44
|
+
serpApiKey,
|
|
45
|
+
braveApiKey,
|
|
46
|
+
tavilyApiKey,
|
|
47
|
+
firecrawlApiKey,
|
|
48
|
+
searxngUrl,
|
|
47
49
|
rateLimit: options.rateLimit
|
|
48
50
|
});
|
|
51
|
+
const defaultMultiSearch = options.defaultMultiSearch ?? false;
|
|
49
52
|
// Create tool instances
|
|
50
|
-
const webSearchTool = new
|
|
51
|
-
const researchAggregator = new
|
|
52
|
-
const factCheckTool = new
|
|
53
|
+
const webSearchTool = new WebSearchTool(searchService, defaultMultiSearch);
|
|
54
|
+
const researchAggregator = new ResearchAggregatorTool(searchService, defaultMultiSearch);
|
|
55
|
+
const factCheckTool = new FactCheckTool(searchService, defaultMultiSearch);
|
|
53
56
|
return {
|
|
54
57
|
name: '@framers/agentos-ext-web-search',
|
|
55
|
-
version: '1.
|
|
58
|
+
version: '1.1.0',
|
|
56
59
|
descriptors: [
|
|
57
60
|
{
|
|
58
|
-
id:
|
|
61
|
+
id: webSearchTool.name,
|
|
59
62
|
kind: 'tool',
|
|
60
63
|
priority: options.priority || 50,
|
|
61
|
-
payload: webSearchTool
|
|
64
|
+
payload: webSearchTool,
|
|
65
|
+
requiredSecrets: [
|
|
66
|
+
{ id: 'serper.apiKey', optional: true },
|
|
67
|
+
{ id: 'serpapi.apiKey', optional: true },
|
|
68
|
+
{ id: 'brave.apiKey', optional: true },
|
|
69
|
+
],
|
|
62
70
|
},
|
|
63
71
|
{
|
|
64
|
-
id:
|
|
72
|
+
id: researchAggregator.name,
|
|
65
73
|
kind: 'tool',
|
|
66
74
|
priority: options.priority || 50,
|
|
67
|
-
payload: researchAggregator
|
|
75
|
+
payload: researchAggregator,
|
|
76
|
+
requiredSecrets: [
|
|
77
|
+
{ id: 'serper.apiKey', optional: true },
|
|
78
|
+
{ id: 'serpapi.apiKey', optional: true },
|
|
79
|
+
{ id: 'brave.apiKey', optional: true },
|
|
80
|
+
],
|
|
68
81
|
},
|
|
69
82
|
{
|
|
70
|
-
id:
|
|
83
|
+
id: factCheckTool.name,
|
|
71
84
|
kind: 'tool',
|
|
72
85
|
priority: options.priority || 50,
|
|
73
|
-
payload: factCheckTool
|
|
86
|
+
payload: factCheckTool,
|
|
87
|
+
requiredSecrets: [
|
|
88
|
+
{ id: 'serper.apiKey', optional: true },
|
|
89
|
+
{ id: 'serpapi.apiKey', optional: true },
|
|
90
|
+
{ id: 'brave.apiKey', optional: true },
|
|
91
|
+
],
|
|
74
92
|
}
|
|
75
93
|
],
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
*/
|
|
79
|
-
onActivate: async () => {
|
|
80
|
-
if (context.onActivate) {
|
|
81
|
-
await context.onActivate();
|
|
82
|
-
}
|
|
83
|
-
context.logger?.info('Web Search Extension activated');
|
|
94
|
+
onActivate: async (lc) => {
|
|
95
|
+
lc.logger?.info('Web Search Extension activated');
|
|
84
96
|
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
*/
|
|
88
|
-
onDeactivate: async () => {
|
|
89
|
-
if (context.onDeactivate) {
|
|
90
|
-
await context.onDeactivate();
|
|
91
|
-
}
|
|
92
|
-
context.logger?.info('Web Search Extension deactivated');
|
|
97
|
+
onDeactivate: async (lc) => {
|
|
98
|
+
lc.logger?.info('Web Search Extension deactivated');
|
|
93
99
|
}
|
|
94
100
|
};
|
|
95
101
|
}
|
|
96
|
-
|
|
97
|
-
|
|
102
|
+
// Export types for consumers
|
|
103
|
+
export { WebSearchTool, ResearchAggregatorTool, FactCheckTool };
|
|
104
|
+
export { SearchProviderService } from './services/searchProvider.js';
|
|
98
105
|
// Default export for convenience
|
|
99
|
-
|
|
106
|
+
export default createExtensionPack;
|
|
100
107
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc;AACd;;;;;;;;GAQG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AA+BrE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAA6B;IAC/D,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAA8B,CAAC;IAErE,MAAM,YAAY,GAChB,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,GA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C;AAChE,OAAO,EAAE,qBAAqB,EAAkC,MAAM,8BAA8B,CAAC;AAGrG,iCAAiC;AACjC,eAAe,mBAAmB,CAAC"}
|
|
@@ -5,6 +5,9 @@ export interface SearchProviderConfig {
|
|
|
5
5
|
serperApiKey?: string;
|
|
6
6
|
serpApiKey?: string;
|
|
7
7
|
braveApiKey?: string;
|
|
8
|
+
searxngUrl?: string;
|
|
9
|
+
tavilyApiKey?: string;
|
|
10
|
+
firecrawlApiKey?: string;
|
|
8
11
|
maxRetries?: number;
|
|
9
12
|
rateLimit?: {
|
|
10
13
|
maxRequests: number;
|
|
@@ -33,6 +36,35 @@ export interface ProviderResponse {
|
|
|
33
36
|
fallback?: boolean;
|
|
34
37
|
};
|
|
35
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* A search result enriched with cross-provider agreement data.
|
|
41
|
+
*/
|
|
42
|
+
export interface MultiSearchResult extends SearchResult {
|
|
43
|
+
/** Which providers returned this URL */
|
|
44
|
+
providers: string[];
|
|
45
|
+
/** Number of providers that returned this URL */
|
|
46
|
+
agreementCount: number;
|
|
47
|
+
/** Confidence score (0-100) based on cross-provider agreement + position */
|
|
48
|
+
confidenceScore: number;
|
|
49
|
+
/** The position this result appeared at in each provider's results */
|
|
50
|
+
providerPositions: Record<string, number>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Response from a multi-provider parallel search aggregation.
|
|
54
|
+
*/
|
|
55
|
+
export interface MultiSearchResponse {
|
|
56
|
+
results: MultiSearchResult[];
|
|
57
|
+
metadata: {
|
|
58
|
+
query: string;
|
|
59
|
+
timestamp: string;
|
|
60
|
+
totalResponseTime: number;
|
|
61
|
+
providersQueried: string[];
|
|
62
|
+
providersSucceeded: string[];
|
|
63
|
+
providersFailed: string[];
|
|
64
|
+
totalRawResults: number;
|
|
65
|
+
deduplicatedCount: number;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
36
68
|
/**
|
|
37
69
|
* Service for managing multiple search providers with fallback support
|
|
38
70
|
*
|
|
@@ -71,6 +103,7 @@ export declare class SearchProviderService {
|
|
|
71
103
|
search(query: string, options?: {
|
|
72
104
|
maxResults?: number;
|
|
73
105
|
provider?: string;
|
|
106
|
+
category?: string;
|
|
74
107
|
}): Promise<ProviderResponse>;
|
|
75
108
|
/**
|
|
76
109
|
* Searches using a specific provider
|
|
@@ -86,10 +119,9 @@ export declare class SearchProviderService {
|
|
|
86
119
|
/**
|
|
87
120
|
* Gets list of available providers based on configured API keys
|
|
88
121
|
*
|
|
89
|
-
* @private
|
|
90
122
|
* @returns {string[]} Array of available provider names
|
|
91
123
|
*/
|
|
92
|
-
|
|
124
|
+
getAvailableProviders(): string[];
|
|
93
125
|
/**
|
|
94
126
|
* Checks if a provider is within rate limits
|
|
95
127
|
*
|
|
@@ -136,7 +168,16 @@ export declare class SearchProviderService {
|
|
|
136
168
|
*/
|
|
137
169
|
private searchDuckDuckGo;
|
|
138
170
|
/**
|
|
139
|
-
* Search using DuckDuckGo
|
|
171
|
+
* Search using DuckDuckGo HTML search page.
|
|
172
|
+
*
|
|
173
|
+
* The Instant Answer API (`api.duckduckgo.com/?format=json`) only returns
|
|
174
|
+
* Wikipedia-style abstracts and related topics — it does NOT return actual
|
|
175
|
+
* web search results. For most factual queries (follower counts, prices,
|
|
176
|
+
* current stats) it returns nothing useful.
|
|
177
|
+
*
|
|
178
|
+
* This method POSTs to the HTML search endpoint instead, which returns real
|
|
179
|
+
* organic search results. If the HTML scrape fails, it falls back to the
|
|
180
|
+
* Instant Answer API as a last resort.
|
|
140
181
|
*
|
|
141
182
|
* @private
|
|
142
183
|
* @param {string} query - Search query
|
|
@@ -144,6 +185,51 @@ export declare class SearchProviderService {
|
|
|
144
185
|
* @returns {Promise<SearchResult[]>} Search results
|
|
145
186
|
*/
|
|
146
187
|
private searchDuckDuckGoAPI;
|
|
188
|
+
/**
|
|
189
|
+
* Scrapes real search results from DuckDuckGo's HTML search page.
|
|
190
|
+
*
|
|
191
|
+
* @private
|
|
192
|
+
*/
|
|
193
|
+
private scrapeDuckDuckGoHTML;
|
|
194
|
+
/**
|
|
195
|
+
* DuckDuckGo Instant Answer API (limited — only returns Wikipedia-style
|
|
196
|
+
* abstracts and related topics, NOT real search results).
|
|
197
|
+
*
|
|
198
|
+
* @private
|
|
199
|
+
*/
|
|
200
|
+
private searchDuckDuckGoInstantAnswer;
|
|
201
|
+
/**
|
|
202
|
+
* Search using a self-hosted SearXNG metasearch instance.
|
|
203
|
+
*
|
|
204
|
+
* @private
|
|
205
|
+
* @param {string} query - Search query
|
|
206
|
+
* @param {number} maxResults - Maximum results
|
|
207
|
+
* @param {Object} [options] - SearXNG-specific options
|
|
208
|
+
* @param {string} [options.categories] - SearXNG categories (e.g. 'general', 'news', 'images')
|
|
209
|
+
* @returns {Promise<SearchResult[]>} Search results
|
|
210
|
+
*/
|
|
211
|
+
private searchSearXNG;
|
|
212
|
+
/**
|
|
213
|
+
* Normalizes a URL for deduplication — strips www, tracking params, trailing slash.
|
|
214
|
+
*/
|
|
215
|
+
static normalizeUrl(rawUrl: string): string;
|
|
216
|
+
/**
|
|
217
|
+
* Search using the Tavily API (AI-optimized search).
|
|
218
|
+
* @see https://docs.tavily.com/docs/tavily-api/rest-api
|
|
219
|
+
*/
|
|
220
|
+
private searchTavily;
|
|
221
|
+
/**
|
|
222
|
+
* Search using the Firecrawl /search endpoint.
|
|
223
|
+
* @see https://docs.firecrawl.dev/api-reference/endpoint/search
|
|
224
|
+
*/
|
|
225
|
+
private searchFirecrawl;
|
|
226
|
+
/**
|
|
227
|
+
* Searches ALL available providers in parallel, then merges, deduplicates,
|
|
228
|
+
* and reranks results by cross-provider agreement.
|
|
229
|
+
*/
|
|
230
|
+
multiSearch(query: string, options?: {
|
|
231
|
+
maxResults?: number;
|
|
232
|
+
}): Promise<MultiSearchResponse>;
|
|
147
233
|
/**
|
|
148
234
|
* Gets recommended search providers with signup information
|
|
149
235
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchProvider.d.ts","sourceRoot":"","sources":["../../src/services/searchProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"searchProvider.d.ts","sourceRoot":"","sources":["../../src/services/searchProvider.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE;QACV,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,QAAQ,EAAE;QACR,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,YAAY;IACrD,wCAAwC;IACxC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,iDAAiD;IACjD,cAAc,EAAE,MAAM,CAAC;IACvB,4EAA4E;IAC5E,eAAe,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,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