MCPcopy
hub / github.com/simstudioai/sim / ensureZodObject

Function ensureZodObject

apps/sim/app/api/tools/stagehand/utils.ts:108–121  ·  view source on GitHub ↗
(logger: Logger, schema: Record<string, any>)

Source from the content-addressed store, hash-verified

106
107// Helper function to ensure we have a ZodObject
108export function ensureZodObject(logger: Logger, schema: Record<string, any>): z.ZodObject<any> {
109 const zodSchema = jsonSchemaToZod(logger, schema)
110
111 // If not already an object type, wrap it in an object
112 if (schema.type !== 'object') {
113 logger.warn('Schema is not an object type, wrapping in an object', {
114 type: schema.type,
115 })
116 return z.object({ value: zodSchema })
117 }
118
119 // Safe cast since we know it's a ZodObject if type is 'object'
120 return zodSchema as z.ZodObject<any>
121}
122
123export function normalizeUrl(url: string): string {
124 // Normalize the URL - only add https:// if needed

Callers 2

route.tsFile · 0.90
route.tsFile · 0.90

Calls 2

jsonSchemaToZodFunction · 0.70
warnMethod · 0.65

Tested by

no test coverage detected