Elffuss BraidHub

kikocis/continue public

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