@@ -3,6 +3,7 @@ import { describeEval } from 'vitest-evals'
3
3
4
4
import { checkFactuality } from '@repo/eval-tools/src/scorers'
5
5
import { eachModel } from '@repo/eval-tools/src/test-models'
6
+ import { KV_NAMESPACE_TOOLS } from '@repo/mcp-common/src/tools/kv_namespace'
6
7
7
8
import { initializeClient , runTask } from './utils' // Assuming utils.ts will exist here
8
9
@@ -11,14 +12,16 @@ eachModel('$modelName', ({ model }) => {
11
12
data : async ( ) => [
12
13
{
13
14
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.` ,
15
16
} ,
16
17
] ,
17
18
task : async ( input : string ) => {
18
19
const client = await initializeClient ( /* Pass necessary mocks/config */ )
19
20
const { promptOutput, toolCalls } = await runTask ( client , model , input )
20
21
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
+ )
22
25
expect ( toolCall , 'Tool kv_namespace_create was not called' ) . toBeDefined ( )
23
26
24
27
return promptOutput
@@ -31,15 +34,16 @@ eachModel('$modelName', ({ model }) => {
31
34
data : async ( ) => [
32
35
{
33
36
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.` ,
36
38
} ,
37
39
] ,
38
40
task : async ( input : string ) => {
39
41
const client = await initializeClient ( /* Pass necessary mocks/config */ )
40
42
const { promptOutput, toolCalls } = await runTask ( client , model , input )
41
43
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
+ )
43
47
expect ( toolCall , 'Tool kv_namespaces_list was not called' ) . toBeDefined ( )
44
48
45
49
return promptOutput
@@ -53,14 +57,16 @@ eachModel('$modelName', ({ model }) => {
53
57
{
54
58
input :
55
59
'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.` ,
57
61
} ,
58
62
] ,
59
63
task : async ( input : string ) => {
60
64
const client = await initializeClient ( /* Pass necessary mocks/config */ )
61
65
const { promptOutput, toolCalls } = await runTask ( client , model , input )
62
66
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
+ )
64
70
expect ( toolCall , 'Tool kv_namespace_update was not called' ) . toBeDefined ( )
65
71
66
72
return promptOutput
@@ -73,16 +79,16 @@ eachModel('$modelName', ({ model }) => {
73
79
data : async ( ) => [
74
80
{
75
81
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.` ,
78
83
} ,
79
84
] ,
80
85
task : async ( input : string ) => {
81
86
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 )
83
88
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
+ )
86
92
expect ( toolCall , 'Tool kv_namespace_get was not called' ) . toBeDefined ( )
87
93
88
94
return promptOutput
@@ -95,14 +101,16 @@ eachModel('$modelName', ({ model }) => {
95
101
data : async ( ) => [
96
102
{
97
103
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.` ,
99
105
} ,
100
106
] ,
101
107
task : async ( input : string ) => {
102
108
const client = await initializeClient ( /* Pass necessary mocks/config */ )
103
109
const { promptOutput, toolCalls } = await runTask ( client , model , input )
104
110
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
+ )
106
114
expect ( toolCall , 'Tool kv_namespace_delete was not called' ) . toBeDefined ( )
107
115
108
116
return promptOutput
0 commit comments