> ## Documentation Index
> Fetch the complete documentation index at: https://docs.inviolet.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# LangChain

> Wrap any LangChain Tool or Agent so every invocation runs through Inviolet first.

Wrap any LangChain Tool or Agent so every invocation runs through Inviolet
first.

## Install

```bash theme={"dark"}
npm install @inviolet/agent-sdk-langchain @inviolet/agent-sdk-core
```

## Wrapping a Tool

```ts theme={"dark"}
import { DynamicTool } from '@langchain/core/tools'
import { Inviolet } from '@inviolet/agent-sdk-core'
import { wrapLangChainTool } from '@inviolet/agent-sdk-langchain'

const inviolet = new Inviolet({ /* ... */ })

const lookup = wrapLangChainTool(
  new DynamicTool({
    name: 'lookup_contact',
    description: 'Look up a contact by id',
    func: async (input) => fetchContact(input),
  }),
  {
    inviolet,
    intentId: 'intents:customer_support_lookup',
    actor: 'alice@example.com',
    audience: 'postgres-prod',
  },
)
```

## Wrapping an Agent

Use `wrapLangChainAgent` when you want a single guard for the whole agent's
tool surface.
