Metadata-Version: 2.4
Name: allybuild-sdk
Version: 1.0.1
Summary: AllyBuild SDK for task scripts — pure-stdlib HTTP facade (client + tasks/mcp/status/reporter/reactive)
License-Expression: MIT
Project-URL: Homepage, https://allybuild.ai/
Keywords: allybuild,sdk,workflow
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# allybuild-sdk

Python SDK for [AllyBuild](https://allybuild.ai/) — the sandbox-isolated task scheduling and execution platform.

It is the interaction surface available inside AllyBuild task scripts: a pure-stdlib HTTP facade (zero third-party dependencies) covering tasks, agents, memories, OKF, MCP, project status, plus a Vue-Reactive-style state store.

- Homepage: <https://allybuild.ai/>

## Installation

```bash
pip install allybuild-sdk
```

Requires Python >= 3.10. No third-party dependencies.

## Usage

Inside an AllyBuild task, your script runs with `workflow.py` (injected with `params` / `reporter` / `TASK_JWT` / `ALLYBUILD_API_URL`):

```python
def run(params: dict, reporter) -> None:
    reporter.set_phase("fetch")        # update current phase
    reporter.set_progress(50)          # update progress 0-100

    data = list_tasks(status="success")
    okf_search("runbook", query="deploy")
    return {"count": len(data)}
```

Import side effects run too (Convention 2) — top-level `create_task(...)` calls are flushed automatically.

### Direct client

```python
from allybuild_sdk import AllyBuildClient, create_client

api = create_client(
    base_url="https://your-host/api",   # ALLYBUILD_API_URL
    token="<TASK_JWT>",
    project_id="<PROJECT_ID>",
)
tasks = api.tasks.list(status="running")
api.reporter.set_progress(20)
```

### Reactive store

A Pinia/Vue-Reactive-style store, in-memory by default, optionally persisted to the AllyBuild backend for cross-task/cross-process sharing:

```python
from allybuild_sdk.reactive import defineStore, getter, action, create_reactive

create_reactive()

@defineStore("counter")
class CounterStore:
    count: int = 0

    @getter
    def display(self) -> str:
        return f"count: {self.count}"

    @action
    def increment(self, by: int = 1) -> None:
        self.count += by

store = CounterStore()
store.increment()
print(store.display)  # "count: 1"
```

## Modules

| Import | Purpose |
|--------|---------|
| `allybuild_sdk` | HTTP client, Reporter, Tasks / Agents / Memories / OKF / MCP APIs, project status proxy |
| `allybuild_sdk.reactive` | Reactive stores: `defineStore`, `getter`, `action`, `field`, `create_reactive`, `HttpBackend` |

## License

MIT
