1616
1717import { generateObject , CoreMessage } from "ai" ;
1818
19- import { GetFunctionResponse , GetFunctionsRequest , GetFunctionsResponse , getFunctionsResponseSchema , MinifiedClient , MinifiedRemoteFunction , MinifiedResourceFunction } from "./funcs_inter_types" ;
19+ import { GetFunctionResponse , GetFunctionsRequest , GetFunctionsResponse , getFunctionsResponseSchema , MinifiedClient , MinifiedRemoteFunction , MinifiedResourceFunction , PathParameter } from "./funcs_inter_types" ;
2020import { Client , GetTypeResponse , Library , RemoteFunction , ResourceFunction } from "./libs_types" ;
2121import { TypeDefinition , AbstractFunction , Type , RecordTypeDefinition } from "./libs_types" ;
2222import { getAnthropicClient , ANTHROPIC_HAIKU } from "../connection" ;
@@ -417,6 +417,13 @@ function getConstructor(functions: (RemoteFunction | ResourceFunction)[]): Remot
417417 return null ;
418418}
419419
420+ function normalizePaths ( paths : ( PathParameter | string ) [ ] ) : string [ ] {
421+ return paths . map ( ( path ) => {
422+ const pathStr = typeof path === "string" ? path : path . name ;
423+ return pathStr . replace ( / \\ ./ g, "." ) ;
424+ } ) ;
425+ }
426+
420427function getCompleteFuncForMiniFunc (
421428 minFunc : MinifiedRemoteFunction | MinifiedResourceFunction ,
422429 fullFunctions : ( RemoteFunction | ResourceFunction ) [ ]
@@ -426,11 +433,14 @@ function getCompleteFuncForMiniFunc(
426433 return fullFunctions . find ( f => 'name' in f && f . name === minFunc . name ) || null ;
427434 } else {
428435 // MinifiedResourceFunction
429- return fullFunctions . find ( f =>
430- 'accessor' in f &&
431- f . accessor === minFunc . accessor &&
432- JSON . stringify ( f . paths ) === JSON . stringify ( minFunc . paths )
433- ) || null ;
436+ return (
437+ fullFunctions . find (
438+ ( f ) =>
439+ 'accessor' in f &&
440+ f . accessor === minFunc . accessor &&
441+ JSON . stringify ( normalizePaths ( f . paths ) ) === JSON . stringify ( normalizePaths ( minFunc . paths ) )
442+ ) || null
443+ ) ;
434444 }
435445}
436446
0 commit comments