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

@damitha-perera/agentgate

v0.1.1

Published

Authorization middleware SDK for AI agents — powered by AgentGate

Readme

agentgate

Authorization middleware SDK for AI agents — powered by AgentGate

One import. One call. Every AI agent action authorized through a 5-gate security pipeline.

npm install @damitha-perera/agentgate

Quick Start

import { AgentGate } from '@damitha-perera/agentgate';

const gate = new AgentGate({
  baseUrl: 'https://agent-gate-theta.vercel.app',
  apiKey: process.env.AGENTGATE_API_KEY!,
});

// 1. Register your agent once (store the token)
const agent = await gate.register({
  name: 'my-crewai-agent',
  framework: 'crewai',
  capabilities: ['gmail.read', 'github.write'],
  trustLevel: 1,
});

// 2. Authorize every action before it executes
const result = await gate.authorize({
  agentToken: agent.token,
  action: { type: 'read', operation: 'list_emails', service: 'gmail' },
  resource: { type: 'email' },
  context: { recipientExternal: false },
});

if (!result.allowed) throw new Error(result.reason);

// result.token is a scoped, 60-second token — use it to call the real API
console.log(result.token?.access_token);

The 5 Gates

Every authorize() call passes through:

| Gate | What it does | | ---- | ------------ | | 1 — Identity | Verifies agent SPIFFE ID and JWT | | 2 — Intent | Parses AuthZEN 4-tuple (who, what, where, context) | | 3 — Policy | Evaluates rules → ALLOW / ESCALATE / DENY | | 4 — Consent | Auth0 CIBA push notification for human approval | | 5 — Token | Issues scoped, 60-second token from Auth0 Token Vault |

API

new AgentGate(config)

const gate = new AgentGate({
  apiKey: 'ag_live_...',      // Required — generate at /dashboard → API Keys
  baseUrl: 'https://...',     // Optional — defaults to agent-gate-theta.vercel.app
});

gate.register(opts): Promise<RegisteredAgent>

Register a new agent. Call once and store the returned token.

const agent = await gate.register({
  name: 'my-agent',
  framework: 'crewai',           // 'crewai' | 'langgraph' | 'autogen' | 'custom' | 'mcp'
  capabilities: ['gmail.read'],
  trustLevel: 1,                 // 1–5, lower = more restrictions
});
// agent.token — pass to authorize()
// agent.id    — store for revocation
// agent.spiffeId — cryptographic identity

gate.authorize(opts): Promise<AuthorizeResult>

Authorize an action. Call before every agent action.

const result = await gate.authorize({
  agentToken: agent.token,
  action: {
    type: 'write',             // 'read' | 'write' | 'delete' | 'execute'
    operation: 'send_email',
    service: 'gmail',
  },
  resource: { type: 'email' },
  context: { recipientExternal: true },
});

// result.allowed   — boolean
// result.decision  — 'ALLOWED' | 'DENIED' | 'ESCALATED'
// result.reason    — human-readable explanation
// result.token     — scoped access token (only when allowed)

gate.revokeAgent(agentId): Promise<RevokeResult>

Revoke a specific agent. All future authorize() calls for this agent will be denied.

gate.revokeService(service): Promise<RevokeResult>

Revoke all agents for a service (e.g. "gmail").

gate.panic(): Promise<RevokeResult>

Emergency: revoke ALL agents immediately.

Decisions

| Decision | Meaning | | -------- | ------- | | ALLOWED | Action approved, result.token contains a scoped 60s token | | DENIED | Action blocked by policy, check result.reason | | ESCALATED | Waiting for human approval via Auth0 CIBA push notification |

LangGraph Example

import { AgentGate } from '@damitha-perera/agentgate';
import { StateGraph } from '@langchain/langgraph';

const gate = new AgentGate({ apiKey: process.env.AGENTGATE_API_KEY! });
const agent = await gate.register({
  name: 'langgraph-writer',
  framework: 'langgraph',
  capabilities: ['gmail.write'],
  trustLevel: 3,
});

const graph = new StateGraph({ ... })
  .addNode('send_email', async (state) => {
    const result = await gate.authorize({
      agentToken: agent.token,
      action: { type: 'write', operation: 'send_email', service: 'gmail' },
      resource: { type: 'email' },
      context: { recipientExternal: state.isExternal },
    });

    if (result.decision === 'ESCALATED') {
      return { ...state, status: 'waiting_for_approval' };
    }
    if (!result.allowed) {
      throw new Error(`Denied: ${result.reason}`);
    }

    // Use result.token.access_token to call Gmail API
  });

CrewAI Example (Python SDK coming soon)

For Python agents, call the REST API directly until agentgate-python is released:

import os, requests

API_KEY = os.environ["AGENTGATE_API_KEY"]
BASE = "https://agent-gate-theta.vercel.app"
HEADERS = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}

# Register
agent = requests.post(f"{BASE}/api/agents/register", json={
    "name": "crewai-agent", "framework": "crewai",
    "capabilities": ["gmail.read"], "trustLevel": 1
}, headers=HEADERS).json()

# Authorize
result = requests.post(f"{BASE}/api/authorize", json={
    "agentToken": agent["token"],
    "action": {"type": "read", "operation": "list_emails", "service": "gmail"},
    "resource": {"type": "email"},
}, headers=HEADERS).json()

if not result["allowed"]:
    raise Exception(result["reason"])

Generate an API Key

  1. Go to agent-gate-theta.vercel.app/dashboard
  2. Log in → API Keys section
  3. Click Generate Key — copy the ag_live_... key (shown once)
  4. Set AGENTGATE_API_KEY in your environment

License

MIT