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

vaspera-guard

v0.2.2

Published

TypeScript SDK for VasperaGuard - AI Agent Safety & Governance

Readme

@vaspera/guard

TypeScript SDK for VasperaGuard - AI Agent Safety & Governance.

Installation

npm install @vaspera/guard
# or
yarn add @vaspera/guard
# or
pnpm add @vaspera/guard

Quick Start

import { Guard } from '@vaspera/guard';

const guard = new Guard({ apiKey: 'vg_...' });

// Check if a command is safe
const result = await guard.check('rm -rf ./temp');

if (result.allowed) {
  console.log('Command is safe to execute');
} else if (result.requiresApproval) {
  console.log('Command requires human approval');
  // Request approval via Slack
  const approval = await guard.requestApproval(result.checkId, {
    channel: 'slack',
    slackChannel: '#devops-approvals'
  });
} else {
  console.log('Command blocked:', result.reason);
  console.log('Suggestions:', result.suggestions);
}

Features

  • Command Safety Analysis - Check commands before execution
  • Human-in-the-Loop Approval - Request approval via Slack, email, or webhook
  • Policy Management - Create and manage safety policies
  • Audit Trail - Query audit logs for compliance
  • TypeScript First - Full type definitions included

API Reference

Constructor

const guard = new Guard({
  apiKey: 'vg_...',           // Required: Your API key
  baseUrl: 'https://...',     // Optional: Custom API URL
  timeout: 30000,             // Optional: Request timeout (ms)
  environment: 'production',  // Optional: Default environment
  project: 'my-app',          // Optional: Default project
  policies: ['policy-1']      // Optional: Default policies
});

Check Command

const result = await guard.check('npm run build', {
  agentId: 'my-agent',
  context: {
    environment: 'production',
    project: 'backend-api'
  }
});

// Result shape
{
  allowed: boolean;
  blocked: boolean;
  requiresApproval: boolean;
  riskScore: number;        // 0-1
  riskLevel: 'low' | 'medium' | 'high' | 'critical';
  reason: string;
  suggestions: string[];
  patterns: string[];       // Dangerous patterns detected
  nearMisses: NearMiss[];   // Typo detection
  checkId: string;
  timestamp: string;
}

Check and Execute

import { execSync } from 'child_process';

// Throws if blocked or requires approval
const { result, check } = await guard.checkAndExecute(
  'ls -la',
  async (cmd) => execSync(cmd).toString()
);

Request Approval

// Slack
const approval = await guard.requestApproval(checkId, {
  channel: 'slack',
  slackChannel: '#devops',
  timeoutMinutes: 30
});

// Email
const approval = await guard.requestApproval(checkId, {
  channel: 'email',
  emails: ['[email protected]'],
  timeoutMinutes: 60
});

// Webhook
const approval = await guard.requestApproval(checkId, {
  channel: 'webhook',
  webhookUrl: 'https://your-app.com/webhooks/approval',
  webhookHeaders: { 'X-Custom-Header': 'value' }
});

Wait for Approval

const approval = await guard.waitForApproval(approvalId, {
  timeoutMs: 300000,      // 5 minutes
  pollIntervalMs: 5000    // Poll every 5 seconds
});

if (approval.status === 'approved') {
  // Execute command
}

Policy Management

// Create policy
const policy = await guard.createPolicy({
  name: 'production-safety',
  rules: [
    { pattern: 'DROP TABLE', action: 'block' },
    { pattern: 'rm -rf /', action: 'block' },
    { pattern: 'chmod 777', action: 'require_approval' }
  ]
});

// Get all policies
const policies = await guard.getPolicies();

// Get specific policy
const policy = await guard.getPolicy('policy-id');

// Delete policy
await guard.deletePolicy('policy-id');

Audit Log

const audit = await guard.getAuditLog({
  limit: 100,
  riskLevel: 'critical',
  agentId: 'my-agent',
  startDate: '2024-01-01T00:00:00Z'
});

for (const entry of audit.entries) {
  console.log(entry.command, entry.riskLevel, entry.checkResult);
}

Error Handling

import {
  Guard,
  GuardError,
  AuthenticationError,
  RateLimitError
} from '@vaspera/guard';

try {
  await guard.check('some command');
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.log('Invalid API key');
  } else if (error instanceof RateLimitError) {
    console.log('Rate limited, retry after:', error.retryAfter);
  } else if (error instanceof GuardError) {
    console.log('API error:', error.code, error.message);
  }
}

License

MIT