ExtensionMessage.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. // webview will hold state
  5. export interface ExtensionMessage {
  6. type:
  7. | "action"
  8. | "state"
  9. | "selectedImages"
  10. | "ollamaModels"
  11. | "theme"
  12. | "workspaceUpdated"
  13. | "invoke"
  14. | "partialMessage"
  15. | "openRouterModels"
  16. text?: string
  17. action?: "chatButtonClicked" | "settingsButtonClicked" | "historyButtonClicked" | "didBecomeVisible"
  18. invoke?: "sendMessage" | "primaryButtonClick" | "secondaryButtonClick"
  19. state?: ExtensionState
  20. images?: string[]
  21. ollamaModels?: string[]
  22. filePaths?: string[]
  23. partialMessage?: ClineMessage
  24. openRouterModels?: Record<string, ModelInfo>
  25. }
  26. export interface ExtensionState {
  27. version: string
  28. apiConfiguration?: ApiConfiguration
  29. customInstructions?: string
  30. alwaysAllowReadOnly?: boolean
  31. alwaysAllowWrite?: boolean
  32. alwaysAllowExecute?: boolean
  33. uriScheme?: string
  34. clineMessages: ClineMessage[]
  35. taskHistory: HistoryItem[]
  36. shouldShowAnnouncement: boolean
  37. }
  38. export interface ClineMessage {
  39. ts: number
  40. type: "ask" | "say"
  41. ask?: ClineAsk
  42. say?: ClineSay
  43. text?: string
  44. images?: string[]
  45. partial?: boolean
  46. }
  47. export type ClineAsk =
  48. | "followup"
  49. | "command"
  50. | "command_output"
  51. | "completion_result"
  52. | "tool"
  53. | "api_req_failed"
  54. | "resume_task"
  55. | "resume_completed_task"
  56. | "mistake_limit_reached"
  57. | "browser_action_launch"
  58. export type ClineSay =
  59. | "task"
  60. | "error"
  61. | "api_req_started"
  62. | "api_req_finished"
  63. | "text"
  64. | "completion_result"
  65. | "user_feedback"
  66. | "user_feedback_diff"
  67. | "api_req_retried"
  68. | "command_output"
  69. | "tool"
  70. | "shell_integration_warning"
  71. | "browser_action"
  72. | "browser_action_result"
  73. | "command"
  74. export interface ClineSayTool {
  75. tool:
  76. | "editedExistingFile"
  77. | "newFileCreated"
  78. | "readFile"
  79. | "listFilesTopLevel"
  80. | "listFilesRecursive"
  81. | "listCodeDefinitionNames"
  82. | "searchFiles"
  83. path?: string
  84. diff?: string
  85. content?: string
  86. regex?: string
  87. filePattern?: string
  88. }
  89. // must keep in sync with system prompt
  90. export const browserActions = ["launch", "click", "type", "scroll_down", "scroll_up", "close"] as const
  91. export type BrowserAction = (typeof browserActions)[number]
  92. export interface ClineSayBrowserAction {
  93. action: BrowserAction
  94. coordinate?: string
  95. text?: string
  96. }
  97. export type BrowserActionResult = {
  98. screenshot?: string
  99. logs?: string
  100. currentUrl?: string
  101. currentMousePosition?: string
  102. }
  103. export interface ClineApiReqInfo {
  104. request?: string
  105. tokensIn?: number
  106. tokensOut?: number
  107. cacheWrites?: number
  108. cacheReads?: number
  109. cost?: number
  110. cancelReason?: ClineApiReqCancelReason
  111. streamingFailedMessage?: string
  112. }
  113. export type ClineApiReqCancelReason = "streaming_failed" | "user_cancelled"