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

wesley-chat-components

v0.2.2

Published

Shared React components for AI chat integration

Downloads

14

Readme

@caesor/wesley-chat-components

Shared React components for AI chat integration with context-aware interactions.

Installation

Using GitHub Package Registry

  1. Create a .npmrc file in your project root:
@caesor:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
  1. Set your GitHub token as an environment variable:
export GITHUB_TOKEN=your_github_personal_access_token

Note: You need a GitHub personal access token with read:packages permission. Create one here.

  1. Install the package:
# Using npm
npm install @caesor/wesley-chat-components

# Using yarn
yarn add @caesor/wesley-chat-components

# Using pnpm
pnpm add @caesor/wesley-chat-components

Features

  • 🤖 AI Chat Widget - Full-featured chat interface with streaming support
  • 🎯 Context-Aware - Different behaviors based on trigger context
  • 🎨 Customizable - Flexible theming and configuration options
  • 📝 Markdown Support - Rich text rendering with syntax highlighting
  • 🔄 Streaming Responses - Real-time message streaming
  • 📱 Responsive - Works on all devices

Quick Start

Basic Chat Widget

import { ChatWidget } from '@caesor/wesley-chat-components';

function App() {
  return (
    <ChatWidget
      apiEndpoint="/api/chat"
      variant="floating"
      position="bottom-right"
      title="AI Assistant"
      initialMessage="Hello! How can I help you today?"
    />
  );
}

Replace Email Links with AI Agent

Replace traditional mailto: links with AI-powered interactions:

import { AgentDialog, createAgentContext } from '@caesor/wesley-chat-components';

// Before: <a href="mailto:[email protected]">Contact Us</a>

// After:
<AgentDialog
  context={createAgentContext('contact')}
  className="contact-button"
>
  Contact Us
</AgentDialog>

Context-Aware Templates

Different contexts for different interaction points:

// Template inquiry
<AgentDialog
  context={{
    trigger: 'template',
    metadata: {
      templateId: 'tech-startup',
      templateTitle: 'Tech Startup Template',
      templateFeatures: ['Hero animations', 'Feature cards', 'Pricing tables']
    }
  }}
>
  Request This Design
</AgentDialog>

// Service inquiry
<AgentDialog
  context={{
    trigger: 'service',
    metadata: {
      serviceType: 'AI Integration'
    }
  }}
>
  Learn More About AI Integration
</AgentDialog>

Components

ChatWidget

Main chat interface component with multiple display variants.

<ChatWidget
  // API Configuration
  apiEndpoint="/api/chat/stream"
  apiKey="your-api-key"

  // UI Configuration
  variant="floating" // 'floating' | 'inline' | 'modal'
  position="bottom-right"
  theme="light"

  // Content
  title="AI Assistant"
  subtitle="How can I help?"
  placeholder="Type your message..."
  initialMessage="Welcome! How can I assist you today?"
  suggestedQuestions={[
    "Tell me about your services",
    "I need help with a project"
  ]}

  // Behavior
  autoOpen={false}
  useStreaming={true}
  persistMessages={false}

  // Events
  onOpen={() => console.log('Chat opened')}
  onClose={() => console.log('Chat closed')}
  onMessageSent={(message, context) => console.log('Sent:', message)}
  onMessageReceived={(message) => console.log('Received:', message)}
  onError={(error) => console.error('Error:', error)}
/>

AgentDialog

Button wrapper that opens chat with specific context.

<AgentDialog
  context={{
    trigger: 'header',
    metadata: { page: 'home' }
  }}
  widgetProps={{
    apiEndpoint: '/api/chat',
    title: 'Sales Assistant'
  }}
  className="cta-button"
  disabled={false}
>
  Start Conversation
</AgentDialog>

MarkdownRenderer

Renders markdown content with syntax highlighting.

import { MarkdownRenderer } from '@caesor/wesley-chat-components';

<MarkdownRenderer
  content="# Hello World\n\nThis is **markdown** content with `code`."
  className="markdown-content"
/>

Context System

The context system helps provide relevant initial messages and suggestions based on where the user triggered the chat.

Available Contexts

  • header - Navigation/header interactions
  • template - Template/product inquiries
  • service - Service-specific questions
  • contact - General contact requests
  • footer - Footer link interactions
  • general - Default context

Using Hooks

import { useAgentContext } from '@caesor/wesley-chat-components';

function MyComponent() {
  const context = useAgentContext({
    trigger: 'template',
    metadata: {
      templateId: 'portfolio',
      templateTitle: 'Portfolio Template'
    }
  });

  return (
    <ChatWidget
      context={context}
      // Context will automatically set initial message and suggestions
    />
  );
}

API Endpoint Requirements

Your API endpoint should accept POST requests with the following format:

Request

{
  message: string;
  context?: AgentContext;
  messages?: Message[];
}

Response (Streaming)

For streaming responses, return Server-Sent Events:

data: {"type": "content", "content": "Hello "}
data: {"type": "content", "content": "world!"}
data: {"type": "done"}

Response (Non-streaming)

{
  "message": "Response from the AI assistant",
  "metadata": {}
}

Styling

The components use Ant Design (antd) for UI elements. Make sure to import antd styles in your app:

// In your main app file
import 'antd/dist/reset.css';

TypeScript

Full TypeScript support with exported types:

import type {
  ChatWidgetProps,
  AgentDialogProps,
  AgentContext,
  Message,
  ChatState
} from '@caesor/wesley-chat-components';

Development

Local Development

# Clone the repository
git clone https://github.com/Caesor/wesley-chat-components.git
cd wesley-chat-components

# Install dependencies
npm install

# Build the package
npm run build

# Link for local testing
npm link

Testing Locally

In your project:

npm link @caesor/wesley-chat-components

Security

See SECURITY.md for our security policy and how to report vulnerabilities.

License

MIT - See LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support