@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
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,8 @@ export interface WebSearchExtensionOptions {
|
|
|
21
21
|
serpApiKey?: string;
|
|
22
22
|
/** Brave Search API key */
|
|
23
23
|
braveApiKey?: string;
|
|
24
|
+
/** SearXNG instance URL (e.g. http://searxng:8080 or http://localhost:8888) */
|
|
25
|
+
searxngUrl?: string;
|
|
24
26
|
/** Default maximum results for searches */
|
|
25
27
|
defaultMaxResults?: number;
|
|
26
28
|
/** Rate limiting configuration */
|
|
@@ -28,13 +30,15 @@ export interface WebSearchExtensionOptions {
|
|
|
28
30
|
maxRequests: number;
|
|
29
31
|
windowMs: number;
|
|
30
32
|
};
|
|
33
|
+
/** Default multi-provider parallel search for all search tools */
|
|
34
|
+
defaultMultiSearch?: boolean;
|
|
31
35
|
/** Extension priority in the stack */
|
|
32
36
|
priority?: number;
|
|
33
37
|
}
|
|
34
38
|
/**
|
|
35
39
|
* Creates the web search extension pack
|
|
36
40
|
*
|
|
37
|
-
* @param {
|
|
41
|
+
* @param {ExtensionPackContext} context - The extension context
|
|
38
42
|
* @returns {ExtensionPack} The configured extension pack
|
|
39
43
|
*
|
|
40
44
|
* @example
|
|
@@ -45,14 +49,13 @@ export interface WebSearchExtensionOptions {
|
|
|
45
49
|
* options: {
|
|
46
50
|
* serperApiKey: process.env.SERPER_API_KEY,
|
|
47
51
|
* defaultMaxResults: 10
|
|
48
|
-
* }
|
|
49
|
-
* logger: console
|
|
52
|
+
* }
|
|
50
53
|
* });
|
|
51
54
|
* ```
|
|
52
55
|
*/
|
|
53
|
-
export declare function createExtensionPack(context:
|
|
56
|
+
export declare function createExtensionPack(context: ExtensionPackContext): ExtensionPack;
|
|
54
57
|
export { WebSearchTool, ResearchAggregatorTool, FactCheckTool };
|
|
55
|
-
export { SearchProviderService, SearchResult, ProviderResponse } from './services/searchProvider';
|
|
56
|
-
export type { SearchProviderConfig } from './services/searchProvider';
|
|
58
|
+
export { SearchProviderService, SearchResult, ProviderResponse } from './services/searchProvider.js';
|
|
59
|
+
export type { SearchProviderConfig, MultiSearchResult, MultiSearchResponse } from './services/searchProvider.js';
|
|
57
60
|
export default createExtensionPack;
|
|
58
61
|
//# 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":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;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,+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,CAyEhF;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,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* AgentOS Web Search Extension
|
|
4
3
|
*
|
|
5
4
|
* Provides web search capabilities through multiple providers with automatic fallback.
|
|
6
5
|
*
|
|
7
6
|
* @module @framers/agentos-ext-web-search
|
|
8
|
-
* @version 1.
|
|
7
|
+
* @version 1.1.0
|
|
9
8
|
* @license MIT
|
|
10
9
|
*/
|
|
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");
|
|
10
|
+
import { WebSearchTool } from './tools/webSearch.js';
|
|
11
|
+
import { ResearchAggregatorTool } from './tools/researchAggregator.js';
|
|
12
|
+
import { FactCheckTool } from './tools/factCheck.js';
|
|
13
|
+
import { SearchProviderService } from './services/searchProvider.js';
|
|
21
14
|
/**
|
|
22
15
|
* Creates the web search extension pack
|
|
23
16
|
*
|
|
24
|
-
* @param {
|
|
17
|
+
* @param {ExtensionPackContext} context - The extension context
|
|
25
18
|
* @returns {ExtensionPack} The configured extension pack
|
|
26
19
|
*
|
|
27
20
|
* @example
|
|
@@ -32,69 +25,78 @@ const searchProvider_1 = require("./services/searchProvider");
|
|
|
32
25
|
* options: {
|
|
33
26
|
* serperApiKey: process.env.SERPER_API_KEY,
|
|
34
27
|
* defaultMaxResults: 10
|
|
35
|
-
* }
|
|
36
|
-
* logger: console
|
|
28
|
+
* }
|
|
37
29
|
* });
|
|
38
30
|
* ```
|
|
39
31
|
*/
|
|
40
|
-
function createExtensionPack(context) {
|
|
41
|
-
const options = context.options
|
|
32
|
+
export function createExtensionPack(context) {
|
|
33
|
+
const options = (context.options ?? {});
|
|
34
|
+
const serperApiKey = options.serperApiKey || process.env.SERPER_API_KEY;
|
|
35
|
+
const serpApiKey = options.serpApiKey || process.env.SERPAPI_API_KEY;
|
|
36
|
+
const braveApiKey = options.braveApiKey || process.env.BRAVE_API_KEY;
|
|
37
|
+
const searxngUrl = options.searxngUrl || process.env.SEARXNG_URL;
|
|
42
38
|
// Initialize search service with configuration
|
|
43
|
-
const searchService = new
|
|
44
|
-
serperApiKey
|
|
45
|
-
serpApiKey
|
|
46
|
-
braveApiKey
|
|
39
|
+
const searchService = new SearchProviderService({
|
|
40
|
+
serperApiKey,
|
|
41
|
+
serpApiKey,
|
|
42
|
+
braveApiKey,
|
|
43
|
+
searxngUrl,
|
|
47
44
|
rateLimit: options.rateLimit
|
|
48
45
|
});
|
|
46
|
+
const defaultMultiSearch = options.defaultMultiSearch ?? false;
|
|
49
47
|
// Create tool instances
|
|
50
|
-
const webSearchTool = new
|
|
51
|
-
const researchAggregator = new
|
|
52
|
-
const factCheckTool = new
|
|
48
|
+
const webSearchTool = new WebSearchTool(searchService, defaultMultiSearch);
|
|
49
|
+
const researchAggregator = new ResearchAggregatorTool(searchService, defaultMultiSearch);
|
|
50
|
+
const factCheckTool = new FactCheckTool(searchService, defaultMultiSearch);
|
|
53
51
|
return {
|
|
54
52
|
name: '@framers/agentos-ext-web-search',
|
|
55
|
-
version: '1.
|
|
53
|
+
version: '1.1.0',
|
|
56
54
|
descriptors: [
|
|
57
55
|
{
|
|
58
|
-
id:
|
|
56
|
+
id: webSearchTool.name,
|
|
59
57
|
kind: 'tool',
|
|
60
58
|
priority: options.priority || 50,
|
|
61
|
-
payload: webSearchTool
|
|
59
|
+
payload: webSearchTool,
|
|
60
|
+
requiredSecrets: [
|
|
61
|
+
{ id: 'serper.apiKey', optional: true },
|
|
62
|
+
{ id: 'serpapi.apiKey', optional: true },
|
|
63
|
+
{ id: 'brave.apiKey', optional: true },
|
|
64
|
+
],
|
|
62
65
|
},
|
|
63
66
|
{
|
|
64
|
-
id:
|
|
67
|
+
id: researchAggregator.name,
|
|
65
68
|
kind: 'tool',
|
|
66
69
|
priority: options.priority || 50,
|
|
67
|
-
payload: researchAggregator
|
|
70
|
+
payload: researchAggregator,
|
|
71
|
+
requiredSecrets: [
|
|
72
|
+
{ id: 'serper.apiKey', optional: true },
|
|
73
|
+
{ id: 'serpapi.apiKey', optional: true },
|
|
74
|
+
{ id: 'brave.apiKey', optional: true },
|
|
75
|
+
],
|
|
68
76
|
},
|
|
69
77
|
{
|
|
70
|
-
id:
|
|
78
|
+
id: factCheckTool.name,
|
|
71
79
|
kind: 'tool',
|
|
72
80
|
priority: options.priority || 50,
|
|
73
|
-
payload: factCheckTool
|
|
81
|
+
payload: factCheckTool,
|
|
82
|
+
requiredSecrets: [
|
|
83
|
+
{ id: 'serper.apiKey', optional: true },
|
|
84
|
+
{ id: 'serpapi.apiKey', optional: true },
|
|
85
|
+
{ id: 'brave.apiKey', optional: true },
|
|
86
|
+
],
|
|
74
87
|
}
|
|
75
88
|
],
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
*/
|
|
79
|
-
onActivate: async () => {
|
|
80
|
-
if (context.onActivate) {
|
|
81
|
-
await context.onActivate();
|
|
82
|
-
}
|
|
83
|
-
context.logger?.info('Web Search Extension activated');
|
|
89
|
+
onActivate: async (lc) => {
|
|
90
|
+
lc.logger?.info('Web Search Extension activated');
|
|
84
91
|
},
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
*/
|
|
88
|
-
onDeactivate: async () => {
|
|
89
|
-
if (context.onDeactivate) {
|
|
90
|
-
await context.onDeactivate();
|
|
91
|
-
}
|
|
92
|
-
context.logger?.info('Web Search Extension deactivated');
|
|
92
|
+
onDeactivate: async (lc) => {
|
|
93
|
+
lc.logger?.info('Web Search Extension deactivated');
|
|
93
94
|
}
|
|
94
95
|
};
|
|
95
96
|
}
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
// Export types for consumers
|
|
98
|
+
export { WebSearchTool, ResearchAggregatorTool, FactCheckTool };
|
|
99
|
+
export { SearchProviderService } from './services/searchProvider.js';
|
|
98
100
|
// Default export for convenience
|
|
99
|
-
|
|
101
|
+
export default createExtensionPack;
|
|
100
102
|
//# 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;;;;;;;;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;AA2BrE;;;;;;;;;;;;;;;;;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,GAAG,CAAC,cAAc,CAAC;IACrD,MAAM,UAAU,GACd,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IACpD,MAAM,WAAW,GACf,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IACnD,MAAM,UAAU,GACd,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;IAEhD,+CAA+C;IAC/C,MAAM,aAAa,GAAG,IAAI,qBAAqB,CAAC;QAC9C,YAAY;QACZ,UAAU;QACV,WAAW;QACX,UAAU;QACV,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC,CAAC;IAEH,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,IAAI,KAAK,CAAC;IA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EAAE,EAAE,eAAe,EAAE,QAAQ,EAAE,IAAI,EAAE;oBACvC,EAAE,EAAE,EAAE,gBAAgB,EAAE,QAAQ,EAAE,IAAI,EAAE;oBACxC,EAAE,EAAE,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE;iBACvC;aACF;SACF;QACD,UAAU,EAAE,KAAK,EAAE,EAA6B,EAAE,EAAE;YAClD,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,gCAAgC,CAAC,CAAC;QACpD,CAAC;QACD,YAAY,EAAE,KAAK,EAAE,EAA6B,EAAE,EAAE;YACpD,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,kCAAkC,CAAC,CAAC;QACtD,CAAC;KACF,CAAC;AACJ,CAAC;AAED,6BAA6B;AAC7B,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,aAAa,EAAE,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAkC,MAAM,8BAA8B,CAAC;AAGrG,iCAAiC;AACjC,eAAe,mBAAmB,CAAC"}
|
|
@@ -5,6 +5,7 @@ export interface SearchProviderConfig {
|
|
|
5
5
|
serperApiKey?: string;
|
|
6
6
|
serpApiKey?: string;
|
|
7
7
|
braveApiKey?: string;
|
|
8
|
+
searxngUrl?: string;
|
|
8
9
|
maxRetries?: number;
|
|
9
10
|
rateLimit?: {
|
|
10
11
|
maxRequests: number;
|
|
@@ -33,6 +34,35 @@ export interface ProviderResponse {
|
|
|
33
34
|
fallback?: boolean;
|
|
34
35
|
};
|
|
35
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* A search result enriched with cross-provider agreement data.
|
|
39
|
+
*/
|
|
40
|
+
export interface MultiSearchResult extends SearchResult {
|
|
41
|
+
/** Which providers returned this URL */
|
|
42
|
+
providers: string[];
|
|
43
|
+
/** Number of providers that returned this URL */
|
|
44
|
+
agreementCount: number;
|
|
45
|
+
/** Confidence score (0-100) based on cross-provider agreement + position */
|
|
46
|
+
confidenceScore: number;
|
|
47
|
+
/** The position this result appeared at in each provider's results */
|
|
48
|
+
providerPositions: Record<string, number>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Response from a multi-provider parallel search aggregation.
|
|
52
|
+
*/
|
|
53
|
+
export interface MultiSearchResponse {
|
|
54
|
+
results: MultiSearchResult[];
|
|
55
|
+
metadata: {
|
|
56
|
+
query: string;
|
|
57
|
+
timestamp: string;
|
|
58
|
+
totalResponseTime: number;
|
|
59
|
+
providersQueried: string[];
|
|
60
|
+
providersSucceeded: string[];
|
|
61
|
+
providersFailed: string[];
|
|
62
|
+
totalRawResults: number;
|
|
63
|
+
deduplicatedCount: number;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
36
66
|
/**
|
|
37
67
|
* Service for managing multiple search providers with fallback support
|
|
38
68
|
*
|
|
@@ -71,6 +101,7 @@ export declare class SearchProviderService {
|
|
|
71
101
|
search(query: string, options?: {
|
|
72
102
|
maxResults?: number;
|
|
73
103
|
provider?: string;
|
|
104
|
+
category?: string;
|
|
74
105
|
}): Promise<ProviderResponse>;
|
|
75
106
|
/**
|
|
76
107
|
* Searches using a specific provider
|
|
@@ -86,10 +117,9 @@ export declare class SearchProviderService {
|
|
|
86
117
|
/**
|
|
87
118
|
* Gets list of available providers based on configured API keys
|
|
88
119
|
*
|
|
89
|
-
* @private
|
|
90
120
|
* @returns {string[]} Array of available provider names
|
|
91
121
|
*/
|
|
92
|
-
|
|
122
|
+
getAvailableProviders(): string[];
|
|
93
123
|
/**
|
|
94
124
|
* Checks if a provider is within rate limits
|
|
95
125
|
*
|
|
@@ -144,6 +174,28 @@ export declare class SearchProviderService {
|
|
|
144
174
|
* @returns {Promise<SearchResult[]>} Search results
|
|
145
175
|
*/
|
|
146
176
|
private searchDuckDuckGoAPI;
|
|
177
|
+
/**
|
|
178
|
+
* Search using a self-hosted SearXNG metasearch instance.
|
|
179
|
+
*
|
|
180
|
+
* @private
|
|
181
|
+
* @param {string} query - Search query
|
|
182
|
+
* @param {number} maxResults - Maximum results
|
|
183
|
+
* @param {Object} [options] - SearXNG-specific options
|
|
184
|
+
* @param {string} [options.categories] - SearXNG categories (e.g. 'general', 'news', 'images')
|
|
185
|
+
* @returns {Promise<SearchResult[]>} Search results
|
|
186
|
+
*/
|
|
187
|
+
private searchSearXNG;
|
|
188
|
+
/**
|
|
189
|
+
* Normalizes a URL for deduplication — strips www, tracking params, trailing slash.
|
|
190
|
+
*/
|
|
191
|
+
static normalizeUrl(rawUrl: string): string;
|
|
192
|
+
/**
|
|
193
|
+
* Searches ALL available providers in parallel, then merges, deduplicates,
|
|
194
|
+
* and reranks results by cross-provider agreement.
|
|
195
|
+
*/
|
|
196
|
+
multiSearch(query: string, options?: {
|
|
197
|
+
maxResults?: number;
|
|
198
|
+
}): Promise<MultiSearchResponse>;
|
|
147
199
|
/**
|
|
148
200
|
* Gets recommended search providers with signup information
|
|
149
201
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchProvider.d.ts","sourceRoot":"","sources":["../../src/services/searchProvider.ts"],"names":[],"mappings":"AAAA;;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,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;;;;;;;;;;;;;;GAcG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,cAAc,CAAoD;IAE1E;;;;OAIG;gBACS,MAAM,EAAE,oBAAoB;
|
|
1
|
+
{"version":3,"file":"searchProvider.d.ts","sourceRoot":"","sources":["../../src/services/searchProvider.ts"],"names":[],"mappings":"AAAA;;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,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,M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