ExtensionMessage.ts 3.7 KB

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