@theia/ai-copilot 1.68.0-next.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -0
- package/lib/browser/copilot-auth-dialog.d.ts +46 -0
- package/lib/browser/copilot-auth-dialog.d.ts.map +1 -0
- package/lib/browser/copilot-auth-dialog.js +246 -0
- package/lib/browser/copilot-auth-dialog.js.map +1 -0
- package/lib/browser/copilot-command-contribution.d.ts +22 -0
- package/lib/browser/copilot-command-contribution.d.ts.map +1 -0
- package/lib/browser/copilot-command-contribution.js +95 -0
- package/lib/browser/copilot-command-contribution.js.map +1 -0
- package/lib/browser/copilot-frontend-application-contribution.d.ts +15 -0
- package/lib/browser/copilot-frontend-application-contribution.d.ts.map +1 -0
- package/lib/browser/copilot-frontend-application-contribution.js +90 -0
- package/lib/browser/copilot-frontend-application-contribution.js.map +1 -0
- package/lib/browser/copilot-frontend-module.d.ts +5 -0
- package/lib/browser/copilot-frontend-module.d.ts.map +1 -0
- package/lib/browser/copilot-frontend-module.js +69 -0
- package/lib/browser/copilot-frontend-module.js.map +1 -0
- package/lib/browser/copilot-status-bar-contribution.d.ts +18 -0
- package/lib/browser/copilot-status-bar-contribution.d.ts.map +1 -0
- package/lib/browser/copilot-status-bar-contribution.js +92 -0
- package/lib/browser/copilot-status-bar-contribution.js.map +1 -0
- package/lib/browser/index.d.ts +5 -0
- package/lib/browser/index.d.ts.map +1 -0
- package/lib/browser/index.js +23 -0
- package/lib/browser/index.js.map +1 -0
- package/lib/common/copilot-auth-service.d.ts +77 -0
- package/lib/common/copilot-auth-service.d.ts.map +1 -0
- package/lib/common/copilot-auth-service.js +22 -0
- package/lib/common/copilot-auth-service.js.map +1 -0
- package/lib/common/copilot-language-models-manager.d.ts +41 -0
- package/lib/common/copilot-language-models-manager.d.ts.map +1 -0
- package/lib/common/copilot-language-models-manager.js +22 -0
- package/lib/common/copilot-language-models-manager.js.map +1 -0
- package/lib/common/copilot-preferences.d.ts +5 -0
- package/lib/common/copilot-preferences.d.ts.map +1 -0
- package/lib/common/copilot-preferences.js +52 -0
- package/lib/common/copilot-preferences.js.map +1 -0
- package/lib/common/index.d.ts +4 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +22 -0
- package/lib/common/index.js.map +1 -0
- package/lib/node/copilot-auth-service-impl.d.ts +28 -0
- package/lib/node/copilot-auth-service-impl.d.ts.map +1 -0
- package/lib/node/copilot-auth-service-impl.js +229 -0
- package/lib/node/copilot-auth-service-impl.js.map +1 -0
- package/lib/node/copilot-backend-module.d.ts +4 -0
- package/lib/node/copilot-backend-module.d.ts.map +1 -0
- package/lib/node/copilot-backend-module.js +39 -0
- package/lib/node/copilot-backend-module.js.map +1 -0
- package/lib/node/copilot-language-model.d.ts +33 -0
- package/lib/node/copilot-language-model.d.ts.map +1 -0
- package/lib/node/copilot-language-model.js +217 -0
- package/lib/node/copilot-language-model.js.map +1 -0
- package/lib/node/copilot-language-models-manager-impl.d.ts +23 -0
- package/lib/node/copilot-language-models-manager-impl.d.ts.map +1 -0
- package/lib/node/copilot-language-models-manager-impl.js +113 -0
- package/lib/node/copilot-language-models-manager-impl.js.map +1 -0
- package/lib/node/index.d.ts +4 -0
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +22 -0
- package/lib/node/index.js.map +1 -0
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.d.ts.map +1 -0
- package/lib/package.spec.js +26 -0
- package/lib/package.spec.js.map +1 -0
- package/package.json +52 -0
- package/src/browser/copilot-auth-dialog.tsx +326 -0
- package/src/browser/copilot-command-contribution.ts +93 -0
- package/src/browser/copilot-frontend-application-contribution.ts +89 -0
- package/src/browser/copilot-frontend-module.ts +86 -0
- package/src/browser/copilot-status-bar-contribution.ts +88 -0
- package/src/browser/index.ts +20 -0
- package/src/browser/style/index.css +167 -0
- package/src/common/copilot-auth-service.ts +103 -0
- package/src/common/copilot-language-models-manager.ts +59 -0
- package/src/common/copilot-preferences.ts +53 -0
- package/src/common/index.ts +19 -0
- package/src/node/copilot-auth-service-impl.ts +274 -0
- package/src/node/copilot-backend-module.ts +58 -0
- package/src/node/copilot-language-model.ts +262 -0
- package/src/node/copilot-language-models-manager-impl.ts +118 -0
- package/src/node/index.ts +19 -0
- package/src/package.spec.ts +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<div align='center'>
|
|
2
|
+
|
|
3
|
+
<br />
|
|
4
|
+
|
|
5
|
+
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
|
|
6
|
+
|
|
7
|
+
<h2>ECLIPSE THEIA - GITHUB COPILOT EXTENSION</h2>
|
|
8
|
+
|
|
9
|
+
<hr />
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
## Description
|
|
14
|
+
|
|
15
|
+
The `@theia/ai-copilot` extension integrates GitHub Copilot language models with Theia AI.
|
|
16
|
+
This allows users to authenticate with their GitHub Copilot subscription and use Copilot models (e.g., GPT-4o, Claude Sonnet) through Theia's AI features.
|
|
17
|
+
|
|
18
|
+
### Authentication
|
|
19
|
+
|
|
20
|
+
The extension uses GitHub's OAuth Device Flow for authentication:
|
|
21
|
+
|
|
22
|
+
1. Click the "Copilot" status bar item or run the **Copilot: Sign In** command
|
|
23
|
+
2. A dialog appears with a device code - click the link to open GitHub's device authorization page
|
|
24
|
+
3. Enter the code and authorize the application
|
|
25
|
+
4. The dialog updates to show "Authenticated" and the status bar reflects the signed-in state
|
|
26
|
+
|
|
27
|
+
Once authenticated, Copilot models become available in the AI Configuration for use with any Theia AI agent.
|
|
28
|
+
|
|
29
|
+
> **Note:** This extension requires an active GitHub Copilot subscription.
|
|
30
|
+
|
|
31
|
+
### Configuration
|
|
32
|
+
|
|
33
|
+
Available models can be configured via the `ai-features.copilot.models` preference:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"ai-features.copilot.models": [
|
|
38
|
+
"gpt-4o",
|
|
39
|
+
"claude-sonnet-4"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### GitHub Enterprise
|
|
45
|
+
|
|
46
|
+
For GitHub Enterprise users, configure the enterprise URL via the `ai-features.copilot.enterpriseUrl` preference:
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"ai-features.copilot.enterpriseUrl": "github.mycompany.com"
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Commands
|
|
55
|
+
|
|
56
|
+
- **Copilot: Sign In** - Initiates the OAuth device flow authentication
|
|
57
|
+
- **Copilot: Sign Out** - Signs out and clears stored credentials
|
|
58
|
+
|
|
59
|
+
## Additional Information
|
|
60
|
+
|
|
61
|
+
- [API documentation for `@theia/ai-copilot`](https://eclipse-theia.github.io/theia/docs/next/modules/_theia_ai-copilot.html)
|
|
62
|
+
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
63
|
+
- [Theia - Website](https://theia-ide.org/)
|
|
64
|
+
|
|
65
|
+
## License
|
|
66
|
+
|
|
67
|
+
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
68
|
+
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
69
|
+
|
|
70
|
+
## Trademark
|
|
71
|
+
|
|
72
|
+
"Theia" is a trademark of the Eclipse Foundation
|
|
73
|
+
<https://www.eclipse.org/theia>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as React from '@theia/core/shared/react';
|
|
2
|
+
import { DialogProps, DialogError } from '@theia/core/lib/browser/dialogs';
|
|
3
|
+
import { ReactDialog } from '@theia/core/lib/browser/dialogs/react-dialog';
|
|
4
|
+
import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
|
|
5
|
+
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
|
6
|
+
import { CommandService } from '@theia/core';
|
|
7
|
+
import { CopilotAuthService, DeviceCodeResponse } from '../common/copilot-auth-service';
|
|
8
|
+
type AuthDialogState = 'loading' | 'waiting' | 'polling' | 'success' | 'error';
|
|
9
|
+
export declare class CopilotAuthDialogProps extends DialogProps {
|
|
10
|
+
enterpriseUrl?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class CopilotAuthDialog extends ReactDialog<boolean> {
|
|
13
|
+
protected readonly props: CopilotAuthDialogProps;
|
|
14
|
+
protected readonly authService: CopilotAuthService;
|
|
15
|
+
protected readonly clipboardService: ClipboardService;
|
|
16
|
+
protected readonly windowService: WindowService;
|
|
17
|
+
protected readonly commandService: CommandService;
|
|
18
|
+
protected state: AuthDialogState;
|
|
19
|
+
protected deviceCodeResponse?: DeviceCodeResponse;
|
|
20
|
+
protected errorMessage?: string;
|
|
21
|
+
protected copied: boolean;
|
|
22
|
+
static readonly ID = "copilot-auth-dialog";
|
|
23
|
+
constructor(props: CopilotAuthDialogProps);
|
|
24
|
+
protected init(): void;
|
|
25
|
+
protected updateButtonStates(): void;
|
|
26
|
+
open(): Promise<boolean | undefined>;
|
|
27
|
+
update(): void;
|
|
28
|
+
protected initiateFlow(): Promise<void>;
|
|
29
|
+
protected accept(): Promise<void>;
|
|
30
|
+
get value(): boolean;
|
|
31
|
+
protected isValid(_value: boolean, _mode: DialogError): DialogError;
|
|
32
|
+
protected handleCopyCode: () => Promise<void>;
|
|
33
|
+
protected handleOpenUrl: () => void;
|
|
34
|
+
protected render(): React.ReactNode;
|
|
35
|
+
protected renderContent(): React.ReactNode;
|
|
36
|
+
protected renderLoading(): React.ReactNode;
|
|
37
|
+
protected renderWaiting(): React.ReactNode;
|
|
38
|
+
protected handleOpenTos: (e: React.MouseEvent) => void;
|
|
39
|
+
protected renderPolling(): React.ReactNode;
|
|
40
|
+
protected renderSuccess(): React.ReactNode;
|
|
41
|
+
protected handleOpenAIConfig: (e: React.MouseEvent) => void;
|
|
42
|
+
protected handleRetry: () => void;
|
|
43
|
+
protected renderError(): React.ReactNode;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=copilot-auth-dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-auth-dialog.d.ts","sourceRoot":"","sources":["../../src/browser/copilot-auth-dialog.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,KAAK,MAAM,0BAA0B,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,8CAA8C,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAC;AAC9E,OAAO,EAAE,cAAc,EAAO,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIxF,KAAK,eAAe,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAE/E,qBACa,sBAAuB,SAAQ,WAAW;IACnD,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,qBACa,iBAAkB,SAAQ,WAAW,CAAC,OAAO,CAAC;uBAsBS,KAAK,EAAE,sBAAsB;IAnB7F,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,kBAAkB,CAAC;IAGnD,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAGtD,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IAGhD,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAElD,SAAS,CAAC,KAAK,EAAE,eAAe,CAAa;IAC7C,SAAS,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;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************************
|
|
3
|
+
// Copyright (C) 2026 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.CopilotAuthDialog = exports.CopilotAuthDialogProps = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const React = require("@theia/core/shared/react");
|
|
21
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
22
|
+
const dialogs_1 = require("@theia/core/lib/browser/dialogs");
|
|
23
|
+
const react_dialog_1 = require("@theia/core/lib/browser/dialogs/react-dialog");
|
|
24
|
+
const clipboard_service_1 = require("@theia/core/lib/browser/clipboard-service");
|
|
25
|
+
const window_service_1 = require("@theia/core/lib/browser/window/window-service");
|
|
26
|
+
const core_1 = require("@theia/core");
|
|
27
|
+
const copilot_auth_service_1 = require("../common/copilot-auth-service");
|
|
28
|
+
const OPEN_AI_CONFIG_VIEW_COMMAND = 'aiConfiguration:open';
|
|
29
|
+
let CopilotAuthDialogProps = class CopilotAuthDialogProps extends dialogs_1.DialogProps {
|
|
30
|
+
};
|
|
31
|
+
exports.CopilotAuthDialogProps = CopilotAuthDialogProps;
|
|
32
|
+
exports.CopilotAuthDialogProps = CopilotAuthDialogProps = tslib_1.__decorate([
|
|
33
|
+
(0, inversify_1.injectable)()
|
|
34
|
+
], CopilotAuthDialogProps);
|
|
35
|
+
let CopilotAuthDialog = class CopilotAuthDialog extends react_dialog_1.ReactDialog {
|
|
36
|
+
static { this.ID = 'copilot-auth-dialog'; }
|
|
37
|
+
constructor(props) {
|
|
38
|
+
super(props);
|
|
39
|
+
this.props = props;
|
|
40
|
+
this.state = 'loading';
|
|
41
|
+
this.copied = false;
|
|
42
|
+
this.handleCopyCode = async () => {
|
|
43
|
+
if (this.deviceCodeResponse) {
|
|
44
|
+
await this.clipboardService.writeText(this.deviceCodeResponse.user_code);
|
|
45
|
+
this.copied = true;
|
|
46
|
+
this.update();
|
|
47
|
+
setTimeout(() => {
|
|
48
|
+
this.copied = false;
|
|
49
|
+
this.update();
|
|
50
|
+
}, 2000);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
this.handleOpenUrl = () => {
|
|
54
|
+
if (this.deviceCodeResponse) {
|
|
55
|
+
this.windowService.openNewWindow(this.deviceCodeResponse.verification_uri, { external: true });
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
this.handleOpenTos = (e) => {
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
this.windowService.openNewWindow('https://docs.github.com/en/site-policy/github-terms/github-terms-of-service', { external: true });
|
|
61
|
+
};
|
|
62
|
+
this.handleOpenAIConfig = (e) => {
|
|
63
|
+
e.preventDefault();
|
|
64
|
+
this.commandService.executeCommand(OPEN_AI_CONFIG_VIEW_COMMAND);
|
|
65
|
+
};
|
|
66
|
+
this.handleRetry = () => {
|
|
67
|
+
this.initiateFlow();
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
init() {
|
|
71
|
+
this.titleNode.textContent = core_1.nls.localize('theia/ai/copilot/auth/title', 'Sign in to GitHub Copilot');
|
|
72
|
+
this.appendAcceptButton(core_1.nls.localize('theia/ai/copilot/auth/authorize', 'I have authorized'));
|
|
73
|
+
this.appendCloseButton(core_1.nls.localizeByDefault('Cancel'));
|
|
74
|
+
}
|
|
75
|
+
updateButtonStates() {
|
|
76
|
+
const isPolling = this.state === 'polling';
|
|
77
|
+
const isSuccess = this.state === 'success';
|
|
78
|
+
if (this.acceptButton) {
|
|
79
|
+
this.acceptButton.disabled = isPolling || isSuccess;
|
|
80
|
+
if (isSuccess) {
|
|
81
|
+
this.acceptButton.style.display = 'none';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (this.closeButton) {
|
|
85
|
+
if (isSuccess) {
|
|
86
|
+
this.closeButton.textContent = core_1.nls.localizeByDefault('Close');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async open() {
|
|
91
|
+
this.initiateFlow();
|
|
92
|
+
return super.open();
|
|
93
|
+
}
|
|
94
|
+
update() {
|
|
95
|
+
super.update();
|
|
96
|
+
this.updateButtonStates();
|
|
97
|
+
}
|
|
98
|
+
async initiateFlow() {
|
|
99
|
+
try {
|
|
100
|
+
this.state = 'loading';
|
|
101
|
+
this.update();
|
|
102
|
+
this.deviceCodeResponse = await this.authService.initiateDeviceFlow(this.props.enterpriseUrl);
|
|
103
|
+
this.state = 'waiting';
|
|
104
|
+
this.update();
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
this.state = 'error';
|
|
108
|
+
this.errorMessage = error instanceof Error ? error.message : String(error);
|
|
109
|
+
this.update();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async accept() {
|
|
113
|
+
if (this.state !== 'waiting' || !this.deviceCodeResponse) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
this.state = 'polling';
|
|
117
|
+
this.update();
|
|
118
|
+
try {
|
|
119
|
+
const success = await this.authService.pollForToken(this.deviceCodeResponse.device_code, this.deviceCodeResponse.interval, this.props.enterpriseUrl);
|
|
120
|
+
if (success) {
|
|
121
|
+
this.state = 'success';
|
|
122
|
+
this.update();
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
this.state = 'error';
|
|
126
|
+
this.errorMessage = core_1.nls.localize('theia/ai/copilot/auth/expired', 'Authorization expired or was denied. Please try again.');
|
|
127
|
+
this.update();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
this.state = 'error';
|
|
132
|
+
this.errorMessage = error instanceof Error ? error.message : String(error);
|
|
133
|
+
this.update();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
get value() {
|
|
137
|
+
return this.state === 'success';
|
|
138
|
+
}
|
|
139
|
+
isValid(_value, _mode) {
|
|
140
|
+
if (this.state === 'error') {
|
|
141
|
+
return this.errorMessage ?? 'An error occurred';
|
|
142
|
+
}
|
|
143
|
+
return '';
|
|
144
|
+
}
|
|
145
|
+
render() {
|
|
146
|
+
return (React.createElement("div", { className: "theia-copilot-auth-dialog-content" }, this.renderContent()));
|
|
147
|
+
}
|
|
148
|
+
renderContent() {
|
|
149
|
+
switch (this.state) {
|
|
150
|
+
case 'loading':
|
|
151
|
+
return this.renderLoading();
|
|
152
|
+
case 'waiting':
|
|
153
|
+
return this.renderWaiting();
|
|
154
|
+
case 'polling':
|
|
155
|
+
return this.renderPolling();
|
|
156
|
+
case 'success':
|
|
157
|
+
return this.renderSuccess();
|
|
158
|
+
case 'error':
|
|
159
|
+
return this.renderError();
|
|
160
|
+
default:
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
renderLoading() {
|
|
165
|
+
return (React.createElement("div", { className: "theia-copilot-auth-state" },
|
|
166
|
+
React.createElement("div", { className: "theia-spin" },
|
|
167
|
+
React.createElement("span", { className: "codicon codicon-loading" })),
|
|
168
|
+
React.createElement("p", null, core_1.nls.localize('theia/ai/copilot/auth/initiating', 'Initiating authentication...'))));
|
|
169
|
+
}
|
|
170
|
+
renderWaiting() {
|
|
171
|
+
const response = this.deviceCodeResponse;
|
|
172
|
+
return (React.createElement("div", { className: "theia-copilot-auth-waiting" },
|
|
173
|
+
React.createElement("p", { className: "theia-copilot-auth-instructions" }, core_1.nls.localize('theia/ai/copilot/auth/instructions', 'To authorize Theia to use GitHub Copilot, visit the URL below and enter the code:')),
|
|
174
|
+
React.createElement("div", { className: "theia-copilot-auth-code-section" },
|
|
175
|
+
React.createElement("div", { className: "theia-copilot-auth-code-display" },
|
|
176
|
+
React.createElement("span", { className: "theia-copilot-auth-code" }, response.user_code),
|
|
177
|
+
React.createElement("button", { className: "theia-button secondary theia-copilot-copy-button", onClick: this.handleCopyCode, title: this.copied
|
|
178
|
+
? core_1.nls.localize('theia/ai/copilot/auth/copied', 'Copied!')
|
|
179
|
+
: core_1.nls.localize('theia/ai/copilot/auth/copyCode', 'Copy code') },
|
|
180
|
+
React.createElement("span", { className: `codicon ${this.copied ? 'codicon-check' : 'codicon-copy'}` }),
|
|
181
|
+
core_1.nls.localizeByDefault('Copy')))),
|
|
182
|
+
React.createElement("div", { className: "theia-copilot-auth-url-section" },
|
|
183
|
+
React.createElement("button", { className: "theia-button theia-copilot-open-url-button", onClick: this.handleOpenUrl },
|
|
184
|
+
React.createElement("span", { className: "codicon codicon-link-external" }),
|
|
185
|
+
core_1.nls.localize('theia/ai/copilot/auth/openGitHub', 'Open GitHub')),
|
|
186
|
+
React.createElement("span", { className: "theia-copilot-auth-url" }, response.verification_uri)),
|
|
187
|
+
React.createElement("p", { className: "theia-copilot-auth-hint" }, core_1.nls.localize('theia/ai/copilot/auth/hint', 'After entering the code and authorizing, click "I have authorized" below.')),
|
|
188
|
+
React.createElement("div", { className: "theia-copilot-auth-privacy" },
|
|
189
|
+
React.createElement("p", { className: "theia-copilot-auth-privacy-text" }, core_1.nls.localize('theia/ai/copilot/auth/privacy', 'Theia is an open-source project. We only request access to your GitHub username ' +
|
|
190
|
+
'to connect to GitHub Copilot services — no other data is accessed or stored.')),
|
|
191
|
+
React.createElement("p", { className: "theia-copilot-auth-tos-text" },
|
|
192
|
+
core_1.nls.localize('theia/ai/copilot/auth/tos', 'By signing in, you agree to the '),
|
|
193
|
+
React.createElement("a", { href: "https://docs.github.com/en/site-policy/github-terms/github-terms-of-service", target: "_blank", rel: "noopener noreferrer", onClick: this.handleOpenTos }, core_1.nls.localize('theia/ai/copilot/auth/tosLink', 'GitHub Terms of Service')),
|
|
194
|
+
"."))));
|
|
195
|
+
}
|
|
196
|
+
renderPolling() {
|
|
197
|
+
return (React.createElement("div", { className: "theia-copilot-auth-state" },
|
|
198
|
+
React.createElement("div", { className: "theia-spin" },
|
|
199
|
+
React.createElement("span", { className: "codicon codicon-loading" })),
|
|
200
|
+
React.createElement("p", null, core_1.nls.localize('theia/ai/copilot/auth/verifying', 'Verifying authorization...'))));
|
|
201
|
+
}
|
|
202
|
+
renderSuccess() {
|
|
203
|
+
return (React.createElement("div", { className: "theia-copilot-auth-state theia-copilot-auth-success" },
|
|
204
|
+
React.createElement("span", { className: "codicon codicon-check" }),
|
|
205
|
+
React.createElement("p", null, core_1.nls.localize('theia/ai/copilot/auth/success', 'Successfully signed in to GitHub Copilot!')),
|
|
206
|
+
React.createElement("p", { className: "theia-copilot-auth-success-hint" },
|
|
207
|
+
core_1.nls.localize('theia/ai/copilot/auth/successHint', 'If your GitHub account has access to Copilot, you can now configure Copilot language models in the '),
|
|
208
|
+
React.createElement("a", { href: "#", onClick: this.handleOpenAIConfig }, core_1.nls.localize('theia/ai/copilot/auth/aiConfiguration', 'AI Configuration')),
|
|
209
|
+
".")));
|
|
210
|
+
}
|
|
211
|
+
renderError() {
|
|
212
|
+
return (React.createElement("div", { className: "theia-copilot-auth-state theia-copilot-auth-error" },
|
|
213
|
+
React.createElement("span", { className: "codicon codicon-error" }),
|
|
214
|
+
React.createElement("p", null, this.errorMessage),
|
|
215
|
+
React.createElement("button", { className: "theia-button", onClick: this.handleRetry }, core_1.nls.localizeByDefault('Try Again'))));
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
exports.CopilotAuthDialog = CopilotAuthDialog;
|
|
219
|
+
tslib_1.__decorate([
|
|
220
|
+
(0, inversify_1.inject)(copilot_auth_service_1.CopilotAuthService),
|
|
221
|
+
tslib_1.__metadata("design:type", Object)
|
|
222
|
+
], CopilotAuthDialog.prototype, "authService", void 0);
|
|
223
|
+
tslib_1.__decorate([
|
|
224
|
+
(0, inversify_1.inject)(clipboard_service_1.ClipboardService),
|
|
225
|
+
tslib_1.__metadata("design:type", Object)
|
|
226
|
+
], CopilotAuthDialog.prototype, "clipboardService", void 0);
|
|
227
|
+
tslib_1.__decorate([
|
|
228
|
+
(0, inversify_1.inject)(window_service_1.WindowService),
|
|
229
|
+
tslib_1.__metadata("design:type", Object)
|
|
230
|
+
], CopilotAuthDialog.prototype, "windowService", void 0);
|
|
231
|
+
tslib_1.__decorate([
|
|
232
|
+
(0, inversify_1.inject)(core_1.CommandService),
|
|
233
|
+
tslib_1.__metadata("design:type", Object)
|
|
234
|
+
], CopilotAuthDialog.prototype, "commandService", void 0);
|
|
235
|
+
tslib_1.__decorate([
|
|
236
|
+
(0, inversify_1.postConstruct)(),
|
|
237
|
+
tslib_1.__metadata("design:type", Function),
|
|
238
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
239
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
240
|
+
], CopilotAuthDialog.prototype, "init", null);
|
|
241
|
+
exports.CopilotAuthDialog = CopilotAuthDialog = tslib_1.__decorate([
|
|
242
|
+
(0, inversify_1.injectable)(),
|
|
243
|
+
tslib_1.__param(0, (0, inversify_1.inject)(CopilotAuthDialogProps)),
|
|
244
|
+
tslib_1.__metadata("design:paramtypes", [CopilotAuthDialogProps])
|
|
245
|
+
], CopilotAuthDialog);
|
|
246
|
+
//# sourceMappingURL=copilot-auth-dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-auth-dialog.js","sourceRoot":"","sources":["../../src/browser/copilot-auth-dialog.tsx"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,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andRegistry, Disposable, DisposableCollection, PreferenceService } from '@theia/core';
|
|
2
|
+
import { CopilotAuthService, CopilotAuthState } from '../common/copilot-auth-service';
|
|
3
|
+
import { CopilotAuthDialog, CopilotAuthDialogProps } from './copilot-auth-dialog';
|
|
4
|
+
export declare namespace CopilotCommands {
|
|
5
|
+
const SIGN_IN: Command;
|
|
6
|
+
const SIGN_OUT: Command;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Command contribution for GitHub Copilot authentication commands.
|
|
10
|
+
*/
|
|
11
|
+
export declare class CopilotCommandContribution implements CommandContribution, Disposable {
|
|
12
|
+
protected readonly authService: CopilotAuthService;
|
|
13
|
+
protected readonly preferenceService: PreferenceService;
|
|
14
|
+
protected readonly dialogProps: CopilotAuthDialogProps;
|
|
15
|
+
protected readonly authDialog: CopilotAuthDialog;
|
|
16
|
+
protected authState: CopilotAuthState;
|
|
17
|
+
protected readonly toDispose: DisposableCollection;
|
|
18
|
+
protected init(): void;
|
|
19
|
+
dispose(): void;
|
|
20
|
+
registerCommands(registry: CommandRegistry): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=copilot-command-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-command-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/copilot-command-contribution.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,UAAU,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACjI,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAGlF,yBAAiB,eAAe,CAAC;IACtB,MAAM,OAAO,EAAE,OAIrB,CAAC;IAEK,MAAM,QAAQ,EAAE,OAItB,CAAC;CACL;AAED;;GAEG;AACH,qBACa,0BAA2B,YAAW,mBAAmB,EAAE,UAAU;IAG9E,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,kBAAkB,CAAC;IAGnD,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAGxD,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,sBAAsB,CAAC;IAGvD,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;IAEjD,SAAS,CAAC,SAAS,EAAE,gBAAgB,CAA8B;IACnE,SAAS,CAAC,QAAQ,CAAC,SAAS,uBAA8B;IAG1D,SAAS,CAAC,IAAI,IAAI,IAAI;IAUtB,OAAO,IAAI,IAAI;IAIf,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;CAoBpD"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 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.CopilotCommandContribution = exports.CopilotCommands = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
+
const core_1 = require("@theia/core");
|
|
22
|
+
const copilot_auth_service_1 = require("../common/copilot-auth-service");
|
|
23
|
+
const copilot_auth_dialog_1 = require("./copilot-auth-dialog");
|
|
24
|
+
const copilot_preferences_1 = require("../common/copilot-preferences");
|
|
25
|
+
var CopilotCommands;
|
|
26
|
+
(function (CopilotCommands) {
|
|
27
|
+
CopilotCommands.SIGN_IN = core_1.Command.toLocalizedCommand({ id: 'copilot.signIn', label: 'Sign in to GitHub Copilot', category: 'Copilot' }, 'theia/ai/copilot/commands/signIn', 'theia/ai/copilot/category');
|
|
28
|
+
CopilotCommands.SIGN_OUT = core_1.Command.toLocalizedCommand({ id: 'copilot.signOut', label: 'Sign out of GitHub Copilot', category: 'Copilot' }, 'theia/ai/copilot/commands/signOut', 'theia/ai/copilot/category');
|
|
29
|
+
})(CopilotCommands || (exports.CopilotCommands = CopilotCommands = {}));
|
|
30
|
+
/**
|
|
31
|
+
* Command contribution for GitHub Copilot authentication commands.
|
|
32
|
+
*/
|
|
33
|
+
let CopilotCommandContribution = class CopilotCommandContribution {
|
|
34
|
+
constructor() {
|
|
35
|
+
this.authState = { isAuthenticated: false };
|
|
36
|
+
this.toDispose = new core_1.DisposableCollection();
|
|
37
|
+
}
|
|
38
|
+
init() {
|
|
39
|
+
this.authService.getAuthState().then(state => {
|
|
40
|
+
this.authState = state;
|
|
41
|
+
});
|
|
42
|
+
this.toDispose.push(this.authService.onAuthStateChanged(state => {
|
|
43
|
+
this.authState = state;
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
dispose() {
|
|
47
|
+
this.toDispose.dispose();
|
|
48
|
+
}
|
|
49
|
+
registerCommands(registry) {
|
|
50
|
+
registry.registerCommand(CopilotCommands.SIGN_IN, {
|
|
51
|
+
execute: async () => {
|
|
52
|
+
const enterpriseUrl = this.preferenceService.get(copilot_preferences_1.COPILOT_ENTERPRISE_URL_PREF);
|
|
53
|
+
this.dialogProps.enterpriseUrl = enterpriseUrl || undefined;
|
|
54
|
+
const result = await this.authDialog.open();
|
|
55
|
+
if (result) {
|
|
56
|
+
this.authState = await this.authService.getAuthState();
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
isEnabled: () => !this.authState.isAuthenticated
|
|
60
|
+
});
|
|
61
|
+
registry.registerCommand(CopilotCommands.SIGN_OUT, {
|
|
62
|
+
execute: async () => {
|
|
63
|
+
await this.authService.signOut();
|
|
64
|
+
},
|
|
65
|
+
isEnabled: () => this.authState.isAuthenticated
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
exports.CopilotCommandContribution = CopilotCommandContribution;
|
|
70
|
+
tslib_1.__decorate([
|
|
71
|
+
(0, inversify_1.inject)(copilot_auth_service_1.CopilotAuthService),
|
|
72
|
+
tslib_1.__metadata("design:type", Object)
|
|
73
|
+
], CopilotCommandContribution.prototype, "authService", void 0);
|
|
74
|
+
tslib_1.__decorate([
|
|
75
|
+
(0, inversify_1.inject)(core_1.PreferenceService),
|
|
76
|
+
tslib_1.__metadata("design:type", Object)
|
|
77
|
+
], CopilotCommandContribution.prototype, "preferenceService", void 0);
|
|
78
|
+
tslib_1.__decorate([
|
|
79
|
+
(0, inversify_1.inject)(copilot_auth_dialog_1.CopilotAuthDialogProps),
|
|
80
|
+
tslib_1.__metadata("design:type", copilot_auth_dialog_1.CopilotAuthDialogProps)
|
|
81
|
+
], CopilotCommandContribution.prototype, "dialogProps", void 0);
|
|
82
|
+
tslib_1.__decorate([
|
|
83
|
+
(0, inversify_1.inject)(copilot_auth_dialog_1.CopilotAuthDialog),
|
|
84
|
+
tslib_1.__metadata("design:type", copilot_auth_dialog_1.CopilotAuthDialog)
|
|
85
|
+
], CopilotCommandContribution.prototype, "authDialog", void 0);
|
|
86
|
+
tslib_1.__decorate([
|
|
87
|
+
(0, inversify_1.postConstruct)(),
|
|
88
|
+
tslib_1.__metadata("design:type", Function),
|
|
89
|
+
tslib_1.__metadata("design:paramtypes", []),
|
|
90
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
91
|
+
], CopilotCommandContribution.prototype, "init", null);
|
|
92
|
+
exports.CopilotCommandContribution = CopilotCommandContribution = tslib_1.__decorate([
|
|
93
|
+
(0, inversify_1.injectable)()
|
|
94
|
+
], CopilotCommandContribution);
|
|
95
|
+
//# sourceMappingURL=copilot-command-contribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-command-contribution.js","sourceRoot":"","sources":["../../src/browser/copilot-command-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,4DAAiF;AACjF,sCAAiI;AACjI,yEAAsF;AACtF,+DAAkF;AAClF,uEAA4E;AAE5E,IAAiB,eAAe,CAY/B;AAZD,WAAiB,eAAe;IACf,uBAAO,GAAY,cAAO,CAAC,kBAAkB,CACtD,EAAE,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,2BAA2B,EAAE,QAAQ,EAAE,SAAS,EAAE,EACjF,kCAAkC,EAClC,2BAA2B,CAC9B,CAAC;IAEW,wBAAQ,GAAY,cAAO,CAAC,kBAAkB,CACvD,EAAE,EAAE,EAAE,iBAAiB,EAAE,KAAK,EAAE,4BAA4B,EAAE,QAAQ,EAAE,SAAS,EAAE,EACnF,mCAAmC,EACnC,2BAA2B,CAC9B,CAAC;AACN,CAAC,EAZgB,eAAe,+BAAf,eAAe,QAY/B;AAED;;GAEG;AAEI,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAAhC;QAcO,cAAS,GAAqB,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC;QAChD,cAAS,GAAG,IAAI,2BAAoB,EAAE,CAAC;IAqC9D,CAAC;IAlCa,IAAI;QACV,IAA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Y,gEAA0B;AAGhB;IADlB,IAAA,kBAAM,EAAC,yCAAkB,CAAC;;+DACwB;AAGhC;IADlB,IAAA,kBAAM,EAAC,wBAAiB,CAAC;;qEAC8B;AAGrC;IADlB,IAAA,kBAAM,EAAC,4CAAsB,CAAC;sCACC,4CAAsB;+DAAC;AAGpC;IADlB,IAAA,kBAAM,EAAC,uCAAiB,CAAC;sCACK,uCAAiB;8DAAC;AAMvC;IADT,IAAA,yBAAa,GAAE;;;;sDASf;qCA1BQ,0BAA0B;IADtC,IAAA,sBAAU,GAAE;GACA,0BAA0B,CAoDtC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PreferenceService } from '@theia/core';
|
|
2
|
+
import { FrontendApplicationContribution } from '@theia/core/lib/browser';
|
|
3
|
+
import { CopilotLanguageModelsManager, CopilotModelDescription } from '../common';
|
|
4
|
+
import { AICorePreferences } from '@theia/ai-core/lib/common/ai-core-preferences';
|
|
5
|
+
export declare class CopilotFrontendApplicationContribution implements FrontendApplicationContribution {
|
|
6
|
+
protected readonly preferenceService: PreferenceService;
|
|
7
|
+
protected readonly manager: CopilotLanguageModelsManager;
|
|
8
|
+
protected readonly aiCorePreferences: AICorePreferences;
|
|
9
|
+
protected prevModels: string[];
|
|
10
|
+
onStart(): void;
|
|
11
|
+
protected handleModelChanges(newModels: string[]): void;
|
|
12
|
+
protected updateAllModels(): void;
|
|
13
|
+
protected createCopilotModelDescription(modelId: string): CopilotModelDescription;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=copilot-frontend-application-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-frontend-application-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/copilot-frontend-application-contribution.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,4BAA4B,EAAE,uBAAuB,EAAuB,MAAM,WAAW,CAAC;AAEvG,OAAO,EAAE,iBAAiB,EAA+B,MAAM,+CAA+C,CAAC;AAE/G,qBACa,sCAAuC,YAAW,+BAA+B;IAG1F,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAGxD,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,4BAA4B,CAAC;IAGzD,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IAExD,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,CAAM;IAEpC,OAAO,IAAI,IAAI;IAsBf,SAAS,CAAC,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI;IAYvD,SAAS,CAAC,eAAe,IAAI,IAAI;IAKjC,SAAS,CAAC,6BAA6B,CAAC,OAAO,EAAE,MAAM,GAAG,uBAAuB;CAYpF"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2026 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.CopilotFrontendApplicationContribution = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
21
|
+
const core_1 = require("@theia/core");
|
|
22
|
+
const common_1 = require("../common");
|
|
23
|
+
const copilot_preferences_1 = require("../common/copilot-preferences");
|
|
24
|
+
const ai_core_preferences_1 = require("@theia/ai-core/lib/common/ai-core-preferences");
|
|
25
|
+
let CopilotFrontendApplicationContribution = class CopilotFrontendApplicationContribution {
|
|
26
|
+
constructor() {
|
|
27
|
+
this.prevModels = [];
|
|
28
|
+
}
|
|
29
|
+
onStart() {
|
|
30
|
+
this.preferenceService.ready.then(() => {
|
|
31
|
+
const models = this.preferenceService.get(copilot_preferences_1.COPILOT_MODELS_PREF, []);
|
|
32
|
+
this.manager.createOrUpdateLanguageModels(...models.map((modelId) => this.createCopilotModelDescription(modelId)));
|
|
33
|
+
this.prevModels = [...models];
|
|
34
|
+
this.preferenceService.onPreferenceChanged(event => {
|
|
35
|
+
if (event.preferenceName === copilot_preferences_1.COPILOT_MODELS_PREF) {
|
|
36
|
+
this.handleModelChanges(this.preferenceService.get(copilot_preferences_1.COPILOT_MODELS_PREF, []));
|
|
37
|
+
}
|
|
38
|
+
else if (event.preferenceName === copilot_preferences_1.COPILOT_ENTERPRISE_URL_PREF) {
|
|
39
|
+
this.manager.refreshModelsStatus();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
this.aiCorePreferences.onPreferenceChanged(event => {
|
|
43
|
+
if (event.preferenceName === ai_core_preferences_1.PREFERENCE_NAME_MAX_RETRIES) {
|
|
44
|
+
this.updateAllModels();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
handleModelChanges(newModels) {
|
|
50
|
+
const oldModels = new Set(this.prevModels);
|
|
51
|
+
const updatedModels = new Set(newModels);
|
|
52
|
+
const modelsToRemove = [...oldModels].filter(model => !updatedModels.has(model));
|
|
53
|
+
const modelsToAdd = [...updatedModels].filter(model => !oldModels.has(model));
|
|
54
|
+
this.manager.removeLanguageModels(...modelsToRemove.map(model => `${common_1.COPILOT_PROVIDER_ID}/${model}`));
|
|
55
|
+
this.manager.createOrUpdateLanguageModels(...modelsToAdd.map((modelId) => this.createCopilotModelDescription(modelId)));
|
|
56
|
+
this.prevModels = newModels;
|
|
57
|
+
}
|
|
58
|
+
updateAllModels() {
|
|
59
|
+
const models = this.preferenceService.get(copilot_preferences_1.COPILOT_MODELS_PREF, []);
|
|
60
|
+
this.manager.createOrUpdateLanguageModels(...models.map((modelId) => this.createCopilotModelDescription(modelId)));
|
|
61
|
+
}
|
|
62
|
+
createCopilotModelDescription(modelId) {
|
|
63
|
+
const id = `${common_1.COPILOT_PROVIDER_ID}/${modelId}`;
|
|
64
|
+
const maxRetries = this.aiCorePreferences.get(ai_core_preferences_1.PREFERENCE_NAME_MAX_RETRIES) ?? 3;
|
|
65
|
+
return {
|
|
66
|
+
id,
|
|
67
|
+
model: modelId,
|
|
68
|
+
enableStreaming: true,
|
|
69
|
+
supportsStructuredOutput: true,
|
|
70
|
+
maxRetries
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
exports.CopilotFrontendApplicationContribution = CopilotFrontendApplicationContribution;
|
|
75
|
+
tslib_1.__decorate([
|
|
76
|
+
(0, inversify_1.inject)(core_1.PreferenceService),
|
|
77
|
+
tslib_1.__metadata("design:type", Object)
|
|
78
|
+
], CopilotFrontendApplicationContribution.prototype, "preferenceService", void 0);
|
|
79
|
+
tslib_1.__decorate([
|
|
80
|
+
(0, inversify_1.inject)(common_1.CopilotLanguageModelsManager),
|
|
81
|
+
tslib_1.__metadata("design:type", Object)
|
|
82
|
+
], CopilotFrontendApplicationContribution.prototype, "manager", void 0);
|
|
83
|
+
tslib_1.__decorate([
|
|
84
|
+
(0, inversify_1.inject)(ai_core_preferences_1.AICorePreferences),
|
|
85
|
+
tslib_1.__metadata("design:type", Object)
|
|
86
|
+
], CopilotFrontendApplicationContribution.prototype, "aiCorePreferences", void 0);
|
|
87
|
+
exports.CopilotFrontendApplicationContribution = CopilotFrontendApplicationContribution = tslib_1.__decorate([
|
|
88
|
+
(0, inversify_1.injectable)()
|
|
89
|
+
], CopilotFrontendApplicationContribution);
|
|
90
|
+
//# sourceMappingURL=copilot-frontend-application-contribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-frontend-application-contribution.js","sourceRoot":"","sources":["../../src/browser/copilot-frontend-application-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,4DAAkE;AAClE,sCAAgD;AAEhD,sCAAuG;AACvG,uEAAiG;AACjG,uFAA+G;AAGxG,IAAM,sCAAsC,GAA5C,MAAM,sCAAsC;IAA5C;QAWO,eAAU,GAAa,EAAE,CAAC;IAqDxC,CAAC;IAnDG,OAAO;QACH,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE;YACnC,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAW,yCAAmB,EAAE,EAAE,CAAC,CAAC;YAC7E,IAAI,CAAC,OAAO,CAAC,4BAA4B,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,OAAe,EAAE,EAAE,CAAC,IAAI,CAAC,6BAA6B,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAC3H,IAAI,CAAC,UAAU,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;YAE9B,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE;gBAC/C,IAAI,KAAK,CAAC,cAAc,KAAK,yCAAmB,EAAE,CAAC;oBAC/C,IAAI,CA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