UNPKG

its-compiler-js

Version:

JavaScript/TypeScript implementation of the Instruction Template Specification (ITS) compiler

65 lines (64 loc) 1.75 kB
/** * Main ITS Compiler implementation */ import { ITSTemplate, CompilationOptions, CompilationResult, ValidationResult, SecurityConfig } from './types.js'; export declare class ITSCompiler { private securityValidator; private variableProcessor; private conditionalEvaluator; private schemaLoader; private securityConfig; constructor(securityConfig?: SecurityConfig); /** * Compile a template from file */ compileFile(templatePath: string, variables?: Record<string, any>, options?: CompilationOptions): Promise<CompilationResult>; /** * Compile a template */ compile(template: ITSTemplate, variables?: Record<string, any>, options?: CompilationOptions): Promise<CompilationResult>; /** * Validate a template */ validate(template: ITSTemplate, baseUrl?: string): Promise<ValidationResult>; /** * Validate content elements */ private validateContent; /** * Load and resolve instruction types from schemas */ private loadInstructionTypes; /** * Generate the final AI prompt */ private generatePrompt; /** * Generate an instruction for a placeholder */ private generateInstruction; /** * Format an instruction template with config values */ private formatInstruction; /** * Get base URL from file path */ private getBaseUrlFromPath; /** * Get default system prompt */ private getDefaultSystemPrompt; /** * Get default processing instructions */ private getDefaultProcessingInstructions; /** * Clear schema cache */ clearCache(): void; /** * Get security status */ getSecurityStatus(): any; }