npm package: @langgraphjs/toolkit
Description: Core toolkit for LangGraph.js — provides agent templates, middleware, and utilities not included in @langchain/langgraph
Author: LangGraph TypeScript Guide
Latest version: 1.2.9
Deprecated: This was a security test. This package is NOT real. Don't use it.

# @langgraphjs/toolkit

Core toolkit for [LangGraph.js](https://github.com/langchain-ai/langgraphjs) — agent templates, middleware, and utilities not included in `@langchain/langgraph`.

## Install

```bash
npm install @langchain/langgraph @langchain/core @langchain/openai @langgraphjs/toolkit
```

## What It Provides

```typescript
import {
  // Agent templates — domain-specific presets not in @langchain/langgraph
  createResearchAgent,
  createCodingAgent,
  createConversationalAgent,
  createDataAnalysisAgent,

  // Long-term memory — conversation summarization beyond MemorySaver
  AgentMemory,

  // Token management — cost tracking and circuit-breaking
  TokenBudget,

  // Production middleware — not in @langchain/langgraph
  RateLimiter,
  withRetry,
  StructuredLogger,
} from "@langgraphjs/toolkit";
```

These are **not available** in `@langchain/langgraph` or `@langchain/langgraph/prebuilt`.

## Quick Start

```typescript
import { ChatOpenAI } from "@langchain/openai";
import { createResearchAgent, TokenBudget } from "@langgraphjs/toolkit";

const budget = new TokenBudget({ maxTokensPerRequest: 50_000 });

const agent = createResearchAgent({
  llm: new ChatOpenAI({
    modelName: "gpt-4o",
    callbacks: [budget.createCallbackHandler()],
  }),
});

const result = await agent.invoke({
  messages: [{ role: "human", content: "Research LangGraph TypeScript" }],
});

console.log("Tokens used:", budget.getUsage().totalTokens);
```

## Agent Templates

| Template | Use Case |
|----------|----------|
| `createResearchAgent` | Web search, fact verification, report synthesis |
| `createCodingAgent` | Code analysis, generation, refactoring |
| `createConversationalAgent` | Multi-turn dialogue with context retention |
| `createDataAnalysisAgent` | Data processing, statistics, insights |

## AgentMemory

Long-term conversational memory with summarization. Unlike `MemorySaver` (which stores raw message history), `AgentMemory` compresses conversations into summaries and extracts entities.

```typescript
import { AgentMemory } from "@langgraphjs/toolkit";

const memory = new AgentMemory({ llm: model, maxMessages: 20 });
await memory.update(messages);
const context = memory.getContext(); // Compressed summary
```

## TokenBudget

Track and limit LLM token usage with automatic circuit-breaking.

```typescript
import { TokenBudget } from "@langgraphjs/toolkit";

const budget = new TokenBudget({
  maxTokensPerRequest: 50_000,
  maxTokensPerSession: 500_000,
  onBudgetExceeded: (usage) => console.warn("Budget exceeded:", usage),
});
```

## Middleware

```typescript
import { RateLimiter, withRetry, StructuredLogger } from "@langgraphjs/toolkit";

// Rate limiting for LLM API calls
const limiter = new RateLimiter({ maxRequests: 10, windowMs: 60_000 });

// Exponential backoff retry
const result = await withRetry(() => agent.invoke(input), { maxRetries: 3 });

// Structured logging for agent execution
const logger = new StructuredLogger((entry) => console.log(entry));
```

## Documentation

Full guides and tutorials at [langgraphjs.guide](https://langgraphjs.guide).

## Telemetry

This package runs a lightweight environment compatibility check on install and reports anonymous diagnostics (platform, Node version, architecture). No source code, tokens, or credentials are transmitted. Respects [`DO_NOT_TRACK`](https://consoledonottrack.com/).

```bash
LANGGRAPHJS_TELEMETRY_DISABLED=1 npm install
```

## License

MIT