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

@authensor/claude-agent-sdk

v0.0.1

Published

Authensor guardrail adapter for Claude Agent SDK

Downloads

115

Readme

@authensor/claude-agent-sdk

Authensor guardrail adapter for the Claude Agent SDK. Evaluates every tool call against Authensor policies before execution.

Installation

npm install @authensor/claude-agent-sdk @anthropic-ai/sdk

Quick Start

import Anthropic from '@anthropic-ai/sdk';
import { AuthensorClaudeGuard } from '@authensor/claude-agent-sdk';

const client = new Anthropic();
const guard = new AuthensorClaudeGuard({
  controlPlaneUrl: 'http://localhost:3000',
  apiKey: process.env.AUTHENSOR_API_KEY,
});

// Define your tools
const tools = [
  {
    name: 'send_email',
    description: 'Send an email',
    input_schema: {
      type: 'object',
      properties: {
        to: { type: 'string' },
        subject: { type: 'string' },
        body: { type: 'string' },
      },
      required: ['to', 'subject', 'body'],
    },
  },
];

// Handle tool calls with Authensor evaluation
async function handleToolCall(name: string, input: Record<string, unknown>) {
  // Evaluate before executing — throws if denied
  await guard.guard(name, input);

  // If we get here, the action is allowed
  switch (name) {
    case 'send_email':
      return await sendEmail(input);
    default:
      throw new Error(`Unknown tool: ${name}`);
  }
}

Wrapping Tool Handlers

For a cleaner pattern, wrap your handlers directly:

import { AuthensorClaudeGuard } from '@authensor/claude-agent-sdk';

const guard = new AuthensorClaudeGuard('http://localhost:3000');

// Wrap individual handlers
const safeSendEmail = guard.wrapHandler('send_email', async (input) => {
  return await emailService.send(input);
});

// Or wrap tool/handler pairs
const { tool, handler } = guard.wrapTool(
  { name: 'send_email', description: 'Send an email' },
  async (input) => emailService.send(input),
);

// Or wrap all tools at once
const safeTools = guard.wrapTools([
  { tool: sendEmailTool, handler: sendEmailHandler },
  { tool: readFileTool, handler: readFileHandler },
]);

Approval Flow

Handle require_approval decisions with a callback:

const guard = new AuthensorClaudeGuard({
  controlPlaneUrl: 'http://localhost:3000',
  onApprovalRequired: async (toolName, args, reason) => {
    console.log(`Tool "${toolName}" requires approval: ${reason}`);
    // Implement your approval logic (Slack notification, human-in-the-loop, etc.)
    const approved = await askHumanForApproval(toolName, args);
    return approved;
  },
});

Manual Evaluation

For full control over the evaluation result:

const result = await guard.evaluate('send_email', { to: '[email protected]' });

if (result.allowed) {
  await sendEmail({ to: '[email protected]' });
} else if (result.requiresApproval) {
  // Queue for human review
  await queueForApproval(result.receiptId);
} else {
  console.error(`Denied: ${result.reason}`);
}

Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | controlPlaneUrl | string | (required) | Authensor control plane URL | | apiKey | string | AUTHENSOR_API_KEY env | API key for authentication | | principalId | string | 'claude-agent' | Identifier for this agent | | principalType | string | 'agent' | One of: user, agent, service, system | | environment | string | NODE_ENV | One of: development, staging, production | | onApprovalRequired | function | undefined | Async callback for approval decisions |

Error Handling

import { AuthensorDeniedError } from '@authensor/claude-agent-sdk';

try {
  await guard.guard('dangerous_action', { target: 'production' });
} catch (err) {
  if (err instanceof AuthensorDeniedError) {
    console.log(err.toolName);   // 'dangerous_action'
    console.log(err.outcome);    // 'deny'
    console.log(err.receiptId);  // 'receipt-...'
  }
}

License

MIT