ExtensionMessage.ts 3.4 KB

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