cognis-digital/ledgermind

GitHub: cognis-digital/ledgermind

一款可自托管的本地 LLM 成本与 token 消耗审计代理,具备异常检测能力并支持 CI/CD 流水线集成。

Stars: 0 | Forks: 0

LEDGERMIND # LEDGERMIND ### 具备异常检测的本地 LLM 成本与 token 取证代理 [![PyPI](https://img.shields.io/pypi/v/cognis-ledgermind.svg?color=6b46c1)](https://pypi.org/project/cognis-ledgermind/) [![CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/8fbc4c528c060433.svg)](https://github.com/cognis-digital/ledgermind/actions) [![License: COCL 1.0](https://img.shields.io/badge/License-COCL%201.0-2b6cb0.svg)](LICENSE) [![Suite](https://img.shields.io/badge/Cognis-Neural%20Suite-6b46c1.svg)](https://github.com/cognis-digital) *AI 安全与治理 — 保护 LLM、agent 及 MCP 供应链。*
``` pip install cognis-ledgermind ledgermind scan . # → prioritized findings in seconds ``` ## 用法 — 逐步指南 1. **安装** (Python 3.8+,仅使用标准库): pip install ledgermind 2. **审计 LLM 请求日志** (JSONL 或 JSON 数组) 以检查成本、token 和异常情况: ledgermind audit logs.jsonl 报告总计金额,以及按模型和按 API key 细分的成本明细。 3. **覆盖定价** 并调整异常灵敏度: ledgermind audit logs.jsonl --pricing custom_pricing.json --mad-threshold 3.0 (`--pricing` 会与内置默认值合并;`--mad-threshold` 是修正后的 z-score 截止值。) 4. **以 JSON 格式读取输出**: ledgermind audit logs.jsonl --format json | jq '.total_cost_usd, .anomalies[]' 5. **在 CI / cron 中对支出异常进行拦截** — 当检测到任何异常时以退出码 `2` 退出: ledgermind audit logs.jsonl --fail-on-anomaly || echo "检测到 LLM 支出异常" ## 目录 - [为什么选择 ledgermind?](#why) · [功能](#features) · [快速开始](#quick-start) · [示例](#example) · [架构](#architecture) · [AI 技术栈](#ai-stack) · [对比](#how-it-compares) · [集成](#integrations) · [随处安装](#install-anywhere) · [相关项目](#related) · [贡献](#contributing) ## 为什么选择 ledgermind? 具备异常检测的本地 LLM 成本与 token 取证代理 — 无需搭建繁重的基础设施。 `ledgermind` 具有单一目的、可脚本化且可自托管:将其指向目标,以您的工作流已有的格式(表格 · JSON · SARIF)获取优先级排序的结果,据此拦截 CI,并让 agent 通过 MCP 驱动它。
↑ 回到顶部
## 功能 - ✅ 定价调用 - ✅ 加载事件 - ✅ 检测异常 - ✅ 构建报告 - ✅ 可在 Linux/macOS/Windows · Docker · devcontainer 上运行 - ✅ 提供 Python、JavaScript、Go 和 Rust 的移植版本 (`ports/`)
↑ 回到顶部
## 快速开始 ``` pip install cognis-ledgermind ledgermind --version ledgermind scan . # scan current project ledgermind scan . --format json # machine-readable ledgermind scan . --fail-on high # CI gate (non-zero exit) ```
↑ 回到顶部
## 示例 ``` $ ledgermind scan . [HIGH ] LED-001 example finding (./src/app.py) [MEDIUM ] LED-002 another signal (./config.yaml) 2 findings · risk score 5 · 38ms ```
↑ 回到顶部
## 架构 ``` flowchart LR IN[addresses + transactions] --> P[ledgermind
cluster + trace] P --> OUT[sanctions xref / report] ```
↑ 回到顶部
## 从任何 AI 技术栈中使用 `ledgermind` 可以与所有流行的 AI 使用方式互操作: - **MCP 服务器** — `ledgermind mcp` (Claude Desktop, Cursor, Cognis.Studio, [uncensored-fleet](https://github.com/cognis-digital/uncensored-fleet)) - **兼容 OpenAI / JSON** — 通过管道将 `ledgermind scan . --format json` 传递给任何 agent 或 LLM - **LangChain · CrewAI · AutoGen · LlamaIndex** — 只需一行代码即可将 CLI/JSON 封装为工具 - **CI / 脚本** — 为非 AI 流水线提供退出码 + SARIF
↑ 回到顶部
## 对比 | | **Cognis ledgermind** | BerriAI | |---|:---:|:---:| | 可自托管,无需账户 | ✅ | 视情况而定 | | 单一命令,零配置 | ✅ | ⚠️ | | 用于 CI 的 JSON + SARIF | ✅ | 视情况而定 | | MCP 原生 (AI agent) | ✅ | ❌ | | 多语言移植 (JS/Go/Rust) | ✅ | ❌ | | 开源许可 | ✅ COCL | 视情况而定 | *秉承 **BerriAI/litellm** 的精神,以 Cognis 的方式重新构建。遗漏了致谢?欢迎提交 PR。*
↑ 回到顶部
## 集成 可接入您的技术栈:用于代码扫描的 **SARIF**,用于任何场景的 **JSON**,用于 AI agent 的 **MCP 服务器** (`ledgermind mcp`),以及用于 SIEM/Slack/Jira 的 webhook 转发器。请参阅 [`docs/INTEGRATIONS.md`](docs/INTEGRATIONS.md)。
↑ 回到顶部
## 安装 — 各种方式,全平台 ``` pip install "git+https://github.com/cognis-digital/ledgermind.git" # pip (works today) pipx install "git+https://github.com/cognis-digital/ledgermind.git" # isolated CLI uv tool install "git+https://github.com/cognis-digital/ledgermind.git" # uv pip install cognis-ledgermind # PyPI (when published) docker run --rm ghcr.io/cognis-digital/ledgermind:latest --help # Docker brew install cognis-digital/tap/ledgermind # Homebrew tap curl -fsSL https://raw.githubusercontent.com/cognis-digital/ledgermind/main/install.sh | sh ``` | Linux | macOS | Windows | Docker | Cloud | |---|---|---|---|---| | `scripts/setup-linux.sh` | `scripts/setup-macos.sh` | `scripts/setup-windows.ps1` | `docker run ghcr.io/cognis-digital/ledgermind` | [DEPLOY.md](docs/DEPLOY.md) (AWS/Azure/GCP/k8s) |
↑ 回到顶部
## 相关的 Cognis 工具 - [`aegis`](https://github.com/cognis-digital/aegis) — AI Agent 权限与访问审计器 — 揭示凭据 + 注入 + 触及范围的致命三要素 - [`promptmirror`](https://github.com/cognis-digital/promptmirror) — 针对任何 LLM 上下文输入的提示注入与间接注入扫描器 - [`adversa`](https://github.com/cognis-digital/adversa) — LLM 红队测试工具套件 — OWASP LLM Top 10 + MITRE ATLAS 攻击包 - [`guardpost`](https://github.com/cognis-digital/guardpost) — 运行时 agent 防火墙 — PII 脱敏、速率限制、策略执行 - [`hallumark`](https://github.com/cognis-digital/hallumark) — 针对 RAG 系统的 LLM 幻觉与基础审计工具 - [`aicard`](https://github.com/cognis-digital/aicard) — 自动生成的 NIST AI RMF / EU AI Act 附录 IV 模型与系统卡片 **探索全套工具 →** [🗂️ 所有 170+ 工具](https://github.com/cognis-digital/cognis-neural-suite) · [⭐ awesome-cognis](https://github.com/cognis-digital/awesome-cognis) · [🔗 cognis-sources](https://github.com/cognis-digital/cognis-sources) · [🤖 uncensored-fleet](https://github.com/cognis-digital/uncensored-fleet) · [🧠 engram](https://github.com/cognis-digital/engram)
↑ 回到顶部
## 互操作性 `{}` 与包含 300+ 工具的 Cognis 套件组合使用 — 输入/输出为 JSON,并共享兼容 OpenAI 的 `/v1` 骨干架构。请参阅 **[INTEROP.md](INTEROP.md)** 了解套件图谱、组合模式和参考技术栈。 ## 许可证 源码可见,基于 **Cognis Open Collaboration License (COCL) v1.0** — 个人、内部评估、研究和教育用途免费;**商业/生产用途需要许可证** (licensing@cognis.digital)。请参阅 [LICENSE](LICENSE)。
Cognis Digital · 170+ 工具的 Cognis Neural Suite 之一 · 让明天更美好
标签:API集成, DLL 劫持, 代理服务, 可观测性, 可视化界面, 大语言模型, 异常检测, 成本管理, 数据可视化, 日志审计, 本地部署, 请求拦截, 逆向工具