Agnuxo1/EnigmAgent

GitHub: Agnuxo1/EnigmAgent

EnigmAgent是一款专为AI Agent设计的本地加密凭据库,通过占位符机制确保API密钥等敏感信息永远不会暴露在LLM上下文窗口和日志中。

Stars: 2 | Forks: 0

# EnigmAgent [![CAJAL](https://img.shields.io/badge/CAJAL-Paper%20Generator-blue)](https://github.com/Agnuxo1/CAJAL) [![CAJAL](https://img.shields.io/badge/CAJAL-Paper%20Generator-blue)](https://github.com/Agnuxo1/CAJAL) [![npm 版本](https://img.shields.io/npm/v/enigmagent-mcp?label=npm&color=cb3837)](https://www.npmjs.com/package/enigmagent-mcp) [![CAJAL](https://img.shields.io/badge/CAJAL-Paper%20Generator-blue)](https://github.com/Agnuxo1/CAJAL) [![npm 下载量](https://img.shields.io/npm/dw/enigmagent-mcp?label=downloads)](https://www.npmjs.com/package/enigmagent-mcp) [![CAJAL](https://img.shields.io/badge/CAJAL-Paper%20Generator-blue)](https://github.com/Agnuxo1/CAJAL) [![许可证: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![CAJAL](https://img.shields.io/badge/CAJAL-Paper%20Generator-blue)](https://github.com/Agnuxo1/CAJAL) [![加密](https://img.shields.io/badge/crypto-Argon2id%20%2B%20AES--256--GCM-green.svg)](docs/THREAT_MODEL.md) [![Glama MCP](https://glama.ai/mcp/servers/Agnuxo1/enigmagent-mcp/badges/score.svg)](https://glama.ai/mcp/servers/Agnuxo1/enigmagent-mcp) [![GitHub 星标](https://img.shields.io/github/stars/Agnuxo1/EnigmAgent?style=social)](https://github.com/Agnuxo1/EnigmAgent) **集成:** [![n8n-nodes-enigmagent](https://img.shields.io/npm/v/n8n-nodes-enigmagent?label=n8n%20node&color=ea4b71)](https://www.npmjs.com/package/n8n-nodes-enigmagent) · [![langchain-enigmagent](https://img.shields.io/pypi/v/langchain-enigmagent?label=langchain&color=1c3c3c)](https://pypi.org/project/langchain-enigmagent/) · [![llama-index-tools-enigmagent](https://img.shields.io/pypi/v/llama-index-tools-enigmagent?label=llamaindex&color=00d4aa)](https://pypi.org/project/llama-index-tools-enigmagent/) · [![crewai-tools-enigmagent](https://img.shields.io/pypi/v/crewai-tools-enigmagent?label=crewai&color=ff5a1f)](https://pypi.org/project/crewai-tools-enigmagent/) · [Claude Desktop](INTEGRATIONS.md#claude-desktop) · [Cursor](INTEGRATIONS.md#cursor) · [Continue.dev](INTEGRATIONS.md#continuedev) · [Cline](INTEGRATIONS.md#cline-vs-code) · [Open WebUI](INTEGRATIONS.md#open-webui) · [更多 →](INTEGRATIONS.md) EnigmAgent 是选项 D。 你的 AI agent 输入 `{{GITHUB_TOKEN}}`。该占位符离开模型,经过对话、日志、上下文窗口——只有当你的工具实际需要凭据的那一刻,EnigmAgent 才会拦截调用,在本地使用 AES-256-GCM 解密真实的 token,并将其注入。明文仅存在一个事件循环周期。模型永远不会看到它。提供商永远不会看到它。你的终端回滚记录也永远不会看到它。 ``` npx enigmagent-mcp --vault ./my.vault.json ``` 这就是**Claude Desktop、Cursor、Continue.dev、Cline、Open WebUI、AnythingLLM 和 LM Studio** 的全部安装过程。一个单独的浏览器扩展涵盖了在浏览器标签页中运行的所有内容。 ## 30 秒 Claude Desktop 设置 将以下内容添加到 `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) 或 `%APPDATA%\Claude\claude_desktop_config.json` (Windows): ``` { "mcpServers": { "enigmagent": { "command": "npx", "args": ["-y", "enigmagent-mcp", "--vault", "/absolute/path/to/my.vault.json"] } } } ``` 重启 Claude Desktop。会出现两个新工具:`enigmagent_resolve` 和 `enigmagent_list`。现在问 Claude: 真实的 token 永远不会进入对话。相同的模式也适用于下方的 [Cursor](#cursor) 和 [Continue.dev](#continuedev)。 ## 问题(详解) 当你使用 AI agent——Claude、ChatGPT、Cursor 或浏览器自动化工具——执行需要凭据的操作时,你面临一个不可能的选择: | 选项 | 会发生什么 | |---|---| | 在聊天中粘贴机密信息 | 它最终会出现在 AI 提供商的日志、上下文窗口,甚至可能是训练数据中 | | 给 agent 一个长期有效的 token | agent 可以在未来的任何会话中以完全权限采取行动 | | 不使用 agent 处理敏感任务 | 你会失去大部分价值 | **EnigmAgent 是选项 D。** agent 只会输入 `{{GITHUB_TOKEN}}`。真实的值永远不会出现在对话、日志或 agent 的记忆中。 ## 工作原理 ``` ┌─────────────────┐ types {{GITHUB_TOKEN}} ┌────────────────────┐ │ LLM / Agent │ ──────────────────────────▶ │ Tool call / Form │ │ (any provider) │ │ (github.com / …) │ └─────────────────┘ └─────────┬──────────┘ │ submit / call (intercepted) ▼ ┌───────────────────────┐ │ EnigmAgent │ │ detects placeholder, │ │ checks domain match, │ │ decrypts → ghp_xxx │ └───────────┬───────────┘ │ real value ▼ ┌───────────────────────┐ │ Request reissued │ │ with real credential │ └───────────────────────┘ ``` 明文值在内存中仅存在大约一个事件循环周期。它永远不会被写入剪贴板,永远不会被记录,也永远不会被任何其他标签页、脚本或 LLM 上下文看到。 ## 安装路径 ### MCP 服务器(推荐用于 AI agent) ``` npx enigmagent-mcp --vault ./my.vault.json # MCP stdio for Claude/Cursor/etc. npx enigmagent-mcp --mode rest --port 3737 # local REST API for custom integrations ``` 设置 `ENIGMAGENT_USER` + `ENIGMAGENT_PASS` 环境变量可跳过交互式解锁提示(CI/无头模式)。 ### 浏览器扩展(用于 Web 表单中的凭据) **Chrome / Edge / Brave** 1. 下载 [最新发布版 ZIP](https://github.com/Agnuxo1/EnigmAgent/releases) 并解压缩。 2. 前往 `chrome://extensions` 并启用右上角的 **开发者模式** 开关。 3. 点击 **加载已解压的扩展程序** 并选择 `extension/` 文件夹。 **Firefox** 1. 前往 `about:debugging#/runtime/this-firefox`。 2. 点击 **临时载入附加组件…** 3. 选择 `extension/manifest.json`。 ## 各客户端配置 ### Claude Desktop 请参阅[上方的 30 秒设置](#30-second-claude-desktop-setup)。 ### Cursor 添加到 `~/.cursor/mcp.json`: ``` { "mcpServers": { "enigmagent": { "command": "npx", "args": ["-y", "enigmagent-mcp", "--vault", "/abs/path/my.vault.json"] } } } ``` ### Continue.dev 在 `~/.continue/config.yaml` 中: ``` mcpServers: - name: enigmagent command: npx args: ["-y", "enigmagent-mcp", "--vault", "/abs/path/my.vault.json"] ``` ### Cline (VS Code) 编辑 `cline_mcp_settings.json`: ``` { "mcpServers": { "enigmagent": { "command": "npx", "args": ["-y", "enigmagent-mcp", "--vault", "/abs/path/my.vault.json"] } } } ``` ### Open WebUI 使用 [`mcpo`](https://github.com/open-webui/mcpo) 作为桥接: ``` mcpo --port 8000 -- npx enigmagent-mcp --vault /abs/path/my.vault.json ``` ## 实际用例 ### 基于浏览器的 agent 告诉你的 agent:*"当你需要在 GitHub 上进行身份验证时,输入 `{{GITHUB_TOKEN}}` 并提交。不要向我索要真实的值。"* agent 输入占位符。EnigmAgent 进行拦截,在绑定的域名上进行解析、注入并重新提交。会显示一个小徽章:**✓ 已使用真实值提交**。 ### 文档注入 (`{{DOC:filename}}`) 将一个 Markdown 文件作为文档机密上传。在绑定域名上的任何文本字段中将其引用为 `{{DOC:system-prompt.md}}`。你的 agent 可以嵌入你的完整系统提示,而无需它出现在聊天中。 ### 个人数据占位符 ``` add NIF @agenciatributaria.gob.es 12345678A add IBAN @banca.example.com ES9121000418450200051332 ``` 任何自定义名称均可使用。域名绑定在所有地方均被强制执行。 ## 占位符语法参考 | 语法 | 解析为 | |---|---| | `{{GITHUB_TOKEN}}` | 名为 `GITHUB_TOKEN` 的机密信息,仅限在其绑定的域名上使用 | | `{{LOGIN:github.com}}` | 绑定到 `github.com` 的第一个机密信息 | | `{{DOC:report.md}}` | 存储文档 `DOC_report.md` 的内容 | | `{{NIF}}` | 个人数据占位符 — 任何自定义名称均可使用 | 名称语法:`[A-Za-z0-9_:\-.@]+` — 不区分大小写。 ## 安全模型 | 层 | 实现 | |---|---| | 密码到密钥的推导 | **Argon2id** (m=64 MiB, t=3, p=1) — `@noble/hashes@1.4.0`,内置,可重现 | | 机密信息加密 | **AES-256-GCM**,每个条目 96 位 nonce | | 密钥材料 | 仅存在于进程内存中 — 永远不会写入磁盘 | | 用户名绑定 | 用户名混合到 Argon2id 上下文中:相同的密码 + 不同的用户 = 不同的密钥 | | 域名强制执行 | 每个机密信息都固定到特定的域名;解析器拒绝不匹配的来源 | | 投递到网站 | 原生 `value` 设置器 + `input`/`change` 事件 — 永远不经过剪贴板,永远不经过控制台 | | Vault 存储 | 磁盘上的加密文件,明文从不持久化保存 | 完整的威胁模型:[docs/THREAT_MODEL.md](docs/THREAT_MODEL.md)。它不能防范以下情况: - 你机器上受损的进程读取已解锁的会话内存 - 你连接到的恶意 MCP 服务器拥有调用 `enigmagent_resolve` 的权限 - 侧信道攻击(时序、交换空间、核心转储)— 这不在 v0.x 版本的范围内 ## EnigmAgent 与 1Password / Bitwarden / `.env` 的对比 | | 1Password / Bitwarden | `.env` 文件 | EnigmAgent | |---|---|---|---| | **目标用户** | 登录的人类 | 避免硬编码机密信息的开发者 | 代表人类行事的 AI agent | | **核心问题** | 为人类填充登录信息 | 将机密信息排除在源代码控制之外 | 将机密信息排除在 AI 上下文窗口和日志之外 | | **静态存储** | 加密(云端) | 明文 | 加密(本地文件) | | **对 LLM 上下文可见** | 是(当人类粘贴时) | 是(当 agent 读取 `.env` 文件时) | **永不** | | **域名绑定** | 每项的 URL 提示 | 无 | 强制执行 | | **云端同步** | 是 | 不适用 | 否 — 设计上仅限本地 | 请使用 1Password 或 Bitwarden 管理你自己的登录信息。请使用 `.env` 文件作为你的本地开发快捷方式。请使用 EnigmAgent 管理你的 AI agent 代表你行事时所需的凭据。 ## 为什么开发这个工具 EnigmAgent 是 [OpenCLAW / P2PCLAW](https://www.p2pclaw.com) 隐私保护本地 AI 工具生态系统的一部分——这是一个多 agent 科学研究网络,数十个 LLM agent 在其中进行协调、相互评估并发表论文。这些 agent 中的每一个都需要凭据。但它们都不应该拥有凭据。 这就是整个问题陈述。这个 vault 只是最小可行的解决方案。 — [Francisco Angulo de Lafuente](https://github.com/Agnuxo1) ## 仓库布局 ``` EnigmAgent/ ├── extension/ Chrome/Firefox extension (MV3) ├── platforms/firefox-ext/ Firefox manifest variant ├── build-tool/ Reproducible build (esbuild + icon generator) ├── docs/ ARCHITECTURE.md, THREAT_MODEL.md │ └── papers/ Background research papers (PDF) ├── examples/ Placeholder schemas ├── tests/ Smoke tests + crypto round-trip ├── glama.json Glama MCP server manifest ├── smithery.yaml Smithery server descriptor ├── PRIVACY.md ├── SECURITY.md Responsible disclosure └── README.md ``` Node/MCP 服务器的源码位于姊妹仓库中:[Agnuxo1/enigmagent-mcp](https://github.com/Agnuxo1/enigmagent-mcp)。 ## 重现扩展构建 ``` cd build-tool npm ci npx esbuild argon2-entry.js \ --bundle --minify --format=iife --target=es2020 \ --outfile=../extension/lib/argon2id.js python make-icons.py ``` `package.json` 和 `package-lock.json` 锁定了 `@noble/hashes@1.4.0`。输出是字节可重现的——可以使用 `sha256sum extension/lib/argon2id.js` 进行验证。 ## 为什么不直接使用 `.env` 文件?(对比) | 方式 | 提示词中有机密信息吗? | 日志中有机密信息吗? | 按域名绑定? | 在 CI 中有效吗? | |---|---|---|---|---|---| | `.env` / 环境变量 | ✅ 否(但 agent 可以读取它们) | ✅ 否 | ❌ 全局 | ✅ 是 | | 粘贴到聊天中 | ❌ 是 — 永久的 | ❌ 是 — 永久的 | — | — | | 1Password CLI | ✅ 否 | ✅ 否 | ❌ 所有 vault | ✅ 是 | | Doppler / HashiCorp Vault | ✅ 否 | ✅ 否 | ❌ 全局命名空间 | ✅ 是 | | **EnigmAgent** | ✅ **否** | ✅ **否** | ✅ **按机密信息** | ✅ 是 | EnigmAgent 是唯一结合了**本地优先加密**、**按机密信息域名绑定**以及**上下文中零明文**的选项。Vault 文件永远不会离开你的机器。 ## 许可证 MIT — 请参阅 [LICENSE](LICENSE)。 ## 🧩 P2PCLAW 生态系统 本项目是 **P2PCLAW** 的一部分——一个具有生产级基准测试、agent 工具和模型分发功能的分布式 AI 研究网络。 | 组件 | 角色 | 链接 | |-----------|------|------| | **OpenCLAW-P2P** | 核心协议 · Lean 4 证明 · 论文 | [github.com/Agnuxo1/OpenCLAW-P2P](https://github.com/Agnuxo1/OpenCLAW-P2P) | | **BenchClaw** | 17 个评判 agent 的基准测试 | [github.com/Agnuxo1/benchclaw](https://github.com/Agnuxo1/benchclaw) | | **EnigmAgent** | 用于凭据的本地加密 vault | [github.com/Agnuxo1/EnigmAgent](https://github.com/Agnuxo1/EnigmAgent) | | **AgentBoot** | 裸机操作系统安装程序 | [github.com/Agnuxo1/AgentBoot](https://github.com/Agnuxo1/AgentBoot) | | **CAJAL** | 用于论文的 4B 研究 LLM | [huggingface.co/Agnuxo/CAJAL-4B-P2PCLAW](https://huggingface.co/Agnuxo/CAJAL-4B-P2PCLAW)🌐 **主站:** [https://www.p2pclaw.com/](https://www.p2pclaw.com/) 📄 **论文:** [arXiv:2604.19792](https://arxiv.org/abs/2604.19792) ## 💝 支持 如果这个工具对你有用: - ⭐ **为仓库加星标** — 这是生态系统发现工具的方式 - 🐛 **提交问题** — 每一个真实的用例都能让项目更加敏锐 - 💰 **赞助:** [github.com/sponsors/Agnuxo1](https://github.com/sponsors/Agnuxo1) 由 **Francisco Angulo de Lafuente** 构建 — 拥有 35 年以上软件开发经验的独立研究员。
标签:AES-256-GCM, AI代理, API密钥管理, Argon2id, Claude Desktop, CrewAI, LangChain, LlamaIndex, LLM上下文安全, MCP服务器, MITM代理, MIT开源, n8n集成, 令牌解析, 企业密钥管理, 加密算法, 敏感信息保护, 本地加密库, 轻量级, 零云端