WebviewMessage.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. import { z } from "zod"
  2. import { ApiConfiguration, ApiProvider } from "./api"
  3. import { Mode, PromptComponent, ModeConfig } from "./modes"
  4. export type ClineAskResponse = "yesButtonClicked" | "noButtonClicked" | "messageResponse"
  5. export type PromptMode = Mode | "enhance"
  6. export type AudioType = "notification" | "celebration" | "progress_loop"
  7. export interface WebviewMessage {
  8. type:
  9. | "apiConfiguration"
  10. | "deleteMultipleTasksWithIds"
  11. | "currentApiConfigName"
  12. | "saveApiConfiguration"
  13. | "upsertApiConfiguration"
  14. | "deleteApiConfiguration"
  15. | "loadApiConfiguration"
  16. | "loadApiConfigurationById"
  17. | "renameApiConfiguration"
  18. | "getListApiConfiguration"
  19. | "customInstructions"
  20. | "allowedCommands"
  21. | "alwaysAllowReadOnly"
  22. | "alwaysAllowReadOnlyOutsideWorkspace"
  23. | "alwaysAllowWrite"
  24. | "alwaysAllowWriteOutsideWorkspace"
  25. | "alwaysAllowExecute"
  26. | "webviewDidLaunch"
  27. | "newTask"
  28. | "askResponse"
  29. | "clearTask"
  30. | "didShowAnnouncement"
  31. | "selectImages"
  32. | "exportCurrentTask"
  33. | "showTaskWithId"
  34. | "deleteTaskWithId"
  35. | "exportTaskWithId"
  36. | "importSettings"
  37. | "exportSettings"
  38. | "resetState"
  39. | "requestOllamaModels"
  40. | "requestLmStudioModels"
  41. | "openImage"
  42. | "openFile"
  43. | "openMention"
  44. | "cancelTask"
  45. | "refreshOpenRouterModels"
  46. | "refreshGlamaModels"
  47. | "refreshUnboundModels"
  48. | "refreshRequestyModels"
  49. | "refreshOpenAiModels"
  50. | "alwaysAllowBrowser"
  51. | "alwaysAllowMcp"
  52. | "alwaysAllowModeSwitch"
  53. | "alwaysAllowSubtasks"
  54. | "playSound"
  55. | "playTts"
  56. | "stopTts"
  57. | "soundEnabled"
  58. | "ttsEnabled"
  59. | "ttsSpeed"
  60. | "soundVolume"
  61. | "diffEnabled"
  62. | "enableCheckpoints"
  63. | "checkpointStorage"
  64. | "browserViewportSize"
  65. | "screenshotQuality"
  66. | "remoteBrowserHost"
  67. | "openMcpSettings"
  68. | "openProjectMcpSettings"
  69. | "restartMcpServer"
  70. | "toggleToolAlwaysAllow"
  71. | "toggleMcpServer"
  72. | "updateMcpTimeout"
  73. | "fuzzyMatchThreshold"
  74. | "writeDelayMs"
  75. | "enhancePrompt"
  76. | "enhancedPrompt"
  77. | "draggedImages"
  78. | "deleteMessage"
  79. | "terminalOutputLineLimit"
  80. | "terminalShellIntegrationTimeout"
  81. | "terminalCommandDelay"
  82. | "terminalPowershellCounter"
  83. | "terminalZshClearEolMark"
  84. | "terminalZshOhMy"
  85. | "terminalZshP10k"
  86. | "terminalZdotdir"
  87. | "mcpEnabled"
  88. | "enableMcpServerCreation"
  89. | "searchCommits"
  90. | "alwaysApproveResubmit"
  91. | "requestDelaySeconds"
  92. | "setApiConfigPassword"
  93. | "requestVsCodeLmModels"
  94. | "mode"
  95. | "updatePrompt"
  96. | "updateSupportPrompt"
  97. | "resetSupportPrompt"
  98. | "getSystemPrompt"
  99. | "copySystemPrompt"
  100. | "systemPrompt"
  101. | "enhancementApiConfigId"
  102. | "updateExperimental"
  103. | "autoApprovalEnabled"
  104. | "updateCustomMode"
  105. | "deleteCustomMode"
  106. | "setopenAiCustomModelInfo"
  107. | "openCustomModesSettings"
  108. | "checkpointDiff"
  109. | "checkpointRestore"
  110. | "deleteMcpServer"
  111. | "maxOpenTabsContext"
  112. | "maxWorkspaceFiles"
  113. | "humanRelayResponse"
  114. | "humanRelayCancel"
  115. | "browserToolEnabled"
  116. | "telemetrySetting"
  117. | "showRooIgnoredFiles"
  118. | "testBrowserConnection"
  119. | "browserConnectionResult"
  120. | "remoteBrowserEnabled"
  121. | "language"
  122. | "maxReadFileLine"
  123. | "searchFiles"
  124. | "toggleApiConfigPin"
  125. | "showGreeting"
  126. text?: string
  127. disabled?: boolean
  128. askResponse?: ClineAskResponse
  129. apiConfiguration?: ApiConfiguration
  130. images?: string[]
  131. bool?: boolean
  132. value?: number
  133. commands?: string[]
  134. audioType?: AudioType
  135. serverName?: string
  136. toolName?: string
  137. alwaysAllow?: boolean
  138. mode?: Mode
  139. promptMode?: PromptMode
  140. customPrompt?: PromptComponent
  141. dataUrls?: string[]
  142. values?: Record<string, any>
  143. query?: string
  144. slug?: string
  145. modeConfig?: ModeConfig
  146. timeout?: number
  147. payload?: WebViewMessagePayload
  148. source?: "global" | "project"
  149. requestId?: string
  150. ids?: string[]
  151. }
  152. export const checkoutDiffPayloadSchema = z.object({
  153. ts: z.number(),
  154. previousCommitHash: z.string().optional(),
  155. commitHash: z.string(),
  156. mode: z.enum(["full", "checkpoint"]),
  157. })
  158. export type CheckpointDiffPayload = z.infer<typeof checkoutDiffPayloadSchema>
  159. export const checkoutRestorePayloadSchema = z.object({
  160. ts: z.number(),
  161. commitHash: z.string(),
  162. mode: z.enum(["preview", "restore"]),
  163. })
  164. export type CheckpointRestorePayload = z.infer<typeof checkoutRestorePayloadSchema>
  165. export type WebViewMessagePayload = CheckpointDiffPayload | CheckpointRestorePayload