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

@dunkyai/ai-validator

v1.0.0

Published

Open-source AI output validator — catch hallucinations, strip narration, verify tool calls. Battle-tested across 90+ production AI agent instances.

Downloads

34

Readme

@dunkyai/ai-validator

Open-source AI output validator for LLM applications. Catch hallucinations, strip narration, verify tool calls.

Battle-tested across 90+ production AI agent instances at Dunky AI.

Install

npm install @dunkyai/ai-validator

Quick Start

import { validate } from '@dunkyai/ai-validator'

const result = validate({
  response: "I've sent the email to [email protected]",
  toolCalls: [
    { name: "gmail_send", input: { to: "[email protected]" }, output: '{"success":true}' }
  ]
})

console.log(result.pass)    // true — action claim matches tool call
console.log(result.cleaned) // "I've sent the email to [email protected]"
console.log(result.issues)  // []

What It Catches

1. Hallucinated Actions

The AI says "I've sent the email" but never actually called a send tool:

const result = validate({
  response: "I've sent the email to [email protected]",
  toolCalls: [] // no tools were called!
})

console.log(result.pass) // false
console.log(result.issues)
// [{ type: "hallucination", message: "AI claims to have performed an action, but none of these tools were called: gmail_send, send_email, sendEmail" }]

2. Narration / Thought Process

The AI leaks its internal monologue into user-facing responses:

const result = validate({
  response: "Let me save this file and extract the text.\n\nHere's the summary of the document..."
})

console.log(result.cleaned) // "Here's the summary of the document..."
console.log(result.issues)
// [{ type: "narration", message: "Narration / thought process stripped", match: "Let me save this file and extract the text." }]

3. Blocked Phrases

Remove specific phrases you don't want in responses:

const result = validate({
  response: "Hey there! The bottom line is we need to move fast.",
  options: {
    blockedPhrases: ["hey there", "the bottom line"]
  }
})

console.log(result.cleaned) // "! is we need to move fast."

API

validate(params)

Main validation function. Returns a ValidationResult.

Params:

  • response (string) — The AI's response text
  • toolCalls (ToolCall[], optional) — Tool calls that were actually executed
  • options (ValidationOptions, optional) — Configuration

Options:

  • checkHallucinations (boolean, default: true) — Check for hallucinated action claims
  • stripNarration (boolean, default: true) — Remove narration lines
  • blockedPhrases (string[], default: []) — Custom phrases to remove
  • narrationPatterns (RegExp[], default: built-in) — Custom narration patterns
  • actionPatterns ({ pattern, tools }[], default: built-in) — Custom hallucination patterns

Returns:

{
  pass: boolean,        // true if no hallucinations found
  cleaned: string,      // response with narration/phrases stripped
  issues: Issue[],      // all issues found
  original: string      // original response
}

checkActionClaims(response, toolNames, patterns?)

Check if the AI claims actions not backed by tool calls.

removeNarration(text, patterns?)

Strip narration lines from text.

removeBlockedPhrases(text, phrases)

Remove specific phrases from text.

Works With Any Model

  • Claude (Anthropic)
  • GPT-4 / GPT-4o (OpenAI)
  • Llama, Mistral, Gemma (via Groq, Together, etc.)
  • Gemini (Google)
  • Any model that uses tool/function calling

License

MIT — use it however you want, commercially or otherwise.

Contributing

Issues and PRs welcome at github.com/dunkyai/ai-validator.