Metadata-Version: 2.4
Name: opspilot-assistant
Version: 0.1.0
Summary: AI-driven operations assistant system
License-Expression: MIT
Keywords: ops,ai,llm,alerting,automation,incident-response
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: System :: Monitoring
Classifier: Framework :: AsyncIO
Classifier: Framework :: FastAPI
Requires-Python: >=3.14
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastapi>=0.115.0
Requires-Dist: uvicorn[standard]>=0.32.0
Requires-Dist: pydantic>=2.10.0
Requires-Dist: pydantic-settings>=2.7.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: sqlalchemy>=2.0.0
Requires-Dist: aiosqlite>=0.20.0
Requires-Dist: httpx>=0.28.0
Requires-Dist: apscheduler>=3.10.0
Requires-Dist: langchain>=1.3.1
Requires-Dist: langchain-openai>=1.2.2
Requires-Dist: openai>=2.38.0
Requires-Dist: langchain-mcp-adapters>=0.2.0
Dynamic: license-file

# OpsPilot

AI 驱动的运维辅助系统。接收告警 → LLM 分析 → 自动/审批处置，形成闭环。

## 快速开始

```bash
# 安装
git clone <repo-url> && cd opspilot
uv sync
```

最小配置（`config.yaml`）：

```yaml
providers:
  mimo:
    model: "mimo-v2.5-pro"
    api_keys:
      - "${MIMO_KEY}"
    base_url: "https://token-plan-cn.xiaomimimo.com/v1"

actions:
  tools:
    builtins: {}

projects:
  - name: my-project
    ingestion:
      webhook:
        enabled: true
        secret: "${WEBHOOK_SECRET}"
```

运行时以 `OpsPilot` 为入口（程序化 API，不读文件、不开端口）：

```python
import asyncio
from core.app import OpsPilot

async def main():
    async with OpsPilot(open("config.yaml").read()) as op:
        result = await op.ingest([event])   # 推入告警
        await op.approve(session_id, "ok")  # 审批

asyncio.run(main())
```

> 宿主负责读取配置文件与挂载 HTTP 服务（见 [REST API](docs/api.md)）。

## 架构

```
告警源 (Prometheus / Grafana / 自定义)
        │
        ▼
   ┌─────────┐
   │ 接入层   │  Webhook 接收 / Pull 拉取 / 格式归一化
   └────┬────┘
        │ AlertEvent
        ▼
   ┌─────────┐
   │ 调度层   │  去重 / 优先级队列 / Worker 池
   └────┬────┘
        │
        ▼
   ┌─────────┐
   │ 决策层   │  Agent 循环: 上下文组装 → LLM 分析 → 工具调用 → 安全检查 → 审批
   └────┬────┘
        │ await 审批决策（approve/reject）
        ▼
   ┌─────────┐
   │ 处置层   │  K8s / Shell / 通知 / 数据库 (@tool) + MCP 扩展
   └────┬────┘
        │
        ▼
   ┌─────────┐
   │ 存储层   │  告警记录 / 分析过程 / 工具调用 / 审批记录
   └─────────┘
```

## 技术栈

| 组件 | 选型 | 说明 |
|------|------|------|
| 语言 | Python 3.14 | |
| 包管理 | uv | uv init / uv add / uv run |
| Web 框架 | FastAPI | 异步支持，自动 OpenAPI 文档 |
| Agent 引擎 | 手写 async 循环 | 上下文压缩 + 非阻塞审批 + 持久化（无 LangGraph 依赖） |
| LLM 抽象 | LangChain | 多模型支持 + @tool 工具定义 |
| CLI | Typer + Rich | 运维友好的表格输出 |
| 数据库 | SQLite + SQLAlchemy | 零依赖，单文件部署 |
| 调度 | APScheduler | Pull 模式定时拉取 |
| MCP | langchain-mcp-adapters | 用户自定义工具扩展 |


## 文档

- [配置参考](docs/config.md) — 完整配置项说明
- [集成指南](docs/integration.md) — 告警源 / 通知 / K8s / 数据库 / MCP / Shell 集成
- [REST API](docs/api.md) — Webhook 端点
