experimental batch tool (#2983)

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Baptiste Cavallo
2025-11-15 07:54:36 +01:00
committed by GitHub
parent 35c737ac68
commit 1056b36eae
5 changed files with 154 additions and 5 deletions

View File

@@ -29,6 +29,7 @@ export namespace Tool {
output: string
attachments?: MessageV2.FilePart[]
}>
formatValidationError?(error: z.ZodError): string
}>
}
@@ -45,7 +46,14 @@ export namespace Tool {
const toolInfo = init instanceof Function ? await init() : init
const execute = toolInfo.execute
toolInfo.execute = (args, ctx) => {
toolInfo.parameters.parse(args)
try {
toolInfo.parameters.parse(args)
} catch (error) {
if (error instanceof z.ZodError && toolInfo.formatValidationError) {
throw new Error(toolInfo.formatValidationError(error))
}
throw error
}
return execute(args, ctx)
}
return toolInfo