Elffuss BraidHub

kikocis/continue public

0cdb3e901c09 · 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 requestOptions?: RequestOptions;
1166}
1167
1168export interface WebSocketOptions {
1169 type: "websocket";
1170 url: string;
1171 requestOptions?: RequestOptions;
1172}
1173
1174export interface SSEOptions {
1175 type: "sse";
1176 url: string;
1177 requestOptions?: RequestOptions;
1178}
1179
1180export interface StreamableHTTPOptions {
1181 type: "streamable-http";
1182 url: string;
1183 requestOptions?: RequestOptions;
1184}
1185
1186export type TransportOptions =
1187 | StdioOptions
1188 | WebSocketOptions
1189 | SSEOptions
1190 | StreamableHTTPOptions;
1191
1192export interface MCPOptions {
1193 name: string;
1194 id: string;
1195 transport: TransportOptions;
1196 faviconUrl?: string;
1197 timeout?: number;
1198}
1199
1200export type MCPConnectionStatus =
1201 | "connecting"
1202 | "connected"
1203 | "error"
1204 | "not-connected";
1205
1206export type MCPPromptArgs = {
1207 name: string;
1208 description?: string;
1209 required?: boolean;
1210}[];
1211
1212export interface MCPPrompt {
1213 name: string;
1214 description?: string;
1215 arguments?: MCPPromptArgs;
1216}
1217
1218// Leaving here to ideate on
1219// export type ContinueConfigSource = "local-yaml" | "local-json" | "hub-assistant" | "hub"
1220
1221// https://modelcontextprotocol.io/docs/concepts/resources#direct-resources
1222export interface MCPResource {
1223 name: string;
1224 uri: string;
1225 description?: string;
1226 mimeType?: string;
1227}
1228
1229// https://modelcontextprotocol.io/docs/concepts/resources#resource-templates
1230export interface MCPResourceTemplate {
1231 uriTemplate: string;
1232 name: string;
1233 description?: string;
1234 mimeType?: string;
1235}
1236
1237export interface MCPTool {
1238 name: string;
1239 description?: string;
1240 inputSchema: {
1241 type: "object";
1242 properties?: Record<string, any>;
1243 };
1244}
1245
1246export interface MCPServerStatus extends MCPOptions {
1247 status: MCPConnectionStatus;
1248 errors: string[];
1249
1250 prompts: MCPPrompt[];
1251 tools: MCPTool[];
1252 resources: MCPResource[];
1253 resourceTemplates: MCPResourceTemplate[];
1254}
1255
1256export interface ContinueUIConfig {
1257 codeBlockToolbarPosition?: "top" | "bottom";
1258 fontSize?: number;
1259 displayRawMarkdown?: boolean;
1260 showChatScrollbar?: boolean;
1261 codeWrap?: boolean;
1262 showSessionTabs?: boolean;
1263 autoAcceptEditToolDiffs?: boolean;
1264 logEditingData?: boolean;
1265}
1266
1267export interface ContextMenuConfig {
1268 comment?: string;
1269 docstring?: string;
1270 fix?: string;
1271 optimize?: string;
1272 fixGrammar?: string;
1273}
1274
1275export interface ExperimentalModelRoles {
1276 repoMapFileSelection?: string;
1277 inlineEdit?: string;
1278 applyCodeBlock?: string;
1279}
1280
1281export interface ExperimentalMCPOptions {
1282 transport: TransportOptions;
1283 faviconUrl?: string;
1284 timeout?: number;
1285}
1286
1287export type ApplyStateStatus =
1288 | "not-started" // Apply state created but not necessarily streaming
1289 | "streaming" // Changes are being applied to the file
1290 | "done" // All changes have been applied, awaiting user to accept/reject
1291 | "closed"; // All changes have been applied. Note that for new files, we immediately set the status to "closed"
1292
1293export interface ApplyState {
1294 streamId: string;
1295 status?: ApplyStateStatus;
1296 numDiffs?: number;
1297 filepath?: string;
1298 fileContent?: string;
1299 toolCallId?: string;
1300}
1301
1302export interface StreamDiffLinesPayload {
1303 prefix: string;
1304 highlighted: string;
1305 suffix: string;
1306 input: string;
1307 language: string | undefined;
1308 modelTitle: string | undefined;
1309 includeRulesInSystemMessage: boolean;
1310 fileUri?: string;
1311}
1312
1313export interface HighlightedCodePayload {
1314 rangeInFileWithContents: RangeInFileWithContents;
1315 prompt?: string;
1316 shouldRun?: boolean;
1317}
1318
1319export interface AcceptOrRejectDiffPayload {
1320 filepath?: string;
1321 streamId?: string;
1322}
1323
1324export interface ShowFilePayload {
1325 filepath: string;
1326}
1327
1328export interface ApplyToFilePayload {
1329 streamId: string;
1330 filepath?: string;
1331 text: string;
1332 toolCallId?: string;
1333 isSearchAndReplace?: boolean;
1334}
1335
1336export interface RangeInFileWithContents {
1337 filepath: string;
1338 range: {
1339 start: { line: number; character: number };
1340 end: { line: number; character: number };
1341 };
1342 contents: string;
1343}
1344
1345export interface RangeInFileWithNextEditInfo {
1346 filepath: string;
1347 range: Range;
1348 fileContents: string;
1349 editText: string;
1350 afterCursorPos: Position;
1351 beforeCursorPos: Position;
1352 workspaceDir: string;
1353}
1354
1355export type SetCodeToEditPayload = RangeInFileWithContents | FileWithContents;
1356
1357/**
1358 * Represents the configuration for a quick action in the Code Lens.
1359 * Quick actions are custom commands that can be added to function and class declarations.
1360 */
1361export interface QuickActionConfig {
1362 /**
1363 * The title of the quick action that will display in the Code Lens.
1364 */
1365 title: string;
1366
1367 /**
1368 * The prompt that will be sent to the model when the quick action is invoked,
1369 * with the function or class body concatenated.
1370 */
1371 prompt: string;
1372
1373 /**
1374 * If `true`, the result of the quick action will be sent to the chat panel.
1375 * If `false`, the streamed result will be inserted into the document.
1376 *
1377 * Defaults to `false`.
1378 */
1379 sendToChat: boolean;
1380}
1381
1382export type DefaultContextProvider = ContextProviderWithParams & {
1383 query?: string;
1384};
1385
1386export interface ExperimentalConfig {
1387 contextMenuPrompts?: ContextMenuConfig;
1388 modelRoles?: ExperimentalModelRoles;
1389 defaultContext?: DefaultContextProvider[];
1390 promptPath?: string;
1391 enableExperimentalTools?: boolean;
1392
1393 /**
1394 * Quick actions are a way to add custom commands to the Code Lens of
1395 * function and class declarations.
1396 */
1397 quickActions?: QuickActionConfig[];
1398
1399 /**
1400 * Automatically read LLM chat responses aloud using system TTS models
1401 */
1402 readResponseTTS?: boolean;
1403
1404 /**
1405 * If set to true, we will attempt to pull down and install an instance of Chromium
1406 * that is compatible with the current version of Puppeteer.
1407 * This is needed to crawl a large number of documentation sites that are dynamically rendered.
1408 */
1409 useChromiumForDocsCrawling?: boolean;
1410 modelContextProtocolServers?: ExperimentalMCPOptions[];
1411
1412 /**
1413 * If enabled, will add the current file as context.
1414 */
1415 useCurrentFileAsContext?: boolean;
1416
1417 /**
1418 * If enabled, will save data on the user's editing processes
1419 */
1420 logEditingData?: boolean;
1421
1422 /**
1423 * If enabled, will enable next edit in place of autocomplete
1424 */
1425 optInNextEditFeature?: boolean;
1426
1427 /**
1428 * If enabled, @codebase will only use tool calling
1429 * instead of embeddings, FTS, recently edited files, etc.
1430 */
1431 codebaseToolCallingOnly?: boolean;
1432}
1433
1434export interface AnalyticsConfig {
1435 provider: string;
1436 url?: string;
1437 clientKey?: string;
1438}
1439
1440export interface JSONModelDescription {
1441 title: string;
1442 provider: string;
1443 underlyingProviderName: string;
1444 model: string;
1445 apiKey?: string;
1446 apiBase?: string;
1447
1448 contextLength?: number;
1449 maxStopWords?: number;
1450 template?: TemplateType;
1451 completionOptions?: BaseCompletionOptions;
1452 systemMessage?: string;
1453 requestOptions?: RequestOptions;
1454 cacheBehavior?: CacheBehavior;
1455
1456 region?: string;
1457 profile?: string;
1458 modelArn?: string;
1459 apiType?: "openai" | "azure";
1460 apiVersion?: string;
1461 deployment?: string;
1462 projectId?: string;
1463 accountId?: string;
1464 aiGatewaySlug?: string;
1465 useLegacyCompletionsEndpoint?: boolean;
1466 deploymentId?: string;
1467}
1468
1469// config.json
1470export interface SerializedContinueConfig {
1471 env?: string[];
1472 allowAnonymousTelemetry?: boolean;
1473 models: JSONModelDescription[];
1474 systemMessage?: string;
1475 completionOptions?: BaseCompletionOptions;
1476 requestOptions?: RequestOptions;
1477 slashCommands?: SlashCommandDescription[];
1478 customCommands?: CustomCommand[];
1479 contextProviders?: ContextProviderWithParams[];
1480 disableIndexing?: boolean;
1481 disableSessionTitles?: boolean;
1482 userToken?: string;
1483 embeddingsProvider?: EmbeddingsProviderDescription;
1484 tabAutocompleteModel?: JSONModelDescription | JSONModelDescription[];
1485 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1486 ui?: ContinueUIConfig;
1487 reranker?: RerankerDescription;
1488 experimental?: ExperimentalConfig;
1489 analytics?: AnalyticsConfig;
1490 docs?: SiteIndexingConfig[];
1491 data?: DataDestination[];
1492}
1493
1494export type ConfigMergeType = "merge" | "overwrite";
1495
1496export type ContinueRcJson = Partial<SerializedContinueConfig> & {
1497 mergeBehavior: ConfigMergeType;
1498};
1499
1500// config.ts - give users simplified interfaces
1501export interface Config {
1502 /** 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 */
1503 allowAnonymousTelemetry?: boolean;
1504 /** Each entry in this array will originally be a JSONModelDescription, the same object from your config.json, but you may add CustomLLMs.
1505 * 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).
1506 * Continue will do the rest of the work to construct prompt templates, handle context items, prune context, etc.
1507 */
1508 models: (CustomLLM | JSONModelDescription)[];
1509 /** A system message to be followed by all of your models */
1510 systemMessage?: string;
1511 /** The default completion options for all models */
1512 completionOptions?: BaseCompletionOptions;
1513 /** Request options that will be applied to all models and context providers */
1514 requestOptions?: RequestOptions;
1515 /** The list of slash commands that will be available in the sidebar */
1516 slashCommands?: (SlashCommand | SlashCommandWithSource)[];
1517 /** Each entry in this array will originally be a ContextProviderWithParams, the same object from your config.json, but you may add CustomContextProviders.
1518 * A CustomContextProvider requires you only to define a title and getContextItems function. When you type '@title <query>', Continue will call `getContextItems(query)`.
1519 */
1520 contextProviders?: (CustomContextProvider | ContextProviderWithParams)[];
1521 /** If set to true, Continue will not index your codebase for retrieval */
1522 disableIndexing?: boolean;
1523 /** If set to true, Continue will not make extra requests to the LLM to generate a summary title of each session. */
1524 disableSessionTitles?: boolean;
1525 /** An optional token to identify a user. Not used by Continue unless you write custom coniguration that requires such a token */
1526 userToken?: string;
1527 /** The provider used to calculate embeddings. If left empty, Continue will use transformers.js to calculate the embeddings with all-MiniLM-L6-v2 */
1528 embeddingsProvider?: EmbeddingsProviderDescription | ILLM;
1529 /** The model that Continue will use for tab autocompletions. */
1530 tabAutocompleteModel?:
1531 | CustomLLM
1532 | JSONModelDescription
1533 | (CustomLLM | JSONModelDescription)[];
1534 /** Options for tab autocomplete */
1535 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1536 /** UI styles customization */
1537 ui?: ContinueUIConfig;
1538 /** Options for the reranker */
1539 reranker?: RerankerDescription | ILLM;
1540 /** Experimental configuration */
1541 experimental?: ExperimentalConfig;
1542 /** Analytics configuration */
1543 analytics?: AnalyticsConfig;
1544 data?: DataDestination[];
1545}
1546
1547// in the actual Continue source code
1548export interface ContinueConfig {
1549 allowAnonymousTelemetry?: boolean;
1550 // systemMessage?: string;
1551 completionOptions?: BaseCompletionOptions;
1552 requestOptions?: RequestOptions;
1553 slashCommands: SlashCommandWithSource[];
1554 contextProviders: IContextProvider[];
1555 disableSessionTitles?: boolean;
1556 disableIndexing?: boolean;
1557 userToken?: string;
1558 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1559 ui?: ContinueUIConfig;
1560 experimental?: ExperimentalConfig;
1561 analytics?: AnalyticsConfig;
1562 docs?: SiteIndexingConfig[];
1563 tools: Tool[];
1564 mcpServerStatuses: MCPServerStatus[];
1565 rules: RuleWithSource[];
1566 modelsByRole: Record<ModelRole, ILLM[]>;
1567 selectedModelByRole: Record<ModelRole, ILLM | null>;
1568 data?: DataDestination[];
1569}
1570
1571export interface BrowserSerializedContinueConfig {
1572 allowAnonymousTelemetry?: boolean;
1573 // systemMessage?: string;
1574 completionOptions?: BaseCompletionOptions;
1575 requestOptions?: RequestOptions;
1576 slashCommands: SlashCommandDescWithSource[];
1577 contextProviders: ContextProviderDescription[];
1578 disableIndexing?: boolean;
1579 disableSessionTitles?: boolean;
1580 userToken?: string;
1581 ui?: ContinueUIConfig;
1582 experimental?: ExperimentalConfig;
1583 analytics?: AnalyticsConfig;
1584 docs?: SiteIndexingConfig[];
1585 tools: Tool[];
1586 mcpServerStatuses: MCPServerStatus[];
1587 rules: RuleWithSource[];
1588 usePlatform: boolean;
1589 tabAutocompleteOptions?: Partial<TabAutocompleteOptions>;
1590 modelsByRole: Record<ModelRole, ModelDescription[]>;
1591 selectedModelByRole: Record<ModelRole, ModelDescription | null>;
1592}
1593
1594// DOCS SUGGESTIONS AND PACKAGE INFO
1595export interface FilePathAndName {
1596 path: string;
1597 name: string;
1598}
1599
1600export interface PackageFilePathAndName extends FilePathAndName {
1601 packageRegistry: string; // e.g. npm, pypi
1602}
1603
1604export type ParsedPackageInfo = {
1605 name: string;
1606 packageFile: PackageFilePathAndName;
1607 language: string;
1608 version: string;
1609};
1610
1611export type PackageDetails = {
1612 docsLink?: string;
1613 docsLinkWarning?: string;
1614 title?: string;
1615 description?: string;
1616 repo?: string;
1617 license?: string;
1618};
1619
1620export type PackageDetailsSuccess = PackageDetails & {
1621 docsLink: string;
1622};
1623
1624export type PackageDocsResult = {
1625 packageInfo: ParsedPackageInfo;
1626} & (
1627 | { error: string; details?: never }
1628 | { details: PackageDetailsSuccess; error?: never }
1629);
1630
1631export interface TerminalOptions {
1632 reuseTerminal?: boolean;
1633 terminalName?: string;
1634 waitForCompletion?: boolean;
1635}
1636
1637export type RuleSource =
1638 | "default-chat"
1639 | "default-agent"
1640 | "model-chat-options"
1641 | "model-agent-options"
1642 | "rules-block"
1643 | "json-systemMessage"
1644 | ".continuerules";
1645
1646export interface RuleWithSource {
1647 name?: string;
1648 slug?: string;
1649 source: RuleSource;
1650 globs?: string | string[];
1651 regex?: string | string[];
1652 rule: string;
1653 description?: string;
1654 ruleFile?: string;
1655 alwaysApply?: boolean;
1656}
1657export interface CompleteOnboardingPayload {
1658 mode: OnboardingModes;
1659 provider?: string;
1660 apiKey?: string;
1661}