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

@nightmoose/aischemagate

v0.4.1

Published

AISchemaGate — thin alias over @nightmoose/contractgate-sdk for LLM structured-output validation. Same engine as DataContractGate.

Readme

@nightmoose/aischemagate

AISchemaGate — thin alias package over @nightmoose/contractgate-sdk for LLM structured-output validation. Same Rust engine, same cg_live_... API keys, same tenant service, same backend as DataContractGate.

npm install @nightmoose/aischemagate

Why this package exists

The underlying engine, SDK, and API are DataContractGate — one validator, one gateway. @nightmoose/aischemagate is the LLM / AI-agent-shaped front door: it re-exports the SDK under a name that reads correctly from the LLM-output-validation angle. Use whichever import name matches your mental model; the behavior is identical.

See:

  • aischemagate.com — product site
  • aischemagate.dev — developer documentation
  • RFC-094 (docs/rfcs/094-sdk-llm-output-guard.md) — SDK design

15-line quickstart

import { LLMGate } from '@nightmoose/aischemagate';
import OpenAI from 'openai';

const gate = new LLMGate({
  apiKey: process.env.CONTRACTGATE_API_KEY!,
  contractId: 'extract_invoice_v1',
  llm: new OpenAI(),
});

const result = await gate.completion({
  model: 'gpt-4o-mini',
  messages: [{ role: 'user', content: 'Extract invoice JSON from: ...' }],
  response_format: { type: 'json_object' },
  autoRepair: true,
});

if (result.ok) forwardDownstream(result.payload);  // egress-sanitized

For Anthropic, call gate.message({ model: 'claude-sonnet-4-5', ... }). For vLLM / Ollama OpenAI-compat, call gate.completion(...) unchanged.

Vercel AI SDK guardrail

aischemagateGuardrail is a LanguageModelV4Middleware. It does not depend on the ai package. wrapGenerate reads the JSON object from text content (or a tool-call input) and posts it to POST /egress/{id}. On success the model text is replaced with the egress payload. Set autoRepair: true to re-prompt, up to maxRetries extra calls (hard cap 5), when min, max, pattern, enum, or compliance_mode fails.

import { generateText, Output, wrapLanguageModel } from 'ai';
import { aischemagateGuardrail } from '@nightmoose/aischemagate';
import { z } from 'zod';

const model = wrapLanguageModel({
  model: yourModel,
  middleware: aischemagateGuardrail({
    apiKey: process.env.CONTRACTGATE_API_KEY!,
    contractId: process.env.CONTRACTGATE_CONTRACT_ID!,
    autoRepair: true,
    maxRetries: 2,
  }),
});

const result = await generateText({
  model,
  output: Output.object({
    schema: z.object({ total: z.number(), currency: z.string() }),
  }),
  prompt: 'Extract the invoice as JSON.',
});

validateStructuredOutput(options, payload) is the same egress check for a JSON object you already have. Copy-paste guides: docs/integrations/.

Running tests locally

Tests resolve the @nightmoose/contractgate-sdk dependency through npm install. From this directory:

npm install
npm run build        # one-time, or after changes
npm test

What's new

See CHANGELOG.md and the parent @nightmoose/contractgate-sdk CHANGELOG — the alias version tracks initial release only; feature work is versioned on contractgate-sdk.