WebviewMessage.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. | "browserViewportSize"
  64. | "screenshotQuality"
  65. | "remoteBrowserHost"
  66. | "openMcpSettings"
  67. | "openProjectMcpSettings"
  68. | "restartMcpServer"
  69. | "toggleToolAlwaysAllow"
  70. | "toggleMcpServer"
  71. | "updateMcpTimeout"
  72. | "fuzzyMatchThreshold"
  73. | "writeDelayMs"
  74. | "enhancePrompt"
  75. | "enhancedPrompt"
  76. | "draggedImages"
  77. | "deleteMessage"
  78. | "terminalOutputLineLimit"
  79. | "terminalShellIntegrationTimeout"
  80. | "terminalCommandDelay"
  81. | "terminalPowershellCounter"
  82. | "terminalZshClearEolMark"
  83. | "terminalZshOhMy"
  84. | "terminalZshP10k"
  85. | "terminalZdotdir"
  86. | "mcpEnabled"
  87. | "enableMcpServerCreation"
  88. | "searchCommits"
  89. | "alwaysApproveResubmit"
  90. | "requestDelaySeconds"
  91. | "setApiConfigPassword"
  92. | "requestVsCodeLmModels"
  93. | "mode"
  94. | "updatePrompt"
  95. | "updateSupportPrompt"
  96. | "resetSupportPrompt"
  97. | "getSystemPrompt"
  98. | "copySystemPrompt"
  99. | "systemPrompt"
  100. | "enhancementApiConfigId"
  101. | "updateExperimental"
  102. | "autoApprovalEnabled"
  103. | "updateCustomMode"
  104. | "deleteCustomMode"
  105. | "setopenAiCustomModelInfo"
  106. | "openCustomModesSettings"
  107. | "checkpointDiff"
  108. | "checkpointRestore"
  109. | "deleteMcpServer"
  110. | "maxOpenTabsContext"
  111. | "maxWorkspaceFiles"
  112. | "humanRelayResponse"
  113. | "humanRelayCancel"
  114. | "browserToolEnabled"
  115. | "telemetrySetting"
  116. | "showRooIgnoredFiles"
  117. | "testBrowserConnection"
  118. | "browserConnectionResult"
  119. | "remoteBrowserEnabled"
  120. | "language"
  121. | "maxReadFileLine"
  122. | "searchFiles"
  123. | "toggleApiConfigPin"
  124. | "showGreeting"
  125. text?: string
  126. disabled?: boolean
  127. askResponse?: ClineAskResponse
  128. apiConfiguration?: ApiConfiguration
  129. images?: string[]
  130. bool?: boolean
  131. value?: number
  132. commands?: string[]
  133. audioType?: AudioType
  134. serverName?: string
  135. toolName?: string
  136. alwaysAllow?: boolean
  137. mode?: Mode
  138. promptMode?: PromptMode
  139. customPrompt?: PromptComponent
  140. dataUrls?: string[]
  141. values?: Record<string, any>
  142. query?: string
  143. slug?: string
  144. modeConfig?: ModeConfig
  145. timeout?: number
  146. payload?: WebViewMessagePayload
  147. source?: "global" | "project"
  148. requestId?: string
  149. ids?: string[]
  150. }
  151. export const checkoutDiffPayloadSchema = z.object({
  152. ts: z.number(),
  153. previousCommitHash: z.string().optional(),
  154. commitHash: z.string(),
  155. mode: z.enum(["full", "checkpoint"]),
  156. })
  157. export type CheckpointDiffPayload = z.infer<typeof checkoutDiffPayloadSchema>
  158. export const checkoutRestorePayloadSchema = z.object({
  159. ts: z.number(),
  160. commitHash: z.string(),
  161. mode: z.enum(["preview", "restore"]),
  162. })
  163. export type CheckpointRestorePayload = z.infer<typeof checkoutRestorePayloadSchema>
  164. export type WebViewMessagePayload = CheckpointDiffPayload | CheckpointRestorePayload