Metadata-Version: 2.4
Name: waken-bedrock
Version: 0.1.0
Summary: AWS Bedrock Target adapter for Waken — routes waken Events to any Bedrock-hosted model via the Converse API.
Project-URL: Homepage, https://github.com/WakenHQ/waken-bedrock
Project-URL: Repository, https://github.com/WakenHQ/waken-bedrock
Project-URL: Issues, https://github.com/WakenHQ/waken-bedrock/issues
Author: Waken contributors
License: MIT
License-File: LICENSE
Keywords: agents,ai,aws,bedrock,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: boto3>=1.34.0
Requires-Dist: waken>=0.1.1
Provides-Extra: dev
Requires-Dist: boto3-stubs[bedrock-runtime]>=1.34.0; extra == 'dev'
Requires-Dist: mypy>=1.11; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest>=8.3; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Description-Content-Type: text/markdown

# waken-bedrock

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

An AWS Bedrock [`Target`](https://github.com/WakenHQ/waken) adapter for
[Waken](https://github.com/WakenHQ/waken) — "nginx for AI agents." Routes
waken `Event`s to any model hosted on Bedrock via the unified `converse` API
and returns the result as a waken `Response`.

## Install

```bash
pip install waken-bedrock
```

## Usage

```python
from waken import Runtime
from waken_bedrock import BedrockAdapter

runtime = Runtime()
runtime.target("bedrock", BedrockAdapter(model_id="anthropic.claude-3-5-sonnet-20241022-v2:0"))
runtime.run()
```

`model_id` is required — Bedrock hosts models from several providers behind
one API, and there's no sensible default across them. This is also the
whole point of this adapter: it's *one* Target that can reach Anthropic,
Meta, Amazon, Mistral, or any other model family Bedrock hosts, just by
changing the string:

```python
runtime.target("claude-on-bedrock", BedrockAdapter(model_id="anthropic.claude-3-5-sonnet-20241022-v2:0"))
runtime.target("llama-on-bedrock", BedrockAdapter(model_id="meta.llama3-1-70b-instruct-v1:0"))
```

## Credentials

Unlike sibling adapters that read a single named API key
(`ANTHROPIC_API_KEY`, `GEMINI_API_KEY`), Bedrock has no equivalent —
`boto3` authenticates through the standard **AWS credential chain**: env
vars (`AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY`/`AWS_SESSION_TOKEN`),
`AWS_PROFILE` and `~/.aws/credentials`, or an EC2/ECS/Lambda instance role,
resolved in that order by `boto3` itself. `BedrockAdapter` never reads or
touches credentials directly. Pass `region_name`, `profile_name`, or
explicit credential keywords through `**client_kwargs`, which go straight to
`boto3.client("bedrock-runtime", ...)`:

```python
runtime.target(
    "bedrock",
    BedrockAdapter(
        model_id="anthropic.claude-3-5-sonnet-20241022-v2:0",
        region_name="us-east-1",
        profile_name="my-aws-profile",
    ),
)
```

## Sessions

Bedrock's `converse` API is stateless per call, the same client-managed-
history shape as the Gemini/Mistral/Cohere sibling adapters: there's no
server-side session id to resume, so the whole conversation is resent on
every turn. `BedrockAdapter` maps a waken `session_id` to a growing list of
Bedrock-shaped messages and replays it in full each call. An `Event` with no
`session_id` is a one-off exchange and is never stored.

`boto3` is a synchronous SDK — the blocking `converse()` call runs on the
default executor (`loop.run_in_executor`) rather than blocking the event
loop directly.

SDK exceptions (throttling, validation errors, access-denied, ...) propagate
unchanged; this adapter doesn't wrap or swallow them.

## Development

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

Tests mock `boto3.client` entirely — no AWS credentials or network access
needed to run the suite.

## License

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