| 1 | import { |
| 2 | DataDestination, |
| 3 | ModelRole, |
| 4 | PromptTemplates, |
| 5 | } from "@continuedev/config-yaml"; |
| 6 | import Parser from "web-tree-sitter"; |
| 7 | import { CodebaseIndexer } from "./indexing/CodebaseIndexer"; |
| 8 | import { LLMConfigurationStatuses } from "./llm/constants"; |
| 9 | |
| 10 | declare global { |
| 11 | interface Window { |
| 12 | ide?: "vscode"; |
| 13 | windowId: string; |
| 14 | serverUrl: string; |
| 15 | vscMachineId: string; |
| 16 | vscMediaUrl: string; |
| 17 | fullColorTheme?: { |
| 18 | rules?: { |
| 19 | token?: string; |
| 20 | foreground?: string; |
| 21 | }[]; |
| 22 | }; |
| 23 | colorThemeName?: string; |
| 24 | workspacePaths?: string[]; |
| 25 | postIntellijMessage?: ( |
| 26 | messageType: string, |
| 27 | data: any, |
| 28 | messageIde: string, |
| 29 | ) => void; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | export interface ChunkWithoutID { |
| 34 | content: string; |
| 35 | startLine: number; |
| 36 | endLine: number; |
| 37 | signature?: string; |
| 38 | otherMetadata?: { [key: string]: any }; |
| 39 | } |
| 40 | |
| 41 | export interface Chunk extends ChunkWithoutID { |
| 42 | digest: string; |
| 43 | filepath: string; |
| 44 | index: number; // Index of the chunk in the document at filepath |
| 45 | } |
| 46 | |
| 47 | export interface IndexingProgressUpdate { |
| 48 | progress: number; |
| 49 | desc: string; |
| 50 | shouldClearIndexes?: boolean; |
| 51 | status: |
| 52 | | "loading" |
| 53 | | "indexing" |
| 54 | | "done" |
| 55 | | "failed" |
| 56 | | "paused" |
| 57 | | "disabled" |
| 58 | | "cancelled"; |
| 59 | debugInfo?: string; |
| 60 | } |
| 61 | |
| 62 | // This is more or less a V2 of IndexingProgressUpdate for docs etc. |
| 63 | export interface IndexingStatus { |
| 64 | id: string; |
| 65 | type: "docs"; |
| 66 | progress: number; |
| 67 | description: string; |
| 68 | status: "indexing" | "complete" | "paused" | "failed" | "aborted" | "pending"; |
| 69 | embeddingsProviderId?: string; |
| 70 | isReindexing?: boolean; |
| 71 | debugInfo?: string; |
| 72 | title: string; |
| 73 | icon?: string; |
| 74 | url?: string; |
| 75 | } |
| 76 | |
| 77 | export type PromptTemplateFunction = ( |
| 78 | history: ChatMessage[], |
| 79 | otherData: Record<string, string>, |
| 80 | ) => string | ChatMessage[]; |
| 81 | |
| 82 | export type PromptTemplate = string | PromptTemplateFunction; |
| 83 | |
| 84 | type RequiredLLMOptions = |
| 85 | | "uniqueId" |
| 86 | | "contextLength" |
| 87 | | "embeddingId" |
| 88 | | "maxEmbeddingChunkSize" |
| 89 | | "maxEmbeddingBatchSize" |
| 90 | | "completionOptions"; |
| 91 | |
| 92 | export interface ILLM |
| 93 | extends Omit<LLMOptions, RequiredLLMOptions>, |
| 94 | Required<Pick<LLMOptions, RequiredLLMOptions>> { |
| 95 | get providerName(): string; |
| 96 | get underlyingProviderName(): string; |
| 97 | |
| 98 | autocompleteOptions?: Partial<TabAutocompleteOptions>; |
| 99 | |
| 100 | complete( |
| 101 | prompt: string, |
| 102 | signal: AbortSignal, |
| 103 | options?: LLMFullCompletionOptions, |
| 104 | ): Promise<string>; |
| 105 | |
| 106 | streamComplete( |
| 107 | prompt: string, |
| 108 | signal: AbortSignal, |
| 109 | options?: LLMFullCompletionOptions, |
| 110 | ): AsyncGenerator<string, PromptLog>; |
| 111 | |
| 112 | streamFim( |
| 113 | prefix: string, |
| 114 | suffix: string, |
| 115 | signal: AbortSignal, |
| 116 | options?: LLMFullCompletionOptions, |
| 117 | ): AsyncGenerator<string, PromptLog>; |
| 118 | |
| 119 | streamChat( |
| 120 | messages: ChatMessage[], |
| 121 | signal: AbortSignal, |
| 122 | options?: LLMFullCompletionOptions, |
| 123 | ): AsyncGenerator<ChatMessage, PromptLog>; |
| 124 | |
| 125 | chat( |
| 126 | messages: ChatMessage[], |
| 127 | signal: AbortSignal, |
| 128 | options?: LLMFullCompletionOptions, |
| 129 | ): Promise<ChatMessage>; |
| 130 | |
| 131 | embed(chunks: string[]): Promise<number[][]>; |
| 132 | |
| 133 | rerank(query: string, chunks: Chunk[]): Promise<number[]>; |
| 134 | |
| 135 | countTokens(text: string): number; |
| 136 | |
| 137 | supportsImages(): boolean; |
| 138 | |
| 139 | supportsCompletions(): boolean; |
| 140 | |
| 141 | supportsPrefill(): boolean; |
| 142 | |
| 143 | supportsFim(): boolean; |
| 144 | |
| 145 | listModels(): Promise<string[]>; |
| 146 | |
| 147 | renderPromptTemplate( |
| 148 | template: PromptTemplate, |
| 149 | history: ChatMessage[], |
| 150 | otherData: Record<string, string>, |
| 151 | canPutWordsInModelsMouth?: boolean, |
| 152 | ): string | ChatMessage[]; |
| 153 | |
| 154 | getConfigurationStatus(): LLMConfigurationStatuses; |
| 155 | } |
| 156 | |
| 157 | export interface ModelInstaller { |
| 158 | installModel( |
| 159 | modelName: string, |
| 160 | signal: AbortSignal, |
| 161 | progressReporter?: (task: string, increment: number, total: number) => void, |
| 162 | ): Promise<any>; |
| 163 | |
| 164 | isInstallingModel(modelName: string): Promise<boolean>; |
| 165 | } |
| 166 | |
| 167 | export type ContextProviderType = "normal" | "query" | "submenu"; |
| 168 | |
| 169 | export interface ContextProviderDescription { |
| 170 | title: ContextProviderName; |
| 171 | displayTitle: string; |
| 172 | description: string; |
| 173 | renderInlineAs?: string; |
| 174 | type: ContextProviderType; |
| 175 | dependsOnIndexing?: boolean; |
| 176 | } |
| 177 | |
| 178 | export type FetchFunction = (url: string | URL, init?: any) => Promise<any>; |
| 179 | |
| 180 | export interface ContextProviderExtras { |
| 181 | config: ContinueConfig; |
| 182 | fullInput: string; |
| 183 | embeddingsProvider: ILLM | null; |
| 184 | reranker: ILLM | null; |
| 185 | llm: ILLM; |
| 186 | ide: IDE; |
| 187 | selectedCode: RangeInFile[]; |
| 188 | fetch: FetchFunction; |
| 189 | isInAgentMode: boolean; |
| 190 | } |
| 191 | |
| 192 | export interface LoadSubmenuItemsArgs { |
| 193 | config: ContinueConfig; |
| 194 | ide: IDE; |
| 195 | fetch: FetchFunction; |
| 196 | } |
| 197 | |
| 198 | export interface CustomContextProvider { |
| 199 | title: string; |
| 200 | displayTitle?: string; |
| 201 | description?: string; |
| 202 | renderInlineAs?: string; |
| 203 | type?: ContextProviderType; |
| 204 | loadSubmenuItems?: ( |
| 205 | args: LoadSubmenuItemsArgs, |
| 206 | ) => Promise<ContextSubmenuItem[]>; |
| 207 | |
| 208 | getContextItems( |
| 209 | query: string, |
| 210 | extras: ContextProviderExtras, |
| 211 | ): Promise<ContextItem[]>; |
| 212 | } |
| 213 | |
| 214 | export interface ContextSubmenuItem { |
| 215 | id: string; |
| 216 | title: string; |
| 217 | description: string; |
| 218 | icon?: string; |
| 219 | metadata?: any; |
| 220 | } |
| 221 | |
| 222 | export interface ContextSubmenuItemWithProvider extends ContextSubmenuItem { |
| 223 | providerTitle: string; |
| 224 | } |
| 225 | |
| 226 | export interface SiteIndexingConfig { |
| 227 | title: string; |
| 228 | startUrl: string; |
| 229 | maxDepth?: number; |
| 230 | faviconUrl?: string; |
| 231 | useLocalCrawling?: boolean; |
| 232 | } |
| 233 | |
| 234 | export interface DocsIndexingDetails { |
| 235 | startUrl: string; |
| 236 | config: SiteIndexingConfig; |
| 237 | indexingStatus: IndexingStatus | undefined; |
| 238 | chunks: Chunk[]; |
| 239 | } |
| 240 | |
| 241 | export interface IContextProvider { |
| 242 | get description(): ContextProviderDescription; |
| 243 | |
| 244 | getContextItems( |
| 245 | query: string, |
| 246 | extras: ContextProviderExtras, |
| 247 | ): Promise<ContextItem[]>; |
| 248 | |
| 249 | loadSubmenuItems(args: LoadSubmenuItemsArgs): Promise<ContextSubmenuItem[]>; |
| 250 | } |
| 251 | |
| 252 | export interface Session { |
| 253 | sessionId: string; |
| 254 | title: string; |
| 255 | workspaceDirectory: string; |
| 256 | history: ChatHistoryItem[]; |
| 257 | } |
| 258 | |
| 259 | export interface SessionMetadata { |
| 260 | sessionId: string; |
| 261 | title: string; |
| 262 | dateCreated: string; |
| 263 | workspaceDirectory: string; |
| 264 | } |
| 265 | |
| 266 | export interface RangeInFile { |
| 267 | filepath: string; |
| 268 | range: Range; |
| 269 | } |
| 270 | |
| 271 | export interface Location { |
| 272 | filepath: string; |
| 273 | position: Position; |
| 274 | } |
| 275 | |
| 276 | export interface FileWithContents { |
| 277 | filepath: string; |
| 278 | contents: string; |
| 279 | } |
| 280 | |
| 281 | export interface Range { |
| 282 | start: Position; |
| 283 | end: Position; |
| 284 | } |
| 285 | |
| 286 | export interface Position { |
| 287 | line: number; |
| 288 | character: number; |
| 289 | } |
| 290 | |
| 291 | export interface FileEdit { |
| 292 | filepath: string; |
| 293 | range: Range; |
| 294 | replacement: string; |
| 295 | } |
| 296 | |
| 297 | export interface ContinueError { |
| 298 | title: string; |
| 299 | message: string; |
| 300 | } |
| 301 | |
| 302 | export interface CompletionOptions extends BaseCompletionOptions { |
| 303 | model: string; |
| 304 | } |
| 305 | |
| 306 | export type ChatMessageRole = |
| 307 | | "user" |
| 308 | | "assistant" |
| 309 | | "thinking" |
| 310 | | "system" |
| 311 | | "tool"; |
| 312 | |
| 313 | export type TextMessagePart = { |
| 314 | type: "text"; |
| 315 | text: string; |
| 316 | }; |
| 317 | |
| 318 | export type ImageMessagePart = { |
| 319 | type: "imageUrl"; |
| 320 | imageUrl: { url: string }; |
| 321 | }; |
| 322 | |
| 323 | export type MessagePart = TextMessagePart | ImageMessagePart; |
| 324 | |
| 325 | export type MessageContent = string | MessagePart[]; |
| 326 | |
| 327 | export interface ToolCall { |
| 328 | id: string; |
| 329 | type: "function"; |
| 330 | function: { |
| 331 | name: string; |
| 332 | arguments: string; |
| 333 | }; |
| 334 | } |
| 335 | |
| 336 | export interface ToolCallDelta { |
| 337 | id?: string; |
| 338 | type?: "function"; |
| 339 | function?: { |
| 340 | name?: string; |
| 341 | arguments?: string; |
| 342 | }; |
| 343 | } |
| 344 | |
| 345 | export interface ToolResultChatMessage { |
| 346 | role: "tool"; |
| 347 | content: string; |
| 348 | toolCallId: string; |
| 349 | } |
| 350 | |
| 351 | export interface UserChatMessage { |
| 352 | role: "user"; |
| 353 | content: MessageContent; |
| 354 | } |
| 355 | |
| 356 | export interface ThinkingChatMessage { |
| 357 | role: "thinking"; |
| 358 | content: MessageContent; |
| 359 | signature?: string; |
| 360 | redactedThinking?: string; |
| 361 | toolCalls?: ToolCallDelta[]; |
| 362 | } |
| 363 | |
| 364 | export interface AssistantChatMessage { |
| 365 | role: "assistant"; |
| 366 | content: MessageContent; |
| 367 | toolCalls?: ToolCallDelta[]; |
| 368 | } |
| 369 | |
| 370 | export interface SystemChatMessage { |
| 371 | role: "system"; |
| 372 | content: string; |
| 373 | } |
| 374 | |
| 375 | export type ChatMessage = |
| 376 | | UserChatMessage |
| 377 | | AssistantChatMessage |
| 378 | | ThinkingChatMessage |
| 379 | | SystemChatMessage |
| 380 | | ToolResultChatMessage; |
| 381 | |
| 382 | export interface ContextItemId { |
| 383 | providerTitle: string; |
| 384 | itemId: string; |
| 385 | } |
| 386 | |
| 387 | export type ContextItemUriTypes = "file" | "url"; |
| 388 | |
| 389 | export interface ContextItemUri { |
| 390 | type: ContextItemUriTypes; |
| 391 | value: string; |
| 392 | } |
| 393 | |
| 394 | export interface ContextItem { |
| 395 | content: string; |
| 396 | name: string; |
| 397 | description: string; |
| 398 | editing?: boolean; |
| 399 | editable?: boolean; |
| 400 | icon?: string; |
| 401 | uri?: ContextItemUri; |
| 402 | hidden?: boolean; |
| 403 | status?: string; |
| 404 | } |
| 405 | |
| 406 | export interface ContextItemWithId extends ContextItem { |
| 407 | id: ContextItemId; |
| 408 | } |
| 409 | |
| 410 | export interface InputModifiers { |
| 411 | useCodebase: boolean; |
| 412 | noContext: boolean; |
| 413 | } |
| 414 | |
| 415 | export interface SymbolWithRange extends RangeInFile { |
| 416 | name: string; |
| 417 | type: Parser.SyntaxNode["type"]; |
| 418 | content: string; |
| 419 | } |
| 420 | |
| 421 | export type FileSymbolMap = Record<string, SymbolWithRange[]>; |
| 422 | |
| 423 | export interface PromptLog { |
| 424 | modelTitle: string; |
| 425 | completionOptions: CompletionOptions; |
| 426 | prompt: string; |
| 427 | completion: string; |
| 428 | } |
| 429 | |
| 430 | export type MessageModes = "chat" | "agent"; |
| 431 | |
| 432 | export type ToolStatus = |
| 433 | | "generating" |
| 434 | | "generated" |
| 435 | | "calling" |
| 436 | | "errored" |
| 437 | | "done" |
| 438 | | "canceled"; |
| 439 | |
| 440 | // Will exist only on "assistant" messages with tool calls |
| 441 | interface ToolCallState { |
| 442 | toolCallId: string; |
| 443 | toolCall: ToolCall; |
| 444 | status: ToolStatus; |
| 445 | parsedArgs: any; |
| 446 | output?: ContextItem[]; |
| 447 | } |
| 448 | |
| 449 | interface Reasoning { |
| 450 | active: boolean; |
| 451 | text: string; |
| 452 | startAt: number; |
| 453 | endAt?: number; |
| 454 | } |
| 455 | |
| 456 | export interface ChatHistoryItem { |
| 457 | message: ChatMessage; |
| 458 | contextItems: ContextItemWithId[]; |
| 459 | editorState?: any; |
| 460 | modifiers?: InputModifiers; |
| 461 | promptLogs?: PromptLog[]; |
| 462 | toolCallState?: ToolCallState; |
| 463 | isGatheringContext?: boolean; |
| 464 | reasoning?: Reasoning; |
| 465 | appliedRules?: RuleWithSource[]; |
| 466 | } |
| 467 | |
| 468 | export interface LLMFullCompletionOptions extends BaseCompletionOptions { |
| 469 | log?: boolean; |
| 470 | model?: string; |
| 471 | } |
| 472 | |
| 473 | export type ToastType = "info" | "error" | "warning"; |
| 474 | |
| 475 | export interface LLMInteractionBase { |
| 476 | interactionId: string; |
| 477 | timestamp: number; |
| 478 | } |
| 479 | |
| 480 | export interface LLMInteractionStartChat extends LLMInteractionBase { |
| 481 | kind: "startChat"; |
| 482 | messages: ChatMessage[]; |
| 483 | options: CompletionOptions; |
| 484 | } |
| 485 | |
| 486 | export interface LLMInteractionStartComplete extends LLMInteractionBase { |
| 487 | kind: "startComplete"; |
| 488 | prompt: string; |
| 489 | options: CompletionOptions; |
| 490 | } |
| 491 | |
| 492 | export interface LLMInteractionStartFim extends LLMInteractionBase { |
| 493 | kind: "startFim"; |
| 494 | prefix: string; |
| 495 | suffix: string; |
| 496 | options: CompletionOptions; |
| 497 | } |
| 498 | |
| 499 | export interface LLMInteractionChunk extends LLMInteractionBase { |
| 500 | kind: "chunk"; |
| 501 | chunk: string; |
| 502 | } |
| 503 | |
| 504 | export interface LLMInteractionMessage extends LLMInteractionBase { |
| 505 | kind: "message"; |
| 506 | message: ChatMessage; |
| 507 | } |
| 508 | |
| 509 | export interface LLMInteractionEnd extends LLMInteractionBase { |
| 510 | promptTokens: number; |
| 511 | generatedTokens: number; |
| 512 | thinkingTokens: number; |
| 513 | } |
| 514 | |
| 515 | export interface LLMInteractionSuccess extends LLMInteractionEnd { |
| 516 | kind: "success"; |
| 517 | } |
| 518 | |
| 519 | export interface LLMInteractionCancel extends LLMInteractionEnd { |
| 520 | kind: "cancel"; |
| 521 | } |
| 522 | |
| 523 | export interface LLMInteractionError extends LLMInteractionEnd { |
| 524 | kind: "error"; |
| 525 | name: string; |
| 526 | message: string; |
| 527 | } |
| 528 | |
| 529 | export type LLMInteractionItem = |
| 530 | | LLMInteractionStartChat |
| 531 | | LLMInteractionStartComplete |
| 532 | | LLMInteractionStartFim |
| 533 | | LLMInteractionChunk |
| 534 | | LLMInteractionMessage |
| 535 | | LLMInteractionSuccess |
| 536 | | LLMInteractionCancel |
| 537 | | LLMInteractionError; |
| 538 | |
| 539 | // When we log a LLM interaction, we want to add the interactionId and timestamp |
| 540 | // in the logger code, so we need a type that omits these members from *each* |
| 541 | // member of the union. This can be done by using the distributive behavior of |
| 542 | // conditional types in Typescript. |
| 543 | // |
| 544 | // www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types |
| 545 | // https://stackoverflow.com/questions/57103834/typescript-omit-a-property-from-all-interfaces-in-a-union-but-keep-the-union-s |
| 546 | type DistributiveOmit<T, K extends PropertyKey> = T extends unknown |
| 547 | ? Omit<T, K> |
| 548 | : never; |
| 549 | |
| 550 | export type LLMInteractionItemDetails = DistributiveOmit< |
| 551 | LLMInteractionItem, |
| 552 | "interactionId" | "timestamp" |
| 553 | >; |
| 554 | |
| 555 | export interface ILLMInteractionLog { |
| 556 | logItem(item: LLMInteractionItemDetails): void; |
| 557 | } |
| 558 | |
| 559 | export interface ILLMLogger { |
| 560 | createInteractionLog(): ILLMInteractionLog; |
| 561 | } |
| 562 | |
| 563 | export interface LLMOptions { |
| 564 | model: string; |
| 565 | |
| 566 | title?: string; |
| 567 | uniqueId?: string; |
| 568 | baseAgentSystemMessage?: string; |
| 569 | baseChatSystemMessage?: string; |
| 570 | autocompleteOptions?: Partial<TabAutocompleteOptions>; |
| 571 | contextLength?: number; |
| 572 | maxStopWords?: number; |
| 573 | completionOptions?: CompletionOptions; |
| 574 | requestOptions?: RequestOptions; |
| 575 | template?: TemplateType; |
| 576 | promptTemplates?: Partial<Record<keyof PromptTemplates, PromptTemplate>>; |
| 577 | templateMessages?: (messages: ChatMessage[]) => string; |
| 578 | logger?: ILLMLogger; |
| 579 | llmRequestHook?: (model: string, prompt: string) => any; |
| 580 | apiKey?: string; |
| 581 | |
| 582 | // continueProperties |
| 583 | apiKeyLocation?: string; |
| 584 | apiBase?: string; |
| 585 | orgScopeId?: string | null; |
| 586 | |
| 587 | onPremProxyUrl?: string | null; |
| 588 | |
| 589 | aiGatewaySlug?: string; |
| 590 | cacheBehavior?: CacheBehavior; |
| 591 | capabilities?: ModelCapability; |
| 592 | roles?: ModelRole[]; |
| 593 | |
| 594 | useLegacyCompletionsEndpoint?: boolean; |
| 595 | |
| 596 | // Embedding options |
| 597 | embeddingId?: string; |
| 598 | maxEmbeddingChunkSize?: number; |
| 599 | maxEmbeddingBatchSize?: number; |
| 600 | |
| 601 | // Cloudflare options |
| 602 | accountId?: string; |
| 603 | |
| 604 | // Azure options |
| 605 | deployment?: string; |
| 606 | apiVersion?: string; |
| 607 | apiType?: string; |
| 608 | |
| 609 | // AWS options |
| 610 | profile?: string; |
| 611 | modelArn?: string; |
| 612 | |
| 613 | // AWS and VertexAI Options |
| 614 | region?: string; |
| 615 | |
| 616 | // VertexAI and Watsonx Options |
| 617 | projectId?: string; |
| 618 | |
| 619 | // IBM watsonx Options |
| 620 | deploymentId?: string; |
| 621 | |
| 622 | env?: Record<string, string | number | boolean>; |
| 623 | } |
| 624 | |
| 625 | type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick< |
| 626 | T, |
| 627 | Exclude<keyof T, Keys> |
| 628 | > & |
| 629 | { |
| 630 | [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>; |
| 631 | }[Keys]; |
| 632 | |
| 633 | export interface CustomLLMWithOptionals { |
| 634 | options: LLMOptions; |
| 635 | streamCompletion?: ( |
| 636 | prompt: string, |
| 637 | signal: AbortSignal, |
| 638 | options: CompletionOptions, |
| 639 | fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>, |
| 640 | ) => AsyncGenerator<string>; |
| 641 | streamChat?: ( |
| 642 | messages: ChatMessage[], |
| 643 | signal: AbortSignal, |
| 644 | options: CompletionOptions, |
| 645 | fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>, |
| 646 | ) => AsyncGenerator<ChatMessage | string>; |
| 647 | listModels?: ( |
| 648 | fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>, |
| 649 | ) => Promise<string[]>; |
| 650 | } |
| 651 | |
| 652 | /** |
| 653 | * The LLM interface requires you to specify either `streamCompletion` or `streamChat` (or both). |
| 654 | */ |
| 655 | export type CustomLLM = RequireAtLeastOne< |
| 656 | CustomLLMWithOptionals, |
| 657 | "streamCompletion" | "streamChat" |
| 658 | >; |
| 659 | |
| 660 | // IDE |
| 661 | |
| 662 | export type DiffLineType = "new" | "old" | "same"; |
| 663 | |
| 664 | export interface DiffLine { |
| 665 | type: DiffLineType; |
| 666 | line: string; |
| 667 | } |
| 668 | |
| 669 | export interface Problem { |
| 670 | filepath: string; |
| 671 | range: Range; |
| 672 | message: string; |
| 673 | } |
| 674 | |
| 675 | export interface Thread { |
| 676 | name: string; |
| 677 | id: number; |
| 678 | } |
| 679 | |
| 680 | export type IdeType = "vscode" | "jetbrains"; |
| 681 | |
| 682 | export interface IdeInfo { |
| 683 | ideType: IdeType; |
| 684 | name: string; |
| 685 | version: string; |
| 686 | remoteName: string; |
| 687 | extensionVersion: string; |
| 688 | } |
| 689 | |
| 690 | export interface BranchAndDir { |
| 691 | branch: string; |
| 692 | directory: string; |
| 693 | } |
| 694 | |
| 695 | export interface IndexTag extends BranchAndDir { |
| 696 | artifactId: string; |
| 697 | } |
| 698 | |
| 699 | export enum FileType { |
| 700 | Unkown = 0, |
| 701 | File = 1, |
| 702 | Directory = 2, |
| 703 | SymbolicLink = 64, |
| 704 | } |
| 705 | |
| 706 | export interface IdeSettings { |
| 707 | remoteConfigServerUrl: string | undefined; |
| 708 | remoteConfigSyncPeriod: number; |
| 709 | userToken: string; |
| 710 | continueTestEnvironment: "none" | "production" | "staging" | "local"; |
| 711 | pauseCodebaseIndexOnStart: boolean; |
| 712 | } |
| 713 | |
| 714 | export interface FileStats { |
| 715 | size: number; |
| 716 | lastModified: number; |
| 717 | } |
| 718 | |
| 719 | /** Map of file name to stats */ |
| 720 | export type FileStatsMap = { |
| 721 | [path: string]: FileStats; |
| 722 | }; |
| 723 | |
| 724 | export interface IDE { |
| 725 | getIdeInfo(): Promise<IdeInfo>; |
| 726 | |
| 727 | getIdeSettings(): Promise<IdeSettings>; |
| 728 | |
| 729 | getDiff(includeUnstaged: boolean): Promise<string[]>; |
| 730 | |
| 731 | getClipboardContent(): Promise<{ text: string; copiedAt: string }>; |
| 732 | |
| 733 | isTelemetryEnabled(): Promise<boolean>; |
| 734 | |
| 735 | isWorkspaceRemote(): Promise<boolean>; |
| 736 | |
| 737 | getUniqueId(): Promise<string>; |
| 738 | |
| 739 | getTerminalContents(): Promise<string>; |
| 740 | |
| 741 | getDebugLocals(threadIndex: number): Promise<string>; |
| 742 | |
| 743 | getTopLevelCallStackSources( |
| 744 | threadIndex: number, |
| 745 | stackDepth: number, |
| 746 | ): Promise<string[]>; |
| 747 | |
| 748 | getAvailableThreads(): Promise<Thread[]>; |
| 749 | |
| 750 | getWorkspaceDirs(): Promise<string[]>; |
| 751 | |
| 752 | getWorkspaceConfigs(): Promise<ContinueRcJson[]>; |
| 753 | |
| 754 | fileExists(fileUri: string): Promise<boolean>; |
| 755 | |
| 756 | writeFile(path: string, contents: string): Promise<void>; |
| 757 | |
| 758 | showVirtualFile(title: string, contents: string): Promise<void>; |
| 759 | |
| 760 | openFile(path: string): Promise<void>; |
| 761 | |
| 762 | openUrl(url: string): Promise<void>; |
| 763 | |
| 764 | runCommand(command: string, options?: TerminalOptions): Promise<void>; |
| 765 | |
| 766 | saveFile(fileUri: string): Promise<void>; |
| 767 | |
| 768 | readFile(fileUri: string): Promise<string>; |
| 769 | |
| 770 | readRangeInFile(fileUri: string, range: Range): Promise<string>; |
| 771 | |
| 772 | showLines(fileUri: string, startLine: number, endLine: number): Promise<void>; |
| 773 | |
| 774 | getOpenFiles(): Promise<string[]>; |
| 775 | |
| 776 | getCurrentFile(): Promise< |
| 777 | | undefined |
| 778 | | { |
| 779 | isUntitled: boolean; |
| 780 | path: string; |
| 781 | contents: string; |
| 782 | } |
| 783 | >; |
| 784 | |
| 785 | getPinnedFiles(): Promise<string[]>; |
| 786 | |
| 787 | getSearchResults(query: string, maxResults?: number): Promise<string>; |
| 788 | |
| 789 | getFileResults(pattern: string, maxResults?: number): Promise<string[]>; |
| 790 | |
| 791 | subprocess(command: string, cwd?: string): Promise<[string, string]>; |
| 792 | |
| 793 | getProblems(fileUri?: string | undefined): Promise<Problem[]>; |
| 794 | |
| 795 | getBranch(dir: string): Promise<string>; |
| 796 | |
| 797 | getTags(artifactId: string): Promise<IndexTag[]>; |
| 798 | |
| 799 | getRepoName(dir: string): Promise<string | undefined>; |
| 800 | |
| 801 | showToast( |
| 802 | type: ToastType, |
| 803 | message: string, |
| 804 | ...otherParams: any[] |
| 805 | ): Promise<any>; |
| 806 | |
| 807 | getGitRootPath(dir: string): Promise<string | undefined>; |
| 808 | |
| 809 | listDir(dir: string): Promise<[string, FileType][]>; |
| 810 | |
| 811 | getFileStats(files: string[]): Promise<FileStatsMap>; |
| 812 | |
| 813 | // Secret Storage |
| 814 | readSecrets(keys: string[]): Promise<Record<string, string>>; |
| 815 | |
| 816 | writeSecrets(secrets: { [key: string]: string }): Promise<void>; |
| 817 | |
| 818 | // LSP |
| 819 | gotoDefinition(location: Location): Promise<RangeInFile[]>; |
| 820 | |
| 821 | // Callbacks |
| 822 | onDidChangeActiveTextEditor(callback: (fileUri: string) => void): void; |
| 823 | } |
| 824 | |
| 825 | // Slash Commands |
| 826 | |
| 827 | export interface ContinueSDK { |
| 828 | ide: IDE; |
| 829 | llm: ILLM; |
| 830 | addContextItem: (item: ContextItemWithId) => void; |
| 831 | history: ChatMessage[]; |
| 832 | input: string; |
| 833 | params?: { [key: string]: any } | undefined; |
| 834 | contextItems: ContextItemWithId[]; |
| 835 | selectedCode: RangeInFile[]; |
| 836 | config: ContinueConfig; |
| 837 | fetch: FetchFunction; |
| 838 | completionOptions?: LLMFullCompletionOptions; |
| 839 | abortController: AbortController; |
| 840 | } |
| 841 | |
| 842 | /* Be careful changing SlashCommand or SlashCommandDescription, config.ts can break */ |
| 843 | export interface SlashCommandDescription { |
| 844 | name: string; |
| 845 | description: string; |
| 846 | prompt?: string; |
| 847 | params?: { [key: string]: any }; |
| 848 | } |
| 849 | |
| 850 | export interface SlashCommand extends SlashCommandDescription { |
| 851 | run: (sdk: ContinueSDK) => AsyncGenerator<string | undefined>; |
| 852 | } |
| 853 | |
| 854 | export interface SlashCommandWithSource extends SlashCommandDescription { |
| 855 | run?: (sdk: ContinueSDK) => AsyncGenerator<string | undefined>; // Optional - only needed for legacy |
| 856 | source: SlashCommandSource; |
| 857 | promptFile?: string; |
| 858 | overrideSystemMessage?: string; |
| 859 | } |
| 860 | |
| 861 | export type SlashCommandSource = |
| 862 | | "built-in-legacy" |
| 863 | | "built-in" |
| 864 | | "json-custom-command" |
| 865 | | "config-ts-slash-command" |
| 866 | | "yaml-prompt-block" |
| 867 | | "mcp-prompt" |
| 868 | | "prompt-file-v1" |
| 869 | | "prompt-file-v2" |
| 870 | | "invokable-rule"; |
| 871 | |
| 872 | export interface SlashCommandDescWithSource extends SlashCommandDescription { |
| 873 | isLegacy: boolean; // Maps to if slashcommand.run exists |
| 874 | source: SlashCommandSource; |
| 875 | promptFile?: string; |
| 876 | mcpServerName?: string; |
| 877 | mcpArgs?: MCPPromptArgs; |
| 878 | } |
| 879 | |
| 880 | // Config |
| 881 | |
| 882 | export type StepName = |
| 883 | | "AnswerQuestionChroma" |
| 884 | | "GenerateShellCommandStep" |
| 885 | | "EditHighlightedCodeStep" |
| 886 | | "ShareSessionStep" |
| 887 | | "CommentCodeStep" |
| 888 | | "ClearHistoryStep" |
| 889 | | "StackOverflowStep" |
| 890 | | "OpenConfigStep" |
| 891 | | "GenerateShellCommandStep" |
| 892 | | "DraftIssueStep"; |
| 893 | |
| 894 | export type ContextProviderName = |
| 895 | | "diff" |
| 896 | | "terminal" |
| 897 | | "debugger" |
| 898 | | "open" |
| 899 | | "google" |
| 900 | | "search" |
| 901 | | "tree" |
| 902 | | "http" |
| 903 | | "codebase" |
| 904 | | "problems" |
| 905 | | "folder" |
| 906 | | "jira" |
| 907 | | "postgres" |
| 908 | | "database" |
| 909 | | "code" |
| 910 | | "docs" |
| 911 | | "gitlab-mr" |
| 912 | | "os" |
| 913 | | "currentFile" |
| 914 | | "greptile" |
| 915 | | "outline" |
| 916 | | "continue-proxy" |
| 917 | | "highlights" |
| 918 | | "file" |
| 919 | | "issue" |
| 920 | | "repo-map" |
| 921 | | "url" |
| 922 | | "commit" |
| 923 | | "web" |
| 924 | | "discord" |
| 925 | | "clipboard" |
| 926 | | string; |
| 927 | |
| 928 | export type TemplateType = |
| 929 | | "llama2" |
| 930 | | "alpaca" |
| 931 | | "zephyr" |
| 932 | | "phi2" |
| 933 | | "phind" |
| 934 | | "anthropic" |
| 935 | | "chatml" |
| 936 | | "none" |
| 937 | | "openchat" |
| 938 | | "deepseek" |
| 939 | | "xwin-coder" |
| 940 | | "neural-chat" |
| 941 | | "codellama-70b" |
| 942 | | "llava" |
| 943 | | "gemma" |
| 944 | | "granite" |
| 945 | | "llama3" |
| 946 | | "codestral"; |
| 947 | |
| 948 | export interface RequestOptions { |
| 949 | timeout?: number; |
| 950 | verifySsl?: boolean; |
| 951 | caBundlePath?: string | string[]; |
| 952 | proxy?: string; |
| 953 | headers?: { [key: string]: string }; |
| 954 | extraBodyProperties?: { [key: string]: any }; |
| 955 | noProxy?: string[]; |
| 956 | clientCertificate?: ClientCertificateOptions; |
| 957 | } |
| 958 | |
| 959 | export interface CacheBehavior { |
| 960 | cacheSystemMessage?: boolean; |
| 961 | cacheConversation?: boolean; |
| 962 | } |
| 963 | |
| 964 | export interface ClientCertificateOptions { |
| 965 | cert: string; |
| 966 | key: string; |
| 967 | passphrase?: string; |
| 968 | } |
| 969 | |
| 970 | export interface StepWithParams { |
| 971 | name: StepName; |
| 972 | params: { [key: string]: any }; |
| 973 | } |
| 974 | |
| 975 | export interface ContextProviderWithParams { |
| 976 | name: ContextProviderName; |
| 977 | params: { [key: string]: any }; |
| 978 | } |
| 979 | |
| 980 | export interface CustomCommand { |
| 981 | name: string; |
| 982 | prompt: string; |
| 983 | description?: string; |
| 984 | } |
| 985 | |
| 986 | export interface Prediction { |
| 987 | type: "content"; |
| 988 | content: |
| 989 | | string |
| 990 | | { |
| 991 | type: "text"; |
| 992 | text: string; |
| 993 | }[]; |
| 994 | } |
| 995 | |
| 996 | export interface ToolExtras { |
| 997 | ide: IDE; |
| 998 | llm: ILLM; |
| 999 | fetch: FetchFunction; |
| 1000 | tool: Tool; |
| 1001 | toolCallId?: string; |
| 1002 | onPartialOutput?: (params: { |
| 1003 | toolCallId: string; |
| 1004 | contextItems: ContextItem[]; |
| 1005 | }) => void; |
| 1006 | config: ContinueConfig; |
| 1007 | codeBaseIndexer?: CodebaseIndexer; |
| 1008 | } |
| 1009 | |
| 1010 | export interface Tool { |
| 1011 | type: "function"; |
| 1012 | function: { |
| 1013 | name: string; |
| 1014 | description?: string; |
| 1015 | parameters?: Record<string, any>; |
| 1016 | strict?: boolean | null; |
| 1017 | }; |
| 1018 | |
| 1019 | displayTitle: string; |
| 1020 | wouldLikeTo?: string; |
| 1021 | isCurrently?: string; |
| 1022 | hasAlready?: string; |
| 1023 | readonly: boolean; |
| 1024 | isInstant?: boolean; |
| 1025 | uri?: string; |
| 1026 | faviconUrl?: string; |
| 1027 | group: string; |
| 1028 | originalFunctionName?: string; |
| 1029 | } |
| 1030 | |
| 1031 | interface ToolChoice { |
| 1032 | type: "function"; |
| 1033 | function: { |
| 1034 | name: string; |
| 1035 | }; |
| 1036 | } |
| 1037 | |
| 1038 | export interface ConfigDependentToolParams { |
| 1039 | rules: RuleWithSource[]; |
| 1040 | enableExperimentalTools: boolean; |
| 1041 | } |
| 1042 | |
| 1043 | export type GetTool = (params: ConfigDependentToolParams) => Tool; |
| 1044 | |
| 1045 | export interface BaseCompletionOptions { |
| 1046 | temperature?: number; |
| 1047 | topP?: number; |
| 1048 | topK?: number; |
| 1049 | minP?: number; |
| 1050 | presencePenalty?: number; |
| 1051 | frequencyPenalty?: number; |
| 1052 | mirostat?: number; |
| 1053 | stop?: string[]; |
| 1054 | maxTokens?: number; |
| 1055 | numThreads?: number; |
| 1056 | useMmap?: boolean; |
| 1057 | keepAlive?: number; |
| 1058 | numGpu?: number; |
| 1059 | raw?: boolean; |
| 1060 | stream?: boolean; |
| 1061 | prediction?: Prediction; |
| 1062 | tools?: Tool[]; |
| 1063 | toolChoice?: ToolChoice; |
| 1064 | reasoning?: boolean; |
| 1065 | reasoningBudgetTokens?: number; |
| 1066 | promptCaching?: boolean; |
| 1067 | } |
| 1068 | |
| 1069 | export interface ModelCapability { |
| 1070 | uploadImage?: boolean; |
| 1071 | tools?: boolean; |
| 1072 | } |
| 1073 | |
| 1074 | export interface ModelDescription { |
| 1075 | title: string; |
| 1076 | provider: string; |
| 1077 | underlyingProviderName: string; |
| 1078 | model: string; |
| 1079 | apiKey?: string; |
| 1080 | |
| 1081 | apiBase?: string; |
| 1082 | apiKeyLocation?: string; |
| 1083 | orgScopeId?: string | null; |
| 1084 | |
| 1085 | onPremProxyUrl?: string | null; |
| 1086 | |
| 1087 | contextLength?: number; |
| 1088 | maxStopWords?: number; |
| 1089 | template?: TemplateType; |
| 1090 | completionOptions?: BaseCompletionOptions; |
| 1091 | baseAgentSystemMessage?: string; |
| 1092 | baseChatSystemMessage?: string; |
| 1093 | requestOptions?: RequestOptions; |
| 1094 | promptTemplates?: { [key: string]: string }; |
| 1095 | cacheBehavior?: CacheBehavior; |
| 1096 | capabilities?: ModelCapability; |
| 1097 | roles?: ModelRole[]; |
| 1098 | configurationStatus?: LLMConfigurationStatuses; |
| 1099 | } |
| 1100 | |
| 1101 | export interface JSONEmbedOptions { |
| 1102 | apiBase?: string; |
| 1103 | apiKey?: string; |
| 1104 | model?: string; |
| 1105 | deployment?: string; |
| 1106 | apiType?: string; |
| 1107 | apiVersion?: string; |
| 1108 | requestOptions?: RequestOptions; |
| 1109 | maxEmbeddingChunkSize?: number; |
| 1110 | maxEmbeddingBatchSize?: number; |
| 1111 | |
| 1112 | // AWS options |
| 1113 | profile?: string; |
| 1114 | |
| 1115 | // AWS and VertexAI Options |
| 1116 | region?: string; |
| 1117 | |
| 1118 | // VertexAI and Watsonx Options |
| 1119 | projectId?: string; |
| 1120 | } |
| 1121 | |
| 1122 | export interface EmbeddingsProviderDescription extends JSONEmbedOptions { |
| 1123 | provider: string; |
| 1124 | } |
| 1125 | |
| 1126 | export interface RerankerDescription { |
| 1127 | name: string; |
| 1128 | params?: { [key: string]: any }; |
| 1129 | } |
| 1130 | |
| 1131 | // TODO: We should consider renaming this to AutocompleteOptions. |
| 1132 | export interface TabAutocompleteOptions { |
| 1133 | disable: boolean; |
| 1134 | maxPromptTokens: number; |
| 1135 | debounceDelay: number; |
| 1136 | modelTimeout: number; |
| 1137 | maxSuffixPercentage: number; |
| 1138 | prefixPercentage: number; |
| 1139 | transform?: boolean; |
| 1140 | template?: string; |
| 1141 | multilineCompletions: "always" | "never" | "auto"; |
| 1142 | slidingWindowPrefixPercentage: number; |
| 1143 | slidingWindowSize: number; |
| 1144 | useCache: boolean; |
| 1145 | onlyMyCode: boolean; |
| 1146 | useRecentlyEdited: boolean; |
| 1147 | useRecentlyOpened: boolean; |
| 1148 | disableInFiles?: string[]; |
| 1149 | useImports?: boolean; |
| 1150 | showWhateverWeHaveAtXMs?: number; |
| 1151 | // true = enabled, false = disabled, number = enabled with priority |
| 1152 | experimental_includeClipboard: boolean | number; |
| 1153 | experimental_includeRecentlyVisitedRanges: boolean | number; |
| 1154 | experimental_includeRecentlyEditedRanges: boolean | number; |
| 1155 | experimental_includeDiff: boolean | number; |
| 1156 | } |
| 1157 | |
| 1158 | export interface StdioOptions { |
| 1159 | type: "stdio"; |
| 1160 | command: string; |
| 1161 | args: string[]; |
| 1162 | env?: Record<string, string>; |
| 1163 | requestOptions?: RequestOptions; |
| 1164 | } |
| 1165 | |
| 1166 | export interface WebSocketOptions { |
| 1167 | type: "websocket"; |
| 1168 | url: string; |
| 1169 | requestOptions?: RequestOptions; |
| 1170 | } |
| 1171 | |
| 1172 | export interface SSEOptions { |
| 1173 | type: "sse"; |
| 1174 | url: string; |
| 1175 | requestOptions?: RequestOptions; |
| 1176 | } |
| 1177 | |
| 1178 | export interface StreamableHTTPOptions { |
| 1179 | type: "streamable-http"; |
| 1180 | url: string; |
| 1181 | requestOptions?: RequestOptions; |
| 1182 | } |
| 1183 | |
| 1184 | export type TransportOptions = |
| 1185 | | StdioOptions |
| 1186 | | WebSocketOptions |
| 1187 | | SSEOptions |
| 1188 | | StreamableHTTPOptions; |
| 1189 | |
| 1190 | export interface MCPOptions { |
| 1191 | name: string; |
| 1192 | id: string; |
| 1193 | transport: TransportOptions; |
| 1194 | faviconUrl?: string; |
| 1195 | timeout?: number; |
| 1196 | } |
| 1197 | |
| 1198 | export type MCPConnectionStatus = |
| 1199 | | "connecting" |
| 1200 | | "connected" |
| 1201 | | "error" |
| 1202 | | "not-connected"; |
| 1203 | |
| 1204 | export type MCPPromptArgs = { |
| 1205 | name: string; |
| 1206 | description?: string; |
| 1207 | required?: boolean; |
| 1208 | }[]; |
| 1209 | |
| 1210 | export interface MCPPrompt { |
| 1211 | name: string; |
| 1212 | description?: string; |
| 1213 | arguments?: MCPPromptArgs; |
| 1214 | } |
| 1215 | |
| 1216 | // Leaving here to ideate on |
| 1217 | // export type ContinueConfigSource = "local-yaml" | "local-json" | "hub-assistant" | "hub" |
| 1218 | |
| 1219 | // https://modelcontextprotocol.io/docs/concepts/resources#direct-resources |
| 1220 | export interface MCPResource { |
| 1221 | name: string; |
| 1222 | uri: string; |
| 1223 | description?: string; |
| 1224 | mimeType?: string; |
| 1225 | } |
| 1226 | |
| 1227 | // https://modelcontextprotocol.io/docs/concepts/resources#resource-templates |
| 1228 | export interface MCPResourceTemplate { |
| 1229 | uriTemplate: string; |
| 1230 | name: string; |
| 1231 | description?: string; |
| 1232 | mimeType?: string; |
| 1233 | } |
| 1234 | |
| 1235 | export interface MCPTool { |
| 1236 | name: string; |
| 1237 | description?: string; |
| 1238 | inputSchema: { |
| 1239 | type: "object"; |
| 1240 | properties?: Record<string, any>; |
| 1241 | }; |
| 1242 | } |
| 1243 | |
| 1244 | export interface MCPServerStatus extends MCPOptions { |
| 1245 | status: MCPConnectionStatus; |
| 1246 | errors: string[]; |
| 1247 | |
| 1248 | prompts: MCPPrompt[]; |
| 1249 | tools: MCPTool[]; |
| 1250 | resources: MCPResource[]; |
| 1251 | resourceTemplates: MCPResourceTemplate[]; |
| 1252 | } |
| 1253 | |
| 1254 | export interface ContinueUIConfig { |
| 1255 | codeBlockToolbarPosition?: "top" | "bottom"; |
| 1256 | fontSize?: number; |
| 1257 | displayRawMarkdown?: boolean; |
| 1258 | showChatScrollbar?: boolean; |
| 1259 | codeWrap?: boolean; |
| 1260 | showSessionTabs?: boolean; |
| 1261 | autoAcceptEditToolDiffs?: boolean; |
| 1262 | logEditingData?: boolean; |
| 1263 | } |
| 1264 | |
| 1265 | export interface ContextMenuConfig { |
| 1266 | comment?: string; |
| 1267 | docstring?: string; |
| 1268 | fix?: string; |
| 1269 | optimize?: string; |
| 1270 | fixGrammar?: string; |
| 1271 | } |
| 1272 | |
| 1273 | export interface ExperimentalModelRoles { |
| 1274 | repoMapFileSelection?: string; |
| 1275 | inlineEdit?: string; |
| 1276 | applyCodeBlock?: string; |
| 1277 | } |
| 1278 | |
| 1279 | export interface ExperimentalMCPOptions { |
| 1280 | transport: TransportOptions; |
| 1281 | faviconUrl?: string; |
| 1282 | timeout?: number; |
| 1283 | } |
| 1284 | |
| 1285 | export type ApplyStateStatus = |
| 1286 | | "not-started" // Apply state created but not necessarily streaming |
| 1287 | | "streaming" // Changes are being applied to the file |
| 1288 | | "done" // All changes have been applied, awaiting user to accept/reject |
| 1289 | | "closed"; // All changes have been applied. Note that for new files, we immediately set the status to "closed" |
| 1290 | |
| 1291 | export interface ApplyState { |
| 1292 | streamId: string; |
| 1293 | status?: ApplyStateStatus; |
| 1294 | numDiffs?: number; |
| 1295 | filepath?: string; |
| 1296 | fileContent?: string; |
| 1297 | toolCallId?: string; |
| 1298 | } |
| 1299 | |
| 1300 | export interface StreamDiffLinesPayload { |
| 1301 | prefix: string; |
| 1302 | highlighted: string; |
| 1303 | suffix: string; |
| 1304 | input: string; |
| 1305 | language: string | undefined; |
| 1306 | modelTitle: string | undefined; |
| 1307 | includeRulesInSystemMessage: boolean; |
| 1308 | fileUri?: string; |
| 1309 | } |
| 1310 | |
| 1311 | export interface HighlightedCodePayload { |
| 1312 | rangeInFileWithContents: RangeInFileWithContents; |
| 1313 | prompt?: string; |
| 1314 | shouldRun?: boolean; |
| 1315 | } |
| 1316 | |
| 1317 | export interface AcceptOrRejectDiffPayload { |
| 1318 | filepath?: string; |
| 1319 | streamId?: string; |
| 1320 | } |
| 1321 | |
| 1322 | export interface ShowFilePayload { |
| 1323 | filepath: string; |
| 1324 | } |
| 1325 | |
| 1326 | export interface ApplyToFilePayload { |
| 1327 | streamId: string; |
| 1328 | filepath?: string; |
| 1329 | text: string; |
| 1330 | toolCallId?: string; |
| 1331 | isSearchAndReplace?: boolean; |
| 1332 | } |
| 1333 | |
| 1334 | export interface RangeInFileWithContents { |
| 1335 | filepath: string; |
| 1336 | range: { |
| 1337 | start: { line: number; character: number }; |
| 1338 | end: { line: number; character: number }; |
| 1339 | }; |
| 1340 | contents: string; |
| 1341 | } |
| 1342 | |
| 1343 | export interface RangeInFileWithNextEditInfo { |
| 1344 | filepath: string; |
| 1345 | range: Range; |
| 1346 | fileContents: string; |
| 1347 | editText: string; |
| 1348 | afterCursorPos: Position; |
| 1349 | beforeCursorPos: Position; |
| 1350 | workspaceDir: string; |
| 1351 | } |
| 1352 | |
| 1353 | export type SetCodeToEditPayload = RangeInFileWithContents | FileWithContents; |
| 1354 | |
| 1355 | /** |
| 1356 | * Represents the configuration for a quick action in the Code Lens. |
| 1357 | * Quick actions are custom commands that can be added to function and class declarations. |
| 1358 | */ |
| 1359 | export interface QuickActionConfig { |
| 1360 | /** |
| 1361 | * The title of the quick action that will display in the Code Lens. |
| 1362 | */ |
| 1363 | title: string; |
| 1364 | |
| 1365 | /** |
| 1366 | * The prompt that will be sent to the model when the quick action is invoked, |
| 1367 | * with the function or class body concatenated. |
| 1368 | */ |
| 1369 | prompt: string; |
| 1370 | |
| 1371 | /** |
| 1372 | * If `true`, the result of the quick action will be sent to the chat panel. |
| 1373 | * If `false`, the streamed result will be inserted into the document. |
| 1374 | * |
| 1375 | * Defaults to `false`. |
| 1376 | */ |
| 1377 | sendToChat: boolean; |
| 1378 | } |
| 1379 | |
| 1380 | export type DefaultContextProvider = ContextProviderWithParams & { |
| 1381 | query?: string; |
| 1382 | }; |
| 1383 | |
| 1384 | export interface ExperimentalConfig { |
| 1385 | contextMenuPrompts?: ContextMenuConfig; |
| 1386 | modelRoles?: ExperimentalModelRoles; |
| 1387 | defaultContext?: DefaultContextProvider[]; |
| 1388 | promptPath?: string; |
| 1389 | enableExperimentalTools?: boolean; |
| 1390 | |
| 1391 | /** |
| 1392 | * Quick actions are a way to add custom commands to the Code Lens of |
| 1393 | * function and class declarations. |
| 1394 | */ |
| 1395 | quickActions?: QuickActionConfig[]; |
| 1396 | |
| 1397 | /** |
| 1398 | * Automatically read LLM chat responses aloud using system TTS models |
| 1399 | */ |
| 1400 | readResponseTTS?: boolean; |
| 1401 | |
| 1402 | /** |
| 1403 | * If set to true, we will attempt to pull down and install an instance of Chromium |
| 1404 | * that is compatible with the current version of Puppeteer. |
| 1405 | * This is needed to crawl a large number of documentation sites that are dynamically rendered. |
| 1406 | */ |
| 1407 | useChromiumForDocsCrawling?: boolean; |
| 1408 | modelContextProtocolServers?: ExperimentalMCPOptions[]; |
| 1409 | |
| 1410 | /** |
| 1411 | * If enabled, will add the current file as context. |
| 1412 | */ |
| 1413 | useCurrentFileAsContext?: boolean; |
| 1414 | |
| 1415 | /** |
| 1416 | * If enabled, will save data on the user's editing processes |
| 1417 | */ |
| 1418 | logEditingData?: boolean; |
| 1419 | |
| 1420 | /** |
| 1421 | * If enabled, will enable next edit in place of autocomplete |
| 1422 | */ |
| 1423 | optInNextEditFeature?: boolean; |
| 1424 | } |
| 1425 | |
| 1426 | export interface AnalyticsConfig { |
| 1427 | provider: string; |
| 1428 | url?: string; |
| 1429 | clientKey?: string; |
| 1430 | } |
| 1431 | |
| 1432 | export interface JSONModelDescription { |
| 1433 | title: string; |
| 1434 | provider: string; |
| 1435 | underlyingProviderName: string; |
| 1436 | model: string; |
| 1437 | apiKey?: string; |
| 1438 | apiBase?: string; |
| 1439 | |
| 1440 | contextLength?: number; |
| 1441 | maxStopWords?: number; |
| 1442 | template?: TemplateType; |
| 1443 | completionOptions?: BaseCompletionOptions; |
| 1444 | systemMessage?: string; |
| 1445 | requestOptions?: RequestOptions; |
| 1446 | cacheBehavior?: CacheBehavior; |
| 1447 | |
| 1448 | region?: string; |
| 1449 | profile?: string; |
| 1450 | modelArn?: string; |
| 1451 | apiType?: "openai" | "azure"; |
| 1452 | apiVersion?: string; |
| 1453 | deployment?: string; |
| 1454 | projectId?: string; |
| 1455 | accountId?: string; |
| 1456 | aiGatewaySlug?: string; |
| 1457 | useLegacyCompletionsEndpoint?: boolean; |
| 1458 | deploymentId?: string; |
| 1459 | } |
| 1460 | |
| 1461 | // config.json |
| 1462 | export interface SerializedContinueConfig { |
| 1463 | env?: string[]; |
| 1464 | allowAnonymousTelemetry?: boolean; |
| 1465 | models: JSONModelDescription[]; |
| 1466 | systemMessage?: string; |
| 1467 | completionOptions?: BaseCompletionOptions; |
| 1468 | requestOptions?: RequestOptions; |
| 1469 | slashCommands?: SlashCommandDescription[]; |
| 1470 | customCommands?: CustomCommand[]; |
| 1471 | contextProviders?: ContextProviderWithParams[]; |
| 1472 | disableIndexing?: boolean; |
| 1473 | disableSessionTitles?: boolean; |
| 1474 | userToken?: string; |
| 1475 | embeddingsProvider?: EmbeddingsProviderDescription; |
| 1476 | tabAutocompleteModel?: JSONModelDescription | JSONModelDescription[]; |
| 1477 | tabAutocompleteOptions?: Partial<TabAutocompleteOptions>; |
| 1478 | ui?: ContinueUIConfig; |
| 1479 | reranker?: RerankerDescription; |
| 1480 | experimental?: ExperimentalConfig; |
| 1481 | analytics?: AnalyticsConfig; |
| 1482 | docs?: SiteIndexingConfig[]; |
| 1483 | data?: DataDestination[]; |
| 1484 | } |
| 1485 | |
| 1486 | export type ConfigMergeType = "merge" | "overwrite"; |
| 1487 | |
| 1488 | export type ContinueRcJson = Partial<SerializedContinueConfig> & { |
| 1489 | mergeBehavior: ConfigMergeType; |
| 1490 | }; |
| 1491 | |
| 1492 | // config.ts - give users simplified interfaces |
| 1493 | export interface Config { |
| 1494 | /** If set to true, Continue will collect anonymous usage data to improve the product. If set to false, we will collect nothing. Read here to learn more: https://docs.continue.dev/telemetry */ |
| 1495 | allowAnonymousTelemetry?: boolean; |
| 1496 | /** Each entry in this array will originally be a JSONModelDescription, the same object from your config.json, but you may add CustomLLMs. |
| 1497 | * A CustomLLM requires you only to define an AsyncGenerator that calls the LLM and yields string updates. You can choose to define either `streamCompletion` or `streamChat` (or both). |
| 1498 | * Continue will do the rest of the work to construct prompt templates, handle context items, prune context, etc. |
| 1499 | */ |
| 1500 | models: (CustomLLM | JSONModelDescription)[]; |
| 1501 | /** A system message to be followed by all of your models */ |
| 1502 | systemMessage?: string; |
| 1503 | /** The default completion options for all models */ |
| 1504 | completionOptions?: BaseCompletionOptions; |
| 1505 | /** Request options that will be applied to all models and context providers */ |
| 1506 | requestOptions?: RequestOptions; |
| 1507 | /** The list of slash commands that will be available in the sidebar */ |
| 1508 | slashCommands?: (SlashCommand | SlashCommandWithSource)[]; |
| 1509 | /** Each entry in this array will originally be a ContextProviderWithParams, the same object from your config.json, but you may add CustomContextProviders. |
| 1510 | * A CustomContextProvider requires you only to define a title and getContextItems function. When you type '@title <query>', Continue will call `getContextItems(query)`. |
| 1511 | */ |
| 1512 | contextProviders?: (CustomContextProvider | ContextProviderWithParams)[]; |
| 1513 | /** If set to true, Continue will not index your codebase for retrieval */ |
| 1514 | disableIndexing?: boolean; |
| 1515 | /** If set to true, Continue will not make extra requests to the LLM to generate a summary title of each session. */ |
| 1516 | disableSessionTitles?: boolean; |
| 1517 | /** An optional token to identify a user. Not used by Continue unless you write custom coniguration that requires such a token */ |
| 1518 | userToken?: string; |
| 1519 | /** The provider used to calculate embeddings. If left empty, Continue will use transformers.js to calculate the embeddings with all-MiniLM-L6-v2 */ |
| 1520 | embeddingsProvider?: EmbeddingsProviderDescription | ILLM; |
| 1521 | /** The model that Continue will use for tab autocompletions. */ |
| 1522 | tabAutocompleteModel?: |
| 1523 | | CustomLLM |
| 1524 | | JSONModelDescription |
| 1525 | | (CustomLLM | JSONModelDescription)[]; |
| 1526 | /** Options for tab autocomplete */ |
| 1527 | tabAutocompleteOptions?: Partial<TabAutocompleteOptions>; |
| 1528 | /** UI styles customization */ |
| 1529 | ui?: ContinueUIConfig; |
| 1530 | /** Options for the reranker */ |
| 1531 | reranker?: RerankerDescription | ILLM; |
| 1532 | /** Experimental configuration */ |
| 1533 | experimental?: ExperimentalConfig; |
| 1534 | /** Analytics configuration */ |
| 1535 | analytics?: AnalyticsConfig; |
| 1536 | data?: DataDestination[]; |
| 1537 | } |
| 1538 | |
| 1539 | // in the actual Continue source code |
| 1540 | export interface ContinueConfig { |
| 1541 | allowAnonymousTelemetry?: boolean; |
| 1542 | // systemMessage?: string; |
| 1543 | completionOptions?: BaseCompletionOptions; |
| 1544 | requestOptions?: RequestOptions; |
| 1545 | slashCommands: SlashCommandWithSource[]; |
| 1546 | contextProviders: IContextProvider[]; |
| 1547 | disableSessionTitles?: boolean; |
| 1548 | disableIndexing?: boolean; |
| 1549 | userToken?: string; |
| 1550 | tabAutocompleteOptions?: Partial<TabAutocompleteOptions>; |
| 1551 | ui?: ContinueUIConfig; |
| 1552 | experimental?: ExperimentalConfig; |
| 1553 | analytics?: AnalyticsConfig; |
| 1554 | docs?: SiteIndexingConfig[]; |
| 1555 | tools: Tool[]; |
| 1556 | mcpServerStatuses: MCPServerStatus[]; |
| 1557 | rules: RuleWithSource[]; |
| 1558 | modelsByRole: Record<ModelRole, ILLM[]>; |
| 1559 | selectedModelByRole: Record<ModelRole, ILLM | null>; |
| 1560 | data?: DataDestination[]; |
| 1561 | } |
| 1562 | |
| 1563 | export interface BrowserSerializedContinueConfig { |
| 1564 | allowAnonymousTelemetry?: boolean; |
| 1565 | // systemMessage?: string; |
| 1566 | completionOptions?: BaseCompletionOptions; |
| 1567 | requestOptions?: RequestOptions; |
| 1568 | slashCommands: SlashCommandDescWithSource[]; |
| 1569 | contextProviders: ContextProviderDescription[]; |
| 1570 | disableIndexing?: boolean; |
| 1571 | disableSessionTitles?: boolean; |
| 1572 | userToken?: string; |
| 1573 | ui?: ContinueUIConfig; |
| 1574 | experimental?: ExperimentalConfig; |
| 1575 | analytics?: AnalyticsConfig; |
| 1576 | docs?: SiteIndexingConfig[]; |
| 1577 | tools: Tool[]; |
| 1578 | mcpServerStatuses: MCPServerStatus[]; |
| 1579 | rules: RuleWithSource[]; |
| 1580 | usePlatform: boolean; |
| 1581 | tabAutocompleteOptions?: Partial<TabAutocompleteOptions>; |
| 1582 | modelsByRole: Record<ModelRole, ModelDescription[]>; |
| 1583 | selectedModelByRole: Record<ModelRole, ModelDescription | null>; |
| 1584 | } |
| 1585 | |
| 1586 | // DOCS SUGGESTIONS AND PACKAGE INFO |
| 1587 | export interface FilePathAndName { |
| 1588 | path: string; |
| 1589 | name: string; |
| 1590 | } |
| 1591 | |
| 1592 | export interface PackageFilePathAndName extends FilePathAndName { |
| 1593 | packageRegistry: string; // e.g. npm, pypi |
| 1594 | } |
| 1595 | |
| 1596 | export type ParsedPackageInfo = { |
| 1597 | name: string; |
| 1598 | packageFile: PackageFilePathAndName; |
| 1599 | language: string; |
| 1600 | version: string; |
| 1601 | }; |
| 1602 | |
| 1603 | export type PackageDetails = { |
| 1604 | docsLink?: string; |
| 1605 | docsLinkWarning?: string; |
| 1606 | title?: string; |
| 1607 | description?: string; |
| 1608 | repo?: string; |
| 1609 | license?: string; |
| 1610 | }; |
| 1611 | |
| 1612 | export type PackageDetailsSuccess = PackageDetails & { |
| 1613 | docsLink: string; |
| 1614 | }; |
| 1615 | |
| 1616 | export type PackageDocsResult = { |
| 1617 | packageInfo: ParsedPackageInfo; |
| 1618 | } & ( |
| 1619 | | { error: string; details?: never } |
| 1620 | | { details: PackageDetailsSuccess; error?: never } |
| 1621 | ); |
| 1622 | |
| 1623 | export interface TerminalOptions { |
| 1624 | reuseTerminal?: boolean; |
| 1625 | terminalName?: string; |
| 1626 | waitForCompletion?: boolean; |
| 1627 | } |
| 1628 | |
| 1629 | export type RuleSource = |
| 1630 | | "default-chat" |
| 1631 | | "default-agent" |
| 1632 | | "model-chat-options" |
| 1633 | | "model-agent-options" |
| 1634 | | "rules-block" |
| 1635 | | "json-systemMessage" |
| 1636 | | ".continuerules"; |
| 1637 | |
| 1638 | export interface RuleWithSource { |
| 1639 | name?: string; |
| 1640 | slug?: string; |
| 1641 | source: RuleSource; |
| 1642 | globs?: string | string[]; |
| 1643 | regex?: string | string[]; |
| 1644 | rule: string; |
| 1645 | description?: string; |
| 1646 | ruleFile?: string; |
| 1647 | alwaysApply?: boolean; |
| 1648 | } |
| 1649 | export interface CompleteOnboardingPayload { |
| 1650 | mode: OnboardingModes; |
| 1651 | provider?: string; |
| 1652 | apiKey?: string; |
| 1653 | } |