Elffuss BraidHub

kikocis/continue public

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