Metadata-Version: 2.4
Name: langchain-kredo
Version: 0.2.0
Summary: LangChain integration for the Kredo agent attestation protocol
Project-URL: Homepage, https://aikredo.com
Project-URL: Repository, https://github.com/jimmotes2024/kredo
Project-URL: Documentation, https://aikredo.com
Author: Jim Motes, Vanguard
License-Expression: MIT
License-File: LICENSE
Keywords: agents,attestation,ed25519,kredo,langchain,trust
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Requires-Dist: kredo>=0.4.0
Requires-Dist: langchain-core<1.0.0,>=0.3.0
Provides-Extra: dev
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Description-Content-Type: text/markdown

# langchain-kredo

LangChain integration for the [Kredo](https://aikredo.com) agent attestation protocol.

One line of code. Signed attestation. Done.

## Install

```bash
pip install langchain-kredo
```

## One-Liner

```python
from langchain_kredo import attest

# That's it. Resolves name, looks up skill, signs, submits.
attest("jim", "incident-triage", "Triaged 3 incidents correctly in SOC exercise")

# With a URL — auto-detected as evidence artifact
attest("jim", "code-review", "https://github.com/org/repo/pull/47")

# With explicit proficiency (1-5, default 3)
attest("jim", "threat-hunting", "Found lateral movement in 4 minutes", proficiency=5)
```

Set `KREDO_PRIVATE_KEY` env var (hex seed) and go. Subject resolved by name or pubkey. Skill resolved by reverse taxonomy lookup — just say `"incident-triage"`, it finds the domain.

## Trust Gate

Policy enforcement for agent pipelines:

```python
from langchain_kredo import KredoSigningClient, KredoTrustGate

client = KredoSigningClient(signing_key="your-hex-seed")
gate = KredoTrustGate(client, min_score=0.3, block_warned=True)

# Check trust
result = gate.check("ed25519:agent-pubkey")
# result.passed, result.score, result.skills, result.attestor_count

# Select best agent for a task (ranks by reputation + diversity + domain proficiency)
best = gate.select_best(candidates, domain="security-operations", skill="incident-triage")

# Build-vs-buy: delegate or self-compute?
delegate = gate.should_delegate(candidates, domain="code-generation", self_proficiency=2)

# Decorator
@gate.require(min_score=0.7)
def sensitive_operation(pubkey: str):
    ...
```

## LangChain Tools

Four tools for agent toolboxes:

```python
from langchain_kredo import KredoCheckTrustTool, KredoSearchAttestationsTool

tools = [
    KredoCheckTrustTool(client=client),
    KredoSearchAttestationsTool(client=client),
]
```

| Tool | Name | Purpose |
|------|------|---------|
| `KredoCheckTrustTool` | `kredo_check_trust` | Check agent reputation + skills + warnings |
| `KredoSearchAttestationsTool` | `kredo_search_attestations` | Find agents by skill/domain/proficiency |
| `KredoSubmitAttestationTool` | `kredo_submit_attestation` | Sign and submit skill attestation |
| `KredoGetTaxonomyTool` | `kredo_get_taxonomy` | Browse valid domains/skills |

## Callback Handler

Tracks chain execution, builds attestation evidence automatically:

```python
from langchain_kredo import KredoCallbackHandler

handler = KredoCallbackHandler()
chain.invoke(input, config={"callbacks": [handler]})

for record in handler.get_records():
    if record.success_rate >= 0.9:
        client.attest_skill(
            subject_pubkey="ed25519:...",
            domain="security-operations",
            skill="incident-triage",
            proficiency=3,
            context=record.build_evidence_context(),
            artifacts=record.build_artifacts(),
        )
```

Collects evidence but never auto-submits. You decide when and what to attest.

## Client

Full signing-aware client for when you need more control:

```python
client = KredoSigningClient(
    signing_key=sk,           # SigningKey, bytes, hex string, or env var
    name="my-agent",
    agent_type="agent",
)

# Read
profile = client.get_profile("ed25519:...")
my_profile = client.my_profile()  # your own profile
results = client.search(domain="security-operations")

# Write
client.register()
client.attest_skill(
    subject_pubkey="ed25519:...",
    domain="security-operations",
    skill="incident-triage",
    proficiency=4,
    context="Demonstrated expert-level triage in SOC exercise",
)
```

## Development

```bash
cd langchain-kredo
pip install -e ".[dev]"
pytest tests/ -v  # 82 tests
```

## License

MIT
