@theia/plugin-ext 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.
- package/lib/common/lm-protocol.d.ts +103 -0
- package/lib/common/lm-protocol.d.ts.map +1 -0
- package/lib/common/lm-protocol.js +21 -0
- package/lib/common/lm-protocol.js.map +1 -0
- package/lib/common/plugin-api-rpc.d.ts +22 -1
- package/lib/common/plugin-api-rpc.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc.js +4 -2
- package/lib/common/plugin-api-rpc.js.map +1 -1
- package/lib/common/plugin-protocol.d.ts +6 -0
- package/lib/common/plugin-protocol.d.ts.map +1 -1
- package/lib/common/plugin-protocol.js.map +1 -1
- package/lib/hosted/browser/worker/worker-plugin-module.d.ts.map +1 -1
- package/lib/hosted/browser/worker/worker-plugin-module.js +2 -0
- package/lib/hosted/browser/worker/worker-plugin-module.js.map +1 -1
- package/lib/hosted/node/plugin-host-module.d.ts.map +1 -1
- package/lib/hosted/node/plugin-host-module.js +4 -0
- package/lib/hosted/node/plugin-host-module.js.map +1 -1
- package/lib/main/browser/comments/comment-thread-widget.d.ts +1 -2
- package/lib/main/browser/comments/comment-thread-widget.d.ts.map +1 -1
- package/lib/main/browser/comments/comment-thread-widget.js +8 -6
- package/lib/main/browser/comments/comment-thread-widget.js.map +1 -1
- package/lib/main/browser/documents-main.d.ts +3 -3
- package/lib/main/browser/documents-main.d.ts.map +1 -1
- package/lib/main/browser/documents-main.js +41 -28
- package/lib/main/browser/documents-main.js.map +1 -1
- package/lib/main/browser/editors-and-documents-main.d.ts +1 -0
- package/lib/main/browser/editors-and-documents-main.d.ts.map +1 -1
- package/lib/main/browser/editors-and-documents-main.js +4 -1
- package/lib/main/browser/editors-and-documents-main.js.map +1 -1
- package/lib/main/browser/lm-main.d.ts +17 -0
- package/lib/main/browser/lm-main.d.ts.map +1 -0
- package/lib/main/browser/lm-main.js +119 -0
- package/lib/main/browser/lm-main.js.map +1 -0
- package/lib/main/browser/main-context.d.ts.map +1 -1
- package/lib/main/browser/main-context.js +4 -3
- package/lib/main/browser/main-context.js.map +1 -1
- package/lib/main/browser/text-editor-model-service.d.ts +9 -2
- package/lib/main/browser/text-editor-model-service.d.ts.map +1 -1
- package/lib/main/browser/text-editor-model-service.js +10 -0
- package/lib/main/browser/text-editor-model-service.js.map +1 -1
- package/lib/main/browser/view/tree-view-widget.d.ts.map +1 -1
- package/lib/main/browser/view/tree-view-widget.js +4 -3
- package/lib/main/browser/view/tree-view-widget.js.map +1 -1
- package/lib/main/browser/workspace-main.d.ts +20 -0
- package/lib/main/browser/workspace-main.d.ts.map +1 -1
- package/lib/main/browser/workspace-main.js +54 -15
- package/lib/main/browser/workspace-main.js.map +1 -1
- package/lib/plugin/document-data.d.ts +3 -1
- package/lib/plugin/document-data.d.ts.map +1 -1
- package/lib/plugin/document-data.js +7 -1
- package/lib/plugin/document-data.js.map +1 -1
- package/lib/plugin/documents.d.ts +7 -1
- package/lib/plugin/documents.d.ts.map +1 -1
- package/lib/plugin/documents.js +21 -3
- package/lib/plugin/documents.js.map +1 -1
- package/lib/plugin/editors-and-documents.d.ts.map +1 -1
- package/lib/plugin/editors-and-documents.js +1 -1
- package/lib/plugin/editors-and-documents.js.map +1 -1
- package/lib/plugin/lm-ext.d.ts +52 -0
- package/lib/plugin/lm-ext.d.ts.map +1 -0
- package/lib/plugin/lm-ext.js +131 -0
- package/lib/plugin/lm-ext.js.map +1 -0
- package/lib/plugin/notebook/notebook-document.d.ts.map +1 -1
- package/lib/plugin/notebook/notebook-document.js +2 -1
- package/lib/plugin/notebook/notebook-document.js.map +1 -1
- package/lib/plugin/plugin-context.d.ts.map +1 -1
- package/lib/plugin/plugin-context.js +34 -12
- package/lib/plugin/plugin-context.js.map +1 -1
- package/lib/plugin/types-impl.d.ts +79 -0
- package/lib/plugin/types-impl.d.ts.map +1 -1
- package/lib/plugin/types-impl.js +43 -1
- package/lib/plugin/types-impl.js.map +1 -1
- package/lib/plugin/workspace.d.ts +11 -0
- package/lib/plugin/workspace.d.ts.map +1 -1
- package/lib/plugin/workspace.js +33 -0
- package/lib/plugin/workspace.js.map +1 -1
- package/package.json +30 -29
- package/src/common/lm-protocol.ts +137 -0
- package/src/common/plugin-api-rpc.ts +12 -4
- package/src/common/plugin-protocol.ts +7 -0
- package/src/hosted/browser/worker/worker-plugin-module.ts +2 -0
- package/src/hosted/node/plugin-host-module.ts +4 -0
- package/src/main/browser/comments/comment-thread-widget.tsx +6 -7
- package/src/main/browser/documents-main.ts +49 -39
- package/src/main/browser/editors-and-documents-main.ts +5 -1
- package/src/main/browser/lm-main.ts +136 -0
- package/src/main/browser/main-context.ts +5 -3
- package/src/main/browser/text-editor-model-service.ts +14 -2
- package/src/main/browser/view/tree-view-widget.tsx +4 -3
- package/src/main/browser/workspace-main.ts +66 -1
- package/src/plugin/document-data.ts +8 -1
- package/src/plugin/documents.ts +22 -5
- package/src/plugin/editors-and-documents.ts +2 -1
- package/src/plugin/lm-ext.ts +158 -0
- package/src/plugin/notebook/notebook-document.ts +2 -1
- package/src/plugin/plugin-context.ts +41 -16
- package/src/plugin/types-impl.ts +104 -0
- package/src/plugin/workspace.ts +39 -1
|
@@ -238,7 +238,9 @@ import {
|
|
|
238
238
|
DebugVisualization,
|
|
239
239
|
TerminalShellExecutionCommandLineConfidence,
|
|
240
240
|
TerminalCompletionItemKind,
|
|
241
|
-
TerminalCompletionList
|
|
241
|
+
TerminalCompletionList,
|
|
242
|
+
McpHttpServerDefinition,
|
|
243
|
+
McpStdioServerDefinition
|
|
242
244
|
} from './types-impl';
|
|
243
245
|
import { AuthenticationExtImpl } from './authentication-ext';
|
|
244
246
|
import { SymbolKind } from '../common/plugin-api-rpc-model';
|
|
@@ -287,6 +289,7 @@ import { NotebookEditorsExtImpl } from './notebook/notebook-editors';
|
|
|
287
289
|
import { TestingExtImpl } from './tests';
|
|
288
290
|
import { UriExtImpl } from './uri-ext';
|
|
289
291
|
import { PluginLogger } from './logger';
|
|
292
|
+
import { LmExtImpl } from './lm-ext';
|
|
290
293
|
|
|
291
294
|
export function createAPIObject<T extends Object>(rawObject: T): T {
|
|
292
295
|
return new Proxy(rawObject, {
|
|
@@ -351,6 +354,7 @@ export function createAPIFactory(
|
|
|
351
354
|
const telemetryExt = rpc.set(MAIN_RPC_CONTEXT.TELEMETRY_EXT, new TelemetryExtImpl());
|
|
352
355
|
const testingExt = rpc.set(MAIN_RPC_CONTEXT.TESTING_EXT, new TestingExtImpl(rpc, commandRegistry));
|
|
353
356
|
const uriExt = rpc.set(MAIN_RPC_CONTEXT.URI_EXT, new UriExtImpl(rpc));
|
|
357
|
+
const lmExt = rpc.set(MAIN_RPC_CONTEXT.MCP_SERVER_DEFINITION_REGISTRY_EXT, new LmExtImpl(rpc));
|
|
354
358
|
rpc.set(MAIN_RPC_CONTEXT.DEBUG_EXT, debugExt);
|
|
355
359
|
|
|
356
360
|
const commandLogger = new PluginLogger(rpc, 'commands-plugin');
|
|
@@ -781,24 +785,37 @@ export function createAPIFactory(
|
|
|
781
785
|
onDidChangeConfiguration(listener, thisArgs?, disposables?): theia.Disposable {
|
|
782
786
|
return preferenceRegistryExt.onDidChangeConfiguration(listener, thisArgs, disposables);
|
|
783
787
|
},
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
788
|
+
decode(content: Uint8Array, options?: { uri?: theia.Uri; encoding?: string }) {
|
|
789
|
+
return workspaceExt.decode(content, options);
|
|
790
|
+
},
|
|
791
|
+
encode(content: string, options?: { uri?: theia.Uri; encoding?: string }) {
|
|
792
|
+
return workspaceExt.encode(content, options);
|
|
793
|
+
},
|
|
794
|
+
async openTextDocument(
|
|
795
|
+
uriOrPathOrOptions?: theia.Uri | string | { language?: string; content?: string; encoding?: string },
|
|
796
|
+
options?: { readonly encoding?: string }
|
|
797
|
+
): Promise<theia.TextDocument | undefined> {
|
|
787
798
|
let uri: URI;
|
|
788
|
-
|
|
789
|
-
uri = URI.file(uriOrFileNameOrOptions);
|
|
790
|
-
|
|
791
|
-
} else if (uriOrFileNameOrOptions instanceof URI) {
|
|
792
|
-
uri = uriOrFileNameOrOptions;
|
|
793
|
-
|
|
794
|
-
} else if (!options || typeof options === 'object') {
|
|
795
|
-
uri = await documents.createDocumentData(options);
|
|
799
|
+
let documentOptions: { language?: string; content?: string; encoding?: string } | undefined;
|
|
796
800
|
|
|
801
|
+
if (typeof uriOrPathOrOptions === 'string') {
|
|
802
|
+
// It's a file path
|
|
803
|
+
uri = URI.file(uriOrPathOrOptions);
|
|
804
|
+
documentOptions = options;
|
|
805
|
+
} else if (URI.isUri(uriOrPathOrOptions)) {
|
|
806
|
+
// It's a URI
|
|
807
|
+
uri = uriOrPathOrOptions;
|
|
808
|
+
documentOptions = options;
|
|
809
|
+
} else if (!uriOrPathOrOptions || typeof uriOrPathOrOptions === 'object') {
|
|
810
|
+
// It's options for creating a new document
|
|
811
|
+
documentOptions = uriOrPathOrOptions as { language?: string; content?: string; encoding?: string };
|
|
812
|
+
uri = await documents.createDocumentData(documentOptions);
|
|
797
813
|
} else {
|
|
798
|
-
return Promise.reject(new Error('illegal argument -
|
|
814
|
+
return Promise.reject(new Error('illegal argument - uriOrPathOrOptions'));
|
|
799
815
|
}
|
|
800
816
|
|
|
801
|
-
|
|
817
|
+
// If we have options with encoding from any source, we need to pass them to openDocument
|
|
818
|
+
const data = await documents.openDocument(uri, documentOptions);
|
|
802
819
|
return data && data.document;
|
|
803
820
|
},
|
|
804
821
|
async openNotebookDocument(uriOrType: theia.Uri | string, content?: NotebookData): Promise<theia.NotebookDocument | undefined> {
|
|
@@ -1342,6 +1359,9 @@ export function createAPIFactory(
|
|
|
1342
1359
|
}
|
|
1343
1360
|
};
|
|
1344
1361
|
|
|
1362
|
+
const mcpContributions = plugin.rawModel.contributes && plugin.rawModel.contributes.mcpServerDefinitionProviders || [];
|
|
1363
|
+
lmExt.registerMcpContributions(mcpContributions);
|
|
1364
|
+
|
|
1345
1365
|
const lm: typeof theia.lm = {
|
|
1346
1366
|
/** @stubbed LanguageModelChat */
|
|
1347
1367
|
selectChatModels(selector?: theia.LanguageModelChatSelector): Thenable<theia.LanguageModelChat[]> {
|
|
@@ -1358,7 +1378,10 @@ export function createAPIFactory(
|
|
|
1358
1378
|
return Disposable.NULL;
|
|
1359
1379
|
},
|
|
1360
1380
|
/** @stubbed LanguageModelTool */
|
|
1361
|
-
tools: []
|
|
1381
|
+
tools: [],
|
|
1382
|
+
registerMcpServerDefinitionProvider(id: string, provider: any): theia.Disposable {
|
|
1383
|
+
return lmExt.registerMcpServerDefinitionProvider(id, provider);
|
|
1384
|
+
}
|
|
1362
1385
|
};
|
|
1363
1386
|
|
|
1364
1387
|
return <typeof theia>{
|
|
@@ -1589,7 +1612,9 @@ export function createAPIFactory(
|
|
|
1589
1612
|
DebugVisualization,
|
|
1590
1613
|
TerminalShellExecutionCommandLineConfidence,
|
|
1591
1614
|
TerminalCompletionItemKind,
|
|
1592
|
-
TerminalCompletionList
|
|
1615
|
+
TerminalCompletionList,
|
|
1616
|
+
McpHttpServerDefinition,
|
|
1617
|
+
McpStdioServerDefinition
|
|
1593
1618
|
};
|
|
1594
1619
|
};
|
|
1595
1620
|
}
|
package/src/plugin/types-impl.ts
CHANGED
|
@@ -4135,3 +4135,107 @@ export enum TerminalShellExecutionCommandLineConfidence {
|
|
|
4135
4135
|
}
|
|
4136
4136
|
|
|
4137
4137
|
// #endregion
|
|
4138
|
+
|
|
4139
|
+
/**
|
|
4140
|
+
* McpStdioServerDefinition represents an MCP server available by running
|
|
4141
|
+
* a local process and operating on its stdin and stdout streams. The process
|
|
4142
|
+
* will be spawned as a child process of the extension host and by default
|
|
4143
|
+
* will not run in a shell environment.
|
|
4144
|
+
*/
|
|
4145
|
+
export class McpStdioServerDefinition {
|
|
4146
|
+
/**
|
|
4147
|
+
* The human-readable name of the server.
|
|
4148
|
+
*/
|
|
4149
|
+
readonly label: string;
|
|
4150
|
+
|
|
4151
|
+
/**
|
|
4152
|
+
* The working directory used to start the server.
|
|
4153
|
+
*/
|
|
4154
|
+
cwd?: URI;
|
|
4155
|
+
|
|
4156
|
+
/**
|
|
4157
|
+
* The command used to start the server. Node.js-based servers may use
|
|
4158
|
+
* `process.execPath` to use the editor's version of Node.js to run the script.
|
|
4159
|
+
*/
|
|
4160
|
+
command: string;
|
|
4161
|
+
|
|
4162
|
+
/**
|
|
4163
|
+
* Additional command-line arguments passed to the server.
|
|
4164
|
+
*/
|
|
4165
|
+
args?: string[];
|
|
4166
|
+
|
|
4167
|
+
/**
|
|
4168
|
+
* Optional additional environment information for the server. Variables
|
|
4169
|
+
* in this environment will overwrite or remove (if null) the default
|
|
4170
|
+
* environment variables of the editor's extension host.
|
|
4171
|
+
*/
|
|
4172
|
+
env?: Record<string, string | number | null>;
|
|
4173
|
+
|
|
4174
|
+
/**
|
|
4175
|
+
* Optional version identification for the server. If this changes, the
|
|
4176
|
+
* editor will indicate that tools have changed and prompt to refresh them.
|
|
4177
|
+
*/
|
|
4178
|
+
version?: string;
|
|
4179
|
+
|
|
4180
|
+
/**
|
|
4181
|
+
* @param label The human-readable name of the server.
|
|
4182
|
+
* @param command The command used to start the server.
|
|
4183
|
+
* @param args Additional command-line arguments passed to the server.
|
|
4184
|
+
* @param env Optional additional environment information for the server.
|
|
4185
|
+
* @param version Optional version identification for the server.
|
|
4186
|
+
*/
|
|
4187
|
+
constructor(label: string, command: string, args?: string[], env?: Record<string, string | number | null>, version?: string) {
|
|
4188
|
+
this.label = label;
|
|
4189
|
+
this.command = command;
|
|
4190
|
+
this.args = args;
|
|
4191
|
+
this.env = env;
|
|
4192
|
+
this.version = version;
|
|
4193
|
+
}
|
|
4194
|
+
}
|
|
4195
|
+
|
|
4196
|
+
/**
|
|
4197
|
+
* McpHttpServerDefinition represents an MCP server available using the
|
|
4198
|
+
* Streamable HTTP transport.
|
|
4199
|
+
*/
|
|
4200
|
+
export class McpHttpServerDefinition {
|
|
4201
|
+
/**
|
|
4202
|
+
* The human-readable name of the server.
|
|
4203
|
+
*/
|
|
4204
|
+
readonly label: string;
|
|
4205
|
+
|
|
4206
|
+
/**
|
|
4207
|
+
* The URI of the server. The editor will make a POST request to this URI
|
|
4208
|
+
* to begin each session.
|
|
4209
|
+
*/
|
|
4210
|
+
uri: URI;
|
|
4211
|
+
|
|
4212
|
+
/**
|
|
4213
|
+
* Optional additional heads included with each request to the server.
|
|
4214
|
+
*/
|
|
4215
|
+
headers?: Record<string, string>;
|
|
4216
|
+
|
|
4217
|
+
/**
|
|
4218
|
+
* Optional version identification for the server. If this changes, the
|
|
4219
|
+
* editor will indicate that tools have changed and prompt to refresh them.
|
|
4220
|
+
*/
|
|
4221
|
+
version?: string;
|
|
4222
|
+
|
|
4223
|
+
/**
|
|
4224
|
+
* @param label The human-readable name of the server.
|
|
4225
|
+
* @param uri The URI of the server.
|
|
4226
|
+
* @param headers Optional additional heads included with each request to the server.
|
|
4227
|
+
*/
|
|
4228
|
+
constructor(label: string, uri: URI, headers?: Record<string, string>, version?: string) {
|
|
4229
|
+
this.label = label;
|
|
4230
|
+
this.uri = uri;
|
|
4231
|
+
this.headers = headers;
|
|
4232
|
+
this.version = version;
|
|
4233
|
+
};
|
|
4234
|
+
}
|
|
4235
|
+
|
|
4236
|
+
/**
|
|
4237
|
+
* Definitions that describe different types of Model Context Protocol servers,
|
|
4238
|
+
* which can be returned from the {@link McpServerDefinitionProvider}.
|
|
4239
|
+
*/
|
|
4240
|
+
export type McpServerDefinition = McpStdioServerDefinition | McpHttpServerDefinition;
|
|
4241
|
+
|
package/src/plugin/workspace.ts
CHANGED
|
@@ -38,13 +38,16 @@ import { EditorsAndDocumentsExtImpl } from './editors-and-documents';
|
|
|
38
38
|
import { Disposable, URI } from './types-impl';
|
|
39
39
|
import { normalize } from '@theia/core/lib/common/paths';
|
|
40
40
|
import { relative } from '../common/paths-util';
|
|
41
|
-
import { Schemes } from '../common/uri-components';
|
|
41
|
+
import { Schemes, UriComponents } from '../common/uri-components';
|
|
42
42
|
import { toWorkspaceFolder } from './type-converters';
|
|
43
43
|
import { MessageRegistryExt } from './message-registry';
|
|
44
44
|
import * as Converter from './type-converters';
|
|
45
45
|
import { FileStat } from '@theia/filesystem/lib/common/files';
|
|
46
46
|
import { isUndefinedOrNull, isUndefined } from '../common/types';
|
|
47
47
|
import { PluginLogger } from './logger';
|
|
48
|
+
import { consumeStream } from '@theia/core/lib/common/stream';
|
|
49
|
+
import { EncodingService } from '@theia/core/lib/common/encoding-service';
|
|
50
|
+
import { BinaryBuffer, BinaryBufferReadableStream } from '@theia/core/lib/common/buffer';
|
|
48
51
|
|
|
49
52
|
@injectable()
|
|
50
53
|
export class WorkspaceExtImpl implements WorkspaceExt {
|
|
@@ -61,6 +64,9 @@ export class WorkspaceExtImpl implements WorkspaceExt {
|
|
|
61
64
|
private proxy: WorkspaceMain;
|
|
62
65
|
private logger: PluginLogger;
|
|
63
66
|
|
|
67
|
+
@inject(EncodingService)
|
|
68
|
+
protected encodingService: EncodingService;
|
|
69
|
+
|
|
64
70
|
private workspaceFoldersChangedEmitter = new Emitter<theia.WorkspaceFoldersChangeEvent>();
|
|
65
71
|
public readonly onDidChangeWorkspaceFolders: Event<theia.WorkspaceFoldersChangeEvent> = this.workspaceFoldersChangedEmitter.event;
|
|
66
72
|
|
|
@@ -508,4 +514,36 @@ export class WorkspaceExtImpl implements WorkspaceExt {
|
|
|
508
514
|
$registerEditSessionIdentityProvider(scheme: string, provider: theia.EditSessionIdentityProvider): theia.Disposable {
|
|
509
515
|
return Disposable.NULL;
|
|
510
516
|
}
|
|
517
|
+
|
|
518
|
+
async decode(content: Uint8Array, args?: { uri?: theia.Uri; encoding?: string }): Promise<string> {
|
|
519
|
+
const [uri, opts] = this.asEncodeDecodeParameters(args);
|
|
520
|
+
const { preferredEncoding, guessEncoding } = await this.proxy.$resolveDecoding(uri, opts);
|
|
521
|
+
const decodeStreamOptions = {
|
|
522
|
+
guessEncoding,
|
|
523
|
+
overwriteEncoding: (detectedEncoding: string | undefined) => {
|
|
524
|
+
if (detectedEncoding === null || detectedEncoding === preferredEncoding) {
|
|
525
|
+
return Promise.resolve(preferredEncoding);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
return this.proxy.$getValidEncoding(uri, detectedEncoding, opts);
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
const stream = (await this.encodingService.decodeStream(BinaryBufferReadableStream.fromBuffer(BinaryBuffer.wrap(content)), decodeStreamOptions)).stream;
|
|
532
|
+
return consumeStream(stream, s => s.join(''));
|
|
533
|
+
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
async encode(content: string, args?: { uri?: theia.Uri; encoding?: string }): Promise<Uint8Array> {
|
|
537
|
+
const [uri, options] = this.asEncodeDecodeParameters(args);
|
|
538
|
+
const { encoding, hasBOM } = await this.proxy.$resolveEncoding(uri, options);
|
|
539
|
+
const buffer = this.encodingService.encode(content, { encoding, hasBOM });
|
|
540
|
+
return buffer.buffer;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
private asEncodeDecodeParameters(opts?: { uri?: theia.Uri; encoding?: string }): [UriComponents | undefined, { encoding: string } | undefined] {
|
|
544
|
+
const uri = Converter.isUriComponents(opts?.uri) ? opts.uri : undefined;
|
|
545
|
+
const encoding = typeof opts?.encoding === 'string' ? opts.encoding : undefined;
|
|
546
|
+
|
|
547
|
+
return [uri, encoding ? { encoding } : undefined];
|
|
548
|
+
}
|
|
511
549
|
}
|