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

@dzhng/claude-agent

v0.2.0

Published

Client library for Claude Agent Server with E2B sandbox support

Readme

@claude-agent/client

A TypeScript client library for connecting to Claude Agent Server with E2B sandbox support.

Installation

npm install @dzhng/claude-agent
# or
yarn add @dzhng/claude-agent
# or
bun add @dzhng/claude-agent

Usage

Basic Example

import { ClaudeAgentClient } from '@dzhng/claude-agent'

const client = new ClaudeAgentClient({
  e2bApiKey: process.env.E2B_API_KEY,
  anthropicApiKey: process.env.ANTHROPIC_API_KEY,
  debug: true,
})

// Start the client (creates E2B sandbox and connects)
await client.start()

// Listen for messages from the agent
client.onMessage(message => {
  console.log('Received:', message)
})

// Send a message to the agent
client.send({
  type: 'user_message',
  data: { content: 'Hello, Claude!' },
})

// Clean up when done
await client.stop()

Use a Custom E2B Template

const client = new ClaudeAgentClient({
  template: 'my-custom-template', // Your custom E2B template name
  e2bApiKey: process.env.E2B_API_KEY,
  anthropicApiKey: process.env.ANTHROPIC_API_KEY,
})

await client.start()

API Reference

ClaudeAgentClient

Constructor Options

interface ClientOptions {
  // Required (unless using environment variables)
  anthropicApiKey?: string
  e2bApiKey?: string

  // Configuration
  template?: string // E2B template name, defaults to 'claude-agent-server'
  timeoutMs?: number // Sandbox timeout, defaults to 5 minutes
  debug?: boolean // Enable debug logging

  // Query Configuration (passed to server)
  agents?: Record<string, AgentDefinition>
  allowedTools?: string[]
  systemPrompt?:
    | string
    | { type: 'preset'; preset: 'claude_code'; append?: string }
  model?: string
}

Methods

  • async start() - Initialize the client and connect to the server
  • send(message: WSInputMessage) - Send a message to the agent
  • onMessage(handler: (message: WSOutputMessage) => void) - Register a message handler (returns unsubscribe function)
  • async writeFile(path, content) - Write a file (string or Blob) to the sandbox
  • async readFile(path, format) - Read a file as 'text' or 'blob'
  • async removeFile(path) - Delete a file or directory
  • async listFiles(path?) - List directory contents
  • async stop() - Disconnect and clean up resources

Message Types

import type {
  AgentDefinition,
  SDKMessage,
  SDKUserMessage,
} from '@anthropic-ai/claude-agent-sdk'

// Input messages you can send
type WSInputMessage =
  | { type: 'user_message'; data: SDKUserMessage }
  | { type: 'interrupt' }

// Output messages you'll receive
type WSOutputMessage =
  | { type: 'connected' }
  | { type: 'sdk_message'; data: SDKMessage }
  | { type: 'error'; error: string }
  | { type: 'info'; data: string }

Environment Variables

  • E2B_API_KEY - Your E2B API key (required)
  • ANTHROPIC_API_KEY - Your Anthropic API key (required)

License

MIT