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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@thinkhive/sdk

v3.1.0

Published

ThinkHive SDK v3.1 - AI agent observability supporting 25 trace formats including LangSmith, Langfuse, Opik, Braintrust, Datadog, MLflow, and more

Readme

ThinkHive SDK

The official JavaScript/TypeScript SDK for ThinkHive - AI Agent Observability Platform.

Features

  • 25 Trace Format Support: Automatic detection and normalization for LangSmith, Langfuse, Helicone, CrewAI, Opik, Braintrust, HoneyHive, Datadog, MLflow, AgentOps, Portkey, TruLens, Lunary, LangWatch, OpenLIT, Maxim AI, Galileo, PostHog, Keywords AI, Agenta, and more
  • Trace Analysis: Analyze AI agent traces with detailed explainability
  • RAG Evaluation: 8 quality metrics for RAG systems (groundedness, faithfulness, etc.)
  • Hallucination Detection: 9 types of hallucination detection
  • Business Impact: Industry-specific ROI calculations
  • Auto-Instrumentation: Works with LangChain, OpenAI, Anthropic, and more
  • OpenTelemetry: Built on OTLP for seamless integration

Installation

npm install @thinkhive/sdk

Quick Start

Basic Usage

import { ThinkHive } from '@thinkhive/sdk';

// Initialize client
const client = new ThinkHive({
  apiKey: 'your_api_key',
  baseUrl: 'https://api.thinkhive.ai'
});

// Send a trace
const result = await client.trace({
  userMessage: 'What is the weather in San Francisco?',
  agentResponse: 'The weather in San Francisco is currently 65°F and sunny.',
  agentId: 'weather-agent'
});

console.log(`Trace ID: ${result.traceId}`);
if (result.analysis) {
  console.log(`Outcome: ${result.analysis.outcome.verdict}`);
  console.log(`Impact Score: ${result.analysis.businessImpact.impactScore}`);
}

With Business Context

const result = await client.trace({
  userMessage: 'I want to cancel my order #12345',
  agentResponse: 'I understand you want to cancel order #12345...',
  agentId: 'support-agent',
  businessContext: {
    customerId: 'cust_abc123',
    transactionValue: 150.00,
    priority: 'high',
    industry: 'ecommerce'
  }
});

// Access ROI metrics
if (result.analysis?.businessImpact?.roi) {
  const roi = result.analysis.businessImpact.roi;
  console.log(`Estimated Revenue Loss: $${roi.estimatedRevenueLoss}`);
  console.log(`Churn Probability: ${roi.churnProbability}%`);
}

Explainer API

// Full trace analysis with RAG evaluation
const analysis = await client.explainer.analyze({
  userMessage: 'What is your return policy?',
  agentResponse: 'Items can be returned within 30 days...',
  retrievedContexts: ['Return Policy: 30 day returns...'],
  outcome: 'success'
}, {
  tier: 'full_llm',
  includeRagEvaluation: true,
  includeHallucinationDetection: true
});

console.log(`Summary: ${analysis.summary}`);
console.log(`Groundedness: ${analysis.ragEvaluation?.groundedness}`);

// Batch analysis
const batchResult = await client.explainer.analyzeBatch([
  { userMessage: '...', agentResponse: '...' },
  { userMessage: '...', agentResponse: '...' }
], { tier: 'fast_llm' });

// Semantic search
const searchResults = await client.explainer.search({
  query: 'refund complaints',
  filters: { outcome: 'failure' },
  limit: 10
});

Quality Metrics

// Get RAG scores
const ragScores = await client.quality.getRagScores('trace-123');
console.log(`Groundedness: ${ragScores.groundedness}`);
console.log(`Faithfulness: ${ragScores.faithfulness}`);

// Get hallucination report
const report = await client.quality.getHallucinationReport('trace-123');
if (report.hasHallucinations) {
  for (const detection of report.detectedTypes) {
    console.log(`- ${detection.type}: ${detection.description}`);
  }
}

// Evaluate RAG for custom input
const evaluation = await client.quality.evaluateRag({
  query: 'What is the return policy?',
  response: 'Items can be returned within 30 days.',
  contexts: [{ content: 'Return Policy: 30 day returns...' }]
});

ROI Analytics

// Get ROI summary
const summary = await client.analytics.getRoiSummary();
console.log(`Revenue Saved: $${summary.totalRevenueSaved}`);

// Get per-agent ROI
const agentRoi = await client.analytics.getRoiByAgent('support-agent');
console.log(`Success Rate: ${agentRoi.successRate}%`);

// Get correlation analysis
const correlations = await client.analytics.getCorrelations();
for (const corr of correlations.correlations) {
  console.log(`${corr.type}: ${corr.actionableInsight}`);
}

Providing Feedback

// After receiving user feedback
await client.feedback({
  traceId: result.traceId,
  rating: 5,
  wasHelpful: true,
  comment: 'Very accurate response!'
});

// When response was incorrect
await client.feedback({
  traceId: result.traceId,
  rating: 2,
  wasHelpful: false,
  hadIssues: ['incorrect_info', 'too_long'],
  correctedResponse: 'The correct answer is...'
});

Auto-Instrumentation

import { init, autoInstrument } from '@thinkhive/sdk';

// Initialize SDK
init({
  apiKey: 'your_api_key',
  serviceName: 'my-ai-agent',
  autoInstrument: true,
  frameworks: ['langchain', 'openai']
});

// Or manually instrument
autoInstrument(client, {
  frameworks: ['langchain', 'openai'],
  capturePrompts: true,
  captureResponses: true,
  businessContext: { industry: 'saas' }
});

// Now all LangChain and OpenAI calls are automatically traced!

Analysis Tiers

| Tier | Description | Latency | Cost | |------|-------------|---------|------| | rule_based | Pattern matching, keyword extraction | ~50ms | Free | | fast_llm | Quick LLM analysis (GPT-3.5) | ~500ms | Low | | full_llm | Complete analysis (GPT-4o) | ~3s | Standard | | deep | Multi-pass with validation | ~15s | Premium |

Environment Variables

| Variable | Description | |----------|-------------| | THINKHIVE_API_KEY | Your ThinkHive API key | | THINKHIVE_ENDPOINT | Custom API endpoint (optional) | | THINKHIVE_SERVICE_NAME | Service name for traces (optional) |

API Reference

See API Documentation for complete type definitions.

License

MIT License - see LICENSE for details.