Skip to content

Commit 10df0d7

Browse files
committed
feat(tools): add safety package init and example outputs
1 parent c547c28 commit 10df0d7

3 files changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{"timestamp":"2026-07-10T12:00:00.000Z","tool_name":"bash_tool","decision":"deny","risk_level":"critical","rule_ids":["DANGEROUS_DELETE_001"],"scan_duration_ms":3.2,"sanitized":false,"intercepted":true,"script_hash":"a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2"}
2+
{"timestamp":"2026-07-10T12:01:00.000Z","tool_name":"python_tool","decision":"allow","risk_level":null,"rule_ids":[],"scan_duration_ms":1.1,"sanitized":false,"intercepted":false,"script_hash":"d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4"}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"decision": "deny",
3+
"risk_level": "critical",
4+
"findings": [
5+
{
6+
"rule_id": "DANGEROUS_DELETE_001",
7+
"risk_type": "dangerous_file_operation",
8+
"risk_level": "critical",
9+
"evidence": "rm -rf /home/user/data",
10+
"message": "Dangerous file deletion detected",
11+
"recommendation": "Use temporary directories or confirm deletion intent"
12+
}
13+
],
14+
"scan_duration_ms": 3.2,
15+
"script_snippet": "rm -rf /home/user/data\n",
16+
"scan_error": null
17+
}

trpc_agent_sdk/tools/safety/__init__.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,34 @@
33
# Copyright (C) 2026 Tencent. All rights reserved.
44
#
55
# tRPC-Agent-Python is licensed under Apache-2.0.
6+
"""Tool Script Safety Guard for tRPC-Agent-Python.
7+
8+
Provides pre-execution safety scanning for Python scripts and Bash commands
9+
executed by tools. Integrates as a BaseFilter and as a standalone scanner.
10+
"""
11+
12+
from ._audit import SafetyAuditLogger
13+
from ._filter import ToolSafetyFilter
14+
from ._policy import SafetyPolicy
15+
from ._scanner import ToolSafetyScanner
16+
from ._telemetry import set_safety_span_attrs
17+
from ._types import AuditEvent
18+
from ._types import Decision
19+
from ._types import RiskLevel
20+
from ._types import RiskType
21+
from ._types import RuleFinding
22+
from ._types import ScanReport
23+
24+
__all__ = [
25+
"ToolSafetyScanner",
26+
"ToolSafetyFilter",
27+
"SafetyPolicy",
28+
"SafetyAuditLogger",
29+
"set_safety_span_attrs",
30+
"AuditEvent",
31+
"Decision",
32+
"RiskLevel",
33+
"RiskType",
34+
"RuleFinding",
35+
"ScanReport",
36+
]

0 commit comments

Comments
 (0)