@codingame/monaco-vscode-ai-service-override 1.85.2
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/ai.d.ts
ADDED
package/ai.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
|
|
2
|
+
import { AiRelatedInformationService } from './vscode/src/vs/workbench/services/aiRelatedInformation/common/aiRelatedInformationService.js';
|
|
3
|
+
import { IAiRelatedInformationService } from 'vscode/vscode/vs/workbench/services/aiRelatedInformation/common/aiRelatedInformation';
|
|
4
|
+
import { IAiEmbeddingVectorService } from 'vscode/vscode/vs/workbench/services/aiEmbeddingVector/common/aiEmbeddingVectorService';
|
|
5
|
+
|
|
6
|
+
function getServiceOverride() {
|
|
7
|
+
return {
|
|
8
|
+
[( IAiRelatedInformationService.toString())]: new SyncDescriptor(AiRelatedInformationService, [], true),
|
|
9
|
+
[( IAiEmbeddingVectorService.toString())]: new SyncDescriptor(AiRelatedInformationService, [], true)
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { getServiceOverride as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function __decorate(decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
}
|
|
7
|
+
function __param(paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { __decorate, __param };
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ai.js';
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ai.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@codingame/monaco-vscode-ai-service-override",
|
|
3
|
+
"version": "1.85.2",
|
|
4
|
+
"keywords": [],
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "CodinGame",
|
|
7
|
+
"url": "http://www.codingame.com"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/CodinGame/monaco-vscode-api.git"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"private": false,
|
|
16
|
+
"description": "VSCode public API plugged on the monaco editor - ai service-override",
|
|
17
|
+
"main": "index.js",
|
|
18
|
+
"module": "index.js",
|
|
19
|
+
"types": "index.d.ts",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"vscode": "npm:@codingame/monaco-vscode-api@1.85.2",
|
|
22
|
+
"monaco-editor": "0.45.0"
|
|
23
|
+
}
|
|
24
|
+
}
|
package/vscode/src/vs/workbench/services/aiRelatedInformation/common/aiRelatedInformationService.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { createCancelablePromise, raceTimeout } from 'monaco-editor/esm/vs/base/common/async.js';
|
|
3
|
+
import { StopWatch } from 'monaco-editor/esm/vs/base/common/stopwatch.js';
|
|
4
|
+
import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
5
|
+
|
|
6
|
+
var AiRelatedInformationService_1;
|
|
7
|
+
let AiRelatedInformationService = class AiRelatedInformationService {
|
|
8
|
+
static { AiRelatedInformationService_1 = this; }
|
|
9
|
+
static { this.DEFAULT_TIMEOUT = 1000 * 10; }
|
|
10
|
+
constructor(logService) {
|
|
11
|
+
this.logService = logService;
|
|
12
|
+
this._providers = ( new Map());
|
|
13
|
+
}
|
|
14
|
+
isEnabled() {
|
|
15
|
+
return this._providers.size > 0;
|
|
16
|
+
}
|
|
17
|
+
registerAiRelatedInformationProvider(type, provider) {
|
|
18
|
+
const providers = this._providers.get(type) ?? [];
|
|
19
|
+
providers.push(provider);
|
|
20
|
+
this._providers.set(type, providers);
|
|
21
|
+
return {
|
|
22
|
+
dispose: () => {
|
|
23
|
+
const providers = this._providers.get(type) ?? [];
|
|
24
|
+
const index = providers.indexOf(provider);
|
|
25
|
+
if (index !== -1) {
|
|
26
|
+
providers.splice(index, 1);
|
|
27
|
+
}
|
|
28
|
+
if (providers.length === 0) {
|
|
29
|
+
this._providers.delete(type);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
async getRelatedInformation(query, types, token) {
|
|
35
|
+
if (this._providers.size === 0) {
|
|
36
|
+
throw new Error('No related information providers registered');
|
|
37
|
+
}
|
|
38
|
+
const providers = [];
|
|
39
|
+
for (const type of types) {
|
|
40
|
+
const typeProviders = this._providers.get(type);
|
|
41
|
+
if (typeProviders) {
|
|
42
|
+
providers.push(...typeProviders);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (providers.length === 0) {
|
|
46
|
+
throw new Error('No related information providers registered for the given types');
|
|
47
|
+
}
|
|
48
|
+
const stopwatch = StopWatch.create();
|
|
49
|
+
const cancellablePromises = ( providers.map((provider) => {
|
|
50
|
+
return createCancelablePromise(async (t) => {
|
|
51
|
+
try {
|
|
52
|
+
const result = await provider.provideAiRelatedInformation(query, t);
|
|
53
|
+
return result.filter(r => types.includes(r.type));
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
}
|
|
57
|
+
return [];
|
|
58
|
+
});
|
|
59
|
+
}));
|
|
60
|
+
try {
|
|
61
|
+
const results = await raceTimeout(Promise.allSettled(cancellablePromises), AiRelatedInformationService_1.DEFAULT_TIMEOUT, () => {
|
|
62
|
+
cancellablePromises.forEach(p => p.cancel());
|
|
63
|
+
this.logService.warn('[AiRelatedInformationService]: Related information provider timed out');
|
|
64
|
+
});
|
|
65
|
+
if (!results) {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
const result = results
|
|
69
|
+
.filter(r => r.status === 'fulfilled')
|
|
70
|
+
.flatMap(r => r.value);
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
stopwatch.stop();
|
|
75
|
+
this.logService.trace(`[AiRelatedInformationService]: getRelatedInformation took ${stopwatch.elapsed()}ms`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
AiRelatedInformationService = AiRelatedInformationService_1 = ( __decorate([
|
|
80
|
+
( __param(0, ILogService))
|
|
81
|
+
], AiRelatedInformationService));
|
|
82
|
+
|
|
83
|
+
export { AiRelatedInformationService };
|