@berthos /审计
哈希链审计记录:将它们写入文件,验证链,编辑有效负载,并验证证明记录。
泊位 在沙盒中运行人工智能代理的工具。每个工具在类中声明它可以接触什么 berth.yml manifest, Linux内核强制执行它。
npm install @berthos/audit
使用
import { createFileAuditSink, readAuditFile, verifyAuditChain, agentActor } from "@berthos/audit";
const sink = createFileAuditSink({ path: "audit.jsonl" });
await sink.record({
ts: new Date().toISOString(),
seq: 0, // the sink assigns the real sequence number
actor: agentActor("assistant"),
action: "agent.tool-call",
target: "filesystem/write_file",
decision: "denied",
reason: "path outside declared filesystem:write scope",
});
const result = verifyAuditChain(readAuditFile("audit.jsonl"));
console.log(result.valid ? "VALID" : `BROKEN at record ${result.brokenAt}`);
每条记录都提交给它之前的记录,因此编辑的记录打破了该记录的链。可以重写整个文件的人可以重新计算链,因此它是防篡改的,而不是防篡改的:如果您需要更多的哈希值,请将最新的哈希值固定在攻击者无法写入的地方。
也出口: redact(), verifyAuditSegments() 对于旋转文件,内存和控制台接收器,以及 verifyAttestation() 查阅 berth attest.