droid-patch 0.4.1 → 0.5.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 CHANGED
@@ -54,23 +54,23 @@ npx droid-patch --skip-login -o /path/to/dir my-droid
54
54
 
55
55
  ### Available Options
56
56
 
57
- | Option | Description |
58
- |--------|-------------|
59
- | `--is-custom` | Patch `isCustom:!0` to `isCustom:!1` (enables context compression for custom models) |
60
- | `--skip-login` | Bypass login by injecting a fake `FACTORY_API_KEY` into the binary |
61
- | `--api-base <url>` | Replace Factory API URL with a custom server (max 22 chars) |
62
- | `--websearch` | Inject local WebSearch proxy with multiple search providers |
63
- | `--reasoning-effort` | Enable reasoning effort UI selector for custom models (set to high) |
64
- | `--dry-run` | Verify patches without actually modifying the binary |
65
- | `-p, --path <path>` | Path to the droid binary (default: `~/.droid/bin/droid`) |
66
- | `-o, --output <dir>` | Output directory for patched binary (creates file without alias) |
67
- | `--no-backup` | Skip creating backup of original binary |
68
- | `-v, --verbose` | Enable verbose output |
57
+ | Option | Description |
58
+ | -------------------- | ------------------------------------------------------------------------------------ |
59
+ | `--is-custom` | Patch `isCustom:!0` to `isCustom:!1` (enables context compression for custom models) |
60
+ | `--skip-login` | Bypass login by injecting a fake `FACTORY_API_KEY` into the binary |
61
+ | `--api-base <url>` | Replace Factory API URL with a custom server (max 22 chars) |
62
+ | `--websearch` | Inject local WebSearch proxy with multiple search providers |
63
+ | `--reasoning-effort` | Enable reasoning effort UI selector for custom models (set to high) |
64
+ | `--dry-run` | Verify patches without actually modifying the binary |
65
+ | `-p, --path <path>` | Path to the droid binary (default: `~/.droid/bin/droid`) |
66
+ | `-o, --output <dir>` | Output directory for patched binary (creates file without alias) |
67
+ | `--no-backup` | Skip creating backup of original binary |
68
+ | `-v, --verbose` | Enable verbose output |
69
69
 
70
70
  ### Manage Aliases and Files
71
71
 
72
72
  ```bash
73
- # List all aliases
73
+ # List all aliases (shows versions, flags, creation time)
74
74
  npx droid-patch list
75
75
 
76
76
  # Remove an alias
@@ -80,8 +80,13 @@ npx droid-patch remove <alias-name>
80
80
  npx droid-patch remove ./my-droid
81
81
  npx droid-patch remove /path/to/patched-binary
82
82
 
83
- # Check proxy status
84
- npx droid-patch proxy-status
83
+ # Remove aliases by filter
84
+ npx droid-patch remove --patch-version=0.4.0 # by droid-patch version
85
+ npx droid-patch remove --droid-version=1.0.40 # by droid version
86
+ npx droid-patch remove --flag=websearch # by feature flag
87
+
88
+ # Clear all droid-patch data (aliases, binaries, metadata)
89
+ npx droid-patch clear
85
90
  ```
86
91
 
87
92
  ### Update Aliases
@@ -147,6 +152,7 @@ Replaces all `process.env.FACTORY_API_KEY` references in the binary with a hardc
147
152
  **Purpose**: Bypass the login/authentication requirement without needing to set the `FACTORY_API_KEY` environment variable.
148
153
 
149
154
  **How it works**:
155
+
150
156
  - The original code checks `process.env.FACTORY_API_KEY` to authenticate
151
157
  - After patching, the code directly uses the fake key string, bypassing the env check
152
158
  - This is a binary-level patch, so it works across all terminal sessions without any environment setup
@@ -160,6 +166,7 @@ Replaces the Factory API base URL (`https://api.factory.ai`) with a custom URL.
160
166
  **Limitation**: URL must be 22 characters or less (same length as original URL).
161
167
 
162
168
  **Examples**:
169
+
163
170
  ```bash
164
171
  # Valid URLs (<=22 chars)
165
172
  npx droid-patch --api-base "http://127.0.0.1:3000" droid-local
@@ -176,16 +183,21 @@ Enables WebSearch functionality through a local proxy server that intercepts `/a
176
183
  **Purpose**: Enable WebSearch functionality without Factory.ai authentication.
177
184
 
178
185
  **Features**:
186
+
179
187
  - **Multiple search providers** with automatic fallback
