superagent-ai/superagent

GitHub: superagent-ai/superagent

Stars: 6424 | Forks: 953

Superagent

Superagent SDK

让您的 AI 应用更安全。

网站 · 文档 · Discord · HuggingFace

Y Combinator GitHub stars MIT License

一个用于 AI agent 安全的开源 SDK。拦截 prompt 注入,脱敏 PII 和密钥,扫描仓库中的威胁,并对您的 agent 运行红队场景。 ## 功能 ### Guard 在运行时检测并拦截 prompt 注入、恶意指令以及不安全的工具调用。 **TypeScript:** ``` import { createClient } from "safety-agent"; const client = createClient(); const result = await client.guard({ input: userMessage }); if (result.classification === "block") { console.log("Blocked:", result.violation_types); } ``` **Python:** ``` from safety_agent import create_client client = create_client() result = await client.guard(input=user_message) if result.classification == "block": print("Blocked:", result.violation_types) ``` ### Redact 自动移除文本中的 PII、PHI 和密钥。 **TypeScript:** ``` const result = await client.redact({ input: "My email is john@example.com and SSN is 123-45-6789", model: "openai/gpt-4o-mini" }); console.log(result.redacted); // "My email is and SSN is " ``` **Python:** ``` result = await client.redact( input="My email is john@example.com and SSN is 123-45-6789", model="openai/gpt-4o-mini" ) print(result.redacted) # "我的邮箱是 ,SSN 是 " ``` ### Scan 分析仓库中针对 AI agent 的攻击,例如仓库投毒和恶意指令。 **TypeScript:** ``` const result = await client.scan({ repo: "https://github.com/user/repo" }); console.log(result.result); // Security report console.log(`Cost: $${result.usage.cost.toFixed(4)}`); ``` **Python:** ``` result = await client.scan(repo="https://github.com/user/repo") print(result.result) # Security report print(f"Cost: ${result.usage.cost:.4f}") ``` ### Test 针对您生产环境中的 agent 运行红队场景。*(即将推出)* ``` const result = await client.test({ endpoint: "https://your-agent.com/chat", scenarios: ["prompt_injection", "data_exfiltration"] }); console.log(result.findings); // Vulnerabilities discovered ``` ## 快速开始 在 [superagent.sh](https://superagent.sh) 注册以获取您的 API key。 **TypeScript:** ``` npm install safety-agent ``` **Python:** ``` uv add safety-agent ``` **设置您的 API key:** ``` export SUPERAGENT_API_KEY=your-key ``` ## 集成选项 | 选项 | 描述 | 链接 | |--------|-------------|------| | **TypeScript SDK** | 在您的应用中直接嵌入 guard、redact 和 scan 功能 | [sdk/typescript](sdk/typescript/README.md) | | **Python SDK** | 在 Python 应用中直接嵌入 guard、redact 和 scan 功能 | [sdk/python](sdk/python/README.md) | | **CLI** | 用于测试和自动化的命令行工具 | [cli](cli/README.md) | | **MCP Server** | 配合 Claude Code 和 Claude Desktop 使用 | [mcp](mcp/README.md) | ## 为什么选择 Superagent SDK? - **适用于任何模型** — OpenAI、Anthropic、Google、Groq、Bedrock 等 - **开源权重模型** — 在您的基础设施上运行 Guard,延迟 50-100ms - **低延迟** — 针对运行时使用进行了优化 - **开源** — MIT 许可证,完全透明 ## 开源权重模型 在您自己的基础设施上运行 Guard。无需 API 调用,数据不会离开您的环境。 | 模型 | 参数量 | 用例 | |-------|------------|----------| | [superagent-guard-0.6b](https://huggingface.co/superagent-ai/superagent-guard-0.6b) | 0.6B | 快速推理,边缘部署 | | [superagent-guard-1.7b](https://huggingface.co/superagent-ai/superagent-guard-1.7b) | 1.7B | 速度与精度的平衡 | | [superagent-guard-4b](https://huggingface.co/superagent-ai/superagent-guard-4b) | 4B | 最高精度 | CPU 版 GGUF:[0.6b-gguf](https://huggingface.co/superagent-ai/superagent-guard-0.6b-gguf) · [1.7b-gguf](https://huggingface.co/superagent-ai/superagent-guard-1.7b-gguf) · [4b-gguf](https://huggingface.co/superagent-ai/superagent-guard-4b-gguf) ## 资源 - [文档](https://docs.superagent.sh) - [Discord 社区](https://discord.gg/spZ7MnqFT4) - [HuggingFace 模型](https://huggingface.co/superagent-ai) - [Twitter/X](https://x.com/superagent_ai) ## 许可证 MIT
标签:AI安全, AI应用防火墙, AMSI绕过, Chat Copilot, DNS 反向解析, GUI应用, Petitpotam, PII检测, TypeScript库, 二进制文件分析, 人工智能安全, 可视化调试, 合规性, 大语言模型安全, 威胁检测, 实时告警, 开源库, 护栏, 提示词注入防御, 搜索引擎爬虫, 敏感信息屏蔽, 数据脱敏, 文档结构分析, 机密管理, 自动化攻击, 自动化攻击, 运行时保护, 逆向工具