genieceo 0.1.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/DEVELOPMENT.md +240 -0
- package/LICENSE +21 -0
- package/README.md +443 -0
- package/config.example.json +28 -0
- package/dist/agent/context.d.ts +38 -0
- package/dist/agent/context.d.ts.map +1 -0
- package/dist/agent/context.js +131 -0
- package/dist/agent/context.js.map +1 -0
- package/dist/agent/index.d.ts +10 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +54 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/loop.d.ts +40 -0
- package/dist/agent/loop.d.ts.map +1 -0
- package/dist/agent/loop.js +104 -0
- package/dist/agent/loop.js.map +1 -0
- package/dist/agent/subagent.d.ts +35 -0
- package/dist/agent/subagent.d.ts.map +1 -0
- package/dist/agent/subagent.js +96 -0
- package/dist/agent/subagent.js.map +1 -0
- package/dist/cli/commands/chat.d.ts +8 -0
- package/dist/cli/commands/chat.d.ts.map +1 -0
- package/dist/cli/commands/chat.js +161 -0
- package/dist/cli/commands/chat.js.map +1 -0
- package/dist/cli/commands/init.d.ts +6 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +56 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/onboard.d.ts +6 -0
- package/dist/cli/commands/onboard.d.ts.map +1 -0
- package/dist/cli/commands/onboard.js +277 -0
- package/dist/cli/commands/onboard.js.map +1 -0
- package/dist/cli/commands/status.d.ts +6 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +107 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +49 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/config/manager.d.ts +43 -0
- package/dist/config/manager.d.ts.map +1 -0
- package/dist/config/manager.js +147 -0
- package/dist/config/manager.js.map +1 -0
- package/dist/config/schema.d.ts +179 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +74 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/providers/llm.d.ts +46 -0
- package/dist/providers/llm.d.ts.map +1 -0
- package/dist/providers/llm.js +175 -0
- package/dist/providers/llm.js.map +1 -0
- package/dist/skills/loader.d.ts +49 -0
- package/dist/skills/loader.d.ts.map +1 -0
- package/dist/skills/loader.js +218 -0
- package/dist/skills/loader.js.map +1 -0
- package/dist/tools/base.d.ts +42 -0
- package/dist/tools/base.d.ts.map +1 -0
- package/dist/tools/base.js +90 -0
- package/dist/tools/base.js.map +1 -0
- package/dist/tools/filesystem.d.ts +17 -0
- package/dist/tools/filesystem.d.ts.map +1 -0
- package/dist/tools/filesystem.js +117 -0
- package/dist/tools/filesystem.js.map +1 -0
- package/dist/tools/shell.d.ts +8 -0
- package/dist/tools/shell.d.ts.map +1 -0
- package/dist/tools/shell.js +79 -0
- package/dist/tools/shell.js.map +1 -0
- package/dist/tools/spawn.d.ts +8 -0
- package/dist/tools/spawn.d.ts.map +1 -0
- package/dist/tools/spawn.js +23 -0
- package/dist/tools/spawn.js.map +1 -0
- package/dist/tools/web.d.ts +8 -0
- package/dist/tools/web.d.ts.map +1 -0
- package/dist/tools/web.js +194 -0
- package/dist/tools/web.js.map +1 -0
- package/dist/types/index.d.ts +51 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/workspace/manager.d.ts +38 -0
- package/dist/workspace/manager.d.ts.map +1 -0
- package/dist/workspace/manager.js +140 -0
- package/dist/workspace/manager.js.map +1 -0
- package/docs/ONBOARDING.md +229 -0
- package/docs/WEB_SEARCH.md +365 -0
- package/package.json +38 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
# Web Search System
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
genieceo's web search system supports multiple providers with automatic fallback, ensuring search functionality is always available to users regardless of their API key configuration or payment preferences.
|
|
6
|
+
|
|
7
|
+
## Architecture
|
|
8
|
+
|
|
9
|
+
### Provider Hierarchy
|
|
10
|
+
|
|
11
|
+
When using `provider: "auto"` (default), the system tries providers in this order:
|
|
12
|
+
|
|
13
|
+
1. **Tavily** (if API key configured)
|
|
14
|
+
- High-quality, AI-optimized search
|
|
15
|
+
- Free tier: 1,000 searches/month
|
|
16
|
+
- Best overall quality
|
|
17
|
+
|
|
18
|
+
2. **Brave** (if API key configured)
|
|
19
|
+
- Premium search API
|
|
20
|
+
- Requires payment
|
|
21
|
+
- Good quality but costly
|
|
22
|
+
|
|
23
|
+
3. **Browser Fallback** (always available)
|
|
24
|
+
- DuckDuckGo HTML scraping
|
|
25
|
+
- No API key needed
|
|
26
|
+
- Free and always works
|
|
27
|
+
- Basic quality but reliable
|
|
28
|
+
|
|
29
|
+
### Provider Selection
|
|
30
|
+
|
|
31
|
+
Users can explicitly select a provider:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"tools": {
|
|
36
|
+
"webSearch": {
|
|
37
|
+
"provider": "tavily" // or "brave", "browser", "auto"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Implementation Details
|
|
44
|
+
|
|
45
|
+
### File Structure
|
|
46
|
+
|
|
47
|
+
- **`src/tools/web.ts`**: Main web search implementation
|
|
48
|
+
- `createWebSearchTool()`: Tool factory function
|
|
49
|
+
- `searchWithTavily()`: Tavily API implementation
|
|
50
|
+
- `searchWithBrave()`: Brave API implementation
|
|
51
|
+
- `searchWithBrowser()`: DuckDuckGo HTML scraping
|
|
52
|
+
|
|
53
|
+
### API Implementations
|
|
54
|
+
|
|
55
|
+
#### Tavily Search
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
POST https://api.tavily.com/search
|
|
59
|
+
Content-Type: application/json
|
|
60
|
+
|
|
61
|
+
{
|
|
62
|
+
"api_key": "tvly-...",
|
|
63
|
+
"query": "search query",
|
|
64
|
+
"max_results": 5,
|
|
65
|
+
"search_depth": "basic",
|
|
66
|
+
"include_answer": false
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Response format:
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"results": [
|
|
74
|
+
{
|
|
75
|
+
"title": "Page title",
|
|
76
|
+
"url": "https://...",
|
|
77
|
+
"content": "Page snippet"
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
#### Brave Search
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
GET https://api.search.brave.com/res/v1/web/search?q=query&count=5
|
|
87
|
+
Headers:
|
|
88
|
+
X-Subscription-Token: BSA...
|
|
89
|
+
Accept: application/json
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Response format:
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"web": {
|
|
96
|
+
"results": [
|
|
97
|
+
{
|
|
98
|
+
"title": "Page title",
|
|
99
|
+
"url": "https://...",
|
|
100
|
+
"description": "Page snippet"
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
#### Browser Fallback (DuckDuckGo)
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
GET https://html.duckduckgo.com/html/?q=query
|
|
111
|
+
Headers:
|
|
112
|
+
User-Agent: Mozilla/5.0 (compatible; genieceo/1.0)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Response: HTML page with search results that are parsed using regex.
|
|
116
|
+
|
|
117
|
+
### Unified Response Format
|
|
118
|
+
|
|
119
|
+
All providers return a consistent format:
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
{
|
|
123
|
+
success: boolean;
|
|
124
|
+
provider: 'brave' | 'tavily' | 'browser';
|
|
125
|
+
query: string;
|
|
126
|
+
results: Array<{
|
|
127
|
+
title: string;
|
|
128
|
+
url: string;
|
|
129
|
+
snippet: string;
|
|
130
|
+
}>;
|
|
131
|
+
total: number;
|
|
132
|
+
note?: string; // Optional note for browser fallback
|
|
133
|
+
error?: string; // If success is false
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Configuration
|
|
138
|
+
|
|
139
|
+
### Config Schema
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
tools: {
|
|
143
|
+
webSearch: {
|
|
144
|
+
provider?: 'auto' | 'brave' | 'tavily' | 'browser';
|
|
145
|
+
brave?: {
|
|
146
|
+
apiKey: string;
|
|
147
|
+
};
|
|
148
|
+
tavily?: {
|
|
149
|
+
apiKey: string;
|
|
150
|
+
};
|
|
151
|
+
// Legacy support
|
|
152
|
+
apiKey?: string;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Migration Handling
|
|
158
|
+
|
|
159
|
+
The config manager automatically migrates legacy configs:
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
// Old format (auto-migrated)
|
|
163
|
+
{
|
|
164
|
+
"tools": {
|
|
165
|
+
"webSearch": {
|
|
166
|
+
"apiKey": "BSA..."
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Migrated to
|
|
172
|
+
{
|
|
173
|
+
"tools": {
|
|
174
|
+
"webSearch": {
|
|
175
|
+
"provider": "auto",
|
|
176
|
+
"brave": {
|
|
177
|
+
"apiKey": "BSA..."
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Error Handling
|
|
185
|
+
|
|
186
|
+
### Auto Mode
|
|
187
|
+
- If a provider fails, the system automatically tries the next provider
|
|
188
|
+
- Errors are logged to console but don't stop the search
|
|
189
|
+
- Browser fallback ensures search always returns results
|
|
190
|
+
|
|
191
|
+
### Specific Provider Mode
|
|
192
|
+
- If the selected provider fails, the error is returned to the agent
|
|
193
|
+
- No automatic fallback to other providers
|
|
194
|
+
- User must fix the configuration or switch providers
|
|
195
|
+
|
|
196
|
+
## Usage Examples
|
|
197
|
+
|
|
198
|
+
### From Agent
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
// The agent calls the tool like this:
|
|
202
|
+
{
|
|
203
|
+
"name": "webSearch",
|
|
204
|
+
"parameters": {
|
|
205
|
+
"query": "latest TypeScript features",
|
|
206
|
+
"count": 5
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### From CLI
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
genieceo chat -m "Search for the latest TypeScript features"
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Testing
|
|
218
|
+
|
|
219
|
+
### Check Configuration
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
genieceo status
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Output shows:
|
|
226
|
+
```
|
|
227
|
+
Web Search Provider: auto
|
|
228
|
+
Tavily: ✓ Configured
|
|
229
|
+
Brave: ○ Not configured
|
|
230
|
+
Browser (fallback): ✓ Always available
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Test Specific Provider
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
# Edit config to set provider: "browser"
|
|
237
|
+
genieceo chat -m "Search for TypeScript"
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Test Auto Fallback
|
|
241
|
+
|
|
242
|
+
Remove all API keys and search should still work with browser fallback.
|
|
243
|
+
|
|
244
|
+
## Performance Considerations
|
|
245
|
+
|
|
246
|
+
### API Latency
|
|
247
|
+
- Tavily: ~500-1500ms
|
|
248
|
+
- Brave: ~300-1000ms
|
|
249
|
+
- Browser: ~1000-2000ms (HTML parsing overhead)
|
|
250
|
+
|
|
251
|
+
### Rate Limits
|
|
252
|
+
- Tavily free tier: 1,000 searches/month
|
|
253
|
+
- Brave: Depends on plan
|
|
254
|
+
- Browser: No rate limits (respectful usage)
|
|
255
|
+
|
|
256
|
+
### Caching
|
|
257
|
+
Currently not implemented. Future enhancement could cache results for repeated queries.
|
|
258
|
+
|
|
259
|
+
## Security
|
|
260
|
+
|
|
261
|
+
### API Keys
|
|
262
|
+
- Stored in `~/.genieceo/config.json`
|
|
263
|
+
- Never logged or exposed
|
|
264
|
+
- Masked in status output (only first 8 and last 4 chars shown)
|
|
265
|
+
|
|
266
|
+
### HTML Scraping
|
|
267
|
+
- Browser fallback only makes GET requests to DuckDuckGo
|
|
268
|
+
- No JavaScript execution
|
|
269
|
+
- Safe regex-based parsing
|
|
270
|
+
- No data sent to third parties
|
|
271
|
+
|
|
272
|
+
## Future Enhancements
|
|
273
|
+
|
|
274
|
+
Potential improvements:
|
|
275
|
+
|
|
276
|
+
1. **Additional Providers**
|
|
277
|
+
- Google Custom Search API
|
|
278
|
+
- Bing Search API
|
|
279
|
+
- SearXNG instances
|
|
280
|
+
|
|
281
|
+
2. **Caching Layer**
|
|
282
|
+
- Cache results for repeated queries
|
|
283
|
+
- Configurable TTL
|
|
284
|
+
|
|
285
|
+
3. **Advanced Browser Search**
|
|
286
|
+
- Integration with Vercel's agent-browser
|
|
287
|
+
- JavaScript rendering for dynamic content
|
|
288
|
+
- Screenshot capture
|
|
289
|
+
|
|
290
|
+
4. **Search Quality**
|
|
291
|
+
- Result ranking/filtering
|
|
292
|
+
- Duplicate detection
|
|
293
|
+
- Domain filtering
|
|
294
|
+
|
|
295
|
+
5. **Monitoring**
|
|
296
|
+
- Usage statistics
|
|
297
|
+
- Provider performance metrics
|
|
298
|
+
- Failure rate tracking
|
|
299
|
+
|
|
300
|
+
## Troubleshooting
|
|
301
|
+
|
|
302
|
+
### Search Always Uses Browser Fallback
|
|
303
|
+
|
|
304
|
+
**Symptoms**: All searches show `provider: "browser"` even with API keys configured
|
|
305
|
+
|
|
306
|
+
**Possible causes**:
|
|
307
|
+
1. API keys are invalid or expired
|
|
308
|
+
2. API keys are not in the correct config location
|
|
309
|
+
3. Provider is explicitly set to "browser"
|
|
310
|
+
|
|
311
|
+
**Solution**:
|
|
312
|
+
```bash
|
|
313
|
+
genieceo status # Check API key status
|
|
314
|
+
# Edit config to verify keys are in correct location
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Search Returns No Results
|
|
318
|
+
|
|
319
|
+
**Symptoms**: `results: []` in response
|
|
320
|
+
|
|
321
|
+
**Possible causes**:
|
|
322
|
+
1. Query too specific or unusual
|
|
323
|
+
2. Provider having issues
|
|
324
|
+
3. Network connectivity problems
|
|
325
|
+
|
|
326
|
+
**Solution**:
|
|
327
|
+
- Try a different, more common query
|
|
328
|
+
- Switch to different provider
|
|
329
|
+
- Check network connection
|
|
330
|
+
|
|
331
|
+
### API Key Errors
|
|
332
|
+
|
|
333
|
+
**Symptoms**: Errors like "API key not configured" or "401 Unauthorized"
|
|
334
|
+
|
|
335
|
+
**Possible causes**:
|
|
336
|
+
1. API key missing from config
|
|
337
|
+
2. API key format incorrect
|
|
338
|
+
3. API key expired or invalid
|
|
339
|
+
|
|
340
|
+
**Solution**:
|
|
341
|
+
```bash
|
|
342
|
+
# Verify API key format:
|
|
343
|
+
# Tavily: tvly-...
|
|
344
|
+
# Brave: BSA...
|
|
345
|
+
|
|
346
|
+
genieceo status # Check configuration
|
|
347
|
+
# Edit config file to fix API keys
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## Contributing
|
|
351
|
+
|
|
352
|
+
When adding a new search provider:
|
|
353
|
+
|
|
354
|
+
1. Add provider config to types and schema
|
|
355
|
+
2. Implement search function in `src/tools/web.ts`
|
|
356
|
+
3. Add to provider hierarchy in `createWebSearchTool()`
|
|
357
|
+
4. Update documentation
|
|
358
|
+
5. Add tests
|
|
359
|
+
6. Update status command to show new provider
|
|
360
|
+
|
|
361
|
+
## Resources
|
|
362
|
+
|
|
363
|
+
- [Tavily API Documentation](https://docs.tavily.com)
|
|
364
|
+
- [Brave Search API Documentation](https://brave.com/search/api)
|
|
365
|
+
- [DuckDuckGo HTML](https://html.duckduckgo.com)
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "genieceo",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Ultra-lightweight AI agent CLI assistant",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"genieceo": "dist/cli/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"dev": "tsc --watch",
|
|
12
|
+
"prepublishOnly": "npm run build",
|
|
13
|
+
"start": "node dist/cli/index.js"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"ai",
|
|
17
|
+
"agent",
|
|
18
|
+
"cli",
|
|
19
|
+
"assistant",
|
|
20
|
+
"llm"
|
|
21
|
+
],
|
|
22
|
+
"author": "",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18.0.0"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@mariozechner/pi-ai": "^0.51.6",
|
|
29
|
+
"chalk": "^4.1.2",
|
|
30
|
+
"commander": "^12.1.0",
|
|
31
|
+
"ora": "^5.4.1",
|
|
32
|
+
"zod": "^3.23.8"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^20.14.0",
|
|
36
|
+
"typescript": "^5.4.5"
|
|
37
|
+
}
|
|
38
|
+
}
|