roo-code.d.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. import { EventEmitter } from "events"
  2. export interface RooCodeEvents {
  3. message: [{ taskId: string; action: "created" | "updated"; message: ClineMessage }]
  4. taskStarted: [taskId: string]
  5. taskPaused: [taskId: string]
  6. taskUnpaused: [taskId: string]
  7. taskAborted: [taskId: string]
  8. taskSpawned: [taskId: string, childTaskId: string]
  9. }
  10. export interface RooCodeAPI extends EventEmitter<RooCodeEvents> {
  11. /**
  12. * Starts a new task with an optional initial message and images.
  13. * @param task Optional initial task message.
  14. * @param images Optional array of image data URIs (e.g., "data:image/webp;base64,...").
  15. * @returns The ID of the new task.
  16. */
  17. startNewTask(task?: string, images?: string[]): Promise<string>
  18. /**
  19. * Clears the current task.
  20. */
  21. clearCurrentTask(lastMessage?: string): Promise<void>
  22. /**
  23. * Cancels the current task.
  24. */
  25. cancelCurrentTask(): Promise<void>
  26. /**
  27. * Sends a message to the current task.
  28. * @param message Optional message to send.
  29. * @param images Optional array of image data URIs (e.g., "data:image/webp;base64,...").
  30. */
  31. sendMessage(message?: string, images?: string[]): Promise<void>
  32. /**
  33. * Simulates pressing the primary button in the chat interface.
  34. */
  35. pressPrimaryButton(): Promise<void>
  36. /**
  37. * Simulates pressing the secondary button in the chat interface.
  38. */
  39. pressSecondaryButton(): Promise<void>
  40. /**
  41. * Sets the configuration for the current task.
  42. * @param values An object containing key-value pairs to set.
  43. */
  44. setConfiguration(values: Partial<ConfigurationValues>): Promise<void>
  45. /**
  46. * Returns true if the API is ready to use.
  47. */
  48. isReady(): boolean
  49. /**
  50. * Returns the messages for a given task.
  51. * @param taskId The ID of the task.
  52. * @returns An array of ClineMessage objects.
  53. */
  54. getMessages(taskId: string): ClineMessage[]
  55. }
  56. export type ClineAsk =
  57. | "followup"
  58. | "command"
  59. | "command_output"
  60. | "completion_result"
  61. | "tool"
  62. | "api_req_failed"
  63. | "resume_task"
  64. | "resume_completed_task"
  65. | "mistake_limit_reached"
  66. | "browser_action_launch"
  67. | "use_mcp_server"
  68. | "finishTask"
  69. export type ClineSay =
  70. | "task"
  71. | "error"
  72. | "api_req_started"
  73. | "api_req_finished"
  74. | "api_req_retried"
  75. | "api_req_retry_delayed"
  76. | "api_req_deleted"
  77. | "text"
  78. | "reasoning"
  79. | "completion_result"
  80. | "user_feedback"
  81. | "user_feedback_diff"
  82. | "command_output"
  83. | "tool"
  84. | "shell_integration_warning"
  85. | "browser_action"
  86. | "browser_action_result"
  87. | "command"
  88. | "mcp_server_request_started"
  89. | "mcp_server_response"
  90. | "new_task_started"
  91. | "new_task"
  92. | "checkpoint_saved"
  93. | "rooignore_error"
  94. export interface ClineMessage {
  95. ts: number
  96. type: "ask" | "say"
  97. ask?: ClineAsk
  98. say?: ClineSay
  99. text?: string
  100. images?: string[]
  101. partial?: boolean
  102. reasoning?: string
  103. conversationHistoryIndex?: number
  104. checkpoint?: Record<string, unknown>
  105. progressStatus?: ToolProgressStatus
  106. }
  107. export type SecretKey =
  108. | "apiKey"
  109. | "glamaApiKey"
  110. | "openRouterApiKey"
  111. | "awsAccessKey"
  112. | "awsSecretKey"
  113. | "awsSessionToken"
  114. | "openAiApiKey"
  115. | "geminiApiKey"
  116. | "openAiNativeApiKey"
  117. | "deepSeekApiKey"
  118. | "mistralApiKey"
  119. | "unboundApiKey"
  120. | "requestyApiKey"
  121. export type GlobalStateKey =
  122. | "apiProvider"
  123. | "apiModelId"
  124. | "glamaModelId"
  125. | "glamaModelInfo"
  126. | "awsRegion"
  127. | "awsUseCrossRegionInference"
  128. | "awsProfile"
  129. | "awsUseProfile"
  130. | "awsCustomArn"
  131. | "vertexKeyFile"
  132. | "vertexJsonCredentials"
  133. | "vertexProjectId"
  134. | "vertexRegion"
  135. | "lastShownAnnouncementId"
  136. | "customInstructions"
  137. | "alwaysAllowReadOnly"
  138. | "alwaysAllowWrite"
  139. | "alwaysAllowExecute"
  140. | "alwaysAllowBrowser"
  141. | "alwaysAllowMcp"
  142. | "alwaysAllowModeSwitch"
  143. | "alwaysAllowSubtasks"
  144. | "taskHistory"
  145. | "openAiBaseUrl"
  146. | "openAiModelId"
  147. | "openAiCustomModelInfo"
  148. | "openAiUseAzure"
  149. | "ollamaModelId"
  150. | "ollamaBaseUrl"
  151. | "lmStudioModelId"
  152. | "lmStudioBaseUrl"
  153. | "anthropicBaseUrl"
  154. | "modelMaxThinkingTokens"
  155. | "azureApiVersion"
  156. | "openAiStreamingEnabled"
  157. | "openRouterModelId"
  158. | "openRouterModelInfo"
  159. | "openRouterBaseUrl"
  160. | "openRouterUseMiddleOutTransform"
  161. | "googleGeminiBaseUrl"
  162. | "allowedCommands"
  163. | "soundEnabled"
  164. | "soundVolume"
  165. | "diffEnabled"
  166. | "enableCheckpoints"
  167. | "checkpointStorage"
  168. | "browserViewportSize"
  169. | "screenshotQuality"
  170. | "remoteBrowserHost"
  171. | "fuzzyMatchThreshold"
  172. | "writeDelayMs"
  173. | "terminalOutputLineLimit"
  174. | "mcpEnabled"
  175. | "enableMcpServerCreation"
  176. | "alwaysApproveResubmit"
  177. | "requestDelaySeconds"
  178. | "rateLimitSeconds"
  179. | "currentApiConfigName"
  180. | "listApiConfigMeta"
  181. | "vsCodeLmModelSelector"
  182. | "mode"
  183. | "modeApiConfigs"
  184. | "customModePrompts"
  185. | "customSupportPrompts"
  186. | "enhancementApiConfigId"
  187. | "experiments" // Map of experiment IDs to their enabled state
  188. | "autoApprovalEnabled"
  189. | "enableCustomModeCreation" // Enable the ability for Roo to create custom modes
  190. | "customModes" // Array of custom modes
  191. | "unboundModelId"
  192. | "requestyModelId"
  193. | "requestyModelInfo"
  194. | "unboundModelInfo"
  195. | "modelTemperature"
  196. | "modelMaxTokens"
  197. | "mistralCodestralUrl"
  198. | "maxOpenTabsContext"
  199. | "maxWorkspaceFiles"
  200. | "browserToolEnabled"
  201. | "lmStudioSpeculativeDecodingEnabled"
  202. | "lmStudioDraftModelId"
  203. | "telemetrySetting"
  204. | "showRooIgnoredFiles"
  205. | "remoteBrowserEnabled"
  206. | "language"
  207. export type ConfigurationKey = GlobalStateKey | SecretKey
  208. export type ConfigurationValues = Record<ConfigurationKey, any>