Metadata-Version: 2.4
Name: nerq-langchain
Version: 0.2.0
Summary: Trust-gate your LangChain agents with Nerq. Preflight trust checks, agent discovery, and trust scoring for 204K+ AI agents.
Author-email: Nerq <hello@zarq.ai>
License-Expression: MIT
Project-URL: Homepage, https://nerq.ai
Project-URL: Documentation, https://nerq.ai/docs/langchain
Project-URL: Repository, https://github.com/zarqai/nerq-langchain
Project-URL: API Docs, https://nerq.ai/nerq/docs
Keywords: nerq,langchain,trust,agents,mcp,preflight,trust-score
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: langchain-core>=0.1.0
Requires-Dist: requests>=2.28.0

# nerq-langchain

Trust-gate your LangChain agents with [Nerq](https://nerq.ai). Preflight trust checks before every tool call.

## Install

```bash
pip install nerq-langchain
```

## Quick Start — trust_gate (3 lines)

```python
from nerq_langchain import trust_gate

agent = initialize_agent(tools, llm)
agent = trust_gate(agent, min_trust=60)
# Every tool call now gets a preflight trust check
```

Before each tool call, `trust_gate` checks the tool's trust score via `nerq.ai/v1/preflight`:

- **PROCEED** (trust >= 70): runs silently
- **CAUTION** (trust 40-69): logs warning, proceeds
- **DENY** (trust < 40): raises `TrustError`
- **UNKNOWN** (not in index): proceeds with warning
- **Network failure**: proceeds with warning (never blocks)

## NerqPreflight — Check trust on any agent

```python
from nerq_langchain import NerqPreflight

tool = NerqPreflight()
print(tool.run("SWE-agent"))
# Nerq Preflight: SWE-agent
# Recommendation: PROCEED
# Trust Score: 92.5/100
# Grade: A+
# Verified: Yes
```

## NerqSearch — Find agents for a task

```python
from nerq_langchain import NerqSearch

tool = NerqSearch()
print(tool.run("code review"))
# Nerq Search: 'code review' — 5 results
# 1. SWE-agent/SWE-agent — Trust: 92.5, Category: security
# ...
```

## In a LangChain agent

```python
from langchain_openai import ChatOpenAI
from langchain.agents import initialize_agent, AgentType
from nerq_langchain import NerqPreflight, NerqSearch, trust_gate

llm = ChatOpenAI(model="gpt-4")
tools = [NerqPreflight(), NerqSearch()]
agent = initialize_agent(tools, llm, agent=AgentType.OPENAI_FUNCTIONS)
agent = trust_gate(agent, min_trust=60)

result = agent.run("Is SWE-agent safe to use for code review?")
```

## With LangGraph

```python
from nerq_langchain import NerqPreflight, NerqSearch
from langgraph.prebuilt import create_react_agent

tools = [NerqPreflight(), NerqSearch()]
agent = create_react_agent(model, tools)
```

## Error handling

```python
from nerq_langchain import trust_gate, TrustError

agent = trust_gate(agent, min_trust=70)

try:
    result = agent.run("Use low-trust-tool to analyze data")
except TrustError as e:
    print(f"Blocked: {e.tool_name} (trust={e.trust_score})")
```

## API

- **Endpoint**: `GET https://nerq.ai/v1/preflight?target={name}`
- **Auth**: None required
- **Rate limit**: Generous (no hard cap during beta)
- **Coverage**: 204K+ agents and tools
- **Latency**: <50ms typical

## Links

- [nerq.ai](https://nerq.ai) — AI Asset Search Engine
- [API Docs](https://nerq.ai/nerq/docs)
- [Preflight Docs](https://nerq.ai/nerq/docs#preflight)
- [KYA — Know Your Agent](https://nerq.ai/kya)
