/** * JSON Schema to GBNF Grammar Converter * * This is a TypeScript port of llama.cpp's json-schema-to-grammar.mjs * which was originally ported from json_schema_to_grammar.py * * Converts JSON Schema to GBNF (GGML BNF) grammar for constraining LLM outputs. */ import type { JSONSchema7 } from "@ai-sdk/provider"; export interface SchemaConverterOptions { /** Property order for object properties */ propOrder?: Record; /** Whether to allow fetching remote schemas (not supported in this port) */ allowFetch?: boolean; /** Whether dot in regex patterns matches newlines */ dotall?: boolean; } /** * SchemaConverter converts JSON Schema to GBNF grammar */ export declare class SchemaConverter { private _propOrder; private _dotall; private _rules; private _refs; private _refsBeingResolved; constructor(options?: SchemaConverterOptions); private _formatLiteral; private _addRule; /** * Resolve $ref references in the schema */ resolveRefs(schema: JSONSchema7, url?: string): void; private _generateUnionRule; private _visitPattern; private _notStrings; private _resolveRef; private _generateConstantRule; visit(schema: JSONSchema7, name?: string): string; private _addPrimitive; private _buildObjectRule; /** * Format the grammar rules as a GBNF grammar string */ formatGrammar(): string; } /** * Convert a JSON Schema to a GBNF grammar string */ export declare function convertJsonSchemaToGrammar(schema: JSONSchema7, options?: SchemaConverterOptions): string; //# sourceMappingURL=json-schema-to-grammar.d.ts.map