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

@bastion-ai/sdk

v0.1.1

Published

TypeScript SDK for the Bastion trust proxy for AI agents

Readme

@bastion-ai/sdk

TypeScript SDK for the Bastion trust proxy. Zero runtime dependencies — uses the global fetch API.

Installation

npm install @bastion-ai/sdk

Requires Node.js 22+ (for native fetch).

Quick Start

import { BastionClient } from '@bastion-ai/sdk';

const client = new BastionClient({
  baseUrl: 'http://localhost:3000',
  apiKey: process.env.PROJECT_API_KEY!, // admin key for management
});

// Check health
const health = await client.health();

Admin Operations

Use the admin API key (PROJECT_API_KEY) to manage agents, credentials, and policies.

Agents

// Create an agent (returns one-time agentSecret)
const { id, agentSecret } = await client.createAgent({
  name: 'Support Bot',
  description: 'Handles refund requests',
  callbackUrl: 'https://example.com/webhook',
});

// List, get, update, delete
const agents = await client.listAgents();
const agent = await client.getAgent(id);
await client.updateAgent(id, { isActive: false });
await client.deleteAgent(id); // soft-delete

Credentials

// Store a credential (encrypted at rest, raw value never returned)
const credential = await client.createCredential({
  name: 'Stripe Production',
  type: 'API_KEY',
  value: 'sk_live_...',
  agentId: agent.id,
});

const credentials = await client.listCredentials(agent.id);
await client.revokeCredential(credential.id);

Policies

const policy = await client.createPolicy({
  agentId: agent.id,
  credentialId: credential.id,
  allowedActions: ['charges.*'],
  deniedActions: ['transfers.*'],
  constraints: {
    maxAmountPerTransaction: 1000,
    maxDailySpend: 5000,
    rateLimit: { maxRequests: 100, windowSeconds: 3600 },
  },
  requiresApprovalAbove: 500,
});

// Dry-run evaluation (no side effects)
const result = await client.evaluatePolicy({
  agentId: agent.id,
  credentialId: credential.id,
  action: 'charges.create',
  params: { amount: 750 },
});
// result.decision → "ESCALATE"

Agent Operations

Use an agent secret (bst_...) for proxy execution.

const agentClient = new BastionClient({
  baseUrl: 'http://localhost:3000',
  apiKey: agentSecret, // agent secret from createAgent
});

const result = await agentClient.execute({
  credentialId: credential.id,
  action: 'charges.create',
  params: { amount: 50 },
  target: {
    url: 'https://api.stripe.com/v1/charges',
    method: 'POST',
    body: { amount: 5000, currency: 'usd' },
  },
});

// result.upstream.status → 200
// result.upstream.body → Stripe's response
// result.meta.policyDecision → "ALLOW"

Custom Credential Injection

await agentClient.execute({
  credentialId: credential.id,
  action: 'test',
  target: { url: 'https://api.example.com' },
  injection: { location: 'header', key: 'X-Api-Key' },
});

HITL (Human-in-the-Loop)

const pending = await client.listPendingRequests();
await client.approveRequest(pending[0].requestId);
await client.denyRequest(requestId, 'Too risky');

Audit

const records = await client.queryAuditRecords({
  agentId: agent.id,
  from: '2026-01-01',
  policyDecision: 'DENY',
  limit: 10,
});

const verification = await client.verifyChain(agent.id);
// verification.valid → true

Error Handling

All API errors throw typed exceptions:

import { BastionForbiddenError, BastionNotFoundError } from '@bastion-ai/sdk';

try {
  await agentClient.execute({ ... });
} catch (err) {
  if (err instanceof BastionForbiddenError) {
    console.log('Policy denied:', err.message);
  }
}

| Error Class | Status | When | | ------------ | ------ | ---- | | BastionValidationError | 400 | Invalid input | | BastionUnauthorizedError | 401 | Bad or missing auth | | BastionForbiddenError | 403 | Policy DENY or HITL timeout | | BastionNotFoundError | 404 | Resource not found | | BastionConflictError | 409 | State conflict | | BastionBadGatewayError | 502 | Upstream API failure |

License

MIT