Elffuss BraidHub

kikocis/continue public

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