1
>
/*---------------------------------------------------------------------------------------------
terminal.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { Event } from '../../../base/common/event.js';
7
>
import { IProcessEnvironment, OperatingSystem } from '../../../base/common/platform.js';
8
>
import { URI, UriComponents } from '../../../base/common/uri.js';
9
>
import { createDecorator } from '../../instantiation/common/instantiation.js';
10
>
import { IPtyHostProcessReplayEvent, ISerializedCommandDetectionCapability, ITerminalCapabilityStore, type ITerminalCommand } from './capabilities/capabilities.js';
11
>
import { IGetTerminalLayoutInfoArgs, IProcessDetails, ISetTerminalLayoutInfoArgs } from './terminalProcess.js';
12
>
import { ThemeIcon } from '../../../base/common/themables.js';
13
>
import { ISerializableEnvironmentVariableCollections } from './environmentVariable.js';
14
>
import { IWorkspaceFolder } from '../../workspace/common/workspace.js';
15
>
import { Registry } from '../../registry/common/platform.js';
16
>
import type * as performance from '../../../base/common/performance.js';
17
>
import { ILogService } from '../../log/common/log.js';
18
>
import type { IAction } from '../../../base/common/actions.js';
19
>
import type { IDisposable } from '../../../base/common/lifecycle.js';
20
>
import type { SingleOrMany } from '../../../base/common/types.js';
21
>
22
>
export const enum TerminalSettingPrefix {
23
>
AutomationProfile = 'terminal.integrated.automationProfile.',
24
>
DefaultProfile = 'terminal.integrated.defaultProfile.',
25
>
Profiles = 'terminal.integrated.profiles.'
26
>
}
27
>
28
>
export const enum TerminalSettingId {
29
>
SendKeybindingsToShell = 'terminal.integrated.sendKeybindingsToShell',
30
>
AutomationProfileLinux = 'terminal.integrated.automationProfile.linux',
31
>
AutomationProfileMacOs = 'terminal.integrated.automationProfile.osx',
32
>
AutomationProfileWindows = 'terminal.integrated.automationProfile.windows',
33
>
AgentHostProfileLinux = 'terminal.integrated.agentHostProfile.linux',
34
>
AgentHostProfileMacOs = 'terminal.integrated.agentHostProfile.osx',
35
>
AgentHostProfileWindows = 'terminal.integrated.agentHostProfile.windows',
36
>
ProfilesWindows = 'terminal.integrated.profiles.windows',
37
>
ProfilesMacOs = 'terminal.integrated.profiles.osx',
38
>
ProfilesLinux = 'terminal.integrated.profiles.linux',
39
>
DefaultProfileLinux = 'terminal.integrated.defaultProfile.linux',
40
>
DefaultProfileMacOs = 'terminal.integrated.defaultProfile.osx',
41
>
DefaultProfileWindows = 'terminal.integrated.defaultProfile.windows',
42
>
UseWslProfiles = 'terminal.integrated.useWslProfiles',
43
>
TabsDefaultColor = 'terminal.integrated.tabs.defaultColor',
44
>
TabsDefaultIcon = 'terminal.integrated.tabs.defaultIcon',
45
>
TabsEnabled = 'terminal.integrated.tabs.enabled',
46
>
TabsEnableAnimation = 'terminal.integrated.tabs.enableAnimation',
47
>
TabsHideCondition = 'terminal.integrated.tabs.hideCondition',
48
>
TabsShowActiveTerminal = 'terminal.integrated.tabs.showActiveTerminal',
49
>
TabsShowActions = 'terminal.integrated.tabs.showActions',
50
>
TabsLocation = 'terminal.integrated.tabs.location',
51
>
TabsFocusMode = 'terminal.integrated.tabs.focusMode',
52
>
TabsAllowAgentCliTitle = 'terminal.integrated.tabs.allowAgentCliTitle',
53
>
MacOptionIsMeta = 'terminal.integrated.macOptionIsMeta',
54
>
MacOptionClickForcesSelection = 'terminal.integrated.macOptionClickForcesSelection',
55
>
AltClickMovesCursor = 'terminal.integrated.altClickMovesCursor',
56
>
CopyOnSelection = 'terminal.integrated.copyOnSelection',
57
>
EnableMultiLinePasteWarning = 'terminal.integrated.enableMultiLinePasteWarning',
58
>
DrawBoldTextInBrightColors = 'terminal.integrated.drawBoldTextInBrightColors',
59
>
FontFamily = 'terminal.integrated.fontFamily',
60
>
FontSize = 'terminal.integrated.fontSize',
61
>
LetterSpacing = 'terminal.integrated.letterSpacing',
62
>
LineHeight = 'terminal.integrated.lineHeight',
63
>
MinimumContrastRatio = 'terminal.integrated.minimumContrastRatio',
64
>
TabStopWidth = 'terminal.integrated.tabStopWidth',
65
>
FastScrollSensitivity = 'terminal.integrated.fastScrollSensitivity',
66
>
MouseWheelScrollSensitivity = 'terminal.integrated.mouseWheelScrollSensitivity',
67
>
BellDuration = 'terminal.integrated.bellDuration',
68
>
FontWeight = 'terminal.integrated.fontWeight',
69
>
FontWeightBold = 'terminal.integrated.fontWeightBold',
70
>
CursorBlinking = 'terminal.integrated.cursorBlinking',
71
>
TextBlinking = 'terminal.integrated.textBlinking',
72
>
CursorStyle = 'terminal.integrated.cursorStyle',
73
>
CursorStyleInactive = 'terminal.integrated.cursorStyleInactive',
74
>
CursorWidth = 'terminal.integrated.cursorWidth',
75
>
Scrollback = 'terminal.integrated.scrollback',
76
>
DetectLocale = 'terminal.integrated.detectLocale',
77
>
DefaultLocation = 'terminal.integrated.defaultLocation',
78
>
GpuAcceleration = 'terminal.integrated.gpuAcceleration',
79
>
TerminalTitleSeparator = 'terminal.integrated.tabs.separator',
80
>
TerminalTitle = 'terminal.integrated.tabs.title',
81
>
TerminalDescription = 'terminal.integrated.tabs.description',
82
>
RightClickBehavior = 'terminal.integrated.rightClickBehavior',
83
>
MiddleClickBehavior = 'terminal.integrated.middleClickBehavior',
84
>
Cwd = 'terminal.integrated.cwd',
85
>
ConfirmOnExit = 'terminal.integrated.confirmOnExit',
86
>
ConfirmOnKill = 'terminal.integrated.confirmOnKill',
87
>
EnableBell = 'terminal.integrated.enableBell',
88
>
EnableVisualBell = 'terminal.integrated.enableVisualBell',
89
>
CommandsToSkipShell = 'terminal.integrated.commandsToSkipShell',
90
>
AllowChords = 'terminal.integrated.allowChords',
91
>
AllowMnemonics = 'terminal.integrated.allowMnemonics',
92
>
TabFocusMode = 'terminal.integrated.tabFocusMode',
93
>
EnvMacOs = 'terminal.integrated.env.osx',
94
>
EnvLinux = 'terminal.integrated.env.linux',
95
>
EnvWindows = 'terminal.integrated.env.windows',
96
>
EnvironmentChangesRelaunch = 'terminal.integrated.environmentChangesRelaunch',
97
>
ShowExitAlert = 'terminal.integrated.showExitAlert',
98
>
SplitCwd = 'terminal.integrated.splitCwd',
99
>
WindowsUseConptyDll = 'terminal.integrated.windowsUseConptyDll',
100
>
WordSeparators = 'terminal.integrated.wordSeparators',
101
>
EnableFileLinks = 'terminal.integrated.enableFileLinks',
102
>
AllowedLinkSchemes = 'terminal.integrated.allowedLinkSchemes',
103
>
UnicodeVersion = 'terminal.integrated.unicodeVersion',
104
>
EnablePersistentSessions = 'terminal.integrated.enablePersistentSessions',
105
>
PersistentSessionReviveProcess = 'terminal.integrated.persistentSessionReviveProcess',
106
>
HideOnStartup = 'terminal.integrated.hideOnStartup',
107
>
HideOnLastClosed = 'terminal.integrated.hideOnLastClosed',
108
>
CustomGlyphs = 'terminal.integrated.customGlyphs',
109
>
RescaleOverlappingGlyphs = 'terminal.integrated.rescaleOverlappingGlyphs',
110
>
PersistentSessionScrollback = 'terminal.integrated.persistentSessionScrollback',
111
>
InheritEnv = 'terminal.integrated.inheritEnv',
112
>
ShowLinkHover = 'terminal.integrated.showLinkHover',
113
>
IgnoreProcessNames = 'terminal.integrated.ignoreProcessNames',
114
>
ShellIntegrationEnabled = 'terminal.integrated.shellIntegration.enabled',
115
>
ShellIntegrationShowWelcome = 'terminal.integrated.shellIntegration.showWelcome',
116
>
ShellIntegrationDecorationsEnabled = 'terminal.integrated.shellIntegration.decorationsEnabled',
117
>
ShellIntegrationTimeout = 'terminal.integrated.shellIntegration.timeout',
118
>
ShellIntegrationQuickFixEnabled = 'terminal.integrated.shellIntegration.quickFixEnabled',
119
>
ShellIntegrationEnvironmentReporting = 'terminal.integrated.shellIntegration.environmentReporting',
120
>
EnableImages = 'terminal.integrated.enableImages',
121
>
SmoothScrolling = 'terminal.integrated.smoothScrolling',
122
>
IgnoreBracketedPasteMode = 'terminal.integrated.ignoreBracketedPasteMode',
123
>
FocusAfterRun = 'terminal.integrated.focusAfterRun',
124
>
FontLigaturesEnabled = 'terminal.integrated.fontLigatures.enabled',
125
>
FontLigaturesFeatureSettings = 'terminal.integrated.fontLigatures.featureSettings',
126
>
FontLigaturesFallbackLigatures = 'terminal.integrated.fontLigatures.fallbackLigatures',
127
>
EnableKittyKeyboardProtocol = 'terminal.integrated.enableKittyKeyboardProtocol',
128
>
EnableWin32InputMode = 'terminal.integrated.enableWin32InputMode',
129
>
AllowInUntrustedWorkspace = 'terminal.integrated.allowInUntrustedWorkspace',
130
>
131
>
// Developer/debug settings
132
>
133
>
/** Simulated latency applied to all calls made to the pty host */
134
>
DeveloperPtyHostLatency = 'terminal.integrated.developer.ptyHost.latency',
135
>
/** Simulated startup delay of the pty host process */
136
>
DeveloperPtyHostStartupDelay = 'terminal.integrated.developer.ptyHost.startupDelay',
137
>
/** Shows the textarea element */
138
>
DevMode = 'terminal.integrated.developer.devMode'
139
>
}
140
>
141
>
export const enum PosixShellType {
142
>
Bash = 'bash',
143
>
Fish = 'fish',
144
>
Sh = 'sh',
145
>
Csh = 'csh',
146
>
Ksh = 'ksh',
147
>
Zsh = 'zsh',
148
>
149
>
}
150
>
export const enum WindowsShellType {
151
>
CommandPrompt = 'cmd',
152
>
Wsl = 'wsl',
153
>
GitBash = 'gitbash',
154
>
}
155
>
156
>
export const enum GeneralShellType {
157
>
Claude = 'claude',
158
>
Codex = 'codex',
159
>
CommandCode = 'commandcode',
160
>
Copilot = 'copilot',
161
>
Gemini = 'gemini',
162
>
PowerShell = 'pwsh',
163
>
Python = 'python',
164
>
Julia = 'julia',
165
>
NuShell = 'nu',
166
>
Node = 'node',
167
>
Xonsh = 'xonsh',
168
>
}
169
>
export type TerminalShellType = PosixShellType | WindowsShellType | GeneralShellType | undefined;
170
>
171
>
export interface IRawTerminalInstanceLayoutInfo<T> {
172
>
relativeSize: number;
173
>
terminal: T;
174
>
}
175
>
export type ITerminalInstanceLayoutInfoById = IRawTerminalInstanceLayoutInfo<number>;
176
>
export type ITerminalInstanceLayoutInfo = IRawTerminalInstanceLayoutInfo<IPtyHostAttachTarget>;
177
>
178
>
export interface IRawTerminalTabLayoutInfo<T> {
179
>
isActive: boolean;
180
>
activePersistentProcessId: number | undefined;
181
>
terminals: IRawTerminalInstanceLayoutInfo<T>[];
182
>
}
183
>
184
>
export type ITerminalTabLayoutInfoById = IRawTerminalTabLayoutInfo<number>;
185
>
186
>
export interface IRawTerminalsLayoutInfo<T> {
187
>
tabs: IRawTerminalTabLayoutInfo<T>[];
188
>
background: T[] | null;
189
>
}
190
>
191
>
export interface IPtyHostAttachTarget {
192
>
id: number;
193
>
pid: number;
194
>
title: string;
195
>
titleSource: TitleEventSource;
196
>
cwd: string;
197
>
workspaceId: string;
198
>
workspaceName: string;
199
>
isOrphan: boolean;
200
>
icon: TerminalIcon | undefined;
201
>
fixedDimensions: IFixedTerminalDimensions | undefined;
202
>
environmentVariableCollections: ISerializableEnvironmentVariableCollections | undefined;
203
>
reconnectionProperties?: IReconnectionProperties;
204
>
waitOnExit?: WaitOnExitValue;
205
>
hideFromUser?: boolean;
206
>
isFeatureTerminal?: boolean;
207
>
type?: TerminalType;
208
>
hasChildProcesses: boolean;
209
>
shellIntegrationNonce: string;
210
>
tabActions?: ITerminalTabAction[];
211
>
}
212
>
213
>
export interface IReconnectionProperties {
214
>
ownerId: string;
215
>
data?: unknown;
216
>
}
217
>
218
>
export type TerminalType = 'Task' | 'Local' | undefined;
219
>
220
>
export enum TitleEventSource {
221
>
/** From the API or the rename command that overrides any other type */
222
>
Api,
223
>
/** From the process name property*/
224
>
Process,
225
>
/** From the VT sequence */
226
>
Sequence,
227
>
/** Config changed */
228
>
Config
229
>
}
230
>
231
>
export type ITerminalsLayoutInfo = IRawTerminalsLayoutInfo<IPtyHostAttachTarget | null>;
232
>
export type ITerminalsLayoutInfoById = IRawTerminalsLayoutInfo<number>;
233
>
234
>
export enum TerminalIpcChannels {
235
>
/**
236
>
* Communicates between the renderer process and shared process.
237
>
*/
238
>
LocalPty = 'localPty',
239
>
/**
240
>
* Communicates between the shared process and the pty host process.
241
>
*/
242
>
PtyHost = 'ptyHost',
243
>
/**
244
>
* Communicates between the renderer process and the pty host process.
245
>
*/
246
>
PtyHostWindow = 'ptyHostWindow',
247
>
/**
248
>
* Deals with logging from the pty host process.
249
>
*/
250
>
Logger = 'logger',
251
>
/**
252
>
* Enables the detection of unresponsive pty hosts.
253
>
*/
254
>
Heartbeat = 'heartbeat'
255
>
}
256
>
257
>
export const enum ProcessPropertyType {
258
>
Cwd = 'cwd',
259
>
InitialCwd = 'initialCwd',
260
>
FixedDimensions = 'fixedDimensions',
261
>
Title = 'title',
262
>
ShellType = 'shellType',
263
>
HasChildProcesses = 'hasChildProcesses',
264
>
ResolvedShellLaunchConfig = 'resolvedShellLaunchConfig',
265
>
OverrideDimensions = 'overrideDimensions',
266
>
FailedShellIntegrationActivation = 'failedShellIntegrationActivation',
267
>
UsedShellIntegrationInjection = 'usedShellIntegrationInjection',
268
>
ShellIntegrationInjectionFailureReason = 'shellIntegrationInjectionFailureReason',
269
>
}
270
>
271
>
export interface IProcessProperty<T extends ProcessPropertyType = ProcessPropertyType> {
272
>
type: T;
273
>
value: IProcessPropertyMap[T];
274
>
}
275
>
276
>
export interface IProcessPropertyMap {
277
>
[ProcessPropertyType.Cwd]: string;
278
>
[ProcessPropertyType.InitialCwd]: string;
279
>
[ProcessPropertyType.FixedDimensions]: IFixedTerminalDimensions;
280
>
[ProcessPropertyType.Title]: string;
281
>
[ProcessPropertyType.ShellType]: TerminalShellType | undefined;
282
>
[ProcessPropertyType.HasChildProcesses]: boolean;
283
>
[ProcessPropertyType.ResolvedShellLaunchConfig]: IShellLaunchConfig;
284
>
[ProcessPropertyType.OverrideDimensions]: ITerminalDimensionsOverride | undefined;
285
>
[ProcessPropertyType.FailedShellIntegrationActivation]: boolean | undefined;
286
>
[ProcessPropertyType.UsedShellIntegrationInjection]: boolean | undefined;
287
>
[ProcessPropertyType.ShellIntegrationInjectionFailureReason]: ShellIntegrationInjectionFailureReason | undefined;
288
>
}
289
>
290
>
export interface IFixedTerminalDimensions {
291
>
/**
292
>
* The fixed columns of the terminal.
293
>
*/
294
>
cols?: number;
295
>
296
>
/**
297
>
* The fixed rows of the terminal.
298
>
*/
299
>
rows?: number;
300
>
}
301
>
302
>
export interface ITerminalLaunchResult {
303
>
injectedArgs: string[];
304
>
}
305
>
306
>
/**
307
>
* A service that communicates with a pty host.
308
>
*/
309
>
export interface IPtyService {
310
>
readonly _serviceBrand: undefined;
311
>
312
>
readonly onProcessData: Event<{ id: number; event: IProcessDataEvent | string }>;
313
>
readonly onProcessReady: Event<{ id: number; event: IProcessReadyEvent }>;
314
>
readonly onProcessReplay: Event<{ id: number; event: IPtyHostProcessReplayEvent }>;
315
>
readonly onProcessOrphanQuestion: Event<{ id: number }>;
316
>
readonly onDidRequestDetach: Event<{ requestId: number; workspaceId: string; instanceId: number }>;
317
>
readonly onDidChangeProperty: Event<{ id: number; property: IProcessProperty }>;
318
>
readonly onProcessExit: Event<{ id: number; event: number | undefined }>;
319
>
320
>
createProcess(
321
>
shellLaunchConfig: IShellLaunchConfig,
322
>
cwd: string,
323
>
cols: number,
324
>
rows: number,
325
>
unicodeVersion: '6' | '11',
326
>
env: IProcessEnvironment,
327
>
executableEnv: IProcessEnvironment,
328
>
options: ITerminalProcessOptions,
329
>
shouldPersist: boolean,
330
>
workspaceId: string,
331
>
workspaceName: string
332
>
): Promise<number>;
333
>
attachToProcess(id: number): Promise<void>;
334
>
detachFromProcess(id: number, forcePersist?: boolean): Promise<void>;
335
>
shutdownAll(): Promise<void>;
336
>
337
>
/**
338
>
* Lists all orphaned processes, ie. those without a connected frontend.
339
>
*/
340
>
listProcesses(): Promise<IProcessDetails[]>;
341
>
getPerformanceMarks(): Promise<performance.PerformanceMark[]>;
342
>
/**
343
>
* Measures and returns the latency of the current and all other processes to the pty host.
344
>
*/
345
>
getLatency(): Promise<IPtyHostLatencyMeasurement[]>;
346
>
347
>
start(id: number): Promise<ITerminalLaunchError | ITerminalLaunchResult | undefined>;
348
>
shutdown(id: number, immediate: boolean): Promise<void>;
349
>
input(id: number, data: string): Promise<void>;
350
>
sendSignal(id: number, signal: string): Promise<void>;
351
>
resize(id: number, cols: number, rows: number, pixelWidth?: number, pixelHeight?: number): Promise<void>;
352
>
clearBuffer(id: number): Promise<void>;
353
>
getInitialCwd(id: number): Promise<string>;
354
>
getCwd(id: number): Promise<string>;
355
>
acknowledgeDataEvent(id: number, charCount: number): Promise<void>;
356
>
setNextCommandId(id: number, commandLine: string, commandId: string): Promise<void>;
357
>
setUnicodeVersion(id: number, version: '6' | '11'): Promise<void>;
358
>
processBinary(id: number, data: string): Promise<void>;
359
>
/** Confirm the process is _not_ an orphan. */
360
>
orphanQuestionReply(id: number): Promise<void>;
361
>
updateTitle(id: number, title: string, titleSource: TitleEventSource): Promise<void>;
362
>
updateIcon(id: number, userInitiated: boolean, icon: TerminalIcon, color?: string): Promise<void>;
363
>
364
>
getDefaultSystemShell(osOverride?: OperatingSystem): Promise<string>;
365
>
getEnvironment(): Promise<IProcessEnvironment>;
366
>
getWslPath(original: string, direction: 'unix-to-win' | 'win-to-unix'): Promise<string>;
367
>
getRevivedPtyNewId(workspaceId: string, id: number): Promise<number | undefined>;
368
>
setTerminalLayoutInfo(args: ISetTerminalLayoutInfoArgs): Promise<void>;
369
>
getTerminalLayoutInfo(args: IGetTerminalLayoutInfoArgs): Promise<ITerminalsLayoutInfo | undefined>;
370
>
reduceConnectionGraceTime(): Promise<void>;
371
>
requestDetachInstance(workspaceId: string, instanceId: number): Promise<IProcessDetails | undefined>;
372
>
acceptDetachInstanceReply(requestId: number, persistentProcessId?: number): Promise<void>;
373
>
freePortKillProcess(port: string): Promise<{ port: string; processId: string }>;
374
>
/**
375
>
* Serializes and returns terminal state.
376
>
* @param ids The persistent terminal IDs to serialize.
377
>
*/
378
>
serializeTerminalState(ids: number[]): Promise<string>;
379
>
/**
380
>
* Revives a workspaces terminal processes, these can then be reconnected to using the normal
381
>
* flow for restoring terminals after reloading.
382
>
*/
383
>
reviveTerminalProcesses(workspaceId: string, state: ISerializedTerminalState[], dateTimeFormatLocate: string): Promise<void>;
384
>
refreshProperty<T extends ProcessPropertyType>(id: number, property: T): Promise<IProcessPropertyMap[T]>;
385
>
updateProperty<T extends ProcessPropertyType>(id: number, property: T, value: IProcessPropertyMap[T]): Promise<void>;
386
>
387
>
// TODO: Make mandatory and remove impl from pty host service
388
>
refreshIgnoreProcessNames?(names: string[]): Promise<void>;
389
>
390
>
// #region Pty service contribution RPC calls
391
>
392
>
installAutoReply(match: string, reply: string): Promise<void>;
393
>
uninstallAllAutoReplies(): Promise<void>;
394
>
395
>
// #endregion
396
>
}
397
>
export const IPtyService = createDecorator<IPtyService>('ptyService');
398
>
399
>
export interface IPtyServiceContribution {
400
>
handleProcessReady(persistentProcessId: number, process: ITerminalChildProcess): void;
401
>
handleProcessDispose(persistentProcessId: number): void;
402
>
handleProcessInput(persistentProcessId: number, data: string): void;
403
>
handleProcessResize(persistentProcessId: number, cols: number, rows: number, pixelWidth?: number, pixelHeight?: number): void;
404
>
}
405
>
406
>
export interface IPtyHostController {
407
>
readonly onPtyHostExit: Event<number>;
408
>
readonly onPtyHostStart: Event<void>;
409
>
readonly onPtyHostUnresponsive: Event<void>;
410
>
readonly onPtyHostResponsive: Event<void>;
411
>
readonly onPtyHostRequestResolveVariables: Event<IRequestResolveVariablesEvent>;
412
>
413
>
restartPtyHost(): Promise<void>;
414
>
acceptPtyHostResolvedVariables(requestId: number, resolved: string[]): Promise<void>;
415
>
getProfiles(workspaceId: string, profiles: unknown, defaultProfile: unknown, includeDetectedProfiles?: boolean): Promise<ITerminalProfile[]>;
416
>
}
417
>
418
>
/**
419
>
* A service that communicates with a pty host controller (eg. main or server
420
>
* process) and is able to launch and forward requests to the pty host.
421
>
*/
422
>
export interface IPtyHostService extends IPtyService, IPtyHostController {
423
>
}
424
>
425
>
export interface IPtyHostLatencyMeasurement {
426
>
label: string;
427
>
latency: number;
428
>
}
429
>
430
>
/**
431
>
* Serialized terminal state matching the interface that can be used across versions, the version
432
>
* should be verified before using the state payload.
433
>
*/
434
>
export interface ICrossVersionSerializedTerminalState {
435
>
version: number;
436
>
state: unknown;
437
>
}
438
>
439
>
export interface ISerializedTerminalState {
440
>
id: number;
441
>
shellLaunchConfig: IShellLaunchConfig;
442
>
processDetails: IProcessDetails;
443
>
processLaunchConfig: IPersistentTerminalProcessLaunchConfig;
444
>
unicodeVersion: '6' | '11';
445
>
replayEvent: IPtyHostProcessReplayEvent;
446
>
timestamp: number;
447
>
}
448
>
449
>
export interface IPersistentTerminalProcessLaunchConfig {
450
>
env: IProcessEnvironment;
451
>
executableEnv: IProcessEnvironment;
452
>
options: ITerminalProcessOptions;
453
>
}
454
>
455
>
export interface IRequestResolveVariablesEvent {
456
>
requestId: number;
457
>
workspaceId: string;
458
>
originalText: string[];
459
>
}
460
>
461
>
export enum HeartbeatConstants {
462
>
/**
463
>
* The duration between heartbeats
464
>
*/
465
>
BeatInterval = 5000,
466
>
/**
467
>
* The duration of the first heartbeat while the pty host is starting up. This is much larger
468
>
* than the regular BeatInterval to accommodate slow machines, we still want to warn about the
469
>
* pty host's unresponsiveness eventually though.
470
>
*/
471
>
ConnectingBeatInterval = 20000,
472
>
/**
473
>
* Defines a multiplier for BeatInterval for how long to wait before starting the second wait
474
>
* timer.
475
>
*/
476
>
FirstWaitMultiplier = 1.2,
477
>
/**
478
>
* Defines a multiplier for BeatInterval for how long to wait before telling the user about
479
>
* non-responsiveness. The second timer is to avoid informing the user incorrectly when waking
480
>
* the computer up from sleep
481
>
*/
482
>
SecondWaitMultiplier = 1,
483
>
/**
484
>
* How long to wait before telling the user about non-responsiveness when they try to create a
485
>
* process. This short circuits the standard wait timeouts to tell the user sooner and only
486
>
* create process is handled to avoid additional perf overhead.
487
>
*/
488
>
CreateProcessTimeout = 5000
489
>
}
490
>
491
>
export interface IHeartbeatService {
492
>
readonly onBeat: Event<void>;
493
>
}
494
>
495
>
496
>
export interface IShellLaunchConfig {
497
>
/**
498
>
* The name of the terminal, if this is not set the name of the process will be used.
499
>
*/
500
>
name?: string;
501
>
502
>
/**
503
>
* A string to follow the name of the terminal with, indicating the type of terminal
504
>
*/
505
>
type?: 'Task' | 'Local';
506
>
507
>
/**
508
>
* The shell executable (bash, cmd, etc.).
509
>
*/
510
>
executable?: string;
511
>
512
>
/**
513
>
* The CLI arguments to use with executable, a string[] is in argv format and will be escaped,
514
>
* a string is in "CommandLine" pre-escaped format and will be used as is. The string option is
515
>
* only supported on Windows and will throw an exception if used on macOS or Linux.
516
>
*/
517
>
args?: string[] | string;
518
>
519
>
/**
520
>
* The current working directory of the terminal, this overrides the `terminal.integrated.cwd`
521
>
* settings key.
522
>
*/
523
>
cwd?: string | URI;
524
>
525
>
/**
526
>
* A custom environment for the terminal, if this is not set the environment will be inherited
527
>
* from the VS Code process.
528
>
*/
529
>
env?: ITerminalEnvironment;
530
>
531
>
/**
532
>
* Whether to ignore a custom cwd from the `terminal.integrated.cwd` settings key (e.g. if the
533
>
* shell is being launched by an extension).
534
>
*/
535
>
ignoreConfigurationCwd?: boolean;
536
>
537
>
/**
538
>
* The reconnection properties for this terminal
539
>
*/
540
>
reconnectionProperties?: IReconnectionProperties;
541
>
542
>
/** Whether to wait for a key press before closing the terminal. */
543
>
waitOnExit?: WaitOnExitValue;
544
>
545
>
/**
546
>
* A string including ANSI escape sequences that will be written to the terminal emulator
547
>
* _before_ the terminal process has launched, when a string is specified, a trailing \n is
548
>
* added at the end. This allows for example the terminal instance to display a styled message
549
>
* as the first line of the terminal. Use \x1b over \033 or \e for the escape control character.
550
>
*/
551
>
initialText?: string | { text: string; trailingNewLine: boolean };
552
>
553
>
/**
554
>
* Custom PTY/pseudoterminal process to use.
555
>
*/
556
>
customPtyImplementation?: (terminalId: number, cols: number, rows: number) => ITerminalChildProcess;
557
>
558
>
/**
559
>
* A UUID generated by the extension host process for terminals created on the extension host process.
560
>
*/
561
>
extHostTerminalId?: string;
562
>
563
>
/**
564
>
* This is a terminal that attaches to an already running terminal.
565
>
*/
566
>
attachPersistentProcess?: {
567
>
id: number;
568
>
findRevivedId?: boolean;
569
>
pid: number;
570
>
title: string;
571
>
titleSource: TitleEventSource;
572
>
cwd: string;
573
>
icon?: TerminalIcon;
574
>
color?: string;
575
>
hasChildProcesses?: boolean;
576
>
fixedDimensions?: IFixedTerminalDimensions;
577
>
environmentVariableCollections?: ISerializableEnvironmentVariableCollections;
578
>
reconnectionProperties?: IReconnectionProperties;
579
>
type?: TerminalType;
580
>
waitOnExit?: WaitOnExitValue;
581
>
hideFromUser?: boolean;
582
>
isFeatureTerminal?: boolean;
583
>
shellIntegrationNonce: string;
584
>
tabActions?: ITerminalTabAction[];
585
>
};
586
>
587
>
/**
588
>
* Whether the terminal process environment should be exactly as provided in
589
>
* `TerminalOptions.env`. When this is false (default), the environment will be based on the
590
>
* window's environment and also apply configured platform settings like
591
>
* `terminal.integrated.env.windows` on top. When this is true, the complete environment must be
592
>
* provided as nothing will be inherited from the process or any configuration.
593
>
*/
594
>
strictEnv?: boolean;
595
>
596
>
/**
597
>
* Whether the terminal process environment will inherit VS Code's "shell environment" that may
598
>
* get sourced from running a login shell depnding on how the application was launched.
599
>
* Consumers that rely on development tools being present in the $PATH should set this to true.
600
>
* This will overwrite the value of the inheritEnv setting.
601
>
*/
602
>
useShellEnvironment?: boolean;
603
>
604
>
/**
605
>
* When enabled the terminal will run the process as normal but not be surfaced to the user
606
>
* until `Terminal.show` is called. The typical usage for this is when you need to run
607
>
* something that may need interactivity but only want to tell the user about it when
608
>
* interaction is needed. Note that the terminals will still be exposed to all extensions
609
>
* as normal. The hidden terminals will not be restored when the workspace is next opened.
610
>
*/
611
>
hideFromUser?: boolean;
612
>
613
>
/**
614
>
* Whether to force the terminal to persist across sessions regardless of the other
615
>
* launch config, like `hideFromUser`.
616
>
*/
617
>
forcePersist?: boolean;
618
>
619
>
/**
620
>
* Whether this terminal is not a terminal that the user directly created and uses, but rather
621
>
* a terminal used to drive some VS Code feature.
622
>
*/
623
>
isFeatureTerminal?: boolean;
624
>
625
>
/**
626
>
* Whether this terminal was created by an extension.
627
>
*/
628
>
isExtensionOwnedTerminal?: boolean;
629
>
630
>
/**
631
>
* The icon for the terminal, used primarily in the terminal tab.
632
>
*/
633
>
icon?: TerminalIcon;
634
>
635
>
/**
636
>
* The color ID to use for this terminal. If not specified it will use the default fallback
637
>
*/
638
>
color?: string;
639
>
640
>
/**
641
>
* When a parent terminal is provided via API, the group needs
642
>
* to find the index in order to place the child
643
>
* directly to the right of its parent.
644
>
*/
645
>
parentTerminalId?: number;
646
>
647
>
/**
648
>
* The dimensions for the instance as set by the user
649
>
* or via Size to Content Width
650
>
*/
651
>
fixedDimensions?: IFixedTerminalDimensions;
652
>
653
>
/**
654
>
* Opt-out of the default terminal persistence on restart and reload
655
>
*/
656
>
isTransient?: boolean;
657
>
658
>
/**
659
>
* Attempt to force shell integration to be enabled by bypassing the {@link isFeatureTerminal}
660
>
* equals false requirement.
661
>
*/
662
>
forceShellIntegration?: boolean;
663
>
664
>
/**
665
>
* Create a terminal without shell integration even when it's enabled
666
>
*/
667
>
ignoreShellIntegration?: boolean;
668
>
669
>
/**
670
>
* Actions to include inline on hover of the terminal tab. E.g. the "Rerun task" action
671
>
*/
672
>
tabActions?: ITerminalTabAction[];
673
>
/**
674
>
* Report terminal's shell environment variables to VS Code and extensions
675
>
*/
676
>
shellIntegrationEnvironmentReporting?: boolean;
677
>
678
>
/**
679
>
* A custom nonce to use for shell integration when provided by an extension.
680
>
* This allows extensions to control shell integration for terminals they create.
681
>
*/
682
>
shellIntegrationNonce?: string;
683
>
684
>
/**
685
>
* A title template string that supports the same variables as the
686
>
* `terminal.integrated.tabs.title` setting. When set, this overrides the config-based
687
>
* title template for this terminal instance.
688
>
*/
689
>
titleTemplate?: string;
690
>
}
691
>
692
>
export interface ITerminalTabAction {
693
>
id: string;
694
>
label: string;
695
>
icon?: ThemeIcon;
696
>
}
697
>
698
>
export type WaitOnExitValue = boolean | string | ((exitCode: number) => string);
699
>
700
>
export interface ICreateContributedTerminalProfileOptions {
701
>
icon?: URI | string | { light: URI; dark: URI };
702
>
color?: string;
703
>
location?: TerminalLocation | { viewColumn: number; preserveState?: boolean } | { splitActiveTerminal: boolean };
704
>
cwd?: string | URI;
705
>
titleTemplate?: string;
706
>
}
707
>
708
>
export enum TerminalLocation {
709
>
Panel = 1,
710
>
Editor = 2
711
>
}
712
>
713
>
export const enum TerminalLocationConfigValue {
714
>
TerminalView = 'view',
715
>
Editor = 'editor'
716
>
}
717
>
718
>
export type TerminalIcon = ThemeIcon | URI | { light: URI; dark: URI };
719
>
720
>
export interface IShellLaunchConfigDto {
721
>
name?: string;
722
>
executable?: string;
723
>
args?: string[] | string;
724
>
cwd?: string | UriComponents;
725
>
env?: ITerminalEnvironment;
726
>
useShellEnvironment?: boolean;
727
>
hideFromUser?: boolean;
728
>
reconnectionProperties?: IReconnectionProperties;
729
>
type?: 'Task' | 'Local';
730
>
isFeatureTerminal?: boolean;
731
>
forceShellIntegration?: boolean;
732
>
tabActions?: ITerminalTabAction[];
733
>
shellIntegrationEnvironmentReporting?: boolean;
734
>
titleTemplate?: string;
735
>
}
736
>
737
>
/**
738
>
* A set of options for the terminal process. These differ from the shell launch config in that they
739
>
* are set internally to the terminal component, not from the outside.
740
>
*/
741
>
export interface ITerminalProcessOptions {
742
>
shellIntegration: {
743
>
enabled: boolean;
744
>
suggestEnabled: boolean;
745
>
nonce: string;
746
>
};
747
>
windowsUseConptyDll: boolean;
748
>
environmentVariableCollections: ISerializableEnvironmentVariableCollections | undefined;
749
>
workspaceFolder: IWorkspaceFolder | undefined;
750
>
isScreenReaderOptimized: boolean;
751
>
}
752
>
753
>
export interface ITerminalEnvironment {
754
>
[key: string]: string | null | undefined;
755
>
}
756
>
757
>
export interface ITerminalLaunchError {
758
>
message: string;
759
>
code?: number;
760
>
}
761
>
762
>
export interface IProcessReadyEvent {
763
>
pid: number;
764
>
cwd: string;
765
>
windowsPty: IProcessReadyWindowsPty | undefined;
766
>
}
767
>
768
>
export interface IProcessReadyWindowsPty {
769
>
/**
770
>
* What pty emulation backend is being used.
771
>
*/
772
>
backend: 'conpty';
773
>
/**
774
>
* The Windows build version (eg. 19045)
775
>
*/
776
>
buildNumber: number;
777
>
}
778
>
779
>
/**
780
>
* An interface representing a raw terminal child process, this contains a subset of the
781
>
* child_process.ChildProcess node.js interface.
782
>
*/
783
>
export interface ITerminalChildProcess {
784
>
/**
785
>
* A unique identifier for the terminal process. Note that the uniqueness only applies to a
786
>
* given pty service connection, IDs will be duplicated for remote and local terminals for
787
>
* example. The ID will be 0 if it does not support reconnection.
788
>
*/
789
>
id: number;
790
>
791
>
/**
792
>
* Whether the process should be persisted across reloads.
793
>
*/
794
>
shouldPersist: boolean;
795
>
796
>
readonly onProcessData: Event<IProcessDataEvent | string>;
797
>
readonly onProcessReady: Event<IProcessReadyEvent>;
798
>
readonly onProcessReplayComplete?: Event<void>;
799
>
readonly onDidChangeProperty: Event<IProcessProperty>;
800
>
readonly onProcessExit: Event<number | undefined>;
801
>
readonly onRestoreCommands?: Event<ISerializedCommandDetectionCapability>;
802
>
803
>
/**
804
>
* Starts the process.
805
>
*
806
>
* @returns undefined when the process was successfully started, otherwise an object containing
807
>
* information on what went wrong.
808
>
*/
809
>
start(): Promise<ITerminalLaunchError | ITerminalLaunchResult | undefined>;
810
>
811
>
/**
812
>
* Detach the process from the UI and await reconnect.
813
>
* @param forcePersist Whether to force the process to persist if it supports persistence.
814
>
*/
815
>
detach?(forcePersist?: boolean): Promise<void>;
816
>
817
>
/**
818
>
* Frees the port and kills the process
819
>
*/
820
>
freePortKillProcess?(port: string): Promise<{ port: string; processId: string }>;
821
>
822
>
/**
823
>
* Shutdown the terminal process.
824
>
*
825
>
* @param immediate When true the process will be killed immediately, otherwise the process will
826
>
* be given some time to make sure no additional data comes through.
827
>
*/
828
>
shutdown(immediate: boolean): void;
829
>
input(data: string): void;
830
>
sendSignal(signal: string): void;
831
>
processBinary(data: string): Promise<void>;
832
>
resize(cols: number, rows: number, pixelWidth?: number, pixelHeight?: number): void;
833
>
clearBuffer(): void | Promise<void>;
834
>
835
>
/**
836
>
* Acknowledge a data event has been parsed by the terminal, this is used to implement flow
837
>
* control to ensure remote processes to not get too far ahead of the client and flood the
838
>
* connection.
839
>
* @param charCount The number of characters being acknowledged.
840
>
*/
841
>
acknowledgeDataEvent(charCount: number): void;
842
>
843
>
/**
844
>
* Sets the unicode version for the process, this drives the size of some characters in the
845
>
* xterm-headless instance.
846
>
*/
847
>
setUnicodeVersion(version: '6' | '11'): Promise<void>;
848
>
849
>
getInitialCwd(): Promise<string>;
850
>
getCwd(): Promise<string>;
851
>
refreshProperty<T extends ProcessPropertyType>(property: T): Promise<IProcessPropertyMap[T]>;
852
>
updateProperty<T extends ProcessPropertyType>(property: T, value: IProcessPropertyMap[T]): Promise<void>;
853
>
}
854
>
855
>
export interface IReconnectConstants {
856
>
graceTime: number;
857
>
shortGraceTime: number;
858
>
scrollback: number;
859
>
}
860
>
861
>
export const enum LocalReconnectConstants {
862
>
/**
863
>
* If there is no reconnection within this time-frame, consider the connection permanently closed...
864
>
*/
865
>
GraceTime = 60000, // 60 seconds
866
>
/**
867
>
* Maximal grace time between the first and the last reconnection...
868
>
*/
869
>
ShortGraceTime = 6000, // 6 seconds
870
>
}
871
>
872
>
export const enum FlowControlConstants {
873
>
/**
874
>
* The number of _unacknowledged_ chars to have been sent before the pty is paused in order for
875
>
* the client to catch up.
876
>
*/
877
>
HighWatermarkChars = 100000,
878
>
/**
879
>
* After flow control pauses the pty for the client the catch up, this is the number of
880
>
* _unacknowledged_ chars to have been caught up to on the client before resuming the pty again.
881
>
* This is used to attempt to prevent pauses in the flowing data; ideally while the pty is
882
>
* paused the number of unacknowledged chars would always be greater than 0 or the client will
883
>
* appear to stutter. In reality this balance is hard to accomplish though so heavy commands
884
>
* will likely pause as latency grows, not flooding the connection is the important thing as
885
>
* it's shared with other core functionality.
886
>
*/
887
>
LowWatermarkChars = 5000,
888
>
/**
889
>
* The number characters that are accumulated on the client side before sending an ack event.
890
>
* This must be less than or equal to LowWatermarkChars or the terminal max never unpause.
891
>
*/
892
>
CharCountAckSize = 5000
893
>
}
894
>
895
>
export interface IProcessDataEvent {
896
>
data: string;
897
>
trackCommit: boolean;
898
>
/**
899
>
* When trackCommit is set, this will be set to a promise that resolves when the data is parsed.
900
>
*/
901
>
writePromise?: Promise<void>;
902
>
}
903
>
904
>
export interface ITerminalDimensions {
905
>
/**
906
>
* The columns of the terminal.
907
>
*/
908
>
cols: number;
909
>
910
>
/**
911
>
* The rows of the terminal.
912
>
*/
913
>
rows: number;
914
>
}
915
>
916
>
export interface ITerminalProfile {
917
>
profileName: string;
918
>
path: string;
919
>
isDefault: boolean;
920
>
/**
921
>
* Whether the terminal profile contains a potentially unsafe {@link path}. For example, the path
922
>
* `C:\Cygwin` is the default install for Cygwin on Windows, but it could be created by any
923
>
* user in a multi-user environment. As such, we don't want to blindly present it as a profile
924
>
* without a warning.
925
>
*/
926
>
isUnsafePath?: boolean;
927
>
/**
928
>
* An additional unsafe path that must exist, for example a script that appears in {@link args}.
929
>
*/
930
>
requiresUnsafePath?: string;
931
>
isAutoDetected?: boolean;
932
>
/**
933
>
* Whether the profile path was found on the `$PATH` environment variable, if so it will be
934
>
* cleaner to display this profile in the UI using only `basename(path)`.
935
>
*/
936
>
isFromPath?: boolean;
937
>
args?: SingleOrMany<string> | undefined;
938
>
env?: ITerminalEnvironment;
939
>
overrideName?: boolean;
940
>
color?: string;
941
>
icon?: ThemeIcon | URI | { light: URI; dark: URI };
942
>
}
943
>
944
>
export interface ITerminalDimensionsOverride extends Readonly<ITerminalDimensions> {
945
>
/**
946
>
* indicate that xterm must receive these exact dimensions, even if they overflow the ui!
947
>
*/
948
>
forceExactSize?: boolean;
949
>
}
950
>
951
>
export const enum ProfileSource {
952
>
GitBash = 'Git Bash',
953
>
Pwsh = 'PowerShell'
954
>
}
955
>
956
>
export interface IBaseUnresolvedTerminalProfile {
957
>
args?: SingleOrMany<string> | undefined;
958
>
isAutoDetected?: boolean;
959
>
overrideName?: boolean;
960
>
icon?: string | ThemeIcon | URI | { light: URI; dark: URI };
961
>
color?: string;
962
>
env?: ITerminalEnvironment;
963
>
requiresPath?: string | ITerminalUnsafePath;
964
>
}
965
>
966
>
export interface ITerminalUnsafePath {
967
>
path: string;
968
>
isUnsafe: true;
969
>
}
970
>
971
>
export interface ITerminalExecutable extends IBaseUnresolvedTerminalProfile {
972
>
path: SingleOrMany<string | ITerminalUnsafePath>;
973
>
}
974
>
975
>
export interface ITerminalProfileSource extends IBaseUnresolvedTerminalProfile {
976
>
source: ProfileSource;
977
>
}
978
>
979
>
export interface ITerminalProfileContribution {
980
>
title: string;
981
>
id: string;
982
>
icon?: URI | { light: URI; dark: URI } | string;
983
>
color?: string;
984
>
titleTemplate?: string;
985
>
}
986
>
987
>
export interface IExtensionTerminalProfile extends ITerminalProfileContribution {
988
>
extensionIdentifier: string;
989
>
}
990
>
991
>
export type ITerminalProfileObject = ITerminalExecutable | ITerminalProfileSource | IExtensionTerminalProfile | null;
992
>
993
>
export interface IShellIntegration {
994
>
readonly capabilities: ITerminalCapabilityStore;
995
>
readonly seenSequences: ReadonlySet<string>;
996
>
readonly status: ShellIntegrationStatus;
997
>
998
>
readonly onDidChangeStatus: Event<ShellIntegrationStatus>;
999
>
readonly onDidChangeSeenSequences: Event<ReadonlySet<string>>;
1000
>
1001
>
deserialize(serialized: ISerializedCommandDetectionCapability): void;
1002
>
1003
>
setNextCommandId(command: string, commandId: string): void;
1004
>
}
1005
>
1006
>
export interface IDecorationAddon {
1007
>
registerMenuItems(command: ITerminalCommand, items: IAction[]): IDisposable;
1008
>
}
1009
>
1010
>
export interface ITerminalCompletionProviderContribution {
1011
>
description?: string;
1012
>
}
1013
>
1014
>
export interface ITerminalContributions {
1015
>
profiles?: ITerminalProfileContribution[];
1016
>
completionProviders?: ITerminalCompletionProviderContribution[];
1017
>
}
1018
>
1019
>
export const enum ShellIntegrationStatus {
1020
>
/** No shell integration sequences have been encountered. */
1021
>
Off,
1022
>
/** Final term shell integration sequences have been encountered. */
1023
>
FinalTerm,
1024
>
/** VS Code shell integration sequences have been encountered. Supercedes FinalTerm. */
1025
>
VSCode
1026
>
}
1027
>
1028
>
1029
>
export const enum ShellIntegrationInjectionFailureReason {
1030
>
/**
1031
>
* The setting is disabled.
1032
>
*/
1033
>
InjectionSettingDisabled = 'injectionSettingDisabled',
1034
>
/**
1035
>
* There is no executable (so there's no way to determine how to inject).
1036
>
*/
1037
>
NoExecutable = 'noExecutable',
1038
>
/**
1039
>
* It's a feature terminal (tasks, debug), unless it's explicitly being forced.
1040
>
*/
1041
>
FeatureTerminal = 'featureTerminal',
1042
>
/**
1043
>
* The ignoreShellIntegration flag is passed (eg. relaunching without shell integration).
1044
>
*/
1045
>
IgnoreShellIntegrationFlag = 'ignoreShellIntegrationFlag',
1046
>
/**
1047
>
* Shell integration doesn't work on older Windows builds that don't support ConPTY.
1048
>
*/
1049
>
UnsupportedWindowsBuild = 'unsupportedWindowsBuild',
1050
>
/**
1051
>
* We're conservative whether we inject when we don't recognize the arguments used for the
1052
>
* shell as we would prefer launching one without shell integration than breaking their profile.
1053
>
*/
1054
>
UnsupportedArgs = 'unsupportedArgs',
1055
>
/**
1056
>
* The shell doesn't have built-in shell integration. Note that this doesn't mean the shell
1057
>
* won't have shell integration in the end.
1058
>
*/
1059
>
UnsupportedShell = 'unsupportedShell',
1060
>
1061
>
1062
>
/**
1063
>
* For zsh, we failed to set the sticky bit on the shell integration script folder.
1064
>
*/
1065
>
FailedToSetStickyBit = 'failedToSetStickyBit',
1066
>
1067
>
/**
1068
>
* For zsh, we failed to create a temp directory for the shell integration script.
1069
>
*/
1070
>
FailedToCreateTmpDir = 'failedToCreateTmpDir',
1071
>
}
1072
>
1073
>
export const enum ShellIntegrationTimeoutOverride {
1074
>
DisableForTests = -2
1075
>
}
1076
>
1077
>
export enum TerminalExitReason {
1078
>
Unknown = 0,
1079
>
Shutdown = 1,
1080
>
Process = 2,
1081
>
User = 3,
1082
>
Extension = 4,
1083
>
}
1084
>
1085
>
export interface ITerminalOutputMatch {
1086
>
regexMatch: RegExpMatchArray;
1087
>
outputLines: string[];
1088
>
}
1089
>
1090
>
/**
1091
>
* A matcher that runs on a sub-section of a terminal command's output
1092
>
*/
1093
>
export interface ITerminalOutputMatcher {
1094
>
/**
1095
>
* A string or regex to match against the unwrapped line. If this is a regex with the multiline
1096
>
* flag, it will scan an amount of lines equal to `\n` instances in the regex + 1.
1097
>
*/
1098
>
lineMatcher: string | RegExp;
1099
>
/**
1100
>
* Which side of the output to anchor the {@link offset} and {@link length} against.
1101
>
*/
1102
>
anchor: 'top' | 'bottom';
1103
>
/**
1104
>
* The number of rows above or below the {@link anchor} to start matching against.
1105
>
*/
1106
>
offset: number;
1107
>
/**
1108
>
* The number of rows to match against, this should be as small as possible for performance
1109
>
* reasons. This is capped at 40.
1110
>
*/
1111
>
length: number;
1112
>
1113
>
/**
1114
>
* If multiple matches are expected - this will result in {@link outputLines} being returned
1115
>
* when there's a {@link regexMatch} from {@link offset} to {@link length}
1116
>
*/
1117
>
multipleMatches?: boolean;
1118
>
}
1119
>
1120
>
export interface ITerminalCommandSelector {
1121
>
id: string;
1122
>
commandLineMatcher: string | RegExp;
1123
>
outputMatcher?: ITerminalOutputMatcher;
1124
>
exitStatus: boolean;
1125
>
commandExitResult: 'success' | 'error';
1126
>
kind?: 'fix' | 'explain';
1127
>
}
1128
>
1129
>
export interface ITerminalBackend extends ITerminalBackendPtyServiceContributions {
1130
>
readonly remoteAuthority: string | undefined;
1131
>
1132
>
readonly isResponsive: boolean;
1133
>
1134
>
/**
1135
>
* A promise that resolves when the backend is ready to be used, ie. after terminal persistence
1136
>
* has been actioned.
1137
>
*/
1138
>
readonly whenReady: Promise<void>;
1139
>
1140
>
/**
1141
>
* Signal to the backend that persistence has been actioned and is ready for use.
1142
>
*/
1143
>
setReady(): void;
1144
>
1145
>
/**
1146
>
* Fired when the ptyHost process becomes non-responsive, this should disable stdin for all
1147
>
* terminals using this pty host connection and mark them as disconnected.
1148
>
*/
1149
>
readonly onPtyHostUnresponsive: Event<void>;
1150
>
/**
1151
>
* Fired when the ptyHost process becomes responsive after being non-responsive. Allowing
1152
>
* previously disconnected terminals to reconnect.
1153
>
*/
1154
>
readonly onPtyHostResponsive: Event<void>;
1155
>
/**
1156
>
* Fired when the ptyHost has been restarted, this is used as a signal for listening terminals
1157
>
* that its pty has been lost and will remain disconnected.
1158
>
*/
1159
>
readonly onPtyHostRestart: Event<void>;
1160
>
1161
>
readonly onDidRequestDetach: Event<{ requestId: number; workspaceId: string; instanceId: number }>;
1162
>
1163
>
attachToProcess(id: number): Promise<ITerminalChildProcess | undefined>;
1164
>
attachToRevivedProcess(id: number): Promise<ITerminalChildProcess | undefined>;
1165
>
listProcesses(): Promise<IProcessDetails[]>;
1166
>
getLatency(): Promise<IPtyHostLatencyMeasurement[]>;
1167
>
getDefaultSystemShell(osOverride?: OperatingSystem): Promise<string>;
1168
>
getProfiles(profiles: unknown, defaultProfile: unknown, includeDetectedProfiles?: boolean): Promise<ITerminalProfile[]>;
1169
>
getWslPath(original: string, direction: 'unix-to-win' | 'win-to-unix'): Promise<string>;
1170
>
getEnvironment(): Promise<IProcessEnvironment>;
1171
>
getShellEnvironment(): Promise<IProcessEnvironment | undefined>;
1172
>
setTerminalLayoutInfo(layoutInfo?: ITerminalsLayoutInfoById): Promise<void>;
1173
>
updateTitle(id: number, title: string, titleSource: TitleEventSource): Promise<void>;
1174
>
updateIcon(id: number, userInitiated: boolean, icon: TerminalIcon, color?: string): Promise<void>;
1175
>
setNextCommandId(id: number, commandLine: string, commandId: string): Promise<void>;
1176
>
getTerminalLayoutInfo(): Promise<ITerminalsLayoutInfo | undefined>;
1177
>
getPerformanceMarks(): Promise<performance.PerformanceMark[]>;
1178
>
reduceConnectionGraceTime(): Promise<void>;
1179
>
requestDetachInstance(workspaceId: string, instanceId: number): Promise<IProcessDetails | undefined>;
1180
>
acceptDetachInstanceReply(requestId: number, persistentProcessId?: number): Promise<void>;
1181
>
persistTerminalState(): Promise<void>;
1182
>
1183
>
createProcess(
1184
>
shellLaunchConfig: IShellLaunchConfig,
1185
>
cwd: string,
1186
>
cols: number,
1187
>
rows: number,
1188
>
unicodeVersion: '6' | '11',
1189
>
env: IProcessEnvironment,
1190
>
options: ITerminalProcessOptions,
1191
>
shouldPersist: boolean
1192
>
): Promise<ITerminalChildProcess>;
1193
>
1194
>
restartPtyHost(): void;
1195
>
}
1196
>
1197
>
export interface ITerminalBackendPtyServiceContributions {
1198
>
installAutoReply(match: string, reply: string): Promise<void>;
1199
>
uninstallAllAutoReplies(): Promise<void>;
1200
>
}
1201
>
1202
>
export const TerminalExtensions = {
1203
>
Backend: 'workbench.contributions.terminal.processBackend'
1204
>
};
1205
>
1206
>
export interface ITerminalBackendRegistry {
1207
>
/**
1208
>
* Gets all backends in the registry.
1209
>
*/
1210
>
backends: ReadonlyMap<string, ITerminalBackend>;
1211
>
1212
>
/**
1213
>
* Registers a terminal backend for a remote authority.
1214
>
*/
1215
>
registerTerminalBackend(backend: ITerminalBackend): void;
1216
>
1217
>
/**
1218
>
* Returns the registered terminal backend for a remote authority.
1219
>
*/
1220
>
getTerminalBackend(remoteAuthority?: string): ITerminalBackend | undefined;
1221
>
}
1222
>
1223
>
class TerminalBackendRegistry implements ITerminalBackendRegistry {
1224
>
private readonly _backends = new Map<string, ITerminalBackend>();
1225
>
1226
>
get backends(): ReadonlyMap<string, ITerminalBackend> { return this._backends; }
1227
>
1228
>
registerTerminalBackend(backend: ITerminalBackend): void {
1229
const key = this._sanitizeRemoteAuthority(backend.remoteAuthority);
1230
if (this._backends.has(key)) {