/** * Registry for managing GuardrailSpec instances and maintaining a catalog of guardrails. * * This module provides the in-memory registry that acts as the authoritative * catalog for all available guardrail specifications. The registry supports * registration, lookup, removal, and metadata inspection for guardrails, * enabling extensibility and dynamic discovery across your application. */ import { z } from 'zod'; import { GuardrailSpec, type GuardrailSpecMetadata } from './spec'; import type { CheckFn, TextInput } from './types'; /** * Metadata snapshot for a guardrail specification. * * This container bundles descriptive and structural details about a guardrail * for inspection, discovery, or documentation. */ export interface Metadata { /** Unique identifier for the guardrail. */ name: string; /** Explanation of what the guardrail checks. */ description: string; /** MIME type (e.g. "text/plain") the guardrail applies to. */ mediaType: string; /** Whether the guardrail has configuration options. */ hasConfig: boolean; /** Whether the guardrail has context requirements. */ hasContext: boolean; /** Optional structured metadata for discovery and documentation. */ metadata?: GuardrailSpecMetadata; } /** * Registry for managing guardrail specifications. * * This class provides a centralized catalog of all available guardrails, * supporting registration, lookup, removal, and metadata inspection. */ export declare class GuardrailRegistry { private specs; /** * Register a new guardrail specification. * * @param name Unique identifier for the guardrail. * @param checkFn Function implementing the guardrail's logic. * @param description Human-readable explanation of the guardrail's purpose. * @param mediaType MIME type to which the guardrail applies. * @param configSchema Optional Zod schema for configuration validation. * @param ctxRequirements Optional Zod schema for context validation. * @param metadata Optional structured metadata. */ register(name: string, checkFn: CheckFn, description: string, mediaType?: string, configSchema?: z.ZodType, ctxRequirements?: z.ZodType, metadata?: GuardrailSpecMetadata): void; /** * Look up a guardrail specification by name. * * @param name Unique identifier for the guardrail. * @returns The guardrail specification, or undefined if not found. */ get(name: string): GuardrailSpec | undefined; /** * Remove a guardrail specification from the registry. * * @param name Unique identifier for the guardrail. * @returns True if the guardrail was removed, false if it wasn't found. */ remove(name: string): boolean; /** * Get metadata for all registered guardrails. * * @returns Array of metadata objects for all registered guardrails. */ metadata(): Metadata[]; /** * Get all registered guardrail specifications. * * @returns Array of all registered guardrail specifications. */ all(): GuardrailSpec[]; /** * Check if a guardrail with the given name is registered. * * @param name Unique identifier for the guardrail. * @returns True if the guardrail is registered, false otherwise. */ has(name: string): boolean; /** * Get the number of registered guardrails. * * @returns The number of registered guardrails. */ size(): number; /** * Return a list of all registered guardrail specifications. * * @returns All registered specs, in registration order. */ get_all(): GuardrailSpec[]; /** * Return summary metadata for all registered guardrail specifications. * * This provides lightweight, serializable descriptions of all guardrails, * suitable for documentation, UI display, or catalog listing. * * @returns List of metadata entries for each registered spec. */ get_all_metadata(): Metadata[]; } /** * Default global registry instance. * * This is the primary registry used by the library for built-in guardrails * and user registrations. */ export declare const defaultSpecRegistry: GuardrailRegistry; //# sourceMappingURL=registry.d.ts.map