import { Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event"; import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri"; import { IProcessPropertyMap, ITerminalChildProcess, ITerminalLaunchError, ITerminalLaunchResult, ProcessPropertyType } from "@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal"; import { IAgentConnection } from "@codingame/monaco-vscode-chat-service-override/vscode/vs/platform/agentHost/common/agentService"; 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 _startBarrier; private readonly _subscriptionDisposables; private _subscriptionRef; private _initialCwd; private readonly _onCommandExecuted; readonly onCommandExecuted: Event; private readonly _onCommandFinished; readonly onCommandFinished: Event; private readonly _onSupportsCommandDetection; readonly onSupportsCommandDetection: Event; private _supportsCommandDetection; get supportsCommandDetection(): boolean; /** * 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); start(): Promise; 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; /** * Resolves a cwd URI for sending over the protocol. Agent-host URIs * are unwrapped to their original URI via {@link fromAgentHostUri}. */ private _resolveCwdForProtocol; input(data: string): void; resize(cols: number, rows: number): void; shutdown(_immediate: boolean): void; 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; }