@theia/ai-chat 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.
Files changed (35) hide show
  1. package/lib/browser/ai-chat-frontend-module.d.ts.map +1 -1
  2. package/lib/browser/ai-chat-frontend-module.js +25 -2
  3. package/lib/browser/ai-chat-frontend-module.js.map +1 -1
  4. package/lib/browser/custom-agent-factory.d.ts +4 -0
  5. package/lib/browser/custom-agent-factory.d.ts.map +1 -0
  6. package/lib/browser/custom-agent-factory.js +20 -0
  7. package/lib/browser/custom-agent-factory.js.map +1 -0
  8. package/lib/browser/custom-agent-frontend-application-contribution.d.ts +13 -0
  9. package/lib/browser/custom-agent-frontend-application-contribution.d.ts.map +1 -0
  10. package/lib/browser/custom-agent-frontend-application-contribution.js +82 -0
  11. package/lib/browser/custom-agent-frontend-application-contribution.js.map +1 -0
  12. package/lib/common/chat-agent-service.d.ts +11 -0
  13. package/lib/common/chat-agent-service.d.ts.map +1 -1
  14. package/lib/common/chat-agent-service.js +3 -0
  15. package/lib/common/chat-agent-service.js.map +1 -1
  16. package/lib/common/custom-chat-agent.d.ts +14 -0
  17. package/lib/common/custom-chat-agent.d.ts.map +1 -0
  18. package/lib/common/custom-chat-agent.js +43 -0
  19. package/lib/common/custom-chat-agent.js.map +1 -0
  20. package/lib/common/index.d.ts +4 -3
  21. package/lib/common/index.d.ts.map +1 -1
  22. package/lib/common/index.js +4 -3
  23. package/lib/common/index.js.map +1 -1
  24. package/lib/common/o1-chat-agent.d.ts +13 -0
  25. package/lib/common/o1-chat-agent.d.ts.map +1 -0
  26. package/lib/common/o1-chat-agent.js +45 -0
  27. package/lib/common/o1-chat-agent.js.map +1 -0
  28. package/package.json +8 -8
  29. package/src/browser/ai-chat-frontend-module.ts +30 -4
  30. package/src/browser/custom-agent-factory.ts +20 -0
  31. package/src/browser/custom-agent-frontend-application-contribution.ts +73 -0
  32. package/src/common/chat-agent-service.ts +15 -0
  33. package/src/common/custom-chat-agent.ts +44 -0
  34. package/src/common/index.ts +4 -3
  35. package/src/common/o1-chat-agent.ts +51 -0
@@ -1 +1 @@
1
- {"version":3,"file":"ai-chat-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/ai-chat-frontend-module.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAkB/D,wBAkCG"}
1
+ {"version":3,"file":"ai-chat-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/ai-chat-frontend-module.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAsB/D,wBAwDG"}
@@ -20,13 +20,17 @@ const core_1 = require("@theia/core");
20
20
  const browser_1 = require("@theia/core/lib/browser");
21
21
  const inversify_1 = require("@theia/core/shared/inversify");
22
22
  const common_2 = require("../common");
23
+ const chat_agents_variable_contribution_1 = require("../common/chat-agents-variable-contribution");
23
24
  const command_chat_agents_1 = require("../common/command-chat-agents");
25
+ const custom_chat_agent_1 = require("../common/custom-chat-agent");
24
26
  const orchestrator_chat_agent_1 = require("../common/orchestrator-chat-agent");
27
+ const response_content_matcher_1 = require("../common/response-content-matcher");
25
28
  const universal_chat_agent_1 = require("../common/universal-chat-agent");
26
29
  const ai_chat_preferences_1 = require("./ai-chat-preferences");
27
- const chat_agents_variable_contribution_1 = require("../common/chat-agents-variable-contribution");
30
+ const custom_agent_frontend_application_contribution_1 = require("./custom-agent-frontend-application-contribution");
28
31
  const frontend_chat_service_1 = require("./frontend-chat-service");
