Elffuss BraidHub

kikocis/continue public

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