Elffuss BraidHub

kikocis/continue public

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