360 Secure SkillHub
360 安全技能中心

black-box

Black Box 是面向 AI 智能体的审计日志工具:通过命令行把关键动作、错误与推理链写入 TiDB Zero 云数据库,并可读取最近若干条日志。支持自带 TiDB 连接凭据;未配置时由技能调用 TiDB Zero 接口尝试创建临时库,并把连接串缓存到本地文件。

lilyjazz
lilyjazz
热度 61.63
最近更新 2026-05-17 12:27:29
分类:自动化依赖:代码执行 / 第三方 API / 读写文件应用场景:工作流 / DevOps

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add black-box
Metadata
name
black-box
description
Indestructible audit logs for agent actions, stored in TiDB Zero.
metadata
{"openclaw":{"emoji":"📦","requires":{"bins":["python3","curl"],"env":["TIDB_HOST","TIDB_PORT","TIDB_USER","TIDB_PASSWORD"]}}}

Black Box (Powered by TiDB Zero)

Overview

Black Box is an indestructible audit log for AI Agents. It acts as a "Flight Data Recorder" that streams critical actions, errors, and reasoning chains to a persistent cloud database (TiDB Zero) in real-time.

Security & Provisioning

  1. Bring Your Own Database (Recommended): Set TIDB_* environment variables.
  2. Auto-Provisioning (Fallback): If no credentials are found, this skill uses the TiDB Zero API to create a temporary database for logging. The connection string is cached in ~/.openclaw_black_box_dsn.

Why use this?

  • Crash Survival: Local logs vanish when containers crash. Cloud logs persist.
  • Audit Trail: Prove exactly what your agent did and why (compliance).
  • Debugging: Retrieve the last 100 actions leading up to a failure.

Prerequisites

  • TiDB Credentials: Standard MySQL connection parameters (TIDB_HOST, TIDB_USER, etc.).
  • Network: Outbound access to TiDB Cloud (port 4000).

Usage

1. Log an Event

Record a critical action or error:

python {baseDir}/run.py --action log --level ERROR --message "System crash imminent: Memory leak detected"

2. Read Logs

Retrieve the last N logs (default: 10):

python {baseDir}/run.py --action read --limit 20

Schema

This skill creates a table agent_logs with columns: timestamp, level, message, metadata (JSON).