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