Metadata-Version: 2.4
Name: open-agent-compiler
Version: 0.1.1
Summary: Python-first agent framework that compiles agent definitions into backend-specific configurations
Project-URL: Homepage, https://github.com/DehydratedWater/OpenAgentCompiler
Project-URL: Repository, https://github.com/DehydratedWater/OpenAgentCompiler
Project-URL: Issues, https://github.com/DehydratedWater/OpenAgentCompiler/issues
Author: Ignacy Daszkiewicz
License: MIT License
        
        Copyright (c) 2026 Ignacy Daszkiewicz
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: agent,ai,compiler,framework,llm,opencode
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
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>=2.0
Requires-Dist: python-dotenv
Provides-Extra: bench
Requires-Dist: pytest-benchmark>=4; extra == 'bench'
Provides-Extra: dev
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pre-commit>=3; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Provides-Extra: testing
Requires-Dist: httpx>=0.27; extra == 'testing'
Description-Content-Type: text/markdown

# OpenAgentCompiler

Python-first agent framework that compiles agent definitions into backend-specific configurations for [OpenCode](https://github.com/opencode-ai/opencode) agents.

## Installation

```bash
pip install open-agent-compiler
```

Or with [uv](https://docs.astral.sh/uv/):

```bash
uv add open-agent-compiler
```

For local/editable development:

```bash
uv add --editable ../OpenAgentCompiler
```

## Quick start

```python
from open_agent_compiler.builders import AgentBuilder, ConfigBuilder, ToolBuilder
from open_agent_compiler.compiler import compile_agent
from open_agent_compiler.writers import OpenCodeWriter
from open_agent_compiler._types import (
    ModelConfig, ModelOptions, ProviderConfig, ProviderOptions,
)

# Define a tool
search = (
    ToolBuilder()
    .name("file-search")
    .description("Search files by glob pattern")
    .from_script("scripts/file_search.py")
    .build()
)

# Configure the model
config = (
    ConfigBuilder()
    .provider(ProviderConfig(
        name="anthropic",
        options=ProviderOptions(api_key="env:ANTHROPIC_API_KEY"),
        models=(ModelConfig(
            name="sonnet",
            id="claude-sonnet-4-5-20250929",
            options=ModelOptions(temperature=0.0),
        ),),
    ))
    .default_model("anthropic/sonnet")
    .build()
)

# Build the agent
agent = (
    AgentBuilder()
    .name("my-agent")
    .description("My custom agent")
    .config(config)
    .tool(search)
    .system_prompt("You are a helpful assistant.")
    .build()
)

# Compile and write to disk
compiled = compile_agent(agent, target="opencode")
OpenCodeWriter(output_dir="build/").write(compiled)
```

## Architecture

```
Builder -> AgentDefinition -> Compiler -> backend dict -> Writer -> disk -> Manager -> external process
```

- **Builders** -- Fluent API classes that produce immutable data types via `.build()`
- **Compiler** -- Transforms an `AgentDefinition` into a backend-specific dict
- **Writers** -- Persist compiled dicts to disk (project files, configs, scripts)
- **Managers** -- Async lifecycle managers that deploy/invoke/teardown agents

## Development

```bash
uv sync --all-extras      # install with dev + bench deps
uv run pytest tests/ -v   # run all tests
uv run ruff check .       # lint
uv run mypy               # type check
```

## Python version

Requires Python 3.12+.

## License

See [LICENSE](LICENSE) for details.
