Metadata-Version: 2.5
Name: pinned
Version: 0.15.4
Summary: One live instance of your class per id, with an HTTP surface
Project-URL: Repository, https://github.com/assistant-ui/harness-sdk
License-Expression: MIT
Requires-Python: >=3.11
Requires-Dist: fastapi>=0.115
Requires-Dist: httpx>=0.27
Requires-Dist: starlette>=0.37
Requires-Dist: statepatch<0.3,>=0.2.0
Provides-Extra: postgres
Requires-Dist: psycopg>=3.1; extra == 'postgres'
Provides-Extra: psutil
Requires-Dist: psutil>=5.9; extra == 'psutil'
Description-Content-Type: text/markdown

# pinned

Durable objects for Python: one live instance of your class per id across a fleet, activated on the first request, with its own HTTP surface. Part of [harness-sdk](https://github.com/assistant-ui/harness-sdk), with `statewire` and `harness-sdk`.

## Install

```sh
uv add pinned
```

Extras: `uv add "pinned[postgres]"`, `uv add "pinned[psutil]"`.

## Use

```python
from fastapi import FastAPI
from pinned import PinnedAPI, PinnedHost, PinnedWorker, route
from pinned.durability import MemoryStateStore

class Counter(PinnedAPI):
    async def lifespan(self):
        self.count = 0
        yield

    @route.post("/increment")
    async def increment(self):
        self.count += 1
        return {"id": self.id, "count": self.count}

worker = PinnedWorker(state_store=MemoryStateStore())
app = FastAPI()
app.include_router(worker)
app.include_router(PinnedHost(Counter, worker=worker, namespace="/counters"))
```

## Docs

- Get started: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/app/docs/get-started/durable-host/page.mdx
- Guide: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/app/docs/guides/pinned/authoring/page.mdx
- Reference: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/app/docs/reference/pinned/page.mdx
- Spec: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/app/docs/spec/pinboard-registry/page.mdx
