Vohlsyr/plugin-trustfetch
GitHub: Vohlsyr/plugin-trustfetch
为 ElizaOS AI 代理提供网页抓取时的 prompt-injection 扫描防护,通过 x402 协议实现无需 API 密钥的按次链上付费。
Stars: 0 | Forks: 0
# @vohlsyr/plugin-trustfetch
用于 [TrustFetch](https://trustfetch.duckdns.org) 的 ElizaOS 插件 —— 为必须阅读不可信内容的 AI 代理提供 prompt-injection 扫描和干净的网页抓取功能。
通过 [x402](https://x402.org) 按次付费 —— 使用 Base 上的 USDC,直接从代理自身的钱包扣除。无需 API 密钥,无需注册。
## Actions
### `SAFE_FETCH_URL`
在一次调用中抓取 URL 并将其转换为干净的 Markdown,同时扫描其中的 prompt-injection 尝试。约 $0.03/次。
### `SCAN_FOR_INJECTION`
扫描您已有的一段文本(而非 URL),查找隐藏的 prompt-injection 尝试。约 $0.02/次。
## 安装说明
```
npm install @vohlsyr/plugin-trustfetch
```
将其添加到您的角色/项目的插件列表中,并设置一个密钥:
```
EVM_PRIVATE_KEY=0x... # a wallet funded with a small amount of USDC on Base
```
这与 ElizaOS 自带的 `@elizaos/plugin-evm` 使用的设置名称相同,因此已经为其他链上操作配置了资金钱包的代理会自动获取它 —— 无需管理第二个密钥。
## 工作原理
1. 该 action 调用真实的 endpoint(例如 `POST /tools/safe-fetch`)。
2. 服务器响应 `402 Payment Required`,并附带价格和支付详情。
3. [`x402-fetch`](https://www.npmjs.com/package/x402-fetch) 使用代理的钱包签名并附加支付,然后重试该请求。
4. 服务器结算支付并返回实际结果。
## 开发
```
npm install
npm run typecheck
npm test # vitest -- mocks the x402-fetch boundary, exercises real
# URL-extraction/request-building/formatting logic
npm run build
```
该插件还内置了一个零成本的 `elizaos test` 测试用例(`trustfetch plugin sanity`),它会 ping 该服务的免费 `/healthz` endpoint —— 该测试不需要钱包或支付。
## License
MIT
标签:AI智能体, ElizaOS, Naabu, Web3支付, x402协议, 内容安全, 提示词注入检测, 自动化攻击