WebviewMessage.ts 9.2 KB

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