fix: add RooCodeAPI interface for e2e tests compatibility

This commit is contained in:
Roo Code 2025-09-28 19:07:34 +00:00
parent c2cc9643e1
commit 3457ecbba3
2 changed files with 47 additions and 1 deletions

View file

@ -2,6 +2,10 @@
* API for programmatic MCP server operations
*/
import type { EventEmitter } from "events"
import type { RooCodeEvents } from "./events.js"
import type { RooCodeSettings, ProviderSettings, ProviderSettingsEntry } from "./index.js"
/**
* Interface for MCP operations that can be accessed programmatically
*/
@ -13,6 +17,47 @@ export interface McpApi {
refreshMcpServers(): Promise<void>
}
/**
* Main API interface for Roo Code extension
*/
export interface RooCodeAPI extends EventEmitter<RooCodeEvents>, McpApi {
// Task Management
startNewTask(options: {
configuration: RooCodeSettings
text?: string
images?: string[]
newTab?: boolean
}): Promise<string>
resumeTask(taskId: string): Promise<void>
isTaskInHistory(taskId: string): Promise<boolean>
getCurrentTaskStack(): unknown
clearCurrentTask(lastMessage?: string): Promise<void>
cancelCurrentTask(): Promise<void>
cancelTask(taskId: string): Promise<void>
// Messaging
sendMessage(text?: string, images?: string[]): Promise<void>
pressPrimaryButton(): Promise<void>
pressSecondaryButton(): Promise<void>
// State
isReady(): boolean
// Configuration
getConfiguration(): RooCodeSettings
setConfiguration(values: RooCodeSettings): Promise<void>
// Profile Management
getProfiles(): string[]
getProfileEntry(name: string): ProviderSettingsEntry | undefined
createProfile(name: string, profile?: ProviderSettings, activate?: boolean): Promise<string>
updateProfile(name: string, profile: ProviderSettings, activate?: boolean): Promise<string | undefined>
upsertProfile(name: string, profile: ProviderSettings, activate?: boolean): Promise<string | undefined>
deleteProfile(name: string): Promise<void>
getActiveProfile(): string | undefined
setActiveProfile(name: string): Promise<string | undefined>
}
/**
* Global MCP API instance that will be set by the extension
*/

View file

@ -8,6 +8,7 @@ import * as vscode from "vscode"
import {
type RooCodeSettings,
type RooCodeEvents,
type RooCodeAPI,
type ProviderSettings,
type ProviderSettingsEntry,
type TaskEvent,
@ -26,7 +27,7 @@ import { Package } from "../shared/package"
import { ClineProvider } from "../core/webview/ClineProvider"
import { openClineInNewTab } from "../activate/registerCommands"
export class API extends EventEmitter<RooCodeEvents> implements McpApi {
export class API extends EventEmitter<RooCodeEvents> implements RooCodeAPI {
private readonly outputChannel: vscode.OutputChannel
private readonly sidebarProvider: ClineProvider
private readonly context: vscode.ExtensionContext