import { Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event"; import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle"; import type { IMarker } from "@xterm/xterm"; import { type ITerminalCommand, type IMarkProperties } from "@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/capabilities/capabilities"; import type { ITerminalOutputMatch, ITerminalOutputMatcher } from "@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal"; import type { IAhpTerminalCommandSource, ITerminalInstance } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal"; import { AhpCommandMarkKind, type AgentHostPty } from "./agentHostPty.js"; /** * An implementation of {@link ITerminalCommand} backed by AHP protocol data * rather than local shell integration markers. For streaming commands (arriving * after initial subscription), real xterm markers are registered via * {@link ITerminalInstance.registerMarker}. For replayed commands (from state * snapshot), stored VT output is used as a fallback since marker positions are * unreliable during bulk replay. */ export declare class AhpTerminalCommand implements ITerminalCommand { command: string; readonly commandLineConfidence: "low" | "medium" | "high"; readonly isTrusted: boolean; timestamp: number; duration: number; readonly id: string; readonly cwd: string | undefined; exitCode: number | undefined; readonly commandStartLineContent: string | undefined; readonly markProperties: IMarkProperties | undefined; readonly executedX: number | undefined; readonly startX: number | undefined; readonly promptStartMarker?: IMarker; readonly marker?: IMarker; readonly aliases?: string[][]; readonly wasReplayed?: boolean; /** * Lazily resolved executed marker. Uses a getter so that the marker is * resolved on first access rather than at construction time, giving xterm * a chance to flush the SetMark sequence through its async write queue. */ get executedMarker(): IMarker | undefined; private _executedMarker; /** * Lazily resolved end marker, same rationale as {@link executedMarker}. */ get endMarker(): IMarker | undefined; set endMarker(value: IMarker | undefined); private _endMarker; private _isComplete; /** * Stored VT output from the AHP content part. Used as a fallback when * xterm markers are not available (e.g. during content replay). */ private _storedOutput; /** * Optional function to lazily resolve markers from the terminal's * {@link IBufferMarkCapability}. Set during construction. */ private readonly _resolveMarker?; constructor(commandId: string, commandLine: string, timestamp: number, options?: { resolveMarker?: (kind: AhpCommandMarkKind) => IMarker | undefined; storedOutput?: string; wasReplayed?: boolean; }); extractCommandLine(): string; getOutput(): string | undefined; /** * Get the raw VT output (with ANSI escape codes preserved). * Used by the terminal mirror for rendering. */ getRawOutput(): string | undefined; hasOutput(): boolean; getOutputMatch(_outputMatcher: ITerminalOutputMatcher): ITerminalOutputMatch | undefined; getPromptRowCount(): number; getCommandRowCount(): number; /** * Append VT output to the stored output buffer. Called during streaming * as `terminal/data` actions arrive. */ appendOutput(data: string): void; /** * Mark this command as finished with the given exit code and duration. */ finish(exitCode: number | undefined, durationMs: number | undefined): void; } /** * A command detection source for AHP terminals. Listens to * {@link AgentHostPty} command lifecycle events and maintains a list of * {@link AhpTerminalCommand} objects, exposing an interface compatible with * {@link IAhpTerminalCommandSource}. */ export declare class AhpTerminalCommandSource extends Disposable implements IAhpTerminalCommandSource { private readonly _commands; private _executingCommand; private readonly _onCommandExecuted; readonly onCommandExecuted: Event; private readonly _onCommandFinished; readonly onCommandFinished: Event; private _terminalInstance; get commands(): readonly ITerminalCommand[]; get executingCommandObject(): ITerminalCommand | undefined; connect(terminalInstance: ITerminalInstance, pty: AgentHostPty): void; getCommandById(id: string): ITerminalCommand | undefined; /** * Resolves an xterm marker by its AHP command mark ID from the * {@link IBufferMarkCapability}. The marker is placed by xterm's OSC 633 * parser when it processes the SetMark sequence injected by * {@link AgentHostPty}, so it is always at the correct cursor position * regardless of whether the data was replayed or streamed. */ private _resolveMarkById; private _handleCommandExecuted; private _handleCommandFinished; }