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

analyst-agent-sdk

v0.1.1

Published

TypeScript SDK for the Analyst Agent AI data analysis service

Readme

Analyst Agent TypeScript SDK

TypeScript/JavaScript client for the Analyst Agent AI data analysis service.

Installation

npm install @analyst-agent/typescript-sdk

Quick Start

import { AnalystClient } from '@analyst-agent/typescript-sdk';

const client = new AnalystClient({
  baseUrl: 'http://localhost:8000',
  apiKey: 'your-api-key' // Optional
});

// Submit a question for analysis
const response = await client.ask({
  question: 'What are the sales trends over the last quarter?',
  data_source: {
    type: 'postgres',
    connection_string: 'postgresql://user:pass@localhost:5432/sales_db'
  },
  preferences: {
    analysis_types: ['descriptive', 'predictive'],
    chart_types: ['line', 'bar']
  }
});

console.log('Job ID:', response.job_id);

// Check job status
const status = await client.getJobStatus(response.job_id);
console.log('Status:', status.status);

// Wait for completion and get results
const result = await client.waitForCompletion(response.job_id);
console.log('Analysis completed:', result.summary);

Convenience Methods

Quick Analysis

For simple use cases, use the quickAnalysis method:

const result = await client.quickAnalysis(
  'What are the top selling products?',
  { type: 'csv', file_path: './sales.csv' }
);

console.log(AnalystClient.getInsightsSummary(result));

Ask and Wait

Submit a question and automatically wait for completion:

const result = await client.askAndWait({
  question: 'Analyze customer churn patterns',
  data_source: { type: 'postgres', connection_string: 'postgresql://...' }
}, {
  onProgress: (status) => console.log(`Progress: ${status.progress}`)
});

Data Source Types

The SDK supports multiple data source types:

PostgreSQL

{
  type: 'postgres',
  connection_string: 'postgresql://user:pass@host:port/db'
}

CSV Files

{
  type: 'csv',
  file_path: './data.csv'
}

MySQL

{
  type: 'mysql',
  connection_string: 'mysql://user:pass@host:port/db'
}

SQLite

{
  type: 'sqlite',
  file_path: './database.db'
}

Error Handling

import { AnalystAgentError } from '@analyst-agent/typescript-sdk';

try {
  const result = await client.ask(request);
} catch (error) {
  if (error instanceof AnalystAgentError) {
    console.error('API Error:', error.message);
    console.error('Status:', error.status);
    console.error('Details:', error.details);
  } else {
    console.error('Unexpected error:', error);
  }
}

Configuration Options

const client = new AnalystClient({
  baseUrl: 'http://localhost:8000',  // Required: API base URL
  apiKey: 'your-api-key',            // Optional: API key for authentication
  timeout: 30000,                    // Optional: Request timeout in ms
  retries: 3,                        // Optional: Number of retries
  retryDelay: 1000                   // Optional: Delay between retries in ms
});

Analysis Preferences

Customize analysis behavior:

{
  analysis_types: ['descriptive', 'inferential', 'predictive'],
  chart_types: ['bar', 'line', 'scatter', 'histogram'],
  include_code: true,           // Include generated Python code
  confidence_threshold: 0.8,    // Minimum confidence for insights
  max_execution_time: 300       // Max execution time in seconds
}

Helper Methods

Extract Insights Summary

const summary = AnalystClient.getInsightsSummary(result);
console.log(summary);

Extract Chart Data

const chartData = AnalystClient.extractChartData(result);
chartData.forEach(chart => {
  console.log(`Chart: ${chart.title} (${chart.type})`);
  console.log('Data:', chart.data);
});

TypeScript Support

The SDK is written in TypeScript and includes full type definitions:

import type { 
  AnalysisRequest, 
  AnalysisResult, 
  DataSourceConfig 
} from '@analyst-agent/typescript-sdk';

const request: AnalysisRequest = {
  question: 'Analyze sales data',
  data_source: {
    type: 'postgres',
    connection_string: 'postgresql://...'
  }
};

Browser Support

The SDK works in both Node.js and modern browsers. For browser usage, ensure your bundler handles the dependencies correctly.

Examples

See the /examples directory for complete usage examples:

  • examples/node-example.js - Node.js usage
  • examples/react-example.tsx - React integration
  • examples/csv-analysis.js - CSV file analysis

Contributing

  1. Clone the repository
  2. Install dependencies: npm install
  3. Build: npm run build
  4. Test: npm run test
  5. Lint: npm run lint

License

MIT License - see LICENSE file for details.