ExtensionMessage.ts 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. import { ApiConfiguration, ModelInfo } from "./api"
  2. import { HistoryItem } from "./HistoryItem"
  3. import { McpServer } from "./mcp"
  4. import { GitCommit } from "../utils/git"
  5. import { Mode, ModeConfig } from "./modes"
  6. import { ExperimentId } from "./experiments"
  7. import { CheckpointStorage } from "./checkpoints"
  8. import { TelemetrySetting } from "./TelemetrySetting"
  9. import type { GlobalSettings, ApiConfigMeta, ClineMessage, ClineAsk, ClineSay } from "../exports/roo-code"
  10. export type { ApiConfigMeta }
  11. export interface LanguageModelChatSelector {
  12. vendor?: string
  13. family?: string
  14. version?: string
  15. id?: string
  16. }
  17. // Represents JSON data that is sent from extension to webview, called
  18. // ExtensionMessage and has 'type' enum which can be 'plusButtonClicked' or
  19. // 'settingsButtonClicked' or 'hello'. Webview will hold state.
  20. export interface ExtensionMessage {
  21. type:
  22. | "action"
  23. | "state"
  24. | "selectedImages"
  25. | "ollamaModels"
  26. | "lmStudioModels"
  27. | "theme"
  28. | "workspaceUpdated"
  29. | "invoke"
  30. | "partialMessage"
  31. | "openRouterModels"
  32. | "glamaModels"
  33. | "unboundModels"
  34. | "requestyModels"
  35. | "openAiModels"
  36. | "mcpServers"
  37. | "enhancedPrompt"
  38. | "commitSearchResults"
  39. | "listApiConfig"
  40. | "vsCodeLmModels"
  41. | "vsCodeLmApiAvailable"
  42. | "requestVsCodeLmModels"
  43. | "updatePrompt"
  44. | "systemPrompt"
  45. | "autoApprovalEnabled"
  46. | "updateCustomMode"
  47. | "deleteCustomMode"
  48. | "currentCheckpointUpdated"
  49. | "showHumanRelayDialog"
  50. | "humanRelayResponse"
  51. | "humanRelayCancel"
  52. | "browserToolEnabled"
  53. | "browserConnectionResult"
  54. | "remoteBrowserEnabled"
  55. | "ttsStart"
  56. | "ttsStop"
  57. | "maxReadFileLine"
  58. | "fileSearchResults"
  59. | "toggleApiConfigPin"
  60. text?: string
  61. action?:
  62. | "chatButtonClicked"
  63. | "mcpButtonClicked"
  64. | "settingsButtonClicked"
  65. | "historyButtonClicked"
  66. | "promptsButtonClicked"
  67. | "didBecomeVisible"
  68. invoke?: "newChat" | "sendMessage" | "primaryButtonClick" | "secondaryButtonClick" | "setChatBoxMessage"
  69. state?: ExtensionState
  70. images?: string[]
  71. ollamaModels?: string[]
  72. lmStudioModels?: string[]
  73. vsCodeLmModels?: { vendor?: string; family?: string; version?: string; id?: string }[]
  74. filePaths?: string[]
  75. openedTabs?: Array<{
  76. label: string
  77. isActive: boolean
  78. path?: string
  79. }>
  80. partialMessage?: ClineMessage
  81. openRouterModels?: Record<string, ModelInfo>
  82. glamaModels?: Record<string, ModelInfo>
  83. unboundModels?: Record<string, ModelInfo>
  84. requestyModels?: Record<string, ModelInfo>
  85. openAiModels?: string[]
  86. mcpServers?: McpServer[]
  87. commits?: GitCommit[]
  88. listApiConfig?: ApiConfigMeta[]
  89. mode?: Mode
  90. customMode?: ModeConfig
  91. slug?: string
  92. success?: boolean
  93. values?: Record<string, any>
  94. requestId?: string
  95. promptText?: string
  96. results?: Array<{
  97. path: string
  98. type: "file" | "folder"
  99. label?: string
  100. }>
  101. error?: string
  102. }
  103. export type ExtensionState = Pick<
  104. GlobalSettings,
  105. | "currentApiConfigName"
  106. | "listApiConfigMeta"
  107. | "pinnedApiConfigs"
  108. // | "lastShownAnnouncementId"
  109. | "customInstructions"
  110. // | "taskHistory" // Optional in GlobalSettings, required here.
  111. | "autoApprovalEnabled"
  112. | "alwaysAllowReadOnly"
  113. | "alwaysAllowReadOnlyOutsideWorkspace"
  114. | "alwaysAllowWrite"
  115. | "alwaysAllowWriteOutsideWorkspace"
  116. // | "writeDelayMs" // Optional in GlobalSettings, required here.
  117. | "alwaysAllowBrowser"
  118. | "alwaysApproveResubmit"
  119. // | "requestDelaySeconds" // Optional in GlobalSettings, required here.
  120. | "alwaysAllowMcp"
  121. | "alwaysAllowModeSwitch"
  122. | "alwaysAllowSubtasks"
  123. | "alwaysAllowExecute"
  124. | "allowedCommands"
  125. | "browserToolEnabled"
  126. | "browserViewportSize"
  127. | "screenshotQuality"
  128. | "remoteBrowserEnabled"
  129. | "remoteBrowserHost"
  130. // | "enableCheckpoints" // Optional in GlobalSettings, required here.
  131. // | "checkpointStorage" // Optional in GlobalSettings, required here.
  132. | "ttsEnabled"
  133. | "ttsSpeed"
  134. | "soundEnabled"
  135. | "soundVolume"
  136. // | "maxOpenTabsContext" // Optional in GlobalSettings, required here.
  137. // | "maxWorkspaceFiles" // Optional in GlobalSettings, required here.
  138. // | "showRooIgnoredFiles" // Optional in GlobalSettings, required here.
  139. // | "maxReadFileLine" // Optional in GlobalSettings, required here.
  140. | "terminalOutputLineLimit"
  141. | "terminalShellIntegrationTimeout"
  142. // | "rateLimitSeconds" // Optional in GlobalSettings, required here.
  143. | "diffEnabled"
  144. | "fuzzyMatchThreshold"
  145. // | "experiments" // Optional in GlobalSettings, required here.
  146. | "language"
  147. // | "telemetrySetting" // Optional in GlobalSettings, required here.
  148. // | "mcpEnabled" // Optional in GlobalSettings, required here.
  149. // | "enableMcpServerCreation" // Optional in GlobalSettings, required here.
  150. // | "mode" // Optional in GlobalSettings, required here.
  151. | "modeApiConfigs"
  152. // | "customModes" // Optional in GlobalSettings, required here.
  153. | "customModePrompts"
  154. | "customSupportPrompts"
  155. | "enhancementApiConfigId"
  156. > & {
  157. version: string
  158. osInfo: string
  159. clineMessages: ClineMessage[]
  160. currentTaskItem?: HistoryItem
  161. apiConfiguration?: ApiConfiguration
  162. uriScheme?: string
  163. shouldShowAnnouncement: boolean
  164. taskHistory: HistoryItem[]
  165. writeDelayMs: number
  166. requestDelaySeconds: number
  167. enableCheckpoints: boolean
  168. checkpointStorage: CheckpointStorage
  169. maxOpenTabsContext: number // Maximum number of VSCode open tabs to include in context (0-500)
  170. maxWorkspaceFiles: number // Maximum number of files to include in current working directory details (0-500)
  171. showRooIgnoredFiles: boolean // Whether to show .rooignore'd files in listings
  172. maxReadFileLine: number // Maximum number of lines to read from a file before truncating
  173. rateLimitSeconds: number // Minimum time between successive requests (0 = disabled).
  174. experiments: Record<ExperimentId, boolean> // Map of experiment IDs to their enabled state
  175. mcpEnabled: boolean
  176. enableMcpServerCreation: boolean
  177. mode: Mode
  178. customModes: ModeConfig[]
  179. toolRequirements?: Record<string, boolean> // Map of tool names to their requirements (e.g. {"apply_diff": true} if diffEnabled)
  180. cwd?: string // Current working directory
  181. telemetrySetting: TelemetrySetting
  182. telemetryKey?: string
  183. machineId?: string
  184. renderContext: "sidebar" | "editor"
  185. settingsImportedAt?: number
  186. }
  187. export type { ClineMessage, ClineAsk, ClineSay }
  188. export interface ClineSayTool {
  189. tool:
  190. | "editedExistingFile"
  191. | "appliedDiff"
  192. | "newFileCreated"
  193. | "readFile"
  194. | "fetchInstructions"
  195. | "listFilesTopLevel"
  196. | "listFilesRecursive"
  197. | "listCodeDefinitionNames"
  198. | "searchFiles"
  199. | "switchMode"
  200. | "newTask"
  201. | "finishTask"
  202. path?: string
  203. diff?: string
  204. content?: string
  205. regex?: string
  206. filePattern?: string
  207. mode?: string
  208. reason?: string
  209. isOutsideWorkspace?: boolean
  210. }
  211. // Must keep in sync with system prompt.
  212. export const browserActions = ["launch", "click", "type", "scroll_down", "scroll_up", "close"] as const
  213. export type BrowserAction = (typeof browserActions)[number]
  214. export interface ClineSayBrowserAction {
  215. action: BrowserAction
  216. coordinate?: string
  217. text?: string
  218. }
  219. export type BrowserActionResult = {
  220. screenshot?: string
  221. logs?: string
  222. currentUrl?: string
  223. currentMousePosition?: string
  224. }
  225. export interface ClineAskUseMcpServer {
  226. serverName: string
  227. type: "use_mcp_tool" | "access_mcp_resource"
  228. toolName?: string
  229. arguments?: string
  230. uri?: string
  231. }
  232. export interface ClineApiReqInfo {
  233. request?: string
  234. tokensIn?: number
  235. tokensOut?: number
  236. cacheWrites?: number
  237. cacheReads?: number
  238. cost?: number
  239. cancelReason?: ClineApiReqCancelReason
  240. streamingFailedMessage?: string
  241. }
  242. export type ClineApiReqCancelReason = "streaming_failed" | "user_cancelled"
  243. export type ToolProgressStatus = {
  244. icon?: string
  245. text?: string
  246. }