import type { Content, View } from "../content/content.js"; import type { Engine } from "../engine/index.js"; import type { PipelineSettings } from "../index.js"; import { RAG } from "./rag.js"; export type PluginBuilder = ( engine: Engine, settings: PipelineSettings, ) => Promise; export interface Plugin { augment(c: Content): Promise; clean(c: Content): Promise; update(c: Content[]): Promise; view?(): Promise; } export const PLUGINS: Record = { noop: { default: RAG.empty as unknown as PluginBuilder }, none: { default: RAG.empty as unknown as PluginBuilder }, }; export async function getPlugin( name: keyof typeof PLUGINS | string, ): Promise<{ default: PluginBuilder }> { if (name.startsWith("file://")) { return import(name); } if (!PLUGINS[name]) throw new Error(`Unknown plugin ${name}`); return PLUGINS[name]; }