| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624 |
- import { EventEmitter } from "events"
- type ProviderSettings = {
- apiProvider?:
- | (
- | "anthropic"
- | "glama"
- | "openrouter"
- | "bedrock"
- | "vertex"
- | "openai"
- | "ollama"
- | "vscode-lm"
- | "lmstudio"
- | "gemini"
- | "openai-native"
- | "mistral"
- | "deepseek"
- | "unbound"
- | "requesty"
- | "human-relay"
- | "fake-ai"
- | "xai"
- )
- | undefined
- apiModelId?: string | undefined
- apiKey?: string | undefined
- anthropicBaseUrl?: string | undefined
- anthropicUseAuthToken?: boolean | undefined
- glamaModelId?: string | undefined
- glamaApiKey?: string | undefined
- openRouterApiKey?: string | undefined
- openRouterModelId?: string | undefined
- openRouterBaseUrl?: string | undefined
- openRouterSpecificProvider?: string | undefined
- openRouterUseMiddleOutTransform?: boolean | undefined
- awsAccessKey?: string | undefined
- awsSecretKey?: string | undefined
- awsSessionToken?: string | undefined
- awsRegion?: string | undefined
- awsUseCrossRegionInference?: boolean | undefined
- awsUsePromptCache?: boolean | undefined
- awspromptCacheId?: string | undefined
- awsProfile?: string | undefined
- awsUseProfile?: boolean | undefined
- awsCustomArn?: string | undefined
- vertexKeyFile?: string | undefined
- vertexJsonCredentials?: string | undefined
- vertexProjectId?: string | undefined
- vertexRegion?: string | undefined
- openAiBaseUrl?: string | undefined
- openAiApiKey?: string | undefined
- openAiHostHeader?: string | undefined
- openAiLegacyFormat?: boolean | undefined
- openAiR1FormatEnabled?: boolean | undefined
- openAiModelId?: string | undefined
- openAiCustomModelInfo?:
- | ({
- maxTokens?: (number | null) | undefined
- maxThinkingTokens?: (number | null) | undefined
- contextWindow: number
- supportsImages?: boolean | undefined
- supportsComputerUse?: boolean | undefined
- supportsPromptCache: boolean
- isPromptCacheOptional?: boolean | undefined
- inputPrice?: number | undefined
- outputPrice?: number | undefined
- cacheWritesPrice?: number | undefined
- cacheReadsPrice?: number | undefined
- description?: string | undefined
- reasoningEffort?: ("low" | "medium" | "high") | undefined
- thinking?: boolean | undefined
- minTokensPerCachePoint?: number | undefined
- maxCachePoints?: number | undefined
- cachableFields?: string[] | undefined
- tiers?:
- | {
- contextWindow: number
- inputPrice?: number | undefined
- outputPrice?: number | undefined
- cacheWritesPrice?: number | undefined
- cacheReadsPrice?: number | undefined
- }[]
- | undefined
- } | null)
- | undefined
- openAiUseAzure?: boolean | undefined
- azureApiVersion?: string | undefined
- openAiStreamingEnabled?: boolean | undefined
- enableReasoningEffort?: boolean | undefined
- ollamaModelId?: string | undefined
- ollamaBaseUrl?: string | undefined
- vsCodeLmModelSelector?:
- | {
- vendor?: string | undefined
- family?: string | undefined
- version?: string | undefined
- id?: string | undefined
- }
- | undefined
- lmStudioModelId?: string | undefined
- lmStudioBaseUrl?: string | undefined
- lmStudioDraftModelId?: string | undefined
- lmStudioSpeculativeDecodingEnabled?: boolean | undefined
- geminiApiKey?: string | undefined
- googleGeminiBaseUrl?: string | undefined
- openAiNativeApiKey?: string | undefined
- mistralApiKey?: string | undefined
- mistralCodestralUrl?: string | undefined
- deepSeekBaseUrl?: string | undefined
- deepSeekApiKey?: string | undefined
- unboundApiKey?: string | undefined
- unboundModelId?: string | undefined
- requestyApiKey?: string | undefined
- requestyModelId?: string | undefined
- xaiApiKey?: string | undefined
- modelMaxTokens?: number | undefined
- modelMaxThinkingTokens?: number | undefined
- includeMaxTokens?: boolean | undefined
- reasoningEffort?: ("low" | "medium" | "high") | undefined
- promptCachingEnabled?: boolean | undefined
- diffEnabled?: boolean | undefined
- fuzzyMatchThreshold?: number | undefined
- modelTemperature?: (number | null) | undefined
- rateLimitSeconds?: number | undefined
- fakeAi?: unknown | undefined
- }
- type GlobalSettings = {
- currentApiConfigName?: string | undefined
- listApiConfigMeta?:
- | {
- id: string
- name: string
- apiProvider?:
- | (
- | "anthropic"
- | "glama"
- | "openrouter"
- | "bedrock"
- | "vertex"
- | "openai"
- | "ollama"
- | "vscode-lm"
- | "lmstudio"
- | "gemini"
- | "openai-native"
- | "mistral"
- | "deepseek"
- | "unbound"
- | "requesty"
- | "human-relay"
- | "fake-ai"
- | "xai"
- )
- | undefined
- }[]
- | undefined
- pinnedApiConfigs?:
- | {
- [x: string]: boolean
- }
- | undefined
- lastShownAnnouncementId?: string | undefined
- customInstructions?: string | undefined
- taskHistory?:
- | {
- id: string
- number: number
- ts: number
- task: string
- tokensIn: number
- tokensOut: number
- cacheWrites?: number | undefined
- cacheReads?: number | undefined
- totalCost: number
- size?: number | undefined
- workspace?: string | undefined
- }[]
- | undefined
- autoApprovalEnabled?: boolean | undefined
- alwaysAllowReadOnly?: boolean | undefined
- alwaysAllowReadOnlyOutsideWorkspace?: boolean | undefined
- alwaysAllowWrite?: boolean | undefined
- alwaysAllowWriteOutsideWorkspace?: boolean | undefined
- writeDelayMs?: number | undefined
- alwaysAllowBrowser?: boolean | undefined
- alwaysApproveResubmit?: boolean | undefined
- requestDelaySeconds?: number | undefined
- alwaysAllowMcp?: boolean | undefined
- alwaysAllowModeSwitch?: boolean | undefined
- alwaysAllowSubtasks?: boolean | undefined
- alwaysAllowExecute?: boolean | undefined
- allowedCommands?: string[] | undefined
- browserToolEnabled?: boolean | undefined
- browserViewportSize?: string | undefined
- screenshotQuality?: number | undefined
- remoteBrowserEnabled?: boolean | undefined
- remoteBrowserHost?: string | undefined
- cachedChromeHostUrl?: string | undefined
- enableCheckpoints?: boolean | undefined
- ttsEnabled?: boolean | undefined
- ttsSpeed?: number | undefined
- soundEnabled?: boolean | undefined
- soundVolume?: number | undefined
- maxOpenTabsContext?: number | undefined
- maxWorkspaceFiles?: number | undefined
- showRooIgnoredFiles?: boolean | undefined
- maxReadFileLine?: number | undefined
- terminalOutputLineLimit?: number | undefined
- terminalShellIntegrationTimeout?: number | undefined
- terminalShellIntegrationDisabled?: boolean | undefined
- terminalCommandDelay?: number | undefined
- terminalPowershellCounter?: boolean | undefined
- terminalZshClearEolMark?: boolean | undefined
- terminalZshOhMy?: boolean | undefined
- terminalZshP10k?: boolean | undefined
- terminalZdotdir?: boolean | undefined
- terminalCompressProgressBar?: boolean | undefined
- rateLimitSeconds?: number | undefined
- diffEnabled?: boolean | undefined
- fuzzyMatchThreshold?: number | undefined
- experiments?:
- | {
- powerSteering: boolean
- }
- | undefined
- language?:
- | (
- | "ca"
- | "de"
- | "en"
- | "es"
- | "fr"
- | "hi"
- | "it"
- | "ja"
- | "ko"
- | "pl"
- | "pt-BR"
- | "ru"
- | "tr"
- | "vi"
- | "zh-CN"
- | "zh-TW"
- )
- | undefined
- telemetrySetting?: ("unset" | "enabled" | "disabled") | undefined
- mcpEnabled?: boolean | undefined
- enableMcpServerCreation?: boolean | undefined
- mode?: string | undefined
- modeApiConfigs?:
- | {
- [x: string]: string
- }
- | undefined
- customModes?:
- | {
- slug: string
- name: string
- roleDefinition: string
- customInstructions?: string | undefined
- groups: (
- | ("read" | "edit" | "browser" | "command" | "mcp" | "modes")
- | [
- "read" | "edit" | "browser" | "command" | "mcp" | "modes",
- {
- fileRegex?: string | undefined
- description?: string | undefined
- },
- ]
- )[]
- source?: ("global" | "project") | undefined
- }[]
- | undefined
- customModePrompts?:
- | {
- [x: string]:
- | {
- roleDefinition?: string | undefined
- customInstructions?: string | undefined
- }
- | undefined
- }
- | undefined
- customSupportPrompts?:
- | {
- [x: string]: string | undefined
- }
- | undefined
- enhancementApiConfigId?: string | undefined
- historyPreviewCollapsed?: boolean | undefined
- }
- type ClineMessage = {
- ts: number
- type: "ask" | "say"
- ask?:
- | (
- | "followup"
- | "command"
- | "command_output"
- | "completion_result"
- | "tool"
- | "api_req_failed"
- | "resume_task"
- | "resume_completed_task"
- | "mistake_limit_reached"
- | "browser_action_launch"
- | "use_mcp_server"
- )
- | undefined
- say?:
- | (
- | "error"
- | "api_req_started"
- | "api_req_finished"
- | "api_req_retried"
- | "api_req_retry_delayed"
- | "api_req_deleted"
- | "text"
- | "reasoning"
- | "completion_result"
- | "user_feedback"
- | "user_feedback_diff"
- | "command_output"
- | "shell_integration_warning"
- | "browser_action"
- | "browser_action_result"
- | "mcp_server_request_started"
- | "mcp_server_response"
- | "subtask_result"
- | "checkpoint_saved"
- | "rooignore_error"
- | "diff_error"
- )
- | undefined
- text?: string | undefined
- images?: string[] | undefined
- partial?: boolean | undefined
- reasoning?: string | undefined
- conversationHistoryIndex?: number | undefined
- checkpoint?:
- | {
- [x: string]: unknown
- }
- | undefined
- progressStatus?:
- | {
- id?: string | undefined
- icon?: string | undefined
- text?: string | undefined
- }
- | undefined
- }
- type TokenUsage = {
- totalTokensIn: number
- totalTokensOut: number
- totalCacheWrites?: number | undefined
- totalCacheReads?: number | undefined
- totalCost: number
- contextTokens: number
- }
- type RooCodeEvents = {
- message: [
- {
- taskId: string
- action: "created" | "updated"
- message: {
- ts: number
- type: "ask" | "say"
- ask?:
- | (
- | "followup"
- | "command"
- | "command_output"
- | "completion_result"
- | "tool"
- | "api_req_failed"
- | "resume_task"
- | "resume_completed_task"
- | "mistake_limit_reached"
- | "browser_action_launch"
- | "use_mcp_server"
- )
- | undefined
- say?:
- | (
- | "error"
- | "api_req_started"
- | "api_req_finished"
- | "api_req_retried"
- | "api_req_retry_delayed"
- | "api_req_deleted"
- | "text"
- | "reasoning"
- | "completion_result"
- | "user_feedback"
- | "user_feedback_diff"
- | "command_output"
- | "shell_integration_warning"
- | "browser_action"
- | "browser_action_result"
- | "mcp_server_request_started"
- | "mcp_server_response"
- | "subtask_result"
- | "checkpoint_saved"
- | "rooignore_error"
- | "diff_error"
- )
- | undefined
- text?: string | undefined
- images?: string[] | undefined
- partial?: boolean | undefined
- reasoning?: string | undefined
- conversationHistoryIndex?: number | undefined
- checkpoint?:
- | {
- [x: string]: unknown
- }
- | undefined
- progressStatus?:
- | {
- id?: string | undefined
- icon?: string | undefined
- text?: string | undefined
- }
- | undefined
- }
- },
- ]
- taskCreated: [string]
- taskStarted: [string]
- taskModeSwitched: [string, string]
- taskPaused: [string]
- taskUnpaused: [string]
- taskAskResponded: [string]
- taskAborted: [string]
- taskSpawned: [string, string]
- taskCompleted: [
- string,
- {
- totalTokensIn: number
- totalTokensOut: number
- totalCacheWrites?: number | undefined
- totalCacheReads?: number | undefined
- totalCost: number
- contextTokens: number
- },
- {
- [x: string]: {
- attempts: number
- failures: number
- }
- },
- ]
- taskTokenUsageUpdated: [
- string,
- {
- totalTokensIn: number
- totalTokensOut: number
- totalCacheWrites?: number | undefined
- totalCacheReads?: number | undefined
- totalCost: number
- contextTokens: number
- },
- ]
- taskToolFailed: [
- string,
- (
- | "execute_command"
- | "read_file"
- | "write_to_file"
- | "apply_diff"
- | "insert_content"
- | "search_and_replace"
- | "search_files"
- | "list_files"
- | "list_code_definition_names"
- | "browser_action"
- | "use_mcp_tool"
- | "access_mcp_resource"
- | "ask_followup_question"
- | "attempt_completion"
- | "switch_mode"
- | "new_task"
- | "fetch_instructions"
- ),
- string,
- ]
- }
- /**
- * RooCodeEvent
- */
- declare enum RooCodeEventName {
- Message = "message",
- TaskCreated = "taskCreated",
- TaskStarted = "taskStarted",
- TaskModeSwitched = "taskModeSwitched",
- TaskPaused = "taskPaused",
- TaskUnpaused = "taskUnpaused",
- TaskAskResponded = "taskAskResponded",
- TaskAborted = "taskAborted",
- TaskSpawned = "taskSpawned",
- TaskCompleted = "taskCompleted",
- TaskTokenUsageUpdated = "taskTokenUsageUpdated",
- TaskToolFailed = "taskToolFailed",
- }
- type RooCodeSettings = GlobalSettings & ProviderSettings
- interface RooCodeAPI extends EventEmitter<RooCodeEvents> {
- /**
- * Starts a new task with an optional initial message and images.
- * @param task Optional initial task message.
- * @param images Optional array of image data URIs (e.g., "data:image/webp;base64,...").
- * @returns The ID of the new task.
- */
- startNewTask({
- configuration,
- text,
- images,
- newTab,
- }: {
- configuration?: RooCodeSettings
- text?: string
- images?: string[]
- newTab?: boolean
- }): Promise<string>
- /**
- * Resumes a task with the given ID.
- * @param taskId The ID of the task to resume.
- * @throws Error if the task is not found in the task history.
- */
- resumeTask(taskId: string): Promise<void>
- /**
- * Checks if a task with the given ID is in the task history.
- * @param taskId The ID of the task to check.
- * @returns True if the task is in the task history, false otherwise.
- */
- isTaskInHistory(taskId: string): Promise<boolean>
- /**
- * Returns the current task stack.
- * @returns An array of task IDs.
- */
- getCurrentTaskStack(): string[]
- /**
- * Clears the current task.
- */
- clearCurrentTask(lastMessage?: string): Promise<void>
- /**
- * Cancels the current task.
- */
- cancelCurrentTask(): Promise<void>
- /**
- * Sends a message to the current task.
- * @param message Optional message to send.
- * @param images Optional array of image data URIs (e.g., "data:image/webp;base64,...").
- */
- sendMessage(message?: string, images?: string[]): Promise<void>
- /**
- * Simulates pressing the primary button in the chat interface.
- */
- pressPrimaryButton(): Promise<void>
- /**
- * Simulates pressing the secondary button in the chat interface.
- */
- pressSecondaryButton(): Promise<void>
- /**
- * Returns the current configuration.
- * @returns The current configuration.
- */
- getConfiguration(): RooCodeSettings
- /**
- * Sets the configuration for the current task.
- * @param values An object containing key-value pairs to set.
- */
- setConfiguration(values: RooCodeSettings): Promise<void>
- /**
- * Creates a new API configuration profile
- * @param name The name of the profile
- * @returns The ID of the created profile
- */
- createProfile(name: string): Promise<string>
- /**
- * Returns a list of all configured profile names
- * @returns Array of profile names
- */
- getProfiles(): string[]
- /**
- * Changes the active API configuration profile
- * @param name The name of the profile to activate
- * @throws Error if the profile does not exist
- */
- setActiveProfile(name: string): Promise<void>
- /**
- * Returns the name of the currently active profile
- * @returns The profile name, or undefined if no profile is active
- */
- getActiveProfile(): string | undefined
- /**
- * Deletes a profile by name
- * @param name The name of the profile to delete
- * @throws Error if the profile does not exist
- */
- deleteProfile(name: string): Promise<void>
- /**
- * Returns true if the API is ready to use.
- */
- isReady(): boolean
- }
- export {
- type ClineMessage,
- type GlobalSettings,
- type ProviderSettings,
- type RooCodeAPI,
- RooCodeEventName,
- type RooCodeEvents,
- type RooCodeSettings,
- type TokenUsage,
- }
|