Elffuss BraidHub

kikocis/continue public

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