
Security News
Open VSX Begins Implementing Pre-Publish Security Checks After Repeated Supply Chain Incidents
Following multiple malicious extension incidents, Open VSX outlines new safeguards designed to catch risky uploads earlier.
@thinkhive/sdk
Advanced tools
ThinkHive SDK v3.3 - AI agent observability with business metrics, ROI analytics, and 25+ trace format support
The official JavaScript/TypeScript SDK for ThinkHive - AI Agent Observability Platform.
npm install @thinkhive/sdk
import { init, runs, traceLLM, shutdown } from '@thinkhive/sdk';
// Initialize the SDK
init({
apiKey: 'th_your_api_key',
serviceName: 'my-ai-agent',
autoInstrument: true,
frameworks: ['langchain', 'openai'],
});
// Create a run (atomic unit of work)
const run = await runs.create({
agentId: 'weather-agent',
conversation: [
{ role: 'user', content: 'What is the weather in San Francisco?' },
{ role: 'assistant', content: 'The weather in San Francisco is currently 65°F and sunny.' }
],
outcome: 'success',
});
console.log(`Run ID: ${run.id}`);
// Shutdown when done
await shutdown();
import { init, traceLLM, traceRetrieval, traceTool, traceChain } from '@thinkhive/sdk';
init({ apiKey: 'th_your_api_key', serviceName: 'my-agent' });
// Trace an LLM call
const response = await traceLLM({
name: 'generate-response',
modelName: 'gpt-4',
provider: 'openai',
input: { prompt: 'Hello!' }
}, async () => {
// Your LLM call here
return await openai.chat.completions.create({...});
});
// Trace a retrieval operation
const docs = await traceRetrieval({
name: 'search-knowledge-base',
query: 'refund policy',
topK: 5
}, async () => {
return await vectorStore.similaritySearch(query, 5);
});
// Trace a tool call
const result = await traceTool({
name: 'lookup-order',
toolName: 'order_lookup',
parameters: { orderId: '12345' }
}, async () => {
return await lookupOrder('12345');
});
import { analyzer } from '@thinkhive/sdk';
// Estimate cost before running analysis
const estimate = await analyzer.estimateCost({
traceIds: ['trace-1', 'trace-2', 'trace-3'],
tier: 'standard',
});
console.log(`Estimated cost: $${estimate.estimatedCost}`);
// Analyze specific traces
const analysis = await analyzer.analyze({
traceIds: ['trace-1', 'trace-2'],
tier: 'standard',
includeRootCause: true,
includeLayers: true,
});
// Analyze traces by time window with smart sampling
const windowAnalysis = await analyzer.analyzeWindow({
agentId: 'support-agent',
startDate: new Date('2024-01-01'),
endDate: new Date('2024-01-31'),
filters: { outcomes: ['failure'], minSeverity: 'medium' },
sampling: { strategy: 'smart', samplePercent: 10 },
});
// Get aggregated insights
const summary = await analyzer.summarize({
agentId: 'support-agent',
startDate: new Date('2024-01-01'),
endDate: new Date('2024-01-31'),
});
import { issues } from '@thinkhive/sdk';
// List issues for an agent
const issueList = await issues.list('support-agent', {
status: 'open',
limit: 10,
});
// Get a specific issue
const issue = await issues.get('issue-123');
// Get fixes for an issue
const fixes = await issues.getFixes('issue-123');
import { apiKeys, hasPermission, canAccessAgent } from '@thinkhive/sdk';
// Create a scoped API key
const result = await apiKeys.create({
name: 'CI Pipeline Key',
permissions: {
read: true,
write: true,
delete: false
},
scopeType: 'agent', // Restrict to specific agents
allowedAgentIds: ['agent-prod-001'],
environment: 'production',
expiresAt: new Date(Date.now() + 90 * 24 * 60 * 60 * 1000) // 90 days
});
console.log(`Key created: ${result.name} (${result.keyPrefix}...)`);
// Check permissions
if (hasPermission(key, 'write')) {
// Can write data
}
// Check agent access
if (canAccessAgent(key, 'agent-123')) {
// Can access this agent
}
import { claims, isFact, isInference, getHighConfidenceClaims } from '@thinkhive/sdk';
// List claims for a run
const claimList = await claims.list(runId);
// Filter by type
const facts = claimList.filter(isFact);
const inferences = claimList.filter(isInference);
// Get high confidence claims
const confident = getHighConfidenceClaims(claimList, 0.9);
import { calibration, calculateBrierScore, isWellCalibrated } from '@thinkhive/sdk';
// Get calibration status
const status = await calibration.getStatus(agentId);
// Calculate Brier score for predictions
const brierScore = calculateBrierScore(predictions, outcomes);
// Check if well calibrated
if (isWellCalibrated(status)) {
console.log('Agent predictions are well calibrated');
}
import {
businessMetrics,
isMetricReady,
needsMoreTraces,
getStatusMessage
} from '@thinkhive/sdk';
// Get current metric value with status
const metric = await businessMetrics.current('agent-123', 'Deflection Rate');
console.log(`${metric.metricName}: ${metric.valueFormatted}`);
if (metric.status === 'insufficient_data') {
console.log(`Need ${metric.minTraceThreshold - metric.traceCount} more traces`);
}
// Get historical data for graphing
const history = await businessMetrics.history('agent-123', 'Deflection Rate', {
startDate: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000),
endDate: new Date(),
granularity: 'daily',
});
console.log(`${history.dataPoints.length} data points`);
console.log(`Change: ${history.summary.changePercent}%`);
// Record external metric values (from CRM, surveys, etc.)
await businessMetrics.record('agent-123', {
metricName: 'CSAT/NPS',
value: 4.5,
unit: 'score',
periodStart: '2024-01-01T00:00:00Z',
periodEnd: '2024-01-07T23:59:59Z',
source: 'survey_system',
sourceDetails: { surveyId: 'survey_456', responseCount: 150 },
});
| Status | Description |
|---|---|
ready | Metric calculated and ready to display |
insufficient_data | Need more traces before calculation |
awaiting_external | External data source not connected |
stale | Data is older than expected |
import {
linking,
generateZendeskMarker,
linkRunToZendeskTicket
} from '@thinkhive/sdk';
// Generate a marker to embed in ticket
const marker = generateZendeskMarker(runId);
// Returns: <!-- thinkhive:run:abc123 -->
// Link a run to a ticket
await linkRunToZendeskTicket(runId, ticketId);
// Get best linking method
import { getBestLinkMethod } from '@thinkhive/sdk';
const method = getBestLinkMethod(runData);
// Returns: 'conversation_id' | 'subject_hash' | 'marker' | etc.
import { init } from '@thinkhive/sdk';
// Initialize with auto-instrumentation
init({
apiKey: 'th_your_api_key',
serviceName: 'my-ai-agent',
autoInstrument: true,
frameworks: ['langchain', 'openai', 'anthropic']
});
// Now all LangChain, OpenAI, and Anthropic calls are automatically traced!
| Tier | Description | Use Case |
|---|---|---|
fast | Quick pattern-based analysis | High-volume, low-latency needs |
standard | LLM-powered analysis | Default for most use cases |
deep | Multi-pass with validation | Critical traces, root cause analysis |
| Variable | Description |
|---|---|
THINKHIVE_API_KEY | Your ThinkHive API key |
THINKHIVE_ENDPOINT | Custom API endpoint (default: https://demo.thinkhive.ai) |
THINKHIVE_SERVICE_NAME | Service name for traces (optional) |
Run-Centric Model: The atomic unit of work is a "Run" (not a trace). A run captures:
Facts vs Inferences: Claims API separates:
Calibrated Predictions: Track prediction accuracy using:
| API | Description |
|---|---|
runs | Create and manage runs (atomic work units) |
claims | Manage facts/inferences for runs |
calibration | Track prediction accuracy |
analyzer | User-selected trace analysis |
issues | Clustered failure patterns |
linking | Connect runs to support tickets |
customerContext | Time-series customer snapshots |
apiKeys | API key management |
businessMetrics | Industry-driven metrics with historical tracking |
roiAnalytics | Business ROI and financial impact analysis |
qualityMetrics | RAG evaluation and hallucination detection |
| API | Description |
|---|---|
humanReview | Human-in-the-loop review queues |
nondeterminism | Multi-sample reliability testing |
evalHealth | Evaluation metric health monitoring |
deterministicGraders | Rule-based evaluation |
conversationEval | Multi-turn conversation evaluation |
transcriptPatterns | Pattern detection in transcripts |
See API Documentation for complete type definitions.
MIT License - see LICENSE for details.
FAQs
ThinkHive SDK v3.3 - AI agent observability with business metrics, ROI analytics, and 25+ trace format support
The npm package @thinkhive/sdk receives a total of 17 weekly downloads. As such, @thinkhive/sdk popularity was classified as not popular.
We found that @thinkhive/sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Following multiple malicious extension incidents, Open VSX outlines new safeguards designed to catch risky uploads earlier.

Research
/Security News
Threat actors compromised four oorzc Open VSX extensions with more than 22,000 downloads, pushing malicious versions that install a staged loader, evade Russian-locale systems, pull C2 from Solana memos, and steal macOS credentials and wallets.

Security News
Lodash 4.17.23 marks a security reset, with maintainers rebuilding governance and infrastructure to support long-term, sustainable maintenance.