@theia/ai-core 1.46.0-next.241
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 +31 -0
- package/data/prompttemplate.tmLanguage.json +107 -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 +28 -0
- package/lib/browser/ai-configuration/agent-configuration-widget.d.ts.map +1 -0
- package/lib/browser/ai-configuration/agent-configuration-widget.js +242 -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 +13 -0
- package/lib/browser/ai-configuration/template-settings-renderer.d.ts.map +1 -0
- package/lib/browser/ai-configuration/template-settings-renderer.js +71 -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 +10 -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 +29 -0
- package/lib/browser/ai-core-preferences.d.ts.map +1 -0
- package/lib/browser/ai-core-preferences.js +98 -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 +33 -0
- package/lib/browser/frontend-prompt-customization-service.d.ts.map +1 -0
- package/lib/browser/frontend-prompt-customization-service.js +237 -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 +29 -0
- package/lib/browser/prompttemplate-contribution.d.ts.map +1 -0
- package/lib/browser/prompttemplate-contribution.js +208 -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 +66 -0
- package/lib/common/agent-service.d.ts.map +1 -0
- package/lib/common/agent-service.js +92 -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 +29 -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 +16 -0
- package/lib/common/language-model-util.d.ts.map +1 -0
- package/lib/common/language-model-util.js +92 -0
- package/lib/common/language-model-util.js.map +1 -0
- package/lib/common/language-model.d.ts +144 -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 +8 -0
- package/lib/common/prompt-service-util.d.ts.map +1 -0
- package/lib/common/prompt-service-util.js +34 -0
- package/lib/common/prompt-service-util.js.map +1 -0
- package/lib/common/prompt-service.d.ts +161 -0
- package/lib/common/prompt-service.d.ts.map +1 -0
- package/lib/common/prompt-service.js +204 -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 +254 -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 +23 -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 +61 -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 +324 -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 +128 -0
- package/src/browser/ai-configuration/variable-configuration-widget.tsx +110 -0
- package/src/browser/ai-core-frontend-application-contribution.ts +39 -0
- package/src/browser/ai-core-frontend-module.ts +161 -0
- package/src/browser/ai-core-preferences.ts +115 -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 +243 -0
- package/src/browser/frontend-variable-service.ts +26 -0
- package/src/browser/index.ts +26 -0
- package/src/browser/prompttemplate-contribution.ts +252 -0
- package/src/browser/style/index.css +127 -0
- package/src/browser/theia-variable-contribution.ts +58 -0
- package/src/common/agent-service.ts +137 -0
- package/src/common/agent.ts +70 -0
- package/src/common/agents-variable-contribution.ts +64 -0
- package/src/common/communication-recording-service.ts +53 -0
- package/src/common/index.ts +30 -0
- package/src/common/language-model-delegate.ts +45 -0
- package/src/common/language-model-util.ts +84 -0
- package/src/common/language-model.spec.ts +86 -0
- package/src/common/language-model.ts +242 -0
- package/src/common/prompt-service-util.ts +31 -0
- package/src/common/prompt-service.spec.ts +301 -0
- package/src/common/prompt-service.ts +334 -0
- package/src/common/protocol.ts +23 -0
- package/src/common/settings-service.ts +38 -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,31 @@
|
|
|
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.FrontendVariableService = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
+
const common_1 = require("../common");
|
|
22
|
+
let FrontendVariableService = class FrontendVariableService extends common_1.DefaultAIVariableService {
|
|
23
|
+
onStart() {
|
|
24
|
+
this.initContributions();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.FrontendVariableService = FrontendVariableService;
|
|
28
|
+
exports.FrontendVariableService = FrontendVariableService = tslib_1.__decorate([
|
|
29
|
+
(0, inversify_1.injectable)()
|
|
30
|
+
], FrontendVariableService);
|
|
31
|
+
//# sourceMappingURL=frontend-variable-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontend-variable-service.js","sourceRoot":"","sources":["../../src/browser/frontend-variable-service.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,4DAA0D;AAC1D,sCAAqD;AAI9C,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,iCAAwB;IACjE,OAAO;QACH,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC7B,CAAC;CACJ,CAAA;AAJY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,sBAAU,GAAE;GACA,uBAAuB,CAInC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './ai-activation-service';
|
|
2
|
+
export * from './ai-core-frontend-application-contribution';
|
|
3
|
+
export * from './ai-core-frontend-module';
|
|
4
|
+
export * from './ai-core-preferences';
|
|
5
|
+
export * from './ai-settings-service';
|
|
6
|
+
export * from './ai-view-contribution';
|
|
7
|
+
export * from './frontend-language-model-registry';
|
|
8
|
+
export * from './frontend-variable-service';
|
|
9
|
+
export * from './prompttemplate-contribution';
|
|
10
|
+
export * from './theia-variable-contribution';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAgBA,cAAc,yBAAyB,CAAC;AACxC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC"}
|
|
@@ -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,29 @@
|
|
|
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 PROMPT_TEMPLATE_EXTENSION = ".prompttemplate";
|
|
10
|
+
export declare const DISCARD_PROMPT_TEMPLATE_CUSTOMIZATIONS: Command;
|
|
11
|
+
export declare const SHOW_ALL_PROMPTS_COMMAND: Command;
|
|
12
|
+
export declare class PromptTemplateContribution implements LanguageGrammarDefinitionContribution, CommandContribution, TabBarToolbarContribution {
|
|
13
|
+
private readonly promptService;
|
|
14
|
+
private readonly messageService;
|
|
15
|
+
protected readonly customizationService: PromptCustomizationService;
|
|
16
|
+
private toolProviders;
|
|
17
|
+
readonly config: monaco.languages.LanguageConfiguration;
|
|
18
|
+
registerTextmateLanguage(registry: TextmateRegistry): void;
|
|
19
|
+
provideFunctionCompletions(model: monaco.editor.ITextModel, position: monaco.Position): ProviderResult<monaco.languages.CompletionList>;
|
|
20
|
+
getCompletionRange(model: monaco.editor.ITextModel, position: monaco.Position, triggerCharacters: string): monaco.Range | undefined;
|
|
21
|
+
private getSuggestions;
|
|
22
|
+
registerCommands(commands: CommandRegistry): void;
|
|
23
|
+
protected isPromptTemplateWidget(widget: Widget): boolean;
|
|
24
|
+
protected canDiscard(widget: EditorWidget): boolean;
|
|
25
|
+
protected discard(widget: EditorWidget): Promise<void>;
|
|
26
|
+
private showAllPrompts;
|
|
27
|
+
registerToolbarItems(registry: TabBarToolbarRegistry): void;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=prompttemplate-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompttemplate-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/prompttemplate-contribution.ts"],"names":[],"mappings":"AA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,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,208 @@
|
|
|
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 = exports.PROMPT_TEMPLATE_EXTENSION = 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.PROMPT_TEMPLATE_EXTENSION = '.prompttemplate';
|
|
29
|
+
exports.DISCARD_PROMPT_TEMPLATE_CUSTOMIZATIONS = {
|
|
30
|
+
id: 'theia-ai-prompt-template:discard',
|
|
31
|
+
iconClass: (0, browser_1.codicon)('discard'),
|
|
32
|
+
category: 'Theia AI Prompt Templates'
|
|
33
|
+
};
|
|
34
|
+
// TODO this command is mainly for testing purposes
|
|
35
|
+
exports.SHOW_ALL_PROMPTS_COMMAND = {
|
|
36
|
+
id: 'theia-ai-prompt-template:show-prompts-command',
|
|
37
|
+
label: 'Show all prompts',
|
|
38
|
+
iconClass: (0, browser_1.codicon)('beaker'),
|
|
39
|
+
category: 'Theia AI Prompt Templates',
|
|
40
|
+
};
|
|
41
|
+
let PromptTemplateContribution = class PromptTemplateContribution {
|
|
42
|
+
constructor() {
|
|
43
|
+
this.config = {
|
|
44
|
+
'brackets': [
|
|
45
|
+
['${', '}'],
|
|
46
|
+
['~{', '}']
|
|
47
|
+
],
|
|
48
|
+
'autoClosingPairs': [
|
|
49
|
+
{ 'open': '${', 'close': '}' },
|
|
50
|
+
{ 'open': '~{', 'close': '}' },
|
|
51
|
+
],
|
|
52
|
+
'surroundingPairs': [
|
|
53
|
+
{ 'open': '${', 'close': '}' },
|
|
54
|
+
{ 'open': '~{', 'close': '}' }
|
|
55
|
+
]
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
registerTextmateLanguage(registry) {
|
|
59
|
+
monaco.languages.register({
|
|
60
|
+
id: PROMPT_TEMPLATE_LANGUAGE_ID,
|
|
61
|
+
'aliases': [
|
|
62
|
+
'Theia AI Prompt Templates'
|
|
63
|
+
],
|
|
64
|
+
'extensions': [
|
|
65
|
+
exports.PROMPT_TEMPLATE_EXTENSION,
|
|
66
|
+
],
|
|
67
|
+
'filenames': []
|
|
68
|
+
});
|
|
69
|
+
monaco.languages.setLanguageConfiguration(PROMPT_TEMPLATE_LANGUAGE_ID, this.config);
|
|
70
|
+
monaco.languages.registerCompletionItemProvider(PROMPT_TEMPLATE_LANGUAGE_ID, {
|
|
71
|
+
// Monaco only supports single character trigger characters
|
|
72
|
+
triggerCharacters: ['{'],
|
|
73
|
+
provideCompletionItems: (model, position, _context, _token) => this.provideFunctionCompletions(model, position),
|
|
74
|
+
});
|
|
75
|
+
const textmateGrammar = require('../../data/prompttemplate.tmLanguage.json');
|
|
76
|
+
const grammarDefinitionProvider = {
|
|
77
|
+
getGrammarDefinition: function () {
|
|
78
|
+
return Promise.resolve({
|
|
79
|
+
format: 'json',
|
|
80
|
+
content: textmateGrammar
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
registry.registerTextmateGrammarScope(PROMPT_TEMPLATE_TEXTMATE_SCOPE, grammarDefinitionProvider);
|
|
85
|
+
registry.mapLanguageIdToTextmateGrammar(PROMPT_TEMPLATE_LANGUAGE_ID, PROMPT_TEMPLATE_TEXTMATE_SCOPE);
|
|
86
|
+
}
|
|
87
|
+
provideFunctionCompletions(model, position) {
|
|
88
|
+
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 : ''; });
|
|
89
|
+
}
|
|
90
|
+
getCompletionRange(model, position, triggerCharacters) {
|
|
91
|
+
// Check if the characters before the current position are the trigger characters
|
|
92
|
+
const lineContent = model.getLineContent(position.lineNumber);
|
|
93
|
+
const triggerLength = triggerCharacters.length;
|
|
94
|
+
const charactersBefore = lineContent.substring(position.column - triggerLength - 1, position.column - 1);
|
|
95
|
+
if (charactersBefore !== triggerCharacters) {
|
|
96
|
+
// Do not return agent suggestions if the user didn't just type the trigger characters
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
// Calculate the range from the position of the trigger characters
|
|
100
|
+
const wordInfo = model.getWordUntilPosition(position);
|
|
101
|
+
return new monaco.Range(position.lineNumber, wordInfo.startColumn, position.lineNumber, position.column);
|
|
102
|
+
}
|
|
103
|
+
getSuggestions(model, position, triggerChars, items, kind, getId, getName, getDescription) {
|
|
104
|
+
const completionRange = this.getCompletionRange(model, position, triggerChars);
|
|
105
|
+
if (completionRange === undefined) {
|
|
106
|
+
return { suggestions: [] };
|
|
107
|
+
}
|
|
108
|
+
const suggestions = items.map(item => ({
|
|
109
|
+
insertText: getId(item),
|
|
110
|
+
kind: kind,
|
|
111
|
+
label: getName(item),
|
|
112
|
+
range: completionRange,
|
|
113
|
+
detail: getDescription(item),
|
|
114
|
+
}));
|
|
115
|
+
return { suggestions };
|
|
116
|
+
}
|
|
117
|
+
registerCommands(commands) {
|
|
118
|
+
commands.registerCommand(exports.DISCARD_PROMPT_TEMPLATE_CUSTOMIZATIONS, {
|
|
119
|
+
isVisible: (widget) => this.isPromptTemplateWidget(widget),
|
|
120
|
+
isEnabled: (widget) => this.canDiscard(widget),
|
|
121
|
+
execute: (widget) => this.discard(widget)
|
|
122
|
+
});
|
|
123
|
+
commands.registerCommand(exports.SHOW_ALL_PROMPTS_COMMAND, {
|
|
124
|
+
execute: () => this.showAllPrompts()
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
isPromptTemplateWidget(widget) {
|
|
128
|
+
if (widget instanceof browser_2.EditorWidget) {
|
|
129
|
+
return PROMPT_TEMPLATE_LANGUAGE_ID === widget.editor.document.languageId;
|
|
130
|
+
}
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
canDiscard(widget) {
|
|
134
|
+
const resourceUri = widget.editor.uri;
|
|
135
|
+
const id = this.customizationService.getTemplateIDFromURI(resourceUri);
|
|
136
|
+
if (id === undefined) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
const rawPrompt = this.promptService.getRawPrompt(id);
|
|
140
|
+
const defaultPrompt = this.promptService.getDefaultRawPrompt(id);
|
|
141
|
+
return (rawPrompt === null || rawPrompt === void 0 ? void 0 : rawPrompt.template) !== (defaultPrompt === null || defaultPrompt === void 0 ? void 0 : defaultPrompt.template);
|
|
142
|
+
}
|
|
143
|
+
async discard(widget) {
|
|
144
|
+
const resourceUri = widget.editor.uri;
|
|
145
|
+
const id = this.customizationService.getTemplateIDFromURI(resourceUri);
|
|
146
|
+
if (id === undefined) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const defaultPrompt = this.promptService.getDefaultRawPrompt(id);
|
|
150
|
+
if (defaultPrompt === undefined) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const source = widget.editor.document.getText();
|
|
154
|
+
const lastLine = widget.editor.document.getLineContent(widget.editor.document.lineCount);
|
|
155
|
+
const replaceOperation = {
|
|
156
|
+
range: {
|
|
157
|
+
start: {
|
|
158
|
+
line: 0,
|
|
159
|
+
character: 0
|
|
160
|
+
},
|
|
161
|
+
end: {
|
|
162
|
+
line: widget.editor.document.lineCount,
|
|
163
|
+
character: lastLine.length
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
text: defaultPrompt.template
|
|
167
|
+
};
|
|
168
|
+
await widget.editor.replaceText({
|
|
169
|
+
source,
|
|
170
|
+
replaceOperations: [replaceOperation]
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
showAllPrompts() {
|
|
174
|
+
const allPrompts = this.promptService.getAllPrompts();
|
|
175
|
+
Object.keys(allPrompts).forEach(id => {
|
|
176
|
+
this.messageService.info(`Prompt Template ID: ${id}\n${allPrompts[id].template}`, 'Got it');
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
registerToolbarItems(registry) {
|
|
180
|
+
registry.registerItem({
|
|
181
|
+
id: exports.DISCARD_PROMPT_TEMPLATE_CUSTOMIZATIONS.id,
|
|
182
|
+
command: exports.DISCARD_PROMPT_TEMPLATE_CUSTOMIZATIONS.id,
|
|
183
|
+
tooltip: 'Discard Customizations'
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
exports.PromptTemplateContribution = PromptTemplateContribution;
|
|
188
|
+
tslib_1.__decorate([
|
|
189
|
+
(0, inversify_1.inject)(common_1.PromptService),
|
|
190
|
+
tslib_1.__metadata("design:type", Object)
|
|
191
|
+
], PromptTemplateContribution.prototype, "promptService", void 0);
|
|
192
|
+
tslib_1.__decorate([
|
|
193
|
+
(0, inversify_1.inject)(core_1.MessageService),
|
|
194
|
+
tslib_1.__metadata("design:type", core_1.MessageService)
|
|
195
|
+
], PromptTemplateContribution.prototype, "messageService", void 0);
|
|
196
|
+
tslib_1.__decorate([
|
|
197
|
+
(0, inversify_1.inject)(common_1.PromptCustomizationService),
|
|
198
|
+
tslib_1.__metadata("design:type", Object)
|
|
199
|
+
], PromptTemplateContribution.prototype, "customizationService", void 0);
|
|
200
|
+
tslib_1.__decorate([
|
|
201
|
+
(0, inversify_1.inject)(core_1.ContributionProvider),
|
|
202
|
+
(0, inversify_1.named)(common_1.ToolProvider),
|
|
203
|
+
tslib_1.__metadata("design:type", Object)
|
|
204
|
+
], PromptTemplateContribution.prototype, "toolProviders", void 0);
|
|
205
|
+
exports.PromptTemplateContribution = PromptTemplateContribution = tslib_1.__decorate([
|
|
206
|
+
(0, inversify_1.injectable)()
|
|
207
|
+
], PromptTemplateContribution);
|
|
208
|
+
//# sourceMappingURL=prompttemplate-contribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompttemplate-contribution.js","sourceRoot":"","sources":["../../src/browser/prompttemplate-contribution.ts"],"names":[],"mappings":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,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;YAC5B,MAAM;YACN,iBAAiB,EAAE,CAAC,gBAAgB,CAAC;SACxC,CAAC,CAAC;IACP,CAAC;IAEO,cAAc;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-contribution.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;AAChF,mGAAqG;AACrG,4DAAkE;AAClE,kEAAiG;AAI1F,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAUlC,iBAAiB,CAAC,OAA0B;QACxC,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;YAC3D,8GAA8G;YAC9G,+FAA+F;YAC/F,IAAI,CAAC,gBAAgB,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;;gBACpD,OAAO,CAAC,gBAAgB,CAAC,EAAE,EAAE,EAAE,SAAS,QAAQ,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,MAAA,QAAQ,CAAC,WAAW,mCAAI,yBAAyB,EAAE,EAAE,IAAI,CAAC,CAAC;YAC1J,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAES,eAAe,CAAC,OAAoC;QAC1D,OAAO,MAAM,OAAO,CAAC,QAAQ,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;IACjF,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAoC,EAAE,OAA0B;QAC7E,yEAAyE;QACzE,6EAA6E;QAC7E,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;QACpG,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,66 @@
|
|
|
1
|
+
import { Event } from '@theia/core';
|
|
2
|
+
import { Agent } from './agent';
|
|
3
|
+
import { AISettingsService } from './settings-service';
|
|
4
|
+
import { PromptService } from './prompt-service';
|
|
5
|
+
export declare const AgentService: unique symbol;
|
|
6
|
+
/**
|
|
7
|
+
* Service to access the list of known Agents.
|
|
8
|
+
*/
|
|
9
|
+
export interface AgentService {
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves a list of all available agents, i.e. agents which are not disabled
|
|
12
|
+
*/
|
|
13
|
+
getAgents(): Agent[];
|
|
14
|
+
/**
|
|
15
|
+
* Retrieves a list of all agents, including disabled ones.
|
|
16
|
+
*/
|
|
17
|
+
getAllAgents(): Agent[];
|
|
18
|
+
/**
|
|
19
|
+
* Enable the agent with the specified id.
|
|
20
|
+
* @param agentId the agent id.
|
|
21
|
+
*/
|
|
22
|
+
enableAgent(agentId: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* disable the agent with the specified id.
|
|
25
|
+
* @param agentId the agent id.
|
|
26
|
+
*/
|
|
27
|
+
disableAgent(agentId: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* query whether this agent is currently enabled or disabled.
|
|
30
|
+
* @param agentId the agent id.
|
|
31
|
+
* @return true if the agent is enabled, false otherwise.
|
|
32
|
+
*/
|
|
33
|
+
isEnabled(agentId: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Allows to register an agent programmatically.
|
|
36
|
+
* @param agent the agent to register
|
|
37
|
+
*/
|
|
38
|
+
registerAgent(agent: Agent): void;
|
|
39
|
+
/**
|
|
40
|
+
* Allows to unregister an agent programmatically.
|
|
41
|
+
* @param agentId the agent id to unregister
|
|
42
|
+
*/
|
|
43
|
+
unregisterAgent(agentId: string): void;
|
|
44
|
+
/**
|
|
45
|
+
* Emitted when the list of agents changes.
|
|
46
|
+
* This can be used to update the UI when agents are added or removed.
|
|
47
|
+
*/
|
|
48
|
+
onDidChangeAgents: Event<void>;
|
|
49
|
+
}
|
|
50
|
+
export declare class AgentServiceImpl implements AgentService {
|
|
51
|
+
protected readonly aiSettingsService: AISettingsService | undefined;
|
|
52
|
+
protected readonly promptService: PromptService;
|
|
53
|
+
protected disabledAgents: Set<string>;
|
|
54
|
+
protected _agents: Agent[];
|
|
55
|
+
private readonly onDidChangeAgentsEmitter;
|
|
56
|
+
readonly onDidChangeAgents: Event<void>;
|
|
57
|
+
protected init(): void;
|
|
58
|
+
registerAgent(agent: Agent): void;
|
|
59
|
+
unregisterAgent(agentId: string): void;
|
|
60
|
+
getAgents(): Agent[];
|
|
61
|
+
getAllAgents(): Agent[];
|
|
62
|
+
enableAgent(agentId: string): void;
|
|
63
|
+
disableAgent(agentId: string): void;
|
|
64
|
+
isEnabled(agentId: string): boolean;
|
|
65
|
+
}
|
|
66
|
+
//# 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,EAAW,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,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;IAEpC;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAElC;;;OAGG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAEvC;;;OAGG;IACH,iBAAiB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;CAClC;AAED,qBACa,gBAAiB,YAAW,YAAY;IAGjD,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAGpE,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IAEhD,SAAS,CAAC,cAAc,cAAqB;IAE7C,SAAS,CAAC,OAAO,EAAE,KAAK,EAAE,CAAM;IAEhC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAuB;IAChE,QAAQ,CAAC,iBAAiB,cAAuC;IAGjE,SAAS,CAAC,IAAI,IAAI,IAAI;IAUtB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAQjC,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAStC,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,92 @@
|
|
|
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 settings_service_1 = require("./settings-service");
|
|
23
|
+
const prompt_service_1 = require("./prompt-service");
|
|
24
|
+
exports.AgentService = Symbol('AgentService');
|
|
25
|
+
let AgentServiceImpl = class AgentServiceImpl {
|
|
26
|
+
constructor() {
|
|
27
|
+
this.disabledAgents = new Set();
|
|
28
|
+
this._agents = [];
|
|
29
|
+
this.onDidChangeAgentsEmitter = new core_1.Emitter();
|
|
30
|
+
this.onDidChangeAgents = this.onDidChangeAgentsEmitter.event;
|
|
31
|
+
}
|
|
32
|
+
init() {
|
|
33
|
+
var _a;
|
|
34
|
+
(_a = this.aiSettingsService) === null || _a === void 0 ? void 0 : _a.getSettings().then(settings => {
|
|
35
|
+
Object.entries(settings).forEach(([agentId, agentSettings]) => {
|
|
36
|
+
if (agentSettings.enable === false) {
|
|
37
|
+
this.disabledAgents.add(agentId);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
registerAgent(agent) {
|
|
43
|
+
this._agents.push(agent);
|
|
44
|
+
agent.promptTemplates.forEach(template => this.promptService.storePromptTemplate(template));
|
|
45
|
+
this.onDidChangeAgentsEmitter.fire();
|
|
46
|
+
}
|
|
47
|
+
unregisterAgent(agentId) {
|
|
48
|
+
const agent = this._agents.find(a => a.id === agentId);
|
|
49
|
+
this._agents = this._agents.filter(a => a.id !== agentId);
|
|
50
|
+
this.onDidChangeAgentsEmitter.fire();
|
|
51
|
+
agent === null || agent === void 0 ? void 0 : agent.promptTemplates.forEach(template => this.promptService.removePrompt(template.id));
|
|
52
|
+
}
|
|
53
|
+
getAgents() {
|
|
54
|
+
return this._agents.filter(agent => this.isEnabled(agent.id));
|
|
55
|
+
}
|
|
56
|
+
getAllAgents() {
|
|
57
|
+
return this._agents;
|
|
58
|
+
}
|
|
59
|
+
enableAgent(agentId) {
|
|
60
|
+
var _a;
|
|
61
|
+
this.disabledAgents.delete(agentId);
|
|
62
|
+
(_a = this.aiSettingsService) === null || _a === void 0 ? void 0 : _a.updateAgentSettings(agentId, { enable: true });
|
|
63
|
+
}
|
|
64
|
+
disableAgent(agentId) {
|
|
65
|
+
var _a;
|
|
66
|
+
this.disabledAgents.add(agentId);
|
|
67
|
+
(_a = this.aiSettingsService) === null || _a === void 0 ? void 0 : _a.updateAgentSettings(agentId, { enable: false });
|
|
68
|
+
}
|
|
69
|
+
isEnabled(agentId) {
|
|
70
|
+
return !this.disabledAgents.has(agentId);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
exports.AgentServiceImpl = AgentServiceImpl;
|
|
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.inject)(prompt_service_1.PromptService),
|
|
81
|
+
tslib_1.__metadata("design:type", Object)
|
|
82
|
+
], AgentServiceImpl.prototype, "promptService", void 0);
|
|
83
|
+
tslib_1.__decorate([
|
|
84
|
+
(0, inversify_1.postConstruct)(),
|
|
85
|
+
tslib_1.__metadata("design:type", Function),
|
|
86
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
87
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
88
|
+
], AgentServiceImpl.prototype, "init", null);
|
|
89
|
+
exports.AgentServiceImpl = AgentServiceImpl = tslib_1.__decorate([
|
|
90
|
+
(0, inversify_1.injectable)()
|
|
91
|
+
], AgentServiceImpl);
|
|
92
|
+
//# sourceMappingURL=agent-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-service.js","sourceRoot":"","sources":["../../src/common/agent-service.ts"],"names":[],"mappings":";;;;AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC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