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

@preclinical/sdk

v0.2.2

Published

TypeScript SDK for the Preclinical healthcare AI safety testing platform

Readme

Preclinical TypeScript SDK

TypeScript SDK for the Preclinical healthcare AI safety testing platform.

Installation

npm install @preclinical/sdk

Quick Start

import { Preclinical } from '@preclinical/sdk';

const client = new Preclinical({ apiKey: 'sk_live_...' });

// Start a test and wait for completion
const test = await client.tests.runAndWait({
  agent_id: 'your-agent-id',
  test_mode: 'demo',
});

console.log(`Status: ${test.status}`);
console.log(`Pass rate: ${test.pass_rate}%`);

// Get detailed results
const results = await client.tests.results(test.id);
for (const r of results.data) {
  const status = r.passed ? 'PASS' : 'FAIL';
  console.log(`[${status}] ${r.scenario_name}`);
}

Usage

Initialize the Client

import { Preclinical } from '@preclinical/sdk';

const client = new Preclinical({
  apiKey: 'sk_live_...',
  baseUrl: 'https://app.preclinical.dev', // optional, defaults to production
});

Agents

// List all agents
const agents = await client.agents.list();

// Create an agent
const agent = await client.agents.create({
  name: 'My Agent',
  provider: 'openai',
  config: {
    api_key: 'sk-...',
    base_url: 'https://api.openai.com/v1',
    target_model: 'gpt-4o',
  },
});

// Get an agent
const fetched = await client.agents.get(agent.id);

// Update an agent
const updated = await client.agents.update(agent.id, { name: 'Renamed Agent' });

// Validate agent configuration
const validation = await client.agents.validate(agent.id);

// Delete an agent
await client.agents.delete(agent.id);

Tests

// Create a test
const created = await client.tests.create({
  agent_id: agent.id,
  test_mode: 'demo', // 'demo' or 'full'
  max_turns: 6,
});

// Get test status
const test = await client.tests.get(created.id);

// List tests with pagination
const tests = await client.tests.list({ limit: 10, offset: 0, status: 'completed' });

// Get test results (scenario-level summaries)
const results = await client.tests.results(test.id);

// Cancel a running test
await client.tests.cancel(test.id);

// Run and wait for completion with progress callback
const completed = await client.tests.runAndWait(
  { agent_id: agent.id, test_mode: 'demo' },
  {
    intervalMs: 10_000,
    timeoutMs: 30 * 60 * 1000,
    onProgress: (t) => console.log(`Status: ${t.status}`),
  }
);

Scenario Runs

Access individual scenario run details including full conversation transcripts.

// List scenario runs for a test
const runs = await client.scenarioRuns.list(test.id, { limit: 10 });

// Get a single scenario run with transcript
const run = await client.scenarioRuns.get(runs.data[0].id);
console.log(`Passed: ${run.passed}`);
console.log(`Grade: ${run.grade_summary}`);

// Print the conversation transcript
for (const entry of run.transcript) {
  console.log(`[${entry.role}]: ${entry.content}`);
}

Scenarios

// List available scenarios
const scenarios = await client.scenarios.list({ limit: 50 });

// Get a specific scenario
const scenario = await client.scenarios.get(scenarios.data[0].id);

Webhooks

// List webhooks
const webhooks = await client.webhooks.list();

// Create a webhook
const webhook = await client.webhooks.create({
  url: 'https://example.com/webhook',
  description: 'Test completion notifications',
  secret: 'whsec_...',
});

// Get a webhook
const fetched = await client.webhooks.get(webhook.id);

// Update a webhook
await client.webhooks.update(webhook.id, { is_enabled: false });

// Test a webhook
const testResult = await client.webhooks.test(webhook.id);

// Get delivery history
const deliveries = await client.webhooks.deliveries(webhook.id);

// Delete a webhook
await client.webhooks.delete(webhook.id);

Error Handling

import { Preclinical, PreclinicalError } from '@preclinical/sdk';

const client = new Preclinical({ apiKey: 'sk_live_...' });

try {
  const test = await client.tests.get('nonexistent-id');
} catch (err) {
  if (err instanceof PreclinicalError) {
    console.error(`API error: ${err.message} (status: ${err.status}, code: ${err.code})`);
  }
}

Types

All types are exported from the package:

import type {
  Agent,
  CreateAgentParams,
  UpdateAgentParams,
  ValidationResult,
  TestRun,
  TestRunCreated,
  CreateTestParams,
  ScenarioResult,
  ScenarioRun,
  Scenario,
  Webhook,
  CreateWebhookParams,
  UpdateWebhookParams,
  WebhookTestResult,
  WebhookDelivery,
  ListParams,
  PaginatedResponse,
  PollOptions,
  PreclinicalConfig,
} from '@preclinical/sdk';

Documentation

Full API docs at docs.preclinical.co