Metadata-Version: 2.5
Name: cognisn-conduit
Version: 0.1.0rc2
Summary: Shared AI integration library for Cognisn products: providers, streaming, prompt caching, agent runner, compaction, skills, MCP client and embeddings.
Project-URL: Homepage, https://github.com/Cognisn/conduit
Project-URL: Source, https://github.com/Cognisn/conduit
Project-URL: Issues, https://github.com/Cognisn/conduit/issues
Project-URL: Changelog, https://github.com/Cognisn/conduit/blob/main/CHANGELOG.md
Author: Cognisn Pty Ltd
License-Expression: MIT
License-File: LICENSE
Keywords: agents,ai,amazon-bedrock,anthropic,gemini,llm,mcp,ollama,openai
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: pydantic<3,>=2.9
Provides-Extra: all-providers
Requires-Dist: anthropic<3,>=2.4; extra == 'all-providers'
Requires-Dist: azure-identity<2,>=1.27; extra == 'all-providers'
Requires-Dist: boto3<2,>=1.35; extra == 'all-providers'
Requires-Dist: google-genai<3,>=2.30; extra == 'all-providers'
Requires-Dist: httpx<1,>=0.28; extra == 'all-providers'
Requires-Dist: openai<4,>=3.45; extra == 'all-providers'
Provides-Extra: anthropic
Requires-Dist: anthropic<3,>=2.4; extra == 'anthropic'
Requires-Dist: azure-identity<2,>=1.27; extra == 'anthropic'
Provides-Extra: bedrock
Requires-Dist: boto3<2,>=1.35; extra == 'bedrock'
Provides-Extra: bedrock-mantle
Requires-Dist: anthropic<3,>=2.4; extra == 'bedrock-mantle'
Requires-Dist: boto3<2,>=1.35; extra == 'bedrock-mantle'
Provides-Extra: cli
Requires-Dist: mcp<2,>=1.30; extra == 'cli'
Requires-Dist: rich<16,>=14; extra == 'cli'
Provides-Extra: dev
Requires-Dist: mypy>=1.11; extra == 'dev'
Requires-Dist: opentelemetry-sdk<2,>=1.30; extra == 'dev'
Requires-Dist: packaging>=24; extra == 'dev'
Requires-Dist: psycopg[binary]>=3.2; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Requires-Dist: testcontainers[postgres]<5,>=4.9; extra == 'dev'
Provides-Extra: gemini
Requires-Dist: google-genai<3,>=2.30; extra == 'gemini'
Provides-Extra: konfig
Requires-Dist: cognisn-konfig<1,>=0.5; extra == 'konfig'
Provides-Extra: local-embeddings
Requires-Dist: sentence-transformers<7,>=6.2; extra == 'local-embeddings'
Requires-Dist: torch<3,>=2.15; extra == 'local-embeddings'
Provides-Extra: mcp
Requires-Dist: mcp<2,>=1.30; extra == 'mcp'
Provides-Extra: ollama
Requires-Dist: httpx<1,>=0.28; extra == 'ollama'
Provides-Extra: openai
Requires-Dist: azure-identity<2,>=1.27; extra == 'openai'
Requires-Dist: openai<4,>=3.45; extra == 'openai'
Provides-Extra: otel
Requires-Dist: opentelemetry-api<2,>=1.30; extra == 'otel'
Provides-Extra: sql
Requires-Dist: aiosqlite<1,>=0.20; extra == 'sql'
Requires-Dist: alembic<2,>=1.13; extra == 'sql'
Requires-Dist: asyncpg<1,>=0.30; extra == 'sql'
Requires-Dist: sqlalchemy[asyncio]<2.1,>=2.0.30; extra == 'sql'
Provides-Extra: testing
Requires-Dist: pytest>=8; extra == 'testing'
Provides-Extra: warden
Requires-Dist: cognisn-warden<0.2,>=0.1.0b8; extra == 'warden'
Description-Content-Type: text/markdown

# conduit

One AI integration layer for Cognisn products.

