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

@agentguardorg/node

v0.1.0

Published

Official Node.js / TypeScript SDK for AgentGuard — AI action firewall

Readme

@agentguardorg/node

Official Node.js / TypeScript SDK for AgentGuard — the AI action firewall that keeps your agents safe.

Install

npm install @agentguardorg/node
# or
pnpm add @agentguardorg/node
# or
yarn add @agentguardorg/node

Requirements: Node.js 18 or later (uses native fetch).

Quick Start

import { AgentGuard } from "@agentguardorg/node";

const guard = new AgentGuard({ apiKey: "ag_live_YOUR_KEY_HERE" });

Then, before your agent executes any action:

const result = await guard.check({
  action: "send_email",
  payload: { to: "[email protected]", body: "Hello!" },
});

if (result.decision === "block") {
  throw new Error(`Action blocked: ${result.reason}`);
}

// proceed with the action

Constructor Options

new AgentGuard({
  apiKey: string;          // required — from your AgentGuard dashboard
  baseUrl?: string;        // default: https://agentguard.dev/api
                           // also read from AGENTGUARD_BASE_URL env var
  timeoutMs?: number;      // default: 5000
})

The baseUrl is resolved in this order:

  1. options.baseUrl passed to the constructor
  2. AGENTGUARD_BASE_URL environment variable
  3. https://agentguard.dev/api (production default)

guard.check() Reference

const result = await guard.check({
  action: string;                        // required — name of the action
  payload: Record<string, unknown>;      // required — data the agent is acting on
  agentId?: string;                      // which agent is acting (improves logging)
  appUserId?: string;                    // end user ID (enables cross-user detection)
  appName?: string;                      // identifies your app in the dashboard
  riskContext?: Record<string, unknown>; // extra metadata for risk scoring
});

Return value

{
  decision: "allow" | "block" | "review";
  riskLevel: "low" | "medium" | "high" | "critical";
  reason: string;
  logId: number | null;
  promptInjectionDetected: boolean;
}

Handling Each Decision

const result = await guard.check({ action, payload });

switch (result.decision) {
  case "allow":
    // Safe to proceed. Execute the action.
    await executeAction(action, payload);
    break;

  case "review":
    // High-risk but not definitively malicious.
    // Queue for human review or notify your security team.
    await queueForReview(action, payload, result.reason);
    break;

  case "block":
    // Policy violation or detected threat. Do NOT proceed.
    throw new Error(`Blocked (${result.riskLevel}): ${result.reason}`);
}

Error Handling

The SDK throws typed errors so you can handle failures precisely:

import {
  AgentGuard,
  AgentGuardAuthError,
  AgentGuardNetworkError,
  AgentGuardServerError,
} from "@agentguardorg/node";

try {
  const result = await guard.check({ action, payload });
} catch (err) {
  if (err instanceof AgentGuardAuthError) {
    // Invalid or expired API key — check your dashboard
    console.error("Auth error:", err.message);
  } else if (err instanceof AgentGuardNetworkError) {
    // Connectivity issue — the SDK already retried once
    // Fall back gracefully (allow or queue for later)
    console.error("Network error:", err.message);
  } else if (err instanceof AgentGuardServerError) {
    // Unexpected server error (5xx)
    console.error(`Server error ${err.statusCode}:`, err.message);
  } else {
    throw err;
  }
}

The SDK automatically retries once on network errors. Auth errors and server errors are never retried.

Example — Express Route

import express from "express";
import { AgentGuard } from "@agentguardorg/node";

const guard = new AgentGuard({ apiKey: process.env.AGENTGUARD_KEY! });
const app = express();
app.use(express.json());

app.post("/agent/send-email", async (req, res) => {
  const { to, body, userId, agentId } = req.body;

  const result = await guard.check({
    action: "send_email",
    payload: { to, body },
    appUserId: userId,
    agentId,
  });

  if (result.decision === "block") {
    return res.status(403).json({ error: result.reason });
  }

  // send the email...
  res.json({ ok: true });
});

Publishing to npm

When you're ready to publish:

cd sdks/node
pnpm run build
npm publish --access public

Make sure your package.json has the correct name, version, and license fields before publishing.

Links