ai-traceguard 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ai_traceguard-0.1.0/.github/FUNDING.yml +1 -0
- ai_traceguard-0.1.0/.github/workflows/publish.yml +21 -0
- ai_traceguard-0.1.0/.gitignore +12 -0
- ai_traceguard-0.1.0/AGENTS.md +28 -0
- ai_traceguard-0.1.0/CHANGELOG.md +11 -0
- ai_traceguard-0.1.0/CONTRIBUTING.md +22 -0
- ai_traceguard-0.1.0/LICENSE +21 -0
- ai_traceguard-0.1.0/PKG-INFO +183 -0
- ai_traceguard-0.1.0/README.en.md +69 -0
- ai_traceguard-0.1.0/README.md +156 -0
- ai_traceguard-0.1.0/SECURITY.md +14 -0
- ai_traceguard-0.1.0/VERIFY.md +12 -0
- ai_traceguard-0.1.0/docs/assets/README.md +30 -0
- ai_traceguard-0.1.0/docs/compliance.md +23 -0
- ai_traceguard-0.1.0/docs/index.html +550 -0
- ai_traceguard-0.1.0/docs/quickstart.md +37 -0
- ai_traceguard-0.1.0/docs/quickstart.zh.md +61 -0
- ai_traceguard-0.1.0/opencode.json +15 -0
- ai_traceguard-0.1.0/policies/base.yaml +31 -0
- ai_traceguard-0.1.0/policies/pack-anti-data-leak.yaml +17 -0
- ai_traceguard-0.1.0/policies/pack-anti-delete.yaml +17 -0
- ai_traceguard-0.1.0/policies/pack-anti-token-runaway.yaml +10 -0
- ai_traceguard-0.1.0/pyproject.toml +39 -0
- ai_traceguard-0.1.0/src/traceguard/__init__.py +6 -0
- ai_traceguard-0.1.0/src/traceguard/__main__.py +6 -0
- ai_traceguard-0.1.0/src/traceguard/audit.py +107 -0
- ai_traceguard-0.1.0/src/traceguard/cli.py +63 -0
- ai_traceguard-0.1.0/src/traceguard/guard.py +113 -0
- ai_traceguard-0.1.0/src/traceguard/policies/base.yaml +31 -0
- ai_traceguard-0.1.0/src/traceguard/policies/pack-anti-data-leak.yaml +17 -0
- ai_traceguard-0.1.0/src/traceguard/policies/pack-anti-delete.yaml +17 -0
- ai_traceguard-0.1.0/src/traceguard/policies/pack-anti-token-runaway.yaml +10 -0
- ai_traceguard-0.1.0/src/traceguard/report.py +49 -0
- ai_traceguard-0.1.0/tests/test_cli.py +14 -0
- ai_traceguard-0.1.0/tests/test_intercept.py +55 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
github: ve-loma
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
- uses: actions/setup-python@v5
|
|
14
|
+
with:
|
|
15
|
+
python-version: "3.12"
|
|
16
|
+
- run: pip install build twine
|
|
17
|
+
- run: python -m build
|
|
18
|
+
- run: twine upload dist/* --skip-existing
|
|
19
|
+
env:
|
|
20
|
+
TWINE_USERNAME: __token__
|
|
21
|
+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# TraceGuard — Agent Runtime Guard
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
TraceGuard 是一个本地 Python 库,拦截 AI Agent 的危险工具调用,
|
|
5
|
+
在执行前阻断或要求人工审批。零服务器依赖,数据不出用户本机。
|
|
6
|
+
|
|
7
|
+
## Architecture
|
|
8
|
+
- `src/traceguard/guard.py` — 拦截层核心
|
|
9
|
+
- `src/traceguard/audit.py` — SHA-256 哈希链审计
|
|
10
|
+
- `src/traceguard/cli.py` — CLI 入口
|
|
11
|
+
- `policies/*.yaml` — 预置策略模板
|
|
12
|
+
- `tests/` — 拦截层验证
|
|
13
|
+
|
|
14
|
+
## Build Commands
|
|
15
|
+
- 安装:`pip install -e ".[dev]"`
|
|
16
|
+
- 测试:`pytest tests/ -v`
|
|
17
|
+
- 构建:`python -m build`
|
|
18
|
+
|
|
19
|
+
## Coding Conventions
|
|
20
|
+
- Python 3.11+,使用 type hints
|
|
21
|
+
- 拦截层逻辑必须是确定性的,不依赖模型推理
|
|
22
|
+
- 策略文件使用 YAML,字段名小写加下划线
|
|
23
|
+
|
|
24
|
+
## Guardrails
|
|
25
|
+
- 绝不添加任何网络请求代码到拦截层
|
|
26
|
+
- 绝不收集或上传用户数据
|
|
27
|
+
- 绝不提供模型 API 接口
|
|
28
|
+
- 审计数据仅存储在本地 SQLite 文件
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Contributing to TraceGuard
|
|
2
|
+
|
|
3
|
+
## Development Setup
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
git clone https://github.com/ve-loma/traceguard
|
|
7
|
+
cd traceguard
|
|
8
|
+
pip install -e ".[dev]"
|
|
9
|
+
pytest tests/ -v
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Adding a Guard Pack
|
|
13
|
+
|
|
14
|
+
1. Create `policies/pack-<name>.yaml`
|
|
15
|
+
2. Add test in `tests/test_intercept.py`
|
|
16
|
+
3. Update README with the new pack
|
|
17
|
+
|
|
18
|
+
## Code Style
|
|
19
|
+
|
|
20
|
+
- Python 3.11+, type hints required
|
|
21
|
+
- Deterministic logic only, no model calls in the intercept path
|
|
22
|
+
- No network requests in the guard layer
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TraceGuard Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ai-traceguard
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Runtime guardrail for AI agents — intercept dangerous tool calls before execution
|
|
5
|
+
Project-URL: Homepage, https://github.com/ve-loma/traceguard
|
|
6
|
+
Project-URL: Repository, https://github.com/ve-loma/traceguard
|
|
7
|
+
Project-URL: Issues, https://github.com/ve-loma/traceguard/issues
|
|
8
|
+
Author: TraceGuard Contributors
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: agent,ai,guardrails,mcp,policy,security
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Topic :: Security
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Requires-Dist: pyyaml>=6.0
|
|
20
|
+
Requires-Dist: rich>=13.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: build; extra == 'dev'
|
|
23
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: twine; extra == 'dev'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# TraceGuard
|
|
29
|
+
|
|
30
|
+
**AI Agent 的工具调用前置拦截器。在执行之前,把危险动作拦下来。**
|
|
31
|
+
|
|
32
|
+
[](https://pypi.org/project/ai-traceguard/)
|
|
33
|
+
[](LICENSE)
|
|
34
|
+
[](pyproject.toml)
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 它解决什么问题
|
|
39
|
+
|
|
40
|
+
AI Agent 会**删掉生产库、把 API Key 发到外部、在死循环里把 Token 烧光**。
|
|
41
|
+
市面上的可观测 / 追踪工具只能**事后记录**——等你看到日志,数据已经没了。
|
|
42
|
+
|
|
43
|
+
TraceGuard 不同:它站在**工具调用的执行路径上**,在动作发生**之前**做出确定性的允许 / 阻断判断。
|
|
44
|
+
|
|
45
|
+
> 追踪工具告诉你「凌晨 3 点删了什么」;
|
|
46
|
+
> TraceGuard 让它在「凌晨 3 点删不掉」。
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 安装
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install ai-traceguard
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
零依赖服务、零配置文件、零网络请求。装完即用。
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 快速开始
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from traceguard import TraceGuard
|
|
64
|
+
|
|
65
|
+
guard = TraceGuard(policy="policies/base.yaml", mode="strict")
|
|
66
|
+
|
|
67
|
+
decision = guard.check("delete_file", {"path": "/data/users.csv"})
|
|
68
|
+
if not decision.allowed:
|
|
69
|
+
print(f"已阻断:{decision.reason}")
|
|
70
|
+
else:
|
|
71
|
+
# 执行真正的工具逻辑
|
|
72
|
+
pass
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
CLI 自检:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
traceguard test
|
|
79
|
+
# delete_file: BLOCKED
|
|
80
|
+
# read_file: ALLOWED
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 策略包(Guard Packs)
|
|
86
|
+
|
|
87
|
+
开箱即用的策略模板,覆盖最常见的翻车场景:
|
|
88
|
+
|
|
89
|
+
| 策略包 | 作用 |
|
|
90
|
+
|---|---|
|
|
91
|
+
| `pack-anti-delete` | 拦截文件 / 数据库删除 |
|
|
92
|
+
| `pack-anti-token-runaway` | 拦截 Token 预算超支 |
|
|
93
|
+
| `pack-anti-data-leak` | 拦截敏感数据外发 |
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
traceguard init --pack anti-delete
|
|
97
|
+
# 生成 traceguard-policy.yaml
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## 审计链(Audit Chain)
|
|
103
|
+
|
|
104
|
+
每一次裁决都会写入本地的 **SHA-256 哈希链**。任何后续篡改都会破坏链条,可被检出。
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
traceguard verify
|
|
108
|
+
# 审计链有效
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
导出给审计 / 合规团队(Pro 能力):
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
from traceguard_pro import export_audit_jsonl, verify_exported_jsonl
|
|
115
|
+
|
|
116
|
+
export_audit_jsonl("traceguard-audit.db", "audit-export.jsonl")
|
|
117
|
+
assert verify_exported_jsonl("audit-export.jsonl") # 第三方可独立复核
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## 三种模式
|
|
123
|
+
|
|
124
|
+
| 模式 | 行为 |
|
|
125
|
+
|---|---|
|
|
126
|
+
| `strict` | HIGH 风险阻断,MEDIUM 需要审批 |
|
|
127
|
+
| `balanced` | HIGH 需要审批,MEDIUM 放行 |
|
|
128
|
+
| `observe` | 全部放行,全部记录(灰度 / 观测用) |
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## 合规与安全
|
|
133
|
+
|
|
134
|
+
TraceGuard 的设计目标是**架构上零风险**:
|
|
135
|
+
|
|
136
|
+
- **无网络请求。** 拦截层永不联系外部服务器,因此没有可被拦截、泄露或审查的东西。
|
|
137
|
+
- **无模型 API。** 不代理、不转售、不路由任何模型调用。
|
|
138
|
+
- **只存本地 SQLite。** 审计数据属于你,永远不出本机。
|
|
139
|
+
- **离线授权。** 授权码本地 HMAC 验签,可在气隙环境中运行。
|
|
140
|
+
|
|
141
|
+
因此:**无需 ICP 备案、无需生成式 AI 备案、无数据出境评估**。详见 [`docs/compliance.md`](docs/compliance.md)。
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## 商业版(TraceGuard Pro)
|
|
146
|
+
|
|
147
|
+
开源核心(MIT)足够个人使用;**生产与合规场景**需要的确定性能力放在 Pro:
|
|
148
|
+
|
|
149
|
+
| 能力 | 说明 | 版本 |
|
|
150
|
+
|---|---|---|
|
|
151
|
+
| 参数级敏感信息扫描 | 拦截参数里的 `api_key` / `password` / `private_key` / PII | Pro |
|
|
152
|
+
| Token 预算 + 死循环拦截 | 会话超预算、同调用反复重试时阻断 | Pro |
|
|
153
|
+
| 可校验审计导出 | JSONL 导出,第三方可独立重算哈希链 | Pro |
|
|
154
|
+
| 行业策略包 | 金融 / 医疗 / DevOps 预设 | Pro |
|
|
155
|
+
| 人工审批流 | MEDIUM 风险改为人工审批而非静默放行 | Team |
|
|
156
|
+
| 席位报表 / 自定义包 / SLA | — | Enterprise |
|
|
157
|
+
|
|
158
|
+
> 未持有效授权时,`ProGuard` 会**优雅降级为开源核心行为**,方便先试后买。
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## 文档
|
|
163
|
+
|
|
164
|
+
- [快速开始](docs/quickstart.md)([中文版](docs/quickstart.zh.md))
|
|
165
|
+
- [合规说明](docs/compliance.md)
|
|
166
|
+
- [安全策略](SECURITY.md)
|
|
167
|
+
- [贡献指南](CONTRIBUTING.md)
|
|
168
|
+
- [变更日志](CHANGELOG.md)
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 许可证
|
|
173
|
+
|
|
174
|
+
核心:**MIT**。商业增值包 `traceguard-pro` 采用商业许可,详见其 README。
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## English (short)
|
|
179
|
+
|
|
180
|
+
TraceGuard is a **local runtime guardrail for AI agents**. It intercepts dangerous
|
|
181
|
+
tool calls *before* execution — no network, no server, deterministic decisions, and a
|
|
182
|
+
tamper-evident local SHA-256 audit chain. Install with `pip install ai-traceguard`.
|
|
183
|
+
Full English docs: [`README.en.md`](README.en.md).
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# TraceGuard
|
|
2
|
+
|
|
3
|
+
Runtime guardrail for AI agents. Intercepts dangerous tool calls before execution.
|
|
4
|
+
|
|
5
|
+
[中文文档](README.md) · [PyPI](https://pypi.org/project/ai-traceguard/)
|
|
6
|
+
|
|
7
|
+
## The Problem
|
|
8
|
+
|
|
9
|
+
AI agents delete production data, leak API keys, and burn through token budgets. Existing observability tools only record what happened — after the damage is done. TraceGuard blocks the action before it executes.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install ai-traceguard
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from traceguard import TraceGuard
|
|
21
|
+
|
|
22
|
+
guard = TraceGuard(policy="policies/base.yaml", mode="strict")
|
|
23
|
+
|
|
24
|
+
decision = guard.check("delete_file", {"path": "/data/users.csv"})
|
|
25
|
+
if not decision.allowed:
|
|
26
|
+
print(f"Blocked: {decision.reason}")
|
|
27
|
+
else:
|
|
28
|
+
# execute the tool
|
|
29
|
+
pass
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Guard Packs
|
|
33
|
+
|
|
34
|
+
Pre-built policy templates for common scenarios:
|
|
35
|
+
|
|
36
|
+
- `pack-anti-delete` — blocks file/database deletion
|
|
37
|
+
- `pack-anti-token-runaway` — blocks token budget overrun
|
|
38
|
+
- `pack-anti-data-leak` — blocks sensitive data exfiltration
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
traceguard init --pack anti-delete
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Audit Chain
|
|
45
|
+
|
|
46
|
+
Every decision is written to a local SHA-256 hash chain. Any tampering breaks the chain and is detectable.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
traceguard verify
|
|
50
|
+
# CHAIN VALID
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Modes
|
|
54
|
+
|
|
55
|
+
| Mode | Behavior |
|
|
56
|
+
|---|---|
|
|
57
|
+
| `strict` | HIGH risk blocked, MEDIUM requires approval |
|
|
58
|
+
| `balanced` | HIGH requires approval, MEDIUM allowed |
|
|
59
|
+
| `observe` | Everything allowed, everything logged |
|
|
60
|
+
|
|
61
|
+
## Compliance
|
|
62
|
+
|
|
63
|
+
- No network requests. Data never leaves your machine.
|
|
64
|
+
- No server dependency. Runs entirely in-process.
|
|
65
|
+
- Local SQLite storage. You own your data.
|
|
66
|
+
|
|
67
|
+
## License
|
|
68
|
+
|
|
69
|
+
MIT
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# TraceGuard
|
|
2
|
+
|
|
3
|
+
**AI Agent 的工具调用前置拦截器。在执行之前,把危险动作拦下来。**
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/ai-traceguard/)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](pyproject.toml)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 它解决什么问题
|
|
12
|
+
|
|
13
|
+
AI Agent 会**删掉生产库、把 API Key 发到外部、在死循环里把 Token 烧光**。
|
|
14
|
+
市面上的可观测 / 追踪工具只能**事后记录**——等你看到日志,数据已经没了。
|
|
15
|
+
|
|
16
|
+
TraceGuard 不同:它站在**工具调用的执行路径上**,在动作发生**之前**做出确定性的允许 / 阻断判断。
|
|
17
|
+
|
|
18
|
+
> 追踪工具告诉你「凌晨 3 点删了什么」;
|
|
19
|
+
> TraceGuard 让它在「凌晨 3 点删不掉」。
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 安装
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install ai-traceguard
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
零依赖服务、零配置文件、零网络请求。装完即用。
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 快速开始
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from traceguard import TraceGuard
|
|
37
|
+
|
|
38
|
+
guard = TraceGuard(policy="policies/base.yaml", mode="strict")
|
|
39
|
+
|
|
40
|
+
decision = guard.check("delete_file", {"path": "/data/users.csv"})
|
|
41
|
+
if not decision.allowed:
|
|
42
|
+
print(f"已阻断:{decision.reason}")
|
|
43
|
+
else:
|
|
44
|
+
# 执行真正的工具逻辑
|
|
45
|
+
pass
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
CLI 自检:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
traceguard test
|
|
52
|
+
# delete_file: BLOCKED
|
|
53
|
+
# read_file: ALLOWED
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 策略包(Guard Packs)
|
|
59
|
+
|
|
60
|
+
开箱即用的策略模板,覆盖最常见的翻车场景:
|
|
61
|
+
|
|
62
|
+
| 策略包 | 作用 |
|
|
63
|
+
|---|---|
|
|
64
|
+
| `pack-anti-delete` | 拦截文件 / 数据库删除 |
|
|
65
|
+
| `pack-anti-token-runaway` | 拦截 Token 预算超支 |
|
|
66
|
+
| `pack-anti-data-leak` | 拦截敏感数据外发 |
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
traceguard init --pack anti-delete
|
|
70
|
+
# 生成 traceguard-policy.yaml
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 审计链(Audit Chain)
|
|
76
|
+
|
|
77
|
+
每一次裁决都会写入本地的 **SHA-256 哈希链**。任何后续篡改都会破坏链条,可被检出。
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
traceguard verify
|
|
81
|
+
# 审计链有效
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
导出给审计 / 合规团队(Pro 能力):
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from traceguard_pro import export_audit_jsonl, verify_exported_jsonl
|
|
88
|
+
|
|
89
|
+
export_audit_jsonl("traceguard-audit.db", "audit-export.jsonl")
|
|
90
|
+
assert verify_exported_jsonl("audit-export.jsonl") # 第三方可独立复核
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## 三种模式
|
|
96
|
+
|
|
97
|
+
| 模式 | 行为 |
|
|
98
|
+
|---|---|
|
|
99
|
+
| `strict` | HIGH 风险阻断,MEDIUM 需要审批 |
|
|
100
|
+
| `balanced` | HIGH 需要审批,MEDIUM 放行 |
|
|
101
|
+
| `observe` | 全部放行,全部记录(灰度 / 观测用) |
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## 合规与安全
|
|
106
|
+
|
|
107
|
+
TraceGuard 的设计目标是**架构上零风险**:
|
|
108
|
+
|
|
109
|
+
- **无网络请求。** 拦截层永不联系外部服务器,因此没有可被拦截、泄露或审查的东西。
|
|
110
|
+
- **无模型 API。** 不代理、不转售、不路由任何模型调用。
|
|
111
|
+
- **只存本地 SQLite。** 审计数据属于你,永远不出本机。
|
|
112
|
+
- **离线授权。** 授权码本地 HMAC 验签,可在气隙环境中运行。
|
|
113
|
+
|
|
114
|
+
因此:**无需 ICP 备案、无需生成式 AI 备案、无数据出境评估**。详见 [`docs/compliance.md`](docs/compliance.md)。
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 商业版(TraceGuard Pro)
|
|
119
|
+
|
|
120
|
+
开源核心(MIT)足够个人使用;**生产与合规场景**需要的确定性能力放在 Pro:
|
|
121
|
+
|
|
122
|
+
| 能力 | 说明 | 版本 |
|
|
123
|
+
|---|---|---|
|
|
124
|
+
| 参数级敏感信息扫描 | 拦截参数里的 `api_key` / `password` / `private_key` / PII | Pro |
|
|
125
|
+
| Token 预算 + 死循环拦截 | 会话超预算、同调用反复重试时阻断 | Pro |
|
|
126
|
+
| 可校验审计导出 | JSONL 导出,第三方可独立重算哈希链 | Pro |
|
|
127
|
+
| 行业策略包 | 金融 / 医疗 / DevOps 预设 | Pro |
|
|
128
|
+
| 人工审批流 | MEDIUM 风险改为人工审批而非静默放行 | Team |
|
|
129
|
+
| 席位报表 / 自定义包 / SLA | — | Enterprise |
|
|
130
|
+
|
|
131
|
+
> 未持有效授权时,`ProGuard` 会**优雅降级为开源核心行为**,方便先试后买。
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 文档
|
|
136
|
+
|
|
137
|
+
- [快速开始](docs/quickstart.md)([中文版](docs/quickstart.zh.md))
|
|
138
|
+
- [合规说明](docs/compliance.md)
|
|
139
|
+
- [安全策略](SECURITY.md)
|
|
140
|
+
- [贡献指南](CONTRIBUTING.md)
|
|
141
|
+
- [变更日志](CHANGELOG.md)
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## 许可证
|
|
146
|
+
|
|
147
|
+
核心:**MIT**。商业增值包 `traceguard-pro` 采用商业许可,详见其 README。
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## English (short)
|
|
152
|
+
|
|
153
|
+
TraceGuard is a **local runtime guardrail for AI agents**. It intercepts dangerous
|
|
154
|
+
tool calls *before* execution — no network, no server, deterministic decisions, and a
|
|
155
|
+
tamper-evident local SHA-256 audit chain. Install with `pip install ai-traceguard`.
|
|
156
|
+
Full English docs: [`README.en.md`](README.en.md).
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Design Principles
|
|
4
|
+
|
|
5
|
+
TraceGuard is designed to be zero-risk by architecture:
|
|
6
|
+
|
|
7
|
+
- **No network requests.** The guard layer never contacts external servers.
|
|
8
|
+
- **No data collection.** All audit data stays in local SQLite.
|
|
9
|
+
- **No model API.** TraceGuard does not proxy, resell, or route model calls.
|
|
10
|
+
- **No server dependency.** Runs entirely in the user's process.
|
|
11
|
+
|
|
12
|
+
## Reporting a Vulnerability
|
|
13
|
+
|
|
14
|
+
Open an issue at https://github.com/ve-loma/traceguard/issues
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# 收款码放这里
|
|
2
|
+
|
|
3
|
+
把这两张图放进本文件夹,官网会自动显示(不用改任何代码):
|
|
4
|
+
|
|
5
|
+
| 文件名 | 内容 |
|
|
6
|
+
|---|---|
|
|
7
|
+
| `wechat-pay.png` | 你的**微信**收款码 |
|
|
8
|
+
| `alipay-pay.png` | 你的**支付宝**收款码 |
|
|
9
|
+
|
|
10
|
+
## 怎么拿到自己的收款码
|
|
11
|
+
|
|
12
|
+
- **微信**:打开微信 → 我 → 服务 → 收付款 → 二维码收款 → 保存收款码
|
|
13
|
+
- **支付宝**:打开支付宝 → 我的 → 收钱 → 保存图片
|
|
14
|
+
|
|
15
|
+
## 注意
|
|
16
|
+
|
|
17
|
+
- 文件名必须**完全一致**(区分大小写):
|
|
18
|
+
`wechat-pay.png`、`alipay-pay.png`
|
|
19
|
+
- 建议用**正方形**图片,导出为 PNG。
|
|
20
|
+
- 没放图时,官网会显示一个虚线占位框,不影响其它功能。
|
|
21
|
+
|
|
22
|
+
## 还要改一处:邮箱
|
|
23
|
+
|
|
24
|
+
打开上一层的 `index.html`,在最底部 `<script>` 开头的 `CONFIG` 里,把
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
email: "your-email@example.com",
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
改成你自己能收信的邮箱。改完保存即可——官网上的邮箱、下单按钮会自动更新。
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Compliance
|
|
2
|
+
|
|
3
|
+
TraceGuard is a local developer tool, not a network service.
|
|
4
|
+
|
|
5
|
+
## What TraceGuard Does Not Do
|
|
6
|
+
|
|
7
|
+
- No model API proxying or resale
|
|
8
|
+
- No user data collection or upload
|
|
9
|
+
- No account pools or reverse proxies
|
|
10
|
+
- No public-facing service
|
|
11
|
+
|
|
12
|
+
## Regulatory Position
|
|
13
|
+
|
|
14
|
+
- **ICP filing**: Not applicable (no server in mainland China)
|
|
15
|
+
- **Generative AI filing**: Not applicable (no public AI service)
|
|
16
|
+
- **Data export assessment**: Not applicable (data never leaves local machine)
|
|
17
|
+
- **Public security filing**: Not applicable (no public-facing service)
|
|
18
|
+
|
|
19
|
+
## Audit Chain for Compliance
|
|
20
|
+
|
|
21
|
+
EU AI Act Article 12 requires automatic event logging for high-risk AI systems.
|
|
22
|
+
TraceGuard's SHA-256 hash chain provides tamper-evident local audit records
|
|
23
|
+
that can be independently verified.
|