180
- - **Auto-start**: Proxy starts automatically when you run the alias
181
- - **Auto-shutdown**: Proxy shuts down after 5 minutes of inactivity (configurable)
182
- - **Process detection**: Stays alive as long as droid is running
188
+ - **Per-instance proxy**: Each droid instance runs its own proxy on an auto-assigned port
189
+ - **Auto-cleanup**: Proxy automatically stops when droid exits
190
+ - **Forward target**: Use `--api-base` with `--websearch` to forward non-search requests to a custom backend
183
191
 
184
192
  **Usage**:
193
+
185
194
  ```bash
186
- # Create alias with websearch
195
+ # Create alias with websearch (uses official Factory API)
187
196
  npx droid-patch --websearch droid-search
188
197
 
198
+ # Create alias with websearch + custom backend
199
+ npx droid-patch --websearch --api-base=http://127.0.0.1:20002 droid-custom
200
+
189
201
  # Just run it - everything is automatic!
190
202
  droid-search
191
203
  ```
@@ -193,6 +205,7 @@ droid-search
193
205
  ### `--reasoning-effort`
194
206
 
195
207
  Enables reasoning effort control for custom models by patching the binary to:
208
+
196
209
  1. Set `supportedReasoningEfforts` from `["none"]` to `["high"]`
197
210
  2. Set `defaultReasoningEffort` from `"none"` to `"high"`
198
211
  3. Enable the reasoning effort UI selector (normally hidden for custom models)
@@ -201,12 +214,14 @@ Enables reasoning effort control for custom models by patching the binary to:
201
214
  **Purpose**: Allow custom models to use reasoning effort features that are normally only available for official models.
202
215
 
203
216
  **How it works**:
217
+
204
218
  - The droid UI shows a reasoning effort selector when `supportedReasoningEfforts.length > 1`
205
219
  - Custom models are hardcoded with `["none"]`, hiding the selector
206
220
  - This patch changes the value to `["high"]` and modifies the UI condition to show the selector
207
221
  - The reasoning effort setting will be sent to your custom model's API
208
222
 
209
223
  **Usage**:
224
+
210
225
  ```bash
211
226
  # Enable reasoning effort for custom models
212
227
  npx droid-patch --reasoning-effort droid-reasoning
@@ -248,14 +263,14 @@ The `--websearch` feature supports multiple search providers. Configure them usi
248
263
 
249
264
  The proxy tries providers in this order and uses the first one that succeeds:
250
265
 
251
- | Priority | Provider | Quality | Free Tier | Setup Difficulty |
252
- |----------|----------|---------|-----------|------------------|
253
- | 1 | Smithery Exa | Excellent | Free (via Smithery) | Easy |
254
- | 2 | Google PSE | Very Good | 10,000/day | Medium |
255
- | 3 | Serper | Very Good | 2,500 free credits | Easy |
256
- | 4 | Brave Search | Good | 2,000/month | Easy |
257
- | 5 | SearXNG | Good | Unlimited (self-host) | Hard |
258
- | 6 | DuckDuckGo | Basic | Unlimited | None |
266
+ | Priority | Provider | Quality | Free Tier | Setup Difficulty |
267
+ | -------- | ------------ | --------- | --------------------- | ---------------- |
268
+ | 1 | Smithery Exa | Excellent | Free (via Smithery) | Easy |
269
+ | 2 | Google PSE | Very Good | 10,000/day | Medium |
270
+ | 3 | Serper | Very Good | 2,500 free credits | Easy |
271
+ | 4 | Brave Search | Good | 2,000/month | Easy |
272
+ | 5 | SearXNG | Good | Unlimited (self-host) | Hard |
273
+ | 6 | DuckDuckGo | Basic | Unlimited | None |
259
274
 
260
275
  ---
261
276
 
@@ -417,6 +432,7 @@ Find public instances at [searx.space](https://searx.space/)
417
432
  #### Option B: Self-Host with Docker
418
433
 
419
434
  1. **Run SearXNG with Docker**
435
+
420
436
  ```bash
421
437
  docker run -d \
422
438
  --name searxng \
@@ -504,31 +520,7 @@ export BRAVE_API_KEY="your_brave_key"
504
520
 
505
521
  ---
506
522
 
