@theia/plugin 1.55.1 → 1.57.0-next.22
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/README.md +18 -8
- package/package.json +3 -3
- package/src/theia.d.ts +505 -62
- package/src/theia.proposed.mappedEditsProvider.d.ts +2 -1
package/README.md
CHANGED
|
@@ -192,6 +192,7 @@ Simple example that show a status bar message with statusBarItem:
|
|
|
192
192
|
item.text = 'test status bar item';
|
|
193
193
|
item.show();
|
|
194
194
|
```
|
|
195
|
+
|
|
195
196
|
#### Output channel API
|
|
196
197
|
|
|
197
198
|
It is possible to show a container for readonly textual information:
|
|
@@ -241,9 +242,10 @@ const terminal = theia.window.createTerminal("Bash terminal", "/bin/bash", ["-l"
|
|
|
241
242
|
```
|
|
242
243
|
|
|
243
244
|
Where are:
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
245
|
+
|
|
246
|
+
- first argument - terminal's name.
|
|
247
|
+
- second argument - path to the executable shell.
|
|
248
|
+
- third argument - arguments to configure executable shell.
|
|
247
249
|
|
|
248
250
|
You can create terminal with specific options:
|
|
249
251
|
|
|
@@ -258,10 +260,11 @@ const options: theia.TerminalOptions {
|
|
|
258
260
|
```
|
|
259
261
|
|
|
260
262
|
Where are:
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
- "
|
|
264
|
-
|
|
263
|
+
|
|
264
|
+
- "shellPath" - path to the executable shell, for example "/bin/bash", "bash", "sh" or so on.
|
|
265
|
+
- "shellArgs" - shell command arguments, for example without login: "-l". If you defined shell command "/bin/bash" and set up shell arguments "-l" than will be created terminal process with command "/bin/bash -l". And client side will connect to stdin/stdout of this process to interaction with user.
|
|
266
|
+
- "cwd" - current working directory;
|
|
267
|
+
- "env"- environment variables for terminal process, for example TERM - identifier terminal window capabilities.
|
|
265
268
|
|
|
266
269
|
Function to create new terminal with defined theia.TerminalOptions described above:
|
|
267
270
|
|
|
@@ -288,6 +291,7 @@ terminal.sendText("Hello, Theia!", false);
|
|
|
288
291
|
```
|
|
289
292
|
|
|
290
293
|
Where are:
|
|
294
|
+
|
|
291
295
|
- first argument - text content.
|
|
292
296
|
- second argument - in case true, terminal will apply new line after the text, otherwise will send only the text.
|
|
293
297
|
|
|
@@ -323,6 +327,7 @@ terminal.processId.then(id => {
|
|
|
323
327
|
Preference API allows one to read or update User's and Workspace's preferences.
|
|
324
328
|
|
|
325
329
|
To get preferences:
|
|
330
|
+
|
|
326
331
|
```typescript
|
|
327
332
|
// editor preferences
|
|
328
333
|
const preferences = theia.workspace.getConfiguration('editor');
|
|
@@ -332,6 +337,7 @@ const fontSize = preferences.get('tabSize');
|
|
|
332
337
|
```
|
|
333
338
|
|
|
334
339
|
To change preference:
|
|
340
|
+
|
|
335
341
|
```typescript
|
|
336
342
|
preferences.onDidChangeConfiguration(e => {
|
|
337
343
|
if (e.affectsConfiguration('editor.tabSize')) {
|
|
@@ -353,6 +359,7 @@ const diagnostics = theia.languages.getDiagnostics(uriToResource)
|
|
|
353
359
|
```
|
|
354
360
|
|
|
355
361
|
To get all diagnostics use:
|
|
362
|
+
|
|
356
363
|
```typescript
|
|
357
364
|
const diagnostics = theia.languages.getDiagnostics()
|
|
358
365
|
```
|
|
@@ -424,6 +431,7 @@ diagnosticsCollection.forEach((uri, diagnostics) => {
|
|
|
424
431
|
#### Signature help
|
|
425
432
|
|
|
426
433
|
To provide signature help form plugin it is required to register provider. For registration 3 items are needed:
|
|
434
|
+
|
|
427
435
|
- Documents selector to describe for which files it should be applied
|
|
428
436
|
- Handler which will do the work
|
|
429
437
|
- Trigger characters after typing of which the handler should be invoked. Often symbols `(` and `,` are used.
|
|
@@ -474,6 +482,7 @@ Example of signature information:
|
|
|
474
482
|
```
|
|
475
483
|
|
|
476
484
|
Note, that:
|
|
485
|
+
|
|
477
486
|
- `activeSignature` and `activeParameter` are zero based.
|
|
478
487
|
- label is usually full method signature.
|
|
479
488
|
- for documentation fields markdown partially supported (Tags aren't supported).
|
|
@@ -762,5 +771,6 @@ function provideRanges(document: theia.TextDocument): theia.ProviderResult<theia
|
|
|
762
771
|
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
763
772
|
|
|
764
773
|
## Trademark
|
|
774
|
+
|
|
765
775
|
"Theia" is a trademark of the Eclipse Foundation
|
|
766
|
-
https://www.eclipse.org/theia
|
|
776
|
+
<https://www.eclipse.org/theia>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.57.0-next.22+35d458a96",
|
|
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.
|
|
30
|
+
"@theia/ext-scripts": "1.56.0"
|
|
31
31
|
},
|
|
32
32
|
"nyc": {
|
|
33
33
|
"extends": "../../configs/nyc.json"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "35d458a961212de264d9579305d984147fa55618"
|
|
36
36
|
}
|
package/src/theia.d.ts
CHANGED
|
@@ -2163,7 +2163,7 @@ export module '@theia/plugin' {
|
|
|
2163
2163
|
/**
|
|
2164
2164
|
* The icon path or {@link ThemeIcon} for the QuickPickItem.
|
|
2165
2165
|
*/
|
|
2166
|
-
iconPath?:
|
|
2166
|
+
iconPath?: IconPath;
|
|
2167
2167
|
|
|
2168
2168
|
/**
|
|
2169
2169
|
* A human-readable string which is rendered less prominent in the same line. Supports rendering of
|
|
@@ -2696,6 +2696,11 @@ export module '@theia/plugin' {
|
|
|
2696
2696
|
* Using a theme color is preferred over a custom color as it gives theme authors and users the possibility to change the color.
|
|
2697
2697
|
*/
|
|
2698
2698
|
export class ThemeColor {
|
|
2699
|
+
/**
|
|
2700
|
+
* The id of this color.
|
|
2701
|
+
*/
|
|
2702
|
+
readonly id: string;
|
|
2703
|
+
|
|
2699
2704
|
/**
|
|
2700
2705
|
* Creates a reference to a theme color.
|
|
2701
2706
|
*/
|
|
@@ -2735,6 +2740,21 @@ export module '@theia/plugin' {
|
|
|
2735
2740
|
private constructor(id: string, color?: ThemeColor);
|
|
2736
2741
|
}
|
|
2737
2742
|
|
|
2743
|
+
/**
|
|
2744
|
+
* Represents an icon in the UI. This is either an uri, separate uris for the light- and dark-themes,
|
|
2745
|
+
* or a {@link ThemeIcon theme icon}.
|
|
2746
|
+
*/
|
|
2747
|
+
export type IconPath = Uri | {
|
|
2748
|
+
/**
|
|
2749
|
+
* The icon path for the light theme.
|
|
2750
|
+
*/
|
|
2751
|
+
light: Uri;
|
|
2752
|
+
/**
|
|
2753
|
+
* The icon path for the dark theme.
|
|
2754
|
+
*/
|
|
2755
|
+
dark: Uri;
|
|
2756
|
+
} | ThemeIcon;
|
|
2757
|
+
|
|
2738
2758
|
/**
|
|
2739
2759
|
* Represents the state of a window.
|
|
2740
2760
|
*/
|
|
@@ -3515,7 +3535,7 @@ export module '@theia/plugin' {
|
|
|
3515
3535
|
/**
|
|
3516
3536
|
* The icon path or {@link ThemeIcon} for the terminal.
|
|
3517
3537
|
*/
|
|
3518
|
-
iconPath?:
|
|
3538
|
+
iconPath?: IconPath;
|
|
3519
3539
|
|
|
3520
3540
|
/**
|
|
3521
3541
|
* The icon {@link ThemeColor} for the terminal.
|
|
@@ -3635,7 +3655,7 @@ export module '@theia/plugin' {
|
|
|
3635
3655
|
/**
|
|
3636
3656
|
* The icon path or {@link ThemeIcon} for the terminal.
|
|
3637
3657
|
*/
|
|
3638
|
-
iconPath?:
|
|
3658
|
+
iconPath?: IconPath;
|
|
3639
3659
|
|
|
3640
3660
|
/**
|
|
3641
3661
|
* The icon {@link ThemeColor} for the terminal.
|
|
@@ -6222,7 +6242,7 @@ export module '@theia/plugin' {
|
|
|
6222
6242
|
/**
|
|
6223
6243
|
* Icon for the button.
|
|
6224
6244
|
*/
|
|
6225
|
-
readonly iconPath:
|
|
6245
|
+
readonly iconPath: IconPath;
|
|
6226
6246
|
|
|
6227
6247
|
/**
|
|
6228
6248
|
* An optional tooltip.
|
|
@@ -6836,7 +6856,7 @@ export module '@theia/plugin' {
|
|
|
6836
6856
|
* When `falsy`, {@link ThemeIcon.Folder Folder Theme Icon} is assigned, if item is collapsible otherwise {@link ThemeIcon.File File Theme Icon}.
|
|
6837
6857
|
* When a {@link ThemeIcon ThemeIcon} is specified, icon is derived from the current file icon theme for the specified theme icon using {@link TreeItem.resourceUri resourceUri} (if provided).
|
|
6838
6858
|
*/
|
|
6839
|
-
iconPath?: string |
|
|
6859
|
+
iconPath?: string | IconPath;
|
|
6840
6860
|
|
|
6841
6861
|
/**
|
|
6842
6862
|
* A human readable string which is rendered less prominent.
|
|
@@ -10607,7 +10627,7 @@ export module '@theia/plugin' {
|
|
|
10607
10627
|
/**
|
|
10608
10628
|
* The icon path or {@link ThemeIcon ThemeIcon} for the edit.
|
|
10609
10629
|
*/
|
|
10610
|
-
iconPath?:
|
|
10630
|
+
iconPath?: IconPath;
|
|
10611
10631
|
}
|
|
10612
10632
|
|
|
10613
10633
|
/**
|
|
@@ -17262,6 +17282,7 @@ export module '@theia/plugin' {
|
|
|
17262
17282
|
|
|
17263
17283
|
/**
|
|
17264
17284
|
* Represents a user request in chat history.
|
|
17285
|
+
* @stubbed
|
|
17265
17286
|
*/
|
|
17266
17287
|
export class ChatRequestTurn {
|
|
17267
17288
|
/**
|
|
@@ -17289,14 +17310,20 @@ export module '@theia/plugin' {
|
|
|
17289
17310
|
*/
|
|
17290
17311
|
readonly references: ChatPromptReference[];
|
|
17291
17312
|
|
|
17313
|
+
/**
|
|
17314
|
+
* The list of tools were attached to this request.
|
|
17315
|
+
*/
|
|
17316
|
+
readonly toolReferences: readonly ChatLanguageModelToolReference[];
|
|
17317
|
+
|
|
17292
17318
|
/**
|
|
17293
17319
|
* @hidden
|
|
17294
17320
|
*/
|
|
17295
|
-
private constructor(prompt: string, command: string | undefined, references: ChatPromptReference[], participant: string);
|
|
17321
|
+
private constructor(prompt: string, command: string | undefined, references: ChatPromptReference[], participant: string, toolReferences: ChatLanguageModelToolReference[]);
|
|
17296
17322
|
}
|
|
17297
17323
|
|
|
17298
17324
|
/**
|
|
17299
17325
|
* Represents a chat participant's response in chat history.
|
|
17326
|
+
* @stubbed
|
|
17300
17327
|
*/
|
|
17301
17328
|
export class ChatResponseTurn {
|
|
17302
17329
|
/**
|
|
@@ -17327,6 +17354,7 @@ export module '@theia/plugin' {
|
|
|
17327
17354
|
|
|
17328
17355
|
/**
|
|
17329
17356
|
* Extra context passed to a participant.
|
|
17357
|
+
* @stubbed
|
|
17330
17358
|
*/
|
|
17331
17359
|
export interface ChatContext {
|
|
17332
17360
|
/**
|
|
@@ -17337,6 +17365,7 @@ export module '@theia/plugin' {
|
|
|
17337
17365
|
|
|
17338
17366
|
/**
|
|
17339
17367
|
* Represents an error result from a chat request.
|
|
17368
|
+
* @stubbed
|
|
17340
17369
|
*/
|
|
17341
17370
|
export interface ChatErrorDetails {
|
|
17342
17371
|
/**
|
|
@@ -17352,6 +17381,7 @@ export module '@theia/plugin' {
|
|
|
17352
17381
|
|
|
17353
17382
|
/**
|
|
17354
17383
|
* The result of a chat request.
|
|
17384
|
+
* @stubbed
|
|
17355
17385
|
*/
|
|
17356
17386
|
export interface ChatResult {
|
|
17357
17387
|
/**
|
|
@@ -17382,6 +17412,7 @@ export module '@theia/plugin' {
|
|
|
17382
17412
|
|
|
17383
17413
|
/**
|
|
17384
17414
|
* Represents user feedback for a result.
|
|
17415
|
+
* @stubbed
|
|
17385
17416
|
*/
|
|
17386
17417
|
export interface ChatResultFeedback {
|
|
17387
17418
|
/**
|
|
@@ -17398,6 +17429,7 @@ export module '@theia/plugin' {
|
|
|
17398
17429
|
|
|
17399
17430
|
/**
|
|
17400
17431
|
* A followup question suggested by the participant.
|
|
17432
|
+
* @stubbed
|
|
17401
17433
|
*/
|
|
17402
17434
|
export interface ChatFollowup {
|
|
17403
17435
|
/**
|
|
@@ -17424,11 +17456,13 @@ export module '@theia/plugin' {
|
|
|
17424
17456
|
|
|
17425
17457
|
/**
|
|
17426
17458
|
* 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.
|
|
17459
|
+
* @stubbed
|
|
17427
17460
|
*/
|
|
17428
17461
|
export interface ChatFollowupProvider {
|
|
17429
17462
|
/**
|
|
17430
17463
|
* Provide followups for the given result.
|
|
17431
17464
|
* @param result This object has the same properties as the result returned from the participant callback, including `metadata`, but is not the same instance.
|
|
17465
|
+
* @param context Extra context passed to a participant.
|
|
17432
17466
|
* @param token A cancellation token.
|
|
17433
17467
|
*/
|
|
17434
17468
|
provideFollowups(result: ChatResult, context: ChatContext, token: CancellationToken): ProviderResult<ChatFollowup[]>;
|
|
@@ -17436,12 +17470,14 @@ export module '@theia/plugin' {
|
|
|
17436
17470
|
|
|
17437
17471
|
/**
|
|
17438
17472
|
* A chat request handler is a callback that will be invoked when a request is made to a chat participant.
|
|
17473
|
+
* @stubbed
|
|
17439
17474
|
*/
|
|
17440
17475
|
export type ChatRequestHandler = (request: ChatRequest, context: ChatContext, response: ChatResponseStream, token: CancellationToken) => ProviderResult<ChatResult | void>;
|
|
17441
17476
|
|
|
17442
17477
|
/**
|
|
17443
17478
|
* 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
|
|
17444
17479
|
* responsible for providing a response to the user. A ChatParticipant is created using {@link chat.createChatParticipant}.
|
|
17480
|
+
* @stubbed
|
|
17445
17481
|
*/
|
|
17446
17482
|
export interface ChatParticipant {
|
|
17447
17483
|
/**
|
|
@@ -17452,16 +17488,7 @@ export module '@theia/plugin' {
|
|
|
17452
17488
|
/**
|
|
17453
17489
|
* An icon for the participant shown in UI.
|
|
17454
17490
|
*/
|
|
17455
|
-
iconPath?:
|
|
17456
|
-
/**
|
|
17457
|
-
* The icon path for the light theme.
|
|
17458
|
-
*/
|
|
17459
|
-
light: Uri;
|
|
17460
|
-
/**
|
|
17461
|
-
* The icon path for the dark theme.
|
|
17462
|
-
*/
|
|
17463
|
-
dark: Uri;
|
|
17464
|
-
} | ThemeIcon;
|
|
17491
|
+
iconPath?: IconPath;
|
|
17465
17492
|
|
|
17466
17493
|
/**
|
|
17467
17494
|
* The handler for requests to this participant.
|
|
@@ -17490,6 +17517,7 @@ export module '@theia/plugin' {
|
|
|
17490
17517
|
|
|
17491
17518
|
/**
|
|
17492
17519
|
* A reference to a value that the user added to their chat request.
|
|
17520
|
+
* @stubbed
|
|
17493
17521
|
*/
|
|
17494
17522
|
export interface ChatPromptReference {
|
|
17495
17523
|
/**
|
|
@@ -17518,6 +17546,7 @@ export module '@theia/plugin' {
|
|
|
17518
17546
|
|
|
17519
17547
|
/**
|
|
17520
17548
|
* A request to a chat participant.
|
|
17549
|
+
* @stubbed
|
|
17521
17550
|
*/
|
|
17522
17551
|
export interface ChatRequest {
|
|
17523
17552
|
/**
|
|
@@ -17545,12 +17574,35 @@ export module '@theia/plugin' {
|
|
|
17545
17574
|
* string-manipulation of the prompt.
|
|
17546
17575
|
*/
|
|
17547
17576
|
readonly references: readonly ChatPromptReference[];
|
|
17577
|
+
|
|
17578
|
+
/**
|
|
17579
|
+
* The list of tools that the user attached to their request.
|
|
17580
|
+
*
|
|
17581
|
+
* When a tool reference is present, the chat participant should make a chat request using
|
|
17582
|
+
* {@link LanguageModelChatToolMode.Required} to force the language model to generate input for the tool. Then, the
|
|
17583
|
+
* participant can use {@link lm.invokeTool} to use the tool attach the result to its request for the user's prompt. The
|
|
17584
|
+
* tool may contribute useful extra context for the user's request.
|
|
17585
|
+
*/
|
|
17586
|
+
readonly toolReferences: readonly ChatLanguageModelToolReference[];
|
|
17587
|
+
|
|
17588
|
+
/**
|
|
17589
|
+
* A token that can be passed to {@link lm.invokeTool} when invoking a tool inside the context of handling a chat request.
|
|
17590
|
+
* This associates the tool invocation to a chat session.
|
|
17591
|
+
*/
|
|
17592
|
+
readonly toolInvocationToken: ChatParticipantToolToken;
|
|
17593
|
+
|
|
17594
|
+
/**
|
|
17595
|
+
* This is the model that is currently selected in the UI. Extensions can use this or use {@link chat.selectChatModels} to
|
|
17596
|
+
* pick another model. Don't hold onto this past the lifetime of the request.
|
|
17597
|
+
*/
|
|
17598
|
+
readonly model: LanguageModelChat;
|
|
17548
17599
|
}
|
|
17549
17600
|
|
|
17550
17601
|
/**
|
|
17551
17602
|
* 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
|
|
17552
17603
|
* 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
|
|
17553
17604
|
* can instantiate a {@link ChatResponsePart} and use the generic {@link ChatResponseStream.push} method to return it.
|
|
17605
|
+
* @stubbed
|
|
17554
17606
|
*/
|
|
17555
17607
|
export interface ChatResponseStream {
|
|
17556
17608
|
/**
|
|
@@ -17567,7 +17619,7 @@ export module '@theia/plugin' {
|
|
|
17567
17619
|
* `push(new ChatResponseAnchorPart(value, title))`.
|
|
17568
17620
|
* An anchor is an inline reference to some type of resource.
|
|
17569
17621
|
*
|
|
17570
|
-
* @param value A uri
|
|
17622
|
+
* @param value A uri or location.
|
|
17571
17623
|
* @param title An optional title that is rendered with value.
|
|
17572
17624
|
*/
|
|
17573
17625
|
anchor(value: Uri | Location, title?: string): void;
|
|
@@ -17606,16 +17658,7 @@ export module '@theia/plugin' {
|
|
|
17606
17658
|
* @param value A uri or location
|
|
17607
17659
|
* @param iconPath Icon for the reference shown in UI
|
|
17608
17660
|
*/
|
|
17609
|
-
reference(value: Uri | Location, iconPath?:
|
|
17610
|
-
/**
|
|
17611
|
-
* The icon path for the light theme.
|
|
17612
|
-
*/
|
|
17613
|
-
light: Uri;
|
|
17614
|
-
/**
|
|
17615
|
-
* The icon path for the dark theme.
|
|
17616
|
-
*/
|
|
17617
|
-
dark: Uri;
|
|
17618
|
-
}): void;
|
|
17661
|
+
reference(value: Uri | Location, iconPath?: IconPath): void;
|
|
17619
17662
|
|
|
17620
17663
|
/**
|
|
17621
17664
|
* Pushes a part to this stream.
|
|
@@ -17627,6 +17670,7 @@ export module '@theia/plugin' {
|
|
|
17627
17670
|
|
|
17628
17671
|
/**
|
|
17629
17672
|
* Represents a part of a chat response that is formatted as Markdown.
|
|
17673
|
+
* @stubbed
|
|
17630
17674
|
*/
|
|
17631
17675
|
export class ChatResponseMarkdownPart {
|
|
17632
17676
|
/**
|
|
@@ -17644,6 +17688,7 @@ export module '@theia/plugin' {
|
|
|
17644
17688
|
|
|
17645
17689
|
/**
|
|
17646
17690
|
* Represents a file tree structure in a chat response.
|
|
17691
|
+
* @stubbed
|
|
17647
17692
|
*/
|
|
17648
17693
|
export interface ChatResponseFileTree {
|
|
17649
17694
|
/**
|
|
@@ -17659,6 +17704,7 @@ export module '@theia/plugin' {
|
|
|
17659
17704
|
|
|
17660
17705
|
/**
|
|
17661
17706
|
* Represents a part of a chat response that is a file tree.
|
|
17707
|
+
* @stubbed
|
|
17662
17708
|
*/
|
|
17663
17709
|
export class ChatResponseFileTreePart {
|
|
17664
17710
|
/**
|
|
@@ -17681,6 +17727,7 @@ export module '@theia/plugin' {
|
|
|
17681
17727
|
|
|
17682
17728
|
/**
|
|
17683
17729
|
* Represents a part of a chat response that is an anchor, that is rendered as a link to a target.
|
|
17730
|
+
* @stubbed
|
|
17684
17731
|
*/
|
|
17685
17732
|
export class ChatResponseAnchorPart {
|
|
17686
17733
|
/**
|
|
@@ -17703,6 +17750,7 @@ export module '@theia/plugin' {
|
|
|
17703
17750
|
|
|
17704
17751
|
/**
|
|
17705
17752
|
* Represents a part of a chat response that is a progress message.
|
|
17753
|
+
* @stubbed
|
|
17706
17754
|
*/
|
|
17707
17755
|
export class ChatResponseProgressPart {
|
|
17708
17756
|
/**
|
|
@@ -17719,6 +17767,7 @@ export module '@theia/plugin' {
|
|
|
17719
17767
|
|
|
17720
17768
|
/**
|
|
17721
17769
|
* Represents a part of a chat response that is a reference, rendered separately from the content.
|
|
17770
|
+
* @stubbed
|
|
17722
17771
|
*/
|
|
17723
17772
|
export class ChatResponseReferencePart {
|
|
17724
17773
|
/**
|
|
@@ -17729,36 +17778,19 @@ export module '@theia/plugin' {
|
|
|
17729
17778
|
/**
|
|
17730
17779
|
* The icon for the reference.
|
|
17731
17780
|
*/
|
|
17732
|
-
iconPath?:
|
|
17733
|
-
/**
|
|
17734
|
-
* The icon path for the light theme.
|
|
17735
|
-
*/
|
|
17736
|
-
light: Uri;
|
|
17737
|
-
/**
|
|
17738
|
-
* The icon path for the dark theme.
|
|
17739
|
-
*/
|
|
17740
|
-
dark: Uri;
|
|
17741
|
-
};
|
|
17781
|
+
iconPath?: IconPath;
|
|
17742
17782
|
|
|
17743
17783
|
/**
|
|
17744
17784
|
* Create a new ChatResponseReferencePart.
|
|
17745
17785
|
* @param value A uri or location
|
|
17746
17786
|
* @param iconPath Icon for the reference shown in UI
|
|
17747
17787
|
*/
|
|
17748
|
-
constructor(value: Uri | Location, iconPath?:
|
|
17749
|
-
/**
|
|
17750
|
-
* The icon path for the light theme.
|
|
17751
|
-
*/
|
|
17752
|
-
light: Uri;
|
|
17753
|
-
/**
|
|
17754
|
-
* The icon path for the dark theme.
|
|
17755
|
-
*/
|
|
17756
|
-
dark: Uri;
|
|
17757
|
-
});
|
|
17788
|
+
constructor(value: Uri | Location, iconPath?: IconPath);
|
|
17758
17789
|
}
|
|
17759
17790
|
|
|
17760
17791
|
/**
|
|
17761
17792
|
* Represents a part of a chat response that is a button that executes a command.
|
|
17793
|
+
* @stubbed
|
|
17762
17794
|
*/
|
|
17763
17795
|
export class ChatResponseCommandButtonPart {
|
|
17764
17796
|
/**
|
|
@@ -17813,6 +17845,7 @@ export module '@theia/plugin' {
|
|
|
17813
17845
|
|
|
17814
17846
|
/**
|
|
17815
17847
|
* Represents a message in a chat. Can assume different roles, like user or assistant.
|
|
17848
|
+
* @stubbed
|
|
17816
17849
|
*/
|
|
17817
17850
|
export class LanguageModelChatMessage {
|
|
17818
17851
|
|
|
@@ -17822,7 +17855,7 @@ export module '@theia/plugin' {
|
|
|
17822
17855
|
* @param content The content of the message.
|
|
17823
17856
|
* @param name The optional name of a user for the message.
|
|
17824
17857
|
*/
|
|
17825
|
-
static User(content: string, name?: string): LanguageModelChatMessage;
|
|
17858
|
+
static User(content: string | (LanguageModelTextPart | LanguageModelToolResultPart)[], name?: string): LanguageModelChatMessage;
|
|
17826
17859
|
|
|
17827
17860
|
/**
|
|
17828
17861
|
* Utility to create a new assistant message.
|
|
@@ -17830,7 +17863,7 @@ export module '@theia/plugin' {
|
|
|
17830
17863
|
* @param content The content of the message.
|
|
17831
17864
|
* @param name The optional name of a user for the message.
|
|
17832
17865
|
*/
|
|
17833
|
-
static Assistant(content: string, name?: string): LanguageModelChatMessage;
|
|
17866
|
+
static Assistant(content: string | (LanguageModelTextPart | LanguageModelToolCallPart)[], name?: string): LanguageModelChatMessage;
|
|
17834
17867
|
|
|
17835
17868
|
/**
|
|
17836
17869
|
* The role of this message.
|
|
@@ -17838,9 +17871,10 @@ export module '@theia/plugin' {
|
|
|
17838
17871
|
role: LanguageModelChatMessageRole;
|
|
17839
17872
|
|
|
17840
17873
|
/**
|
|
17841
|
-
*
|
|
17874
|
+
* A string or heterogeneous array of things that a message can contain as content. Some parts may be message-type
|
|
17875
|
+
* specific for some models.
|
|
17842
17876
|
*/
|
|
17843
|
-
content:
|
|
17877
|
+
content: (LanguageModelTextPart | LanguageModelToolResultPart | LanguageModelToolCallPart)[];
|
|
17844
17878
|
|
|
17845
17879
|
/**
|
|
17846
17880
|
* The optional name of a user for this message.
|
|
@@ -17854,31 +17888,40 @@ export module '@theia/plugin' {
|
|
|
17854
17888
|
* @param content The content of the message.
|
|
17855
17889
|
* @param name The optional name of a user for the message.
|
|
17856
17890
|
*/
|
|
17857
|
-
constructor(role: LanguageModelChatMessageRole, content: string, name?: string);
|
|
17891
|
+
constructor(role: LanguageModelChatMessageRole, content: string | (LanguageModelTextPart | LanguageModelToolResultPart | LanguageModelToolCallPart)[], name?: string);
|
|
17858
17892
|
}
|
|
17859
17893
|
|
|
17860
17894
|
/**
|
|
17861
17895
|
* Represents a language model response.
|
|
17862
17896
|
*
|
|
17863
17897
|
* @see {@link LanguageModelAccess.chatRequest}
|
|
17898
|
+
* @stubbed
|
|
17864
17899
|
*/
|
|
17865
17900
|
export interface LanguageModelChatResponse {
|
|
17866
17901
|
|
|
17867
17902
|
/**
|
|
17868
|
-
* An async iterable that is a stream of text
|
|
17903
|
+
* An async iterable that is a stream of text and tool-call parts forming the overall response. A
|
|
17904
|
+
* {@link LanguageModelTextPart} is part of the assistant's response to be shown to the user. A
|
|
17905
|
+
* {@link LanguageModelToolCallPart} is a request from the language model to call a tool. The latter will
|
|
17906
|
+
* only be returned if tools were passed in the request via {@link LanguageModelChatRequestOptions.tools}. The
|
|
17907
|
+
* `unknown`-type is used as a placeholder for future parts, like image data parts.
|
|
17869
17908
|
*
|
|
17870
|
-
* *Note* that this stream will error when during data receiving an error occurs. Consumers of
|
|
17871
|
-
* the
|
|
17909
|
+
* *Note* that this stream will error when during data receiving an error occurs. Consumers of the stream should handle
|
|
17910
|
+
* the errors accordingly.
|
|
17872
17911
|
*
|
|
17873
|
-
* To cancel the stream, the consumer can {@link CancellationTokenSource.cancel cancel} the token that was used to make
|
|
17874
|
-
* or break from the for-loop.
|
|
17912
|
+
* To cancel the stream, the consumer can {@link CancellationTokenSource.cancel cancel} the token that was used to make
|
|
17913
|
+
* the request or break from the for-loop.
|
|
17875
17914
|
*
|
|
17876
17915
|
* @example
|
|
17877
17916
|
* ```ts
|
|
17878
17917
|
* try {
|
|
17879
17918
|
* // consume stream
|
|
17880
|
-
* for await (const chunk of response.
|
|
17881
|
-
*
|
|
17919
|
+
* for await (const chunk of response.stream) {
|
|
17920
|
+
* if (chunk instanceof LanguageModelTextPart) {
|
|
17921
|
+
* console.log("TEXT", chunk);
|
|
17922
|
+
* } else if (chunk instanceof LanguageModelToolCallPart) {
|
|
17923
|
+
* console.log("TOOL CALL", chunk);
|
|
17924
|
+
* }
|
|
17882
17925
|
* }
|
|
17883
17926
|
*
|
|
17884
17927
|
* } catch(e) {
|
|
@@ -17887,6 +17930,13 @@ export module '@theia/plugin' {
|
|
|
17887
17930
|
* }
|
|
17888
17931
|
* ```
|
|
17889
17932
|
*/
|
|
17933
|
+
stream: AsyncIterable<LanguageModelTextPart | LanguageModelToolCallPart | unknown>;
|
|
17934
|
+
|
|
17935
|
+
/**
|
|
17936
|
+
* This is equivalent to filtering everything except for text parts from a {@link LanguageModelChatResponse.stream}.
|
|
17937
|
+
*
|
|
17938
|
+
* @see {@link LanguageModelChatResponse.stream}
|
|
17939
|
+
*/
|
|
17890
17940
|
text: AsyncIterable<string>;
|
|
17891
17941
|
}
|
|
17892
17942
|
|
|
@@ -17894,6 +17944,7 @@ export module '@theia/plugin' {
|
|
|
17894
17944
|
* Represents a language model for making chat requests.
|
|
17895
17945
|
*
|
|
17896
17946
|
* @see {@link lm.selectChatModels}
|
|
17947
|
+
* @stubbed
|
|
17897
17948
|
*/
|
|
17898
17949
|
export interface LanguageModelChat {
|
|
17899
17950
|
|
|
@@ -17934,8 +17985,8 @@ export module '@theia/plugin' {
|
|
|
17934
17985
|
* Make a chat request using a language model.
|
|
17935
17986
|
*
|
|
17936
17987
|
* *Note* that language model use may be subject to access restrictions and user consent. Calling this function
|
|
17937
|
-
* for the first time (for
|
|
17938
|
-
* must _only be called in response to a user action!_
|
|
17988
|
+
* for the first time (for an extension) will show a consent dialog to the user and because of that this function
|
|
17989
|
+
* must _only be called in response to a user action!_ Extensions can use {@link LanguageModelAccessInformation.canSendRequest}
|
|
17939
17990
|
* to check if they have the necessary permissions to make a request.
|
|
17940
17991
|
*
|
|
17941
17992
|
* This function will return a rejected promise if making a request to the language model is not
|
|
@@ -17946,6 +17997,10 @@ export module '@theia/plugin' {
|
|
|
17946
17997
|
* - quota limits exceeded, see {@link LanguageModelError.Blocked `Blocked`}
|
|
17947
17998
|
* - other issues in which case extension must check {@link LanguageModelError.cause `LanguageModelError.cause`}
|
|
17948
17999
|
*
|
|
18000
|
+
* An extension can make use of language model tool calling by passing a set of tools to
|
|
18001
|
+
* {@link LanguageModelChatRequestOptions.tools}. The language model will return a {@link LanguageModelToolCallPart} and
|
|
18002
|
+
* the extension can invoke the tool and make another request with the result.
|
|
18003
|
+
*
|
|
17949
18004
|
* @param messages An array of message instances.
|
|
17950
18005
|
* @param options Options that control the request.
|
|
17951
18006
|
* @param token A cancellation token which controls the request. See {@link CancellationTokenSource} for how to create one.
|
|
@@ -17966,6 +18021,7 @@ export module '@theia/plugin' {
|
|
|
17966
18021
|
* Describes how to select language models for chat requests.
|
|
17967
18022
|
*
|
|
17968
18023
|
* @see {@link lm.selectChatModels}
|
|
18024
|
+
* @stubbed
|
|
17969
18025
|
*/
|
|
17970
18026
|
export interface LanguageModelChatSelector {
|
|
17971
18027
|
|
|
@@ -18001,6 +18057,7 @@ export module '@theia/plugin' {
|
|
|
18001
18057
|
* failure causes, like `if(someError.code === vscode.LanguageModelError.NotFound.name) {...}`
|
|
18002
18058
|
* for the case of referring to an unknown language model. For unspecified errors the `cause`-property
|
|
18003
18059
|
* will contain the actual error.
|
|
18060
|
+
* @stubbed
|
|
18004
18061
|
*/
|
|
18005
18062
|
export class LanguageModelError extends Error {
|
|
18006
18063
|
|
|
@@ -18034,6 +18091,7 @@ export module '@theia/plugin' {
|
|
|
18034
18091
|
* Options for making a chat request using a language model.
|
|
18035
18092
|
*
|
|
18036
18093
|
* @see {@link LanguageModelChat.sendRequest}
|
|
18094
|
+
* @stubbed
|
|
18037
18095
|
*/
|
|
18038
18096
|
export interface LanguageModelChatRequestOptions {
|
|
18039
18097
|
|
|
@@ -18047,6 +18105,24 @@ export module '@theia/plugin' {
|
|
|
18047
18105
|
* and need to be lookup in the respective documentation.
|
|
18048
18106
|
*/
|
|
18049
18107
|
modelOptions?: { [name: string]: any };
|
|
18108
|
+
|
|
18109
|
+
/**
|
|
18110
|
+
* An optional list of tools that are available to the language model. These could be registered tools available via
|
|
18111
|
+
* {@link lm.tools}, or private tools that are just implemented within the calling extension.
|
|
18112
|
+
*
|
|
18113
|
+
* If the LLM requests to call one of these tools, it will return a {@link LanguageModelToolCallPart} in
|
|
18114
|
+
* {@link LanguageModelChatResponse.stream}. It's the caller's responsibility to invoke the tool. If it's a tool
|
|
18115
|
+
* registered in {@link lm.tools}, that means calling {@link lm.invokeTool}.
|
|
18116
|
+
*
|
|
18117
|
+
* Then, the tool result can be provided to the LLM by creating an Assistant-type {@link LanguageModelChatMessage} with a
|
|
18118
|
+
* {@link LanguageModelToolCallPart}, followed by a User-type message with a {@link LanguageModelToolResultPart}.
|
|
18119
|
+
*/
|
|
18120
|
+
tools?: LanguageModelChatTool[];
|
|
18121
|
+
|
|
18122
|
+
/**
|
|
18123
|
+
* The tool-selecting mode to use. {@link LanguageModelChatToolMode.Auto} by default.
|
|
18124
|
+
*/
|
|
18125
|
+
toolMode?: LanguageModelChatToolMode;
|
|
18050
18126
|
}
|
|
18051
18127
|
|
|
18052
18128
|
/**
|
|
@@ -18087,10 +18163,56 @@ export module '@theia/plugin' {
|
|
|
18087
18163
|
* @stubbed
|
|
18088
18164
|
*/
|
|
18089
18165
|
export function selectChatModels(selector?: LanguageModelChatSelector): Thenable<LanguageModelChat[]>;
|
|
18166
|
+
|
|
18167
|
+
/**
|
|
18168
|
+
* Register a LanguageModelTool. The tool must also be registered in the package.json `languageModelTools` contribution
|
|
18169
|
+
* point. A registered tool is available in the {@link lm.tools} list for any extension to see. But in order for it to
|
|
18170
|
+
* be seen by a language model, it must be passed in the list of available tools in {@link LanguageModelChatRequestOptions.tools}.
|
|
18171
|
+
* @returns A {@link Disposable} that unregisters the tool when disposed.
|
|
18172
|
+
* @stubbed
|
|
18173
|
+
*/
|
|
18174
|
+
export function registerTool<T>(name: string, tool: LanguageModelTool<T>): Disposable;
|
|
18175
|
+
|
|
18176
|
+
/**
|
|
18177
|
+
* A list of all available tools that were registered by all extensions using {@link lm.registerTool}. They can be called
|
|
18178
|
+
* with {@link lm.invokeTool} with input that match their declared `inputSchema`.
|
|
18179
|
+
* @stubbed
|
|
18180
|
+
*/
|
|
18181
|
+
export const tools: readonly LanguageModelToolInformation[];
|
|
18182
|
+
|
|
18183
|
+
/**
|
|
18184
|
+
* Invoke a tool listed in {@link lm.tools} by name with the given input. The input will be validated against
|
|
18185
|
+
* the schema declared by the tool
|
|
18186
|
+
*
|
|
18187
|
+
* A tool can be invoked by a chat participant, in the context of handling a chat request, or globally by any extension in
|
|
18188
|
+
* any custom flow.
|
|
18189
|
+
*
|
|
18190
|
+
* In the former case, the caller shall pass the
|
|
18191
|
+
* {@link LanguageModelToolInvocationOptions.toolInvocationToken toolInvocationToken}, which comes with the a
|
|
18192
|
+
* {@link ChatRequest.toolInvocationToken chat request}. This makes sure the chat UI shows the tool invocation for the
|
|
18193
|
+
* correct conversation.
|
|
18194
|
+
*
|
|
18195
|
+
* A tool {@link LanguageModelToolResult result} is an array of {@link LanguageModelTextPart text-} and
|
|
18196
|
+
* {@link LanguageModelPromptTsxPart prompt-tsx}-parts. If the tool caller is using `@vscode/prompt-tsx`, it can
|
|
18197
|
+
* incorporate the response parts into its prompt using a `ToolResult`. If not, the parts can be passed along to the
|
|
18198
|
+
* {@link LanguageModelChat} via a user message with a {@link LanguageModelToolResultPart}.
|
|
18199
|
+
*
|
|
18200
|
+
* If a chat participant wants to preserve tool results for requests across multiple turns, it can store tool results in
|
|
18201
|
+
* the {@link ChatResult.metadata} returned from the handler and retrieve them on the next turn from
|
|
18202
|
+
* {@link ChatResponseTurn.result}.
|
|
18203
|
+
*
|
|
18204
|
+
* @param name The name of the tool to call.
|
|
18205
|
+
* @param options The options to use when invoking the tool.
|
|
18206
|
+
* @param token A cancellation token. See {@link CancellationTokenSource} for how to create one.
|
|
18207
|
+
* @returns The result of the tool invocation.
|
|
18208
|
+
* @stubbed
|
|
18209
|
+
*/
|
|
18210
|
+
export function invokeTool(name: string, options: LanguageModelToolInvocationOptions<object>, token?: CancellationToken): Thenable<LanguageModelToolResult>;
|
|
18090
18211
|
}
|
|
18091
18212
|
|
|
18092
18213
|
/**
|
|
18093
18214
|
* Represents extension specific information about the access to language models.
|
|
18215
|
+
* @stubbed
|
|
18094
18216
|
*/
|
|
18095
18217
|
export interface LanguageModelAccessInformation {
|
|
18096
18218
|
|
|
@@ -18109,6 +18231,327 @@ export module '@theia/plugin' {
|
|
|
18109
18231
|
* model does not exist or consent hasn't been asked for.
|
|
18110
18232
|
*/
|
|
18111
18233
|
canSendRequest(chat: LanguageModelChat): boolean | undefined;
|
|
18234
|
+
|
|
18235
|
+
}
|
|
18236
|
+
|
|
18237
|
+
/**
|
|
18238
|
+
* A tool that is available to the language model via {@link LanguageModelChatRequestOptions}. A language model uses all the
|
|
18239
|
+
* properties of this interface to decide which tool to call, and how to call it.
|
|
18240
|
+
* @stubbed
|
|
18241
|
+
*/
|
|
18242
|
+
export interface LanguageModelChatTool {
|
|
18243
|
+
/**
|
|
18244
|
+
* The name of the tool.
|
|
18245
|
+
*/
|
|
18246
|
+
name: string;
|
|
18247
|
+
|
|
18248
|
+
/**
|
|
18249
|
+
* The description of the tool.
|
|
18250
|
+
*/
|
|
18251
|
+
description: string;
|
|
18252
|
+
|
|
18253
|
+
/**
|
|
18254
|
+
* A JSON schema for the input this tool accepts.
|
|
18255
|
+
*/
|
|
18256
|
+
inputSchema?: object;
|
|
18257
|
+
}
|
|
18258
|
+
|
|
18259
|
+
/**
|
|
18260
|
+
* A tool-calling mode for the language model to use.
|
|
18261
|
+
*/
|
|
18262
|
+
export enum LanguageModelChatToolMode {
|
|
18263
|
+
/**
|
|
18264
|
+
* The language model can choose to call a tool or generate a message. Is the default.
|
|
18265
|
+
*/
|
|
18266
|
+
Auto = 1,
|
|
18267
|
+
|
|
18268
|
+
/**
|
|
18269
|
+
* The language model must call one of the provided tools. Note- some models only support a single tool when using this
|
|
18270
|
+
* mode.
|
|
18271
|
+
*/
|
|
18272
|
+
Required = 2
|
|
18273
|
+
}
|
|
18274
|
+
|
|
18275
|
+
/**
|
|
18276
|
+
* A language model response part indicating a tool call, returned from a {@link LanguageModelChatResponse}, and also can be
|
|
18277
|
+
* included as a content part on a {@link LanguageModelChatMessage}, to represent a previous tool call in a chat request.
|
|
18278
|
+
* @stubbed
|
|
18279
|
+
*/
|
|
18280
|
+
export class LanguageModelToolCallPart {
|
|
18281
|
+
/**
|
|
18282
|
+
* The ID of the tool call. This is a unique identifier for the tool call within the chat request.
|
|
18283
|
+
*/
|
|
18284
|
+
callId: string;
|
|
18285
|
+
|
|
18286
|
+
/**
|
|
18287
|
+
* The name of the tool to call.
|
|
18288
|
+
*/
|
|
18289
|
+
name: string;
|
|
18290
|
+
|
|
18291
|
+
/**
|
|
18292
|
+
* The input with which to call the tool.
|
|
18293
|
+
*/
|
|
18294
|
+
input: object;
|
|
18295
|
+
|
|
18296
|
+
/**
|
|
18297
|
+
* Create a new LanguageModelToolCallPart.
|
|
18298
|
+
*
|
|
18299
|
+
* @param callId The ID of the tool call.
|
|
18300
|
+
* @param name The name of the tool to call.
|
|
18301
|
+
* @param input The input with which to call the tool.
|
|
18302
|
+
*/
|
|
18303
|
+
constructor(callId: string, name: string, input: object);
|
|
18304
|
+
}
|
|
18305
|
+
|
|
18306
|
+
/**
|
|
18307
|
+
* The result of a tool call. This is the counterpart of a {@link LanguageModelToolCallPart tool call} and
|
|
18308
|
+
* it can only be included in the content of a User message
|
|
18309
|
+
* @stubbed
|
|
18310
|
+
*/
|
|
18311
|
+
export class LanguageModelToolResultPart {
|
|
18312
|
+
/**
|
|
18313
|
+
* The ID of the tool call.
|
|
18314
|
+
*
|
|
18315
|
+
* *Note* that this should match the {@link LanguageModelToolCallPart.callId callId} of a tool call part.
|
|
18316
|
+
*/
|
|
18317
|
+
callId: string;
|
|
18318
|
+
|
|
18319
|
+
/**
|
|
18320
|
+
* The value of the tool result.
|
|
18321
|
+
*/
|
|
18322
|
+
content: (LanguageModelTextPart | LanguageModelPromptTsxPart | unknown)[];
|
|
18323
|
+
|
|
18324
|
+
/**
|
|
18325
|
+
* @param callId The ID of the tool call.
|
|
18326
|
+
* @param content The content of the tool result.
|
|
18327
|
+
*/
|
|
18328
|
+
constructor(callId: string, content: (LanguageModelTextPart | LanguageModelPromptTsxPart | unknown)[]);
|
|
18329
|
+
}
|
|
18330
|
+
|
|
18331
|
+
/**
|
|
18332
|
+
* A language model response part containing a piece of text, returned from a {@link LanguageModelChatResponse}.
|
|
18333
|
+
* @stubbed
|
|
18334
|
+
*/
|
|
18335
|
+
export class LanguageModelTextPart {
|
|
18336
|
+
/**
|
|
18337
|
+
* The text content of the part.
|
|
18338
|
+
*/
|
|
18339
|
+
value: string;
|
|
18340
|
+
|
|
18341
|
+
/**
|
|
18342
|
+
* Construct a text part with the given content.
|
|
18343
|
+
* @param value The text content of the part.
|
|
18344
|
+
*/
|
|
18345
|
+
constructor(value: string);
|
|
18346
|
+
}
|
|
18347
|
+
|
|
18348
|
+
/**
|
|
18349
|
+
* A language model response part containing a PromptElementJSON from `@vscode/prompt-tsx`.
|
|
18350
|
+
* @see {@link LanguageModelToolResult}
|
|
18351
|
+
* @stubbed
|
|
18352
|
+
*/
|
|
18353
|
+
export class LanguageModelPromptTsxPart {
|
|
18354
|
+
/**
|
|
18355
|
+
* The value of the part.
|
|
18356
|
+
*/
|
|
18357
|
+
value: unknown;
|
|
18358
|
+
|
|
18359
|
+
/**
|
|
18360
|
+
* Construct a prompt-tsx part with the given content.
|
|
18361
|
+
* @param value The value of the part, the result of `renderPromptElementJSON` from `@vscode/prompt-tsx`.
|
|
18362
|
+
*/
|
|
18363
|
+
constructor(value: unknown);
|
|
18364
|
+
}
|
|
18365
|
+
|
|
18366
|
+
/**
|
|
18367
|
+
* A result returned from a tool invocation. If using `@vscode/prompt-tsx`, this result may be rendered using a `ToolResult`.
|
|
18368
|
+
* @stubbed
|
|
18369
|
+
*/
|
|
18370
|
+
export class LanguageModelToolResult {
|
|
18371
|
+
/**
|
|
18372
|
+
* A list of tool result content parts. Includes `unknown` becauses this list may be extended with new content types in
|
|
18373
|
+
* the future.
|
|
18374
|
+
* @see {@link lm.invokeTool}.
|
|
18375
|
+
*/
|
|
18376
|
+
content: (LanguageModelTextPart | LanguageModelPromptTsxPart | unknown)[];
|
|
18377
|
+
|
|
18378
|
+
/**
|
|
18379
|
+
* Create a LanguageModelToolResult
|
|
18380
|
+
* @param content A list of tool result content parts
|
|
18381
|
+
*/
|
|
18382
|
+
constructor(content: (LanguageModelTextPart | LanguageModelPromptTsxPart)[]);
|
|
18383
|
+
}
|
|
18384
|
+
|
|
18385
|
+
/**
|
|
18386
|
+
* A token that can be passed to {@link lm.invokeTool} when invoking a tool inside the context of handling a chat request.
|
|
18387
|
+
*/
|
|
18388
|
+
export type ChatParticipantToolToken = never;
|
|
18389
|
+
|
|
18390
|
+
/**
|
|
18391
|
+
* Options provided for tool invocation.
|
|
18392
|
+
* @stubbed
|
|
18393
|
+
*/
|
|
18394
|
+
export interface LanguageModelToolInvocationOptions<T> {
|
|
18395
|
+
/**
|
|
18396
|
+
* An opaque object that ties a tool invocation to a chat request from a {@link ChatParticipant chat participant}.
|
|
18397
|
+
*
|
|
18398
|
+
* The _only_ way to get a valid tool invocation token is using the provided {@link ChatRequest.toolInvocationToken toolInvocationToken}
|
|
18399
|
+
* from a chat request. In that case, a progress bar will be automatically shown for the tool invocation in the chat response view, and if
|
|
18400
|
+
* the tool requires user confirmation, it will show up inline in the chat view.
|
|
18401
|
+
*
|
|
18402
|
+
* If the tool is being invoked outside of a chat request, `undefined` should be passed instead, and no special UI except for
|
|
18403
|
+
* confirmations will be shown.
|
|
18404
|
+
*
|
|
18405
|
+
* *Note* that a tool that invokes another tool during its invocation, can pass along the `toolInvocationToken` that it received.
|
|
18406
|
+
*/
|
|
18407
|
+
toolInvocationToken: ChatParticipantToolToken | undefined;
|
|
18408
|
+
|
|
18409
|
+
/**
|
|
18410
|
+
* The input with which to invoke the tool. The input must match the schema defined in
|
|
18411
|
+
* {@link LanguageModelToolInformation.inputSchema}
|
|
18412
|
+
*/
|
|
18413
|
+
input: T;
|
|
18414
|
+
|
|
18415
|
+
/**
|
|
18416
|
+
* Options to hint at how many tokens the tool should return in its response, and enable the tool to count tokens
|
|
18417
|
+
* accurately.
|
|
18418
|
+
*/
|
|
18419
|
+
tokenizationOptions?: LanguageModelToolTokenizationOptions;
|
|
18420
|
+
}
|
|
18421
|
+
|
|
18422
|
+
/**
|
|
18423
|
+
* Options related to tokenization for a tool invocation.
|
|
18424
|
+
* @stubbed
|
|
18425
|
+
*/
|
|
18426
|
+
export interface LanguageModelToolTokenizationOptions {
|
|
18427
|
+
/**
|
|
18428
|
+
* If known, the maximum number of tokens the tool should emit in its result.
|
|
18429
|
+
*/
|
|
18430
|
+
tokenBudget: number;
|
|
18431
|
+
|
|
18432
|
+
/**
|
|
18433
|
+
* Count the number of tokens in a message using the model specific tokenizer-logic.
|
|
18434
|
+
* @param text A string.
|
|
18435
|
+
* @param token Optional cancellation token. See {@link CancellationTokenSource} for how to create one.
|
|
18436
|
+
* @returns A thenable that resolves to the number of tokens.
|
|
18437
|
+
*/
|
|
18438
|
+
countTokens(text: string, token?: CancellationToken): Thenable<number>;
|
|
18439
|
+
}
|
|
18440
|
+
|
|
18441
|
+
/**
|
|
18442
|
+
* Information about a registered tool available in {@link lm.tools}.
|
|
18443
|
+
* @stubbed
|
|
18444
|
+
*/
|
|
18445
|
+
export interface LanguageModelToolInformation {
|
|
18446
|
+
/**
|
|
18447
|
+
* A unique name for the tool.
|
|
18448
|
+
*/
|
|
18449
|
+
readonly name: string;
|
|
18450
|
+
|
|
18451
|
+
/**
|
|
18452
|
+
* A description of this tool that may be passed to a language model.
|
|
18453
|
+
*/
|
|
18454
|
+
readonly description: string;
|
|
18455
|
+
|
|
18456
|
+
/**
|
|
18457
|
+
* A JSON schema for the input this tool accepts.
|
|
18458
|
+
*/
|
|
18459
|
+
readonly inputSchema: object | undefined;
|
|
18460
|
+
|
|
18461
|
+
/**
|
|
18462
|
+
* A set of tags, declared by the tool, that roughly describe the tool's capabilities. A tool user may use these to filter
|
|
18463
|
+
* the set of tools to just ones that are relevant for the task at hand.
|
|
18464
|
+
*/
|
|
18465
|
+
readonly tags: readonly string[];
|
|
18466
|
+
}
|
|
18467
|
+
|
|
18468
|
+
/**
|
|
18469
|
+
* Options for {@link LanguageModelTool.prepareInvocation}.
|
|
18470
|
+
* @stubbed
|
|
18471
|
+
*/
|
|
18472
|
+
export interface LanguageModelToolInvocationPrepareOptions<T> {
|
|
18473
|
+
/**
|
|
18474
|
+
* The input that the tool is being invoked with.
|
|
18475
|
+
*/
|
|
18476
|
+
input: T;
|
|
18477
|
+
}
|
|
18478
|
+
|
|
18479
|
+
/**
|
|
18480
|
+
* A tool that can be invoked by a call to a {@link LanguageModelChat}.
|
|
18481
|
+
* @stubbed
|
|
18482
|
+
*/
|
|
18483
|
+
export interface LanguageModelTool<T> {
|
|
18484
|
+
/**
|
|
18485
|
+
* Invoke the tool with the given input and return a result.
|
|
18486
|
+
*
|
|
18487
|
+
* The provided {@link LanguageModelToolInvocationOptions.input} has been validated against the declared schema.
|
|
18488
|
+
*/
|
|
18489
|
+
invoke(options: LanguageModelToolInvocationOptions<T>, token: CancellationToken): ProviderResult<LanguageModelToolResult>;
|
|
18490
|
+
|
|
18491
|
+
/**
|
|
18492
|
+
* Called once before a tool is invoked. It's recommended to implement this to customize the progress message that appears
|
|
18493
|
+
* while the tool is running, and to provide a more useful message with context from the invocation input. Can also
|
|
18494
|
+
* signal that a tool needs user confirmation before running, if appropriate.
|
|
18495
|
+
*
|
|
18496
|
+
* * *Note 1:* Must be free of side-effects.
|
|
18497
|
+
* * *Note 2:* A call to `prepareInvocation` is not necessarily followed by a call to `invoke`.
|
|
18498
|
+
*/
|
|
18499
|
+
prepareInvocation?(options: LanguageModelToolInvocationPrepareOptions<T>, token: CancellationToken): ProviderResult<PreparedToolInvocation>;
|
|
18500
|
+
}
|
|
18501
|
+
|
|
18502
|
+
/**
|
|
18503
|
+
* When this is returned in {@link PreparedToolInvocation}, the user will be asked to confirm before running the tool. These
|
|
18504
|
+
* messages will be shown with buttons that say "Continue" and "Cancel".
|
|
18505
|
+
* @stubbed
|
|
18506
|
+
*/
|
|
18507
|
+
export interface LanguageModelToolConfirmationMessages {
|
|
18508
|
+
/**
|
|
18509
|
+
* The title of the confirmation message.
|
|
18510
|
+
*/
|
|
18511
|
+
title: string;
|
|
18512
|
+
|
|
18513
|
+
/**
|
|
18514
|
+
* The body of the confirmation message.
|
|
18515
|
+
*/
|
|
18516
|
+
message: string | MarkdownString;
|
|
18517
|
+
}
|
|
18518
|
+
|
|
18519
|
+
/**
|
|
18520
|
+
* The result of a call to {@link LanguageModelTool.prepareInvocation}.
|
|
18521
|
+
* @stubbed
|
|
18522
|
+
*/
|
|
18523
|
+
export interface PreparedToolInvocation {
|
|
18524
|
+
/**
|
|
18525
|
+
* A customized progress message to show while the tool runs.
|
|
18526
|
+
*/
|
|
18527
|
+
invocationMessage?: string;
|
|
18528
|
+
|
|
18529
|
+
/**
|
|
18530
|
+
* The presence of this property indicates that the user should be asked to confirm before running the tool. The user
|
|
18531
|
+
* should be asked for confirmation for any tool that has a side-effect or may potentially be dangerous.
|
|
18532
|
+
*/
|
|
18533
|
+
confirmationMessages?: LanguageModelToolConfirmationMessages;
|
|
18534
|
+
}
|
|
18535
|
+
|
|
18536
|
+
/**
|
|
18537
|
+
* A reference to a tool that the user manually attached to their request, either using the `#`-syntax inline, or as an
|
|
18538
|
+
* attachment via the paperclip button.
|
|
18539
|
+
* @stubbed
|
|
18540
|
+
*/
|
|
18541
|
+
export interface ChatLanguageModelToolReference {
|
|
18542
|
+
/**
|
|
18543
|
+
* The tool name. Refers to a tool listed in {@link lm.tools}.
|
|
18544
|
+
*/
|
|
18545
|
+
readonly name: string;
|
|
18546
|
+
|
|
18547
|
+
/**
|
|
18548
|
+
* The start and end index of the reference in the {@link ChatRequest.prompt prompt}. When undefined, the reference was
|
|
18549
|
+
* not part of the prompt text.
|
|
18550
|
+
*
|
|
18551
|
+
* *Note* that the indices take the leading `#`-character into account which means they can be used to modify the prompt
|
|
18552
|
+
* as-is.
|
|
18553
|
+
*/
|
|
18554
|
+
readonly range?: [start: number, end: number];
|
|
18112
18555
|
}
|
|
18113
18556
|
|
|
18114
18557
|
/**
|
|
@@ -35,6 +35,7 @@ export module '@theia/plugin' {
|
|
|
35
35
|
export interface ConversationResponse {
|
|
36
36
|
readonly type: 'response';
|
|
37
37
|
readonly message: string;
|
|
38
|
+
readonly result?: ChatResult;
|
|
38
39
|
readonly references?: DocumentContextItem[];
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -69,7 +70,7 @@ export module '@theia/plugin' {
|
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
export interface MappedEditsRequest {
|
|
72
|
-
readonly codeBlocks: { code: string; resource: Uri }[];
|
|
73
|
+
readonly codeBlocks: { code: string; resource: Uri; markdownBeforeBlock?: string }[];
|
|
73
74
|
// for every prior response that contains codeblocks, make sure we pass the code as well as the resources based on the reported codemapper URIs
|
|
74
75
|
readonly conversation: (ConversationRequest | ConversationResponse)[];
|
|
75
76
|
}
|