WebviewMessage.ts 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. import { z } from "zod"
  2. import {
  3. type ProviderSettings,
  4. type PromptComponent,
  5. type ModeConfig,
  6. type InstallMarketplaceItemOptions,
  7. type MarketplaceItem,
  8. marketplaceItemSchema,
  9. } from "@roo-code/types"
  10. import type { ShareVisibility } from "@roo-code/cloud"
  11. import { Mode } from "./modes"
  12. export type ClineAskResponse = "yesButtonClicked" | "noButtonClicked" | "messageResponse" | "objectResponse"
  13. export type PromptMode = Mode | "enhance"
  14. export type AudioType = "notification" | "celebration" | "progress_loop"
  15. export interface UpdateTodoListPayload {
  16. todos: any[]
  17. }
  18. export interface WebviewMessage {
  19. type:
  20. | "updateTodoList"
  21. | "deleteMultipleTasksWithIds"
  22. | "currentApiConfigName"
  23. | "saveApiConfiguration"
  24. | "upsertApiConfiguration"
  25. | "deleteApiConfiguration"
  26. | "loadApiConfiguration"
  27. | "loadApiConfigurationById"
  28. | "renameApiConfiguration"
  29. | "getListApiConfiguration"
  30. | "customInstructions"
  31. | "allowedCommands"
  32. | "deniedCommands"
  33. | "alwaysAllowReadOnly"
  34. | "alwaysAllowReadOnlyOutsideWorkspace"
  35. | "alwaysAllowWrite"
  36. | "alwaysAllowWriteOutsideWorkspace"
  37. | "alwaysAllowWriteProtected"
  38. | "alwaysAllowExecute"
  39. | "alwaysAllowFollowupQuestions"
  40. | "alwaysAllowUpdateTodoList"
  41. | "followupAutoApproveTimeoutMs"
  42. | "webviewDidLaunch"
  43. | "newTask"
  44. | "askResponse"
  45. | "terminalOperation"
  46. | "clearTask"
  47. | "didShowAnnouncement"
  48. | "selectImages"
  49. | "exportCurrentTask"
  50. | "shareCurrentTask"
  51. | "showTaskWithId"
  52. | "deleteTaskWithId"
  53. | "exportTaskWithId"
  54. | "importSettings"
  55. | "exportSettings"
  56. | "resetState"
  57. | "flushRouterModels"
  58. | "requestRouterModels"
  59. | "requestOpenAiModels"
  60. | "requestOllamaModels"
  61. | "requestLmStudioModels"
  62. | "requestVsCodeLmModels"
  63. | "requestHuggingFaceModels"
  64. | "openImage"
  65. | "saveImage"
  66. | "openFile"
  67. | "openMention"
  68. | "cancelTask"
  69. | "updateVSCodeSetting"
  70. | "getVSCodeSetting"
  71. | "vsCodeSetting"
  72. | "alwaysAllowBrowser"
  73. | "alwaysAllowMcp"
  74. | "alwaysAllowModeSwitch"
  75. | "allowedMaxRequests"
  76. | "allowedMaxCost"
  77. | "alwaysAllowSubtasks"
  78. | "alwaysAllowUpdateTodoList"
  79. | "autoCondenseContext"
  80. | "autoCondenseContextPercent"
  81. | "condensingApiConfigId"
  82. | "updateCondensingPrompt"
  83. | "playSound"
  84. | "playTts"
  85. | "stopTts"
  86. | "soundEnabled"
  87. | "ttsEnabled"
  88. | "ttsSpeed"
  89. | "soundVolume"
  90. | "diffEnabled"
  91. | "enableCheckpoints"
  92. | "browserViewportSize"
  93. | "screenshotQuality"
  94. | "remoteBrowserHost"
  95. | "openMcpSettings"
  96. | "openProjectMcpSettings"
  97. | "restartMcpServer"
  98. | "refreshAllMcpServers"
  99. | "toggleToolAlwaysAllow"
  100. | "toggleToolEnabledForPrompt"
  101. | "toggleMcpServer"
  102. | "updateMcpTimeout"
  103. | "fuzzyMatchThreshold"
  104. | "writeDelayMs"
  105. | "diagnosticsEnabled"
  106. | "enhancePrompt"
  107. | "enhancedPrompt"
  108. | "draggedImages"
  109. | "deleteMessage"
  110. | "deleteMessageConfirm"
  111. | "submitEditedMessage"
  112. | "editMessageConfirm"
  113. | "terminalOutputLineLimit"
  114. | "terminalOutputCharacterLimit"
  115. | "terminalShellIntegrationTimeout"
  116. | "terminalShellIntegrationDisabled"
  117. | "terminalCommandDelay"
  118. | "terminalPowershellCounter"
  119. | "terminalZshClearEolMark"
  120. | "terminalZshOhMy"
  121. | "terminalZshP10k"
  122. | "terminalZdotdir"
  123. | "terminalCompressProgressBar"
  124. | "mcpEnabled"
  125. | "enableMcpServerCreation"
  126. | "remoteControlEnabled"
  127. | "searchCommits"
  128. | "alwaysApproveResubmit"
  129. | "requestDelaySeconds"
  130. | "setApiConfigPassword"
  131. | "mode"
  132. | "updatePrompt"
  133. | "updateSupportPrompt"
  134. | "getSystemPrompt"
  135. | "copySystemPrompt"
  136. | "systemPrompt"
  137. | "enhancementApiConfigId"
  138. | "includeTaskHistoryInEnhance"
  139. | "updateExperimental"
  140. | "autoApprovalEnabled"
  141. | "updateCustomMode"
  142. | "deleteCustomMode"
  143. | "setopenAiCustomModelInfo"
  144. | "openCustomModesSettings"
  145. | "checkpointDiff"
  146. | "checkpointRestore"
  147. | "deleteMcpServer"
  148. | "maxOpenTabsContext"
  149. | "maxWorkspaceFiles"
  150. | "humanRelayResponse"
  151. | "humanRelayCancel"
  152. | "browserToolEnabled"
  153. | "codebaseIndexEnabled"
  154. | "telemetrySetting"
  155. | "showRooIgnoredFiles"
  156. | "testBrowserConnection"
  157. | "browserConnectionResult"
  158. | "remoteBrowserEnabled"
  159. | "language"
  160. | "maxReadFileLine"
  161. | "maxImageFileSize"
  162. | "maxTotalImageSize"
  163. | "maxConcurrentFileReads"
  164. | "includeDiagnosticMessages"
  165. | "maxDiagnosticMessages"
  166. | "searchFiles"
  167. | "toggleApiConfigPin"
  168. | "setHistoryPreviewCollapsed"
  169. | "hasOpenedModeSelector"
  170. | "accountButtonClicked"
  171. | "rooCloudSignIn"
  172. | "rooCloudSignOut"
  173. | "condenseTaskContextRequest"
  174. | "requestIndexingStatus"
  175. | "startIndexing"
  176. | "clearIndexData"
  177. | "indexingStatusUpdate"
  178. | "indexCleared"
  179. | "focusPanelRequest"
  180. | "profileThresholds"
  181. | "setHistoryPreviewCollapsed"
  182. | "openExternal"
  183. | "filterMarketplaceItems"
  184. | "marketplaceButtonClicked"
  185. | "installMarketplaceItem"
  186. | "installMarketplaceItemWithParameters"
  187. | "cancelMarketplaceInstall"
  188. | "removeInstalledMarketplaceItem"
  189. | "marketplaceInstallResult"
  190. | "fetchMarketplaceData"
  191. | "switchTab"
  192. | "profileThresholds"
  193. | "shareTaskSuccess"
  194. | "exportMode"
  195. | "exportModeResult"
  196. | "importMode"
  197. | "importModeResult"
  198. | "checkRulesDirectory"
  199. | "checkRulesDirectoryResult"
  200. | "saveCodeIndexSettingsAtomic"
  201. | "requestCodeIndexSecretStatus"
  202. | "requestCommands"
  203. | "openCommandFile"
  204. | "deleteCommand"
  205. | "createCommand"
  206. | "insertTextIntoTextarea"
  207. text?: string
  208. editedMessageContent?: string
  209. tab?: "settings" | "history" | "mcp" | "modes" | "chat" | "marketplace" | "account"
  210. disabled?: boolean
  211. context?: string
  212. dataUri?: string
  213. askResponse?: ClineAskResponse
  214. apiConfiguration?: ProviderSettings
  215. images?: string[]
  216. bool?: boolean
  217. value?: number
  218. commands?: string[]
  219. audioType?: AudioType
  220. serverName?: string
  221. toolName?: string
  222. alwaysAllow?: boolean
  223. isEnabled?: boolean
  224. mode?: Mode
  225. promptMode?: PromptMode
  226. customPrompt?: PromptComponent
  227. dataUrls?: string[]
  228. values?: Record<string, any>
  229. query?: string
  230. setting?: string
  231. slug?: string
  232. modeConfig?: ModeConfig
  233. timeout?: number
  234. payload?: WebViewMessagePayload
  235. source?: "global" | "project"
  236. requestId?: string
  237. ids?: string[]
  238. hasSystemPromptOverride?: boolean
  239. terminalOperation?: "continue" | "abort"
  240. messageTs?: number
  241. historyPreviewCollapsed?: boolean
  242. filters?: { type?: string; search?: string; tags?: string[] }
  243. url?: string // For openExternal
  244. mpItem?: MarketplaceItem
  245. mpInstallOptions?: InstallMarketplaceItemOptions
  246. config?: Record<string, any> // Add config to the payload
  247. visibility?: ShareVisibility // For share visibility
  248. hasContent?: boolean // For checkRulesDirectoryResult
  249. checkOnly?: boolean // For deleteCustomMode check
  250. codeIndexSettings?: {
  251. // Global state settings
  252. codebaseIndexEnabled: boolean
  253. codebaseIndexQdrantUrl: string
  254. codebaseIndexEmbedderProvider: "openai" | "ollama" | "openai-compatible" | "gemini" | "mistral"
  255. codebaseIndexEmbedderBaseUrl?: string
  256. codebaseIndexEmbedderModelId: string
  257. codebaseIndexEmbedderModelDimension?: number // Generic dimension for all providers
  258. codebaseIndexOpenAiCompatibleBaseUrl?: string
  259. codebaseIndexSearchMaxResults?: number
  260. codebaseIndexSearchMinScore?: number
  261. // Secret settings
  262. codeIndexOpenAiKey?: string
  263. codeIndexQdrantApiKey?: string
  264. codebaseIndexOpenAiCompatibleApiKey?: string
  265. codebaseIndexGeminiApiKey?: string
  266. codebaseIndexMistralApiKey?: string
  267. }
  268. }
  269. export const checkoutDiffPayloadSchema = z.object({
  270. ts: z.number(),
  271. previousCommitHash: z.string().optional(),
  272. commitHash: z.string(),
  273. mode: z.enum(["full", "checkpoint"]),
  274. })
  275. export type CheckpointDiffPayload = z.infer<typeof checkoutDiffPayloadSchema>
  276. export const checkoutRestorePayloadSchema = z.object({
  277. ts: z.number(),
  278. commitHash: z.string(),
  279. mode: z.enum(["preview", "restore"]),
  280. })
  281. export type CheckpointRestorePayload = z.infer<typeof checkoutRestorePayloadSchema>
  282. export interface IndexingStatusPayload {
  283. state: "Standby" | "Indexing" | "Indexed" | "Error"
  284. message: string
  285. }
  286. export interface IndexClearedPayload {
  287. success: boolean
  288. error?: string
  289. }
  290. export const installMarketplaceItemWithParametersPayloadSchema = z.object({
  291. item: marketplaceItemSchema,
  292. parameters: z.record(z.string(), z.any()),
  293. })
  294. export type InstallMarketplaceItemWithParametersPayload = z.infer<
  295. typeof installMarketplaceItemWithParametersPayloadSchema
  296. >
  297. export type WebViewMessagePayload =
  298. | CheckpointDiffPayload
  299. | CheckpointRestorePayload
  300. | IndexingStatusPayload
  301. | IndexClearedPayload
  302. | InstallMarketplaceItemWithParametersPayload
  303. | UpdateTodoListPayload