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