Skip to main content

Python SDK for Treeship - portable trust receipts for agent workflows

Project description

treeship-sdk

Python SDK for Treeship -- portable trust receipts for agent workflows.

Install

pip install treeship-sdk

Requires the treeship CLI binary in PATH:

curl -fsSL treeship.dev/install | sh
treeship init

Usage

from treeship_sdk import Treeship

ts = Treeship()

# Attest an action
result = ts.attest_action(actor="agent://my-agent", action="tool.call")
print(result.artifact_id)  # art_abc123...

# Attest a decision (LLM reasoning)
ts.attest_decision(
    actor="agent://analyst",
    model="claude-opus-4",
    tokens_in=8432,
    tokens_out=1247,
    summary="Contract looks standard.",
    confidence=0.91,
)

# Attest an approval
approval = ts.attest_approval(
    approver="human://alice",
    description="approve payment max $500",
)
print(approval.nonce)  # binding token; replay enforcement is package-local in v0.9.6

# Attest with approval binding
ts.attest_action(
    actor="agent://executor",
    action="stripe.charge.create",
    approval_nonce=approval.nonce,
)

# Verify
result = ts.verify("art_abc123")
print(result.outcome)  # "pass"

# Push to Hub
push = ts.hub_push("art_abc123")
print(push.hub_url)  # https://treeship.dev/verify/art_abc123

# Wrap a command
result = ts.wrap("npm test", actor="agent://ci")
print(result.artifact_id)

API

Method Returns Description
attest_action(actor, action, ...) ActionResult Sign an action receipt
attest_approval(approver, description, ...) ApprovalResult Sign an approval with nonce
attest_handoff(from_actor, to_actor, artifacts) ActionResult Sign a handoff receipt
attest_decision(actor, model, ...) ActionResult Sign a decision receipt
verify(artifact_id) VerifyResult Verify an artifact chain
hub_push(artifact_id) PushResult Push artifact to the configured Hub
wrap(command, actor) ActionResult Wrap a shell command

How it works

The SDK calls the treeship CLI binary via subprocess. All signing happens in the Rust binary. The Python SDK is a thin wrapper.

License

Apache-2.0

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

treeship_sdk-0.9.7.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

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

treeship_sdk-0.9.7-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file treeship_sdk-0.9.7.tar.gz.

File metadata

  • Download URL: treeship_sdk-0.9.7.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for treeship_sdk-0.9.7.tar.gz
Algorithm Hash digest
SHA256 9db0fce50fc9cab7adc5ea190547bff244f7834736ba7187ab23a947ed461c87
MD5 8d5c31e63745a6d4389d189b679d45c0
BLAKE2b-256 9011b5cd5f8c04f978eaa8e1094cff7bae5248ad2a1ffae54d513004792eb46a

See more details on using hashes here.

File details

Details for the file treeship_sdk-0.9.7-py3-none-any.whl.

File metadata

  • Download URL: treeship_sdk-0.9.7-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for treeship_sdk-0.9.7-py3-none-any.whl
Algorithm Hash digest
SHA256 0c3a1363b098e2412f84f9d2fdaa4fdf2e71271cbb70ffc8ec07dbbb3fe9b169
MD5 9d2f5f35f72260fad54800c816989599
BLAKE2b-256 0a260951ee4b60743ef7fe68eee9279b809ddf8f8ffc4ca10ac7796c8bc0ee54

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