@@ -3,6 +3,7 @@ import { describeEval } from 'vitest-evals'
33
44import { checkFactuality } from '@repo/eval-tools/src/scorers'
55import { eachModel } from '@repo/eval-tools/src/test-models'
6+ import { KV_NAMESPACE_TOOLS } from '@repo/mcp-common/src/tools/kv_namespace'
67
78import { initializeClient , runTask } from './utils' // Assuming utils.ts will exist here
89
@@ -11,14 +12,16 @@ eachModel('$modelName', ({ model }) => {
1112 data : async ( ) => [
1213 {
1314 input : 'Create a new Cloudflare KV Namespace called "my-test-namespace".' ,
14- expected : ' The kv_namespaces_create tool should be called to create a new kv namespace.' ,
15+ expected : ` The ${ KV_NAMESPACE_TOOLS . kv_namespace_create } tool should be called to create a new kv namespace.` ,
1516 } ,
1617 ] ,
1718 task : async ( input : string ) => {
1819 const client = await initializeClient ( /* Pass necessary mocks/config */ )
1920 const { promptOutput, toolCalls } = await runTask ( client , model , input )
2021
21- const toolCall = toolCalls . find ( ( call ) => call . toolName === 'kv_namespace_create' )
22+ const toolCall = toolCalls . find (
23+ ( call ) => call . toolName === KV_NAMESPACE_TOOLS . kv_namespace_create
24+ )
2225 expect ( toolCall , 'Tool kv_namespace_create was not called' ) . toBeDefined ( )
2326
2427 return promptOutput
@@ -31,15 +34,16 @@ eachModel('$modelName', ({ model }) => {
3134 data : async ( ) => [
3235 {
3336 input : 'List all my Cloudflare KV Namespaces.' ,
34- expected :
35- 'The kv_namespaces_list tool should be called to retrieve the list of kv namespaces. There should be at least one kv namespace in the list.' ,
37+ expected : `The ${ KV_NAMESPACE_TOOLS . kv_namespaces_list } tool should be called to retrieve the list of kv namespaces. There should be at least one kv namespace in the list.` ,
3638 } ,
3739 ] ,
3840 task : async ( input : string ) => {
3941 const client = await initializeClient ( /* Pass necessary mocks/config */ )
4042 const { promptOutput, toolCalls } = await runTask ( client , model , input )
4143
42- const toolCall = toolCalls . find ( ( call ) => call . toolName === 'kv_namespaces_list' )
44+ const toolCall = toolCalls . find (
45+ ( call ) => call . toolName === KV_NAMESPACE_TOOLS . kv_namespaces_list
46+ )
4347 expect ( toolCall , 'Tool kv_namespaces_list was not called' ) . toBeDefined ( )
4448
4549 return promptOutput
@@ -53,14 +57,16 @@ eachModel('$modelName', ({ model }) => {
5357 {
5458 input :
5559 'Rename my Cloudflare KV Namespace called "my-test-namespace" to "my-new-test-namespace".' ,
56- expected : ' The kv_namespace_update tool should be called to rename the kv namespace.' ,
60+ expected : ` The ${ KV_NAMESPACE_TOOLS . kv_namespace_update } tool should be called to rename the kv namespace.` ,
5761 } ,
5862 ] ,
5963 task : async ( input : string ) => {
6064 const client = await initializeClient ( /* Pass necessary mocks/config */ )
6165 const { promptOutput, toolCalls } = await runTask ( client , model , input )
6266
63- const toolCall = toolCalls . find ( ( call ) => call . toolName === 'kv_namespace_update' )
67+ const toolCall = toolCalls . find (
68+ ( call ) => call . toolName === KV_NAMESPACE_TOOLS . kv_namespace_update
69+ )
6470 expect ( toolCall , 'Tool kv_namespace_update was not called' ) . toBeDefined ( )
6571
6672 return promptOutput
@@ -73,16 +79,16 @@ eachModel('$modelName', ({ model }) => {
7379 data : async ( ) => [
7480 {
7581 input : 'Get details of my Cloudflare KV Namespace called "my-new-test-namespace".' ,
76- expected :
77- 'The kv_namespace_get tool should be called to retrieve the details of the kv namespace.' ,
82+ expected : `The ${ KV_NAMESPACE_TOOLS . kv_namespace_get } tool should be called to retrieve the details of the kv namespace.` ,
7883 } ,
7984 ] ,
8085 task : async ( input : string ) => {
8186 const client = await initializeClient ( /* Pass necessary mocks/config */ )
82- const { promptOutput, toolCalls, fullResult } = await runTask ( client , model , input )
87+ const { promptOutput, toolCalls } = await runTask ( client , model , input )
8388
84- console . log ( 'fullResult' , JSON . stringify ( await fullResult . response , null , 2 ) )
85- const toolCall = toolCalls . find ( ( call ) => call . toolName === 'kv_namespace_get' )
89+ const toolCall = toolCalls . find (
90+ ( call ) => call . toolName === KV_NAMESPACE_TOOLS . kv_namespace_get
91+ )
8692 expect ( toolCall , 'Tool kv_namespace_get was not called' ) . toBeDefined ( )
8793
8894 return promptOutput
@@ -95,14 +101,16 @@ eachModel('$modelName', ({ model }) => {
95101 data : async ( ) => [
96102 {
97103 input : 'Look up the id of my only KV namespace and delete it.' ,
98- expected : ' The kv_namespace_delete tool should be called to delete the kv namespace.' ,
104+ expected : ` The ${ KV_NAMESPACE_TOOLS . kv_namespace_delete } tool should be called to delete the kv namespace.` ,
99105 } ,
100106 ] ,
101107 task : async ( input : string ) => {
102108 const client = await initializeClient ( /* Pass necessary mocks/config */ )
103109 const { promptOutput, toolCalls } = await runTask ( client , model , input )
104110
105- const toolCall = toolCalls . find ( ( call ) => call . toolName === 'kv_namespace_delete' )
111+ const toolCall = toolCalls . find (
112+ ( call ) => call . toolName === KV_NAMESPACE_TOOLS . kv_namespace_delete
113+ )
106114 expect ( toolCall , 'Tool kv_namespace_delete was not called' ) . toBeDefined ( )
107115
108116 return promptOutput
0 commit comments