roo-code.d.ts 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. import { EventEmitter } from "events"
  2. type ProviderSettings = {
  3. apiProvider?:
  4. | (
  5. | "anthropic"
  6. | "glama"
  7. | "openrouter"
  8. | "bedrock"
  9. | "vertex"
  10. | "openai"
  11. | "ollama"
  12. | "vscode-lm"
  13. | "lmstudio"
  14. | "gemini"
  15. | "openai-native"
  16. | "mistral"
  17. | "deepseek"
  18. | "unbound"
  19. | "requesty"
  20. | "human-relay"
  21. | "fake-ai"
  22. | "xai"
  23. )
  24. | undefined
  25. apiModelId?: string | undefined
  26. apiKey?: string | undefined
  27. anthropicBaseUrl?: string | undefined
  28. anthropicUseAuthToken?: boolean | undefined
  29. glamaModelId?: string | undefined
  30. glamaApiKey?: string | undefined
  31. openRouterApiKey?: string | undefined
  32. openRouterModelId?: string | undefined
  33. openRouterBaseUrl?: string | undefined
  34. openRouterSpecificProvider?: string | undefined
  35. openRouterUseMiddleOutTransform?: boolean | undefined
  36. awsAccessKey?: string | undefined
  37. awsSecretKey?: string | undefined
  38. awsSessionToken?: string | undefined
  39. awsRegion?: string | undefined
  40. awsUseCrossRegionInference?: boolean | undefined
  41. awsUsePromptCache?: boolean | undefined
  42. awspromptCacheId?: string | undefined
  43. awsProfile?: string | undefined
  44. awsUseProfile?: boolean | undefined
  45. awsCustomArn?: string | undefined
  46. vertexKeyFile?: string | undefined
  47. vertexJsonCredentials?: string | undefined
  48. vertexProjectId?: string | undefined
  49. vertexRegion?: string | undefined
  50. openAiBaseUrl?: string | undefined
  51. openAiApiKey?: string | undefined
  52. openAiHostHeader?: string | undefined
  53. openAiLegacyFormat?: boolean | undefined
  54. openAiR1FormatEnabled?: boolean | undefined
  55. openAiModelId?: string | undefined
  56. openAiCustomModelInfo?:
  57. | ({
  58. maxTokens?: (number | null) | undefined
  59. maxThinkingTokens?: (number | null) | undefined
  60. contextWindow: number
  61. supportsImages?: boolean | undefined
  62. supportsComputerUse?: boolean | undefined
  63. supportsPromptCache: boolean
  64. isPromptCacheOptional?: boolean | undefined
  65. inputPrice?: number | undefined
  66. outputPrice?: number | undefined
  67. cacheWritesPrice?: number | undefined
  68. cacheReadsPrice?: number | undefined
  69. description?: string | undefined
  70. reasoningEffort?: ("low" | "medium" | "high") | undefined
  71. thinking?: boolean | undefined
  72. minTokensPerCachePoint?: number | undefined
  73. maxCachePoints?: number | undefined
  74. cachableFields?: string[] | undefined
  75. tiers?:
  76. | {
  77. contextWindow: number
  78. inputPrice?: number | undefined
  79. outputPrice?: number | undefined
  80. cacheWritesPrice?: number | undefined
  81. cacheReadsPrice?: number | undefined
  82. }[]
  83. | undefined
  84. } | null)
  85. | undefined
  86. openAiUseAzure?: boolean | undefined
  87. azureApiVersion?: string | undefined
  88. openAiStreamingEnabled?: boolean | undefined
  89. enableReasoningEffort?: boolean | undefined
  90. ollamaModelId?: string | undefined
  91. ollamaBaseUrl?: string | undefined
  92. vsCodeLmModelSelector?:
  93. | {
  94. vendor?: string | undefined
  95. family?: string | undefined
  96. version?: string | undefined
  97. id?: string | undefined
  98. }
  99. | undefined
  100. lmStudioModelId?: string | undefined
  101. lmStudioBaseUrl?: string | undefined
  102. lmStudioDraftModelId?: string | undefined
  103. lmStudioSpeculativeDecodingEnabled?: boolean | undefined
  104. geminiApiKey?: string | undefined
  105. googleGeminiBaseUrl?: string | undefined
  106. openAiNativeApiKey?: string | undefined
  107. mistralApiKey?: string | undefined
  108. mistralCodestralUrl?: string | undefined
  109. deepSeekBaseUrl?: string | undefined
  110. deepSeekApiKey?: string | undefined
  111. unboundApiKey?: string | undefined
  112. unboundModelId?: string | undefined
  113. requestyApiKey?: string | undefined
  114. requestyModelId?: string | undefined
  115. xaiApiKey?: string | undefined
  116. modelMaxTokens?: number | undefined
  117. modelMaxThinkingTokens?: number | undefined
  118. includeMaxTokens?: boolean | undefined
  119. reasoningEffort?: ("low" | "medium" | "high") | undefined
  120. promptCachingEnabled?: boolean | undefined
  121. diffEnabled?: boolean | undefined
  122. fuzzyMatchThreshold?: number | undefined
  123. modelTemperature?: (number | null) | undefined
  124. rateLimitSeconds?: number | undefined
  125. fakeAi?: unknown | undefined
  126. }
  127. type GlobalSettings = {
  128. currentApiConfigName?: string | undefined
  129. listApiConfigMeta?:
  130. | {
  131. id: string
  132. name: string
  133. apiProvider?:
  134. | (
  135. | "anthropic"
  136. | "glama"
  137. | "openrouter"
  138. | "bedrock"
  139. | "vertex"
  140. | "openai"
  141. | "ollama"
  142. | "vscode-lm"
  143. | "lmstudio"
  144. | "gemini"
  145. | "openai-native"
  146. | "mistral"
  147. | "deepseek"
  148. | "unbound"
  149. | "requesty"
  150. | "human-relay"
  151. | "fake-ai"
  152. | "xai"
  153. )
  154. | undefined
  155. }[]
  156. | undefined
  157. pinnedApiConfigs?:
  158. | {
  159. [x: string]: boolean
  160. }
  161. | undefined
  162. lastShownAnnouncementId?: string | undefined
  163. customInstructions?: string | undefined
  164. taskHistory?:
  165. | {
  166. id: string
  167. number: number
  168. ts: number
  169. task: string
  170. tokensIn: number
  171. tokensOut: number
  172. cacheWrites?: number | undefined
  173. cacheReads?: number | undefined
  174. totalCost: number
  175. size?: number | undefined
  176. workspace?: string | undefined
  177. }[]
  178. | undefined
  179. autoApprovalEnabled?: boolean | undefined
  180. alwaysAllowReadOnly?: boolean | undefined
  181. alwaysAllowReadOnlyOutsideWorkspace?: boolean | undefined
  182. alwaysAllowWrite?: boolean | undefined
  183. alwaysAllowWriteOutsideWorkspace?: boolean | undefined
  184. writeDelayMs?: number | undefined
  185. alwaysAllowBrowser?: boolean | undefined
  186. alwaysApproveResubmit?: boolean | undefined
  187. requestDelaySeconds?: number | undefined
  188. alwaysAllowMcp?: boolean | undefined
  189. alwaysAllowModeSwitch?: boolean | undefined
  190. alwaysAllowSubtasks?: boolean | undefined
  191. alwaysAllowExecute?: boolean | undefined
  192. allowedCommands?: string[] | undefined
  193. browserToolEnabled?: boolean | undefined
  194. browserViewportSize?: string | undefined
  195. screenshotQuality?: number | undefined
  196. remoteBrowserEnabled?: boolean | undefined
  197. remoteBrowserHost?: string | undefined
  198. cachedChromeHostUrl?: string | undefined
  199. enableCheckpoints?: boolean | undefined
  200. ttsEnabled?: boolean | undefined
  201. ttsSpeed?: number | undefined
  202. soundEnabled?: boolean | undefined
  203. soundVolume?: number | undefined
  204. maxOpenTabsContext?: number | undefined
  205. maxWorkspaceFiles?: number | undefined
  206. showRooIgnoredFiles?: boolean | undefined
  207. maxReadFileLine?: number | undefined
  208. terminalOutputLineLimit?: number | undefined
  209. terminalShellIntegrationTimeout?: number | undefined
  210. terminalShellIntegrationDisabled?: boolean | undefined
  211. terminalCommandDelay?: number | undefined
  212. terminalPowershellCounter?: boolean | undefined
  213. terminalZshClearEolMark?: boolean | undefined
  214. terminalZshOhMy?: boolean | undefined
  215. terminalZshP10k?: boolean | undefined
  216. terminalZdotdir?: boolean | undefined
  217. terminalCompressProgressBar?: boolean | undefined
  218. rateLimitSeconds?: number | undefined
  219. diffEnabled?: boolean | undefined
  220. fuzzyMatchThreshold?: number | undefined
  221. experiments?:
  222. | {
  223. powerSteering: boolean
  224. }
  225. | undefined
  226. language?:
  227. | (
  228. | "ca"
  229. | "de"
  230. | "en"
  231. | "es"
  232. | "fr"
  233. | "hi"
  234. | "it"
  235. | "ja"
  236. | "ko"
  237. | "pl"
  238. | "pt-BR"
  239. | "ru"
  240. | "tr"
  241. | "vi"
  242. | "zh-CN"
  243. | "zh-TW"
  244. )
  245. | undefined
  246. telemetrySetting?: ("unset" | "enabled" | "disabled") | undefined
  247. mcpEnabled?: boolean | undefined
  248. enableMcpServerCreation?: boolean | undefined
  249. mode?: string | undefined
  250. modeApiConfigs?:
  251. | {
  252. [x: string]: string
  253. }
  254. | undefined
  255. customModes?:
  256. | {
  257. slug: string
  258. name: string
  259. roleDefinition: string
  260. customInstructions?: string | undefined
  261. groups: (
  262. | ("read" | "edit" | "browser" | "command" | "mcp" | "modes")
  263. | [
  264. "read" | "edit" | "browser" | "command" | "mcp" | "modes",
  265. {
  266. fileRegex?: string | undefined
  267. description?: string | undefined
  268. },
  269. ]
  270. )[]
  271. source?: ("global" | "project") | undefined
  272. }[]
  273. | undefined
  274. customModePrompts?:
  275. | {
  276. [x: string]:
  277. | {
  278. roleDefinition?: string | undefined
  279. customInstructions?: string | undefined
  280. }
  281. | undefined
  282. }
  283. | undefined
  284. customSupportPrompts?:
  285. | {
  286. [x: string]: string | undefined
  287. }
  288. | undefined
  289. enhancementApiConfigId?: string | undefined
  290. historyPreviewCollapsed?: boolean | undefined
  291. }
  292. type ClineMessage = {
  293. ts: number
  294. type: "ask" | "say"
  295. ask?:
  296. | (
  297. | "followup"
  298. | "command"
  299. | "command_output"
  300. | "completion_result"
  301. | "tool"
  302. | "api_req_failed"
  303. | "resume_task"
  304. | "resume_completed_task"
  305. | "mistake_limit_reached"
  306. | "browser_action_launch"
  307. | "use_mcp_server"
  308. )
  309. | undefined
  310. say?:
  311. | (
  312. | "error"
  313. | "api_req_started"
  314. | "api_req_finished"
  315. | "api_req_retried"
  316. | "api_req_retry_delayed"
  317. | "api_req_deleted"
  318. | "text"
  319. | "reasoning"
  320. | "completion_result"
  321. | "user_feedback"
  322. | "user_feedback_diff"
  323. | "command_output"
  324. | "shell_integration_warning"
  325. | "browser_action"
  326. | "browser_action_result"
  327. | "mcp_server_request_started"
  328. | "mcp_server_response"
  329. | "subtask_result"
  330. | "checkpoint_saved"
  331. | "rooignore_error"
  332. | "diff_error"
  333. )
  334. | undefined
  335. text?: string | undefined
  336. images?: string[] | undefined
  337. partial?: boolean | undefined
  338. reasoning?: string | undefined
  339. conversationHistoryIndex?: number | undefined
  340. checkpoint?:
  341. | {
  342. [x: string]: unknown
  343. }
  344. | undefined
  345. progressStatus?:
  346. | {
  347. id?: string | undefined
  348. icon?: string | undefined
  349. text?: string | undefined
  350. }
  351. | undefined
  352. }
  353. type TokenUsage = {
  354. totalTokensIn: number
  355. totalTokensOut: number
  356. totalCacheWrites?: number | undefined
  357. totalCacheReads?: number | undefined
  358. totalCost: number
  359. contextTokens: number
  360. }
  361. type RooCodeEvents = {
  362. message: [
  363. {
  364. taskId: string
  365. action: "created" | "updated"
  366. message: {
  367. ts: number
  368. type: "ask" | "say"
  369. ask?:
  370. | (
  371. | "followup"
  372. | "command"
  373. | "command_output"
  374. | "completion_result"
  375. | "tool"
  376. | "api_req_failed"
  377. | "resume_task"
  378. | "resume_completed_task"
  379. | "mistake_limit_reached"
  380. | "browser_action_launch"
  381. | "use_mcp_server"
  382. )
  383. | undefined
  384. say?:
  385. | (
  386. | "error"
  387. | "api_req_started"
  388. | "api_req_finished"
  389. | "api_req_retried"
  390. | "api_req_retry_delayed"
  391. | "api_req_deleted"
  392. | "text"
  393. | "reasoning"
  394. | "completion_result"
  395. | "user_feedback"
  396. | "user_feedback_diff"
  397. | "command_output"
  398. | "shell_integration_warning"
  399. | "browser_action"
  400. | "browser_action_result"
  401. | "mcp_server_request_started"
  402. | "mcp_server_response"
  403. | "subtask_result"
  404. | "checkpoint_saved"
  405. | "rooignore_error"
  406. | "diff_error"
  407. )
  408. | undefined
  409. text?: string | undefined
  410. images?: string[] | undefined
  411. partial?: boolean | undefined
  412. reasoning?: string | undefined
  413. conversationHistoryIndex?: number | undefined
  414. checkpoint?:
  415. | {
  416. [x: string]: unknown
  417. }
  418. | undefined
  419. progressStatus?:
  420. | {
  421. id?: string | undefined
  422. icon?: string | undefined
  423. text?: string | undefined
  424. }
  425. | undefined
  426. }
  427. },
  428. ]
  429. taskCreated: [string]
  430. taskStarted: [string]
  431. taskModeSwitched: [string, string]
  432. taskPaused: [string]
  433. taskUnpaused: [string]
  434. taskAskResponded: [string]
  435. taskAborted: [string]
  436. taskSpawned: [string, string]
  437. taskCompleted: [
  438. string,
  439. {
  440. totalTokensIn: number
  441. totalTokensOut: number
  442. totalCacheWrites?: number | undefined
  443. totalCacheReads?: number | undefined
  444. totalCost: number
  445. contextTokens: number
  446. },
  447. {
  448. [x: string]: {
  449. attempts: number
  450. failures: number
  451. }
  452. },
  453. ]
  454. taskTokenUsageUpdated: [
  455. string,
  456. {
  457. totalTokensIn: number
  458. totalTokensOut: number
  459. totalCacheWrites?: number | undefined
  460. totalCacheReads?: number | undefined
  461. totalCost: number
  462. contextTokens: number
  463. },
  464. ]
  465. taskToolFailed: [
  466. string,
  467. (
  468. | "execute_command"
  469. | "read_file"
  470. | "write_to_file"
  471. | "apply_diff"
  472. | "insert_content"
  473. | "search_and_replace"
  474. | "search_files"
  475. | "list_files"
  476. | "list_code_definition_names"
  477. | "browser_action"
  478. | "use_mcp_tool"
  479. | "access_mcp_resource"
  480. | "ask_followup_question"
  481. | "attempt_completion"
  482. | "switch_mode"
  483. | "new_task"
  484. | "fetch_instructions"
  485. ),
  486. string,
  487. ]
  488. }
  489. /**
  490. * RooCodeEvent
  491. */
  492. declare enum RooCodeEventName {
  493. Message = "message",
  494. TaskCreated = "taskCreated",
  495. TaskStarted = "taskStarted",
  496. TaskModeSwitched = "taskModeSwitched",
  497. TaskPaused = "taskPaused",
  498. TaskUnpaused = "taskUnpaused",
  499. TaskAskResponded = "taskAskResponded",
  500. TaskAborted = "taskAborted",
  501. TaskSpawned = "taskSpawned",
  502. TaskCompleted = "taskCompleted",
  503. TaskTokenUsageUpdated = "taskTokenUsageUpdated",
  504. TaskToolFailed = "taskToolFailed",
  505. }
  506. type RooCodeSettings = GlobalSettings & ProviderSettings
  507. interface RooCodeAPI extends EventEmitter<RooCodeEvents> {
  508. /**
  509. * Starts a new task with an optional initial message and images.
  510. * @param task Optional initial task message.
  511. * @param images Optional array of image data URIs (e.g., "data:image/webp;base64,...").
  512. * @returns The ID of the new task.
  513. */
  514. startNewTask({
  515. configuration,
  516. text,
  517. images,
  518. newTab,
  519. }: {
  520. configuration?: RooCodeSettings
  521. text?: string
  522. images?: string[]
  523. newTab?: boolean
  524. }): Promise<string>
  525. /**
  526. * Resumes a task with the given ID.
  527. * @param taskId The ID of the task to resume.
  528. * @throws Error if the task is not found in the task history.
  529. */
  530. resumeTask(taskId: string): Promise<void>
  531. /**
  532. * Checks if a task with the given ID is in the task history.
  533. * @param taskId The ID of the task to check.
  534. * @returns True if the task is in the task history, false otherwise.
  535. */
  536. isTaskInHistory(taskId: string): Promise<boolean>
  537. /**
  538. * Returns the current task stack.
  539. * @returns An array of task IDs.
  540. */
  541. getCurrentTaskStack(): string[]
  542. /**
  543. * Clears the current task.
  544. */
  545. clearCurrentTask(lastMessage?: string): Promise<void>
  546. /**
  547. * Cancels the current task.
  548. */
  549. cancelCurrentTask(): Promise<void>
  550. /**
  551. * Sends a message to the current task.
  552. * @param message Optional message to send.
  553. * @param images Optional array of image data URIs (e.g., "data:image/webp;base64,...").
  554. */
  555. sendMessage(message?: string, images?: string[]): Promise<void>
  556. /**
  557. * Simulates pressing the primary button in the chat interface.
  558. */
  559. pressPrimaryButton(): Promise<void>
  560. /**
  561. * Simulates pressing the secondary button in the chat interface.
  562. */
  563. pressSecondaryButton(): Promise<void>
  564. /**
  565. * Returns the current configuration.
  566. * @returns The current configuration.
  567. */
  568. getConfiguration(): RooCodeSettings
  569. /**
  570. * Sets the configuration for the current task.
  571. * @param values An object containing key-value pairs to set.
  572. */
  573. setConfiguration(values: RooCodeSettings): Promise<void>
  574. /**
  575. * Creates a new API configuration profile
  576. * @param name The name of the profile
  577. * @returns The ID of the created profile
  578. */
  579. createProfile(name: string): Promise<string>
  580. /**
  581. * Returns a list of all configured profile names
  582. * @returns Array of profile names
  583. */
  584. getProfiles(): string[]
  585. /**
  586. * Changes the active API configuration profile
  587. * @param name The name of the profile to activate
  588. * @throws Error if the profile does not exist
  589. */
  590. setActiveProfile(name: string): Promise<void>
  591. /**
  592. * Returns the name of the currently active profile
  593. * @returns The profile name, or undefined if no profile is active
  594. */
  595. getActiveProfile(): string | undefined
  596. /**
  597. * Deletes a profile by name
  598. * @param name The name of the profile to delete
  599. * @throws Error if the profile does not exist
  600. */
  601. deleteProfile(name: string): Promise<void>
  602. /**
  603. * Returns true if the API is ready to use.
  604. */
  605. isReady(): boolean
  606. }
  607. export {
  608. type ClineMessage,
  609. type GlobalSettings,
  610. type ProviderSettings,
  611. type RooCodeAPI,
  612. RooCodeEventName,
  613. type RooCodeEvents,
  614. type RooCodeSettings,
  615. type TokenUsage,
  616. }