@theia/ai-terminal 1.67.0-next.56 → 1.67.0-next.59

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.
@@ -0,0 +1,23 @@
1
+ import { Agent, LanguageModelRegistry, LanguageModelRequirement, PromptService } from '@theia/ai-core/lib/common';
2
+ import { LanguageModelService } from '@theia/ai-core/lib/browser';
3
+ import { ILogger } from '@theia/core';
4
+ export declare class AiTerminalAgent implements Agent {
5
+ id: string;
6
+ name: string;
7
+ description: string;
8
+ variables: never[];
9
+ functions: never[];
10
+ agentSpecificVariables: {
11
+ name: string;
12
+ usedInPrompt: boolean;
13
+ description: string;
14
+ }[];
15
+ prompts: import("@theia/ai-core/lib/common").PromptVariantSet[];
16
+ languageModelRequirements: LanguageModelRequirement[];
17
+ protected languageModelRegistry: LanguageModelRegistry;
18
+ protected promptService: PromptService;
19
+ protected logger: ILogger;
20
+ protected languageModelService: LanguageModelService;
21
+ getCommands(userRequest: string, cwd: string, shell: string, recentTerminalContents: string[]): Promise<string[]>;
22
+ }
23
+ //# sourceMappingURL=ai-terminal-agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-terminal-agent.d.ts","sourceRoot":"","sources":["../../src/browser/ai-terminal-agent.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,KAAK,EAGL,qBAAqB,EACrB,wBAAwB,EACxB,aAAa,EAEhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAgB,OAAO,EAAO,MAAM,aAAa,CAAC;AAWzD,qBACa,eAAgB,YAAW,KAAK;IAEzC,EAAE,SAAwB;IAC1B,IAAI,SAAwB;IAC5B,WAAW,SAEqI;IAChJ,SAAS,UAAM;IACf,SAAS,UAAM;IACf,sBAAsB;;;;QAqBpB;IACF,OAAO,yDAAmB;IAC1B,yBAAyB,EAAE,wBAAwB,EAAE,CAKnD;IAGF,SAAS,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IAGvD,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC;IAGvC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC;IAG1B,SAAS,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAE/C,WAAW,CACb,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,sBAAsB,EAAE,MAAM,EAAE,GACjC,OAAO,CAAC,MAAM,EAAE,CAAC;CA+EvB"}
@@ -0,0 +1,161 @@
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.AiTerminalAgent = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const common_1 = require("@theia/ai-core/lib/common");
21
+ const browser_1 = require("@theia/ai-core/lib/browser");
22
+ const core_1 = require("@theia/core");
23
+ const ai_terminal_prompt_template_1 = require("./ai-terminal-prompt-template");
24
+ const inversify_1 = require("@theia/core/shared/inversify");
25
+ const zod_1 = require("zod");
26
+ const zod_to_json_schema_1 = require("zod-to-json-schema");
27
+ const Commands = zod_1.z.object({
28
+ commands: zod_1.z.array(zod_1.z.string()),
29
+ });
30
+ let AiTerminalAgent = class AiTerminalAgent {
31
+ constructor() {
32
+ this.id = 'Terminal Assistant';
33
+ this.name = 'Terminal Assistant';
34
+ this.description = core_1.nls.localize('theia/ai/terminal/agent/description', 'This agent provides assistance to write and execute arbitrary terminal commands. \
35
+ Based on the user\'s request, it suggests commands and allows the user to directly paste and execute them in the terminal. \
36
+ It accesses the current directory, environment and the recent terminal output of the terminal session to provide context-aware assistance');
37
+ this.variables = [];
38
+ this.functions = [];
39
+ this.agentSpecificVariables = [
40
+ {
41
+ name: 'userRequest',
42
+ usedInPrompt: true,
43
+ description: core_1.nls.localize('theia/ai/terminal/agent/vars/userRequest/description', 'The user\'s question or request.')
44
+ },
45
+ {
46
+ name: 'shell',
47
+ usedInPrompt: true,
48
+ description: core_1.nls.localize('theia/ai/terminal/agent/vars/shell/description', 'The shell being used, e.g., /usr/bin/zsh.')
49
+ },
50
+ {
51
+ name: 'cwd',
52
+ usedInPrompt: true,
53
+ description: core_1.nls.localize('theia/ai/terminal/agent/vars/cwd/description', 'The current working directory.')
54
+ },
55
+ {
56
+ name: 'recentTerminalContents',
57
+ usedInPrompt: true,
58
+ description: core_1.nls.localize('theia/ai/terminal/agent/vars/recentTerminalContents/description', 'The last 0 to 50 recent lines visible in the terminal.')
59
+ }
60
+ ];
61
+ this.prompts = ai_terminal_prompt_template_1.terminalPrompts;
62
+ this.languageModelRequirements = [
63
+ {
64
+ purpose: 'suggest-terminal-commands',
65
+ identifier: 'default/universal',
66
+ }
67
+ ];
68
+ }
69
+ async getCommands(userRequest, cwd, shell, recentTerminalContents) {
70
+ const lm = await this.languageModelRegistry.selectLanguageModel({
71
+ agent: this.id,
72
+ ...this.languageModelRequirements[0]
73
+ });
74
+ if (!lm) {
75
+ this.logger.error('No language model available for the AI Terminal Agent.');
76
+ return [];
77
+ }
78
+ const parameters = {
79
+ userRequest,
80
+ shell,
81
+ cwd,
82
+ recentTerminalContents
83
+ };
84
+ const systemMessage = await this.promptService.getResolvedPromptFragment('terminal-system', parameters).then(p => p === null || p === void 0 ? void 0 : p.text);
85
+ const request = await this.promptService.getResolvedPromptFragment('terminal-user', parameters).then(p => p === null || p === void 0 ? void 0 : p.text);
86
+ if (!systemMessage || !request) {
87
+ this.logger.error('The prompt service didn\'t return prompts for the AI Terminal Agent.');
88
+ return [];
89
+ }
90
+ // since we do not actually hold complete conversions, the request/response pair is considered a session
91
+ const sessionId = (0, core_1.generateUuid)();
92
+ const requestId = (0, core_1.generateUuid)();
93
+ const llmRequest = {
94
+ messages: [
95
+ {
96
+ actor: 'ai',
97
+ type: 'text',
98
+ text: systemMessage
99
+ },
100
+ {
101
+ actor: 'user',
102
+ type: 'text',
103
+ text: request
104
+ }
105
+ ],
106
+ response_format: {
107
+ type: 'json_schema',
108
+ json_schema: {
109
+ name: 'terminal-commands',
110
+ description: 'Suggested terminal commands based on the user request',
111
+ schema: (0, zod_to_json_schema_1.default)(Commands)
112
+ }
113
+ },
114
+ agentId: this.id,
115
+ requestId,
116
+ sessionId
117
+ };
118
+ try {
119
+ const result = await this.languageModelService.sendRequest(lm, llmRequest);
120
+ if ((0, common_1.isLanguageModelParsedResponse)(result)) {
121
+ // model returned structured output
122
+ const parsedResult = Commands.safeParse(result.parsed);
123
+ if (parsedResult.success) {
124
+ return parsedResult.data.commands;
125
+ }
126
+ }
127
+ // fall back to agent-based parsing of result
128
+ const jsonResult = await (0, common_1.getJsonOfResponse)(result);
129
+ const parsedJsonResult = Commands.safeParse(jsonResult);
130
+ if (parsedJsonResult.success) {
131
+ return parsedJsonResult.data.commands;
132
+ }
133
+ return [];
134
+ }
135
+ catch (error) {
136
+ this.logger.error('Error obtaining the command suggestions.', error);
137
+ return [];
138
+ }
139
+ }
140
+ };
141
+ exports.AiTerminalAgent = AiTerminalAgent;
142
+ tslib_1.__decorate([
143
+ (0, inversify_1.inject)(common_1.LanguageModelRegistry),
144
+ tslib_1.__metadata("design:type", Object)
145
+ ], AiTerminalAgent.prototype, "languageModelRegistry", void 0);
146
+ tslib_1.__decorate([
147
+ (0, inversify_1.inject)(common_1.PromptService),
148
+ tslib_1.__metadata("design:type", Object)
149
+ ], AiTerminalAgent.prototype, "promptService", void 0);
150
+ tslib_1.__decorate([
151
+ (0, inversify_1.inject)(core_1.ILogger),
152
+ tslib_1.__metadata("design:type", Object)
153
+ ], AiTerminalAgent.prototype, "logger", void 0);
154
+ tslib_1.__decorate([
155
+ (0, inversify_1.inject)(browser_1.LanguageModelService),
156
+ tslib_1.__metadata("design:type", Object)
157
+ ], AiTerminalAgent.prototype, "languageModelService", void 0);
158
+ exports.AiTerminalAgent = AiTerminalAgent = tslib_1.__decorate([
159
+ (0, inversify_1.injectable)()
160
+ ], AiTerminalAgent);
161
+ //# sourceMappingURL=ai-terminal-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-terminal-agent.js","sourceRoot":"","sources":["../../src/browser/ai-terminal-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,sDAQmC;AACnC,wDAAkE;AAClE,sCAAyD;AACzD,+EAAgE;AAChE,4DAAkE;AAClE,6BAAwB;AACxB,2DAAiD;AAEjD,MAAM,QAAQ,GAAG,OAAC,CAAC,MAAM,CAAC;IACtB,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;CAChC,CAAC,CAAC;AAII,IAAM,eAAe,GAArB,MAAM,eAAe;IAArB;QAEH,OAAE,GAAG,oBAAoB,CAAC;QAC1B,SAAI,GAAG,oBAAoB,CAAC;QAC5B,gBAAW,GAAG,UAAG,CAAC,QAAQ,CAAC,qCAAqC,EAAE;;kJAE4E,CAAC,CAAC;QAChJ,cAAS,GAAG,EAAE,CAAC;QACf,cAAS,GAAG,EAAE,CAAC;QACf,2BAAsB,GAAG;YACrB;gBACI,IAAI,EAAE,a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,GAAG,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBACvD,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;oBACvB,OAAO,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC;gBACtC,CAAC;YACL,CAAC;YAED,6CAA6C;YAC7C,MAAM,UAAU,GAAG,MAAM,IAAA,0BAAiB,EAAC,MAAM,CAAC,CAAC;YACnD,MAAM,gBAAgB,GAAG,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;YACxD,IAAI,gBAAgB,CAAC,OAAO,EAAE,CAAC;gBAC3B,OAAO,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC1C,CAAC;YAED,OAAO,EAAE,CAAC;QAEd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,0CAA0C,EAAE,KAAK,CAAC,CAAC;YACrE,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC;CAEJ,CAAA;AAvIY,0CAAe;AAwCd;IADT,IAAA,kBAAM,EAAC,8BAAqB,CAAC;;8DACyB;AAG7C;IADT,IAAA,kBAAM,EAAC,sBAAa,CAAC;;sDACiB;AAG7B;IADT,IAAA,kBAAM,EAAC,cAAO,CAAC;;+CACU;AAGhB;IADT,IAAA,kBAAM,EAAC,8BAAoB,CAAC;;6DACwB;0BAjD5C,eAAe;IAD3B,IAAA,sBAAU,GAAE;GACA,eAAe,CAuI3B"}
@@ -0,0 +1,16 @@
1
+ import { CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry } from '@theia/core';
2
+ import { ApplicationShell, KeybindingContribution, KeybindingRegistry } from '@theia/core/lib/browser';
3
+ import { TerminalService } from '@theia/terminal/lib/browser/base/terminal-service';
4
+ import { AiTerminalAgent } from './ai-terminal-agent';
5
+ import { AICommandHandlerFactory } from '@theia/ai-core/lib/browser/ai-command-handler-factory';
6
+ export declare class AiTerminalCommandContribution implements CommandContribution, MenuContribution, KeybindingContribution {
7
+ protected terminalService: TerminalService;
8
+ protected terminalAgent: AiTerminalAgent;
9
+ protected commandHandlerFactory: AICommandHandlerFactory;
10
+ private readonly agentService;
11
+ protected readonly shell: ApplicationShell;
12
+ registerKeybindings(keybindings: KeybindingRegistry): void;
13
+ registerMenus(menus: MenuModelRegistry): void;
14
+ registerCommands(commands: CommandRegistry): void;
15
+ }
16
+ //# sourceMappingURL=ai-terminal-contribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-terminal-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/ai-terminal-contribution.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAW,mBAAmB,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACjH,OAAO,EAAE,gBAAgB,EAAW,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAEhH,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AAGpF,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uDAAuD,CAAC;AAUhG,qBACa,6BAA8B,YAAW,mBAAmB,EAAE,gBAAgB,EAAE,sBAAsB;IAG/G,SAAS,CAAC,eAAe,EAAE,eAAe,CAAC;IAG3C,SAAS,CAAC,aAAa,EAAE,eAAe,CAAC;IAGzC,SAAS,CAAC,qBAAqB,EAAE,uBAAuB,CAAC;IAGzD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAG5C,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IAE3C,mBAAmB,CAAC,WAAW,EAAE,kBAAkB,GAAG,IAAI;IAO1D,aAAa,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;IAO7C,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;CAkBpD"}
@@ -0,0 +1,191 @@
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.AiTerminalCommandContribution = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const browser_1 = require("@theia/ai-core/lib/browser");
21
+ const core_1 = require("@theia/core");
22
+ const browser_2 = require("@theia/core/lib/browser");
23
+ const inversify_1 = require("@theia/core/shared/inversify");
24
+ const terminal_service_1 = require("@theia/terminal/lib/browser/base/terminal-service");
25
+ const terminal_frontend_contribution_1 = require("@theia/terminal/lib/browser/terminal-frontend-contribution");
26
+ const terminal_widget_impl_1 = require("@theia/terminal/lib/browser/terminal-widget-impl");
27
+ const ai_terminal_agent_1 = require("./ai-terminal-agent");
28
+ const ai_command_handler_factory_1 = require("@theia/ai-core/lib/browser/ai-command-handler-factory");
29
+ const ai_core_1 = require("@theia/ai-core");
30
+ const nls_1 = require("@theia/core/lib/common/nls");
31
+ const AI_TERMINAL_COMMAND = core_1.Command.toLocalizedCommand({
32
+ id: 'ai-terminal:open',
33
+ label: 'Ask AI',
34
+ iconClass: (0, browser_2.codicon)('sparkle')
35
+ }, 'theia/ai/terminal/askAi');
36
+ let AiTerminalCommandContribution = class AiTerminalCommandContribution {
37
+ registerKeybindings(keybindings) {
38
+ keybindings.registerKeybinding({
39
+ command: AI_TERMINAL_COMMAND.id,
40
+ keybinding: 'ctrlcmd+i',
41
+ when: `terminalFocus && ${browser_1.ENABLE_AI_CONTEXT_KEY}`
42
+ });
43
+ }
44
+ registerMenus(menus) {
45
+ menus.registerMenuAction([...terminal_frontend_contribution_1.TerminalMenus.TERMINAL_CONTEXT_MENU, '_5'], {
46
+ when: browser_1.ENABLE_AI_CONTEXT_KEY,
47
+ commandId: AI_TERMINAL_COMMAND.id,
48
+ icon: AI_TERMINAL_COMMAND.iconClass
49
+ });
50
+ }
51
+ registerCommands(commands) {
52
+ commands.registerCommand(AI_TERMINAL_COMMAND, this.commandHandlerFactory({
53
+ execute: () => {
54
+ const currentTerminal = this.terminalService.currentTerminal;
55
+ if (currentTerminal instanceof terminal_widget_impl_1.TerminalWidgetImpl && currentTerminal.kind === 'user') {
56
+ new AiTerminalChatWidget(currentTerminal, this.terminalAgent);
57
+ }
58
+ },
59
+ isEnabled: () =>
60
+ // Ensure it is only enabled for terminals explicitly launched by the user, not to terminals created e.g. for running tasks
61
+ this.agentService.isEnabled(this.terminalAgent.id)
62
+ && this.shell.currentWidget instanceof terminal_widget_impl_1.TerminalWidgetImpl
63
+ && this.shell.currentWidget.kind === 'user'
64
+ }));
65
+ }
66
+ };
67
+ exports.AiTerminalCommandContribution = AiTerminalCommandContribution;
68
+ tslib_1.__decorate([
69
+ (0, inversify_1.inject)(terminal_service_1.TerminalService),
70
+ tslib_1.__metadata("design:type", Object)
71
+ ], AiTerminalCommandContribution.prototype, "terminalService", void 0);
72
+ tslib_1.__decorate([
73
+ (0, inversify_1.inject)(ai_terminal_agent_1.AiTerminalAgent),
74
+ tslib_1.__metadata("design:type", ai_terminal_agent_1.AiTerminalAgent)
75
+ ], AiTerminalCommandContribution.prototype, "terminalAgent", void 0);
76
+ tslib_1.__decorate([
77
+ (0, inversify_1.inject)(ai_command_handler_factory_1.AICommandHandlerFactory),
78
+ tslib_1.__metadata("design:type", Function)
79
+ ], AiTerminalCommandContribution.prototype, "commandHandlerFactory", void 0);
80
+ tslib_1.__decorate([
81
+ (0, inversify_1.inject)(ai_core_1.AgentService),
82
+ tslib_1.__metadata("design:type", Object)
83
+ ], AiTerminalCommandContribution.prototype, "agentService", void 0);
84
+ tslib_1.__decorate([
85
+ (0, inversify_1.inject)(browser_2.ApplicationShell),
86
+ tslib_1.__metadata("design:type", browser_2.ApplicationShell)
87
+ ], AiTerminalCommandContribution.prototype, "shell", void 0);
88
+ exports.AiTerminalCommandContribution = AiTerminalCommandContribution = tslib_1.__decorate([
89
+ (0, inversify_1.injectable)()
90
+ ], AiTerminalCommandContribution);
91
+ class AiTerminalChatWidget {
92
+ constructor(terminalWidget, terminalAgent) {
93
+ this.terminalWidget = terminalWidget;
94
+ this.terminalAgent = terminalAgent;
95
+ this.haveResult = false;
96
+ this.chatContainer = document.createElement('div');
97
+ this.chatContainer.className = 'ai-terminal-chat-container';
98
+ const chatCloseButton = document.createElement('span');
99
+ chatCloseButton.className = 'closeButton codicon codicon-close';
100
+ chatCloseButton.onclick = () => this.dispose();
101
+ this.chatContainer.appendChild(chatCloseButton);
102
+ const chatResultContainer = document.createElement('div');
103
+ chatResultContainer.className = 'ai-terminal-chat-result';
104
+ this.chatResultParagraph = document.createElement('p');
105
+ this.chatResultParagraph.textContent = nls_1.nls.localize('theia/ai/terminal/howCanIHelp', 'How can I help you?');
106
+ chatResultContainer.appendChild(this.chatResultParagraph);
107
+ this.chatContainer.appendChild(chatResultContainer);
108
+ this.chatInputContainer = document.createElement('div');
109
+ this.chatInputContainer.className = 'ai-terminal-chat-input-container';
110
+ this.chatInput = document.createElement('textarea');
111
+ this.chatInput.className = 'theia-input theia-ChatInput';
112
+ this.chatInput.placeholder = nls_1.nls.localize('theia/ai/terminal/askTerminalCommand', 'Ask about a terminal command...');
113
+ this.chatInput.onkeydown = event => {
114
+ if (event.key === 'Enter' && !event.shiftKey) {
115
+ event.preventDefault();
116
+ if (!this.haveResult) {
117
+ this.send();
118
+ }
119
+ else {
120
+ this.terminalWidget.sendText(this.chatResultParagraph.innerText);
121
+ this.dispose();
122
+ }
123
+ }
124
+ else if (event.key === 'Escape') {
125
+ this.dispose();
126
+ }
127
+ else if (event.key === 'ArrowUp' && this.haveResult) {
128
+ this.updateChatResult(this.getNextCommandIndex(1));
129
+ }
130
+ else if (event.key === 'ArrowDown' && this.haveResult) {
131
+ this.updateChatResult(this.getNextCommandIndex(-1));
132
+ }
133
+ };
134
+ this.chatInputContainer.appendChild(this.chatInput);
135
+ const chatInputOptionsContainer = document.createElement('div');
136
+ const chatInputOptionsSpan = document.createElement('span');
137
+ chatInputOptionsSpan.className = 'codicon codicon-send option';
138
+ chatInputOptionsSpan.title = nls_1.nls.localizeByDefault('Send');
139
+ chatInputOptionsSpan.onclick = () => this.send();
140
+ chatInputOptionsContainer.appendChild(chatInputOptionsSpan);
141
+ this.chatInputContainer.appendChild(chatInputOptionsContainer);
142
+ this.chatContainer.appendChild(this.chatInputContainer);
143
+ terminalWidget.node.appendChild(this.chatContainer);
144
+ this.chatInput.focus();
145
+ }
146
+ async send() {
147
+ const userRequest = this.chatInput.value;
148
+ if (userRequest) {
149
+ this.chatInput.value = '';
150
+ this.chatResultParagraph.innerText = nls_1.nls.localize('theia/ai/terminal/loading', 'Loading');
151
+ this.chatResultParagraph.className = 'loading';
152
+ const cwd = (await this.terminalWidget.cwd).toString();
153
+ const processInfo = await this.terminalWidget.processInfo;
154
+ const shell = processInfo.executable;
155
+ const recentTerminalContents = this.getRecentTerminalCommands();
156
+ this.commands = await this.terminalAgent.getCommands(userRequest, cwd, shell, recentTerminalContents);
157
+ if (this.commands.length > 0) {
158
+ this.chatResultParagraph.className = 'command';
159
+ this.chatResultParagraph.innerText = this.commands[0];
160
+ this.chatInput.placeholder = nls_1.nls.localize('theia/ai/terminal/hitEnterConfirm', 'Hit enter to confirm');
161
+ if (this.commands.length > 1) {
162
+ this.chatInput.placeholder += nls_1.nls.localize('theia/ai/terminal/useArrowsAlternatives', ' or use ⇅ to show alternatives...');
163
+ }
164
+ this.haveResult = true;
165
+ }
166
+ else {
167
+ this.chatResultParagraph.className = '';
168
+ this.chatResultParagraph.innerText = nls_1.nls.localizeByDefault('No results');
169
+ this.chatInput.placeholder = nls_1.nls.localize('theia/ai/terminal/tryAgain', 'Try again...');
170
+ }
171
+ }
172
+ }
173
+ getRecentTerminalCommands() {
174
+ const maxLines = 100;
175
+ return this.terminalWidget.buffer.getLines(0, this.terminalWidget.buffer.length > maxLines ? maxLines : this.terminalWidget.buffer.length);
176
+ }
177
+ getNextCommandIndex(step) {
178
+ const currentIndex = this.commands.indexOf(this.chatResultParagraph.innerText);
179
+ const nextIndex = (currentIndex + step + this.commands.length) % this.commands.length;
180
+ return nextIndex;
181
+ }
182
+ updateChatResult(index) {
183
+ this.chatResultParagraph.innerText = this.commands[index];
184
+ }
185
+ dispose() {
186
+ this.chatInput.value = '';
187
+ this.terminalWidget.node.removeChild(this.chatContainer);
188
+ this.terminalWidget.getTerminal().focus();
189
+ }
190
+ }
191
+ //# sourceMappingURL=ai-terminal-contribution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-terminal-contribution.js","sourceRoot":"","sources":["../../src/browser/ai-terminal-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;;;;AAEhF,wDAAmE;AACnE,sCAAiH;AACjH,qDAAgH;AAChH,4DAAkE;AAClE,wFAAoF;AACpF,+GAA2F;AAC3F,2FAAsF;AACtF,2DAAsD;AACtD,sGAAgG;AAChG,4CAA8C;AAC9C,oDAAiD;AAEjD,MAAM,mBAAmB,GAAG,cAAO,CAAC,kBAAkB,CAAC;IACnD,EAAE,EAAE,kBAAkB;IACtB,KAAK,EAAE,QAAQ;IACf,SAAS,EAAE,IAAA,iBAAO,EAAC,SAAS,CAA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AAyB;QAC/B,MAAM,QAAQ,GAAG,GAAG,CAAC;QACrB,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EACxC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAC9F,CAAC;IACN,CAAC;IAES,mBAAmB,CAAC,IAAY;QACtC,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;QAC/E,MAAM,SAAS,GAAG,CAAC,YAAY,GAAG,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;QACtF,OAAO,SAAS,CAAC;IACrB,CAAC;IAES,gBAAgB,CAAC,KAAa;QACpC,IAAI,CAAC,mBAAmB,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9D,CAAC;IAES,OAAO;QACb,IAAI,CAAC,SAAS,CAAC,KAAK,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACzD,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,CAAC;IAC9C,CAAC;CACJ"}
@@ -0,0 +1,5 @@
1
+ import { ContainerModule } from '@theia/core/shared/inversify';
2
+ import '../../src/browser/style/ai-terminal.css';
3
+ declare const _default: ContainerModule;
4
+ export default _default;
5
+ //# sourceMappingURL=ai-terminal-frontend-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-terminal-frontend-module.d.ts","sourceRoot":"","sources":["../../src/browser/ai-terminal-frontend-module.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAI/D,OAAO,yCAAyC,CAAC;;AAEjD,wBAQG"}
@@ -0,0 +1,33 @@
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 common_1 = require("@theia/ai-core/lib/common");
19
+ const core_1 = require("@theia/core");
20
+ const browser_1 = require("@theia/core/lib/browser");
21
+ const inversify_1 = require("@theia/core/shared/inversify");
22
+ const ai_terminal_agent_1 = require("./ai-terminal-agent");
23
+ const ai_terminal_contribution_1 = require("./ai-terminal-contribution");
24
+ require("../../src/browser/style/ai-terminal.css");
25
+ exports.default = new inversify_1.ContainerModule(bind => {
26
+ bind(ai_terminal_contribution_1.AiTerminalCommandContribution).toSelf().inSingletonScope();
27
+ for (const identifier of [core_1.CommandContribution, core_1.MenuContribution, browser_1.KeybindingContribution]) {
28
+ bind(identifier).toService(ai_terminal_contribution_1.AiTerminalCommandContribution);
29
+ }
30
+ bind(ai_terminal_agent_1.AiTerminalAgent).toSelf().inSingletonScope();
31
+ bind(common_1.Agent).toService(ai_terminal_agent_1.AiTerminalAgent);
32
+ });
33
+ //# sourceMappingURL=ai-terminal-frontend-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-terminal-frontend-module.js","sourceRoot":"","sources":["../../src/browser/ai-terminal-frontend-module.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,sDAAkD;AAClD,sCAAoE;AACpE,qDAAiE;AACjE,4DAA+D;AAC/D,2DAAsD;AACtD,yEAA2E;AAE3E,mDAAiD;AAEjD,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACtC,IAAI,CAAC,wDAA6B,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAChE,KAAK,MAAM,UAAU,IAAI,CAAC,0BAAmB,EAAE,uBAAgB,EAAE,gCAAsB,CAAC,EAAE,CAAC;QACvF,IAAI,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,wDAA6B,CAAC,CAAC;IAC9D,CAAC;IAED,IAAI,CAAC,mCAAe,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAClD,IAAI,CAAC,cAAK,CAAC,CAAC,SAAS,CAAC,mCAAe,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { PromptVariantSet } from '@theia/ai-core';
2
+ export declare const terminalPrompts: PromptVariantSet[];
3
+ //# sourceMappingURL=ai-terminal-prompt-template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-terminal-prompt-template.d.ts","sourceRoot":"","sources":["../../src/browser/ai-terminal-prompt-template.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,eAAO,MAAM,eAAe,EAAE,gBAAgB,EAkE7C,CAAC"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/tslint/config */
3
+ // *****************************************************************************
4
+ // Copyright (C) 2025 EclipseSource GmbH and others.
5
+ //
6
+ // This file is licensed under the MIT License.
7
+ // See LICENSE-MIT.txt in the project root for license information.
8
+ // https://opensource.org/license/mit.
9
+ //
10
+ // SPDX-License-Identifier: MIT
11
+ // *****************************************************************************
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.terminalPrompts = void 0;
14
+ exports.terminalPrompts = [
15
+ {
16
+ id: 'terminal-system',
17
+ defaultVariant: {
18
+ id: 'terminal-system-default',
19
+ template: `{{!-- This prompt is licensed under the MIT License (https://opensource.org/license/mit).
20
+ Made improvements or adaptations to this prompt template? We’d love for you to share it with the community! Contribute back here:
21
+ https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
22
+ # Instructions
23
+ Generate one or more command suggestions based on the user's request, considering the shell being used,
24
+ the current working directory, and the recent terminal contents. Provide the best suggestion first,
25
+ followed by other relevant suggestions if the user asks for further options.
26
+
27
+ Parameters:
28
+ - user-request: The user's question or request.
29
+ - shell: The shell being used, e.g., /usr/bin/zsh.
30
+ - cwd: The current working directory.
31
+ - recent-terminal-contents: The last 0 to 50 recent lines visible in the terminal.
32
+
33
+ Return the result in the following JSON format:
34
+ {
35
+ "commands": [
36
+ "best_command_suggestion",
37
+ "next_best_command_suggestion",
38
+ "another_command_suggestion"
39
+ ]
40
+ }
41
+
42
+ ## Example
43
+ user-request: "How do I commit changes?"
44
+ shell: "/usr/bin/zsh"
45
+ cwd: "/home/user/project"
46
+ recent-terminal-contents:
47
+ git status
48
+ On branch main
49
+ Your branch is up to date with 'origin/main'.
50
+ nothing to commit, working tree clean
51
+
52
+ ## Expected JSON output
53
+ \`\`\`json
54
+ \{
55
+ "commands": [
56
+ "git commit",
57
+ "git commit --amend",
58
+ "git commit -a"
59
+ ]
60
+ }
61
+ \`\`\`
62
+ `
63
+ }
64
+ },
65
+ {
66
+ id: 'terminal-user',
67
+ defaultVariant: {
68
+ id: 'terminal-user-default',
69
+ template: `{{!-- This prompt is licensed under the MIT License (https://opensource.org/license/mit).
70
+ Made improvements or adaptations to this prompt template? We’d love for you to share it with the community! Contribute back here:
71
+ https://github.com/eclipse-theia/theia/discussions/new?category=prompt-template-contribution --}}
72
+ user-request: {{userRequest}}
73
+ shell: {{shell}}
74
+ cwd: {{cwd}}
75
+ recent-terminal-contents:
76
+ {{recentTerminalContents}}
77
+ `
78
+ }
79
+ }
80
+ ];
81
+ //# sourceMappingURL=ai-terminal-prompt-template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-terminal-prompt-template.js","sourceRoot":"","sources":["../../src/browser/ai-terminal-prompt-template.ts"],"names":[],"mappings":";AAAA,qDAAqD;AACrD,gFAAgF;AAChF,oDAAoD;AACpD,EAAE;AACF,+CAA+C;AAC/C,mEAAmE;AACnE,sCAAsC;AACtC,EAAE;AACF,+BAA+B;AAC/B,gFAAgF;;;AAInE,QAAA,eAAe,GAAuB;IACjD;QACE,EAAE,EAAE,iBAAiB;QACrB,cAAc,EAAE;YACd,EAAE,EAAE,yBAAyB;YAC7B,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Cf;SACI;KACF;IACD;QACE,EAAE,EAAE,eAAe;QACnB,cAAc,EAAE;YACd,EAAE,EAAE,uBAAuB;YAC3B,QAAQ,EAAE;;;;;;;;CAQf;SACI;KACF;CACF,CAAC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=package.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.spec.d.ts","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 EclipseSource GmbH and others.
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
+ /* note: this bogus test file is required so that
17
+ we are able to run mocha unit tests on this
18
+ package, without having any actual unit tests in it.
19
+ This way a coverage report will be generated,
20
+ showing 0% coverage, instead of no report.
21
+ This file can be removed once we have real unit
22
+ tests in place. */
23
+ describe('ai-terminal package', () => {
24
+ it('support code coverage statistics', () => true);
25
+ });
26
+ //# sourceMappingURL=package.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.spec.js","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,oDAAoD;AACpD,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;;;;;;qBAMqB;AAErB,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IAEjC,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;AACvD,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@theia/ai-terminal",
3
- "version": "1.67.0-next.56+d8f18cc386c",
3
+ "version": "1.67.0-next.59+3f14297ea",
4
4
  "description": "Theia - AI Terminal Extension",
5
5
  "dependencies": {
6
- "@theia/ai-chat": "1.67.0-next.56+d8f18cc386c",
7
- "@theia/ai-core": "1.67.0-next.56+d8f18cc386c",
8
- "@theia/core": "1.67.0-next.56+d8f18cc386c",
9
- "@theia/terminal": "1.67.0-next.56+d8f18cc386c",
6
+ "@theia/ai-chat": "1.67.0-next.59+3f14297ea",
7
+ "@theia/ai-core": "1.67.0-next.59+3f14297ea",
8
+ "@theia/core": "1.67.0-next.59+3f14297ea",
9
+ "@theia/terminal": "1.67.0-next.59+3f14297ea",
10
10
  "zod": "^3.23.8",
11
11
  "zod-to-json-schema": "^3.23.2"
12
12
  },
@@ -48,5 +48,5 @@
48
48
  "nyc": {
49
49
  "extends": "../../configs/nyc.json"
50
50
  },
51
- "gitHead": "d8f18cc386c45a736cd193d42eab02c8f64c6b10"
51
+ "gitHead": "3f14297ea2edcdb1fffd74afee0613e70b43e125"
52
52
  }