WebviewMessage.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. | "currentApiConfigName"
  11. | "upsertApiConfiguration"
  12. | "deleteApiConfiguration"
  13. | "loadApiConfiguration"
  14. | "renameApiConfiguration"
  15. | "getListApiConfiguration"
  16. | "customInstructions"
  17. | "allowedCommands"
  18. | "alwaysAllowReadOnly"
  19. | "alwaysAllowWrite"
  20. | "alwaysAllowExecute"
  21. | "webviewDidLaunch"
  22. | "newTask"
  23. | "askResponse"
  24. | "clearTask"
  25. | "didShowAnnouncement"
  26. | "selectImages"
  27. | "exportCurrentTask"
  28. | "showTaskWithId"
  29. | "deleteTaskWithId"
  30. | "exportTaskWithId"
  31. | "resetState"
  32. | "requestOllamaModels"
  33. | "requestLmStudioModels"
  34. | "openImage"
  35. | "openFile"
  36. | "openMention"
  37. | "cancelTask"
  38. | "refreshGlamaModels"
  39. | "refreshOpenRouterModels"
  40. | "refreshOpenAiModels"
  41. | "refreshUnboundModels"
  42. | "refreshRequestyModels"
  43. | "alwaysAllowBrowser"
  44. | "alwaysAllowMcp"
  45. | "alwaysAllowModeSwitch"
  46. | "playSound"
  47. | "soundEnabled"
  48. | "soundVolume"
  49. | "diffEnabled"
  50. | "checkpointsEnabled"
  51. | "browserViewportSize"
  52. | "screenshotQuality"
  53. | "openMcpSettings"
  54. | "restartMcpServer"
  55. | "toggleToolAlwaysAllow"
  56. | "toggleMcpServer"
  57. | "updateMcpTimeout"
  58. | "fuzzyMatchThreshold"
  59. | "preferredLanguage"
  60. | "writeDelayMs"
  61. | "enhancePrompt"
  62. | "enhancedPrompt"
  63. | "draggedImages"
  64. | "deleteMessage"
  65. | "terminalOutputLineLimit"
  66. | "mcpEnabled"
  67. | "enableMcpServerCreation"
  68. | "searchCommits"
  69. | "refreshGlamaModels"
  70. | "alwaysApproveResubmit"
  71. | "requestDelaySeconds"
  72. | "rateLimitSeconds"
  73. | "setApiConfigPassword"
  74. | "requestVsCodeLmModels"
  75. | "mode"
  76. | "updatePrompt"
  77. | "updateSupportPrompt"
  78. | "resetSupportPrompt"
  79. | "getSystemPrompt"
  80. | "copySystemPrompt"
  81. | "systemPrompt"
  82. | "enhancementApiConfigId"
  83. | "updateExperimental"
  84. | "autoApprovalEnabled"
  85. | "updateCustomMode"
  86. | "deleteCustomMode"
  87. | "setopenAiCustomModelInfo"
  88. | "openCustomModesSettings"
  89. | "checkpointDiff"
  90. | "checkpointRestore"
  91. | "maxOpenTabsContext"
  92. text?: string
  93. disabled?: boolean
  94. askResponse?: ClineAskResponse
  95. apiConfiguration?: ApiConfiguration
  96. images?: string[]
  97. bool?: boolean
  98. value?: number
  99. commands?: string[]
  100. audioType?: AudioType
  101. serverName?: string
  102. toolName?: string
  103. alwaysAllow?: boolean
  104. mode?: Mode
  105. promptMode?: PromptMode
  106. customPrompt?: PromptComponent
  107. dataUrls?: string[]
  108. values?: Record<string, any>
  109. query?: string
  110. slug?: string
  111. modeConfig?: ModeConfig
  112. timeout?: number
  113. payload?: WebViewMessagePayload
  114. }
  115. export const checkoutDiffPayloadSchema = z.object({
  116. ts: z.number(),
  117. commitHash: z.string(),
  118. mode: z.enum(["full", "checkpoint"]),
  119. })
  120. export type CheckpointDiffPayload = z.infer<typeof checkoutDiffPayloadSchema>
  121. export const checkoutRestorePayloadSchema = z.object({
  122. ts: z.number(),
  123. commitHash: z.string(),
  124. mode: z.enum(["preview", "restore"]),
  125. })
  126. export type CheckpointRestorePayload = z.infer<typeof checkoutRestorePayloadSchema>
  127. export type WebViewMessagePayload = CheckpointDiffPayload | CheckpointRestorePayload