Metadata-Version: 2.4
Name: coreason_maco
Version: 0.4.0
Summary: Coreason MACO: A Multi-Agent Collaborative Orchestrator for robust strategic reasoning and graph-based execution.
License: # The Prosperity Public License 3.0.0
         
         Contributor: CoReason, Inc.
         
         Source Code: https://github.com/CoReason-AI/coreason_maco
         
         ## Purpose
         
         This license allows you to use and share this software for noncommercial purposes for free and to try this software for commercial purposes for thirty days.
         
         ## Agreement
         
         In order to receive this license, you have to agree to its rules.  Those rules are both obligations under that agreement and conditions to your license.  Don't do anything with this software that triggers a rule you can't or won't follow.
         
         ## Notices
         
         Make sure everyone who gets a copy of any part of this software from you, with or without changes, also gets the text of this license and the contributor and source code lines above.
         
         ## Commercial Trial
         
         Limit your use of this software for commercial purposes to a thirty-day trial period.  If you use this software for work, your company gets one trial period for all personnel, not one trial per person.
         
         ## Contributions Back
         
         Developing feedback, changes, or additions that you contribute back to the contributor on the terms of a standardized public software license such as [the Blue Oak Model License 1.0.0](https://blueoakcouncil.org/license/1.0.0), [the Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.html), [the MIT license](https://spdx.org/licenses/MIT.html), or [the two-clause BSD license](https://spdx.org/licenses/BSD-2-Clause.html) doesn't count as use for a commercial purpose.
         
         ## Personal Uses
         
         Personal use for research, experiment, and testing for the benefit of public knowledge, personal study, private entertainment, hobby projects, amateur pursuits, or religious observance, without any anticipated commercial application, doesn't count as use for a commercial purpose.
         
         ## Noncommercial Organizations
         
         Use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization, or government institution doesn't count as use for a commercial purpose regardless of the source of funding or obligations resulting from the funding.
         
         ## Defense
         
         Don't make any legal claim against anyone accusing this software, with or without changes, alone or with other technology, of infringing any patent.
         
         ## Copyright
         
         The contributor licenses you to do everything with this software that would otherwise infringe their copyright in it.
         
         ## Patent
         
         The contributor licenses you to do everything with this software that would otherwise infringe any patents they can license or become able to license.
         
         ## Reliability
         
         The contributor can't revoke this license.
         
         ## Excuse
         
         You're excused for unknowingly breaking [Notices](#notices) if you take all practical steps to comply within thirty days of learning you broke the rule.
         
         ## No Liability
         
         ***As far as the law allows, this software comes as is, without any warranty or condition, and the contributor won't be liable to anyone for any damages related to this software or this license, under any kind of legal claim.***
License-File: LICENSE
License-File: NOTICE
Author: Gowtham A Rao
Author-email: gowtham.rao@coreason.ai
Requires-Python: >=3.12, <3.15
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Requires-Dist: aiofiles (>=23.0.0)
Requires-Dist: anyio (>=4.12.1,<5.0.0)
Requires-Dist: coreason-identity (>=0.4.1,<0.5.0)
Requires-Dist: coreason-manifest (>=0.6.0,<0.7.0)
Requires-Dist: fastapi (>=0.128.0,<0.129.0)
Requires-Dist: httpx (>=0.28.1,<0.29.0)
Requires-Dist: jinja2 (>=3.1.6,<4.0.0)
Requires-Dist: loguru (>=0.7.2,<0.8.0)
Requires-Dist: networkx
Requires-Dist: pydantic (>=2.0,<3.0)
Requires-Dist: types-aiofiles (>=23.0.0)
Requires-Dist: uvicorn (>=0.40.0,<0.41.0)
Project-URL: Documentation, https://github.com/CoReason-AI/coreason_maco
Project-URL: Homepage, https://github.com/CoReason-AI/coreason_maco
Project-URL: Repository, https://github.com/CoReason-AI/coreason_maco
Description-Content-Type: text/markdown

# CoReason Runtime Engine ("The General")

**Multi-Agent Collaborative Orchestrator (MACO)**

[![License: Prosperity 3.0](https://img.shields.io/badge/license-Prosperity%203.0-blue)](LICENSE)
[![CI/Status](https://github.com/CoReason-AI/coreason_maco/actions/workflows/ci.yml/badge.svg)](https://github.com/CoReason-AI/coreason_maco/actions)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Documentation](https://img.shields.io/badge/docs-product%20requirements-blue)](docs/product_requirements.md)

## Overview

**`coreason-maco`** is the runtime engine designed to transform AI from a "Chatbot" into a **"Strategic Simulator."** It executes pre-defined, deterministic workflows ("Recipes") where multiple specialized AI agents collaborate, debate, and verify each other's work.

As the **Orchestrator**, it manages a team of specialized agents to:
*   **Break down** complex problems into steps.
*   **Execute** parallel research streams.
*   **Debate** findings using a "Council of Models" (Architectural Triangulation).
*   **Visualize** the entire thought process in real-time.

## Features

*   **"Glass Box" Visualization:** Exposes internal state in real-time. Users can see exactly which agent is working, what data they are accessing, and where they are in the process.
*   **Architectural Triangulation ("The Council"):** Automatically "triangulates" answers by asking three distinct models (e.g., OpenAI, Anthropic, DeepSeek) and having a fourth "Judge" agent synthesize the consensus.
*   **Counterfactual Simulation ("What-If" Analysis):** Allows users to "Fork" the reasoning process to explore different scenarios without losing original data.
*   **GxP Compliance & Determinism:** Ensures workflows are reproducible. Running the same "Recipe" with the same inputs and "Seed" yields the exact same result.
*   **Secure Identity Propagation:** Propagates `UserContext` (Identity Passport) securely to all workers and tools, ensuring "On-Behalf-Of" execution without leaking tokens in UI events.

## Installation

```bash
pip install coreason_maco
```

## Usage

Here is how to initialize and execute a workflow using `coreason-maco`:

```python
import asyncio
from coreason_maco.core.controller import WorkflowController
from coreason_maco.infrastructure.server_defaults import ServerRegistry

# Optional: Import UserContext if available
try:
    from coreason_identity.models import UserContext
except ImportError:
    UserContext = None

async def main():
    # 1. Initialize Services (Dependency Injection)
    services = ServerRegistry()

    # 2. Initialize Controller
    controller = WorkflowController(services=services)

    # 3. Define a Simple Manifest (Recipe)
    manifest = {
        "name": "Simple Greeting",
        "nodes": [
            {"id": "node_1", "type": "LLM", "config": {"prompt": "Say hello!"}}
        ],
        "edges": []
    }

    # 4. Define Inputs
    inputs = {
        "user_id": "test_user",
        "trace_id": "trace_123",
        "secrets_map": {}
    }

    # 5. Execute Workflow
    print("Starting Workflow...")
    # Pass user_context (Optional)
    async for event in controller.execute_recipe(manifest, inputs, user_context=None):
        print(f"Event: {event.event_type} | Node: {event.node_id} | Payload: {event.payload}")

if __name__ == "__main__":
    asyncio.run(main())
```

