ExtensionMessage.ts 4.2 KB

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