Skip to main content

AgentLock Python SDK for AI agent integration

Project description

agentlock-sdk (Python)

Python SDK for integrating AI agents with AgentLock.

Installation

pip install agentlock-sdk
# or with poetry:
poetry add agentlock-sdk

Quick Start

from agentlock import AgentLockClient, generate_keypair

# Generate once
keypair = generate_keypair()
print("Public key (register in dashboard):", keypair.public_key)

# Create client
client = AgentLockClient(
    base_url="https://your-agentlock.vercel.app",
    agent_id="your-agent-id",
    private_key=keypair.private_key,  # or load from env
)

# Request an action
result = client.request_action(
    action_type="write",
    tool="demo",
    payload={"message": "Hello from Python!"},
)

print(result.decision)  # ALLOW | REQUIRE_APPROVAL | BLOCK

if result.status == "PENDING":
    final = client.await_result(result.request_id)
    print(final)

SDK Implementation

See src/agentlock/client.py for the full implementation. Uses pynacl for Ed25519 signing.

SSH sessions

with client.ssh.open(credential_id="cred-1") as session:
    print(session.run("uname -a").stdout)
    print(session.run("uptime").stdout)
# auto-closes

Re-attach to an existing session:

sessions = client.ssh.list()
ops = next((s for s in sessions if s.host == "ops-prod-01"), None)
if ops:
    print(ops.run("tail -n 50 /var/log/nginx/access.log").stdout)

Browser snapshot

snap = client.browser_snapshot(session_id)
# {"html": ..., "url": ..., "title": ..., "screenshot": ... (optional)}

HTTP requests

res = client.http_request(
    method="POST",
    url="https://api.example.com/items",
    body={"name": "x"},
    credential_id="cred-api",
)
# {"status": 201, "headers": {...}, "body": {...}, "duration_ms": 42}

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

agentlock_sdk-0.2.0.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

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

agentlock_sdk-0.2.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file agentlock_sdk-0.2.0.tar.gz.

File metadata

  • Download URL: agentlock_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for agentlock_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ebb43af99295044569013742b01d7f8fa8f81c7059889438d69d7195bfbe5d72
MD5 6b9ac572c7bf6e5c9bb6223ad722ad72
BLAKE2b-256 80911e636c8e346654343a06ac46b4048b53763335130c52513c8f04427b1db4

See more details on using hashes here.

File details

Details for the file agentlock_sdk-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: agentlock_sdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for agentlock_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7e82b5bb06fe33897214eefa4c0232459284d0cd3cebfdd5c61ed7d946d3fa4
MD5 dc50b8c2993bdf6346c223e3a0e24004
BLAKE2b-256 9f17b3a5985586a5afd270d7d10623ab8e152593fc984573aab377a8ce84b6ee

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