@theia/plugin 1.50.1 → 1.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theia/plugin",
3
- "version": "1.50.1",
3
+ "version": "1.52.0",
4
4
  "description": "Theia - Plugin API",
5
5
  "types": "./src/theia.d.ts",
6
6
  "publishConfig": {
@@ -27,10 +27,10 @@
27
27
  "watch": "theiaext watch"
28
28
  },
29
29
  "devDependencies": {
30
- "@theia/ext-scripts": "1.50.1"
30
+ "@theia/ext-scripts": "1.52.0"
31
31
  },
32
32
  "nyc": {
33
33
  "extends": "../../configs/nyc.json"
34
34
  },
35
- "gitHead": "ffefc7ac2c0f6c63256042b7710551304200e5e1"
35
+ "gitHead": "40ceebcd4ee75f13ec16b9dc7314e9384493c1ac"
36
36
  }
@@ -291,6 +291,13 @@ export module '@theia/plugin' {
291
291
  * see - workspace.fs for how to read and write files and folders from an uri.
292
292
  */
293
293
  readonly logUri: Uri;
294
+
295
+ /**
296
+ * An object that keeps information about how this extension can use language models.
297
+ *
298
+ * @see {@link LanguageModelChat.sendRequest}
299
+ */
300
+ readonly languageModelAccessInformation: LanguageModelAccessInformation;
294
301
  }
295
302
 
