@@ -2,10 +2,10 @@ import { describe, it, expect } from "vitest";
22import { buildToolList } from "../../composeTools.js" ;
33
44// Helper to recursively check if a schema contains any $ref entries (except within oneOf/anyOf/allOf arrays)
5- function hasUnresolvedRefs ( obj : any , path = "" ) : { found : boolean ; paths : string [ ] } {
5+ function hasUnresolvedRefs ( obj : unknown , path = "" ) : { found : boolean ; paths : string [ ] } {
66 const paths : string [ ] = [ ] ;
77
8- function traverse ( val : any , p : string ) {
8+ function traverse ( val : unknown , p : string ) {
99 if ( ! val || typeof val !== "object" ) return ;
1010
1111 if ( Array . isArray ( val ) ) {
@@ -39,32 +39,21 @@ describe("unit: tool list resolver", () => {
3939 // specific checks for presentations tools
4040 const createTemplate = tools . find ( ( t ) => t . name === "create_proof_template" ) ;
4141 expect ( createTemplate ) . toBeDefined ( ) ;
42- const s1 = createTemplate ! . inputSchema as any ;
43- const isZod = ( x : any ) => x && typeof x . safeParse === 'function' ;
44- if ( isZod ( s1 ) ) {
45- expect ( isZod ( s1 ) ) . toBe ( true ) ;
46- } else {
47- expect ( s1 . $ref ) . toBeUndefined ( ) ;
48- expect ( s1 . type ) . toBe ( "object" ) ;
49- }
42+ const s1 = createTemplate ! . inputSchema as Record < string , unknown > ;
43+ expect ( s1 . $ref ) . toBeUndefined ( ) ;
44+ expect ( s1 . type ) . toBe ( "object" ) ;
5045
5146 const createRequest = tools . find ( ( t ) => t . name === "create_proof_request" ) ;
5247 expect ( createRequest ) . toBeDefined ( ) ;
53- const s2 = createRequest ! . inputSchema as any ;
54- if ( isZod ( s2 ) ) {
55- expect ( isZod ( s2 ) ) . toBe ( true ) ;
56- } else {
57- expect ( s2 . $ref ) . toBeUndefined ( ) ;
58- expect ( s2 . properties ) . toBeDefined ( ) ;
59- }
48+ const s2 = createRequest ! . inputSchema as Record < string , unknown > ;
49+ expect ( s2 . $ref ) . toBeUndefined ( ) ;
50+ expect ( s2 . properties ) . toBeDefined ( ) ;
6051
6152 // generic assertion: no tool should expose a top-level $ref-only inputSchema
6253 for ( const t of tools ) {
63- const s = t . inputSchema as any ;
64- const isZod = ( x : any ) => x && typeof x . safeParse === 'function' ;
54+ const s = t . inputSchema ;
6555 if ( s && typeof s === 'object' ) {
66- if ( isZod ( s ) ) continue ;
67- expect ( s . $ref ) . toBeUndefined ( ) ;
56+ expect ( ( s as Record < string , unknown > ) . $ref ) . toBeUndefined ( ) ;
6857 }
6958 }
7059 } ) ;
@@ -77,42 +66,37 @@ describe("unit: tool list resolver", () => {
7766 const createIssuer = tools . find ( ( t ) => t . name === "create_issuer" ) ;
7867 expect ( createIssuer ) . toBeDefined ( ) ;
7968
80- const schema = createIssuer ! . inputSchema as any ;
81- const isZod = ( x : any ) => x && typeof x . safeParse === 'function' ;
82- if ( isZod ( schema ) ) {
83- expect ( isZod ( schema ) ) . toBe ( true ) ;
84- return ;
85- }
69+ const schema = createIssuer ! . inputSchema as Record < string , unknown > ;
8670
8771 // Should have resolved credentialOptions from a $ref to an actual object
8872 expect ( schema . properties ) . toBeDefined ( ) ;
89- expect ( schema . properties . credentialOptions ) . toBeDefined ( ) ;
90- expect ( ( schema . properties . credentialOptions as any ) . $ref ) . toBeUndefined ( ) ;
73+ expect ( ( schema . properties as Record < string , unknown > ) . credentialOptions ) . toBeDefined ( ) ;
74+ expect ( ( ( schema . properties as Record < string , unknown > ) . credentialOptions as Record < string , unknown > ) . $ref ) . toBeUndefined ( ) ;
9175
9276 // credentialOptions should have credential property (from CredentialIssueRequest)
93- const credentialOptions = schema . properties . credentialOptions as any ;
77+ const credentialOptions = ( schema . properties as Record < string , unknown > ) . credentialOptions as Record < string , unknown > ;
9478 expect ( credentialOptions . properties ) . toBeDefined ( ) ;
95- expect ( credentialOptions . properties . credential ) . toBeDefined ( ) ;
79+ expect ( ( credentialOptions . properties as Record < string , unknown > ) . credential ) . toBeDefined ( ) ;
9680
9781 // credential property should also be resolved (from Credential schema)
98- const credentialProp = credentialOptions . properties . credential as any ;
82+ const credentialProp = ( credentialOptions . properties as Record < string , unknown > ) . credential as Record < string , unknown > ;
9983 expect ( credentialProp . $ref ) . toBeUndefined ( ) ;
10084 expect ( credentialProp . type ) . toBe ( "object" ) ;
10185 expect ( credentialProp . properties ) . toBeDefined ( ) ;
10286
10387 // The credential should have subject property (not credentialSubject)
104- expect ( credentialProp . properties . subject ) . toBeDefined ( ) ;
105- expect ( credentialProp . properties . credentialSubject ) . toBeUndefined ( ) ;
88+ expect ( ( credentialProp . properties as Record < string , unknown > ) . subject ) . toBeDefined ( ) ;
89+ expect ( ( credentialProp . properties as Record < string , unknown > ) . credentialSubject ) . toBeUndefined ( ) ;
10690 } ) ;
10791
10892 it ( "ensures no tool has bare $ref-only top-level inputSchema" , ( ) => {
10993 const tools = buildToolList ( ) ;
11094
11195 for ( const tool of tools ) {
112- const schema = tool . inputSchema as any ;
96+ const schema = tool . inputSchema ;
11397 if ( schema && typeof schema === "object" ) {
11498 // Top-level should never be a bare $ref
115- expect ( schema . $ref ) . toBeUndefined ( ) ;
99+ expect ( ( schema as Record < string , unknown > ) . $ref ) . toBeUndefined ( ) ;
116100 }
117101 }
118102 } ) ;
@@ -121,10 +105,8 @@ describe("unit: tool list resolver", () => {
121105 const tools = buildToolList ( ) ;
122106
123107 for ( const tool of tools ) {
124- const schema = tool . inputSchema as any ;
108+ const schema = tool . inputSchema ;
125109 if ( ! schema ) continue ;
126- const isZod = ( x : any ) => x && typeof x . safeParse === 'function' ;
127- if ( isZod ( schema ) ) continue ; // Zod schemas don't use $ref
128110
129111 if ( schema && typeof schema === "object" ) {
130112 const { found, paths } = hasUnresolvedRefs ( schema , tool . name ) ;
0 commit comments