507
- ## Proxy Management
508
-
509
- ### Auto-Shutdown
510
-
511
- The proxy automatically shuts down after 5 minutes of inactivity to save resources.
512
-
513
- ```bash
514
- # Customize timeout (in seconds)
515
- export DROID_PROXY_IDLE_TIMEOUT=600 # 10 minutes
516
- export DROID_PROXY_IDLE_TIMEOUT=0 # Disable auto-shutdown
517
- ```
518
-
519
- ### Check Proxy Status
520
-
521
- ```bash
522
- npx droid-patch proxy-status
523
- ```
524
-
525
- Output shows:
526
- - Proxy running status
527
- - Process ID
528
- - Droid process detection
529
- - Idle timeout settings
530
-
531
- ### Debug Mode
523
+ ## Debug Mode
532
524
 
533
525
  Enable detailed logging to troubleshoot search issues:
534
526
 
@@ -547,15 +539,23 @@ npx droid-patch --websearch droid-search
547
539
  droid-search # Just works!
548
540
 
549
541
  # Full-featured droid
550
- npx droid-patch --is-custom --skip-login --websearch droid-full
542
+ npx droid-patch --is-custom --skip-login --websearch --reasoning-effort droid-full
543
+
544
+ # Websearch with custom backend
545
+ npx droid-patch --websearch --api-base=http://127.0.0.1:20002 droid-custom
551
546
 
552
547
  # Create a standalone patched binary in current directory
553
548
  npx droid-patch --skip-login -o . my-droid
554
549
  ./my-droid --version
555
550
 
551
+ # List all aliases with version info
552
+ npx droid-patch list
553
+
556
554
  # Clean up
557
- npx droid-patch remove droid-search # remove alias and all related files
558
- npx droid-patch remove ./my-droid # remove file
555
+ npx droid-patch remove droid-search # remove single alias
556
+ npx droid-patch remove --flag=websearch # remove all websearch aliases
557
+ npx droid-patch remove --patch-version=0.4.0 # remove by droid-patch version
558
+ npx droid-patch clear # remove everything
559
559
  ```
560
560
 
561
561
  ## License
package/README.zh-CN.md CHANGED
@@ -54,23 +54,23 @@ npx droid-patch --skip-login -o /path/to/dir my-droid
54
54
 
55
55
  ### 可用选项
56
56
 
57
- | 选项 | 说明 |
58
- |------|------|
59
- | `--is-custom` | 将 `isCustom:!0` 修改为 `isCustom:!1`(为自定义模型启用上下文压缩) |
60
- | `--skip-login` | 通过注入假的 `FACTORY_API_KEY` 跳过登录验证 |
61
- | `--api-base <url>` | 将 Factory API URL 替换为自定义服务器(最多 22 个字符) |
62
- | `--websearch` | 注入本地 WebSearch 代理,支持多个搜索提供商 |
63
- | `--reasoning-effort` | 为自定义模型启用推理强度 UI 选择器(设置为 high) |
64
- | `--dry-run` | 验证修补但不实际修改二进制文件 |
65
- | `-p, --path <path>` | droid 二进制文件路径(默认:`~/.droid/bin/droid`) |
66
- | `-o, --output <dir>` | 修补后二进制文件的输出目录(直接创建文件,不创建别名) |
67
- | `--no-backup` | 跳过创建原始二进制文件的备份 |
68
- | `-v, --verbose` | 启用详细输出 |
57
+ | 选项 | 说明 |
58
+ | -------------------- | ------------------------------------------------------------------- |
59
+ | `--is-custom` | 将 `isCustom:!0` 修改为 `isCustom:!1`(为自定义模型启用上下文压缩) |
60
+ | `--skip-login` | 通过注入假的 `FACTORY_API_KEY` 跳过登录验证 |
61
+ | `--api-base <url>` | 将 Factory API URL 替换为自定义服务器(最多 22 个字符) |
62
+ | `--websearch` | 注入本地 WebSearch 代理,支持多个搜索提供商 |
63
+ | `--reasoning-effort` | 为自定义模型启用推理强度 UI 选择器(设置为 high) |
64
+ | `--dry-run` | 验证修补但不实际修改二进制文件 |
65
+ | `-p, --path <path>` | droid 二进制文件路径(默认:`~/.droid/bin/droid`) |
66
+ | `-o, --output <dir>` | 修补后二进制文件的输出目录(直接创建文件,不创建别名) |
67
+ | `--no-backup` | 跳过创建原始二进制文件的备份 |
68
+ | `-v, --verbose` | 启用详细输出 |
69
69
 
70
70
  ### 管理别名和文件
71
71
 
72
72
  ```bash
