@theia/ai-core 1.55.0-next.37 → 1.55.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/lib/browser/ai-configuration/agent-configuration-widget.d.ts +1 -0
- package/lib/browser/ai-configuration/agent-configuration-widget.d.ts.map +1 -1
- package/lib/browser/ai-configuration/agent-configuration-widget.js +7 -1
- package/lib/browser/ai-configuration/agent-configuration-widget.js.map +1 -1
- package/lib/browser/ai-configuration/template-settings-renderer.js +1 -1
- package/lib/browser/ai-configuration/template-settings-renderer.js.map +1 -1
- package/lib/browser/ai-core-frontend-application-contribution.d.ts +3 -1
- package/lib/browser/ai-core-frontend-application-contribution.d.ts.map +1 -1
- package/lib/browser/ai-core-frontend-application-contribution.js +6 -6
- package/lib/browser/ai-core-frontend-application-contribution.js.map +1 -1
- package/lib/browser/frontend-prompt-customization-service.d.ts +6 -5
- package/lib/browser/frontend-prompt-customization-service.d.ts.map +1 -1
- package/lib/browser/frontend-prompt-customization-service.js +72 -35
- package/lib/browser/frontend-prompt-customization-service.js.map +1 -1
- package/lib/browser/prompttemplate-contribution.d.ts +1 -0
- package/lib/browser/prompttemplate-contribution.d.ts.map +1 -1
- package/lib/browser/prompttemplate-contribution.js +3 -2
- package/lib/browser/prompttemplate-contribution.js.map +1 -1
- package/lib/common/agent-service.d.ts +21 -3
- package/lib/common/agent-service.d.ts.map +1 -1
- package/lib/common/agent-service.js +17 -13
- package/lib/common/agent-service.js.map +1 -1
- package/lib/common/communication-recording-service.d.ts +1 -0
- package/lib/common/communication-recording-service.d.ts.map +1 -1
- package/lib/common/prompt-service.d.ts +33 -3
- package/lib/common/prompt-service.d.ts.map +1 -1
- package/lib/common/prompt-service.js +23 -1
- package/lib/common/prompt-service.js.map +1 -1
- package/package.json +12 -10
- package/src/browser/ai-configuration/agent-configuration-widget.tsx +8 -0
- package/src/browser/ai-configuration/template-settings-renderer.tsx +1 -1
- package/src/browser/ai-core-frontend-application-contribution.ts +7 -8
- package/src/browser/frontend-prompt-customization-service.ts +73 -35
- package/src/browser/prompttemplate-contribution.ts +3 -1
- package/src/browser/style/index.css +5 -0
- package/src/common/agent-service.ts +42 -13
- package/src/common/communication-recording-service.ts +2 -0
- package/src/common/prompt-service.ts +51 -3
|
@@ -19,13 +19,15 @@ const tslib_1 = require("tslib");
|
|
|
19
19
|
// *****************************************************************************
|
|
20
20
|
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
21
|
const core_1 = require("@theia/core");
|
|
22
|
-
const agent_1 = require("./agent");
|
|
23
22
|
const settings_service_1 = require("./settings-service");
|
|
23
|
+
const prompt_service_1 = require("./prompt-service");
|
|
24
24
|
exports.AgentService = Symbol('AgentService');
|
|
25
25
|
let AgentServiceImpl = class AgentServiceImpl {
|
|
26
26
|
constructor() {
|
|
27
27
|
this.disabledAgents = new Set();
|
|
28
28
|
this._agents = [];
|
|
29
|
+
this.onDidChangeAgentsEmitter = new core_1.Emitter();
|
|
30
|
+
this.onDidChangeAgents = this.onDidChangeAgentsEmitter.event;
|
|
29
31
|
}
|
|
30
32
|
init() {
|
|
31
33
|
var _a;
|
|
@@ -37,19 +39,22 @@ let AgentServiceImpl = class AgentServiceImpl {
|
|
|
37
39
|
});
|
|
38
40
|
});
|
|
39
41
|
}
|
|
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
42
|
registerAgent(agent) {
|
|
46
43
|
this._agents.push(agent);
|
|
44
|
+
agent.promptTemplates.forEach(template => this.promptService.storePrompt(template.id, template.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));
|
|
47
52
|
}
|
|
48
53
|
getAgents() {
|
|
49
|
-
return this.
|
|
54
|
+
return this._agents.filter(agent => this.isEnabled(agent.id));
|
|
50
55
|
}
|
|
51
56
|
getAllAgents() {
|
|
52
|
-
return this.
|
|
57
|
+
return this._agents;
|
|
53
58
|
}
|
|
54
59
|
enableAgent(agentId) {
|
|
55
60
|
var _a;
|
|
@@ -66,16 +71,15 @@ let AgentServiceImpl = class AgentServiceImpl {
|
|
|
66
71
|
}
|
|
67
72
|
};
|
|
68
73
|
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
74
|
tslib_1.__decorate([
|
|
75
75
|
(0, inversify_1.inject)(settings_service_1.AISettingsService),
|
|
76
76
|
(0, inversify_1.optional)(),
|
|
77
77
|
tslib_1.__metadata("design:type", Object)
|
|
78
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);
|
|
79
83
|
tslib_1.__decorate([
|
|
80
84
|
(0, inversify_1.postConstruct)(),
|
|
81
85
|
tslib_1.__metadata("design:type", Function),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-service.js","sourceRoot":"","sources":["../../src/common/agent-service.ts"],"names":[],"mappings":";;;;AAAA,gFAAgF;AAChF,yCAAyC;AACzC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AC3E,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;AAhEY,4CAAgB;AAGN;IADlB,IAAA,kBAAM,EAAC,oCAAiB,CAAC;IAAE,IAAA,oBAAQ,GAAE;;2DAC8B;AAGjD;IADlB,IAAA,kBAAM,EAAC,8BAAa,CAAC;;uDAC0B;AAUtC;IADT,IAAA,yBAAa,GAAE;;;;4CASf;2BAxBQ,gBAAgB;IAD5B,IAAA,sBAAU,GAAE;GACA,gBAAgB,CAgE5B"}
|
|
@@ -19,6 +19,7 @@ export interface CommunicationRecordingService {
|
|
|
19
19
|
recordResponse(responseEntry: CommunicationResponseEntry): void;
|
|
20
20
|
readonly onDidRecordResponse: Event<CommunicationResponseEntry>;
|
|
21
21
|
getHistory(agentId: string): CommunicationHistory;
|
|
22
|
+
getSessionHistory(sessionId: string): CommunicationHistory;
|
|
22
23
|
clearHistory(): void;
|
|
23
24
|
readonly onStructuralChange: Event<void>;
|
|
24
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"communication-recording-service.d.ts","sourceRoot":"","sources":["../../src/common/communication-recording-service.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,MAAM,MAAM,oBAAoB,GAAG,yBAAyB,EAAE,CAAC;AAE/D,MAAM,WAAW,yBAAyB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACxB;AAED,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,yBAAyB,EAAE,UAAU,GAAG,cAAc,CAAC,CAAC;AACrG,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAC;AAEpF,eAAO,MAAM,6BAA6B,eAA0C,CAAC;AACrF,MAAM,WAAW,6BAA6B;IAC1C,aAAa,CAAC,YAAY,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC7D,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAE9D,cAAc,CAAC,aAAa,EAAE,0BAA0B,GAAG,IAAI,CAAC;IAChE,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAEhE,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB,CAAC;IAElD,YAAY,IAAI,IAAI,CAAC;IACrB,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;CAC5C"}
|
|
1
|
+
{"version":3,"file":"communication-recording-service.d.ts","sourceRoot":"","sources":["../../src/common/communication-recording-service.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,MAAM,MAAM,oBAAoB,GAAG,yBAAyB,EAAE,CAAC;AAE/D,MAAM,WAAW,yBAAyB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACxB;AAED,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,yBAAyB,EAAE,UAAU,GAAG,cAAc,CAAC,CAAC;AACrG,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAC;AAEpF,eAAO,MAAM,6BAA6B,eAA0C,CAAC;AACrF,MAAM,WAAW,6BAA6B;IAC1C,aAAa,CAAC,YAAY,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC7D,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAE9D,cAAc,CAAC,aAAa,EAAE,0BAA0B,GAAG,IAAI,CAAC;IAChE,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAEhE,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB,CAAC;IAElD,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,oBAAoB,CAAC;IAE3D,YAAY,IAAI,IAAI,CAAC;IACrB,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;CAC5C"}
|
|
@@ -39,16 +39,32 @@ export interface PromptService {
|
|
|
39
39
|
[key: string]: unknown;
|
|
40
40
|
}): Promise<ResolvedPromptTemplate | undefined>;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* Adds a prompt to the list of prompts.
|
|
43
43
|
* @param id the id of the prompt
|
|
44
44
|
* @param prompt the prompt template to store
|
|
45
45
|
*/
|
|
46
46
|
storePrompt(id: string, prompt: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Removes a prompt from the list of prompts.
|
|
49
|
+
* @param id the id of the prompt
|
|
50
|
+
*/
|
|
51
|
+
removePrompt(id: string): void;
|
|
47
52
|
/**
|
|
48
53
|
* Return all known prompts as a {@link PromptMap map}.
|
|
49
54
|
*/
|
|
50
55
|
getAllPrompts(): PromptMap;
|
|
51
56
|
}
|
|
57
|
+
export interface CustomAgentDescription {
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
description: string;
|
|
61
|
+
prompt: string;
|
|
62
|
+
defaultLLM: string;
|
|
63
|
+
}
|
|
64
|
+
export declare namespace CustomAgentDescription {
|
|
65
|
+
function is(entry: unknown): entry is CustomAgentDescription;
|
|
66
|
+
function equals(a: CustomAgentDescription, b: CustomAgentDescription): boolean;
|
|
67
|
+
}
|
|
52
68
|
export declare const PromptCustomizationService: unique symbol;
|
|
53
69
|
export interface PromptCustomizationService {
|
|
54
70
|
/**
|
|
@@ -67,9 +83,9 @@ export interface PromptCustomizationService {
|
|
|
67
83
|
* on the implementation. Implementation may for example decide to
|
|
68
84
|
* open an editor, or request more information from the user, ...
|
|
69
85
|
* @param id the template id.
|
|
70
|
-
* @param content optional content to
|
|
86
|
+
* @param content optional default content to initialize the template
|
|
71
87
|
*/
|
|
72
|
-
editTemplate(id: string,
|
|
88
|
+
editTemplate(id: string, defaultContent?: string): void;
|
|
73
89
|
/**
|
|
74
90
|
* Reset the template to its default value.
|
|
75
91
|
* @param id the template id.
|
|
@@ -84,6 +100,19 @@ export interface PromptCustomizationService {
|
|
|
84
100
|
* Event which is fired when the prompt template is changed.
|
|
85
101
|
*/
|
|
86
102
|
readonly onDidChangePrompt: Event<string>;
|
|
103
|
+
/**
|
|
104
|
+
* Return all custom agents.
|
|
105
|
+
* @returns all custom agents
|
|
106
|
+
*/
|
|
107
|
+
getCustomAgents(): Promise<CustomAgentDescription[]>;
|
|
108
|
+
/**
|
|
109
|
+
* Event which is fired when custom agents are modified.
|
|
110
|
+
*/
|
|
111
|
+
readonly onDidChangeCustomAgents: Event<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Open the custom agent yaml file.
|
|
114
|
+
*/
|
|
115
|
+
openCustomAgentYaml(): void;
|
|
87
116
|
}
|
|
88
117
|
export declare class PromptServiceImpl implements PromptService {
|
|
89
118
|
protected readonly customizationService: PromptCustomizationService | undefined;
|
|
@@ -97,5 +126,6 @@ export declare class PromptServiceImpl implements PromptService {
|
|
|
97
126
|
}): Promise<ResolvedPromptTemplate | undefined>;
|
|
98
127
|
getAllPrompts(): PromptMap;
|
|
99
128
|
storePrompt(id: string, prompt: string): void;
|
|
129
|
+
removePrompt(id: string): void;
|
|
100
130
|
}
|
|
101
131
|
//# sourceMappingURL=prompt-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-service.d.ts","sourceRoot":"","sources":["../../src/common/prompt-service.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,MAAM,WAAW,cAAc;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IAAG,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,CAAA;CAAE;AAE3D,MAAM,WAAW,sBAAsB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,oFAAoF;IACpF,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,oBAAoB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CACnD;AAED,eAAO,MAAM,aAAa,eAA0B,CAAC;AACrD,MAAM,WAAW,aAAa;IAC1B;;;OAGG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC;IACrD;;;OAGG;IACH,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC;IAC5D;;;;;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,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;CAGjC"}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
16
|
// *****************************************************************************
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.PromptServiceImpl = exports.PromptCustomizationService = exports.PromptService = void 0;
|
|
18
|
+
exports.PromptServiceImpl = exports.PromptCustomizationService = exports.CustomAgentDescription = exports.PromptService = void 0;
|
|
19
19
|
const tslib_1 = require("tslib");
|
|
20
20
|
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
21
|
const variable_service_1 = require("./variable-service");
|
|
@@ -23,6 +23,25 @@ const tool_invocation_registry_1 = require("./tool-invocation-registry");
|
|
|
23
23
|
const language_model_util_1 = require("./language-model-util");
|
|
24
24
|
const prompt_service_util_1 = require("./prompt-service-util");
|
|
25
25
|
exports.PromptService = Symbol('PromptService');
|
|
26
|
+
var CustomAgentDescription;
|
|
27
|
+
(function (CustomAgentDescription) {
|
|
28
|
+
function is(entry) {
|
|
29
|
+
// eslint-disable-next-line no-null/no-null
|
|
30
|
+
return typeof entry === 'object' && entry !== null
|
|
31
|
+
&& 'id' in entry && typeof entry.id === 'string'
|
|
32
|
+
&& 'name' in entry && typeof entry.name === 'string'
|
|
33
|
+
&& 'description' in entry && typeof entry.description === 'string'
|
|
34
|
+
&& 'prompt' in entry
|
|
35
|
+
&& typeof entry.prompt === 'string'
|
|
36
|
+
&& 'defaultLLM' in entry
|
|
37
|
+
&& typeof entry.defaultLLM === 'string';
|
|
38
|
+
}
|
|
39
|
+
CustomAgentDescription.is = is;
|
|
40
|
+
function equals(a, b) {
|
|
41
|
+
return a.id === b.id && a.name === b.name && a.description === b.description && a.prompt === b.prompt && a.defaultLLM === b.defaultLLM;
|
|
42
|
+
}
|
|
43
|
+
CustomAgentDescription.equals = equals;
|
|
44
|
+
})(CustomAgentDescription || (exports.CustomAgentDescription = CustomAgentDescription = {}));
|
|
26
45
|
exports.PromptCustomizationService = Symbol('PromptCustomizationService');
|
|
27
46
|
let PromptServiceImpl = class PromptServiceImpl {
|
|
28
47
|
constructor() {
|
|
@@ -116,6 +135,9 @@ let PromptServiceImpl = class PromptServiceImpl {
|
|
|
116
135
|
storePrompt(id, prompt) {
|
|
117
136
|
this._prompts[id] = { id, template: prompt };
|
|
118
137
|
}
|
|
138
|
+
removePrompt(id) {
|
|
139
|
+
delete this._prompts[id];
|
|
140
|
+
}
|
|
119
141
|
};
|
|
120
142
|
exports.PromptServiceImpl = PromptServiceImpl;
|
|
121
143
|
tslib_1.__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-service.js","sourceRoot":"","sources":["../../src/common/prompt-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;;;;AAGhF,4DAA4E;AAC5E,yDAAuD;AACvD,yEAAoE;AACpE,+DAAgE;AAEhE,+DAAqF;AAiBxE,QAAA,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"prompt-service.js","sourceRoot":"","sources":["../../src/common/prompt-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;;;;AAGhF,4DAA4E;AAC5E,yDAAuD;AACvD,yEAAoE;AACpE,+DAAgE;AAEhE,+D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ACL,CAAC;IACD,WAAW,CAAC,EAAU,EAAE,MAAc;QAClC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACjD,CAAC;IACD,YAAY,CAAC,EAAU;QACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;CACJ,CAAA;AArGY,8CAAiB;AAEP;IADlB,IAAA,kBAAM,EAAC,kCAA0B,CAAC;IAAE,IAAA,oBAAQ,GAAE;;+DACiC;AAG7D;IADlB,IAAA,kBAAM,EAAC,oCAAiB,CAAC;IAAE,IAAA,oBAAQ,GAAE;;0DAC4B;AAG/C;IADlB,IAAA,kBAAM,EAAC,iDAAsB,CAAC;IAAE,IAAA,oBAAQ,GAAE;;iEACmC;4BARrE,iBAAiB;IAD7B,IAAA,sBAAU,GAAE;GACA,iBAAiB,CAqG7B"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/ai-core",
|
|
3
|
-
"version": "1.55.0
|
|
3
|
+
"version": "1.55.0",
|
|
4
4
|
"description": "Theia - AI Core",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.55.0
|
|
7
|
-
"@theia/editor": "1.55.0
|
|
8
|
-
"@theia/filesystem": "1.55.0
|
|
9
|
-
"@theia/monaco": "1.55.0
|
|
6
|
+
"@theia/core": "1.55.0",
|
|
7
|
+
"@theia/editor": "1.55.0",
|
|
8
|
+
"@theia/filesystem": "1.55.0",
|
|
9
|
+
"@theia/monaco": "1.55.0",
|
|
10
10
|
"@theia/monaco-editor-core": "1.83.101",
|
|
11
|
-
"@theia/output": "1.55.0
|
|
12
|
-
"@theia/variable-resolver": "1.55.0
|
|
13
|
-
"@theia/workspace": "1.55.0
|
|
11
|
+
"@theia/output": "1.55.0",
|
|
12
|
+
"@theia/variable-resolver": "1.55.0",
|
|
13
|
+
"@theia/workspace": "1.55.0",
|
|
14
|
+
"@types/js-yaml": "^4.0.9",
|
|
15
|
+
"js-yaml": "^4.1.0",
|
|
14
16
|
"minimatch": "^5.1.0",
|
|
15
17
|
"tslib": "^2.6.2"
|
|
16
18
|
},
|
|
@@ -50,10 +52,10 @@
|
|
|
50
52
|
"watch": "theiaext watch"
|
|
51
53
|
},
|
|
52
54
|
"devDependencies": {
|
|
53
|
-
"@theia/ext-scripts": "1.
|
|
55
|
+
"@theia/ext-scripts": "1.55.0"
|
|
54
56
|
},
|
|
55
57
|
"nyc": {
|
|
56
58
|
"extends": "../../configs/nyc.json"
|
|
57
59
|
},
|
|
58
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "0e7a523b8e798679d2e098709c63bd7060e54c8a"
|
|
59
61
|
}
|
|
@@ -87,6 +87,7 @@ export class AIAgentConfigurationWidget extends ReactWidget {
|
|
|
87
87
|
|
|
88
88
|
this.aiSettingsService.onDidChange(() => this.update());
|
|
89
89
|
this.aiConfigurationSelectionService.onDidAgentChange(() => this.update());
|
|
90
|
+
this.agentService.onDidChangeAgents(() => this.update());
|
|
90
91
|
this.update();
|
|
91
92
|
}
|
|
92
93
|
|
|
@@ -100,6 +101,9 @@ export class AIAgentConfigurationWidget extends ReactWidget {
|
|
|
100
101
|
</li>
|
|
101
102
|
)}
|
|
102
103
|
</ul>
|
|
104
|
+
<div className='configuration-agents-add'>
|
|
105
|
+
<button style={{ marginLeft: 0 }} className='theia-button main' onClick={() => this.addCustomAgent()}>Add Custom Agent</button>
|
|
106
|
+
</div>
|
|
103
107
|
</div>
|
|
104
108
|
<div className='configuration-agent-panel preferences-editor-widget'>
|
|
105
109
|
{this.renderAgentDetails()}
|
|
@@ -205,6 +209,10 @@ export class AIAgentConfigurationWidget extends ReactWidget {
|
|
|
205
209
|
this.aiConfigurationSelectionService.selectConfigurationTab(AIVariableConfigurationWidget.ID);
|
|
206
210
|
}
|
|
207
211
|
|
|
212
|
+
protected addCustomAgent(): void {
|
|
213
|
+
this.promptCustomizationService.openCustomAgentYaml();
|
|
214
|
+
}
|
|
215
|
+
|
|
208
216
|
protected setActiveAgent(agent: Agent): void {
|
|
209
217
|
this.aiConfigurationSelectionService.setActiveAgent(agent);
|
|
210
218
|
this.update();
|
|
@@ -25,7 +25,7 @@ export interface TemplateSettingProps {
|
|
|
25
25
|
|
|
26
26
|
export const TemplateRenderer: React.FC<TemplateSettingProps> = ({ agentId, template, promptCustomizationService }) => {
|
|
27
27
|
const openTemplate = React.useCallback(async () => {
|
|
28
|
-
promptCustomizationService.editTemplate(template.id);
|
|
28
|
+
promptCustomizationService.editTemplate(template.id, template.template);
|
|
29
29
|
}, [template, promptCustomizationService]);
|
|
30
30
|
const resetTemplate = React.useCallback(async () => {
|
|
31
31
|
promptCustomizationService.resetTemplate(template.id);
|
|
@@ -15,23 +15,22 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
18
|
-
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
19
|
-
import {
|
|
18
|
+
import { inject, injectable, named } from '@theia/core/shared/inversify';
|
|
19
|
+
import { Agent } from '../common';
|
|
20
20
|
import { AgentService } from '../common/agent-service';
|
|
21
|
+
import { ContributionProvider } from '@theia/core/lib/common/contribution-provider';
|
|
21
22
|
|
|
22
23
|
@injectable()
|
|
23
24
|
export class AICoreFrontendApplicationContribution implements FrontendApplicationContribution {
|
|
24
25
|
@inject(AgentService)
|
|
25
26
|
private readonly agentService: AgentService;
|
|
26
27
|
|
|
27
|
-
@inject(
|
|
28
|
-
|
|
28
|
+
@inject(ContributionProvider) @named(Agent)
|
|
29
|
+
protected readonly agentsProvider: ContributionProvider<Agent>;
|
|
29
30
|
|
|
30
31
|
onStart(): void {
|
|
31
|
-
this.
|
|
32
|
-
|
|
33
|
-
this.promptService.storePrompt(t.id, t.template);
|
|
34
|
-
});
|
|
32
|
+
this.agentsProvider.getContributions().forEach(agent => {
|
|
33
|
+
this.agentService.registerAgent(agent);
|
|
35
34
|
});
|
|
36
35
|
}
|
|
37
36
|
|
|
@@ -17,13 +17,22 @@
|
|
|
17
17
|
import { DisposableCollection, URI, Event, Emitter } from '@theia/core';
|
|
18
18
|
import { OpenerService } from '@theia/core/lib/browser';
|
|
19
19
|
import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
|
|
20
|
-
import { PromptCustomizationService,
|
|
20
|
+
import { PromptCustomizationService, CustomAgentDescription } from '../common';
|
|
21
21
|
import { BinaryBuffer } from '@theia/core/lib/common/buffer';
|
|
22
22
|
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
23
23
|
import { FileChangesEvent } from '@theia/filesystem/lib/common/files';
|
|
24
24
|
import { AICorePreferences, PREFERENCE_NAME_PROMPT_TEMPLATES } from './ai-core-preferences';
|
|
25
|
-
import { AgentService } from '../common/agent-service';
|
|
26
25
|
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
|
|
26
|
+
import { load, dump } from 'js-yaml';
|
|
27
|
+
import { PROMPT_TEMPLATE_EXTENSION } from './prompttemplate-contribution';
|
|
28
|
+
|
|
29
|
+
const templateEntry = {
|
|
30
|
+
id: 'my_agent',
|
|
31
|
+
name: 'My Agent',
|
|
32
|
+
description: 'This is an example agent. Please adapt the properties to fit your needs.',
|
|
33
|
+
prompt: 'You are an example agent. Be nice and helpful to the user.',
|
|
34
|
+
defaultLLM: 'openai/gpt-4o'
|
|
35
|
+
};
|
|
27
36
|
|
|
28
37
|
@injectable()
|
|
29
38
|
export class FrontendPromptCustomizationServiceImpl implements PromptCustomizationService {
|
|
@@ -40,9 +49,6 @@ export class FrontendPromptCustomizationServiceImpl implements PromptCustomizati
|
|
|
40
49
|
@inject(OpenerService)
|
|
41
50
|
protected readonly openerService: OpenerService;
|
|
42
51
|
|
|
43
|
-
@inject(AgentService)
|
|
44
|
-
protected readonly agentService: AgentService;
|
|
45
|
-
|
|
46
52
|
protected readonly trackedTemplateURIs = new Set<string>();
|
|
47
53
|
protected templates = new Map<string, string>();
|
|
48
54
|
|
|
@@ -51,6 +57,9 @@ export class FrontendPromptCustomizationServiceImpl implements PromptCustomizati
|
|
|
51
57
|
private readonly onDidChangePromptEmitter = new Emitter<string>();
|
|
52
58
|
readonly onDidChangePrompt: Event<string> = this.onDidChangePromptEmitter.event;
|
|
53
59
|
|
|
60
|
+
private readonly onDidChangeCustomAgentsEmitter = new Emitter<void>();
|
|
61
|
+
readonly onDidChangeCustomAgents = this.onDidChangeCustomAgentsEmitter.event;
|
|
62
|
+
|
|
54
63
|
@postConstruct()
|
|
55
64
|
protected init(): void {
|
|
56
65
|
this.preferences.onPreferenceChanged(event => {
|
|
@@ -72,6 +81,9 @@ export class FrontendPromptCustomizationServiceImpl implements PromptCustomizati
|
|
|
72
81
|
|
|
73
82
|
this.toDispose.push(this.fileService.watch(templateURI, { recursive: true, excludes: [] }));
|
|
74
83
|
this.toDispose.push(this.fileService.onDidFilesChange(async (event: FileChangesEvent) => {
|
|
84
|
+
if (event.changes.some(change => change.resource.toString().endsWith('customAgents.yml'))) {
|
|
85
|
+
this.onDidChangeCustomAgentsEmitter.fire();
|
|
86
|
+
}
|
|
75
87
|
// check deleted templates
|
|
76
88
|
for (const deletedFile of event.getDeleted()) {
|
|
77
89
|
if (this.trackedTemplateURIs.has(deletedFile.resource.toString())) {
|
|
@@ -84,25 +96,26 @@ export class FrontendPromptCustomizationServiceImpl implements PromptCustomizati
|
|
|
84
96
|
// check updated templates
|
|
85
97
|
for (const updatedFile of event.getUpdated()) {
|
|
86
98
|
if (this.trackedTemplateURIs.has(updatedFile.resource.toString())) {
|
|
87
|
-
const
|
|
99
|
+
const fileContent = await this.fileService.read(updatedFile.resource);
|
|
88
100
|
const templateId = this.removePromptTemplateSuffix(updatedFile.resource.path.name);
|
|
89
|
-
_templates.set(templateId,
|
|
101
|
+
_templates.set(templateId, fileContent.value);
|
|
90
102
|
this.onDidChangePromptEmitter.fire(templateId);
|
|
91
103
|
}
|
|
92
104
|
}
|
|
93
105
|
// check new templates
|
|
94
106
|
for (const addedFile of event.getAdded()) {
|
|
95
|
-
if (addedFile.resource.parent.toString() === templateURI.toString() && addedFile.resource.path.ext ===
|
|
107
|
+
if (addedFile.resource.parent.toString() === templateURI.toString() && addedFile.resource.path.ext === PROMPT_TEMPLATE_EXTENSION) {
|
|
96
108
|
this.trackedTemplateURIs.add(addedFile.resource.toString());
|
|
97
|
-
const
|
|
109
|
+
const fileContent = await this.fileService.read(addedFile.resource);
|
|
98
110
|
const templateId = this.removePromptTemplateSuffix(addedFile.resource.path.name);
|
|
99
|
-
_templates.set(templateId,
|
|
111
|
+
_templates.set(templateId, fileContent.value);
|
|
100
112
|
this.onDidChangePromptEmitter.fire(templateId);
|
|
101
113
|
}
|
|
102
114
|
}
|
|
103
115
|
|
|
104
116
|
}));
|
|
105
117
|
|
|
118
|
+
this.onDidChangeCustomAgentsEmitter.fire();
|
|
106
119
|
const stat = await this.fileService.resolve(templateURI);
|
|
107
120
|
if (stat.children === undefined) {
|
|
108
121
|
return;
|
|
@@ -113,11 +126,11 @@ export class FrontendPromptCustomizationServiceImpl implements PromptCustomizati
|
|
|
113
126
|
continue;
|
|
114
127
|
}
|
|
115
128
|
const fileURI = file.resource;
|
|
116
|
-
if (fileURI.path.ext ===
|
|
129
|
+
if (fileURI.path.ext === PROMPT_TEMPLATE_EXTENSION) {
|
|
117
130
|
this.trackedTemplateURIs.add(fileURI.toString());
|
|
118
|
-
const
|
|
131
|
+
const fileContent = await this.fileService.read(fileURI);
|
|
119
132
|
const templateId = this.removePromptTemplateSuffix(file.name);
|
|
120
|
-
_templates.set(templateId,
|
|
133
|
+
_templates.set(templateId, fileContent.value);
|
|
121
134
|
this.onDidChangePromptEmitter.fire(templateId);
|
|
122
135
|
}
|
|
123
136
|
}
|
|
@@ -133,11 +146,11 @@ export class FrontendPromptCustomizationServiceImpl implements PromptCustomizati
|
|
|
133
146
|
}
|
|
134
147
|
|
|
135
148
|
protected async getTemplateURI(templateId: string): Promise<URI> {
|
|
136
|
-
return (await this.getTemplatesDirectoryURI()).resolve(`${templateId}
|
|
149
|
+
return (await this.getTemplatesDirectoryURI()).resolve(`${templateId}${PROMPT_TEMPLATE_EXTENSION}`);
|
|
137
150
|
}
|
|
138
151
|
|
|
139
152
|
protected removePromptTemplateSuffix(filename: string): string {
|
|
140
|
-
const suffix =
|
|
153
|
+
const suffix = PROMPT_TEMPLATE_EXTENSION;
|
|
141
154
|
if (filename.endsWith(suffix)) {
|
|
142
155
|
return filename.slice(0, -suffix.length);
|
|
143
156
|
}
|
|
@@ -152,17 +165,10 @@ export class FrontendPromptCustomizationServiceImpl implements PromptCustomizati
|
|
|
152
165
|
return this.templates.get(id);
|
|
153
166
|
}
|
|
154
167
|
|
|
155
|
-
async editTemplate(id: string,
|
|
156
|
-
const template = this.getOriginalTemplate(id);
|
|
157
|
-
if (template === undefined) {
|
|
158
|
-
throw new Error(`Unable to edit template ${id}: template not found.`);
|
|
159
|
-
}
|
|
168
|
+
async editTemplate(id: string, defaultContent?: string): Promise<void> {
|
|
160
169
|
const editorUri = await this.getTemplateURI(id);
|
|
161
170
|
if (! await this.fileService.exists(editorUri)) {
|
|
162
|
-
await this.fileService.createFile(editorUri, BinaryBuffer.fromString(
|
|
163
|
-
} else if (content) {
|
|
164
|
-
// Write content to the file before opening it
|
|
165
|
-
await this.fileService.writeFile(editorUri, BinaryBuffer.fromString(content));
|
|
171
|
+
await this.fileService.createFile(editorUri, BinaryBuffer.fromString(defaultContent ?? ''));
|
|
166
172
|
}
|
|
167
173
|
const openHandler = await this.openerService.getOpener(editorUri);
|
|
168
174
|
openHandler.open(editorUri);
|
|
@@ -175,17 +181,6 @@ export class FrontendPromptCustomizationServiceImpl implements PromptCustomizati
|
|
|
175
181
|
}
|
|
176
182
|
}
|
|
177
183
|
|
|
178
|
-
getOriginalTemplate(id: string): PromptTemplate | undefined {
|
|
179
|
-
for (const agent of this.agentService.getAllAgents()) {
|
|
180
|
-
for (const template of agent.promptTemplates) {
|
|
181
|
-
if (template.id === id) {
|
|
182
|
-
return template;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return undefined;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
184
|
getTemplateIDFromURI(uri: URI): string | undefined {
|
|
190
185
|
const id = this.removePromptTemplateSuffix(uri.path.name);
|
|
191
186
|
if (this.templates.has(id)) {
|
|
@@ -194,4 +189,47 @@ export class FrontendPromptCustomizationServiceImpl implements PromptCustomizati
|
|
|
194
189
|
return undefined;
|
|
195
190
|
}
|
|
196
191
|
|
|
192
|
+
async getCustomAgents(): Promise<CustomAgentDescription[]> {
|
|
193
|
+
const customAgentYamlUri = (await this.getTemplatesDirectoryURI()).resolve('customAgents.yml');
|
|
194
|
+
const yamlExists = await this.fileService.exists(customAgentYamlUri);
|
|
195
|
+
if (!yamlExists) {
|
|
196
|
+
return [];
|
|
197
|
+
}
|
|
198
|
+
const fileContent = await this.fileService.read(customAgentYamlUri, { encoding: 'utf-8' });
|
|
199
|
+
try {
|
|
200
|
+
const doc = load(fileContent.value);
|
|
201
|
+
if (!Array.isArray(doc) || !doc.every(entry => CustomAgentDescription.is(entry))) {
|
|
202
|
+
console.debug('Invalid customAgents.yml file content');
|
|
203
|
+
return [];
|
|
204
|
+
}
|
|
205
|
+
const readAgents = doc as CustomAgentDescription[];
|
|
206
|
+
// make sure all agents are unique (id and name)
|
|
207
|
+
const uniqueAgentIds = new Set<string>();
|
|
208
|
+
const uniqueAgents: CustomAgentDescription[] = [];
|
|
209
|
+
readAgents.forEach(agent => {
|
|
210
|
+
if (uniqueAgentIds.has(agent.id)) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
uniqueAgentIds.add(agent.id);
|
|
214
|
+
uniqueAgents.push(agent);
|
|
215
|
+
});
|
|
216
|
+
return uniqueAgents;
|
|
217
|
+
} catch (e) {
|
|
218
|
+
console.debug(e.message, e);
|
|
219
|
+
return [];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
async openCustomAgentYaml(): Promise<void> {
|
|
224
|
+
const customAgentYamlUri = (await this.getTemplatesDirectoryURI()).resolve('customAgents.yml');
|
|
225
|
+
const content = dump([templateEntry]);
|
|
226
|
+
if (! await this.fileService.exists(customAgentYamlUri)) {
|
|
227
|
+
await this.fileService.createFile(customAgentYamlUri, BinaryBuffer.fromString(content));
|
|
228
|
+
} else {
|
|
229
|
+
const fileContent = (await this.fileService.readFile(customAgentYamlUri)).value;
|
|
230
|
+
await this.fileService.writeFile(customAgentYamlUri, BinaryBuffer.concat([fileContent, BinaryBuffer.fromString(content)]));
|
|
231
|
+
}
|
|
232
|
+
const openHandler = await this.openerService.getOpener(customAgentYamlUri);
|
|
233
|
+
openHandler.open(customAgentYamlUri);
|
|
234
|
+
}
|
|
197
235
|
}
|
|
@@ -28,6 +28,8 @@ import { ProviderResult } from '@theia/monaco-editor-core/esm/vs/editor/common/l
|
|
|
28
28
|
const PROMPT_TEMPLATE_LANGUAGE_ID = 'theia-ai-prompt-template';
|
|
29
29
|
const PROMPT_TEMPLATE_TEXTMATE_SCOPE = 'source.prompttemplate';
|
|
30
30
|
|
|
31
|
+
export const PROMPT_TEMPLATE_EXTENSION = '.prompttemplate';
|
|
32
|
+
|
|
31
33
|
export const DISCARD_PROMPT_TEMPLATE_CUSTOMIZATIONS: Command = {
|
|
32
34
|
id: 'theia-ai-prompt-template:discard',
|
|
33
35
|
iconClass: codicon('discard'),
|
|
@@ -81,7 +83,7 @@ export class PromptTemplateContribution implements LanguageGrammarDefinitionCont
|
|
|
81
83
|
'Theia AI Prompt Templates'
|
|
82
84
|
],
|
|
83
85
|
'extensions': [
|
|
84
|
-
|
|
86
|
+
PROMPT_TEMPLATE_EXTENSION,
|
|
85
87
|
],
|
|
86
88
|
'filenames': []
|
|
87
89
|
});
|