Elffuss BraidHub

kikocis/continue public

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