UNPKG

tinyagent-ts

Version:

Modern TypeScript framework for building AI agents with pluggable tools and ReAct reasoning

23 lines (22 loc) 1.18 kB
export type TemplateData = Record<string, unknown>; export type TemplateFn = (data?: TemplateData) => string; export type TemplateRegistry = Record<string, TemplateFn>; export declare const defaultTemplates: TemplateRegistry; export declare class PromptEngine { private templates; constructor(overrides?: Partial<TemplateRegistry>, fileOverrides?: Record<string, string>); /** Render a template by key */ render(name: string, data?: TemplateData): string; /** Register brand‑new template (fails if key exists) */ register(name: string, template: TemplateFn): void; /** Overwrite existing or create new template unconditionally */ overwrite(name: string, template: TemplateFn): void; /** Register template from a markdown file (fails if key exists) */ registerFromFile(name: string, filePath: string): void; /** Load every .md file in dir as new templates (fails on duplicates) */ loadDir(dir: string): void; /** Overwrite (or create) template from file */ overwriteFromFile(name: string, filePath: string): void; /** Apply multiple file overrides at once */ applyFileOverrides(map: Record<string, string>): void; }