11import { transformJSONSchema } from '../..//lib/transform-json-schema' ;
2- import type { infer as zodInfer , ZodType } from 'zod' ;
32import * as z from 'zod/v4' ;
43import { AnthropicError } from '../../core/error' ;
54import { AutoParseableBetaOutputFormat } from '../../lib/beta-parser' ;
@@ -14,9 +13,9 @@ import { BetaToolResultContentBlockParam } from '../../resources/beta';
1413 * This can be passed directly to the `.create()` method but will not
1514 * result in any automatic parsing, you'll have to parse the response yourself.
1615 */
17- export function betaZodOutputFormat < ZodInput extends ZodType > (
16+ export function betaZodOutputFormat < ZodInput extends z . ZodType > (
1817 zodObject : ZodInput ,
19- ) : AutoParseableBetaOutputFormat < zodInfer < ZodInput > > {
18+ ) : AutoParseableBetaOutputFormat < z . infer < ZodInput > > {
2019 let jsonSchema = z . toJSONSchema ( zodObject , { reused : 'ref' } ) ;
2120
2221 jsonSchema = transformJSONSchema ( jsonSchema ) ;
@@ -46,15 +45,15 @@ export function betaZodOutputFormat<ZodInput extends ZodType>(
4645 * converted into JSON Schema when passed to the API. The provided function's
4746 * input arguments will also be validated against the provided schema.
4847 */
49- export function betaZodTool < InputSchema extends ZodType > ( options : {
48+ export function betaZodTool < InputSchema extends z . ZodType > ( options : {
5049 name : string ;
5150 inputSchema : InputSchema ;
5251 description : string ;
5352 run : (
54- args : zodInfer < InputSchema > ,
53+ args : z . infer < InputSchema > ,
5554 context ?: BetaToolRunContext ,
5655 ) => Promisable < string | Array < BetaToolResultContentBlockParam > > ;
57- } ) : BetaRunnableTool < zodInfer < InputSchema > > {
56+ } ) : BetaRunnableTool < z . infer < InputSchema > > {
5857 const jsonSchema = z . toJSONSchema ( options . inputSchema , { reused : 'ref' } ) ;
5958
6059 if ( jsonSchema . type !== 'object' ) {
@@ -70,6 +69,6 @@ export function betaZodTool<InputSchema extends ZodType>(options: {
7069 input_schema : objectSchema ,
7170 description : options . description ,
7271 run : options . run ,
73- parse : ( args : unknown ) => options . inputSchema . parse ( args ) as zodInfer < InputSchema > ,
72+ parse : ( args : unknown ) => options . inputSchema . parse ( args ) as z . infer < InputSchema > ,
7473 } ;
7574}
0 commit comments