Metadata-Version: 2.4
Name: waken-mistral
Version: 0.1.0
Summary: Mistral Target adapter for Waken — routes waken Events to Mistral AI's chat API.
Project-URL: Homepage, https://github.com/WakenHQ/waken-mistral
Project-URL: Repository, https://github.com/WakenHQ/waken-mistral
Project-URL: Issues, https://github.com/WakenHQ/waken-mistral/issues
Author: Waken contributors
License: MIT
License-File: LICENSE
Keywords: agents,ai,mistral,waken
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.12
Requires-Dist: mistralai>=1.0.0
Requires-Dist: waken>=0.1.1
Provides-Extra: dev
Requires-Dist: mypy>=1.11; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest>=8.3; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Description-Content-Type: text/markdown

# waken-mistral

[![CI](https://github.com/WakenHQ/waken-mistral/actions/workflows/ci.yml/badge.svg)](https://github.com/WakenHQ/waken-mistral/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-lightgrey)](https://github.com/WakenHQ/waken-mistral/blob/main/LICENSE)

A Mistral [`Target`](https://github.com/WakenHQ/waken) adapter for
[Waken](https://github.com/WakenHQ/waken) — "nginx for AI agents." Routes
waken `Event`s to Mistral AI's chat completion API and returns the result as
a waken `Response`.

## Install

```bash
pip install waken-mistral
```

## Usage

```python
from waken import Runtime
from waken_mistral import MistralAdapter

runtime = Runtime()
runtime.target("mistral", MistralAdapter())
runtime.run()
```

`MistralAdapter` reads `MISTRAL_API_KEY` from the environment — that's the
`mistralai` SDK's own convention, nothing waken-specific. Pass `api_key=...`
(or any other `Mistral` client keyword, e.g. `server_url=...`) to override:

```python
runtime.target("mistral", MistralAdapter(model="mistral-small-latest", api_key="..."))
```

## Sessions

Unlike Claude or OpenAI, Mistral's chat completion API has no server-side
resumable session id — it's a stateless endpoint that expects the full
conversation history resent on every call. So `MistralAdapter` maps a waken
`session_id` to a plain, growing list of `{"role": ..., "content": ...}`
messages, appends the new user prompt and the assistant's reply to that list
on every turn, and resends the whole thing each time. History is kept
**client-side, in this process's memory only** — there's no persistence
layer, and it's lost on restart. That's the same tradeoff `waken` itself
makes for sessions in general: the runtime only stores the session *id*
mapping, never conversation content, so any content-level durability is the
adapter's responsibility, not the runtime's. An `Event` with no `session_id`
sends a fresh one-message list each call and is never stored.

## Development

```bash
git clone https://github.com/WakenHQ/waken-mistral
cd waken-mistral
pip install -e ".[dev]"
pytest
```

Tests mock `mistralai.client.Mistral` entirely — no API key or network
access needed to run the suite.

## License

[MIT](https://github.com/WakenHQ/waken-mistral/blob/main/LICENSE)
