Python SDK for Contract Lane Operator API
Project description
contractlane-operator-sdk
Python SDK for the Contract Lane Operator API.
Install
pip install contractlane-operator-sdk
Quickstart
from contractlane_operator_sdk import ClientOptions, OperatorClient
client = OperatorClient(
ClientOptions(
base_url="https://localhost",
session_token=lambda: "session-token",
operator_token=lambda: "operator-token",
challenge_headers=lambda _: {
"X-Signup-Challenge": "signup-challenge-token",
"X-Operator-Challenge": "proof-challenge",
"X-Operator-Challenge-Token": "challenge-provider-token",
},
)
)
1) Human signup/auth
start = client.public.signup.start({"email": "owner@example.com", "org_name": "Acme"})
session_id = start.data["signup_session"]["session_id"]
client.public.signup.verify({"session_id": session_id, "verification_code": "123456"})
client.public.signup.complete({"session_id": session_id, "project_name": "Default", "agent_name": "Primary"})
2) Admin actor + credential issue
org = client.operator.admin.create_org({"name": "Acme", "admin_email": "owner@example.com"})
org_id = org.data["org"]["org_id"]
project = client.operator.admin.create_project(org_id, {"name": "Project A"})
project_id = project.data["project"]["project_id"]
actor = client.operator.admin.create_actor(project_id, {"name": "Bot", "scopes": ["cel.contracts:write"]})
actor_id = actor.data["actor"]["actor_id"]
client.operator.admin.issue_credential({"actor_id": actor_id, "upstream_token": "upstream-token"})
3) Agent-first enrollment
challenge = client.public.agent_enrollment.challenge(
{"public_key_jwk": {"kty": "OKP", "crv": "Ed25519", "x": "..."}}
)
challenge_id = challenge.data["challenge"]["challenge_id"]
client.public.agent_enrollment.start(
{
"challenge_id": challenge_id,
"signature": "base64url-signature",
"sponsor_email": "owner@example.com",
"requested_scopes": ["cel.contracts:write"],
}
)
4) Gateway contract action
client.gateway.cel.create_contract({"template_id": "tpl_123", "payload": {}})
client.gateway.cel.contract_action("ctr_123", "send", {"note": "go"})
Notes
- Mutating operator/public endpoints auto-inject
Idempotency-Key. request_idis available viaresponse.meta.request_id.- Challenge hooks can provide
X-Signup-Challenge,X-Operator-Challenge, andX-Operator-Challenge-Token; per-request headers can override hook values. - Failures raise
APIErrorwithstatus,code,message,request_id,meta,raw_body.
Integration Tests
Run against a live operator stack:
python -m pytest tests/integration -m integration
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
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 contractlane_operator_sdk-0.1.0.tar.gz.
File metadata
- Download URL: contractlane_operator_sdk-0.1.0.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a392da4ba5c9b5abd32da6900028acd39c73cfc07917a9a3f64ba958c6e8a03
|
|
| MD5 |
23316a8d0053a5f2cfba75b59d95c5fd
|
|
| BLAKE2b-256 |
c38e4e1a5bb9df2087d13fa5d2dc55ec2ffc0af574162632bb3153206b6c5e23
|
File details
Details for the file contractlane_operator_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: contractlane_operator_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c52d4f400b8f071ef19792f636c5a0b34cd482dbbfb460b930751e29490ff4c
|
|
| MD5 |
38f25b0d7dedb0ab632e301d5ea1b500
|
|
| BLAKE2b-256 |
7cbb30a4ef3f8af045c4256ab43b57f1f5758f479bffb9c1a363b40ea18206aa
|