npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dupecom/botcha-langchain

v0.1.1

Published

LangChain integration for BOTCHA - make AI agents transparently solve BOTCHA challenges

Downloads

26

Readme

@dupecom/botcha-langchain

LangChain integration for BOTCHA - make AI agents transparently solve BOTCHA challenges.

Installation

npm install @dupecom/botcha-langchain @langchain/core

Features

  • BotchaTool: LangChain Tool for AI agents to solve BOTCHA challenges
  • BotchaRequestWrapper: Automatic challenge solving for HTTP requests
  • TypeScript support with full type definitions
  • Automatic token management and caching
  • Seamless integration with existing LangChain agents

Usage

BotchaTool - For LangChain Agents

Use BotchaTool to give your LangChain agent the ability to solve BOTCHA challenges and access bot-only APIs:

import { BotchaTool } from '@dupecom/botcha-langchain';
import { ChatOpenAI } from '@langchain/openai';
import { createReactAgent } from '@langchain/langgraph/prebuilt';

// Create the BOTCHA tool
const botchaTool = new BotchaTool({
  baseUrl: 'https://api.botcha.ai'
});

// Create your agent with the tool
const agent = createReactAgent({
  llm: new ChatOpenAI({ model: 'gpt-4' }),
  tools: [botchaTool],
});

// The agent can now call the tool to get tokens
// It will understand to use it when encountering BOTCHA-protected APIs
const response = await agent.invoke({
  messages: [{ role: 'user', content: 'Access the bot-only API at https://api.example.com/agent-only' }]
});

BotchaRequestWrapper - For HTTP Requests

Use BotchaRequestWrapper to automatically solve BOTCHA challenges when making HTTP requests:

import { BotchaRequestWrapper } from '@dupecom/botcha-langchain';

const wrapper = new BotchaRequestWrapper({
  baseUrl: 'https://api.botcha.ai'
});

// Automatically solves challenges if needed
const response = await wrapper.fetch('https://protected-api.com/data');
const data = await response.json();

// Get a token for manual use
const token = await wrapper.getToken();

API Reference

BotchaTool

LangChain Tool that enables AI agents to solve BOTCHA challenges.

Options:

interface BotchaToolOptions {
  baseUrl?: string;          // BOTCHA service URL (default: https://botcha.ai)
  agentIdentity?: string;    // Custom User-Agent
  maxRetries?: number;       // Max retry attempts (default: 3)
  autoToken?: boolean;       // Auto token management (default: true)
  name?: string;             // Tool name (default: "botcha_solver")
  description?: string;      // Tool description
}

Methods:

  • invoke(input): Call the tool (used by LangChain agents)
  • getToken(): Get a JWT token directly
  • clearToken(): Clear the cached token

BotchaRequestWrapper

Wraps HTTP requests to automatically handle BOTCHA challenges.

Options:

interface BotchaRequestWrapperOptions {
  baseUrl?: string;          // BOTCHA service URL (default: https://botcha.ai)
  agentIdentity?: string;    // Custom User-Agent
  maxRetries?: number;       // Max retry attempts (default: 3)
  autoToken?: boolean;       // Auto token management (default: true)
  fetchFn?: typeof fetch;    // Custom fetch implementation
}

Methods:

  • fetch(url, init?): Fetch with automatic challenge solving
  • getToken(): Get a JWT token
  • clearToken(): Clear the cached token
  • createHeaders(): Get headers with challenge solution

How It Works

  1. Token-Based Auth (Recommended): Automatically acquires JWT tokens from the BOTCHA service
  2. Challenge Header Method: Falls back to solving challenges via HTTP headers if needed
  3. Automatic Retry: Retries failed requests with solved challenges
  4. Token Caching: Caches tokens until near expiry (55 minutes)

Examples

React Agent with BOTCHA

import { BotchaTool } from '@dupecom/botcha-langchain';
import { ChatAnthropic } from '@langchain/anthropic';
import { createReactAgent } from '@langchain/langgraph/prebuilt';

const agent = createReactAgent({
  llm: new ChatAnthropic({ model: 'claude-3-sonnet' }),
  tools: [
    new BotchaTool({ baseUrl: 'https://api.botcha.ai' }),
    // ... other tools
  ],
});

const result = await agent.invoke({
  messages: [{ 
    role: 'user', 
    content: 'Get data from the bot-only endpoint at https://api.example.com/agents/data' 
  }]
});

Custom Fetch Wrapper

import { BotchaRequestWrapper } from '@dupecom/botcha-langchain';

const wrapper = new BotchaRequestWrapper({
  baseUrl: 'https://api.botcha.ai',
  agentIdentity: 'MyAgent/1.0',
  maxRetries: 5,
});

async function fetchProtectedData(endpoint: string) {
  const response = await wrapper.fetch(`https://api.example.com${endpoint}`);
  
  if (!response.ok) {
    throw new Error(`Request failed: ${response.status}`);
  }
  
  return await response.json();
}

const data = await fetchProtectedData('/agent-only');

License

MIT

Links