import { EditorRangeMark } from './editor-overlay'; import { MarkdownEdit } from './markdown-format'; import { MarkdownEditorAi, MarkdownEditorAiAction, MarkdownEditorSelection } from './types'; /** * Rewrites selected text with the host's AI. A session holds the text, tracked * through every edit while it is open, and the answer as it streams in. The * answer goes into the document only when the user takes it, in place of the * text or as a block below it, as one undo step; the text it wrote then * lights up for a moment. */ /** `compose`: the user is choosing what to ask. */ export type MarkdownAiStatus = 'compose' | 'waiting' | 'streaming' | 'done' | 'failed'; export interface MarkdownAiSession { status: MarkdownAiStatus; /** What was asked; null until something is. */ action: MarkdownEditorAiAction | null; instruction: string; /** The text the answer rewrites. */ original: string; /** The answer so far, trimmed once it is finished. */ answer: string; } export interface MarkdownAiOptions { ai: () => MarkdownEditorAi | undefined; doc: () => string; track: (selection: MarkdownEditorSelection) => MarkdownEditorSelection; untrack: (range: MarkdownEditorSelection) => void; /** Applies a local edit as one undo step and puts the caret at its selection. */ commit: (edit: MarkdownEdit, before: MarkdownEditorSelection) => void; /** Where the block holding `pos` ends: an answer inserted below goes there. */ blockEnd: (pos: number) => number; /** Gives the editor its focus and `selection` back. */ restore: (selection: MarkdownEditorSelection) => void; /** The marks changed. */ repaint: () => void; onError: (error: unknown) => void; } export declare function useMarkdownAi(options: MarkdownAiOptions): { session: import('vue').ShallowRef; open: (selection: MarkdownEditorSelection) => boolean; run: (action: MarkdownEditorAiAction, instruction?: string) => Promise; stop: () => void; retry: () => void; accept: (below?: boolean) => void; discard: () => void; close: () => MarkdownEditorSelection | null; marks: () => EditorRangeMark[]; }; export type MarkdownAi = ReturnType;