import type { RequestHandler, Request, Application } from "express"; export * from "./backendTypes"; export function setupAiAssistantRoutes(args: { app: Application; /** * A function that returns the bearer token for the AI assistant to use for * back-channel request proxying. This should be a JWT token that can be * decoded on the `kazoo-web` application to authenticate the request. */ getBearerToken: ( headers: Record ) => Promise; /** * The host of the application to proxy requests to. */ targetHost: string; /** * The port of the application to proxy requests to. Defaults to 80. */ targetPort?: number; /** * The protocol of the application to proxy requests to. Defaults to "http". */ targetProtocol?: string; /** * Whether to follow redirects. Defaults to true. */ followRedirects?: boolean; /** * The route path to the local service's AI assistant. Defaults to * "/ai-assistant". */ route?: string; /** * The logger to use for logging. */ logger?: Pick; /** * Middleware functions to run before the proxy request. */ preflightMiddlewares?: RequestHandler[]; /** * A function that should return the target path for the proxy request, based * on the incoming full path. The path returned will be appended to the * target host and port to form the final URL. * * @example * ```ts * getTargetPath: (fullPath) => { * return fullPath; * } * ``` */ getTargetPath: (fullPath: string) => string; /** * Optional callbacks to invoke after successful REST endpoint responses. * Only invoked when the response status is 200. * * @example * ```ts * onRestEndpointSuccess: { * '/api/api-ai-assistant/v1/chat': async ({ request, response }) => { * console.log('Chat complete:', response); * }, * } * ``` */ onRestEndpointSuccess?: import("./backendTypes").RestEndpointCallbacks; /** * Optional callbacks to invoke after successful GraphQL operation responses. * Only invoked when the response status is 200 and the operation name matches. * Keys should match the GraphQL operation names (e.g., "AppendMessageToConversation"). * * @example * ```ts * onGraphQLOperationSuccess: { * AppendMessageToConversation: async ({ request, response }) => { * const conversationId = response.data?.appendMessage?.conversation?.id; * console.log('Message appended to conversation:', conversationId); * // Store conversation ID, update UI, etc. * }, * } * ``` */ onGraphQLOperationSuccess?: import("./backendTypes").GraphQLOperationCallbacks; }): void;