ExtensionMessage.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. uriScheme?: string
  32. clineMessages: ClineMessage[]
  33. taskHistory: HistoryItem[]
  34. shouldShowAnnouncement: boolean
  35. }
  36. export interface ClineMessage {
  37. ts: number
  38. type: "ask" | "say"
  39. ask?: ClineAsk
  40. say?: ClineSay
  41. text?: string
  42. images?: string[]
  43. partial?: boolean
  44. }
  45. export type ClineAsk =
  46. | "followup"
  47. | "command"
  48. | "command_output"
  49. | "completion_result"
  50. | "tool"
  51. | "api_req_failed"
  52. | "resume_task"
  53. | "resume_completed_task"
  54. | "mistake_limit_reached"
  55. export type ClineSay =
  56. | "task"
  57. | "error"
  58. | "api_req_started"
  59. | "api_req_finished"
  60. | "text"
  61. | "completion_result"
  62. | "user_feedback"
  63. | "user_feedback_diff"
  64. | "api_req_retried"
  65. | "command_output"
  66. | "tool"
  67. | "shell_integration_warning"
  68. | "inspect_site_result"
  69. export interface ClineSayTool {
  70. tool:
  71. | "editedExistingFile"
  72. | "newFileCreated"
  73. | "readFile"
  74. | "listFilesTopLevel"
  75. | "listFilesRecursive"
  76. | "listCodeDefinitionNames"
  77. | "searchFiles"
  78. | "inspectSite"
  79. path?: string
  80. diff?: string
  81. content?: string
  82. regex?: string
  83. filePattern?: string
  84. }
  85. export interface ClineApiReqInfo {
  86. request?: string
  87. tokensIn?: number
  88. tokensOut?: number
  89. cacheWrites?: number
  90. cacheReads?: number
  91. cost?: number
  92. cancelReason?: ClineApiReqCancelReason
  93. streamingFailedMessage?: string
  94. }
  95. export type ClineApiReqCancelReason = "streaming_failed" | "user_cancelled"