296
303
  export namespace commands {
package/src/theia.d.ts CHANGED
@@ -24,18 +24,20 @@
24
24
  import './theia-extra';
25
25
  import './theia.proposed.canonicalUriProvider';
26
26
  import './theia.proposed.customEditorMove';
27
+ import './theia.proposed.debugVisualization';
27
28
  import './theia.proposed.diffCommand';
28
29
  import './theia.proposed.documentPaste';
29
30
  import './theia.proposed.editSessionIdentityProvider';
30
31
  import './theia.proposed.extensionsAny';
31
32
  import './theia.proposed.externalUriOpener';
33
+ import './theia.proposed.findTextInFiles';
34
+ import './theia.proposed.fsChunks';
32
35
  import './theia.proposed.mappedEditsProvider';
36
+ import './theia.proposed.multiDocumentHighlightProvider';
33
37
  import './theia.proposed.notebookCellExecutionState';
34
38
  import './theia.proposed.notebookKernelSource';
35
39
  import './theia.proposed.notebookMessaging';
36
- import './theia.proposed.findTextInFiles';
37
- import './theia.proposed.fsChunks';
38
- import './theia.proposed.multiDocumentHighlightProvider';
40
+ import './theia.proposed.portsAttributes';
39
41
  import './theia.proposed.profileContentHandlers';
40
42
  import './theia.proposed.resolvers';
41
43
  import './theia.proposed.scmValidation';
@@ -3172,7 +3174,7 @@ export module '@theia/plugin' {
3172
3174
  /**
3173
3175
  * The icon path or {@link ThemeIcon} for the terminal.
3174
3176
  */
3175
- iconPath?: ThemeIcon;
3177
+ iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
3176
3178
 
3177
3179
  /**
3178
3180
  * The icon {@link ThemeColor} for the terminal.
@@ -3293,7 +3295,7 @@ export module '@theia/plugin' {
3293
3295
  /**
3294
3296
  * The icon path or {@link ThemeIcon} for the terminal.
3295
3297
  */
3296
- iconPath?: ThemeIcon;
3298
+ iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
3297
3299
 
3298
3300
  /**
3299
3301
  * The icon {@link ThemeColor} for the terminal.
@@ -4028,6 +4030,14 @@ export module '@theia/plugin' {
4028
4030
  * The current `Extension` instance.
4029
4031
  */
4030
4032
  readonly extension: Extension<any>;
4033
+
4034
+ /**
4035
+ * An object that keeps information about how this extension can use language models.
4036
+ *
4037
+ * @see {@link LanguageModelChat.sendRequest}
4038
+ * @stubbed
4039
+ */
4040
+ readonly languageModelAccessInformation: LanguageModelAccessInformation;
4031
4041
  }
4032
4042
 
4033
4043
  /**
@@ -7734,6 +7744,9 @@ export module '@theia/plugin' {
7734
7744
 
7735
7745
  /**
7736
7746
  * The application root folder from which the editor is running.
7747
+ *
7748
+ * *Note* that the value is the empty string when running in an
7749
+ * environment that has no representation of an application root folder.
7737
7750
  */
7738
7751
  export const appRoot: string;
7739
7752
 
@@ -12074,6 +12087,12 @@ export module '@theia/plugin' {
12074
12087
  * When true, the debug viewlet will not be automatically revealed for this session.
12075
12088
  */
12076
12089
  suppressDebugView?: boolean;
12090
+ /**
12091
+ * Signals to the editor that the debug session was started from a test run
12092
+ * request. This is used to link the lifecycle of the debug session and
12093
+ * test run in UI actions.
12094
+ */
12095
+ testRun?: TestRun;
12077
12096
  }
12078
12097
 
12079
12098
  /**
@@ -12437,6 +12456,50 @@ export module '@theia/plugin' {
12437
12456
  Dynamic = 2
12438
12457
  }
12439
12458
 
12459
+ /**
12460
+ * Represents a thread in a debug session.
12461
+ */
12462
+ export class DebugThread {
12463
+ /**
12464
+ * Debug session for thread.
12465
+ */
12466
+ readonly session: DebugSession;
12467
+
12468
+ /**
12469
+ * ID of the associated thread in the debug protocol.
12470
+ */
12471
+ readonly threadId: number;
12472
+
12473
+ /**
12474
+ * @hidden
12475
+ */
12476
+ private constructor(session: DebugSession, threadId: number);
12477
+ }
12478
+
12479
+ /**
12480
+ * Represents a stack frame in a debug session.
12481
+ */
12482
+ export class DebugStackFrame {
12483
+ /**
12484
+ * Debug session for thread.
12485
+ */
12486
+ readonly session: DebugSession;
12487
+
12488
+ /**
12489
+ * ID of the associated thread in the debug protocol.
12490
+ */
12491
+ readonly threadId: number;
12492
+ /**
12493
+ * ID of the stack frame in the debug protocol.
12494
+ */
12495
+ readonly frameId: number;
12496
+
12497
+ /**
12498
+ * @hidden
12499
+ */
12500
+ private constructor(session: DebugSession, threadId: number, frameId: number);
12501
+ }
12502
+
12440
12503
  /**
12441
12504
  * Namespace for debug functionality.
12442
12505
  */
@@ -12486,6 +12549,19 @@ export module '@theia/plugin' {
12486
12549
  */
12487
12550
  export const onDidChangeBreakpoints: Event<BreakpointsChangeEvent>;
12488
12551
 
12552
+ /**
12553
+ * The currently focused thread or stack frame, or `undefined` if no
12554
+ * thread or stack is focused. A thread can be focused any time there is
12555
+ * an active debug session, while a stack frame can only be focused when
12556
+ * a session is paused and the call stack has been retrieved.
12557
+ */
12558
+ export const activeStackItem: DebugThread | DebugStackFrame | undefined;
12559
+
12560
+ /**
12561
+ * An event which fires when the {@link debug.activeStackItem} has changed.
12562
+ */
12563
+ export const onDidChangeActiveStackItem: Event<DebugThread | DebugStackFrame | undefined>;
12564
+
12489
12565
  /**
12490
12566
  * Register a {@link DebugAdapterDescriptorFactory debug adapter descriptor factory} for a specific debug type.
12491
12567
  * An extension is only allowed to register a DebugAdapterDescriptorFactory for the debug type(s) defined by the extension. Otherwise an error is thrown.
@@ -16242,13 +16318,22 @@ export module '@theia/plugin' {
16242
16318
  */
16243
16319
  readonly continuous?: boolean;
16244
16320
 
16321
+ /**
16322
+ * Controls how test Test Results view is focused. If true, the editor
16323
+ * will keep the maintain the user's focus. If false, the editor will
16324
+ * prefer to move focus into the Test Results view, although
16325
+ * this may be configured by users.
16326
+ */
16327
+ readonly preserveFocus: boolean;
16328
+
16245
16329
  /**
16246
16330
  * @param include Array of specific tests to run, or undefined to run all tests
16247
16331
  * @param exclude An array of tests to exclude from the run.
16248
16332
  * @param profile The run profile used for this request.
16249
16333
  * @param continuous Whether to run tests continuously as source changes.
16334
+ * @param preserveFocus Whether to preserve the user's focus when the run is started
16250
16335
  */
16251
- constructor(include?: readonly TestItem[], exclude?: readonly TestItem[], profile?: TestRunProfile, continuous?: boolean);
16336
+ constructor(include?: readonly TestItem[], exclude?: readonly TestItem[], profile?: TestRunProfile, continuous?: boolean, preserveFocus?: boolean);
16252
16337
  }
16253
16338
 
16254
16339
  /**
@@ -16729,6 +16814,857 @@ export module '@theia/plugin' {
16729
16814
  */
16730
16815
  export type FileCoverageDetail = StatementCoverage | DeclarationCoverage;
16731
16816
 
16817
+ /**
16818
+ * Represents a user request in chat history.
16819
+ */
16820
+ export class ChatRequestTurn {
16821
+ /**
16822
+ * The prompt as entered by the user.
16823
+ *
16824
+ * Information about references used in this request is stored in {@link ChatRequestTurn.references}.
16825
+ *
16826
+ * *Note* that the {@link ChatParticipant.name name} of the participant and the {@link ChatCommand.name command}
16827
+ * are not part of the prompt.
16828
+ */
16829
+ readonly prompt: string;
16830
+
16831
+ /**
16832
+ * The id of the chat participant to which this request was directed.
16833
+ */
16834
+ readonly participant: string;
16835
+
16836
+ /**
16837
+ * The name of the {@link ChatCommand command} that was selected for this request.
16838
+ */
16839
+ readonly command?: string;
16840
+
16841
+ /**
16842
+ * The references that were used in this message.
16843
+ */
16844
+ readonly references: ChatPromptReference[];
16845
+
16846
+ /**
16847
+ * @hidden
16848
+ */
16849
+ private constructor(prompt: string, command: string | undefined, references: ChatPromptReference[], participant: string);
16850
+ }
16851
+
16852
+ /**
16853
+ * Represents a chat participant's response in chat history.
16854
+ */
16855
+ export class ChatResponseTurn {
16856
+ /**
16857
+ * The content that was received from the chat participant. Only the stream parts that represent actual content (not metadata) are represented.
16858
+ */
16859
+ readonly response: ReadonlyArray<ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart>;
16860
+
16861
+ /**
16862
+ * The result that was received from the chat participant.
16863
+ */
16864
+ readonly result: ChatResult;
16865
+
16866
+ /**
16867
+ * The id of the chat participant that this response came from.
16868
+ */
16869
+ readonly participant: string;
16870
+
16871
+ /**
16872
+ * The name of the command that this response came from.
16873
+ */
16874
+ readonly command?: string;
16875
+
16876
+ /**
16877
+ * @hidden
16878
+ */
16879
+ private constructor(response: ReadonlyArray<ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart>, result: ChatResult, participant: string);
16880
+ }
16881
+
16882
+ /**
16883
+ * Extra context passed to a participant.
16884
+ */
16885
+ export interface ChatContext {
16886
+ /**
16887
+ * All of the chat messages so far in the current chat session. Currently, only chat messages for the current participant are included.
16888
+ */
16889
+ readonly history: ReadonlyArray<ChatRequestTurn | ChatResponseTurn>;
16890
+ }
16891
+
16892
+ /**
16893
+ * Represents an error result from a chat request.
16894
+ */
16895
+ export interface ChatErrorDetails {
16896
+ /**
16897
+ * An error message that is shown to the user.
16898
+ */
16899
+ message: string;
16900
+
16901
+ /**
16902
+ * If set to true, the response will be partly blurred out.
16903
+ */
16904
+ responseIsFiltered?: boolean;
16905
+ }
16906
+
16907
+ /**
16908
+ * The result of a chat request.
16909
+ */
16910
+ export interface ChatResult {
16911
+ /**
16912
+ * If the request resulted in an error, this property defines the error details.
16913
+ */
16914
+ errorDetails?: ChatErrorDetails;
16915
+
16916
+ /**
16917
+ * Arbitrary metadata for this result. Can be anything, but must be JSON-stringifyable.
16918
+ */
16919
+ readonly metadata?: { readonly [key: string]: any };
16920
+ }
16921
+
16922
+ /**
16923
+ * Represents the type of user feedback received.
16924
+ */
16925
+ export enum ChatResultFeedbackKind {
16926
+ /**
16927
+ * The user marked the result as unhelpful.
16928
+ */
16929
+ Unhelpful = 0,
16930
+
16931
+ /**
16932
+ * The user marked the result as helpful.
16933
+ */
16934
+ Helpful = 1,
16935
+ }
16936
+
16937
+ /**
16938
+ * Represents user feedback for a result.
16939
+ */
16940
+ export interface ChatResultFeedback {
16941
+ /**
16942
+ * The ChatResult for which the user is providing feedback.
16943
+ * This object has the same properties as the result returned from the participant callback, including `metadata`, but is not the same instance.
16944
+ */
16945
+ readonly result: ChatResult;
16946
+
16947
+ /**
16948
+ * The kind of feedback that was received.
16949
+ */
16950
+ readonly kind: ChatResultFeedbackKind;
16951
+ }
16952
+
16953
+ /**
16954
+ * A followup question suggested by the participant.
16955
+ */
16956
+ export interface ChatFollowup {
16957
+ /**
16958
+ * The message to send to the chat.
16959
+ */
16960
+ prompt: string;
16961
+
16962
+ /**
16963
+ * A title to show the user. The prompt will be shown by default, when this is unspecified.
16964
+ */
16965
+ label?: string;
16966
+
16967
+ /**
16968
+ * By default, the followup goes to the same participant/command. But this property can be set to invoke a different participant by ID.
16969
+ * Followups can only invoke a participant that was contributed by the same extension.
16970
+ */
16971
+ participant?: string;
16972
+
16973
+ /**
16974
+ * By default, the followup goes to the same participant/command. But this property can be set to invoke a different command.
16975
+ */
16976
+ command?: string;
16977
+ }
16978
+
16979
+ /**
16980
+ * Will be invoked once after each request to get suggested followup questions to show the user. The user can click the followup to send it to the chat.
16981
+ */
16982
+ export interface ChatFollowupProvider {
16983
+ /**
16984
+ * Provide followups for the given result.
16985
+ * @param result This object has the same properties as the result returned from the participant callback, including `metadata`, but is not the same instance.
16986
+ * @param token A cancellation token.
16987
+ */
16988
+ provideFollowups(result: ChatResult, context: ChatContext, token: CancellationToken): ProviderResult<ChatFollowup[]>;
16989
+ }
16990
+
16991
+ /**
16992
+ * A chat request handler is a callback that will be invoked when a request is made to a chat participant.
16993
+ */
16994
+ export type ChatRequestHandler = (request: ChatRequest, context: ChatContext, response: ChatResponseStream, token: CancellationToken) => ProviderResult<ChatResult | void>;
16995
+
16996
+ /**
16997
+ * A chat participant can be invoked by the user in a chat session, using the `@` prefix. When it is invoked, it handles the chat request and is solely
16998
+ * responsible for providing a response to the user. A ChatParticipant is created using {@link chat.createChatParticipant}.
16999
+ */
17000
+ export interface ChatParticipant {
17001
+ /**
17002
+ * A unique ID for this participant.
17003
+ */
17004
+ readonly id: string;
17005
+
17006
+ /**
17007
+ * An icon for the participant shown in UI.
17008
+ */
17009
+ iconPath?: Uri | {
17010
+ /**
17011
+ * The icon path for the light theme.
17012
+ */
17013
+ light: Uri;
17014
+ /**
17015
+ * The icon path for the dark theme.
17016
+ */
17017
+ dark: Uri;
17018
+ } | ThemeIcon;
17019
+
17020
+ /**
17021
+ * The handler for requests to this participant.
17022
+ */
17023
+ requestHandler: ChatRequestHandler;
17024
+
17025
+ /**
17026
+ * This provider will be called once after each request to retrieve suggested followup questions.
17027
+ */
17028
+ followupProvider?: ChatFollowupProvider;
17029
+
17030
+ /**
17031
+ * An event that fires whenever feedback for a result is received, e.g. when a user up- or down-votes
17032
+ * a result.
17033
+ *
17034
+ * The passed {@link ChatResultFeedback.result result} is guaranteed to be the same instance that was
17035
+ * previously returned from this chat participant.
17036
+ */
17037
+ onDidReceiveFeedback: Event<ChatResultFeedback>;
17038
+
17039
+ /**
17040
+ * Dispose this participant and free resources.
17041
+ */
17042
+ dispose(): void;
17043
+ }
17044
+
17045
+ /**
17046
+ * A reference to a value that the user added to their chat request.
17047
+ */
17048
+ export interface ChatPromptReference {
17049
+ /**
17050
+ * A unique identifier for this kind of reference.
17051
+ */
17052
+ readonly id: string;
17053
+
17054
+ /**
17055
+ * The start and end index of the reference in the {@link ChatRequest.prompt prompt}. When undefined, the reference was not part of the prompt text.
17056
+ *
17057
+ * *Note* that the indices take the leading `#`-character into account which means they can
17058
+ * used to modify the prompt as-is.
17059
+ */
17060
+ readonly range?: [start: number, end: number];
17061
+
17062
+ /**
17063
+ * A description of this value that could be used in an LLM prompt.
17064
+ */
17065
+ readonly modelDescription?: string;
17066
+
17067
+ /**
17068
+ * The value of this reference. The `string | Uri | Location` types are used today, but this could expand in the future.
17069
+ */
17070
+ readonly value: string | Uri | Location | unknown;
17071
+ }
17072
+
17073
+ /**
17074
+ * A request to a chat participant.
17075
+ */
17076
+ export interface ChatRequest {
17077
+ /**
17078
+ * The prompt as entered by the user.
17079
+ *
17080
+ * Information about references used in this request is stored in {@link ChatRequest.references}.
17081
+ *
17082
+ * *Note* that the {@link ChatParticipant.name name} of the participant and the {@link ChatCommand.name command}
17083
+ * are not part of the prompt.
17084
+ */
17085
+ readonly prompt: string;
17086
+
17087
+ /**
17088
+ * The name of the {@link ChatCommand command} that was selected for this request.
17089
+ */
17090
+ readonly command: string | undefined;
17091
+
17092
+ /**
17093
+ * The list of references and their values that are referenced in the prompt.
17094
+ *
17095
+ * *Note* that the prompt contains references as authored and that it is up to the participant
17096
+ * to further modify the prompt, for instance by inlining reference values or creating links to
17097
+ * headings which contain the resolved values. References are sorted in reverse by their range
17098
+ * in the prompt. That means the last reference in the prompt is the first in this list. This simplifies
17099
+ * string-manipulation of the prompt.
17100
+ */
17101
+ readonly references: readonly ChatPromptReference[];
17102
+ }
17103
+
17104
+ /**
17105
+ * The ChatResponseStream is how a participant is able to return content to the chat view. It provides several methods for streaming different types of content
17106
+ * which will be rendered in an appropriate way in the chat view. A participant can use the helper method for the type of content it wants to return, or it
17107
+ * can instantiate a {@link ChatResponsePart} and use the generic {@link ChatResponseStream.push} method to return it.
17108
+ */
17109
+ export interface ChatResponseStream {
17110
+ /**
17111
+ * Push a markdown part to this stream. Short-hand for
17112
+ * `push(new ChatResponseMarkdownPart(value))`.
17113
+ *
17114
+ * @see {@link ChatResponseStream.push}
17115
+ * @param value A markdown string or a string that should be interpreted as markdown. The boolean form of {@link MarkdownString.isTrusted} is NOT supported.
17116
+ */
17117
+ markdown(value: string | MarkdownString): void;
17118
+
17119
+ /**
17120
+ * Push an anchor part to this stream. Short-hand for
17121
+ * `push(new ChatResponseAnchorPart(value, title))`.
17122
+ * An anchor is an inline reference to some type of resource.
17123
+ *
17124
+ * @param value A uri, location, or symbol information.
17125
+ * @param title An optional title that is rendered with value.
17126
+ */
17127
+ anchor(value: Uri | Location, title?: string): void;
17128
+
17129
+ /**
17130
+ * Push a command button part to this stream. Short-hand for
17131
+ * `push(new ChatResponseCommandButtonPart(value, title))`.
17132
+ *
17133
+ * @param command A Command that will be executed when the button is clicked.
17134
+ */
17135
+ button(command: Command): void;
17136
+
17137
+ /**
17138
+ * Push a filetree part to this stream. Short-hand for
17139
+ * `push(new ChatResponseFileTreePart(value))`.
17140
+ *
17141
+ * @param value File tree data.
17142
+ * @param baseUri The base uri to which this file tree is relative.
17143
+ */
17144
+ filetree(value: ChatResponseFileTree[], baseUri: Uri): void;
17145
+
17146
+ /**
17147
+ * Push a progress part to this stream. Short-hand for
17148
+ * `push(new ChatResponseProgressPart(value))`.
17149
+ *
17150
+ * @param value A progress message
17151
+ */
17152
+ progress(value: string): void;
17153
+
17154
+ /**
17155
+ * Push a reference to this stream. Short-hand for
17156
+ * `push(new ChatResponseReferencePart(value))`.
17157
+ *
17158
+ * *Note* that the reference is not rendered inline with the response.
17159
+ *
17160
+ * @param value A uri or location
17161
+ * @param iconPath Icon for the reference shown in UI
17162
+ */
17163
+ reference(value: Uri | Location, iconPath?: Uri | ThemeIcon | {
17164
+ /**
17165
+ * The icon path for the light theme.
17166
+ */
17167
+ light: Uri;
17168
+ /**
17169
+ * The icon path for the dark theme.
17170
+ */
17171
+ dark: Uri;
17172
+ }): void;
17173
+
17174
+ /**
17175
+ * Pushes a part to this stream.
17176
+ *
17177
+ * @param part A response part, rendered or metadata
17178
+ */
17179
+ push(part: ChatResponsePart): void;
17180
+ }
17181
+
17182
+ /**
17183
+ * Represents a part of a chat response that is formatted as Markdown.
17184
+ */
17185
+ export class ChatResponseMarkdownPart {
17186
+ /**
17187
+ * A markdown string or a string that should be interpreted as markdown.
17188
+ */
17189
+ value: MarkdownString;
17190
+
17191
+ /**
17192
+ * Create a new ChatResponseMarkdownPart.
17193
+ *
17194
+ * @param value A markdown string or a string that should be interpreted as markdown. The boolean form of {@link MarkdownString.isTrusted} is NOT supported.
17195
+ */
17196
+ constructor(value: string | MarkdownString);
17197
+ }
17198
+
17199
+ /**
17200
+ * Represents a file tree structure in a chat response.
17201
+ */
17202
+ export interface ChatResponseFileTree {
17203
+ /**
17204
+ * The name of the file or directory.
17205
+ */
17206
+ name: string;
17207
+
17208
+ /**
17209
+ * An array of child file trees, if the current file tree is a directory.
17210
+ */
17211
+ children?: ChatResponseFileTree[];
17212
+ }
17213
+
17214
+ /**
17215
+ * Represents a part of a chat response that is a file tree.
17216
+ */
17217
+ export class ChatResponseFileTreePart {
17218
+ /**
17219
+ * File tree data.
17220
+ */
17221
+ value: ChatResponseFileTree[];
17222
+
17223
+ /**
17224
+ * The base uri to which this file tree is relative
17225
+ */
17226
+ baseUri: Uri;
17227
+
17228
+ /**
17229
+ * Create a new ChatResponseFileTreePart.
17230
+ * @param value File tree data.
17231
+ * @param baseUri The base uri to which this file tree is relative.
17232
+ */
17233
+ constructor(value: ChatResponseFileTree[], baseUri: Uri);
17234
+ }
17235
+
17236
+ /**
17237
+ * Represents a part of a chat response that is an anchor, that is rendered as a link to a target.
17238
+ */
17239
+ export class ChatResponseAnchorPart {
17240
+ /**
17241
+ * The target of this anchor.
17242
+ */
17243
+ value: Uri | Location;
17244
+
17245
+ /**
17246
+ * An optional title that is rendered with value.
17247
+ */
17248
+ title?: string;
17249
+
17250
+ /**
17251
+ * Create a new ChatResponseAnchorPart.
17252
+ * @param value A uri or location.
17253
+ * @param title An optional title that is rendered with value.
17254
+ */
17255
+ constructor(value: Uri | Location, title?: string);
17256
+ }
17257
+
17258
+ /**
17259
+ * Represents a part of a chat response that is a progress message.
17260
+ */
17261
+ export class ChatResponseProgressPart {
17262
+ /**
17263
+ * The progress message
17264
+ */
17265
+ value: string;
17266
+
17267
+ /**
17268
+ * Create a new ChatResponseProgressPart.
17269
+ * @param value A progress message
17270
+ */
17271
+ constructor(value: string);
17272
+ }
17273
+
17274
+ /**
17275
+ * Represents a part of a chat response that is a reference, rendered separately from the content.
17276
+ */
17277
+ export class ChatResponseReferencePart {
17278
+ /**
17279
+ * The reference target.
17280
+ */
17281
+ value: Uri | Location;
17282
+
17283
+ /**
17284
+ * The icon for the reference.
17285
+ */
17286
+ iconPath?: Uri | ThemeIcon | {
17287
+ /**
17288
+ * The icon path for the light theme.
17289
+ */
17290
+ light: Uri;
17291
+ /**
17292
+ * The icon path for the dark theme.
17293
+ */
17294
+ dark: Uri;
17295
+ };
17296
+
17297
+ /**
17298
+ * Create a new ChatResponseReferencePart.
17299
+ * @param value A uri or location
17300
+ * @param iconPath Icon for the reference shown in UI
17301
+ */
17302
+ constructor(value: Uri | Location, iconPath?: Uri | ThemeIcon | {
17303
+ /**
17304
+ * The icon path for the light theme.
17305
+ */
17306
+ light: Uri;
17307
+ /**
17308
+ * The icon path for the dark theme.
17309
+ */
17310
+ dark: Uri;
17311
+ });
17312
+ }
17313
+
17314
+ /**
17315
+ * Represents a part of a chat response that is a button that executes a command.
17316
+ */
17317
+ export class ChatResponseCommandButtonPart {
17318
+ /**
17319
+ * The command that will be executed when the button is clicked.
17320
+ */
17321
+ value: Command;
17322
+
17323
+ /**
17324
+ * Create a new ChatResponseCommandButtonPart.
17325
+ * @param value A Command that will be executed when the button is clicked.
17326
+ */
17327
+ constructor(value: Command);
17328
+ }
17329
+
17330
+ /**
17331
+ * Represents the different chat response types.
17332
+ */
17333
+ export type ChatResponsePart = ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart
17334
+ | ChatResponseProgressPart | ChatResponseReferencePart | ChatResponseCommandButtonPart;
17335
+
17336
+ /**
17337
+ * Namespace for chat functionality. Users interact with chat participants by sending messages
17338
+ * to them in the chat view. Chat participants can respond with markdown or other types of content
17339
+ * via the {@link ChatResponseStream}.
17340
+ */
17341
+ export namespace chat {
17342
+ /**
17343
+ * Create a new {@link ChatParticipant chat participant} instance.
17344
+ *
17345
+ * @param id A unique identifier for the participant.
17346
+ * @param handler A request handler for the participant.
17347
+ * @returns A new chat participant
17348
+ * @stubbed
17349
+ */
17350
+ export function createChatParticipant(id: string, handler: ChatRequestHandler): ChatParticipant;
17351
+ }
17352
+
17353
+ /**
17354
+ * Represents the role of a chat message. This is either the user or the assistant.
17355
+ */
17356
+ export enum LanguageModelChatMessageRole {
17357
+ /**
17358
+ * The user role, e.g the human interacting with a language model.
17359
+ */
17360
+ User = 1,
17361
+
17362
+ /**
17363
+ * The assistant role, e.g. the language model generating responses.
17364
+ */
17365
+ Assistant = 2
17366
+ }
17367
+
17368
+ /**
17369
+ * Represents a message in a chat. Can assume different roles, like user or assistant.
17370
+ */
17371
+ export class LanguageModelChatMessage {
17372
+
17373
+ /**
17374
+ * Utility to create a new user message.
17375
+ *
17376
+ * @param content The content of the message.
17377
+ * @param name The optional name of a user for the message.
17378
+ */
17379
+ static User(content: string, name?: string): LanguageModelChatMessage;
17380
+
17381
+ /**
17382
+ * Utility to create a new assistant message.
17383
+ *
17384
+ * @param content The content of the message.
17385
+ * @param name The optional name of a user for the message.
17386
+ */
17387
+ static Assistant(content: string, name?: string): LanguageModelChatMessage;
17388
+
17389
+ /**
17390
+ * The role of this message.
17391
+ */
17392
+ role: LanguageModelChatMessageRole;
17393
+
17394
+ /**
17395
+ * The content of this message.
17396
+ */
17397
+ content: string;
17398
+
17399
+ /**
17400
+ * The optional name of a user for this message.
17401
+ */
17402
+ name: string | undefined;
17403
+
17404
+ /**
17405
+ * Create a new user message.
17406
+ *
17407
+ * @param role The role of the message.
17408
+ * @param content The content of the message.
17409
+ * @param name The optional name of a user for the message.
17410
+ */
17411
+ constructor(role: LanguageModelChatMessageRole, content: string, name?: string);
17412
+ }
17413
+
17414
+ /**
17415
+ * Represents a language model response.
17416
+ *
17417
+ * @see {@link LanguageModelAccess.chatRequest}
17418
+ */
17419
+ export interface LanguageModelChatResponse {
17420
+
17421
+ /**
17422
+ * An async iterable that is a stream of text chunks forming the overall response.
17423
+ *
17424
+ * *Note* that this stream will error when during data receiving an error occurs. Consumers of
17425
+ * the stream should handle the errors accordingly.
17426
+ *
17427
+ * To cancel the stream, the consumer can {@link CancellationTokenSource.cancel cancel} the token that was used to make the request
17428
+ * or break from the for-loop.
17429
+ *
17430
+ * @example
17431
+ * ```ts
17432
+ * try {
17433
+ * // consume stream
17434
+ * for await (const chunk of response.text) {
17435
+ * console.log(chunk);
17436
+ * }
17437
+ *
17438
+ * } catch(e) {
17439
+ * // stream ended with an error
17440
+ * console.error(e);
17441
+ * }
17442
+ * ```
17443
+ */
17444
+ text: AsyncIterable<string>;
17445
+ }
17446
+
17447
+ /**
17448
+ * Represents a language model for making chat requests.
17449
+ *
17450
+ * @see {@link lm.selectChatModels}
17451
+ */
17452
+ export interface LanguageModelChat {
17453
+
17454
+ /**
17455
+ * Human-readable name of the language model.
17456
+ */
17457
+ readonly name: string;
17458
+
17459
+ /**
17460
+ * Opaque identifier of the language model.
17461
+ */
17462
+ readonly id: string;
17463
+
17464
+ /**
17465
+ * A well-known identifier of the vendor of the language model. An example is `copilot`, but
17466
+ * values are defined by extensions contributing chat models and need to be looked up with them.
17467
+ */
17468
+ readonly vendor: string;
17469
+
17470
+ /**
17471
+ * Opaque family-name of the language model. Values might be `gpt-3.5-turbo`, `gpt4`, `phi2`, or `llama`
17472
+ * but they are defined by extensions contributing languages and subject to change.
17473
+ */
17474
+ readonly family: string;
17475
+
17476
+ /**
17477
+ * Opaque version string of the model. This is defined by the extension contributing the language model
17478
+ * and subject to change.
17479
+ */
17480
+ readonly version: string;
17481
+
17482
+ /**
17483
+ * The maximum number of tokens that can be sent to the model in a single request.
17484
+ */
17485
+ readonly maxInputTokens: number;
17486
+
17487
+ /**
17488
+ * Make a chat request using a language model.
17489
+ *
17490
+ * *Note* that language model use may be subject to access restrictions and user consent. Calling this function
17491
+ * for the first time (for a extension) will show a consent dialog to the user and because of that this function
17492
+ * must _only be called in response to a user action!_ Extension can use {@link LanguageModelAccessInformation.canSendRequest}
17493
+ * to check if they have the necessary permissions to make a request.
17494
+ *
17495
+ * This function will return a rejected promise if making a request to the language model is not
17496
+ * possible. Reasons for this can be:
17497
+ *
17498
+ * - user consent not given, see {@link LanguageModelError.NoPermissions `NoPermissions`}
17499
+ * - model does not exist anymore, see {@link LanguageModelError.NotFound `NotFound`}
17500
+ * - quota limits exceeded, see {@link LanguageModelError.Blocked `Blocked`}
17501
+ * - other issues in which case extension must check {@link LanguageModelError.cause `LanguageModelError.cause`}
17502
+ *
17503
+ * @param messages An array of message instances.
17504
+ * @param options Options that control the request.
17505
+ * @param token A cancellation token which controls the request. See {@link CancellationTokenSource} for how to create one.
17506
+ * @returns A thenable that resolves to a {@link LanguageModelChatResponse}. The promise will reject when the request couldn't be made.
17507
+ */
17508
+ sendRequest(messages: LanguageModelChatMessage[], options?: LanguageModelChatRequestOptions, token?: CancellationToken): Thenable<LanguageModelChatResponse>;
17509
+
17510
+ /**
17511
+ * Count the number of tokens in a message using the model specific tokenizer-logic.
17512
+ * @param text A string or a message instance.
17513
+ * @param token Optional cancellation token. See {@link CancellationTokenSource} for how to create one.
17514
+ * @returns A thenable that resolves to the number of tokens.
17515
+ */
17516
+ countTokens(text: string | LanguageModelChatMessage, token?: CancellationToken): Thenable<number>;
17517
+ }
17518
+
17519
+ /**
17520
+ * Describes how to select language models for chat requests.
17521
+ *
17522
+ * @see {@link lm.selectChatModels}
17523
+ */
17524
+ export interface LanguageModelChatSelector {
17525
+
17526
+ /**
17527
+ * A vendor of language models.
17528
+ * @see {@link LanguageModelChat.vendor}
17529
+ */
17530
+ vendor?: string;
17531
+
17532
+ /**
17533
+ * A family of language models.
17534
+ * @see {@link LanguageModelChat.family}
17535
+ */
17536
+ family?: string;
17537
+
17538
+ /**
17539
+ * The version of a language model.
17540
+ * @see {@link LanguageModelChat.version}
17541
+ */
17542
+ version?: string;
17543
+
17544
+ /**
17545
+ * The identifier of a language model.
17546
+ * @see {@link LanguageModelChat.id}
17547
+ */
17548
+ id?: string;
17549
+ }
17550
+
17551
+ /**
17552
+ * An error type for language model specific errors.
17553
+ *
17554
+ * Consumers of language models should check the code property to determine specific
17555
+ * failure causes, like `if(someError.code === vscode.LanguageModelError.NotFound.name) {...}`
17556
+ * for the case of referring to an unknown language model. For unspecified errors the `cause`-property
17557
+ * will contain the actual error.
17558
+ */
17559
+ export class LanguageModelError extends Error {
17560
+
17561
+ /**
17562
+ * The requestor does not have permissions to use this
17563
+ * language model
17564
+ */
17565
+ static NoPermissions(message?: string): LanguageModelError;
17566
+
17567
+ /**
17568
+ * The requestor is blocked from using this language model.
17569
+ */
17570
+ static Blocked(message?: string): LanguageModelError;
17571
+
17572
+ /**
17573
+ * The language model does not exist.
17574
+ */
17575
+ static NotFound(message?: string): LanguageModelError;
17576
+
17577
+ /**
17578
+ * A code that identifies this error.
17579
+ *
17580
+ * Possible values are names of errors, like {@linkcode LanguageModelError.NotFound NotFound},
17581
+ * or `Unknown` for unspecified errors from the language model itself. In the latter case the
17582
+ * `cause`-property will contain the actual error.
17583
+ */
17584
+ readonly code: string;
17585
+ }
17586
+
17587
+ /**
17588
+ * Options for making a chat request using a language model.
17589
+ *
17590
+ * @see {@link LanguageModelChat.sendRequest}
17591
+ */
17592
+ export interface LanguageModelChatRequestOptions {
17593
+
17594
+ /**
17595
+ * A human-readable message that explains why access to a language model is needed and what feature is enabled by it.
17596
+ */
17597
+ justification?: string;
17598
+
17599
+ /**
17600
+ * A set of options that control the behavior of the language model. These options are specific to the language model
17601
+ * and need to be lookup in the respective documentation.
17602
+ */
17603
+ modelOptions?: { [name: string]: any };
17604
+ }
17605
+
17606
+ /**
17607
+ * Namespace for language model related functionality.
17608
+ */
17609
+ export namespace lm {
17610
+
17611
+ /**
17612
+ * An event that is fired when the set of available chat models changes.
17613
+ * @stubbed
17614
+ */
17615
+ export const onDidChangeChatModels: Event<void>;
17616
+
17617
+ /**
17618
+ * Select chat models by a {@link LanguageModelChatSelector selector}. This can yield multiple or no chat models and
17619
+ * extensions must handle these cases, esp. when no chat model exists, gracefully.
17620
+ *
17621
+ * ```ts
17622
+ * const models = await vscode.lm.selectChatModels({ family: 'gpt-3.5-turbo' });
17623
+ * if (models.length > 0) {
17624
+ * const [first] = models;
17625
+ * const response = await first.sendRequest(...)
17626
+ * // ...
17627
+ * } else {
17628
+ * // NO chat models available
17629
+ * }
17630
+ * ```
17631
+ *
17632
+ * A selector can be written to broadly match all models of a given vendor or family, or it can narrowly select one model by ID.
17633
+ * Keep in mind that the available set of models will change over time, but also that prompts may perform differently in
17634
+ * different models.
17635
+ *
17636
+ * *Note* that extensions can hold on to the results returned by this function and use them later. However, when the
17637
+ * {@link onDidChangeChatModels}-event is fired the list of chat models might have changed and extensions should re-query.
17638
+ *
17639
+ * @param selector A chat model selector. When omitted all chat models are returned.
17640
+ * @returns An array of chat models, can be empty!
17641
+ * @stubbed
17642
+ */
17643
+ export function selectChatModels(selector?: LanguageModelChatSelector): Thenable<LanguageModelChat[]>;
17644
+ }
17645
+
17646
+ /**
17647
+ * Represents extension specific information about the access to language models.
17648
+ */
17649
+ export interface LanguageModelAccessInformation {
17650
+
17651
+ /**
17652
+ * An event that fires when access information changes.
17653
+ */
17654
+ onDidChange: Event<void>;
17655
+
17656
+ /**
17657
+ * Checks if a request can be made to a language model.
17658
+ *
17659
+ * *Note* that calling this function will not trigger a consent UI but just checks for a persisted state.
17660
+ *
17661
+ * @param chat A language model chat object.
17662
+ * @return `true` if a request can be made, `false` if not, `undefined` if the language
17663
+ * model does not exist or consent hasn't been asked for.
17664
+ */
17665
+ canSendRequest(chat: LanguageModelChat): boolean | undefined;
17666
+ }
17667
+
16732
17668
  /**
16733
17669
  * Thenable is a common denominator between ES6 promises, Q, jquery.Deferred, WinJS.Promise,
16734
17670
  * and others. This API makes no assumption about what promise library is being used which
@@ -0,0 +1,189 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 Typefox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ /*---------------------------------------------------------------------------------------------
18
+ * Copyright (c) Microsoft Corporation. All rights reserved.
19
+ * Licensed under the MIT License. See License.txt in the project root for license information.
20
+ *--------------------------------------------------------------------------------------------*/
21
+
22
+ /* eslint-disable @typescript-eslint/no-explicit-any */
23
+
24
+ declare module '@theia/plugin' {
25
+ export namespace debug {
26
+ /**
27
+ * Registers a custom data visualization for variables when debugging.
28
+ *
29
+ * @param id The corresponding ID in the package.json `debugVisualizers` contribution point.
30
+ * @param provider The {@link DebugVisualizationProvider} to register
31
+ * @stubbed
32
+ */
33
+ export function registerDebugVisualizationProvider<T extends DebugVisualization>(
34
+ id: string,
35
+ provider: DebugVisualizationProvider<T>
36
+ ): Disposable;
37
+
38
+ /**
39
+ * Registers a tree that can be referenced by {@link DebugVisualization.visualization}.
40
+ * @param id
41
+ * @param provider
42
+ * @stubbed
43
+ */
44
+ export function registerDebugVisualizationTreeProvider<T extends DebugTreeItem>(
45
+ id: string,
46
+ provider: DebugVisualizationTree<T>
47
+ ): Disposable;
48
+ }
49
+
50
+ /**
51
+ * An item from the {@link DebugVisualizationTree}
52
+ */
53
+ export interface DebugTreeItem {
54
+ /**
55
+ * A human-readable string describing this item.
56
+ */
57
+ label: string;
58
+
59
+ /**
60
+ * A human-readable string which is rendered less prominent.
61
+ */
62
+ description?: string;
63
+
64
+ /**
65
+ * {@link TreeItemCollapsibleState} of the tree item.
66
+ */
67
+ collapsibleState?: TreeItemCollapsibleState;
68
+
69
+ /**
70
+ * Context value of the tree item. This can be used to contribute item specific actions in the tree.
71
+ * For example, a tree item is given a context value as `folder`. When contributing actions to `view/item/context`
72
+ * using `menus` extension point, you can specify context value for key `viewItem` in `when` expression like `viewItem == folder`.
73
+ * ```json
74
+ * "contributes": {
75
+ * "menus": {
76
+ * "view/item/context": [
77
+ * {
78
+ * "command": "extension.deleteFolder",
79
+ * "when": "viewItem == folder"
80
+ * }
81
+ * ]
82
+ * }
83
+ * }
84
+ * ```
85
+ * This will show action `extension.deleteFolder` only for items with `contextValue` is `folder`.
86
+ */
87
+ contextValue?: string;
88
+
89
+ /**
90
+ * Whether this item can be edited by the user.
91
+ */
92
+ canEdit?: boolean;
93
+ }
94
+
95
+ /**
96
+ * Provides a tree that can be referenced in debug visualizations.
97
+ */
98
+ export interface DebugVisualizationTree<T extends DebugTreeItem = DebugTreeItem> {
99
+ /**
100
+ * Gets the tree item for an element or the base context item.
101
+ */
102
+ getTreeItem(context: DebugVisualizationContext): ProviderResult<T>;
103
+ /**
104
+ * Gets children for the tree item or the best context item.
105
+ */
106
+ getChildren(element: T): ProviderResult<T[]>;
107
+ /**
108
+ * Handles the user editing an item.
109
+ */
110
+ editItem?(item: T, value: string): ProviderResult<T>;
111
+ }
112
+
113
+ export class DebugVisualization {
114
+ /**
115
+ * The name of the visualization to show to the user.
116
+ */
117
+ name: string;
118
+
119
+ /**
120
+ * An icon for the view when it's show in inline actions.
121
+ */
122
+ iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
123
+
124
+ /**
125
+ * Visualization to use for the variable. This may be either:
126
+ * - A command to run when the visualization is selected for a variable.
127
+ * - A reference to a previously-registered {@link DebugVisualizationTree}
128
+ */
129
+ visualization?: Command | { treeId: string };
130
+
131
+ /**
132
+ * Creates a new debug visualization object.
133
+ * @param name Name of the visualization to show to the user.
134
+ */
135
+ constructor(name: string);
136
+ }
137
+
138
+ export interface DebugVisualizationProvider<T extends DebugVisualization = DebugVisualization> {
139
+ /**
140
+ * Called for each variable when the debug session stops. It should return
141
+ * any visualizations the extension wishes to show to the user.
142
+ *
143
+ * Note that this is only called when its `when` clause defined under the
144
+ * `debugVisualizers` contribution point in the `package.json` evaluates
145
+ * to true.
146
+ */
147
+ provideDebugVisualization(context: DebugVisualizationContext, token: CancellationToken): ProviderResult<T[]>;
148
+
149
+ /**
150
+ * Invoked for a variable when a user picks the visualizer.
151
+ *
152
+ * It may return a {@link TreeView} that's shown in the Debug Console or
153
+ * inline in a hover. A visualizer may choose to return `undefined` from
154
+ * this function and instead trigger other actions in the UI, such as opening
155
+ * a custom {@link WebviewView}.
156
+ */
157
+ resolveDebugVisualization?(visualization: T, token: CancellationToken): ProviderResult<T>;
158
+ }
159
+
160
+ export interface DebugVisualizationContext {
161
+ /**
162
+ * The Debug Adapter Protocol Variable to be visualized.
163
+ * @see https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable
164
+ */
165
+ variable: any;
166
+ /**
167
+ * The Debug Adapter Protocol variable reference the type (such as a scope
168
+ * or another variable) that contained this one. Empty for variables
169
+ * that came from user evaluations in the Debug Console.
170
+ * @see https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable
171
+ */
172
+ containerId?: number;
173
+ /**
174
+ * The ID of the Debug Adapter Protocol StackFrame in which the variable was found,
175
+ * for variables that came from scopes in a stack frame.
176
+ * @see https://microsoft.github.io/debug-adapter-protocol/specification#Types_StackFrame
177
+ */
178
+ frameId?: number;
179
+ /**
180
+ * The ID of the Debug Adapter Protocol Thread in which the variable was found.
181
+ * @see https://microsoft.github.io/debug-adapter-protocol/specification#Types_StackFrame
182
+ */
183
+ threadId: number;
184
+ /**
185
+ * The debug session the variable belongs to.
186
+ */
187
+ session: DebugSession;
188
+ }
189
+ }
@@ -0,0 +1,115 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 Typefox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ /*---------------------------------------------------------------------------------------------
18
+ * Copyright (c) Microsoft Corporation. All rights reserved.
19
+ * Licensed under the MIT License. See License.txt in the project root for license information.
20
+ *--------------------------------------------------------------------------------------------*/
21
+
22
+ declare module '@theia/plugin' {
23
+
24
+ /**
25
+ * The action that should be taken when a port is discovered through automatic port forwarding discovery.
26
+ */
27
+ export enum PortAutoForwardAction {
28
+ /**
29
+ * Notify the user that the port is being forwarded. This is the default action.
30
+ */
31
+ Notify = 1,
32
+ /**
33
+ * Once the port is forwarded, open the user's web browser to the forwarded port.
34
+ */
35
+ OpenBrowser = 2,
36
+ /**
37
+ * Once the port is forwarded, open the preview browser to the forwarded port.
38
+ */
39
+ OpenPreview = 3,
40
+ /**
41
+ * Forward the port silently.
42
+ */
43
+ Silent = 4,
44
+ /**
45
+ * Do not forward the port.
46
+ */
47
+ Ignore = 5
48
+ }
49
+
50
+ /**
51
+ * The attributes that a forwarded port can have.
52
+ */
53
+ export class PortAttributes {
54
+ /**
55
+ * The action to be taken when this port is detected for auto forwarding.
56
+ */
57
+ autoForwardAction: PortAutoForwardAction;
58
+
59
+ /**
60
+ * Creates a new PortAttributes object
61
+ * @param port the port number
62
+ * @param autoForwardAction the action to take when this port is detected
63
+ */
64
+ constructor(autoForwardAction: PortAutoForwardAction);
65
+ }
66
+
67
+ /**
68
+ * A provider of port attributes. Port attributes are used to determine what action should be taken when a port is discovered.
69
+ */
70
+ export interface PortAttributesProvider {
71
+ /**
72
+ * Provides attributes for the given port. For ports that your extension doesn't know about, simply
73
+ * return undefined. For example, if `providePortAttributes` is called with ports 3000 but your
74
+ * extension doesn't know anything about 3000 you should return undefined.
75
+ * @param port The port number of the port that attributes are being requested for.
76
+ * @param pid The pid of the process that is listening on the port. If the pid is unknown, undefined will be passed.
77
+ * @param commandLine The command line of the process that is listening on the port. If the command line is unknown, undefined will be passed.
78
+ * @param token A cancellation token that indicates the result is no longer needed.
79
+ */
80
+ providePortAttributes(attributes: { port: number; pid?: number; commandLine?: string }, token: CancellationToken): ProviderResult<PortAttributes>;
81
+ }
82
+
83
+ /**
84
+ * A selector that will be used to filter which {@link PortAttributesProvider} should be called for each port.
85
+ */
86
+ export interface PortAttributesSelector {
87
+ /**
88
+ * Specifying a port range will cause your provider to only be called for ports within the range.
89
+ * The start is inclusive and the end is exclusive.
90
+ */
91
+ portRange?: [number, number] | number;
92
+
93
+ /**
94
+ * Specifying a command pattern will cause your provider to only be called for processes whose command line matches the pattern.
95
+ */
96
+ commandPattern?: RegExp;
97
+ }
98
+
99
+ export namespace workspace {
100
+ /**
101
+ * If your extension listens on ports, consider registering a PortAttributesProvider to provide information
102
+ * about the ports. For example, a debug extension may know about debug ports in it's debuggee. By providing
103
+ * this information with a PortAttributesProvider the extension can tell the editor that these ports should be
104
+ * ignored, since they don't need to be user facing.
105
+ *
106
+ * The results of the PortAttributesProvider are merged with the user setting `remote.portsAttributes`. If the values conflict, the user setting takes precedence.
107
+ *
108
+ * @param portSelector It is best practice to specify a port selector to avoid unnecessary calls to your provider.
109
+ * If you don't specify a port selector your provider will be called for every port, which will result in slower port forwarding for the user.
110
+ * @param provider The {@link PortAttributesProvider PortAttributesProvider}.
111
+ * @stubbed
112
+ */
113
+ export function registerPortAttributesProvider(portSelector: PortAttributesSelector, provider: PortAttributesProvider): Disposable;
114
+ }
115
+ }