diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index f2fefbb39..022ca8b53 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -5,6 +5,7 @@ import { ConfigResult, ConfigValidationError, FQSN, + isAssistantUnrolledNonNullable, ModelRole, PlatformClient, RegistryClient, @@ -92,7 +93,15 @@ async function loadConfigYaml( renderSecrets: true, }, )); - const errors = validateConfigYaml(config); + + const errors = isAssistantUnrolledNonNullable(config) + ? validateConfigYaml(config) + : [ + { + fatal: true, + message: "Assistant includes blocks that don't exist", + }, + ]; if (errors?.some((error) => error.fatal)) { return { @@ -122,29 +131,13 @@ async function configYamlToContinueConfig( allowFreeTrial: boolean = true, ): Promise<{ config: ContinueConfig; errors: ConfigValidationError[] }> { const localErrors: ConfigValidationError[] = []; + const continueConfig: ContinueConfig = { slashCommands: [], models: [], tools: [...allTools], mcpServerStatuses: [], systemMessage: config.rules?.join("\n"), - experimental: { - modelContextProtocolServers: config.mcpServers?.map((mcpServer) => ({ - transport: { - type: "stdio", - command: mcpServer.command, - args: mcpServer.args ?? [], - env: mcpServer.env, - }, - })), - }, - docs: config.docs?.map((doc) => ({ - title: doc.name, - startUrl: doc.startUrl, - rootUrl: doc.rootUrl, - faviconUrl: doc.faviconUrl, - })), - rules: config.rules, contextProviders: [], modelsByRole: { chat: [], @@ -164,7 +157,38 @@ async function configYamlToContinueConfig( rerank: null, summarize: null, }, - data: config.data, + }; + + // Right now, if there are any missing packages in the config, then we will just throw an error + if (!isAssistantUnrolledNonNullable(config)) { + return { + config: continueConfig, + errors: [ + { + message: "Found missing blocks in config.yaml", + fatal: true, + }, + ], + }; + } + + continueConfig.data = config.data; + continueConfig.rules = config.rules; + continueConfig.docs = config.docs?.map((doc) => ({ + title: doc.name, + startUrl: doc.startUrl, + rootUrl: doc.rootUrl, + faviconUrl: doc.faviconUrl, + })); + continueConfig.experimental = { + modelContextProtocolServers: config.mcpServers?.map((mcpServer) => ({ + transport: { + type: "stdio", + command: mcpServer.command, + args: mcpServer.args ?? [], + env: mcpServer.env, + }, + })), }; // Prompt files - diff --git a/core/package-lock.json b/core/package-lock.json index 259750d62..043f6b2bd 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -13,7 +13,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "1.0.67", + "@continuedev/config-yaml": "^1.0.75", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", @@ -2974,10 +2974,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.67", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.67.tgz", - "integrity": "sha512-RbJXSH2Z9XmaN1h9Dm0Qfru7UeAdCAEWMiEgJ9A2FGHysR9oxbQDqptk1Y61oDSpYeX+lWsxkz/SFIc2PjNnKg==", - "license": "Apache-2.0", + "version": "1.0.75", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.75.tgz", + "integrity": "sha512-N2YlSBiuWRlTn+6ERuueUoEAzMM3J1npQAYzJ32p5OAaggEYMUDNqAfqixvfr8MT/9M/JSYZ7buv1RSiM0qSig==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", diff --git a/core/package.json b/core/package.json index 43604af98..d8995be86 100644 --- a/core/package.json +++ b/core/package.json @@ -47,7 +47,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.758.0", "@aws-sdk/credential-providers": "^3.758.0", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "1.0.67", + "@continuedev/config-yaml": "^1.0.75", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.8", "@continuedev/openai-adapters": "^1.0.18", diff --git a/packages/config-yaml/package.json b/packages/config-yaml/package.json index bf763c1e6..7069105af 100644 --- a/packages/config-yaml/package.json +++ b/packages/config-yaml/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.69", + "version": "1.0.75", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/config-yaml/src/schemas/index.ts b/packages/config-yaml/src/schemas/index.ts index 96f25b73b..ba6aa5e79 100644 --- a/packages/config-yaml/src/schemas/index.ts +++ b/packages/config-yaml/src/schemas/index.ts @@ -89,6 +89,31 @@ export const assistantUnrolledSchema = baseConfigYamlSchema.extend({ export type AssistantUnrolled = z.infer; +export const assistantUnrolledSchemaNonNullable = baseConfigYamlSchema.extend({ + models: z.array(modelSchema).optional(), + context: z.array(contextSchema).optional(), + data: z.array(dataSchema).optional(), + mcpServers: z.array(mcpServerSchema).optional(), + rules: z.array(z.string()).optional(), + prompts: z.array(promptSchema).optional(), + docs: z.array(docSchema).optional(), +}); + +export type AssistantUnrolledNonNullable = z.infer< + typeof assistantUnrolledSchemaNonNullable +>; + +export const isAssistantUnrolledNonNullable = ( + a: AssistantUnrolled, +): a is AssistantUnrolledNonNullable => + (!a.models || a.models.every((m) => m !== null)) && + (!a.context || a.context.every((c) => c !== null)) && + (!a.data || a.data.every((d) => d !== null)) && + (!a.mcpServers || a.mcpServers.every((s) => s !== null)) && + (!a.rules || a.rules.every((r) => r !== null)) && + (!a.prompts || a.prompts.every((p) => p !== null)) && + (!a.docs || a.docs.every((d) => d !== null)); + export const blockSchema = baseConfigYamlSchema.and( z.union([ z.object({ models: z.array(modelSchema).length(1) }),