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

@vital-ai/vital-agent-container-client-nodejs

v1.0.0

Published

TypeScript WebSocket client for services that exchange JSON messages

Readme

vital-agent-container-client-nodejs

A TypeScript WebSocket client for communicating with WebSocket services that exchange JSON messages.

Features

  • WebSocket connection management (connect/disconnect)
  • JSON message serialization and deserialization
  • Automatic reconnection with configurable retries
  • Connection status monitoring and events
  • Typed event-based message handling
  • Promise-based async/await API

Installation

npm install vital-agent-container-client-nodejs

Usage

Basic Connection

import { VitalAgentClient } from 'vital-agent-container-client-nodejs';

// Create a client instance
const client = new VitalAgentClient();

// Connect to a WebSocket server
client.connect('ws://your-server:8080')
  .then(() => {
    console.log('Connected to server');
  })
  .catch(err => {
    console.error('Connection failed:', err.message);
  });

// Handle incoming messages
client.on('message', (message) => {
  console.log('Received message:', message);
});

// Close the connection when done
client.disconnect();

Advanced Configuration

import { VitalAgentClient } from 'vital-agent-container-client-nodejs';

// Create a client with custom options
const client = new VitalAgentClient({
  reconnect: {
    enabled: true,     // Enable automatic reconnection
    maxAttempts: 5,    // Maximum number of reconnection attempts
    delay: 2000        // Delay between attempts (milliseconds)
  },
  headers: {           // Custom headers
    'Authorization': 'Bearer your-token'
  },
  connectionTimeout: 5000  // Connection timeout (milliseconds)
});

// Connect with handlers
async function connectToServer() {
  try {
    await client.connect('ws://your-server:8080');
    console.log('Connected successfully');
  } catch (error) {
    console.error('Connection failed:', error);
  }
}

// Send a message
async function sendMessage() {
  if (client.isConnected()) {
    try {
      await client.send({
        type: 'request',
        action: 'getData',
        parameters: { id: 123 }
      });
      console.log('Message sent');
    } catch (error) {
      console.error('Failed to send message:', error);
    }
  }
}

// Register event handlers
client.on('connected', () => {
  console.log('Connection established');
});

client.on('disconnected', ({ code, reason }) => {
  console.log(`Disconnected: Code ${code}, Reason: ${reason}`);
});

client.on('reconnecting', ({ attempt, maxAttempts }) => {
  console.log(`Reconnecting: Attempt ${attempt}/${maxAttempts}`);
});

client.on('error', (error) => {
  console.error('WebSocket error:', error);
});

API Reference

VitalAgentClient

The main client class for WebSocket communication.

Constructor

constructor(options?: ClientOptions)
  • options - Optional configuration options for the client.

Methods

  • connect(url: string): Promise<void> - Opens a WebSocket connection to the specified URL.
  • disconnect(code?: number, reason?: string): Promise<void> - Closes the WebSocket connection.
  • send(message: any): Promise<void> - Sends a JSON message through the WebSocket connection.
  • getStatus(): ConnectionStatus - Gets the current connection status.
  • isConnected(): boolean - Checks if the client is currently connected.

Events

  • 'connected' - Emitted when a connection is established.
  • 'disconnected' - Emitted when the connection is closed, with { code, reason }.
  • 'message' - Emitted when a message is received, with the parsed JSON message.
  • 'error' - Emitted when an error occurs.
  • 'reconnecting' - Emitted when attempting to reconnect, with { attempt, maxAttempts }.
  • 'reconnectFailed' - Emitted when all reconnection attempts have failed.

ConnectionStatus

Enum for connection status:

  • DISCONNECTED
  • CONNECTING
  • CONNECTED
  • RECONNECTING
  • CLOSING

License

ISC