Elffuss BraidHub

kikocis/continue public

e841ee848161 · 37.0 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 enableExperimentalTools: boolean;
1013}
1014
1015export type GetTool = (params: ConfigDependentToolParams) => Tool;
1016
1017export interface BaseCompletionOptions {
1018 temperature?: number;
1019 topP?: number;
1020 topK?: number;
1021 minP?: number;
1022 presencePenalty?: number;
1023 frequencyPenalty?: number;
1024 mirostat?: number;
1025 stop?: string[];
1026 maxTokens?: number;
1027 numThreads?: number;
1028 useMmap?: boolean;
1029 keepAlive?: number;
1030 numGpu?: number;
1031 raw?: boolean;
1032 stream?: boolean;
1033 prediction?: Prediction;
1034 tools?: Tool[];
1035 toolChoice?: ToolChoice;
1036 reasoning?: boolean;
1037 reasoningBudgetTokens?: number;
1038 promptCaching?: boolean;
1039}
1040
1041export interface ModelCapability {
1042 uploadImage?: boolean;
1043 tools?: boolean;
1044}
1045
1046export interface ModelDescription {
1047 title: string;
1048 provider: string;
1049 underlyingProviderName: string;
1050 model: string;
1051 apiKey?: string;
1052
1053 apiBase?: string;
1054 apiKeyLocation?: string;
1055 orgScopeId?: string | null;
1056
1057 onPremProxyUrl?: string | null;
1058
1059 contextLength?: number;
1060 maxStopWords?: number;
1061 template?: TemplateType;
1062 completionOptions?: BaseCompletionOptions;
1063 baseAgentSystemMessage?: string;
1064 baseChatSystemMessage?: string;
1065 requestOptions?: RequestOptions;
1066 promptTemplates?: { [key: string]: string };
1067 cacheBehavior?: CacheBehavior;
1068 capabilities?: ModelCapability;
1069 roles?: ModelRole[];
1070 configurationStatus?: LLMConfigurationStatuses;
1071}
1072
1073export interface JSONEmbedOptions {
1074 apiBase?: string;
1075 apiKey?: string;
1076 model?: string;
1077 deployment?: string;
1078 apiType?: string;
1079 apiVersion?: string;
1080 requestOptions?: RequestOptions;
1081 maxEmbeddingChunkSize?: number;
1082 maxEmbeddingBatchSize?: number;
1083
1084 // AWS options
1085 profile?: string;
1086
1087 // AWS and VertexAI Options
1088 region?: string;
1089
1090 // VertexAI and Watsonx Options
1091 projectId?: string;
1092}
1093
1094export interface EmbeddingsProviderDescription extends JSONEmbedOptions {
1095 provider: string;
1096}
1097
1098export interface RerankerDescription {
1099 name: string;
1100 params?: { [key: string]: any };
1101}
1102
1103// TODO: We should consider renaming this to AutocompleteOptions.
1104export interface TabAutocompleteOptions {
1105 disable: boolean;
1106 maxPromptTokens: number;
1107 debounceDelay: number;
1108 modelTimeout: number;
1109 maxSuffixPercentage: number;
1110 prefixPercentage: number;
1111 transform?: boolean;
1112 template?: string;
1113 multilineCompletions: "always" | "never" | "auto";
1114 slidingWindowPrefixPercentage: number;
1115 slidingWindowSize: number;
1116 useCache: boolean;
1117 onlyMyCode: boolean;
1118 useRecentlyEdited: boolean;
1119 useRecentlyOpened: boolean;
1120 disableInFiles?: string[];
1121 useImports?: boolean;
1122 showWhateverWeHaveAtXMs?: number;
1123 // true = enabled, false = disabled, number = enabled with priority
1124 experimental_includeClipboard: boolean | number;
1125 experimental_includeRecentlyVisitedRanges: boolean | number;
1126 experimental_includeRecentlyEditedRanges: boolean | number;
1127 experimental_includeDiff: boolean | number;
1128}
1129
1130export interface StdioOptions {
1131 type: "stdio";
1132 command: string;
1133 args: string[];
1134 env?: Record<string, string>;
1135 requestOptions?: RequestOptions;
1136}
1137
1138export interface WebSocketOptions {
1139 type: "websocket";
1140 url: string;
1141 requestOptions?: RequestOptions;
1142}
1143
1144export interface SSEOptions {
1145 type: "sse";
1146 url: string;
1147 requestOptions?: RequestOptions;
1148}
1149
1150export interface StreamableHTTPOptions {
1151 type: "streamable-http";
1152 url: string;
1153 requestOptions?: RequestOptions;
1154}
1155
1156export type TransportOptions =
1157 | StdioOptions
1158 | WebSocketOptions
1159 | SSEOptions
1160 | StreamableHTTPOptions;
1161
1162export interface MCPOptions {
1163 name: string;
1164 id: string;
1165 transport: TransportOptions;
1166 faviconUrl?: string;
1167 timeout?: number;
1168}
1169
1170export type MCPConnectionStatus =
1171 | "connecting"
1172 | "connected"
1173 | "error"
1174 | "not-connected";
1175
1176export interface MCPPrompt {
1177 name: string;
1178 description?: string;
1179 arguments?: {
1180 name: string;
1181 description?: string;
1182 required?: boolean;
1183 }[];
1184}
1185
1186// Leaving here to ideate on
1187// export type ContinueConfigSource = "local-yaml" | "local-json" | "hub-assistant" | "hub"
1188
1189// https://modelcontextprotocol.io/docs/concepts/resources#direct-resources
1190export interface MCPResource {
1191 name: string;
1192 uri: string;
1193 description?: string;
1194 mimeType?: string;
1195}
1196
1197// https://modelcontextprotocol.io/docs/concepts/resources#resource-templates
1198export interface MCPResourceTemplate {
1199 uriTemplate: string;
1200 name: string;
1201 description?: string;
1202 mimeType?: string;
1203}
1204
1205export interface MCPTool {
1206 name: string;
1207 description?: string;
1208 inputSchema: {
1209 type: "object";
1210 properties?: Record<string, any>;
1211 };
1212}
1213
1214export interface MCPServerStatus extends MCPOptions {
1215 status: MCPConnectionStatus;
1216 errors: string[];
1217
1218 prompts: MCPPrompt[];
1219 tools: MCPTool[];
1220 resources: MCPResource[];
1221 resourceTemplates: MCPResourceTemplate[];
1222}
1223
1224export interface ContinueUIConfig {
1225 codeBlockToolbarPosition?: "top" | "bottom";
1226 fontSize?: number;
1227 displayRawMarkdown?: boolean;
1228 showChatScrollbar?: boolean;
1229 codeWrap?: boolean;
1230 showSessionTabs?: boolean;
1231 autoAcceptEditToolDiffs?: boolean;
1232}
1233
1234export interface ContextMenuConfig {
1235 comment?: string;
1236 docstring?: string;
1237 fix?: string;
1238 optimize?: string;
1239 fixGrammar?: string;
1240}
1241
1242export interface ExperimentalModelRoles {
1243 repoMapFileSelection?: string;
1244 inlineEdit?: string;
1245 applyCodeBlock?: string;
1246}
1247
1248export interface ExperimentalMCPOptions {
1249 transport: TransportOptions;
1250 faviconUrl?: string;
1251 timeout?: number;
1252}
1253
1254export type ApplyStateStatus =
1255 | "not-started" // Apply state created but not necessarily streaming
1256 | "streaming" // Changes are being applied to the file
1257 | "done" // All changes have been applied, awaiting user to accept/reject
1258 | "closed"; // All changes have been applied. Note that for new files, we immediately set the status to "closed"
1259
1260export interface ApplyState {
1261 streamId: string;
1262 status?: ApplyStateStatus;
1263 numDiffs?: number;
1264 filepath?: string;
1265 fileContent?: string;
1266 toolCallId?: string;
1267}
1268
1269export interface StreamDiffLinesPayload {
1270 prefix: string;
1271 highlighted: string;
1272 suffix: string;
1273 input: string;
1274 language: string | undefined;
1275 modelTitle: string | undefined;
1276 includeRulesInSystemMessage: boolean;
1277 fileUri?: string;
1278}
1279
1280export interface HighlightedCodePayload {
1281 rangeInFileWithContents: RangeInFileWithContents;
1282 prompt?: string;
1283 shouldRun?: boolean;
1284}
1285
1286export interface AcceptOrRejectDiffPayload {
1287 filepath?: string;
1288 streamId?: string;
1289}
1290
1291export interface ShowFilePayload {
1292 filepath: string;
1293}
1294
1295export interface ApplyToFilePayload {
1296 streamId: string;
1297 filepath?: string;
1298 text: string;
1299 toolCallId?: string;
1300 isSearchAndReplace?: boolean;
1301}
1302
1303export interface RangeInFileWithContents {
1304 filepath: string;
1305 range: {
1306 start: { line: number; character: number };
1307 end: { line: number; character: number };
1308 };
1309 contents: string;
1310}
1311
1312export type SetCodeToEditPayload = RangeInFileWithContents | FileWithContents;
1313
1314/**
1315 * Represents the configuration for a quick action in the Code Lens.
1316 * Quick actions are custom commands that can be added to function and class declarations.
1317 */
1318export interface QuickActionConfig {
1319 /**
1320 * The title of the quick action that will display in the Code Lens.
1321 */
1322 title: string;
1323
1324 /**
1325 * The prompt that will be sent to the model when the quick action is invoked,
1326 * with the function or class body concatenated.
1327 */
1328 prompt: string;
1329
1330 /**
1331 * If `true`, the result of the quick action will be sent to the chat panel.
1332 * If `false`, the streamed result will be inserted into the document.
1333 *
1334 * Defaults to `false`.
1335 */
1336 sendToChat: boolean;
1337}
1338
1339export type DefaultContextProvider = ContextProviderWithParams & {
1340 query?: string;
1341};
1342
1343export interface ExperimentalConfig {
1344 contextMenuPrompts?: ContextMenuConfig;
1345 modelRoles?: ExperimentalModelRoles;
1346 defaultContext?: DefaultContextProvider[];
1347 promptPath?: string;
1348 enableExperimentalTools?: boolean;
1349
1350 /**
1351 * Quick actions are a way to add custom commands to the Code Lens of
1352 * function and class declarations.
1353 */
1354 quickActions?: QuickActionConfig[];
1355
1356 /**
1357 * Automatically read LLM chat responses aloud using system TTS models
1358 */
1359 readResponseTTS?: boolean;
1360
1361 /**
1362 * If set to true, we will attempt to pull down and install an instance of Chromium
1363 * that is compatible with the current version of Puppeteer.
1364 * This is needed to crawl a large number of documentation sites that are dynamically rendered.
1365 */
1366 useChromiumForDocsCrawling?: boolean;
1367 modelContextProtocolServers?: ExperimentalMCPOptions[];
1368
1369 /**
1370 * If enabled, will add the current file as context.
1371 */
1372 useCurrentFileAsContext?: boolean;
1373}
1374
1375export interface AnalyticsConfig {
1376 provider: string;
1377 url?: string;
1378 clientKey?: string;
1379}
1380
1381export interface JSONModelDescription {
1382 title: string;
1383 provider: string;
1384 underlyingProviderName: string;
1385 model: string;
1386 apiKey?: string;
1387 apiBase?: string;
1388
1389 contextLength?: number;
1390 maxStopWords?: number;
1391 template?: TemplateType;
1392 completionOptions?: BaseCompletionOptions;
1393 systemMessage?: string;
1394 requestOptions?: RequestOptions;
1395 cacheBehavior?: CacheBehavior;
1396
1397 region?: string;
1398 profile?: string;
1399 modelArn?: string;
1400 apiType?: "openai" | "azure";
1401 apiVersion?: string;
1402 deployment?: string;
1403 projectId?: string;
1404 accountId?: string;
1405 aiGatewaySlug?: string;
1406 useLegacyCompletionsEndpoint?: boolean;
1407 deploymentId?: string;
1408}
1409
1410// config.json
1411export interface SerializedContinueConfig {
1412 env?: string[];
1413 allowAnonymousTelemetry?: boolean;
1414 models: JSONModelDescription[];
1415 systemMessage?: string;
1416 completionOptions?: BaseCompletionOptions;
1417 requestOptions?: RequestOptions;
1418 slashCommands?: SlashCommandDescription[];
1419 customCommands?: CustomCommand[];
1420 contextProviders?: ContextProviderWithParams[];
1421 disableIndexing?: boolean;
1422 disableSessionTitles?: boolean;
1423 userToken?: string;
1424 embeddingsProvider?: EmbeddingsProviderDescription;
1425 tabAutocompleteModel?: JSONModelDescription | JSONModelDescription[];
1426 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1427 ui?: ContinueUIConfig;
1428 reranker?: RerankerDescription;
1429 experimental?: ExperimentalConfig;
1430 analytics?: AnalyticsConfig;
1431 docs?: SiteIndexingConfig[];
1432 data?: DataDestination[];
1433}
1434
1435export type ConfigMergeType = "merge" | "overwrite";
1436
1437export type ContinueRcJson = Partial<SerializedContinueConfig> & {
1438 mergeBehavior: ConfigMergeType;
1439};
1440
1441// config.ts - give users simplified interfaces
1442export interface Config {
1443 /** 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 */
1444 allowAnonymousTelemetry?: boolean;
1445 /** Each entry in this array will originally be a JSONModelDescription, the same object from your config.json, but you may add CustomLLMs.
1446 * 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).
1447 * Continue will do the rest of the work to construct prompt templates, handle context items, prune context, etc.
1448 */
1449 models: (CustomLLM | JSONModelDescription)[];
1450 /** A system message to be followed by all of your models */
1451 systemMessage?: string;
1452 /** The default completion options for all models */
1453 completionOptions?: BaseCompletionOptions;
1454 /** Request options that will be applied to all models and context providers */
1455 requestOptions?: RequestOptions;
1456 /** The list of slash commands that will be available in the sidebar */
1457 slashCommands?: SlashCommand[];
1458 /** Each entry in this array will originally be a ContextProviderWithParams, the same object from your config.json, but you may add CustomContextProviders.
1459 * A CustomContextProvider requires you only to define a title and getContextItems function. When you type '@title <query>', Continue will call `getContextItems(query)`.
1460 */
1461 contextProviders?: (CustomContextProvider | ContextProviderWithParams)[];
1462 /** If set to true, Continue will not index your codebase for retrieval */
1463 disableIndexing?: boolean;
1464 /** If set to true, Continue will not make extra requests to the LLM to generate a summary title of each session. */
1465 disableSessionTitles?: boolean;
1466 /** An optional token to identify a user. Not used by Continue unless you write custom coniguration that requires such a token */
1467 userToken?: string;
1468 /** The provider used to calculate embeddings. If left empty, Continue will use transformers.js to calculate the embeddings with all-MiniLM-L6-v2 */
1469 embeddingsProvider?: EmbeddingsProviderDescription | ILLM;
1470 /** The model that Continue will use for tab autocompletions. */
1471 tabAutocompleteModel?:
1472 | CustomLLM
1473 | JSONModelDescription
1474 | (CustomLLM | JSONModelDescription)[];
1475 /** Options for tab autocomplete */
1476 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1477 /** UI styles customization */
1478 ui?: ContinueUIConfig;
1479 /** Options for the reranker */
1480 reranker?: RerankerDescription | ILLM;
1481 /** Experimental configuration */
1482 experimental?: ExperimentalConfig;
1483 /** Analytics configuration */
1484 analytics?: AnalyticsConfig;
1485 data?: DataDestination[];
1486}
1487
1488// in the actual Continue source code
1489export interface ContinueConfig {
1490 allowAnonymousTelemetry?: boolean;
1491 // systemMessage?: string;
1492 completionOptions?: BaseCompletionOptions;
1493 requestOptions?: RequestOptions;
1494 slashCommands: SlashCommand[];
1495 contextProviders: IContextProvider[];
1496 disableSessionTitles?: boolean;
1497 disableIndexing?: boolean;
1498 userToken?: string;
1499 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1500 ui?: ContinueUIConfig;
1501 experimental?: ExperimentalConfig;
1502 analytics?: AnalyticsConfig;
1503 docs?: SiteIndexingConfig[];
1504 tools: Tool[];
1505 mcpServerStatuses: MCPServerStatus[];
1506 rules: RuleWithSource[];
1507 modelsByRole: Record<ModelRole, ILLM[]>;
1508 selectedModelByRole: Record<ModelRole, ILLM | null>;
1509 data?: DataDestination[];
1510}
1511
1512export interface BrowserSerializedContinueConfig {
1513 allowAnonymousTelemetry?: boolean;
1514 // systemMessage?: string;
1515 completionOptions?: BaseCompletionOptions;
1516 requestOptions?: RequestOptions;
1517 slashCommands: SlashCommandDescription[];
1518 contextProviders: ContextProviderDescription[];
1519 disableIndexing?: boolean;
1520 disableSessionTitles?: boolean;
1521 userToken?: string;
1522 ui?: ContinueUIConfig;
1523 experimental?: ExperimentalConfig;
1524 analytics?: AnalyticsConfig;
1525 docs?: SiteIndexingConfig[];
1526 tools: Tool[];
1527 mcpServerStatuses: MCPServerStatus[];
1528 rules: RuleWithSource[];
1529 usePlatform: boolean;
1530 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1531 modelsByRole: Record<ModelRole, ModelDescription[]>;
1532 selectedModelByRole: Record<ModelRole, ModelDescription | null>;
1533}
1534
1535// DOCS SUGGESTIONS AND PACKAGE INFO
1536export interface FilePathAndName {
1537 path: string;
1538 name: string;
1539}
1540
1541export interface PackageFilePathAndName extends FilePathAndName {
1542 packageRegistry: string; // e.g. npm, pypi
1543}
1544
1545export type ParsedPackageInfo = {
1546 name: string;
1547 packageFile: PackageFilePathAndName;
1548 language: string;
1549 version: string;
1550};
1551
1552export type PackageDetails = {
1553 docsLink?: string;
1554 docsLinkWarning?: string;
1555 title?: string;
1556 description?: string;
1557 repo?: string;
1558 license?: string;
1559};
1560
1561export type PackageDetailsSuccess = PackageDetails & {
1562 docsLink: string;
1563};
1564
1565export type PackageDocsResult = {
1566 packageInfo: ParsedPackageInfo;
1567} & (
1568 | { error: string; details?: never }
1569 | { details: PackageDetailsSuccess; error?: never }
1570);
1571
1572export interface TerminalOptions {
1573 reuseTerminal?: boolean;
1574 terminalName?: string;
1575 waitForCompletion?: boolean;
1576}
1577
1578export type RuleSource =
1579 | "default-chat"
1580 | "default-agent"
1581 | "model-chat-options"
1582 | "model-agent-options"
1583 | "rules-block"
1584 | "json-systemMessage"
1585 | ".continuerules";
1586
1587export interface RuleWithSource {
1588 name?: string;
1589 slug?: string;
1590 source: RuleSource;
1591 globs?: string | string[];
1592 regex?: string | string[];
1593 rule: string;
1594 description?: string;
1595 ruleFile?: string;
1596 alwaysApply?: boolean;
1597}
1598export interface CompleteOnboardingPayload {
1599 mode: OnboardingModes;
1600 provider?: string;
1601 apiKey?: string;
1602}