@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,29 @@
|
|
|
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
|
+
const tslib_1 = require("tslib");
|
|
19
|
+
tslib_1.__exportStar(require("./ai-activation-service"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./ai-core-frontend-application-contribution"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./ai-core-frontend-module"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./ai-core-preferences"), exports);
|
|
23
|
+
tslib_1.__exportStar(require("./ai-settings-service"), exports);
|
|
24
|
+
tslib_1.__exportStar(require("./ai-view-contribution"), exports);
|
|
25
|
+
tslib_1.__exportStar(require("./frontend-language-model-registry"), exports);
|
|
26
|
+
tslib_1.__exportStar(require("./frontend-variable-service"), exports);
|
|
27
|
+
tslib_1.__exportStar(require("./prompttemplate-contribution"), exports);
|
|
28
|
+
tslib_1.__exportStar(require("./theia-variable-contribution"), exports);
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEhF,kEAAwC;AACxC,sFAA4D;AAC5D,oEAA0C;AAC1C,gEAAsC;AACtC,gEAAsC;AACtC,iEAAuC;AACvC,6EAAmD;AACnD,sEAA4C;AAC5C,wEAA8C;AAC9C,wEAA8C"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LanguageGrammarDefinitionContribution, TextmateRegistry } from '@theia/monaco/lib/browser/textmate';
|
|
2
|
+
import * as monaco from '@theia/monaco-editor-core';
|
|
3
|
+
import { Command, CommandContribution, CommandRegistry } from '@theia/core';
|
|
4
|
+
import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
|
|
5
|
+
import { Widget } from '@theia/core/lib/browser';
|
|
6
|
+
import { EditorWidget } from '@theia/editor/lib/browser';
|
|
7
|
+
import { PromptCustomizationService } from '../common';
|
|
8
|
+
import { ProviderResult } from '@theia/monaco-editor-core/esm/vs/editor/common/languages';
|
|
9
|
+
export declare const DISCARD_PROMPT_TEMPLATE_CUSTOMIZATIONS: Command;
|
|
10
|
+
export declare const SHOW_ALL_PROMPTS_COMMAND: Command;
|
|
11
|
+
export declare class PromptTemplateContribution implements LanguageGrammarDefinitionContribution, CommandContribution, TabBarToolbarContribution {
|
|
12
|
+
private readonly promptService;
|
|
13
|
+
private readonly messageService;
|
|
14
|
+
protected readonly customizationService: PromptCustomizationService;
|
|
15
|
+
private toolProviders;
|
|
16
|
+
readonly config: monaco.languages.LanguageConfiguration;
|
|
17
|
+
registerTextmateLanguage(registry: TextmateRegistry): void;
|
|
18
|
+
provideFunctionCompletions(model: monaco.editor.ITextModel, position: monaco.Position): ProviderResult<monaco.languages.CompletionList>;
|
|
19
|
+
getCompletionRange(model: monaco.editor.ITextModel, position: monaco.Position, triggerCharacters: string): monaco.Range | undefined;
|
|
20
|
+
private getSuggestions;
|
|
21
|
+
registerCommands(commands: CommandRegistry): void;
|
|
22
|
+
protected isPromptTemplateWidget(widget: Widget): boolean;
|
|
23
|
+
protected canDiscard(widget: EditorWidget): boolean;
|
|
24
|
+
protected discard(widget: EditorWidget): Promise<void>;
|
|
25
|
+
private showAllPrompts;
|
|
26
|
+
registerToolbarItems(registry: TabBarToolbarRegistry): void;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=prompttemplate-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompttemplate-contribution.d.ts","source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CAAC,QAAQ,EAAE,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,GAAG,SAAS;IAwBnI,OAAO,CAAC,cAAc;IAwBtB,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAYjD,SAAS,CAAC,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;IAOzD,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO;cAWnC,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAkC5D,OAAO,CAAC,cAAc;IAOtB,oBAAoB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,IAAI;CAO9D"}
|
|
@@ -0,0 +1,207 @@
|
|
|
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.PromptTemplateContribution = exports.SHOW_ALL_PROMPTS_COMMAND = exports.DISCARD_PROMPT_TEMPLATE_CUSTOMIZATIONS = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
+
const monaco = require("@theia/monaco-editor-core");
|
|
22
|
+
const core_1 = require("@theia/core");
|
|
23
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
24
|
+
const browser_2 = require("@theia/editor/lib/browser");
|
|
25
|
+
const common_1 = require("../common");
|
|
26
|
+
const PROMPT_TEMPLATE_LANGUAGE_ID = 'theia-ai-prompt-template';
|
|
27
|
+
const PROMPT_TEMPLATE_TEXTMATE_SCOPE = 'source.prompttemplate';
|
|
28
|
+
exports.DISCARD_PROMPT_TEMPLATE_CUSTOMIZATIONS = {
|
|
29
|
+
id: 'theia-ai-prompt-template:discard',
|
|
30
|
+
iconClass: (0, browser_1.codicon)('discard'),
|
|
31
|
+
category: 'Theia AI Prompt Templates'
|
|
32
|
+
};
|
|
33
|
+
// TODO this command is mainly for testing purposes
|
|
34
|
+
exports.SHOW_ALL_PROMPTS_COMMAND = {
|
|
35
|
+
id: 'theia-ai-prompt-template:show-prompts-command',
|
|
36
|
+
label: 'Show all prompts',
|
|
37
|
+
iconClass: (0, browser_1.codicon)('beaker'),
|
|
38
|
+
category: 'Theia AI Prompt Templates',
|
|
39
|
+
};
|
|
40
|
+
let PromptTemplateContribution = class PromptTemplateContribution {
|
|
41
|
+
constructor() {
|
|
42
|
+
this.config = {
|
|
43
|
+
'brackets': [
|
|
44
|
+
['${', '}'],
|
|
45
|
+
['~{', '}']
|
|
46
|
+
],
|
|
47
|
+
'autoClosingPairs': [
|
|
48
|
+
{ 'open': '${', 'close': '}' },
|
|
49
|
+
{ 'open': '~{', 'close': '}' },
|
|
50
|
+
],
|
|
51
|
+
'surroundingPairs': [
|
|
52
|
+
{ 'open': '${', 'close': '}' },
|
|
53
|
+
{ 'open': '~{', 'close': '}' }
|
|
54
|
+
]
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
registerTextmateLanguage(registry) {
|
|
58
|
+
monaco.languages.register({
|
|
59
|
+
id: PROMPT_TEMPLATE_LANGUAGE_ID,
|
|
60
|
+
'aliases': [
|
|
61
|
+
'Theia AI Prompt Templates'
|
|
62
|
+
],
|
|
63
|
+
'extensions': [
|
|
64
|
+
'.prompttemplate',
|
|
65
|
+
],
|
|
66
|
+
'filenames': []
|
|
67
|
+
});
|
|
68
|
+
monaco.languages.setLanguageConfiguration(PROMPT_TEMPLATE_LANGUAGE_ID, this.config);
|
|
69
|
+
monaco.languages.registerCompletionItemProvider(PROMPT_TEMPLATE_LANGUAGE_ID, {
|
|
70
|
+
// Monaco only supports single character trigger characters
|
|
71
|
+
triggerCharacters: ['{'],
|
|
72
|
+
provideCompletionItems: (model, position, _context, _token) => this.provideFunctionCompletions(model, position),
|
|
73
|
+
});
|
|
74
|
+
const textmateGrammar = require('../../data/prompttemplate.tmLanguage.json');
|
|
75
|
+
const grammarDefinitionProvider = {
|
|
76
|
+
getGrammarDefinition: function () {
|
|
77
|
+
return Promise.resolve({
|
|
78
|
+
format: 'json',
|
|
79
|
+
content: textmateGrammar
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
registry.registerTextmateGrammarScope(PROMPT_TEMPLATE_TEXTMATE_SCOPE, grammarDefinitionProvider);
|
|
84
|
+
registry.mapLanguageIdToTextmateGrammar(PROMPT_TEMPLATE_LANGUAGE_ID, PROMPT_TEMPLATE_TEXTMATE_SCOPE);
|
|
85
|
+
}
|
|
86
|
+
provideFunctionCompletions(model, position) {
|
|
87
|
+
return this.getSuggestions(model, position, '~{', this.toolProviders.getContributions().map(provider => provider.getTool()), monaco.languages.CompletionItemKind.Function, tool => tool.id, tool => tool.name, tool => { var _a; return (_a = tool.description) !== null && _a !== void 0 ? _a : ''; });
|
|
88
|
+
}
|
|
89
|
+
getCompletionRange(model, position, triggerCharacters) {
|
|
90
|
+
// Check if the characters before the current position are the trigger characters
|
|
91
|
+
const lineContent = model.getLineContent(position.lineNumber);
|
|
92
|
+
const triggerLength = triggerCharacters.length;
|
|
93
|
+
const charactersBefore = lineContent.substring(position.column - triggerLength - 1, position.column - 1);
|
|
94
|
+
if (charactersBefore !== triggerCharacters) {
|
|
95
|
+
// Do not return agent suggestions if the user didn't just type the trigger characters
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
// Calculate the range from the position of the trigger characters
|
|
99
|
+
const wordInfo = model.getWordUntilPosition(position);
|
|
100
|
+
return new monaco.Range(position.lineNumber, wordInfo.startColumn, position.lineNumber, position.column);
|
|
101
|
+
}
|
|
102
|
+
getSuggestions(model, position, triggerChars, items, kind, getId, getName, getDescription) {
|
|
103
|
+
const completionRange = this.getCompletionRange(model, position, triggerChars);
|
|
104
|
+
if (completionRange === undefined) {
|
|
105
|
+
return { suggestions: [] };
|
|
106
|
+
}
|
|
107
|
+
const suggestions = items.map(item => ({
|
|
108
|
+
insertText: getId(item),
|
|
109
|
+
kind: kind,
|
|
110
|
+
label: getName(item),
|
|
111
|
+
range: completionRange,
|
|
112
|
+
detail: getDescription(item),
|
|
113
|
+
}));
|
|
114
|
+
return { suggestions };
|
|
115
|
+
}
|
|
116
|
+
registerCommands(commands) {
|
|
117
|
+
commands.registerCommand(exports.DISCARD_PROMPT_TEMPLATE_CUSTOMIZATIONS, {
|
|
118
|
+
isVisible: (widget) => this.isPromptTemplateWidget(widget),
|
|
119
|
+
isEnabled: (widget) => this.canDiscard(widget),
|
|
120
|
+
execute: (widget) => this.discard(widget)
|
|
121
|
+
});
|
|
122
|
+
commands.registerCommand(exports.SHOW_ALL_PROMPTS_COMMAND, {
|
|
123
|
+
execute: () => this.showAllPrompts()
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
isPromptTemplateWidget(widget) {
|
|
127
|
+
if (widget instanceof browser_2.EditorWidget) {
|
|
128
|
+
return PROMPT_TEMPLATE_LANGUAGE_ID === widget.editor.document.languageId;
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
canDiscard(widget) {
|
|
133
|
+
const resourceUri = widget.editor.uri;
|
|
134
|
+
const id = this.customizationService.getTemplateIDFromURI(resourceUri);
|
|
135
|
+
if (id === undefined) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
const rawPrompt = this.promptService.getRawPrompt(id);
|
|
139
|
+
const defaultPrompt = this.promptService.getDefaultRawPrompt(id);
|
|
140
|
+
return (rawPrompt === null || rawPrompt === void 0 ? void 0 : rawPrompt.template) !== (defaultPrompt === null || defaultPrompt === void 0 ? void 0 : defaultPrompt.template);
|
|
141
|
+
}
|
|
142
|
+
async discard(widget) {
|
|
143
|
+
const resourceUri = widget.editor.uri;
|
|
144
|
+
const id = this.customizationService.getTemplateIDFromURI(resourceUri);
|
|
145
|
+
if (id === undefined) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const defaultPrompt = this.promptService.getDefaultRawPrompt(id);
|
|
149
|
+
if (defaultPrompt === undefined) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const source = widget.editor.document.getText();
|
|
153
|
+
const lastLine = widget.editor.document.getLineContent(widget.editor.document.lineCount);
|
|
154
|
+
const replaceOperation = {
|
|
155
|
+
range: {
|
|
156
|
+
start: {
|
|
157
|
+
line: 0,
|
|
158
|
+
character: 0
|
|
159
|
+
},
|
|
160
|
+
end: {
|
|
161
|
+
line: widget.editor.document.lineCount,
|
|
162
|
+
character: lastLine.length
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
text: defaultPrompt.template
|
|
166
|
+
};
|
|
167
|
+
await widget.editor.replaceText({
|
|
168
|
+
source,
|
|
169
|
+
replaceOperations: [replaceOperation]
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
showAllPrompts() {
|
|
173
|
+
const allPrompts = this.promptService.getAllPrompts();
|
|
174
|
+
Object.keys(allPrompts).forEach(id => {
|
|
175
|
+
this.messageService.info(`Prompt Template ID: ${id}\n${allPrompts[id].template}`, 'Got it');
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
registerToolbarItems(registry) {
|
|
179
|
+
registry.registerItem({
|
|
180
|
+
id: exports.DISCARD_PROMPT_TEMPLATE_CUSTOMIZATIONS.id,
|
|
181
|
+
command: exports.DISCARD_PROMPT_TEMPLATE_CUSTOMIZATIONS.id,
|
|
182
|
+
tooltip: 'Discard Customizations'
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
exports.PromptTemplateContribution = PromptTemplateContribution;
|
|
187
|
+
tslib_1.__decorate([
|
|
188
|
+
(0, inversify_1.inject)(common_1.PromptService),
|
|
189
|
+
tslib_1.__metadata("design:type", Object)
|
|
190
|
+
], PromptTemplateContribution.prototype, "promptService", void 0);
|
|
191
|
+
tslib_1.__decorate([
|
|
192
|
+
(0, inversify_1.inject)(core_1.MessageService),
|
|
193
|
+
tslib_1.__metadata("design:type", core_1.MessageService)
|
|
194
|
+
], PromptTemplateContribution.prototype, "messageService", void 0);
|
|
195
|
+
tslib_1.__decorate([
|
|
196
|
+
(0, inversify_1.inject)(common_1.PromptCustomizationService),
|
|
197
|
+
tslib_1.__metadata("design:type", Object)
|
|
198
|
+
], PromptTemplateContribution.prototype, "customizationService", void 0);
|
|
199
|
+
tslib_1.__decorate([
|
|
200
|
+
(0, inversify_1.inject)(core_1.ContributionProvider),
|
|
201
|
+
(0, inversify_1.named)(common_1.ToolProvider),
|
|
202
|
+
tslib_1.__metadata("design:type", Object)
|
|
203
|
+
], PromptTemplateContribution.prototype, "toolProviders", void 0);
|
|
204
|
+
exports.PromptTemplateContribution = PromptTemplateContribution = tslib_1.__decorate([
|
|
205
|
+
(0, inversify_1.injectable)()
|
|
206
|
+
], PromptTemplateContribution);
|
|
207
|
+
//# sourceMappingURL=prompttemplate-contribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompttemplate-contribution.js","sourceRoot":"","sources":["../../src/browser/prompttemplate-contribution.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AAC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QAClB,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC;QACtD,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;YACjC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,uBAAuB,EAAE,KAAK,UAAU,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC;QAChG,CAAC,CAAC,CAAC;IACP,CAAC;IAED,oBAAoB,CAAC,QAA+B;QAChD,QAAQ,CAAC,YAAY,CAAC;YAClB,EAAE,EAAE,8CAAsC,CAAC,EAAE;YAC7C,OAAO,EAAE,8CAAsC,CAAC,EAAE;YAClD,OAAO,EAAE,wBAAwB;SACpC,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AA5MY,gEAA0B;AAGlB;IADhB,IAAA,kBAAM,EAAC,sBAAa,CAAC;;iEACwB;AAG7B;IADhB,IAAA,kBAAM,EAAC,qBAAc,CAAC;sCACU,qBAAc;kEAAC;AAG7B;IADlB,IAAA,kBAAM,EAAC,mCAA0B,CAAC;;wEACiC;AAI5D;IAFP,IAAA,kBAAM,EAAC,2BAAoB,CAAC;IAC5B,IAAA,iBAAK,EAAC,qBAAY,CAAC;;iEACsC;qCAbjD,0BAA0B;IADtC,IAAA,sBAAU,GAAE;GACA,0BAA0B,CA4MtC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
|
|
2
|
+
import { VariableRegistry, VariableResolverService } from '@theia/variable-resolver/lib/browser';
|
|
3
|
+
import { AIVariableContribution, AIVariableResolver, AIVariableService, AIVariableResolutionRequest, AIVariableContext, ResolvedAIVariable } from '../common';
|
|
4
|
+
export declare class TheiaVariableContribution implements AIVariableContribution, AIVariableResolver {
|
|
5
|
+
protected readonly variableResolverService: VariableResolverService;
|
|
6
|
+
protected readonly variableRegistry: VariableRegistry;
|
|
7
|
+
protected readonly stateService: FrontendApplicationStateService;
|
|
8
|
+
registerVariables(service: AIVariableService): void;
|
|
9
|
+
protected toTheiaVariable(request: AIVariableResolutionRequest): string;
|
|
10
|
+
canResolve(request: AIVariableResolutionRequest, context: AIVariableContext): Promise<number>;
|
|
11
|
+
resolve(request: AIVariableResolutionRequest, context: AIVariableContext): Promise<ResolvedAIVariable | undefined>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=theia-variable-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theia-variable-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/theia-variable-contribution.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AAErG,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AACjG,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE9J,qBACa,yBAA0B,YAAW,sBAAsB,EAAE,kBAAkB;IAExF,SAAS,CAAC,QAAQ,CAAC,uBAAuB,EAAE,uBAAuB,CAAC;IAGpE,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAGtD,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,+BAA+B,CAAC;IAEjE,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAUnD,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,2BAA2B,GAAG,MAAM;IAIjE,UAAU,CAAC,OAAO,EAAE,2BAA2B,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAO7F,OAAO,CAAC,OAAO,EAAE,2BAA2B,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC;CAI3H"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TheiaVariableContribution = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// *****************************************************************************
|
|
6
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
7
|
+
//
|
|
8
|
+
// This program and the accompanying materials are made available under the
|
|
9
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
10
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
11
|
+
//
|
|
12
|
+
// This Source Code may also be made available under the following Secondary
|
|
13
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
14
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
15
|
+
// with the GNU Classpath Exception which is available at
|
|
16
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
17
|
+
//
|
|
18
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
19
|
+
// *****************************************************************************
|
|
20
|
+
const frontend_application_state_1 = require("@theia/core/lib/browser/frontend-application-state");
|
|
21
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
22
|
+
const browser_1 = require("@theia/variable-resolver/lib/browser");
|
|
23
|
+
let TheiaVariableContribution = class TheiaVariableContribution {
|
|
24
|
+
registerVariables(service) {
|
|
25
|
+
this.stateService.reachedState('initialized_layout').then(() => {
|
|
26
|
+
// some variable contributions in Theia are done as part of the onStart, same as our AI variable contributions
|
|
27
|
+
// we therefore wait for all of them to be registered before we register we map them to our own
|
|
28
|
+
this.variableRegistry.getVariables().forEach(variable => {
|
|
29
|
+
var _a;
|
|
30
|
+
service.registerResolver({ id: `theia-${variable.name}`, name: variable.name, description: (_a = variable.description) !== null && _a !== void 0 ? _a : 'Theia Built-in Variable' }, this);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
toTheiaVariable(request) {
|
|
35
|
+
return `$\{${request.variable.name}${request.arg ? ':' + request.arg : ''}}`;
|
|
36
|
+
}
|
|
37
|
+
async canResolve(request, context) {
|
|
38
|
+
// some variables are not resolvable without providing a specific context
|
|
39
|
+
// this may be expensive but was not a problem for Theia's built-in variables
|
|
40
|
+
const resolved = await this.variableResolverService.resolve(this.toTheiaVariable(request), context);
|
|
41
|
+
return !resolved ? 0 : 1;
|
|
42
|
+
}
|
|
43
|
+
async resolve(request, context) {
|
|
44
|
+
const resolved = await this.variableResolverService.resolve(this.toTheiaVariable(request), context);
|
|
45
|
+
return resolved ? { value: resolved, variable: request.variable } : undefined;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
exports.TheiaVariableContribution = TheiaVariableContribution;
|
|
49
|
+
tslib_1.__decorate([
|
|
50
|
+
(0, inversify_1.inject)(browser_1.VariableResolverService),
|
|
51
|
+
tslib_1.__metadata("design:type", browser_1.VariableResolverService)
|
|
52
|
+
], TheiaVariableContribution.prototype, "variableResolverService", void 0);
|
|
53
|
+
tslib_1.__decorate([
|
|
54
|
+
(0, inversify_1.inject)(browser_1.VariableRegistry),
|
|
55
|
+
tslib_1.__metadata("design:type", browser_1.VariableRegistry)
|
|
56
|
+
], TheiaVariableContribution.prototype, "variableRegistry", void 0);
|
|
57
|
+
tslib_1.__decorate([
|
|
58
|
+
(0, inversify_1.inject)(frontend_application_state_1.FrontendApplicationStateService),
|
|
59
|
+
tslib_1.__metadata("design:type", frontend_application_state_1.FrontendApplicationStateService)
|
|
60
|
+
], TheiaVariableContribution.prototype, "stateService", void 0);
|
|
61
|
+
exports.TheiaVariableContribution = TheiaVariableContribution = tslib_1.__decorate([
|
|
62
|
+
(0, inversify_1.injectable)()
|
|
63
|
+
], TheiaVariableContribution);
|
|
64
|
+
//# sourceMappingURL=theia-variable-contribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theia-variable-contribution.js","sourceRoot":"","sources":["../../src/browser/theia-variable-cont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,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAoC,EAAE,OAA0B;QAC1E,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;QACpG,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAClF,CAAC;CACJ,CAAA;AAnCY,8DAAyB;AAEf;IADlB,IAAA,kBAAM,EAAC,iCAAuB,CAAC;sCACY,iCAAuB;0EAAC;AAGjD;IADlB,IAAA,kBAAM,EAAC,0BAAgB,CAAC;sCACY,0BAAgB;mEAAC;AAGnC;IADlB,IAAA,kBAAM,EAAC,4DAA+B,CAAC;sCACP,4DAA+B;+DAAC;oCARxD,yBAAyB;IADrC,IAAA,sBAAU,GAAE;GACA,yBAAyB,CAmCrC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ContributionProvider } from '@theia/core';
|
|
2
|
+
import { Agent } from './agent';
|
|
3
|
+
import { AISettingsService } from './settings-service';
|
|
4
|
+
export declare const AgentService: unique symbol;
|
|
5
|
+
/**
|
|
6
|
+
* Service to access the list of known Agents.
|
|
7
|
+
*/
|
|
8
|
+
export interface AgentService {
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves a list of all available agents, i.e. agents which are not disabled
|
|
11
|
+
*/
|
|
12
|
+
getAgents(): Agent[];
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves a list of all agents, including disabled ones.
|
|
15
|
+
*/
|
|
16
|
+
getAllAgents(): Agent[];
|
|
17
|
+
/**
|
|
18
|
+
* Enable the agent with the specified id.
|
|
19
|
+
* @param agentId the agent id.
|
|
20
|
+
*/
|
|
21
|
+
enableAgent(agentId: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* disable the agent with the specified id.
|
|
24
|
+
* @param agentId the agent id.
|
|
25
|
+
*/
|
|
26
|
+
disableAgent(agentId: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* query whether this agent is currently enabled or disabled.
|
|
29
|
+
* @param agentId the agent id.
|
|
30
|
+
* @return true if the agent is enabled, false otherwise.
|
|
31
|
+
*/
|
|
32
|
+
isEnabled(agentId: string): boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare class AgentServiceImpl implements AgentService {
|
|
35
|
+
protected readonly agentsProvider: ContributionProvider<Agent>;
|
|
36
|
+
protected readonly aiSettingsService: AISettingsService | undefined;
|
|
37
|
+
protected disabledAgents: Set<string>;
|
|
38
|
+
protected _agents: Agent[];
|
|
39
|
+
protected init(): void;
|
|
40
|
+
private get agents();
|
|
41
|
+
registerAgent(agent: Agent): void;
|
|
42
|
+
getAgents(): Agent[];
|
|
43
|
+
getAllAgents(): Agent[];
|
|
44
|
+
enableAgent(agentId: string): void;
|
|
45
|
+
disableAgent(agentId: string): void;
|
|
46
|
+
isEnabled(agentId: string): boolean;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=agent-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-service.d.ts","sourceRoot":"","sources":["../../src/common/agent-service.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,eAAO,MAAM,YAAY,eAAyB,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,SAAS,IAAI,KAAK,EAAE,CAAC;IACrB;;OAEG;IACH,YAAY,IAAI,KAAK,EAAE,CAAC;IACxB;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC;;;OAGG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC;;;;OAIG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;CACvC;AAED,qBACa,gBAAiB,YAAW,YAAY;IAGjD,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAG/D,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAEpE,SAAS,CAAC,cAAc,cAAqB;IAE7C,SAAS,CAAC,OAAO,EAAE,KAAK,EAAE,CAAM;IAGhC,SAAS,CAAC,IAAI,IAAI,IAAI;IAUtB,OAAO,KAAK,MAAM,GAIjB;IAED,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAIjC,SAAS,IAAI,KAAK,EAAE;IAIpB,YAAY,IAAI,KAAK,EAAE;IAIvB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAKlC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAKnC,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;CAGtC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AgentServiceImpl = exports.AgentService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// *****************************************************************************
|
|
6
|
+
// Copyright (C) 2024 EclipseSource GmbH.
|
|
7
|
+
//
|
|
8
|
+
// This program and the accompanying materials are made available under the
|
|
9
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
10
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
11
|
+
//
|
|
12
|
+
// This Source Code may also be made available under the following Secondary
|
|
13
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
14
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
15
|
+
// with the GNU Classpath Exception which is available at
|
|
16
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
17
|
+
//
|
|
18
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
19
|
+
// *****************************************************************************
|
|
20
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
+
const core_1 = require("@theia/core");
|
|
22
|
+
const agent_1 = require("./agent");
|
|
23
|
+
const settings_service_1 = require("./settings-service");
|
|
24
|
+
exports.AgentService = Symbol('AgentService');
|
|
25
|
+
let AgentServiceImpl = class AgentServiceImpl {
|
|
26
|
+
constructor() {
|
|
27
|
+
this.disabledAgents = new Set();
|
|
28
|
+
this._agents = [];
|
|
29
|
+
}
|
|
30
|
+
init() {
|
|
31
|
+
var _a;
|
|
32
|
+
(_a = this.aiSettingsService) === null || _a === void 0 ? void 0 : _a.getSettings().then(settings => {
|
|
33
|
+
Object.entries(settings).forEach(([agentId, agentSettings]) => {
|
|
34
|
+
if (agentSettings.enable === false) {
|
|
35
|
+
this.disabledAgents.add(agentId);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
get agents() {
|
|
41
|
+
// We can't collect the contributions at @postConstruct because this will lead to a circular dependency
|
|
42
|
+
// with agents reusing the chat agent service (e.g. orchestrator) which in turn injects the agent service
|
|
43
|
+
return [...this.agentsProvider.getContributions(), ...this._agents];
|
|
44
|
+
}
|
|
45
|
+
registerAgent(agent) {
|
|
46
|
+
this._agents.push(agent);
|
|
47
|
+
}
|
|
48
|
+
getAgents() {
|
|
49
|
+
return this.agents.filter(agent => this.isEnabled(agent.id));
|
|
50
|
+
}
|
|
51
|
+
getAllAgents() {
|
|
52
|
+
return this.agents;
|
|
53
|
+
}
|
|
54
|
+
enableAgent(agentId) {
|
|
55
|
+
var _a;
|
|
56
|
+
this.disabledAgents.delete(agentId);
|
|
57
|
+
(_a = this.aiSettingsService) === null || _a === void 0 ? void 0 : _a.updateAgentSettings(agentId, { enable: true });
|
|
58
|
+
}
|
|
59
|
+
disableAgent(agentId) {
|
|
60
|
+
var _a;
|
|
61
|
+
this.disabledAgents.add(agentId);
|
|
62
|
+
(_a = this.aiSettingsService) === null || _a === void 0 ? void 0 : _a.updateAgentSettings(agentId, { enable: false });
|
|
63
|
+
}
|
|
64
|
+
isEnabled(agentId) {
|
|
65
|
+
return !this.disabledAgents.has(agentId);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
exports.AgentServiceImpl = AgentServiceImpl;
|
|
69
|
+
tslib_1.__decorate([
|
|
70
|
+
(0, inversify_1.inject)(core_1.ContributionProvider),
|
|
71
|
+
(0, inversify_1.named)(agent_1.Agent),
|
|
72
|
+
tslib_1.__metadata("design:type", Object)
|
|
73
|
+
], AgentServiceImpl.prototype, "agentsProvider", void 0);
|
|
74
|
+
tslib_1.__decorate([
|
|
75
|
+
(0, inversify_1.inject)(settings_service_1.AISettingsService),
|
|
76
|
+
(0, inversify_1.optional)(),
|
|
77
|
+
tslib_1.__metadata("design:type", Object)
|
|
78
|
+
], AgentServiceImpl.prototype, "aiSettingsService", void 0);
|
|
79
|
+
tslib_1.__decorate([
|
|
80
|
+
(0, inversify_1.postConstruct)(),
|
|
81
|
+
tslib_1.__metadata("design:type", Function),
|
|
82
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
83
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
84
|
+
], AgentServiceImpl.prototype, "init", null);
|
|
85
|
+
exports.AgentServiceImpl = AgentServiceImpl = tslib_1.__decorate([
|
|
86
|
+
(0, inversify_1.injectable)()
|
|
87
|
+
], AgentServiceImpl);
|
|
88
|
+
//# sourceMappingURL=agent-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-service.js","sourceRoot":"","sources":["../../src/common/agent-service.ts"],"names":[],"mappings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,CAAC,EAAE,CAAC,CAAC,CAAC;IACjE,CAAC;IAED,YAAY;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,WAAW,CAAC,OAAe;;QACvB,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACpC,MAAA,IAAI,CAAC,iBAAiB,0CAAE,mBAAmB,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,YAAY,CAAC,OAAe;;QACxB,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACjC,MAAA,IAAI,CAAC,iBAAiB,0CAAE,mBAAmB,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,SAAS,CAAC,OAAe;QACrB,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;CACJ,CAAA;AAtDY,4CAAgB;AAGN;IADlB,IAAA,kBAAM,EAAC,2BAAoB,CAAC;IAAE,IAAA,iBAAK,EAAC,aAAK,CAAC;;wDACoB;AAG5C;IADlB,IAAA,kBAAM,EAAC,oCAAiB,CAAC;IAAE,IAAA,oBAAQ,GAAE;;2DAC8B;AAO1D;IADT,IAAA,yBAAa,GAAE;;;;4CASf;2BArBQ,gBAAgB;IAD5B,IAAA,sBAAU,GAAE;GACA,gBAAgB,CAsD5B"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { LanguageModelRequirement } from './language-model';
|
|
2
|
+
import { PromptTemplate } from './prompt-service';
|
|
3
|
+
export interface AgentSpecificVariables {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
usedInPrompt: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const Agent: unique symbol;
|
|
9
|
+
/**
|
|
10
|
+
* Agents represent the main functionality of the AI system. They are responsible for processing user input, collecting information from the environment,
|
|
11
|
+
* invoking and processing LLM responses, and providing the final response to the user while recording their actions in the AI history.
|
|
12
|
+
*
|
|
13
|
+
* Agents are meant to cover all use cases, from specialized scenarios to general purpose chat bots.
|
|
14
|
+
*
|
|
15
|
+
* Agents are encouraged to provide a detailed description of their functionality and their processed inputs.
|
|
16
|
+
* They can also declare their used prompt templates, which makes them configurable for the user.
|
|
17
|
+
*/
|
|
18
|
+
export interface Agent {
|
|
19
|
+
/**
|
|
20
|
+
* Used to identify an agent, e.g. when it is requesting language models, etc.
|
|
21
|
+
*
|
|
22
|
+
* @note This parameter might be removed in favor of `name`. Therefore, it is recommended to set `id` to the same value as `name` for now.
|
|
23
|
+
*/
|
|
24
|
+
readonly id: string;
|
|
25
|
+
/**
|
|
26
|
+
* Human-readable name shown to users to identify the agent. Must be unique.
|
|
27
|
+
* Use short names without "Agent" or "Chat" (see `tags` for adding further properties).
|
|
28
|
+
*/
|
|
29
|
+
readonly name: string;
|
|
30
|
+
/** A markdown description of its functionality and its privacy-relevant requirements, including function call handlers that access some data autonomously. */
|
|
31
|
+
readonly description: string;
|
|
32
|
+
/** The list of global variable identifiers this agent needs to clarify its context requirements. See #39. */
|
|
33
|
+
readonly variables: string[];
|
|
34
|
+
/** The prompt templates introduced and used by this agent. */
|
|
35
|
+
readonly promptTemplates: PromptTemplate[];
|
|
36
|
+
/** Required language models. This includes the purpose and optional language model selector arguments. See #47. */
|
|
37
|
+
readonly languageModelRequirements: LanguageModelRequirement[];
|
|
38
|
+
/** A list of tags to filter agents and to display capabilities in the UI */
|
|
39
|
+
readonly tags?: String[];
|
|
40
|
+
/** The list of local variable identifiers this agent needs to clarify its context requirements. */
|
|
41
|
+
readonly agentSpecificVariables: AgentSpecificVariables[];
|
|
42
|
+
/** The list of global function identifiers this agent needs to clarify its context requirements. */
|
|
43
|
+
readonly functions: string[];
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/common/agent.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,WAAW,sBAAsB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;CACzB;AAED,eAAO,MAAM,KAAK,eAAkB,CAAC;AACrC;;;;;;;;GAQG;AACH,MAAM,WAAW,KAAK;IAClB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,8JAA8J;IAC9J,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,6GAA6G;IAC7G,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;IAE7B,8DAA8D;IAC9D,QAAQ,CAAC,eAAe,EAAE,cAAc,EAAE,CAAC;IAE3C,mHAAmH;IACnH,QAAQ,CAAC,yBAAyB,EAAE,wBAAwB,EAAE,CAAC;IAE/D,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAEzB,mGAAmG;IACnG,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,EAAE,CAAC;IAE1D,oGAAoG;IACpG,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;CAChC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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.Agent = void 0;
|
|
19
|
+
exports.Agent = Symbol('Agent');
|
|
20
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/common/agent.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAWnE,QAAA,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AIVariable, AIVariableContext, AIVariableContribution, AIVariableResolutionRequest, AIVariableResolver, AIVariableService, ResolvedAIVariable } from './variable-service';
|
|
2
|
+
import { MaybePromise } from '@theia/core';
|
|
3
|
+
import { AgentService } from './agent-service';
|
|
4
|
+
export declare const AGENTS_VARIABLE: AIVariable;
|
|
5
|
+
export interface ResolvedAgentsVariable extends ResolvedAIVariable {
|
|
6
|
+
agents: AgentDescriptor[];
|
|
7
|
+
}
|
|
8
|
+
export interface AgentDescriptor {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class AgentsVariableContribution implements AIVariableContribution, AIVariableResolver {
|
|
14
|
+
protected readonly agentService: AgentService;
|
|
15
|
+
registerVariables(service: AIVariableService): void;
|
|
16
|
+
canResolve(request: AIVariableResolutionRequest, _context: AIVariableContext): MaybePromise<number>;
|
|
17
|
+
resolve(request: AIVariableResolutionRequest, context: AIVariableContext): Promise<ResolvedAgentsVariable | undefined>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=agents-variable-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-variable-contribution.d.ts","sourceRoot":"","sources":["../../src/common/agents-variable-contribution.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACnL,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,eAAO,MAAM,eAAe,EAAE,UAI7B,CAAC;AAEF,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAC9D,MAAM,EAAE,eAAe,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,eAAe;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,qBACa,0BAA2B,YAAW,sBAAsB,EAAE,kBAAkB;IAGzF,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAE9C,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAInD,UAAU,CAAC,OAAO,EAAE,2BAA2B,EAAE,QAAQ,EAAE,iBAAiB,GAAG,YAAY,CAAC,MAAM,CAAC;IAO7F,OAAO,CAAC,OAAO,EAAE,2BAA2B,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC;CAU/H"}
|