export type Tone = 'info' | 'success' | 'warning' | 'error'; export interface PluginDocument { id: string; path: string | null; name: string; content: string; checksum: string; language: string } export interface TextEdit { from: number; to: number; text: string } export interface StatusAction { id: string; title: string; command: string; args?: unknown; group?: string; disabled?: boolean } export interface StatusItem { text: string; title?: string; command?: string; icon?: string; tone?: Tone; busy?: boolean; actions?: StatusAction[]; documentId?: string; args?: unknown } export interface DocumentInfo { id: string; path: string | null; name: string; relativePath: string | null; active: boolean; modified: boolean } export interface FileDecoration { extensions?: string[]; paths?: string[]; svg: string; title?: string } export interface VersionItem { id: string; label: string; meta?: string; rev?: number; content?: string; actionLabel?: string } export interface VersionSource { path: string; title?: string; emptyText?: string; items: VersionItem[] } export interface PluginContext { endpoint: string; workspace: boolean; workspaceId: string; apiVersion: 1; sdkVersion: string; capabilities: string[]; permissions: string[]; theme: 'light' | 'dark'; development: boolean } export interface PluginSelection { documentId: string; from: number; to: number; text: string; checksum: string } export interface PluginApi { apiVersion: 1; sdkVersion: string; signal: AbortSignal; rpc(method: string, args?: Record): Promise; context(): Promise; capabilities: { get(): Promise; has(name: string): Promise }; configuration: { get>(): Promise }; theme: { get(): Promise<'light' | 'dark'>; onDidChange(callback: (theme: 'light' | 'dark') => unknown): () => void }; notifications: { show(message: string, options?: { tone?: Tone; duration?: number }): Promise }; storage: { get(key: string): Promise; set(key: string, value: unknown): Promise; keys(): Promise; delete(key: string): Promise }; workspace: { list(path?: string): Promise<{ name: string; directory: boolean }[]>; read(path: string): Promise<{ content: string | null; checksum: string | null }>; write(path: string, content: string, expectedHash?: string | null): Promise; delete(path: string, expectedHash: string): Promise; }; net: { request(path: string, options?: { method?: 'GET' | 'PUT' | 'POST' | 'DELETE'; body?: unknown }): Promise<{ status: number; data: T }> }; editor: { getActiveDocument(): Promise; getDocument(documentId: string): Promise; listDocuments(): Promise; focusDocument(documentId: string): Promise; getSelection(documentId?: string): Promise; setSelection(documentId: string, expectedChecksum: string, from: number, to?: number): Promise; showDiff(options: { path?: string; content: string; label?: string; rev?: number; actions?: StatusAction[]; actionLabel?: string }): Promise; showVersions(options: { path?: string; title?: string; items: VersionItem[] }): Promise; reloadDocument(documentId: string): Promise; applyEdits(documentId: string, expectedChecksum: string, edits: TextEdit[]): Promise<{ documentId: string; checksum: string }>; onDidSave(callback: (event: { path: string; name: string }) => unknown): () => void; onDidChangeDocuments(callback: (documents: DocumentInfo[]) => unknown): () => void; onDidChangeContent(callback: (event: { documentIds: string[] }) => unknown): () => void; }; versions: { set(source: VersionSource): Promise; remove(path: string): Promise; onDidSelect(callback: (event: { rev: number; path?: string }) => unknown): () => void; onDidRequestRefresh(callback: (event: unknown) => unknown): () => void }; styles: { setMarkdown(id: string, css: string): Promise; remove(id: string): Promise }; commands: { register(id: string, title: string, callback: (args: unknown) => unknown): Promise<() => void> }; statusBar: { set(id: string, item: StatusItem): Promise; remove(id: string): Promise }; fileIcons: { set(id: string, item: FileDecoration): Promise; remove(id: string): Promise }; fileBadges: { set(id: string, item: FileDecoration): Promise; remove(id: string): Promise }; tasks: { set(id: string, task: { title: string; status?: string; tone?: Tone; command?: string; args?: unknown; progress?: number; reveal?: boolean }): Promise; remove(id: string): Promise }; on(name: string, callback: (payload: unknown) => unknown): () => void; onDispose(callback: () => void): () => void; dispose(): void; } export const SDK_VERSION: string; export class PluginError extends Error { code: string; constructor(message: string, code?: string) } export function createPluginClient(port: MessagePort, options?: { timeoutMs?: number }): PluginApi; export function definePlugin(activate: (api: PluginApi) => void | (() => void) | Promise void)>): void;