@@ -21,7 +21,7 @@ import {
2121import { WatchdogClient } from './WatchdogClient.js' ;
2222
2323const MS_PER_DAY = 24 * 60 * 60 * 1000 ;
24- const PARAM_BLOCKLIST = new Set ( [ 'uid' ] ) ;
24+ export const PARAM_BLOCKLIST = new Set ( [ 'uid' , 'reqid' , 'msgid '] ) ;
2525
2626const SUPPORTED_ZOD_TYPES = [
2727 'ZodString' ,
@@ -36,7 +36,7 @@ function isZodType(type: string): type is ZodType {
3636 return SUPPORTED_ZOD_TYPES . includes ( type as ZodType ) ;
3737}
3838
39- function getZodType ( zodType : zod . ZodTypeAny ) : ZodType {
39+ export function getZodType ( zodType : zod . ZodTypeAny ) : ZodType {
4040 const def = zodType . _def ;
4141 const typeName = def . typeName ;
4242
@@ -59,7 +59,7 @@ function getZodType(zodType: zod.ZodTypeAny): ZodType {
5959
6060type LoggedToolCallArgValue = string | number | boolean ;
6161
62- function transformName ( zodType : ZodType , name : string ) : string {
62+ export function transformArgName ( zodType : ZodType , name : string ) : string {
6363 if ( zodType === 'ZodString' ) {
6464 return `${ name } _length` ;
6565 } else if ( zodType === 'ZodArray' ) {
@@ -69,6 +69,22 @@ function transformName(zodType: ZodType, name: string): string {
6969 }
7070}
7171
72+ export function transformArgType ( zodType : ZodType ) : string {
73+ if ( zodType === 'ZodString' || zodType === 'ZodArray' ) {
74+ return 'number' ;
75+ }
76+ switch ( zodType ) {
77+ case 'ZodNumber' :
78+ return 'number' ;
79+ case 'ZodBoolean' :
80+ return 'boolean' ;
81+ case 'ZodEnum' :
82+ return 'enum' ;
83+ default :
84+ throw new Error ( `Unsupported zod type for tool parameter: ${ zodType } ` ) ;
85+ }
86+ }
87+
7288function transformValue (
7389 zodType : ZodType ,
7490 value : unknown ,
@@ -117,7 +133,7 @@ export function sanitizeParams(
117133 `parameter ${ name } has type ${ zodType } but value ${ value } is not of equivalent type` ,
118134 ) ;
119135 }
120- const transformedName = transformName ( zodType , name ) ;
136+ const transformedName = transformArgName ( zodType , name ) ;
121137 const transformedValue = transformValue ( zodType , value ) ;
122138 transformed [ transformedName ] = transformedValue ;
123139 }
0 commit comments