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

@gilf/chat-websocket-server

v1.0.18

Published

A TypeScript-based WebSocket server that enables chat functionality with both AI language models (ChatGPT and Gemini) and human operators. The system allows users to chat with AI models when no operator is available, and seamlessly switch to human operato

Readme

WebSocket Chat Server with LLM Integration

A TypeScript-based WebSocket server that enables chat functionality with both AI language models (ChatGPT and Gemini) and human operators. The system allows users to chat with AI models when no operator is available, and seamlessly switch to human operator support when needed.

Features

  • Real-time chat using WebSocket connections
  • Support for multiple AI providers:
    • OpenAI's ChatGPT
    • Google's Gemini
  • Human operator integration:
    • Secure operator authentication
    • One-to-one chat sessions between operators and users
    • Operator can only chat with one user at a time
  • Automatic fallback to AI when no operator is available
  • Command-line interfaces for both users and operators
  • Written in TypeScript for better type safety and developer experience

Prerequisites

  • Node.js (v16 or higher)
  • Yarn package manager
  • OpenAI API key
  • Google Gemini API key

Installation

  1. Clone the repository:
git clone https://github.com/onepointconsulting/operator-chat
cd chat-websocket-server
  1. Install dependencies:
yarn install
  1. Create a .env file in the root directory with the following variables:
OPENAI_API_KEY=<key>
OPENAI_MODEL=gpt-4o-mini
INITIAL_PROVIDER=openai
# INITIAL_PROVIDER=gemini # uncomment this to use gemini
GEMINI_API_KEY=<key>
GEMINI_MODEL=gemini-1.5-flash

OPERATOR_PASSWORD=<pass>
PORT=4000

PROMPT_FILE=config/prompts.toml
SLICE_SIZE=5

You can use the .env_local file as a template to create your own .env file.

  1. Make sure you have the prompts file in the config folder.

Here is an example of the prompts file:

[basic]
system_message = """You are a helpful assistant in british English.

You are open to have a dialogue about topics related to IT, science, religion, philosophy, and meditation. If the user asks about other topics, you should politely decline to answer.

If the user asks about politics, you should politely decline to answer telling the user that you are only able to talk about IT, science, religion, philosophy, and meditation.

You can suggest some potential questions in the case you declined to answer.

"""

initial_questions = [
    "What is your name?",
    "What is your role in the company?"
]

[configuration]
max_history_size = 5

Usage

  1. Start the server:
yarn start
  1. Start the operator client:
yarn operator

Operator Commands:

  • /connect <userId> - Connect to a specific user
  • /disconnect - Disconnect from the current user
  • /quit - Exit the operator interface
  • /help - Show the help menu
  • /set-name <name> - Set your name
  • Any other input will be sent as a message to the connected user
  1. Start the user client:
yarn client

Publishing

Use:

npm publish