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

cactus-plugin

v1.0.0-alpha.22

Published

Cactus LLM inspection for Rozenite.

Downloads

10

Readme

mit licence npm downloads Chat PRs Welcome

The Rozenite Cactus Plugin provides real-time LLM inspection + monitoring for Cactus-powered chatbots within your React Native DevTools environment. Track LLM + Embedding requests, token streaming, RAG retrievals, and performance metrics in real-time.

Learn more about Cactus here!

Features

  • Real-time LLM Inspection: Monitor Cactus LLM requests, responses, and streaming tokens
  • RAG Operations Tracking: View retrieval-augmented generation operations with scores and sources
  • Performance Metrics: Track latency, token counts, and operation timing
  • Event-Driven Architecture: Stream events from your Cactus integrations automatically
  • React Native DevTools Integration: Seamless integration with existing RN DevTools workflow
  • Type-Safe Event Handling: Full TypeScript support for all event types and callbacks

Installation

Install the Cactus plugin as a dependency:

npm install cactus-rozenite

Note: This plugin requires Cactus libraries as peer dependencies. Make sure you have Cactus React installed:

npm install cactus-react

Quick Start

1. Install the Plugin

npm install cactus-rozenite

2. Integrate with Your App

Add Cactus event emission to your React Native app - wrap your Cactus operations:

import { postInspectorEvent } from 'cactus-rozenite';
import { CactusAgent } from 'cactus-react';

// Example: Initialize Cactus with event monitoring
const cactusAgent = new CactusAgent({...});

// Wrap your chat/rag operations
async function monitoredQuery(query: string, conversationId: string) {
  const requestId = `${conversationId}-${Date.now()}`;

  // Emit start event
  postInspectorEvent({
    kind: 'llm:start',
    requestId,
    model: cactusAgent.getModel(),
    params: cactusAgent.getConfig(),
    promptPreview: query.slice(0, 500),
    time: Date.now(),
  });

  try {
    const result = await cactusAgent.query(query);

    // Emit successful completion
    postInspectorEvent({
      kind: 'llm:end',
      requestId,
      totalTokens: result.usage?.total_tokens,
      latencyMs: Date.now() - (result.startTime || 0),
      finishReason: result.finish_reason,
      time: Date.now(),
    });

    // Emit RAG retrieval if available
    if (result.sources) {
      postInspectorEvent({
        kind: 'rag:retrieve',
        requestId,
        query,
        k: result.sources.length,
        sources: result.sources.map(s => ({
          id: s.id,
          title: s.metadata?.title,
          score: s.score,
          uri: s.metadata?.uri,
          preview: s.text?.slice(0, 240),
        })),
        latencyMs: result.searchLatency || 0,
        time: Date.now(),
      });
    }

    return result;
  } catch (error) {
    // Emit error event
    postInspectorEvent({
      kind: 'llm:error',
      requestId,
      message: String(error),
      time: Date.now(),
    });
    throw error;
  }
}

3. Access DevTools

Start your development server and open React Native DevTools. You'll find the "Cactus / RAG" panel displaying live LLM and RAG event streams.

Advanced Integration

Streaming Token Events

For token-by-token streaming, wrap your streaming handlers:

// Create a streaming wrapper
function withStreamingInspection(requestId: string) {
  let chunkCount = 0;
  let fullResponse = '';

  return (token: string) => {
    chunkCount++;
    fullResponse += token;

    postInspectorEvent({
      kind: 'llm:chunk',
      requestId,
      delta: token,
      time: Date.now(),
    });
  };
}

// Use with Cactus streaming
const requestId = `stream-${Date.now()}`;
cactusAgent.streamingQuery(query, withStreamingInspection(requestId));

Error Handling

Always wrap operations in try/catch to capture errors:

try {
  await cactusAgent.embedDocuments(documents);
} catch (error) {
  postInspectorEvent({
    kind: 'llm:error',
    requestId: 'embed-operation',
    message: `Embedding failed: ${error.message}`,
    time: Date.now(),
  });
}

Event Types

The plugin tracks these Cactus operations:

  • llm:start: Request initialization with model, parameters, and prompt preview
  • llm:chunk: Streaming token deltas (if streaming is enabled)
  • llm:end: Request completion with latency, token counts, and finish reason
  • llm:error: Failed requests with error messages
  • rag:retrieve: RAG source retrievals with similarity scores and document metadata

Data Privacy

The plugin automatically:

  • Truncates prompts to first 500 characters to avoid sensitive data exposure
  • Limits source previews to 240 characters per document
  • Only runs in development builds (DEV mode)
  • Gates all operations behind development checks

Usage Examples

React Hook Integration

For React components, you can create custom hooks:

import { useCallback } from 'react';
import { useCactusDevTools, postInspectorEvent } from 'cactus-rozenite';

function useMonitoredCactus() {
  // Initialize DevTools (optional)
  useCactusDevTools();

  const monitoredQuery = useCallback(async (query: string) => {
    const requestId = `query-${Date.now()}`;

    postInspectorEvent({
      kind: 'llm:start',
      requestId,
      model: 'cactus-model',
      params: { temperature: 0.7 },
      promptPreview: query,
      time: Date.now(),
    });

    return cactusAgent.query(query).finally(() => {
      // Emit end/error events here
    });
  }, []);

  return { monitoredQuery };
}

Performance Monitoring

Track performance bottlenecks in your RAG pipeline:

// Measure retrieval performance
const retrieveStart = performance.now();
const sources = await vectorIndex.search(query, { k: 5 });
const latencyMs = performance.now() - retrieveStart;

postInspectorEvent({
  kind: 'rag:retrieve',
  requestId,
  query,
  k: sources.length,
  sources: sources.map(s => ({
    id: s.id,
    score: s.score,
    title: s.metadata?.title,
    preview: s.text?.slice(0, 100),
  })),
  latencyMs,
  time: Date.now(),
});

Made with ❤️ for the Cactus + Rozenite Ecosystem

cactus-rozenite is an open-source project that enhances the Cactus experience for React Native developers.

Contribute to the ongoing evolution of local LLM tooling!

Links

License

By contributing to Rozenite, you agree that your contributions will be licensed under its MIT license.