@theia/plugin-ext 1.50.0 → 1.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/lib/common/plugin-api-rpc.d.ts +13 -2
  2. package/lib/common/plugin-api-rpc.d.ts.map +1 -1
  3. package/lib/common/plugin-api-rpc.js +12 -1
  4. package/lib/common/plugin-api-rpc.js.map +1 -1
  5. package/lib/common/proxy-handler.d.ts.map +1 -1
  6. package/lib/common/proxy-handler.js +3 -1
  7. package/lib/common/proxy-handler.js.map +1 -1
  8. package/lib/common/test-types.d.ts +1 -0
  9. package/lib/common/test-types.d.ts.map +1 -1
  10. package/lib/common/test-types.js.map +1 -1
  11. package/lib/hosted/browser/hosted-plugin.d.ts.map +1 -1
  12. package/lib/hosted/browser/hosted-plugin.js +2 -0
  13. package/lib/hosted/browser/hosted-plugin.js.map +1 -1
  14. package/lib/hosted/browser/worker/worker-env-ext.d.ts +0 -3
  15. package/lib/hosted/browser/worker/worker-env-ext.d.ts.map +1 -1
  16. package/lib/hosted/browser/worker/worker-env-ext.js +2 -4
  17. package/lib/hosted/browser/worker/worker-env-ext.js.map +1 -1
  18. package/lib/main/browser/documents-main.d.ts +2 -4
  19. package/lib/main/browser/documents-main.d.ts.map +1 -1
  20. package/lib/main/browser/documents-main.js +2 -18
  21. package/lib/main/browser/documents-main.js.map +1 -1
  22. package/lib/main/browser/editors-and-documents-main.d.ts +2 -1
  23. package/lib/main/browser/editors-and-documents-main.d.ts.map +1 -1
  24. package/lib/main/browser/editors-and-documents-main.js +12 -5
  25. package/lib/main/browser/editors-and-documents-main.js.map +1 -1
  26. package/lib/main/browser/main-context.d.ts.map +1 -1
  27. package/lib/main/browser/main-context.js +4 -6
  28. package/lib/main/browser/main-context.js.map +1 -1
  29. package/lib/main/browser/notebooks/renderers/cell-output-webview.d.ts +7 -0
  30. package/lib/main/browser/notebooks/renderers/cell-output-webview.d.ts.map +1 -1
  31. package/lib/main/browser/notebooks/renderers/cell-output-webview.js +30 -4
  32. package/lib/main/browser/notebooks/renderers/cell-output-webview.js.map +1 -1
  33. package/lib/main/browser/notebooks/renderers/output-webview-internal.d.ts.map +1 -1
  34. package/lib/main/browser/notebooks/renderers/output-webview-internal.js +15 -0
  35. package/lib/main/browser/notebooks/renderers/output-webview-internal.js.map +1 -1
  36. package/lib/main/browser/notebooks/renderers/webview-communication.d.ts +5 -1
  37. package/lib/main/browser/notebooks/renderers/webview-communication.d.ts.map +1 -1
  38. package/lib/main/browser/tabs/tabs-main.d.ts +5 -3
  39. package/lib/main/browser/tabs/tabs-main.d.ts.map +1 -1
  40. package/lib/main/browser/tabs/tabs-main.js +37 -13
  41. package/lib/main/browser/tabs/tabs-main.js.map +1 -1
  42. package/lib/main/browser/test-main.d.ts +3 -2
  43. package/lib/main/browser/test-main.d.ts.map +1 -1
  44. package/lib/main/browser/test-main.js +7 -3
  45. package/lib/main/browser/test-main.js.map +1 -1
  46. package/lib/main/browser/text-editor-model-service.d.ts +1 -0
  47. package/lib/main/browser/text-editor-model-service.d.ts.map +1 -1
  48. package/lib/main/browser/text-editor-model-service.js +8 -0
  49. package/lib/main/browser/text-editor-model-service.js.map +1 -1
  50. package/lib/main/browser/view/tree-views-main.d.ts +0 -1
  51. package/lib/main/browser/view/tree-views-main.d.ts.map +1 -1
  52. package/lib/main/browser/view/tree-views-main.js +0 -3
  53. package/lib/main/browser/view/tree-views-main.js.map +1 -1
  54. package/lib/main/browser/view/view-context-key-service.d.ts +0 -2
  55. package/lib/main/browser/view/view-context-key-service.d.ts.map +1 -1
  56. package/lib/main/browser/view/view-context-key-service.js +0 -4
  57. package/lib/main/browser/view/view-context-key-service.js.map +1 -1
  58. package/lib/main/browser/window-state-main.js +1 -1
  59. package/lib/main/browser/window-state-main.js.map +1 -1
  60. package/lib/plugin/plugin-context.d.ts.map +1 -1
  61. package/lib/plugin/plugin-context.js +42 -2
  62. package/lib/plugin/plugin-context.js.map +1 -1
  63. package/lib/plugin/plugin-manager.d.ts +3 -1
  64. package/lib/plugin/plugin-manager.d.ts.map +1 -1
  65. package/lib/plugin/plugin-manager.js +13 -1
  66. package/lib/plugin/plugin-manager.js.map +1 -1
  67. package/lib/plugin/tests.d.ts +2 -2
  68. package/lib/plugin/tests.d.ts.map +1 -1
  69. package/lib/plugin/tests.js +12 -13
  70. package/lib/plugin/tests.js.map +1 -1
  71. package/lib/plugin/types-impl.d.ts +84 -1
  72. package/lib/plugin/types-impl.d.ts.map +1 -1
  73. package/lib/plugin/types-impl.js +106 -4
  74. package/lib/plugin/types-impl.js.map +1 -1
  75. package/package.json +29 -29
  76. package/src/common/plugin-api-rpc.ts +15 -2
  77. package/src/common/proxy-handler.ts +3 -1
  78. package/src/common/test-types.ts +1 -0
  79. package/src/hosted/browser/hosted-plugin.ts +3 -1
  80. package/src/hosted/browser/worker/worker-env-ext.ts +2 -4
  81. package/src/main/browser/documents-main.ts +3 -21
  82. package/src/main/browser/editors-and-documents-main.ts +13 -5
  83. package/src/main/browser/main-context.ts +5 -7
  84. package/src/main/browser/notebooks/renderers/cell-output-webview.tsx +33 -4
  85. package/src/main/browser/notebooks/renderers/output-webview-internal.ts +18 -0
  86. package/src/main/browser/notebooks/renderers/webview-communication.ts +12 -1
  87. package/src/main/browser/tabs/tabs-main.ts +39 -15
  88. package/src/main/browser/test-main.ts +8 -3
  89. package/src/main/browser/text-editor-model-service.ts +9 -0
  90. package/src/main/browser/view/tree-views-main.ts +0 -4
  91. package/src/main/browser/view/view-context-key-service.ts +0 -6
  92. package/src/main/browser/window-state-main.ts +1 -1
  93. package/src/plugin/plugin-context.ts +59 -4
  94. package/src/plugin/plugin-manager.ts +17 -3
  95. package/src/plugin/tests.ts +14 -14
  96. package/src/plugin/types-impl.ts +121 -0
