droid-patch 0.1.2 → 0.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 +360 -6
- package/README.zh-CN.md +491 -0
- package/dist/{alias-DcCF7R2B.js → alias-C9LRaTwF.js} +106 -4
- package/dist/alias-C9LRaTwF.js.map +1 -0
- package/dist/cli.js +814 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/alias-DcCF7R2B.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# droid-patch
|
|
2
2
|
|
|
3
|
+
English | [简体中文](./README.zh-CN.md)
|
|
4
|
+
|
|
3
5
|
CLI tool to patch the droid binary with various modifications.
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
@@ -21,8 +23,11 @@ npx droid-patch --is-custom droid-custom
|
|
|
21
23
|
# Patch with --skip-login to bypass login requirement
|
|
22
24
|
npx droid-patch --skip-login droid-nologin
|
|
23
25
|
|
|
26
|
+
# Patch with --websearch to enable local search proxy
|
|
27
|
+
npx droid-patch --websearch droid-search
|
|
28
|
+
|
|
24
29
|
# Combine multiple patches
|
|
25
|
-
npx droid-patch --is-custom --skip-login droid-
|
|
30
|
+
npx droid-patch --is-custom --skip-login --websearch droid-full
|
|
26
31
|
|
|
27
32
|
# Specify a custom path to the droid binary
|
|
28
33
|
npx droid-patch --skip-login -p /path/to/droid my-droid
|
|
@@ -50,6 +55,8 @@ npx droid-patch --skip-login -o /path/to/dir my-droid
|
|
|
50
55
|
|--------|-------------|
|
|
51
56
|
| `--is-custom` | Patch `isCustom:!0` to `isCustom:!1` (enables context compression for custom models) |
|
|
52
57
|
| `--skip-login` | Bypass login by injecting a fake `FACTORY_API_KEY` into the binary |
|
|
58
|
+
| `--api-base <url>` | Replace Factory API URL with a custom server (max 22 chars) |
|
|
59
|
+
| `--websearch` | Inject local WebSearch proxy with multiple search providers |
|
|
53
60
|
| `--dry-run` | Verify patches without actually modifying the binary |
|
|
54
61
|
| `-p, --path <path>` | Path to the droid binary (default: `~/.droid/bin/droid`) |
|
|
55
62
|
| `-o, --output <dir>` | Output directory for patched binary (creates file without alias) |
|
|
@@ -68,6 +75,9 @@ npx droid-patch remove <alias-name>
|
|
|
68
75
|
# Remove a patched binary file by path
|
|
69
76
|
npx droid-patch remove ./my-droid
|
|
70
77
|
npx droid-patch remove /path/to/patched-binary
|
|
78
|
+
|
|
79
|
+
# Check proxy status
|
|
80
|
+
npx droid-patch proxy-status
|
|
71
81
|
```
|
|
72
82
|
|
|
73
83
|
### Check Version
|
|
@@ -112,24 +122,368 @@ Replaces all `process.env.FACTORY_API_KEY` references in the binary with a hardc
|
|
|
112
122
|
|
|
113
123
|
**Purpose**: Bypass the login/authentication requirement without needing to set the `FACTORY_API_KEY` environment variable.
|
|
114
124
|
|
|
115
|
-
**How it works**:
|
|
125
|
+
**How it works**:
|
|
116
126
|
- The original code checks `process.env.FACTORY_API_KEY` to authenticate
|
|
117
127
|
- After patching, the code directly uses the fake key string, bypassing the env check
|
|
118
128
|
- This is a binary-level patch, so it works across all terminal sessions without any environment setup
|
|
119
129
|
|
|
130
|
+
### `--api-base <url>`
|
|
131
|
+
|
|
132
|
+
Replaces the Factory API base URL (`https://api.factory.ai`) with a custom URL.
|
|
133
|
+
|
|
134
|
+
**Purpose**: Redirect API requests to a custom server (e.g., local proxy).
|
|
135
|
+
|
|
136
|
+
**Limitation**: URL must be 22 characters or less (same length as original URL).
|
|
137
|
+
|
|
138
|
+
**Examples**:
|
|
139
|
+
```bash
|
|
140
|
+
# Valid URLs (<=22 chars)
|
|
141
|
+
npx droid-patch --api-base "http://127.0.0.1:3000" droid-local
|
|
142
|
+
npx droid-patch --api-base "http://localhost:80" droid-local
|
|
143
|
+
|
|
144
|
+
# Invalid (too long)
|
|
145
|
+
npx droid-patch --api-base "http://my-long-domain.com:3000" droid # Error!
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### `--websearch`
|
|
149
|
+
|
|
150
|
+
Enables WebSearch functionality through a local proxy server that intercepts `/api/tools/exa/search` requests.
|
|
151
|
+
|
|
152
|
+
**Purpose**: Enable WebSearch functionality without Factory.ai authentication.
|
|
153
|
+
|
|
154
|
+
**Features**:
|
|
155
|
+
- **Multiple search providers** with automatic fallback
|
|
156
|
+
- **Auto-start**: Proxy starts automatically when you run the alias
|
|
157
|
+
- **Auto-shutdown**: Proxy shuts down after 5 minutes of inactivity (configurable)
|
|
158
|
+
- **Process detection**: Stays alive as long as droid is running
|
|
159
|
+
|
|
160
|
+
**Usage**:
|
|
161
|
+
```bash
|
|
162
|
+
# Create alias with websearch
|
|
163
|
+
npx droid-patch --websearch droid-search
|
|
164
|
+
|
|
165
|
+
# Just run it - everything is automatic!
|
|
166
|
+
droid-search
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## WebSearch Configuration Guide
|
|
172
|
+
|
|
173
|
+
The `--websearch` feature supports multiple search providers. Configure them using environment variables in your shell config (`~/.zshrc`, `~/.bashrc`, etc.).
|
|
174
|
+
|
|
175
|
+
### Search Provider Priority
|
|
176
|
+
|
|
177
|
+
The proxy tries providers in this order and uses the first one that succeeds:
|
|
178
|
+
|
|
179
|
+
| Priority | Provider | Quality | Free Tier | Setup Difficulty |
|
|
180
|
+
|----------|----------|---------|-----------|------------------|
|
|
181
|
+
| 1 | Smithery Exa | Excellent | Free (via Smithery) | Easy |
|
|
182
|
+
| 2 | Google PSE | Very Good | 10,000/day | Medium |
|
|
183
|
+
| 3 | Serper | Very Good | 2,500 free credits | Easy |
|
|
184
|
+
| 4 | Brave Search | Good | 2,000/month | Easy |
|
|
185
|
+
| 5 | SearXNG | Good | Unlimited (self-host) | Hard |
|
|
186
|
+
| 6 | DuckDuckGo | Basic | Unlimited | None |
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## 1. Smithery Exa (Recommended)
|
|
191
|
+
|
|
192
|
+
[Smithery Exa](https://smithery.ai/server/exa) provides high-quality semantic search results through the MCP protocol. Smithery acts as a free proxy to the Exa search API.
|
|
193
|
+
|
|
194
|
+
### Setup Steps
|
|
195
|
+
|
|
196
|
+
1. **Create a Smithery Account**
|
|
197
|
+
- Go to [smithery.ai](https://smithery.ai)
|
|
198
|
+
- Sign up for a free account
|
|
199
|
+
|
|
200
|
+
2. **Get Your API Key**
|
|
201
|
+
- Navigate to your account settings
|
|
202
|
+
- Copy your API key
|
|
203
|
+
|
|
204
|
+
3. **Get Your Profile ID**
|
|
205
|
+
- Go to [smithery.ai/server/exa](https://smithery.ai/server/exa)
|
|
206
|
+
- Your profile ID is shown in the connection URL or settings
|
|
207
|
+
|
|
208
|
+
4. **Configure Environment Variables**
|
|
209
|
+
```bash
|
|
210
|
+
# Add to ~/.zshrc or ~/.bashrc
|
|
211
|
+
export SMITHERY_API_KEY="your_api_key_here"
|
|
212
|
+
export SMITHERY_PROFILE="your_profile_id"
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Pricing
|
|
216
|
+
|
|
217
|
+
- **Free** through Smithery (Smithery proxies the Exa API at no cost)
|
|
218
|
+
- Note: The official Exa API (exa.ai) is paid, but Smithery provides free access
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## 2. Google Programmable Search Engine (PSE)
|
|
223
|
+
|
|
224
|
+
Google PSE provides high-quality search results with a generous free tier.
|
|
225
|
+
|
|
226
|
+
### Setup Steps
|
|
227
|
+
|
|
228
|
+
#### Step 1: Create a Programmable Search Engine
|
|
229
|
+
|
|
230
|
+
1. Go to [Google Programmable Search Engine Console](https://cse.google.com/all)
|
|
231
|
+
2. Click **"Add"** to create a new search engine
|
|
232
|
+
3. Configure:
|
|
233
|
+
- **Sites to search**: Enter `*` to search the entire web
|
|
234
|
+
- **Name**: Give it a descriptive name (e.g., "Web Search")
|
|
235
|
+
4. Click **"Create"**
|
|
236
|
+
5. Click **"Control Panel"** for your new search engine
|
|
237
|
+
6. Copy the **Search engine ID (cx)** - looks like `017576662512468239146:omuauf_lfve`
|
|
238
|
+
|
|
239
|
+
#### Step 2: Get an API Key
|
|
240
|
+
|
|
241
|
+
1. Go to [Google Cloud Console](https://console.cloud.google.com/)
|
|
242
|
+
2. Create a new project or select an existing one
|
|
243
|
+
3. Enable the **Custom Search API**:
|
|
244
|
+
- Go to **"APIs & Services"** > **"Library"**
|
|
245
|
+
- Search for **"Custom Search API"**
|
|
246
|
+
- Click **"Enable"**
|
|
247
|
+
4. Create credentials:
|
|
248
|
+
- Go to **"APIs & Services"** > **"Credentials"**
|
|
249
|
+
- Click **"Create Credentials"** > **"API Key"**
|
|
250
|
+
- Copy the API key
|
|
251
|
+
|
|
252
|
+
#### Step 3: Configure Environment Variables
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
# Add to ~/.zshrc or ~/.bashrc
|
|
256
|
+
export GOOGLE_PSE_API_KEY="AIzaSy..." # Your API key
|
|
257
|
+
export GOOGLE_PSE_CX="017576662512468239146:omuauf_lfve" # Your Search engine ID
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Free Tier Limits
|
|
261
|
+
|
|
262
|
+
- **10,000 queries/day** free
|
|
263
|
+
- Max 10 results per query
|
|
264
|
+
- After limit: $5 per 1,000 queries
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## 3. Serper
|
|
269
|
+
|
|
270
|
+
[Serper](https://serper.dev) provides Google search results through an easy-to-use API.
|
|
271
|
+
|
|
272
|
+
### Setup Steps
|
|
273
|
+
|
|
274
|
+
1. **Create an Account**
|
|
275
|
+
- Go to [serper.dev](https://serper.dev)
|
|
276
|
+
- Sign up for a free account
|
|
277
|
+
|
|
278
|
+
2. **Get Your API Key**
|
|
279
|
+
- After signing in, your API key is displayed on the dashboard
|
|
280
|
+
- Copy the API key
|
|
281
|
+
|
|
282
|
+
3. **Configure Environment Variable**
|
|
283
|
+
```bash
|
|
284
|
+
# Add to ~/.zshrc or ~/.bashrc
|
|
285
|
+
export SERPER_API_KEY="your_api_key_here"
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
### Free Tier
|
|
289
|
+
|
|
290
|
+
- **2,500 free credits** on signup
|
|
291
|
+
- 1 credit = 1 search query
|
|
292
|
+
- Paid plans available for more usage
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## 4. Brave Search
|
|
297
|
+
|
|
298
|
+
[Brave Search API](https://brave.com/search/api/) provides privacy-focused search results.
|
|
299
|
+
|
|
300
|
+
### Setup Steps
|
|
301
|
+
|
|
302
|
+
1. **Create an Account**
|
|
303
|
+
- Go to [brave.com/search/api](https://brave.com/search/api/)
|
|
304
|
+
- Click **"Get Started"**
|
|
305
|
+
|
|
306
|
+
2. **Subscribe to a Plan**
|
|
307
|
+
- Choose the **Free** plan (2,000 queries/month)
|
|
308
|
+
- Or a paid plan for more queries
|
|
309
|
+
|
|
310
|
+
3. **Get Your API Key**
|
|
311
|
+
- Go to your API dashboard
|
|
312
|
+
- Copy your API key
|
|
313
|
+
|
|
314
|
+
4. **Configure Environment Variable**
|
|
315
|
+
```bash
|
|
316
|
+
# Add to ~/.zshrc or ~/.bashrc
|
|
317
|
+
export BRAVE_API_KEY="BSA..."
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### Free Tier
|
|
321
|
+
|
|
322
|
+
- **2,000 queries/month** free
|
|
323
|
+
- Rate limit: 1 query/second
|
|
324
|
+
- Paid plans start at $5/month for 20,000 queries
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## 5. SearXNG (Self-Hosted)
|
|
329
|
+
|
|
330
|
+
[SearXNG](https://github.com/searxng/searxng) is a free, privacy-respecting metasearch engine you can self-host.
|
|
331
|
+
|
|
332
|
+
### Setup Steps
|
|
333
|
+
|
|
334
|
+
#### Option A: Use a Public Instance
|
|
335
|
+
|
|
336
|
+
You can use a public SearXNG instance, but availability and reliability vary.
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
# Example public instance (check if it's available)
|
|
340
|
+
export SEARXNG_URL="https://searx.be"
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
Find public instances at [searx.space](https://searx.space/)
|
|
344
|
+
|
|
345
|
+
#### Option B: Self-Host with Docker
|
|
346
|
+
|
|
347
|
+
1. **Run SearXNG with Docker**
|
|
348
|
+
```bash
|
|
349
|
+
docker run -d \
|
|
350
|
+
--name searxng \
|
|
351
|
+
-p 8080:8080 \
|
|
352
|
+
-e SEARXNG_BASE_URL=http://localhost:8080 \
|
|
353
|
+
searxng/searxng
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
2. **Configure Environment Variable**
|
|
357
|
+
```bash
|
|
358
|
+
# Add to ~/.zshrc or ~/.bashrc
|
|
359
|
+
export SEARXNG_URL="http://localhost:8080"
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### Advantages
|
|
363
|
+
|
|
364
|
+
- Unlimited searches
|
|
365
|
+
- No API key required
|
|
366
|
+
- Privacy-focused
|
|
367
|
+
- Aggregates results from multiple search engines
|
|
368
|
+
|
|
369
|
+
### Disadvantages
|
|
370
|
+
|
|
371
|
+
- Requires self-hosting for reliability
|
|
372
|
+
- Public instances may be slow or unavailable
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
## 6. DuckDuckGo (Default Fallback)
|
|
377
|
+
|
|
378
|
+
DuckDuckGo is used automatically as the final fallback when no other providers are configured or available.
|
|
379
|
+
|
|
380
|
+
### Configuration
|
|
381
|
+
|
|
382
|
+
**No configuration required!** DuckDuckGo works out of the box.
|
|
383
|
+
|
|
384
|
+
### Limitations
|
|
385
|
+
|
|
386
|
+
- HTML scraping (less reliable than API)
|
|
387
|
+
- Basic results compared to other providers
|
|
388
|
+
- May be rate-limited with heavy use
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## Quick Configuration Examples
|
|
393
|
+
|
|
394
|
+
### Minimal Setup (Free, No API Keys)
|
|
395
|
+
|
|
396
|
+
Just use DuckDuckGo fallback:
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
npx droid-patch --websearch droid-search
|
|
400
|
+
droid-search # Works immediately with DuckDuckGo
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### Recommended Setup (Best Quality)
|
|
404
|
+
|
|
405
|
+
```bash
|
|
406
|
+
# Add to ~/.zshrc or ~/.bashrc
|
|
407
|
+
export SMITHERY_API_KEY="your_smithery_key"
|
|
408
|
+
export SMITHERY_PROFILE="your_profile_id"
|
|
409
|
+
|
|
410
|
+
# Fallback: Google PSE
|
|
411
|
+
export GOOGLE_PSE_API_KEY="your_google_key"
|
|
412
|
+
export GOOGLE_PSE_CX="your_search_engine_id"
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
### Budget-Friendly Setup (All Free)
|
|
416
|
+
|
|
417
|
+
```bash
|
|
418
|
+
# Add to ~/.zshrc or ~/.bashrc
|
|
419
|
+
|
|
420
|
+
# Option 1: Google PSE (10,000/day free)
|
|
421
|
+
export GOOGLE_PSE_API_KEY="your_google_key"
|
|
422
|
+
export GOOGLE_PSE_CX="your_search_engine_id"
|
|
423
|
+
|
|
424
|
+
# Option 2: Serper (2,500 free credits)
|
|
425
|
+
export SERPER_API_KEY="your_serper_key"
|
|
426
|
+
|
|
427
|
+
# Option 3: Brave (2,000/month free)
|
|
428
|
+
export BRAVE_API_KEY="your_brave_key"
|
|
429
|
+
|
|
430
|
+
# DuckDuckGo is always available as final fallback
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
---
|
|
434
|
+
|
|
435
|
+
## Proxy Management
|
|
436
|
+
|
|
437
|
+
### Auto-Shutdown
|
|
438
|
+
|
|
439
|
+
The proxy automatically shuts down after 5 minutes of inactivity to save resources.
|
|
440
|
+
|
|
441
|
+
```bash
|
|
442
|
+
# Customize timeout (in seconds)
|
|
443
|
+
export DROID_PROXY_IDLE_TIMEOUT=600 # 10 minutes
|
|
444
|
+
export DROID_PROXY_IDLE_TIMEOUT=0 # Disable auto-shutdown
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
### Check Proxy Status
|
|
448
|
+
|
|
449
|
+
```bash
|
|
450
|
+
npx droid-patch proxy-status
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
Output shows:
|
|
454
|
+
- Proxy running status
|
|
455
|
+
- Process ID
|
|
456
|
+
- Droid process detection
|
|
457
|
+
- Idle timeout settings
|
|
458
|
+
|
|
459
|
+
### Debug Mode
|
|
460
|
+
|
|
461
|
+
Enable detailed logging to troubleshoot search issues:
|
|
462
|
+
|
|
463
|
+
```bash
|
|
464
|
+
export DROID_SEARCH_DEBUG=1
|
|
465
|
+
droid-search
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
---
|
|
469
|
+
|
|
120
470
|
## Examples
|
|
121
471
|
|
|
122
472
|
```bash
|
|
123
|
-
# Quick start: create
|
|
124
|
-
npx droid-patch --
|
|
473
|
+
# Quick start: create droid with websearch
|
|
474
|
+
npx droid-patch --websearch droid-search
|
|
475
|
+
droid-search # Just works!
|
|
476
|
+
|
|
477
|
+
# Full-featured droid
|
|
478
|
+
npx droid-patch --is-custom --skip-login --websearch droid-full
|
|
125
479
|
|
|
126
480
|
# Create a standalone patched binary in current directory
|
|
127
481
|
npx droid-patch --skip-login -o . my-droid
|
|
128
482
|
./my-droid --version
|
|
129
483
|
|
|
130
484
|
# Clean up
|
|
131
|
-
npx droid-patch remove
|
|
132
|
-
npx droid-patch remove ./my-droid
|
|
485
|
+
npx droid-patch remove droid-search # remove alias and all related files
|
|
486
|
+
npx droid-patch remove ./my-droid # remove file
|
|
133
487
|
```
|
|
134
488
|
|
|
135
489
|
## License
|