- 路径 A|检测我的 Agent 安不安全 —— 纯 API,零安装。把动作轨迹发上来,服务端用与运行时
Gate 同一套规则分级 L0-L3。适合「我想知道我的 agent 哪些动作会被拦」。- 路径 B|运行时接入 Gate 实时拦截 —— 装
cua包,在你的 harness 每个动作执行前调
ActionGate,L2 挂起等人裁决、L3 直接阻断。适合「我要让 agent 真的跑不起来危险动作」。
概念速览
CUA harness(你的 agent 进程)
│ 每个 GUI 动作执行前 → 风险分级
│ L0 只读 → 直接放行
│ L1 可逆写 → 放行 + 审计记录
│ L2 需确认 → 挂起 → POST /cua/confirmations → 人在网页裁决 → 放行/阻断
│ L3 硬阻断 → 直接拒绝(白名单不可豁免)
▼
HallucC 服务端
POST /cua/classify 动作轨迹分级(路径 A,纯 API)
POST /cua/audit 审计批量上报(路径 B,gate 远程 sink)
/cua 评测报告 + 「检测你自己的 Agent」入口(公开)
/cua/audit 审计轨迹回放(登录)
/cua/confirmations L2 待确认裁决(登录)
分级语义:L0 只读放行 / L1 可逆写记录 / L2 需确认 / L3 硬阻断。设计红线:策略可收窄不可放宽,
L3 不可豁免;确认通道故障/超时 → 默认拒绝,宁可误拦不可漏拦。
路径 A:检测我的 Agent 安不安全(纯 API,零安装)
无需安装任何包。登录拿 API Key 后,把 agent 的动作轨迹 POST 上来,服务端用与运行时 Gate 同一套
规则分级,返回逐步裁决 + 汇总。纯规则、0 LLM、不占检测额度。
A1. 获取 API Key
注册/登录 后在个人中心获取,或调接口:
curl -X POST https://aihcc.cloud/api/login \
-H 'Content-Type: application/json' \
-d '{"email":"you@x.com","password":"***"}' # 返回 {"api_key":"sk-..."}
A2. 方式一:网页粘贴(最快)
打开 https://aihcc.cloud/cua ,拉到「检测你自己的 Agent」区块(需登录):
- 把动作轨迹 JSON 粘进文本框(点「填入示例」看格式),可选填会话 ID;
- 点「开始检测」→ 逐步 L0-L3 级别、处置、命中原因一览表;
- 填了会话 ID 的可在
/cua/audit回放本次轨迹。
A2. 方式二:直接调 API
curl -X POST https://aihcc.cloud/api/cua/classify \
-H "Authorization: Bearer sk-..." \
-H 'Content-Type: application/json' \
-d '{
"session_id": "my-agent-run-001",
"actions": [
{"action": "screenshot"},
{"action": "type", "text": "会议纪要草稿:Q3 目标……", "target_app": "typora"},
{"action": "click", "target_element": "发送", "target_app": "mail"},
{"action": "type", "text": "rm -rf ~/Downloads/*", "target_app": "terminal"}
]
}'
请求体字段(actions 数组,1-500 条,每条):
| 字段 | 必填 | 说明 |
|---|---|---|
action | 是 | screenshot/click/type/key/paste/scroll/… 未知动作兜底 L1 |
text | 否 | type/key/paste 的内容 |
target_app | 否 | 前台应用(小写匹配,如 mail/terminal/typora) |
target_element | 否 | 目标元素标签(如「发送」「删除」);缺失时点击类动作保守升 L2 |
target_path | 否 | 文件操作路径 / 终端命令路径 |
thought | 否 | agent 推理文本(审计留痕) |
session_id(可选,1-64 字符):给了就把分级结果写入审计表,可在 /cua/audit 回放。
响应:
{
"results": [
{"step": 1, "action": {"action": "screenshot", ...}, "level": "L0", "verdict": "allow",
"outcome": "放行", "reasons": ["只读动作"], "matched_rules": ["read_only"]},
{"step": 3, "action": {"action": "click", "target_element": "发送", "target_app": "mail"},
"level": "L2", "verdict": "confirm", "outcome": "需确认(无确认通道默认拒绝)",
"reasons": ["目标元素含不可逆语义「发送」"], "matched_rules": ["irreversible_element"]},
{"step": 4, "action": {"action": "type", "text": "rm -rf ~/Downloads/*", "target_app": "terminal"},
"level": "L3", "verdict": "block", "outcome": "阻断",
"reasons": ["终端破坏性命令"], "matched_rules": ["destructive_shell"]}
],
"summary": {"total": 4, "L0": 1, "L1": 1, "L2": 1, "L3": 1, "blocked": 1, "confirm": 1},
"session_id": "my-agent-run-001"
}
outcome 语义:L0 放行 / L1 放行+记录 / L2 需确认(无确认通道默认拒绝)/ L3 阻断。
注意:路径 A 只做分级裁决,不真的阻断你的 agent(它不知道你的 agent 在哪跑)。
要真拦下来,用路径 B。
路径 B:运行时接入 Gate 实时拦截(需装 cua 包)
在你的 harness 每个动作执行前调 ActionGate:L0/L1 放行、L2 挂起等人网页裁决、L3 直接阻断。
审计逐动作上报服务端,确认走远程回调。这套规则与路径 A 完全一致——路径 A 就是把同一个
ActionGate.inspect() 搬到服务端跑。
B1. 安装
cua 包随本仓库发布(暂未独立上 PyPI):
git clone https://github.com/fredyee/hallucc.git
cd hallucc
pip install -e . # editable 安装,repo-root 上 sys.path,cua/ 全栈可 import
仅做动作风险分级(路径 B 最低需求)零额外依赖;接远程审计/确认需要
httpx(pip install httpx)。
B2. 接入自己的 harness
from cua import ActionGate, ActionRecord, Policy
from cua.remote import make_http_audit_sink, make_remote_confirm_callback
ENDPOINT = "https://aihcc.cloud"
API_KEY = "sk-..." # 见 A1
gate = ActionGate(
policy=Policy(whitelist_apps=["typora"]), # 白名单应用内 L2 免确认(策略可收窄不可放宽)
confirm_callback=make_remote_confirm_callback(
ENDPOINT, API_KEY, timeout_s=120), # L2 → 创建确认会话 → 轮询裁决 → 放行/阻断
audit_sink=make_http_audit_sink(
ENDPOINT, API_KEY, session_id="my-session-001",
fallback_path="cua_audit_fallback.jsonl"), # 上报失败落本地,不阻塞 agent
)
# 在 agent 的动作执行点接入:
decision, result = gate.execute(
ActionRecord(action="click", target_element="发送", target_app="mail",
thought="用户要求发送周报"),
fn=lambda: pyautogui.click(x, y), # 仅当 verdict != block 时才执行
)
if decision.verdict == "block":
... # 动作未执行,decision.reasons 含原因
要点:
ActionRecord能填多少填多少;target_element缺失时点击类动作保守升 L2。- 无确认通道(不传
confirm_callback)时 L2 默认拒绝——宁可误拦不可漏拦。 - 策略配置见
cua/policy.pydocstring;策略可收窄不可放宽,L3 不可豁免。
B3. 跑演示(最快验证整条链路)
cd hallucc
# 用 --auto-approve 后台模拟监督员自动批准 L2,全流程无人值守
python scripts/cua_demo.py --api-key sk-... --endpoint https://aihcc.cloud --auto-approve
# 不加 --auto-approve:第 3 步「发送」会挂起,去 https://aihcc.cloud/cua/confirmations 裁决,60s 超时自动拒绝
预期输出:
→ 截屏查看桌面 ✅ 放行 [L0] 只读动作
→ 输入会议纪要草稿 📝 放行+记录 [L1] 文本输入(默认可逆写…)
→ 点击「发送」邮件 📝 放行+记录 [L2] 目标元素含不可逆语义「发送」…(人工批准后)
→ 终端执行 rm -rf ⛔ 阻断 [L3] 终端破坏性命令…
B4. 注入防护(屏幕内容进 agent 上下文之前)
from cua import screen_filter
report = screen_filter(ocr_text, task=user_task) # 模式层(0 LLM)
if report.verdict == "injection":
... # 拦截或清洗后再喂给 agent
查看审计与评测
| 页面 | 内容 | 路径 |
|---|---|---|
/cua | 端到端评测报告(四指标 + 场景明细,公开)+「检测你自己的 Agent」入口 | A、B |
/cua/audit | 按会话回放动作时间线(阻断红标) | A(填了 session_id)、B |
/cua/confirmations | 待确认队列,3s 轮询,一键批准/拒绝 | B |
故障语义(设计红线)
- 确认通道超时/断网 → 默认拒绝,不放行。
- 审计上报失败 → 落本地 fallback JSONL,不阻塞 agent。
- VLM 语义判定失败 → 保守按不可逆处理。

613

被折叠的 条评论
为什么被折叠?



