Skip to main content

Python SDK for ptrace — verifiable audit trails for AI agents

Project description

ptrace SDK for Python

Verifiable audit trails for AI agents. Sign, log, verify.

Install

pip install ptrace-sdk

Quick Start

from ptrace import PtraceClient

client = PtraceClient("0xYOUR_PRIVATE_KEY")

# Declare what your agent is allowed to do
client.create_policy(
    allowed_actions=["read_feed", "post_reply"],
    denied_actions=["financial_commitment"],
)

# Log an action (auto-chains to previous entry)
client.log_action(
    action="post_reply",
    target="forum.example.com/topics/123",
    content_hash=PtraceClient.content_hash("My reply content"),
)

# Verify the chain
result = client.verify_chain(client.address)
print(result)  # {"data": {"chain_intact": true, ...}}

API

PtraceClient(private_key, api_url="https://api.ptrace.xyz")

Create a client. The private key is an Ethereum ECDSA key (0x-prefixed hex).

.create_policy(allowed_actions?, denied_actions?, allowed_targets?)

Declare your agent's policy. At least one of allowed_actions or denied_actions required.

.log_action(action, target, content_hash, metadata?)

Log what your agent did. prev_hash is tracked automatically. Retries once on 409 (hash chain conflict).

.file_report(agent, category, action_observed, target, observed_at, description, severity)

Report observed behavior of another agent.

.get_agent(address) / .get_logs(address) / .verify_chain(address)

Read agent info, logs, and chain verification.

PtraceClient.content_hash(data)

Static method. Returns "sha256:<hex>" hash of a string.

409 Conflict Handling

log_action() automatically retries once on 409 by fetching the latest prev_hash from the server. This handles concurrent log submissions gracefully.


Built by Anona Labs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ptrace_sdk-0.1.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ptrace_sdk-0.1.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file ptrace_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: ptrace_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for ptrace_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c63878c2f5bed35ad14e178172cd735738a0533b9e3a334887690b3d4a7c067c
MD5 ba6d237036eb192ecee6d6931668f42e
BLAKE2b-256 9e9dff8741227fcd344282a06dc44648d24404dcc480352a3caa9d88bf371d39

See more details on using hashes here.

File details

Details for the file ptrace_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ptrace_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for ptrace_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 11bd03bf5630189ed9e37150ebe457cb802cc1443bec3391b360fa47f6278ec8
MD5 3af3c1c394bd04bedbfabfb03e996cb2
BLAKE2b-256 9f89c7c81626a95a756c8f0872eb551186c26274512d07bc7d4211c882b38502

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page