Elffuss BraidHub

kikocis/continue public

972ea8cfaef0 · 36.3 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 onDidCloseTextDocument(callback: (fileUris: string[]) => void): void;
818}
819
820// Slash Commands
821
822export interface ContinueSDK {
823 ide: IDE;
824 llm: ILLM;
825 addContextItem: (item: ContextItemWithId) => void;
826 history: ChatMessage[];
827 input: string;
828 params?: { [key: string]: any } | undefined;
829 contextItems: ContextItemWithId[];
830 selectedCode: RangeInFile[];
831 config: ContinueConfig;
832 fetch: FetchFunction;
833 completionOptions?: LLMFullCompletionOptions;
834}
835
836export interface SlashCommand {
837 name: string;
838 description: string;
839 prompt?: string;
840 params?: { [key: string]: any };
841 promptFile?: string;
842 run: (sdk: ContinueSDK) => AsyncGenerator<string | undefined>;
843}
844
845// Config
846
847export type StepName =
848 | "AnswerQuestionChroma"
849 | "GenerateShellCommandStep"
850 | "EditHighlightedCodeStep"
851 | "ShareSessionStep"
852 | "CommentCodeStep"
853 | "ClearHistoryStep"
854 | "StackOverflowStep"
855 | "OpenConfigStep"
856 | "GenerateShellCommandStep"
857 | "DraftIssueStep";
858
859export type ContextProviderName =
860 | "diff"
861 | "terminal"
862 | "debugger"
863 | "open"
864 | "google"
865 | "search"
866 | "tree"
867 | "http"
868 | "codebase"
869 | "problems"
870 | "folder"
871 | "jira"
872 | "postgres"
873 | "database"
874 | "code"
875 | "docs"
876 | "gitlab-mr"
877 | "os"
878 | "currentFile"
879 | "greptile"
880 | "outline"
881 | "continue-proxy"
882 | "highlights"
883 | "file"
884 | "issue"
885 | "repo-map"
886 | "url"
887 | "commit"
888 | "web"
889 | "discord"
890 | "clipboard"
891 | string;
892
893export type TemplateType =
894 | "llama2"
895 | "alpaca"
896 | "zephyr"
897 | "phi2"
898 | "phind"
899 | "anthropic"
900 | "chatml"
901 | "none"
902 | "openchat"
903 | "deepseek"
904 | "xwin-coder"
905 | "neural-chat"
906 | "codellama-70b"
907 | "llava"
908 | "gemma"
909 | "granite"
910 | "llama3"
911 | "codestral";
912
913export interface RequestOptions {
914 timeout?: number;
915 verifySsl?: boolean;
916 caBundlePath?: string | string[];
917 proxy?: string;
918 headers?: { [key: string]: string };
919 extraBodyProperties?: { [key: string]: any };
920 noProxy?: string[];
921 clientCertificate?: ClientCertificateOptions;
922}
923
924export interface CacheBehavior {
925 cacheSystemMessage?: boolean;
926 cacheConversation?: boolean;
927}
928
929export interface ClientCertificateOptions {
930 cert: string;
931 key: string;
932 passphrase?: string;
933}
934
935export interface StepWithParams {
936 name: StepName;
937 params: { [key: string]: any };
938}
939
940export interface ContextProviderWithParams {
941 name: ContextProviderName;
942 params: { [key: string]: any };
943}
944
945export type SlashCommandDescription = Omit<SlashCommand, "run">;
946
947export interface CustomCommand {
948 name: string;
949 prompt: string;
950 description?: string;
951}
952
953export interface Prediction {
954 type: "content";
955 content:
956 | string
957 | {
958 type: "text";
959 text: string;
960 }[];
961}
962
963export interface ToolExtras {
964 ide: IDE;
965 llm: ILLM;
966 fetch: FetchFunction;
967 tool: Tool;
968 toolCallId?: string;
969 onPartialOutput?: (params: {
970 toolCallId: string;
971 contextItems: ContextItem[];
972 }) => void;
973 config: ContinueConfig;
974}
975
976export interface Tool {
977 type: "function";
978 function: {
979 name: string;
980 description?: string;
981 parameters?: Record<string, any>;
982 strict?: boolean | null;
983 };
984
985 displayTitle: string;
986 wouldLikeTo?: string;
987 isCurrently?: string;
988 hasAlready?: string;
989 readonly: boolean;
990 isInstant?: boolean;
991 uri?: string;
992 faviconUrl?: string;
993 group: string;
994}
995
996interface ToolChoice {
997 type: "function";
998 function: {
999 name: string;
1000 };
1001}
1002
1003export interface ConfigDependentToolParams {
1004 rules: RuleWithSource[];
1005}
1006
1007export type GetTool = (params: ConfigDependentToolParams) => Tool;
1008
1009export interface BaseCompletionOptions {
1010 temperature?: number;
1011 topP?: number;
1012 topK?: number;
1013 minP?: number;
1014 presencePenalty?: number;
1015 frequencyPenalty?: number;
1016 mirostat?: number;
1017 stop?: string[];
1018 maxTokens?: number;
1019 numThreads?: number;
1020 useMmap?: boolean;
1021 keepAlive?: number;
1022 numGpu?: number;
1023 raw?: boolean;
1024 stream?: boolean;
1025 prediction?: Prediction;
1026 tools?: Tool[];
1027 toolChoice?: ToolChoice;
1028 reasoning?: boolean;
1029 reasoningBudgetTokens?: number;
1030 promptCaching?: boolean;
1031}
1032
1033export interface ModelCapability {
1034 uploadImage?: boolean;
1035 tools?: boolean;
1036}
1037
1038export interface ModelDescription {
1039 title: string;
1040 provider: string;
1041 underlyingProviderName: string;
1042 model: string;
1043 apiKey?: string;
1044
1045 apiBase?: string;
1046 apiKeyLocation?: string;
1047 orgScopeId?: string | null;
1048
1049 onPremProxyUrl?: string | null;
1050
1051 contextLength?: number;
1052 maxStopWords?: number;
1053 template?: TemplateType;
1054 completionOptions?: BaseCompletionOptions;
1055 baseAgentSystemMessage?: string;
1056 baseChatSystemMessage?: string;
1057 requestOptions?: RequestOptions;
1058 promptTemplates?: { [key: string]: string };
1059 cacheBehavior?: CacheBehavior;
1060 capabilities?: ModelCapability;
1061 roles?: ModelRole[];
1062 configurationStatus?: LLMConfigurationStatuses;
1063}
1064
1065export interface JSONEmbedOptions {
1066 apiBase?: string;
1067 apiKey?: string;
1068 model?: string;
1069 deployment?: string;
1070 apiType?: string;
1071 apiVersion?: string;
1072 requestOptions?: RequestOptions;
1073 maxEmbeddingChunkSize?: number;
1074 maxEmbeddingBatchSize?: number;
1075
1076 // AWS options
1077 profile?: string;
1078
1079 // AWS and VertexAI Options
1080 region?: string;
1081
1082 // VertexAI and Watsonx Options
1083 projectId?: string;
1084}
1085
1086export interface EmbeddingsProviderDescription extends JSONEmbedOptions {
1087 provider: string;
1088}
1089
1090export interface RerankerDescription {
1091 name: string;
1092 params?: { [key: string]: any };
1093}
1094
1095export interface TabAutocompleteOptions {
1096 disable: boolean;
1097 maxPromptTokens: number;
1098 debounceDelay: number;
1099 modelTimeout: number;
1100 maxSuffixPercentage: number;
1101 prefixPercentage: number;
1102 transform?: boolean;
1103 template?: string;
1104 multilineCompletions: "always" | "never" | "auto";
1105 slidingWindowPrefixPercentage: number;
1106 slidingWindowSize: number;
1107 useCache: boolean;
1108 onlyMyCode: boolean;
1109 useRecentlyEdited: boolean;
1110 useRecentlyOpened: boolean;
1111 disableInFiles?: string[];
1112 useImports?: boolean;
1113 showWhateverWeHaveAtXMs?: number;
1114 // true = enabled, false = disabled, number = enabled with priority
1115 experimental_includeClipboard: boolean | number;
1116 experimental_includeRecentlyVisitedRanges: boolean | number;
1117 experimental_includeRecentlyEditedRanges: boolean | number;
1118 experimental_includeDiff: boolean | number;
1119}
1120
1121export interface StdioOptions {
1122 type: "stdio";
1123 command: string;
1124 args: string[];
1125 env?: Record<string, string>;
1126 requestOptions?: RequestOptions;
1127}
1128
1129export interface WebSocketOptions {
1130 type: "websocket";
1131 url: string;
1132 requestOptions?: RequestOptions;
1133}
1134
1135export interface SSEOptions {
1136 type: "sse";
1137 url: string;
1138 requestOptions?: RequestOptions;
1139}
1140
1141export interface StreamableHTTPOptions {
1142 type: "streamable-http";
1143 url: string;
1144 requestOptions?: RequestOptions;
1145}
1146
1147export type TransportOptions =
1148 | StdioOptions
1149 | WebSocketOptions
1150 | SSEOptions
1151 | StreamableHTTPOptions;
1152
1153export interface MCPOptions {
1154 name: string;
1155 id: string;
1156 transport: TransportOptions;
1157 faviconUrl?: string;
1158 timeout?: number;
1159}
1160
1161export type MCPConnectionStatus =
1162 | "connecting"
1163 | "connected"
1164 | "error"
1165 | "not-connected";
1166
1167export interface MCPPrompt {
1168 name: string;
1169 description?: string;
1170 arguments?: {
1171 name: string;
1172 description?: string;
1173 required?: boolean;
1174 }[];
1175}
1176
1177// Leaving here to ideate on
1178// export type ContinueConfigSource = "local-yaml" | "local-json" | "hub-assistant" | "hub"
1179
1180// https://modelcontextprotocol.io/docs/concepts/resources#direct-resources
1181export interface MCPResource {
1182 name: string;
1183 uri: string;
1184 description?: string;
1185 mimeType?: string;
1186}
1187
1188// https://modelcontextprotocol.io/docs/concepts/resources#resource-templates
1189export interface MCPResourceTemplate {
1190 uriTemplate: string;
1191 name: string;
1192 description?: string;
1193 mimeType?: string;
1194}
1195
1196export interface MCPTool {
1197 name: string;
1198 description?: string;
1199 inputSchema: {
1200 type: "object";
1201 properties?: Record<string, any>;
1202 };
1203}
1204
1205export interface MCPServerStatus extends MCPOptions {
1206 status: MCPConnectionStatus;
1207 errors: string[];
1208
1209 prompts: MCPPrompt[];
1210 tools: MCPTool[];
1211 resources: MCPResource[];
1212 resourceTemplates: MCPResourceTemplate[];
1213}
1214
1215export interface ContinueUIConfig {
1216 codeBlockToolbarPosition?: "top" | "bottom";
1217 fontSize?: number;
1218 displayRawMarkdown?: boolean;
1219 showChatScrollbar?: boolean;
1220 codeWrap?: boolean;
1221 showSessionTabs?: boolean;
1222 autoAcceptEditToolDiffs?: boolean;
1223}
1224
1225export interface ContextMenuConfig {
1226 comment?: string;
1227 docstring?: string;
1228 fix?: string;
1229 optimize?: string;
1230 fixGrammar?: string;
1231}
1232
1233export interface ExperimentalModelRoles {
1234 repoMapFileSelection?: string;
1235 inlineEdit?: string;
1236 applyCodeBlock?: string;
1237}
1238
1239export interface ExperimentalMCPOptions {
1240 transport: TransportOptions;
1241 faviconUrl?: string;
1242 timeout?: number;
1243}
1244
1245export type ApplyStateStatus =
1246 | "not-started" // Apply state created but not necessarily streaming
1247 | "streaming" // Changes are being applied to the file
1248 | "done" // All changes have been applied, awaiting user to accept/reject
1249 | "closed"; // All changes have been applied. Note that for new files, we immediately set the status to "closed"
1250
1251export interface ApplyState {
1252 streamId: string;
1253 status?: ApplyStateStatus;
1254 numDiffs?: number;
1255 filepath?: string;
1256 fileContent?: string;
1257 toolCallId?: string;
1258}
1259
1260export interface StreamDiffLinesPayload {
1261 prefix: string;
1262 highlighted: string;
1263 suffix: string;
1264 input: string;
1265 language: string | undefined;
1266 modelTitle: string | undefined;
1267 includeRulesInSystemMessage: boolean;
1268 fileUri?: string;
1269}
1270
1271export interface HighlightedCodePayload {
1272 rangeInFileWithContents: RangeInFileWithContents;
1273 prompt?: string;
1274 shouldRun?: boolean;
1275}
1276
1277export interface AcceptOrRejectDiffPayload {
1278 filepath: string;
1279 streamId?: string;
1280}
1281
1282export interface ShowFilePayload {
1283 filepath: string;
1284}
1285
1286export interface RangeInFileWithContents {
1287 filepath: string;
1288 range: {
1289 start: { line: number; character: number };
1290 end: { line: number; character: number };
1291 };
1292 contents: string;
1293}
1294
1295export type SetCodeToEditPayload = RangeInFileWithContents | FileWithContents;
1296
1297/**
1298 * Represents the configuration for a quick action in the Code Lens.
1299 * Quick actions are custom commands that can be added to function and class declarations.
1300 */
1301export interface QuickActionConfig {
1302 /**
1303 * The title of the quick action that will display in the Code Lens.
1304 */
1305 title: string;
1306
1307 /**
1308 * The prompt that will be sent to the model when the quick action is invoked,
1309 * with the function or class body concatenated.
1310 */
1311 prompt: string;
1312
1313 /**
1314 * If `true`, the result of the quick action will be sent to the chat panel.
1315 * If `false`, the streamed result will be inserted into the document.
1316 *
1317 * Defaults to `false`.
1318 */
1319 sendToChat: boolean;
1320}
1321
1322export type DefaultContextProvider = ContextProviderWithParams & {
1323 query?: string;
1324};
1325
1326export interface ExperimentalConfig {
1327 contextMenuPrompts?: ContextMenuConfig;
1328 modelRoles?: ExperimentalModelRoles;
1329 defaultContext?: DefaultContextProvider[];
1330 promptPath?: string;
1331
1332 /**
1333 * Quick actions are a way to add custom commands to the Code Lens of
1334 * function and class declarations.
1335 */
1336 quickActions?: QuickActionConfig[];
1337
1338 /**
1339 * Automatically read LLM chat responses aloud using system TTS models
1340 */
1341 readResponseTTS?: boolean;
1342
1343 /**
1344 * If set to true, we will attempt to pull down and install an instance of Chromium
1345 * that is compatible with the current version of Puppeteer.
1346 * This is needed to crawl a large number of documentation sites that are dynamically rendered.
1347 */
1348 useChromiumForDocsCrawling?: boolean;
1349 modelContextProtocolServers?: ExperimentalMCPOptions[];
1350
1351 /**
1352 * If enabled, will add the current file as context.
1353 */
1354 useCurrentFileAsContext?: boolean;
1355}
1356
1357export interface AnalyticsConfig {
1358 provider: string;
1359 url?: string;
1360 clientKey?: string;
1361}
1362
1363export interface JSONModelDescription {
1364 title: string;
1365 provider: string;
1366 underlyingProviderName: string;
1367 model: string;
1368 apiKey?: string;
1369 apiBase?: string;
1370
1371 contextLength?: number;
1372 maxStopWords?: number;
1373 template?: TemplateType;
1374 completionOptions?: BaseCompletionOptions;
1375 systemMessage?: string;
1376 requestOptions?: RequestOptions;
1377 cacheBehavior?: CacheBehavior;
1378
1379 region?: string;
1380 profile?: string;
1381 modelArn?: string;
1382 apiType?: "openai" | "azure";
1383 apiVersion?: string;
1384 deployment?: string;
1385 projectId?: string;
1386 accountId?: string;
1387 aiGatewaySlug?: string;
1388 useLegacyCompletionsEndpoint?: boolean;
1389 deploymentId?: string;
1390}
1391
1392// config.json
1393export interface SerializedContinueConfig {
1394 env?: string[];
1395 allowAnonymousTelemetry?: boolean;
1396 models: JSONModelDescription[];
1397 systemMessage?: string;
1398 completionOptions?: BaseCompletionOptions;
1399 requestOptions?: RequestOptions;
1400 slashCommands?: SlashCommandDescription[];
1401 customCommands?: CustomCommand[];
1402 contextProviders?: ContextProviderWithParams[];
1403 disableIndexing?: boolean;
1404 disableSessionTitles?: boolean;
1405 userToken?: string;
1406 embeddingsProvider?: EmbeddingsProviderDescription;
1407 tabAutocompleteModel?: JSONModelDescription | JSONModelDescription[];
1408 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1409 ui?: ContinueUIConfig;
1410 reranker?: RerankerDescription;
1411 experimental?: ExperimentalConfig;
1412 analytics?: AnalyticsConfig;
1413 docs?: SiteIndexingConfig[];
1414 data?: DataDestination[];
1415}
1416
1417export type ConfigMergeType = "merge" | "overwrite";
1418
1419export type ContinueRcJson = Partial<SerializedContinueConfig> & {
1420 mergeBehavior: ConfigMergeType;
1421};
1422
1423// config.ts - give users simplified interfaces
1424export interface Config {
1425 /** 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 */
1426 allowAnonymousTelemetry?: boolean;
1427 /** Each entry in this array will originally be a JSONModelDescription, the same object from your config.json, but you may add CustomLLMs.
1428 * 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).
1429 * Continue will do the rest of the work to construct prompt templates, handle context items, prune context, etc.
1430 */
1431 models: (CustomLLM | JSONModelDescription)[];
1432 /** A system message to be followed by all of your models */
1433 systemMessage?: string;
1434 /** The default completion options for all models */
1435 completionOptions?: BaseCompletionOptions;
1436 /** Request options that will be applied to all models and context providers */
1437 requestOptions?: RequestOptions;
1438 /** The list of slash commands that will be available in the sidebar */
1439 slashCommands?: SlashCommand[];
1440 /** Each entry in this array will originally be a ContextProviderWithParams, the same object from your config.json, but you may add CustomContextProviders.
1441 * A CustomContextProvider requires you only to define a title and getContextItems function. When you type '@title <query>', Continue will call `getContextItems(query)`.
1442 */
1443 contextProviders?: (CustomContextProvider | ContextProviderWithParams)[];
1444 /** If set to true, Continue will not index your codebase for retrieval */
1445 disableIndexing?: boolean;
1446 /** If set to true, Continue will not make extra requests to the LLM to generate a summary title of each session. */
1447 disableSessionTitles?: boolean;
1448 /** An optional token to identify a user. Not used by Continue unless you write custom coniguration that requires such a token */
1449 userToken?: string;
1450 /** The provider used to calculate embeddings. If left empty, Continue will use transformers.js to calculate the embeddings with all-MiniLM-L6-v2 */
1451 embeddingsProvider?: EmbeddingsProviderDescription | ILLM;
1452 /** The model that Continue will use for tab autocompletions. */
1453 tabAutocompleteModel?:
1454 | CustomLLM
1455 | JSONModelDescription
1456 | (CustomLLM | JSONModelDescription)[];
1457 /** Options for tab autocomplete */
1458 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1459 /** UI styles customization */
1460 ui?: ContinueUIConfig;
1461 /** Options for the reranker */
1462 reranker?: RerankerDescription | ILLM;
1463 /** Experimental configuration */
1464 experimental?: ExperimentalConfig;
1465 /** Analytics configuration */
1466 analytics?: AnalyticsConfig;
1467 data?: DataDestination[];
1468}
1469
1470// in the actual Continue source code
1471export interface ContinueConfig {
1472 allowAnonymousTelemetry?: boolean;
1473 // systemMessage?: string;
1474 completionOptions?: BaseCompletionOptions;
1475 requestOptions?: RequestOptions;
1476 slashCommands: SlashCommand[];
1477 contextProviders: IContextProvider[];
1478 disableSessionTitles?: boolean;
1479 disableIndexing?: boolean;
1480 userToken?: string;
1481 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1482 ui?: ContinueUIConfig;
1483 experimental?: ExperimentalConfig;
1484 analytics?: AnalyticsConfig;
1485 docs?: SiteIndexingConfig[];
1486 tools: Tool[];
1487 mcpServerStatuses: MCPServerStatus[];
1488 rules: RuleWithSource[];
1489 modelsByRole: Record<ModelRole, ILLM[]>;
1490 selectedModelByRole: Record<ModelRole, ILLM | null>;
1491 data?: DataDestination[];
1492}
1493
1494export interface BrowserSerializedContinueConfig {
1495 allowAnonymousTelemetry?: boolean;
1496 // systemMessage?: string;
1497 completionOptions?: BaseCompletionOptions;
1498 requestOptions?: RequestOptions;
1499 slashCommands: SlashCommandDescription[];
1500 contextProviders: ContextProviderDescription[];
1501 disableIndexing?: boolean;
1502 disableSessionTitles?: boolean;
1503 userToken?: string;
1504 ui?: ContinueUIConfig;
1505 experimental?: ExperimentalConfig;
1506 analytics?: AnalyticsConfig;
1507 docs?: SiteIndexingConfig[];
1508 tools: Tool[];
1509 mcpServerStatuses: MCPServerStatus[];
1510 rules: RuleWithSource[];
1511 usePlatform: boolean;
1512 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1513 modelsByRole: Record<ModelRole, ModelDescription[]>;
1514 selectedModelByRole: Record<ModelRole, ModelDescription | null>;
1515}
1516
1517// DOCS SUGGESTIONS AND PACKAGE INFO
1518export interface FilePathAndName {
1519 path: string;
1520 name: string;
1521}
1522
1523export interface PackageFilePathAndName extends FilePathAndName {
1524 packageRegistry: string; // e.g. npm, pypi
1525}
1526
1527export type ParsedPackageInfo = {
1528 name: string;
1529 packageFile: PackageFilePathAndName;
1530 language: string;
1531 version: string;
1532};
1533
1534export type PackageDetails = {
1535 docsLink?: string;
1536 docsLinkWarning?: string;
1537 title?: string;
1538 description?: string;
1539 repo?: string;
1540 license?: string;
1541};
1542
1543export type PackageDetailsSuccess = PackageDetails & {
1544 docsLink: string;
1545};
1546
1547export type PackageDocsResult = {
1548 packageInfo: ParsedPackageInfo;
1549} & (
1550 | { error: string; details?: never }
1551 | { details: PackageDetailsSuccess; error?: never }
1552);
1553
1554export interface TerminalOptions {
1555 reuseTerminal?: boolean;
1556 terminalName?: string;
1557 waitForCompletion?: boolean;
1558}
1559
1560export type RuleSource =
1561 | "default-chat"
1562 | "default-agent"
1563 | "model-chat-options"
1564 | "model-agent-options"
1565 | "rules-block"
1566 | "json-systemMessage"
1567 | ".continuerules";
1568
1569export interface RuleWithSource {
1570 name?: string;
1571 slug?: string;
1572 source: RuleSource;
1573 globs?: string | string[];
1574 rule: string;
1575 description?: string;
1576 ruleFile?: string;
1577 alwaysApply?: boolean;
1578}