import { Event } from "../../../../base/common/event.js"; import { URI } from "../../../../base/common/uri.js"; import { IProcessPropertyMap, ITerminalChildProcess, ITerminalLaunchError, ITerminalLaunchResult, ProcessPropertyType } from "../../../../platform/terminal/common/terminal.js"; import { ITerminalLogService } from "../../../../platform/terminal/common/terminal.service.js"; import { IAgentConnection } from "../../../../platform/agentHost/common/agentService.js"; import { BasePty } from "../common/basePty.js"; /** * Options for creating a new terminal on an agent host. */ export interface IAgentHostPtyOptions { /** Human-readable terminal name. */ readonly name?: string; /** Initial working directory URI. */ readonly cwd?: URI; /** * When true, attach to an existing terminal on the agent host instead of * creating a new one. The terminal must already exist server-side (e.g. * created by a tool). The pty will subscribe to its state and replay * content without calling `createTerminal`. */ readonly attachOnly?: boolean; } export interface IAgentHostPtyCommandExecutedEvent { readonly commandId: string; readonly commandLine: string; readonly timestamp: number; /** The stored VT output for this command (present during content replay). */ readonly storedOutput?: string; } export interface IAgentHostPtyCommandFinishedEvent { readonly commandId: string; readonly exitCode?: number; readonly durationMs?: number; } export declare enum AhpCommandMarkKind { Executed = "s", End = "e" } /** * Generates the mark ID used to correlate SetMark VT codes with xterm markers * via {@link IBufferMarkCapability.getMark}. */ export declare function getAhpCommandMarkId(commandId: string, kind: AhpCommandMarkKind): string; /** * A pseudo-terminal backed by an Agent Host Protocol terminal subscription. * * Uses `customPtyImplementation` on `IShellLaunchConfig` so the * `TerminalProcessManager` bypasses the pty host backend entirely. * * Data flow: * terminal/data → onProcessData * terminal/exited → onProcessExit * input(data) → dispatch terminal/input * resize(c,r) → dispatch terminal/resized * shutdown() → disposeTerminal command */ export declare class AgentHostPty extends BasePty implements ITerminalChildProcess { private _connection; private readonly _terminalUri; private readonly _options; private readonly _logService; private readonly _startBarrier; private readonly _lifetime; private readonly _subscription; private _terminalCreation; private _initialCwd; private _didSignalReady; private readonly _onCommandExecuted; readonly onCommandExecuted: Event; private readonly _onCommandFinished; readonly onCommandFinished: Event; private readonly _onSupportsCommandDetection; readonly onSupportsCommandDetection: Event; private _supportsCommandDetection; get supportsCommandDetection(): boolean; private _isCommandStateKnown; private _pendingCommandCount; private readonly _executingCommandIds; /** * Whether a shell command is pending or executing in the terminal, or * `undefined` when the command state is unknown. */ get isCommandExecuting(): boolean | undefined; /** The working directory the terminal started in and its current one, as reported by the host. */ get cwd(): { readonly initial: string; readonly current: string; }; /** * Records that a command line is about to be submitted to the shell * prompt, so the terminal counts as busy until the shell reports that the * command started executing. */ markCommandPending(): void; /** * Command IDs for sentinel commands that should be suppressed from shell * integration events. When the copilot shell tools fall back to sentinel- * based exit code detection, shell integration may also detect the sentinel * echo as a real command — we filter those out here. */ private readonly _suppressedCommandIds; constructor(id: number, _connection: IAgentConnection, _terminalUri: URI, _options: IAgentHostPtyOptions | undefined, _logService: ITerminalLogService); start(): Promise; private _clearTerminalCreation; private _signalReady; private _handleAction; /** * Replays structured terminal content parts from the initial state snapshot. * Emits command lifecycle events for command parts so that consumers * (e.g. {@link AhpTerminalCommandSource}) can reconstruct command history. */ private _replayContent; /** Maps a client cwd into the owning connection's host space for the protocol. */ private _resolveCwdForProtocol; private _createSubscription; private _waitForHydration; input(data: string): void; resize(cols: number, rows: number): void; shutdown(_immediate: boolean): void; private _requestHostTerminalDisposal; private _disposeHostTerminal; private _logHostDisposalError; private _exitAndDispose; getInitialCwd(): Promise; getCwd(): Promise; clearBuffer(): Promise; acknowledgeDataEvent(_charCount: number): void; setUnicodeVersion(_version: "6" | "11"): Promise; processBinary(_data: string): Promise; sendSignal(_signal: string): void; refreshProperty(type: T): Promise; updateProperty(_type: T, _value: IProcessPropertyMap[T]): Promise; /** * Reconnect this pty to a new agent host connection. Tears down the * old subscription and re-subscribes with the new connection, replaying * content from the server-side snapshot. Terminal output during the * disconnect gap is a stream (not state), so some loss is expected. * * @returns `true` if reconnection succeeded, `false` otherwise. */ reconnect(newConnection: IAgentConnection): Promise; /** The terminal URI this pty is subscribed to. */ get terminalUri(): URI; dispose(): void; }