Elffuss BraidHub

kikocis/continue public

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