Metadata-Version: 2.4
Name: managed-agents
Version: 0.2.0
Summary: Nomotic governance for AI agents. Works with Claude, LangChain, CrewAI, AutoGen, OpenAI, or any custom framework.
Project-URL: Homepage, https://nomotic.ai
Project-URL: Documentation, https://nomotic.ai/docs/integrations/sdk-quickstart
Project-URL: Repository, https://github.com/nomoticai/managed-agents
Project-URL: Issue Tracker, https://github.com/nomoticai/managed-agents/issues
Project-URL: Changelog, https://github.com/nomoticai/managed-agents/blob/main/CHANGELOG.md
License: MIT
Keywords: ai-agents,autogen,claude,crewai,governance,langchain,llm,managed-agents,nomotic,openai
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27.0
Provides-Extra: dev
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-asyncio; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: respx; extra == 'dev'
Description-Content-Type: text/markdown

# managed-agents

Nomotic governance for AI agents. Works with any framework.

Govern every tool call before it reaches execution. DENY verdicts block
the action. ESCALATE routes to human review. Every evaluation is recorded
in your Nomotic audit trail.

## Install

```
pip install managed-agents
```

## Quick Start

```python
from managed_agents import NomoticHarness, GovernanceDenied

harness = NomoticHarness(
    api_key="nm_live_...",    # from amp.nomotic.ai/settings
    agent_id="nmc-...",       # from amp.nomotic.ai/identity
    platform="langchain",     # tags evaluations in your audit trail
)

async def execute_tool(tool_name: str, tool_input: dict) -> str:
    await harness.govern(tool_name, tool_input)
    return await your_runtime.execute(tool_name, tool_input)

try:
    await execute_tool("write_file", {"path": "/etc/passwd", "content": "..."})
except GovernanceDenied as e:
    print(f"Blocked: {e}")
```

## With Prescreening

Block destructive patterns before they reach the governance API:

```python
from managed_agents import NomoticHarness, StandardPrescreener

harness = NomoticHarness(
    api_key="nm_live_...",
    agent_id="nmc-...",
    prescreener=StandardPrescreener(
        block_destructive_shell=True,    # rm -rf, DROP TABLE, mkfs, fork bombs
        block_bulk_operations=True,      # >10 emails, >20 files, >5 calendar items
        escalate_credential_access=True, # .ssh/, .env, /etc/passwd
    ),
)
```

## With Policy Presets

```python
from managed_agents import NomoticHarness, ToolPolicy

harness = NomoticHarness(
    api_key="nm_live_...",
    agent_id="nmc-...",
    policy=ToolPolicy.SHELL,       # trust_threshold=0.85, veto: scope+ethics
    # policy=ToolPolicy.FILESYSTEM # trust_threshold=0.75, veto: reversibility
    # policy=ToolPolicy.EMAIL      # trust_threshold=0.70, veto: data_sensitivity
)
```

## Sync Usage

```python
result = harness.govern_sync("bash", {"command": "ls -la"})
```

## Without an API Key

No api_key → pass-through mode. Prescreener still blocks dangerous patterns.
Verdicts logged locally to ~/.nomotic/managed-agents.log.

After 10 evaluations, a nudge suggests registering at amp.nomotic.ai
for full governance, audit trail, trust scores, and fleet management.

```python
harness = NomoticHarness(agent_id="local-agent")  # no api_key
```

## Framework Support

```python
platform="claude"      # Claude Managed Agents
platform="langchain"   # LangChain / LangGraph
platform="crewai"      # CrewAI
platform="autogen"     # AutoGen
platform="openai"      # OpenAI SDK / Assistants API
platform="custom"      # Any other framework
```

## Session Correlation

```python
from managed_agents import NomoticHarness, GovernedSession

harness = NomoticHarness(api_key="...", agent_id="...")
session = GovernedSession(session_id="sess_abc123", harness=harness)

verdict = await session.govern_and_record("send_email", {"to": "user@example.com"})
print(session.governance_summary())
```

## Configuration

| Parameter          | Default    | Description                                     |
|--------------------|------------|-------------------------------------------------|
| api_key            | None       | Nomotic API key. None = pass-through mode       |
| agent_id           | required   | Nomotic agent ID (nmc-...)                      |
| platform           | "custom"   | Framework tag for audit trail                   |
| fail_open          | True       | Allow on governance service error               |
| block_on_escalate  | False      | Raise GovernanceEscalated on ESCALATE           |
| timeout            | 3.0        | HTTP timeout in seconds                         |
| prescreener        | None       | Pre-evaluation deterministic checks             |
| policy             | None       | Governance policy preset                        |
| tool_name_map      | None       | Custom tool name → action verb overrides        |
| circuit_breaker    | None       | CircuitBreaker for API resilience               |
| local_log          | True       | Log verdicts to ~/.nomotic/managed-agents.log   |
| suppress_nudge     | False      | Suppress amp.nomotic.ai registration nudge      |
| on_verdict         | None       | Callback for every verdict                      |
| on_escalate        | None       | Callback for ESCALATE verdicts                  |
| on_deny            | None       | Callback for DENY verdicts                      |
| session_id         | None       | Session ID for multi-turn correlation           |
| org_context        | {}         | Additional context injected into evaluations    |

## Links

- [Nomotic Platform](https://amp.nomotic.ai)
- [Documentation](https://nomotic.ai/docs/integrations/sdk-quickstart)
- [GitHub](https://github.com/nomoticai/managed-agents)
