Elffuss BraidHub

kikocis/continue public

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