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

restarules-sdk

v0.3.0

Published

Validate and evaluate AI agent compliance against RestaRules venue conduct rules

Readme

restarules-sdk

Validate and evaluate AI agent compliance against RestaRules venue conduct rules.

What is RestaRules?

RestaRules is an open standard that lets restaurants publish machine-readable conduct rules for AI agents. Restaurants host a JSON file at /.well-known/agent-venue-rules.json defining what AI agents are and aren't allowed to do — disclosure requirements, allowed channels, rate limits, party size policies, deposit requirements, and more. This SDK lets developers validate those rules files and evaluate whether a proposed agent action is compliant.

Installation

The SDK is not yet published to npm. To use it locally:

git clone https://github.com/selfradiance/restarules.git
cd restarules/sdk
npm install

Then reference it from your project:

const { validateRules, evaluateCompliance } = require('./path/to/restarules/sdk');

Quick Start

const { validateRules, evaluateCompliance } = require("./path/to/restarules/sdk");

// 1. Validate a rules file
const rules = {
  schema_version: "0.3",
  venue_name: "Example Restaurant",
  venue_url: "https://example.com",
  last_updated: "2026-03-09",
  effective_at: "2026-03-09",
  default_policy: "deny_if_unspecified",
  disclosure_required: { enabled: true, phrasing: "I am an AI assistant." },
  allowed_channels: ["phone", "web"]
};

const validation = validateRules(rules);
console.log(validation.valid);   // true
console.log(validation.errors);  // null

// 2. Evaluate compliance for a proposed action
const decision = evaluateCompliance(rules, {
  channel: "phone",
  partySize: 4,
  action: "booking_request",
  attempts: 1
});

console.log(decision.channel);      // { result: "ALLOWED" }
console.log(decision.disclosure);   // { required: true, phrasing: "I am an AI assistant." }

API Reference

validateRules(rules)

  • rules (object) — A parsed RestaRules JSON object.
  • Returns { valid: boolean, errors: array|null }.
  • Uses JSON Schema Draft 2020-12 validation via Ajv.

evaluateCompliance(rules, params)

  • rules (object) — A validated RestaRules JSON object.
  • params (object) — The proposed agent action:
    • channel (string|null) — The channel the agent intends to use (e.g., "phone", "web", "sms")
    • partySize (number|null) — Party size for the booking
    • action (string|null) — The action identifier. For rate limit checks, this matches against rate_limits[].action (venue-facing labels like "booking_request", "inquiry"). For channel checks, this matches against allowed_channels_by_action keys (agent-facing action types like "create_booking", "cancel_booking"). For booking window checks, must be "create_booking" to trigger enforcement. See spec Section 4 (Action Vocabularies) for the full explanation of the two vocabularies.
    • attempts (number|null) — Number of attempts the agent has made for this action
    • targetTime (string|null) — ISO 8601 datetime of the proposed booking (e.g., "2026-03-20T19:00:00-05:00"). Required for booking_window enforcement when action is "create_booking". MUST be timezone-qualified (with UTC offset or Z suffix) — naive timestamps without timezone offsets produce environment-dependent results and MUST NOT be used
    • currentTime (string|null) — ISO 8601 datetime to use as "now" for booking window calculations (e.g., "2026-03-20T14:00:00-05:00"). Defaults to the actual current time if omitted. Useful for deterministic testing. MUST be timezone-qualified when provided
  • Returns an object with decisions for each rule section:

| Property | Description | |---|---| | disclosure | { required, phrasing } — whether the agent must identify itself | | channel | { result, source, allowedChannels }"ALLOWED", "DENIED", or "NOT_CHECKED". source is "per_action_override" or "base" indicating which channel list was used. allowedChannels lists the effective channels | | partySize | { result, autoMax }"ALLOWED", "ESCALATE_TO_HUMAN", "DENIED_DEFAULT_POLICY", or "NOT_CHECKED" | | escalationConditions | Array of non-party-size escalation triggers | | rateLimit | { result, limit, windowValue, windowUnit, appliesTo, countingScope }"WITHIN_LIMITS", "EXCEEDED", "DENIED_DEFAULT_POLICY", or "NOT_CHECKED". countingScope is "per_agent" (default), "per_user", or "per_session" | | thirdParty | { defined, noResale, noTransfer, identityBound } or { defined: false, defaultPolicyResult } | | complaintEndpoint | URL string or null | | venueMetadata | { currency, timezone } | | depositPolicy | { defined, required, amount, currency, refundable } or { defined: false, defaultPolicyResult } | | userAcknowledgmentRequirements | { defined, policies, skippedPolicies } or { defined: false, defaultPolicyResult }. skippedPolicies lists any policy names that reference absent fields (silently skipped, null when none) | | cancellationPolicy | { defined, penaltyApplies, windowMinutes, penaltyAmount, currency } or { defined: false } | | noShowPolicy | { defined, fee, currency, gracePeriodMinutes } or { defined: false } | | bookingWindow | { defined, enforced, result, reason, minHoursAhead, maxDaysAhead }result is "ALLOWED", "DENIED", or "NOT_EVALUATED". enforced is true only when action is create_booking, targetTime is provided, and venue_timezone is present |

Permission fields respect default_policy when absent — returning "DENIED_DEFAULT_POLICY" or "ALLOWED" depending on the venue's setting. Informational fields (complaintEndpoint, cancellationPolicy, noShowPolicy) never block actions.

Schema Version

This SDK validates against RestaRules schema v0.3. Rules files with schema_version "0.1", "0.2", or "0.3" are accepted.

Links