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

@agentiam/openai

v0.1.2

Published

Agent IAM adapter for the OpenAI Node.js SDK

Readme

@agentiam/openai

The official AgentIAM adapter for the raw OpenAI SDK.

If you are building an AI agent from scratch using openai directly, this adapter intercepts tool calls generated by the model and enforces your IAM policies before executing the underlying functions.

Installation

npm install @agentiam/core @agentiam/openai

Quickstart

import { OpenAI } from "openai";
import { createAgentIAM, definePolicy } from "@agentiam/core";
import { runGuardedTools, resumeGuardedTool } from "@agentiam/openai";

const openai = new OpenAI();

// 1. Define your tool logic
const tools = {
  delete_database: async () => { /* ... */ }
};

// 2. Define your IAM policy
const policy = definePolicy({
  id: "openai-example",
  name: "OpenAI Example",
  defaultDecision: "deny",
  rules: [
    {
      id: "require-approval-delete",
      decision: "approval_required",
      when: { action: "delete_database" }
    }
  ]
});

const iam = createAgentIAM({ policy });

// 3. Process LLM Responses
const response = await openai.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Delete the database." }],
  tools: [/* your tool definitions */]
});

const message = response.choices[0].message;

if (message.tool_calls) {
  // Pass the raw tool calls through AgentIAM
  const results = await runGuardedTools({
    iam,
    toolCalls: message.tool_calls,
    tools
  });

  for (const result of results) {
    if (result.status === "executed") {
      console.log("Executed successfully!", result.output);
    } else if (result.status === "denied") {
      console.log("Action blocked by policy.");
    } else if (result.status === "pending") {
      console.log(`Approval required. Checkpoint ID: ${result.checkpointId}`);
      
      // ... Prompt user for approval ...
      await iam.checkpoints.approve(result.checkpointId);
      
      // Resume execution
      const output = await resumeGuardedTool({
        iam,
        checkpointId: result.checkpointId,
        tools
      });
      console.log("Executed after approval:", output);
    }
  }
}

Strict Mode

By default, runGuardedTools returns a structured array of results, even for pending checkpoints. If you prefer to throw errors on pending checkpoints, you can enable strict mode:

import { ApprovalRequiredError, ClarificationRequiredError } from "@agentiam/openai";

try {
  await runGuardedTools({
    iam,
    toolCalls: message.tool_calls,
    tools,
    strict: true
  });
} catch (error) {
  if (error instanceof ApprovalRequiredError) {
    console.log("Need approval for checkpoint:", error.checkpointId);
  }
}