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

@boolbyte/engine

v0.6.0

Published

A TypeScript client library for interacting with the ByteEngine API

Readme

ByteEngine JavaScript Client

A comprehensive TypeScript/JavaScript client library for interacting with the ByteEngine API. ByteEngine is a powerful AI platform that provides workers, sessions, tasks, and various AI capabilities.

Features

  • 🤖 Worker Management - Create and manage AI workers with different models and configurations
  • 💬 Session Management - Handle conversational sessions with message history
  • 📋 Task Management - Execute and monitor AI tasks with tool support
  • 🧠 Knowledge Base - Manage and query knowledge bases
  • 🛠️ Toolkit Integration - Attach and configure various tools and functions
  • 📁 Storage - File upload and storage management
  • 🏥 ByteFhir - Healthcare-specific FHIR data processing
  • 🔧 Model Management - Configure and manage AI models
  • 🌐 Endpoint Management - Manage API endpoints

Installation

npm install @boolbyte/engine

Quick Start

import { ByteEngineClient, Models } from '@boolbyte/engine';

// Initialize the client
const client = new ByteEngineClient({
  baseUrl: 'https://api.byteengine.boolbyte.com',
  apiKey: 'your-api-key-here',
  timeout: 30000 // optional, in milliseconds
});

// Create a worker
const worker = await client.worker.createWorker({
  name: 'My AI Assistant',
  description: 'A helpful AI assistant',
  instructions: 'You are a helpful AI assistant that can answer questions and help with tasks.',
  defaultModelName: Models.LLAMA_3_70B
});

console.log('Created worker:', worker.data);

Configuration

The ByteEngineClient requires the following configuration:

interface ByteEngineClientConfig {
  baseUrl: string;    // Your ByteEngine API base URL
  apiKey: string;     // Your API key
  timeout?: number;   // Request timeout in milliseconds (optional)
}

Client Modules

The ByteEngineClient provides access to various specialized clients:

Worker Client

Manage AI workers and their configurations:

// List all workers
const workers = await client.worker.listWorkers();

// Get a specific worker
const worker = await client.worker.getWorker('worker-id');

// Create a new worker
const newWorker = await client.worker.createWorker({
  name: 'My Worker',
  description: 'A custom AI worker',
  instructions: 'You are a helpful assistant.',
  defaultModelName: Models.LLAMA_3_70B,
  modelNames: [Models.LLAMA_3_70B, Models.GEMMA_3_12B]
});

// Update a worker
const updatedWorker = await client.worker.updateWorker('worker-id', {
  name: 'Updated Worker Name',
  instructions: 'Updated instructions'
});

// Delete a worker
await client.worker.deleteWorker('worker-id');

Session Client

Handle conversational sessions with message management:

// Create a new session
const session = await client.session.createSession({
  workerId: 'worker-id',
  metadata: { userId: 'user-123' }
});

// Add a message to the session
await client.session.addMessage('session-id', {
  content: 'Hello, how can you help me?',
  role: 'user'
});

// Send a message (creates and processes)
const response = await client.session.sendMessage('session-id', {
  content: 'What is the weather like?',
  role: 'user'
});

// List all messages in a session
const messages = await client.session.listMessages('session-id');

// Get a specific message
const message = await client.session.getMessage('session-id', 'message-id');

// Parse message content
const messageText = client.session.parseMessage(message.data);

// Update session metadata
await client.session.updateSession('session-id', {
  metadata: { status: 'active' }
});

// List all sessions
const sessions = await client.session.listSessions();

// Delete a session
await client.session.deleteSession('session-id');

Task Client

Execute and monitor AI tasks:

// Create a task
const task = await client.task.createTask('session-id', {
  model: Models.LLAMA_3_70B,
  instructions: 'Analyze the following data and provide insights.',
  temperature: 0.7,
  maxCompletionTokens: 1000,
  toolChoice: 'auto'
});

// List tasks for a session
const tasks = await client.task.listTasks('session-id', {
  limit: 10,
  order: 'desc'
});

// Get a specific task
const taskDetails = await client.task.getTask('session-id', 'task-id');

// Submit tool outputs (when task requires action)
await client.task.submitToolOutputs('session-id', 'task-id', {
  toolOutputs: [
    {
      toolCallId: 'call-123',
      output: 'Tool execution result'
    }
  ]
});

// Cancel a task
await client.task.cancelTask('session-id', 'task-id');

// Resume a cancelled task
await client.task.resumeTask('session-id', 'task-id');

// Update task metadata
await client.task.updateTask('session-id', 'task-id', {
  metadata: { priority: 'high' }
});

Knowledge Base Client

Manage knowledge bases for enhanced AI responses:

// List knowledge bases
const knowledgeBases = await client.knowledgeBase.listKnowledgeBases();

// Create a knowledge base
const kb = await client.knowledgeBase.createKnowledgeBase({
  name: 'Company Documentation',
  description: 'Internal company knowledge base'
});

// Upload documents to knowledge base
const uploadResult = await client.knowledgeBase.uploadDocument('kb-id', file);

// Query knowledge base
const results = await client.knowledgeBase.queryKnowledgeBase('kb-id', {
  query: 'What is our company policy on remote work?',
  limit: 5
});

Storage Client

