Metadata-Version: 2.4
Name: cowboy-sdk
Version: 0.1.1
Summary: SDK for developing Cowboy Actors
Author: Cowboy Labs
License: MIT
Project-URL: Homepage, https://github.com/cowboylabs/cowboy
Project-URL: Documentation, https://github.com/cowboylabs/cowboy/blob/main/refs/dev_support/cowboy_sdk_developer_manual.md
Project-URL: Repository, https://github.com/cowboylabs/cowboy.git
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Intended Audience :: Developers
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: cbor2>=5.6.0

# Cowboy SDK

The official Python SDK for developing autonomous actors on the **Cowboy PVM (Python Virtual Machine)**.

With this SDK, you can write fully deterministic on-chain Python code that interacts natively with LLMs, APIs, and the broader Cowboy ecosystem.

## Features

- **Decentralized AI Agents**: Write prompt chains, FSM-based LLM logic, and MCP integrations directly in Python.
- **`@runner.continuation`**: Turn Python `async` functions into verified Finite State Machines (FSMs) capable of pausing execution, offloading heavy compute (LLM inference, HTTP requests) to Runners, and seamlessly resuming on the next block.
- **Robust Determinism**: The SDK strips away standard Python non-determinism (`time`, `random`, `set`) and replaces it with consensus-safe primitives.
- **CBOR-backed State**: The `CowboyModel` and `self.storage` dict provide automatic schema validation and canonical CBOR serialization for zero-boilerplate state management.
- **Built-in Async Primitives**: Leverage `TaskGroup` for concurrent Runner tasks, `Retry` for robust backoff logic, and `bounded_loop` to ensure safety limits.

## Quick Start

```shell
pip install cowboy-sdk
```

```python
from cowboy_sdk import actor, runner, capture

@actor
class MyAgent:
    def init(self, payload):
        self.storage["calls"] = 0
        return b"ok"

    @runner.continuation
    async def chat(self, msg):
        ctx = capture()
        ctx.prompt = msg.get("message", "Hello")
        
        # Off-chain heavy compute (LLM) securely verified via consensus
        result = await runner.llm(ctx.prompt, system_prompt="You are a helpful assistant")
        
        # Execution resumes here on the next block
        chat_id = self.storage.get("calls", 0)
        self.storage[f"reply:{chat_id}"] = result
        self.storage["calls"] = chat_id + 1
        
        return b"ok"

def _a(): return MyAgent()
def init(p): return _a().init(p)
def chat(p): return _a().chat(p)
def chat__resume(p): return _a().chat__resume(p)
def on_runner_result(p): return _a().on_runner_result(p)
```

## Documentation & Tools

- **Developer Manual**: [View on GitHub](https://github.com/cowboylabs/cowboy/blob/main/refs/dev_support/cowboy_sdk_developer_manual.md)
- **Vibe Coding Blueprint (Claude Code)**: Learn how to set up autonomous development without local chain dependencies. [View Guide](https://github.com/cowboylabs/cowboy/blob/main/refs/dev_support/remote_developer_guide.md).
- **Cowboy CLI**: Pre-compiled binary required to deploy and send transactions. Download from the [GitHub Releases](https://github.com/cowboylabs/cowboy/releases).

## License

MIT License. See the repository for details.
