@@ -2,7 +2,11 @@ import type {
22 SpotifyCheckSavedTracksParams ,
33 SpotifyCheckSavedTracksResponse ,
44} from '@/tools/spotify/types'
5- import { splitSpotifyLibraryIds , spotifyLibraryUrl } from '@/tools/spotify/utils'
5+ import {
6+ sendRemainingSpotifyLibraryChunks ,
7+ splitSpotifyLibraryIds ,
8+ spotifyLibraryUrl ,
9+ } from '@/tools/spotify/utils'
610import type { ToolConfig } from '@/tools/types'
711
812export const spotifyCheckSavedTracksTool : ToolConfig <
@@ -25,21 +29,29 @@ export const spotifyCheckSavedTracksTool: ToolConfig<
2529 type : 'string' ,
2630 required : true ,
2731 visibility : 'user-or-llm' ,
28- description : 'Comma-separated track IDs to check (max 40 )' ,
32+ description : 'Comma-separated track IDs to check (max 50 )' ,
2933 } ,
3034 } ,
3135
3236 request : {
33- url : ( params ) => spotifyLibraryUrl ( params . trackIds , 'track' , { contains : true } ) ,
37+ url : ( params ) => spotifyLibraryUrl ( params . trackIds , 'track' , { contains : true , maxIds : 50 } ) ,
3438 method : 'GET' ,
3539 headers : ( params ) => ( {
3640 Authorization : `Bearer ${ params . accessToken } ` ,
3741 } ) ,
3842 } ,
3943
4044 transformResponse : async ( response , params ) : Promise < SpotifyCheckSavedTracksResponse > => {
41- const data = await response . json ( )
42- const ids = splitSpotifyLibraryIds ( params ?. trackIds || '' )
45+ const data : boolean [ ] = [
46+ ...( await response . json ( ) ) ,
47+ ...( params
48+ ? await sendRemainingSpotifyLibraryChunks ( params , params . trackIds , 'track' , 'GET' , {
49+ contains : true ,
50+ maxIds : 50 ,
51+ } )
52+ : [ ] ) ,
53+ ]
54+ const ids = splitSpotifyLibraryIds ( params ?. trackIds || '' , 50 )
4355
4456 const results = ids . map ( ( id , index ) => ( {
4557 id,
0 commit comments