Handle file uploads and storage:

// Upload a file
const fileUpload = await client.storage.uploadFile(file, {
  purpose: 'document',
  metadata: { category: 'research' }
});

// List files
const files = await client.storage.listFiles();

// Get file details
const fileDetails = await client.storage.getFile('file-id');

// Download file content
const fileContent = await client.storage.downloadFile('file-id');

// Delete a file
await client.storage.deleteFile('file-id');

Toolkit Client

Manage tools and toolkits for workers:

// List available toolkits
const toolkits = await client.toolkit.listToolkits();

// Get toolkit details
const toolkit = await client.toolkit.getToolkit('toolkit-name');

// List tools in a toolkit
const tools = await client.toolkit.listTools('toolkit-name');

Model Client

Manage AI models and configurations:

// List available models
const models = await client.model.listModels();

// Get model details
const model = await client.model.getModel('model-name');

FHIR Store Client

Healthcare-specific FHIR store/server management:

// List all FHIR stores
const fhirStores = await client.store.listFhirStores();

// Get a specific FHIR store
const store = await client.store.getFhirStore('store-id');

// Create a new FHIR store
const newStore = await client.store.createFhirStore({
  name: 'My FHIR Store',
  description: 'Healthcare data store',
  region: 'global',
  fhirVersion: 'R4'
});

// Initialize an authenticated fhir-kit-client instance for a store
await client.store.initializeFhirStoreClient('store-id');
const fhirKit = client.store.getFhirStoreClient();

// Use fhir-kit-client directly
const patient = await fhirKit?.read({ resourceType: 'Patient', id: '123' });

FHIR Client (direct re-export)

If you prefer to use FHIR operations directly without the ByteEngineClient, you can import the FhirClient (a direct re-export of fhir-kit-client):

import { FhirClient } from '@boolbyte/engine';

const fhir = new FhirClient({ baseUrl: 'https://your-fhir-server' });

// Read a Patient
const patient = await fhir.read({ resourceType: 'Patient', id: '123' });

// Search Patients
const bundle = await fhir.search({
  resourceType: 'Patient',
  searchParams: { family: 'Smith' }
});

Error Handling

The client provides comprehensive error handling:

try {
  const worker = await client.worker.createWorker({
    name: 'Test Worker',
    defaultModelName: Models.LLAMA_3_70B
  });
} catch (error) {
  if (error.message.includes('ByteEngine API Error')) {
    console.error('API Error:', error.message);
  } else {
    console.error('Unexpected error:', error);
  }
}

Response Format

All API responses follow a consistent format:

interface ApiResponse<T> {
  success: boolean;
  message: string;
  data?: T;
  total?: number;
  firstId?: string;
  lastId?: string;
  hasMore?: boolean;
}

Pagination

Many list endpoints support pagination:

// List with pagination
const tasks = await client.task.listTasks('session-id', {
  after: 'task-id',  // Get tasks after this ID
  limit: 20,         // Limit results
  order: 'desc'      // Sort order
});

// Check if there are more results
if (tasks.hasMore) {
  const nextPage = await client.task.listTasks('session-id', {
    after: tasks.lastId,
    limit: 20
  });
}

TypeScript Support

The library is built with TypeScript and provides full type definitions:

import { 
  ByteEngineClient, 
  Models, 
  TaskStatus, 
  MessageRole,
  CreateWorkerApiDto,
  SessionApiDto 
} from '@boolbyte/engine';

// All types are available for your use
const workerData: CreateWorkerApiDto = {
  name: 'Typed Worker',
  defaultModelName: Models.LLAMA_3_70B
};

Advanced Usage

Custom Timeout Configuration

const client = new ByteEngineClient({
  baseUrl: 'https://api.byteengine.boolbyte.com',
  apiKey: 'your-api-key',
  timeout: 60000 // 60 seconds
});

Working with Message Content

// Complex message content with annotations
const message = await client.session.sendMessage('session-id', {
  content: [
    {
      type: 'text',
      text: {
        value: 'Please analyze this document',
        annotations: []
      }
    },
    {
      type: 'image_url',
      image_url: {
        url: 'https://example.com/image.jpg',
        detail: 'high'
      }
    }
  ],
  role: 'user'
});

Task Status Monitoring

// Poll task status until completion
async function waitForTaskCompletion(sessionId: string, taskId: string) {
  while (true) {
    const task = await client.task.getTask(sessionId, taskId);
    
    if (task.data.status === 'completed') {
      return task.data;
    } else if (task.data.status === 'failed') {
      throw new Error(`Task failed: ${task.data.lastError?.message}`);
    }
    
    // Wait before polling again
    await new Promise(resolve => setTimeout(resolve, 1000));
  }
}

Contributing

We welcome contributions! Please see our contributing guidelines for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

Changelog

This project uses automatic changelog generation based on Conventional Commits. The changelog is automatically updated with each release.

Automatic Changelog Generation

The changelog is automatically generated from commit messages using:

  • Standard Version - For version bumping and release changelog generation
  • Auto Changelog - For continuous changelog updates
  • Conventional Commits - For consistent commit message format

Quick Commands

# Make a conventional commit
npm run commit

# Generate changelog from commits
npm run changelog

# Create a new release (version bump + changelog)
npm run release