Metadata-Version: 2.4
Name: crossnode
Version: 0.2.0
Summary: The official Python SDK for the crossnode platform.
Author: crossnode
Project-URL: Homepage, https://www.crossnode.sh
Project-URL: Repository, https://github.com/crossnode-ai
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: docstring-parser>=0.16
Requires-Dist: pydantic>=2.0
Requires-Dist: requests>=2.32.4

# Crossnode Python SDK

The official Python SDK for interacting with the Crossnode AI platform.

## Installation

```bash
pip install crossnode
```

## Authentication

Authenticate the client using an API Key from your crossnode dashboard. By default, the SDK looks for the `CROSSNODE_API_KEY` environment variable.

```python
import os
from crossnode import CrossnodeClient

os.environ["CROSSNODE_API_KEY"] = "sk-crossnode-..."
client = CrossnodeClient()
```

## Core Resources

The SDK provides programmatic access to your Agents, Runs, and Tools.

### 1. Agents

Manage and run your AI agents.

```python
# List agents
agents = client.agents.list(limit=10)

# Get specific agent
agent = client.agents.retrieve(agent_id="agt_123")

# Trigger an agent run
run = client.agents.run(agent_id="agt_123", input_data="Analyze the market trends.")

# Export an agent configuration
config = client.agents.export(agent_id="agt_123")

# View run history for an agent
history = client.agents.list_runs(agent_id="agt_123")
```

### 2. Runs

Access and control agent execution logs, chat workflows, and files.

```python
# Check run status
status = client.runs.retrieve(run_id=run["id"])

# Stream agent logs in real-time (Server-Sent Events)
for event in client.runs.stream_logs(run_id=run["id"]):
    print(event)

# Upload a file to the sandbox for the agent to use
file_info = client.runs.upload_file(run_id=run["id"], file_path="dataset.csv")

# Continue a conversational agent session
response = client.runs.chat_continue(run_id=run["id"], input_text="What about Q3?")

# Pause and resume execution
client.runs.pause(run_id=run["id"])
client.runs.resume(run_id=run["id"])

# Human-In-The-Loop: List and approve pending runs
pending = client.runs.list_pending_approvals()
client.runs.approve(run_id=pending[0]["run_id"], decision="approved")
```

### 3. Tools

Register, list, and delete custom tools used by your agents.

```python
from crossnode import tool

@tool
def get_customer_details(customer_id: int) -> dict:
    """
    Retrieves the details for a specific customer.

    :param customer_id: The unique identifier for the customer.
    """
    if customer_id == 123:
        return {"name": "Jane Doe", "plan": "premium"}
    return {"error": "Customer not found"}

# Register the Python function as a tool on Crossnode
registered_tool = client.tools.register(get_customer_details)

# List available tools
tools = client.tools.list()

# Retrieve or delete a tool
client.tools.retrieve(tool_id=registered_tool["id"])
client.tools.delete(tool_id=registered_tool["id"])
```