conduit gives a Python product model providers, a model catalogue with residency policy, streaming, prompt caching, normalised usage, an agent runner with budgets and hand-off, compaction, skills, an MCP client, embeddings, product-supplied storage, and audit and monitoring events. It supplies the mechanisms; each product keeps its own policy (its prompts, guardrails, approvals and billing).

## Status

**Release candidate.** conduit 0.1.0rc2 is on PyPI as a pre-release, built from the `release/v0.1.0` branch. Every layer described here is built and tested; the public API may still change before 0.1.0 if testing of the release candidate finds a problem.

## Design in brief

- **Async first.** Every interface is async, and every provider streams. A supported sync facade runs calls on an event loop conduit owns.
- **Layered, with optional extras.** The core is always installed and depends on pydantic alone. Every provider SDK and every layer's own dependencies are optional extras, and dependencies point one way: upper layers depend on the core, never the reverse.
- **Checked at start-up.** The product declares its task classes with capability floors, assigns a provider and model to each, and states its residency policy. An undeclared model, a model below a floor, an assignment that would breach residency, or a credential written in plain text is refused at start-up, before any client exists, never part-way through a task.
- **One funnel for every model call.** Every call passes through the provider registry, which holds it to its assignment and emits exactly one finished event with its usage, however the call ends.
- **Usage you can bill.** Every usage figure carries input, output, cache-read and cache-write tokens separately.
- **Content stays out of events by default.** Events carry identifiers, hashes, sizes and outcomes; prompt and tool content is recorded only when the product opts in.
- **Storage-agnostic.** Products supply their own transcript store, event sink, skill source, secret resolver, approval handler and MCP token store, with a conformance test suite for each store and source. In-memory, local JSON file and SQL reference backends are provided.

## Requirements

Python 3.12 or later.

## Installation

The PyPI package is `cognisn-conduit` and the import name is `conduit`. Until 0.1.0 is final, ask for the pre-release explicitly, with `pip install --pre` or a pinned version such as `cognisn-conduit==0.1.0rc2`:

```sh
pip install "cognisn-conduit[bedrock]"
uv add "cognisn-conduit[anthropic,mcp]"
```

