deploy: current vibn theia state
Made-with: Cursor
This commit is contained in:
103
packages/ai-copilot/src/common/copilot-auth-service.ts
Normal file
103
packages/ai-copilot/src/common/copilot-auth-service.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
// *****************************************************************************
|
||||
// Copyright (C) 2026 EclipseSource GmbH.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// http://www.eclipse.org/legal/epl-2.0.
|
||||
//
|
||||
// This Source Code may also be made available under the following Secondary
|
||||
// Licenses when the conditions for such availability set forth in the Eclipse
|
||||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
||||
// with the GNU Classpath Exception which is available at
|
||||
// https://www.gnu.org/software/classpath/license.html.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
||||
// *****************************************************************************
|
||||
|
||||
import { Event } from '@theia/core';
|
||||
|
||||
export const COPILOT_AUTH_SERVICE_PATH = '/services/copilot/auth';
|
||||
export const CopilotAuthService = Symbol('CopilotAuthService');
|
||||
export const CopilotAuthServiceClient = Symbol('CopilotAuthServiceClient');
|
||||
|
||||
/**
|
||||
* Response from GitHub's device code endpoint.
|
||||
*/
|
||||
export interface DeviceCodeResponse {
|
||||
/** URL where user should enter the code (e.g., https://github.com/login/device) */
|
||||
verification_uri: string;
|
||||
/** Code to display to the user (e.g., XXXX-XXXX) */
|
||||
user_code: string;
|
||||
/** Device code used for polling */
|
||||
device_code: string;
|
||||
/** Polling interval in seconds */
|
||||
interval: number;
|
||||
/** Expiration time in seconds */
|
||||
expires_in: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Current authentication state.
|
||||
*/
|
||||
export interface CopilotAuthState {
|
||||
/** Whether the user is authenticated */
|
||||
isAuthenticated: boolean;
|
||||
/** GitHub username if authenticated */
|
||||
accountLabel?: string;
|
||||
/** GitHub Enterprise URL if using enterprise */
|
||||
enterpriseUrl?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Client interface for receiving auth state change notifications.
|
||||
*/
|
||||
export interface CopilotAuthServiceClient {
|
||||
onAuthStateChanged(state: CopilotAuthState): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Service for handling GitHub Copilot OAuth Device Flow authentication.
|
||||
*/
|
||||
export interface CopilotAuthService {
|
||||
/**
|
||||
* Initiates the OAuth Device Flow.
|
||||
* Returns device code information for the UI to display.
|
||||
* @param enterpriseUrl Optional GitHub Enterprise domain
|
||||
*/
|
||||
initiateDeviceFlow(enterpriseUrl?: string): Promise<DeviceCodeResponse>;
|
||||
|
||||
/**
|
||||
* Polls for the access token after user authorizes.
|
||||
* @param deviceCode The device code from initiateDeviceFlow
|
||||
* @param interval Polling interval in seconds
|
||||
* @param enterpriseUrl Optional GitHub Enterprise domain
|
||||
* @returns true if authentication succeeded, false if expired/denied
|
||||
*/
|
||||
pollForToken(deviceCode: string, interval: number, enterpriseUrl?: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Get the current authentication state.
|
||||
*/
|
||||
getAuthState(): Promise<CopilotAuthState>;
|
||||
|
||||
/**
|
||||
* Get the access token for API calls.
|
||||
* @returns The access token or undefined if not authenticated
|
||||
*/
|
||||
getAccessToken(): Promise<string | undefined>;
|
||||
|
||||
/**
|
||||
* Sign out and clear stored credentials.
|
||||
*/
|
||||
signOut(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Set the client to receive auth state change notifications.
|
||||
*/
|
||||
setClient(client: CopilotAuthServiceClient | undefined): void;
|
||||
|
||||
/**
|
||||
* Event fired when authentication state changes.
|
||||
*/
|
||||
readonly onAuthStateChanged: Event<CopilotAuthState>;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
// *****************************************************************************
|
||||
// Copyright (C) 2026 EclipseSource GmbH.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// http://www.eclipse.org/legal/epl-2.0.
|
||||
//
|
||||
// This Source Code may also be made available under the following Secondary
|
||||
// Licenses when the conditions for such availability set forth in the Eclipse
|
||||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
||||
// with the GNU Classpath Exception which is available at
|
||||
// https://www.gnu.org/software/classpath/license.html.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
||||
// *****************************************************************************
|
||||
|
||||
export const COPILOT_LANGUAGE_MODELS_MANAGER_PATH = '/services/copilot/language-model-manager';
|
||||
export const CopilotLanguageModelsManager = Symbol('CopilotLanguageModelsManager');
|
||||
|
||||
export const COPILOT_PROVIDER_ID = 'copilot';
|
||||
|
||||
export interface CopilotModelDescription {
|
||||
/**
|
||||
* The identifier of the model which will be shown in the UI.
|
||||
* Format: copilot/{modelName}
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* The model ID as used by the Copilot API (e.g., 'gpt-4o', 'claude-3.5-sonnet').
|
||||
*/
|
||||
model: string;
|
||||
/**
|
||||
* Indicate whether the streaming API shall be used.
|
||||
*/
|
||||
enableStreaming: boolean;
|
||||
/**
|
||||
* Flag to configure whether the model supports structured output.
|
||||
*/
|
||||
supportsStructuredOutput: boolean;
|
||||
/**
|
||||
* Maximum number of retry attempts when a request fails.
|
||||
*/
|
||||
maxRetries: number;
|
||||
}
|
||||
|
||||
export interface CopilotLanguageModelsManager {
|
||||
/**
|
||||
* Create or update language models in the registry.
|
||||
*/
|
||||
createOrUpdateLanguageModels(...models: CopilotModelDescription[]): Promise<void>;
|
||||
/**
|
||||
* Remove language models from the registry.
|
||||
*/
|
||||
removeLanguageModels(...modelIds: string[]): void;
|
||||
/**
|
||||
* Refresh the status of all Copilot models (e.g., after authentication state changes).
|
||||
*/
|
||||
refreshModelsStatus(): Promise<void>;
|
||||
}
|
||||
53
packages/ai-copilot/src/common/copilot-preferences.ts
Normal file
53
packages/ai-copilot/src/common/copilot-preferences.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
// *****************************************************************************
|
||||
// Copyright (C) 2026 EclipseSource GmbH.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// http://www.eclipse.org/legal/epl-2.0.
|
||||
//
|
||||
// This Source Code may also be made available under the following Secondary
|
||||
// Licenses when the conditions for such availability set forth in the Eclipse
|
||||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
||||
// with the GNU Classpath Exception which is available at
|
||||
// https://www.gnu.org/software/classpath/license.html.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
||||
// *****************************************************************************
|
||||
|
||||
import { AI_CORE_PREFERENCES_TITLE } from '@theia/ai-core/lib/common/ai-core-preferences';
|
||||
import { nls, PreferenceSchema } from '@theia/core';
|
||||
|
||||
export const COPILOT_MODELS_PREF = 'ai-features.copilot.models';
|
||||
export const COPILOT_ENTERPRISE_URL_PREF = 'ai-features.copilot.enterpriseUrl';
|
||||
|
||||
export const CopilotPreferencesSchema: PreferenceSchema = {
|
||||
properties: {
|
||||
[COPILOT_MODELS_PREF]: {
|
||||
type: 'array',
|
||||
description: nls.localize('theia/ai/copilot/models/description',
|
||||
'GitHub Copilot models to use. Available models depend on your Copilot subscription.'),
|
||||
title: AI_CORE_PREFERENCES_TITLE,
|
||||
// https://models.dev/?search=copilot
|
||||
default: [
|
||||
'claude-haiku-4.5',
|
||||
'claude-sonnet-4.5',
|
||||
'claude-opus-4.5',
|
||||
'gemini-2.5-pro',
|
||||
'gpt-4.1',
|
||||
'gpt-4o',
|
||||
'gpt-5-mini',
|
||||
'gpt-5.2',
|
||||
],
|
||||
items: {
|
||||
type: 'string'
|
||||
}
|
||||
},
|
||||
[COPILOT_ENTERPRISE_URL_PREF]: {
|
||||
type: 'string',
|
||||
markdownDescription: nls.localize('theia/ai/copilot/enterpriseUrl/mdDescription',
|
||||
'GitHub Enterprise domain for Copilot API (e.g., `github.mycompany.com`). Leave empty for GitHub.com.'),
|
||||
title: AI_CORE_PREFERENCES_TITLE,
|
||||
default: ''
|
||||
}
|
||||
}
|
||||
};
|
||||
19
packages/ai-copilot/src/common/index.ts
Normal file
19
packages/ai-copilot/src/common/index.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
// *****************************************************************************
|
||||
// Copyright (C) 2026 EclipseSource GmbH.
|
||||
//
|
||||
// This program and the accompanying materials are made available under the
|
||||
// terms of the Eclipse Public License v. 2.0 which is available at
|
||||
// http://www.eclipse.org/legal/epl-2.0.
|
||||
//
|
||||
// This Source Code may also be made available under the following Secondary
|
||||
// Licenses when the conditions for such availability set forth in the Eclipse
|
||||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
||||
// with the GNU Classpath Exception which is available at
|
||||
// https://www.gnu.org/software/classpath/license.html.
|
||||
//
|
||||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
||||
// *****************************************************************************
|
||||
|
||||
export * from './copilot-language-models-manager';
|
||||
export * from './copilot-auth-service';
|
||||
export * from './copilot-preferences';
|
||||
Reference in New Issue
Block a user