WebviewMessage.ts 9.1 KB

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