Metadata-Version: 2.4
Name: constaia
Version: 0.1.0
Summary: Configuration-as-code toolkit for typed, validated AI agent configs.
Author: 
License: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# constaia

`constaia` is a configuration-as-code toolkit for building, validating, and deploying typed configuration objects for AI agents and LLM applications. It lets you declare agent prompts, model parameters, tool schemas, and runtime policies as versioned `Config` objects that are validated against a schema before they reach production. It is designed for teams shipping generative features who need reproducible agent behavior, change review, and rollback without hand-editing YAML.

Configs are serialisable to JSON, diffable across versions, and can be exported to the Constaia control plane for deployment tracking.

## Features

- Declarative `Config` and `Agent` classes with field validation, defaults, and deprecation warnings.
- Compose reusable `Prompt`, `ToolSpec`, and `ModelProfile` objects and reference them across multiple agents.
- Validate every config against its JSON schema with `constaia.validate()` before deployment; failures raise `ConfigError` with a precise field path.
- Diff two config versions with `constaia.diff()` and emit a human-readable changelog for review.
- Export configs to JSON, YAML, or the Constaia platform; load them back with `constaia.load()`.
- Built-in profiles for OpenAI, Anthropic, and open-weight model families with sane parameter defaults.
- Lock a config to a semantic version and pin model IDs for reproducible agent runs.

## Installation

```bash
pip install "constaia~=0.2.0"
```

## Quick start

```python
from constaia import Config, Agent, ModelProfile, ToolSpec

profile = ModelProfile(provider="openai", model="gpt-4o-mini", temperature=0.2)

lookup = ToolSpec(
    name="lookup_order",
    description="Fetch an order by ID.",
    parameters={"order_id": {"type": "string", "required": True}},
)

agent = Agent(
    name="support-triage",
    system_prompt="Triage incoming tickets and route by urgency.",
    model=profile,
    tools=[lookup],
)

config = Config(agents=[agent], version="1.4.0")
constaia.validate(config)

print(constaia.diff(prev_config, config))  # human-readable changelog
constaia.deploy(config)  # push to the Constaia platform
```

## API

- `Config(*, agents: list[Agent], version: str) -> Config` — root config object; serialise with `.to_json()` / `.to_yaml()`.
- `Agent(name, system_prompt, model, tools=None)` — a single agent definition with model profile and tools.
- `constaia.validate(config: Config) -> None` — schema-validates a config; raises `ConfigError` on violations.
- `constaia.diff(a: Config, b: Config) -> str` — returns a structured changelog between two config versions.
- `constaia.load(source: str | Path) -> Config` — loads a config from a JSON/YAML file or platform URL.

## Configuration

- `CONSTAIA_API_TOKEN` — token used by `constaia.deploy()` and `constaia.load()` to talk to the Constaia platform.
- `CONSTAIA_PROFILE` — one of `openai`, `anthropic`, `oss` to scope the default model profiles.

## License

MIT
