Elffuss BraidHub

kikocis/continue public

920ebdc17685 · 39.5 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" // Tool call arguments are being streamed from the LLM
436 | "generated" // Tool call is complete and ready for execution (awaiting approval)
437 | "calling" // Tool is actively being executed
438 | "errored" // Tool execution failed with an error
439 | "done" // Tool execution completed successfully
440 | "canceled"; // Tool call was canceled by user or system
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 toolCallStates?: 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 DiffType = "new" | "old" | "same";
670
671export interface DiffObject {
672 type: DiffType;
673}
674
675export interface DiffLine extends DiffObject {
676 line: string;
677}
678
679interface DiffChar extends DiffObject {
680 char: string;
681 oldIndex?: number; // Character index assuming a flattened line string.
682 newIndex?: number;
683 oldCharIndexInLine?: number; // Character index assuming new lines reset the character index to 0.
684 newCharIndexInLine?: number;
685 oldLineIndex?: number;
686 newLineIndex?: number;
687}
688
689export interface Problem {
690 filepath: string;
691 range: Range;
692 message: string;
693}
694
695export interface Thread {
696 name: string;
697 id: number;
698}
699
700export type IdeType = "vscode" | "jetbrains";
701
702export interface IdeInfo {
703 ideType: IdeType;
704 name: string;
705 version: string;
706 remoteName: string;
707 extensionVersion: string;
708}
709
710export interface BranchAndDir {
711 branch: string;
712 directory: string;
713}
714
715export interface IndexTag extends BranchAndDir {
716 artifactId: string;
717}
718
719export enum FileType {
720 Unkown = 0,
721 File = 1,
722 Directory = 2,
723 SymbolicLink = 64,
724}
725
726export interface IdeSettings {
727 remoteConfigServerUrl: string | undefined;
728 remoteConfigSyncPeriod: number;
729 userToken: string;
730 continueTestEnvironment: "none" | "production" | "staging" | "local";
731 pauseCodebaseIndexOnStart: boolean;
732}
733
734export interface FileStats {
735 size: number;
736 lastModified: number;
737}
738
739/** Map of file name to stats */
740export type FileStatsMap = {
741 [path: string]: FileStats;
742};
743
744export interface IDE {
745 getIdeInfo(): Promise<IdeInfo>;
746
747 getIdeSettings(): Promise<IdeSettings>;
748
749 getDiff(includeUnstaged: boolean): Promise<string[]>;
750
751 getClipboardContent(): Promise<{ text: string; copiedAt: string }>;
752
753 isTelemetryEnabled(): Promise<boolean>;
754
755 isWorkspaceRemote(): Promise<boolean>;
756
757 getUniqueId(): Promise<string>;
758
759 getTerminalContents(): Promise<string>;
760
761 getDebugLocals(threadIndex: number): Promise<string>;
762
763 getTopLevelCallStackSources(
764 threadIndex: number,
765 stackDepth: number,
766 ): Promise<string[]>;
767
768 getAvailableThreads(): Promise<Thread[]>;
769
770 getWorkspaceDirs(): Promise<string[]>;
771
772 getWorkspaceConfigs(): Promise<ContinueRcJson[]>;
773
774 fileExists(fileUri: string): Promise<boolean>;
775
776 writeFile(path: string, contents: string): Promise<void>;
777
778 showVirtualFile(title: string, contents: string): Promise<void>;
779
780 openFile(path: string): Promise<void>;
781
782 openUrl(url: string): Promise<void>;
783
784 runCommand(command: string, options?: TerminalOptions): Promise<void>;
785
786 saveFile(fileUri: string): Promise<void>;
787
788 readFile(fileUri: string): Promise<string>;
789
790 readRangeInFile(fileUri: string, range: Range): Promise<string>;
791
792 showLines(fileUri: string, startLine: number, endLine: number): Promise<void>;
793
794 getOpenFiles(): Promise<string[]>;
795
796 getCurrentFile(): Promise<
797 | undefined
798 | {
799 isUntitled: boolean;
800 path: string;
801 contents: string;
802 }
803 >;
804
805 getPinnedFiles(): Promise<string[]>;
806
807 getSearchResults(query: string, maxResults?: number): Promise<string>;
808
809 getFileResults(pattern: string, maxResults?: number): Promise<string[]>;
810
811 subprocess(command: string, cwd?: string): Promise<[string, string]>;
812
813 getProblems(fileUri?: string | undefined): Promise<Problem[]>;
814
815 getBranch(dir: string): Promise<string>;
816
817 getTags(artifactId: string): Promise<IndexTag[]>;
818
819 getRepoName(dir: string): Promise<string | undefined>;
820
821 showToast(
822 type: ToastType,
823 message: string,
824 ...otherParams: any[]
825 ): Promise<any>;
826
827 getGitRootPath(dir: string): Promise<string | undefined>;
828
829 listDir(dir: string): Promise<[string, FileType][]>;
830
831 getFileStats(files: string[]): Promise<FileStatsMap>;
832
833 // Secret Storage
834 readSecrets(keys: string[]): Promise<Record<string, string>>;
835
836 writeSecrets(secrets: { [key: string]: string }): Promise<void>;
837
838 // LSP
839 gotoDefinition(location: Location): Promise<RangeInFile[]>;
840
841 // Callbacks
842 onDidChangeActiveTextEditor(callback: (fileUri: string) => void): void;
843}
844
845// Slash Commands
846
847export interface ContinueSDK {
848 ide: IDE;
849 llm: ILLM;
850 addContextItem: (item: ContextItemWithId) => void;
851 history: ChatMessage[];
852 input: string;
853 params?: { [key: string]: any } | undefined;
854 contextItems: ContextItemWithId[];
855 selectedCode: RangeInFile[];
856 config: ContinueConfig;
857 fetch: FetchFunction;
858 completionOptions?: LLMFullCompletionOptions;
859 abortController: AbortController;
860}
861
862/* Be careful changing SlashCommand or SlashCommandDescription, config.ts can break */
863export interface SlashCommandDescription {
864 name: string;
865 description: string;
866 prompt?: string;
867 params?: { [key: string]: any };
868}
869
870export interface SlashCommand extends SlashCommandDescription {
871 run: (sdk: ContinueSDK) => AsyncGenerator<string | undefined>;
872}
873
874export interface SlashCommandWithSource extends SlashCommandDescription {
875 run?: (sdk: ContinueSDK) => AsyncGenerator<string | undefined>; // Optional - only needed for legacy
876 source: SlashCommandSource;
877 promptFile?: string;
878 overrideSystemMessage?: string;
879}
880
881export type SlashCommandSource =
882 | "built-in-legacy"
883 | "built-in"
884 | "json-custom-command"
885 | "config-ts-slash-command"
886 | "yaml-prompt-block"
887 | "mcp-prompt"
888 | "prompt-file-v1"
889 | "prompt-file-v2"
890 | "invokable-rule";
891
892export interface SlashCommandDescWithSource extends SlashCommandDescription {
893 isLegacy: boolean; // Maps to if slashcommand.run exists
894 source: SlashCommandSource;
895 promptFile?: string;
896 mcpServerName?: string;
897 mcpArgs?: MCPPromptArgs;
898}
899
900// Config
901
902export type StepName =
903 | "AnswerQuestionChroma"
904 | "GenerateShellCommandStep"
905 | "EditHighlightedCodeStep"
906 | "ShareSessionStep"
907 | "CommentCodeStep"
908 | "ClearHistoryStep"
909 | "StackOverflowStep"
910 | "OpenConfigStep"
911 | "GenerateShellCommandStep"
912 | "DraftIssueStep";
913
914export type ContextProviderName =
915 | "diff"
916 | "terminal"
917 | "debugger"
918 | "open"
919 | "google"
920 | "search"
921 | "tree"
922 | "http"
923 | "codebase"
924 | "problems"
925 | "folder"
926 | "jira"
927 | "postgres"
928 | "database"
929 | "code"
930 | "docs"
931 | "gitlab-mr"
932 | "os"
933 | "currentFile"
934 | "greptile"
935 | "outline"
936 | "continue-proxy"
937 | "highlights"
938 | "file"
939 | "issue"
940 | "repo-map"
941 | "url"
942 | "commit"
943 | "web"
944 | "discord"
945 | "clipboard"
946 | string;
947
948export type TemplateType =
949 | "llama2"
950 | "alpaca"
951 | "zephyr"
952 | "phi2"
953 | "phind"
954 | "anthropic"
955 | "chatml"
956 | "none"
957 | "openchat"
958 | "deepseek"
959 | "xwin-coder"
960 | "neural-chat"
961 | "codellama-70b"
962 | "llava"
963 | "gemma"
964 | "granite"
965 | "llama3"
966 | "codestral";
967
968export interface RequestOptions {
969 timeout?: number;
970 verifySsl?: boolean;
971 caBundlePath?: string | string[];
972 proxy?: string;
973 headers?: { [key: string]: string };
974 extraBodyProperties?: { [key: string]: any };
975 noProxy?: string[];
976 clientCertificate?: ClientCertificateOptions;
977}
978
979export interface CacheBehavior {
980 cacheSystemMessage?: boolean;
981 cacheConversation?: boolean;
982}
983
984export interface ClientCertificateOptions {
985 cert: string;
986 key: string;
987 passphrase?: string;
988}
989
990export interface StepWithParams {
991 name: StepName;
992 params: { [key: string]: any };
993}
994
995export interface ContextProviderWithParams {
996 name: ContextProviderName;
997 params: { [key: string]: any };
998}
999
1000export interface CustomCommand {
1001 name: string;
1002 prompt: string;
1003 description?: string;
1004}
1005
1006export interface Prediction {
1007 type: "content";
1008 content:
1009 | string
1010 | {
1011 type: "text";
1012 text: string;
1013 }[];
1014}
1015
1016export interface ToolExtras {
1017 ide: IDE;
1018 llm: ILLM;
1019 fetch: FetchFunction;
1020 tool: Tool;
1021 toolCallId?: string;
1022 onPartialOutput?: (params: {
1023 toolCallId: string;
1024 contextItems: ContextItem[];
1025 }) => void;
1026 config: ContinueConfig;
1027 codeBaseIndexer?: CodebaseIndexer;
1028}
1029
1030export interface Tool {
1031 type: "function";
1032 function: {
1033 name: string;
1034 description?: string;
1035 parameters?: Record<string, any>;
1036 strict?: boolean | null;
1037 };
1038
1039 displayTitle: string;
1040 wouldLikeTo?: string;
1041 isCurrently?: string;
1042 hasAlready?: string;
1043 readonly: boolean;
1044 isInstant?: boolean;
1045 uri?: string;
1046 faviconUrl?: string;
1047 group: string;
1048 originalFunctionName?: string;
1049}
1050
1051interface ToolChoice {
1052 type: "function";
1053 function: {
1054 name: string;
1055 };
1056}
1057
1058export interface ConfigDependentToolParams {
1059 rules: RuleWithSource[];
1060 enableExperimentalTools: boolean;
1061}
1062
1063export type GetTool = (params: ConfigDependentToolParams) => Tool;
1064
1065export interface BaseCompletionOptions {
1066 temperature?: number;
1067 topP?: number;
1068 topK?: number;
1069 minP?: number;
1070 presencePenalty?: number;
1071 frequencyPenalty?: number;
1072 mirostat?: number;
1073 stop?: string[];
1074 maxTokens?: number;
1075 numThreads?: number;
1076 useMmap?: boolean;
1077 keepAlive?: number;
1078 numGpu?: number;
1079 raw?: boolean;
1080 stream?: boolean;
1081 prediction?: Prediction;
1082 tools?: Tool[];
1083 toolChoice?: ToolChoice;
1084 reasoning?: boolean;
1085 reasoningBudgetTokens?: number;
1086 promptCaching?: boolean;
1087}
1088
1089export interface ModelCapability {
1090 uploadImage?: boolean;
1091 tools?: boolean;
1092}
1093
1094export interface ModelDescription {
1095 title: string;
1096 provider: string;
1097 underlyingProviderName: string;
1098 model: string;
1099 apiKey?: string;
1100
1101 apiBase?: string;
1102 apiKeyLocation?: string;
1103 envSecretLocations?: Record<string, string>;
1104 orgScopeId?: string | null;
1105
1106 onPremProxyUrl?: string | null;
1107
1108 contextLength?: number;
1109 maxStopWords?: number;
1110 template?: TemplateType;
1111 completionOptions?: BaseCompletionOptions;
1112 baseAgentSystemMessage?: string;
1113 basePlanSystemMessage?: string;
1114 baseChatSystemMessage?: string;
1115 requestOptions?: RequestOptions;
1116 promptTemplates?: { [key: string]: string };
1117 cacheBehavior?: CacheBehavior;
1118 capabilities?: ModelCapability;
1119 roles?: ModelRole[];
1120 configurationStatus?: LLMConfigurationStatuses;
1121}
1122
1123export interface JSONEmbedOptions {
1124 apiBase?: string;
1125 apiKey?: string;
1126 model?: string;
1127 deployment?: string;
1128 apiType?: string;
1129 apiVersion?: string;
1130 requestOptions?: RequestOptions;
1131 maxEmbeddingChunkSize?: number;
1132 maxEmbeddingBatchSize?: number;
1133
1134 // AWS options
1135 profile?: string;
1136
1137 // AWS and VertexAI Options
1138 region?: string;
1139
1140 // VertexAI and Watsonx Options
1141 projectId?: string;
1142}
1143
1144export interface EmbeddingsProviderDescription extends JSONEmbedOptions {
1145 provider: string;
1146}
1147
1148export interface RerankerDescription {
1149 name: string;
1150 params?: { [key: string]: any };
1151}
1152
1153// TODO: We should consider renaming this to AutocompleteOptions.
1154export interface TabAutocompleteOptions {
1155 disable: boolean;
1156 maxPromptTokens: number;
1157 debounceDelay: number;
1158 modelTimeout: number;
1159 maxSuffixPercentage: number;
1160 prefixPercentage: number;
1161 transform?: boolean;
1162 template?: string;
1163 multilineCompletions: "always" | "never" | "auto";
1164 slidingWindowPrefixPercentage: number;
1165 slidingWindowSize: number;
1166 useCache: boolean;
1167 onlyMyCode: boolean;
1168 useRecentlyEdited: boolean;
1169 useRecentlyOpened: boolean;
1170 disableInFiles?: string[];
1171 useImports?: boolean;
1172 showWhateverWeHaveAtXMs?: number;
1173 // true = enabled, false = disabled, number = enabled with priority
1174 experimental_includeClipboard: boolean | number;
1175 experimental_includeRecentlyVisitedRanges: boolean | number;
1176 experimental_includeRecentlyEditedRanges: boolean | number;
1177 experimental_includeDiff: boolean | number;
1178}
1179
1180export interface StdioOptions {
1181 type: "stdio";
1182 command: string;
1183 args: string[];
1184 env?: Record<string, string>;
1185 cwd?: string;
1186 requestOptions?: RequestOptions;
1187}
1188
1189export interface WebSocketOptions {
1190 type: "websocket";
1191 url: string;
1192 requestOptions?: RequestOptions;
1193}
1194
1195export interface SSEOptions {
1196 type: "sse";
1197 url: string;
1198 requestOptions?: RequestOptions;
1199}
1200
1201export interface StreamableHTTPOptions {
1202 type: "streamable-http";
1203 url: string;
1204 requestOptions?: RequestOptions;
1205}
1206
1207export type TransportOptions =
1208 | StdioOptions
1209 | WebSocketOptions
1210 | SSEOptions
1211 | StreamableHTTPOptions;
1212
1213export interface MCPOptions {
1214 name: string;
1215 id: string;
1216 transport: TransportOptions;
1217 faviconUrl?: string;
1218 timeout?: number;
1219}
1220
1221export type MCPConnectionStatus =
1222 | "connecting"
1223 | "connected"
1224 | "error"
1225 | "not-connected";
1226
1227export type MCPPromptArgs = {
1228 name: string;
1229 description?: string;
1230 required?: boolean;
1231}[];
1232
1233export interface MCPPrompt {
1234 name: string;
1235 description?: string;
1236 arguments?: MCPPromptArgs;
1237}
1238
1239// Leaving here to ideate on
1240// export type ContinueConfigSource = "local-yaml" | "local-json" | "hub-assistant" | "hub"
1241
1242// https://modelcontextprotocol.io/docs/concepts/resources#direct-resources
1243export interface MCPResource {
1244 name: string;
1245 uri: string;
1246 description?: string;
1247 mimeType?: string;
1248}
1249
1250// https://modelcontextprotocol.io/docs/concepts/resources#resource-templates
1251export interface MCPResourceTemplate {
1252 uriTemplate: string;
1253 name: string;
1254 description?: string;
1255 mimeType?: string;
1256}
1257
1258export interface MCPTool {
1259 name: string;
1260 description?: string;
1261 inputSchema: {
1262 type: "object";
1263 properties?: Record<string, any>;
1264 };
1265}
1266
1267export interface MCPServerStatus extends MCPOptions {
1268 status: MCPConnectionStatus;
1269 errors: string[];
1270
1271 prompts: MCPPrompt[];
1272 tools: MCPTool[];
1273 resources: MCPResource[];
1274 resourceTemplates: MCPResourceTemplate[];
1275}
1276
1277export interface ContinueUIConfig {
1278 codeBlockToolbarPosition?: "top" | "bottom";
1279 fontSize?: number;
1280 displayRawMarkdown?: boolean;
1281 showChatScrollbar?: boolean;
1282 codeWrap?: boolean;
1283 showSessionTabs?: boolean;
1284 autoAcceptEditToolDiffs?: boolean;
1285 logEditingData?: boolean;
1286}
1287
1288export interface ContextMenuConfig {
1289 comment?: string;
1290 docstring?: string;
1291 fix?: string;
1292 optimize?: string;
1293 fixGrammar?: string;
1294}
1295
1296export interface ExperimentalModelRoles {
1297 repoMapFileSelection?: string;
1298 inlineEdit?: string;
1299 applyCodeBlock?: string;
1300}
1301
1302export interface ExperimentalMCPOptions {
1303 transport: TransportOptions;
1304 faviconUrl?: string;
1305 timeout?: number;
1306}
1307
1308export type ApplyStateStatus =
1309 | "not-started" // Apply state created but not necessarily streaming
1310 | "streaming" // Changes are being applied to the file
1311 | "done" // All changes have been applied, awaiting user to accept/reject
1312 | "closed"; // All changes have been applied. Note that for new files, we immediately set the status to "closed"
1313
1314export interface ApplyState {
1315 streamId: string;
1316 status?: ApplyStateStatus;
1317 numDiffs?: number;
1318 filepath?: string;
1319 fileContent?: string;
1320 toolCallId?: string;
1321}
1322
1323export interface StreamDiffLinesPayload {
1324 prefix: string;
1325 highlighted: string;
1326 suffix: string;
1327 input: string;
1328 language: string | undefined;
1329 modelTitle: string | undefined;
1330 includeRulesInSystemMessage: boolean;
1331 fileUri?: string;
1332}
1333
1334export interface HighlightedCodePayload {
1335 rangeInFileWithContents: RangeInFileWithContents;
1336 prompt?: string;
1337 shouldRun?: boolean;
1338}
1339
1340export interface AcceptOrRejectDiffPayload {
1341 filepath?: string;
1342 streamId?: string;
1343}
1344
1345export interface ShowFilePayload {
1346 filepath: string;
1347}
1348
1349export interface ApplyToFilePayload {
1350 streamId: string;
1351 filepath?: string;
1352 text: string;
1353 toolCallId?: string;
1354 isSearchAndReplace?: boolean;
1355}
1356
1357export interface RangeInFileWithContents {
1358 filepath: string;
1359 range: {
1360 start: { line: number; character: number };
1361 end: { line: number; character: number };
1362 };
1363 contents: string;
1364}
1365
1366export interface RangeInFileWithNextEditInfo {
1367 filepath: string;
1368 range: Range;
1369 fileContents: string;
1370 editText: string;
1371 afterCursorPos: Position;
1372 beforeCursorPos: Position;
1373 workspaceDir: string;
1374}
1375
1376export type SetCodeToEditPayload = RangeInFileWithContents | FileWithContents;
1377
1378/**
1379 * Represents the configuration for a quick action in the Code Lens.
1380 * Quick actions are custom commands that can be added to function and class declarations.
1381 */
1382export interface QuickActionConfig {
1383 /**
1384 * The title of the quick action that will display in the Code Lens.
1385 */
1386 title: string;
1387
1388 /**
1389 * The prompt that will be sent to the model when the quick action is invoked,
1390 * with the function or class body concatenated.
1391 */
1392 prompt: string;
1393
1394 /**
1395 * If `true`, the result of the quick action will be sent to the chat panel.
1396 * If `false`, the streamed result will be inserted into the document.
1397 *
1398 * Defaults to `false`.
1399 */
1400 sendToChat: boolean;
1401}
1402
1403export type DefaultContextProvider = ContextProviderWithParams & {
1404 query?: string;
1405};
1406
1407export interface ExperimentalConfig {
1408 contextMenuPrompts?: ContextMenuConfig;
1409 modelRoles?: ExperimentalModelRoles;
1410 defaultContext?: DefaultContextProvider[];
1411 promptPath?: string;
1412 enableExperimentalTools?: boolean;
1413
1414 /**
1415 * Quick actions are a way to add custom commands to the Code Lens of
1416 * function and class declarations.
1417 */
1418 quickActions?: QuickActionConfig[];
1419
1420 /**
1421 * Automatically read LLM chat responses aloud using system TTS models
1422 */
1423 readResponseTTS?: boolean;
1424
1425 /**
1426 * If set to true, we will attempt to pull down and install an instance of Chromium
1427 * that is compatible with the current version of Puppeteer.
1428 * This is needed to crawl a large number of documentation sites that are dynamically rendered.
1429 */
1430 useChromiumForDocsCrawling?: boolean;
1431 modelContextProtocolServers?: ExperimentalMCPOptions[];
1432
1433 /**
1434 * If enabled, will add the current file as context.
1435 */
1436 useCurrentFileAsContext?: boolean;
1437
1438 /**
1439 * If enabled, will save data on the user's editing processes
1440 */
1441 logEditingData?: boolean;
1442
1443 /**
1444 * If enabled, will enable next edit in place of autocomplete
1445 */
1446 optInNextEditFeature?: boolean;
1447
1448 /**
1449 * If enabled, @codebase will only use tool calling
1450 * instead of embeddings, FTS, recently edited files, etc.
1451 */
1452 codebaseToolCallingOnly?: boolean;
1453}
1454
1455export interface AnalyticsConfig {
1456 provider: string;
1457 url?: string;
1458 clientKey?: string;
1459}
1460
1461export interface JSONModelDescription {
1462 title: string;
1463 provider: string;
1464 underlyingProviderName: string;
1465 model: string;
1466 apiKey?: string;
1467 apiBase?: string;
1468
1469 contextLength?: number;
1470 maxStopWords?: number;
1471 template?: TemplateType;
1472 completionOptions?: BaseCompletionOptions;
1473 systemMessage?: string;
1474 requestOptions?: RequestOptions;
1475 cacheBehavior?: CacheBehavior;
1476
1477 region?: string;
1478 profile?: string;
1479 modelArn?: string;
1480 apiType?: "openai" | "azure";
1481 apiVersion?: string;
1482 deployment?: string;
1483 projectId?: string;
1484 accountId?: string;
1485 aiGatewaySlug?: string;
1486 useLegacyCompletionsEndpoint?: boolean;
1487 deploymentId?: string;
1488}
1489
1490// config.json
1491export interface SerializedContinueConfig {
1492 env?: string[];
1493 allowAnonymousTelemetry?: boolean;
1494 models: JSONModelDescription[];
1495 systemMessage?: string;
1496 completionOptions?: BaseCompletionOptions;
1497 requestOptions?: RequestOptions;
1498 slashCommands?: SlashCommandDescription[];
1499 customCommands?: CustomCommand[];
1500 contextProviders?: ContextProviderWithParams[];
1501 disableIndexing?: boolean;
1502 disableSessionTitles?: boolean;
1503 userToken?: string;
1504 embeddingsProvider?: EmbeddingsProviderDescription;
1505 tabAutocompleteModel?: JSONModelDescription | JSONModelDescription[];
1506 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1507 ui?: ContinueUIConfig;
1508 reranker?: RerankerDescription;
1509 experimental?: ExperimentalConfig;
1510 analytics?: AnalyticsConfig;
1511 docs?: SiteIndexingConfig[];
1512 data?: DataDestination[];
1513}
1514
1515export type ConfigMergeType = "merge" | "overwrite";
1516
1517export type ContinueRcJson = Partial<SerializedContinueConfig> & {
1518 mergeBehavior: ConfigMergeType;
1519};
1520
1521// config.ts - give users simplified interfaces
1522export interface Config {
1523 /** 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 */
1524 allowAnonymousTelemetry?: boolean;
1525 /** Each entry in this array will originally be a JSONModelDescription, the same object from your config.json, but you may add CustomLLMs.
1526 * 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).
1527 * Continue will do the rest of the work to construct prompt templates, handle context items, prune context, etc.
1528 */
1529 models: (CustomLLM | JSONModelDescription)[];
1530 /** A system message to be followed by all of your models */
1531 systemMessage?: string;
1532 /** The default completion options for all models */
1533 completionOptions?: BaseCompletionOptions;
1534 /** Request options that will be applied to all models and context providers */
1535 requestOptions?: RequestOptions;
1536 /** The list of slash commands that will be available in the sidebar */
1537 slashCommands?: (SlashCommand | SlashCommandWithSource)[];
1538 /** Each entry in this array will originally be a ContextProviderWithParams, the same object from your config.json, but you may add CustomContextProviders.
1539 * A CustomContextProvider requires you only to define a title and getContextItems function. When you type '@title <query>', Continue will call `getContextItems(query)`.
1540 */
1541 contextProviders?: (CustomContextProvider | ContextProviderWithParams)[];
1542 /** If set to true, Continue will not index your codebase for retrieval */
1543 disableIndexing?: boolean;
1544 /** If set to true, Continue will not make extra requests to the LLM to generate a summary title of each session. */
1545 disableSessionTitles?: boolean;
1546 /** An optional token to identify a user. Not used by Continue unless you write custom coniguration that requires such a token */
1547 userToken?: string;
1548 /** The provider used to calculate embeddings. If left empty, Continue will use transformers.js to calculate the embeddings with all-MiniLM-L6-v2 */
1549 embeddingsProvider?: EmbeddingsProviderDescription | ILLM;
1550 /** The model that Continue will use for tab autocompletions. */
1551 tabAutocompleteModel?:
1552 | CustomLLM
1553 | JSONModelDescription
1554 | (CustomLLM | JSONModelDescription)[];
1555 /** Options for tab autocomplete */
1556 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1557 /** UI styles customization */
1558 ui?: ContinueUIConfig;
1559 /** Options for the reranker */
1560 reranker?: RerankerDescription | ILLM;
1561 /** Experimental configuration */
1562 experimental?: ExperimentalConfig;
1563 /** Analytics configuration */
1564 analytics?: AnalyticsConfig;
1565 data?: DataDestination[];
1566}
1567
1568// in the actual Continue source code
1569export interface ContinueConfig {
1570 allowAnonymousTelemetry?: boolean;
1571 // systemMessage?: string;
1572 completionOptions?: BaseCompletionOptions;
1573 requestOptions?: RequestOptions;
1574 slashCommands: SlashCommandWithSource[];
1575 contextProviders: IContextProvider[];
1576 disableSessionTitles?: boolean;
1577 disableIndexing?: boolean;
1578 userToken?: string;
1579 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1580 ui?: ContinueUIConfig;
1581 experimental?: ExperimentalConfig;
1582 analytics?: AnalyticsConfig;
1583 docs?: SiteIndexingConfig[];
1584 tools: Tool[];
1585 mcpServerStatuses: MCPServerStatus[];
1586 rules: RuleWithSource[];
1587 modelsByRole: Record<ModelRole, ILLM[]>;
1588 selectedModelByRole: Record<ModelRole, ILLM | null>;
1589 data?: DataDestination[];
1590}
1591
1592export interface BrowserSerializedContinueConfig {
1593 allowAnonymousTelemetry?: boolean;
1594 // systemMessage?: string;
1595 completionOptions?: BaseCompletionOptions;
1596 requestOptions?: RequestOptions;
1597 slashCommands: SlashCommandDescWithSource[];
1598 contextProviders: ContextProviderDescription[];
1599 disableIndexing?: boolean;
1600 disableSessionTitles?: boolean;
1601 userToken?: string;
1602 ui?: ContinueUIConfig;
1603 experimental?: ExperimentalConfig;
1604 analytics?: AnalyticsConfig;
1605 docs?: SiteIndexingConfig[];
1606 tools: Tool[];
1607 mcpServerStatuses: MCPServerStatus[];
1608 rules: RuleWithSource[];
1609 usePlatform: boolean;
1610 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1611 modelsByRole: Record<ModelRole, ModelDescription[]>;
1612 selectedModelByRole: Record<ModelRole, ModelDescription | null>;
1613}
1614
1615// DOCS SUGGESTIONS AND PACKAGE INFO
1616export interface FilePathAndName {
1617 path: string;
1618 name: string;
1619}
1620
1621export interface PackageFilePathAndName extends FilePathAndName {
1622 packageRegistry: string; // e.g. npm, pypi
1623}
1624
1625export type ParsedPackageInfo = {
1626 name: string;
1627 packageFile: PackageFilePathAndName;
1628 language: string;
1629 version: string;
1630};
1631
1632export type PackageDetails = {
1633 docsLink?: string;
1634 docsLinkWarning?: string;
1635 title?: string;
1636 description?: string;
1637 repo?: string;
1638 license?: string;
1639};
1640
1641export type PackageDetailsSuccess = PackageDetails & {
1642 docsLink: string;
1643};
1644
1645export type PackageDocsResult = {
1646 packageInfo: ParsedPackageInfo;
1647} & (
1648 | { error: string; details?: never }
1649 | { details: PackageDetailsSuccess; error?: never }
1650);
1651
1652export interface TerminalOptions {
1653 reuseTerminal?: boolean;
1654 terminalName?: string;
1655 waitForCompletion?: boolean;
1656}
1657
1658export type RuleSource =
1659 | "default-chat"
1660 | "default-plan"
1661 | "default-agent"
1662 | "model-options-chat"
1663 | "model-options-plan"
1664 | "model-options-agent"
1665 | "rules-block"
1666 | "json-systemMessage"
1667 | ".continuerules";
1668
1669export interface RuleWithSource {
1670 name?: string;
1671 slug?: string;
1672 source: RuleSource;
1673 globs?: string | string[];
1674 regex?: string | string[];
1675 rule: string;
1676 description?: string;
1677 ruleFile?: string;
1678 alwaysApply?: boolean;
1679}
1680export interface CompleteOnboardingPayload {
1681 mode: OnboardingModes;
1682 provider?: string;
1683 apiKey?: string;
1684}