MCPcopy
hub / github.com/CodebuffAI/codebuff / ensureZodSchema

Function ensureZodSchema

packages/agent-runtime/src/tools/prompts.ts:24–36  ·  view source on GitHub ↗
(
  schema: z.ZodType | Record<string, unknown>,
)

Source from the content-addressed store, hash-verified

22 * (from SDK custom tools that were serialized), converts it to Zod.
23 */
24export function ensureZodSchema(
25 schema: z.ZodType | Record<string, unknown>,
26): z.ZodType {
27 // Check if it's already a Zod schema by looking for the safeParse method
28 if (
29 schema &&
30 typeof (schema as { safeParse?: unknown }).safeParse === 'function'
31 ) {
32 return schema as z.ZodType
33 }
34 // JSON Schema object - convert to Zod
35 return convertJsonSchemaToZod(schema as Record<string, unknown>)
36}
37
38function ensureJsonSchemaCompatible(schema: z.ZodType): z.ZodType {
39 try {

Callers 5

parseRawCustomToolCallFunction · 0.90
fullToolListFunction · 0.85
getShortToolInstructionsFunction · 0.85
getToolSetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected