import { UIDLAIAssistantChat } from '@teleporthq/teleport-types'; /** * What keeps the chat from being a free LLM key and a public transcript store * (A5-H3). The routes used to be open to anyone, unthrottled, with no message * length cap, every call spending the merchant's own model key; and an * anonymous visitor's conversation was whoever presented its id. * * - `/api/ai-chat/message` is limited per visitor (AI_CHAT_MESSAGE_LIMITS) * through the shared security runtime, refuses a message over * AI_CHAT_MAX_MESSAGE_CHARS, and every model call it makes (rephrase, * embedding, answer) counts against the site's one daily AI budget * (AI_SITE_BUDGET_KEY), the same counter the workflow AI nodes use. * - An anonymous visitor is the owner of a random key in an httpOnly cookie * the routes set; the `user_id` stored is a uuid derived one-way from it, * and nothing in the request body can name another. On https the cookie is * AI_CHAT_VISITOR_COOKIE_SECURE (`__Host-`: `Path=/`, `Secure`, no * `Domain`), which a sibling site on the shared hosting domain cannot set; * plain http (local development) uses AI_CHAT_VISITOR_COOKIE. Its value is * `.`, so a value these routes did not issue is * replaced, never adopted; without the app secret the chat refuses. A * signed-in visitor (auth-protected chat) is the session user, as before. * - A conversation id is only ever used by its owner: a message to someone * else's (or an unknown) conversation starts a new one, and reading, * renaming or deleting someone else's is a 404. */ export declare const AI_CHAT_MAX_MESSAGE_CHARS = 4000; export declare const AI_CHAT_MESSAGE_LIMITS: ReadonlyArray<[number, number]>; export declare const AI_SITE_BUDGET_KEY = "site:ai-calls"; export declare const AI_SITE_CALLS_PER_DAY = 2000; export declare const AI_CHAT_VISITOR_COOKIE = "__tq_ai_chat"; export declare const AI_CHAT_VISITOR_COOKIE_SECURE = "__Host-tq_ai_chat"; /** Longest conversation title / username stored. */ export declare const AI_CHAT_MAX_LABEL_CHARS = 200; /** Per-visitor limit of the conversation read routes, `[limit, windowSeconds]`. */ export declare const AI_CHAT_READ_LIMIT: [number, number]; export interface ChatRouteOptions { /** The project has authentication: the session reader checks revocation. */ withSessionRevocation?: boolean; } export declare function generateMessageRouteCode(chat: UIDLAIAssistantChat, options?: ChatRouteOptions): string; export declare function generateConversationsRouteCode(chat: UIDLAIAssistantChat, options?: ChatRouteOptions): string; export declare function generateConversationByIdRouteCode(chat: UIDLAIAssistantChat, options?: ChatRouteOptions): string; export declare function generateConversationMessagesRouteCode(chat: UIDLAIAssistantChat, options?: ChatRouteOptions): string; //# sourceMappingURL=api-route-generator.d.ts.map