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

@dev.tringuyen/greenzone-agent

v1.0.44

Published

GreenZone AI Chat Agent - Reusable AI Chat Widget with OpenAI integration

Downloads

217

Readme

🌿 GreenZone Agent

Version License TypeScript React

Enterprise-grade AI Chat Widget powered by OpenAI

Developed by Trí Nguyễn — CTO, The GreenZone


FeaturesInstallationUsageConfigurationAPI

✨ Features

| Feature | Description | |---------|-------------| | 🚀 Streaming Responses | Real-time AI responses with OpenAI streaming | | 🔐 Authentication | Auto-sends JWT token from localStorage | | 📎 File Attachments | Upload PDFs and documents for AI analysis | | 💾 Chat History | Persistent conversation history with session management | | 🎨 Themeable | Fully customizable colors, fonts, and branding | | ⚡ Virtualized List | Optimized performance with thousands of messages | | 📱 Responsive | Works on desktop and mobile with fullscreen mode | | 🔧 Resizable Panel | Drag to resize chat panel width | | 🌐 Web Search | Built-in web search tool integration |

📦 Installation

# npm
npm install @dev.tringuyen/greenzone-agent

# yarn
yarn add @dev.tringuyen/greenzone-agent

# pnpm
pnpm add @dev.tringuyen/greenzone-agent

🚀 Usage

Quick Start

import { ChatWidget } from '@dev.tringuyen/greenzone-agent';

function App() {
  return (
    <>
      <YourApp />
      
      {/* Drop-in AI Chat - Just one line! */}
      <ChatWidget apiBaseUrl="https://your-api.com" />
    </>
  );
}

With Full Configuration

import { ChatWidget } from '@dev.tringuyen/greenzone-agent';

function App() {
  return (
    <ChatWidget 
      apiBaseUrl="https://api.your-domain.com"
      projectId="my-project-123"
      position="bottom-right"
      panelWidth={500}
      theme={{
        primaryColor: '#14B8A6',
        fontFamily: 'Inter, sans-serif',
      }}
      branding={{
        title: 'My AI Assistant',
        subtitle: 'Powered by AI',
        welcomeMessage: 'How can I help you today?',
        inputPlaceholder: 'Type your message...',
        logo: 'https://example.com/logo.png',
      }}
      features={{
        fileUpload: true,
        history: true,
        resize: true,
        fullscreen: true,
      }}
      context={{
        currentPage: 'dashboard',
        systemPrompt: 'You are a helpful assistant.',
      }}
      onOpen={() => console.log('Chat opened')}
      onClose={() => console.log('Chat closed')}
    />
  );
}

⚙️ Configuration

ChatWidgetConfig

| Property | Type | Default | Description | |----------|------|---------|-------------| | apiBaseUrl | string | required | Base URL of your API (origin only, e.g., https://api.example.com) | | projectId | string | undefined | Project ID sent as X-Project-Id header | | isOpen | boolean | undefined | Controlled open state (optional) | | onOpenChange | (isOpen: boolean) => void | undefined | Callback when open state changes | | position | 'bottom-right' \| 'bottom-left' | 'bottom-right' | Trigger button position | | panelWidth | number | 500 | Initial panel width in pixels | | zIndex | number | 9999 | Z-index of the widget |

Theme Options

theme?: {
  primaryColor?: string;      // Default: '#14B8A6'
  backgroundColor?: string;   // Default: '#FFFFFF'
  textColor?: string;         // Default: '#0F172A'
  fontFamily?: string;        // Default: 'system-ui'
}

Branding

branding?: {
  title?: string;             // Default: 'GreenZone AI'
  subtitle?: string;          // Subtitle under title
  welcomeMessage?: string;    // Welcome screen message
  inputPlaceholder?: string;  // Input field placeholder
  logo?: string;              // Logo URL (optional)
}

Feature Flags

features?: {
  fileUpload?: boolean;   // Enable PDF upload (default: true)
  history?: boolean;      // Enable chat history (default: true)
  resize?: boolean;       // Enable panel resizing (default: true)
  fullscreen?: boolean;   // Enable fullscreen mode (default: true)
}

🔐 Authentication

The widget automatically sends authentication headers with every API request:

Authorization: Bearer <token>
X-Project-Id: <projectId>

To authenticate, store the JWT token in localStorage:

// After user login
localStorage.setItem('auth_token', 'your-jwt-token');

The widget will automatically include this token in all requests.

🔌 API Requirements

Your backend needs to implement these endpoints:

| Method | Endpoint | Description | |--------|----------|-------------| | POST | /api/v1/chat | Streaming chat (SSE) | | POST | /api/v1/files/upload | File upload | | GET | /api/v1/files/status/:jobId | Upload status polling | | GET | /api/history | List chat sessions | | POST | /api/history | Save chat session | | DELETE | /api/history/:id | Delete session |

Note: Chat & file endpoints use /api/v1/, while history uses /api/ (no v1).

📋 Requirements

  • React 18.0+
  • Tailwind CSS (components use Tailwind utility classes)
  • Motion 11.0+ (framer-motion successor)

Tailwind CSS Setup

Add this to your CSS to include widget styles:

@import "tailwindcss";
@source "../node_modules/@dev.tringuyen/greenzone-agent/dist/**/*.js";

🛠️ Development

# Clone the repo
git clone https://github.com/thegreenzone/greenzone-agent.git

# Install dependencies
yarn install

# Build
yarn build

# Watch mode
yarn dev

📄 License

UNLICENSED - Proprietary software. All rights reserved.


Built with ❤️ by The GreenZone

Making AI accessible for everyone