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

@chucky.cloud/sdk

v0.3.3

Published

Universal TypeScript SDK for Chucky - build Claude-powered AI assistants for browser and Node.js

Readme

@chucky.cloud/sdk

npm version License: MIT TypeScript Node.js

Universal TypeScript SDK for Chucky - build Claude-powered AI assistants for browser and Node.js.

Installation

npm install @chucky.cloud/sdk

Quick Start

import { ChuckyClient, tool, createBudget, createToken } from '@chucky.cloud/sdk';

// Server-side: Create a token for your user
const token = await createToken({
  userId: 'user-123',
  projectId: 'your-project-uuid',
  secret: 'your-hmac-secret',
  budget: createBudget({
    aiDollars: 1.00,
    computeHours: 1,
    window: 'day',
  }),
});

// Create client with the token
const client = new ChuckyClient({ token });

// Create a session
const session = await client.createSession({
  model: 'claude-sonnet-4-5-20250929',
});

// Send a message and get response
const result = await session.send('Hello, world!');
console.log(result.text);

Features

  • Browser & Node.js Support: Same API works in both environments
  • Sessions: Multi-turn conversations with state persistence
  • One-shot Prompts: Stateless prompt execution
  • Tools: Define custom tools with full type safety
  • Streaming: Real-time response streaming
  • Token Management: Create and verify JWT tokens

Sessions

Creating a Session

const session = await client.createSession({
  model: 'claude-sonnet-4-5-20250929',
  systemPrompt: 'You are a helpful assistant.',
  maxTurns: 10,
});

const result = await session.send('What is 2 + 2?');
console.log(result.text); // "4"

// Multi-turn conversation
const followUp = await session.send('And what is that times 3?');
console.log(followUp.text); // "12"

Resuming a Session

const session = await client.resumeSession('session-123', {
  continue: true,
});

Streaming Responses

for await (const event of session.sendStream('Tell me a story')) {
  if (event.type === 'text') {
    process.stdout.write(event.text);
  } else if (event.type === 'tool_use') {
    console.log('Using tool:', event.name);
  }
}

Tools

Defining Tools

import { tool, textResult } from '@chucky.cloud/sdk';

const weatherTool = tool(
  'get_weather',
  'Get current weather for a city',
  {
    type: 'object',
    properties: {
      city: { type: 'string', description: 'City name' },
      unit: { type: 'string', enum: ['celsius', 'fahrenheit'] },
    },
    required: ['city'],
  },
  async ({ city, unit }) => textResult(`Weather in ${city}: Sunny, 72°${unit === 'celsius' ? 'C' : 'F'}`)
);

const session = await client.createSession({
  tools: [weatherTool],
});

Browser Tools

Tools that execute in the browser:

import { browserTool } from '@chucky.cloud/sdk';

const alertTool = browserTool({
  name: 'show_alert',
  description: 'Show an alert dialog',
  inputSchema: {
    type: 'object',
    properties: { message: { type: 'string' } },
    required: ['message'],
  },
  handler: async ({ message }) => {
    alert(message);
    return { content: [{ type: 'text', text: 'Alert shown' }] };
  },
});

MCP Server Builder

import { mcpServer, tool } from '@chucky.cloud/sdk';

const myTools = mcpServer('my-tools', '1.0.0')
  .addTool({
    name: 'greet',
    description: 'Greet someone',
    inputSchema: {
      type: 'object',
      properties: { name: { type: 'string' } },
      required: ['name'],
    },
    handler: async ({ name }) => ({
      content: [{ type: 'text', text: `Hello, ${name}!` }],
    }),
  })
  .build();

const session = await client.createSession({
  mcpServers: [myTools],
});

Token Management

Creating Tokens (Server-side)

import { createToken, createBudget } from '@chucky.cloud/sdk';

const token = await createToken({
  userId: 'user-123',
  projectId: 'your-project-uuid',
  secret: 'your-hmac-secret',
  expiresIn: 3600, // 1 hour
  budget: createBudget({
    aiDollars: 5.00,
    computeHours: 2,
    window: 'day',
  }),
  permissions: {
    tools: ['get_weather', 'search'],
    maxTurns: 20,
  },
});

Verifying Tokens

import { verifyToken, decodeToken, isTokenExpired } from '@chucky.cloud/sdk';

// Verify signature
const isValid = await verifyToken(token, 'your-hmac-secret');

// Decode without verification
const decoded = decodeToken(token);
console.log(decoded.payload.sub); // User ID
console.log(decoded.payload.budget); // Budget limits

// Check expiration
if (isTokenExpired(token)) {
  console.log('Token has expired');
}

Client Options

const client = new ChuckyClient({
  // Required
  token: 'your-jwt-token',

  // Optional
  baseUrl: 'wss://conjure.chucky.cloud/ws', // Custom endpoint
  debug: false,                          // Enable debug logging
  timeout: 30000,                        // Connection timeout (ms)
  keepAliveInterval: 300000,             // Keep-alive interval (ms)
  autoReconnect: true,                   // Auto-reconnect on disconnect
  maxReconnectAttempts: 5,               // Max reconnect attempts
});

Session Options

const session = await client.createSession({
  // Model
  model: 'claude-sonnet-4-5-20250929',
  fallbackModel: 'claude-3-5-haiku-20241022',

  // Limits
  maxTurns: 10,
  maxBudgetUsd: 1.00,
  maxThinkingTokens: 10000,

  // System prompt
  systemPrompt: 'You are a helpful assistant.',
  // Or use preset:
  // systemPrompt: { type: 'preset', preset: 'claude_code', append: 'Be concise.' },

  // Tools
  tools: [myTool],
  allowedTools: ['get_weather'],
  disallowedTools: ['dangerous_tool'],

  // MCP servers
  mcpServers: [myServer],

  // Sub-agents
  agents: {
    researcher: {
      name: 'Researcher',
      model: 'claude-sonnet-4-5-20250929',
      tools: ['search'],
    },
  },

  // Session management
  sessionId: 'session-123',    // Resume existing session
  forkSession: true,           // Fork instead of resume
  continue: true,              // Continue from where left off

  // Output
  includePartialMessages: true,
  outputFormat: {
    type: 'json_schema',
    schema: { /* your schema */ },
  },
});

Error Handling

import {
  ChuckyError,
  ConnectionError,
  AuthenticationError,
  BudgetExceededError,
  ConcurrencyLimitError,
} from '@chucky.cloud/sdk';

try {
  await session.send('Hello');
} catch (error) {
  if (error instanceof BudgetExceededError) {
    console.log('Budget exceeded:', error.message);
  } else if (error instanceof ConcurrencyLimitError) {
    console.log('Too many concurrent sessions');
  } else if (error instanceof AuthenticationError) {
    console.log('Invalid token');
  } else if (error instanceof ConnectionError) {
    console.log('Connection failed');
  }
}

TypeScript

The SDK is fully typed. All types are exported:

import type {
  // Options
  ClientOptions,
  SessionOptions,
  PromptOptions,

  // Tools
  ToolDefinition,
  ToolResult,
  ToolInputSchema,
  McpServerDefinition,

  // Results
  SessionResult,
  PromptResult,
  Message,

  // Token
  BudgetTokenPayload,
  TokenBudget,

  // Streaming
  StreamingEvent,
} from '@chucky.cloud/sdk';

License

MIT