Metadata-Version: 2.4
Name: librefang-sdk
Version: 0.5.7
Summary: Official Python client and SDK for the LibreFang Agent OS
Author-email: LibreFang Team <team@librefang.ai>
License-Expression: MIT
Project-URL: Homepage, https://librefang.ai
Project-URL: Repository, https://github.com/librefang/librefang
Project-URL: Issues, https://github.com/librefang/librefang/issues
Keywords: librefang,agent,ai,llm,autonomous-agent,sdk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-asyncio; extra == "dev"
Dynamic: license-file
Dynamic: requires-python

# LibreFang Python SDK

Official Python client and SDK for the LibreFang Agent OS.

## Installation

```bash
pip install librefang
```

## Two Packages

This package provides two different interfaces:

### 1. REST API Client (`librefang.client`)

Control LibreFang remotely via its REST API.

```python
from librefang import Client

client = Client("http://localhost:4545")

# Create an agent
agent = client.agents.create(template="assistant")
print(f"Agent created: {agent['id']}")

# Send a message
reply = client.agents.message(agent["id"], "Hello!")
print(reply)

# Stream a response
for event in client.agents.stream(agent["id"], "Tell me a story"):
    if event.get("type") == "text_delta":
        print(event["delta"], end="", flush=True)
```

### 2. Agent SDK (`librefang.sdk`)

Write Python agents that run inside LibreFang.

```python
from librefang import Agent

agent = Agent()

@agent.on_message
def handle(message: str, context: dict) -> str:
    return f"You said: {message}"

agent.run()
```

Or use the simple input/output functions:

```python
from librefang import read_input, respond

data = read_input()
result = f"Echo: {data['message']}"
respond(result)
```

## Examples

See the `examples/` directory for more examples:

### Client Examples
- `client_basic.py` - Basic REST API usage
- `client_streaming.py` - Streaming responses

### SDK Examples
- `echo_agent.py` - Simple echo agent

## Requirements

- Python 3.8+

## License

MIT
