ExtensionMessage.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. // type that represents json data that is sent from extension to webview, called ExtensionMessage and has 'type' enum which can be 'plusButtonClicked' or 'settingsButtonClicked' or 'hello'
  2. import { ApiConfiguration, ApiProvider, ModelInfo } from "./api"
  3. import { HistoryItem } from "./HistoryItem"
  4. import { McpServer } from "./mcp"
  5. import { GitCommit } from "../utils/git"
  6. // webview will hold state
  7. export interface ExtensionMessage {
  8. type:
  9. | "action"
  10. | "state"
  11. | "selectedImages"
  12. | "ollamaModels"
  13. | "lmStudioModels"
  14. | "theme"
  15. | "workspaceUpdated"
  16. | "invoke"
  17. | "partialMessage"
  18. | "glamaModels"
  19. | "openRouterModels"
  20. | "openAiModels"
  21. | "mcpServers"
  22. | "enhancedPrompt"
  23. | "commitSearchResults"
  24. | "listApiConfig"
  25. text?: string
  26. action?:
  27. | "chatButtonClicked"
  28. | "mcpButtonClicked"
  29. | "settingsButtonClicked"
  30. | "historyButtonClicked"
  31. | "didBecomeVisible"
  32. invoke?: "sendMessage" | "primaryButtonClick" | "secondaryButtonClick"
  33. state?: ExtensionState
  34. images?: string[]
  35. ollamaModels?: string[]
  36. lmStudioModels?: string[]
  37. filePaths?: string[]
  38. partialMessage?: ClineMessage
  39. glamaModels?: Record<string, ModelInfo>
  40. openRouterModels?: Record<string, ModelInfo>
  41. openAiModels?: string[]
  42. mcpServers?: McpServer[]
  43. commits?: GitCommit[]
  44. listApiConfig?: ApiConfigMeta[]
  45. }
  46. export interface ApiConfigMeta {
  47. name: string
  48. apiProvider?: ApiProvider
  49. }
  50. export interface ExtensionState {
  51. version: string
  52. clineMessages: ClineMessage[]
  53. taskHistory: HistoryItem[]
  54. shouldShowAnnouncement: boolean
  55. apiConfiguration?: ApiConfiguration
  56. currentApiConfigName?: string
  57. listApiConfigMeta?: ApiConfigMeta[]
  58. customInstructions?: string
  59. alwaysAllowReadOnly?: boolean
  60. alwaysAllowWrite?: boolean
  61. alwaysAllowExecute?: boolean
  62. alwaysAllowBrowser?: boolean
  63. alwaysAllowMcp?: boolean
  64. alwaysApproveResubmit?: boolean
  65. requestDelaySeconds: number
  66. uriScheme?: string
  67. allowedCommands?: string[]
  68. soundEnabled?: boolean
  69. soundVolume?: number
  70. diffEnabled?: boolean
  71. browserViewportSize?: string
  72. screenshotQuality?: number
  73. fuzzyMatchThreshold?: number
  74. preferredLanguage: string
  75. writeDelayMs: number
  76. terminalOutputLineLimit?: number
  77. mcpEnabled: boolean
  78. }
  79. export interface ClineMessage {
  80. ts: number
  81. type: "ask" | "say"
  82. ask?: ClineAsk
  83. say?: ClineSay
  84. text?: string
  85. images?: string[]
  86. partial?: boolean
  87. }
  88. export type ClineAsk =
  89. | "followup"
  90. | "command"
  91. | "command_output"
  92. | "completion_result"
  93. | "tool"
  94. | "api_req_failed"
  95. | "resume_task"
  96. | "resume_completed_task"
  97. | "mistake_limit_reached"
  98. | "browser_action_launch"
  99. | "use_mcp_server"
  100. export type ClineSay =
  101. | "task"
  102. | "error"
  103. | "api_req_started"
  104. | "api_req_finished"
  105. | "text"
  106. | "completion_result"
  107. | "user_feedback"
  108. | "user_feedback_diff"
  109. | "api_req_retried"
  110. | "api_req_retry_delayed"
  111. | "command_output"
  112. | "tool"
  113. | "shell_integration_warning"
  114. | "browser_action"
  115. | "browser_action_result"
  116. | "command"
  117. | "mcp_server_request_started"
  118. | "mcp_server_response"
  119. export interface ClineSayTool {
  120. tool:
  121. | "editedExistingFile"
  122. | "appliedDiff"
  123. | "newFileCreated"
  124. | "readFile"
  125. | "listFilesTopLevel"
  126. | "listFilesRecursive"
  127. | "listCodeDefinitionNames"
  128. | "searchFiles"
  129. path?: string
  130. diff?: string
  131. content?: string
  132. regex?: string
  133. filePattern?: string
  134. }
  135. // must keep in sync with system prompt
  136. export const browserActions = ["launch", "click", "type", "scroll_down", "scroll_up", "close"] as const
  137. export type BrowserAction = (typeof browserActions)[number]
  138. export interface ClineSayBrowserAction {
  139. action: BrowserAction
  140. coordinate?: string
  141. text?: string
  142. }
  143. export type BrowserActionResult = {
  144. screenshot?: string
  145. logs?: string
  146. currentUrl?: string
  147. currentMousePosition?: string
  148. }
  149. export interface ClineAskUseMcpServer {
  150. serverName: string
  151. type: "use_mcp_tool" | "access_mcp_resource"
  152. toolName?: string
  153. arguments?: string
  154. uri?: string
  155. }
  156. export interface ClineApiReqInfo {
  157. request?: string
  158. tokensIn?: number
  159. tokensOut?: number
  160. cacheWrites?: number
  161. cacheReads?: number
  162. cost?: number
  163. cancelReason?: ClineApiReqCancelReason
  164. streamingFailedMessage?: string
  165. }
  166. export type ClineApiReqCancelReason = "streaming_failed" | "user_cancelled"