feat: remove tools from schema
This commit is contained in:
parent
71eb67d2ab
commit
5bbda4f115
7 changed files with 20 additions and 27 deletions
4
packages/config-yaml/package-lock.json
generated
4
packages/config-yaml/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@continuedev/config-yaml",
|
||||
"version": "1.0.51",
|
||||
"version": "1.0.52",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@continuedev/config-yaml",
|
||||
"version": "1.0.51",
|
||||
"version": "1.0.52",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ export * from "./load/clientRender.js";
|
|||
export * from "./load/getBlockType.js";
|
||||
export * from "./load/merge.js";
|
||||
export * from "./load/proxySecretResolution.js";
|
||||
export * from "./load/typeGuards.js";
|
||||
export * from "./load/unroll.js";
|
||||
export * from "./schemas/data/index.js";
|
||||
export * from "./schemas/index.js";
|
||||
|
|
|
|||
|
|
@ -4,20 +4,18 @@ export type BlockType =
|
|||
| "models"
|
||||
| "context"
|
||||
| "docs"
|
||||
| "tools"
|
||||
| "mcpServers"
|
||||
| "data"
|
||||
| "rules"
|
||||
| "prompts";
|
||||
export function getBlockType(block: ConfigYaml): BlockType {
|
||||
|
||||
export function getBlockType(block: ConfigYaml): BlockType | undefined {
|
||||
if (block.context?.length) {
|
||||
return "context";
|
||||
} else if (block.models?.length) {
|
||||
return "models";
|
||||
} else if (block.docs?.length) {
|
||||
return "docs";
|
||||
} else if (block.tools?.length) {
|
||||
return "tools";
|
||||
} else if (block.mcpServers?.length) {
|
||||
return "mcpServers";
|
||||
} else if (block.data?.length) {
|
||||
|
|
@ -27,6 +25,6 @@ export function getBlockType(block: ConfigYaml): BlockType {
|
|||
} else if (block.prompts?.length) {
|
||||
return "prompts";
|
||||
} else {
|
||||
throw new Error("Unknown block type");
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ export function mergePackages(
|
|||
models: [...(current.models ?? []), ...(incoming.models ?? [])],
|
||||
context: [...(current.context ?? []), ...(incoming.context ?? [])],
|
||||
data: [...(current.data ?? []), ...(incoming.data ?? [])],
|
||||
tools: [...(current.tools ?? []), ...(incoming.tools ?? [])],
|
||||
mcpServers: [...(current.mcpServers ?? []), ...(incoming.mcpServers ?? [])],
|
||||
rules: [...(current.rules ?? []), ...(incoming.rules ?? [])],
|
||||
prompts: [...(current.prompts ?? []), ...(incoming.prompts ?? [])],
|
||||
|
|
|
|||
13
packages/config-yaml/src/load/typeGuards.ts
Normal file
13
packages/config-yaml/src/load/typeGuards.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import * as z from "zod";
|
||||
import { blockItemWrapperSchema } from "../schemas/index.js";
|
||||
|
||||
export const isBlockItemWrapper = (
|
||||
block: unknown,
|
||||
): block is z.infer<
|
||||
ReturnType<typeof blockItemWrapperSchema<z.AnyZodObject>>
|
||||
> => {
|
||||
const baseSchema = z.object({});
|
||||
const schema = blockItemWrapperSchema(baseSchema);
|
||||
|
||||
return schema.safeParse(block).success;
|
||||
};
|
||||
|
|
@ -273,15 +273,7 @@ export async function unrollBlocks(
|
|||
const sections: (keyof Omit<
|
||||
ConfigYaml,
|
||||
"name" | "version" | "rules" | "schema"
|
||||
>)[] = [
|
||||
"models",
|
||||
"context",
|
||||
"data",
|
||||
"tools",
|
||||
"mcpServers",
|
||||
"prompts",
|
||||
"docs",
|
||||
];
|
||||
>)[] = ["models", "context", "data", "mcpServers", "prompts", "docs"];
|
||||
|
||||
// For each section, replace "uses/with" blocks with the real thing
|
||||
for (const section of sections) {
|
||||
|
|
|
|||
|
|
@ -7,13 +7,6 @@ export const contextSchema = z.object({
|
|||
params: z.any().optional(),
|
||||
});
|
||||
|
||||
const toolSchema = z.object({
|
||||
name: z.string(),
|
||||
description: z.string(),
|
||||
run: z.string(),
|
||||
params: z.any().optional(),
|
||||
});
|
||||
|
||||
const mcpServerSchema = z.object({
|
||||
name: z.string(),
|
||||
command: z.string(),
|
||||
|
|
@ -66,7 +59,6 @@ export const configYamlSchema = baseConfigYamlSchema.extend({
|
|||
.optional(),
|
||||
context: z.array(blockOrSchema(contextSchema)).optional(),
|
||||
data: z.array(blockOrSchema(dataSchema)).optional(),
|
||||
tools: z.array(blockOrSchema(toolSchema)).optional(),
|
||||
mcpServers: z.array(blockOrSchema(mcpServerSchema)).optional(),
|
||||
rules: z
|
||||
.array(
|
||||
|
|
@ -89,7 +81,6 @@ export const assistantUnrolledSchema = baseConfigYamlSchema.extend({
|
|||
models: z.array(modelSchema).optional(),
|
||||
context: z.array(contextSchema).optional(),
|
||||
data: z.array(dataSchema).optional(),
|
||||
tools: z.array(toolSchema).optional(),
|
||||
mcpServers: z.array(mcpServerSchema).optional(),
|
||||
rules: z.array(z.string()).optional(),
|
||||
prompts: z.array(promptSchema).optional(),
|
||||
|
|
@ -103,7 +94,6 @@ export const blockSchema = baseConfigYamlSchema.and(
|
|||
z.object({ models: z.array(modelSchema).length(1) }),
|
||||
z.object({ context: z.array(contextSchema).length(1) }),
|
||||
z.object({ data: z.array(dataSchema).length(1) }),
|
||||
z.object({ tools: z.array(toolSchema).length(1) }),
|
||||
z.object({ mcpServers: z.array(mcpServerSchema).length(1) }),
|
||||
z.object({ rules: z.array(z.string()).length(1) }),
|
||||
z.object({ prompts: z.array(promptSchema).length(1) }),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue