ptrace-sdk
v0.1.1
Published
TypeScript SDK for ptrace — verifiable audit trails for AI agents
Readme
ptrace SDK for TypeScript
Verifiable audit trails for AI agents. Sign, log, verify.
Install
npm install ptrace-sdkQuick Start
import { PtraceClient } from "ptrace-sdk";
const client = new PtraceClient("0xYOUR_PRIVATE_KEY");
// Declare what your agent is allowed to do
await client.createPolicy({
allowedActions: ["read_feed", "post_reply"],
deniedActions: ["financial_commitment"],
});
// Log an action (auto-chains to previous entry)
await client.logAction(
"post_reply",
"forum.example.com/topics/123",
PtraceClient.contentHash("My reply content"),
);
// Verify the chain
const result = await client.verifyChain(client.address);
console.log(result); // { data: { chain_intact: true, ... } }API
new PtraceClient(privateKey, apiUrl?)
Create a client. Defaults to https://api.ptrace.xyz.
.createPolicy({ allowedActions?, deniedActions?, allowedTargets? })
Declare your agent's policy.
.logAction(action, target, contentHash, metadata?)
Log what your agent did. prevHash is tracked automatically. Retries once on 409.
.fileReport({ agent, category, actionObserved, target, observedAt, description, severity })
Report observed behavior of another agent.
.getAgent(address) / .getLogs(address) / .verifyChain(address)
Read agent info, logs, and chain verification.
PtraceClient.contentHash(data)
Static. Returns "sha256:<hex>" hash of a string.
PtraceClient.canonicalJson(payload)
Static. Produces canonical JSON (sorted keys, no sig, compact).
Built by Anona Labs