29
- const response_content_matcher_1 = require("../common/response-content-matcher");
32
+ const custom_agent_factory_1 = require("./custom-agent-factory");
33
+ const o1_chat_agent_1 = require("../common/o1-chat-agent");
30
34
  exports.default = new inversify_1.ContainerModule(bind => {
31
35
  (0, core_1.bindContributionProvider)(bind, common_1.Agent);
32
36
  (0, core_1.bindContributionProvider)(bind, common_2.ChatAgent);
@@ -45,6 +49,9 @@ exports.default = new inversify_1.ContainerModule(bind => {
45
49
  bind(orchestrator_chat_agent_1.OrchestratorChatAgent).toSelf().inSingletonScope();
46
50
  bind(common_1.Agent).toService(orchestrator_chat_agent_1.OrchestratorChatAgent);
47
51
  bind(common_2.ChatAgent).toService(orchestrator_chat_agent_1.OrchestratorChatAgent);
52
+ bind(o1_chat_agent_1.O1ChatAgent).toSelf().inSingletonScope();
53
+ bind(common_1.Agent).toService(o1_chat_agent_1.O1ChatAgent);
54
+ bind(common_2.ChatAgent).toService(o1_chat_agent_1.O1ChatAgent);
48
55
  bind(universal_chat_agent_1.UniversalChatAgent).toSelf().inSingletonScope();
49
56
  bind(common_1.Agent).toService(universal_chat_agent_1.UniversalChatAgent);
50
57
  bind(common_2.ChatAgent).toService(universal_chat_agent_1.UniversalChatAgent);
@@ -52,5 +59,21 @@ exports.default = new inversify_1.ContainerModule(bind => {
52
59
  bind(common_1.Agent).toService(command_chat_agents_1.CommandChatAgent);
53
60
  bind(common_2.ChatAgent).toService(command_chat_agents_1.CommandChatAgent);
54
61
  bind(browser_1.PreferenceContribution).toConstantValue({ schema: ai_chat_preferences_1.aiChatPreferences });
62
+ bind(custom_chat_agent_1.CustomChatAgent).toSelf();
63
+ bind(custom_agent_factory_1.CustomAgentFactory).toFactory(ctx => (id, name, description, prompt, defaultLLM) => {
64
+ const agent = ctx.container.get(custom_chat_agent_1.CustomChatAgent);
65
+ agent.id = id;
66
+ agent.name = name;
67
+ agent.description = description;
68
+ agent.prompt = prompt;
69
+ agent.languageModelRequirements = [{
70
+ purpose: 'chat',
71
+ identifier: defaultLLM,
72
+ }];
73
+ ctx.container.get(common_2.ChatAgentService).registerChatAgent(agent);
74
+ ctx.container.get(common_1.AgentService).registerAgent(agent);
75
+ return agent;
76
+ });
77
+ bind(browser_1.FrontendApplicationContribution).to(custom_agent_frontend_application_contribution_1.AICustomAgentsFrontendApplicationContribution).inSingletonScope();
55
78
  });
56
79
  //# sourceMappingURL=ai-chat-frontend-module.js.map
@@ -1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CAAC,CAAC;IAE5E,IAAI,CAAC,mCAAe,CAAC,CAAC,MAAM,EAAE,CAAC;IAC/B,IAAI,CAAC,yCAAkB,CAAC,CAAC,SAAS,CAC9B,GAAG,CAAC,EAAE,CAAC,CAAC,EAAU,EAAE,IAAY,EAAE,WAAmB,EAAE,MAAc,EAAE,UAAkB,EAAE,EAAE;QACzF,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,GAAG,CAAkB,mCAAe,CAAC,CAAC;QAClE,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;QACd,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QAClB,KAAK,CAAC,WAAW,GAAG,WAAW,CAAC;QAChC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;QACtB,KAAK,CAAC,yBAAyB,GAAG,CAAC;gBAC/B,OAAO,EAAE,MAAM;gBACf,UAAU,EAAE,UAAU;aACzB,CAAC,CAAC;QACH,GAAG,CAAC,SAAS,CAAC,GAAG,CAAmB,yBAAgB,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAC/E,GAAG,CAAC,SAAS,CAAC,GAAG,CAAe,qBAAY,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACnE,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC,CAAC;IACP,IAAI,CAAC,yCAA+B,CAAC,CAAC,EAAE,CAAC,8FAA6C,CAAC,CAAC,gBAAgB,EAAE,CAAC;AAC/G,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { CustomChatAgent } from '../common';
2
+ export declare const CustomAgentFactory: unique symbol;
3
+ export type CustomAgentFactory = (id: string, name: string, description: string, prompt: string, defaultLLM: string) => CustomChatAgent;
4
+ //# sourceMappingURL=custom-agent-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-agent-factory.d.ts","sourceRoot":"","sources":["../../src/browser/custom-agent-factory.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,eAAO,MAAM,kBAAkB,eAA+B,CAAC;AAC/D,MAAM,MAAM,kBAAkB,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,eAAe,CAAC"}
@@ -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.CustomAgentFactory = void 0;
19
+ exports.CustomAgentFactory = Symbol('CustomAgentFactory');
20
+ //# sourceMappingURL=custom-agent-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-agent-factory.js","sourceRoot":"","sources":["../../src/browser/custom-agent-factory.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;;;AAInE,QAAA,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { PromptCustomizationService } from '@theia/ai-core';
2
+ import { FrontendApplicationContribution } from '@theia/core/lib/browser';
3
+ import { CustomAgentFactory } from './custom-agent-factory';
4
+ export declare class AICustomAgentsFrontendApplicationContribution implements FrontendApplicationContribution {
5
+ protected readonly customAgentFactory: CustomAgentFactory;
6
+ protected readonly customizationService: PromptCustomizationService;
7
+ private readonly agentService;
8
+ private readonly chatAgentService;
9
+ private knownCustomAgents;
10
+ onStart(): void;
11
+ onStop(): void;
12
+ }
13
+ //# sourceMappingURL=custom-agent-frontend-application-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-agent-frontend-application-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/custom-agent-frontend-application-contribution.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAwC,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAClG,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAG1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,qBACa,6CAA8C,YAAW,+BAA+B;IAEjG,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IAG1D,SAAS,CAAC,QAAQ,CAAC,oBAAoB,EAAE,0BAA0B,CAAC;IAGpE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAG5C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmB;IAEpD,OAAO,CAAC,iBAAiB,CAAkD;IAC3E,OAAO,IAAI,IAAI;IAiCf,MAAM,IAAI,IAAI;CAEjB"}
@@ -0,0 +1,82 @@
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.AICustomAgentsFrontendApplicationContribution = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const ai_core_1 = require("@theia/ai-core");
21
+ const inversify_1 = require("@theia/core/shared/inversify");
22
+ const common_1 = require("../common");
23
+ const custom_agent_factory_1 = require("./custom-agent-factory");
24
+ let AICustomAgentsFrontendApplicationContribution = class AICustomAgentsFrontendApplicationContribution {
25
+ constructor() {
26
+ this.knownCustomAgents = new Map();
27
+ }
28
+ onStart() {
29
+ var _a, _b;
30
+ (_a = this.customizationService) === null || _a === void 0 ? void 0 : _a.getCustomAgents().then(customAgents => {
31
+ customAgents.forEach(agent => {
32
+ this.customAgentFactory(agent.id, agent.name, agent.description, agent.prompt, agent.defaultLLM);
33
+ this.knownCustomAgents.set(agent.id, agent);
34
+ });
35
+ }).catch(e => {
36
+ console.error('Failed to load custom agents', e);
37
+ });
38
+ (_b = this.customizationService) === null || _b === void 0 ? void 0 : _b.onDidChangeCustomAgents(() => {
39
+ var _a;
40
+ (_a = this.customizationService) === null || _a === void 0 ? void 0 : _a.getCustomAgents().then(customAgents => {
41
+ const customAgentsToAdd = customAgents.filter(agent => !this.knownCustomAgents.has(agent.id) || !ai_core_1.CustomAgentDescription.equals(this.knownCustomAgents.get(agent.id), agent));
42
+ const customAgentIdsToRemove = [...this.knownCustomAgents.values()].filter(agent => !customAgents.find(a => ai_core_1.CustomAgentDescription.equals(a, agent))).map(a => a.id);
43
+ // delete first so we don't have to deal with the case where we add and remove the same agentId
44
+ customAgentIdsToRemove.forEach(id => {
45
+ this.chatAgentService.unregisterChatAgent(id);
46
+ this.agentService.unregisterAgent(id);
47
+ this.knownCustomAgents.delete(id);
48
+ });
49
+ customAgentsToAdd
50
+ .forEach(agent => {
51
+ this.customAgentFactory(agent.id, agent.name, agent.description, agent.prompt, agent.defaultLLM);
52
+ this.knownCustomAgents.set(agent.id, agent);
53
+ });
54
+ }).catch(e => {
55
+ console.error('Failed to load custom agents', e);
56
+ });
57
+ });
58
+ }
59
+ onStop() {
60
+ }
61
+ };
62
+ exports.AICustomAgentsFrontendApplicationContribution = AICustomAgentsFrontendApplicationContribution;
63
+ tslib_1.__decorate([
64
+ (0, inversify_1.inject)(custom_agent_factory_1.CustomAgentFactory),
65
+ tslib_1.__metadata("design:type", Function)
66
+ ], AICustomAgentsFrontendApplicationContribution.prototype, "customAgentFactory", void 0);
67
+ tslib_1.__decorate([
68
+ (0, inversify_1.inject)(ai_core_1.PromptCustomizationService),
69
+ tslib_1.__metadata("design:type", Object)
70
+ ], AICustomAgentsFrontendApplicationContribution.prototype, "customizationService", void 0);
71
+ tslib_1.__decorate([
72
+ (0, inversify_1.inject)(ai_core_1.AgentService),
73
+ tslib_1.__metadata("design:type", Object)
74
+ ], AICustomAgentsFrontendApplicationContribution.prototype, "agentService", void 0);
75
+ tslib_1.__decorate([
76
+ (0, inversify_1.inject)(common_1.ChatAgentService),
77
+ tslib_1.__metadata("design:type", Object)
78
+ ], AICustomAgentsFrontendApplicationContribution.prototype, "chatAgentService", void 0);
79
+ exports.AICustomAgentsFrontendApplicationContribution = AICustomAgentsFrontendApplicationContribution = tslib_1.__decorate([
80
+ (0, inversify_1.injectable)()
81
+ ], AICustomAgentsFrontendApplicationContribution);
82
+ //# sourceMappingURL=custom-agent-frontend-application-contribution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-agent-frontend-application-contribution.js","sourceRoot":"","sources":["../../src/browser/custom-agent-frontend-application-contribution.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;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C,oCAA0B,CAAC;;2FACiC;AAGnD;IADhB,IAAA,kBAAM,EAAC,sBAAY,CAAC;;mFACuB;AAG3B;IADhB,IAAA,kBAAM,EAAC,yBAAgB,CAAC;;uFAC2B;wDAX3C,6CAA6C;IADzD,IAAA,sBAAU,GAAE;GACA,6CAA6C,CAiDzD"}
@@ -18,6 +18,16 @@ export interface ChatAgentService {
18
18
  * Returns all agents, including disabled ones.
19
19
  */
20
20
  getAllAgents(): ChatAgent[];
21
+ /**
22
+ * Allows to register a chat agent programmatically.
23
+ * @param agent the agent to register
24
+ */
25
+ registerChatAgent(agent: ChatAgent): void;
26
+ /**
27
+ * Allows to unregister a chat agent programmatically.
28
+ * @param agentId the agent id to unregister
29
+ */
30
+ unregisterChatAgent(agentId: string): void;
21
31
  }
22
32
  export declare class ChatAgentServiceImpl implements ChatAgentService {
23
33
  protected readonly agentContributions: ContributionProvider<ChatAgent>;
@@ -26,6 +36,7 @@ export declare class ChatAgentServiceImpl implements ChatAgentService {
26
36
  protected _agents: ChatAgent[];
27
37
  protected get agents(): ChatAgent[];
28
38
  registerChatAgent(agent: ChatAgent): void;
39
+ unregisterChatAgent(agentId: string): void;
29
40
  getAgent(id: string): ChatAgent | undefined;
30
41
  getAgents(): ChatAgent[];
31
42
  getAllAgents(): ChatAgent[];
@@ -1 +1 @@
1
- {"version":3,"file":"chat-agent-service.d.ts","sourceRoot":"","sources":["../../src/common/chat-agent-service.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAO,MAAM,gBAAgB,eAA6B,CAAC;AAC3D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B;;OAEG;IACH,SAAS,IAAI,SAAS,EAAE,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,EA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E,MAAM,GAAG,IAAI,CAAC;CAC9C;AACD,qBACa,oBAAqB,YAAW,gBAAgB;IAGzD,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAGvE,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC;IAG1B,SAAS,CAAC,YAAY,EAAE,YAAY,CAAC;IAErC,SAAS,CAAC,OAAO,EAAE,SAAS,EAAE,CAAM;IAEpC,SAAS,KAAK,MAAM,IAAI,SAAS,EAAE,CAIlC;IAED,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAGzC,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI1C,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAM3C,SAAS,IAAI,SAAS,EAAE;IAGxB,YAAY,IAAI,SAAS,EAAE;IAI3B,OAAO,CAAC,eAAe;CAG1B"}
@@ -39,6 +39,9 @@ let ChatAgentServiceImpl = class ChatAgentServiceImpl {
39
39
  registerChatAgent(agent) {
40
40
  this._agents.push(agent);
41
41
  }
42
+ unregisterChatAgent(agentId) {
43
+ this._agents = this._agents.filter(a => a.id !== agentId);
44
+ }
42
45
  getAgent(id) {
43
46
  if (!this._agentIsEnabled(id)) {
44
47
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"chat-agent-service.js","sourceRoot":"","sources":["../../src/common/chat-agent-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;AAChF;;;gGAGgG;AAChG,6JAA6J;;;;AAE7J,sCAA4D;AAC5D,4DAAyE;AACzE,+CAA0C;AAC1C,4CAA8C;AAEjC,QAA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CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,SAAS;QACL,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/D,CAAC;IACD,YAAY;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAEO,eAAe,CAAC,EAAU;QAC9B,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC3C,CAAC;CACJ,CAAA;AA1CY,oDAAoB;AAGV;IADlB,IAAA,kBAAM,EAAC,2BAAoB,CAAC;IAAE,IAAA,iBAAK,EAAC,uBAAS,CAAC;;gEACwB;AAG7D;IADT,IAAA,kBAAM,EAAC,cAAO,CAAC;;oDACU;AAGhB;IADT,IAAA,kBAAM,EAAC,sBAAY,CAAC;;0DACgB;+BAT5B,oBAAoB;IADhC,IAAA,sBAAU,GAAE;GACA,oBAAoB,CA0ChC"}
@@ -0,0 +1,14 @@
1
+ import { AgentSpecificVariables, PromptTemplate } from '@theia/ai-core';
2
+ import { AbstractStreamParsingChatAgent, ChatAgent, SystemMessageDescription } from './chat-agents';
3
+ export declare class CustomChatAgent extends AbstractStreamParsingChatAgent implements ChatAgent {
4
+ name: string;
5
+ description: string;
6
+ readonly variables: string[];
7
+ readonly functions: string[];
8
+ readonly promptTemplates: PromptTemplate[];
9
+ readonly agentSpecificVariables: AgentSpecificVariables[];
10
+ constructor();
11
+ protected getSystemMessageDescription(): Promise<SystemMessageDescription | undefined>;
12
+ set prompt(prompt: string);
13
+ }
14
+ //# sourceMappingURL=custom-chat-agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-chat-agent.d.ts","sourceRoot":"","sources":["../../src/common/custom-chat-agent.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,8BAA8B,EAAE,SAAS,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAGpG,qBACa,eACT,SAAQ,8BACR,YAAW,SAAS;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAM;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAM;IAClC,QAAQ,CAAC,eAAe,EAAE,cAAc,EAAE,CAAM;IAChD,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,EAAE,CAAM;;cAMtC,2BAA2B,IAAI,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC;IAKrG,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAExB;CACJ"}
@@ -0,0 +1,43 @@
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.CustomChatAgent = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const chat_agents_1 = require("./chat-agents");
21
+ const inversify_1 = require("@theia/core/shared/inversify");
22
+ let CustomChatAgent = class CustomChatAgent extends chat_agents_1.AbstractStreamParsingChatAgent {
23
+ constructor() {
24
+ super('CustomChatAgent', [{ purpose: 'chat' }], 'chat');
25
+ this.variables = [];
26
+ this.functions = [];
27
+ this.promptTemplates = [];
28
+ this.agentSpecificVariables = [];
29
+ }
30
+ async getSystemMessageDescription() {
31
+ const resolvedPrompt = await this.promptService.getPrompt(`${this.name}_prompt`);
32
+ return resolvedPrompt ? chat_agents_1.SystemMessageDescription.fromResolvedPromptTemplate(resolvedPrompt) : undefined;
33
+ }
34
+ set prompt(prompt) {
35
+ this.promptTemplates.push({ id: `${this.name}_prompt`, template: prompt });
36
+ }
37
+ };
38
+ exports.CustomChatAgent = CustomChatAgent;
39
+ exports.CustomChatAgent = CustomChatAgent = tslib_1.__decorate([
40
+ (0, inversify_1.injectable)(),
41
+ tslib_1.__metadata("design:paramtypes", [])
42
+ ], CustomChatAgent);
43
+ //# sourceMappingURL=custom-chat-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-chat-agent.js","sourceRoot":"","sources":["../../src/common/custom-chat-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;;;;AAGhF,+CAAoG;AACpG,4DAA0D;AAGnD,IAAM,eAAe,GAArB,MAAM,eACT,SAAQ,4CAA8B;IAStC;QAEI,KAAK,CAAC,iBAAiB,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;QAPnD,cAAS,GAAa,EAAE,CAAC;QACzB,cAAS,GAAa,EAAE,CAAC;QACzB,oBAAe,GAAqB,EAAE,CAAC;QACvC,2BAAsB,GAA6B,EAAE,CAAC;IAK/D,CAAC;IACkB,KAAK,CAAC,2BAA2B;QAChD,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,IAAI,SAAS,CAAC,CAAC;QACjF,OAAO,cAAc,CAAC,CAAC,CAAC,sCAAwB,CAAC,0BAA0B,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5G,CAAC;IAED,IAAI,MAAM,CAAC,MAAc;QACrB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/E,CAAC;CACJ,CAAA;AAtBY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,GAAE;;GACA,eAAe,CAsB3B"}
@@ -1,10 +1,11 @@
1
- export * from './chat-agent-service';
2
1
  export * from './chat-agents';
2
+ export * from './chat-agent-service';
3
3
  export * from './chat-model';
4
- export * from './parsed-chat-request';
5
4
  export * from './chat-request-parser';
6
5
  export * from './chat-service';
7
6
  export * from './command-chat-agents';
8
- export * from './universal-chat-agent';
7
+ export * from './custom-chat-agent';
8
+ export * from './parsed-chat-request';
9
9
  export * from './orchestrator-chat-agent';
10
+ export * from './universal-chat-agent';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAeA,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAeA,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC"}
@@ -16,13 +16,14 @@ const tslib_1 = require("tslib");
16
16
  //
17
17
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
18
18
  // *****************************************************************************
19
- tslib_1.__exportStar(require("./chat-agent-service"), exports);
20
19
  tslib_1.__exportStar(require("./chat-agents"), exports);
20
+ tslib_1.__exportStar(require("./chat-agent-service"), exports);
21
21
  tslib_1.__exportStar(require("./chat-model"), exports);
22
- tslib_1.__exportStar(require("./parsed-chat-request"), exports);
23
22
  tslib_1.__exportStar(require("./chat-request-parser"), exports);
24
23
  tslib_1.__exportStar(require("./chat-service"), exports);
25
24
  tslib_1.__exportStar(require("./command-chat-agents"), exports);
26
- tslib_1.__exportStar(require("./universal-chat-agent"), exports);
25
+ tslib_1.__exportStar(require("./custom-chat-agent"), exports);
26
+ tslib_1.__exportStar(require("./parsed-chat-request"), exports);
27
27
  tslib_1.__exportStar(require("./orchestrator-chat-agent"), exports);
28
+ tslib_1.__exportStar(require("./universal-chat-agent"), exports);
28
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/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;AAChF,+DAAqC;AACrC,wDAA8B;AAC9B,uDAA6B;AAC7B,gEAAsC;AACtC,gEAAsC;AACtC,yDAA+B;AAC/B,gEAAsC;AACtC,iEAAuC;AACvC,oEAA0C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/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;AAChF,wDAA8B;AAC9B,+DAAqC;AACrC,uDAA6B;AAC7B,gEAAsC;AACtC,yDAA+B;AAC/B,gEAAsC;AACtC,8DAAoC;AACpC,gEAAsC;AACtC,oEAA0C;AAC1C,iEAAuC"}
@@ -0,0 +1,13 @@
1
+ import { ChatAgent, AbstractStreamParsingChatAgent, SystemMessageDescription } from './chat-agents';
2
+ import { AgentSpecificVariables, PromptTemplate } from '@theia/ai-core';
3
+ export declare class O1ChatAgent extends AbstractStreamParsingChatAgent implements ChatAgent {
4
+ name: string;
5
+ description: string;
6
+ promptTemplates: PromptTemplate[];
7
+ readonly agentSpecificVariables: AgentSpecificVariables[];
8
+ readonly variables: string[];
9
+ readonly functions: string[];
10
+ constructor();
11
+ protected getSystemMessageDescription(): Promise<SystemMessageDescription | undefined>;
12
+ }
13
+ //# sourceMappingURL=o1-chat-agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"o1-chat-agent.d.ts","sourceRoot":"","sources":["../../src/common/o1-chat-agent.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,SAAS,EACT,8BAA8B,EAC9B,wBAAwB,EAC3B,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAExE,qBACa,WAAY,SAAQ,8BAA+B,YAAW,SAAS;IAEzE,IAAI,SAAgB;IACpB,WAAW,SAAsD;IACjE,eAAe,EAAE,cAAc,EAAE,CAAM;IAC9C,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,EAAE,CAAM;IAC/D,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAM;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAM;;cAalB,2BAA2B,IAAI,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC;CAI/F"}
@@ -0,0 +1,45 @@
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.O1ChatAgent = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const chat_agents_1 = require("./chat-agents");
21
+ const inversify_1 = require("@theia/core/shared/inversify");
22
+ let O1ChatAgent = class O1ChatAgent extends chat_agents_1.AbstractStreamParsingChatAgent {
23
+ constructor() {
24
+ super('o1-preview', [{
25
+ purpose: 'chat',
26
+ identifier: 'openai/o1-preview',
27
+ }], 'chat');
28
+ this.name = 'O1-Preview';
29
+ this.description = 'An agent for interacting with ChatGPT o1-preview';
30
+ this.promptTemplates = [];
31
+ this.agentSpecificVariables = [];
32
+ this.variables = [];
33
+ this.functions = [];
34
+ }
35
+ async getSystemMessageDescription() {
36
+ // O1 currently does not support system prompts
37
+ return undefined;
38
+ }
39
+ };
40
+ exports.O1ChatAgent = O1ChatAgent;
41
+ exports.O1ChatAgent = O1ChatAgent = tslib_1.__decorate([
42
+ (0, inversify_1.injectable)(),
43
+ tslib_1.__metadata("design:paramtypes", [])
44
+ ], O1ChatAgent);
45
+ //# sourceMappingURL=o1-chat-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"o1-chat-agent.js","sourceRoot":"","sources":["../../src/common/o1-chat-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;;;;AAEhF,+CAIuB;AAEvB,4DAA0D;AAInD,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,4CAA8B;IAS3D;QACI,KAAK,CACD,YAAY,EACZ,CAAC;gBACG,OAAO,EAAE,MAAM;gBACf,UAAU,EAAE,mBAAmB;aAClC,CAAC,EACF,MAAM,CACT,CAAC;QAfC,SAAI,GAAG,YAAY,CAAC;QACpB,gBAAW,GAAG,kDAAkD,CAAC;QACjE,oBAAe,GAAqB,EAAE,CAAC;QACrC,2BAAsB,GAA6B,EAAE,CAAC;QACtD,cAAS,GAAa,EAAE,CAAC;QACzB,cAAS,GAAa,EAAE,CAAC;IAWlC,CAAC;IAES,KAAK,CAAC,2BAA2B;QACvC,+CAA+C;QAC/C,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ,CAAA;AAxBY,kCAAW;sBAAX,WAAW;IADvB,IAAA,sBAAU,GAAE;;GACA,WAAW,CAwBvB"}
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@theia/ai-chat",
3
- "version": "1.55.0-next.37+4e7843ca5",
3
+ "version": "1.55.0",
4
4
  "description": "Theia - AI Chat Extension",
5
5
  "dependencies": {
6
- "@theia/ai-core": "1.55.0-next.37+4e7843ca5",
7
- "@theia/ai-history": "1.55.0-next.37+4e7843ca5",
8
- "@theia/core": "1.55.0-next.37+4e7843ca5",
9
- "@theia/filesystem": "1.55.0-next.37+4e7843ca5",
10
- "@theia/workspace": "1.55.0-next.37+4e7843ca5",
6
+ "@theia/ai-core": "1.55.0",
7
+ "@theia/ai-history": "1.55.0",
8
+ "@theia/core": "1.55.0",
9
+ "@theia/filesystem": "1.55.0",
10
+ "@theia/workspace": "1.55.0",
11
11
  "minimatch": "^5.1.0",
12
12
  "tslib": "^2.6.2"
13
13
  },
@@ -45,10 +45,10 @@
45
45
  "watch": "theiaext watch"
46
46
  },
47
47
  "devDependencies": {
48
- "@theia/ext-scripts": "1.54.0"
48
+ "@theia/ext-scripts": "1.55.0"
49
49
  },
50
50
  "nyc": {
51
51
  "extends": "../../configs/nyc.json"
52
52
  },
53
- "gitHead": "4e7843ca5ce4625e3b4823b9a87debd805906fba"
53
+ "gitHead": "0e7a523b8e798679d2e098709c63bd7060e54c8a"
54
54
  }
@@ -14,9 +14,9 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import { Agent, AIVariableContribution } from '@theia/ai-core/lib/common';
17
+ import { Agent, AgentService, AIVariableContribution } from '@theia/ai-core/lib/common';
18
18
  import { bindContributionProvider } from '@theia/core';
19
- import { PreferenceContribution } from '@theia/core/lib/browser';
19
+ import { FrontendApplicationContribution, PreferenceContribution } from '@theia/core/lib/browser';
20
20
  import { ContainerModule } from '@theia/core/shared/inversify';
21
21
  import {
22
22
  ChatAgent,
@@ -27,13 +27,17 @@ import {
27
27
  ChatService,
28
28
  DefaultChatAgentId
29
29
  } from '../common';
30
+ import { ChatAgentsVariableContribution } from '../common/chat-agents-variable-contribution';
30
31
  import { CommandChatAgent } from '../common/command-chat-agents';
32
+ import { CustomChatAgent } from '../common/custom-chat-agent';
31
33
  import { OrchestratorChatAgent, OrchestratorChatAgentId } from '../common/orchestrator-chat-agent';
34
+ import { DefaultResponseContentFactory, DefaultResponseContentMatcherProvider, ResponseContentMatcherProvider } from '../common/response-content-matcher';
32
35
  import { UniversalChatAgent } from '../common/universal-chat-agent';
33
36
  import { aiChatPreferences } from './ai-chat-preferences';
34
- import { ChatAgentsVariableContribution } from '../common/chat-agents-variable-contribution';
37
+ import { AICustomAgentsFrontendApplicationContribution } from './custom-agent-frontend-application-contribution';
35
38
  import { FrontendChatServiceImpl } from './frontend-chat-service';
36
- import { DefaultResponseContentMatcherProvider, DefaultResponseContentFactory, ResponseContentMatcherProvider } from '../common/response-content-matcher';
39
+ import { CustomAgentFactory } from './custom-agent-factory';
40
+ import { O1ChatAgent } from '../common/o1-chat-agent';
37
41
 
38
42
  export default new ContainerModule(bind => {
39
43
  bindContributionProvider(bind, Agent);
@@ -60,6 +64,10 @@ export default new ContainerModule(bind => {
60
64
  bind(Agent).toService(OrchestratorChatAgent);
61
65
  bind(ChatAgent).toService(OrchestratorChatAgent);
62
66
 
67
+ bind(O1ChatAgent).toSelf().inSingletonScope();
68
+ bind(Agent).toService(O1ChatAgent);
69
+ bind(ChatAgent).toService(O1ChatAgent);
70
+
63
71
  bind(UniversalChatAgent).toSelf().inSingletonScope();
64
72
  bind(Agent).toService(UniversalChatAgent);
65
73
  bind(ChatAgent).toService(UniversalChatAgent);
@@ -69,4 +77,22 @@ export default new ContainerModule(bind => {
69
77
  bind(ChatAgent).toService(CommandChatAgent);
70
78
 
71
79
  bind(PreferenceContribution).toConstantValue({ schema: aiChatPreferences });
80
+
81
+ bind(CustomChatAgent).toSelf();
82
+ bind(CustomAgentFactory).toFactory<CustomChatAgent, [string, string, string, string, string]>(
83
+ ctx => (id: string, name: string, description: string, prompt: string, defaultLLM: string) => {
84
+ const agent = ctx.container.get<CustomChatAgent>(CustomChatAgent);
85
+ agent.id = id;
86
+ agent.name = name;
87
+ agent.description = description;
88
+ agent.prompt = prompt;
89
+ agent.languageModelRequirements = [{
90
+ purpose: 'chat',
91
+ identifier: defaultLLM,
92
+ }];
93
+ ctx.container.get<ChatAgentService>(ChatAgentService).registerChatAgent(agent);
94
+ ctx.container.get<AgentService>(AgentService).registerAgent(agent);
95
+ return agent;
96
+ });
97
+ bind(FrontendApplicationContribution).to(AICustomAgentsFrontendApplicationContribution).inSingletonScope();
72
98
  });
@@ -0,0 +1,20 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 EclipseSource GmbH.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { CustomChatAgent } from '../common';
18
+
19
+ export const CustomAgentFactory = Symbol('CustomAgentFactory');
20
+ export type CustomAgentFactory = (id: string, name: string, description: string, prompt: string, defaultLLM: string) => CustomChatAgent;
@@ -0,0 +1,73 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 EclipseSource GmbH.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { AgentService, CustomAgentDescription, PromptCustomizationService } from '@theia/ai-core';
18
+ import { FrontendApplicationContribution } from '@theia/core/lib/browser';
19
+ import { inject, injectable } from '@theia/core/shared/inversify';
20
+ import { ChatAgentService } from '../common';
21
+ import { CustomAgentFactory } from './custom-agent-factory';
22
+
23
+ @injectable()
24
+ export class AICustomAgentsFrontendApplicationContribution implements FrontendApplicationContribution {
25
+ @inject(CustomAgentFactory)
26
+ protected readonly customAgentFactory: CustomAgentFactory;
27
+
28
+ @inject(PromptCustomizationService)
29
+ protected readonly customizationService: PromptCustomizationService;
30
+
31
+ @inject(AgentService)
32
+ private readonly agentService: AgentService;
33
+
34
+ @inject(ChatAgentService)
35
+ private readonly chatAgentService: ChatAgentService;
36
+
37
+ private knownCustomAgents: Map<string, CustomAgentDescription> = new Map();
38
+ onStart(): void {
39
+ this.customizationService?.getCustomAgents().then(customAgents => {
40
+ customAgents.forEach(agent => {
41
+ this.customAgentFactory(agent.id, agent.name, agent.description, agent.prompt, agent.defaultLLM);
42
+ this.knownCustomAgents.set(agent.id, agent);
43
+ });
44
+ }).catch(e => {
45
+ console.error('Failed to load custom agents', e);
46
+ });
47
+ this.customizationService?.onDidChangeCustomAgents(() => {
48
+ this.customizationService?.getCustomAgents().then(customAgents => {
49
+ const customAgentsToAdd = customAgents.filter(agent =>
50
+ !this.knownCustomAgents.has(agent.id) || !CustomAgentDescription.equals(this.knownCustomAgents.get(agent.id)!, agent));
51
+ const customAgentIdsToRemove = [...this.knownCustomAgents.values()].filter(agent =>
52
+ !customAgents.find(a => CustomAgentDescription.equals(a, agent))).map(a => a.id);
53
+
54
+ // delete first so we don't have to deal with the case where we add and remove the same agentId
55
+ customAgentIdsToRemove.forEach(id => {
56
+ this.chatAgentService.unregisterChatAgent(id);
57
+ this.agentService.unregisterAgent(id);
58
+ this.knownCustomAgents.delete(id);
59
+ });
60
+ customAgentsToAdd
61
+ .forEach(agent => {
62
+ this.customAgentFactory(agent.id, agent.name, agent.description, agent.prompt, agent.defaultLLM);
63
+ this.knownCustomAgents.set(agent.id, agent);
64
+ });
65
+ }).catch(e => {
66
+ console.error('Failed to load custom agents', e);
67
+ });
68
+ });
69
+ }
70
+
71
+ onStop(): void {
72
+ }
73
+ }
@@ -41,6 +41,18 @@ export interface ChatAgentService {
41
41
  * Returns all agents, including disabled ones.
42
42
  */
43
43
  getAllAgents(): ChatAgent[];
44
+
45
+ /**
46
+ * Allows to register a chat agent programmatically.
47
+ * @param agent the agent to register
48
+ */
49
+ registerChatAgent(agent: ChatAgent): void;
50
+
51
+ /**
52
+ * Allows to unregister a chat agent programmatically.
53
+ * @param agentId the agent id to unregister
54
+ */
55
+ unregisterChatAgent(agentId: string): void;
44
56
  }
45
57
  @injectable()
46
58
  export class ChatAgentServiceImpl implements ChatAgentService {
@@ -65,6 +77,9 @@ export class ChatAgentServiceImpl implements ChatAgentService {
65
77
  registerChatAgent(agent: ChatAgent): void {
66
78
  this._agents.push(agent);
67
79
  }
80
+ unregisterChatAgent(agentId: string): void {
81
+ this._agents = this._agents.filter(a => a.id !== agentId);
82
+ }
68
83
 
69
84
  getAgent(id: string): ChatAgent | undefined {
70
85
  if (!this._agentIsEnabled(id)) {
@@ -0,0 +1,44 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 EclipseSource GmbH.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { AgentSpecificVariables, PromptTemplate } from '@theia/ai-core';
18
+ import { AbstractStreamParsingChatAgent, ChatAgent, SystemMessageDescription } from './chat-agents';
19
+ import { injectable } from '@theia/core/shared/inversify';
20
+
21
+ @injectable()
22
+ export class CustomChatAgent
23
+ extends AbstractStreamParsingChatAgent
24
+ implements ChatAgent {
25
+ name: string;
26
+ description: string;
27
+ readonly variables: string[] = [];
28
+ readonly functions: string[] = [];
29
+ readonly promptTemplates: PromptTemplate[] = [];
30
+ readonly agentSpecificVariables: AgentSpecificVariables[] = [];
31
+
32
+ constructor(
33
+ ) {
34
+ super('CustomChatAgent', [{ purpose: 'chat' }], 'chat');
35
+ }
36
+ protected override async getSystemMessageDescription(): Promise<SystemMessageDescription | undefined> {
37
+ const resolvedPrompt = await this.promptService.getPrompt(`${this.name}_prompt`);
38
+ return resolvedPrompt ? SystemMessageDescription.fromResolvedPromptTemplate(resolvedPrompt) : undefined;
39
+ }
40
+
41
+ set prompt(prompt: string) {
42
+ this.promptTemplates.push({ id: `${this.name}_prompt`, template: prompt });
43
+ }
44
+ }
@@ -13,12 +13,13 @@
13
13
  //
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
- export * from './chat-agent-service';
17
16
  export * from './chat-agents';
17
+ export * from './chat-agent-service';
18
18
  export * from './chat-model';
19
- export * from './parsed-chat-request';
20
19
  export * from './chat-request-parser';
21
20
  export * from './chat-service';
22
21
  export * from './command-chat-agents';
23
- export * from './universal-chat-agent';
22
+ export * from './custom-chat-agent';
23
+ export * from './parsed-chat-request';
24
24
  export * from './orchestrator-chat-agent';
25
+ export * from './universal-chat-agent';
@@ -0,0 +1,51 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 EclipseSource GmbH.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import {
18
+ ChatAgent,
19
+ AbstractStreamParsingChatAgent,
20
+ SystemMessageDescription
21
+ } from './chat-agents';
22
+
23
+ import { injectable } from '@theia/core/shared/inversify';
24
+ import { AgentSpecificVariables, PromptTemplate } from '@theia/ai-core';
25
+
26
+ @injectable()
27
+ export class O1ChatAgent extends AbstractStreamParsingChatAgent implements ChatAgent {
28
+
29
+ public name = 'O1-Preview';
30
+ public description = 'An agent for interacting with ChatGPT o1-preview';
31
+ public promptTemplates: PromptTemplate[] = [];
32
+ readonly agentSpecificVariables: AgentSpecificVariables[] = [];
33
+ readonly variables: string[] = [];
34
+ readonly functions: string[] = [];
35
+
36
+ constructor() {
37
+ super(
38
+ 'o1-preview',
39
+ [{
40
+ purpose: 'chat',
41
+ identifier: 'openai/o1-preview',
42
+ }],
43
+ 'chat'
44
+ );
45
+ }
46
+
47
+ protected async getSystemMessageDescription(): Promise<SystemMessageDescription | undefined> {
48
+ // O1 currently does not support system prompts
49
+ return undefined;
50
+ }
51
+ }