Expand description
Scope 守卫 + 限额检查 + 审计日志
两种模式:
- scope 模式(
state.is_scope_mode()):必须持有 api-key,且 scope 匹配 - legacy 模式(没配 keys-file):读工具全放行;写工具走
enable_trading/allow_real_trading两级开关
Enums§
- Tool
Scope - 工具需要的 scope 类别
Functions§
- args_
short_ hash - 计算 args 的短哈希(前 8 hex),用于审计日志(不存原始敏感字段)
- emit_
trade_ outcome - 交易工具执行完后的审计事件:解析 handler 返回的 JSON,success / failure
写入 audit JSONL。
key_id = None时用 “” 占位(legacy 模式)。 - scope_
for_ tool - 工具名 → 所需 scope。