import { z } from 'zod'; import { CatalogTemplate } from './catalog/types'; import { CompactNode } from './compact/types'; import { Proposal } from './proposal/types'; export type CopilotRequest = { messages: { role: 'user' | 'assistant'; text: string; attachments?: { url: string; mediaType: string; }[]; }[]; /** Snapshot of ROOT, ids included. */ page: CompactNode; selection?: { nodeId: string; sectionId?: string; }; screen: 'xs' | 'sm' | 'md' | 'lg'; resources: { imageSources?: { src: string; alt?: string; }[]; templates?: CatalogTemplate[]; }; }; export type CopilotEvent = { type: 'text'; delta: string; } | { type: 'proposal'; proposal: Proposal; } | { type: 'error'; message: string; }; export type CopilotHandler = (request: CopilotRequest, options: { signal: AbortSignal; }) => AsyncIterable; /** * Request limits: the request comes from the browser, so a backend parsing it must not trust its size. `pageDepth` * bounds the page and each template tree (levels of `children`); `propsDepth` bounds the objects and arrays nested in * one node's props. */ export declare const COPILOT_LIMITS: { readonly messageText: 100000; readonly messages: 200; readonly attachments: 20; readonly attachmentUrl: 4096; readonly mediaType: 100; readonly pageDepth: 200; readonly propsDepth: 32; }; export declare const compactPageSchema: z.ZodType; /** * Whether a request accepts `url` as an attachment: http(s), no whitespace, at most `COPILOT_LIMITS.attachmentUrl` * characters. Check uploaded URLs with it before sending them. */ export declare function isCopilotAttachmentUrl(url: string): boolean; /** Shape and size of a copilot request (`COPILOT_LIMITS`); attachment urls must be http(s). */ export declare const copilotRequestSchema: z.ZodType; export declare const copilotEventSchema: z.ZodType;