Elffuss BraidHub

kikocis/continue public

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