/** * Commands issued through the public chat controller before the lazily * loaded chat shell can act on them: questions to submit, a page to attach * to the next message, and a request to start a new conversation. The * provider owns one queue; the active shell drains it once its stored * history has loaded and no response is streaming. */ /** Page attached to a chat message. `url` is a site-relative path. */ export interface ChatPageAttachment { title?: string; url: string; } export interface ChatPendingAsk { id: number; text: string; } export interface ChatCommandState { attachedPage: ChatPageAttachment | null; /** Set when the current conversation must be cleared before anything else. */ clearRequested: boolean; pendingAsks: readonly ChatPendingAsk[]; /** * True while a shell is running a queued command. Shared across the * desktop panel and mobile drawer so a shell that becomes active mid-command * (for example after a resize) waits instead of sending concurrently. */ running: boolean; } /** Matches the chat route's `pageContext.url` limit. */ export declare const MAX_CHAT_PAGE_URL_CHARS = 2048; /** * Reduce a page reference to the site-relative path the chat route resolves * against the site's own pages. Relative URLs resolve against `origin`; for * absolute URLs only the path is kept, so a production URL still names the * page on a preview deployment. Query strings and fragments are dropped. * Returns `null` for anything that is not an HTTP(S) URL or path. */ export declare const normalizeChatPage: (page: { title?: unknown; url?: unknown; } | undefined, origin: string) => ChatPageAttachment | null; /** Label for an attached page: its title, falling back to its path. */ export declare const getChatPageLabel: (page: ChatPageAttachment) => string; /** * Read the page attachment persisted in a user message's metadata, if any. */ export declare const getMessagePageAttachment: (metadata: unknown) => ChatPageAttachment | null; export interface ChatCommandQueue { /** * Queue `text` as a user message. Returns `false` (and queues nothing) * when the trimmed text is empty. */ ask: (text: string) => boolean; /** * Start a new conversation about `page`: drops questions queued for the * current conversation, requests a clear, and attaches the page to the * next message. */ attachPage: (page: ChatPageAttachment) => void; /** * Claim the queue for one command. Returns `false` when another command is * already running, so the caller must not start one. */ beginCommand: () => boolean; /** Mark a requested clear as done. */ completeClear: () => void; /** Remove the attached page without sending it. */ detachPage: () => void; /** Release the claim taken by `beginCommand`. */ endCommand: () => void; getState: () => ChatCommandState; subscribe: (listener: () => void) => () => void; /** Remove and return the attached page, so only one message carries it. */ takeAttachedPage: () => ChatPageAttachment | null; /** Remove and return the oldest queued question. */ takeNextAsk: () => ChatPendingAsk | null; } export declare const createChatCommandQueue: () => ChatCommandQueue; /** Whether the chat can submit a message or clear without interrupting one. */ export declare const isChatIdle: (status: string) => status is "error" | "ready"; /** * What the active chat shell should do next with the queue. A requested * clear interrupts a streaming answer (`"stop"`) and runs before any queued * question; questions wait for the chat to be idle and for the previous * command, in either shell, to settle (`state.running`). */ export declare const getNextChatCommand: ({ state, status, }: { state: ChatCommandState; status: string; }) => "ask" | "clear" | "stop" | null; //# sourceMappingURL=commands.d.ts.map