/** * Server Adapters - AI SDK Wrapper * * Provides server adapters for HTTP, Express, Hono, Fastify, and Nest.js. */ export interface ServerHandler { /** Handle a request */ handle(req: any, res: any): Promise; } export interface ServerHandlerConfig { /** Agent or generateText/streamText function */ handler: (input: any) => Promise; /** Enable streaming (default: true) */ streaming?: boolean; /** CORS headers */ cors?: boolean | CorsConfig; /** Request body parser */ bodyParser?: (req: any) => Promise; /** Response formatter */ responseFormatter?: (result: any) => any; /** Error handler */ onError?: (error: Error, req: any, res: any) => void; } export interface CorsConfig { origin?: string | string[]; methods?: string[]; headers?: string[]; credentials?: boolean; } /** * Create an HTTP server handler. * * @example * ```typescript * import { createServer } from 'http'; * import { createHttpHandler } from 'praisonai/ai'; * * const handler = createHttpHandler({ * handler: async (input) => { * return await generateText({ model: 'gpt-4o', prompt: input.prompt }); * } * }); * * createServer(handler.handle).listen(3000); * ``` */ export declare function createHttpHandler(config: ServerHandlerConfig): ServerHandler; /** * Create an Express handler. * * @example * ```typescript * import express from 'express'; * import { createExpressHandler } from 'praisonai/ai'; * * const app = express(); * app.use(express.json()); * * app.post('/api/chat', createExpressHandler({ * handler: async (input) => { * return await streamText({ model: 'gpt-4o', messages: input.messages }); * } * })); * ``` */ export declare function createExpressHandler(config: ServerHandlerConfig): (req: any, res: any) => Promise; /** * Create a Hono handler. * * @example * ```typescript * import { Hono } from 'hono'; * import { createHonoHandler } from 'praisonai/ai'; * * const app = new Hono(); * * app.post('/api/chat', createHonoHandler({ * handler: async (input) => { * return await streamText({ model: 'gpt-4o', messages: input.messages }); * } * })); * ``` */ export declare function createHonoHandler(config: ServerHandlerConfig): (c: any) => Promise; /** * Create a Fastify handler. * * @example * ```typescript * import Fastify from 'fastify'; * import { createFastifyHandler } from 'praisonai/ai'; * * const fastify = Fastify(); * * fastify.post('/api/chat', createFastifyHandler({ * handler: async (input) => { * return await streamText({ model: 'gpt-4o', messages: input.messages }); * } * })); * ``` */ export declare function createFastifyHandler(config: ServerHandlerConfig): (request: any, reply: any) => Promise; /** * Create a Nest.js controller method decorator config. * * @example * ```typescript * import { Controller, Post, Body, Res } from '@nestjs/common'; * import { createNestHandler } from 'praisonai/ai'; * * @Controller('api') * export class ChatController { * private handler = createNestHandler({ * handler: async (input) => { * return await streamText({ model: 'gpt-4o', messages: input.messages }); * } * }); * * @Post('chat') * async chat(@Body() body: any, @Res() res: any) { * return this.handler(body, res); * } * } * ``` */ export declare function createNestHandler(config: ServerHandlerConfig): (body: any, res: any) => Promise;