<!-- SPDX-License-Identifier: Apache-2.0 -->
**Status:** stable · **Owner:** Developer Relations · **License:** Apache-2.0

# `langchain` — KYE adapter for LangChain

A thin LangChain [`BaseCallbackHandler`](https://js.langchain.com/docs/concepts/callbacks)
that emits the KYE governance + evidence envelopes around every chain / agent
run. Register it on your existing chain — the chain is unchanged.

```ts
import { KyeCallbackHandler } from "./src/adapter.js";
await chain.invoke(input, { callbacks: [new KyeCallbackHandler()] });
```

- `handleChainStart` → `kye.agent.governance.v1` (the §52 task-start binding).
- `handleToolStart` / `handleLLMStart` → `kye.evidence.tool_call.v1` per step.
- `handleChainEnd` → `kye.agent.completion.v1` (the task-end ledger).

## Non-competition lock (§0 / §0.30 / §32 — permanent)

KYE **governs** the LangChain run as a first-class principal; it does **NOT**
run, replace, or vendor LangChain. `langchain` is a peer dependency, referenced
as an integration point only. The non-competition lock vs LangChain (and
LlamaIndex / CrewAI / Firecrawl / CocoIndex / OpenAI Agents SDK / Claude Agent
SDK) is permanent.

## Reuses the canonical envelope

Same three envelopes as
[`governed-agent`](../../agent-dev-kit-templates/governed-agent/README.md) (§32)
— no new envelope is invented. Reference shapes:
[`public/examples/agent-governance/`](../../../examples/agent-governance/).

## Files

- `src/adapter.ts` — the `KyeCallbackHandler`.
