Elffuss BraidHub

kikocis/continue public

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