| 1 | import { z } from "zod"; |
| 2 | |
| 3 | export const completionOptionsSchema = z.object({ |
| 4 | temperature: z.number().optional(), |
| 5 | topP: z.number().optional(), |
| 6 | topK: z.number().optional(), |
| 7 | minP: z.number().optional(), |
| 8 | presencePenalty: z.number().optional(), |
| 9 | frequencyPenalty: z.number().optional(), |
| 10 | mirostat: z.number().optional(), |
| 11 | stop: z.array(z.string()).optional(), |
| 12 | maxTokens: z.number().optional(), |
| 13 | numThreads: z.number().optional(), |
| 14 | useMmap: z.boolean().optional(), |
| 15 | keepAlive: z.number().optional(), |
| 16 | numGpu: z.number().optional(), |
| 17 | raw: z.boolean().optional(), |
| 18 | stream: z.boolean().optional(), |
| 19 | }); |
| 20 | export type CompletionOptions = z.infer<typeof completionOptionsSchema>; |
| 21 | |
| 22 | export const clientCertificateOptionsSchema = z.object({ |
| 23 | cert: z.string(), |
| 24 | key: z.string(), |
| 25 | passphrase: z.string().optional(), |
| 26 | }); |
| 27 | export type ClientCertificateOptions = z.infer< |
| 28 | typeof clientCertificateOptionsSchema |
| 29 | >; |
| 30 | |
| 31 | export const requestOptionsSchema = z.object({ |
| 32 | timeout: z.number().optional(), |
| 33 | verifySsl: z.boolean().optional(), |
| 34 | caBundlePath: z.union([z.string(), z.array(z.string())]).optional(), |
| 35 | proxy: z.string().optional(), |
| 36 | headers: z.record(z.string()).optional(), |
| 37 | extraBodyProperties: z.record(z.any()).optional(), |
| 38 | noProxy: z.array(z.string()).optional(), |
| 39 | clientCertificate: clientCertificateOptionsSchema.optional(), |
| 40 | }); |
| 41 | export type RequestOptions = z.infer<typeof requestOptionsSchema>; |
| 42 | |
| 43 | export const modelDescriptionSchema = z.object({ |
| 44 | title: z.string(), |
| 45 | provider: z.enum([ |
| 46 | "openai", |
| 47 | "anthropic", |
| 48 | "cohere", |
| 49 | "ollama", |
| 50 | "huggingface-tgi", |
| 51 | "huggingface-inference-api", |
| 52 | "replicate", |
| 53 | "gemini", |
| 54 | "mistral", |
| 55 | "bedrock", |
| 56 | "sagemaker", |
| 57 | "cloudflare", |
| 58 | "azure", |
| 59 | "ovhcloud", |
| 60 | "continue-proxy", |
| 61 | "nebius", |
| 62 | "scaleway", |
| 63 | "watsonx", |
| 64 | ]), |
| 65 | model: z.string(), |
| 66 | apiKey: z.string().optional(), |
| 67 | apiBase: z.string().optional(), |
| 68 | contextLength: z.number().optional(), |
| 69 | template: z |
| 70 | .enum([ |
| 71 | "llama2", |
| 72 | "alpaca", |
| 73 | "zephyr", |
| 74 | "phi2", |
| 75 | "phind", |
| 76 | "anthropic", |
| 77 | "chatml", |
| 78 | "none", |
| 79 | "openchat", |
| 80 | "deepseek", |
| 81 | "xwin-coder", |
| 82 | "neural-chat", |
| 83 | "codellama-70b", |
| 84 | "llava", |
| 85 | "gemma", |
| 86 | "llama3", |
| 87 | ]) |
| 88 | .optional(), |
| 89 | completionOptions: completionOptionsSchema.optional(), |
| 90 | systemMessage: z.string().optional(), |
| 91 | requestOptions: z |
| 92 | .object({ |
| 93 | timeout: z.number().optional(), |
| 94 | verifySsl: z.boolean().optional(), |
| 95 | caBundlePath: z.union([z.string(), z.array(z.string())]).optional(), |
| 96 | proxy: z.string().optional(), |
| 97 | headers: z.record(z.string()).optional(), |
| 98 | extraBodyProperties: z.record(z.any()).optional(), |
| 99 | noProxy: z.array(z.string()).optional(), |
| 100 | }) |
| 101 | .optional(), |
| 102 | promptTemplates: z.record(z.string()).optional(), |
| 103 | }); |
| 104 | export type ModelDescription = z.infer<typeof modelDescriptionSchema>; |
| 105 | |
| 106 | export const embeddingsProviderSchema = z.object({ |
| 107 | provider: z.enum([ |
| 108 | "transformers.js", |
| 109 | "ollama", |
| 110 | "openai", |
| 111 | "cohere", |
| 112 | "gemini", |
| 113 | "ovhcloud", |
| 114 | "continue-proxy", |
| 115 | "nebius", |
| 116 | "scaleway", |
| 117 | "watsonx", |
| 118 | ]), |
| 119 | apiBase: z.string().optional(), |
| 120 | apiKey: z.string().optional(), |
| 121 | model: z.string().optional(), |
| 122 | deployment: z.string().optional(), |
| 123 | apiType: z.string().optional(), |
| 124 | apiVersion: z.string().optional(), |
| 125 | requestOptions: requestOptionsSchema.optional(), |
| 126 | }); |
| 127 | export type EmbeddingsProvider = z.infer<typeof embeddingsProviderSchema>; |
| 128 | |
| 129 | export const uiOptionsSchema = z.object({ |
| 130 | codeBlockToolbarPosition: z.enum(["top", "bottom"]).optional(), |
| 131 | fontSize: z.number().optional(), |
| 132 | displayRawMarkdown: z.boolean().optional(), |
| 133 | showChatScrollbar: z.boolean().optional(), |
| 134 | codeWrap: z.boolean().optional(), |
| 135 | }); |
| 136 | export type UiOptions = z.infer<typeof uiOptionsSchema>; |
| 137 | |
| 138 | export const tabAutocompleteOptionsSchema = z.object({ |
| 139 | disable: z.boolean(), |
| 140 | maxPromptTokens: z.number(), |
| 141 | debounceDelay: z.number(), |
| 142 | maxSuffixPercentage: z.number(), |
| 143 | prefixPercentage: z.number(), |
| 144 | transform: z.boolean().optional(), |
| 145 | template: z.string().optional(), |
| 146 | multilineCompletions: z.enum(["always", "never", "auto"]), |
| 147 | slidingWindowPrefixPercentage: z.number(), |
| 148 | slidingWindowSize: z.number(), |
| 149 | useCache: z.boolean(), |
| 150 | onlyMyCode: z.boolean(), |
| 151 | useRecentlyEdited: z.boolean(), |
| 152 | disableInFiles: z.array(z.string()).optional(), |
| 153 | useImports: z.boolean().optional(), |
| 154 | // Experimental options: true = enabled, false = disabled, number = enabled w priority |
| 155 | experimental_includeClipboard: z.union([z.boolean(), z.number()]).optional(), |
| 156 | experimental_includeRecentlyVisitedRanges: z |
| 157 | .union([z.boolean(), z.number()]) |
| 158 | .optional(), |
| 159 | experimental_includeRecentlyEditedRanges: z |
| 160 | .union([z.boolean(), z.number()]) |
| 161 | .optional(), |
| 162 | experimental_includeDiff: z.union([z.boolean(), z.number()]).optional(), |
| 163 | experimental_enableStaticContextualization: z.boolean().optional(), |
| 164 | }); |
| 165 | export type TabAutocompleteOptions = z.infer< |
| 166 | typeof tabAutocompleteOptionsSchema |
| 167 | >; |
| 168 | |
| 169 | export const slashCommandSchema = z.object({ |
| 170 | name: z.string(), |
| 171 | description: z.string(), |
| 172 | params: z.record(z.any()).optional(), |
| 173 | }); |
| 174 | export type SlashCommand = z.infer<typeof slashCommandSchema>; |
| 175 | |
| 176 | export const customCommandSchema = z.object({ |
| 177 | name: z.string(), |
| 178 | description: z.string(), |
| 179 | params: z.record(z.any()).optional(), |
| 180 | }); |
| 181 | export type CustomCommand = z.infer<typeof customCommandSchema>; |
| 182 | |
| 183 | export const contextProviderSchema = z.object({ |
| 184 | name: z.string(), |
| 185 | params: z.record(z.string(), z.any()), |
| 186 | }); |
| 187 | export type ContextProvider = z.infer<typeof contextProviderSchema>; |
| 188 | |
| 189 | export const rerankerSchema = z.object({ |
| 190 | name: z.enum(["cohere", "voyage", "watsonx", "llm", "continue-proxy"]), |
| 191 | params: z.record(z.any()).optional(), |
| 192 | }); |
| 193 | export type Reranker = z.infer<typeof rerankerSchema>; |
| 194 | |
| 195 | export const analyticsSchema = z.object({ |
| 196 | provider: z.enum([ |
| 197 | "posthog", |
| 198 | "amplitude", |
| 199 | "segment", |
| 200 | "logstash", |
| 201 | "mixpanel", |
| 202 | "splunk", |
| 203 | "datadog", |
| 204 | "continue-proxy", |
| 205 | ]), |
| 206 | url: z.string().optional(), |
| 207 | clientKey: z.string().optional(), |
| 208 | }); |
| 209 | export type Analytics = z.infer<typeof analyticsSchema>; |
| 210 | |
| 211 | export const devDataSchema = z.object({ |
| 212 | url: z.string().optional(), |
| 213 | }); |
| 214 | export type DevData = z.infer<typeof devDataSchema>; |
| 215 | |
| 216 | export const siteIndexingConfigSchema = z.object({ |
| 217 | startUrl: z.string(), |
| 218 | rootUrl: z.string().optional(), |
| 219 | title: z.string(), |
| 220 | maxDepth: z.number().optional(), |
| 221 | faviconUrl: z.string().optional(), |
| 222 | useLocalCrawling: z.boolean().optional(), |
| 223 | sourceFile: z.string().optional(), |
| 224 | }); |
| 225 | |
| 226 | export const controlPlaneConfigSchema = z.object({ |
| 227 | useContinueForTeamsProxy: z.boolean().optional(), |
| 228 | proxyUrl: z.string().optional(), |
| 229 | }); |
| 230 | |
| 231 | export const configJsonSchema = z.object({ |
| 232 | models: z.array(modelDescriptionSchema), |
| 233 | tabAutocompleteModel: modelDescriptionSchema.optional(), |
| 234 | embeddingsProvider: embeddingsProviderSchema.optional(), |
| 235 | reranker: rerankerSchema.optional(), |
| 236 | analytics: analyticsSchema, |
| 237 | devData: devDataSchema, |
| 238 | allowAnonymousTelemetry: z.boolean().optional(), |
| 239 | systemMessage: z.string().optional(), |
| 240 | completionOptions: completionOptionsSchema.optional(), |
| 241 | requestOptions: requestOptionsSchema.optional(), |
| 242 | slashCommands: z.array(slashCommandSchema).optional(), |
| 243 | customCommands: z.array(customCommandSchema).optional(), |
| 244 | contextProviders: z.array(contextProviderSchema).optional(), |
| 245 | disableIndexing: z.boolean().optional(), |
| 246 | tabAutocompleteOptions: tabAutocompleteOptionsSchema.optional(), |
| 247 | ui: uiOptionsSchema.optional(), |
| 248 | docs: z.array(siteIndexingConfigSchema).optional(), |
| 249 | controlPlane: controlPlaneConfigSchema.optional(), |
| 250 | }); |
| 251 | export type ConfigJson = z.infer<typeof configJsonSchema>; |