mirage-proxy
安装并配置 Mirage-proxy 作为 OpenClaw LLM API 调用的透明 PII/秘密过滤器。通过代理处理二进制安装、提供程序配置、自动重启和多模型路由。
安装 / 下载方式
TotalClaw CLI推荐
totalclaw skills install shop:totalclaw:totalclaw~chandika-mirage-proxycURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~chandika-mirage-proxy/file -o chandika-mirage-proxy.md# mirage-proxy for OpenClaw
Transparent secrets/PII filter between OpenClaw and LLM providers. Replaces sensitive data with plausible fakes — the LLM never knows.
GitHub: https://github.com/chandika/mirage-proxy
## Quick Setup
Run the bundled setup script:
```bash
bash ~/.openclaw/workspace/skills/mirage-proxy/setup.sh
```
This downloads the binary, creates an auto-restart wrapper, starts the proxy, and verifies it's running.
To uninstall: `bash ~/.openclaw/workspace/skills/mirage-proxy/setup.sh --uninstall`
## Configure OpenClaw Providers
After setup.sh succeeds, patch the OpenClaw config. Keep original providers AND add mirage versions for instant fallback:
```json5
{
"models": {
"mode": "merge",
"providers": {
"mirage-anthropic": {
"baseUrl": "http://127.0.0.1:8686/anthropic",
"api": "anthropic-messages",
"apiKey": "${ANTHROPIC_API_KEY}",
"models": [
{ "id": "claude-opus-4-6", "name": "Claude Opus 4.6 (mirage)", "api": "anthropic-messages", "reasoning": true, "input": ["text", "image"], "cost": {"input":0,"output":0,"cacheRead":0,"cacheWrite":0}, "contextWindow": 200000, "maxTokens": 32000 },
{ "id": "claude-sonnet-4-6", "name": "Claude Sonnet 4.6 (mirage)", "api": "anthropic-messages", "reasoning": true, "input": ["text", "image"], "cost": {"input":0,"output":0,"cacheRead":0,"cacheWrite":0}, "contextWindow": 200000, "maxTokens": 16000 },
{ "id": "claude-haiku-3-6", "name": "Claude Haiku 3.6 (mirage)", "api": "anthropic-messages", "reasoning": false, "input": ["text", "image"], "cost": {"input":0,"output":0,"cacheRead":0,"cacheWrite":0}, "contextWindow": 200000, "maxTokens": 8192 }
]
}
}
},
"agents": {
"defaults": {
"models": {
"anthropic/claude-opus-4-6": { "alias": "anthropic-opus" },
"anthropic/claude-sonnet-4-6": { "alias": "anthropic-sonnet" },
"anthropic/claude-haiku-3-6": { "alias": "anthropic-haiku" },
"mirage-anthropic/claude-opus-4-6": { "alias": "mirage-opus" },
"mirage-anthropic/claude-sonnet-4-6": { "alias": "mirage-sonnet" },
"mirage-anthropic/claude-haiku-3-6": { "alias": "mirage-haiku" }
}
}
}
}
```
### OpenAI / Codex (OAuth)
For OAuth-based providers (no API key env var), override the built-in provider baseUrl instead of creating a custom provider:
```json5
{
"models": {
"mode": "merge",
"providers": {
"openai-codex": {
"baseUrl": "http://127.0.0.1:8686"
}
}
}
}
```
⚠️ Do NOT add `"apiKey": "${OPENAI_API_KEY}"` to custom providers unless the env var exists in your container — it will crash OpenClaw on startup.
## Model Aliases
After config, switch with `/model`:
| Alias | Route |
|---|---|
| `anthropic-opus` | Direct to Anthropic |
| `mirage-opus` | Via mirage-proxy → Anthropic |
| `anthropic-sonnet` | Direct |
| `mirage-sonnet` | Via mirage |
| `codex` | Direct to OpenAI (or miraged if baseUrl overridden) |
## Persistence
mirage-proxy dies on OpenClaw restarts. Two solutions:
**Docker entrypoint (recommended):**
```yaml
# docker-compose.yml
command: sh -c "nohup /home/node/.openclaw/workspace/start-mirage.sh > /dev/null 2>&1 & exec openclaw start"
```
**Heartbeat check (fallback):**
Add to HEARTBEAT.md:
```
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8686/
```
If 000 or connection refused → restart via `start-mirage.sh`.
## Verify
```bash
# Proxy running?
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8686/
# Expect 502 (up, no path matched)
# Check redaction stats
tail -20 ~/.openclaw/workspace/mirage-proxy.log
# Look for: 🛡️ SECRET (AWS Access Key) [40 chars] → AKIA••••
```
---
## 中文说明
# 面向 OpenClaw 的 mirage-proxy
OpenClaw 与 LLM 提供商之间的透明密钥/PII 过滤器。将敏感数据替换为可信的伪造数据——LLM 永远不会知道。
GitHub: https://github.com/chandika/mirage-proxy
## 快速设置
运行捆绑的设置脚本:
```bash
bash ~/.openclaw/workspace/skills/mirage-proxy/setup.sh
```
这会下载二进制文件、创建自动重启包装器、启动代理并验证其正在运行。
卸载:`bash ~/.openclaw/workspace/skills/mirage-proxy/setup.sh --uninstall`
## 配置 OpenClaw 提供商
setup.sh 成功后,修补 OpenClaw 配置。保留原始提供商**并**添加 mirage 版本以实现即时回退:
```json5
{
"models": {
"mode": "merge",
"providers": {
"mirage-anthropic": {
"baseUrl": "http://127.0.0.1:8686/anthropic",
"api": "anthropic-messages",
"apiKey": "${ANTHROPIC_API_KEY}",
"models": [
{ "id": "claude-opus-4-6", "name": "Claude Opus 4.6 (mirage)", "api": "anthropic-messages", "reasoning": true, "input": ["text", "image"], "cost": {"input":0,"output":0,"cacheRead":0,"cacheWrite":0}, "contextWindow": 200000, "maxTokens": 32000 },
{ "id": "claude-sonnet-4-6", "name": "Claude Sonnet 4.6 (mirage)", "api": "anthropic-messages", "reasoning": true, "input": ["text", "image"], "cost": {"input":0,"output":0,"cacheRead":0,"cacheWrite":0}, "contextWindow": 200000, "maxTokens": 16000 },
{ "id": "claude-haiku-3-6", "name": "Claude Haiku 3.6 (mirage)", "api": "anthropic-messages", "reasoning": false, "input": ["text", "image"], "cost": {"input":0,"output":0,"cacheRead":0,"cacheWrite":0}, "contextWindow": 200000, "maxTokens": 8192 }
]
}
}
},
"agents": {
"defaults": {
"models": {
"anthropic/claude-opus-4-6": { "alias": "anthropic-opus" },
"anthropic/claude-sonnet-4-6": { "alias": "anthropic-sonnet" },
"anthropic/claude-haiku-3-6": { "alias": "anthropic-haiku" },
"mirage-anthropic/claude-opus-4-6": { "alias": "mirage-opus" },
"mirage-anthropic/claude-sonnet-4-6": { "alias": "mirage-sonnet" },
"mirage-anthropic/claude-haiku-3-6": { "alias": "mirage-haiku" }
}
}
}
}
```
### OpenAI / Codex (OAuth)
对于基于 OAuth 的提供商(无 API key 环境变量),覆盖内置提供商的 baseUrl,而不是创建自定义提供商:
```json5
{
"models": {
"mode": "merge",
"providers": {
"openai-codex": {
"baseUrl": "http://127.0.0.1:8686"
}
}
}
}
```
⚠️ 不要向自定义提供商添加 `"apiKey": "${OPENAI_API_KEY}"`,除非该环境变量在你的容器中存在——否则它会在启动时使 OpenClaw 崩溃。
## 模型别名
配置后,用 `/model` 切换:
| 别名 | 路由 |
|---|---|
| `anthropic-opus` | 直连 Anthropic |
| `mirage-opus` | 经 mirage-proxy → Anthropic |
| `anthropic-sonnet` | 直连 |
| `mirage-sonnet` | 经 mirage |
| `codex` | 直连 OpenAI(若覆盖 baseUrl 则经 mirage) |
## 持久化
mirage-proxy 在 OpenClaw 重启时会终止。两种解决方案:
**Docker 入口点(推荐):**
```yaml
# docker-compose.yml
command: sh -c "nohup /home/node/.openclaw/workspace/start-mirage.sh > /dev/null 2>&1 & exec openclaw start"
```
**心跳检查(回退):**
添加到 HEARTBEAT.md:
```
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8686/
```
如果返回 000 或连接被拒绝 → 通过 `start-mirage.sh` 重启。
## 验证
```bash
# Proxy running?
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8686/
# Expect 502 (up, no path matched)
# Check redaction stats
tail -20 ~/.openclaw/workspace/mirage-proxy.log
# Look for: 🛡️ SECRET (AWS Access Key) [40 chars] → AKIA••••
```