import { AppConfig, IChatProgress, IMarker, WithEventBus } from '@opensumi/ide-core-browser'; import { WorkbenchEditorService } from '@opensumi/ide-editor'; import { EditorGroupCloseEvent, EditorGroupOpenEvent } from '@opensumi/ide-editor/lib/browser'; import { ICodeEditor, ITextModel, Range } from '@opensumi/ide-monaco'; import { URI } from '@opensumi/ide-utils'; import { SumiReadableStream } from '@opensumi/ide-utils/lib/stream'; import { CodeBlockData } from '../../common/types'; import { ChatInternalService } from '../chat/chat.internal.service'; import { BaseInlineDiffPreviewer } from '../widget/inline-diff'; import type { BaseInlineStreamDiffHandler } from '../widget/inline-stream-diff/inline-stream-diff.handler'; export declare abstract class BaseApplyService extends WithEventBus { static readonly CHAT_EDITING_SOURCE_RESOLVER_SCHEME = "chat-editing-source"; protected chatInternalService: ChatInternalService; protected appConfig: AppConfig; protected readonly editorService: WorkbenchEditorService; private readonly inlineDiffService; private readonly markerService; private readonly editorDocumentModelService; private readonly aiReporter; private onCodeBlockUpdateEmitter; onCodeBlockUpdate: import("@opensumi/ide-core-browser").Event; private currentSessionId?; constructor(); private getMessageCodeBlocks; private activePreviewerMap; private editorListenerMap; onEditorGroupClose(event: EditorGroupCloseEvent): void; onEditorGroupOpen(event: EditorGroupOpenEvent): Promise; get currentPreviewer(): BaseInlineDiffPreviewer | undefined; /** * 获取指定uri的 code block,按version降序排序 */ getUriCodeBlocks(uri: URI): CodeBlockData[] | undefined; getPendingPaths(sessionId?: string): string[]; getSessionCodeBlocks(sessionId?: string): CodeBlockData[]; getCodeBlock(toolCallId: string, messageId?: string): CodeBlockData | undefined; protected updateCodeBlock(codeBlock: CodeBlockData): void; registerCodeBlock(relativePath: string, content: string, toolCallId: string, instructions?: string): Promise; private duringApply?; /** * Apply changes of a code block */ apply(codeBlock: CodeBlockData): Promise; /** * 渲染apply结果(支持流式和直接输出结果) * 副作用:渲染时会添加accept、reject操作监听器,监听到结果时会自动更新codeBlock的result */ renderApplyResult(editor: ICodeEditor, codeBlock: CodeBlockData, updatedContentOrStream: string | SumiReadableStream, range?: Range): Promise<{ result?: { diff: string; diagnosticInfos: IMarker[]; }; updatedCode: string; }>; /** * Cancel an ongoing apply operation */ cancelApply(blockData: CodeBlockData, keepStatus?: boolean): void; cancelAllApply(sessionId?: string): void; revealApplyPosition(blockData: CodeBlockData): void; processAll(type: 'accept' | 'reject', uri?: URI): Promise; protected doProcess(type: 'accept' | 'reject', relativePath: string): void; protected listenPartialEdit(model: ITextModel, codeBlock: CodeBlockData): Promise<{ diff: string; diagnosticInfos: IMarker[]; }>; protected getDiffResult(originalContent: string, appliedResult: string, relativePath: string): { diff: string; rangesFromDiffHunk: Range[]; }; /** * Apply changes of a code block, return stream to render inline diff in stream mode, result to render inline diff directly * range is optional, if not provided, the result will be applied to the the full file */ protected abstract doApply(codeBlock: CodeBlockData): Promise<{ range?: Range; stream?: SumiReadableStream; result?: string; }>; protected getDiagnosticInfos(uri: string, ranges: Range[]): IMarker[]; } //# sourceMappingURL=base-apply.service.d.ts.map