Metadata-Version: 2.4
Name: pfc-langchain
Version: 0.1.0
Summary: Thin LangChain adapter for PFC execution-boundary decisions
License: MIT
Keywords: pfc,langchain,governance,agents,integration
Author: Dan Evans
Requires-Python: >=3.9,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: pfc-core (>=0.1.0,<0.2.0)
Project-URL: Homepage, https://example.com/pfc-integrations
Project-URL: Repository, https://example.com/pfc-integrations
Description-Content-Type: text/markdown

# pfc-langchain

`pfc-langchain` is a thin execution-boundary wrapper for LangChain-style tools.
It asks PFC for a decision before the wrapped callable runs, then returns the tool
result together with PFC decision metadata.

## What It Does

- Wraps a callable tool with a PFC pre-execution decision
- Preserves a simple callable interface
- Returns the tool result, decision id, and receipt hash in one response

## Install

From this monorepo:

```bash
pip install -e ./packages/pfc_core
pip install -e ./packages/pfc_langchain
```

## Quick Start

```python
from pfc_langchain import GovernedTool


class EchoTool:
    name = "echo"
    description = "Return the provided value"

    def __call__(self, value):
        return {"echo": value}


tool = GovernedTool(
    EchoTool(),
    policy_id="policy-123",
    pfc_api_key="pfc_test_key",
)

result = tool(value="hello")
print(result)
```

## How It Works

1. `GovernedTool` builds a PFC execution payload from the wrapped tool call.
2. It sends that payload to PFC before the tool executes.
3. If PFC allows the action, the tool runs and the wrapper returns `result`,
   `decision_id`, and `receipt`.
4. If PFC blocks the action, the wrapped tool is not executed.

## Failure Behavior

- If the wrapped object is not callable, `GovernedTool` raises `TypeError`.
- If PFC returns a blocking decision, `pfc_core.middleware.PFCBlockedError` is raised.
- If the PFC API request fails, the underlying PFC client raises an exception.

## Limitations

- This package is intentionally thin and does not manage prompts, chains, or policies.
- It treats the wrapped object as a generic callable rather than depending on
  specific LangChain internals.
- Positional arguments are represented in the PFC payload under an `args` list.

