import { Disposable } from 'vscode-languageserver-protocol'; import { Cable as ActionCableCable } from '@anycable/core'; import { ConfigService } from './config_service'; import { ICodeSuggestionModel } from './tracking/tracking_types'; import { LsFetch } from './fetch'; import { AdditionalContext, SuggestionOption, ApiRequest } from './api_types'; export interface ApiReconfiguredData { /** is the API client configured in a way that allows it to send request to the API */ isInValidState: boolean; validationMessage?: string; } export interface GitLabApiClient { checkToken(token: string | undefined): Promise; getCodeSuggestions(request: CodeSuggestionRequest): Promise; getStreamingCodeSuggestions(request: CodeSuggestionRequest): AsyncGenerator; fetchFromApi(request: ApiRequest): Promise; connectToCable(): Promise; onApiReconfigured(listener: (data: ApiReconfiguredData) => void): Disposable; readonly instanceVersion?: string; } export declare const GitLabApiClient: import("@gitlab-org/di").InterfaceId; export type GenerationType = 'comment' | 'small_file' | 'empty_function' | undefined; export interface CodeSuggestionRequest { prompt_version: number; project_path: string; model_provider?: string; project_id: number; current_file: CodeSuggestionRequestCurrentFile; intent?: 'completion' | 'generation'; stream?: boolean; /** how many suggestion options should the API return */ choices_count?: number; /** additional context to provide to the model */ context?: AdditionalContext[]; user_instruction?: string; generation_type?: GenerationType; } export interface CodeSuggestionRequestCurrentFile { file_name: string; content_above_cursor: string; content_below_cursor: string; } export interface CodeSuggestionResponse { choices?: SuggestionOption[]; model?: ICodeSuggestionModel; status: number; error?: string; isDirectConnection?: boolean; } export interface StartStreamOption { uniqueTrackingId: string; /** the streamId represents the beginning of a stream * */ streamId: string; } export type SuggestionOptionOrStream = SuggestionOption | StartStreamOption; export interface PersonalAccessToken { name: string; scopes: string[]; active: boolean; } export interface OAuthToken { scope: string[]; } export interface TokenCheckResponse { valid: boolean; reason?: 'unknown' | 'not_active' | 'invalid_scopes'; message?: string; } export interface IDirectConnectionDetailsHeaders { 'X-Gitlab-Global-User-Id': string; 'X-Gitlab-Instance-Id': string; 'X-Gitlab-Host-Name': string; 'X-Gitlab-Saas-Duo-Pro-Namespace-Ids': string; } export interface IDirectConnectionModelDetails { model_provider: string; model_name: string; } export interface IDirectConnectionDetails { base_url: string; token: string; expires_at: number; headers: IDirectConnectionDetailsHeaders; model_details: IDirectConnectionModelDetails; } export declare class GitLabAPI implements GitLabApiClient { #private; constructor(lsFetch: LsFetch, configService: ConfigService); onApiReconfigured(listener: (data: ApiReconfiguredData) => void): Disposable; configureApi({ token, baseUrl, }: { token?: string; baseUrl?: string; }): Promise; checkToken(token?: string): Promise; getCodeSuggestions(request: CodeSuggestionRequest): Promise; getStreamingCodeSuggestions(request: CodeSuggestionRequest): AsyncGenerator; fetchFromApi(request: ApiRequest): Promise; connectToCable(): Promise; get instanceVersion(): string | undefined; }