API Reference
Complete API reference for Feima Copilot extension.
Extension Commands
Section titled “Extension Commands”feima.signIn
Section titled “feima.signIn”Sign in to your Feima account using OAuth2.
Signature:
function signIn(): Promise<void>Usage:
import * as vscode from 'vscode';
const signInCommand = vscode.commands.registerCommand('feima.signIn', async () => { // Signs the user in via OAuth2});Throws:
Error- If authentication fails
feima.showAccount
Section titled “feima.showAccount”Display current account information.
Signature:
function showAccount(): Promise<void>Usage:
const showAccountCommand = vscode.commands.registerCommand('feima.showAccount', async () => { // Shows email and account ID});Throws:
Error- If not signed in
feima.signOut
Section titled “feima.signOut”Sign out from Feima account.
Signature:
function signOut(): Promise<void>Usage:
const signOutCommand = vscode.commands.registerCommand('feima.signOut', async () => { // Clears all stored tokens});Language Model Provider
Section titled “Language Model Provider”LanguageModelProvider
Section titled “LanguageModelProvider”Main provider for Feima language models.
Interface:
interface LanguageModelProvider { readonly models: LanguageModel[]; getModel(id: string): LanguageModel | undefined; refreshModels(): Promise<void>;}LanguageModel
Section titled “LanguageModel”Represents a single AI model.
Interface:
interface LanguageModel { readonly id: string; readonly name: string; readonly description: string; readonly provider: string; readonly contextLength: number; readonly maxOutputTokens: number; readonly capabilities: ModelCapabilities;}Properties:
| Property | Type | Description |
|---|---|---|
id | string | Unique model identifier |
name | string | Display name |
description | string | Model description |
provider | string | Provider name |
contextLength | number | Maximum context tokens |
maxOutputTokens | number | Maximum output tokens |
capabilities | ModelCapabilities | Supported capabilities |
ModelCapabilities
Section titled “ModelCapabilities”Capabilities of a language model.
Interface:
interface ModelCapabilities { readonly codeGeneration: boolean; readonly codeReview: boolean; readonly reasoning: boolean; readonly supportsImages?: boolean; readonly supportsTools?: boolean;}Authentication Service
Section titled “Authentication Service”OAuth2Service
Section titled “OAuth2Service”Handles OAuth2 authentication with Feima IDP.
Interface:
interface OAuth2Service { signIn(): Promise<Session>; signOut(): Promise<void>; getCurrentSession(): Session | null; refreshAccessToken(): Promise<void>;}Session
Section titled “Session”Represents an authenticated session.
Interface:
interface Session { readonly accessToken: string; readonly refreshToken: string; readonly expiresAt: Date; readonly user: UserInfo;}UserInfo
Section titled “UserInfo”User information from Feima IDP.
Interface:
interface UserInfo { readonly email: string; readonly sub: string; readonly provider: 'wechat' | 'weibo';}Configuration
Section titled “Configuration”ConfigurationOptions
Section titled “ConfigurationOptions”Extension configuration options.
Interface:
interface ConfigurationOptions { readonly defaultModel: string; readonly showStatusBar: boolean; readonly autoRefreshToken: boolean; readonly enableDebugLogging: boolean; readonly requestTimeout: number; readonly maxRetries: number;}getConfiguration()
Section titled “getConfiguration()”Get current extension configuration.
Signature:
function getConfiguration(): ConfigurationOptionsUsage:
const config = getConfiguration();console.log(config.defaultModel);Events
Section titled “Events”SessionChangedEvent
Section titled “SessionChangedEvent”Fired when the user session changes.
Type:
type SessionChangedEvent = Session | null;Usage:
authService.onSessionChanged((session) => { if (session) { console.log('User signed in:', session.user.email); } else { console.log('User signed out'); }});ModelsUpdatedEvent
Section titled “ModelsUpdatedEvent”Fired when available models are updated.
Type:
type ModelsUpdatedEvent = LanguageModel[];Usage:
provider.onModelsUpdated((models) => { console.log('Available models:', models.length);});API Client
Section titled “API Client”FeimaApiClient
Section titled “FeimaApiClient”HTTP client for Feima API.
Interface:
interface FeimaApiClient { completions(request: CompletionRequest): Promise<CompletionResponse>; chat(request: ChatRequest): Promise<ChatResponse>; models(): Promise<LanguageModel[]>;}CompletionRequest
Section titled “CompletionRequest”Request for text completion.
Interface:
interface CompletionRequest { readonly model: string; readonly prompt: string; readonly maxTokens?: number; readonly temperature?: number; readonly stop?: string[];}CompletionResponse
Section titled “CompletionResponse”Response from completion API.
Interface:
interface CompletionResponse { readonly id: string; readonly model: string; readonly choices: CompletionChoice[]; readonly usage: Usage;}ChatRequest
Section titled “ChatRequest”Request for chat completion.
Interface:
interface ChatRequest { readonly model: string; readonly messages: ChatMessage[]; readonly maxTokens?: number; readonly temperature?: number; readonly stream?: boolean;}ChatMessage
Section titled “ChatMessage”Single message in a chat conversation.
Interface:
interface ChatMessage { readonly role: 'user' | 'assistant' | 'system'; readonly content: string;}Token usage information.
Interface:
interface Usage { readonly promptTokens: number; readonly completionTokens: number; readonly totalTokens: number;}Error Types
Section titled “Error Types”AuthenticationError
Section titled “AuthenticationError”Thrown when authentication fails.
class AuthenticationError extends Error { readonly code: string; constructor(message: string, code: string);}ApiError
Section titled “ApiError”Thrown when API request fails.
class ApiError extends Error { readonly statusCode: number; readonly requestId: string; constructor(message: string, statusCode: number, requestId: string);}RateLimitError
Section titled “RateLimitError”Thrown when rate limit is exceeded.
class RateLimitError extends Error { readonly retryAfter: number; constructor(message: string, retryAfter: number);}Extension API
Section titled “Extension API”activate()
Section titled “activate()”Main extension activation function.
Signature:
export function activate(context: vscode.ExtensionContext): voidParameters:
context- VS Code extension context
deactivate()
Section titled “deactivate()”Extension deactivation function.
Signature:
export function deactivate(): void | Promise<void>Examples
Section titled “Examples”Sign In Example
Section titled “Sign In Example”import * as vscode from 'vscode';import { OAuth2Service } from './auth/oauthService';
const authService = new OAuth2Service(context);
async function signInExample() { try { const session = await authService.signIn(); vscode.window.showInformationMessage( `Signed in as ${session.user.email}` ); } catch (error) { vscode.window.showErrorMessage( `Sign in failed: ${error.message}` ); }}Get Model Example
Section titled “Get Model Example”import { LanguageModelProvider } from './models/languageModelProvider';
const provider = new LanguageModelProvider(context);
function getModelExample() { const model = provider.getModel('deepseek-coder-v2'); if (model) { console.log(`Model: ${model.name}`); console.log(`Provider: ${model.provider}`); console.log(`Context: ${model.contextLength} tokens`); }}Chat API Example
Section titled “Chat API Example”import { FeimaApiClient } from './services/feimaApiClient';
const api = new FeimaApiClient(authService);
async function chatExample() { const response = await api.chat({ model: 'deepseek-coder-v2', messages: [ { role: 'user', content: 'Write a hello world function in TypeScript' } ], maxTokens: 500 });
console.log(response.choices[0].message.content);}LogLevel
Section titled “LogLevel”Log level enum.
enum LogLevel { Debug = 'debug', Info = 'info', Warn = 'warn', Error = 'error'}ModelProvider
Section titled “ModelProvider”Model provider enum.
enum ModelProvider { DeepSeek = 'deepseek', Alibaba = 'alibaba', Tencent = 'tencent', OpenAI = 'openai', Anthropic = 'anthropic', Google = 'google'}Constants
Section titled “Constants”Model IDs
Section titled “Model IDs”export const MODEL_IDS = { DEEPSEEK_CODER_V2: 'deepseek-coder-v2', TONGYI_QIANWEN_3_CODER: 'tongyi-qianwen-3-coder', TENCENT_HUNYUAN: 'tencent-hunyuan', GPT_4O: 'gpt-4o', CLAUDE_3_5_SONNET: 'claude-3.5-sonnet', GEMINI_1_5_PRO: 'gemini-1.5-pro'} as const;Configuration Keys
Section titled “Configuration Keys”export const CONFIG_KEYS = { DEFAULT_MODEL: 'feima.defaultModel', SHOW_STATUS_BAR: 'feima.showStatusBar', AUTO_REFRESH_TOKEN: 'feima.autoRefreshToken', ENABLE_DEBUG_LOGGING: 'feima.enableDebugLogging', REQUEST_TIMEOUT: 'feima.requestTimeout', MAX_RETRIES: 'feima.maxRetries'} as const;Next Steps
Section titled “Next Steps”- Development Setup - Set up development environment
- Testing Guide - Test your changes
- Building Guide - Build and package