ExtensionMessage.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // type that represents json data that is sent from extension to webview, called ExtensionMessage and has 'type' enum which can be 'plusButtonTapped' or 'settingsButtonTapped' or 'hello'
  2. import { ApiConfiguration } from "./api"
  3. import { HistoryItem } from "./HistoryItem"
  4. // webview will hold state
  5. export interface ExtensionMessage {
  6. type: "action" | "state" | "selectedImages"
  7. text?: string
  8. action?: "chatButtonTapped" | "settingsButtonTapped" | "historyButtonTapped" | "didBecomeVisible"
  9. state?: ExtensionState
  10. images?: string[]
  11. }
  12. export interface ExtensionState {
  13. version: string
  14. apiConfiguration?: ApiConfiguration
  15. customInstructions?: string
  16. alwaysAllowReadOnly?: boolean
  17. themeName?: string
  18. uriScheme?: string
  19. claudeMessages: ClaudeMessage[]
  20. taskHistory: HistoryItem[]
  21. shouldShowAnnouncement: boolean
  22. }
  23. export interface ClaudeMessage {
  24. ts: number
  25. type: "ask" | "say"
  26. ask?: ClaudeAsk
  27. say?: ClaudeSay
  28. text?: string
  29. images?: string[]
  30. }
  31. export type ClaudeAsk =
  32. | "followup"
  33. | "command"
  34. | "command_output"
  35. | "completion_result"
  36. | "tool"
  37. | "api_req_failed"
  38. | "resume_task"
  39. | "resume_completed_task"
  40. export type ClaudeSay =
  41. | "task"
  42. | "error"
  43. | "api_req_started"
  44. | "api_req_finished"
  45. | "text"
  46. | "completion_result"
  47. | "user_feedback"
  48. | "user_feedback_diff"
  49. | "api_req_retried"
  50. | "command_output"
  51. | "tool"
  52. export interface ClaudeSayTool {
  53. tool:
  54. | "editedExistingFile"
  55. | "newFileCreated"
  56. | "readFile"
  57. | "listFilesTopLevel"
  58. | "listFilesRecursive"
  59. | "listCodeDefinitionNames"
  60. | "searchFiles"
  61. path?: string
  62. diff?: string
  63. content?: string
  64. regex?: string
  65. filePattern?: string
  66. }