resolve type errors
This commit is contained in:
parent
caf6cb02e4
commit
cfb7079494
5 changed files with 74 additions and 26 deletions
|
|
@ -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 -
|
||||
|
|
|
|||
9
core/package-lock.json
generated
9
core/package-lock.json
generated
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -89,6 +89,31 @@ export const assistantUnrolledSchema = baseConfigYamlSchema.extend({
|
|||
|
||||
export type AssistantUnrolled = z.infer<typeof assistantUnrolledSchema>;
|
||||
|
||||
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) }),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue