@theia/plugin 1.63.0-next.24 → 1.63.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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/theia.d.ts +380 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theia/plugin",
3
- "version": "1.63.0-next.24+83b50cc66",
3
+ "version": "1.63.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.62.0"
30
+ "@theia/ext-scripts": "1.63.0"
31
31
  },
32
32
  "nyc": {
33
33
  "extends": "../../configs/nyc.json"
34
34
  },
35
- "gitHead": "83b50cc66b001a5b9100ccd944dcace04cd4ae2e"
35
+ "gitHead": "facf442522991134333495a0b90cf56a56990280"
36
36
  }
package/src/theia.d.ts CHANGED
@@ -1454,6 +1454,24 @@ export module '@theia/plugin' {
1454
1454
  */
1455
1455
  readonly languageId: string;
1456
1456
 
1457
+ /**
1458
+ * The file encoding of this document that will be used when the document is saved.
1459
+ *
1460
+ * Use the {@link workspace.onDidChangeTextDocument onDidChangeTextDocument}-event to
1461
+ * get notified when the document encoding changes.
1462
+ *
1463
+ * Note that the possible encoding values are currently defined as any of the following:
1464
+ * 'utf8', 'utf8bom', 'utf16le', 'utf16be', 'windows1252', 'iso88591', 'iso88593',
1465
+ * 'iso885915', 'macroman', 'cp437', 'windows1256', 'iso88596', 'windows1257',
1466
+ * 'iso88594', 'iso885914', 'windows1250', 'iso88592', 'cp852', 'windows1251',
1467
+ * 'cp866', 'cp1125', 'iso88595', 'koi8r', 'koi8u', 'iso885913', 'windows1253',
1468
+ * 'iso88597', 'windows1255', 'iso88598', 'iso885910', 'iso885916', 'windows1254',
1469
+ * 'iso88599', 'windows1258', 'gbk', 'gb18030', 'cp950', 'big5hkscs', 'shiftjis',
1470
+ * 'eucjp', 'euckr', 'windows874', 'iso885911', 'koi8ru', 'koi8t', 'gb2312',
1471
+ * 'cp865', 'cp850'.
1472
+ */
1473
+ readonly encoding: string;
1474
+
1457
1475
  /**
1458
1476
  * The version number of this document (it will strictly increase after each
1459
1477
  * change, including undo/redo).
@@ -7871,29 +7889,75 @@ export module '@theia/plugin' {
7871
7889
  * Opens a document. Will return early if this document is already open. Otherwise
7872
7890
  * the document is loaded and the {@link workspace.onDidOpenTextDocument didOpen}-event fires.
7873
7891
  *
7874
- * The document is denoted by an {@link Uri uri}. Depending on the {@link Uri.scheme scheme} the
7892
+ * The document is denoted by an {@link Uri}. Depending on the {@link Uri.scheme scheme} the
7875
7893
  * following rules apply:
7876
- * * `file`-scheme: Open a file on disk, will be rejected if the file does not exist or cannot be loaded.
7877
- * * `untitled`-scheme: A new file that should be saved on disk, e.g. `untitled:c:\frodo\new.js`. The language
7878
- * will be derived from the file name.
7879
- * * For all other schemes the registered text document content {@link TextDocumentContentProvider providers} are consulted.
7894
+ * * `file`-scheme: Open a file on disk (`openTextDocument(Uri.file(path))`). Will be rejected if the file
7895
+ * does not exist or cannot be loaded.
7896
+ * * `untitled`-scheme: Open a blank untitled file with associated path (`openTextDocument(Uri.file(path).with({ scheme: 'untitled' }))`).
7897
+ * The language will be derived from the file name.
7898
+ * * For all other schemes contributed {@link TextDocumentContentProvider text document content providers} and
7899
+ * {@link FileSystemProvider file system providers} are consulted.
7880
7900
  *
7881
7901
  * *Note* that the lifecycle of the returned document is owned by the editor and not by the extension. That means an
7882
- * [`onDidClose`](#workspace.onDidCloseTextDocument)-event can occur at any time after opening it.
7902
+ * {@linkcode workspace.onDidCloseTextDocument onDidClose}-event can occur at any time after opening it.
7883
7903
  *
7884
7904
  * @param uri Identifies the resource to open.
7885
- * @return A promise that resolves to a {@link TextDocument document}.
7905
+ * @returns A promise that resolves to a {@link TextDocument document}.
7886
7906
  */
7887
- export function openTextDocument(uri: Uri): Thenable<TextDocument | undefined>;
7907
+ export function openTextDocument(uri: Uri, options?: {
7908
+ /**
7909
+ * The {@link TextDocument.encoding encoding} of the document to use
7910
+ * for decoding the underlying buffer to text. If omitted, the encoding
7911
+ * will be guessed based on the file content and/or the editor settings
7912
+ * unless the document is already opened.
7913
+ *
7914
+ * Opening a text document that was already opened with a different encoding
7915
+ * has the potential of changing the text contents of the text document.
7916
+ * Specifically, when the encoding results in a different set of characters
7917
+ * than the previous encoding. As such, an error is thrown for dirty documents
7918
+ * when the specified encoding is different from the encoding of the document.
7919
+ *
7920
+ * See {@link TextDocument.encoding} for more information about valid
7921
+ * values for encoding. Using an unsupported encoding will fallback to the
7922
+ * default encoding for the document.
7923
+ *
7924
+ * *Note* that if you open a document with an encoding that does not
7925
+ * support decoding the underlying bytes, content may be replaced with
7926
+ * substitution characters as appropriate.
7927
+ */
7928
+ readonly encoding?: string;
7929
+ }): Thenable<TextDocument>;
7888
7930
 
7889
7931
  /**
7890
- * A short-hand for `openTextDocument(Uri.file(fileName))`.
7932
+ * A short-hand for `openTextDocument(Uri.file(path))`.
7891
7933
  *
7892
- * @see {@link openTextDocument openTextDocument}
7893
- * @param fileName A name of a file on disk.
7894
- * @return A promise that resolves to a {@link TextDocument document}.
7934
+ * @see {@link workspace.openTextDocument}
7935
+ * @param path A path of a file on disk.
7936
+ * @returns A promise that resolves to a {@link TextDocument document}.
7895
7937
  */
7896
- export function openTextDocument(fileName: string): Thenable<TextDocument | undefined>;
7938
+ export function openTextDocument(path: string, options?: {
7939
+ /**
7940
+ * The {@link TextDocument.encoding encoding} of the document to use
7941
+ * for decoding the underlying buffer to text. If omitted, the encoding
7942
+ * will be guessed based on the file content and/or the editor settings
7943
+ * unless the document is already opened.
7944
+ *
7945
+ * Opening a text document that was already opened with a different encoding
7946
+ * has the potential of changing the text contents of the text document.
7947
+ * Specifically, when the encoding results in a different set of characters
7948
+ * than the previous encoding. As such, an error is thrown for dirty documents
7949
+ * when the specified encoding is different from the encoding of the document.
7950
+ *
7951
+ * See {@link TextDocument.encoding} for more information about valid
7952
+ * values for encoding. Using an unsupported encoding will fallback to the
7953
+ * default encoding for the document.
7954
+ *
7955
+ * *Note* that if you open a document with an encoding that does not
7956
+ * support decoding the underlying bytes, content may be replaced with
7957
+ * substitution characters as appropriate.
7958
+ */
7959
+ readonly encoding?: string;
7960
+ }): Thenable<TextDocument>;
7897
7961
 
7898
7962
  /**
7899
7963
  * Opens an untitled text document. The editor will prompt the user for a file
@@ -7901,9 +7965,26 @@ export module '@theia/plugin' {
7901
7965
  * specify the *language* and/or the *content* of the document.
7902
7966
  *
7903
7967
  * @param options Options to control how the document will be created.
7904
- * @return A promise that resolves to a {@link TextDocument document}.
7968
+ * @returns A promise that resolves to a {@link TextDocument document}.
7905
7969
  */
7906
- export function openTextDocument(options?: { language?: string; content?: string; }): Thenable<TextDocument | undefined>;
7970
+ export function openTextDocument(options?: {
7971
+ /**
7972
+ * The {@link TextDocument.languageId language} of the document.
7973
+ */
7974
+ language?: string;
7975
+ /**
7976
+ * The initial contents of the document.
7977
+ */
7978
+ content?: string;
7979
+ /**
7980
+ * The {@link TextDocument.encoding encoding} of the document.
7981
+ *
7982
+ * See {@link TextDocument.encoding} for more information about valid
7983
+ * values for encoding. Using an unsupported encoding will fallback to the
7984
+ * default encoding for the document.
7985
+ */
7986
+ readonly encoding?: string;
7987
+ }): Thenable<TextDocument>;
7907
7988
 
7908
7989
  /**
7909
7990
  * Open a notebook. Will return early if this notebook is already {@link NotebookDocument loaded}.
@@ -8138,6 +8219,130 @@ export module '@theia/plugin' {
8138
8219
  * Event that fires when the current workspace has been trusted.
8139
8220
  */
8140
8221
  export const onDidGrantWorkspaceTrust: Event<void>;
8222
+
8223
+ /**
8224
+ * Decodes the content from a `Uint8Array` to a `string`. You MUST
8225
+ * provide the entire content at once to ensure that the encoding
8226
+ * can properly apply. Do not use this method to decode content
8227
+ * in chunks, as that may lead to incorrect results.
8228
+ *
8229
+ * Will pick an encoding based on settings and the content of the
8230
+ * buffer (for example byte order marks).
8231
+ *
8232
+ * *Note* that if you decode content that is unsupported by the
8233
+ * encoding, the result may contain substitution characters as
8234
+ * appropriate.
8235
+ *
8236
+ * @throws This method will throw an error when the content is binary.
8237
+ *
8238
+ * @param content The text content to decode as a `Uint8Array`.
8239
+ * @returns A thenable that resolves to the decoded `string`.
8240
+ */
8241
+ export function decode(content: Uint8Array): Thenable<string>;
8242
+
8243
+ /**
8244
+ * Decodes the content from a `Uint8Array` to a `string` using the
8245
+ * provided encoding. You MUST provide the entire content at once
8246
+ * to ensure that the encoding can properly apply. Do not use this
8247
+ * method to decode content in chunks, as that may lead to incorrect
8248
+ * results.
8249
+ *
8250
+ * *Note* that if you decode content that is unsupported by the
8251
+ * encoding, the result may contain substitution characters as
8252
+ * appropriate.
8253
+ *
8254
+ * @throws This method will throw an error when the content is binary.
8255
+ *
8256
+ * @param content The text content to decode as a `Uint8Array`.
8257
+ * @param options Additional context for picking the encoding.
8258
+ * @returns A thenable that resolves to the decoded `string`.
8259
+ */
8260
+ export function decode(content: Uint8Array, options: {
8261
+ /**
8262
+ * Allows to explicitly pick the encoding to use.
8263
+ * See {@link TextDocument.encoding} for more information
8264
+ * about valid values for encoding.
8265
+ * Using an unsupported encoding will fallback to the
8266
+ * default configured encoding.
8267
+ */
8268
+ readonly encoding: string;
8269
+ }): Thenable<string>;
8270
+
8271
+ /**
8272
+ * Decodes the content from a `Uint8Array` to a `string`. You MUST
8273
+ * provide the entire content at once to ensure that the encoding
8274
+ * can properly apply. Do not use this method to decode content
8275
+ * in chunks, as that may lead to incorrect results.
8276
+ *
8277
+ * The encoding is picked based on settings and the content
8278
+ * of the buffer (for example byte order marks).
8279
+ *
8280
+ * *Note* that if you decode content that is unsupported by the
8281
+ * encoding, the result may contain substitution characters as
8282
+ * appropriate.
8283
+ *
8284
+ * @throws This method will throw an error when the content is binary.
8285
+ *
8286
+ * @param content The content to decode as a `Uint8Array`.
8287
+ * @param options Additional context for picking the encoding.
8288
+ * @returns A thenable that resolves to the decoded `string`.
8289
+ */
8290
+ export function decode(content: Uint8Array, options: {
8291
+ /**
8292
+ * The URI that represents the file if known. This information
8293
+ * is used to figure out the encoding related configuration
8294
+ * for the file if any.
8295
+ */
8296
+ readonly uri: Uri;
8297
+ }): Thenable<string>;
8298
+
8299
+ /**
8300
+ * Encodes the content of a `string` to a `Uint8Array`.
8301
+ *
8302
+ * Will pick an encoding based on settings.
8303
+ *
8304
+ * @param content The content to decode as a `string`.
8305
+ * @returns A thenable that resolves to the encoded `Uint8Array`.
8306
+ */
8307
+ export function encode(content: string): Thenable<Uint8Array>;
8308
+
8309
+ /**
8310
+ * Encodes the content of a `string` to a `Uint8Array` using the
8311
+ * provided encoding.
8312
+ *
8313
+ * @param content The content to decode as a `string`.
8314
+ * @param options Additional context for picking the encoding.
8315
+ * @returns A thenable that resolves to the encoded `Uint8Array`.
8316
+ */
8317
+ export function encode(content: string, options: {
8318
+ /**
8319
+ * Allows to explicitly pick the encoding to use.
8320
+ * See {@link TextDocument.encoding} for more information
8321
+ * about valid values for encoding.
8322
+ * Using an unsupported encoding will fallback to the
8323
+ * default configured encoding.
8324
+ */
8325
+ readonly encoding: string;
8326
+ }): Thenable<Uint8Array>;
8327
+
8328
+ /**
8329
+ * Encodes the content of a `string` to a `Uint8Array`.
8330
+ *
8331
+ * The encoding is picked based on settings.
8332
+ *
8333
+ * @param content The content to decode as a `string`.
8334
+ * @param options Additional context for picking the encoding.
8335
+ * @returns A thenable that resolves to the encoded `Uint8Array`.
8336
+ */
8337
+ export function encode(content: string, options: {
8338
+ /**
8339
+ * The URI that represents the file if known. This information
8340
+ * is used to figure out the encoding related configuration
8341
+ * for the file if any.
8342
+ */
8343
+ readonly uri: Uri;
8344
+ }): Thenable<Uint8Array>;
8345
+
8141
8346
  }
8142
8347
 
8143
8348
  export interface WorkspaceTrustRequestButton {
@@ -18662,6 +18867,138 @@ export module '@theia/plugin' {
18662
18867
  toolMode?: LanguageModelChatToolMode;
18663
18868
  }
18664
18869
 
18870
+ /**
18871
+ * McpStdioServerDefinition represents an MCP server available by running
18872
+ * a local process and operating on its stdin and stdout streams. The process
18873
+ * will be spawned as a child process of the extension host and by default
18874
+ * will not run in a shell environment.
18875
+ */
18876
+ export class McpStdioServerDefinition {
18877
+ /**
18878
+ * The human-readable name of the server.
18879
+ */
18880
+ readonly label: string;
18881
+
18882
+ /**
18883
+ * The working directory used to start the server.
18884
+ */
18885
+ cwd?: Uri;
18886
+
18887
+ /**
18888
+ * The command used to start the server. Node.js-based servers may use
18889
+ * `process.execPath` to use the editor's version of Node.js to run the script.
18890
+ */
18891
+ command: string;
18892
+
18893
+ /**
18894
+ * Additional command-line arguments passed to the server.
18895
+ */
18896
+ args: string[];
18897
+
18898
+ /**
18899
+ * Optional additional environment information for the server. Variables
18900
+ * in this environment will overwrite or remove (if null) the default
18901
+ * environment variables of the editor's extension host.
18902
+ */
18903
+ env: Record<string, string | number | null>;
18904
+
18905
+ /**
18906
+ * Optional version identification for the server. If this changes, the
18907
+ * editor will indicate that tools have changed and prompt to refresh them.
18908
+ */
18909
+ version?: string;
18910
+
18911
+ /**
18912
+ * @param label The human-readable name of the server.
18913
+ * @param command The command used to start the server.
18914
+ * @param args Additional command-line arguments passed to the server.
18915
+ * @param env Optional additional environment information for the server.
18916
+ * @param version Optional version identification for the server.
18917
+ */
18918
+ constructor(label: string, command: string, args?: string[], env?: Record<string, string | number | null>, version?: string);
18919
+ }
18920
+
18921
+ /**
18922
+ * McpHttpServerDefinition represents an MCP server available using the
18923
+ * Streamable HTTP transport.
18924
+ */
18925
+ export class McpHttpServerDefinition {
18926
+ /**
18927
+ * The human-readable name of the server.
18928
+ */
18929
+ readonly label: string;
18930
+
18931
+ /**
18932
+ * The URI of the server. The editor will make a POST request to this URI
18933
+ * to begin each session.
18934
+ */
18935
+ uri: Uri;
18936
+
18937
+ /**
18938
+ * Optional additional heads included with each request to the server.
18939
+ */
18940
+ headers: Record<string, string>;
18941
+
18942
+ /**
18943
+ * Optional version identification for the server. If this changes, the
18944
+ * editor will indicate that tools have changed and prompt to refresh them.
18945
+ */
18946
+ version?: string;
18947
+
18948
+ /**
18949
+ * @param label The human-readable name of the server.
18950
+ * @param uri The URI of the server.
18951
+ * @param headers Optional additional heads included with each request to the server.
18952
+ */
18953
+ constructor(label: string, uri: Uri, headers?: Record<string, string>, version?: string);
18954
+ }
18955
+
18956
+ /**
18957
+ * Definitions that describe different types of Model Context Protocol servers,
18958
+ * which can be returned from the {@link McpServerDefinitionProvider}.
18959
+ */
18960
+ export type McpServerDefinition = McpStdioServerDefinition | McpHttpServerDefinition;
18961
+
18962
+ /**
18963
+ * A type that can provide Model Context Protocol server definitions. This
18964
+ * should be registered using {@link lm.registerMcpServerDefinitionProvider}
18965
+ * during extension activation.
18966
+ */
18967
+ export interface McpServerDefinitionProvider<T extends McpServerDefinition = McpServerDefinition> {
18968
+ /**
18969
+ * Optional event fired to signal that the set of available servers has changed.
18970
+ */
18971
+ readonly onDidChangeMcpServerDefinitions?: Event<void>;
18972
+
18973
+ /**
18974
+ * Provides available MCP servers. The editor will call this method eagerly
18975
+ * to ensure the availability of servers for the language model, and so
18976
+ * extensions should not take actions which would require user
18977
+ * interaction, such as authentication.
18978
+ *
18979
+ * @param token A cancellation token.
18980
+ * @returns An array of MCP available MCP servers
18981
+ */
18982
+ provideMcpServerDefinitions(token: CancellationToken): ProviderResult<T[]>;
18983
+
18984
+ /**
18985
+ * This function will be called when the editor needs to start a MCP server.
18986
+ * At this point, the extension may take any actions which may require user
18987
+ * interaction, such as authentication. Any non-`readonly` property of the
18988
+ * server may be modified, and the extension should return the resolved server.
18989
+ *
18990
+ * The extension may return undefined to indicate that the server
18991
+ * should not be started, or throw an error. If there is a pending tool
18992
+ * call, the editor will cancel it and return an error message to the
18993
+ * language model.
18994
+ *
18995
+ * @param server The MCP server to resolve
18996
+ * @param token A cancellation token.
18997
+ * @returns The resolved server or thenable that resolves to such. This may
18998
+ * be the given `server` definition with non-readonly properties filled in.
18999
+ */
19000
+ resolveMcpServerDefinition?(server: T, token: CancellationToken): ProviderResult<T>;
19001
+ }
18665
19002
  /**
18666
19003
  * Namespace for language model related functionality.
18667
19004
  */
@@ -18745,6 +19082,34 @@ export module '@theia/plugin' {
18745
19082
  * @stubbed
18746
19083
  */
18747
19084
  export function invokeTool(name: string, options: LanguageModelToolInvocationOptions<object>, token?: CancellationToken): Thenable<LanguageModelToolResult>;
19085
+
19086
+ /**
19087
+ * Registers a provider that publishes Model Context Protocol servers for the editor to
19088
+ * consume. This allows MCP servers to be dynamically provided to the editor in
19089
+ * addition to those the user creates in their configuration files.
19090
+ *
19091
+ * Before calling this method, extensions must register the `contributes.mcpServerDefinitionProviders`
19092
+ * extension point with the corresponding {@link id}, for example:
19093
+ *
19094
+ * ```js
19095
+ * "contributes": {
19096
+ * "mcpServerDefinitionProviders": [
19097
+ * {
19098
+ * "id": "cool-cloud-registry.mcp-servers",
19099
+ * "label": "Cool Cloud Registry",
19100
+ * }
19101
+ * ]
19102
+ * }
19103
+ * ```
19104
+ *
19105
+ * When a new McpServerDefinitionProvider is available, the editor will present a 'refresh'
19106
+ * action to the user to discover new servers. To enable this flow, extensions should
19107
+ * call `registerMcpServerDefinitionProvider` during activation.
19108
+ * @param id The ID of the provider, which is unique to the extension.
19109
+ * @param provider The provider to register
19110
+ * @returns A disposable that unregisters the provider when disposed.
19111
+ */
19112
+ export function registerMcpServerDefinitionProvider(id: string, provider: McpServerDefinitionProvider): Disposable;
18748
19113
  }
18749
19114
 
18750
19115
  /**