MCPcopy Create free account
hub / github.com/Effect-TS/effect / getSchemas

Function getSchemas

packages/ai/ai/src/Toolkit.ts:281–299  ·  view source on GitHub ↗
(tool: Tool.Any)

Source from the content-addressed store, hash-verified

279 readonly encodeResult: (u: unknown) => Effect.Effect<unknown, ParseError>
280 }>()
281 const getSchemas = (tool: Tool.Any) => {
282 let schemas = schemasCache.get(tool)
283 if (Predicate.isUndefined(schemas)) {
284 const handler = context.unsafeMap.get(tool.id)! as Tool.Handler<any>
285 const decodeParameters = Schema.decodeUnknown(tool.parametersSchema as Schema.Schema.Any) as any
286 const resultSchema = Schema.Union(tool.successSchema, tool.failureSchema)
287 const validateResult = Schema.validate(resultSchema) as any
288 const encodeResult = Schema.encodeUnknown(resultSchema) as any
289 schemas = {
290 context: handler.context,
291 handler: handler.handler,
292 decodeParameters,
293 validateResult,
294 encodeResult
295 }
296 schemasCache.set(tool, schemas)
297 }
298 return schemas
299 }
300 const handle = Effect.fn("Toolkit.handle", { captureStackTrace: false })(
301 function*(name: string, params: unknown) {
302 yield* Effect.annotateCurrentSpan({ tool: name, parameters: params })

Callers 1

commitFunction · 0.70

Calls 3

validateMethod · 0.80
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected