import { ChatModel, ChatRequestModel, ChatResponseContent } from '@theia/ai-chat/lib/common'; export interface ChatFindOptions { matchCase: boolean; wholeWord: boolean; useRegex: boolean; } export interface ChatFindTextRange { start: number; end: number; } /** * A match of the find query inside a chat session, located by the tree node that renders it. */ export interface ChatFindMatch extends ChatFindTextRange { /** Id of the tree node rendering the matched text: the request id or the response id. */ nodeId: string; /** The `kind` of the matched response part, or {@link ChatFindMatch.REQUEST_KIND} for request text. */ kind: string; /** Index into `response.response.content`; `undefined` for request text. */ contentIndex?: number; /** 0-based index of this match among all matches inside the same text. */ occurrence: number; } export declare namespace ChatFindMatch { const REQUEST_KIND = "request"; /** Stable identity of a match across recomputations of the match list. */ function key(match: ChatFindMatch): string; } /** * Computes find matches over a chat session model. Only the displayed branch (`model.getRequests()`) is searched. * * Text is searched as it is rendered, not as it is stored: markdown is rendered the way the chat renders it and * its text read with {@link ChatFindText}, the same way the highlighter reads the mounted DOM, so match offsets * are valid in both. Subclass and override {@link getSearchableText} to search additional content kinds. */ export declare class ChatFindMatcher { /** VS Code's default `editor.wordSeparators`; whitespace separates words as well. */ protected static readonly WORD_SEPARATORS = "`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?"; /** Rendered text by the object it was rendered for, reused while its source text is unchanged. */ protected readonly renderedTextCache: WeakMap; /** * Builds the regular expression shared by model matching and DOM highlighting. * @returns `undefined` for an empty query or an invalid regular expression. */ createRegExp(query: string, options: ChatFindOptions): RegExp | undefined; /** All matches in tree order: request row, then response row, content parts in order, offsets ascending. */ findMatches(model: ChatModel, regexp: RegExp): ChatFindMatch[]; /** All non-empty occurrences of `regexp` in `text`, in order. */ findInText(text: string, regexp: RegExp): ChatFindTextRange[]; /** * Restricts `source` to whole words the way VS Code does: each end of a match must be the end of the text, next * to a word separator, or itself a word separator. Unlike `\b`, this also works for queries such as `C++` or `foo()`. */ protected wrapWholeWord(source: string): string; protected collect(matches: ChatFindMatch[], regexp: RegExp, text: string, nodeId: string, kind: string, contentIndex: number | undefined): void; /** * The request text as rendered by `ChatRequestRender`: agent, variable and function mentions as labels, * text parts as inline markdown, inline image parts skipped. */ protected getRequestText(request: ChatRequestModel): string; /** * The searchable text of a response part as it is rendered, or `undefined` for kinds that are not searched * (tool calls, reasoning, progress, informational content, which the chat does not render, ...). */ protected getSearchableText(content: ChatResponseContent): string | undefined; /** The text of `markdown` rendered the way `useMarkdownRendering` renders it, cached per `owner`. */ protected getRenderedMarkdownText(owner: object, markdown: string, skipSurroundingParagraph: boolean, blockExternalResourceLoading: boolean): string; } //# sourceMappingURL=chat-find-matcher.d.ts.map