| 1 | import { |
| 2 | BlockType, |
| 3 | ConfigResult, |
| 4 | DevDataLogEvent, |
| 5 | ModelRole, |
| 6 | } from "@continuedev/config-yaml"; |
| 7 | |
| 8 | import { |
| 9 | AutocompleteInput, |
| 10 | RecentlyEditedRange, |
| 11 | } from "../autocomplete/util/types"; |
| 12 | import { SharedConfigSchema } from "../config/sharedConfig"; |
| 13 | import { GlobalContextModelSelections } from "../util/GlobalContext"; |
| 14 | |
| 15 | import { |
| 16 | BrowserSerializedContinueConfig, |
| 17 | ChatMessage, |
| 18 | CompiledMessagesResult, |
| 19 | CompleteOnboardingPayload, |
| 20 | ContextItem, |
| 21 | ContextItemWithId, |
| 22 | ContextSubmenuItem, |
| 23 | DiffLine, |
| 24 | DocsIndexingDetails, |
| 25 | ExperimentalModelRoles, |
| 26 | FileSymbolMap, |
| 27 | IdeSettings, |
| 28 | LLMFullCompletionOptions, |
| 29 | MessageOption, |
| 30 | ModelDescription, |
| 31 | PromptLog, |
| 32 | RangeInFile, |
| 33 | RangeInFileWithNextEditInfo, |
| 34 | SerializedContinueConfig, |
| 35 | Session, |
| 36 | SessionMetadata, |
| 37 | SiteIndexingConfig, |
| 38 | SlashCommandDescWithSource, |
| 39 | StreamDiffLinesPayload, |
| 40 | ToolCall, |
| 41 | } from "../"; |
| 42 | import { AutocompleteCodeSnippet } from "../autocomplete/snippets/types"; |
| 43 | import { GetLspDefinitionsFunction } from "../autocomplete/types"; |
| 44 | import { ConfigHandler } from "../config/ConfigHandler"; |
| 45 | import { SerializedOrgWithProfiles } from "../config/ProfileLifecycleManager"; |
| 46 | import { ControlPlaneSessionInfo } from "../control-plane/AuthTypes"; |
| 47 | import { FreeTrialStatus } from "../control-plane/client"; |
| 48 | |
| 49 | export enum OnboardingModes { |
| 50 | API_KEY = "API Key", |
| 51 | LOCAL = "Local", |
| 52 | MODELS_ADD_ON = "Models Add-On", |
| 53 | } |
| 54 | |
| 55 | export interface ListHistoryOptions { |
| 56 | offset?: number; |
| 57 | limit?: number; |
| 58 | } |
| 59 | |
| 60 | export type ToCoreFromIdeOrWebviewProtocol = { |
| 61 | // Special |
| 62 | ping: [string, string]; |
| 63 | abort: [undefined, void]; |
| 64 | cancelApply: [undefined, void]; |
| 65 | |
| 66 | // History |
| 67 | "history/list": [ListHistoryOptions, SessionMetadata[]]; |
| 68 | "history/delete": [{ id: string }, void]; |
| 69 | "history/load": [{ id: string }, Session]; |
| 70 | "history/save": [Session, void]; |
| 71 | "history/clear": [undefined, void]; |
| 72 | "devdata/log": [DevDataLogEvent, void]; |
| 73 | "config/addOpenAiKey": [string, void]; |
| 74 | "config/addModel": [ |
| 75 | { |
| 76 | model: SerializedContinueConfig["models"][number]; |
| 77 | role?: keyof ExperimentalModelRoles; |
| 78 | }, |
| 79 | void, |
| 80 | ]; |
| 81 | "config/addLocalWorkspaceBlock": [{ blockType: BlockType }, void]; |
| 82 | "config/newPromptFile": [undefined, void]; |
| 83 | "config/ideSettingsUpdate": [IdeSettings, void]; |
| 84 | "config/getSerializedProfileInfo": [ |
| 85 | undefined, |
| 86 | { |
| 87 | result: ConfigResult<BrowserSerializedContinueConfig>; |
| 88 | profileId: string | null; |
| 89 | organizations: SerializedOrgWithProfiles[]; |
| 90 | selectedOrgId: string; |
| 91 | }, |
| 92 | ]; |
| 93 | "config/deleteModel": [{ title: string }, void]; |
| 94 | "config/reload": [undefined, void]; |
| 95 | "config/refreshProfiles": [ |
| 96 | ( |
| 97 | | undefined |
| 98 | | { |
| 99 | selectOrgId?: string; |
| 100 | selectProfileId?: string; |
| 101 | } |
| 102 | ), |
| 103 | void, |
| 104 | ]; |
| 105 | "config/openProfile": [ |
| 106 | { profileId: string | undefined; element?: { sourceFile?: string } }, |
| 107 | void, |
| 108 | ]; |
| 109 | "config/updateSharedConfig": [SharedConfigSchema, SharedConfigSchema]; |
| 110 | "config/updateSelectedModel": [ |
| 111 | { |
| 112 | profileId: string; |
| 113 | role: ModelRole; |
| 114 | title: string | null; |
| 115 | }, |
| 116 | GlobalContextModelSelections, |
| 117 | ]; |
| 118 | "context/getContextItems": [ |
| 119 | { |
| 120 | name: string; |
| 121 | query: string; |
| 122 | fullInput: string; |
| 123 | selectedCode: RangeInFile[]; |
| 124 | isInAgentMode: boolean; |
| 125 | }, |
| 126 | ContextItemWithId[], |
| 127 | ]; |
| 128 | "mcp/reloadServer": [ |
| 129 | { |
| 130 | id: string; |
| 131 | }, |
| 132 | void, |
| 133 | ]; |
| 134 | "mcp/getPrompt": [ |
| 135 | { |
| 136 | serverName: string; |
| 137 | promptName: string; |
| 138 | args?: Record<string, string>; |
| 139 | }, |
| 140 | { |
| 141 | prompt: string; |
| 142 | description: string | undefined; |
| 143 | }, |
| 144 | ]; |
| 145 | "context/getSymbolsForFiles": [{ uris: string[] }, FileSymbolMap]; |
| 146 | "context/loadSubmenuItems": [{ title: string }, ContextSubmenuItem[]]; |
| 147 | "autocomplete/complete": [AutocompleteInput, string[]]; |
| 148 | "context/addDocs": [SiteIndexingConfig, void]; |
| 149 | "context/removeDocs": [Pick<SiteIndexingConfig, "startUrl">, void]; |
| 150 | "context/indexDocs": [{ reIndex: boolean }, void]; |
| 151 | "autocomplete/cancel": [undefined, void]; |
| 152 | "autocomplete/accept": [{ completionId: string }, void]; |
| 153 | "nextEdit/predict": [AutocompleteInput, string[]]; |
| 154 | "nextEdit/reject": [{ completionId: string }, void]; |
| 155 | "nextEdit/accept": [{ completionId: string }, void]; |
| 156 | "llm/complete": [ |
| 157 | { |
| 158 | prompt: string; |
| 159 | completionOptions: LLMFullCompletionOptions; |
| 160 | title: string; |
| 161 | }, |
| 162 | string, |
| 163 | ]; |
| 164 | "llm/listModels": [{ title: string }, string[] | undefined]; |
| 165 | "llm/streamChat": [ |
| 166 | { |
| 167 | messages: ChatMessage[]; |
| 168 | completionOptions: LLMFullCompletionOptions; |
| 169 | title: string; |
| 170 | messageOptions?: MessageOption; |
| 171 | legacySlashCommandData?: { |
| 172 | command: SlashCommandDescWithSource; |
| 173 | input: string; |
| 174 | contextItems: ContextItemWithId[]; |
| 175 | historyIndex: number; |
| 176 | selectedCode: RangeInFile[]; |
| 177 | }; |
| 178 | }, |
| 179 | AsyncGenerator<ChatMessage, PromptLog>, |
| 180 | ]; |
| 181 | streamDiffLines: [StreamDiffLinesPayload, AsyncGenerator<DiffLine>]; |
| 182 | "llm/compileChat": [ |
| 183 | { messages: ChatMessage[]; options: LLMFullCompletionOptions }, |
| 184 | CompiledMessagesResult, |
| 185 | ]; |
| 186 | "chatDescriber/describe": [ |
| 187 | { |
| 188 | text: string; |
| 189 | }, |
| 190 | string | undefined, |
| 191 | ]; |
| 192 | "conversation/compact": [ |
| 193 | { |
| 194 | index: number; |
| 195 | sessionId: string; |
| 196 | }, |
| 197 | string | undefined, |
| 198 | ]; |
| 199 | "stats/getTokensPerDay": [ |
| 200 | undefined, |
| 201 | { day: string; promptTokens: number; generatedTokens: number }[], |
| 202 | ]; |
| 203 | "stats/getTokensPerModel": [ |
| 204 | undefined, |
| 205 | { model: string; promptTokens: number; generatedTokens: number }[], |
| 206 | ]; |
| 207 | "tts/kill": [undefined, void]; |
| 208 | |
| 209 | // Codebase indexing |
| 210 | "index/setPaused": [boolean, void]; |
| 211 | "index/forceReIndex": [ |
| 212 | undefined | { dirs?: string[]; shouldClearIndexes?: boolean }, |
| 213 | void, |
| 214 | ]; |
| 215 | "index/indexingProgressBarInitialized": [undefined, void]; |
| 216 | "onboarding/complete": [CompleteOnboardingPayload, void]; |
| 217 | |
| 218 | // File changes |
| 219 | "files/changed": [{ uris?: string[] }, void]; |
| 220 | "files/opened": [{ uris?: string[] }, void]; |
| 221 | "files/created": [{ uris?: string[] }, void]; |
| 222 | "files/deleted": [{ uris?: string[] }, void]; |
| 223 | "files/closed": [{ uris?: string[] }, void]; |
| 224 | "files/smallEdit": [ |
| 225 | { |
| 226 | actions: RangeInFileWithNextEditInfo[]; |
| 227 | configHandler: ConfigHandler; |
| 228 | getDefsFromLspFunction: GetLspDefinitionsFunction; |
| 229 | recentlyEditedRanges: RecentlyEditedRange[]; |
| 230 | recentlyVisitedRanges: AutocompleteCodeSnippet[]; |
| 231 | }, |
| 232 | void, |
| 233 | ]; |
| 234 | |
| 235 | // Docs etc. Indexing. TODO move codebase to this |
| 236 | "indexing/reindex": [{ type: string; id: string }, void]; |
| 237 | "indexing/abort": [{ type: string; id: string }, void]; |
| 238 | "indexing/setPaused": [{ type: string; id: string; paused: boolean }, void]; |
| 239 | "docs/getSuggestedDocs": [undefined, void]; |
| 240 | "docs/initStatuses": [undefined, void]; |
| 241 | "docs/getDetails": [{ startUrl: string }, DocsIndexingDetails]; |
| 242 | addAutocompleteModel: [{ model: ModelDescription }, void]; |
| 243 | |
| 244 | "auth/getAuthUrl": [{ useOnboarding: boolean }, { url: string }]; |
| 245 | "tools/call": [ |
| 246 | { toolCall: ToolCall }, |
| 247 | { contextItems: ContextItem[]; errorMessage?: string }, |
| 248 | ]; |
| 249 | "clipboardCache/add": [{ content: string }, void]; |
| 250 | "controlPlane/openUrl": [{ path: string; orgSlug?: string }, void]; |
| 251 | "controlPlane/getFreeTrialStatus": [undefined, FreeTrialStatus | null]; |
| 252 | "controlPlane/getModelsAddOnUpgradeUrl": [ |
| 253 | { vsCodeUriScheme?: string }, |
| 254 | { url: string } | null, |
| 255 | ]; |
| 256 | isItemTooBig: [{ item: ContextItemWithId }, boolean]; |
| 257 | didChangeControlPlaneSessionInfo: [ |
| 258 | { sessionInfo: ControlPlaneSessionInfo | undefined }, |
| 259 | void, |
| 260 | ]; |
| 261 | "process/markAsBackgrounded": [{ toolCallId: string }, void]; |
| 262 | "process/isBackgrounded": [{ toolCallId: string }, boolean]; |
| 263 | "mdm/setLicenseKey": [{ licenseKey: string }, boolean]; |
| 264 | }; |