import { TElement } from 'platejs'; import { EditorConfig } from '../../../lib/config-provider'; import { EditorPluginKit } from '../../../types/plugin-types'; /** * Copilot 配置选项 */ export interface CopilotOptions { /** API 地址 */ apiUrl?: string; /** 自定义请求头 */ headers?: Record; /** 系统提示词 */ systemPrompt?: string; /** 防抖延迟(毫秒),默认 500 */ debounceDelay?: number; /** 是否在错误时使用随机文本填充,默认 true */ useFallbackOnError?: boolean; /** 自定义提示生成函数 */ getPrompt?: (context: { editor: unknown; contextEntry: [TElement, number[]] | null; }) => string; /** 自定义补全结果处理函数 */ onComplete?: (completion: string) => string; /** 快捷键配置 */ shortcuts?: { accept?: string; acceptNextWord?: string; reject?: string; triggerSuggestion?: string; }; /** 是否启用,默认 true */ enabled?: boolean; } /** 导出系统提示词供外部使用 */ export declare const COPILOT_SYSTEM_PROMPT = "You are an advanced AI writing assistant, similar to VSCode Copilot but for general text. Your task is to predict and generate the next part of the text based on the given context.\n\nRules:\n- Continue the text naturally up to the next punctuation mark (., ,, ;, :, ?, or !).\n- Maintain style and tone. Don't repeat given text.\n- For unclear context, provide the most likely continuation.\n- Handle code snippets, lists, or structured text if needed.\n- Don't include \"\"\" in your response.\n- CRITICAL: Always end with a punctuation mark.\n- CRITICAL: Avoid starting a new block. Do not use block formatting like >, #, 1., 2., -, etc. The suggestion should continue in the same block as the context.\n- If no context is provided or you can't generate a continuation, return \"0\" without explanation."; /** * 创建 Copilot 插件配置 * @param editorConfig 编辑器配置(可选,用于自定义 API 地址和请求头) * @param options Copilot 特定配置选项 */ export declare function createCopilotKit(editorConfig?: EditorConfig, options?: CopilotOptions): EditorPluginKit; /** * 默认 Copilot 插件(使用默认配置) */ export declare const CopilotKit: EditorPluginKit; /** * 创建禁用的 Copilot Kit(仅包含 Markdown 支持) */ export declare const DisabledCopilotKit: EditorPluginKit;