@theia/plugin 1.55.1 → 1.57.0-next.112

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/src/theia.d.ts CHANGED
@@ -43,6 +43,7 @@ import './theia.proposed.profileContentHandlers';
43
43
  import './theia.proposed.resolvers';
44
44
  import './theia.proposed.scmValidation';
45
45
  import './theia.proposed.shareProvider';
46
+ import './theia.proposed.terminalCompletionProvider';
46
47
  import './theia.proposed.terminalQuickFixProvider';
47
48
  import './theia.proposed.textSearchProvider';
48
49
  import './theia.proposed.timeline';
@@ -2163,7 +2164,7 @@ export module '@theia/plugin' {
2163
2164
  /**
2164
2165
  * The icon path or {@link ThemeIcon} for the QuickPickItem.
2165
2166
  */
2166
- iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
2167
+ iconPath?: IconPath;
2167
2168
 
2168
2169
  /**
2169
2170
  * A human-readable string which is rendered less prominent in the same line. Supports rendering of
@@ -2696,6 +2697,11 @@ export module '@theia/plugin' {
2696
2697
  * Using a theme color is preferred over a custom color as it gives theme authors and users the possibility to change the color.
2697
2698
  */
2698
2699
  export class ThemeColor {
2700
+ /**
2701
+ * The id of this color.
2702
+ */
2703
+ readonly id: string;
2704
+
2699
2705
  /**
2700
2706
  * Creates a reference to a theme color.
2701
2707
  */
@@ -2735,6 +2741,21 @@ export module '@theia/plugin' {
2735
2741
  private constructor(id: string, color?: ThemeColor);
2736
2742
  }
2737
2743
 
2744
+ /**
2745
+ * Represents an icon in the UI. This is either an uri, separate uris for the light- and dark-themes,
2746
+ * or a {@link ThemeIcon theme icon}.
2747
+ */
2748
+ export type IconPath = Uri | {
2749
+ /**
2750
+ * The icon path for the light theme.
2751
+ */
2752
+ light: Uri;
2753
+ /**
2754
+ * The icon path for the dark theme.
2755
+ */
2756
+ dark: Uri;
2757
+ } | ThemeIcon;
2758
+
2738
2759
  /**
2739
2760
  * Represents the state of a window.
2740
2761
  */
@@ -3515,7 +3536,7 @@ export module '@theia/plugin' {
3515
3536
  /**
3516
3537
  * The icon path or {@link ThemeIcon} for the terminal.
3517
3538
  */
3518
- iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
3539
+ iconPath?: IconPath;
3519
3540
 
3520
3541
  /**
3521
3542
  * The icon {@link ThemeColor} for the terminal.
@@ -3635,7 +3656,7 @@ export module '@theia/plugin' {
3635
3656
  /**
3636
3657
  * The icon path or {@link ThemeIcon} for the terminal.
3637
3658
  */
3638
- iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
3659
+ iconPath?: IconPath;
3639
3660
 
3640
3661
  /**
3641
3662
  * The icon {@link ThemeColor} for the terminal.
@@ -6222,7 +6243,7 @@ export module '@theia/plugin' {
6222
6243
  /**
6223
6244
  * Icon for the button.
6224
6245
  */
6225
- readonly iconPath: Uri | { light: Uri; dark: Uri } | ThemeIcon;
6246
+ readonly iconPath: IconPath;
6226
6247
 
6227
6248
  /**
6228
6249
  * An optional tooltip.
@@ -6836,7 +6857,7 @@ export module '@theia/plugin' {
6836
6857
  * When `falsy`, {@link ThemeIcon.Folder Folder Theme Icon} is assigned, if item is collapsible otherwise {@link ThemeIcon.File File Theme Icon}.
6837
6858
  * 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
6859
  */
6839
- iconPath?: string | Uri | { light: string | Uri; dark: string | Uri } | ThemeIcon;
6860
+ iconPath?: string | IconPath;
6840
6861
 
6841
6862
  /**
6842
6863
  * A human readable string which is rendered less prominent.
@@ -10285,7 +10306,7 @@ export module '@theia/plugin' {
10285
10306
  * @return An array of commands, quick fixes, or refactorings or a thenable of such. The lack of a result can be
10286
10307
  * signaled by returning `undefined`, `null`, or an empty array.
10287
10308
  */
10288
- provideCodeActions(document: TextDocument, range: Range | Selection, context: CodeActionContext, token: CancellationToken): ProviderResult<(Command | T)[]>;
10309
+ provideCodeActions(document: TextDocument, range: Range | Selection, context: CodeActionContext, token: CancellationToken): ProviderResult<Array<Command | T>>;
10289
10310
 
10290
10311
  /**
10291
10312
  * Given a code action fill in its `edit`-property. Changes to
@@ -10607,7 +10628,7 @@ export module '@theia/plugin' {
10607
10628
  /**
10608
10629
  * The icon path or {@link ThemeIcon ThemeIcon} for the edit.
10609
10630
  */
10610
- iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
10631
+ iconPath?: IconPath;
10611
10632
  }
10612
10633
 
10613
10634
  /**
@@ -13160,7 +13181,7 @@ export module '@theia/plugin' {
13160
13181
  * @param args The command arguments.
13161
13182
  * @param options Optional options for the started the shell.
13162
13183
  */
13163
- constructor(command: string | ShellQuotedString, args: (string | ShellQuotedString)[], options?: ShellExecutionOptions);
13184
+ constructor(command: string | ShellQuotedString, args: Array<string | ShellQuotedString>, options?: ShellExecutionOptions);
13164
13185
 
13165
13186
  /**
13166
13187
  * The shell command line. Is `undefined` if created with a command and arguments.
@@ -16542,6 +16563,30 @@ export module '@theia/plugin' {
16542
16563
  */
16543
16564
  loadDetailedCoverage?: (testRun: TestRun, fileCoverage: FileCoverage, token: CancellationToken) => Thenable<FileCoverageDetail[]>;
16544
16565
 
16566
+ /**
16567
+ * An extension-provided function that provides detailed statement and
16568
+ * function-level coverage for a single test in a file. This is the per-test
16569
+ * sibling of {@link TestRunProfile.loadDetailedCoverage}, called only if
16570
+ * a test item is provided in {@link FileCoverage.includesTests} and only
16571
+ * for files where such data is reported.
16572
+ *
16573
+ * Often {@link TestRunProfile.loadDetailedCoverage} will be called first
16574
+ * when a user opens a file, and then this method will be called if they
16575
+ * drill down into specific per-test coverage information. This method
16576
+ * should then return coverage data only for constructs the given test item
16577
+ * executed during the test run.
16578
+ *
16579
+ * The {@link FileCoverage} object passed to this function is the same
16580
+ * instance emitted on {@link TestRun.addCoverage} calls associated with this profile.
16581
+ *
16582
+ * @param testRun The test run that generated the coverage data.
16583
+ * @param fileCoverage The file coverage object to load detailed coverage for.
16584
+ * @param fromTestItem The test item to request coverage information for.
16585
+ * @param token A cancellation token that indicates the operation should be cancelled.
16586
+ * @stubbed
16587
+ */
16588
+ loadDetailedCoverageForTest?: (testRun: TestRun, fileCoverage: FileCoverage, fromTestItem: TestItem, token: CancellationToken) => Thenable<FileCoverageDetail[]>;
16589
+
16545
16590
  /**
16546
16591
  * Deletes the run profile.
16547
16592
  */
@@ -17136,6 +17181,13 @@ export module '@theia/plugin' {
17136
17181
  */
17137
17182
  declarationCoverage?: TestCoverageCount;
17138
17183
 
17184
+ /**
17185
+ * A list of {@link TestItem test cases} that generated coverage in this
17186
+ * file. If set, then {@link TestRunProfile.loadDetailedCoverageForTest}
17187
+ * should also be defined in order to retrieve detailed coverage information.
17188
+ */
17189
+ includesTests?: TestItem[];
17190
+
17139
17191
  /**
17140
17192
  * Creates a {@link FileCoverage} instance with counts filled in from
17141
17193
  * the coverage details.
@@ -17151,12 +17203,14 @@ export module '@theia/plugin' {
17151
17203
  * used to represent line coverage.
17152
17204
  * @param branchCoverage Branch coverage information
17153
17205
  * @param declarationCoverage Declaration coverage information
17206
+ * @param includesTests Test cases included in this coverage report, see {@link includesTests}
17154
17207
  */
17155
17208
  constructor(
17156
17209
  uri: Uri,
17157
17210
  statementCoverage: TestCoverageCount,
17158
17211
  branchCoverage?: TestCoverageCount,
17159
17212
  declarationCoverage?: TestCoverageCount,
17213
+ includesTests?: TestItem[],
17160
17214
  );
17161
17215
  }
17162
17216
 
@@ -17262,6 +17316,7 @@ export module '@theia/plugin' {
17262
17316
 
17263
17317
  /**
17264
17318
  * Represents a user request in chat history.
17319
+ * @stubbed
17265
17320
  */
17266
17321
  export class ChatRequestTurn {
17267
17322
  /**
@@ -17271,51 +17326,67 @@ export module '@theia/plugin' {
17271
17326
  *
17272
17327
  * *Note* that the {@link ChatParticipant.name name} of the participant and the {@link ChatCommand.name command}
17273
17328
  * are not part of the prompt.
17329
+ * @stubbed
17274
17330
  */
17275
17331
  readonly prompt: string;
17276
17332
 
17277
17333
  /**
17278
17334
  * The id of the chat participant to which this request was directed.
17335
+ * @stubbed
17279
17336
  */
17280
17337
  readonly participant: string;
17281
17338
 
17282
17339
  /**
17283
17340
  * The name of the {@link ChatCommand command} that was selected for this request.
17341
+ * @stubbed
17284
17342
  */
17285
17343
  readonly command?: string;
17286
17344
 
17287
17345
  /**
17288
17346
  * The references that were used in this message.
17347
+ * @stubbed
17289
17348
  */
17290
17349
  readonly references: ChatPromptReference[];
17291
17350
 
17351
+ /**
17352
+ * The list of tools were attached to this request.
17353
+ * @stubbed
17354
+ */
17355
+ readonly toolReferences: readonly ChatLanguageModelToolReference[];
17356
+
17292
17357
  /**
17293
17358
  * @hidden
17359
+ * @stubbed
17294
17360
  */
17295
- private constructor(prompt: string, command: string | undefined, references: ChatPromptReference[], participant: string);
17361
+ private constructor(prompt: string, command: string | undefined, references: ChatPromptReference[], participant: string, toolReferences: ChatLanguageModelToolReference[]);
17296
17362
  }
17297
17363
 
17298
17364
  /**
17299
17365
  * Represents a chat participant's response in chat history.
17366
+ * @stubbed
17300
17367
  */
17301
17368
  export class ChatResponseTurn {
17302
17369
  /**
17303
17370
  * The content that was received from the chat participant. Only the stream parts that represent actual content (not metadata) are represented.
17371
+ * @stubbed
17304
17372
  */
17305
17373
  readonly response: ReadonlyArray<ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart>;
17306
17374
 
17307
17375
  /**
17308
17376
  * The result that was received from the chat participant.
17377
+ * @stubbed
17309
17378
  */
17310
17379
  readonly result: ChatResult;
17311
17380
 
17312
17381
  /**
17313
17382
  * The id of the chat participant that this response came from.
17383
+ * @stubbed
17314
17384
  */
17315
17385
  readonly participant: string;
17316
17386
 
17317
17387
  /**
17318
17388
  * The name of the command that this response came from.
17389
+ * @stubbed
17319
17390
  */
17320
17391
  readonly command?: string;
17321
17392
 
@@ -17327,40 +17398,48 @@ export module '@theia/plugin' {
17327
17398
 
17328
17399
  /**
17329
17400
  * Extra context passed to a participant.
17401
+ * @stubbed
17330
17402
  */
17331
17403
  export interface ChatContext {
17332
17404
  /**
17333
17405
  * All of the chat messages so far in the current chat session. Currently, only chat messages for the current participant are included.
17406
+ * @stubbed
17334
17407
  */
17335
17408
  readonly history: ReadonlyArray<ChatRequestTurn | ChatResponseTurn>;
17336
17409
  }
17337
17410
 
17338
17411
  /**
17339
17412
  * Represents an error result from a chat request.
17413
+ * @stubbed
17340
17414
  */
17341
17415
  export interface ChatErrorDetails {
17342
17416
  /**
17343
17417
  * An error message that is shown to the user.
17418
+ * @stubbed
17344
17419
  */
17345
17420
  message: string;
17346
17421
 
17347
17422
  /**
17348
17423
  * If set to true, the response will be partly blurred out.
17424
+ * @stubbed
17349
17425
  */
17350
17426
  responseIsFiltered?: boolean;
17351
17427
  }
17352
17428
 
17353
17429
  /**
17354
17430
  * The result of a chat request.
17431
+ * @stubbed
17355
17432
  */
17356
17433
  export interface ChatResult {
17357
17434
  /**
17358
17435
  * If the request resulted in an error, this property defines the error details.
17436
+ * @stubbed
17359
17437
  */
17360
17438
  errorDetails?: ChatErrorDetails;
17361
17439
 
17362
17440
  /**
17363
17441
  * Arbitrary metadata for this result. Can be anything, but must be JSON-stringifyable.
17442
+ * @stubbed
17364
17443
  */
17365
17444
  readonly metadata?: { readonly [key: string]: any };
17366
17445
  }
@@ -17382,53 +17461,63 @@ export module '@theia/plugin' {
17382
17461
 
17383
17462
  /**
17384
17463
  * Represents user feedback for a result.
17464
+ * @stubbed
17385
17465
  */
17386
17466
  export interface ChatResultFeedback {
17387
17467
  /**
17388
17468
  * The ChatResult for which the user is providing feedback.
17389
17469
  * This object has the same properties as the result returned from the participant callback, including `metadata`, but is not the same instance.
17470
+ * @stubbed
17390
17471
  */
17391
17472
  readonly result: ChatResult;
17392
17473
 
17393
17474
  /**
17394
17475
  * The kind of feedback that was received.
17476
+ * @stubbed
17395
17477
  */
17396
17478
  readonly kind: ChatResultFeedbackKind;
17397
17479
  }
17398
17480
 
17399
17481
  /**
17400
17482
  * A followup question suggested by the participant.
17483
+ * @stubbed
17401
17484
  */
17402
17485
  export interface ChatFollowup {
17403
17486
  /**
17404
17487
  * The message to send to the chat.
17488
+ * @stubbed
17405
17489
  */
17406
17490
  prompt: string;
17407
17491
 
17408
17492
  /**
17409
17493
  * A title to show the user. The prompt will be shown by default, when this is unspecified.
17494
+ * @stubbed
17410
17495
  */
17411
17496
  label?: string;
17412
17497
 
17413
17498
  /**
17414
17499
  * By default, the followup goes to the same participant/command. But this property can be set to invoke a different participant by ID.
17415
17500
  * Followups can only invoke a participant that was contributed by the same extension.
17501
+ * @stubbed
17416
17502
  */
17417
17503
  participant?: string;
17418
17504
 
17419
17505
  /**
17420
17506
  * By default, the followup goes to the same participant/command. But this property can be set to invoke a different command.
17507
+ * @stubbed
17421
17508
  */
17422
17509
  command?: string;
17423
17510
  }
17424
17511
 
17425
17512
  /**
17426
17513
  * 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.
17514
+ * @stubbed
17427
17515
  */
17428
17516
  export interface ChatFollowupProvider {
17429
17517
  /**
17430
17518
  * Provide followups for the given result.
17431
17519
  * @param result This object has the same properties as the result returned from the participant callback, including `metadata`, but is not the same instance.
17520
+ * @param context Extra context passed to a participant.
17432
17521
  * @param token A cancellation token.
17433
17522
  */
17434
17523
  provideFollowups(result: ChatResult, context: ChatContext, token: CancellationToken): ProviderResult<ChatFollowup[]>;
@@ -17436,40 +17525,37 @@ export module '@theia/plugin' {
17436
17525
 
17437
17526
  /**
17438
17527
  * A chat request handler is a callback that will be invoked when a request is made to a chat participant.
17528
+ * @stubbed
17439
17529
  */
17440
17530
  export type ChatRequestHandler = (request: ChatRequest, context: ChatContext, response: ChatResponseStream, token: CancellationToken) => ProviderResult<ChatResult | void>;
17441
17531
 
17442
17532
  /**
17443
17533
  * 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
17534
  * responsible for providing a response to the user. A ChatParticipant is created using {@link chat.createChatParticipant}.
17535
+ * @stubbed
17445
17536
  */
17446
17537
  export interface ChatParticipant {
17447
17538
  /**
17448
17539
  * A unique ID for this participant.
17540
+ * @stubbed
17449
17541
  */
17450
17542
  readonly id: string;
17451
17543
 
17452
17544
  /**
17453
17545
  * An icon for the participant shown in UI.
17546
+ * @stubbed
17454
17547
  */
17455
- iconPath?: Uri | {
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;
17548
+ iconPath?: IconPath;
17465
17549
 
17466
17550
  /**
17467
17551
  * The handler for requests to this participant.
17552
+ * @stubbed
17468
17553
  */
17469
17554
  requestHandler: ChatRequestHandler;
17470
17555
 
17471
17556
  /**
17472
17557
  * This provider will be called once after each request to retrieve suggested followup questions.
17558
+ * @stubbed
17473
17559
  */
17474
17560
  followupProvider?: ChatFollowupProvider;
17475
17561
 
@@ -17479,21 +17565,25 @@ export module '@theia/plugin' {
17479
17565
  *
17480
17566
  * The passed {@link ChatResultFeedback.result result} is guaranteed to be the same instance that was
17481
17567
  * previously returned from this chat participant.
17568
+ * @stubbed
17482
17569
  */
17483
17570
  onDidReceiveFeedback: Event<ChatResultFeedback>;
17484
17571
 
17485
17572
  /**
17486
17573
  * Dispose this participant and free resources.
17574
+ * @stubbed
17487
17575
  */
17488
17576
  dispose(): void;
17489
17577
  }
17490
17578
 
17491
17579
  /**
17492
17580
  * A reference to a value that the user added to their chat request.
17581
+ * @stubbed
17493
17582
  */
17494
17583
  export interface ChatPromptReference {
17495
17584
  /**
17496
17585
  * A unique identifier for this kind of reference.
17586
+ * @stubbed
17497
17587
  */
17498
17588
  readonly id: string;
17499
17589
 
@@ -17502,22 +17592,26 @@ export module '@theia/plugin' {
17502
17592
  *
17503
17593
  * *Note* that the indices take the leading `#`-character into account which means they can
17504
17594
  * used to modify the prompt as-is.
17595
+ * @stubbed
17505
17596
  */
17506
17597
  readonly range?: [start: number, end: number];
17507
17598
 
17508
17599
  /**
17509
17600
  * A description of this value that could be used in an LLM prompt.
17601
+ * @stubbed
17510
17602
  */
17511
17603
  readonly modelDescription?: string;
17512
17604
 
17513
17605
  /**
17514
17606
  * The value of this reference. The `string | Uri | Location` types are used today, but this could expand in the future.
17607
+ * @stubbed
17515
17608
  */
17516
17609
  readonly value: string | Uri | Location | unknown;
17517
17610
  }
17518
17611
 
17519
17612
  /**
17520
17613
  * A request to a chat participant.
17614
+ * @stubbed
17521
17615
  */
17522
17616
  export interface ChatRequest {
17523
17617
  /**
@@ -17527,11 +17621,13 @@ export module '@theia/plugin' {
17527
17621
  *
17528
17622
  * *Note* that the {@link ChatParticipant.name name} of the participant and the {@link ChatCommand.name command}
17529
17623
  * are not part of the prompt.
17624
+ * @stubbed
17530
17625
  */
17531
17626
  readonly prompt: string;
17532
17627
 
17533
17628
  /**
17534
17629
  * The name of the {@link ChatCommand command} that was selected for this request.
17630
+ * @stubbed
17535
17631
  */
17536
17632
  readonly command: string | undefined;
17537
17633
 
@@ -17543,14 +17639,41 @@ export module '@theia/plugin' {
17543
17639
  * headings which contain the resolved values. References are sorted in reverse by their range
17544
17640
  * in the prompt. That means the last reference in the prompt is the first in this list. This simplifies
17545
17641
  * string-manipulation of the prompt.
17642
+ * @stubbed
17546
17643
  */
17547
17644
  readonly references: readonly ChatPromptReference[];
17645
+
17646
+ /**
17647
+ * The list of tools that the user attached to their request.
17648
+ *
17649
+ * When a tool reference is present, the chat participant should make a chat request using
17650
+ * {@link LanguageModelChatToolMode.Required} to force the language model to generate input for the tool. Then, the
17651
+ * participant can use {@link lm.invokeTool} to use the tool attach the result to its request for the user's prompt. The
17652
+ * tool may contribute useful extra context for the user's request.
17653
+ * @stubbed
17654
+ */
17655
+ readonly toolReferences: readonly ChatLanguageModelToolReference[];
17656
+
17657
+ /**
17658
+ * A token that can be passed to {@link lm.invokeTool} when invoking a tool inside the context of handling a chat request.
17659
+ * This associates the tool invocation to a chat session.
17660
+ * @stubbed
17661
+ */
17662
+ readonly toolInvocationToken: ChatParticipantToolToken;
17663
+
17664
+ /**
17665
+ * This is the model that is currently selected in the UI. Extensions can use this or use {@link chat.selectChatModels} to
17666
+ * pick another model. Don't hold onto this past the lifetime of the request.
17667
+ * @stubbed
17668
+ */
17669
+ readonly model: LanguageModelChat;
17548
17670
  }
17549
17671
 
17550
17672
  /**
17551
17673
  * 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
17674
  * 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
17675
  * can instantiate a {@link ChatResponsePart} and use the generic {@link ChatResponseStream.push} method to return it.
17676
+ * @stubbed
17554
17677
  */
17555
17678
  export interface ChatResponseStream {
17556
17679
  /**
@@ -17559,6 +17682,7 @@ export module '@theia/plugin' {
17559
17682
  *
17560
17683
  * @see {@link ChatResponseStream.push}
17561
17684
  * @param value A markdown string or a string that should be interpreted as markdown. The boolean form of {@link MarkdownString.isTrusted} is NOT supported.
17685
+ * @stubbed
17562
17686
  */
17563
17687
  markdown(value: string | MarkdownString): void;
17564
17688
 
@@ -17567,8 +17691,9 @@ export module '@theia/plugin' {
17567
17691
  * `push(new ChatResponseAnchorPart(value, title))`.
17568
17692
  * An anchor is an inline reference to some type of resource.
17569
17693
  *
17570
- * @param value A uri, location, or symbol information.
17694
+ * @param value A uri or location.
17571
17695
  * @param title An optional title that is rendered with value.
17696
+ * @stubbed
17572
17697
  */
17573
17698
  anchor(value: Uri | Location, title?: string): void;
17574
17699
 
@@ -17577,6 +17702,7 @@ export module '@theia/plugin' {
17577
17702
  * `push(new ChatResponseCommandButtonPart(value, title))`.
17578
17703
  *
17579
17704
  * @param command A Command that will be executed when the button is clicked.
17705
+ * @stubbed
17580
17706
  */
17581
17707
  button(command: Command): void;
17582
17708
 
@@ -17586,6 +17712,7 @@ export module '@theia/plugin' {
17586
17712
  *
17587
17713
  * @param value File tree data.
17588
17714
  * @param baseUri The base uri to which this file tree is relative.
17715
+ * @stubbed
17589
17716
  */
17590
17717
  filetree(value: ChatResponseFileTree[], baseUri: Uri): void;
17591
17718
 
@@ -17594,6 +17721,7 @@ export module '@theia/plugin' {
17594
17721
  * `push(new ChatResponseProgressPart(value))`.
17595
17722
  *
17596
17723
  * @param value A progress message
17724
+ * @stubbed
17597
17725
  */
17598
17726
  progress(value: string): void;
17599
17727
 
@@ -17605,32 +17733,27 @@ export module '@theia/plugin' {
17605
17733
  *
17606
17734
  * @param value A uri or location
17607
17735
  * @param iconPath Icon for the reference shown in UI
17736
+ * @stubbed
17608
17737
  */
17609
- reference(value: Uri | Location, iconPath?: Uri | ThemeIcon | {
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;
17738
+ reference(value: Uri | Location, iconPath?: IconPath): void;
17619
17739
 
17620
17740
  /**
17621
17741
  * Pushes a part to this stream.
17622
17742
  *
17623
17743
  * @param part A response part, rendered or metadata
17744
+ * @stubbed
17624
17745
  */
17625
17746
  push(part: ChatResponsePart): void;
17626
17747
  }
17627
17748
 
17628
17749
  /**
17629
17750
  * Represents a part of a chat response that is formatted as Markdown.
17751
+ * @stubbed
17630
17752
  */
17631
17753
  export class ChatResponseMarkdownPart {
17632
17754
  /**
17633
17755
  * A markdown string or a string that should be interpreted as markdown.
17756
+ * @stubbed
17634
17757
  */
17635
17758
  value: MarkdownString;
17636
17759
 
@@ -17638,36 +17761,43 @@ export module '@theia/plugin' {
17638
17761
  * Create a new ChatResponseMarkdownPart.
17639
17762
  *
17640
17763
  * @param value A markdown string or a string that should be interpreted as markdown. The boolean form of {@link MarkdownString.isTrusted} is NOT supported.
17764
+ * @stubbed
17641
17765
  */
17642
17766
  constructor(value: string | MarkdownString);
17643
17767
  }
17644
17768
 
17645
17769
  /**
17646
17770
  * Represents a file tree structure in a chat response.
17771
+ * @stubbed
17647
17772
  */
17648
17773
  export interface ChatResponseFileTree {
17649
17774
  /**
17650
17775
  * The name of the file or directory.
17776
+ * @stubbed
17651
17777
  */
17652
17778
  name: string;
17653
17779
 
17654
17780
  /**
17655
17781
  * An array of child file trees, if the current file tree is a directory.
17782
+ * @stubbed
17656
17783
  */
17657
17784
  children?: ChatResponseFileTree[];
17658
17785
  }
17659
17786
 
17660
17787
  /**
17661
17788
  * Represents a part of a chat response that is a file tree.
17789
+ * @stubbed
17662
17790
  */
17663
17791
  export class ChatResponseFileTreePart {
17664
17792
  /**
17665
17793
  * File tree data.
17794
+ * @stubbed
17666
17795
  */
17667
17796
  value: ChatResponseFileTree[];
17668
17797
 
17669
17798
  /**
17670
17799
  * The base uri to which this file tree is relative
17800
+ * @stubbed
17671
17801
  */
17672
17802
  baseUri: Uri;
17673
17803
 
@@ -17675,21 +17805,25 @@ export module '@theia/plugin' {
17675
17805
  * Create a new ChatResponseFileTreePart.
17676
17806
  * @param value File tree data.
17677
17807
  * @param baseUri The base uri to which this file tree is relative.
17808
+ * @stubbed
17678
17809
  */
17679
17810
  constructor(value: ChatResponseFileTree[], baseUri: Uri);
17680
17811
  }
17681
17812
 
17682
17813
  /**
17683
17814
  * Represents a part of a chat response that is an anchor, that is rendered as a link to a target.
17815
+ * @stubbed
17684
17816
  */
17685
17817
  export class ChatResponseAnchorPart {
17686
17818
  /**
17687
17819
  * The target of this anchor.
17820
+ * @stubbed
17688
17821
  */
17689
17822
  value: Uri | Location;
17690
17823
 
17691
17824
  /**
17692
17825
  * An optional title that is rendered with value.
17826
+ * @stubbed
17693
17827
  */
17694
17828
  title?: string;
17695
17829
 
@@ -17697,78 +17831,71 @@ export module '@theia/plugin' {
17697
17831
  * Create a new ChatResponseAnchorPart.
17698
17832
  * @param value A uri or location.
17699
17833
  * @param title An optional title that is rendered with value.
17834
+ * @stubbed
17700
17835
  */
17701
17836
  constructor(value: Uri | Location, title?: string);
17702
17837
  }
17703
17838
 
17704
17839
  /**
17705
17840
  * Represents a part of a chat response that is a progress message.
17841
+ * @stubbed
17706
17842
  */
17707
17843
  export class ChatResponseProgressPart {
17708
17844
  /**
17709
17845
  * The progress message
17846
+ * @stubbed
17710
17847
  */
17711
17848
  value: string;
17712
17849
 
17713
17850
  /**
17714
17851
  * Create a new ChatResponseProgressPart.
17715
17852
  * @param value A progress message
17853
+ * @stubbed
17716
17854
  */
17717
17855
  constructor(value: string);
17718
17856
  }
17719
17857
 
17720
17858
  /**
17721
17859
  * Represents a part of a chat response that is a reference, rendered separately from the content.
17860
+ * @stubbed
17722
17861
  */
17723
17862
  export class ChatResponseReferencePart {
17724
17863
  /**
17725
17864
  * The reference target.
17865
+ * @stubbed
17726
17866
  */
17727
17867
  value: Uri | Location;
17728
17868
 
17729
17869
  /**
17730
17870
  * The icon for the reference.
17871
+ * @stubbed
17731
17872
  */
17732
- iconPath?: Uri | ThemeIcon | {
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
- };
17873
+ iconPath?: IconPath;
17742
17874
 
17743
17875
  /**
17744
17876
  * Create a new ChatResponseReferencePart.
17745
17877
  * @param value A uri or location
17746
17878
  * @param iconPath Icon for the reference shown in UI
17879
+ * @stubbed
17747
17880
  */
17748
- constructor(value: Uri | Location, iconPath?: Uri | ThemeIcon | {
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
- });
17881
+ constructor(value: Uri | Location, iconPath?: IconPath);
17758
17882
  }
17759
17883
 
17760
17884
  /**
17761
17885
  * Represents a part of a chat response that is a button that executes a command.
17886
+ * @stubbed
17762
17887
  */
17763
17888
  export class ChatResponseCommandButtonPart {
17764
17889
  /**
17765
17890
  * The command that will be executed when the button is clicked.
17891
+ * @stubbed
17766
17892
  */
17767
17893
  value: Command;
17768
17894
 
17769
17895
  /**
17770
17896
  * Create a new ChatResponseCommandButtonPart.
17771
17897
  * @param value A Command that will be executed when the button is clicked.
17898
+ * @stubbed
17772
17899
  */
17773
17900
  constructor(value: Command);
17774
17901
  }
@@ -17813,6 +17940,7 @@ export module '@theia/plugin' {
17813
17940
 
17814
17941
  /**
17815
17942
  * Represents a message in a chat. Can assume different roles, like user or assistant.
17943
+ * @stubbed
17816
17944
  */
17817
17945
  export class LanguageModelChatMessage {
17818
17946
 
@@ -17821,64 +17949,80 @@ export module '@theia/plugin' {
17821
17949
  *
17822
17950
  * @param content The content of the message.
17823
17951
  * @param name The optional name of a user for the message.
17952
+ * @stubbed
17824
17953
  */
17825
- static User(content: string, name?: string): LanguageModelChatMessage;
17954
+ static User(content: string | Array<LanguageModelTextPart | LanguageModelToolResultPart>, name?: string): LanguageModelChatMessage;
17826
17955
 
17827
17956
  /**
17828
17957
  * Utility to create a new assistant message.
17829
17958
  *
17830
17959
  * @param content The content of the message.
17831
17960
  * @param name The optional name of a user for the message.
17961
+ * @stubbed
17832
17962
  */
17833
- static Assistant(content: string, name?: string): LanguageModelChatMessage;
17963
+ static Assistant(content: string | Array<(LanguageModelTextPart | LanguageModelToolCallPart)>, name?: string): LanguageModelChatMessage;
17834
17964
 
17835
17965
  /**
17836
17966
  * The role of this message.
17967
+ * @stubbed
17837
17968
  */
17838
17969
  role: LanguageModelChatMessageRole;
17839
17970
 
17840
17971
  /**
17841
- * The content of this message.
17972
+ * A string or heterogeneous array of things that a message can contain as content. Some parts may be message-type
17973
+ * specific for some models.
17974
+ * @stubbed
17842
17975
  */
17843
- content: string;
17976
+ content: Array<(LanguageModelTextPart | LanguageModelToolResultPart | LanguageModelToolCallPart)>;
17844
17977
 
17845
17978
  /**
17846
17979
  * The optional name of a user for this message.
17980
+ * @stubbed
17847
17981
  */
17848
17982
  name: string | undefined;
17849
17983
 
17850
17984
  /**
17851
17985
  * Create a new user message.
17986
+ * @stubbed
17852
17987
  *
17853
17988
  * @param role The role of the message.
17854
17989
  * @param content The content of the message.
17855
17990
  * @param name The optional name of a user for the message.
17856
17991
  */
17857
- constructor(role: LanguageModelChatMessageRole, content: string, name?: string);
17992
+ constructor(role: LanguageModelChatMessageRole, content: string | Array<LanguageModelTextPart | LanguageModelToolResultPart | LanguageModelToolCallPart>, name?: string);
17858
17993
  }
17859
17994
 
17860
17995
  /**
17861
17996
  * Represents a language model response.
17862
17997
  *
17863
17998
  * @see {@link LanguageModelAccess.chatRequest}
17999
+ * @stubbed
17864
18000
  */
17865
18001
  export interface LanguageModelChatResponse {
17866
18002
 
17867
18003
  /**
17868
- * An async iterable that is a stream of text chunks forming the overall response.
18004
+ * An async iterable that is a stream of text and tool-call parts forming the overall response. A
18005
+ * {@link LanguageModelTextPart} is part of the assistant's response to be shown to the user. A
18006
+ * {@link LanguageModelToolCallPart} is a request from the language model to call a tool. The latter will
18007
+ * only be returned if tools were passed in the request via {@link LanguageModelChatRequestOptions.tools}. The
18008
+ * `unknown`-type is used as a placeholder for future parts, like image data parts.
17869
18009
  *
17870
- * *Note* that this stream will error when during data receiving an error occurs. Consumers of
17871
- * the stream should handle the errors accordingly.
18010
+ * *Note* that this stream will error when during data receiving an error occurs. Consumers of the stream should handle
18011
+ * the errors accordingly.
17872
18012
  *
17873
- * To cancel the stream, the consumer can {@link CancellationTokenSource.cancel cancel} the token that was used to make the request
17874
- * or break from the for-loop.
18013
+ * To cancel the stream, the consumer can {@link CancellationTokenSource.cancel cancel} the token that was used to make
18014
+ * the request or break from the for-loop.
17875
18015
  *
17876
18016
  * @example
17877
18017
  * ```ts
17878
18018
  * try {
17879
18019
  * // consume stream
17880
- * for await (const chunk of response.text) {
17881
- * console.log(chunk);
18020
+ * for await (const chunk of response.stream) {
18021
+ * if (chunk instanceof LanguageModelTextPart) {
18022
+ * console.log("TEXT", chunk);
18023
+ * } else if (chunk instanceof LanguageModelToolCallPart) {
18024
+ * console.log("TOOL CALL", chunk);
18025
+ * }
17882
18026
  * }
17883
18027
  *
17884
18028
  * } catch(e) {
@@ -17886,6 +18030,15 @@ export module '@theia/plugin' {
17886
18030
  * console.error(e);
17887
18031
  * }
17888
18032
  * ```
18033
+ * @stubbed
18034
+ */
18035
+ stream: AsyncIterable<LanguageModelTextPart | LanguageModelToolCallPart | unknown>;
18036
+
18037
+ /**
18038
+ * This is equivalent to filtering everything except for text parts from a {@link LanguageModelChatResponse.stream}.
18039
+ *
18040
+ * @see {@link LanguageModelChatResponse.stream}
18041
+ * @stubbed
17889
18042
  */
17890
18043
  text: AsyncIterable<string>;
17891
18044
  }
@@ -17894,39 +18047,46 @@ export module '@theia/plugin' {
17894
18047
  * Represents a language model for making chat requests.
17895
18048
  *
17896
18049
  * @see {@link lm.selectChatModels}
18050
+ * @stubbed
17897
18051
  */
17898
18052
  export interface LanguageModelChat {
17899
18053
 
17900
18054
  /**
17901
18055
  * Human-readable name of the language model.
18056
+ * @stubbed
17902
18057
  */
17903
18058
  readonly name: string;
17904
18059
 
17905
18060
  /**
17906
18061
  * Opaque identifier of the language model.
18062
+ * @stubbed
17907
18063
  */
17908
18064
  readonly id: string;
17909
18065
 
17910
18066
  /**
17911
18067
  * A well-known identifier of the vendor of the language model. An example is `copilot`, but
17912
18068
  * values are defined by extensions contributing chat models and need to be looked up with them.
18069
+ * @stubbed
17913
18070
  */
17914
18071
  readonly vendor: string;
17915
18072
 
17916
18073
  /**
17917
18074
  * Opaque family-name of the language model. Values might be `gpt-3.5-turbo`, `gpt4`, `phi2`, or `llama`
17918
18075
  * but they are defined by extensions contributing languages and subject to change.
18076
+ * @stubbed
17919
18077
  */
17920
18078
  readonly family: string;
17921
18079
 
17922
18080
  /**
17923
18081
  * Opaque version string of the model. This is defined by the extension contributing the language model
17924
18082
  * and subject to change.
18083
+ * @stubbed
17925
18084
  */
17926
18085
  readonly version: string;
17927
18086
 
17928
18087
  /**
17929
18088
  * The maximum number of tokens that can be sent to the model in a single request.
18089
+ * @stubbed
17930
18090
  */
17931
18091
  readonly maxInputTokens: number;
17932
18092
 
@@ -17934,8 +18094,8 @@ export module '@theia/plugin' {
17934
18094
  * Make a chat request using a language model.
17935
18095
  *
17936
18096
  * *Note* that language model use may be subject to access restrictions and user consent. Calling this function
17937
- * for the first time (for a extension) will show a consent dialog to the user and because of that this function
17938
- * must _only be called in response to a user action!_ Extension can use {@link LanguageModelAccessInformation.canSendRequest}
18097
+ * for the first time (for an extension) will show a consent dialog to the user and because of that this function
18098
+ * must _only be called in response to a user action!_ Extensions can use {@link LanguageModelAccessInformation.canSendRequest}
17939
18099
  * to check if they have the necessary permissions to make a request.
17940
18100
  *
17941
18101
  * This function will return a rejected promise if making a request to the language model is not
@@ -17946,10 +18106,15 @@ export module '@theia/plugin' {
17946
18106
  * - quota limits exceeded, see {@link LanguageModelError.Blocked `Blocked`}
17947
18107
  * - other issues in which case extension must check {@link LanguageModelError.cause `LanguageModelError.cause`}
17948
18108
  *
18109
+ * An extension can make use of language model tool calling by passing a set of tools to
18110
+ * {@link LanguageModelChatRequestOptions.tools}. The language model will return a {@link LanguageModelToolCallPart} and
18111
+ * the extension can invoke the tool and make another request with the result.
18112
+ *
17949
18113
  * @param messages An array of message instances.
17950
18114
  * @param options Options that control the request.
17951
18115
  * @param token A cancellation token which controls the request. See {@link CancellationTokenSource} for how to create one.
17952
18116
  * @returns A thenable that resolves to a {@link LanguageModelChatResponse}. The promise will reject when the request couldn't be made.
18117
+ * @stubbed
17953
18118
  */
17954
18119
  sendRequest(messages: LanguageModelChatMessage[], options?: LanguageModelChatRequestOptions, token?: CancellationToken): Thenable<LanguageModelChatResponse>;
17955
18120
 
@@ -17958,6 +18123,7 @@ export module '@theia/plugin' {
17958
18123
  * @param text A string or a message instance.
17959
18124
  * @param token Optional cancellation token. See {@link CancellationTokenSource} for how to create one.
17960
18125
  * @returns A thenable that resolves to the number of tokens.
18126
+ * @stubbed
17961
18127
  */
17962
18128
  countTokens(text: string | LanguageModelChatMessage, token?: CancellationToken): Thenable<number>;
17963
18129
  }
@@ -17966,30 +18132,35 @@ export module '@theia/plugin' {
17966
18132
  * Describes how to select language models for chat requests.
17967
18133
  *
17968
18134
  * @see {@link lm.selectChatModels}
18135
+ * @stubbed
17969
18136
  */
17970
18137
  export interface LanguageModelChatSelector {
17971
18138
 
17972
18139
  /**
17973
18140
  * A vendor of language models.
17974
18141
  * @see {@link LanguageModelChat.vendor}
18142
+ * @stubbed
17975
18143
  */
17976
18144
  vendor?: string;
17977
18145
 
17978
18146
  /**
17979
18147
  * A family of language models.
17980
18148
  * @see {@link LanguageModelChat.family}
18149
+ * @stubbed
17981
18150
  */
17982
18151
  family?: string;
17983
18152
 
17984
18153
  /**
17985
18154
  * The version of a language model.
17986
18155
  * @see {@link LanguageModelChat.version}
18156
+ * @stubbed
17987
18157
  */
17988
18158
  version?: string;
17989
18159
 
17990
18160
  /**
17991
18161
  * The identifier of a language model.
17992
18162
  * @see {@link LanguageModelChat.id}
18163
+ * @stubbed
17993
18164
  */
17994
18165
  id?: string;
17995
18166
  }
@@ -18001,22 +18172,26 @@ export module '@theia/plugin' {
18001
18172
  * failure causes, like `if(someError.code === vscode.LanguageModelError.NotFound.name) {...}`
18002
18173
  * for the case of referring to an unknown language model. For unspecified errors the `cause`-property
18003
18174
  * will contain the actual error.
18175
+ * @stubbed
18004
18176
  */
18005
18177
  export class LanguageModelError extends Error {
18006
18178
 
18007
18179
  /**
18008
18180
  * The requestor does not have permissions to use this
18009
18181
  * language model
18182
+ * @stubbed
18010
18183
  */
18011
18184
  static NoPermissions(message?: string): LanguageModelError;
18012
18185
 
18013
18186
  /**
18014
18187
  * The requestor is blocked from using this language model.
18188
+ * @stubbed
18015
18189
  */
18016
18190
  static Blocked(message?: string): LanguageModelError;
18017
18191
 
18018
18192
  /**
18019
18193
  * The language model does not exist.
18194
+ * @stubbed
18020
18195
  */
18021
18196
  static NotFound(message?: string): LanguageModelError;
18022
18197
 
@@ -18026,6 +18201,7 @@ export module '@theia/plugin' {
18026
18201
  * Possible values are names of errors, like {@linkcode LanguageModelError.NotFound NotFound},
18027
18202
  * or `Unknown` for unspecified errors from the language model itself. In the latter case the
18028
18203
  * `cause`-property will contain the actual error.
18204
+ * @stubbed
18029
18205
  */
18030
18206
  readonly code: string;
18031
18207
  }
@@ -18034,19 +18210,42 @@ export module '@theia/plugin' {
18034
18210
  * Options for making a chat request using a language model.
18035
18211
  *
18036
18212
  * @see {@link LanguageModelChat.sendRequest}
18213
+ * @stubbed
18037
18214
  */
18038
18215
  export interface LanguageModelChatRequestOptions {
18039
18216
 
18040
18217
  /**
18041
18218
  * A human-readable message that explains why access to a language model is needed and what feature is enabled by it.
18219
+ * @stubbed
18042
18220
  */
18043
18221
  justification?: string;
18044
18222
 
18045
18223
  /**
18046
18224
  * A set of options that control the behavior of the language model. These options are specific to the language model
18047
18225
  * and need to be lookup in the respective documentation.
18226
+ * @stubbed
18048
18227
  */
18049
18228
  modelOptions?: { [name: string]: any };
18229
+
18230
+ /**
18231
+ * An optional list of tools that are available to the language model. These could be registered tools available via
18232
+ * {@link lm.tools}, or private tools that are just implemented within the calling extension.
18233
+ *
18234
+ * If the LLM requests to call one of these tools, it will return a {@link LanguageModelToolCallPart} in
18235
+ * {@link LanguageModelChatResponse.stream}. It's the caller's responsibility to invoke the tool. If it's a tool
18236
+ * registered in {@link lm.tools}, that means calling {@link lm.invokeTool}.
18237
+ *
18238
+ * Then, the tool result can be provided to the LLM by creating an Assistant-type {@link LanguageModelChatMessage} with a
18239
+ * {@link LanguageModelToolCallPart}, followed by a User-type message with a {@link LanguageModelToolResultPart}.
18240
+ * @stubbed
18241
+ */
18242
+ tools?: LanguageModelChatTool[];
18243
+
18244
+ /**
18245
+ * The tool-selecting mode to use. {@link LanguageModelChatToolMode.Auto} by default.
18246
+ * @stubbed
18247
+ */
18248
+ toolMode?: LanguageModelChatToolMode;
18050
18249
  }
18051
18250
 
18052
18251
  /**
@@ -18087,15 +18286,62 @@ export module '@theia/plugin' {
18087
18286
  * @stubbed
18088
18287
  */
18089
18288
  export function selectChatModels(selector?: LanguageModelChatSelector): Thenable<LanguageModelChat[]>;
18289
+
18290
+ /**
18291
+ * Register a LanguageModelTool. The tool must also be registered in the package.json `languageModelTools` contribution
18292
+ * point. A registered tool is available in the {@link lm.tools} list for any extension to see. But in order for it to
18293
+ * be seen by a language model, it must be passed in the list of available tools in {@link LanguageModelChatRequestOptions.tools}.
18294
+ * @returns A {@link Disposable} that unregisters the tool when disposed.
18295
+ * @stubbed
18296
+ */
18297
+ export function registerTool<T>(name: string, tool: LanguageModelTool<T>): Disposable;
18298
+
18299
+ /**
18300
+ * A list of all available tools that were registered by all extensions using {@link lm.registerTool}. They can be called
18301
+ * with {@link lm.invokeTool} with input that match their declared `inputSchema`.
18302
+ * @stubbed
18303
+ */
18304
+ export const tools: readonly LanguageModelToolInformation[];
18305
+
18306
+ /**
18307
+ * Invoke a tool listed in {@link lm.tools} by name with the given input. The input will be validated against
18308
+ * the schema declared by the tool
18309
+ *
18310
+ * A tool can be invoked by a chat participant, in the context of handling a chat request, or globally by any extension in
18311
+ * any custom flow.
18312
+ *
18313
+ * In the former case, the caller shall pass the
18314
+ * {@link LanguageModelToolInvocationOptions.toolInvocationToken toolInvocationToken}, which comes with the a
18315
+ * {@link ChatRequest.toolInvocationToken chat request}. This makes sure the chat UI shows the tool invocation for the
18316
+ * correct conversation.
18317
+ *
18318
+ * A tool {@link LanguageModelToolResult result} is an array of {@link LanguageModelTextPart text-} and
18319
+ * {@link LanguageModelPromptTsxPart prompt-tsx}-parts. If the tool caller is using `@vscode/prompt-tsx`, it can
18320
+ * incorporate the response parts into its prompt using a `ToolResult`. If not, the parts can be passed along to the
18321
+ * {@link LanguageModelChat} via a user message with a {@link LanguageModelToolResultPart}.
18322
+ *
18323
+ * If a chat participant wants to preserve tool results for requests across multiple turns, it can store tool results in
18324
+ * the {@link ChatResult.metadata} returned from the handler and retrieve them on the next turn from
18325
+ * {@link ChatResponseTurn.result}.
18326
+ *
18327
+ * @param name The name of the tool to call.
18328
+ * @param options The options to use when invoking the tool.
18329
+ * @param token A cancellation token. See {@link CancellationTokenSource} for how to create one.
18330
+ * @returns The result of the tool invocation.
18331
+ * @stubbed
18332
+ */
18333
+ export function invokeTool(name: string, options: LanguageModelToolInvocationOptions<object>, token?: CancellationToken): Thenable<LanguageModelToolResult>;
18090
18334
  }
18091
18335
 
18092
18336
  /**
18093
18337
  * Represents extension specific information about the access to language models.
18338
+ * @stubbed
18094
18339
  */
18095
18340
  export interface LanguageModelAccessInformation {
18096
18341
 
18097
18342
  /**
18098
18343
  * An event that fires when access information changes.
18344
+ * @stubbed
18099
18345
  */
18100
18346
  onDidChange: Event<void>;
18101
18347
 
@@ -18107,8 +18353,364 @@ export module '@theia/plugin' {
18107
18353
  * @param chat A language model chat object.
18108
18354
  * @return `true` if a request can be made, `false` if not, `undefined` if the language
18109
18355
  * model does not exist or consent hasn't been asked for.
18356
+ * @stubbed
18110
18357
  */
18111
18358
  canSendRequest(chat: LanguageModelChat): boolean | undefined;
18359
+
18360
+ }
18361
+
18362
+ /**
18363
+ * A tool that is available to the language model via {@link LanguageModelChatRequestOptions}. A language model uses all the
18364
+ * properties of this interface to decide which tool to call, and how to call it.
18365
+ * @stubbed
18366
+ */
18367
+ export interface LanguageModelChatTool {
18368
+ /**
18369
+ * The name of the tool.
18370
+ * @stubbed
18371
+ */
18372
+ name: string;
18373
+
18374
+ /**
18375
+ * The description of the tool.
18376
+ * @stubbed
18377
+ */
18378
+ description: string;
18379
+
18380
+ /**
18381
+ * A JSON schema for the input this tool accepts.
18382
+ * @stubbed
18383
+ */
18384
+ inputSchema?: object;
18385
+ }
18386
+
18387
+ /**
18388
+ * A tool-calling mode for the language model to use.
18389
+ */
18390
+ export enum LanguageModelChatToolMode {
18391
+ /**
18392
+ * The language model can choose to call a tool or generate a message. Is the default.
18393
+ */
18394
+ Auto = 1,
18395
+
18396
+ /**
18397
+ * The language model must call one of the provided tools. Note- some models only support a single tool when using this
18398
+ * mode.
18399
+ */
18400
+ Required = 2
18401
+ }
18402
+
18403
+ /**
18404
+ * A language model response part indicating a tool call, returned from a {@link LanguageModelChatResponse}, and also can be
18405
+ * included as a content part on a {@link LanguageModelChatMessage}, to represent a previous tool call in a chat request.
18406
+ * @stubbed
18407
+ */
18408
+ export class LanguageModelToolCallPart {
18409
+ /**
18410
+ * The ID of the tool call. This is a unique identifier for the tool call within the chat request.
18411
+ * @stubbed
18412
+ */
18413
+ callId: string;
18414
+
18415
+ /**
18416
+ * The name of the tool to call.
18417
+ * @stubbed
18418
+ */
18419
+ name: string;
18420
+
18421
+ /**
18422
+ * The input with which to call the tool.
18423
+ * @stubbed
18424
+ */
18425
+ input: object;
18426
+
18427
+ /**
18428
+ * Create a new LanguageModelToolCallPart.
18429
+ *
18430
+ * @param callId The ID of the tool call.
18431
+ * @param name The name of the tool to call.
18432
+ * @param input The input with which to call the tool.
18433
+ * @stubbed
18434
+ */
18435
+ constructor(callId: string, name: string, input: object);
18436
+ }
18437
+
18438
+ /**
18439
+ * The result of a tool call. This is the counterpart of a {@link LanguageModelToolCallPart tool call} and
18440
+ * it can only be included in the content of a User message
18441
+ * @stubbed
18442
+ */
18443
+ export class LanguageModelToolResultPart {
18444
+ /**
18445
+ * The ID of the tool call.
18446
+ *
18447
+ * *Note* that this should match the {@link LanguageModelToolCallPart.callId callId} of a tool call part.
18448
+ * @stubbed
18449
+ */
18450
+ callId: string;
18451
+
18452
+ /**
18453
+ * The value of the tool result.
18454
+ * @stubbed
18455
+ */
18456
+ content: Array<LanguageModelTextPart | LanguageModelPromptTsxPart | unknown>;
18457
+
18458
+ /**
18459
+ * @param callId The ID of the tool call.
18460
+ * @param content The content of the tool result.
18461
+ * @stubbed
18462
+ */
18463
+ constructor(callId: string, content: Array<(LanguageModelTextPart | LanguageModelPromptTsxPart | unknown)>);
18464
+ }
18465
+
18466
+ /**
18467
+ * A language model response part containing a piece of text, returned from a {@link LanguageModelChatResponse}.
18468
+ * @stubbed
18469
+ */
18470
+ export class LanguageModelTextPart {
18471
+ /**
18472
+ * The text content of the part.
18473
+ * @stubbed
18474
+ */
18475
+ value: string;
18476
+
18477
+ /**
18478
+ * Construct a text part with the given content.
18479
+ * @param value The text content of the part.
18480
+ * @stubbed
18481
+ */
18482
+ constructor(value: string);
18483
+ }
18484
+
18485
+ /**
18486
+ * A language model response part containing a PromptElementJSON from `@vscode/prompt-tsx`.
18487
+ * @see {@link LanguageModelToolResult}
18488
+ * @stubbed
18489
+ */
18490
+ export class LanguageModelPromptTsxPart {
18491
+ /**
18492
+ * The value of the part.
18493
+ * @stubbed
18494
+ */
18495
+ value: unknown;
18496
+
18497
+ /**
18498
+ * Construct a prompt-tsx part with the given content.
18499
+ * @param value The value of the part, the result of `renderPromptElementJSON` from `@vscode/prompt-tsx`.
18500
+ * @stubbed
18501
+ */
18502
+ constructor(value: unknown);
18503
+ }
18504
+
18505
+ /**
18506
+ * A result returned from a tool invocation. If using `@vscode/prompt-tsx`, this result may be rendered using a `ToolResult`.
18507
+ * @stubbed
18508
+ */
18509
+ export class LanguageModelToolResult {
18510
+ /**
18511
+ * A list of tool result content parts. Includes `unknown` becauses this list may be extended with new content types in
18512
+ * the future.
18513
+ * @see {@link lm.invokeTool}.
18514
+ * @stubbed
18515
+ */
18516
+ content: Array<(LanguageModelTextPart | LanguageModelPromptTsxPart | unknown)>;
18517
+
18518
+ /**
18519
+ * Create a LanguageModelToolResult
18520
+ * @param content A list of tool result content parts
18521
+ * @stubbed
18522
+ */
18523
+ constructor(content: Array<(LanguageModelTextPart | LanguageModelPromptTsxPart)>);
18524
+ }
18525
+
18526
+ /**
18527
+ * A token that can be passed to {@link lm.invokeTool} when invoking a tool inside the context of handling a chat request.
18528
+ */
18529
+ export type ChatParticipantToolToken = never;
18530
+
18531
+ /**
18532
+ * Options provided for tool invocation.
18533
+ * @stubbed
18534
+ */
18535
+ export interface LanguageModelToolInvocationOptions<T> {
18536
+ /**
18537
+ * An opaque object that ties a tool invocation to a chat request from a {@link ChatParticipant chat participant}.
18538
+ *
18539
+ * The _only_ way to get a valid tool invocation token is using the provided {@link ChatRequest.toolInvocationToken toolInvocationToken}
18540
+ * 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
18541
+ * the tool requires user confirmation, it will show up inline in the chat view.
18542
+ *
18543
+ * If the tool is being invoked outside of a chat request, `undefined` should be passed instead, and no special UI except for
18544
+ * confirmations will be shown.
18545
+ *
18546
+ * *Note* that a tool that invokes another tool during its invocation, can pass along the `toolInvocationToken` that it received.
18547
+ * @stubbed
18548
+ */
18549
+ toolInvocationToken: ChatParticipantToolToken | undefined;
18550
+
18551
+ /**
18552
+ * The input with which to invoke the tool. The input must match the schema defined in
18553
+ * {@link LanguageModelToolInformation.inputSchema}
18554
+ * @stubbed
18555
+ */
18556
+ input: T;
18557
+
18558
+ /**
18559
+ * Options to hint at how many tokens the tool should return in its response, and enable the tool to count tokens
18560
+ * accurately.
18561
+ * @stubbed
18562
+ */
18563
+ tokenizationOptions?: LanguageModelToolTokenizationOptions;
18564
+ }
18565
+
18566
+ /**
18567
+ * Options related to tokenization for a tool invocation.
18568
+ * @stubbed
18569
+ */
18570
+ export interface LanguageModelToolTokenizationOptions {
18571
+ /**
18572
+ * If known, the maximum number of tokens the tool should emit in its result.
18573
+ * @stubbed
18574
+ */
18575
+ tokenBudget: number;
18576
+
18577
+ /**
18578
+ * Count the number of tokens in a message using the model specific tokenizer-logic.
18579
+ * @param text A string.
18580
+ * @param token Optional cancellation token. See {@link CancellationTokenSource} for how to create one.
18581
+ * @returns A thenable that resolves to the number of tokens.
18582
+ * @stubbed
18583
+ */
18584
+ countTokens(text: string, token?: CancellationToken): Thenable<number>;
18585
+ }
18586
+
18587
+ /**
18588
+ * Information about a registered tool available in {@link lm.tools}.
18589
+ * @stubbed
18590
+ */
18591
+ export interface LanguageModelToolInformation {
18592
+ /**
18593
+ * A unique name for the tool.
18594
+ * @stubbed
18595
+ */
18596
+ readonly name: string;
18597
+
18598
+ /**
18599
+ * A description of this tool that may be passed to a language model.
18600
+ * @stubbed
18601
+ */
18602
+ readonly description: string;
18603
+
18604
+ /**
18605
+ * A JSON schema for the input this tool accepts.
18606
+ * @stubbed
18607
+ */
18608
+ readonly inputSchema: object | undefined;
18609
+
18610
+ /**
18611
+ * A set of tags, declared by the tool, that roughly describe the tool's capabilities. A tool user may use these to filter
18612
+ * the set of tools to just ones that are relevant for the task at hand.
18613
+ * @stubbed
18614
+ */
18615
+ readonly tags: readonly string[];
18616
+ }
18617
+
18618
+ /**
18619
+ * Options for {@link LanguageModelTool.prepareInvocation}.
18620
+ * @stubbed
18621
+ */
18622
+ export interface LanguageModelToolInvocationPrepareOptions<T> {
18623
+ /**
18624
+ * The input that the tool is being invoked with.
18625
+ * @stubbed
18626
+ */
18627
+ input: T;
18628
+ }
18629
+
18630
+ /**
18631
+ * A tool that can be invoked by a call to a {@link LanguageModelChat}.
18632
+ * @stubbed
18633
+ */
18634
+ export interface LanguageModelTool<T> {
18635
+ /**
18636
+ * Invoke the tool with the given input and return a result.
18637
+ *
18638
+ * The provided {@link LanguageModelToolInvocationOptions.input} has been validated against the declared schema.
18639
+ * @stubbed
18640
+ */
18641
+ invoke(options: LanguageModelToolInvocationOptions<T>, token: CancellationToken): ProviderResult<LanguageModelToolResult>;
18642
+
18643
+ /**
18644
+ * Called once before a tool is invoked. It's recommended to implement this to customize the progress message that appears
18645
+ * while the tool is running, and to provide a more useful message with context from the invocation input. Can also
18646
+ * signal that a tool needs user confirmation before running, if appropriate.
18647
+ *
18648
+ * * *Note 1:* Must be free of side-effects.
18649
+ * * *Note 2:* A call to `prepareInvocation` is not necessarily followed by a call to `invoke`.
18650
+ * @stubbed
18651
+ */
18652
+ prepareInvocation?(options: LanguageModelToolInvocationPrepareOptions<T>, token: CancellationToken): ProviderResult<PreparedToolInvocation>;
18653
+ }
18654
+
18655
+ /**
18656
+ * When this is returned in {@link PreparedToolInvocation}, the user will be asked to confirm before running the tool. These
18657
+ * messages will be shown with buttons that say "Continue" and "Cancel".
18658
+ * @stubbed
18659
+ */
18660
+ export interface LanguageModelToolConfirmationMessages {
18661
+ /**
18662
+ * The title of the confirmation message.
18663
+ * @stubbed
18664
+ */
18665
+ title: string;
18666
+
18667
+ /**
18668
+ * The body of the confirmation message.
18669
+ * @stubbed
18670
+ */
18671
+ message: string | MarkdownString;
18672
+ }
18673
+
18674
+ /**
18675
+ * The result of a call to {@link LanguageModelTool.prepareInvocation}.
18676
+ * @stubbed
18677
+ */
18678
+ export interface PreparedToolInvocation {
18679
+ /**
18680
+ * A customized progress message to show while the tool runs.
18681
+ * @stubbed
18682
+ */
18683
+ invocationMessage?: string | MarkdownString;
18684
+
18685
+ /**
18686
+ * The presence of this property indicates that the user should be asked to confirm before running the tool. The user
18687
+ * should be asked for confirmation for any tool that has a side-effect or may potentially be dangerous.
18688
+ * @stubbed
18689
+ */
18690
+ confirmationMessages?: LanguageModelToolConfirmationMessages;
18691
+ }
18692
+
18693
+ /**
18694
+ * A reference to a tool that the user manually attached to their request, either using the `#`-syntax inline, or as an
18695
+ * attachment via the paperclip button.
18696
+ * @stubbed
18697
+ */
18698
+ export interface ChatLanguageModelToolReference {
18699
+ /**
18700
+ * The tool name. Refers to a tool listed in {@link lm.tools}.
18701
+ * @stubbed
18702
+ */
18703
+ readonly name: string;
18704
+
18705
+ /**
18706
+ * The start and end index of the reference in the {@link ChatRequest.prompt prompt}. When undefined, the reference was
18707
+ * not part of the prompt text.
18708
+ *
18709
+ * *Note* that the indices take the leading `#`-character into account which means they can be used to modify the prompt
18710
+ * as-is.
18711
+ * @stubbed
18712
+ */
18713
+ readonly range?: [start: number, end: number];
18112
18714
  }
18113
18715
 
18114
18716
  /**