WebviewMessage.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. | "mcpEnabled"
  82. | "enableMcpServerCreation"
  83. | "searchCommits"
  84. | "alwaysApproveResubmit"
  85. | "requestDelaySeconds"
  86. | "rateLimitSeconds"
  87. | "setApiConfigPassword"
  88. | "requestVsCodeLmModels"
  89. | "mode"
  90. | "updatePrompt"
  91. | "updateSupportPrompt"
  92. | "resetSupportPrompt"
  93. | "getSystemPrompt"
  94. | "copySystemPrompt"
  95. | "systemPrompt"
  96. | "enhancementApiConfigId"
  97. | "updateExperimental"
  98. | "autoApprovalEnabled"
  99. | "updateCustomMode"
  100. | "deleteCustomMode"
  101. | "setopenAiCustomModelInfo"
  102. | "openCustomModesSettings"
  103. | "checkpointDiff"
  104. | "checkpointRestore"
  105. | "deleteMcpServer"
  106. | "maxOpenTabsContext"
  107. | "maxWorkspaceFiles"
  108. | "humanRelayResponse"
  109. | "humanRelayCancel"
  110. | "browserToolEnabled"
  111. | "telemetrySetting"
  112. | "showRooIgnoredFiles"
  113. | "testBrowserConnection"
  114. | "discoverBrowser"
  115. | "browserConnectionResult"
  116. | "remoteBrowserEnabled"
  117. | "language"
  118. | "maxReadFileLine"
  119. | "searchFiles"
  120. | "toggleApiConfigPin"
  121. text?: string
  122. disabled?: boolean
  123. askResponse?: ClineAskResponse
  124. apiConfiguration?: ApiConfiguration
  125. images?: string[]
  126. bool?: boolean
  127. value?: number
  128. commands?: string[]
  129. audioType?: AudioType
  130. serverName?: string
  131. toolName?: string
  132. alwaysAllow?: boolean
  133. mode?: Mode
  134. promptMode?: PromptMode
  135. customPrompt?: PromptComponent
  136. dataUrls?: string[]
  137. values?: Record<string, any>
  138. query?: string
  139. slug?: string
  140. modeConfig?: ModeConfig
  141. timeout?: number
  142. payload?: WebViewMessagePayload
  143. source?: "global" | "project"
  144. requestId?: string
  145. ids?: string[]
  146. }
  147. export const checkoutDiffPayloadSchema = z.object({
  148. ts: z.number(),
  149. previousCommitHash: z.string().optional(),
  150. commitHash: z.string(),
  151. mode: z.enum(["full", "checkpoint"]),
  152. })
  153. export type CheckpointDiffPayload = z.infer<typeof checkoutDiffPayloadSchema>
  154. export const checkoutRestorePayloadSchema = z.object({
  155. ts: z.number(),
  156. commitHash: z.string(),
  157. mode: z.enum(["preview", "restore"]),
  158. })
  159. export type CheckpointRestorePayload = z.infer<typeof checkoutRestorePayloadSchema>
  160. export type WebViewMessagePayload = CheckpointDiffPayload | CheckpointRestorePayload