Metadata-Version: 2.4
Name: agentlock-sdk
Version: 0.2.0
Summary: AgentLock Python SDK for AI agent integration
License: MIT
Requires-Python: >=3.9
Requires-Dist: httpx>=0.27.0
Provides-Extra: all
Requires-Dist: cryptography>=43.0.0; extra == 'all'
Requires-Dist: pynacl>=1.5.0; extra == 'all'
Provides-Extra: cryptography
Requires-Dist: cryptography>=43.0.0; extra == 'cryptography'
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Provides-Extra: nacl
Requires-Dist: pynacl>=1.5.0; extra == 'nacl'
Description-Content-Type: text/markdown

# agentlock-sdk (Python)

Python SDK for integrating AI agents with AgentLock.

## Installation

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

## Quick Start

```python
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

```python
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:

```python
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

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

## HTTP requests

```python
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}
```
