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

@supermodeltools/sdk

v0.10.0

Published

TypeScript SDK for the Supermodel API - code graph generation and analysis

Downloads

3,591

Readme

Supermodel TypeScript SDK

Official TypeScript/JavaScript SDK for the Supermodel API.

Generate code graphs, dependency analysis, and domain models from your source code repositories.

Installation

npm install @supermodeltools/sdk

Quick Start

Basic Usage (Auto-Polling)

The SDK provides a high-level SupermodelClient that automatically handles async job polling:

import { SupermodelClient, DefaultApi, Configuration } from '@supermodeltools/sdk';
import { readFile } from 'node:fs/promises';

// Configure the API client
const api = new DefaultApi(new Configuration({
  basePath: 'https://api.supermodeltools.com',
  apiKey: () => process.env.SUPERMODEL_API_KEY || ''
}));

// Create the async client wrapper
const client = new SupermodelClient(api);

// Generate a code graph (polling handled automatically)
const zipBuffer = await readFile('./my-repo.zip');
const zipBlob = new Blob([zipBuffer]);

const result = await client.generateSupermodelGraph(zipBlob);
console.log(`Generated graph with ${result.graph.nodes.length} nodes`);

Advanced Configuration

Configure polling behavior for long-running operations:

const client = new SupermodelClient(api, {
  // Maximum time to wait for job completion
  timeoutMs: 900000,  // 15 minutes (default)

  // Polling interval when server doesn't specify
  defaultRetryIntervalMs: 10000,  // 10 seconds (default)

  // Maximum number of polling attempts
  maxPollingAttempts: 90,  // (default)

  // Progress callback
  onPollingProgress: (progress) => {
    console.log(`Job ${progress.jobId}: ${progress.status} ` +
                `(${progress.attempt}/${progress.maxAttempts})`);
  },

  // Cancellation support
  signal: abortController.signal,
});

Per-Request Configuration

Override client defaults for specific requests:

// Use a custom idempotency key
const result = await client.generateDependencyGraph(zipBlob, {
  idempotencyKey: 'my-repo:dependency:abc123',
});

// Add custom headers (e.g., for different auth)
const result = await client.generateCallGraph(zipBlob, {
  initOverrides: {
    headers: { 'Authorization': 'Bearer custom-token' }
  }
});

// Cancel a specific request
const controller = new AbortController();
const promise = client.generateParseGraph(zipBlob, {
  signal: controller.signal
});

// Later: controller.abort();

Available Methods

SupermodelClient (Async Wrapper)

All methods automatically handle polling until job completion:

  • generateSupermodelGraph(file, options?) - Full Supermodel IR with all analysis
  • generateDependencyGraph(file, options?) - Module/package dependencies
  • generateCallGraph(file, options?) - Function-level call relationships
  • generateDomainGraph(file, options?) - High-level domain model
  • generateParseGraph(file, options?) - AST-level parse tree

Raw API (Manual Polling)

Access the underlying API for manual control:

const rawApi = client.rawApi;

// Make initial request
let response = await rawApi.generateDependencyGraph({
  idempotencyKey: 'my-key',
  file: zipBlob
});

// Poll manually
while (response.status === 'pending' || response.status === 'processing') {
  await sleep(response.retryAfter * 1000);
  response = await rawApi.generateDependencyGraph({
    idempotencyKey: 'my-key',
    file: zipBlob
  });
}

if (response.status === 'completed') {
  console.log(response.result);
}

Configuration Options

AsyncClientOptions

| Option | Type | Default | Description | |--------|------|---------|-------------| | timeoutMs | number | 900000 (15 min) | Maximum time to wait for job completion | | defaultRetryIntervalMs | number | 10000 (10 sec) | Polling interval when server doesn't specify | | maxPollingAttempts | number | 90 | Maximum number of polling attempts | | onPollingProgress | function | undefined | Callback for polling progress updates | | generateIdempotencyKey | function | crypto.randomUUID() | Custom idempotency key generator | | signal | AbortSignal | undefined | AbortSignal for cancelling operations |

GraphRequestOptions

