Metadata-Version: 2.4
Name: sigmodx-integrations
Version: 0.2.0
Summary: Agent framework integrations for Sigmodx audit infrastructure
Project-URL: Homepage, https://sigmodx.com
Project-URL: Documentation, https://sigmodx.com/docs/agent-api
Project-URL: Repository, https://github.com/Sigmodx/integrations-python
Project-URL: Bug Tracker, https://github.com/Sigmodx/integrations-python/issues
License: MIT
License-File: LICENSE
Keywords: ai-agents,audit,compliance,cryptographic-attestation,langchain,langgraph,sigmodx,sox
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Requires-Dist: langchain-core>=0.2.0
Requires-Dist: sigmodx>=0.3.0
Provides-Extra: all
Requires-Dist: langchain-core>=0.2.0; extra == 'all'
Requires-Dist: langgraph>=0.2.0; extra == 'all'
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.2.0; extra == 'langchain'
Provides-Extra: langgraph
Requires-Dist: langchain-core>=0.2.0; extra == 'langgraph'
Requires-Dist: langgraph>=0.2.0; extra == 'langgraph'
Description-Content-Type: text/markdown

# sigmodx-integrations

Agent framework integrations for [Sigmodx](https://sigmodx.com) —
audit infrastructure for AI agents making consequential decisions.

## Installation

```bash
pip install sigmodx-integrations
```

## LangChain (Live)

Register one callback. Every agent tool call is automatically logged
to Sigmodx with cryptographic attestation.

```python
from sigmodx import SigmodxClient
from sigmodx_integrations import SigmodxCallbackHandler, ANOMALY_DETECTION_CONFIG

client = SigmodxClient(
    api_key="your-api-key",
    agent_id="your-agent-uuid",
)

handler = SigmodxCallbackHandler(
    client=client,
    config=ANOMALY_DETECTION_CONFIG,
)

result = agent_executor.invoke(
    {"input": "Check transaction TXN-2026-4421"},
    config={"callbacks": [handler]},
)
```

The handler:

- Hashes tool inputs client-side (your data never leaves your environment)
- Extracts decision type, rationale, and metadata from tool output
- Submits the decision to Sigmodx's append-only audit trail
- Never blocks agent execution — errors are logged, not raised

## LangGraph (Live)

Two integration patterns — use whichever fits your graph structure.

### Pattern 1: Stream event handler (recommended)

Process events from `.astream_events()` to log all tool calls
automatically.

```python
from sigmodx import SigmodxClient
from sigmodx_integrations.langgraph import (
    SigmodxLangGraphCallback,
    LANGGRAPH_ANOMALY_CONFIG
)

client = SigmodxClient(api_key="...", agent_id="...")
handler = SigmodxLangGraphCallback(
    client=client,
    config=LANGGRAPH_ANOMALY_CONFIG
)

# Process stream events
async for event in graph.astream_events(inputs, version="v2"):
    await handler.aprocess_event(event)

# Or process synchronously
for event in graph.stream(inputs):
    handler.process_event(event)
```

### Pattern 2: Node decorator

Wrap specific decision-making nodes directly.

```python
from sigmodx_integrations.langgraph import (
    sigmodx_node,
    LANGGRAPH_ANOMALY_CONFIG
)

@sigmodx_node(client=client, config=LANGGRAPH_ANOMALY_CONFIG)
def analyze_transaction(state: dict) -> dict:
    # your existing node logic
    return {
        "decision": "flag",
        "rationale": "Amount 3x historical average.",
        "anomaly_subtype": "unusual_amount",
        "severity": "high",
        "transaction_amount": state["amount"]
    }

graph.add_node("analyze_transaction", analyze_transaction)
```

### Installation

```bash
pip install "sigmodx-integrations[langgraph]"
# or
pip install sigmodx-integrations langgraph
```

## Custom scenario mapping

```python
from sigmodx_integrations import SigmodxCallbackHandler, ScenarioConfig

config = ScenarioConfig(
    scenario="invoice_approval",
    filter_tools=["approve_invoice", "reject_invoice"],
    decision_type_extractor=lambda output: output.get("decision"),
    rationale_extractor=lambda output: output.get("reason"),
    metadata_extractor=lambda output: {
        "invoice_amount": output.get("amount"),
        "vendor_id": output.get("vendor_id"),
    },
)

handler = SigmodxCallbackHandler(client=client, config=config)
```

## Universal adapter (any framework)

```python
from sigmodx_integrations import SigmodxAdapter

adapter = SigmodxAdapter(client=client, scenario="anomaly_detection")

adapter.log(
    inputs={"txn_ref": "TXN-001", "amount": 5000},
    decision_type="flag",
    rationale="Amount 3x historical average.",
    anomaly_subtype="unusual_amount",
    severity="high",
    transaction_amount=5000,
)
```

## Supported frameworks

| Framework | Status |
|-----------|--------|
| LangChain | Live |
| LangGraph | Live |
| Universal adapter | Live |
| AutoGen | Coming soon |
| CrewAI | Coming soon |
| OpenAI Agents SDK | Coming soon |
| Semantic Kernel | Coming soon |

Request framework prioritization:
[github.com/Sigmodx/integrations-python/issues](https://github.com/Sigmodx/integrations-python/issues)

## Links

- [Sigmodx](https://sigmodx.com)
- [Agent API reference](https://sigmodx.com/docs/agent-api)
- [GitHub](https://github.com/Sigmodx/integrations-python)