@@ -19,7 +19,7 @@
19
19
 
20
20
  import type * as theia from '@theia/plugin';
21
21
  import { CommandRegistryImpl } from './command-registry';
22
- import { Emitter } from '@theia/core/lib/common/event';
22
+ import { Emitter, Event } from '@theia/core/lib/common/event';
23
23
  import { CancellationError, CancellationToken, CancellationTokenSource } from '@theia/core/lib/common/cancellation';
24
24
  import { QuickOpenExtImpl } from './quick-open';
25
25
  import {
@@ -124,6 +124,8 @@ import {
124
124
  Breakpoint,
125
125
  SourceBreakpoint,
126
126
  FunctionBreakpoint,
127
+ DebugStackFrame,
128
+ DebugThread,
127
129
  FoldingRange,
128
130
  FoldingRangeKind,
129
131
  SelectionRange,
@@ -211,7 +213,19 @@ import {
211
213
  DeclarationCoverage,
212
214
  FileCoverage,
213
215
  StatementCoverage,
214
- TestCoverageCount
216
+ TestCoverageCount,
217
+ ChatRequestTurn,
218
+ ChatResponseTurn,
219
+ ChatResponseAnchorPart,
220
+ ChatResponseCommandButtonPart,
221
+ ChatResponseFileTreePart,
222
+ ChatResponseMarkdownPart,
223
+ ChatResponseProgressPart,
224
+ ChatResponseReferencePart,
225
+ ChatResultFeedbackKind,
226
+ LanguageModelChatMessage,
227
+ LanguageModelChatMessageRole,
228
+ LanguageModelError
215
229
  } from './types-impl';
216
230
  import { AuthenticationExtImpl } from './authentication-ext';
217
231
  import { SymbolKind } from '../common/plugin-api-rpc-model';
@@ -1078,6 +1092,14 @@ export function createAPIFactory(
1078
1092
  get onDidChangeBreakpoints(): theia.Event<theia.BreakpointsChangeEvent> {
1079
1093
  return debugExt.onDidChangeBreakpoints;
1080
1094
  },
1095
+ /** @stubbed */
1096
+ get activeStackItem(): DebugThread | DebugStackFrame | undefined {
1097
+ return undefined;
1098
+ },
1099
+ /** @stubbed */
1100
+ get onDidChangeActiveStackItem(): theia.Event<DebugThread | DebugStackFrame | undefined> {
1101
+ return Event.None;
1102
+ },
1081
1103
  registerDebugAdapterDescriptorFactory(debugType: string, factory: theia.DebugAdapterDescriptorFactory): Disposable {
1082
1104
  return debugExt.registerDebugAdapterDescriptorFactory(debugType, factory);
1083
1105
  },
@@ -1223,9 +1245,27 @@ export function createAPIFactory(
1223
1245
  /** @stubbed MappedEditsProvider */
1224
1246
  registerMappedEditsProvider(documentSelector: theia.DocumentSelector, provider: theia.MappedEditsProvider): Disposable {
1225
1247
  return Disposable.NULL;
1248
+ },
1249
+ /** @stubbed ChatRequestHandler */
1250
+ createChatParticipant(id: string, handler: theia.ChatRequestHandler): theia.ChatParticipant {
1251
+ return {
1252
+ id,
1253
+ requestHandler: handler,
1254
+ dispose() {},
1255
+ onDidReceiveFeedback: (listener, thisArgs?, disposables?) => Event.None(listener, thisArgs, disposables)
1256
+ };
1226
1257
  }
1227
1258
  };
1228
1259
 
1260
+ const lm: typeof theia.lm = {
1261
+ /** @stubbed LanguageModelChat */
1262
+ selectChatModels(selector?: theia.LanguageModelChatSelector): Thenable<theia.LanguageModelChat[]> {
1263
+ return Promise.resolve([]);
1264
+ },
1265
+ /** @stubbed LanguageModelChat */
1266
+ onDidChangeChatModels: (listener, thisArgs?, disposables?) => Event.None(listener, thisArgs, disposables)
1267
+ };
1268
+
1229
1269
  return <typeof theia>{
1230
1270
  version: require('../../package.json').version,
1231
1271
  authentication,
@@ -1244,6 +1284,7 @@ export function createAPIFactory(
1244
1284
  notebooks,
1245
1285
  l10n,
1246
1286
  tests,
1287
+ lm,
1247
1288
  // Types
1248
1289
  StatusBarAlignment: StatusBarAlignment,
1249
1290
  Disposable: Disposable,
@@ -1341,6 +1382,8 @@ export function createAPIFactory(
1341
1382
  Breakpoint,
1342
1383
  SourceBreakpoint,
1343
1384
  FunctionBreakpoint,
1385
+ DebugStackFrame,
1386
+ DebugThread,
1344
1387
  Color,
1345
1388
  ColorInformation,
1346
1389
  ColorPresentation,
@@ -1426,7 +1469,19 @@ export function createAPIFactory(
1426
1469
  DeclarationCoverage,
1427
1470
  FileCoverage,
1428
1471
  StatementCoverage,
1429
- TestCoverageCount
1472
+ TestCoverageCount,
1473
+ ChatRequestTurn,
1474
+ ChatResponseTurn,
1475
+ ChatResponseAnchorPart,
1476
+ ChatResponseCommandButtonPart,
1477
+ ChatResponseFileTreePart,
1478
+ ChatResponseMarkdownPart,
1479
+ ChatResponseProgressPart,
1480
+ ChatResponseReferencePart,
1481
+ ChatResultFeedbackKind,
1482
+ LanguageModelChatMessage,
1483
+ LanguageModelChatMessageRole,
1484
+ LanguageModelError
1430
1485
  };
1431
1486
  };
1432
1487
  }
@@ -1508,7 +1563,7 @@ export class PluginExt<T> extends Plugin<T> implements ExtensionPlugin<T> {
1508
1563
 
1509
1564
  this.extensionPath = this.pluginPath;
1510
1565
  this.extensionUri = this.pluginUri;
1511
- this.extensionKind = ExtensionKind.UI; // stub as a local extension (not running on a remote workspace)
1566
+ this.extensionKind = pluginManager.getPluginKind();
1512
1567
  this.isFromDifferentExtensionHost = isFromDifferentExtensionHost;
1513
1568
  }
1514
1569
 
@@ -29,7 +29,8 @@ import {
29
29
  PluginManagerInitializeParams,
30
30
  PluginManagerStartParams,
31
31
  TerminalServiceExt,
32
- LocalizationExt
32
+ LocalizationExt,
33
+ ExtensionKind
33
34
  } from '../common/plugin-api-rpc';
34
35
  import { PluginMetadata, PluginJsonValidationContribution } from '../common/plugin-protocol';
35
36
  import * as theia from '@theia/plugin';
@@ -40,7 +41,7 @@ import { PreferenceRegistryExtImpl } from './preference-registry';
40
41
  import { InternalStorageExt, Memento, GlobalState } from './plugin-storage';
41
42
  import { ExtPluginApi } from '../common/plugin-ext-api-contribution';
42
43
  import { RPCProtocol } from '../common/rpc-protocol';
43
- import { Emitter } from '@theia/core/lib/common/event';
44
+ import { Emitter, Event } from '@theia/core/lib/common/event';
44
45
  import { WebviewsExtImpl } from './webviews';
45
46
  import { URI as Uri } from './types-impl';
46
47
  import { InternalSecretsExt, SecretStorageExt } from '../plugin/secrets-ext';
@@ -121,6 +122,7 @@ export abstract class AbstractPluginManagerExtImpl<P extends Record<string, any>
121
122
  private notificationMain: NotificationMain;
122
123
 
123
124
  protected jsonValidation: PluginJsonValidationContribution[] = [];
125
+ protected pluginKind = ExtensionKind.UI;
124
126
  protected ready = new Deferred();
125
127
 
126
128
  @postConstruct()
@@ -389,7 +391,14 @@ export abstract class AbstractPluginManagerExtImpl<P extends Record<string, any>
389
391
  environmentVariableCollection: this.terminalService.getEnvironmentVariableCollection(plugin.model.id),
390
392
  extensionMode: extensionModeValue,
391
393
  extension,
392
- logUri: Uri.file(logPath)
394
+ logUri: Uri.file(logPath),
395
+ languageModelAccessInformation: {
396
+ /** @stubbed LanguageModelChat */
397
+ onDidChange: (listener, thisArgs?, disposables?) => Event.None(listener, thisArgs, disposables),
398
+ canSendRequest(chat: theia.LanguageModelChat): boolean | undefined {
399
+ return undefined;
400
+ }
401
+ }
393
402
  };
394
403
  this.pluginContextsMap.set(plugin.model.id, pluginContext);
395
404
 
@@ -410,6 +419,10 @@ export abstract class AbstractPluginManagerExtImpl<P extends Record<string, any>
410
419
  }
411
420
  }
412
421
 
422
+ getPluginKind(): theia.ExtensionKind {
423
+ return this.pluginKind;
424
+ }
425
+
413
426
  getAllPlugins(): Plugin[] {
414
427
  return Array.from(this.registry.values());
415
428
  }
@@ -477,6 +490,7 @@ export class PluginManagerExtImpl extends AbstractPluginManagerExtImpl<PluginMan
477
490
 
478
491
  this.webview.init(params.webview);
479
492
  this.jsonValidation = params.jsonValidation;
493
+ this.pluginKind = params.pluginKind;
480
494
 
481
495
  this.supportedActivationEvents = new Set(params.supportedActivationEvents ?? []);
482
496
  }
