Elffuss BraidHub

kikocis/continue public

91fbf794ce85 · 37.9 KiBRawPermalink
1import {
2 DataDestination,
3 ModelRole,
4 PromptTemplates,
5} from "@continuedev/config-yaml";
6import Parser from "web-tree-sitter";
7import { CodebaseIndexer } from "./indexing/CodebaseIndexer";
8import { LLMConfigurationStatuses } from "./llm/constants";
9
10declare 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
33export interface ChunkWithoutID {
34 content: string;
35 startLine: number;
36 endLine: number;
37 signature?: string;
38 otherMetadata?: { [key: string]: any };
39}
40
41export interface Chunk extends ChunkWithoutID {
42 digest: string;
43 filepath: string;
44 index: number; // Index of the chunk in the document at filepath
45}
46
47export 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.
63export 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
77export type PromptTemplateFunction = (
78 history: ChatMessage[],
79 otherData: Record<string, string>,
80) => string | ChatMessage[];
81
82export type PromptTemplate = string | PromptTemplateFunction;
83
84type RequiredLLMOptions =
85 | "uniqueId"
86 | "contextLength"
87 | "embeddingId"
88 | "maxEmbeddingChunkSize"
89 | "maxEmbeddingBatchSize"
90 | "completionOptions";
91
92export 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
157export 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
167export type ContextProviderType = "normal" | "query" | "submenu";
168
169export interface ContextProviderDescription {
170 title: ContextProviderName;
171 displayTitle: string;
172 description: string;
173 renderInlineAs?: string;
174 type: ContextProviderType;
175 dependsOnIndexing?: boolean;
176}
177
178export type FetchFunction = (url: string | URL, init?: any) => Promise<any>;
179
180export 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
191export interface LoadSubmenuItemsArgs {
192 config: ContinueConfig;
193 ide: IDE;
194 fetch: FetchFunction;
195}
196
197export 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
213export interface ContextSubmenuItem {
214 id: string;
215 title: string;
216 description: string;
217 icon?: string;
218 metadata?: any;
219}
220
221export interface ContextSubmenuItemWithProvider extends ContextSubmenuItem {
222 providerTitle: string;
223}
224
225export interface SiteIndexingConfig {
226 title: string;
227 startUrl: string;
228 maxDepth?: number;
229 faviconUrl?: string;
230 useLocalCrawling?: boolean;
231}
232
233export interface DocsIndexingDetails {
234 startUrl: string;
235 config: SiteIndexingConfig;
236 indexingStatus: IndexingStatus | undefined;
237 chunks: Chunk[];
238}
239
240export 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
251export interface Session {
252 sessionId: string;
253 title: string;
254 workspaceDirectory: string;
255 history: ChatHistoryItem[];
256}
257
258export interface SessionMetadata {
259 sessionId: string;
260 title: string;
261 dateCreated: string;
262 workspaceDirectory: string;
263}
264
265export interface RangeInFile {
266 filepath: string;
267 range: Range;
268}
269
270export interface Location {
271 filepath: string;
272 position: Position;
273}
274
275export interface FileWithContents {
276 filepath: string;
277 contents: string;
278}
279
280export interface Range {
281 start: Position;
282 end: Position;
283}
284
285export interface Position {
286 line: number;
287 character: number;
288}
289
290export interface FileEdit {
291 filepath: string;
292 range: Range;
293 replacement: string;
294}
295
296export interface ContinueError {
297 title: string;
298 message: string;
299}
300
301export interface CompletionOptions extends BaseCompletionOptions {
302 model: string;
303}
304
305export type ChatMessageRole =
306 | "user"
307 | "assistant"
308 | "thinking"
309 | "system"
310 | "tool";
311
312export type TextMessagePart = {
313 type: "text";
314 text: string;
315};
316
317export type ImageMessagePart = {
318 type: "imageUrl";
319 imageUrl: { url: string };
320};
321
322export type MessagePart = TextMessagePart | ImageMessagePart;
323
324export type MessageContent = string | MessagePart[];
325
326export interface ToolCall {
327 id: string;
328 type: "function";
329 function: {
330 name: string;
331 arguments: string;
332 };
333}
334
335export interface ToolCallDelta {
336 id?: string;
337 type?: "function";
338 function?: {
339 name?: string;
340 arguments?: string;
341 };
342}
343
344export interface ToolResultChatMessage {
345 role: "tool";
346 content: string;
347 toolCallId: string;
348}
349
350export interface UserChatMessage {
351 role: "user";
352 content: MessageContent;
353}
354
355export interface ThinkingChatMessage {
356 role: "thinking";
357 content: MessageContent;
358 signature?: string;
359 redactedThinking?: string;
360 toolCalls?: ToolCallDelta[];
361}
362
363export interface AssistantChatMessage {
364 role: "assistant";
365 content: MessageContent;
366 toolCalls?: ToolCallDelta[];
367}
368
369export interface SystemChatMessage {
370 role: "system";
371 content: string;
372}
373
374export type ChatMessage =
375 | UserChatMessage
376 | AssistantChatMessage
377 | ThinkingChatMessage
378 | SystemChatMessage
379 | ToolResultChatMessage;
380
381export interface ContextItemId {
382 providerTitle: string;
383 itemId: string;
384}
385
386export type ContextItemUriTypes = "file" | "url";
387
388export interface ContextItemUri {
389 type: ContextItemUriTypes;
390 value: string;
391}
392
393export 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
405export interface ContextItemWithId extends ContextItem {
406 id: ContextItemId;
407}
408
409export interface InputModifiers {
410 useCodebase: boolean;
411 noContext: boolean;
412}
413
414export interface SymbolWithRange extends RangeInFile {
415 name: string;
416 type: Parser.SyntaxNode["type"];
417 content: string;
418}
419
420export type FileSymbolMap = Record<string, SymbolWithRange[]>;
421
422export interface PromptLog {
423 modelTitle: string;
424 completionOptions: CompletionOptions;
425 prompt: string;
426 completion: string;
427}
428
429export type MessageModes = "chat" | "agent";
430
431export 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
440interface ToolCallState {
441 toolCallId: string;
442 toolCall: ToolCall;
443 status: ToolStatus;
444 parsedArgs: any;
445 output?: ContextItem[];
446}
447
448interface Reasoning {
449 active: boolean;
450 text: string;
451 startAt: number;
452 endAt?: number;
453}
454
455export 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
467export interface LLMFullCompletionOptions extends BaseCompletionOptions {
468 log?: boolean;
469 model?: string;
470}
471
472export type ToastType = "info" | "error" | "warning";
473
474export interface LLMInteractionBase {
475 interactionId: string;
476 timestamp: number;
477}
478
479export interface LLMInteractionStartChat extends LLMInteractionBase {
480 kind: "startChat";
481 messages: ChatMessage[];
482 options: CompletionOptions;
483}
484
485export interface LLMInteractionStartComplete extends LLMInteractionBase {
486 kind: "startComplete";
487 prompt: string;
488 options: CompletionOptions;
489}
490
491export interface LLMInteractionStartFim extends LLMInteractionBase {
492 kind: "startFim";
493 prefix: string;
494 suffix: string;
495 options: CompletionOptions;
496}
497
498export interface LLMInteractionChunk extends LLMInteractionBase {
499 kind: "chunk";
500 chunk: string;
501}
502
503export interface LLMInteractionMessage extends LLMInteractionBase {
504 kind: "message";
505 message: ChatMessage;
506}
507
508export interface LLMInteractionEnd extends LLMInteractionBase {
509 promptTokens: number;
510 generatedTokens: number;
511 thinkingTokens: number;
512}
513
514export interface LLMInteractionSuccess extends LLMInteractionEnd {
515 kind: "success";
516}
517
518export interface LLMInteractionCancel extends LLMInteractionEnd {
519 kind: "cancel";
520}
521
522export interface LLMInteractionError extends LLMInteractionEnd {
523 kind: "error";
524 name: string;
525 message: string;
526}
527
528export 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
545type DistributiveOmit<T, K extends PropertyKey> = T extends unknown
546 ? Omit<T, K>
547 : never;
548
549export type LLMInteractionItemDetails = DistributiveOmit<
550 LLMInteractionItem,
551 "interactionId" | "timestamp"
552>;
553
554export interface ILLMInteractionLog {
555 logItem(item: LLMInteractionItemDetails): void;
556}
557
558export interface ILLMLogger {
559 createInteractionLog(): ILLMInteractionLog;
560}
561
562export 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
624type 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
632export 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 */
654export type CustomLLM = RequireAtLeastOne<
655 CustomLLMWithOptionals,
656 "streamCompletion" | "streamChat"
657>;
658
659// IDE
660
661export type DiffLineType = "new" | "old" | "same";
662
663export interface DiffLine {
664 type: DiffLineType;
665 line: string;
666}
667
668export interface Problem {
669 filepath: string;
670 range: Range;
671 message: string;
672}
673
674export interface Thread {
675 name: string;
676 id: number;
677}
678
679export type IdeType = "vscode" | "jetbrains";
680
681export interface IdeInfo {
682 ideType: IdeType;
683 name: string;
684 version: string;
685 remoteName: string;
686 extensionVersion: string;
687}
688
689export interface BranchAndDir {
690 branch: string;
691 directory: string;
692}
693
694export interface IndexTag extends BranchAndDir {
695 artifactId: string;
696}
697
698export enum FileType {
699 Unkown = 0,
700 File = 1,
701 Directory = 2,
702 SymbolicLink = 64,
703}
704
705export interface IdeSettings {
706 remoteConfigServerUrl: string | undefined;
707 remoteConfigSyncPeriod: number;
708 userToken: string;
709 continueTestEnvironment: "none" | "production" | "staging" | "local";
710 pauseCodebaseIndexOnStart: boolean;
711}
712
713export interface FileStats {
714 size: number;
715 lastModified: number;
716}
717
718/** Map of file name to stats */
719export type FileStatsMap = {
720 [path: string]: FileStats;
721};
722
723export 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
826export 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 */
842export interface SlashCommandDescription {
843 name: string;
844 description: string;
845 prompt?: string;
846 params?: { [key: string]: any };
847}
848
849export interface SlashCommand extends SlashCommandDescription {
850 run: (sdk: ContinueSDK) => AsyncGenerator<string | undefined>;
851}
852
853export 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
860export 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
871export 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
881export type StepName =
882 | "AnswerQuestionChroma"
883 | "GenerateShellCommandStep"
884 | "EditHighlightedCodeStep"
885 | "ShareSessionStep"
886 | "CommentCodeStep"
887 | "ClearHistoryStep"
888 | "StackOverflowStep"
889 | "OpenConfigStep"
890 | "GenerateShellCommandStep"
891 | "DraftIssueStep";
892
893export 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
927export 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
947export 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
958export interface CacheBehavior {
959 cacheSystemMessage?: boolean;
960 cacheConversation?: boolean;
961}
962
963export interface ClientCertificateOptions {
964 cert: string;
965 key: string;
966 passphrase?: string;
967}
968
969export interface StepWithParams {
970 name: StepName;
971 params: { [key: string]: any };
972}
973
974export interface ContextProviderWithParams {
975 name: ContextProviderName;
976 params: { [key: string]: any };
977}
978
979export interface CustomCommand {
980 name: string;
981 prompt: string;
982 description?: string;
983}
984
985export interface Prediction {
986 type: "content";
987 content:
988 | string
989 | {
990 type: "text";
991 text: string;
992 }[];
993}
994
995export 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
1009export 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
1030interface ToolChoice {
1031 type: "function";
1032 function: {
1033 name: string;
1034 };
1035}
1036
1037export interface ConfigDependentToolParams {
1038 rules: RuleWithSource[];
1039 enableExperimentalTools: boolean;
1040}
1041
1042export type GetTool = (params: ConfigDependentToolParams) => Tool;
1043
1044export interface BaseCompletionOptions {
1045 temperature?: number;
1046 topP?: number;
1047 topK?: number;
1048 minP?: number;
1049 presencePenalty?: number;
1050 frequencyPenalty?: number;
1051 mirostat?: number;
1052 stop?: string[];
1053 maxTokens?: number;
1054 numThreads?: number;
1055 useMmap?: boolean;
1056 keepAlive?: number;
1057 numGpu?: number;
1058 raw?: boolean;
1059 stream?: boolean;
1060 prediction?: Prediction;
1061 tools?: Tool[];
1062 toolChoice?: ToolChoice;
1063 reasoning?: boolean;
1064 reasoningBudgetTokens?: number;
1065 promptCaching?: boolean;
1066}
1067
1068export interface ModelCapability {
1069 uploadImage?: boolean;
1070 tools?: boolean;
1071}
1072
1073export interface ModelDescription {
1074 title: string;
1075 provider: string;
1076 underlyingProviderName: string;
1077 model: string;
1078 apiKey?: string;
1079
1080 apiBase?: string;
1081 apiKeyLocation?: string;
1082 orgScopeId?: string | null;
1083
1084 onPremProxyUrl?: string | null;
1085
1086 contextLength?: number;
1087 maxStopWords?: number;
1088 template?: TemplateType;
1089 completionOptions?: BaseCompletionOptions;
1090 baseAgentSystemMessage?: string;
1091 baseChatSystemMessage?: string;
1092 requestOptions?: RequestOptions;
1093 promptTemplates?: { [key: string]: string };
1094 cacheBehavior?: CacheBehavior;
1095 capabilities?: ModelCapability;
1096 roles?: ModelRole[];
1097 configurationStatus?: LLMConfigurationStatuses;
1098}
1099
1100export interface JSONEmbedOptions {
1101 apiBase?: string;
1102 apiKey?: string;
1103 model?: string;
1104 deployment?: string;
1105 apiType?: string;
1106 apiVersion?: string;
1107 requestOptions?: RequestOptions;
1108 maxEmbeddingChunkSize?: number;
1109 maxEmbeddingBatchSize?: number;
1110
1111 // AWS options
1112 profile?: string;
1113
1114 // AWS and VertexAI Options
1115 region?: string;
1116
1117 // VertexAI and Watsonx Options
1118 projectId?: string;
1119}
1120
1121export interface EmbeddingsProviderDescription extends JSONEmbedOptions {
1122 provider: string;
1123}
1124
1125export interface RerankerDescription {
1126 name: string;
1127 params?: { [key: string]: any };
1128}
1129
1130// TODO: We should consider renaming this to AutocompleteOptions.
1131export interface TabAutocompleteOptions {
1132 disable: boolean;
1133 maxPromptTokens: number;
1134 debounceDelay: number;
1135 modelTimeout: number;
1136 maxSuffixPercentage: number;
1137 prefixPercentage: number;
1138 transform?: boolean;
1139 template?: string;
1140 multilineCompletions: "always" | "never" | "auto";
1141 slidingWindowPrefixPercentage: number;
1142 slidingWindowSize: number;
1143 useCache: boolean;
1144 onlyMyCode: boolean;
1145 useRecentlyEdited: boolean;
1146 useRecentlyOpened: boolean;
1147 disableInFiles?: string[];
1148 useImports?: boolean;
1149 showWhateverWeHaveAtXMs?: number;
1150 // true = enabled, false = disabled, number = enabled with priority
1151 experimental_includeClipboard: boolean | number;
1152 experimental_includeRecentlyVisitedRanges: boolean | number;
1153 experimental_includeRecentlyEditedRanges: boolean | number;
1154 experimental_includeDiff: boolean | number;
1155}
1156
1157export interface StdioOptions {
1158 type: "stdio";
1159 command: string;
1160 args: string[];
1161 env?: Record<string, string>;
1162 requestOptions?: RequestOptions;
1163}
1164
1165export interface WebSocketOptions {
1166 type: "websocket";
1167 url: string;
1168 requestOptions?: RequestOptions;
1169}
1170
1171export interface SSEOptions {
1172 type: "sse";
1173 url: string;
1174 requestOptions?: RequestOptions;
1175}
1176
1177export interface StreamableHTTPOptions {
1178 type: "streamable-http";
1179 url: string;
1180 requestOptions?: RequestOptions;
1181}
1182
1183export type TransportOptions =
1184 | StdioOptions
1185 | WebSocketOptions
1186 | SSEOptions
1187 | StreamableHTTPOptions;
1188
1189export interface MCPOptions {
1190 name: string;
1191 id: string;
1192 transport: TransportOptions;
1193 faviconUrl?: string;
1194 timeout?: number;
1195}
1196
1197export type MCPConnectionStatus =
1198 | "connecting"
1199 | "connected"
1200 | "error"
1201 | "not-connected";
1202
1203export type MCPPromptArgs = {
1204 name: string;
1205 description?: string;
1206 required?: boolean;
1207}[];
1208
1209export interface MCPPrompt {
1210 name: string;
1211 description?: string;
1212 arguments?: MCPPromptArgs;
1213}
1214
1215// Leaving here to ideate on
1216// export type ContinueConfigSource = "local-yaml" | "local-json" | "hub-assistant" | "hub"
1217
1218// https://modelcontextprotocol.io/docs/concepts/resources#direct-resources
1219export interface MCPResource {
1220 name: string;
1221 uri: string;
1222 description?: string;
1223 mimeType?: string;
1224}
1225
1226// https://modelcontextprotocol.io/docs/concepts/resources#resource-templates
1227export interface MCPResourceTemplate {
1228 uriTemplate: string;
1229 name: string;
1230 description?: string;
1231 mimeType?: string;
1232}
1233
1234export interface MCPTool {
1235 name: string;
1236 description?: string;
1237 inputSchema: {
1238 type: "object";
1239 properties?: Record<string, any>;
1240 };
1241}
1242
1243export interface MCPServerStatus extends MCPOptions {
1244 status: MCPConnectionStatus;
1245 errors: string[];
1246
1247 prompts: MCPPrompt[];
1248 tools: MCPTool[];
1249 resources: MCPResource[];
1250 resourceTemplates: MCPResourceTemplate[];
1251}
1252
1253export interface ContinueUIConfig {
1254 codeBlockToolbarPosition?: "top" | "bottom";
1255 fontSize?: number;
1256 displayRawMarkdown?: boolean;
1257 showChatScrollbar?: boolean;
1258 codeWrap?: boolean;
1259 showSessionTabs?: boolean;
1260 autoAcceptEditToolDiffs?: boolean;
1261}
1262
1263export interface ContextMenuConfig {
1264 comment?: string;
1265 docstring?: string;
1266 fix?: string;
1267 optimize?: string;
1268 fixGrammar?: string;
1269}
1270
1271export interface ExperimentalModelRoles {
1272 repoMapFileSelection?: string;
1273 inlineEdit?: string;
1274 applyCodeBlock?: string;
1275}
1276
1277export interface ExperimentalMCPOptions {
1278 transport: TransportOptions;
1279 faviconUrl?: string;
1280 timeout?: number;
1281}
1282
1283export type ApplyStateStatus =
1284 | "not-started" // Apply state created but not necessarily streaming
1285 | "streaming" // Changes are being applied to the file
1286 | "done" // All changes have been applied, awaiting user to accept/reject
1287 | "closed"; // All changes have been applied. Note that for new files, we immediately set the status to "closed"
1288
1289export interface ApplyState {
1290 streamId: string;
1291 status?: ApplyStateStatus;
1292 numDiffs?: number;
1293 filepath?: string;
1294 fileContent?: string;
1295 toolCallId?: string;
1296}
1297
1298export interface StreamDiffLinesPayload {
1299 prefix: string;
1300 highlighted: string;
1301 suffix: string;
1302 input: string;
1303 language: string | undefined;
1304 modelTitle: string | undefined;
1305 includeRulesInSystemMessage: boolean;
1306 fileUri?: string;
1307}
1308
1309export interface HighlightedCodePayload {
1310 rangeInFileWithContents: RangeInFileWithContents;
1311 prompt?: string;
1312 shouldRun?: boolean;
1313}
1314
1315export interface AcceptOrRejectDiffPayload {
1316 filepath?: string;
1317 streamId?: string;
1318}
1319
1320export interface ShowFilePayload {
1321 filepath: string;
1322}
1323
1324export interface ApplyToFilePayload {
1325 streamId: string;
1326 filepath?: string;
1327 text: string;
1328 toolCallId?: string;
1329 isSearchAndReplace?: boolean;
1330}
1331
1332export interface RangeInFileWithContents {
1333 filepath: string;
1334 range: {
1335 start: { line: number; character: number };
1336 end: { line: number; character: number };
1337 };
1338 contents: string;
1339}
1340
1341export type SetCodeToEditPayload = RangeInFileWithContents | FileWithContents;
1342
1343/**
1344 * Represents the configuration for a quick action in the Code Lens.
1345 * Quick actions are custom commands that can be added to function and class declarations.
1346 */
1347export interface QuickActionConfig {
1348 /**
1349 * The title of the quick action that will display in the Code Lens.
1350 */
1351 title: string;
1352
1353 /**
1354 * The prompt that will be sent to the model when the quick action is invoked,
1355 * with the function or class body concatenated.
1356 */
1357 prompt: string;
1358
1359 /**
1360 * If `true`, the result of the quick action will be sent to the chat panel.
1361 * If `false`, the streamed result will be inserted into the document.
1362 *
1363 * Defaults to `false`.
1364 */
1365 sendToChat: boolean;
1366}
1367
1368export type DefaultContextProvider = ContextProviderWithParams & {
1369 query?: string;
1370};
1371
1372export interface ExperimentalConfig {
1373 contextMenuPrompts?: ContextMenuConfig;
1374 modelRoles?: ExperimentalModelRoles;
1375 defaultContext?: DefaultContextProvider[];
1376 promptPath?: string;
1377 enableExperimentalTools?: boolean;
1378
1379 /**
1380 * Quick actions are a way to add custom commands to the Code Lens of
1381 * function and class declarations.
1382 */
1383 quickActions?: QuickActionConfig[];
1384
1385 /**
1386 * Automatically read LLM chat responses aloud using system TTS models
1387 */
1388 readResponseTTS?: boolean;
1389
1390 /**
1391 * If set to true, we will attempt to pull down and install an instance of Chromium
1392 * that is compatible with the current version of Puppeteer.
1393 * This is needed to crawl a large number of documentation sites that are dynamically rendered.
1394 */
1395 useChromiumForDocsCrawling?: boolean;
1396 modelContextProtocolServers?: ExperimentalMCPOptions[];
1397
1398 /**
1399 * If enabled, will add the current file as context.
1400 */
1401 useCurrentFileAsContext?: boolean;
1402}
1403
1404export interface AnalyticsConfig {
1405 provider: string;
1406 url?: string;
1407 clientKey?: string;
1408}
1409
1410export interface JSONModelDescription {
1411 title: string;
1412 provider: string;
1413 underlyingProviderName: string;
1414 model: string;
1415 apiKey?: string;
1416 apiBase?: string;
1417
1418 contextLength?: number;
1419 maxStopWords?: number;
1420 template?: TemplateType;
1421 completionOptions?: BaseCompletionOptions;
1422 systemMessage?: string;
1423 requestOptions?: RequestOptions;
1424 cacheBehavior?: CacheBehavior;
1425
1426 region?: string;
1427 profile?: string;
1428 modelArn?: string;
1429 apiType?: "openai" | "azure";
1430 apiVersion?: string;
1431 deployment?: string;
1432 projectId?: string;
1433 accountId?: string;
1434 aiGatewaySlug?: string;
1435 useLegacyCompletionsEndpoint?: boolean;
1436 deploymentId?: string;
1437}
1438
1439// config.json
1440export interface SerializedContinueConfig {
1441 env?: string[];
1442 allowAnonymousTelemetry?: boolean;
1443 models: JSONModelDescription[];
1444 systemMessage?: string;
1445 completionOptions?: BaseCompletionOptions;
1446 requestOptions?: RequestOptions;
1447 slashCommands?: SlashCommandDescription[];
1448 customCommands?: CustomCommand[];
1449 contextProviders?: ContextProviderWithParams[];
1450 disableIndexing?: boolean;
1451 disableSessionTitles?: boolean;
1452 userToken?: string;
1453 embeddingsProvider?: EmbeddingsProviderDescription;
1454 tabAutocompleteModel?: JSONModelDescription | JSONModelDescription[];
1455 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1456 ui?: ContinueUIConfig;
1457 reranker?: RerankerDescription;
1458 experimental?: ExperimentalConfig;
1459 analytics?: AnalyticsConfig;
1460 docs?: SiteIndexingConfig[];
1461 data?: DataDestination[];
1462}
1463
1464export type ConfigMergeType = "merge" | "overwrite";
1465
1466export type ContinueRcJson = Partial<SerializedContinueConfig> & {
1467 mergeBehavior: ConfigMergeType;
1468};
1469
1470// config.ts - give users simplified interfaces
1471export interface Config {
1472 /** 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 */
1473 allowAnonymousTelemetry?: boolean;
1474 /** Each entry in this array will originally be a JSONModelDescription, the same object from your config.json, but you may add CustomLLMs.
1475 * 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).
1476 * Continue will do the rest of the work to construct prompt templates, handle context items, prune context, etc.
1477 */
1478 models: (CustomLLM | JSONModelDescription)[];
1479 /** A system message to be followed by all of your models */
1480 systemMessage?: string;
1481 /** The default completion options for all models */
1482 completionOptions?: BaseCompletionOptions;
1483 /** Request options that will be applied to all models and context providers */
1484 requestOptions?: RequestOptions;
1485 /** The list of slash commands that will be available in the sidebar */
1486 slashCommands?: (SlashCommand | SlashCommandWithSource)[];
1487 /** Each entry in this array will originally be a ContextProviderWithParams, the same object from your config.json, but you may add CustomContextProviders.
1488 * A CustomContextProvider requires you only to define a title and getContextItems function. When you type '@title <query>', Continue will call `getContextItems(query)`.
1489 */
1490 contextProviders?: (CustomContextProvider | ContextProviderWithParams)[];
1491 /** If set to true, Continue will not index your codebase for retrieval */
1492 disableIndexing?: boolean;
1493 /** If set to true, Continue will not make extra requests to the LLM to generate a summary title of each session. */
1494 disableSessionTitles?: boolean;
1495 /** An optional token to identify a user. Not used by Continue unless you write custom coniguration that requires such a token */
1496 userToken?: string;
1497 /** The provider used to calculate embeddings. If left empty, Continue will use transformers.js to calculate the embeddings with all-MiniLM-L6-v2 */
1498 embeddingsProvider?: EmbeddingsProviderDescription | ILLM;
1499 /** The model that Continue will use for tab autocompletions. */
1500 tabAutocompleteModel?:
1501 | CustomLLM
1502 | JSONModelDescription
1503 | (CustomLLM | JSONModelDescription)[];
1504 /** Options for tab autocomplete */
1505 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1506 /** UI styles customization */
1507 ui?: ContinueUIConfig;
1508 /** Options for the reranker */
1509 reranker?: RerankerDescription | ILLM;
1510 /** Experimental configuration */
1511 experimental?: ExperimentalConfig;
1512 /** Analytics configuration */
1513 analytics?: AnalyticsConfig;
1514 data?: DataDestination[];
1515}
1516
1517// in the actual Continue source code
1518export interface ContinueConfig {
1519 allowAnonymousTelemetry?: boolean;
1520 // systemMessage?: string;
1521 completionOptions?: BaseCompletionOptions;
1522 requestOptions?: RequestOptions;
1523 slashCommands: SlashCommandWithSource[];
1524 contextProviders: IContextProvider[];
1525 disableSessionTitles?: boolean;
1526 disableIndexing?: boolean;
1527 userToken?: string;
1528 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1529 ui?: ContinueUIConfig;
1530 experimental?: ExperimentalConfig;
1531 analytics?: AnalyticsConfig;
1532 docs?: SiteIndexingConfig[];
1533 tools: Tool[];
1534 mcpServerStatuses: MCPServerStatus[];
1535 rules: RuleWithSource[];
1536 modelsByRole: Record<ModelRole, ILLM[]>;
1537 selectedModelByRole: Record<ModelRole, ILLM | null>;
1538 data?: DataDestination[];
1539}
1540
1541export interface BrowserSerializedContinueConfig {
1542 allowAnonymousTelemetry?: boolean;
1543 // systemMessage?: string;
1544 completionOptions?: BaseCompletionOptions;
1545 requestOptions?: RequestOptions;
1546 slashCommands: SlashCommandDescWithSource[];
1547 contextProviders: ContextProviderDescription[];
1548 disableIndexing?: boolean;
1549 disableSessionTitles?: boolean;
1550 userToken?: string;
1551 ui?: ContinueUIConfig;
1552 experimental?: ExperimentalConfig;
1553 analytics?: AnalyticsConfig;
1554 docs?: SiteIndexingConfig[];
1555 tools: Tool[];
1556 mcpServerStatuses: MCPServerStatus[];
1557 rules: RuleWithSource[];
1558 usePlatform: boolean;
1559 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1560 modelsByRole: Record<ModelRole, ModelDescription[]>;
1561 selectedModelByRole: Record<ModelRole, ModelDescription | null>;
1562}
1563
1564// DOCS SUGGESTIONS AND PACKAGE INFO
1565export interface FilePathAndName {
1566 path: string;
1567 name: string;
1568}
1569
1570export interface PackageFilePathAndName extends FilePathAndName {
1571 packageRegistry: string; // e.g. npm, pypi
1572}
1573
1574export type ParsedPackageInfo = {
1575 name: string;
1576 packageFile: PackageFilePathAndName;
1577 language: string;
1578 version: string;
1579};
1580
1581export type PackageDetails = {
1582 docsLink?: string;
1583 docsLinkWarning?: string;
1584 title?: string;
1585 description?: string;
1586 repo?: string;
1587 license?: string;
1588};
1589
1590export type PackageDetailsSuccess = PackageDetails & {
1591 docsLink: string;
1592};
1593
1594export type PackageDocsResult = {
1595 packageInfo: ParsedPackageInfo;
1596} & (
1597 | { error: string; details?: never }
1598 | { details: PackageDetailsSuccess; error?: never }
1599);
1600
1601export interface TerminalOptions {
1602 reuseTerminal?: boolean;
1603 terminalName?: string;
1604 waitForCompletion?: boolean;
1605}
1606
1607export type RuleSource =
1608 | "default-chat"
1609 | "default-agent"
1610 | "model-chat-options"
1611 | "model-agent-options"
1612 | "rules-block"
1613 | "json-systemMessage"
1614 | ".continuerules";
1615
1616export interface RuleWithSource {
1617 name?: string;
1618 slug?: string;
1619 source: RuleSource;
1620 globs?: string | string[];
1621 regex?: string | string[];
1622 rule: string;
1623 description?: string;
1624 ruleFile?: string;
1625 alwaysApply?: boolean;
1626}
1627export interface CompleteOnboardingPayload {
1628 mode: OnboardingModes;
1629 provider?: string;
1630 apiKey?: string;
1631}