Ebencode-x/sentinai-project

GitHub: Ebencode-x/sentinai-project

一款自愈型 DevOps Agent,通过实时监控应用日志并调用大模型自动生成结构化代码修复方案与告警。

Stars: 0 | Forks: 0

[![CI](https://static.pigsec.cn/wp-content/uploads/repos/cas/b6/b6eae711bff84e027b4fe5a363b97f6d0b6abbad826737c9fc2c8b4605724eff.svg)](https://github.com/Ebencode-x/sentinai-project/actions/workflows/ci.yml) [![Python](https://img.shields.io/badge/python-3.11-blue)](https://python.org) [![测试](https://img.shields.io/badge/tests-686%20passing-brightgreen)]() [![发布](https://img.shields.io/badge/release-v0.1.0-teal)](https://github.com/Ebencode-x/sentinai-project/releases/tag/v0.1.0) [![许可证](https://img.shields.io/badge/license-MIT-green)]() # SentinAI — 自愈型 DevOps Agent 无需人工排查。无需将堆栈跟踪复制粘贴到 ChatGPT。凌晨 3 点也不会再错过任何警报。 ## 功能介绍 SentinAI 实时监控您的应用程序日志。一旦发现错误,它就会: 1. 将完整的堆栈跟踪聚合成一个结构化事件 2. 将其发送到 LLM(Claude 或 OpenAI)进行分析 3. 返回一个结构化的修复计划 —— 包括摘要、代码修复、配置更改、置信度分数、风险、具体的统一 diff 补丁以及单元测试指导 4. 触发内容丰富的 Slack 警报和/或可供现有工具使用的通用 webhook payload 5. 通过 REST API 公开所有内容,并提供实时可观测性指标 —— 包括可直接用于 Grafana 的 Prometheus `/metrics` endpoint ## 架构 ``` ┌─────────────────────┐ │ Vulnerable App │ generates ERROR / EXCEPTION / 500 │ :9000 │ └────────┬────────────┘ │ writes to ▼ ┌─────────────────────┐ │ logs/app.log │ └────────┬────────────┘ │ tailed by ▼ ┌──────────────────────────────────────────────────────────┐ │ SentinAI Core :8000 │ │ │ │ LogWatcher ──► IncidentNormalizer ──► RemediationEngine │ │ │ │ │ │ fingerprint + LLM adapter │ │ dedup window (Claude / OpenAI / │ │ stub) │ │ │ │ │ ┌───────┴────────┐ │ │ │ Slack alert │ │ │ │ GitHub PR │ │ │ │ REST API │ │ │ └────────────────┘ │ └──────────────────────────────────────────────────────────┘ ``` ## 功能特性 | 功能特性 | 状态 | |---|---| | 实时日志监控(支持 inode 安全轮转) | ✅ | | 事件去重 + 指纹提取 | ✅ | | Claude (Haiku/Sonnet) 分析 | ✅ | | OpenAI (GPT-4o-mini) 分析 | ✅ | | SmartStub 模式 —— 离线回退,无需 API 密钥 | ✅ | | Prompt 缓存(降低 90% 成本) | ✅ | | 结构化 JSON 修复输出 | ✅ | | 统一 diff 补丁生成 | ✅ | | AST 级别的语义补丁验证 | ✅ | | Prompt 注入防御(6 种模式类别) | ✅ | | 针对每个事件的单元测试指导 | ✅ | | Slack 富文本警报 | ✅ | | GitHub PR 自动创建 | ✅ | | Prometheus `/metrics` endpoint | ✅ | | FastAPI REST API | ✅ | | AI 助手聊天(SSE 流式传输) | ✅ | | 实时可观测性图表 | ✅ | | 不可变 JSONL 审计日志 | ✅ | | 桌面应用 —— Windows (Tauri) | ✅ | | CI/CD (GitHub Actions) | ✅ | | 686 项测试,100% 通过率 | ✅ | ## 快速开始 ### 选项 A —— Docker(推荐) ``` git clone https://github.com/Ebencode-x/sentinai-project.git cd sentinai-project cp .env.example .env # add your API keys docker-compose up ``` API 可在 `http://localhost:8000` 访问 ### 选项 B —— Python ``` git clone https://github.com/Ebencode-x/sentinai-project.git cd sentinai-project pip install -r requirements.txt cp .env.example .env # add your API keys uvicorn src.main:app --reload ``` ### 选项 C —— Windows 桌面应用 从[最新发布版本](https://github.com/Ebencode-x/sentinai-project/releases/tag/v0.1.0)下载 `SentinAI_0.1.0_x64-setup.exe` 并运行安装程序。 ## 配置 将 `.env.example` 复制到 `.env` 并填入您的值: ``` # LLM Provider: anthropic | openai | stub LLM_PROVIDER=anthropic ANTHROPIC_API_KEY=sk-ant-... # Slack(可选) SLACK_WEBHOOK_URL=https://hooks.slack.com/... # GitHub PR 自动创建(可选) GITHUB_TOKEN=ghp_... GITHUB_REPO=your-org/your-repo # SentinAI API key(本地开发可任意设置) SENTINAI_API_KEY=sk-sentinai-dev-local ``` ## API 参考 | 方法 | Endpoint | 描述 | |---|---|---| | GET | `/health/live` | 存活探针 | | GET | `/health/ready` | 就绪探针 + 依赖检查 | | GET | `/incidents` | 列出近期事件 | | GET | `/stats` | 指标快照 | | POST | `/scan-now` | 触发手动扫描 | | POST | `/api/chat` | AI 助手(SSE 流式传输) | | GET | `/metrics` | Prometheus 指标 | ## 运行测试 ``` pip install -r requirements-dev.txt pytest tests/ -v --cov=src ``` 涵盖单元测试、集成测试和端到端套件的 686 项测试。 ## 项目结构 ``` sentinai-project/ ├── src/ │ ├── api/ # FastAPI routes (auth, chat, incidents, health) │ ├── core/ # Config, metrics, rate limiter, state │ ├── integrations/ # LLM clients, GitHub, Slack, notifier │ ├── models/ # Pydantic event models │ └── services/ # LogWatcher, RemediationEngine, pipeline ├── sentinai/ │ └── llm/ # Provider-agnostic LLM abstraction layer ├── src-tauri/ # Tauri desktop app (Windows/macOS/Linux) ├── frontend/ # React + Vite dashboard ├── tests/ # 686 tests ├── docker-compose.yml └── Dockerfile ``` ## 路线图 - [ ] Railway / AWS 部署 - [ ] 多租户 API(团队 + 配额) - [ ] Grafana 仪表盘模板 - [ ] macOS + Linux 桌面构建版本 - [ ] React Native 移动端应用 - [ ] Product Hunt 发布 ## 作者 **Ebenezer Richard Masanja** —— 坦桑尼亚姆贝亚科学技术大学 (MUST) ICT 专业一年级学生。 [![GitHub](https://img.shields.io/badge/GitHub-Ebencode--x-181717?style=flat-square&logo=github)](https://github.com/Ebencode-x) [![LinkedIn](https://img.shields.io/badge/LinkedIn-ebenezer--masanja-0A66C2?style=flat-square&logo=linkedin)](https://www.linkedin.com/in/ebenezer-masanja/) ## 许可证 MIT —— 可免费使用、修改和分发。
标签:AIOps, DLL 劫持, 告警通知, 大语言模型, 自动化运维, 自定义请求头, 请求拦截, 逆向工具