73
- # 列出所有别名
73
+ # 列出所有别名(显示版本、flags、创建时间)
74
74
  npx droid-patch list
75
75
 
76
76
  # 删除别名
@@ -80,8 +80,13 @@ npx droid-patch remove <alias-name>
80
80
  npx droid-patch remove ./my-droid
81
81
  npx droid-patch remove /path/to/patched-binary
82
82
 
83
- # 检查代理状态
84
- npx droid-patch proxy-status
83
+ # 按条件删除别名
84
+ npx droid-patch remove --patch-version=0.4.0 # 按 droid-patch 版本
85
+ npx droid-patch remove --droid-version=1.0.40 # 按 droid 版本
86
+ npx droid-patch remove --flag=websearch # 按功能 flag
87
+
88
+ # 清除所有 droid-patch 数据(别名、二进制文件、元数据)
89
+ npx droid-patch clear
85
90
  ```
86
91
 
87
92
  ### 更新别名
@@ -147,6 +152,7 @@ export PATH="$HOME/.droid-patch/aliases:$PATH"
147
152
  **用途**:无需设置 `FACTORY_API_KEY` 环境变量即可跳过登录/认证要求。
148
153
 
149
154
  **工作原理**:
155
+
150
156
  - 原始代码通过检查 `process.env.FACTORY_API_KEY` 进行认证
151
157
  - 修补后,代码直接使用假密钥字符串,绕过环境变量检查
152
158
  - 这是二进制级别的修补,因此在所有终端会话中都有效,无需任何环境设置
@@ -160,6 +166,7 @@ export PATH="$HOME/.droid-patch/aliases:$PATH"
160
166
  **限制**:URL 必须不超过 22 个字符(与原始 URL 长度相同)。
161
167
 
162
168
  **示例**:
169
+
163
170
  ```bash
164
171
  # 有效的 URL(<=22 个字符)
165
172
  npx droid-patch --api-base "http://127.0.0.1:3000" droid-local
@@ -176,16 +183,21 @@ npx droid-patch --api-base "http://my-long-domain.com:3000" droid # 错误!
176
183
  **用途**:无需 Factory.ai 认证即可使用 WebSearch 功能。
177
184
 
178
185
  **特性**:
186
+
179
187
  - **多搜索提供商**:支持自动降级
180
- - **自动启动**:运行别名时代理自动启动
181
- - **自动关闭**:空闲 5 分钟后代理自动关闭(可配置)
182
- - **进程检测**:只要 droid 在运行,代理就保持活跃
188
+ - **每实例独立代理**:每个 droid 实例运行自己的代理,自动分配端口
189
+ - **自动清理**:droid 退出时代理自动停止
190
+ - **转发目标**:使用 `--api-base` 配合 `--websearch` 可将非搜索请求转发到自定义后端
183
191
 
184
192
  **使用方法**:
193
+
185
194
  ```bash
186
- # 创建带 websearch 的别名
195
+ # 创建带 websearch 的别名(使用官方 Factory API)
187
196
  npx droid-patch --websearch droid-search
188
197
 
198
+ # 创建带 websearch + 自定义后端的别名
199
+ npx droid-patch --websearch --api-base=http://127.0.0.1:20002 droid-custom
200
+
189
201
  # 直接运行 - 一切都是自动的!
190
202
  droid-search
191
203
  ```
@@ -193,6 +205,7 @@ droid-search
193
205
  ### `--reasoning-effort`
194
206
 
195
207
  通过修补二进制文件为自定义模型启用推理强度控制:
208
+
196
209
  1. 将 `supportedReasoningEfforts` 从 `["none"]` 改为 `["high"]`
197
210
  2. 将 `defaultReasoningEffort` 从 `"none"` 改为 `"high"`
198
211
  3. 启用推理强度 UI 选择器(通常对自定义模型隐藏)
@@ -201,12 +214,14 @@ droid-search
201
214
  **用途**:允许自定义模型使用通常仅对官方模型可用的推理强度功能。
202
215
 
203
216
  **工作原理**:
217
+
204
218
  - 当 `supportedReasoningEfforts.length > 1` 时,droid UI 会显示推理强度选择器
205
219
  - 自定义模型硬编码为 `["none"]`,隐藏了选择器
206
220
  - 此补丁将值改为 `["high"]` 并修改 UI 条件以显示选择器
207
221
  - 推理强度设置将发送到您的自定义模型 API
208
222
 
209
223
  **使用方法**:
