@codingame/monaco-vscode-ai-service-override 16.1.0 → 17.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -4,11 +4,14 @@ import { SyncDescriptor } from '@codingame/monaco-vscode-api/vscode/vs/platform/
4
4
  import { IAiEmbeddingVectorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/aiEmbeddingVector/common/aiEmbeddingVectorService.service';
5
5
  import { IAiRelatedInformationService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/aiRelatedInformation/common/aiRelatedInformation.service';
6
6
  import { AiRelatedInformationService } from './vscode/src/vs/workbench/services/aiRelatedInformation/common/aiRelatedInformationService.js';
7
+ import { IAiSettingsSearchService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/aiSettingsSearch/common/aiSettingsSearch.service';
8
+ import { AiSettingsSearchService } from './vscode/src/vs/workbench/services/aiSettingsSearch/common/aiSettingsSearchService.js';
7
9
 
8
10
  function getServiceOverride() {
9
11
  return {
10
12
  [IAiRelatedInformationService.toString()]: new SyncDescriptor(AiRelatedInformationService, [], true),
11
- [IAiEmbeddingVectorService.toString()]: new SyncDescriptor(AiRelatedInformationService, [], true)
13
+ [IAiEmbeddingVectorService.toString()]: new SyncDescriptor(AiRelatedInformationService, [], true),
14
+ [IAiSettingsSearchService.toString()]: new SyncDescriptor(AiSettingsSearchService, [], true)
12
15
  };
13
16
  }
14
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-ai-service-override",
3
- "version": "16.1.0",
3
+ "version": "17.0.0",
4
4
  "private": false,
5
5
  "description": "VSCode public API plugged on the monaco editor - ai service-override",
6
6
  "keywords": [],
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "type": "module",
17
17
  "dependencies": {
18
- "@codingame/monaco-vscode-api": "16.1.0"
18
+ "@codingame/monaco-vscode-api": "17.0.0"
19
19
  },
20
20
  "main": "index.js",
21
21
  "module": "index.js",
@@ -1,7 +1,7 @@
1
1
  import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
2
2
  import { IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
3
3
  import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
4
- import { IAiRelatedInformationProvider, RelatedInformationType, RelatedInformationResult } from "@codingame/monaco-vscode-d609a7d3-bf87-551a-884f-550a8b327ec5-common/vscode/vs/workbench/services/aiRelatedInformation/common/aiRelatedInformation";
4
+ import { IAiRelatedInformationProvider, RelatedInformationType, RelatedInformationResult } from "@codingame/monaco-vscode-quickaccess-service-override/vscode/vs/workbench/services/aiRelatedInformation/common/aiRelatedInformation";
5
5
  import { IAiRelatedInformationService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/aiRelatedInformation/common/aiRelatedInformation.service";
6
6
  export declare class AiRelatedInformationService implements IAiRelatedInformationService {
7
7
  private readonly logService;
@@ -0,0 +1,17 @@
1
+ import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
2
+ import { IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
3
+ import { AiSettingsSearchResult, IAiSettingsSearchProvider } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/aiSettingsSearch/common/aiSettingsSearch";
4
+ import { IAiSettingsSearchService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/aiSettingsSearch/common/aiSettingsSearch.service";
5
+ export declare class AiSettingsSearchService implements IAiSettingsSearchService {
6
+ readonly _serviceBrand: undefined;
7
+ private static readonly MAX_PICKS;
8
+ private _providers;
9
+ private _llmRankedResultsPromises;
10
+ private _embeddingsResultsPromises;
11
+ isEnabled(): boolean;
12
+ registerSettingsSearchProvider(provider: IAiSettingsSearchProvider): IDisposable;
13
+ startSearch(query: string, token: CancellationToken): void;
14
+ getEmbeddingsResults(query: string, token: CancellationToken): Promise<string[] | null>;
15
+ getLLMRankedResults(query: string, token: CancellationToken): Promise<string[] | null>;
16
+ handleSearchResult(result: AiSettingsSearchResult): void;
17
+ }
@@ -0,0 +1,73 @@
1
+
2
+ import { DeferredPromise, raceCancellation } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
3
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/extensions';
4
+ import { AiSettingsSearchResultKind } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/aiSettingsSearch/common/aiSettingsSearch';
5
+ import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
6
+
7
+ class AiSettingsSearchService {
8
+ constructor() {
9
+ this._providers = [];
10
+ this._llmRankedResultsPromises = ( new Map());
11
+ this._embeddingsResultsPromises = ( new Map());
12
+ }
13
+ static { this.MAX_PICKS = 5; }
14
+ isEnabled() {
15
+ return this._providers.length > 0;
16
+ }
17
+ registerSettingsSearchProvider(provider) {
18
+ this._providers.push(provider);
19
+ return {
20
+ dispose: () => {
21
+ const index = this._providers.indexOf(provider);
22
+ if (index !== -1) {
23
+ this._providers.splice(index, 1);
24
+ }
25
+ }
26
+ };
27
+ }
28
+ startSearch(query, token) {
29
+ if (!this.isEnabled()) {
30
+ throw ( new Error('No settings search providers registered'));
31
+ }
32
+ this._providers.forEach(provider => provider.searchSettings(query, { limit: AiSettingsSearchService.MAX_PICKS }, token));
33
+ }
34
+ async getEmbeddingsResults(query, token) {
35
+ if (!this.isEnabled()) {
36
+ throw ( new Error('No settings search providers registered'));
37
+ }
38
+ const promise = ( new DeferredPromise());
39
+ this._embeddingsResultsPromises.set(query, promise);
40
+ const result = await raceCancellation(promise.p, token);
41
+ return result ?? null;
42
+ }
43
+ async getLLMRankedResults(query, token) {
44
+ if (!this.isEnabled()) {
45
+ throw ( new Error('No settings search providers registered'));
46
+ }
47
+ const promise = ( new DeferredPromise());
48
+ this._llmRankedResultsPromises.set(query, promise);
49
+ const result = await raceCancellation(promise.p, token);
50
+ return result ?? null;
51
+ }
52
+ handleSearchResult(result) {
53
+ if (!this.isEnabled()) {
54
+ return;
55
+ }
56
+ if (result.kind === AiSettingsSearchResultKind.EMBEDDED) {
57
+ const promise = this._embeddingsResultsPromises.get(result.query);
58
+ if (promise) {
59
+ promise.complete(result.settings);
60
+ this._embeddingsResultsPromises.delete(result.query);
61
+ }
62
+ }
63
+ else if (result.kind === AiSettingsSearchResultKind.LLM_RANKED) {
64
+ const promise = this._llmRankedResultsPromises.get(result.query);
65
+ if (promise) {
66
+ promise.complete(result.settings);
67
+ this._llmRankedResultsPromises.delete(result.query);
68
+ }
69
+ }
70
+ }
71
+ }
72
+
73
+ export { AiSettingsSearchService };