@@ -3348,9 +3348,19 @@ async function testTool(toolId) {
3348
3348
input . className =
3349
3349
"mt-1 block w-full rounded-md border border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:bg-gray-900 text-gray-700 dark:text-gray-300 dark:border-gray-700 dark:focus:border-indigo-400 dark:focus:ring-indigo-400" ;
3350
3350
3351
- if ( prop . items ?. type === "number" ) {
3351
+ const itemTypes = Array . isArray ( prop . items ?. anyOf )
3352
+ ? prop . items . anyOf . map ( ( t ) => t . type )
3353
+ : [ prop . items ?. type ] ;
3354
+
3355
+ if (
3356
+ itemTypes . includes ( "number" ) ||
3357
+ itemTypes . includes ( "integer" )
3358
+ ) {
3352
3359
input . type = "number" ;
3353
- } else if ( prop . items ?. type === "boolean" ) {
3360
+ input . step = itemTypes . includes ( "integer" )
3361
+ ? "1"
3362
+ : "any" ;
3363
+ } else if ( itemTypes . includes ( "boolean" ) ) {
3354
3364
input . type = "checkbox" ;
3355
3365
input . value = "true" ;
3356
3366
input . checked = value === true || value === "true" ;
@@ -3390,9 +3400,16 @@ async function testTool(toolId) {
3390
3400
} ) ;
3391
3401
3392
3402
if ( Array . isArray ( prop . default ) ) {
3393
- prop . default . forEach ( ( val ) => {
3394
- arrayContainer . appendChild ( createArrayInput ( val ) ) ;
3395
- } ) ;
3403
+ if ( prop . default . length > 0 ) {
3404
+ prop . default . forEach ( ( val ) => {
3405
+ arrayContainer . appendChild (
3406
+ createArrayInput ( val ) ,
3407
+ ) ;
3408
+ } ) ;
3409
+ } else {
3410
+ // Create one empty input for empty default arrays
3411
+ arrayContainer . appendChild ( createArrayInput ( ) ) ;
3412
+ }
3396
3413
} else {
3397
3414
arrayContainer . appendChild ( createArrayInput ( ) ) ;
3398
3415
}
@@ -3537,10 +3554,13 @@ async function runToolTest() {
3537
3554
// Convert values based on the items schema type
3538
3555
if ( prop . items ) {
3539
3556
const itemType = Array . isArray ( prop . items . anyOf )
3540
- ? prop . items . anyOf . map ( t => t . type )
3557
+ ? prop . items . anyOf . map ( ( t ) => t . type )
3541
3558
: [ prop . items . type ] ;
3542
3559
3543
- if ( itemType . includes ( "number" ) || itemType . includes ( "integer" ) ) {
3560
+ if (
3561
+ itemType . includes ( "number" ) ||
3562
+ itemType . includes ( "integer" )
3563
+ ) {
3544
3564
value = inputValues . map ( ( v ) => {
3545
3565
const num = Number ( v ) ;
3546
3566
if ( isNaN ( num ) ) {
@@ -3549,17 +3569,26 @@ async function runToolTest() {
3549
3569
return num ;
3550
3570
} ) ;
3551
3571
} else if ( itemType . includes ( "boolean" ) ) {
3552
- value = inputValues . map ( v => v === "true" || v === true ) ;
3572
+ value = inputValues . map (
3573
+ ( v ) => v === "true" || v === true ,
3574
+ ) ;
3553
3575
} else if ( itemType . includes ( "object" ) ) {
3554
3576
value = inputValues . map ( ( v ) => {
3555
3577
try {
3556
3578
const parsed = JSON . parse ( v ) ;
3557
- if ( typeof parsed !== "object" || Array . isArray ( parsed ) ) {
3558
- throw new Error ( `Value must be an object` ) ;
3579
+ if (
3580
+ typeof parsed !== "object" ||
3581
+ Array . isArray ( parsed )
3582
+ ) {
3583
+ throw new Error (
3584
+ "Value must be an object" ,
3585
+ ) ;
3559
3586
}
3560
3587
return parsed ;
3561
3588
} catch {
3562
- throw new Error ( `Invalid object format for ${ key } ` ) ;
3589
+ throw new Error (
3590
+ `Invalid object format for ${ key } ` ,
3591
+ ) ;
3563
3592
}
3564
3593
} ) ;
3565
3594
} else {
0 commit comments