WebviewMessage.ts 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. import { z } from "zod"
  2. import type { ProviderSettings, PromptComponent, ModeConfig } from "@roo-code/types"
  3. import { InstallMarketplaceItemOptions, MarketplaceItem } from "../services/marketplace/types"
  4. import { marketplaceItemSchema } from "../services/marketplace/schemas"
  5. import { Mode } from "./modes"
  6. export type ClineAskResponse = "yesButtonClicked" | "noButtonClicked" | "messageResponse" | "objectResponse"
  7. export type PromptMode = Mode | "enhance"
  8. export type AudioType = "notification" | "celebration" | "progress_loop"
  9. export interface WebviewMessage {
  10. type:
  11. | "deleteMultipleTasksWithIds"
  12. | "currentApiConfigName"
  13. | "saveApiConfiguration"
  14. | "upsertApiConfiguration"
  15. | "deleteApiConfiguration"
  16. | "loadApiConfiguration"
  17. | "loadApiConfigurationById"
  18. | "renameApiConfiguration"
  19. | "getListApiConfiguration"
  20. | "customInstructions"
  21. | "allowedCommands"
  22. | "alwaysAllowReadOnly"
  23. | "alwaysAllowReadOnlyOutsideWorkspace"
  24. | "alwaysAllowWrite"
  25. | "alwaysAllowWriteOutsideWorkspace"
  26. | "alwaysAllowExecute"
  27. | "webviewDidLaunch"
  28. | "newTask"
  29. | "askResponse"
  30. | "terminalOperation"
  31. | "clearTask"
  32. | "didShowAnnouncement"
  33. | "selectImages"
  34. | "exportCurrentTask"
  35. | "shareCurrentTask"
  36. | "showTaskWithId"
  37. | "deleteTaskWithId"
  38. | "exportTaskWithId"
  39. | "importSettings"
  40. | "exportSettings"
  41. | "resetState"
  42. | "flushRouterModels"
  43. | "requestRouterModels"
  44. | "requestOpenAiModels"
  45. | "requestOllamaModels"
  46. | "requestLmStudioModels"
  47. | "requestVsCodeLmModels"
  48. | "openImage"
  49. | "saveImage"
  50. | "openFile"
  51. | "openMention"
  52. | "cancelTask"
  53. | "updateVSCodeSetting"
  54. | "getVSCodeSetting"
  55. | "vsCodeSetting"
  56. | "alwaysAllowBrowser"
  57. | "alwaysAllowMcp"
  58. | "alwaysAllowModeSwitch"
  59. | "allowedMaxRequests"
  60. | "alwaysAllowSubtasks"
  61. | "autoCondenseContext"
  62. | "autoCondenseContextPercent"
  63. | "condensingApiConfigId"
  64. | "updateCondensingPrompt"
  65. | "playSound"
  66. | "playTts"
  67. | "stopTts"
  68. | "soundEnabled"
  69. | "ttsEnabled"
  70. | "ttsSpeed"
  71. | "soundVolume"
  72. | "diffEnabled"
  73. | "enableCheckpoints"
  74. | "browserViewportSize"
  75. | "screenshotQuality"
  76. | "remoteBrowserHost"
  77. | "openMcpSettings"
  78. | "openProjectMcpSettings"
  79. | "restartMcpServer"
  80. | "refreshAllMcpServers"
  81. | "toggleToolAlwaysAllow"
  82. | "toggleMcpServer"
  83. | "updateMcpTimeout"
  84. | "fuzzyMatchThreshold"
  85. | "writeDelayMs"
  86. | "enhancePrompt"
  87. | "enhancedPrompt"
  88. | "draggedImages"
  89. | "deleteMessage"
  90. | "terminalOutputLineLimit"
  91. | "terminalShellIntegrationTimeout"
  92. | "terminalShellIntegrationDisabled"
  93. | "terminalCommandDelay"
  94. | "terminalPowershellCounter"
  95. | "terminalZshClearEolMark"
  96. | "terminalZshOhMy"
  97. | "terminalZshP10k"
  98. | "terminalZdotdir"
  99. | "terminalCompressProgressBar"
  100. | "mcpEnabled"
  101. | "enableMcpServerCreation"
  102. | "searchCommits"
  103. | "alwaysApproveResubmit"
  104. | "requestDelaySeconds"
  105. | "setApiConfigPassword"
  106. | "mode"
  107. | "updatePrompt"
  108. | "updateSupportPrompt"
  109. | "resetSupportPrompt"
  110. | "getSystemPrompt"
  111. | "copySystemPrompt"
  112. | "systemPrompt"
  113. | "enhancementApiConfigId"
  114. | "updateExperimental"
  115. | "autoApprovalEnabled"
  116. | "updateCustomMode"
  117. | "deleteCustomMode"
  118. | "setopenAiCustomModelInfo"
  119. | "openCustomModesSettings"
  120. | "checkpointDiff"
  121. | "checkpointRestore"
  122. | "deleteMcpServer"
  123. | "maxOpenTabsContext"
  124. | "maxWorkspaceFiles"
  125. | "humanRelayResponse"
  126. | "humanRelayCancel"
  127. | "browserToolEnabled"
  128. | "telemetrySetting"
  129. | "showRooIgnoredFiles"
  130. | "testBrowserConnection"
  131. | "browserConnectionResult"
  132. | "remoteBrowserEnabled"
  133. | "language"
  134. | "maxReadFileLine"
  135. | "maxConcurrentFileReads"
  136. | "searchFiles"
  137. | "toggleApiConfigPin"
  138. | "setHistoryPreviewCollapsed"
  139. | "accountButtonClicked"
  140. | "rooCloudSignIn"
  141. | "rooCloudSignOut"
  142. | "condenseTaskContextRequest"
  143. | "requestIndexingStatus"
  144. | "startIndexing"
  145. | "clearIndexData"
  146. | "indexingStatusUpdate"
  147. | "indexCleared"
  148. | "codebaseIndexConfig"
  149. | "setHistoryPreviewCollapsed"
  150. | "openExternal"
  151. | "filterMarketplaceItems"
  152. | "marketplaceButtonClicked"
  153. | "installMarketplaceItem"
  154. | "installMarketplaceItemWithParameters"
  155. | "cancelMarketplaceInstall"
  156. | "removeInstalledMarketplaceItem"
  157. | "marketplaceInstallResult"
  158. | "switchTab"
  159. text?: string
  160. tab?: "settings" | "history" | "mcp" | "modes" | "chat" | "marketplace" | "account"
  161. disabled?: boolean
  162. dataUri?: string
  163. askResponse?: ClineAskResponse
  164. apiConfiguration?: ProviderSettings
  165. images?: string[]
  166. bool?: boolean
  167. value?: number
  168. commands?: string[]
  169. audioType?: AudioType
  170. serverName?: string
  171. toolName?: string
  172. alwaysAllow?: boolean
  173. mode?: Mode
  174. promptMode?: PromptMode
  175. customPrompt?: PromptComponent
  176. dataUrls?: string[]
  177. values?: Record<string, any>
  178. query?: string
  179. setting?: string
  180. slug?: string
  181. modeConfig?: ModeConfig
  182. timeout?: number
  183. payload?: WebViewMessagePayload
  184. source?: "global" | "project"
  185. requestId?: string
  186. ids?: string[]
  187. hasSystemPromptOverride?: boolean
  188. terminalOperation?: "continue" | "abort"
  189. historyPreviewCollapsed?: boolean
  190. filters?: { type?: string; search?: string; tags?: string[] }
  191. url?: string // For openExternal
  192. mpItem?: MarketplaceItem
  193. mpInstallOptions?: InstallMarketplaceItemOptions
  194. config?: Record<string, any> // Add config to the payload
  195. }
  196. export const checkoutDiffPayloadSchema = z.object({
  197. ts: z.number(),
  198. previousCommitHash: z.string().optional(),
  199. commitHash: z.string(),
  200. mode: z.enum(["full", "checkpoint"]),
  201. })
  202. export type CheckpointDiffPayload = z.infer<typeof checkoutDiffPayloadSchema>
  203. export const checkoutRestorePayloadSchema = z.object({
  204. ts: z.number(),
  205. commitHash: z.string(),
  206. mode: z.enum(["preview", "restore"]),
  207. })
  208. export type CheckpointRestorePayload = z.infer<typeof checkoutRestorePayloadSchema>
  209. export interface IndexingStatusPayload {
  210. state: "Standby" | "Indexing" | "Indexed" | "Error"
  211. message: string
  212. }
  213. export interface IndexClearedPayload {
  214. success: boolean
  215. error?: string
  216. }
  217. export const installMarketplaceItemWithParametersPayloadSchema = z.object({
  218. item: marketplaceItemSchema.strict(),
  219. parameters: z.record(z.string(), z.any()),
  220. })
  221. export type InstallMarketplaceItemWithParametersPayload = z.infer<
  222. typeof installMarketplaceItemWithParametersPayloadSchema
  223. >
  224. export type WebViewMessagePayload =
  225. | CheckpointDiffPayload
  226. | CheckpointRestorePayload
  227. | IndexingStatusPayload
  228. | IndexClearedPayload
  229. | InstallMarketplaceItemWithParametersPayload