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

@holocronlab/botruntime-zai

v2.8.17

Published

Zui AI (zai) - an LLM utility library written on top of Zui and the botruntime Cognitive client

Readme

Zai - AI Operations Made Simple

Zai is a powerful LLM utility library that provides a clean, type-safe API for common AI operations. Built on Zui schemas and the botruntime Cognitive client, it makes AI operations simple, intuitive, and production-ready.

Key Features

  • Simple API - One-liner operations for common AI tasks
  • Type Safety - Full TypeScript support with Zui schema validation
  • Active Learning - Learn from examples and improve over time
  • Performance - Built-in retries, caching, and error handling
  • Infinite Documents - Handle any document size with automatic chunking
  • Usage Tracking - Monitor tokens, costs, and performance

Installation

npm install @holocronlab/botruntime-zai @holocronlab/botruntime-client @holocronlab/botruntime-zui

Quick Start

import { Client } from '@holocronlab/botruntime-client'
import { Zai } from '@holocronlab/botruntime-zai'
import { z } from '@holocronlab/botruntime-zui'

// Initialize
const client = new Client({ botId: 'YOUR_BOT_ID', token: 'YOUR_TOKEN' })
const zai = new Zai({ client })

// Extract structured data
const person = await zai.extract(
  'John Doe is 30 years old and lives in New York',
  z.object({
    name: z.string(),
    age: z.number(),
    location: z.string(),
  })
)
// Result: { name: 'John Doe', age: 30, location: 'New York' }

// Check content
const isPositive = await zai.check('This product is amazing!', 'expresses positive sentiment')
// Result: true

// Generate text
const story = await zai.text('Write a short story about AI', { length: 200 })

// Summarize documents
const summary = await zai.summarize(longDocument, { length: 500 })

Core Operations

  • .extract(content, schema, options?) - Extract structured data
  • .check(content, condition, options?) - Verify boolean condition
  • .label(content, criteria, options?) - Apply multiple labels
  • .rewrite(content, instruction, options?) - Transform text
  • .filter(items, condition, options?) - Filter array items
  • .group(items, options?) - Organize items into categories
  • .rate(items, instructions, options?) - Rate items on 1-5 scale
  • .sort(items, instructions, options?) - Order items with natural language
  • .text(prompt, options?) - Generate text
  • .summarize(content, options?) - Create summary
  • .answer(documents, question, options?) - Answer questions from documents
  • .patch(content, instructions, options?) - Apply micropatches to text

Progress Tracking

const response = zai.summarize(veryLongDocument)

response.on('progress', (progress) => {
  console.log(`${progress.requests.percentage * 100}% complete`)
})

const summary = await response

Usage Monitoring

const { output, usage } = await zai.extract(text, schema).result()

console.log({
  tokens: usage.tokens.total,
  cost: usage.cost.total,
})

Active Learning

const zai = new Zai({
  client,
  activeLearning: {
    enable: true,
    tableName: 'SentimentTable',
    taskId: 'product-reviews',
  },
})

const result = await zai.learn('sentiment').check(review, 'Is this positive?')

Chaining Configuration

const fastZai = zai.with({ modelId: 'fast' })
await fastZai.check(text, 'Is this spam?')

const gpt4Zai = zai.with({ modelId: 'openai:gpt-4' })
await gpt4Zai.extract(document, complexSchema)

Custom Abort Signals

const controller = new AbortController()
const response = zai.summarize(document).bindSignal(controller.signal)

setTimeout(() => controller.abort(), 5000)

API Reference

Zai Class

  • new Zai(options) - Create instance with client and configuration
  • .with(config) - Create new instance with merged configuration
  • .learn(taskId) - Enable active learning for specific task

Response Methods

  • await response - Get simple result
  • await response.result() - Get detailed result with metadata
  • await response.usage() - Get usage statistics (via .result())
  • response.on('progress', handler) - Track progress
  • response.abort() - Cancel operation

License

ISC - See LICENSE file for details