224
+
210
225
  ```bash
211
226
  # 为自定义模型启用推理强度
212
227
  npx droid-patch --reasoning-effort droid-reasoning
@@ -248,14 +263,14 @@ npx droid-patch --is-custom --reasoning-effort droid-full
248
263
 
249
264
  代理按以下顺序尝试提供商,使用第一个成功的:
250
265
 
251
- | 优先级 | 提供商 | 质量 | 免费额度 | 设置难度 |
252
- |--------|--------|------|----------|----------|
253
- | 1 | Smithery Exa | 优秀 | 免费(通过 Smithery) | 简单 |
254
- | 2 | Google PSE | 很好 | 10,000 次/天 | 中等 |
255
- | 3 | Serper | 很好 | 2,500 免费额度 | 简单 |
256
- | 4 | Brave Search | 好 | 2,000 次/月 | 简单 |
257
- | 5 | SearXNG | 好 | 无限(自托管) | 较难 |
258
- | 6 | DuckDuckGo | 基本 | 无限 | 无需配置 |
266
+ | 优先级 | 提供商 | 质量 | 免费额度 | 设置难度 |
267
+ | ------ | ------------ | ---- | --------------------- | -------- |
268
+ | 1 | Smithery Exa | 优秀 | 免费(通过 Smithery) | 简单 |
269
+ | 2 | Google PSE | 很好 | 10,000 次/天 | 中等 |
270
+ | 3 | Serper | 很好 | 2,500 免费额度 | 简单 |
271
+ | 4 | Brave Search | 好 | 2,000 次/月 | 简单 |
272
+ | 5 | SearXNG | 好 | 无限(自托管) | 较难 |
273
+ | 6 | DuckDuckGo | 基本 | 无限 | 无需配置 |
259
274
 
260
275
  ---
261
276
 
@@ -417,6 +432,7 @@ export SEARXNG_URL="https://searx.be"
417
432
  #### 选项 B:使用 Docker 自托管
418
433
 
419
434
  1. **使用 Docker 运行 SearXNG**
435
+
420
436
  ```bash
421
437
  docker run -d \
422
438
  --name searxng \
@@ -504,31 +520,7 @@ export BRAVE_API_KEY="your_brave_key"
504
520
 
505
521
  ---
506
522
 
507
- ## 代理管理
508
-
509
- ### 自动关闭
510
-
511
- 代理在空闲 5 分钟后自动关闭以节省资源。
512
-
513
- ```bash
514
- # 自定义超时时间(秒)
515
- export DROID_PROXY_IDLE_TIMEOUT=600 # 10 分钟
516
- export DROID_PROXY_IDLE_TIMEOUT=0 # 禁用自动关闭
517
- ```
518
-
519
- ### 检查代理状态
520
-
521
- ```bash
522
- npx droid-patch proxy-status
523
- ```
524
-
525
- 输出显示:
526
- - 代理运行状态
527
- - 进程 ID
528
- - Droid 进程检测
529
- - 空闲超时设置
530
-
531
- ### 调试模式
523
+ ## 调试模式
532
524
 
533
525
  启用详细日志以排查搜索问题:
534
526
 
@@ -547,15 +539,23 @@ npx droid-patch --websearch droid-search
547
539
  droid-search # 直接使用!
548
540
 
549
541
  # 全功能 droid
550
- npx droid-patch --is-custom --skip-login --websearch droid-full
542
+ npx droid-patch --is-custom --skip-login --websearch --reasoning-effort droid-full
543
+
544
+ # websearch + 自定义后端
545
+ npx droid-patch --websearch --api-base=http://127.0.0.1:20002 droid-custom
551
546
 
552
547
  # 在当前目录创建独立的修补后二进制文件
553
548
  npx droid-patch --skip-login -o . my-droid
554
549
  ./my-droid --version
555
550
 
551
+ # 列出所有别名及版本信息
552
+ npx droid-patch list
553
+
556
554
  # 清理
557
- npx droid-patch remove droid-search # 删除别名和所有相关文件
558
- npx droid-patch remove ./my-droid # 删除文件
555
+ npx droid-patch remove droid-search # 删除单个别名
556
+ npx droid-patch remove --flag=websearch # 删除所有 websearch 别名
557
+ npx droid-patch remove --patch-version=0.4.0 # 按 droid-patch 版本删除
558
+ npx droid-patch clear # 删除所有
559
559
  ```
560
560
 
561
561
  ## 许可证