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.0.tar.gz (4.2 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.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ptrace_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 4.2 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.0.tar.gz
Algorithm Hash digest
SHA256 0de35ae4043e7f7946decfcad38b9c2379fcf683f9ea50fb2accc8cc6afe3dba
MD5 c47f3f4531a12388e9aa10b2f66513c1
BLAKE2b-256 9e7923b63906afc2bfcc6b704d0e75069d8f08e18c1dadc4162a330abc86fe75

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ptrace_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 458c655e5fa903afff910634a1e48ffc8697b2293020263b20ae22d8f78ea06a
MD5 515c96d41162bbb0fab4c9d5ae634cb4
BLAKE2b-256 bee0ebfae262a8811571762bf790632a26a7a6d1143be963ba9f8d2ba9c89707

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