Python REST SDK for Ecto Ledger - The Cryptographic Veto Engine for AI Agents
Project description
Ecto Ledger SDK — Python
A typed async REST client for Ecto Ledger with built-in LangChain and AutoGen support.
Installation
# Core client only
pip install ectoledger-sdk
# With LangChain support
pip install 'ectoledger-sdk[langchain]'
# With AutoGen support
pip install 'ectoledger-sdk[autogen]'
Quick start
import asyncio
from ectoledger_sdk import LedgerClient
async def main():
async with LedgerClient("http://localhost:3000", bearer_token="your_token") as client:
sessions = await client.list_sessions()
print(f"Found {len(sessions)} active sessions.")
asyncio.run(main())
Constructor
LedgerClient(
base_url="http://localhost:3000", # Server URL (required in production)
bearer_token=None, # Optional RBAC token
timeout=30.0, # HTTP timeout in seconds
)
Note: The default
base_urlonly works for local development. In Docker Compose or Kubernetes you must pass the correct service URL.
Error handling
All methods raise LedgerSdkError on non-2xx responses:
from ectoledger_sdk import LedgerSdkError
try:
await client.verify_chain(session_id)
except LedgerSdkError as exc:
print(exc.status_code, exc.body)
LangChain integration
from ectoledger_sdk.langchain import LedgerTool
ledger_tool = LedgerTool(
session_id="your-session-uuid",
base_url="http://localhost:3000",
)
# Add ledger_tool to your agent's tool list
AutoGen integration
from ectoledger_sdk.autogen import LedgerHook
hook = LedgerHook(session_id="your-session-uuid")
hook.attach(my_agent)
Testing
cd sdk/python
pip install ".[dev]"
pytest tests/ -v
API Reference
Status
| Method | Returns | Description |
|---|---|---|
get_status() |
StatusResponse |
Server status (demo mode, version) |
Sessions
| Method | Returns | Description |
|---|---|---|
list_sessions(limit=50, offset=None, status=None) |
list[Session] |
List recent sessions with optional pagination and status filter |
create_session(goal, policy_hash=None, session_did=None) |
Session |
Open a new audit session |
get_session(session_id) |
Session |
Fetch a single session |
seal_session(session_id) |
None |
Mark session as finished |
Chat
| Method | Returns | Description |
|---|---|---|
chat(session_id, message) |
dict |
Send a message within a running session |
Events
| Method | Returns | Description |
|---|---|---|
get_events(session_id) |
list[LedgerEvent] |
Fetch all events for a session |
append_event(session_id, payload) |
AppendResult |
Sign and append an event |
stream_events(session_id) |
AsyncIterator[dict] |
SSE live event stream |
Chain Verification & Compliance
| Method | Returns | Description |
|---|---|---|
verify_chain(session_id) |
bool |
Verify hash chain integrity |
prove_compliance(session_id) |
ComplianceBundle |
Typed compliance proof bundle |
export_certificate(session_id) |
bytes |
Download .elc audit certificate |
Reports & Verifiable Credentials
| Method | Returns | Description |
|---|---|---|
get_report(session_id) |
dict |
Audit report as a dictionary |
get_session_vc(session_id) |
dict |
W3C Verifiable Credential (VC-JWT) |
verify_session_vc(session_id) |
dict |
Verify VC structural integrity |
Metrics
| Method | Returns | Description |
|---|---|---|
get_metrics() |
MetricsSummary |
System metrics summary |
get_security_metrics() |
SecurityMetrics |
Security event counters |
get_prometheus_metrics() |
str |
Raw Prometheus text output |
Configuration
| Method | Returns | Description |
|---|---|---|
get_config() |
ConfigResponse |
Current server configuration |
update_config(patch) |
dict |
Apply partial config update |
Tripwire Configuration
| Method | Returns | Description |
|---|---|---|
get_tripwire_config() |
TripwireConfig |
Current tripwire guard config |
update_tripwire_config(patch) |
dict |
Apply partial tripwire update |
Policies
| Method | Returns | Description |
|---|---|---|
list_policies() |
list[str] |
List available policy names |
get_policy(name) |
str |
Retrieve policy TOML content |
save_policy(name, content) |
None |
Create or overwrite a policy |
delete_policy(name) |
None |
Remove a policy |
RBAC Tokens
| Method | Returns | Description |
|---|---|---|
list_tokens() |
list[TokenListRow] |
List tokens (hashed, not raw) |
create_token(role, label=None) |
CreateTokenResponse |
Create a new API token |
delete_token(token_hash) |
None |
Revoke a token |
Webhooks
| Method | Returns | Description |
|---|---|---|
list_webhooks() |
list[WebhookListRow] |
List configured webhooks |
create_webhook(label, url, siem_format="json", filter_kinds=None) |
WebhookListRow |
Register a webhook |
delete_webhook(webhook_id) |
None |
Remove a webhook |
toggle_webhook(webhook_id, enabled) |
dict |
Enable/disable a webhook |
Approval Gates
| Method | Returns | Description |
|---|---|---|
get_pending_approval(session_id) |
PendingApproval | None |
Get pending approval gate |
post_approval_decision(session_id, gate_id, approved, reason=None) |
None |
Submit decision |
Admin
| Method | Returns | Description |
|---|---|---|
reset_demo() |
dict |
Reset server to demo defaults |
Licensing & Contact
Licensed under the Apache License 2.0.
Maintained by Björn Roman Kohlberger.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ectoledger_sdk-0.6.2.tar.gz.
File metadata
- Download URL: ectoledger_sdk-0.6.2.tar.gz
- Upload date:
- Size: 52.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fd1997300fad3d16301b059acad9f1358262732df5aafa10dcdad37dcd12e16
|
|
| MD5 |
980b25cd938f0013415eff04d7d5b8a8
|
|
| BLAKE2b-256 |
9b0cd1faf75b45f469895f9f5a7d6e232aa10391120ac096684b3e591b9de436
|
Provenance
The following attestation bundles were made for ectoledger_sdk-0.6.2.tar.gz:
Publisher:
release.yml on EctoSpace/EctoLedger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ectoledger_sdk-0.6.2.tar.gz -
Subject digest:
0fd1997300fad3d16301b059acad9f1358262732df5aafa10dcdad37dcd12e16 - Sigstore transparency entry: 1061551264
- Sigstore integration time:
-
Permalink:
EctoSpace/EctoLedger@9976fbfd04b9de94e0780d79351fe6d981f6abc2 -
Branch / Tag:
refs/tags/v0.6.2 - Owner: https://github.com/EctoSpace
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9976fbfd04b9de94e0780d79351fe6d981f6abc2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ectoledger_sdk-0.6.2-py3-none-any.whl.
File metadata
- Download URL: ectoledger_sdk-0.6.2-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddb3b21e58133a98bdcf566d1918f60e4e58000c4f18497087dfa6fa34a7b827
|
|
| MD5 |
2efbecebd871ab423b680427446ce5d3
|
|
| BLAKE2b-256 |
9890a090f62781c37be73fa66dfe7268e02d137937d8854be73a74614a6144fe
|
Provenance
The following attestation bundles were made for ectoledger_sdk-0.6.2-py3-none-any.whl:
Publisher:
release.yml on EctoSpace/EctoLedger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ectoledger_sdk-0.6.2-py3-none-any.whl -
Subject digest:
ddb3b21e58133a98bdcf566d1918f60e4e58000c4f18497087dfa6fa34a7b827 - Sigstore transparency entry: 1061551266
- Sigstore integration time:
-
Permalink:
EctoSpace/EctoLedger@9976fbfd04b9de94e0780d79351fe6d981f6abc2 -
Branch / Tag:
refs/tags/v0.6.2 - Owner: https://github.com/EctoSpace
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9976fbfd04b9de94e0780d79351fe6d981f6abc2 -
Trigger Event:
push
-
Statement type: