import { PipelineResult, Pipeline } from 'open-guardrail-core'; declare class GuardrailBlockedError extends Error { readonly stage: 'input' | 'output'; readonly result: PipelineResult; constructor(stage: 'input' | 'output', result: PipelineResult); } type InputExtractor = (req: any) => string; interface GuardrailMiddlewareOptions { input?: Pipeline; output?: Pipeline; inputFrom?: 'body' | 'query' | InputExtractor; fieldName?: string; onBlocked?: (result: PipelineResult, req: any, res: any) => void; } interface OutputGuardOptions { output: Pipeline; onBlocked?: (result: PipelineResult) => void; } /** * Create an Express middleware that guards incoming request text. * * @example * ```typescript * import express from 'express'; * import { pipe, promptInjection } from 'open-guardrail'; * import { createGuardrailMiddleware } from 'open-guardrail-express'; * * const app = express(); * app.use(express.json()); * app.use(createGuardrailMiddleware({ * input: pipe(promptInjection({ action: 'block' })), * })); * ``` */ declare function createGuardrailMiddleware(options: GuardrailMiddlewareOptions): (req: any, res: any, next: any) => Promise; /** * Guard output text before sending a response. * * @example * ```typescript * import { pipe, pii } from 'open-guardrail'; * import { createOutputGuard } from 'open-guardrail-express'; * * const guardOutput = createOutputGuard({ * output: pipe(pii({ entities: ['email'], action: 'mask' })), * }); * * app.post('/chat', async (req, res) => { * const llmResponse = await getLLMResponse(req.body.message); * const safe = await guardOutput(llmResponse); * res.json({ reply: safe }); * }); * ``` */ declare function createOutputGuard(options: OutputGuardOptions): (text: string) => Promise; export { GuardrailBlockedError, type GuardrailMiddlewareOptions, type InputExtractor, type OutputGuardOptions, createGuardrailMiddleware, createOutputGuard };