/** * ServerlessAdapter - Adapts AgentBase for serverless platforms. * * Supports AWS Lambda, Google Cloud Functions, Azure Functions, and CGI mode. * Auto-detects platform from environment variables. */ /** Supported serverless platform identifiers, or 'auto' for environment-based detection. */ export type ServerlessPlatform = 'lambda' | 'gcf' | 'azure' | 'cgi' | 'auto'; /** Normalized incoming event from a serverless platform. */ export interface ServerlessEvent { /** HTTP method (AWS Lambda style). */ httpMethod?: string; /** HTTP method (GCF/Azure style). */ method?: string; /** Request headers as key-value pairs. */ headers?: Record; /** Request body, either raw JSON string or parsed object. */ body?: string | Record; /** Request path. */ path?: string; /** Raw request path (AWS API Gateway v2). */ rawPath?: string; /** Query string parameters as key-value pairs. */ queryStringParameters?: Record; /** Platform-specific request context metadata. */ requestContext?: Record; } /** Normalized outgoing response returned to a serverless platform. */ export interface ServerlessResponse { /** HTTP status code. */ statusCode: number; /** Response headers as key-value pairs. */ headers: Record; /** Response body as a string. */ body: string; } /** * Adapts a Hono application for deployment on AWS Lambda, Google Cloud Functions, Azure Functions, or CGI. * * Accepts the provider's native event shape (`APIGatewayProxyEvent`, Google Functions `Request`, * Azure function arguments, CGI env + stdin) and returns a provider-native response. * * @example AWS Lambda handler * ```ts * import { AgentBase, ServerlessAdapter } from '@signalwire/sdk'; * * const agent = new AgentBase({ name: 'lambda', route: '/' }); * agent.setPromptText('You are a helpful assistant.'); * * const adapter = new ServerlessAdapter('aws'); * * export const handler = async (event: any) => { * return adapter.handleRequest(agent.asRouter(), event); * }; * ``` */ export declare class ServerlessAdapter { private platform; /** * Create a ServerlessAdapter for the given platform. * @param platform - Target platform; defaults to 'auto' which detects from environment variables. */ constructor(platform?: ServerlessPlatform); /** * Detect the serverless platform by inspecting well-known environment variables. * @returns The detected platform identifier; defaults to 'lambda' if no match is found. */ detectPlatform(): ServerlessPlatform; /** * Get the resolved platform identifier. * @returns The serverless platform this adapter is configured for. */ getPlatform(): ServerlessPlatform; /** * Convert a serverless event into a standard Request, route it through the Hono app, and return a normalized response. * @param app - A Hono-compatible application with a `fetch` method. * @param event - The incoming serverless event to process. * @returns The normalized serverless response. */ handleRequest(app: { fetch: (req: Request) => Response | Promise; }, event: ServerlessEvent): Promise; /** * Generate the platform-specific invocation URL for a deployed function. * @param opts - Optional overrides for region, project, function name, stage, or API ID. * @returns The constructed URL string. */ generateUrl(opts?: { region?: string; projectId?: string; functionName?: string; stage?: string; apiId?: string; }): string; /** * Create an AWS Lambda-compatible handler function from a Hono app. * @param app - A Hono-compatible application with a `fetch` method. * @returns A function that accepts a Lambda event and returns a promise of a serverless response. */ static createLambdaHandler(app: { fetch: (req: Request) => Response | Promise; }): (event: ServerlessEvent) => Promise; /** * Create a Google Cloud Functions-compatible handler from a Hono app. * @param app - A Hono-compatible application with a `fetch` method. * @returns A function that accepts GCF request/response objects. */ static createGcfHandler(app: { fetch: (req: Request) => Response | Promise; }): (req: any, res: any) => Promise; /** * Create an Azure Functions-compatible handler from a Hono app. * @param app - A Hono-compatible application with a `fetch` method. * @returns A function that accepts an Azure context and request object. */ static createAzureHandler(app: { fetch: (req: Request) => Response | Promise; }): (context: any, req: any) => Promise; }