diff --git a/packages/types/src/api.ts b/packages/types/src/api.ts index 440d1a4e30..d2832d60e4 100644 --- a/packages/types/src/api.ts +++ b/packages/types/src/api.ts @@ -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 } +/** + * Main API interface for Roo Code extension + */ +export interface RooCodeAPI extends EventEmitter, McpApi { + // Task Management + startNewTask(options: { + configuration: RooCodeSettings + text?: string + images?: string[] + newTab?: boolean + }): Promise + resumeTask(taskId: string): Promise + isTaskInHistory(taskId: string): Promise + getCurrentTaskStack(): unknown + clearCurrentTask(lastMessage?: string): Promise + cancelCurrentTask(): Promise + cancelTask(taskId: string): Promise + + // Messaging + sendMessage(text?: string, images?: string[]): Promise + pressPrimaryButton(): Promise + pressSecondaryButton(): Promise + + // State + isReady(): boolean + + // Configuration + getConfiguration(): RooCodeSettings + setConfiguration(values: RooCodeSettings): Promise + + // Profile Management + getProfiles(): string[] + getProfileEntry(name: string): ProviderSettingsEntry | undefined + createProfile(name: string, profile?: ProviderSettings, activate?: boolean): Promise + updateProfile(name: string, profile: ProviderSettings, activate?: boolean): Promise + upsertProfile(name: string, profile: ProviderSettings, activate?: boolean): Promise + deleteProfile(name: string): Promise + getActiveProfile(): string | undefined + setActiveProfile(name: string): Promise +} + /** * Global MCP API instance that will be set by the extension */ diff --git a/src/extension/api.ts b/src/extension/api.ts index 5601a9453a..6d97020eaf 100644 --- a/src/extension/api.ts +++ b/src/extension/api.ts @@ -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 implements McpApi { +export class API extends EventEmitter implements RooCodeAPI { private readonly outputChannel: vscode.OutputChannel private readonly sidebarProvider: ClineProvider private readonly context: vscode.ExtensionContext