The core install and the stub provider need no extra. [Setting up providers](https://github.com/Cognisn/conduit/blob/main/docs/guides/providers.md) has install lines for each installer, including CPU-only torch for local embeddings.

### Extras

| Extra | Adds |
|---|---|
| `bedrock` | Amazon Bedrock provider (Converse; AWS credential chain, access keys as secrets, and Bedrock API keys) and Titan embeddings |
| `bedrock-mantle` | Single-Region Claude through Amazon Bedrock's mantle endpoint, with Bedrock API keys |
| `anthropic` | Anthropic provider (direct, and Claude in Microsoft Foundry with an API key or Microsoft Entra ID) |
| `openai` | OpenAI-compatible provider (OpenAI, X.AI and Microsoft Foundry with an API key or Microsoft Entra ID) and embeddings |
| `gemini` | Gemini API provider and embeddings |
| `ollama` | Ollama provider and embeddings |
| `all-providers` | Every provider above but `bedrock-mantle` (its two libraries are already in `all-providers`) |
| `local-embeddings` | Local embeddings with sentence-transformers on CPU-only torch |
| `mcp` | MCP client over the official SDK (stdio, streamable HTTP and SSE), with static credentials and an OAuth 2.1 client |
| `sql` | SQL transcript and token stores (SQLAlchemy; Postgres and SQLite) with their own schema and migrations |
| `konfig` | konfig settings loader and secret resolver |
| `warden` | Records conduit events in warden's audit trail (metadata only). The extra installs 33 runtime packages on Linux and Windows beyond the core's 5 (38 in all, as `python scripts/licence_audit.py --extra warden` counts them; a few fewer on macOS), including psycopg (LGPL-3.0) under its named licence exception and fido2 (BSD-2-Clause with Apache-2.0 and MPL-2.0 files) under its own, in the licence audit |
| `otel` | OpenTelemetry spans and metrics (the OpenTelemetry API; the product supplies the SDK and exporters) |
| `testing` | pytest, for the conformance suites' pytest plugin (`conduit.testing.conformance`) |
| `cli` | The `conduit` terminal interface demonstrating the public API (`uvx --from "cognisn-conduit[cli]" conduit`); installs rich and the `mcp` extra |

The agent runner, compaction, skills and the in-memory and JSON stores are part of the core install.

## A first call

This runs as it stands, against the stub provider:

```python
import asyncio

from conduit import ConduitSettings, LiteralSecretResolver, Message, TaskClass, start
from conduit.providers import builtin_factories

settings = ConduitSettings.model_validate(
    {
        "providers": {"local": {"kind": "stub", "not_for_production": True}},
        "assignments": {"triage": {"provider": "local", "model": "stub-echo"}},
    }
)


async def main() -> str:
    runtime = await start(
        settings,
        task_classes=[TaskClass(name="triage")],
        factories=builtin_factories(),
        secrets=LiteralSecretResolver({}),
    )
    try:
        binding = runtime.for_task("triage")
        response = await binding.provider.complete(
            binding.request(messages=[Message.user("Hello from example.com")])
        )
        return response.text
    finally:
        await runtime.aclose()


assert asyncio.run(main()) == "Hello from example.com"
```

To call a real model, configure its provider (for example `{"kind": "bedrock", "region": "eu-west-2"}`), assign one of its models, and use an `EnvironmentSecretResolver` or your own resolver for its credentials.

Import the core's names (types, settings, events, errors, tools, transcript entries and backend models) from `conduit` itself, and each layer's names from its package: `conduit.agent`, `conduit.stores`, `conduit.mcp`, `conduit.providers.bedrock` and so on. Importing `conduit` loads the core alone.

## Guides

- [Integrating conduit](https://github.com/Cognisn/conduit/blob/main/docs/guides/integration.md): settings, start-up, task classes, catalogue overlays, residency, events and capture, the agent runner and the sync facade.
- [Setting up providers](https://github.com/Cognisn/conduit/blob/main/docs/guides/providers.md) and [embeddings](https://github.com/Cognisn/conduit/blob/main/docs/guides/embeddings.md).
- [Writing backends](https://github.com/Cognisn/conduit/blob/main/docs/guides/backends.md), their conformance suites, and evaluating agent tasks.
- [Skills](https://github.com/Cognisn/conduit/blob/main/docs/guides/skills.md), [MCP servers](https://github.com/Cognisn/conduit/blob/main/docs/guides/mcp.md), [compaction](https://github.com/Cognisn/conduit/blob/main/docs/guides/compaction.md), [audit and telemetry](https://github.com/Cognisn/conduit/blob/main/docs/guides/observability.md) and [the terminal interface](https://github.com/Cognisn/conduit/blob/main/docs/guides/terminal.md).
- [Adoption notes](https://github.com/Cognisn/conduit/blob/main/docs/guides/adoption.md) for products moving onto conduit.

The full design is in [docs/design/architecture.md](https://github.com/Cognisn/conduit/blob/main/docs/design/architecture.md).

## Development

```sh
pip install -e ".[dev,all-providers,bedrock-mantle,cli,konfig,local-embeddings,mcp,otel,sql,testing,warden]"
ruff format --check .
ruff check .
mypy --strict
pytest
python scripts/licence_audit.py
python scripts/licence_audit.py --all-extras
```

The default test run never calls a live model or service. Tests marked `integration` need live providers and are skipped by default. Every Python example in this README and in the guides is executed by `tests/docs/test_guides.py`; a guide whose examples need an extra you have not installed is skipped, naming the extra. With every extra installed, set `CONDUIT_ALL_EXTRAS=require`, as CI does: a missing extra then fails these tests and the event-content tripwire instead of skipping them, and any other value of the variable is refused. The MCP tests' loopback servers take ports the operating system assigns, unless `CONDUIT_MCP_TEST_PORT_BASE` is set to a slot's base port.

## Licence

MIT. Copyright (c) 2026 Cognisn Pty Ltd. See [LICENSE](https://github.com/Cognisn/conduit/blob/main/LICENSE).
