Metadata-Version: 2.5
Name: tars-sdk
Version: 0.2.1
Summary: Client SDK for TARS — the self-hosted managed-agents platform (agents, durable sessions, streaming turns, client-executed tools, files).
Project-URL: Homepage, https://github.com/LegendariTech/tars
Project-URL: Repository, https://github.com/LegendariTech/tars
Project-URL: Changelog, https://github.com/LegendariTech/tars/blob/dev/sdk-python/CHANGELOG.md
Author: Legendari
License-Expression: MIT
Keywords: agents,ai,anthropic,mcp,sdk,tars
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
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: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: httpx<1,>=0.27
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Description-Content-Type: text/markdown

# tars-sdk

Python client for [TARS](https://github.com/LegendariTech/tars) — a
self-hosted managed-agents platform: server-side agent loops in sandboxes,
an append-only session event log with SSE streaming + replay, client-executed
tools, files, and usage metering.

```bash
pip install tars-sdk
```

Python 3.10+, async (`asyncio`), one dependency (`httpx`).

## Quickstart

```python
import asyncio, os
from tars_sdk import TarsClient, TextDeltaEvent

async def main():
    async with TarsClient(
        api_key=os.environ["TARS_API_KEY"],          # tars_sk_…
        base_url="https://your-tars-host",
        provider_keys={"openrouter": os.environ["OPENROUTER_API_KEY"]},
    ) as tars:
        agent = await tars.agents.create(
            name="assistant",
            system="You are a helpful assistant.",
            model="openrouter/anthropic/claude-sonnet-5",
        )
        session = await tars.sessions.create(agent_id=agent.id)
        async for ev in session.send("Summarize the attached file."):
            if isinstance(ev, TextDeltaEvent):
                print(ev.text, end="", flush=True)

asyncio.run(main())
```

## Streaming surfaces

- `session.send(text)` — yields the turn's events; client-executed tools
  you registered (`tools=` on `sessions.create` / `session.on_tool_call`)
  are run and their results returned to the turn automatically. Handlers
  may be sync or async.
- `session.send_raw(text)` — same events, **no auto-dispatch**: hosts
  that own their tool dispatcher consume this.
- `session.stream(after)` — replay the journal after a seq, then
  live-tail; survives restarts.
- `session.resume(after)` — reconnect to the current turn only.

Every event is a `SessionEvent` dataclass (`TextDeltaEvent`,
`ToolCallEvent`, `TurnEndEvent`, …); a type newer than this SDK arrives as
`UnknownEvent` with the payload in `raw`. Non-2xx answers raise
`TarsApiError` with `status` and the stable `code`.

## Everything else

`tars.skills`, `tars.mcp_credentials`, `tars.mcp.list_tools`, `tars.usage`,
`tars.api_keys`, `tars.completions` and `tars.admin` (admin keys) cover the
rest of the API, one typed method per `/v1/*` route. On
`agents.update`, a keyword you do not pass is unchanged; passing `None` for
a clearable field (description, tools, metadata, mcp_servers, skills,
environment, reasoning) clears it.

Full docs: the TARS docs site, *SDK for Python* page.
