Elffuss BraidHub

kikocis/continue public

d691089ac9f7 · 36.6 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 getUniqueId(): Promise<string>;
735
736 getTerminalContents(): Promise<string>;
737
738 getDebugLocals(threadIndex: number): Promise<string>;
739
740 getTopLevelCallStackSources(
741 threadIndex: number,
742 stackDepth: number,
743 ): Promise<string[]>;
744
745 getAvailableThreads(): Promise<Thread[]>;
746
747 getWorkspaceDirs(): Promise<string[]>;
748
749 getWorkspaceConfigs(): Promise<ContinueRcJson[]>;
750
751 fileExists(fileUri: string): Promise<boolean>;
752
753 writeFile(path: string, contents: string): Promise<void>;
754
755 showVirtualFile(title: string, contents: string): Promise<void>;
756
757 openFile(path: string): Promise<void>;
758
759 openUrl(url: string): Promise<void>;
760
761 runCommand(command: string, options?: TerminalOptions): Promise<void>;
762
763 saveFile(fileUri: string): Promise<void>;
764
765 readFile(fileUri: string): Promise<string>;
766
767 readRangeInFile(fileUri: string, range: Range): Promise<string>;
768
769 showLines(fileUri: string, startLine: number, endLine: number): Promise<void>;
770
771 getOpenFiles(): Promise<string[]>;
772
773 getCurrentFile(): Promise<
774 | undefined
775 | {
776 isUntitled: boolean;
777 path: string;
778 contents: string;
779 }
780 >;
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 // Secret Storage
811 readSecrets(keys: string[]): Promise<Record<string, string>>;
812
813 writeSecrets(secrets: { [key: string]: string }): Promise<void>;
814
815 // LSP
816 gotoDefinition(location: Location): Promise<RangeInFile[]>;
817
818 // Callbacks
819 onDidChangeActiveTextEditor(callback: (fileUri: string) => void): void;
820}
821
822// Slash Commands
823
824export interface ContinueSDK {
825 ide: IDE;
826 llm: ILLM;
827 addContextItem: (item: ContextItemWithId) => void;
828 history: ChatMessage[];
829 input: string;
830 params?: { [key: string]: any } | undefined;
831 contextItems: ContextItemWithId[];
832 selectedCode: RangeInFile[];
833 config: ContinueConfig;
834 fetch: FetchFunction;
835 completionOptions?: LLMFullCompletionOptions;
836}
837
838export interface SlashCommand {
839 name: string;
840 description: string;
841 prompt?: string;
842 params?: { [key: string]: any };
843 promptFile?: string;
844 run: (sdk: ContinueSDK) => AsyncGenerator<string | undefined>;
845}
846
847// Config
848
849export type StepName =
850 | "AnswerQuestionChroma"
851 | "GenerateShellCommandStep"
852 | "EditHighlightedCodeStep"
853 | "ShareSessionStep"
854 | "CommentCodeStep"
855 | "ClearHistoryStep"
856 | "StackOverflowStep"
857 | "OpenConfigStep"
858 | "GenerateShellCommandStep"
859 | "DraftIssueStep";
860
861export type ContextProviderName =
862 | "diff"
863 | "terminal"
864 | "debugger"
865 | "open"
866 | "google"
867 | "search"
868 | "tree"
869 | "http"
870 | "codebase"
871 | "problems"
872 | "folder"
873 | "jira"
874 | "postgres"
875 | "database"
876 | "code"
877 | "docs"
878 | "gitlab-mr"
879 | "os"
880 | "currentFile"
881 | "greptile"
882 | "outline"
883 | "continue-proxy"
884 | "highlights"
885 | "file"
886 | "issue"
887 | "repo-map"
888 | "url"
889 | "commit"
890 | "web"
891 | "discord"
892 | "clipboard"
893 | string;
894
895export type TemplateType =
896 | "llama2"
897 | "alpaca"
898 | "zephyr"
899 | "phi2"
900 | "phind"
901 | "anthropic"
902 | "chatml"
903 | "none"
904 | "openchat"
905 | "deepseek"
906 | "xwin-coder"
907 | "neural-chat"
908 | "codellama-70b"
909 | "llava"
910 | "gemma"
911 | "granite"
912 | "llama3"
913 | "codestral";
914
915export interface RequestOptions {
916 timeout?: number;
917 verifySsl?: boolean;
918 caBundlePath?: string | string[];
919 proxy?: string;
920 headers?: { [key: string]: string };
921 extraBodyProperties?: { [key: string]: any };
922 noProxy?: string[];
923 clientCertificate?: ClientCertificateOptions;
924}
925
926export interface CacheBehavior {
927 cacheSystemMessage?: boolean;
928 cacheConversation?: boolean;
929}
930
931export interface ClientCertificateOptions {
932 cert: string;
933 key: string;
934 passphrase?: string;
935}
936
937export interface StepWithParams {
938 name: StepName;
939 params: { [key: string]: any };
940}
941
942export interface ContextProviderWithParams {
943 name: ContextProviderName;
944 params: { [key: string]: any };
945}
946
947export type SlashCommandDescription = Omit<SlashCommand, "run">;
948
949export interface CustomCommand {
950 name: string;
951 prompt: string;
952 description?: string;
953}
954
955export interface Prediction {
956 type: "content";
957 content:
958 | string
959 | {
960 type: "text";
961 text: string;
962 }[];
963}
964
965export interface ToolExtras {
966 ide: IDE;
967 llm: ILLM;
968 fetch: FetchFunction;
969 tool: Tool;
970 toolCallId?: string;
971 onPartialOutput?: (params: {
972 toolCallId: string;
973 contextItems: ContextItem[];
974 }) => void;
975 config: ContinueConfig;
976 codeBaseIndexer?: CodebaseIndexer;
977}
978
979export interface Tool {
980 type: "function";
981 function: {
982 name: string;
983 description?: string;
984 parameters?: Record<string, any>;
985 strict?: boolean | null;
986 };
987
988 displayTitle: string;
989 wouldLikeTo?: string;
990 isCurrently?: string;
991 hasAlready?: string;
992 readonly: boolean;
993 isInstant?: boolean;
994 uri?: string;
995 faviconUrl?: string;
996 group: string;
997 originalFunctionName?: string;
998}
999
1000interface ToolChoice {
1001 type: "function";
1002 function: {
1003 name: string;
1004 };
1005}
1006
1007export interface ConfigDependentToolParams {
1008 rules: RuleWithSource[];
1009}
1010
1011export type GetTool = (params: ConfigDependentToolParams) => Tool;
1012
1013export interface BaseCompletionOptions {
1014 temperature?: number;
1015 topP?: number;
1016 topK?: number;
1017 minP?: number;
1018 presencePenalty?: number;
1019 frequencyPenalty?: number;
1020 mirostat?: number;
1021 stop?: string[];
1022 maxTokens?: number;
1023 numThreads?: number;
1024 useMmap?: boolean;
1025 keepAlive?: number;
1026 numGpu?: number;
1027 raw?: boolean;
1028 stream?: boolean;
1029 prediction?: Prediction;
1030 tools?: Tool[];
1031 toolChoice?: ToolChoice;
1032 reasoning?: boolean;
1033 reasoningBudgetTokens?: number;
1034 promptCaching?: boolean;
1035}
1036
1037export interface ModelCapability {
1038 uploadImage?: boolean;
1039 tools?: boolean;
1040}
1041
1042export interface ModelDescription {
1043 title: string;
1044 provider: string;
1045 underlyingProviderName: string;
1046 model: string;
1047 apiKey?: string;
1048
1049 apiBase?: string;
1050 apiKeyLocation?: string;
1051 orgScopeId?: string | null;
1052
1053 onPremProxyUrl?: string | null;
1054
1055 contextLength?: number;
1056 maxStopWords?: number;
1057 template?: TemplateType;
1058 completionOptions?: BaseCompletionOptions;
1059 baseAgentSystemMessage?: string;
1060 baseChatSystemMessage?: string;
1061 requestOptions?: RequestOptions;
1062 promptTemplates?: { [key: string]: string };
1063 cacheBehavior?: CacheBehavior;
1064 capabilities?: ModelCapability;
1065 roles?: ModelRole[];
1066 configurationStatus?: LLMConfigurationStatuses;
1067}
1068
1069export interface JSONEmbedOptions {
1070 apiBase?: string;
1071 apiKey?: string;
1072 model?: string;
1073 deployment?: string;
1074 apiType?: string;
1075 apiVersion?: string;
1076 requestOptions?: RequestOptions;
1077 maxEmbeddingChunkSize?: number;
1078 maxEmbeddingBatchSize?: number;
1079
1080 // AWS options
1081 profile?: string;
1082
1083 // AWS and VertexAI Options
1084 region?: string;
1085
1086 // VertexAI and Watsonx Options
1087 projectId?: string;
1088}
1089
1090export interface EmbeddingsProviderDescription extends JSONEmbedOptions {
1091 provider: string;
1092}
1093
1094export interface RerankerDescription {
1095 name: string;
1096 params?: { [key: string]: any };
1097}
1098
1099// TODO: We should consider renaming this to AutocompleteOptions.
1100export interface TabAutocompleteOptions {
1101 disable: boolean;
1102 maxPromptTokens: number;
1103 debounceDelay: number;
1104 modelTimeout: number;
1105 maxSuffixPercentage: number;
1106 prefixPercentage: number;
1107 transform?: boolean;
1108 template?: string;
1109 multilineCompletions: "always" | "never" | "auto";
1110 slidingWindowPrefixPercentage: number;
1111 slidingWindowSize: number;
1112 useCache: boolean;
1113 onlyMyCode: boolean;
1114 useRecentlyEdited: boolean;
1115 useRecentlyOpened: boolean;
1116 disableInFiles?: string[];
1117 useImports?: boolean;
1118 showWhateverWeHaveAtXMs?: number;
1119 // true = enabled, false = disabled, number = enabled with priority
1120 experimental_includeClipboard: boolean | number;
1121 experimental_includeRecentlyVisitedRanges: boolean | number;
1122 experimental_includeRecentlyEditedRanges: boolean | number;
1123 experimental_includeDiff: boolean | number;
1124}
1125
1126export interface StdioOptions {
1127 type: "stdio";
1128 command: string;
1129 args: string[];
1130 env?: Record<string, string>;
1131 requestOptions?: RequestOptions;
1132}
1133
1134export interface WebSocketOptions {
1135 type: "websocket";
1136 url: string;
1137 requestOptions?: RequestOptions;
1138}
1139
1140export interface SSEOptions {
1141 type: "sse";
1142 url: string;
1143 requestOptions?: RequestOptions;
1144}
1145
1146export interface StreamableHTTPOptions {
1147 type: "streamable-http";
1148 url: string;
1149 requestOptions?: RequestOptions;
1150}
1151
1152export type TransportOptions =
1153 | StdioOptions
1154 | WebSocketOptions
1155 | SSEOptions
1156 | StreamableHTTPOptions;
1157
1158export interface MCPOptions {
1159 name: string;
1160 id: string;
1161 transport: TransportOptions;
1162 faviconUrl?: string;
1163 timeout?: number;
1164}
1165
1166export type MCPConnectionStatus =
1167 | "connecting"
1168 | "connected"
1169 | "error"
1170 | "not-connected";
1171
1172export interface MCPPrompt {
1173 name: string;
1174 description?: string;
1175 arguments?: {
1176 name: string;
1177 description?: string;
1178 required?: boolean;
1179 }[];
1180}
1181
1182// Leaving here to ideate on
1183// export type ContinueConfigSource = "local-yaml" | "local-json" | "hub-assistant" | "hub"
1184
1185// https://modelcontextprotocol.io/docs/concepts/resources#direct-resources
1186export interface MCPResource {
1187 name: string;
1188 uri: string;
1189 description?: string;
1190 mimeType?: string;
1191}
1192
1193// https://modelcontextprotocol.io/docs/concepts/resources#resource-templates
1194export interface MCPResourceTemplate {
1195 uriTemplate: string;
1196 name: string;
1197 description?: string;
1198 mimeType?: string;
1199}
1200
1201export interface MCPTool {
1202 name: string;
1203 description?: string;
1204 inputSchema: {
1205 type: "object";
1206 properties?: Record<string, any>;
1207 };
1208}
1209
1210export interface MCPServerStatus extends MCPOptions {
1211 status: MCPConnectionStatus;
1212 errors: string[];
1213
1214 prompts: MCPPrompt[];
1215 tools: MCPTool[];
1216 resources: MCPResource[];
1217 resourceTemplates: MCPResourceTemplate[];
1218}
1219
1220export interface ContinueUIConfig {
1221 codeBlockToolbarPosition?: "top" | "bottom";
1222 fontSize?: number;
1223 displayRawMarkdown?: boolean;
1224 showChatScrollbar?: boolean;
1225 codeWrap?: boolean;
1226 showSessionTabs?: boolean;
1227 autoAcceptEditToolDiffs?: boolean;
1228}
1229
1230export interface ContextMenuConfig {
1231 comment?: string;
1232 docstring?: string;
1233 fix?: string;
1234 optimize?: string;
1235 fixGrammar?: string;
1236}
1237
1238export interface ExperimentalModelRoles {
1239 repoMapFileSelection?: string;
1240 inlineEdit?: string;
1241 applyCodeBlock?: string;
1242}
1243
1244export interface ExperimentalMCPOptions {
1245 transport: TransportOptions;
1246 faviconUrl?: string;
1247 timeout?: number;
1248}
1249
1250export type ApplyStateStatus =
1251 | "not-started" // Apply state created but not necessarily streaming
1252 | "streaming" // Changes are being applied to the file
1253 | "done" // All changes have been applied, awaiting user to accept/reject
1254 | "closed"; // All changes have been applied. Note that for new files, we immediately set the status to "closed"
1255
1256export interface ApplyState {
1257 streamId: string;
1258 status?: ApplyStateStatus;
1259 numDiffs?: number;
1260 filepath?: string;
1261 fileContent?: string;
1262 toolCallId?: string;
1263}
1264
1265export interface StreamDiffLinesPayload {
1266 prefix: string;
1267 highlighted: string;
1268 suffix: string;
1269 input: string;
1270 language: string | undefined;
1271 modelTitle: string | undefined;
1272 includeRulesInSystemMessage: boolean;
1273 fileUri?: string;
1274}
1275
1276export interface HighlightedCodePayload {
1277 rangeInFileWithContents: RangeInFileWithContents;
1278 prompt?: string;
1279 shouldRun?: boolean;
1280}
1281
1282export interface AcceptOrRejectDiffPayload {
1283 filepath: string;
1284 streamId?: string;
1285}
1286
1287export interface ShowFilePayload {
1288 filepath: string;
1289}
1290
1291export interface RangeInFileWithContents {
1292 filepath: string;
1293 range: {
1294 start: { line: number; character: number };
1295 end: { line: number; character: number };
1296 };
1297 contents: string;
1298}
1299
1300export type SetCodeToEditPayload = RangeInFileWithContents | FileWithContents;
1301
1302/**
1303 * Represents the configuration for a quick action in the Code Lens.
1304 * Quick actions are custom commands that can be added to function and class declarations.
1305 */
1306export interface QuickActionConfig {
1307 /**
1308 * The title of the quick action that will display in the Code Lens.
1309 */
1310 title: string;
1311
1312 /**
1313 * The prompt that will be sent to the model when the quick action is invoked,
1314 * with the function or class body concatenated.
1315 */
1316 prompt: string;
1317
1318 /**
1319 * If `true`, the result of the quick action will be sent to the chat panel.
1320 * If `false`, the streamed result will be inserted into the document.
1321 *
1322 * Defaults to `false`.
1323 */
1324 sendToChat: boolean;
1325}
1326
1327export type DefaultContextProvider = ContextProviderWithParams & {
1328 query?: string;
1329};
1330
1331export interface ExperimentalConfig {
1332 contextMenuPrompts?: ContextMenuConfig;
1333 modelRoles?: ExperimentalModelRoles;
1334 defaultContext?: DefaultContextProvider[];
1335 promptPath?: string;
1336
1337 /**
1338 * Quick actions are a way to add custom commands to the Code Lens of
1339 * function and class declarations.
1340 */
1341 quickActions?: QuickActionConfig[];
1342
1343 /**
1344 * Automatically read LLM chat responses aloud using system TTS models
1345 */
1346 readResponseTTS?: boolean;
1347
1348 /**
1349 * If set to true, we will attempt to pull down and install an instance of Chromium
1350 * that is compatible with the current version of Puppeteer.
1351 * This is needed to crawl a large number of documentation sites that are dynamically rendered.
1352 */
1353 useChromiumForDocsCrawling?: boolean;
1354 modelContextProtocolServers?: ExperimentalMCPOptions[];
1355
1356 /**
1357 * If enabled, will add the current file as context.
1358 */
1359 useCurrentFileAsContext?: boolean;
1360}
1361
1362export interface AnalyticsConfig {
1363 provider: string;
1364 url?: string;
1365 clientKey?: string;
1366}
1367
1368export interface JSONModelDescription {
1369 title: string;
1370 provider: string;
1371 underlyingProviderName: string;
1372 model: string;
1373 apiKey?: string;
1374 apiBase?: string;
1375
1376 contextLength?: number;
1377 maxStopWords?: number;
1378 template?: TemplateType;
1379 completionOptions?: BaseCompletionOptions;
1380 systemMessage?: string;
1381 requestOptions?: RequestOptions;
1382 cacheBehavior?: CacheBehavior;
1383
1384 region?: string;
1385 profile?: string;
1386 modelArn?: string;
1387 apiType?: "openai" | "azure";
1388 apiVersion?: string;
1389 deployment?: string;
1390 projectId?: string;
1391 accountId?: string;
1392 aiGatewaySlug?: string;
1393 useLegacyCompletionsEndpoint?: boolean;
1394 deploymentId?: string;
1395}
1396
1397// config.json
1398export interface SerializedContinueConfig {
1399 env?: string[];
1400 allowAnonymousTelemetry?: boolean;
1401 models: JSONModelDescription[];
1402 systemMessage?: string;
1403 completionOptions?: BaseCompletionOptions;
1404 requestOptions?: RequestOptions;
1405 slashCommands?: SlashCommandDescription[];
1406 customCommands?: CustomCommand[];
1407 contextProviders?: ContextProviderWithParams[];
1408 disableIndexing?: boolean;
1409 disableSessionTitles?: boolean;
1410 userToken?: string;
1411 embeddingsProvider?: EmbeddingsProviderDescription;
1412 tabAutocompleteModel?: JSONModelDescription | JSONModelDescription[];
1413 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1414 ui?: ContinueUIConfig;
1415 reranker?: RerankerDescription;
1416 experimental?: ExperimentalConfig;
1417 analytics?: AnalyticsConfig;
1418 docs?: SiteIndexingConfig[];
1419 data?: DataDestination[];
1420}
1421
1422export type ConfigMergeType = "merge" | "overwrite";
1423
1424export type ContinueRcJson = Partial<SerializedContinueConfig> & {
1425 mergeBehavior: ConfigMergeType;
1426};
1427
1428// config.ts - give users simplified interfaces
1429export interface Config {
1430 /** 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 */
1431 allowAnonymousTelemetry?: boolean;
1432 /** Each entry in this array will originally be a JSONModelDescription, the same object from your config.json, but you may add CustomLLMs.
1433 * 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).
1434 * Continue will do the rest of the work to construct prompt templates, handle context items, prune context, etc.
1435 */
1436 models: (CustomLLM | JSONModelDescription)[];
1437 /** A system message to be followed by all of your models */
1438 systemMessage?: string;
1439 /** The default completion options for all models */
1440 completionOptions?: BaseCompletionOptions;
1441 /** Request options that will be applied to all models and context providers */
1442 requestOptions?: RequestOptions;
1443 /** The list of slash commands that will be available in the sidebar */
1444 slashCommands?: SlashCommand[];
1445 /** Each entry in this array will originally be a ContextProviderWithParams, the same object from your config.json, but you may add CustomContextProviders.
1446 * A CustomContextProvider requires you only to define a title and getContextItems function. When you type '@title <query>', Continue will call `getContextItems(query)`.
1447 */
1448 contextProviders?: (CustomContextProvider | ContextProviderWithParams)[];
1449 /** If set to true, Continue will not index your codebase for retrieval */
1450 disableIndexing?: boolean;
1451 /** If set to true, Continue will not make extra requests to the LLM to generate a summary title of each session. */
1452 disableSessionTitles?: boolean;
1453 /** An optional token to identify a user. Not used by Continue unless you write custom coniguration that requires such a token */
1454 userToken?: string;
1455 /** The provider used to calculate embeddings. If left empty, Continue will use transformers.js to calculate the embeddings with all-MiniLM-L6-v2 */
1456 embeddingsProvider?: EmbeddingsProviderDescription | ILLM;
1457 /** The model that Continue will use for tab autocompletions. */
1458 tabAutocompleteModel?:
1459 | CustomLLM
1460 | JSONModelDescription
1461 | (CustomLLM | JSONModelDescription)[];
1462 /** Options for tab autocomplete */
1463 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1464 /** UI styles customization */
1465 ui?: ContinueUIConfig;
1466 /** Options for the reranker */
1467 reranker?: RerankerDescription | ILLM;
1468 /** Experimental configuration */
1469 experimental?: ExperimentalConfig;
1470 /** Analytics configuration */
1471 analytics?: AnalyticsConfig;
1472 data?: DataDestination[];
1473}
1474
1475// in the actual Continue source code
1476export interface ContinueConfig {
1477 allowAnonymousTelemetry?: boolean;
1478 // systemMessage?: string;
1479 completionOptions?: BaseCompletionOptions;
1480 requestOptions?: RequestOptions;
1481 slashCommands: SlashCommand[];
1482 contextProviders: IContextProvider[];
1483 disableSessionTitles?: boolean;
1484 disableIndexing?: boolean;
1485 userToken?: string;
1486 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1487 ui?: ContinueUIConfig;
1488 experimental?: ExperimentalConfig;
1489 analytics?: AnalyticsConfig;
1490 docs?: SiteIndexingConfig[];
1491 tools: Tool[];
1492 mcpServerStatuses: MCPServerStatus[];
1493 rules: RuleWithSource[];
1494 modelsByRole: Record<ModelRole, ILLM[]>;
1495 selectedModelByRole: Record<ModelRole, ILLM | null>;
1496 data?: DataDestination[];
1497}
1498
1499export interface BrowserSerializedContinueConfig {
1500 allowAnonymousTelemetry?: boolean;
1501 // systemMessage?: string;
1502 completionOptions?: BaseCompletionOptions;
1503 requestOptions?: RequestOptions;
1504 slashCommands: SlashCommandDescription[];
1505 contextProviders: ContextProviderDescription[];
1506 disableIndexing?: boolean;
1507 disableSessionTitles?: boolean;
1508 userToken?: string;
1509 ui?: ContinueUIConfig;
1510 experimental?: ExperimentalConfig;
1511 analytics?: AnalyticsConfig;
1512 docs?: SiteIndexingConfig[];
1513 tools: Tool[];
1514 mcpServerStatuses: MCPServerStatus[];
1515 rules: RuleWithSource[];
1516 usePlatform: boolean;
1517 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1518 modelsByRole: Record<ModelRole, ModelDescription[]>;
1519 selectedModelByRole: Record<ModelRole, ModelDescription | null>;
1520}
1521
1522// DOCS SUGGESTIONS AND PACKAGE INFO
1523export interface FilePathAndName {
1524 path: string;
1525 name: string;
1526}
1527
1528export interface PackageFilePathAndName extends FilePathAndName {
1529 packageRegistry: string; // e.g. npm, pypi
1530}
1531
1532export type ParsedPackageInfo = {
1533 name: string;
1534 packageFile: PackageFilePathAndName;
1535 language: string;
1536 version: string;
1537};
1538
1539export type PackageDetails = {
1540 docsLink?: string;
1541 docsLinkWarning?: string;
1542 title?: string;
1543 description?: string;
1544 repo?: string;
1545 license?: string;
1546};
1547
1548export type PackageDetailsSuccess = PackageDetails & {
1549 docsLink: string;
1550};
1551
1552export type PackageDocsResult = {
1553 packageInfo: ParsedPackageInfo;
1554} & (
1555 | { error: string; details?: never }
1556 | { details: PackageDetailsSuccess; error?: never }
1557);
1558
1559export interface TerminalOptions {
1560 reuseTerminal?: boolean;
1561 terminalName?: string;
1562 waitForCompletion?: boolean;
1563}
1564
1565export type RuleSource =
1566 | "default-chat"
1567 | "default-agent"
1568 | "model-chat-options"
1569 | "model-agent-options"
1570 | "rules-block"
1571 | "json-systemMessage"
1572 | ".continuerules";
1573
1574export interface RuleWithSource {
1575 name?: string;
1576 slug?: string;
1577 source: RuleSource;
1578 globs?: string | string[];
1579 rule: string;
1580 description?: string;
1581 ruleFile?: string;
1582 alwaysApply?: boolean;
1583}
1584
1585export interface CompleteOnboardingPayload {
1586 mode: OnboardingModes;
1587 provider?: string;
1588 apiKey?: string;
1589}