WebviewMessage.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. | "renameApiConfiguration"
  17. | "getListApiConfiguration"
  18. | "customInstructions"
  19. | "allowedCommands"
  20. | "alwaysAllowReadOnly"
  21. | "alwaysAllowWrite"
  22. | "alwaysAllowExecute"
  23. | "webviewDidLaunch"
  24. | "newTask"
  25. | "askResponse"
  26. | "clearTask"
  27. | "didShowAnnouncement"
  28. | "selectImages"
  29. | "exportCurrentTask"
  30. | "showTaskWithId"
  31. | "deleteTaskWithId"
  32. | "exportTaskWithId"
  33. | "resetState"
  34. | "requestOllamaModels"
  35. | "requestLmStudioModels"
  36. | "openImage"
  37. | "openFile"
  38. | "openMention"
  39. | "cancelTask"
  40. | "refreshOpenRouterModels"
  41. | "refreshGlamaModels"
  42. | "refreshUnboundModels"
  43. | "refreshRequestyModels"
  44. | "refreshOpenAiModels"
  45. | "alwaysAllowBrowser"
  46. | "alwaysAllowMcp"
  47. | "alwaysAllowModeSwitch"
  48. | "alwaysAllowSubtasks"
  49. | "playSound"
  50. | "playTts"
  51. | "soundEnabled"
  52. | "ttsEnabled"
  53. | "ttsSpeed"
  54. | "soundVolume"
  55. | "diffEnabled"
  56. | "enableCheckpoints"
  57. | "checkpointStorage"
  58. | "browserViewportSize"
  59. | "screenshotQuality"
  60. | "remoteBrowserHost"
  61. | "openMcpSettings"
  62. | "restartMcpServer"
  63. | "toggleToolAlwaysAllow"
  64. | "toggleMcpServer"
  65. | "updateMcpTimeout"
  66. | "fuzzyMatchThreshold"
  67. | "writeDelayMs"
  68. | "enhancePrompt"
  69. | "enhancedPrompt"
  70. | "draggedImages"
  71. | "deleteMessage"
  72. | "terminalOutputLineLimit"
  73. | "terminalShellIntegrationTimeout"
  74. | "mcpEnabled"
  75. | "enableMcpServerCreation"
  76. | "enableCustomModeCreation"
  77. | "searchCommits"
  78. | "alwaysApproveResubmit"
  79. | "requestDelaySeconds"
  80. | "rateLimitSeconds"
  81. | "setApiConfigPassword"
  82. | "requestVsCodeLmModels"
  83. | "mode"
  84. | "updatePrompt"
  85. | "updateSupportPrompt"
  86. | "resetSupportPrompt"
  87. | "getSystemPrompt"
  88. | "copySystemPrompt"
  89. | "systemPrompt"
  90. | "enhancementApiConfigId"
  91. | "updateExperimental"
  92. | "autoApprovalEnabled"
  93. | "updateCustomMode"
  94. | "deleteCustomMode"
  95. | "setopenAiCustomModelInfo"
  96. | "openCustomModesSettings"
  97. | "checkpointDiff"
  98. | "checkpointRestore"
  99. | "deleteMcpServer"
  100. | "maxOpenTabsContext"
  101. | "maxWorkspaceFiles"
  102. | "humanRelayResponse"
  103. | "humanRelayCancel"
  104. | "browserToolEnabled"
  105. | "telemetrySetting"
  106. | "showRooIgnoredFiles"
  107. | "testBrowserConnection"
  108. | "discoverBrowser"
  109. | "browserConnectionResult"
  110. | "remoteBrowserEnabled"
  111. | "language"
  112. text?: string
  113. disabled?: boolean
  114. askResponse?: ClineAskResponse
  115. apiConfiguration?: ApiConfiguration
  116. images?: string[]
  117. bool?: boolean
  118. value?: number
  119. commands?: string[]
  120. audioType?: AudioType
  121. serverName?: string
  122. toolName?: string
  123. alwaysAllow?: boolean
  124. mode?: Mode
  125. promptMode?: PromptMode
  126. customPrompt?: PromptComponent
  127. dataUrls?: string[]
  128. values?: Record<string, any>
  129. query?: string
  130. slug?: string
  131. modeConfig?: ModeConfig
  132. timeout?: number
  133. payload?: WebViewMessagePayload
  134. source?: "global" | "project"
  135. requestId?: string
  136. ids?: string[]
  137. }
  138. export const checkoutDiffPayloadSchema = z.object({
  139. ts: z.number(),
  140. previousCommitHash: z.string().optional(),
  141. commitHash: z.string(),
  142. mode: z.enum(["full", "checkpoint"]),
  143. })
  144. export type CheckpointDiffPayload = z.infer<typeof checkoutDiffPayloadSchema>
  145. export const checkoutRestorePayloadSchema = z.object({
  146. ts: z.number(),
  147. commitHash: z.string(),
  148. mode: z.enum(["preview", "restore"]),
  149. })
  150. export type CheckpointRestorePayload = z.infer<typeof checkoutRestorePayloadSchema>
  151. export type WebViewMessagePayload = CheckpointDiffPayload | CheckpointRestorePayload