@theia/ai-core 1.54.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/README.md +30 -0
- package/data/prompttemplate.tmLanguage.json +52 -0
- package/lib/browser/ai-activation-service.d.ts +17 -0
- package/lib/browser/ai-activation-service.d.ts.map +1 -0
- package/lib/browser/ai-activation-service.js +63 -0
- package/lib/browser/ai-activation-service.js.map +1 -0
- package/lib/browser/ai-command-handler-factory.d.ts +4 -0
- package/lib/browser/ai-command-handler-factory.d.ts.map +1 -0
- package/lib/browser/ai-command-handler-factory.js +20 -0
- package/lib/browser/ai-command-handler-factory.js.map +1 -0
- package/lib/browser/ai-configuration/agent-configuration-widget.d.ts +27 -0
- package/lib/browser/ai-configuration/agent-configuration-widget.d.ts.map +1 -0
- package/lib/browser/ai-configuration/agent-configuration-widget.js +231 -0
- package/lib/browser/ai-configuration/agent-configuration-widget.js.map +1 -0
- package/lib/browser/ai-configuration/ai-configuration-service.d.ts +13 -0
- package/lib/browser/ai-configuration/ai-configuration-service.d.ts.map +1 -0
- package/lib/browser/ai-configuration/ai-configuration-service.js +44 -0
- package/lib/browser/ai-configuration/ai-configuration-service.js.map +1 -0
- package/lib/browser/ai-configuration/ai-configuration-view-contribution.d.ts +12 -0
- package/lib/browser/ai-configuration/ai-configuration-view-contribution.d.ts.map +1 -0
- package/lib/browser/ai-configuration/ai-configuration-view-contribution.js +41 -0
- package/lib/browser/ai-configuration/ai-configuration-view-contribution.js.map +1 -0
- package/lib/browser/ai-configuration/ai-configuration-widget.d.ts +20 -0
- package/lib/browser/ai-configuration/ai-configuration-widget.d.ts.map +1 -0
- package/lib/browser/ai-configuration/ai-configuration-widget.js +88 -0
- package/lib/browser/ai-configuration/ai-configuration-widget.js.map +1 -0
- package/lib/browser/ai-configuration/language-model-renderer.d.ts +13 -0
- package/lib/browser/ai-configuration/language-model-renderer.d.ts.map +1 -0
- package/lib/browser/ai-configuration/language-model-renderer.js +104 -0
- package/lib/browser/ai-configuration/language-model-renderer.js.map +1 -0
- package/lib/browser/ai-configuration/template-settings-renderer.d.ts +11 -0
- package/lib/browser/ai-configuration/template-settings-renderer.d.ts.map +1 -0
- package/lib/browser/ai-configuration/template-settings-renderer.js +33 -0
- package/lib/browser/ai-configuration/template-settings-renderer.js.map +1 -0
- package/lib/browser/ai-configuration/variable-configuration-widget.d.ts +20 -0
- package/lib/browser/ai-configuration/variable-configuration-widget.d.ts.map +1 -0
- package/lib/browser/ai-configuration/variable-configuration-widget.js +99 -0
- package/lib/browser/ai-configuration/variable-configuration-widget.js.map +1 -0
- package/lib/browser/ai-core-frontend-application-contribution.d.ts +8 -0
- package/lib/browser/ai-core-frontend-application-contribution.d.ts.map +1 -0
- package/lib/browser/ai-core-frontend-application-contribution.js +46 -0
- package/lib/browser/ai-core-frontend-application-contribution.js.map +1 -0
- package/lib/browser/ai-core-frontend-module.d.ts +4 -0
- package/lib/browser/ai-core-frontend-module.d.ts.map +1 -0
- package/lib/browser/ai-core-frontend-module.js +122 -0
- package/lib/browser/ai-core-frontend-module.js.map +1 -0
- package/lib/browser/ai-core-preferences.d.ts +14 -0
- package/lib/browser/ai-core-preferences.d.ts.map +1 -0
- package/lib/browser/ai-core-preferences.js +69 -0
- package/lib/browser/ai-core-preferences.js.map +1 -0
- package/lib/browser/ai-settings-service.d.ts +14 -0
- package/lib/browser/ai-settings-service.d.ts.map +1 -0
- package/lib/browser/ai-settings-service.js +56 -0
- package/lib/browser/ai-settings-service.js.map +1 -0
- package/lib/browser/ai-view-contribution.d.ts +14 -0
- package/lib/browser/ai-view-contribution.d.ts.map +1 -0
- package/lib/browser/ai-view-contribution.js +71 -0
- package/lib/browser/ai-view-contribution.js.map +1 -0
- package/lib/browser/frontend-language-model-registry.d.ts +39 -0
- package/lib/browser/frontend-language-model-registry.d.ts.map +1 -0
- package/lib/browser/frontend-language-model-registry.js +321 -0
- package/lib/browser/frontend-language-model-registry.js.map +1 -0
- package/lib/browser/frontend-prompt-customization-service.d.ts +31 -0
- package/lib/browser/frontend-prompt-customization-service.d.ts.map +1 -0
- package/lib/browser/frontend-prompt-customization-service.js +194 -0
- package/lib/browser/frontend-prompt-customization-service.js.map +1 -0
- package/lib/browser/frontend-variable-service.d.ts +6 -0
- package/lib/browser/frontend-variable-service.d.ts.map +1 -0
- package/lib/browser/frontend-variable-service.js +31 -0
- package/lib/browser/frontend-variable-service.js.map +1 -0
- package/lib/browser/index.d.ts +11 -0
- package/lib/browser/index.d.ts.map +1 -0
- package/lib/browser/index.js +29 -0
- package/lib/browser/index.js.map +1 -0
- package/lib/browser/prompttemplate-contribution.d.ts +28 -0
- package/lib/browser/prompttemplate-contribution.d.ts.map +1 -0
- package/lib/browser/prompttemplate-contribution.js +207 -0
- package/lib/browser/prompttemplate-contribution.js.map +1 -0
- package/lib/browser/theia-variable-contribution.d.ts +13 -0
- package/lib/browser/theia-variable-contribution.d.ts.map +1 -0
- package/lib/browser/theia-variable-contribution.js +64 -0
- package/lib/browser/theia-variable-contribution.js.map +1 -0
- package/lib/common/agent-service.d.ts +48 -0
- package/lib/common/agent-service.d.ts.map +1 -0
- package/lib/common/agent-service.js +88 -0
- package/lib/common/agent-service.js.map +1 -0
- package/lib/common/agent.d.ts +45 -0
- package/lib/common/agent.d.ts.map +1 -0
- package/lib/common/agent.js +20 -0
- package/lib/common/agent.js.map +1 -0
- package/lib/common/agents-variable-contribution.d.ts +19 -0
- package/lib/common/agents-variable-contribution.d.ts.map +1 -0
- package/lib/common/agents-variable-contribution.js +56 -0
- package/lib/common/agents-variable-contribution.js.map +1 -0
- package/lib/common/communication-recording-service.d.ts +23 -0
- package/lib/common/communication-recording-service.d.ts.map +1 -0
- package/lib/common/communication-recording-service.js +20 -0
- package/lib/common/communication-recording-service.js.map +1 -0
- package/lib/common/index.d.ts +16 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +34 -0
- package/lib/common/index.js.map +1 -0
- package/lib/common/language-model-delegate.d.ts +24 -0
- package/lib/common/language-model-delegate.d.ts.map +1 -0
- package/lib/common/language-model-delegate.js +26 -0
- package/lib/common/language-model-delegate.js.map +1 -0
- package/lib/common/language-model-util.d.ts +5 -0
- package/lib/common/language-model-util.d.ts.map +1 -0
- package/lib/common/language-model-util.js +75 -0
- package/lib/common/language-model-util.js.map +1 -0
- package/lib/common/language-model.d.ts +137 -0
- package/lib/common/language-model.d.ts.map +1 -0
- package/lib/common/language-model.js +142 -0
- package/lib/common/language-model.js.map +1 -0
- package/lib/common/language-model.spec.d.ts +2 -0
- package/lib/common/language-model.spec.d.ts.map +1 -0
- package/lib/common/language-model.spec.js +62 -0
- package/lib/common/language-model.spec.js.map +1 -0
- package/lib/common/prompt-service-util.d.ts +5 -0
- package/lib/common/prompt-service-util.d.ts.map +1 -0
- package/lib/common/prompt-service-util.js +23 -0
- package/lib/common/prompt-service-util.js.map +1 -0
- package/lib/common/prompt-service.d.ts +101 -0
- package/lib/common/prompt-service.d.ts.map +1 -0
- package/lib/common/prompt-service.js +139 -0
- package/lib/common/prompt-service.js.map +1 -0
- package/lib/common/prompt-service.spec.d.ts +2 -0
- package/lib/common/prompt-service.spec.d.ts.map +1 -0
- package/lib/common/prompt-service.spec.js +86 -0
- package/lib/common/prompt-service.spec.js.map +1 -0
- package/lib/common/protocol.d.ts +7 -0
- package/lib/common/protocol.d.ts.map +1 -0
- package/lib/common/protocol.js +20 -0
- package/lib/common/protocol.js.map +1 -0
- package/lib/common/settings-service.d.ts +18 -0
- package/lib/common/settings-service.d.ts.map +1 -0
- package/lib/common/settings-service.js +5 -0
- package/lib/common/settings-service.js.map +1 -0
- package/lib/common/today-variable-contribution.d.ts +17 -0
- package/lib/common/today-variable-contribution.d.ts.map +1 -0
- package/lib/common/today-variable-contribution.js +48 -0
- package/lib/common/today-variable-contribution.js.map +1 -0
- package/lib/common/tomorrow-variable-contribution.d.ts +17 -0
- package/lib/common/tomorrow-variable-contribution.d.ts.map +1 -0
- package/lib/common/tomorrow-variable-contribution.js +48 -0
- package/lib/common/tomorrow-variable-contribution.js.map +1 -0
- package/lib/common/tool-invocation-registry.d.ts +23 -0
- package/lib/common/tool-invocation-registry.d.ts.map +1 -0
- package/lib/common/tool-invocation-registry.js +72 -0
- package/lib/common/tool-invocation-registry.js.map +1 -0
- package/lib/common/variable-service.d.ts +70 -0
- package/lib/common/variable-service.d.ts.map +1 -0
- package/lib/common/variable-service.js +122 -0
- package/lib/common/variable-service.js.map +1 -0
- package/lib/node/ai-core-backend-module.d.ts +4 -0
- package/lib/node/ai-core-backend-module.d.ts.map +1 -0
- package/lib/node/ai-core-backend-module.js +47 -0
- package/lib/node/ai-core-backend-module.js.map +1 -0
- package/lib/node/backend-language-model-registry.d.ts +12 -0
- package/lib/node/backend-language-model-registry.d.ts.map +1 -0
- package/lib/node/backend-language-model-registry.js +61 -0
- package/lib/node/backend-language-model-registry.js.map +1 -0
- package/lib/node/language-model-frontend-delegate.d.ts +18 -0
- package/lib/node/language-model-frontend-delegate.d.ts.map +1 -0
- package/lib/node/language-model-frontend-delegate.js +100 -0
- package/lib/node/language-model-frontend-delegate.js.map +1 -0
- package/package.json +59 -0
- package/src/browser/ai-activation-service.ts +56 -0
- package/src/browser/ai-command-handler-factory.ts +20 -0
- package/src/browser/ai-configuration/agent-configuration-widget.tsx +299 -0
- package/src/browser/ai-configuration/ai-configuration-service.ts +43 -0
- package/src/browser/ai-configuration/ai-configuration-view-contribution.ts +54 -0
- package/src/browser/ai-configuration/ai-configuration-widget.tsx +80 -0
- package/src/browser/ai-configuration/language-model-renderer.tsx +113 -0
- package/src/browser/ai-configuration/template-settings-renderer.tsx +39 -0
- package/src/browser/ai-configuration/variable-configuration-widget.tsx +110 -0
- package/src/browser/ai-core-frontend-application-contribution.ts +40 -0
- package/src/browser/ai-core-frontend-module.ts +161 -0
- package/src/browser/ai-core-preferences.ts +76 -0
- package/src/browser/ai-settings-service.ts +50 -0
- package/src/browser/ai-view-contribution.ts +77 -0
- package/src/browser/frontend-language-model-registry.ts +405 -0
- package/src/browser/frontend-prompt-customization-service.ts +197 -0
- package/src/browser/frontend-variable-service.ts +26 -0
- package/src/browser/index.ts +26 -0
- package/src/browser/prompttemplate-contribution.ts +250 -0
- package/src/browser/style/index.css +90 -0
- package/src/browser/theia-variable-contribution.ts +58 -0
- package/src/common/agent-service.ts +108 -0
- package/src/common/agent.ts +70 -0
- package/src/common/agents-variable-contribution.ts +64 -0
- package/src/common/communication-recording-service.ts +44 -0
- package/src/common/index.ts +30 -0
- package/src/common/language-model-delegate.ts +45 -0
- package/src/common/language-model-util.ts +67 -0
- package/src/common/language-model.spec.ts +86 -0
- package/src/common/language-model.ts +237 -0
- package/src/common/prompt-service-util.ts +21 -0
- package/src/common/prompt-service.spec.ts +98 -0
- package/src/common/prompt-service.ts +213 -0
- package/src/common/protocol.ts +23 -0
- package/src/common/settings-service.ts +33 -0
- package/src/common/today-variable-contribution.ts +67 -0
- package/src/common/tomorrow-variable-contribution.ts +66 -0
- package/src/common/tool-invocation-registry.ts +79 -0
- package/src/common/variable-service.ts +177 -0
- package/src/node/ai-core-backend-module.ts +83 -0
- package/src/node/backend-language-model-registry.ts +59 -0
- package/src/node/language-model-frontend-delegate.ts +116 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.LanguageModelFrontendDelegateImpl = exports.LanguageModelRegistryFrontendDelegateImpl = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
+
const core_1 = require("@theia/core");
|
|
22
|
+
const common_1 = require("../common");
|
|
23
|
+
const backend_language_model_registry_1 = require("./backend-language-model-registry");
|
|
24
|
+
let LanguageModelRegistryFrontendDelegateImpl = class LanguageModelRegistryFrontendDelegateImpl {
|
|
25
|
+
setClient(client) {
|
|
26
|
+
this.registry.setClient(client);
|
|
27
|
+
}
|
|
28
|
+
async getLanguageModelDescriptions() {
|
|
29
|
+
return (await this.registry.getLanguageModels()).map(model => this.registry.mapToMetaData(model));
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.LanguageModelRegistryFrontendDelegateImpl = LanguageModelRegistryFrontendDelegateImpl;
|
|
33
|
+
tslib_1.__decorate([
|
|
34
|
+
(0, inversify_1.inject)(common_1.LanguageModelRegistry),
|
|
35
|
+
tslib_1.__metadata("design:type", backend_language_model_registry_1.BackendLanguageModelRegistry)
|
|
36
|
+
], LanguageModelRegistryFrontendDelegateImpl.prototype, "registry", void 0);
|
|
37
|
+
exports.LanguageModelRegistryFrontendDelegateImpl = LanguageModelRegistryFrontendDelegateImpl = tslib_1.__decorate([
|
|
38
|
+
(0, inversify_1.injectable)()
|
|
39
|
+
], LanguageModelRegistryFrontendDelegateImpl);
|
|
40
|
+
let LanguageModelFrontendDelegateImpl = class LanguageModelFrontendDelegateImpl {
|
|
41
|
+
constructor() {
|
|
42
|
+
this.requestCancellationTokenMap = new Map();
|
|
43
|
+
}
|
|
44
|
+
setClient(client) {
|
|
45
|
+
this.frontendDelegateClient = client;
|
|
46
|
+
}
|
|
47
|
+
cancel(requestId) {
|
|
48
|
+
var _a;
|
|
49
|
+
(_a = this.requestCancellationTokenMap.get(requestId)) === null || _a === void 0 ? void 0 : _a.cancel();
|
|
50
|
+
}
|
|
51
|
+
async request(modelId, request, requestId, cancellationToken) {
|
|
52
|
+
var _a;
|
|
53
|
+
const model = await this.registry.getLanguageModel(modelId);
|
|
54
|
+
if (!model) {
|
|
55
|
+
throw new Error(`Request was sent to non-existent language model ${modelId}`);
|
|
56
|
+
}
|
|
57
|
+
(_a = request.tools) === null || _a === void 0 ? void 0 : _a.forEach(tool => {
|
|
58
|
+
tool.handler = async (args_string) => this.frontendDelegateClient.toolCall(requestId, tool.id, args_string);
|
|
59
|
+
});
|
|
60
|
+
if (cancellationToken) {
|
|
61
|
+
const tokenSource = new core_1.CancellationTokenSource();
|
|
62
|
+
cancellationToken = tokenSource.token;
|
|
63
|
+
this.requestCancellationTokenMap.set(requestId, tokenSource);
|
|
64
|
+
}
|
|
65
|
+
const response = await model.request(request, cancellationToken);
|
|
66
|
+
if ((0, common_1.isLanguageModelTextResponse)(response) || (0, common_1.isLanguageModelParsedResponse)(response)) {
|
|
67
|
+
return response;
|
|
68
|
+
}
|
|
69
|
+
if ((0, common_1.isLanguageModelStreamResponse)(response)) {
|
|
70
|
+
const delegate = {
|
|
71
|
+
streamId: (0, core_1.generateUuid)(),
|
|
72
|
+
};
|
|
73
|
+
this.sendTokens(delegate.streamId, response.stream);
|
|
74
|
+
return delegate;
|
|
75
|
+
}
|
|
76
|
+
this.logger.error(`Received unexpected response from language model ${modelId}. Trying to continue without touching the response.`, response);
|
|
77
|
+
return response;
|
|
78
|
+
}
|
|
79
|
+
sendTokens(id, stream) {
|
|
80
|
+
(async () => {
|
|
81
|
+
for await (const token of stream) {
|
|
82
|
+
this.frontendDelegateClient.send(id, token);
|
|
83
|
+
}
|
|
84
|
+
this.frontendDelegateClient.send(id, undefined);
|
|
85
|
+
})();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
exports.LanguageModelFrontendDelegateImpl = LanguageModelFrontendDelegateImpl;
|
|
89
|
+
tslib_1.__decorate([
|
|
90
|
+
(0, inversify_1.inject)(common_1.LanguageModelRegistry),
|
|
91
|
+
tslib_1.__metadata("design:type", Object)
|
|
92
|
+
], LanguageModelFrontendDelegateImpl.prototype, "registry", void 0);
|
|
93
|
+
tslib_1.__decorate([
|
|
94
|
+
(0, inversify_1.inject)(core_1.ILogger),
|
|
95
|
+
tslib_1.__metadata("design:type", Object)
|
|
96
|
+
], LanguageModelFrontendDelegateImpl.prototype, "logger", void 0);
|
|
97
|
+
exports.LanguageModelFrontendDelegateImpl = LanguageModelFrontendDelegateImpl = tslib_1.__decorate([
|
|
98
|
+
(0, inversify_1.injectable)()
|
|
99
|
+
], LanguageModelFrontendDelegateImpl);
|
|
100
|
+
//# sourceMappingURL=language-model-frontend-delegate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-model-frontend-delegate.js","sourceRoot":"","sources":["../../src/node/language-model-frontend-delegate.ts"],"names":[],"mappings":"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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@theia/ai-core",
|
|
3
|
+
"version": "1.54.0",
|
|
4
|
+
"description": "Theia - AI Core",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@theia/core": "1.54.0",
|
|
7
|
+
"@theia/editor": "1.54.0",
|
|
8
|
+
"@theia/filesystem": "1.54.0",
|
|
9
|
+
"@theia/monaco": "1.54.0",
|
|
10
|
+
"@theia/monaco-editor-core": "1.83.101",
|
|
11
|
+
"@theia/output": "1.54.0",
|
|
12
|
+
"@theia/variable-resolver": "1.54.0",
|
|
13
|
+
"@theia/workspace": "1.54.0",
|
|
14
|
+
"minimatch": "^5.1.0",
|
|
15
|
+
"tslib": "^2.6.2"
|
|
16
|
+
},
|
|
17
|
+
"main": "lib/common",
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"theiaExtensions": [
|
|
22
|
+
{
|
|
23
|
+
"frontend": "lib/browser/ai-core-frontend-module",
|
|
24
|
+
"backend": "lib/node/ai-core-backend-module"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"keywords": [
|
|
28
|
+
"theia-extension"
|
|
29
|
+
],
|
|
30
|
+
"license": "EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/eclipse-theia/theia.git"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/eclipse-theia/theia/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/eclipse-theia/theia",
|
|
39
|
+
"files": [
|
|
40
|
+
"data",
|
|
41
|
+
"lib",
|
|
42
|
+
"src"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "theiaext build",
|
|
46
|
+
"clean": "theiaext clean",
|
|
47
|
+
"compile": "theiaext compile",
|
|
48
|
+
"lint": "theiaext lint",
|
|
49
|
+
"test": "theiaext test",
|
|
50
|
+
"watch": "theiaext watch"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@theia/ext-scripts": "1.54.0"
|
|
54
|
+
},
|
|
55
|
+
"nyc": {
|
|
56
|
+
"extends": "../../configs/nyc.json"
|
|
57
|
+
},
|
|
58
|
+
"gitHead": "8fb36a237db744cff6e78eaff1481e1f36bb7a69"
|
|
59
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
17
|
+
import { FrontendApplicationContribution, PreferenceService } from '@theia/core/lib/browser';
|
|
18
|
+
import { Emitter, MaybePromise, Event, } from '@theia/core';
|
|
19
|
+
import { ContextKeyService, ContextKey } from '@theia/core/lib/browser/context-key-service';
|
|
20
|
+
import { PREFERENCE_NAME_ENABLE_EXPERIMENTAL } from './ai-core-preferences';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Context key for the experimental AI feature. It is set to `true` if the feature is enabled.
|
|
24
|
+
*/
|
|
25
|
+
// We reuse the enablement preference for the context key
|
|
26
|
+
export const EXPERIMENTAL_AI_CONTEXT_KEY = PREFERENCE_NAME_ENABLE_EXPERIMENTAL;
|
|
27
|
+
|
|
28
|
+
@injectable()
|
|
29
|
+
export class AIActivationService implements FrontendApplicationContribution {
|
|
30
|
+
@inject(ContextKeyService)
|
|
31
|
+
protected readonly contextKeyService: ContextKeyService;
|
|
32
|
+
|
|
33
|
+
@inject(PreferenceService)
|
|
34
|
+
protected preferenceService: PreferenceService;
|
|
35
|
+
|
|
36
|
+
protected isExperimentalEnabledKey: ContextKey<boolean>;
|
|
37
|
+
|
|
38
|
+
protected onDidChangeExperimental = new Emitter<boolean>();
|
|
39
|
+
get onDidChangeActiveStatus(): Event<boolean> {
|
|
40
|
+
return this.onDidChangeExperimental.event;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
get isActive(): boolean {
|
|
44
|
+
return this.isExperimentalEnabledKey.get() ?? false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
initialize(): MaybePromise<void> {
|
|
48
|
+
this.isExperimentalEnabledKey = this.contextKeyService.createKey(EXPERIMENTAL_AI_CONTEXT_KEY, false);
|
|
49
|
+
this.preferenceService.onPreferenceChanged(e => {
|
|
50
|
+
if (e.preferenceName === PREFERENCE_NAME_ENABLE_EXPERIMENTAL) {
|
|
51
|
+
this.isExperimentalEnabledKey.set(e.newValue);
|
|
52
|
+
this.onDidChangeExperimental.fire(e.newValue);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { CommandHandler } from '@theia/core';
|
|
18
|
+
|
|
19
|
+
export type AICommandHandlerFactory = (handler: CommandHandler) => CommandHandler;
|
|
20
|
+
export const AICommandHandlerFactory = Symbol('AICommandHandlerFactory');
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { codicon, ReactWidget } from '@theia/core/lib/browser';
|
|
18
|
+
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
19
|
+
import * as React from '@theia/core/shared/react';
|
|
20
|
+
import {
|
|
21
|
+
Agent,
|
|
22
|
+
AISettingsService,
|
|
23
|
+
AIVariableService,
|
|
24
|
+
LanguageModel,
|
|
25
|
+
LanguageModelRegistry,
|
|
26
|
+
PROMPT_FUNCTION_REGEX,
|
|
27
|
+
PROMPT_VARIABLE_REGEX,
|
|
28
|
+
PromptCustomizationService,
|
|
29
|
+
PromptService,
|
|
30
|
+
} from '../../common';
|
|
31
|
+
import { LanguageModelRenderer } from './language-model-renderer';
|
|
32
|
+
import { TemplateRenderer } from './template-settings-renderer';
|
|
33
|
+
import { AIConfigurationSelectionService } from './ai-configuration-service';
|
|
34
|
+
import { AIVariableConfigurationWidget } from './variable-configuration-widget';
|
|
35
|
+
import { AgentService } from '../../common/agent-service';
|
|
36
|
+
|
|
37
|
+
interface ParsedPrompt {
|
|
38
|
+
functions: string[];
|
|
39
|
+
globalVariables: string[];
|
|
40
|
+
agentSpecificVariables: string[];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
@injectable()
|
|
44
|
+
export class AIAgentConfigurationWidget extends ReactWidget {
|
|
45
|
+
|
|
46
|
+
static readonly ID = 'ai-agent-configuration-container-widget';
|
|
47
|
+
static readonly LABEL = 'Agents';
|
|
48
|
+
|
|
49
|
+
@inject(AgentService)
|
|
50
|
+
protected readonly agentService: AgentService;
|
|
51
|
+
|
|
52
|
+
@inject(LanguageModelRegistry)
|
|
53
|
+
protected readonly languageModelRegistry: LanguageModelRegistry;
|
|
54
|
+
|
|
55
|
+
@inject(PromptCustomizationService)
|
|
56
|
+
protected readonly promptCustomizationService: PromptCustomizationService;
|
|
57
|
+
|
|
58
|
+
@inject(AISettingsService)
|
|
59
|
+
protected readonly aiSettingsService: AISettingsService;
|
|
60
|
+
|
|
61
|
+
@inject(AIConfigurationSelectionService)
|
|
62
|
+
protected readonly aiConfigurationSelectionService: AIConfigurationSelectionService;
|
|
63
|
+
|
|
64
|
+
@inject(AIVariableService)
|
|
65
|
+
protected readonly variableService: AIVariableService;
|
|
66
|
+
|
|
67
|
+
@inject(PromptService)
|
|
68
|
+
protected promptService: PromptService;
|
|
69
|
+
|
|
70
|
+
protected languageModels: LanguageModel[] | undefined;
|
|
71
|
+
|
|
72
|
+
@postConstruct()
|
|
73
|
+
protected init(): void {
|
|
74
|
+
this.id = AIAgentConfigurationWidget.ID;
|
|
75
|
+
this.title.label = AIAgentConfigurationWidget.LABEL;
|
|
76
|
+
this.title.closable = false;
|
|
77
|
+
|
|
78
|
+
this.languageModelRegistry.getLanguageModels().then(models => {
|
|
79
|
+
this.languageModels = models ?? [];
|
|
80
|
+
this.update();
|
|
81
|
+
});
|
|
82
|
+
this.toDispose.push(this.languageModelRegistry.onChange(({ models }) => {
|
|
83
|
+
this.languageModels = models;
|
|
84
|
+
this.update();
|
|
85
|
+
}));
|
|
86
|
+
this.toDispose.push(this.promptCustomizationService.onDidChangePrompt(() => this.update()));
|
|
87
|
+
|
|
88
|
+
this.aiSettingsService.onDidChange(() => this.update());
|
|
89
|
+
this.aiConfigurationSelectionService.onDidAgentChange(() => this.update());
|
|
90
|
+
this.update();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
protected render(): React.ReactNode {
|
|
94
|
+
return <div className='ai-agent-configuration-main'>
|
|
95
|
+
<div className='configuration-agents-list preferences-tree-widget theia-TreeContainer' style={{ width: '25%' }}>
|
|
96
|
+
<ul>
|
|
97
|
+
{this.agentService.getAllAgents().map(agent =>
|
|
98
|
+
<li key={agent.id} className='theia-TreeNode theia-CompositeTreeNode theia-ExpandableTreeNode' onClick={() => this.setActiveAgent(agent)}>
|
|
99
|
+
{this.renderAgentName(agent)}
|
|
100
|
+
</li>
|
|
101
|
+
)}
|
|
102
|
+
</ul>
|
|
103
|
+
</div>
|
|
104
|
+
<div className='configuration-agent-panel preferences-editor-widget'>
|
|
105
|
+
{this.renderAgentDetails()}
|
|
106
|
+
</div>
|
|
107
|
+
</div>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private renderAgentName(agent: Agent): React.ReactNode {
|
|
111
|
+
const tagsSuffix = agent.tags?.length ? <span>{agent.tags.map(tag => <span className='agent-tag'>{tag}</span>)}</span> : '';
|
|
112
|
+
return <span>{agent.name} {tagsSuffix}</span>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private renderAgentDetails(): React.ReactNode {
|
|
116
|
+
const agent = this.aiConfigurationSelectionService.getActiveAgent();
|
|
117
|
+
if (!agent) {
|
|
118
|
+
return <div>Please select an Agent first!</div>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const enabled = this.agentService.isEnabled(agent.id);
|
|
122
|
+
|
|
123
|
+
const parsedPromptParts = this.parsePromptTemplatesForVariableAndFunction(agent);
|
|
124
|
+
const globalVariables = Array.from(new Set([...parsedPromptParts.globalVariables, ...agent.variables]));
|
|
125
|
+
const functions = Array.from(new Set([...parsedPromptParts.functions, ...agent.functions]));
|
|
126
|
+
|
|
127
|
+
return <div key={agent.id} style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start' }}>
|
|
128
|
+
<div className='settings-section-title settings-section-category-title' style={{ paddingLeft: 0, paddingBottom: 10 }}>{this.renderAgentName(agent)}</div>
|
|
129
|
+
<div style={{ paddingBottom: 10 }}>{agent.description}</div>
|
|
130
|
+
<div style={{ paddingBottom: 10 }}>
|
|
131
|
+
<label>
|
|
132
|
+
<input type="checkbox" checked={enabled} onChange={this.toggleAgentEnabled} />
|
|
133
|
+
Enable Agent
|
|
134
|
+
</label>
|
|
135
|
+
</div>
|
|
136
|
+
<div className='ai-templates'>
|
|
137
|
+
{agent.promptTemplates?.map(template =>
|
|
138
|
+
<TemplateRenderer
|
|
139
|
+
key={agent?.id + '.' + template.id}
|
|
140
|
+
agentId={agent.id}
|
|
141
|
+
template={template}
|
|
142
|
+
promptCustomizationService={this.promptCustomizationService} />)}
|
|
143
|
+
</div>
|
|
144
|
+
<div className='ai-lm-requirements'>
|
|
145
|
+
<LanguageModelRenderer
|
|
146
|
+
agent={agent}
|
|
147
|
+
languageModels={this.languageModels}
|
|
148
|
+
aiSettingsService={this.aiSettingsService}
|
|
149
|
+
languageModelRegistry={this.languageModelRegistry} />
|
|
150
|
+
</div>
|
|
151
|
+
<div>
|
|
152
|
+
<span>Used Global Variables:</span>
|
|
153
|
+
<ul className='variable-references'>
|
|
154
|
+
<AgentGlobalVariables variables={globalVariables} showVariableConfigurationTab={this.showVariableConfigurationTab.bind(this)} />
|
|
155
|
+
</ul>
|
|
156
|
+
</div>
|
|
157
|
+
<div>
|
|
158
|
+
<span>Used agent-specific Variables:</span>
|
|
159
|
+
<ul className='variable-references'>
|
|
160
|
+
<AgentSpecificVariables
|
|
161
|
+
promptVariables={parsedPromptParts.agentSpecificVariables}
|
|
162
|
+
agent={agent}
|
|
163
|
+
/>
|
|
164
|
+
</ul>
|
|
165
|
+
</div>
|
|
166
|
+
<div>
|
|
167
|
+
<span>Used Functions:</span>
|
|
168
|
+
<ul className='function-references'>
|
|
169
|
+
<AgentFunctions functions={functions} />
|
|
170
|
+
</ul>
|
|
171
|
+
</div>
|
|
172
|
+
</div>;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private parsePromptTemplatesForVariableAndFunction(agent: Agent): ParsedPrompt {
|
|
176
|
+
const promptTemplates = agent.promptTemplates;
|
|
177
|
+
const result: ParsedPrompt = { functions: [], globalVariables: [], agentSpecificVariables: [] };
|
|
178
|
+
promptTemplates.forEach(template => {
|
|
179
|
+
const storedPrompt = this.promptService.getRawPrompt(template.id);
|
|
180
|
+
const prompt = storedPrompt?.template ?? template.template;
|
|
181
|
+
const variableMatches = [...prompt.matchAll(PROMPT_VARIABLE_REGEX)];
|
|
182
|
+
|
|
183
|
+
variableMatches.forEach(match => {
|
|
184
|
+
const variableId = match[1];
|
|
185
|
+
// if the variable is part of the variable service and not part of the agent specific variables then it is a global variable
|
|
186
|
+
if (this.variableService.hasVariable(variableId) &&
|
|
187
|
+
agent.agentSpecificVariables.find(v => v.name === variableId) === undefined) {
|
|
188
|
+
result.globalVariables.push(variableId);
|
|
189
|
+
} else {
|
|
190
|
+
result.agentSpecificVariables.push(variableId);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const functionMatches = [...prompt.matchAll(PROMPT_FUNCTION_REGEX)];
|
|
195
|
+
functionMatches.forEach(match => {
|
|
196
|
+
const functionId = match[1];
|
|
197
|
+
result.functions.push(functionId);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
});
|
|
201
|
+
return result;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
protected showVariableConfigurationTab(): void {
|
|
205
|
+
this.aiConfigurationSelectionService.selectConfigurationTab(AIVariableConfigurationWidget.ID);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
protected setActiveAgent(agent: Agent): void {
|
|
209
|
+
this.aiConfigurationSelectionService.setActiveAgent(agent);
|
|
210
|
+
this.update();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
private toggleAgentEnabled = () => {
|
|
214
|
+
const agent = this.aiConfigurationSelectionService.getActiveAgent();
|
|
215
|
+
if (!agent) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
const enabled = this.agentService.isEnabled(agent.id);
|
|
219
|
+
if (enabled) {
|
|
220
|
+
this.agentService.disableAgent(agent.id);
|
|
221
|
+
} else {
|
|
222
|
+
this.agentService.enableAgent(agent.id);
|
|
223
|
+
}
|
|
224
|
+
this.update();
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
}
|
|
228
|
+
interface AgentGlobalVariablesProps {
|
|
229
|
+
variables: string[];
|
|
230
|
+
showVariableConfigurationTab: () => void;
|
|
231
|
+
}
|
|
232
|
+
const AgentGlobalVariables = ({ variables: globalVariables, showVariableConfigurationTab }: AgentGlobalVariablesProps) => {
|
|
233
|
+
if (globalVariables.length === 0) {
|
|
234
|
+
return <>None</>;
|
|
235
|
+
}
|
|
236
|
+
return <>
|
|
237
|
+
{globalVariables.map(variableId => <li key={variableId} className='theia-TreeNode theia-CompositeTreeNode theia-ExpandableTreeNode theia-mod-selected'>
|
|
238
|
+
<div key={variableId} onClick={() => { showVariableConfigurationTab(); }} className='variable-reference'>
|
|
239
|
+
<span>{variableId}</span>
|
|
240
|
+
<i className={codicon('chevron-right')}></i>
|
|
241
|
+
</div></li>)}
|
|
242
|
+
|
|
243
|
+
</>;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
interface AgentFunctionsProps {
|
|
247
|
+
functions: string[];
|
|
248
|
+
}
|
|
249
|
+
const AgentFunctions = ({ functions }: AgentFunctionsProps) => {
|
|
250
|
+
if (functions.length === 0) {
|
|
251
|
+
return <>None</>;
|
|
252
|
+
}
|
|
253
|
+
return <>
|
|
254
|
+
{functions.map(functionId => <li key={functionId} className='variable-reference'>
|
|
255
|
+
<span>{functionId}</span>
|
|
256
|
+
</li>)}
|
|
257
|
+
</>;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
interface AgentSpecificVariablesProps {
|
|
261
|
+
promptVariables: string[];
|
|
262
|
+
agent: Agent;
|
|
263
|
+
}
|
|
264
|
+
const AgentSpecificVariables = ({ promptVariables, agent }: AgentSpecificVariablesProps) => {
|
|
265
|
+
const agentDefinedVariablesName = agent.agentSpecificVariables.map(v => v.name);
|
|
266
|
+
const variables = Array.from(new Set([...promptVariables, ...agentDefinedVariablesName]));
|
|
267
|
+
if (variables.length === 0) {
|
|
268
|
+
return <>None</>;
|
|
269
|
+
}
|
|
270
|
+
return <>
|
|
271
|
+
{variables.map(variableId =>
|
|
272
|
+
<AgentSpecifcVariable
|
|
273
|
+
key={variableId}
|
|
274
|
+
variableId={variableId}
|
|
275
|
+
agent={agent}
|
|
276
|
+
promptVariables={promptVariables} />
|
|
277
|
+
|
|
278
|
+
)}
|
|
279
|
+
</>;
|
|
280
|
+
};
|
|
281
|
+
interface AgentSpecifcVariableProps {
|
|
282
|
+
variableId: string;
|
|
283
|
+
agent: Agent;
|
|
284
|
+
promptVariables: string[];
|
|
285
|
+
}
|
|
286
|
+
const AgentSpecifcVariable = ({ variableId, agent, promptVariables }: AgentSpecifcVariableProps) => {
|
|
287
|
+
const agentDefinedVariable = agent.agentSpecificVariables.find(v => v.name === variableId);
|
|
288
|
+
const undeclared = agentDefinedVariable === undefined;
|
|
289
|
+
const notUsed = !promptVariables.includes(variableId) && agentDefinedVariable?.usedInPrompt === true;
|
|
290
|
+
return <li key={variableId}>
|
|
291
|
+
<div><span>Name:</span> <span>{variableId}</span></div>
|
|
292
|
+
{undeclared ? <div><span>Undeclared</span></div> :
|
|
293
|
+
(<>
|
|
294
|
+
<div><span>Description:</span> <span>{agentDefinedVariable.description}</span></div>
|
|
295
|
+
{notUsed && <div>Not used in prompt</div>}
|
|
296
|
+
</>)}
|
|
297
|
+
<hr />
|
|
298
|
+
</li>;
|
|
299
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { Emitter } from '@theia/core';
|
|
18
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
19
|
+
import { Agent } from '../../common';
|
|
20
|
+
|
|
21
|
+
@injectable()
|
|
22
|
+
export class AIConfigurationSelectionService {
|
|
23
|
+
protected activeAgent?: Agent;
|
|
24
|
+
|
|
25
|
+
protected readonly onDidSelectConfigurationEmitter = new Emitter<string>();
|
|
26
|
+
onDidSelectConfiguration = this.onDidSelectConfigurationEmitter.event;
|
|
27
|
+
|
|
28
|
+
protected readonly onDidAgentChangeEmitter = new Emitter<Agent | undefined>();
|
|
29
|
+
onDidAgentChange = this.onDidSelectConfigurationEmitter.event;
|
|
30
|
+
|
|
31
|
+
public getActiveAgent(): Agent | undefined {
|
|
32
|
+
return this.activeAgent;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public setActiveAgent(agent?: Agent): void {
|
|
36
|
+
this.activeAgent = agent;
|
|
37
|
+
this.onDidAgentChangeEmitter.fire(agent);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public selectConfigurationTab(widgetId: string): void {
|
|
41
|
+
this.onDidSelectConfigurationEmitter.fire(widgetId);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
import { FrontendApplication } from '@theia/core/lib/browser';
|
|
17
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
18
|
+
import { AIViewContribution } from '../ai-view-contribution';
|
|
19
|
+
import { AIConfigurationContainerWidget } from './ai-configuration-widget';
|
|
20
|
+
import { Command, CommandRegistry } from '@theia/core';
|
|
21
|
+
|
|
22
|
+
export const AI_CONFIGURATION_TOGGLE_COMMAND_ID = 'aiConfiguration:toggle';
|
|
23
|
+
export const OPEN_AI_CONFIG_VIEW = Command.toLocalizedCommand({
|
|
24
|
+
id: 'aiConfiguration:open',
|
|
25
|
+
label: 'Open AI Configuration view',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
@injectable()
|
|
29
|
+
export class AIAgentConfigurationViewContribution extends AIViewContribution<AIConfigurationContainerWidget> {
|
|
30
|
+
|
|
31
|
+
constructor() {
|
|
32
|
+
super({
|
|
33
|
+
widgetId: AIConfigurationContainerWidget.ID,
|
|
34
|
+
widgetName: AIConfigurationContainerWidget.LABEL,
|
|
35
|
+
defaultWidgetOptions: {
|
|
36
|
+
area: 'main',
|
|
37
|
+
rank: 100
|
|
38
|
+
},
|
|
39
|
+
toggleCommandId: AI_CONFIGURATION_TOGGLE_COMMAND_ID
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async initializeLayout(_app: FrontendApplication): Promise<void> {
|
|
44
|
+
await this.openView();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
override registerCommands(commands: CommandRegistry): void {
|
|
48
|
+
super.registerCommands(commands);
|
|
49
|
+
commands.registerCommand(OPEN_AI_CONFIG_VIEW, {
|
|
50
|
+
execute: () => this.openView({ activate: true }),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|