| Option | Type | Default | Description | |--------|------|---------|-------------| | idempotencyKey | string | auto-generated | Idempotency key for request deduplication | | initOverrides | RequestInit | undefined | Custom fetch options (headers, etc.) | | signal | AbortSignal | undefined | Request-specific abort signal |

Error Handling

import { JobFailedError, PollingTimeoutError } from '@supermodeltools/sdk';

try {
  const result = await client.generateDependencyGraph(zipBlob);
} catch (error) {
  if (error instanceof JobFailedError) {
    console.error(`Job ${error.jobId} failed: ${error.errorMessage}`);
  } else if (error instanceof PollingTimeoutError) {
    console.error(`Job ${error.jobId} timed out after ${error.timeoutMs}ms`);
  } else if (error.name === 'AbortError') {
    console.log('Operation cancelled');
  } else {
    throw error;
  }
}

Idempotency

The API uses idempotency keys to prevent duplicate processing. The same key will always return the same result:

// Generate a stable key from your repo state
import crypto from 'crypto';
import { execSync } from 'child_process';

const gitHash = execSync('git rev-parse --short HEAD').toString().trim();
const idempotencyKey = `my-project:supermodel:${gitHash}`;

// This will generate once, then return cached result on subsequent calls
const result = await client.generateSupermodelGraph(zipBlob, {
  idempotencyKey
});

Preparing Repository Archives

For Git Repositories (Recommended)

cd /path/to/your/repo
git archive -o /tmp/repo.zip HEAD

This automatically respects .gitignore and creates clean, reproducible archives.

For Any Directory

cd /path/to/your/repo
zip -r /tmp/repo.zip . \
  -x "node_modules/*" \
  -x ".git/*" \
  -x "dist/*" \
  -x "*.pyc" \
  -x "__pycache__/*"

What to Include

  • ✅ Source code files (.py, .js, .ts, .java, etc.)
  • ✅ Configuration files (package.json, pyproject.toml, etc.)
  • ✅ Type definitions (.d.ts, .pyi)
  • ❌ Dependencies (node_modules/, venv/, target/)
  • ❌ Build outputs (dist/, build/, .next/)
  • ❌ Large binaries, images, datasets

Size Limits

Archives should be under 50MB. If larger:

  • Ensure dependencies are excluded
  • Consider analyzing a subdirectory
  • Check for accidentally committed binaries

TypeScript Support

Full TypeScript definitions are included. Types are automatically resolved via package.json.

import type {
  SupermodelIR,
  CodeGraphEnvelope,
  DomainClassificationResponse,
} from '@supermodeltools/sdk';

// Types are available for all request/response models

Environment Support

  • ✅ Node.js (18+)
  • ✅ Modern browsers (with Blob support)
  • ✅ Webpack, Vite, Rollup
  • ✅ ES6 modules and CommonJS

Authentication

Get your API key from the Supermodel Dashboard.

const api = new DefaultApi(new Configuration({
  basePath: 'https://api.supermodeltools.com',
  apiKey: () => process.env.SUPERMODEL_API_KEY || ''
}));

Rate Limiting

The API includes rate limiting headers in responses:

const response = await rawApi.generateDependencyGraphRaw({
  idempotencyKey: 'key',
  file: blob
});

console.log(response.raw.headers.get('RateLimit-Limit'));
console.log(response.raw.headers.get('RateLimit-Remaining'));
console.log(response.raw.headers.get('RateLimit-Reset'));

Examples

Integration with mcpbr

import { SupermodelClient, DefaultApi, Configuration } from '@supermodeltools/sdk';

const api = new DefaultApi(new Configuration({
  basePath: process.env.SUPERMODEL_BASE_URL || 'https://api.supermodeltools.com',
  apiKey: () => process.env.SUPERMODEL_API_KEY || ''
}));

// Configure for long-running benchmark operations
const client = new SupermodelClient(api, {
  timeoutMs: 900000,           // 15 minutes
  maxPollingAttempts: 90,       // 90 attempts
  onPollingProgress: (progress) => {
    console.log(`[${progress.jobId}] ${progress.status} - ` +
                `attempt ${progress.attempt}/${progress.maxAttempts}`);
  }
});

Links

License

This SDK is licensed under the MIT License. See the main repository for details.