@@ -135,7 +135,7 @@ export class TestControllerImpl implements theia.TestController {
135
135
  }
136
136
 
137
137
  createTestRun(request: theia.TestRunRequest, name?: string, persist: boolean = true): theia.TestRun {
138
- return this.testRunStarted(request, name || '', persist, true);
138
+ return this.testRunStarted(request, name || '', persist, true);
139
139
  }
140
140
 
141
141
  dispose() {
@@ -149,7 +149,7 @@ export class TestControllerImpl implements theia.TestController {
149
149
  return existing;
150
150
  }
151
151
 
152
- const run = new TestRun(this, this.proxy, name, persist, isRunning);
152
+ const run = new TestRun(this, this.proxy, name, persist, isRunning, request.preserveFocus);
153
153
  const endListener = run.onWillFlush(() => {
154
154
  // make sure we notify the front end of test item changes before test run state is sent
155
155
  this.deltaBuilder.flush();
@@ -162,7 +162,7 @@ export class TestControllerImpl implements theia.TestController {
162
162
  return run;
163
163
  }
164
164
 
165
- runTestsForUI(profileId: string, name: string, includedTests: string[][], excludedTests: string[][]): void {
165
+ runTestsForUI(profileId: string, name: string, includedTests: string[][], excludedTests: string[][], preserveFocus: boolean): void {
166
166
  const profile = this.getProfile(profileId);
167
167
  if (!profile) {
168
168
  console.error(`No test run profile found for controller ${this.id} with id ${profileId} `);
@@ -197,7 +197,7 @@ export class TestControllerImpl implements theia.TestController {
197
197
  .filter(isDefined);
198
198
 
199
199
  const request = new TestRunRequest(
200
- includeTests, excludeTests, profile, false // don't support continuous run yet
200
+ includeTests, excludeTests, profile, false /* don't support continuous run yet */, preserveFocus
201
201
  );
202
202
 
203
203
  const run = this.testRunStarted(request, name, false, false);
@@ -258,13 +258,14 @@ class TestRun implements theia.TestRun {
258
258
  private readonly proxy: TestingMain,
259
259
  readonly name: string,
260
260
  readonly isPersisted: boolean,
261
- isRunning: boolean) {
261
+ isRunning: boolean,
262
+ preserveFocus: boolean) {
262
263
  this.id = generateUuid();
263
264
 
264
265
  this.tokenSource = new CancellationTokenSource();
265
266
  this.token = this.tokenSource.token;
266
267
 
267
- this.proxy.$notifyTestRunCreated(this.controller.id, { id: this.id, name: this.name, isRunning });
268
+ this.proxy.$notifyTestRunCreated(this.controller.id, { id: this.id, name: this.name, isRunning }, preserveFocus);
268
269
  }
269
270
  enqueued(test: theia.TestItem): void {
270
271
  this.updateTestState(test, { itemPath: checkTestInstance(test).path, state: TestExecutionState.Queued });
@@ -444,7 +445,7 @@ export class TestingExtImpl implements TestingExt {
444
445
  }
445
446
 
446
447
  runTestsForUI(req: TestRunRequestDTO): void {
447
- this.withController(req.controllerId).runTestsForUI(req.profileId, req.name, req.includedTests, req.excludedTests);
448
+ this.withController(req.controllerId).runTestsForUI(req.profileId, req.name, req.includedTests, req.excludedTests, req.preserveFocus);
448
449
  }
449
450
 
450
451
  /**
@@ -469,13 +470,7 @@ export class TestRunProfile implements theia.TestRunProfile {
469
470
  isDefault = false,
470
471
  tag: theia.TestTag | undefined = undefined,
471
472
  ) {
472
- this.proxy = proxy;
473
- this.label = label;
474
- this.tag = tag;
475
- this.label = label;
476
- this.isDefault = isDefault;
477
-
478
- this.proxy.$notifyTestRunProfileCreated(controllerId, {
473
+ proxy.$notifyTestRunProfileCreated(controllerId, {
479
474
  id: profileId,
480
475
  kind: kind,
481
476
  tag: tag ? tag.toString() : '',
@@ -483,6 +478,11 @@ export class TestRunProfile implements theia.TestRunProfile {
483
478
  isDefault: isDefault,
484
479
  canConfigure: false,
485
480
  });
481
+ this.proxy = proxy;
482
+ this.label = label;
483
+ this.tag = tag;
484
+ this.label = label;
485
+ this.isDefault = isDefault;
486
486
  }
487
487
 
488
488
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -3028,6 +3028,14 @@ export class FunctionBreakpoint extends Breakpoint {
3028
3028
  }
3029
3029
  }
3030
3030
 
3031
+ export class DebugThread {
3032
+ private constructor(readonly session: theia.DebugSession, readonly threadId: number) { }
3033
+ }
3034
+
3035
+ export class DebugStackFrame {
3036
+ private constructor(readonly session: theia.DebugSession, readonly threadId: number, readonly frameId: number) { }
3037
+ }
3038
+
3031
3039
  @es5ClassCompat
3032
3040
  export class Color {
3033
3041
  readonly red: number;
@@ -3329,6 +3337,7 @@ export class TestRunRequest implements theia.TestRunRequest {
3329
3337
  public readonly exclude: theia.TestItem[] | undefined = undefined,
3330
3338
  public readonly profile: theia.TestRunProfile | undefined = undefined,
3331
3339
  public readonly continuous: boolean | undefined = undefined,
3340
+ public readonly preserveFocus: boolean = true
3332
3341
  ) { }
3333
3342
  }
3334
3343
 
@@ -3846,3 +3855,115 @@ export class TerminalQuickFixOpener {
3846
3855
  constructor(uri: theia.Uri) { }
3847
3856
  }
3848
3857
 
3858
+ // #region Chat
3859
+ export class ChatRequestTurn {
3860
+ readonly prompt: string;
3861
+ readonly participant: string;
3862
+ readonly command?: string;
3863
+ readonly references: theia.ChatPromptReference[];
3864
+ private constructor(prompt: string, command: string | undefined, references: theia.ChatPromptReference[], participant: string) {
3865
+ this.prompt = prompt;
3866
+ this.command = command;
3867
+ this.participant = participant;
3868
+ this.references = references;
3869
+ };
3870
+ }
3871
+
3872
+ export class ChatResponseTurn {
3873
+ readonly command?: string;
3874
+
3875
+ private constructor(readonly response: ReadonlyArray<theia.ChatResponseMarkdownPart | theia.ChatResponseFileTreePart | theia.ChatResponseAnchorPart
3876
+ | theia.ChatResponseCommandButtonPart>, readonly result: theia.ChatResult, readonly participant: string) { }
3877
+ }
3878
+
3879
+ export class ChatResponseAnchorPart {
3880
+ value: URI | Location;
3881
+ title?: string;
3882
+
3883
+ constructor(value: URI | Location, title?: string) { }
3884
+ }
3885
+
3886
+ export class ChatResponseProgressPart {
3887
+ value: string;
3888
+
3889
+ constructor(value: string) { }
3890
+ }
3891
+
3892
+ export class ChatResponseReferencePart {
3893
+ value: URI | Location;
3894
+ iconPath?: URI | ThemeIcon | { light: URI; dark: URI; };
3895
+
3896
+ constructor(value: URI | theia.Location, iconPath?: URI | ThemeIcon | {
3897
+ light: URI;
3898
+ dark: URI;
3899
+ }) { }
3900
+ }
3901
+ export class ChatResponseCommandButtonPart {
3902
+ value: theia.Command;
3903
+
3904
+ constructor(value: theia.Command) { }
3905
+ }
3906
+
3907
+ export class ChatResponseMarkdownPart {
3908
+ value: theia.MarkdownString;
3909
+
3910
+ constructor(value: string | theia.MarkdownString) {
3911
+ }
3912
+ }
3913
+
3914
+ export class ChatResponseFileTreePart {
3915
+ value: theia.ChatResponseFileTree[];
3916
+ baseUri: URI;
3917
+
3918
+ constructor(value: theia.ChatResponseFileTree[], baseUri: URI) { }
3919
+ }
3920
+
3921
+ export type ChatResponsePart = ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart
3922
+ | ChatResponseProgressPart | ChatResponseReferencePart | ChatResponseCommandButtonPart;
3923
+
3924
+ export enum ChatResultFeedbackKind {
3925
+ Unhelpful = 0,
3926
+ Helpful = 1,
3927
+ }
3928
+
3929
+ export enum LanguageModelChatMessageRole {
3930
+ User = 1,
3931
+ Assistant = 2
3932
+ }
3933
+
3934
+ export class LanguageModelChatMessage {
3935
+
3936
+ static User(content: string, name?: string): LanguageModelChatMessage {
3937
+ return new LanguageModelChatMessage(LanguageModelChatMessageRole.User, content, name);
3938
+ }
3939
+
3940
+ static Assistant(content: string, name?: string): LanguageModelChatMessage {
3941
+ return new LanguageModelChatMessage(LanguageModelChatMessageRole.Assistant, content, name);
3942
+ }
3943
+
3944
+ constructor(public role: LanguageModelChatMessageRole, public content: string, public name?: string) { }
3945
+ }
3946
+
3947
+ export class LanguageModelError extends Error {
3948
+
3949
+ static NoPermissions(message?: string): LanguageModelError {
3950
+ return new LanguageModelError(message, LanguageModelError.NoPermissions.name);
3951
+ }
3952
+
3953
+ static Blocked(message?: string): LanguageModelError {
3954
+ return new LanguageModelError(message, LanguageModelError.Blocked.name);
3955
+ }
3956
+
3957
+ static NotFound(message?: string): LanguageModelError {
3958
+ return new LanguageModelError(message, LanguageModelError.NotFound.name);
3959
+ }
3960
+
3961
+ readonly code: string;
3962
+
3963
+ constructor(message?: string, code?: string) {
3964
+ super(message);
3965
+ this.name = 'LanguageModelError';
3966
+ this.code = code ?? '';
3967
+ }
3968
+ }
3969
+ // #endregion