import { type LanguageModel } from "ai"; import { type GeistdocsConfig } from "../config"; import { type ChatMixedbreadOptions } from "../internal/chat-retrieval"; import { type GeistdocsPageFilter } from "../page-visibility"; import type { GeistdocsSourceBundle } from "../source"; type SourceBundle = GeistdocsSourceBundle; /** * Headers for upstream requests: a static value, or a function that receives * the incoming chat `Request` (for per-request values) and may be async. */ type ChatUpstreamHeaders = HeadersInit | ((request: Request) => HeadersInit | Promise); interface ChatProxyConfig { headers?: ChatUpstreamHeaders; url: string; } /** * What proxy and eve agent modes add to the message they forward. * - `"auto"`: on the first user message, the attached page (or the page at * `currentRoute`) excerpt plus related docs from retrieval, emitted as * source citations. * - `"page-only"`: only a page the request attaches with `pageContext`, in * full, and no citations; every other message is forwarded as sent. */ type ChatContextInjection = "auto" | "page-only"; interface ChatEveAgentOptions { /** * Send eve's turn-scoped `clientContext: { currentPage: { url, title } }` * with every message, including the message that starts a replacement * session; prewarm requests carry no message, so they never send it. * `url` is the absolute public URL of `currentRoute` * (on `config.siteUrl`, or the request origin); `title` is included when * the route is a page Ask AI may see. @default false */ clientContext?: boolean; /** * Extra headers for requests to the eve agent, replacing the default * `Authorization: Bearer ` when an `authorization` * header is provided. A function receives the incoming chat `Request` and * may be async, for per-request tokens or forwarded values. * Server-only: never expose auth material through `geistdocs.tsx`. */ headers?: ChatUpstreamHeaders; /** * Secret used to sign the httpOnly cookie that binds a browser to its eve * session. Defaults to the `GEISTDOCS_CHAT_SECRET` environment variable * and must be at least 32 bytes (`openssl rand -base64 32`). Without a * secret, every turn starts a fresh eve session with the conversation * inlined, and prewarm requests are refused. Server-only. */ secret?: string; /** * Forward the agent's tool outputs to the client and show the URLs found * in them as source citations. When `false`, tool calls still show as * activity, but their outputs reach the client as `null` and produce no * citations. @default true */ toolCitations?: boolean; /** Overrides `config.ai.eveAgent.url` (e.g. for a staging agent). */ url?: string; /** * Names of the agent tools whose calls the client sees. Calls to any * other tool, with their results and citations, are not forwarded. * Omit to forward every tool call. */ visibleTools?: string[]; } interface ChatRequestLimits { /** * Most messages accepted in one request. Larger requests receive 400. * @default 200 */ maxMessages?: number; /** * Longest legacy `pageContext.content` accepted, in characters. Longer * requests receive 400. Pages referenced by `pageContext.url` alone are * read from the site's sources and are not rejected; with * `contextInjection: "page-only"`, their Markdown is truncated to this * length before it is forwarded. * @default 200_000 */ maxPageContextChars?: number; /** * Largest request body accepted, in bytes. Larger requests receive 413. * @default 1_000_000 */ maxRequestBytes?: number; } interface CreateChatRouteOptions { config: Pick; /** * Docs context proxy and eve agent modes add to forwarded messages. * `"page-only"` forwards messages as sent unless the request attaches a * page with `pageContext`. Ignored in the default AI Gateway mode, which * retrieves docs with its own tools. @default "auto" */ contextInjection?: ChatContextInjection; /** * Server-side options for the eve agent responder configured through * `config.ai.eveAgent`. Mutually exclusive with `proxy`. */ eveAgent?: ChatEveAgentOptions; /** Narrows the stable public corpus available to Ask AI. */ filterPage?: GeistdocsPageFilter; /** * Request size caps applied before any model, proxy, or agent call. Rate * limiting is not included; wrap the route with your own. */ limits?: ChatRequestLimits; /** * Server-only Mixedbread overrides. Environment variables are used when * these values are omitted. */ mixedbread?: ChatMixedbreadOptions; /** * Model used to answer Ask AI requests in the default AI Gateway mode. * Accepts any AI SDK `LanguageModel`, including AI Gateway model strings * such as `"xai/grok-4.5"`. Ignored in proxy and eve agent modes, where * the external service selects the model. Defaults to * `"openai/gpt-5.6-sol"`. */ model?: LanguageModel; proxy?: ChatProxyConfig; source?: SourceBundle; sources?: SourceBundle[]; } export declare const createChatRoute: ({ config, contextInjection, eveAgent, filterPage, limits, mixedbread, model, proxy, source, sources, }: CreateChatRouteOptions) => { POST: (req: Request) => Promise; maxDuration: 800; }; export {}; //# sourceMappingURL=chat.d.ts.map